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 { edInitSync } from "../../nova/ed/logic/ed-sync";
import { Loading } from "../../utils/ui/loading";
import init from "wasm-gzip";
export default page({
url: "/ed/:site_id/:page_id",
component: ({}) => {
const p = useGlobal(EDGlobal, "EDITOR");
url: "/ed/:site_id/:page_id",
component: ({}) => {
const p = useGlobal(EDGlobal, "EDITOR");
const w = window as any;
if (!w.Y) {
(async () => {
(window as any).Y = await import("yjs");
(window as any).syncronize = (await import("y-pojo")).syncronize;
p.render();
})();
return <Loading note="init" />;
}
const w = window as any;
if (!w.Y) {
(async () => {
await init();
(window as any).Y = await import("yjs");
(window as any).syncronize = (await import("y-pojo")).syncronize;
p.render();
})();
return <Loading note="init" />;
}
if (!edInitSync(p)) {
return <Loading note="connecting-ws" />;
}
if (!edInitSync(p)) {
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 { dbProxy } from "../../../base/load/db/db-proxy";
import { jscript } from "../../../utils/script/jscript";
import { PG } from "./ed-global";
let w = window as unknown as {
db: ReturnType<typeof dbProxy>;
api: ApiProxy;
db: ReturnType<typeof dbProxy>;
api: ApiProxy;
};
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.render();
p.script.loaded = true;
p.render();
};