wip fix
This commit is contained in:
parent
77a527447c
commit
4d47bafb8e
|
|
@ -62,17 +62,23 @@ export const parseJs = (
|
||||||
attr.value.expression.loc
|
attr.value.expression.loc
|
||||||
) {
|
) {
|
||||||
const loc = attr.value.expression.loc as any;
|
const loc = attr.value.expression.loc as any;
|
||||||
const start = attr.value.expression.properties[0].loc?.start;
|
const start = attr.value.expression.properties[0].loc
|
||||||
const end =
|
?.start as any;
|
||||||
attr.value.expression.properties[
|
const end = attr.value.expression.properties[
|
||||||
attr.value.expression.properties.length - 1
|
attr.value.expression.properties.length - 1
|
||||||
].loc?.end;
|
].loc?.end as any;
|
||||||
|
|
||||||
if (typeof start === "number" && typeof end === "number") {
|
if (
|
||||||
local.value = code.substring(
|
typeof start === "number" &&
|
||||||
loc.start.index,
|
typeof end === "number" &&
|
||||||
loc.end.index
|
typeof loc.start.index === "number"
|
||||||
);
|
) {
|
||||||
|
local.value = code.substring(start, end);
|
||||||
|
local.index = loc.start.index;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof start === "object" && typeof end === "object") {
|
||||||
|
local.value = `{${code.substring(start.index, end.index)}}`;
|
||||||
local.index = loc.start.index;
|
local.index = loc.start.index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ export const getMRoot = (p: PG) => {
|
||||||
export const getMetaById = (p: PG, id: string) => {
|
export const getMetaById = (p: PG, id: string) => {
|
||||||
if (active.comp_id) {
|
if (active.comp_id) {
|
||||||
if (p.comp.list[active.comp_id])
|
if (p.comp.list[active.comp_id])
|
||||||
return p.comp.list[active.comp_id].meta[active.item_id];
|
return p.comp.list[active.comp_id].meta[id];
|
||||||
} else {
|
} else {
|
||||||
return p.page.meta[id];
|
return p.page.meta[id];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -172,9 +172,7 @@ export const syncWalkMap = (
|
||||||
}
|
}
|
||||||
|
|
||||||
const old_id = item.id;
|
const old_id = item.id;
|
||||||
|
|
||||||
mapItem(mcomp, item, ref_ids);
|
mapItem(mcomp, item, ref_ids);
|
||||||
item.originalId = item.id;
|
|
||||||
item.id = old_id;
|
item.id = old_id;
|
||||||
|
|
||||||
const meta: EdMeta = {
|
const meta: EdMeta = {
|
||||||
|
|
@ -361,7 +359,7 @@ const mapItem = (
|
||||||
val = e.toJSON() as any;
|
val = e.toJSON() as any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
item[k] = val;
|
if (k !== "originalId") item[k] = val;
|
||||||
} else {
|
} else {
|
||||||
item[k] = [];
|
item[k] = [];
|
||||||
const childs = e as unknown as TypedArray<{}>;
|
const childs = e as unknown as TypedArray<{}>;
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ export const declareScope = async (
|
||||||
delete e.s.s.props[e.name];
|
delete e.s.s.props[e.name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
existing[name] = arg;
|
existing[name] = arg;
|
||||||
});
|
});
|
||||||
spreadScope(p, s, (arg) => {
|
spreadScope(p, s, (arg) => {
|
||||||
|
|
@ -125,7 +126,8 @@ const spreadScope = (
|
||||||
arg: { prev?: { comp_id: string; item_id: string } }
|
arg: { prev?: { comp_id: string; item_id: string } }
|
||||||
) => {
|
) => {
|
||||||
let { prev } = arg;
|
let { prev } = arg;
|
||||||
for (const parent_id of parents) {
|
for (const _parent_id of parents) {
|
||||||
|
let parent_id = _parent_id;
|
||||||
if (parent_id === "root") continue;
|
if (parent_id === "root") continue;
|
||||||
let item = null as null | ISingleScope;
|
let item = null as null | ISingleScope;
|
||||||
const meta = p.page.meta[parent_id];
|
const meta = p.page.meta[parent_id];
|
||||||
|
|
@ -145,6 +147,9 @@ const spreadScope = (
|
||||||
if (comp_id) {
|
if (comp_id) {
|
||||||
const scope = p.comp.list[comp_id].scope;
|
const scope = p.comp.list[comp_id].scope;
|
||||||
item = scope[meta.item.originalId || meta.item.id];
|
item = scope[meta.item.originalId || meta.item.id];
|
||||||
|
if (item) {
|
||||||
|
parent_id = meta.item.originalId || meta.item.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,6 +161,7 @@ const spreadScope = (
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
const scope = item.s;
|
const scope = item.s;
|
||||||
|
|
||||||
if (scope) {
|
if (scope) {
|
||||||
if (scope.local)
|
if (scope.local)
|
||||||
each({
|
each({
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,11 @@ export const expandTreeHook = (
|
||||||
if (cur && cur.parent_item) {
|
if (cur && cur.parent_item) {
|
||||||
const id = cur.parent_item.mitem?.get("id");
|
const id = cur.parent_item.mitem?.get("id");
|
||||||
if (id) {
|
if (id) {
|
||||||
|
shouldOpen.add(id);
|
||||||
|
|
||||||
let meta: EdMeta | undefined = getMetaById(p, id);
|
let meta: EdMeta | undefined = getMetaById(p, id);
|
||||||
while (meta) {
|
while (meta) {
|
||||||
const id = cur.parent_item.mitem?.get("id");
|
const id = meta.parent_item.id;
|
||||||
if (id && !shouldOpen.has(id)) {
|
if (id && !shouldOpen.has(id)) {
|
||||||
shouldOpen.add(id);
|
shouldOpen.add(id);
|
||||||
meta = getMetaById(p, id);
|
meta = getMetaById(p, id);
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ export const EdTreeName = ({
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<Name name={node.text} is_jsx_prop={is_jsx_prop} />
|
<Name name={node.text} is_jsx_prop={is_jsx_prop} />
|
||||||
{/* <div className={"text-[9px] text-gray-500 -mt-1"}>{node.id} - {item.originalId}</div> */}
|
<div className={"text-[9px] text-gray-500 -mt-1"}>{node.id} - {item.originalId}</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ import { createPassProp } from "./script/create-pass-prop";
|
||||||
import { ErrorBox } from "./script/error-box";
|
import { ErrorBox } from "./script/error-box";
|
||||||
import { mergeScopeUpwards } from "./script/merge-upward";
|
import { mergeScopeUpwards } from "./script/merge-upward";
|
||||||
|
|
||||||
|
const renderLimitConfig = {
|
||||||
|
maxCount: 30,
|
||||||
|
maxTime: 10,
|
||||||
|
};
|
||||||
const renderLimit = {} as Record<
|
const renderLimit = {} as Record<
|
||||||
string,
|
string,
|
||||||
Record<string, { ts: number; count: number; cache: ReactNode }>
|
Record<string, { ts: number; count: number; cache: ReactNode }>
|
||||||
|
|
@ -71,18 +75,25 @@ export const ViewMetaScript: FC<{
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.abs(renderLimit[v.current.page_id][item.id].ts - Date.now()) < 100) {
|
if (
|
||||||
|
Math.abs(renderLimit[v.current.page_id][item.id].ts - Date.now()) <
|
||||||
|
renderLimitConfig.maxTime
|
||||||
|
) {
|
||||||
renderLimit[v.current.page_id][item.id].count++;
|
renderLimit[v.current.page_id][item.id].count++;
|
||||||
|
|
||||||
if (renderLimit[v.current.page_id][item.id].count > 100) {
|
if (
|
||||||
|
renderLimit[v.current.page_id][item.id].count > renderLimitConfig.maxCount
|
||||||
|
) {
|
||||||
let js = "";
|
let js = "";
|
||||||
if (typeof item.adv?.js === "string") {
|
if (typeof item.adv?.js === "string") {
|
||||||
js = item.adv.js;
|
js = item.adv.js;
|
||||||
}
|
}
|
||||||
console.warn(
|
console.warn(
|
||||||
`Maximum render limit (100 render in 100ms) reached in item [${
|
`Maximum render limit (${renderLimitConfig.maxCount} render in ${
|
||||||
item.name
|
renderLimitConfig.maxTime
|
||||||
}]:\n${js.length > 30 ? js.substring(0, 30) + "..." : js}`
|
}ms) reached in item [${item.name}]:\n${
|
||||||
|
js.length > 30 ? js.substring(0, 30) + "..." : js
|
||||||
|
}`
|
||||||
);
|
);
|
||||||
return renderLimit[v.current.page_id][item.id].cache;
|
return renderLimit[v.current.page_id][item.id].cache;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ export const jsMount = async (editor: MonacoEditor, monaco: Monaco, p?: PG) => {
|
||||||
let meta = p.page.meta[id];
|
let meta = p.page.meta[id];
|
||||||
if (active.comp_id) {
|
if (active.comp_id) {
|
||||||
meta = p.comp.list[active.comp_id].meta[id];
|
meta = p.comp.list[active.comp_id].meta[id];
|
||||||
|
if (!meta) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
active.instance.comp_id = active.comp_id;
|
active.instance.comp_id = active.comp_id;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue