This commit is contained in:
Rizky 2024-04-24 22:21:30 +07:00
parent 6a76b2ef03
commit d51366b53e
7 changed files with 42 additions and 56 deletions

File diff suppressed because one or more lines are too long

View File

@ -53,7 +53,7 @@ const serverMain = () => ({
);
}
} catch (e) {
console.log(`Failed to init server ${site_id}`, e);
console.log(`Failed to init server ${site_id}\n`, e);
}
}, 10);
},

View File

@ -1,6 +1,5 @@
import { createRouter } from "radix3";
import { FC, Suspense, lazy } from "react";
import { Geiger } from "react-geiger";
import { GlobalContext, useLocal } from "web-utils";
import { w } from "../utils/types/general";
import { Loading } from "../utils/ui/loading";

View File

@ -164,7 +164,6 @@ export const EdScriptMonaco: FC<{}> = () => {
case "item":
{
types._raw = declareScope(p, meta, monaco);
const model = monaco.editor.createModel(
trim(val),
"typescript",
@ -313,7 +312,7 @@ export const EdScriptMonaco: FC<{}> = () => {
let scope: boolean | ParsedScope = false;
p.ui.popup.script.typings.status = "ok";
p.ui.popup.script.typings.err_msg = "";
if (stype === "prop-master") {
p.sync.code.edit({
type: "prop-master",

View File

@ -103,8 +103,11 @@ export const EdSidePropInstance: FC<{ meta: IMeta }> = ({ meta }) => {
);
evn(arg);
} catch (e) {
console.warn(
`Error prop ${k} in item [${meta.item.name}], source:`,
v.valueBuilt
);
console.error(e);
console.warn(k, v.valueBuilt);
}
}
}

View File

@ -3,6 +3,7 @@ import { w } from "../types/general";
import { baseTypings } from "./types/base";
import { extractProp } from "./types/prop";
import { prismaExtendType } from "./prisma-extend";
import { propPopover } from "../../nova/ed/panel/side/prop-master/prop-form";
export type MonacoEditor = Parameters<OnMount>[0];
type Monaco = Parameters<OnMount>[1];
@ -52,14 +53,14 @@ declare module "ts:runtime/library" {
`\
declare module "ts:prisma" {
${prisma["prisma.d.ts"]
.replace(
`import * as runtime from './runtime/library.js';`,
`import * as runtime from 'ts:runtime/library';`
)
.replace(
`import * as runtime from './runtime/library';`,
`import * as runtime from 'ts:runtime/library';`
)}
.replace(
`import * as runtime from './runtime/library.js';`,
`import * as runtime from 'ts:runtime/library';`
)
.replace(
`import * as runtime from './runtime/library';`,
`import * as runtime from 'ts:runtime/library';`
)}
}`,
`ts:prisma.d.ts`
);
@ -114,32 +115,32 @@ import {
import prisma from 'ts:prisma';
${iftext(
apiTypes,
`\
apiTypes,
`\
import "./api"
import type * as SRVAPI from "${apiPath}";`
)}
)}
declare global {
const db: prisma.PrismaClient & ${prismaExtendType};
${baseTypings}
${propText.join("\n")}
${iftext(
apiTypes,
`
apiTypes,
`
type Api = typeof SRVAPI;
type ApiName = keyof Api;
const api: { [k in ApiName]: Awaited<Api[k]["handler"]>["_"]["api"] } & { _raw: any };
`
)}
)}
}
`,
"ts:global.d.ts"
);
register(monaco, propText.join("\n"), "ts:typings.d.ts");
};
const loadText = async (url: string) => {

View File

@ -15,7 +15,6 @@ export const useLocal = <T extends object>(
render: () => void;
},
deps: (deps || []) as any[],
promisedKeys: new Set<string>(),
ready: false,
_loading: {} as any,
});
@ -29,22 +28,6 @@ export const useLocal = <T extends object>(
if (local.ready === false) {
local._loading = {};
for (const [k, v] of Object.entries(data)) {
if (!local.promisedKeys.has(k)) {
let val = v;
if (typeof val === "object" && val instanceof Promise) {
local._loading[k] = true;
local.promisedKeys.add(k);
(local.data as any)[k] = null;
val.then((resolved) => {
(local.data as any)[k] = resolved;
local._loading[k] = false;
local.data.render();
});
}
}
}
local.data.render = () => {
if (local.ready) _render({});
};