From 0f520d14c499aac93aa978b00fb4b5132308e685 Mon Sep 17 00:00:00 2001 From: Rizky Date: Wed, 5 Jun 2024 08:59:49 +0700 Subject: [PATCH] fix --- app/srv/ws/sync/entity/snapshot.ts | 2 +- app/web/src/nova/ed/ed-base.tsx | 2 +- app/web/src/nova/ed/logic/ed-route.ts | 1 + app/web/src/nova/prod/root.tsx | 19 +++++++++---------- app/web/src/nova/vi/preview.tsx | 22 +++++++++++++++++----- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/app/srv/ws/sync/entity/snapshot.ts b/app/srv/ws/sync/entity/snapshot.ts index b82d1562..02071c50 100644 --- a/app/srv/ws/sync/entity/snapshot.ts +++ b/app/srv/ws/sync/entity/snapshot.ts @@ -89,7 +89,7 @@ export const snapshot = { async update(data: DocSnapshot) { const id = `${data.type}-${data.id}`; - this, _db[id] = data; + this._db[id] = data; return true; }, diff --git a/app/web/src/nova/ed/ed-base.tsx b/app/web/src/nova/ed/ed-base.tsx index d9d108d0..bff9aa1c 100644 --- a/app/web/src/nova/ed/ed-base.tsx +++ b/app/web/src/nova/ed/ed-base.tsx @@ -35,7 +35,7 @@ export const EdBase = () => { const vscode_url = isLocalhost() ? "http://localhost:8443?" : "https://prasi-vsc.avolut.com/?tkn=prasi&"; - + if (p.status === "load-site") { return ( { base.route.pages = pages; const basepath = w._prasi.basepath; - let url = `${ - basepath.endsWith("/") ? basepath : `${basepath}/` - }_prasi/code/index.js`; + let url = `${basepath.endsWith("/") ? basepath : `${basepath}/` + }_prasi/code/index.js`; const cur = new URL(location.href); if (url.startsWith("/")) { @@ -224,19 +223,19 @@ export const Root = () => { await setkv(`comp-${id}`, item); } - } catch (e) {} + } catch (e) { } return comp.list[comp_id]; }} layout={ base.layout.id && base.layout.root && base.layout.meta ? { - id: base.layout.id, - meta: base.layout.meta, - entry: Object.values(base.layout.root.childs) - .filter((e) => e) - .map((e) => e.id), - } + id: base.layout.id, + meta: base.layout.meta, + entry: Object.values(base.layout.root.childs) + .filter((e) => e) + .map((e) => e.id), + } : undefined } script={{ init_local_effect: base.init_local_effect }} diff --git a/app/web/src/nova/vi/preview.tsx b/app/web/src/nova/vi/preview.tsx index 55b871ab..4af7d573 100644 --- a/app/web/src/nova/vi/preview.tsx +++ b/app/web/src/nova/vi/preview.tsx @@ -1,7 +1,7 @@ import { get } from "idb-keyval"; import parseUA from "ua-parser-js"; import init, { decompress } from "wasm-gzip"; -import { useGlobal } from "web-utils"; +import { deepClone, useGlobal } from "web-utils"; import { w } from "../../utils/types/general"; import { IRoot } from "../../utils/types/root"; import { DeadEnd } from "../../utils/ui/deadend"; @@ -16,6 +16,7 @@ import { loadSite } from "../ed/logic/ed-site"; import { treeCacheBuild } from "../ed/logic/tree/build"; import { nav } from "./render/script/extract-nav"; import { Vi } from "./vi"; +import { loadComponent } from "../ed/logic/comp/load"; const decoder = new TextDecoder(); export const ViPreview = (arg: { pathname: string }) => { @@ -123,13 +124,24 @@ export const ViPreview = (arg: { pathname: string }) => { entry={p.page.entry} api={p.script.api} db={p.script.db} + comp_load={async (comp_id) => { + let comp = p.comp.loaded[comp_id]; + if (comp) { + return comp; + } + + await loadComponent(p, comp_id); + comp = p.comp.loaded[comp_id]; + + return deepClone(comp); + }} layout={ p.site.layout.id && p.site.layout.meta ? { - id: p.site.layout.id, - meta: p.site.layout.meta, - entry: p.site.layout.entry, - } + id: p.site.layout.id, + meta: p.site.layout.meta, + entry: p.site.layout.entry, + } : undefined } render_stat="disabled"