fix
This commit is contained in:
parent
7d8f2b363f
commit
ba64852760
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,6 @@
|
||||||
import globalExternals from "@fal-works/esbuild-plugin-global-externals";
|
import globalExternals from "@fal-works/esbuild-plugin-global-externals";
|
||||||
import style from "@hyrious/esbuild-plugin-style";
|
import style from "@hyrious/esbuild-plugin-style";
|
||||||
|
import { $ } from "bun";
|
||||||
import { dir } from "dir";
|
import { dir } from "dir";
|
||||||
import { context, formatMessages } from "esbuild";
|
import { context, formatMessages } from "esbuild";
|
||||||
import { cleanPlugin } from "esbuild-clean-plugin";
|
import { cleanPlugin } from "esbuild-clean-plugin";
|
||||||
|
|
@ -12,8 +13,6 @@ import { user } from "../../../entity/user";
|
||||||
import { sendWS } from "../../../sync-handler";
|
import { sendWS } from "../../../sync-handler";
|
||||||
import { SyncType } from "../../../type";
|
import { SyncType } from "../../../type";
|
||||||
import { code } from "../../code";
|
import { code } from "../../code";
|
||||||
import { $ } from "bun";
|
|
||||||
import { waitUntil } from "web-utils";
|
|
||||||
const pending = {} as any;
|
const pending = {} as any;
|
||||||
|
|
||||||
export const initFrontEnd = async (
|
export const initFrontEnd = async (
|
||||||
|
|
@ -178,11 +177,30 @@ const initBuildCtx = async ({
|
||||||
root: string;
|
root: string;
|
||||||
}) => {
|
}) => {
|
||||||
const out_dir_temp = dir.data(`code/${id_site}/site/build-temp`);
|
const out_dir_temp = dir.data(`code/${id_site}/site/build-temp`);
|
||||||
const out_dir_switch = dir.data(`code/${id_site}/site/build-switch`);
|
|
||||||
const out_dir = dir.data(`code/${id_site}/site/build`);
|
const out_dir = dir.data(`code/${id_site}/site/build`);
|
||||||
|
|
||||||
|
const site_filename = "internal.tsx";
|
||||||
|
const site_tsx = Bun.file(dir.data(root + `/${site_filename}`));
|
||||||
|
if (!(await site_tsx.exists())) {
|
||||||
|
await Bun.write(
|
||||||
|
site_tsx,
|
||||||
|
`\
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
// export const Loading = () => {
|
||||||
|
// return <></>;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// export const NotFound = () => {
|
||||||
|
// return <></>;
|
||||||
|
// };
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return await context({
|
return await context({
|
||||||
absWorkingDir: dir.data(root),
|
absWorkingDir: dir.data(root),
|
||||||
entryPoints: ["index.tsx"],
|
entryPoints: ["index.tsx", site_filename],
|
||||||
outdir: out_dir_temp,
|
outdir: out_dir_temp,
|
||||||
format: "esm",
|
format: "esm",
|
||||||
bundle: true,
|
bundle: true,
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ const start = async () => {
|
||||||
sworkerRegister(react);
|
sworkerRegister(react);
|
||||||
defineReact();
|
defineReact();
|
||||||
await defineWindow(false);
|
await defineWindow(false);
|
||||||
|
|
||||||
sworkerAddCache(base_url);
|
sworkerAddCache(base_url);
|
||||||
|
|
||||||
const el = document.getElementById("root");
|
const el = document.getElementById("root");
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import { w } from "./w";
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
import("./font");
|
import("./font");
|
||||||
// initDevLiveReload();
|
|
||||||
initBaseConfig();
|
initBaseConfig();
|
||||||
const div = document.getElementById("root");
|
const div = document.getElementById("root");
|
||||||
if (div) {
|
if (div) {
|
||||||
|
|
@ -17,6 +16,19 @@ import { w } from "./w";
|
||||||
};
|
};
|
||||||
defineReact();
|
defineReact();
|
||||||
|
|
||||||
|
let internal_url = "/_prasi/code/internal.js";
|
||||||
|
if (location.pathname.startsWith("/prod")) {
|
||||||
|
const patharr = location.pathname.split("/");
|
||||||
|
internal_url = `/prod/${patharr[2]}${internal_url}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const prasi_internal = await import(internal_url);
|
||||||
|
if (typeof prasi_internal === "object") {
|
||||||
|
const w = window as any;
|
||||||
|
if (prasi_internal.Loading) w.ContentLoading = prasi_internal.Loading;
|
||||||
|
if (prasi_internal.NotFound) w.ContentNotFound = prasi_internal.NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
w.navigateOverride = (_href: string) => {
|
w.navigateOverride = (_href: string) => {
|
||||||
if (_href && _href.startsWith("/")) {
|
if (_href && _href.startsWith("/")) {
|
||||||
if (isPreview()) {
|
if (isPreview()) {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { treeRebuild } from "../../nova/ed/logic/tree/build";
|
|
||||||
import { useGlobal } from "web-utils";
|
const w = window as any;
|
||||||
|
|
||||||
export const DeadEnd: FC<{ children: any; back?: () => void }> = ({
|
export const DeadEnd: FC<{ children: any; back?: () => void }> = ({
|
||||||
children,
|
children,
|
||||||
back,
|
back,
|
||||||
}) => {
|
}) => {
|
||||||
|
if (w.ContentNotFound) {
|
||||||
|
return <w.ContentNotFound />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center w-full h-full fixed inset-0 flex-col">
|
<div className="flex items-center justify-center w-full h-full fixed inset-0 flex-col">
|
||||||
<div>{children}</div>
|
<div>{children}</div>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
import { FC, ReactElement, ReactNode, useEffect } from "react";
|
import { FC, ReactElement, ReactNode, useEffect } from "react";
|
||||||
import { useLocal } from "web-utils";
|
import { useLocal } from "web-utils";
|
||||||
|
|
||||||
const w = window as unknown as { loadingIcon: string };
|
const w = window as unknown as {
|
||||||
|
loadingIcon: string;
|
||||||
|
ContentLoading?: FC<{ alt?: any; note?: any }>;
|
||||||
|
};
|
||||||
|
|
||||||
export const Loading: FC<{
|
export const Loading: FC<{
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
|
|
@ -46,6 +49,8 @@ export const Loading: FC<{
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const CustomLoading = w.ContentLoading;
|
||||||
|
console.log()
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{backdrop !== false && (
|
{backdrop !== false && (
|
||||||
|
|
@ -96,33 +101,37 @@ export const Loading: FC<{
|
||||||
typeof show !== "undefined" ? (show ? "" : "hidden") : ""
|
typeof show !== "undefined" ? (show ? "" : "hidden") : ""
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
{CustomLoading ? (
|
||||||
className={cx(
|
<CustomLoading alt={alt} note={note} />
|
||||||
"w-1/6 flex flex-col items-center justify-center",
|
) : (
|
||||||
css`
|
<div
|
||||||
min-width: 30px;
|
className={cx(
|
||||||
.pr-outer {
|
"w-1/6 flex flex-col items-center justify-center",
|
||||||
background: rgba(0, 0, 0, 0.1) !important;
|
css`
|
||||||
}
|
min-width: 30px;
|
||||||
`
|
.pr-outer {
|
||||||
)}
|
background: rgba(0, 0, 0, 0.1) !important;
|
||||||
>
|
}
|
||||||
<div className="text-[10px] text-slate-400 whitespace-nowrap">
|
`
|
||||||
{note}
|
)}
|
||||||
</div>
|
>
|
||||||
|
<div className="text-[10px] text-slate-400 whitespace-nowrap">
|
||||||
|
{note}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="pr-outer w-full h-[3px] flex items-stretch rounded-sm overflow-hidden">
|
<div className="pr-outer w-full h-[3px] flex items-stretch rounded-sm overflow-hidden">
|
||||||
<div
|
<div
|
||||||
className={cx(
|
className={cx(
|
||||||
"bg-blue-800 transition-all duration-200 rounded-sm w-full",
|
"bg-blue-800 transition-all duration-200 rounded-sm w-full",
|
||||||
css`
|
css`
|
||||||
transform: translate(${-100 + local.value * 200}%);
|
transform: translate(${-100 + local.value * 200}%);
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
></div>
|
></div>
|
||||||
|
</div>
|
||||||
|
{alt}
|
||||||
</div>
|
</div>
|
||||||
{alt}
|
)}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,11 @@ export const createServer = async () => {
|
||||||
|
|
||||||
if (serveStatic.exists(url)) {
|
if (serveStatic.exists(url)) {
|
||||||
return serveStatic.serve(url);
|
return serveStatic.serve(url);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const response = serveStatic.serveSitePublic(url);
|
||||||
|
if (response) return response;
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const api_response = await serveAPI.serve(url, req, prasi);
|
const api_response = await serveAPI.serve(url, req, prasi);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { join } from "path";
|
||||||
import { g } from "utils/global";
|
import { g } from "utils/global";
|
||||||
import { CORS_HEADERS } from "./serve-api";
|
import { CORS_HEADERS } from "./serve-api";
|
||||||
import { existsAsync } from "fs-jetpack";
|
import { existsAsync } from "fs-jetpack";
|
||||||
|
import { code } from "../../../app/srv/ws/sync/code/code";
|
||||||
|
|
||||||
if (!g.static_cache) {
|
if (!g.static_cache) {
|
||||||
g.static_cache = {};
|
g.static_cache = {};
|
||||||
|
|
@ -70,6 +71,23 @@ export const serveStatic = {
|
||||||
exists: (url: URL) => {
|
exists: (url: URL) => {
|
||||||
return !!cache.static[url.pathname];
|
return !!cache.static[url.pathname];
|
||||||
},
|
},
|
||||||
|
serveSitePublic: (url: URL) => {
|
||||||
|
if (!cache.static[url.pathname] && url.pathname.startsWith("/prod")) {
|
||||||
|
const parts = url.pathname.split("/");
|
||||||
|
const id_site = parts[2];
|
||||||
|
if (id_site && id_site.length > 5) {
|
||||||
|
const trail = parts.slice(3).join("/");
|
||||||
|
if (!trail.startsWith("_prasi") && trail.length > 3) {
|
||||||
|
const path = code.path(id_site, "site", "src", `/public/${trail}`);
|
||||||
|
|
||||||
|
const file = Bun.file(path);
|
||||||
|
if (file.size > 0) {
|
||||||
|
return new Response(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
async serve(url: URL) {
|
async serve(url: URL) {
|
||||||
if (g.mode === "prod") {
|
if (g.mode === "prod") {
|
||||||
let file = cache.static[url.pathname];
|
let file = cache.static[url.pathname];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue