This commit is contained in:
Rizky 2023-11-21 16:16:30 +07:00
parent 877a816eaa
commit 1938782368
6 changed files with 17 additions and 20 deletions

View File

@ -3,6 +3,7 @@ import { EComp, EPage, ESite } from "../../../web/src/nova/ed/logic/ed-global";
import { IItem } from "../../../web/src/utils/types/item";
import { site_group } from "./actions/site_group";
import { activity } from "./entity/activity";
import { parseJs } from "./editor/parser/parse-js";
/*
WARNING:
@ -89,10 +90,7 @@ export const SyncActions = {
({}) as Record<string, { id: string; username: string }>,
},
swc: {
parse: async (
arg:
| { type: "page", page_id: string; item_id?: string }
| { type: "comp", comp_id: string; item_id?: string }
) => ({}) as Record<string, string>,
parse: async (code: string | Record<string, string>) =>
({}) as Record<string, ReturnType<typeof parseJs>>,
},
};

View File

@ -1,24 +1,21 @@
import { IContent } from "../../../../web/src/utils/types/general";
import { SAction } from "../actions";
import { parseJs } from "../editor/parser/parse-js";
import { docs } from "../entity/docs";
import { SyncConnection } from "../type";
export const swc_parse: SAction["swc"]["parse"] = async function (
this: SyncConnection,
arg
code
) {
if (arg.type === "page") {
let ydoc = docs.page[arg.page_id];
if (ydoc) {
const item = ydoc.doc.getMap("map").get("root")?.toJSON() as IContent;
const res = parseItem(item);
console.log(res);
if (typeof code === "object") {
const result: Record<string, ReturnType<typeof parseJs>> = {};
for (const [k, v] of Object.entries(code)) {
result[k] = parseJs(v);
}
return result;
}
let result = null as unknown as Awaited<ReturnType<SAction["swc"]["parse"]>>;
return result;
return { _: parseJs(code) };
};
type ParseParent = Record<string, {}>;

View File

@ -62,8 +62,11 @@ export const parseJs = (code: string) => {
},
});
const result: any = {};
if (local.name) {
const result = {} as {
local: typeof local | undefined;
passprop: typeof passprop | undefined;
};
if (!local.name) {
result.local = local;
}
if (Object.keys(passprop).length > 0) {

View File

@ -14,6 +14,7 @@
"@paralleldrive/cuid2": "2.2.2",
"@parcel/packager-wasm": "^2.10.1",
"@parcel/service-worker": "^2.10.1",
"recast": "^0.23.4",
"@qiwi/deep-proxy": "^2.0.3",
"algoliasearch": "^4.20.0",
"date-fns": "^2.30.0",

View File

@ -62,12 +62,10 @@ export const treeRebuild = async (p: PG, arg?: { note?: string }) => {
}
}
});
await p.sync.swc.parse({ type: "page", page_id: p.page.cur.id });
p.page.building = false;
p.render();
p.page.render();
}
};

BIN
bun.lockb

Binary file not shown.