This commit is contained in:
Rizky 2023-10-31 16:43:56 +07:00
parent 1022a8b50a
commit 7d405e5145
11 changed files with 63 additions and 78 deletions

View File

@ -1,54 +1,52 @@
export const SyncActionDefinition = { export const SyncActionDefinition = {
"code": { "code": {
"create": "0", "open": "0",
"list": "1", "close": "1"
"load": "2"
}, },
"site": { "site": {
"list": "3", "list": "2",
"group": "4", "group": "3",
"load": "5", "load": "4",
"update": "6" "update": "5"
}, },
"comp": { "comp": {
"new": "7", "new": "6",
"list": "8", "list": "7",
"group": "9", "group": "8",
"load": "10" "load": "9"
}, },
"page": { "page": {
"list": "11", "list": "10",
"load": "12" "load": "11"
}, },
"yjs": { "yjs": {
"um": "13", "um": "12",
"sv_local": "14", "sv_local": "13",
"diff_local": "15", "diff_local": "14",
"sv_remote": "16" "sv_remote": "15"
}, },
"activity": "17", "activity": "16",
"client": { "client": {
"info": "18" "info": "17"
} }
}; };
export const SyncActionPaths = { export const SyncActionPaths = {
"0": "code.create", "0": "code.open",
"1": "code.list", "1": "code.close",
"2": "code.load", "2": "site.list",
"3": "site.list", "3": "site.group",
"4": "site.group", "4": "site.load",
"5": "site.load", "5": "site.update",
"6": "site.update", "6": "comp.new",
"7": "comp.new", "7": "comp.list",
"8": "comp.list", "8": "comp.group",
"9": "comp.group", "9": "comp.load",
"10": "comp.load", "10": "page.list",
"11": "page.list", "11": "page.load",
"12": "page.load", "12": "yjs.um",
"13": "yjs.um", "13": "yjs.sv_local",
"14": "yjs.sv_local", "14": "yjs.diff_local",
"15": "yjs.diff_local", "15": "yjs.sv_remote",
"16": "yjs.sv_remote", "16": "activity",
"17": "activity", "17": "client.info"
"18": "client.info"
}; };

View File

@ -14,14 +14,12 @@ import { Activity, ActivityKind } from "./type";
WILL *BREAK* OFFLINE STORAGE -- WILL *BREAK* OFFLINE STORAGE --
ONLY ADDITION IS ALLOWED ONLY ADDITION IS ALLOWED
*/ */
export type SAction = typeof SyncActions; export type SAction = typeof SyncActions;
export const SyncActions = { export const SyncActions = {
code: { code: {
create: async (id_site: string, name: string) => ({}) as { id: string }, open: async (id_site: string) => ({}) as { id: string },
list: async (id_site: string) => ({}) as { ids: string[] }, close: async (id_site: string) => ({}) as { id: string },
load: async (id: string) => ({}) as { bin: Uint8Array } | void,
}, },
site: { site: {
list: async () => list: async () =>

View File

@ -1,11 +1,11 @@
import { SAction } from "../actions"; import { SAction } from "../actions";
import { SyncConnection } from "../type"; import { SyncConnection } from "../type";
export const code_load: SAction["code"]["load"] = async function ( export const code_close: SAction["code"]["close"] = async function (
this: SyncConnection, this: SyncConnection,
) { ) {
let result = null as unknown as Awaited< let result = null as unknown as Awaited<
ReturnType<SAction["code"]["load"]> ReturnType<SAction["code"]["close"]>
>; >;
return result; return result;
} }

View File

@ -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<SAction["code"]["create"]>
>;
return result;
}

View File

@ -1,11 +1,11 @@
import { SAction } from "../actions"; import { SAction } from "../actions";
import { SyncConnection } from "../type"; import { SyncConnection } from "../type";
export const code_list: SAction["code"]["list"] = async function ( export const code_open: SAction["code"]["open"] = async function (
this: SyncConnection, this: SyncConnection,
) { ) {
let result = null as unknown as Awaited< let result = null as unknown as Awaited<
ReturnType<SAction["code"]["list"]> ReturnType<SAction["code"]["open"]>
>; >;
return result; return result;
} }

View File

@ -1,6 +1,5 @@
export * from "./code_create"; export * from "./code_open";
export * from "./code_list"; export * from "./code_close";
export * from "./code_load";
export * from "./site_list"; export * from "./site_list";
export * from "./site_group"; export * from "./site_group";
export * from "./site_load"; export * from "./site_load";

BIN
bun.lockb

Binary file not shown.

View File

@ -25,6 +25,7 @@
}, },
"dependencies": { "dependencies": {
"brotli-wasm": "^2.0.1", "brotli-wasm": "^2.0.1",
"fdir": "^6.1.0" "fdir": "^6.1.0",
"typescript": "^5.2.2"
} }
} }

View File

@ -26,10 +26,12 @@ if (g.mode === "dev") {
await startDevWatcher(); await startDevWatcher();
} }
/** init lmdb */ /** init lmdb */
user.conf.init(); user.conf.init();
snapshot.init(); snapshot.init();
await preparePrisma(); await preparePrisma();
await ensureNotRunning(); await ensureNotRunning();
@ -39,12 +41,17 @@ if (g.db) {
}); });
} }
await initSrv(); await initSrv();
await syncActionDefinition(); await syncActionDefinition();
await generateAPIFrm(); await generateAPIFrm();
await prepareApiRoutes(); await prepareApiRoutes();
await prepareAPITypes();
await parcelBuild();
await createServer();
g.status = "ready"; await prepareAPITypes();
await parcelBuild();
// await createServer();
// g.status = "ready";

View File

@ -35,6 +35,7 @@ export const ${name} = {
const targetFile = dir.path("app/srv/exports.d.ts"); const targetFile = dir.path("app/srv/exports.d.ts");
const args = [ const args = [
process.execPath,
dir.path("node_modules/.bin/tsc"), dir.path("node_modules/.bin/tsc"),
dir.path("app/srv/exports.ts"), dir.path("app/srv/exports.ts"),
"--declaration", "--declaration",
@ -43,19 +44,10 @@ export const ${name} = {
targetFile, targetFile,
]; ];
if (g.mode === "dev") { if (g.mode === "dev") {
const tsc = spawn( const tsc = spawn(args, {
[
dir.path("node_modules/.bin/tsc"),
dir.path("app/srv/exports.ts"),
"--declaration",
"--emitDeclarationOnly",
"--outFile",
targetFile,
],
{
cwd: dir.path(`node_modules/.bin`), cwd: dir.path(`node_modules/.bin`),
} });
);
await tsc.exited; await tsc.exited;
} }

View File

@ -6,6 +6,7 @@ import { g } from "./global";
const decoder = new TextDecoder(); const decoder = new TextDecoder();
export const parcelBuild = async () => { export const parcelBuild = async () => {
await dirAsync("app/static"); await dirAsync("app/static");
const args = [ const args = [
"node", "node",
dir.path("node_modules/.bin/parcel"), dir.path("node_modules/.bin/parcel"),