fix
This commit is contained in:
parent
cef839fd93
commit
3b0f394b07
File diff suppressed because one or more lines are too long
|
|
@ -57,7 +57,7 @@ export const EdScriptMonaco: FC<{}> = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!w.monaco_loaded) {
|
if (!w.monaco_loaded) {
|
||||||
w.monaco_loaded = true;
|
w.monaco_loaded = true;
|
||||||
setTimeout(console.clear, 500);
|
// setTimeout(console.clear, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|
|
||||||
|
|
@ -30,15 +30,12 @@ export const declareScope = (p: PG, meta: IMeta, monaco: Monaco) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const vars: Record<string, { mode: "local" | "prop" | "type"; val: string }> =
|
const vars: Record<string, { mode: "local" | "prop" | "type"; val: string }> =
|
||||||
{};
|
{};
|
||||||
let m_prev = null;
|
let m_prev = null;
|
||||||
|
|
||||||
const comp_types = {} as Record<string, string>;
|
const comp_types = {} as Record<string, string>;
|
||||||
|
|
||||||
|
|
||||||
for (const m of cur_path) {
|
for (const m of cur_path) {
|
||||||
if (m.item.component?.props) {
|
if (m.item.component?.props) {
|
||||||
for (const [name, prop] of Object.entries(m.item.component.props)) {
|
for (const [name, prop] of Object.entries(m.item.component.props)) {
|
||||||
|
|
@ -49,6 +46,11 @@ export const declareScope = (p: PG, meta: IMeta, monaco: Monaco) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (m.editor_props) {
|
||||||
|
for (const [k, v] of Object.entries(m.editor_props) as any) {
|
||||||
|
vars[k] = { mode: "prop", val: v };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m.mitem?.parent && (m.mitem?.parent as any).get("meta")) {
|
if (m.mitem?.parent && (m.mitem?.parent as any).get("meta")) {
|
||||||
let prop_name = "";
|
let prop_name = "";
|
||||||
|
|
@ -75,7 +77,7 @@ export const declareScope = (p: PG, meta: IMeta, monaco: Monaco) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,7 +136,7 @@ return typings;
|
||||||
comp_types[k] = v;
|
comp_types[k] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
} catch (e) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (comp && comp.typings) {
|
if (comp && comp.typings) {
|
||||||
|
|
@ -149,7 +151,7 @@ return typings;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tree_types: string[] = [];
|
const tree_types: string[] = [];
|
||||||
const tree_usage: { import: string, usage: string }[] = [];
|
const tree_usage: { import: string; usage: string }[] = [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (const [k, v] of Object.entries(vars)) {
|
for (const [k, v] of Object.entries(vars)) {
|
||||||
i++;
|
i++;
|
||||||
|
|
@ -162,7 +164,7 @@ declare module "item-${im}" {
|
||||||
`);
|
`);
|
||||||
tree_usage.push({
|
tree_usage.push({
|
||||||
import: `import { \$\$_${k} } from "item-${im}";`,
|
import: `import { \$\$_${k} } from "item-${im}";`,
|
||||||
usage: `const ${k} = null as unknown as (typeof \$\$_${k} & { render: ()=> void }); `
|
usage: `const ${k} = null as unknown as (typeof \$\$_${k} & { render: ()=> void }); `,
|
||||||
});
|
});
|
||||||
} else if (v.mode === "prop") {
|
} else if (v.mode === "prop") {
|
||||||
const im = tree_types.length;
|
const im = tree_types.length;
|
||||||
|
|
@ -174,7 +176,7 @@ declare module "item-${im}" {
|
||||||
`);
|
`);
|
||||||
tree_usage.push({
|
tree_usage.push({
|
||||||
import: `import { \$\$_${k} } from "item-${im}";`,
|
import: `import { \$\$_${k} } from "item-${im}";`,
|
||||||
usage: `const ${k} = \$\$_${k};`
|
usage: `const ${k} = \$\$_${k};`,
|
||||||
});
|
});
|
||||||
} else if (v.mode === "type") {
|
} else if (v.mode === "type") {
|
||||||
tree_types.push(`
|
tree_types.push(`
|
||||||
|
|
@ -184,12 +186,16 @@ export const ${k} = null as unknown as ${v.val};
|
||||||
}
|
}
|
||||||
|
|
||||||
register(monaco, tree_types.join("\n"), "ts:tree_types.d.ts");
|
register(monaco, tree_types.join("\n"), "ts:tree_types.d.ts");
|
||||||
register(monaco, `\
|
register(
|
||||||
${tree_usage.map(e => e.import).join("\n")}
|
monaco,
|
||||||
|
`\
|
||||||
|
${tree_usage.map((e) => e.import).join("\n")}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
${tree_usage.map(e => e.usage).join("\n")}
|
${tree_usage.map((e) => e.usage).join("\n")}
|
||||||
}`, "tree_usage.ts");
|
}`,
|
||||||
|
"tree_usage.ts"
|
||||||
|
);
|
||||||
register(monaco, Object.values(comp_types).join("\n"), "ts:comp_types.d.ts");
|
register(monaco, Object.values(comp_types).join("\n"), "ts:comp_types.d.ts");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ export const createViPassProp = (
|
||||||
}
|
}
|
||||||
|
|
||||||
const _pass = { ...passprop, ...script_pass };
|
const _pass = { ...passprop, ...script_pass };
|
||||||
|
meta.editor_props = _pass;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!Array.isArray(arg.children) &&
|
!Array.isArray(arg.children) &&
|
||||||
isValidElement(arg.children) &&
|
isValidElement(arg.children) &&
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ export type IMeta = {
|
||||||
comp_id: string;
|
comp_id: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
editor_props?: any;
|
||||||
script?: {
|
script?: {
|
||||||
scope?: any;
|
scope?: any;
|
||||||
result: ReactNode;
|
result: ReactNode;
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ export const jscript = {
|
||||||
jscript.editor = e.Editor;
|
jscript.editor = e.Editor;
|
||||||
e.loader.config({
|
e.loader.config({
|
||||||
paths: {
|
paths: {
|
||||||
vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.49.0/min/vs",
|
vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.50.0/min/vs",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.events.editorLoaded();
|
this.events.editorLoaded();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue