diff --git a/app/web/src/nova/deploy/main.tsx b/app/web/src/nova/deploy/main.tsx
index 7b8b00f9..9eb372e5 100644
--- a/app/web/src/nova/deploy/main.tsx
+++ b/app/web/src/nova/deploy/main.tsx
@@ -2,6 +2,7 @@ import { createRoot } from "react-dom/client";
import { defineReact, defineWindow } from "web-utils";
import { Root } from "./root";
import { initBaseConfig } from "./base/base";
+import { w } from "./w";
(async () => {
initBaseConfig();
@@ -10,6 +11,30 @@ import { initBaseConfig } from "./base/base";
const root = createRoot(div);
await defineWindow(false);
defineReact();
+
+ w.navigateOverride = (_href: string) => {
+ if (_href && _href.startsWith("/")) {
+ if (
+ location.hostname.split(".").length === 4 ||
+ location.hostname === "prasi.app" ||
+ location.hostname === "prasi.avolut.com" ||
+ location.hostname.includes("ngrok") ||
+ location.hostname === "localhost" ||
+ location.hostname === "127.0.0.1" ||
+ location.hostname === "10.0.2.2" // android localhost
+ ) {
+ if (
+ location.pathname.startsWith("/deploy") &&
+ !_href.startsWith("/deploy")
+ ) {
+ const patharr = location.pathname.split("/");
+ _href = `/deploy/${patharr[2]}${_href}`;
+ }
+ }
+ }
+ return _href;
+ };
+
root.render();
if (document.body.classList.contains("opacity-0")) {
document.body.classList.remove("opacity-0");
diff --git a/app/web/src/nova/deploy/root.tsx b/app/web/src/nova/deploy/root.tsx
index f6a07393..0ffbc93d 100644
--- a/app/web/src/nova/deploy/root.tsx
+++ b/app/web/src/nova/deploy/root.tsx
@@ -1,18 +1,23 @@
-import { useLocal } from "web-utils";
+import { FC, useState } from "react";
import { DeadEnd } from "../../utils/ui/deadend";
import { Loading } from "../../utils/ui/loading";
+import { evalCJS } from "../ed/logic/ed-sync";
+import { Vi } from "../vi/vi";
import { base } from "./base/base";
+import { scanComponent } from "./base/component";
import { loadPage } from "./base/page";
import { detectResponsiveMode } from "./base/responsive";
import { initBaseRoute, rebuildMeta } from "./base/route";
-import { scanComponent } from "./base/component";
-import { Vi } from "../vi/vi";
-import { evalCJS } from "../ed/logic/ed-sync";
-
-const w = window as any;
+import { w } from "./w";
+import { GlobalContext } from "web-utils";
export const Root = () => {
- const local = useLocal({});
+ // #region context
+ const [_, set] = useState({});
+ const render = () => set({});
+ w.prasiContext.render = render;
+ const Provider = GlobalContext.Provider as FC<{ value: any; children: any }>;
+ // #endregion
// #region init
if (base.route.status !== "ready") {
@@ -30,11 +35,11 @@ export const Root = () => {
);
if (site_script) {
for (const [k, v] of Object.entries(site_script)) {
- w[k] = v;
+ (window as any)[k] = v;
}
}
- local.render();
+ render();
});
}
return ;
@@ -66,10 +71,10 @@ export const Root = () => {
await scanComponent(root.childs);
rebuildMeta(p.meta, root);
base.page.cache[p.id] = p;
- local.render();
+ render();
})
.catch(() => {
- local.render();
+ render();
});
return ;
@@ -80,61 +85,63 @@ export const Root = () => {
// #endregion
return (
-
-
+
+
- e)
- .map((e) => e.id)}
- meta={base.page.meta}
- mode={base.mode}
- page_id={base.page.id}
- site_id={base.site.id}
- db={base.site.db}
- api={base.site.api}
- 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),
- }
- : undefined
- }
- script={{ init_local_effect: base.init_local_effect }}
- />
+ css`
+ contain: content;
+ `
+ )}
+ >
+ e)
+ .map((e) => e.id)}
+ meta={base.page.meta}
+ mode={base.mode}
+ page_id={base.page.id}
+ site_id={base.site.id}
+ db={base.site.db}
+ api={base.site.api}
+ 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),
+ }
+ : undefined
+ }
+ script={{ init_local_effect: base.init_local_effect }}
+ />
+
-
+
);
};
diff --git a/app/web/src/nova/deploy/w.ts b/app/web/src/nova/deploy/w.ts
index 366a1af2..25f79e14 100644
--- a/app/web/src/nova/deploy/w.ts
+++ b/app/web/src/nova/deploy/w.ts
@@ -1,6 +1,8 @@
export const w = window as unknown as {
- _prasi: {
- context: {};
- render: () => {};
+ prasiContext: {
+ global: any;
+ render: () => void;
};
+ params: any;
+ navigateOverride: (href: string) => void;
};