From 988025bfac4c64b6d1c7b4ff0e0b4bde709a16cb Mon Sep 17 00:00:00 2001 From: Szymon Nowakowski Date: Thu, 18 Jun 2026 20:29:18 +0200 Subject: [PATCH] Erasable syntax only, update pnpm --- Dockerfile | 2 +- package.json | 2 +- packages/common/src/the_api.ts | 12 +-- packages/frontend/src/FileReducer.ts | 112 ------------------------ packages/frontend/src/hooks/useStore.ts | 10 ++- packages/frontend/src/routes/Piece.tsx | 18 ++-- pnpm-workspace.yaml | 10 +-- tsconfig.base.json | 1 + 8 files changed, 32 insertions(+), 135 deletions(-) delete mode 100644 packages/frontend/src/FileReducer.ts diff --git a/Dockerfile b/Dockerfile index 7821f92..3c9c2da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN pnpm exec tsc --build #RUN pnpm exec eslint . RUN pnpm --filter frontend exec vite build -FROM oven/bun:1 +FROM oven/bun:1.3.14 WORKDIR /usr/src/app COPY --from=build /app . diff --git a/package.json b/package.json index b0f06b5..4d7ac05 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "backend:dev": "bun run --watch packages/backend/src/app.ts", "docker:build": "docker build -t music-repo .", - "docker:run": "docker run --init --publish 3000:3000 --rm music-repo", + "docker:run": "docker run --env-file .env --init --publish 3000:3000 --rm music-repo", "frontend:build": "pnpm --filter frontend exec vite build", "frontend:dev": "pnpm --filter frontend exec vite --open" }, diff --git a/packages/common/src/the_api.ts b/packages/common/src/the_api.ts index 7e64adb..12c4f01 100644 --- a/packages/common/src/the_api.ts +++ b/packages/common/src/the_api.ts @@ -5,11 +5,13 @@ import * as Api from "./Api"; // --- MARK: COMMON TYPES ------------------------------------------------------ -export enum Role { - Viewer = "Viewer", - Editor = "Editor", - Admin = "Admin", -} +export const Role = Object.freeze({ + Viewer: "Viewer", + Editor: "Editor", + Admin: "Admin", +}); + +export type Role = (typeof Role)[keyof (typeof Role)]; export const SystemInformation = Schema.Struct({ createdBy: pipe(UserId, Schema.optionalWith({ as: "Option", exact: true })), diff --git a/packages/frontend/src/FileReducer.ts b/packages/frontend/src/FileReducer.ts deleted file mode 100644 index ee4811d..0000000 --- a/packages/frontend/src/FileReducer.ts +++ /dev/null @@ -1,112 +0,0 @@ -import { mapProp } from "@/hooks/useStore"; -import { Update } from "common"; -import { getMediaTypeForFile } from "common/MediaType"; - -export function FileReducer(prev: FileReducer.State, action: FileReducer.Action): FileReducer.State { - switch (action.type) { - case "reset": - return FileReducer.initial; - case "file": - if (prev.file !== null) { - if (action.file !== null) { - if (prev.file.name === prev.filename && getMediaTypeForFile(prev.file) === prev.mediaType) { - return Object.freeze({ - filename: action.file.name, - mediaType: getMediaTypeForFile(action.file), - file: action.file, - }); - } else { - return mapProp("file", action.file as File | null)(prev); - } - } else { - if (prev.file.name === prev.filename && prev.file.type === prev.mediaType) { - return FileReducer.initial; - } else { - return mapProp("file", action.file as File | null)(prev); - } - } - } else { - if (action.file !== null) { - if (prev.filename === "" && prev.mediaType === "") { - return Object.freeze({ - filename: action.file.name, - mediaType: getMediaTypeForFile(action.file), - file: action.file, - }); - } else { - return mapProp("file", action.file as File | null)(prev); - } - } else { - return prev; - } - } - case "filename": - return mapProp("filename", action.filename)(prev); - case "mediaType": - return mapProp("mediaType", action.mediaType)(prev); - } -} - -export namespace FileReducer { - - export interface ResetAction { - readonly type: "reset"; - } - - export const reset: ResetAction = Object.freeze({ - type: "reset", - }); - - export interface SetFileAction { - readonly type: "file"; - readonly file: File | null; - } - - export function setFile(file: File | null): SetFileAction { - return Object.freeze({ - type: "file", - file, - }); - } - - export interface SetFilenameAction { - readonly type: "filename"; - readonly filename: Update; - } - - export function setFilename(filename: Update): SetFilenameAction { - return Object.freeze({ - type: "filename", - filename, - }); - } - - export interface SetMediaTypeAction { - readonly type: "mediaType"; - readonly mediaType: Update; - } - - export function setMediaType(mediaType: Update): SetMediaTypeAction { - return Object.freeze({ - type: "mediaType", - mediaType, - }); - } - - export type Action = ResetAction | - SetFileAction | - SetFilenameAction | - SetMediaTypeAction; - - export interface State { - readonly filename: string; - readonly mediaType: string; - readonly file: File | null; - } - - export const initial: State = Object.freeze({ - filename: "", - mediaType: "", - file: null, - }); -} diff --git a/packages/frontend/src/hooks/useStore.ts b/packages/frontend/src/hooks/useStore.ts index 23ffa1a..45a4067 100644 --- a/packages/frontend/src/hooks/useStore.ts +++ b/packages/frontend/src/hooks/useStore.ts @@ -37,11 +37,17 @@ class Listener { private lastState: T; + private readonly selector: Selector; + private readonly setState: (state: T) => void; + constructor( - readonly selector: Selector, - readonly setState: (state: T) => void, + selector: Selector, + setState: (state: T) => void, ) { this.lastState = selector(store); + + this.selector = selector; + this.setState = setState; } react() { diff --git a/packages/frontend/src/routes/Piece.tsx b/packages/frontend/src/routes/Piece.tsx index 3ddc05d..0638a51 100644 --- a/packages/frontend/src/routes/Piece.tsx +++ b/packages/frontend/src/routes/Piece.tsx @@ -210,18 +210,20 @@ namespace AttachmentRow { } } -enum LocalCopyState { - Uninitialized = "uninitialized", - Online = "online", - Offline = "offline", - Loading = "loading", - Error = "error", -} +const LocalCopyState = Object.freeze({ + Uninitialized: "uninitialized", + Online: "online", + Offline: "offline", + Loading: "loading", + Error: "error", +}); + +type LocalCopyState = (typeof LocalCopyState)[keyof (typeof LocalCopyState)]; function AttachmentRow(props: AttachmentRow.Props) { const [cloneDialogOpen, setCloneDialogOpen] = useState(false); - const [localCopyState, setLocalCopyState] = useState(LocalCopyState.Uninitialized); + const [localCopyState, setLocalCopyState] = useState(LocalCopyState.Uninitialized); useLayoutEffect(() => { if (localCopyState !== LocalCopyState.Uninitialized) return; diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 6910d6c..affe4ce 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -2,12 +2,10 @@ packages: - '.' - 'packages/*' -ignoredBuiltDependencies: - - 'gl' - -onlyBuiltDependencies: - - '@tailwindcss/oxide' - - 'esbuild' +allowBuilds: + '@tailwindcss/oxide': true + 'esbuild': true + 'gl': false catalog: '@effect/language-service': '^0.21.8' diff --git a/tsconfig.base.json b/tsconfig.base.json index 5f7e5f9..379f927 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -22,6 +22,7 @@ "forceConsistentCasingInFileNames": true, "isolatedModules": true, "allowImportingTsExtensions": true, + "erasableSyntaxOnly": true, "skipLibCheck": true,