fix
This commit is contained in:
parent
722b8ccea8
commit
71caede8a4
File diff suppressed because one or more lines are too long
|
|
@ -30,12 +30,15 @@ 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)) {
|
||||||
|
|
@ -72,7 +75,7 @@ export const declareScope = (p: PG, meta: IMeta, monaco: Monaco) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,7 +134,7 @@ return typings;
|
||||||
comp_types[k] = v;
|
comp_types[k] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (comp && comp.typings) {
|
if (comp && comp.typings) {
|
||||||
|
|
@ -146,8 +149,10 @@ return typings;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tree_types: string[] = [];
|
const tree_types: string[] = [];
|
||||||
const tree_usage: string[] = [];
|
const tree_usage: { import: string, usage: string }[] = [];
|
||||||
|
let i = 0;
|
||||||
for (const [k, v] of Object.entries(vars)) {
|
for (const [k, v] of Object.entries(vars)) {
|
||||||
|
i++;
|
||||||
if (v.mode === "local") {
|
if (v.mode === "local") {
|
||||||
const im = tree_types.length;
|
const im = tree_types.length;
|
||||||
tree_types.push(`\
|
tree_types.push(`\
|
||||||
|
|
@ -155,10 +160,10 @@ declare module "item-${im}" {
|
||||||
export const \$\$_${k} = ${v.val};
|
export const \$\$_${k} = ${v.val};
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
tree_usage.push(`
|
tree_usage.push({
|
||||||
import { \$\$_${k} } from "item-${im}";
|
import: `import { \$\$_${k} } from "item-${im}";`,
|
||||||
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;
|
||||||
tree_types.push(`\
|
tree_types.push(`\
|
||||||
|
|
@ -167,10 +172,10 @@ declare module "item-${im}" {
|
||||||
export const \$\$_${k} = ${v.val};
|
export const \$\$_${k} = ${v.val};
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
tree_usage.push(`
|
tree_usage.push({
|
||||||
import { \$\$_${k} } from "item-${im}";
|
import: `import { \$\$_${k} } from "item-${im}";`,
|
||||||
const ${k} = null as unknown as typeof \$\$_${k};
|
usage: `const ${k} = \$\$_${k};`
|
||||||
`);
|
});
|
||||||
} else if (v.mode === "type") {
|
} else if (v.mode === "type") {
|
||||||
tree_types.push(`
|
tree_types.push(`
|
||||||
export const ${k} = null as unknown as ${v.val};
|
export const ${k} = null as unknown as ${v.val};
|
||||||
|
|
@ -178,8 +183,13 @@ export const ${k} = null as unknown as ${v.val};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
register(monaco, tree_usage.join("\n"), "ts:tree_usage.d.ts");
|
|
||||||
register(monaco, tree_types.join("\n"), "ts:tree_types.d.ts");
|
register(monaco, tree_types.join("\n"), "ts:tree_types.d.ts");
|
||||||
|
register(monaco, `\
|
||||||
|
${tree_usage.map(e => e.import).join("\n")}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
${tree_usage.map(e => e.usage).join("\n")}
|
||||||
|
}`, "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");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,26 +44,26 @@ export const EdPropInstanceText: FC<{
|
||||||
dragnum={
|
dragnum={
|
||||||
typeof valnum === "number" && !isNaN(valnum)
|
typeof valnum === "number" && !isNaN(valnum)
|
||||||
? {
|
? {
|
||||||
value: valnum,
|
value: valnum,
|
||||||
onChange(value) {
|
onChange(value) {
|
||||||
local.value = Math.round(value) + "";
|
local.value = Math.round(value) + "";
|
||||||
local.render();
|
local.render();
|
||||||
},
|
},
|
||||||
onChanged(value) {
|
onChanged(value) {
|
||||||
local.value = Math.round(value) + "";
|
local.value = Math.round(value) + "";
|
||||||
local.render();
|
local.render();
|
||||||
|
|
||||||
clearTimeout(local.timeout);
|
clearTimeout(local.timeout);
|
||||||
local.timeout = setTimeout(() => {
|
local.timeout = setTimeout(() => {
|
||||||
mprop.doc?.transact(() => {
|
mprop.doc?.transact(() => {
|
||||||
mprop.set("value", `\`${local.value}\``);
|
mprop.set("value", `\`${local.value}\``);
|
||||||
mprop.set("valueBuilt", `\`${local.value}\``);
|
mprop.set("valueBuilt", `\`${local.value}\``);
|
||||||
});
|
});
|
||||||
treeRebuild(p);
|
treeRebuild(p);
|
||||||
p.render();
|
p.render();
|
||||||
}, 200);
|
}, 1000);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue