fix
This commit is contained in:
parent
4ba40f8708
commit
b7a193d909
|
|
@ -1,5 +1,5 @@
|
|||
/// <reference types="node" />
|
||||
/// <reference types="react" />
|
||||
/// <reference types="node" />
|
||||
declare module "app/srv/api/npm-size" {
|
||||
export const _: {
|
||||
url: string;
|
||||
|
|
@ -18,95 +18,6 @@ declare module "app/srv/api/site-dts" {
|
|||
api(site_id: string): Promise<string>;
|
||||
};
|
||||
}
|
||||
declare module "app/srv/global" {
|
||||
import { site, user } from "dbgen";
|
||||
import { ExecaChildProcess } from "execa";
|
||||
export const glb: {
|
||||
lastUpdate: Record<string, number>;
|
||||
prasiSrv: {
|
||||
status: Record<string, "unavailable" | "installing" | "starting" | "started" | "stopped" | "destroying">;
|
||||
running: Record<string, ExecaChildProcess>;
|
||||
};
|
||||
npm: {
|
||||
page: Record<string, null | {
|
||||
file: Buffer;
|
||||
etag: string;
|
||||
}>;
|
||||
site: Record<string, null | {
|
||||
file: Buffer;
|
||||
etag: string;
|
||||
}>;
|
||||
};
|
||||
};
|
||||
export type Session = {
|
||||
user: user & {
|
||||
site: site[];
|
||||
};
|
||||
};
|
||||
}
|
||||
declare module "app/web/src/utils/types/ws" {
|
||||
export type WS_MSG = WS_MSG_GET_COMP | WS_MSG_SET_COMP | WS_MSG_GET_PAGE | WS_MSG_SET_PAGE | WS_MSG_SV_LOCAL | WS_MSG_SVDIFF_REMOTE | WS_MSG_DIFF_LOCAL | WS_MSG_UNDO | WS_MSG_REDO | WS_MSG_NEW_COMP | WS_SITE_JS | {
|
||||
type: "ping";
|
||||
} | {
|
||||
type: "pong";
|
||||
};
|
||||
export type WS_SITE_JS = {
|
||||
type: "site-js";
|
||||
id_site: string;
|
||||
src: string;
|
||||
};
|
||||
export type WS_MSG_GET_COMP = {
|
||||
type: "get_comp";
|
||||
comp_id: string;
|
||||
};
|
||||
export type WS_MSG_SET_COMP = {
|
||||
type: "set_comp";
|
||||
comp_id: string;
|
||||
changes: string;
|
||||
};
|
||||
export type WS_MSG_GET_PAGE = {
|
||||
type: "get_page";
|
||||
page_id: string;
|
||||
};
|
||||
export type WS_MSG_SET_PAGE = {
|
||||
type: "set_page";
|
||||
changes: string;
|
||||
};
|
||||
export type WS_MSG_NEW_COMP = {
|
||||
type: "new_comp";
|
||||
id: string;
|
||||
doc: string;
|
||||
};
|
||||
export type WS_MSG_UNDO = {
|
||||
type: "undo";
|
||||
mode: "page" | "site" | "comp";
|
||||
id: string;
|
||||
};
|
||||
export type WS_MSG_REDO = {
|
||||
type: "redo";
|
||||
mode: "page" | "site" | "comp";
|
||||
id: string;
|
||||
};
|
||||
export type WS_MSG_SV_LOCAL = {
|
||||
type: "sv_local";
|
||||
mode: "page" | "site" | "comp";
|
||||
id: string;
|
||||
sv_local: string;
|
||||
};
|
||||
export type WS_MSG_SVDIFF_REMOTE = {
|
||||
type: "svd_remote";
|
||||
mode: "page" | "site" | "comp";
|
||||
id: string;
|
||||
sv_remote: string;
|
||||
diff_remote: string;
|
||||
};
|
||||
export type WS_MSG_DIFF_LOCAL = {
|
||||
type: "diff_local";
|
||||
mode: "page" | "site" | "comp";
|
||||
id: string;
|
||||
diff_local: string;
|
||||
};
|
||||
}
|
||||
declare module "app/web/src/utils/types/meta-fn" {
|
||||
import { TypedMap } from "yjs-types";
|
||||
import { IItem, MItem } from "app/web/src/utils/types/item";
|
||||
|
|
@ -398,6 +309,69 @@ declare module "app/web/src/utils/types/general" {
|
|||
item: ITEM;
|
||||
};
|
||||
}
|
||||
declare module "app/web/src/utils/types/ws" {
|
||||
export type WS_MSG = WS_MSG_GET_COMP | WS_MSG_SET_COMP | WS_MSG_GET_PAGE | WS_MSG_SET_PAGE | WS_MSG_SV_LOCAL | WS_MSG_SVDIFF_REMOTE | WS_MSG_DIFF_LOCAL | WS_MSG_UNDO | WS_MSG_REDO | WS_MSG_NEW_COMP | WS_SITE_JS | {
|
||||
type: "ping";
|
||||
} | {
|
||||
type: "pong";
|
||||
};
|
||||
export type WS_SITE_JS = {
|
||||
type: "site-js";
|
||||
id_site: string;
|
||||
src: string;
|
||||
};
|
||||
export type WS_MSG_GET_COMP = {
|
||||
type: "get_comp";
|
||||
comp_id: string;
|
||||
};
|
||||
export type WS_MSG_SET_COMP = {
|
||||
type: "set_comp";
|
||||
comp_id: string;
|
||||
changes: string;
|
||||
};
|
||||
export type WS_MSG_GET_PAGE = {
|
||||
type: "get_page";
|
||||
page_id: string;
|
||||
};
|
||||
export type WS_MSG_SET_PAGE = {
|
||||
type: "set_page";
|
||||
changes: string;
|
||||
};
|
||||
export type WS_MSG_NEW_COMP = {
|
||||
type: "new_comp";
|
||||
id: string;
|
||||
doc: string;
|
||||
};
|
||||
export type WS_MSG_UNDO = {
|
||||
type: "undo";
|
||||
mode: "page" | "site" | "comp";
|
||||
id: string;
|
||||
};
|
||||
export type WS_MSG_REDO = {
|
||||
type: "redo";
|
||||
mode: "page" | "site" | "comp";
|
||||
id: string;
|
||||
};
|
||||
export type WS_MSG_SV_LOCAL = {
|
||||
type: "sv_local";
|
||||
mode: "page" | "site" | "comp";
|
||||
id: string;
|
||||
sv_local: string;
|
||||
};
|
||||
export type WS_MSG_SVDIFF_REMOTE = {
|
||||
type: "svd_remote";
|
||||
mode: "page" | "site" | "comp";
|
||||
id: string;
|
||||
sv_remote: string;
|
||||
diff_remote: string;
|
||||
};
|
||||
export type WS_MSG_DIFF_LOCAL = {
|
||||
type: "diff_local";
|
||||
mode: "page" | "site" | "comp";
|
||||
id: string;
|
||||
diff_local: string;
|
||||
};
|
||||
}
|
||||
declare module "app/srv/ws/edit/tools/load-page" {
|
||||
import { Page } from "app/web/src/utils/types/general";
|
||||
export const loadPage: (page_id: string) => Promise<Page>;
|
||||
|
|
@ -572,6 +546,38 @@ declare module "app/srv/ws/edit/edit-global" {
|
|||
};
|
||||
};
|
||||
}
|
||||
declare module "app/srv/api/page-reload" {
|
||||
export const _: {
|
||||
url: string;
|
||||
api(page_id: string): Promise<string>;
|
||||
};
|
||||
}
|
||||
declare module "app/srv/global" {
|
||||
import { site, user } from "dbgen";
|
||||
import { ExecaChildProcess } from "execa";
|
||||
export const glb: {
|
||||
lastUpdate: Record<string, number>;
|
||||
prasiSrv: {
|
||||
status: Record<string, "unavailable" | "installing" | "starting" | "started" | "stopped" | "destroying">;
|
||||
running: Record<string, ExecaChildProcess>;
|
||||
};
|
||||
npm: {
|
||||
page: Record<string, null | {
|
||||
file: Buffer;
|
||||
etag: string;
|
||||
}>;
|
||||
site: Record<string, null | {
|
||||
file: Buffer;
|
||||
etag: string;
|
||||
}>;
|
||||
};
|
||||
};
|
||||
export type Session = {
|
||||
user: user & {
|
||||
site: site[];
|
||||
};
|
||||
};
|
||||
}
|
||||
declare module "app/srv/api/npm-bundle" {
|
||||
export type NPMImportAs = {
|
||||
main: {
|
||||
|
|
@ -634,6 +640,13 @@ declare module "app/srv/exports" {
|
|||
args: string[];
|
||||
handler: Promise<typeof import("app/srv/api/site-dts")>;
|
||||
};
|
||||
export const page_reload: {
|
||||
name: string;
|
||||
url: string;
|
||||
path: string;
|
||||
args: string[];
|
||||
handler: Promise<typeof import("app/srv/api/page-reload")>;
|
||||
};
|
||||
export const npm_bundle: {
|
||||
name: string;
|
||||
url: string;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,13 @@ export const site_dts = {
|
|||
args: ["site_id"],
|
||||
handler: import("./api/site-dts")
|
||||
}
|
||||
export const page_reload = {
|
||||
name: "page_reload",
|
||||
url: "/page-reload/:page_id",
|
||||
path: "app/srv/api/page-reload.ts",
|
||||
args: ["page_id"],
|
||||
handler: import("./api/page-reload")
|
||||
}
|
||||
export const npm_bundle = {
|
||||
name: "npm_bundle",
|
||||
url: "/npm-bundle/:mode/:id",
|
||||
|
|
|
|||
|
|
@ -14,12 +14,20 @@ export const jscript = {
|
|||
editor: null as typeof MonacoEditor | null,
|
||||
build: null as null | FBuild,
|
||||
_init: false,
|
||||
_editor: false,
|
||||
async init() {
|
||||
if (!this._init) {
|
||||
this._init = true;
|
||||
const { sendIPC } = await import("./esbuild/ipc");
|
||||
await initJS();
|
||||
|
||||
if (!this._editor) {
|
||||
this._editor = true;
|
||||
const e = await import("@monaco-editor/react");
|
||||
jscript.editor = e.Editor;
|
||||
e.loader.config({ paths: { vs: "/min/vs" } });
|
||||
}
|
||||
|
||||
this.build = async (entry, src, files, verbose?: boolean) => {
|
||||
const options: BuildOptions = {
|
||||
entryPoints: [entry],
|
||||
|
|
@ -51,13 +59,7 @@ export const EScriptElement: FC<{}> = ({}) => {
|
|||
const p = useGlobal(EditorGlobal, "EDITOR");
|
||||
|
||||
if (!jscript.editor) {
|
||||
Promise.all([
|
||||
import("@monaco-editor/react").then((e) => {
|
||||
jscript.editor = e.Editor;
|
||||
e.loader.config({ paths: { vs: "/min/vs" } });
|
||||
}),
|
||||
jscript.init(),
|
||||
]).then(() => {
|
||||
jscript.init().then(() => {
|
||||
p.render();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue