diff --git a/app/web/src/nova/ed/logic/tree/build.tsx b/app/web/src/nova/ed/logic/tree/build.tsx
index 20561a9e..82b7e903 100644
--- a/app/web/src/nova/ed/logic/tree/build.tsx
+++ b/app/web/src/nova/ed/logic/tree/build.tsx
@@ -1,6 +1,4 @@
import { IItem, MItem } from "../../../../utils/types/item";
-import { viEvalProps } from "../../../vi/render/comp";
-import { viEvalScript } from "../../../vi/render/script";
import { genMeta } from "../../../view/logic/meta/meta";
import { PG, active } from "../ed-global";
import { pushTreeNode } from "./build/push-tree";
@@ -44,18 +42,18 @@ export const treeRebuild = async (p: PG, arg?: { note?: string }) => {
if (!is_layout) {
pushTreeNode(p, meta);
- if (meta.item.component?.props) {
- viEvalProps({ meta: p.page.meta, tick: 0 }, meta);
- }
+ // if (meta.item.component?.props) {
+ // viEvalProps({ meta: p.page.meta, tick: 0 }, meta);
+ // }
- if (meta.item.adv?.jsBuilt) {
- viEvalScript({ meta: p.page.meta, tick: 0 }, meta);
- }
+ // if (meta.item.adv?.jsBuilt) {
+ // viEvalScript({ meta: p.page.meta, tick: 0 }, meta);
+ // }
}
},
},
},
- { item, mitem }
+ { item }
);
}
}
diff --git a/app/web/src/nova/ed/panel/main/main.tsx b/app/web/src/nova/ed/panel/main/main.tsx
index 46c67fe3..6fee7467 100644
--- a/app/web/src/nova/ed/panel/main/main.tsx
+++ b/app/web/src/nova/ed/panel/main/main.tsx
@@ -4,7 +4,7 @@ import { EDGlobal } from "../../logic/ed-global";
export const EdMain = () => {
const p = useGlobal(EDGlobal, "EDITOR");
- return ;
+ return ;
// const local = useLocal({
// el: null as ReactNode,
diff --git a/app/web/src/nova/vi/vi.tsx b/app/web/src/nova/vi/vi.tsx
index 02364526..154afe7a 100644
--- a/app/web/src/nova/vi/vi.tsx
+++ b/app/web/src/nova/vi/vi.tsx
@@ -5,9 +5,7 @@ import { ErrorBox } from "./utils/error-box";
export const Vi: typeof ViRoot = (props) => {
return (
-
-
-
+ {/* */}
);
};
diff --git a/app/web/src/nova/view/logic/meta/comp.tsx b/app/web/src/nova/view/logic/meta/comp.tsx
index a15a8dd6..09aefd50 100644
--- a/app/web/src/nova/view/logic/meta/comp.tsx
+++ b/app/web/src/nova/view/logic/meta/comp.tsx
@@ -1,5 +1,3 @@
-import { MItem } from "../../../../utils/types/item";
-import { evalPropVis } from "./comp/eval-prop-vis";
import { instantiate } from "./comp/instantiate";
import { walkProp } from "./comp/walk-prop";
import { genMeta } from "./meta";
@@ -13,7 +11,6 @@ export const genComp = (
r: ReturnType
) => {
const { item } = arg;
- const mitem = arg.mitem as MItem | undefined;
if (item.type === "item" && item.component?.id && arg.parent?.item.id) {
let pcomp = p.comps[item.component.id];
if (p.on?.visit_component) {
@@ -26,18 +23,11 @@ export const genComp = (
if (pcomp) {
const ref_ids = r?.ref_ids || item.component?.ref_ids || {};
- let mref_ids = r?.mref_ids || mitem?.get("component")?.get("ref_ids");
- if (!mref_ids && mitem) {
- mitem.get("component")?.set("ref_ids", new Y.Map() as any);
- mref_ids = mitem.get("component")?.get("ref_ids");
- }
-
- instantiate(item, pcomp.comp, ref_ids, mref_ids);
+ instantiate(item, pcomp.comp, ref_ids);
const meta: IMeta = {
item: simplifyItemChild(item),
- mitem,
parent: {
id: arg.parent.item.id,
instance_id: arg.parent?.instance?.id,
@@ -50,26 +40,16 @@ export const genComp = (
},
};
- const props = {} as Record;
-
walkProp({
item,
- mitem: mitem,
pcomp,
- each(name, prop, mprop) {
+ each(name, prop) {
if (meta.scope.def?.props) {
meta.scope.def.props[name] = {
value: prop.valueBuilt,
- type: {
- "": "text",
- "content-element": "jsx",
- option: "opt",
- text: "text",
- }[prop.meta?.type || ""] as any,
visible: false,
};
}
- props[name] = { value: prop.valueBuilt, visible: prop.visible };
const comp_id = item.component?.id;
if (
prop.meta?.type === "content-element" &&
@@ -78,7 +58,6 @@ export const genComp = (
) {
genMeta(p, {
item: prop.content,
- mitem: mprop?.get("content"),
is_root: false,
jsx_prop: {
is_root: true,
@@ -87,26 +66,14 @@ export const genComp = (
},
parent: {
item,
- mitem: mitem,
comp: pcomp.comp,
- mcomp: pcomp.mcomp,
instance: arg.parent?.instance || item,
- minstance: arg.parent?.minstance || mitem,
},
});
}
},
});
- const vis = evalPropVis(props);
- if (vis && meta.scope.def?.props) {
- for (const [k, v] of Object.entries(vis)) {
- if (meta.scope.def.props[k]) {
- meta.scope.def.props[k].visible = v === false;
- }
- }
- }
-
if (p.on) {
if (p.on.item_exists && p.meta[item.id]) {
p.on.item_exists({ old: p.meta[item.id], new: meta });
@@ -126,18 +93,13 @@ export const genComp = (
}
for (const [k, v] of Object.entries(item.childs)) {
- const mchild = mitem?.get("childs")?.get(k as unknown as number);
genMeta(p, {
item: v,
- mitem: mchild,
is_root: false,
parent: {
item,
- mitem: mitem,
comp: pcomp.comp,
- mcomp: pcomp.mcomp,
instance: arg.parent?.instance || item,
- minstance: arg.parent?.minstance || mitem,
},
});
}
diff --git a/app/web/src/nova/view/logic/meta/comp/eval-prop-vis.ts b/app/web/src/nova/view/logic/meta/comp/eval-prop-vis.ts
deleted file mode 100644
index 55d05671..00000000
--- a/app/web/src/nova/view/logic/meta/comp/eval-prop-vis.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-export const evalPropVis = (
- props: Record
-) => {
- try {
- const src = `
- ${Object.entries(props)
- .map(([k, v]) => `const ${k} = ${v.value}`)
- .join("\n")}
-
- return {
- ${Object.entries(props)
- .filter(([_, v]) => v.visible)
- .map(([k, v]) => `${k}: ${v.visible},`)
- .join("\n")}
- }
- `;
- const fn = new Function(src);
-
- return fn() as Record;
- } catch (e) {}
-};
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 6b322b4f..02d00279 100644
--- a/app/web/src/nova/view/logic/meta/comp/instantiate.tsx
+++ b/app/web/src/nova/view/logic/meta/comp/instantiate.tsx
@@ -1,12 +1,10 @@
import { createId } from "@paralleldrive/cuid2";
-import { TypedMap } from "yjs-types";
import { IItem } from "../../../../../utils/types/item";
export const instantiate = (
item: IItem,
comp: IItem,
- ref_ids: Record,
- mref_ids?: Record & TypedMap>
+ ref_ids: Record
) => {
const newitem = structuredClone(comp);
if (newitem.component) {
@@ -16,29 +14,24 @@ export const instantiate = (
if (item.id) {
newitem.id = item.id;
}
-
+
if (item.component) {
newitem.component = item.component;
}
- walkChild(newitem, ref_ids, mref_ids);
+ walkChild(newitem, ref_ids);
};
-const walkChild = (
- item: IItem,
- ref_ids: Record,
- mref_ids?: Record & TypedMap>
-) => {
+const walkChild = (item: IItem, ref_ids: Record) => {
if (!ref_ids[item.id]) {
ref_ids[item.id] = createId();
- mref_ids?.set(item.id, ref_ids[item.id]);
}
item.id = ref_ids[item.id];
if (item.childs) {
for (const child of item.childs) {
- walkChild(child as IItem, ref_ids, mref_ids);
+ walkChild(child as IItem, ref_ids);
}
}
};
diff --git a/app/web/src/nova/view/logic/meta/comp/walk-prop.tsx b/app/web/src/nova/view/logic/meta/comp/walk-prop.tsx
index 39a9507a..530f1805 100644
--- a/app/web/src/nova/view/logic/meta/comp/walk-prop.tsx
+++ b/app/web/src/nova/view/logic/meta/comp/walk-prop.tsx
@@ -1,21 +1,12 @@
-import { IItem, MItem } from "../../../../../utils/types/item";
-import { FMCompDef, FNCompDef } from "../../../../../utils/types/meta-fn";
+import { IItem } from "../../../../../utils/types/item";
+import { FNCompDef } from "../../../../../utils/types/meta-fn";
export const walkProp = (arg: {
item: IItem;
- mitem?: MItem;
- pcomp: { comp: IItem; mcomp?: MItem };
- each: (name: string, prop: FNCompDef, mprop?: FMCompDef) => void;
+ pcomp: { comp: IItem };
+ each: (name: string, prop: FNCompDef) => void;
}) => {
for (const [k, v] of Object.entries(arg.pcomp.comp.component?.props || {})) {
- let mprop = arg.mitem?.get("component")?.get("props")?.get(k);
- if (!mprop) {
- const map = new Y.Map() as any;
- syncronize(map, v);
- arg.mitem?.get("component")?.get("props")?.set(k, map);
- mprop = arg.mitem?.get("component")?.get("props")?.get(k);
- }
-
const props = arg.item.component?.props;
let prop = props?.[k];
if (props) {
@@ -26,7 +17,7 @@ export const walkProp = (arg: {
}
if (prop) {
- arg.each(k, prop, mprop);
+ arg.each(k, prop);
}
}
};
diff --git a/app/web/src/nova/view/logic/meta/hydrate.tsx b/app/web/src/nova/view/logic/meta/hydrate.tsx
deleted file mode 100644
index 67b99237..00000000
--- a/app/web/src/nova/view/logic/meta/hydrate.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { IItem, MItem } from "../../../../utils/types/item";
-import { IRoot, MRoot } from "../../../../utils/types/root";
-import { initLoadComp } from "./comp/init-load-comp";
-import { genMeta } from "./meta";
-import { GenMetaP } from "./types";
-
-export const hydrateRoot = async (
- p: GenMetaP,
- mroot: MRoot | MItem,
- loadComponents: (comp_ids: string[]) => Promise
-) => {
- const root = mroot.toJSON() as IRoot;
- if (root.type === "root") {
- const mitems: MItem[] = [];
- (mroot as MRoot).get("childs")?.forEach(async (mitem) => {
- mitems.push(mitem);
- });
-
- await Promise.all(mitems.map((mitem) => hydrate(p, mitem, loadComponents)));
- } else {
- await hydrate(p, mroot as MItem, loadComponents);
- }
-};
-
-const hydrate = async (
- p: GenMetaP,
- mitem: MItem,
- loadComponents: (comp_ids: string[]) => Promise
-) => {
- const item = mitem.toJSON() as IItem;
- await initLoadComp(p, item, loadComponents);
-
- genMeta(
- {
- ...p,
- },
- { item, mitem }
- );
-};
diff --git a/app/web/src/nova/view/logic/meta/meta.tsx b/app/web/src/nova/view/logic/meta/meta.tsx
index 89f81b38..a046af5d 100644
--- a/app/web/src/nova/view/logic/meta/meta.tsx
+++ b/app/web/src/nova/view/logic/meta/meta.tsx
@@ -1,4 +1,4 @@
-import { IItem, MItem } from "../../../../utils/types/item";
+import { IItem } from "../../../../utils/types/item";
import { genComp } from "./comp";
import { applyRefIds } from "./ref-ids";
import { simplifyItemChild } from "./simplify";
@@ -9,19 +9,11 @@ export const genMeta = (p: GenMetaP, arg: GenMetaArg) => {
fn();
};
- if (arg.is_root && arg.mitem) {
- const transact = arg.mitem.doc?.transact;
- if (transact) {
- wrapper = transact;
- }
- }
-
wrapper(() => {
const { parent } = arg;
const item = arg.item as IItem;
- const mitem = arg.mitem as MItem | undefined;
- const r = applyRefIds(item, mitem, parent, p.smeta);
+ const r = applyRefIds(item, parent);
if (item.type === "item" && item.component?.id) {
genComp(p, arg, r);
return;
@@ -38,10 +30,6 @@ export const genMeta = (p: GenMetaP, arg: GenMetaArg) => {
scope: {},
};
- if (p.set_mitem !== false && mitem) {
- meta.mitem = mitem;
- }
-
if (p.on?.visit) {
p.on.visit(meta);
}
@@ -60,19 +48,14 @@ export const genMeta = (p: GenMetaP, arg: GenMetaArg) => {
}
if (item.childs) {
- for (const [k, v] of Object.entries(item.childs)) {
- const mchild = mitem?.get("childs")?.get(k as unknown as number);
+ for (const [_, v] of Object.entries(item.childs)) {
genMeta(p, {
item: v,
- mitem: mchild,
is_root: false,
parent: {
item,
- mitem: mitem,
comp: arg.parent?.comp,
- mcomp: arg.parent?.mcomp,
instance: arg.parent?.instance,
- minstance: arg.parent?.minstance,
},
});
}
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 00c90087..f5900c56 100644
--- a/app/web/src/nova/view/logic/meta/ref-ids.tsx
+++ b/app/web/src/nova/view/logic/meta/ref-ids.tsx
@@ -1,41 +1,16 @@
import { createId } from "@paralleldrive/cuid2";
import { IContent, MContent } from "../../../../utils/types/general";
import { IItem } from "../../../../utils/types/item";
-import { ISimpleMeta } from "./types";
-const timeouts = {} as Record;
-
-export const applyRefIds = (
- item: IContent,
- mitem?: MContent,
- parent?: { instance?: IItem; minstance?: MContent },
- smeta?: Record
-) => {
+export const applyRefIds = (item: IContent, parent?: { instance?: IItem }) => {
const instance = parent?.instance;
if (instance && instance.component) {
- const parentcomp = parent?.minstance?.get("component");
- let mref_ids = parentcomp?.get("ref_ids");
-
const ref_ids = instance.component.ref_ids;
if (ref_ids) {
if (!ref_ids[item.id]) {
ref_ids[item.id] = createId();
-
- // 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]) {
@@ -44,6 +19,6 @@ export const applyRefIds = (
}
}
- return { ref_ids, mref_ids };
+ return { ref_ids };
}
};
diff --git a/app/web/src/nova/view/logic/meta/types.ts b/app/web/src/nova/view/logic/meta/types.ts
index 283898ec..609f4b1e 100644
--- a/app/web/src/nova/view/logic/meta/types.ts
+++ b/app/web/src/nova/view/logic/meta/types.ts
@@ -1,12 +1,10 @@
-import { FC, ReactNode } from "react";
-import { IContent, MContent } from "../../../../utils/types/general";
-import { IItem, MItem } from "../../../../utils/types/item";
-import { ViContext } from "../../../vi/render/parts";
-import { ViRender } from "../../../vi/render/render";
+import { ReactNode } from "react";
+import { IContent } from "../../../../utils/types/general";
+import { IItem } from "../../../../utils/types/item";
export type GenMetaP = {
meta: Record;
- comps: Record;
+ comps: Record;
on?: {
visit_component?: (id: string) => void;
visit?: (meta: IMeta) => void;
@@ -14,22 +12,17 @@ export type GenMetaP = {
item_new?: (arg: { new: IMeta }) => void;
};
smeta?: Record;
- set_mitem?: boolean;
set_meta?: boolean;
};
export type GenMetaArg = {
item: IContent;
is_root?: boolean;
- mitem?: MContent;
jsx_prop?: IMeta["jsx_prop"];
parent?: {
item: IItem;
- mitem?: MItem;
comp?: IItem;
- mcomp?: MItem;
instance?: IItem;
- minstance?: MItem;
};
};
@@ -49,13 +42,10 @@ export type ISimpleMeta = {
export type IMeta = {
item: IItem;
- mitem?: MItem;
parent?: {
id: string;
instance_id?: string;
comp_id?: string;
- minstance?: MItem;
- mcomp?: MItem;
};
jsx_prop?: {
name: string;
@@ -68,10 +58,7 @@ export type IMeta = {
scope: {
val?: any;
def?: {
- props?: Record<
- string,
- { value: string; type: "jsx" | "text" | "opt"; visible: boolean }
- >;
+ props?: Record;
local?: {
name: string;
idx: number;