wip ed wasm gzip

This commit is contained in:
Rizky 2024-01-23 06:53:21 +07:00
parent df73b97c2b
commit 38814dd5f1
2 changed files with 25 additions and 25 deletions

View File

@ -3,26 +3,28 @@ import { EdBase } from "../../nova/ed/ed-base";
import { EDGlobal } from "../../nova/ed/logic/ed-global"; import { EDGlobal } from "../../nova/ed/logic/ed-global";
import { edInitSync } from "../../nova/ed/logic/ed-sync"; import { edInitSync } from "../../nova/ed/logic/ed-sync";
import { Loading } from "../../utils/ui/loading"; import { Loading } from "../../utils/ui/loading";
import init from "wasm-gzip";
export default page({ export default page({
url: "/ed/:site_id/:page_id", url: "/ed/:site_id/:page_id",
component: ({}) => { component: ({}) => {
const p = useGlobal(EDGlobal, "EDITOR"); const p = useGlobal(EDGlobal, "EDITOR");
const w = window as any; const w = window as any;
if (!w.Y) { if (!w.Y) {
(async () => { (async () => {
(window as any).Y = await import("yjs"); await init();
(window as any).syncronize = (await import("y-pojo")).syncronize; (window as any).Y = await import("yjs");
p.render(); (window as any).syncronize = (await import("y-pojo")).syncronize;
})(); p.render();
return <Loading note="init" />; })();
} return <Loading note="init" />;
}
if (!edInitSync(p)) { if (!edInitSync(p)) {
return <Loading note="connecting-ws" />; return <Loading note="connecting-ws" />;
} }
return <EdBase />; return <EdBase />;
}, },
}); });

View File

@ -1,20 +1,18 @@
import init from "wasm-gzip";
import { ApiProxy } from "../../../base/load/api/api-proxy"; import { ApiProxy } from "../../../base/load/api/api-proxy";
import { dbProxy } from "../../../base/load/db/db-proxy"; import { dbProxy } from "../../../base/load/db/db-proxy";
import { jscript } from "../../../utils/script/jscript"; import { jscript } from "../../../utils/script/jscript";
import { PG } from "./ed-global"; import { PG } from "./ed-global";
let w = window as unknown as { let w = window as unknown as {
db: ReturnType<typeof dbProxy>; db: ReturnType<typeof dbProxy>;
api: ApiProxy; api: ApiProxy;
}; };
export const edInit = async (p: PG) => { export const edInit = async (p: PG) => {
p.status = "ready"; p.status = "ready";
await init(); jscript.init(p.render, { esbuild: false });
jscript.init(p.render, { esbuild: false });
p.script.loaded = true; p.script.loaded = true;
p.render(); p.render();
}; };