fix
This commit is contained in:
parent
e15106866b
commit
568e382fda
|
|
@ -1,52 +1,54 @@
|
|||
export const SyncActionDefinition = {
|
||||
"code": {
|
||||
"create": "0",
|
||||
"load": "1"
|
||||
"list": "1",
|
||||
"load": "2"
|
||||
},
|
||||
"site": {
|
||||
"list": "2",
|
||||
"group": "3",
|
||||
"load": "4",
|
||||
"update": "5"
|
||||
"list": "3",
|
||||
"group": "4",
|
||||
"load": "5",
|
||||
"update": "6"
|
||||
},
|
||||
"comp": {
|
||||
"new": "6",
|
||||
"list": "7",
|
||||
"group": "8",
|
||||
"load": "9"
|
||||
"new": "7",
|
||||
"list": "8",
|
||||
"group": "9",
|
||||
"load": "10"
|
||||
},
|
||||
"page": {
|
||||
"list": "10",
|
||||
"load": "11"
|
||||
"list": "11",
|
||||
"load": "12"
|
||||
},
|
||||
"yjs": {
|
||||
"um": "12",
|
||||
"sv_local": "13",
|
||||
"diff_local": "14",
|
||||
"sv_remote": "15"
|
||||
"um": "13",
|
||||
"sv_local": "14",
|
||||
"diff_local": "15",
|
||||
"sv_remote": "16"
|
||||
},
|
||||
"activity": "16",
|
||||
"activity": "17",
|
||||
"client": {
|
||||
"info": "17"
|
||||
"info": "18"
|
||||
}
|
||||
};
|
||||
export const SyncActionPaths = {
|
||||
"0": "code.create",
|
||||
"1": "code.load",
|
||||
"2": "site.list",
|
||||
"3": "site.group",
|
||||
"4": "site.load",
|
||||
"5": "site.update",
|
||||
"6": "comp.new",
|
||||
"7": "comp.list",
|
||||
"8": "comp.group",
|
||||
"9": "comp.load",
|
||||
"10": "page.list",
|
||||
"11": "page.load",
|
||||
"12": "yjs.um",
|
||||
"13": "yjs.sv_local",
|
||||
"14": "yjs.diff_local",
|
||||
"15": "yjs.sv_remote",
|
||||
"16": "activity",
|
||||
"17": "client.info"
|
||||
"1": "code.list",
|
||||
"2": "code.load",
|
||||
"3": "site.list",
|
||||
"4": "site.group",
|
||||
"5": "site.load",
|
||||
"6": "site.update",
|
||||
"7": "comp.new",
|
||||
"8": "comp.list",
|
||||
"9": "comp.group",
|
||||
"10": "comp.load",
|
||||
"11": "page.list",
|
||||
"12": "page.load",
|
||||
"13": "yjs.um",
|
||||
"14": "yjs.sv_local",
|
||||
"15": "yjs.diff_local",
|
||||
"16": "yjs.sv_remote",
|
||||
"17": "activity",
|
||||
"18": "client.info"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ export type SAction = typeof SyncActions;
|
|||
export const SyncActions = {
|
||||
code: {
|
||||
create: async (id_site: string, name: string) => ({}) as { id: string },
|
||||
load: async (id: string) => ({}) as {},
|
||||
list: async (id_site: string) => ({}) as { ids: string[] },
|
||||
load: async (id: string) => ({}) as { bin: Uint8Array } | void,
|
||||
},
|
||||
site: {
|
||||
list: async () =>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
import { SAction } from "../actions";
|
||||
import { SyncConnection } from "../type";
|
||||
export const code_list: SAction["code"]["list"] = async function (
|
||||
this: SyncConnection,
|
||||
) {
|
||||
let result = null as unknown as Awaited<
|
||||
ReturnType<SAction["code"]["list"]>
|
||||
>;
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
export * from "./code_create";
|
||||
export * from "./code_list";
|
||||
export * from "./code_load";
|
||||
export * from "./site_list";
|
||||
export * from "./site_group";
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ const start = async () => {
|
|||
const sw = await registerServiceWorker();
|
||||
|
||||
const cacheCurrentPage = () => {
|
||||
const swc = navigator.serviceWorker.controller;
|
||||
if (swc) {
|
||||
const swController = navigator.serviceWorker.controller;
|
||||
if (swController) {
|
||||
[location.href, "", "/", "/ed", "/ed/_/_", "/login"].forEach((url) => {
|
||||
swc.postMessage({
|
||||
swController.postMessage({
|
||||
type: "add-cache",
|
||||
url: url,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { NodeModel } from "@minoru/react-dnd-treeview";
|
|||
import { ReactElement } from "react";
|
||||
import { clientStartSync } from "../../../utils/sync/ws-client";
|
||||
import { IItem, MItem } from "../../../utils/types/item";
|
||||
import { DComp, DPage, IRoot } from "../../../utils/types/root";
|
||||
import { DCode, DComp, DPage, IRoot } from "../../../utils/types/root";
|
||||
import { ISection } from "../../../utils/types/section";
|
||||
import { IText, MText } from "../../../utils/types/text";
|
||||
import { SAction } from "../../../../../srv/ws/sync/actions";
|
||||
|
|
@ -17,23 +17,6 @@ export const EmptySite = {
|
|||
js_compiled: "",
|
||||
};
|
||||
|
||||
type CODE_MODULE_NAME = string;
|
||||
type CODE_FILE_PATH = string;
|
||||
export const EmptyCode = {
|
||||
id: "",
|
||||
name: "",
|
||||
use_as_main: false,
|
||||
npm: {} as Record<
|
||||
CODE_MODULE_NAME,
|
||||
{ id: string; module: string; version: string }
|
||||
>,
|
||||
files: {} as Record<
|
||||
CODE_FILE_PATH,
|
||||
{ id: string; name: string; type: "f" | "d" }
|
||||
>,
|
||||
};
|
||||
|
||||
export type ECode = typeof EmptyCode;
|
||||
export type ESite = typeof EmptySite;
|
||||
export type EPage = typeof EmptyPage;
|
||||
export type EComp = typeof EmptyComp;
|
||||
|
|
@ -110,10 +93,10 @@ export const EDGlobal = {
|
|||
list: {} as Record<string, { comp: EComp; doc: DComp }>,
|
||||
group: {} as Record<string, Awaited<ReturnType<SAction["comp"]["group"]>>>,
|
||||
},
|
||||
ui: {
|
||||
code: {
|
||||
loaded: {} as Record<string, ECode>,
|
||||
doc: null as null | DCode,
|
||||
},
|
||||
ui: {
|
||||
layout: {
|
||||
left: parseInt(localStorage.getItem("prasi-layout-left") || "250"),
|
||||
right: parseInt(localStorage.getItem("prasi-layout-right") || "250"),
|
||||
|
|
@ -134,6 +117,11 @@ export const EDGlobal = {
|
|||
open: {} as Record<string, string[]>,
|
||||
},
|
||||
popup: {
|
||||
code: {
|
||||
open: false,
|
||||
id: "",
|
||||
file: "",
|
||||
},
|
||||
site: null as null | ((site_id: string) => void | Promise<void>),
|
||||
site_form: null as null | {
|
||||
group_id: string;
|
||||
|
|
|
|||
|
|
@ -9,11 +9,8 @@ export const EdSiteJS = () => {
|
|||
style="slim"
|
||||
className="font-bold font-mono"
|
||||
onClick={() => {
|
||||
// p.sync.activity(
|
||||
// { page_id: p.page.cur.id, item_id: "site" },
|
||||
// "js",
|
||||
// Activity.Open
|
||||
// );
|
||||
p.ui.popup.code.open = true;
|
||||
p.render();
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
import { useGlobal } from "web-utils";
|
||||
import { EDGlobal } from "../../../logic/ed-global";
|
||||
|
||||
export const EdPopCode = () => {
|
||||
const p = useGlobal(EDGlobal, "EDITOR");
|
||||
|
||||
if (!p.ui.popup.code) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <></>;
|
||||
};
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import { useGlobal } from "web-utils";
|
||||
import { EDGlobal } from "../../../logic/ed-global";
|
||||
import { EdMonaco } from "../monaco/monaco";
|
||||
|
||||
export const EdCode = () => {
|
||||
const p = useGlobal(EDGlobal, "EDITOR");
|
||||
|
||||
if (!p.ui.popup.code.open) return null;
|
||||
|
||||
return (
|
||||
<EdMonaco
|
||||
id="code"
|
||||
type="js"
|
||||
filename=""
|
||||
modal={false}
|
||||
monaco={{
|
||||
value: p.site.js,
|
||||
onChange: async (v) => {},
|
||||
}}
|
||||
onClose={() => {}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
@ -18,6 +18,7 @@ export const EdMonaco = (arg: {
|
|||
val?: Record<string, any>;
|
||||
types?: Record<string, string>;
|
||||
};
|
||||
modal?: boolean;
|
||||
}) => {
|
||||
const filename = arg.filename;
|
||||
const m = arg.monaco;
|
||||
|
|
@ -88,6 +89,14 @@ export const EdMonaco = (arg: {
|
|||
};
|
||||
}
|
||||
|
||||
if (arg.modal === false) {
|
||||
return (
|
||||
<EdMonacoWrap header={arg.header} footer={arg.footer}>
|
||||
{(Editor) => <Editor {...prop} />}
|
||||
</EdMonacoWrap>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { compress } from "wasm-gzip";
|
||||
import { useGlobal, useLocal } from "web-utils";
|
||||
import { Activity } from "../../../../../../srv/ws/sync/type";
|
||||
import { jscript } from "../../../../utils/script/jscript";
|
||||
import { EDGlobal } from "../../logic/ed-global";
|
||||
import { EdUserConn } from "../activity/user-conn";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { TypedArray, TypedDoc, TypedMap } from "yjs-types";
|
||||
import { ISection } from "./section";
|
||||
import { MItem } from "./item";
|
||||
|
||||
import * as Y from "yjs";
|
||||
export type IRoot = {
|
||||
id: "root";
|
||||
type: "root";
|
||||
|
|
@ -20,3 +20,11 @@ export type DPage = TypedDoc<{
|
|||
export type DComp = TypedDoc<{
|
||||
map: TypedMap<{ id: string; root: MItem; ts?: number }>;
|
||||
}>;
|
||||
|
||||
export type DCode = TypedDoc<{
|
||||
map: TypedMap<{
|
||||
id: string;
|
||||
files: TypedMap<Record<string, Y.Text>>;
|
||||
npm: TypedMap<Record<string, string>>;
|
||||
}>;
|
||||
}>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue