(async (resolve) => {
+ const module = await importCJS(`/nova-load/code/${id}/index.js`);
+ for (const [k, v] of Object.entries(module)) {
+ w[k] = v;
+ }
+ resolve();
+ })
+ );
+ }
+
+ await Promise.all(promises);
+
+ v.mode = "rebuild";
+ v.render();
+ }
+};
+
+const importCJS = async (url: string) => {
+ const module = { exports: { __esModule: true as true | undefined } };
+ const res = await fetch(url);
+
+ const src = await res.text();
+ if (src) {
+ const fn = new Function("module", src);
+ await fn(module);
+
+ const result = { ...module.exports };
+ if (result.__esModule) {
+ delete result.__esModule;
+ }
+
+ return result;
+ }
+
+ return {};
+};
diff --git a/app/web/src/nova/view/render/entry.tsx b/app/web/src/nova/view/render/entry.tsx
new file mode 100644
index 00000000..bd3cd109
--- /dev/null
+++ b/app/web/src/nova/view/render/entry.tsx
@@ -0,0 +1,15 @@
+import { useGlobal } from "web-utils";
+import { ViewGlobal } from "../logic/global";
+import { VSection } from "./section";
+
+export const VEntry = () => {
+ const v = useGlobal(ViewGlobal, "VIEW");
+
+ return (
+ <>
+ {v.entry.map((section_id) => {
+ return ;
+ })}
+ >
+ );
+};
diff --git a/app/web/src/nova/view/render/meta.tsx b/app/web/src/nova/view/render/meta.tsx
new file mode 100644
index 00000000..89d42426
--- /dev/null
+++ b/app/web/src/nova/view/render/meta.tsx
@@ -0,0 +1,11 @@
+import { FC } from "react";
+import { useGlobal } from "web-utils";
+import { ViewGlobal } from "../logic/global";
+
+export const ViewMeta: FC<{ id: string }> = ({ id }) => {
+ const v = useGlobal(ViewGlobal, "VIEW");
+
+ const meta = v.meta[id];
+ const item = meta.item;
+ return ;
+};
diff --git a/app/web/src/nova/view/render/section.tsx b/app/web/src/nova/view/render/section.tsx
index d9eafba0..eb97916a 100644
--- a/app/web/src/nova/view/render/section.tsx
+++ b/app/web/src/nova/view/render/section.tsx
@@ -1,10 +1,6 @@
-import { FC, ReactNode } from "react";
-import { ISection } from "../../../utils/types/section";
+import { FC } from "react";
+import { ViewMeta } from "./meta";
-export const VSection: FC<{ item: ISection; children: ReactNode }> = ({
- item,
- children,
-}) => {
- console.log(item);
- return ;
+export const VSection: FC<{ id: string }> = ({ id }) => {
+ return ;
};
diff --git a/app/web/src/nova/view/view.tsx b/app/web/src/nova/view/view.tsx
index 9147b59e..a57bf730 100644
--- a/app/web/src/nova/view/view.tsx
+++ b/app/web/src/nova/view/view.tsx
@@ -2,36 +2,50 @@ import { FC } from "react";
import { useGlobal } from "web-utils";
import { Loading } from "../../utils/ui/loading";
import { ViewGlobal } from "./logic/global";
-import { VInit } from "./logic/init";
+import { vInit } from "./logic/init";
+import { vLoadCode } from "./logic/load-code";
import { VLoad } from "./logic/types";
-import { VSection } from "./render/section";
-import { ISection } from "../../utils/types/section";
+import { VEntry } from "./render/entry";
export const View: FC<{
load: VLoad;
-}> = ({ load }) => {
+ site_id: string;
+ page_id: string;
+ bind?: (arg: { render: () => void }) => void;
+}> = ({ load, site_id, page_id, bind: onLoad }) => {
const v = useGlobal(ViewGlobal, "VIEW");
- if (v.mode === "init") {
- VInit(v, load);
+ if (v.current.page_id !== page_id || v.current.site_id !== site_id) {
+ v.mode = "init";
}
- return (
-
- {v.mode !== "ready" ? (
-
- ) : (
- v.entry.map((section_id) => {
- const meta = v.meta[section_id];
- const section = meta.item as ISection;
+ if (onLoad) {
+ onLoad({
+ render() {
+ v.mode = "rebuild";
+ v.render();
+ },
+ });
+ }
- return (
-
- Hello
-
- );
- })
- )}
-
- );
+ if (v.mode === "init") {
+ vInit(v, { load, page_id, site_id });
+ if (v.mode === "init") {
+ return ;
+ }
+ }
+
+ if (v.mode === "load-code" || v.mode === "loading-code") {
+ vLoadCode(v);
+ if (v.mode === "load-code" || v.mode === "loading-code") {
+ return ;
+ }
+ }
+
+ if (v.mode === "rebuild") {
+ v.bodyCache = ;
+ v.mode = "ready";
+ }
+
+ return {v.bodyCache}
;
};