diff --git a/app/srv/ws/sync/actions-def.ts b/app/srv/ws/sync/actions-def.ts index 04051d41..96d405cb 100644 --- a/app/srv/ws/sync/actions-def.ts +++ b/app/srv/ws/sync/actions-def.ts @@ -1,54 +1,52 @@ export const SyncActionDefinition = { "code": { - "create": "0", - "list": "1", - "load": "2" + "open": "0", + "close": "1" }, "site": { - "list": "3", - "group": "4", - "load": "5", - "update": "6" + "list": "2", + "group": "3", + "load": "4", + "update": "5" }, "comp": { - "new": "7", - "list": "8", - "group": "9", - "load": "10" + "new": "6", + "list": "7", + "group": "8", + "load": "9" }, "page": { - "list": "11", - "load": "12" + "list": "10", + "load": "11" }, "yjs": { - "um": "13", - "sv_local": "14", - "diff_local": "15", - "sv_remote": "16" + "um": "12", + "sv_local": "13", + "diff_local": "14", + "sv_remote": "15" }, - "activity": "17", + "activity": "16", "client": { - "info": "18" + "info": "17" } }; export const SyncActionPaths = { - "0": "code.create", - "1": "code.list", - "2": "code.load", - "3": "site.list", - "4": "site.group", - "5": "site.load", - "6": "site.update", - "7": "comp.new", - "8": "comp.list", - "9": "comp.group", - "10": "comp.load", - "11": "page.list", - "12": "page.load", - "13": "yjs.um", - "14": "yjs.sv_local", - "15": "yjs.diff_local", - "16": "yjs.sv_remote", - "17": "activity", - "18": "client.info" + "0": "code.open", + "1": "code.close", + "2": "site.list", + "3": "site.group", + "4": "site.load", + "5": "site.update", + "6": "comp.new", + "7": "comp.list", + "8": "comp.group", + "9": "comp.load", + "10": "page.list", + "11": "page.load", + "12": "yjs.um", + "13": "yjs.sv_local", + "14": "yjs.diff_local", + "15": "yjs.sv_remote", + "16": "activity", + "17": "client.info" }; diff --git a/app/srv/ws/sync/actions.ts b/app/srv/ws/sync/actions.ts index 230431ce..c3168588 100644 --- a/app/srv/ws/sync/actions.ts +++ b/app/srv/ws/sync/actions.ts @@ -14,14 +14,12 @@ import { Activity, ActivityKind } from "./type"; WILL *BREAK* OFFLINE STORAGE -- ONLY ADDITION IS ALLOWED */ - export type SAction = typeof SyncActions; export const SyncActions = { code: { - create: async (id_site: string, name: string) => ({}) as { id: string }, - list: async (id_site: string) => ({}) as { ids: string[] }, - load: async (id: string) => ({}) as { bin: Uint8Array } | void, + open: async (id_site: string) => ({}) as { id: string }, + close: async (id_site: string) => ({}) as { id: string }, }, site: { list: async () => diff --git a/app/srv/ws/sync/actions/code_load.ts b/app/srv/ws/sync/actions/code_close.ts similarity index 61% rename from app/srv/ws/sync/actions/code_load.ts rename to app/srv/ws/sync/actions/code_close.ts index aa7df99c..26b7ff02 100644 --- a/app/srv/ws/sync/actions/code_load.ts +++ b/app/srv/ws/sync/actions/code_close.ts @@ -1,11 +1,11 @@ import { SAction } from "../actions"; import { SyncConnection } from "../type"; -export const code_load: SAction["code"]["load"] = async function ( +export const code_close: SAction["code"]["close"] = async function ( this: SyncConnection, ) { let result = null as unknown as Awaited< - ReturnType + ReturnType >; return result; } \ No newline at end of file diff --git a/app/srv/ws/sync/actions/code_create.ts b/app/srv/ws/sync/actions/code_create.ts deleted file mode 100644 index 6e163a12..00000000 --- a/app/srv/ws/sync/actions/code_create.ts +++ /dev/null @@ -1,11 +0,0 @@ - -import { SAction } from "../actions"; -import { SyncConnection } from "../type"; -export const code_create: SAction["code"]["create"] = async function ( - this: SyncConnection, -) { - let result = null as unknown as Awaited< - ReturnType - >; - return result; -} \ No newline at end of file diff --git a/app/srv/ws/sync/actions/code_list.ts b/app/srv/ws/sync/actions/code_open.ts similarity index 62% rename from app/srv/ws/sync/actions/code_list.ts rename to app/srv/ws/sync/actions/code_open.ts index 49eb1422..83b39101 100644 --- a/app/srv/ws/sync/actions/code_list.ts +++ b/app/srv/ws/sync/actions/code_open.ts @@ -1,11 +1,11 @@ import { SAction } from "../actions"; import { SyncConnection } from "../type"; -export const code_list: SAction["code"]["list"] = async function ( +export const code_open: SAction["code"]["open"] = async function ( this: SyncConnection, ) { let result = null as unknown as Awaited< - ReturnType + ReturnType >; return result; } \ No newline at end of file diff --git a/app/srv/ws/sync/actions/index.ts b/app/srv/ws/sync/actions/index.ts index 9d0130b6..b63cf3b0 100644 --- a/app/srv/ws/sync/actions/index.ts +++ b/app/srv/ws/sync/actions/index.ts @@ -1,6 +1,5 @@ -export * from "./code_create"; -export * from "./code_list"; -export * from "./code_load"; +export * from "./code_open"; +export * from "./code_close"; export * from "./site_list"; export * from "./site_group"; export * from "./site_load"; diff --git a/bun.lockb b/bun.lockb index 91ef701c..7904c342 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index c51020f3..cfe719ad 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ }, "dependencies": { "brotli-wasm": "^2.0.1", - "fdir": "^6.1.0" + "fdir": "^6.1.0", + "typescript": "^5.2.2" } } diff --git a/pkgs/core/index.ts b/pkgs/core/index.ts index cbf9e932..4490a64d 100644 --- a/pkgs/core/index.ts +++ b/pkgs/core/index.ts @@ -26,10 +26,12 @@ if (g.mode === "dev") { await startDevWatcher(); } + /** init lmdb */ user.conf.init(); snapshot.init(); + await preparePrisma(); await ensureNotRunning(); @@ -39,12 +41,17 @@ if (g.db) { }); } + await initSrv(); await syncActionDefinition(); + await generateAPIFrm(); await prepareApiRoutes(); -await prepareAPITypes(); -await parcelBuild(); -await createServer(); -g.status = "ready"; +await prepareAPITypes(); + +await parcelBuild(); + +// await createServer(); + +// g.status = "ready"; diff --git a/pkgs/core/server/prep-api-ts.ts b/pkgs/core/server/prep-api-ts.ts index f1ded836..27b05fa1 100644 --- a/pkgs/core/server/prep-api-ts.ts +++ b/pkgs/core/server/prep-api-ts.ts @@ -35,6 +35,7 @@ export const ${name} = { const targetFile = dir.path("app/srv/exports.d.ts"); const args = [ + process.execPath, dir.path("node_modules/.bin/tsc"), dir.path("app/srv/exports.ts"), "--declaration", @@ -43,19 +44,10 @@ export const ${name} = { targetFile, ]; if (g.mode === "dev") { - const tsc = spawn( - [ - dir.path("node_modules/.bin/tsc"), - dir.path("app/srv/exports.ts"), - "--declaration", - "--emitDeclarationOnly", - "--outFile", - targetFile, - ], - { - cwd: dir.path(`node_modules/.bin`), - } - ); + const tsc = spawn(args, { + cwd: dir.path(`node_modules/.bin`), + }); + await tsc.exited; } diff --git a/pkgs/core/utils/parcel.ts b/pkgs/core/utils/parcel.ts index 1ccf719e..9bad92a1 100644 --- a/pkgs/core/utils/parcel.ts +++ b/pkgs/core/utils/parcel.ts @@ -6,6 +6,7 @@ import { g } from "./global"; const decoder = new TextDecoder(); export const parcelBuild = async () => { await dirAsync("app/static"); + const args = [ "node", dir.path("node_modules/.bin/parcel"),