fix
This commit is contained in:
parent
1e34f0d25d
commit
b58490700b
|
|
@ -16,7 +16,6 @@
|
||||||
"algoliasearch": "^4.20.0",
|
"algoliasearch": "^4.20.0",
|
||||||
"date-fns": "^2.30.0",
|
"date-fns": "^2.30.0",
|
||||||
"downshift": "^8.2.2",
|
"downshift": "^8.2.2",
|
||||||
"emmet-monaco-es": "^5.3.0",
|
|
||||||
"esbuild-wasm": "^0.19.4",
|
"esbuild-wasm": "^0.19.4",
|
||||||
"idb-keyval": "^6.2.1",
|
"idb-keyval": "^6.2.1",
|
||||||
"js-base64": "^3.7.5",
|
"js-base64": "^3.7.5",
|
||||||
|
|
@ -84,8 +83,8 @@
|
||||||
"@types/lodash.set": "^4.3.7",
|
"@types/lodash.set": "^4.3.7",
|
||||||
"@types/lodash.trim": "4.5.7",
|
"@types/lodash.trim": "4.5.7",
|
||||||
"@types/prettier": "3.0.0",
|
"@types/prettier": "3.0.0",
|
||||||
"@types/react": "18.2.28",
|
"@types/react": "^18.2.0",
|
||||||
"@types/react-dom": "18.2.13",
|
"@types/react-dom": "^18.2.0",
|
||||||
"@types/tinycolor2": "^1.4.4",
|
"@types/tinycolor2": "^1.4.4",
|
||||||
"@types/uuid": "9.0.5",
|
"@types/uuid": "9.0.5",
|
||||||
"@types/vscode": "^1.83.0",
|
"@types/vscode": "^1.83.0",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { page } from "web-init";
|
import { page } from "web-utils";
|
||||||
|
|
||||||
export default page({
|
export default page({
|
||||||
url: "*",
|
url: "*",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { page } from "web-init";
|
import { page } from "web-utils";
|
||||||
import { useLocal } from "web-utils";
|
import { useLocal } from "web-utils";
|
||||||
import { Loading } from "../../../utils/ui/loading";
|
import { Loading } from "../../../utils/ui/loading";
|
||||||
import { formStyle } from "../../../utils/ui/form.style";
|
import { formStyle } from "../../../utils/ui/form.style";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { page } from "web-init";
|
import { page } from "web-utils";
|
||||||
import { Loading } from "../../../utils/ui/loading";
|
import { Loading } from "../../../utils/ui/loading";
|
||||||
|
|
||||||
export default page({
|
export default page({
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { page } from "web-init";
|
import { page } from "web-utils";
|
||||||
import { useLocal } from "web-utils";
|
import { useLocal } from "web-utils";
|
||||||
import { Loading } from "../../../utils/ui/loading";
|
import { Loading } from "../../../utils/ui/loading";
|
||||||
import { formStyle } from "../../../utils/ui/form.style";
|
import { formStyle } from "../../../utils/ui/form.style";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { page } from "web-init";
|
import { page } from "web-utils";
|
||||||
import { Loading } from "../../utils/ui/loading";
|
import { Loading } from "../../utils/ui/loading";
|
||||||
|
|
||||||
export default page({
|
export default page({
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { page } from "web-init";
|
import { page } from "web-utils";
|
||||||
import { useLocal } from "web-utils";
|
import { useLocal } from "web-utils";
|
||||||
import { Loading } from "../../utils/ui/loading";
|
import { Loading } from "../../utils/ui/loading";
|
||||||
import { Suspense, lazy, useEffect } from "react";
|
import { Suspense, lazy, useEffect } from "react";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { validate } from "uuid";
|
import { validate } from "uuid";
|
||||||
import { page } from "web-init";
|
import { page } from "web-utils";
|
||||||
import { Live } from "../../render/live/live";
|
import { Live } from "../../render/live/live";
|
||||||
import { defaultLoader } from "../../render/live/logic/default-loader";
|
import { defaultLoader } from "../../render/live/logic/default-loader";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { FC } from "react";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { GlobalContext } from "web-utils";
|
||||||
|
|
||||||
|
const w = window as unknown as {
|
||||||
|
prasiContext: any;
|
||||||
|
rootRender: any;
|
||||||
|
};
|
||||||
|
|
||||||
|
w.prasiContext = {
|
||||||
|
global: {},
|
||||||
|
render() {},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Root: FC<{}> = ({}) => {
|
||||||
|
const [_, render] = useState({});
|
||||||
|
w.prasiContext.render = () => {
|
||||||
|
render({});
|
||||||
|
};
|
||||||
|
w.rootRender = w.prasiContext.render;
|
||||||
|
|
||||||
|
const Provider = GlobalContext.Provider as FC<{ value: any; children: any }>;
|
||||||
|
return <Provider value={w.prasiContext}>Hello mantapun alamuko</Provider>;
|
||||||
|
};
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
import { createRoot } from "react-dom/client";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
import { Root } from "./base/root";
|
||||||
|
|
||||||
const registerServiceWorker = async () => {
|
const registerServiceWorker = async () => {
|
||||||
if ("serviceWorker" in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
|
|
@ -17,3 +19,8 @@ const registerServiceWorker = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
registerServiceWorker();
|
registerServiceWorker();
|
||||||
|
|
||||||
|
const el = document.getElementById("root");
|
||||||
|
if (el) {
|
||||||
|
createRoot(el).render(<Root />);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { FC, ReactElement, ReactNode } from "react";
|
import { FC, ReactElement, ReactNode } from "react";
|
||||||
import { createRouter } from "web-init";
|
import { createRouter } from "web-utils";
|
||||||
import { CompDoc } from "../../../base/global/content-editor";
|
import { CompDoc } from "../../../base/global/content-editor";
|
||||||
import { IContent, MContent, MPage } from "../../../utils/types/general";
|
import { IContent, MContent, MPage } from "../../../utils/types/general";
|
||||||
import { IItem, MItem } from "../../../utils/types/item";
|
import { IItem, MItem } from "../../../utils/types/item";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { fetchSendApi } from "web-init/src/web/iframe-cors";
|
import { fetchSendApi } from "web-utils/src/web/iframe-cors";
|
||||||
import { useGlobal, useLocal } from "web-utils";
|
import { useGlobal, useLocal } from "web-utils";
|
||||||
import { Gallery } from "./Gallery";
|
import { Gallery } from "./Gallery";
|
||||||
import { Loading } from "../../../../../utils/ui/loading";
|
import { Loading } from "../../../../../utils/ui/loading";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { FC, useTransition } from "react";
|
import { FC, useTransition } from "react";
|
||||||
import { fetchSendApi } from "web-init/src/web/iframe-cors";
|
import { fetchSendApi } from "web-utils/src/web/iframe-cors";
|
||||||
import { useLocal } from "web-utils";
|
import { useLocal } from "web-utils";
|
||||||
import { Button } from "./Button";
|
import { Button } from "./Button";
|
||||||
export const FilePicker: FC<{
|
export const FilePicker: FC<{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import get from "lodash.get";
|
import get from "lodash.get";
|
||||||
import { FC, useTransition } from "react";
|
import { FC, useTransition } from "react";
|
||||||
import { fetchSendApi } from "web-init/src/web/iframe-cors";
|
import { fetchSendApi } from "web-utils/src/web/iframe-cors";
|
||||||
import { useGlobal, useLocal } from "web-utils";
|
import { useGlobal, useLocal } from "web-utils";
|
||||||
import { Loading } from "../../../../../utils/ui/loading";
|
import { Loading } from "../../../../../utils/ui/loading";
|
||||||
import { EditorGlobal } from "../../../logic/global";
|
import { EditorGlobal } from "../../../logic/global";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { createRouter } from "web-init";
|
import { createRouter } from "web-utils";
|
||||||
import { CompDoc } from "../../../base/global/content-editor";
|
import { CompDoc } from "../../../base/global/content-editor";
|
||||||
import { IContent, MContent, MPage } from "../../../utils/types/general";
|
import { IContent, MContent, MPage } from "../../../utils/types/general";
|
||||||
import { IItem, MItem } from "../../../utils/types/item";
|
import { IItem, MItem } from "../../../utils/types/item";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { validate } from "uuid";
|
import { validate } from "uuid";
|
||||||
import { createRouter, type apiClient } from "web-init";
|
import { createRouter, type apiClient } from "web-utils";
|
||||||
import {
|
import {
|
||||||
createAPI,
|
createAPI,
|
||||||
createDB,
|
createDB,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import { FC, useState } from "react";
|
import { FC, useState } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import { defineReact } from "web-init/src/web/define-react";
|
import { GlobalContext, defineReact, defineWindow } from "web-utils";
|
||||||
import { defineWindow } from "web-init/src/web/define-window";
|
|
||||||
import { GlobalContext } from "web-utils";
|
|
||||||
import { SiteLoader } from "./site-loader";
|
import { SiteLoader } from "./site-loader";
|
||||||
|
|
||||||
const w = window as unknown as {
|
const w = window as unknown as {
|
||||||
|
|
@ -22,15 +20,16 @@ const Root: FC<{ url: URL; Live: any }> = ({ url, Live }) => {
|
||||||
};
|
};
|
||||||
w.rootRender = w.prasiContext.render;
|
w.rootRender = w.prasiContext.render;
|
||||||
|
|
||||||
|
const Provider = GlobalContext.Provider as FC<{ value: any; children: any }>;
|
||||||
return (
|
return (
|
||||||
<GlobalContext.Provider value={w.prasiContext}>
|
<Provider value={w.prasiContext}>
|
||||||
<Live
|
<Live
|
||||||
domain={url.host}
|
domain={url.host}
|
||||||
pathname={location.pathname}
|
pathname={location.pathname}
|
||||||
loader={SiteLoader}
|
loader={SiteLoader}
|
||||||
mode="prod"
|
mode="prod"
|
||||||
/>
|
/>
|
||||||
</GlobalContext.Provider>
|
</Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { createStore, get, set } from "idb-keyval";
|
import { createStore, get, set } from "idb-keyval";
|
||||||
import trim from "lodash.trim";
|
import trim from "lodash.trim";
|
||||||
import { apiClient, dbClient } from "web-init";
|
import { apiClient, dbClient } from "web-utils";
|
||||||
import { createFrameCors } from "web-init/src/web/iframe-cors";
|
import { createFrameCors } from "web-utils/src/web/iframe-cors";
|
||||||
export const w = window as unknown as {
|
export const w = window as unknown as {
|
||||||
prasiApi: Record<string, any>;
|
prasiApi: Record<string, any>;
|
||||||
apiHeaders: any;
|
apiHeaders: any;
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,5 @@
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
// "noEmit": true,
|
// "noEmit": true,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"baseUrl": "./src",
|
|
||||||
},
|
},
|
||||||
"include": [
|
|
||||||
"./src/**/*",
|
|
||||||
"./jsx-*.ts",
|
|
||||||
"pkgs/coditor",
|
|
||||||
"public/jsx-worker.js",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
import * as PAGES from "../../../app/gen/web/page/web";
|
|
||||||
|
|
||||||
export const pages = PAGES;
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun run --silent --watch ./pkgs/core/index.ts dev",
|
"dev": "bun run --silent --watch ./pkgs/core/index.ts dev",
|
||||||
|
"clean": "rm -rf app/static && rm -rf app/web/.parcel-cache",
|
||||||
"prod": "bun run --silent ./pkgs/core/index.ts",
|
"prod": "bun run --silent ./pkgs/core/index.ts",
|
||||||
"pull": "cd app/db && bun prisma db pull && bun prisma generate",
|
"pull": "cd app/db && bun prisma db pull && bun prisma generate",
|
||||||
"pkgs-upgrade": "bun run --silent ./pkgs/core/upgrade.ts"
|
"pkgs-upgrade": "bun run --silent ./pkgs/core/upgrade.ts"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Server } from "bun";
|
import { Server, Subprocess } from "bun";
|
||||||
import { Logger } from "pino";
|
import { Logger } from "pino";
|
||||||
import { RadixRouter } from "radix3";
|
import { RadixRouter } from "radix3";
|
||||||
import { PrismaClient } from "../../../app/db/db";
|
import { PrismaClient } from "../../../app/db/db";
|
||||||
|
|
@ -24,4 +24,5 @@ export const g = global as unknown as {
|
||||||
js: string;
|
js: string;
|
||||||
etag: string;
|
etag: string;
|
||||||
};
|
};
|
||||||
|
parcel: Subprocess;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,13 @@ export const parcelBuild = async () => {
|
||||||
"--dist-dir",
|
"--dist-dir",
|
||||||
dir(`app/static`),
|
dir(`app/static`),
|
||||||
];
|
];
|
||||||
|
|
||||||
await removeAsync(dir("app/static"));
|
|
||||||
|
|
||||||
g.log.info(`Building web with parcel`);
|
g.log.info(`Building web with parcel`);
|
||||||
if (g.mode !== "dev") {
|
if (g.mode !== "dev") {
|
||||||
|
await removeAsync(dir("app/static"));
|
||||||
|
await removeAsync(dir("app/web/.parcel-cache"));
|
||||||
|
|
||||||
const parcel = spawn({
|
const parcel = spawn({
|
||||||
cmd: args,
|
cmd: args,
|
||||||
cwd: dir("app/web"),
|
cwd: dir("app/web"),
|
||||||
stdio: ["ignore", "inherit", "inherit"],
|
stdio: ["ignore", "inherit", "inherit"],
|
||||||
});
|
});
|
||||||
|
|
@ -32,6 +32,8 @@ export const parcelBuild = async () => {
|
||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
g.parcel = parcel;
|
||||||
|
|
||||||
let output = true;
|
let output = true;
|
||||||
(async () => {
|
(async () => {
|
||||||
if (parcel.stdout) {
|
if (parcel.stdout) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
"main": "src/export.ts",
|
"main": "src/export.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@paralleldrive/cuid2": "2.2.0",
|
"@paralleldrive/cuid2": "2.2.0",
|
||||||
|
"goober": "^2.1.13",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-dom": "18.2.0"
|
"react-dom": "18.2.0"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import React from "react";
|
||||||
|
import ReactDOM from "react-dom";
|
||||||
|
import JSXDevRuntime from "react/jsx-dev-runtime";
|
||||||
|
import JSXRuntime from "react/jsx-runtime";
|
||||||
|
|
||||||
|
export const defineReact = () => {
|
||||||
|
const w = typeof window === "object" ? window : (globalThis as any);
|
||||||
|
|
||||||
|
w.React = React;
|
||||||
|
w.ReactDOM = ReactDOM;
|
||||||
|
w.JSXRuntime = JSXRuntime;
|
||||||
|
w.JSXDevRuntime = JSXDevRuntime;
|
||||||
|
w.Fragment = React.Fragment;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
import { css, extractCss } from "goober";
|
||||||
|
import { waitUntil } from "web-utils";
|
||||||
|
|
||||||
|
export const defineWindow = async (awaitServerUrl = true) => {
|
||||||
|
let w = typeof window === "object" ? window : (globalThis as any);
|
||||||
|
|
||||||
|
if (awaitServerUrl) await waitUntil(() => w.__SRV_URL__);
|
||||||
|
|
||||||
|
const location = window["location"];
|
||||||
|
|
||||||
|
const host =
|
||||||
|
0 === location.protocol.indexOf("http") ? location.hostname : "localhost",
|
||||||
|
scheme =
|
||||||
|
"https:" != location.protocol || /localhost|127.0.0.1|0.0.0.0/.test(host)
|
||||||
|
? "http"
|
||||||
|
: "https";
|
||||||
|
|
||||||
|
if (w.__SRV_URL__) {
|
||||||
|
w.serverurl = w.__SRV_URL__;
|
||||||
|
const serverURL = new URL(w.serverurl);
|
||||||
|
if (
|
||||||
|
serverURL.hostname === "localhost" ||
|
||||||
|
serverURL.hostname === "127.0.0.1"
|
||||||
|
) {
|
||||||
|
serverURL.hostname = location.hostname;
|
||||||
|
serverURL.pathname = serverURL.pathname === "/" ? "" : serverURL.pathname;
|
||||||
|
w.serverurl = serverURL.toString();
|
||||||
|
if (w.serverurl.endsWith("/")) {
|
||||||
|
w.serverurl = w.serverurl.substring(0, w.serverurl.length - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const port = location.port;
|
||||||
|
w.baseurl = scheme + "://" + host + (port ? ":" + port : "") + "/";
|
||||||
|
w.basepath = "/";
|
||||||
|
w.css = css;
|
||||||
|
w.extractCss = extractCss;
|
||||||
|
w.pathname = location.pathname;
|
||||||
|
|
||||||
|
w.cx = (...classNames: any[]) => {
|
||||||
|
const result: string[] = [];
|
||||||
|
|
||||||
|
classNames
|
||||||
|
.filter((e) => {
|
||||||
|
if (e) {
|
||||||
|
if (typeof e === "string" && e.trim()) return true;
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
.forEach((e) => {
|
||||||
|
if (Array.isArray(e)) {
|
||||||
|
for (const f of e) {
|
||||||
|
if (typeof f === "string" && f.trim()) {
|
||||||
|
result.push(f.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else result.push(e.trim());
|
||||||
|
});
|
||||||
|
return result.join(" ");
|
||||||
|
};
|
||||||
|
|
||||||
|
w.navigate = (href: string) => {
|
||||||
|
let _href = href;
|
||||||
|
|
||||||
|
if (typeof w.navigateOverride === "function") {
|
||||||
|
_href = w.navigateOverride(href);
|
||||||
|
if (!_href) return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
history.pushState({}, "", _href);
|
||||||
|
if (w.rootRes) w.rootRes.pathname = href;
|
||||||
|
w.pathname = href;
|
||||||
|
|
||||||
|
if (w.rootRender) {
|
||||||
|
w.rootRender();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof window === "object") {
|
||||||
|
window.addEventListener("popstate", () => {
|
||||||
|
if (w.preventPopRender) {
|
||||||
|
w.preventPopRender = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (w.rootRender) {
|
||||||
|
w.pathname = location.pathname;
|
||||||
|
w.rootRender();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -3,4 +3,8 @@ export * from "./wait-until";
|
||||||
export * from "./lazify";
|
export * from "./lazify";
|
||||||
export * from "./use-global";
|
export * from "./use-global";
|
||||||
import * as _React from "react";
|
import * as _React from "react";
|
||||||
|
export * from "./page";
|
||||||
|
export * from "./global";
|
||||||
|
export * from "./define-react";
|
||||||
|
export * from "./define-window";
|
||||||
export const React = _React;
|
export const React = _React;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
declare global {
|
||||||
|
const navigate: (path: string) => void;
|
||||||
|
}
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { FC, ReactElement } from "react";
|
||||||
|
|
||||||
|
export const page = (arg: { url: string; component: FC<any> }) => {
|
||||||
|
return arg;
|
||||||
|
};
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
import "../../web-init/src/types";
|
|
||||||
|
|
||||||
export const useLocal = <T extends object>(
|
export const useLocal = <T extends object>(
|
||||||
data: T,
|
data: T,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue