fix(javascript): trace wrapped Electron IPC paths in large bundles (#1874)

Co-authored-by: David <17119984+fengdwx@users.noreply.github.com>
This commit is contained in:
DavidandDavid authored and GitHub committed 2026-10-12 09:28:59 +08:00
1 parent d93fbda390
commit 87b9793c53
46 files changed
+3213 -355

No files matched your search

@@ -9,6 +9,85 @@ const resultValue = (body: string) =>
"result",
).returnSites[0]?.value;
describe("bounded paths through dynamic selectors and class origins", () => {
it("bounds linked-list walks through class instances", () => {
const start = performance.now();
const analysis = analyzeJavaScriptSemantics(`
class List { tail = null; }
export function walk() {
const list = new List();
let node = list.tail;
while (node) { use(node.value.parent); node = node.previous; }
return 42;
}
`);
expect(onlyCallable(analysis, "walk").returnSites[0]?.value).toEqual({
status: "literal",
value: 42,
});
expect(performance.now() - start).toBeLessThan(2000);
}, 30000);
it("retains effects through class getter aliases while bounding loop paths", () => {
expect(
resultValue(`
const shared = { value: 1 };
class List { get tail() { return { value: shared }; } }
let node = new List().tail;
while (node) { use(node.value); node = node.previous; }
return shared.value;
`)?.status,
).toBe("unknown");
});
it("bounds dynamic-key setter loops that also create literal containers", () => {
const start = performance.now();
const analysis = analyzeJavaScriptSemantics(`
export function set(root, keys, value) {
let node = root;
for (const [index, key] of keys.entries()) {
if (index === keys.length - 1) { node[key] = value; return root; }
const child = node[key];
if (isObject(child)) { node = child; continue; }
const fresh = isIndex(keys[index + 1]) ? [] : {};
node[key] = fresh;
node = fresh;
}
return root;
}
export function unaffected() { return 42; }
`);
expect(onlyCallable(analysis, "unaffected").returnSites[0]?.value).toEqual({
status: "literal",
value: 42,
});
expect(onlyCallable(analysis, "set").returnSites[0]?.value.status).toBe(
"unknown",
);
expect(performance.now() - start).toBeLessThan(2000);
}, 30000);
it("retains shared-child mutations reached by dynamic-key alias loops", () => {
expect(
resultValue(`
const shared = { value: 1 };
const source = { child: { next: shared }, keep: 3 };
let node = source.child;
while (flag) { node = node[key] || {}; node.value = 2; }
return shared.value;
`)?.status,
).toBe("unknown");
expect(
resultValue(`
const source = { child: { value: 1 }, keep: 3 };
let node = source.child;
while (flag) { node = node[key] || {}; node.value = 2; }
return source.keep;
`),
).toEqual({ status: "literal", value: 3 });
});
});
describe("bounded member path propagation", () => {
it("bounds cyclic member paths with no observed container origin", () => {
const branches = Array.from(