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