diff --git a/app/srv/ws/sync/actions/page_load.ts b/app/srv/ws/sync/actions/page_load.ts
index e5fe03d0..5002b56c 100644
--- a/app/srv/ws/sync/actions/page_load.ts
+++ b/app/srv/ws/sync/actions/page_load.ts
@@ -219,12 +219,12 @@ const scanMeta = async (doc: DPage, sync: SyncConnection) => {
}
const comps: EPage["comps"] = {};
- // for (const [id, v] of Object.entries(mcomps)) {
- // const snap = snapshot.get("comp", id);
- // if (snap) {
- // comps[id] = { id, snapshot: await gzipAsync(snap.bin) };
- // }
- // }
+ for (const [id, v] of Object.entries(mcomps)) {
+ const snap = snapshot.get("comp", id);
+ if (snap) {
+ comps[id] = { id, snapshot: await gzipAsync(snap.bin) };
+ }
+ }
return { meta: simplifyMeta(meta), comps, entry };
};
diff --git a/app/web/src/nova/ed/ed-right.tsx b/app/web/src/nova/ed/ed-right.tsx
index 5b96d82c..40b68f24 100644
--- a/app/web/src/nova/ed/ed-right.tsx
+++ b/app/web/src/nova/ed/ed-right.tsx
@@ -23,8 +23,15 @@ export const EdRight = () => {
)}
>
{!meta ? (
-
- Select an item
+
+

+
— Select an Item —
) : (
<>
diff --git a/app/web/src/nova/ed/logic/tree/build.tsx b/app/web/src/nova/ed/logic/tree/build.tsx
index 1f6852e1..188ff1b6 100644
--- a/app/web/src/nova/ed/logic/tree/build.tsx
+++ b/app/web/src/nova/ed/logic/tree/build.tsx
@@ -1,170 +1,7 @@
-import { waitUntil } from "web-utils";
-import { EdMeta, PG, active } from "../ed-global";
-import {
- loadComponent,
- loadcomp,
- syncWalkLoad,
- syncWalkMap,
-} from "./sync-walk";
+import { PG, active } from "../ed-global";
export const treeRebuild = async (p: PG, arg?: { note?: string }) => {
- const doc = p.page.doc;
- if (!doc) return;
-
- const root = doc.getMap("map").get("root");
- if (root) {
- p.page.building = true;
- p.render();
-
- p.page.entry = [];
- p.page.tree = [];
- p.page.meta = {};
-
- const portal = {
- in: {} as Record
,
- out: {} as Record,
- };
-
- p.page.root_id = "root";
- if (p.site.layout && p.site.layout.id !== p.page.cur.id) {
- const ldoc = p.page.list[p.site.layout.id];
- if (ldoc) {
- const lroot = ldoc.doc.getMap("map").get("root");
- if (lroot) {
- const sections = lroot.get("childs");
- if (sections) {
- sections.map((e) => {
- return syncWalkLoad(p, e, (id) => {
- return loadComponent(p, id);
- });
- });
-
- if (loadcomp.pending.size > 0) {
- await waitUntil(() => {
- return loadcomp.pending.size === 0;
- });
- }
-
- ldoc.doc.transact(() => {
- sections.map((e) => {
- if (p.page.root_id === "root") {
- p.page.entry.push(e.get("id"));
- }
- syncWalkMap(
- {
- note: "tree-rebuild layout",
- comps: p.comp.list,
- item_loading: p.ui.tree.item_loading,
- meta: p.page.meta,
- scope: p.page.scope,
- },
- {
- is_layout: true,
- mitem: e,
- parent_item: { id: p.page.root_id },
- tree_root_id: p.page.root_id,
- skip_add_tree: true,
- portal,
- each(meta) {
- if (meta.item.name === "content") {
- p.page.root_id = meta.item.id;
- }
- },
- }
- );
- });
- });
-
- for (const [k, portal_out] of Object.entries(portal.out)) {
- const name = k.replace(/⮕/gi, "").trim();
- const portal_in = portal.in[`⬅${name}`];
- if (portal_in) {
- for (const key of Object.keys(portal_in)) {
- delete (portal_in as any)[key];
- }
- for (const [k, v] of Object.entries(portal_out)) {
- (portal_in as any)[k] = v;
- }
- }
- }
- }
-
- // if p.page.root_id is root, it means content is not found.
- // if content is not found, do not use layout.
- if (p.page.root_id === "root") {
- p.page.entry = [];
- p.page.tree = [];
- p.page.meta = {};
- }
- }
- }
- }
-
- const sections = root.get("childs");
- if (sections) {
- sections.map((e) => {
- return syncWalkLoad(p, e, (id) => {
- return loadComponent(p, id);
- });
- });
-
- if (loadcomp.pending.size > 0) {
- await waitUntil(() => {
- return loadcomp.pending.size === 0;
- });
- }
- }
-
- doc.transact(() => {
- const sections = root.get("childs");
- if (sections) {
- sections.map((e) => {
- if (p.page.root_id === "root") {
- p.page.entry.push(e.get("id"));
- } else {
- const meta = p.page.meta[p.page.root_id];
- if (meta && meta.item.type === "item") {
- meta.item.childs.push({ id: e.get("id") } as any);
- }
- }
- syncWalkMap(
- {
- note: "tree-rebuild doc",
- comps: p.comp.list,
- item_loading: p.ui.tree.item_loading,
- meta: p.page.meta,
- tree: p.page.tree,
- scope: p.page.scope,
- },
- {
- is_layout: false,
- mitem: e,
- parent_item: { id: p.page.root_id },
- tree_root_id: p.page.root_id,
- portal,
- }
- );
- });
-
- for (const [k, portal_out] of Object.entries(portal.out)) {
- const name = k.replace(/⮕/gi, "").trim();
- const portal_in = portal.in[`⬅${name}`];
- if (portal_in) {
- for (const key of Object.keys(portal_in)) {
- delete (portal_in as any)[key];
- }
- for (const [k, v] of Object.entries(portal_out)) {
- (portal_in as any)[k] = v;
- }
- }
- }
- }
- });
-
- p.page.building = false;
- p.render();
- p.page.render();
- }
+ console.log(p.comp.list);
};
export const getMRoot = (p: PG) => {
diff --git a/app/web/src/nova/view/logic/meta/comp/instantiate.tsx b/app/web/src/nova/view/logic/meta/comp/instantiate.tsx
index 5459a5eb..6b322b4f 100644
--- a/app/web/src/nova/view/logic/meta/comp/instantiate.tsx
+++ b/app/web/src/nova/view/logic/meta/comp/instantiate.tsx
@@ -9,9 +9,14 @@ export const instantiate = (
mref_ids?: Record & TypedMap>
) => {
const newitem = structuredClone(comp);
+ if (newitem.component) {
+ newitem.component.ref_ids = {};
+ }
+
if (item.id) {
newitem.id = item.id;
}
+
if (item.component) {
newitem.component = item.component;
}
diff --git a/app/web/src/nova/view/logic/meta/meta.tsx b/app/web/src/nova/view/logic/meta/meta.tsx
index 8d8ffe23..7b29805b 100644
--- a/app/web/src/nova/view/logic/meta/meta.tsx
+++ b/app/web/src/nova/view/logic/meta/meta.tsx
@@ -57,6 +57,7 @@ export const genMeta = (p: GenMetaP, arg: GenMetaArg) => {
p.meta[item.id] = meta;
}
}
+
if (item.childs) {
for (const [k, v] of Object.entries(item.childs)) {
const mchild = mitem?.get("childs")?.get(k as unknown as number);
diff --git a/app/web/src/nova/view/logic/meta/ref-ids.tsx b/app/web/src/nova/view/logic/meta/ref-ids.tsx
index 813b54c4..00c90087 100644
--- a/app/web/src/nova/view/logic/meta/ref-ids.tsx
+++ b/app/web/src/nova/view/logic/meta/ref-ids.tsx
@@ -1,8 +1,6 @@
import { createId } from "@paralleldrive/cuid2";
-import { TypedMap } from "yjs-types";
import { IContent, MContent } from "../../../../utils/types/general";
import { IItem } from "../../../../utils/types/item";
-import set from "lodash.set";
import { ISimpleMeta } from "./types";
const timeouts = {} as Record;
@@ -25,28 +23,19 @@ export const applyRefIds = (
if (!ref_ids[item.id]) {
ref_ids[item.id] = createId();
- if (mitem) {
- const mitemcomp = mitem.get("component");
- if (mitemcomp) {
- const mref_ids = new Y.Map() as any;
- syncronize(mref_ids, ref_ids);
- mitemcomp.set("ref_ids", mref_ids);
- }
- }
-
- if (parentcomp) {
- clearTimeout(timeouts[instance.id]);
- timeouts[instance.id] = setTimeout(() => {
- if (mref_ids) {
- const mref_ids = new Y.Map() as any;
- syncronize(mref_ids, ref_ids);
- const parentcomp = parent?.minstance?.get("component");
- if (parentcomp) {
- parentcomp.set("ref_ids", mref_ids);
- }
- }
- }, 50);
- }
+ // if (parentcomp) {
+ // clearTimeout(timeouts[instance.id]);
+ // timeouts[instance.id] = setTimeout(() => {
+ // if (mref_ids) {
+ // const mref_ids = new Y.Map() as any;
+ // syncronize(mref_ids, ref_ids);
+ // const parentcomp = parent?.minstance?.get("component");
+ // if (parentcomp) {
+ // parentcomp.set("ref_ids", mref_ids);
+ // }
+ // }
+ // }, 50);
+ // }
}
if (ref_ids[item.id]) {
diff --git a/app/web/src/nova/view/logic/meta/simplify.tsx b/app/web/src/nova/view/logic/meta/simplify.tsx
index 2d38dd8b..11f4eb3e 100644
--- a/app/web/src/nova/view/logic/meta/simplify.tsx
+++ b/app/web/src/nova/view/logic/meta/simplify.tsx
@@ -41,12 +41,3 @@ export const simplifyMeta = (allmeta: Record) => {
return smeta;
};
-
-function formatBytes(bytes: number, decimals: number) {
- if (bytes == 0) return "0 Bytes";
- var k = 1024,
- dm = decimals || 2,
- sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
- i = Math.floor(Math.log(bytes) / Math.log(k));
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
-}