rerender-lens 0.4.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +127 -0
- package/README.md +208 -359
- package/dist/{budget-LkNjGtRc.d.ts → budget-CA1MS7lB.d.cts} +20 -10
- package/dist/{budget-COBu7jBU.d.cts → budget-ok1VDJ4t.d.ts} +20 -10
- package/dist/cli.cjs +322 -53
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +322 -53
- package/dist/cli.js.map +1 -1
- package/dist/{devtools-BkCct3cJ.d.cts → devtools-Cl5n_52v.d.ts} +17 -2
- package/dist/{devtools-CZebzpF6.d.ts → devtools-UwQx2VYS.d.cts} +17 -2
- package/dist/index.cjs +537 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +137 -8
- package/dist/index.d.ts +137 -8
- package/dist/index.js +521 -50
- package/dist/index.js.map +1 -1
- package/dist/jest-setup.cjs +1690 -0
- package/dist/jest-setup.cjs.map +1 -0
- package/dist/jest-setup.d.cts +8 -0
- package/dist/jest-setup.d.ts +8 -0
- package/dist/jest-setup.js +1688 -0
- package/dist/jest-setup.js.map +1 -0
- package/dist/jest.cjs +1777 -0
- package/dist/jest.cjs.map +1 -0
- package/dist/jest.d.cts +23 -0
- package/dist/jest.d.ts +23 -0
- package/dist/jest.js +1768 -0
- package/dist/jest.js.map +1 -0
- package/dist/{notifiers-BjjGSHpp.d.ts → notifiers-B5poAEvE.d.cts} +8 -4
- package/dist/{notifiers-BGQtWKfX.d.cts → notifiers-CqQW0Eum.d.ts} +8 -4
- package/dist/playwright.cjs +230 -28
- package/dist/playwright.cjs.map +1 -1
- package/dist/playwright.d.cts +4 -4
- package/dist/playwright.d.ts +4 -4
- package/dist/playwright.js +230 -28
- package/dist/playwright.js.map +1 -1
- package/dist/relay.cjs +71 -19
- package/dist/relay.cjs.map +1 -1
- package/dist/relay.d.cts +25 -3
- package/dist/relay.d.ts +25 -3
- package/dist/relay.js +71 -19
- package/dist/relay.js.map +1 -1
- package/dist/rerender-lens.iife.js +457 -62
- package/dist/runner-report-Bvqoe89M.d.ts +46 -0
- package/dist/runner-report-CvpDg2zt.d.cts +46 -0
- package/dist/setup.cjs +209 -35
- package/dist/setup.cjs.map +1 -1
- package/dist/setup.js +209 -35
- package/dist/setup.js.map +1 -1
- package/dist/{types-BzUEVkxJ.d.cts → types-DwNN5cWe.d.cts} +82 -2
- package/dist/{types-BzUEVkxJ.d.ts → types-DwNN5cWe.d.ts} +82 -2
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vitest-setup.cjs +357 -44
- package/dist/vitest-setup.cjs.map +1 -1
- package/dist/vitest-setup.d.cts +4 -4
- package/dist/vitest-setup.d.ts +4 -4
- package/dist/vitest-setup.js +357 -44
- package/dist/vitest-setup.js.map +1 -1
- package/dist/vitest.cjs +420 -80
- package/dist/vitest.cjs.map +1 -1
- package/dist/vitest.d.cts +21 -39
- package/dist/vitest.d.ts +21 -39
- package/dist/vitest.js +421 -81
- package/dist/vitest.js.map +1 -1
- package/package.json +41 -4
- package/panel/panel.css +49 -0
- package/panel/panel.js +871 -353
package/dist/playwright.cjs
CHANGED
|
@@ -8,50 +8,206 @@ var url = require('url');
|
|
|
8
8
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
9
9
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
10
10
|
|
|
11
|
-
// src/
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
// src/diff.ts
|
|
12
|
+
var AVOIDABLE_KINDS = /* @__PURE__ */ new Set(["deep-equal", "function", "element"]);
|
|
13
|
+
|
|
14
|
+
// src/causes.ts
|
|
15
|
+
var isAncestorReport = (anc, r) => anc.path.length < r.path.length && r.path[anc.path.length] === anc.component && anc.path.every((p, i) => r.path[i] === p);
|
|
16
|
+
var bump = (m, key, n = 1) => void m.set(key, (m.get(key) || 0) + n);
|
|
17
|
+
function indexByComponent(reports) {
|
|
18
|
+
const index = /* @__PURE__ */ new Map();
|
|
19
|
+
for (const r of reports) {
|
|
20
|
+
const list = index.get(r.component);
|
|
21
|
+
if (list) list.push(r);
|
|
22
|
+
else index.set(r.component, [r]);
|
|
23
|
+
}
|
|
24
|
+
return index;
|
|
25
|
+
}
|
|
26
|
+
function rootCauseOf(r, commitReports, index = indexByComponent(commitReports)) {
|
|
27
|
+
let cur = r;
|
|
28
|
+
const seen = /* @__PURE__ */ new Set([r]);
|
|
29
|
+
while (cur.trigger === "parent" && cur.parent) {
|
|
30
|
+
const parent = cur.parent;
|
|
31
|
+
const candidates = index.get(parent.name);
|
|
32
|
+
const p = candidates && candidates.find((x) => isAncestorReport(x, cur));
|
|
33
|
+
if (!p || seen.has(p)) return { name: parent.name, trigger: parent.trigger, report: null };
|
|
34
|
+
seen.add(p);
|
|
35
|
+
cur = p;
|
|
36
|
+
}
|
|
37
|
+
return cur === r ? null : { name: cur.component, trigger: cur.trigger, report: cur };
|
|
38
|
+
}
|
|
39
|
+
function rootCausesOf(reports) {
|
|
40
|
+
const roots = /* @__PURE__ */ new Map();
|
|
41
|
+
const rootByReport = /* @__PURE__ */ new Map();
|
|
42
|
+
const index = indexByComponent(reports);
|
|
43
|
+
let avoidable = 0;
|
|
44
|
+
let wasted = 0;
|
|
45
|
+
for (const r of reports) {
|
|
46
|
+
if (!r.avoidable) continue;
|
|
47
|
+
avoidable++;
|
|
48
|
+
if (typeof r.selfDuration === "number") wasted += r.selfDuration;
|
|
49
|
+
const root = rootCauseOf(r, reports, index);
|
|
50
|
+
const name = root ? root.name : r.parent && r.parent.name || "(unknown)";
|
|
51
|
+
const trigger = root ? root.trigger : r.parent && r.parent.trigger || "parent";
|
|
52
|
+
rootByReport.set(r, name);
|
|
53
|
+
let agg = roots.get(name);
|
|
54
|
+
if (!agg) {
|
|
55
|
+
agg = { name, trigger, count: 0, components: /* @__PURE__ */ new Map() };
|
|
56
|
+
roots.set(name, agg);
|
|
57
|
+
}
|
|
58
|
+
agg.count++;
|
|
59
|
+
bump(agg.components, r.component);
|
|
60
|
+
}
|
|
61
|
+
return { roots: [...roots.values()].sort((a, b) => b.count - a.count), rootByReport, avoidable, wasted };
|
|
62
|
+
}
|
|
63
|
+
function groupByCommit(reports) {
|
|
64
|
+
const out = /* @__PURE__ */ new Map();
|
|
65
|
+
for (const r of reports) {
|
|
66
|
+
if (typeof r.commitId !== "number" || r.commitId <= 0) continue;
|
|
67
|
+
const list = out.get(r.commitId);
|
|
68
|
+
if (list) list.push(r);
|
|
69
|
+
else out.set(r.commitId, [r]);
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
function rankRootCauses(reports) {
|
|
74
|
+
const byName = /* @__PURE__ */ new Map();
|
|
75
|
+
for (const commit of groupByCommit(reports).values()) {
|
|
76
|
+
for (const root of rootCausesOf(commit).roots) {
|
|
77
|
+
let agg = byName.get(root.name);
|
|
78
|
+
if (!agg) {
|
|
79
|
+
agg = { name: root.name, trigger: root.trigger, commits: 0, count: 0, components: /* @__PURE__ */ new Map() };
|
|
80
|
+
byName.set(root.name, agg);
|
|
81
|
+
}
|
|
82
|
+
agg.commits++;
|
|
83
|
+
agg.count += root.count;
|
|
84
|
+
for (const [c, n] of root.components) bump(agg.components, c, n);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return [...byName.values()].sort((a, b) => b.count - a.count || b.commits - a.commits || a.name.localeCompare(b.name));
|
|
88
|
+
}
|
|
89
|
+
var plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
90
|
+
function formatRootCauses(reports, limit = 5) {
|
|
91
|
+
const ranked = rankRootCauses(reports);
|
|
92
|
+
const lines = ranked.slice(0, limit).map((root, i) => `${String(i + 1).padStart(2)}. <${root.name}> (${root.trigger}) started ${plural(root.commits, "commit")}, ${plural(root.count, "avoidable re-render")} (${[...root.components].map(([c, n]) => `<${c}>${n > 1 ? " x" + n : ""}`).join(", ")})`);
|
|
93
|
+
if (ranked.length > limit) lines.push(` \u2026 ${ranked.length - limit} more`);
|
|
94
|
+
return lines.join("\n");
|
|
21
95
|
}
|
|
22
96
|
|
|
23
97
|
// src/fixes.ts
|
|
24
|
-
var
|
|
98
|
+
var MAX_FIX_REPORTS = 50;
|
|
25
99
|
var rootOf = (path) => path.split(/[.[]/)[0] || path;
|
|
100
|
+
var identifier = (name) => /^[A-Za-z_$][\w$]*$/.test(name) ? name : "value";
|
|
101
|
+
function shortValue(v, max = 60) {
|
|
102
|
+
let s;
|
|
103
|
+
try {
|
|
104
|
+
s = JSON.stringify(v);
|
|
105
|
+
} catch {
|
|
106
|
+
s = String(v);
|
|
107
|
+
}
|
|
108
|
+
if (s === void 0) s = String(v);
|
|
109
|
+
return s.length > max ? s.slice(0, max - 3) + "..." : s;
|
|
110
|
+
}
|
|
26
111
|
function fixesFor(r) {
|
|
27
112
|
const out = [];
|
|
28
|
-
const
|
|
29
|
-
const
|
|
113
|
+
const ownerName = r.owner || r.parent && r.parent.name || null;
|
|
114
|
+
const propChanges = r.propChanges || [];
|
|
115
|
+
const changes = [...propChanges, ...r.stateChanges || [], ...r.hookChanges || []];
|
|
30
116
|
if (r.avoidable && (changes.length === 0 || r.memoized === false)) {
|
|
117
|
+
const identical = changes.length === 0;
|
|
31
118
|
out.push({
|
|
32
119
|
kind: "memo",
|
|
33
120
|
owner: r.component,
|
|
34
121
|
target: r.component,
|
|
35
122
|
prop: null,
|
|
36
123
|
label: `Wrap <${r.component}> in React.memo`,
|
|
37
|
-
detail:
|
|
124
|
+
detail: identical ? `<${r.component}> re-rendered with identical props because <${r.parent && r.parent.name || "its parent"}> re-rendered.` : `<${r.component}> is not memoized: fixing its props alone will not stop the re-render.`,
|
|
125
|
+
snippet: `// ${r.component}
|
|
126
|
+
import { memo } from 'react';
|
|
127
|
+
|
|
128
|
+
export const ${r.component} = memo(function ${r.component}(props) {
|
|
129
|
+
// ...
|
|
130
|
+
});
|
|
131
|
+
// class components: extend PureComponent instead`
|
|
38
132
|
});
|
|
39
133
|
}
|
|
40
|
-
for (const c of
|
|
41
|
-
if (!
|
|
134
|
+
for (const c of propChanges) {
|
|
135
|
+
if (!AVOIDABLE_KINDS.has(c.kind)) continue;
|
|
136
|
+
const owner = ownerName || "?";
|
|
42
137
|
const root = rootOf(c.path);
|
|
138
|
+
const id = identifier(root);
|
|
43
139
|
if (root === "children" && (c.kind === "element" || c.kind === "deep-equal")) {
|
|
44
|
-
out.push({
|
|
140
|
+
out.push({
|
|
141
|
+
kind: "children",
|
|
142
|
+
owner,
|
|
143
|
+
target: r.component,
|
|
144
|
+
prop: "children",
|
|
145
|
+
label: `memoize children of <${r.component}> in <${owner}>`,
|
|
146
|
+
detail: `<${owner}> re-creates the children of <${r.component}> on every render; they have the same types and props each time.`,
|
|
147
|
+
snippet: `// ${owner}
|
|
148
|
+
import { useMemo } from 'react';
|
|
149
|
+
|
|
150
|
+
const children = useMemo(() => (
|
|
151
|
+
<>{/* the same elements */}</>
|
|
152
|
+
), [/* deps */]);
|
|
153
|
+
|
|
154
|
+
<${r.component}>{children}</${r.component}>
|
|
155
|
+
|
|
156
|
+
// static children: hoist them to module scope
|
|
157
|
+
const STATIC = <em>hi</em>;`
|
|
158
|
+
});
|
|
45
159
|
} else if (c.kind === "function") {
|
|
46
|
-
out.push({
|
|
160
|
+
out.push({
|
|
161
|
+
kind: "useCallback",
|
|
162
|
+
owner,
|
|
163
|
+
target: r.component,
|
|
164
|
+
prop: root,
|
|
165
|
+
label: `useCallback(${root}) in <${owner}>`,
|
|
166
|
+
detail: `prop "${c.path}" of <${r.component}> is a new function on every render of <${owner}>.`,
|
|
167
|
+
snippet: `// ${owner}
|
|
168
|
+
import { useCallback } from 'react';
|
|
169
|
+
|
|
170
|
+
const ${id} = useCallback((/* args */) => {
|
|
171
|
+
// ...
|
|
172
|
+
}, [/* deps */]);
|
|
173
|
+
|
|
174
|
+
<${r.component} ${root}={${id}} />`
|
|
175
|
+
});
|
|
47
176
|
} else if (c.kind === "element") {
|
|
48
|
-
out.push({
|
|
177
|
+
out.push({
|
|
178
|
+
kind: "useMemoElement",
|
|
179
|
+
owner,
|
|
180
|
+
target: r.component,
|
|
181
|
+
prop: root,
|
|
182
|
+
label: `memoize element prop ${root} in <${owner}>`,
|
|
183
|
+
detail: `prop "${c.path}" of <${r.component}> is a new element with the same type and props on every render of <${owner}>.`,
|
|
184
|
+
snippet: `// ${owner}
|
|
185
|
+
import { useMemo } from 'react';
|
|
186
|
+
|
|
187
|
+
const ${id} = useMemo(() => ${shortValue(c.next, 40)}, [/* deps */]);
|
|
188
|
+
// or pass it as children from a component that does not re-render`
|
|
189
|
+
});
|
|
49
190
|
} else {
|
|
50
|
-
|
|
191
|
+
const isArray = Array.isArray(c.next);
|
|
192
|
+
out.push({
|
|
193
|
+
kind: "useMemo",
|
|
194
|
+
owner,
|
|
195
|
+
target: r.component,
|
|
196
|
+
prop: root,
|
|
197
|
+
label: `useMemo(${root}) in <${owner}>`,
|
|
198
|
+
detail: `prop "${c.path}" of <${r.component}> is a new ${isArray ? "array" : "object"} with the same contents on every render of <${owner}>.`,
|
|
199
|
+
snippet: `// ${owner}
|
|
200
|
+
import { useMemo } from 'react';
|
|
201
|
+
|
|
202
|
+
const ${id} = useMemo(() => (${shortValue(c.next, 80)}), [/* deps */]);
|
|
203
|
+
|
|
204
|
+
// or, when it never changes, hoist it to module scope:
|
|
205
|
+
const ${id.toUpperCase()} = ${shortValue(c.next, 80)};`
|
|
206
|
+
});
|
|
51
207
|
}
|
|
52
208
|
}
|
|
53
|
-
for (const c of [...r.stateChanges, ...r.hookChanges]) {
|
|
54
|
-
const isContext = c.hook === "useContext";
|
|
209
|
+
for (const c of [...r.stateChanges || [], ...r.hookChanges || []]) {
|
|
210
|
+
const isContext = c.hook === "useContext" || /^useContext/.test(c.path);
|
|
55
211
|
const ctxName = isContext ? (/useContext\((.*)\)/.exec(c.path) || [])[1] || "Context" : "";
|
|
56
212
|
const providerOwner = isContext && c.provider && c.provider.component ? c.provider.component : null;
|
|
57
213
|
if (isContext && c.kind === "different" && c.changedKeys && typeof c.totalKeys === "number" && c.changedKeys.length > 0 && c.changedKeys.length < c.totalKeys) {
|
|
@@ -61,20 +217,63 @@ function fixesFor(r) {
|
|
|
61
217
|
target: r.component,
|
|
62
218
|
prop: ctxName,
|
|
63
219
|
label: `split ${ctxName}${providerOwner ? ` in <${providerOwner}>` : ""}: only ${c.changedKeys.join(", ")} changed`,
|
|
64
|
-
detail: `${c.changedKeys.
|
|
220
|
+
detail: `${c.changedKeys.map((k) => `"${k}"`).join(", ")} of ${c.totalKeys} keys changed in ${ctxName}, yet every consumer (like <${r.component}>) re-rendered. Consumers that read the other keys re-render for nothing.`,
|
|
221
|
+
snippet: `// ${providerOwner || "Provider"}
|
|
222
|
+
// one context per independently-changing slice
|
|
223
|
+
const ${identifier(ctxName)}Static = createContext(...);
|
|
224
|
+
const ${identifier(ctxName)}${c.changedKeys.map((k) => k[0].toUpperCase() + k.slice(1)).join("")} = createContext(...);
|
|
225
|
+
|
|
226
|
+
// or keep one context and let consumers select a slice:
|
|
227
|
+
const ${c.changedKeys[0]} = useContextSelector(${ctxName}, (v) => v.${c.changedKeys[0]});`
|
|
65
228
|
});
|
|
66
229
|
continue;
|
|
67
230
|
}
|
|
68
|
-
if (!
|
|
231
|
+
if (!AVOIDABLE_KINDS.has(c.kind)) continue;
|
|
69
232
|
if (isContext) {
|
|
70
|
-
out.push({
|
|
233
|
+
out.push({
|
|
234
|
+
kind: "contextValue",
|
|
235
|
+
owner: providerOwner || `${ctxName}.Provider`,
|
|
236
|
+
target: r.component,
|
|
237
|
+
prop: ctxName,
|
|
238
|
+
label: `memoize the ${ctxName} provider value${providerOwner ? ` in <${providerOwner}>` : ""}`,
|
|
239
|
+
detail: `<${r.component}> re-rendered because ${ctxName} produced a new value that is deep-equal to the previous one${providerOwner ? ` (Provider rendered by <${providerOwner}>)` : ""}.`,
|
|
240
|
+
snippet: `// ${providerOwner || `where <${ctxName}.Provider> is rendered`}
|
|
241
|
+
const value = useMemo(() => ({ /* ... */ }), [/* deps */]);
|
|
242
|
+
<${ctxName}.Provider value={value}>`
|
|
243
|
+
});
|
|
71
244
|
} else if (c.hook === "useSyncExternalStore") {
|
|
72
245
|
const chain = c.custom || [];
|
|
73
246
|
const redux = chain.some((n) => /^use(App)?Selector$/.test(n));
|
|
74
247
|
const zustand = !redux && chain.some((n) => /^use[A-Z]\w*Store$/.test(n) || n === "useStore" || n === "useBoundStore");
|
|
75
|
-
|
|
248
|
+
const via = chain.length ? ` via ${chain.join(" \u203A ")}` : "";
|
|
249
|
+
out.push({
|
|
250
|
+
kind: "storeSnapshot",
|
|
251
|
+
owner: r.component,
|
|
252
|
+
target: r.component,
|
|
253
|
+
prop: c.path,
|
|
254
|
+
label: redux ? `memoize the selector in <${r.component}>` : zustand ? `useShallow in <${r.component}>` : `stable getSnapshot in <${r.component}>`,
|
|
255
|
+
detail: redux ? `the selector${via} returns a new object on every call, so the component re-renders on every store change.` : zustand ? `the store selector${via} returns a new object on every call, so the component re-renders on every store change.` : `${c.path}${via} returned a new reference with the same contents; getSnapshot must return a cached value.`,
|
|
256
|
+
snippet: redux ? `// ${r.component}
|
|
257
|
+
import { shallowEqual } from 'react-redux';
|
|
258
|
+
const slice = useSelector(selectSlice, shallowEqual);
|
|
259
|
+
// or memoize: const selectSlice = createSelector([selectA, selectB], (a, b) => ({ a, b }));` : zustand ? `// ${r.component}
|
|
260
|
+
import { useShallow } from 'zustand/react/shallow';
|
|
261
|
+
const { a, b } = useStore(useShallow((s) => ({ a: s.a, b: s.b })));
|
|
262
|
+
// or select a primitive: const a = useStore((s) => s.a);` : `// ${r.component}
|
|
263
|
+
// getSnapshot must return the same reference while the data is unchanged
|
|
264
|
+
const snapshot = useSyncExternalStore(subscribe, store.getSnapshot /* cached */);`
|
|
265
|
+
});
|
|
76
266
|
} else {
|
|
77
|
-
out.push({
|
|
267
|
+
out.push({
|
|
268
|
+
kind: "bailout",
|
|
269
|
+
owner: r.component,
|
|
270
|
+
target: r.component,
|
|
271
|
+
prop: c.path,
|
|
272
|
+
label: `bail out before setting ${c.path} in <${r.component}>`,
|
|
273
|
+
detail: `${c.path} was set to a value deep-equal to the current one (new reference).`,
|
|
274
|
+
snippet: `// ${r.component}
|
|
275
|
+
setState((prev) => (deepEqual(prev, next) ? prev : next));`
|
|
276
|
+
});
|
|
78
277
|
}
|
|
79
278
|
}
|
|
80
279
|
return out;
|
|
@@ -88,11 +287,12 @@ function rankFixes(reports) {
|
|
|
88
287
|
const key = fixKey(f);
|
|
89
288
|
let agg = byKey.get(key);
|
|
90
289
|
if (!agg) {
|
|
91
|
-
agg = { ...f, key, count: 0, components: {} };
|
|
290
|
+
agg = { ...f, key, count: 0, components: {}, reports: [] };
|
|
92
291
|
byKey.set(key, agg);
|
|
93
292
|
}
|
|
94
293
|
agg.count++;
|
|
95
294
|
agg.components[r.component] = (agg.components[r.component] || 0) + 1;
|
|
295
|
+
if (agg.reports.length < MAX_FIX_REPORTS) agg.reports.push(r);
|
|
96
296
|
}
|
|
97
297
|
}
|
|
98
298
|
return [...byKey.values()].sort((a, b) => b.count - a.count || a.label.localeCompare(b.label));
|
|
@@ -102,6 +302,8 @@ function formatFixes(reports, limit = 10) {
|
|
|
102
302
|
if (!ranked.length) return "No avoidable re-renders.";
|
|
103
303
|
const lines = ranked.slice(0, limit).map((f, i) => `${String(i + 1).padStart(2)}. ${f.label} (removes ${f.count}: ${Object.entries(f.components).map(([c, n]) => `<${c}>${n > 1 ? " x" + n : ""}`).join(", ")})`);
|
|
104
304
|
if (ranked.length > limit) lines.push(` \u2026 ${ranked.length - limit} more`);
|
|
305
|
+
const roots = formatRootCauses(reports, 5);
|
|
306
|
+
if (roots) lines.push("", "Root causes:", roots);
|
|
105
307
|
return lines.join("\n");
|
|
106
308
|
}
|
|
107
309
|
|
package/dist/playwright.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../node_modules/tsup/assets/cjs_shims.js","../src/report.ts","../src/fixes.ts","../src/budget.ts","../src/playwright.ts"],"names":["dirname","fileURLToPath","join","readFileSync"],"mappings":";;;;;;;AAKA,IAAM,gBAAA,GAAmB,MACvB,OAAO,QAAA,KAAa,WAAA,GAChB,IAAI,GAAA,CAAI,CAAA,KAAA,EAAQ,UAAU,CAAA,CAAE,CAAA,CAAE,IAAA,GAC7B,QAAA,CAAS,aAAA,IAAiB,QAAA,CAAS,aAAA,CAAc,OAAA,CAAQ,WAAA,EAAY,KAAM,QAAA,GAC1E,QAAA,CAAS,aAAA,CAAc,GAAA,GACvB,IAAI,GAAA,CAAI,SAAA,EAAW,QAAA,CAAS,OAAO,CAAA,CAAE,IAAA;AAEtC,IAAM,gCAAgC,gBAAA,EAAiB;;;AC0BvD,SAAS,YAAY,MAAA,EAAsC;AAChE,EAAA,MAAM,KAAA,GAAQ,UAAU,EAAC;AACzB,EAAA,IAAI,MAAM,IAAA,CAAK,CAAC,MAAM,eAAA,CAAgB,IAAA,CAAK,CAAC,CAAC,CAAA;AAC3C,IAAA,OAAO,6JAAA;AACT,EAAA,IAAI,MAAM,IAAA,CAAK,CAAC,MAAM,kBAAA,CAAmB,IAAA,CAAK,CAAC,CAAC,CAAA;AAC9C,IAAA,OAAO,8HAAA;AACT,EAAA,IAAI,KAAA,CAAM,IAAA,CAAK,CAAC,CAAA,KAAM,oBAAA,CAAqB,IAAA,CAAK,CAAC,CAAA,IAAK,CAAA,KAAM,UAAA,IAAc,CAAA,KAAM,eAAe,CAAA;AAC7F,IAAA,OAAO,kJAAA;AACT,EAAA,OAAO,oJAAA;AACT;;;ACnBA,IAAM,4BAAY,IAAI,GAAA,CAAY,CAAC,YAAA,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,IAAA,EAAM,GAAG,IAAA,EAAK;AAC7E,EAAA,OAAO,CAAA,EAAG,MAAA,IAAU,aAAA,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA,UAAA,EAA2I,IAAA,CAAK,SAAA,CAAU,IAAI,CAAC,CAAA;AAAA,wCAAA,EAA8C,QAAQ,IAAA,CAAK,SAAA,CAAU,EAAE,KAAA,EAAO,IAAI,IAAI,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAA,CAAA;AAC1R;AAGA,eAAsB,mBAAA,CAAoB,IAAA,EAAgB,OAAA,GAA0B,EAAC,EAAkB;AACrG,EAAA,MAAM,KAAK,aAAA,CAAc,EAAE,SAAS,aAAA,CAAc,OAAO,GAAG,CAAA;AAC9D;AAGA,eAAsB,YAAY,IAAA,EAAyC;AACzE,EAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,QAAA,CAAwC,yFAAyF,CAAA;AAC3J,EAAA,IAAI,CAAC,MAAA,EAAQ,MAAM,IAAI,MAAM,2FAA2F,CAAA;AACxH,EAAA,OAAO,MAAA,CAAO,OAAA;AAChB;AAGA,eAAsB,aAAa,IAAA,EAA+B;AAChE,EAAA,MAAM,IAAA,CAAK,SAAS,yEAAyE,CAAA;AAC/F;AAMO,SAAS,kBAAA,CAAmB,SAAyB,MAAA,EAAuC;AACjG,EAAA,OAAO,kBAAA,CAAmB,SAAS,MAAM,CAAA;AAC3C","file":"playwright.cjs","sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import type { Change, CommitCause, CommitPriority, HookChange, HookSnapshot, Options, ParentInfo, RenderReport, RenderTrigger, SourceLocation } from './types';\n\nconst now = (): number =>\n typeof performance !== 'undefined' && typeof performance.now === 'function' ? performance.now() : Date.now();\n\nexport interface BuildInput {\n component: string;\n instanceId?: number;\n renderCount: number;\n prevProps: Record<string, unknown>;\n nextProps: Record<string, unknown>;\n propChanges: Change[];\n stateChanges?: Change[];\n hookChanges?: HookChange[];\n hookState?: HookSnapshot[];\n contexts?: { name: string; value: unknown }[];\n state?: Record<string, unknown>;\n parent?: ParentInfo | null;\n owner?: string | null;\n path?: string[];\n /** Default true: `useWhyRerender` and the console output assume the component decides on props alone. */\n memoized?: boolean;\n selfDuration?: number;\n treeDuration?: number;\n commitId?: number;\n commitPriority?: CommitPriority;\n source?: SourceLocation;\n updaters?: string[];\n commitCause?: CommitCause;\n afterCommit?: number;\n key?: string | null;\n}\n\n/** `useCart › useState#0` when custom hook names are known, else `useState #0`. */\nexport const hookLabel = (c: { hook: string; index: number; custom?: string[] }): string =>\n c.custom && c.custom.length ? `${c.custom.join(' › ')} › ${c.hook}#${c.index}` : `${c.hook} #${c.index}`;\n\n/** Store-specific advice for a `useSyncExternalStore` snapshot that is a new reference with equal contents. */\nexport function storeAdvice(custom: string[] | undefined): string {\n const chain = custom ?? [];\n if (chain.some((n) => /^useSelector$/.test(n)))\n return 'the Redux selector returns a new object on every call: return a stored slice, pass shallowEqual as the equality function, or memoize it with createSelector';\n if (chain.some((n) => /^useAppSelector$/.test(n)))\n return 'the selector returns a new object on every call: return a stored slice, pass shallowEqual, or memoize it with createSelector';\n if (chain.some((n) => /^use[A-Z]\\w*Store$/.test(n) || n === 'useStore' || n === 'useBoundStore'))\n return 'the store selector returns a new object on every call: select a primitive, or wrap the selector with useShallow (Zustand) / an equality function';\n return 'getSnapshot returns a new reference with the same contents: cache the snapshot in the store and return the same object while the data is unchanged';\n}\n\nconst isGenuine = (c: Change): boolean => c.kind === 'different' || c.kind === 'added' || c.kind === 'removed';\n\n/** `children` re-created in the parent's render: the classic memo-defeater, with its own advice. */\nconst isChildren = (change: Change): boolean => change.path === 'children';\n\nexport function fixFor(change: Change): string {\n if (isChildren(change) && (change.kind === 'element' || change.kind === 'deep-equal')) {\n return `lift the children out of the parent's render: memoize them with useMemo, hoist static elements to module scope, or render them from a component that does not re-render`;\n }\n switch (change.kind) {\n case 'function':\n return `wrap it in useCallback (or hoist it out of the parent's render)`;\n case 'element':\n return `memoize the element with useMemo, or pass it as children from a stable parent`;\n case 'deep-equal':\n return Array.isArray(change.next)\n ? `memoize the array with useMemo (same items, new reference)`\n : `memoize the object with useMemo, or hoist it to module scope if it is constant`;\n default:\n return '';\n }\n}\n\nfunction describe(change: Change): string {\n if (isChildren(change) && (change.kind === 'element' || change.kind === 'deep-equal')) {\n return `children are new React elements with the same types and props on every render of the parent`;\n }\n switch (change.kind) {\n case 'deep-equal':\n return `prop \"${change.path}\" is a new reference but deep-equal to the previous value`;\n case 'function':\n return `prop \"${change.path}\" is a new function instance on every render`;\n case 'element':\n return `prop \"${change.path}\" is a new React element with the same type and props`;\n case 'different':\n return `prop \"${change.path}\" changed`;\n case 'added':\n return `prop \"${change.path}\" was added`;\n case 'removed':\n return `prop \"${change.path}\" was removed`;\n }\n}\n\nexport function buildReport(input: BuildInput): RenderReport {\n const stateChanges = input.stateChanges ?? [];\n const hookChanges = input.hookChanges ?? [];\n const isStateHook = (h: HookChange): boolean => h.hook === 'useState' || h.hook === 'useReducer';\n const genuineProps = input.propChanges.some(isGenuine);\n const genuineState = stateChanges.some(isGenuine) || hookChanges.some((h) => isStateHook(h) && isGenuine(h));\n const genuineHooks = hookChanges.some((h) => !isStateHook(h) && isGenuine(h));\n const causes = [genuineProps && 'props', genuineState && 'state', genuineHooks && 'hooks'].filter(Boolean) as RenderTrigger[];\n\n let trigger: RenderTrigger;\n if (causes.length === 0) trigger = 'parent';\n else if (causes.length === 1) trigger = causes[0]!;\n else trigger = 'mixed';\n\n const avoidable = trigger === 'parent';\n const reasons: string[] = [];\n\n if (avoidable && input.propChanges.length === 0 && stateChanges.length === 0 && hookChanges.length === 0) {\n const who = input.parent ? `<${input.parent.name}> re-rendered (${describeTrigger(input.parent.trigger)})` : 'its parent re-rendered';\n reasons.push(`re-rendered with identical props because ${who}. Wrap \"${input.component}\" in React.memo (or extend PureComponent).`);\n } else if (avoidable && input.parent) {\n reasons.push(`caused by <${input.parent.name}> re-rendering (${describeTrigger(input.parent.trigger)}).`);\n }\n for (const c of input.propChanges) {\n const fix = fixFor(c);\n reasons.push(fix ? `${describe(c)}: ${fix}.` : `${describe(c)}.`);\n }\n const memoized = input.memoized !== false;\n if (avoidable && !memoized && input.propChanges.length > 0) {\n reasons.push(\n `\"${input.component}\" is not memoized, so fixing the props alone will not stop this re-render: also wrap it in React.memo (or extend PureComponent).`,\n );\n }\n for (const c of stateChanges) {\n if (isGenuine(c)) reasons.push(`state \"${c.path}\" changed.`);\n else reasons.push(`setState was called with a value deep-equal to the current \"${c.path}\" (new reference, same contents).`);\n }\n for (const c of hookChanges) {\n if (c.hook === 'useContext' && isGenuine(c)) {\n const where = c.provider && c.provider.component ? ` (provided by <${c.provider.component}>)` : '';\n const keys =\n c.changedKeys && typeof c.totalKeys === 'number' && c.changedKeys.length > 0 && c.changedKeys.length < c.totalKeys\n ? `: only ${c.changedKeys.map((k) => `\"${k}\"`).join(', ')} of ${c.totalKeys} keys changed, yet every consumer re-renders. Split the context or memoize the slices consumers read`\n : '';\n reasons.push(`${c.path} changed${where}${keys}.`);\n } else if (isGenuine(c)) reasons.push(`${hookLabel(c)} changed.`);\n else if (isStateHook(c))\n reasons.push(`${hookLabel(c)} was set to a value deep-equal to the current one (new reference, same contents): reuse the existing object or bail out before calling the setter.`);\n else if (c.hook === 'useSyncExternalStore') reasons.push(`${hookLabel(c)} returned a new reference that is deep-equal to the previous value: ${storeAdvice(c.custom)}.`);\n else reasons.push(`${hookLabel(c)} returned a new reference that is deep-equal to the previous value: memoize the context/store value where it is produced.`);\n }\n if (input.commitCause === 'effect-after-commit') {\n const who = input.updaters && input.updaters.length ? input.updaters.map((u) => `<${u}>`).join(', ') : 'a component that rendered in it';\n reasons.push(`this commit was scheduled right after commit #${input.afterCommit ?? '?'} by ${who}: an effect there set state (effect → setState loop). Derive the value during render or compute it before setting state.`);\n } else if (input.commitCause === 'suspense-resolved') {\n reasons.push('this commit shows content that was suspended (a Suspense boundary resolved).');\n }\n\n const report: RenderReport = {\n component: input.component,\n instanceId: input.instanceId ?? 0,\n commitId: input.commitId ?? 0,\n renderCount: input.renderCount,\n trigger,\n avoidable,\n memoized,\n props: { prev: input.prevProps, next: input.nextProps },\n propChanges: input.propChanges,\n stateChanges,\n hookChanges,\n parent: input.parent ?? null,\n owner: input.owner ?? null,\n path: input.path ?? [],\n reasons,\n time: now(),\n };\n if (input.selfDuration !== undefined) report.selfDuration = input.selfDuration;\n if (input.treeDuration !== undefined) report.treeDuration = input.treeDuration;\n if (input.commitPriority) report.commitPriority = input.commitPriority;\n if (input.source) report.source = input.source;\n if (input.hookState) report.hookState = input.hookState;\n if (input.contexts) report.contexts = input.contexts;\n if (input.state) report.state = input.state;\n if (input.updaters && input.updaters.length) report.updaters = input.updaters;\n if (input.commitCause) report.commitCause = input.commitCause;\n if (input.afterCommit !== undefined) report.afterCommit = input.afterCommit;\n if (input.key !== undefined) report.key = input.key;\n return report;\n}\n\nfunction describeTrigger(t: RenderTrigger): string {\n switch (t) {\n case 'props':\n return 'its props changed';\n case 'state':\n return 'its state changed';\n case 'hooks':\n return 'a context or store it reads changed';\n case 'mixed':\n return 'its props and state changed';\n default:\n return 'its own parent re-rendered';\n }\n}\n\nconst KIND_LABEL: Record<Change['kind'], string> = {\n 'deep-equal': 'equal by value',\n function: 'new function',\n element: 'equal element',\n different: 'changed',\n added: 'added',\n removed: 'removed',\n};\n\nexport function summarize(report: RenderReport): string {\n const counts = new Map<string, number>();\n for (const c of [...report.propChanges, ...report.stateChanges, ...report.hookChanges]) {\n counts.set(c.kind, (counts.get(c.kind) ?? 0) + 1);\n }\n const parts = [...counts].map(([kind, n]) => `${n} ${KIND_LABEL[kind as Change['kind']]}`);\n if (parts.length === 0) parts.push('no changes');\n return parts.join(', ');\n}\n\n/** Default notifier: prints a console group per report. */\nexport function printReport(report: RenderReport, options: Options): void {\n const c = options.console ?? console;\n const open = options.collapse === false ? c.group : c.groupCollapsed;\n const verdict = report.avoidable ? 'avoidable re-render' : `re-render (${report.trigger})`;\n open.call(c, `[rerender-lens] <${report.component}> ${verdict}: ${summarize(report)}`);\n for (const r of report.reasons) c.log(`- ${r}`);\n if (report.path.length) c.log(`at ${[...report.path, report.component].join(' > ')}`);\n for (const ch of [...report.propChanges, ...report.stateChanges, ...report.hookChanges]) {\n c.log(`${ch.path} (${KIND_LABEL[ch.kind]})`, { prev: ch.prev, next: ch.next });\n }\n c.log('props', report.props);\n if (report.hookState && report.hookState.length) c.log('hooks', Object.fromEntries(report.hookState.map((h) => [h.path, h.value])));\n if (report.contexts && report.contexts.length) c.log('contexts', Object.fromEntries(report.contexts.map((x) => [x.name, x.value])));\n if (report.state) c.log('state', report.state);\n c.groupEnd();\n}\n","/**\n * Concrete fixes derived from reports, ranked by how many avoidable re-renders each one removes.\n * The same logic drives the extension's Fixes view; here it is typed on `RenderReport` for tests,\n * CI budgets and the CLI. Pure.\n */\nimport type { Change, HookChange, RenderReport } from './types';\nimport { storeAdvice } from './report';\n\nexport type FixKind = 'memo' | 'useCallback' | 'useMemo' | 'useMemoElement' | 'children' | 'contextValue' | 'splitContext' | 'storeSnapshot' | 'bailout';\n\nexport interface Fix {\n kind: FixKind;\n /** Where the change goes (the component that must be edited, or `<Ctx>.Provider`). */\n owner: string;\n /** The component whose re-render this removes. */\n target: string;\n prop: string | null;\n label: string;\n detail: string;\n}\n\nexport interface RankedFix extends Fix {\n key: string;\n /** Avoidable re-renders this fix removes. */\n count: number;\n components: Record<string, number>;\n}\n\nconst AVOIDABLE = new Set<string>(['deep-equal', 'function', 'element']);\nconst rootOf = (path: string): string => path.split(/[.[]/)[0] || path;\n\nexport function fixesFor(r: RenderReport): Fix[] {\n const out: Fix[] = [];\n const owner = r.owner || (r.parent && r.parent.name) || '?';\n const changes: Change[] = [...r.propChanges, ...r.stateChanges, ...r.hookChanges];\n if (r.avoidable && (changes.length === 0 || r.memoized === false)) {\n out.push({\n kind: 'memo',\n owner: r.component,\n target: r.component,\n prop: null,\n label: `Wrap <${r.component}> in React.memo`,\n detail: changes.length === 0 ? `<${r.component}> re-rendered with identical props because <${(r.parent && r.parent.name) || 'its parent'}> re-rendered.` : `<${r.component}> is not memoized: fixing its props alone will not stop the re-render.`,\n });\n }\n for (const c of r.propChanges) {\n if (!AVOIDABLE.has(c.kind)) continue;\n const root = rootOf(c.path);\n if (root === 'children' && (c.kind === 'element' || c.kind === 'deep-equal')) {\n out.push({ kind: 'children', owner, target: r.component, prop: 'children', label: `memoize children of <${r.component}> in <${owner}>`, detail: `<${owner}> re-creates the children of <${r.component}> on every render.` });\n } else if (c.kind === 'function') {\n out.push({ kind: 'useCallback', owner, target: r.component, prop: root, label: `useCallback(${root}) in <${owner}>`, detail: `prop \"${c.path}\" of <${r.component}> is a new function on every render of <${owner}>.` });\n } else if (c.kind === 'element') {\n out.push({ kind: 'useMemoElement', owner, target: r.component, prop: root, label: `memoize element prop ${root} in <${owner}>`, detail: `prop \"${c.path}\" of <${r.component}> is a new element with the same type and props on every render of <${owner}>.` });\n } else {\n out.push({ kind: 'useMemo', owner, target: r.component, prop: root, label: `useMemo(${root}) in <${owner}>`, detail: `prop \"${c.path}\" of <${r.component}> is a new ${Array.isArray(c.next) ? 'array' : 'object'} with the same contents on every render of <${owner}>.` });\n }\n }\n for (const c of [...r.stateChanges, ...r.hookChanges] as (Change & Partial<HookChange>)[]) {\n const isContext = c.hook === 'useContext';\n const ctxName = isContext ? (/useContext\\((.*)\\)/.exec(c.path) || [])[1] || 'Context' : '';\n const providerOwner = isContext && c.provider && c.provider.component ? c.provider.component : null;\n if (isContext && c.kind === 'different' && c.changedKeys && typeof c.totalKeys === 'number' && c.changedKeys.length > 0 && c.changedKeys.length < c.totalKeys) {\n out.push({\n kind: 'splitContext',\n owner: providerOwner || `${ctxName}.Provider`,\n target: r.component,\n prop: ctxName,\n label: `split ${ctxName}${providerOwner ? ` in <${providerOwner}>` : ''}: only ${c.changedKeys.join(', ')} changed`,\n detail: `${c.changedKeys.length} of ${c.totalKeys} keys changed in ${ctxName}, yet every consumer re-rendered.`,\n });\n continue;\n }\n if (!AVOIDABLE.has(c.kind)) continue;\n if (isContext) {\n out.push({ kind: 'contextValue', owner: providerOwner || `${ctxName}.Provider`, target: r.component, prop: ctxName, label: `memoize the ${ctxName} provider value${providerOwner ? ` in <${providerOwner}>` : ''}`, detail: `${ctxName} produced a new value that is deep-equal to the previous one.` });\n } else if (c.hook === 'useSyncExternalStore') {\n const chain = c.custom || [];\n const redux = chain.some((n) => /^use(App)?Selector$/.test(n));\n const zustand = !redux && chain.some((n) => /^use[A-Z]\\w*Store$/.test(n) || n === 'useStore' || n === 'useBoundStore');\n out.push({ kind: 'storeSnapshot', owner: r.component, target: r.component, prop: c.path, label: redux ? `memoize the selector in <${r.component}>` : zustand ? `useShallow in <${r.component}>` : `stable getSnapshot in <${r.component}>`, detail: storeAdvice(c.custom) });\n } else {\n out.push({ kind: 'bailout', owner: r.component, target: r.component, prop: c.path, label: `bail out before setting ${c.path} in <${r.component}>`, detail: `${c.path} was set to a value deep-equal to the current one (new reference).` });\n }\n }\n return out;\n}\n\nexport const fixKey = (f: Fix): string => `${f.kind}|${f.owner}|${f.prop || f.target}`;\n\n/** Every fix across `reports`, most re-renders removed first. */\nexport function rankFixes(reports: RenderReport[]): RankedFix[] {\n const byKey = new Map<string, RankedFix>();\n for (const r of reports) {\n if (!r.avoidable) continue;\n for (const f of fixesFor(r)) {\n const key = fixKey(f);\n let agg = byKey.get(key);\n if (!agg) {\n agg = { ...f, key, count: 0, components: {} };\n byKey.set(key, agg);\n }\n agg.count++;\n agg.components[r.component] = (agg.components[r.component] || 0) + 1;\n }\n }\n return [...byKey.values()].sort((a, b) => b.count - a.count || a.label.localeCompare(b.label));\n}\n\n/** Multi-line text for a test failure or a CI log. */\nexport function formatFixes(reports: RenderReport[], limit = 10): string {\n const ranked = rankFixes(reports);\n if (!ranked.length) return 'No avoidable re-renders.';\n const lines = ranked.slice(0, limit).map((f, i) => `${String(i + 1).padStart(2)}. ${f.label} (removes ${f.count}: ${Object.entries(f.components).map(([c, n]) => `<${c}>${n > 1 ? ' x' + n : ''}`).join(', ')})`);\n if (ranked.length > limit) lines.push(` … ${ranked.length - limit} more`);\n return lines.join('\\n');\n}\n","/**\n * Re-render budgets for CI: a JSON baseline of allowed avoidable re-renders per component, checked\n * against a collector's reports (like a bundle-size budget). Pure; reading and writing the file is\n * up to the test runner (`fs`), so this works in Node and in the browser.\n */\nimport type { RenderReport } from './types';\nimport { formatFixes } from './fixes';\n\n/** `{ \"*\": 0, \"ProductRow\": 3 }`: max avoidable re-renders per component; `*` is the default. */\nexport type Budget = Record<string, number>;\n\nexport interface BudgetViolation {\n component: string;\n avoidable: number;\n allowed: number;\n}\n\nexport interface BudgetResult {\n ok: boolean;\n violations: BudgetViolation[];\n /** Components with headroom left, so budgets can be tightened. */\n slack: { component: string; avoidable: number; allowed: number }[];\n counts: Record<string, number>;\n}\n\nexport function avoidableCounts(reports: RenderReport[]): Record<string, number> {\n const counts: Record<string, number> = {};\n for (const r of reports) if (r.avoidable) counts[r.component] = (counts[r.component] || 0) + 1;\n return counts;\n}\n\nexport function checkBudget(reports: RenderReport[], budget: Budget | number): BudgetResult {\n const b: Budget = typeof budget === 'number' ? { '*': budget } : budget;\n const fallback = typeof b['*'] === 'number' ? b['*'] : 0;\n const counts = avoidableCounts(reports);\n const violations: BudgetViolation[] = [];\n const slack: BudgetResult['slack'] = [];\n const names = new Set([...Object.keys(counts), ...Object.keys(b).filter((k) => k !== '*')]);\n for (const component of names) {\n const allowed = typeof b[component] === 'number' ? b[component]! : fallback;\n const avoidable = counts[component] || 0;\n if (avoidable > allowed) violations.push({ component, avoidable, allowed });\n else if (avoidable < allowed) slack.push({ component, avoidable, allowed });\n }\n violations.sort((x, y) => y.avoidable - y.allowed - (x.avoidable - x.allowed));\n return { ok: violations.length === 0, violations, slack, counts };\n}\n\n/** A budget that exactly matches the current counts (the baseline to commit). */\nexport function toBudget(reports: RenderReport[]): Budget {\n return { '*': 0, ...avoidableCounts(reports) };\n}\n\n/** Throws with the violations and the ranked fixes; use it from a test. */\nexport function assertWithinBudget(reports: RenderReport[], budget: Budget | number): BudgetResult {\n const result = checkBudget(reports, budget);\n if (result.ok) return result;\n const lines = result.violations.map((v) => ` <${v.component}>: ${v.avoidable} avoidable re-render${v.avoidable === 1 ? '' : 's'} (budget ${v.allowed})`);\n throw new Error(`Re-render budget exceeded:\\n${lines.join('\\n')}\\n\\nFixes, most impact first:\\n${formatFixes(reports)}`);\n}\n","/**\n * Playwright helper: run rerender-lens inside any page under test, then pull the reports and assert\n * a budget from the test. Works on production-like builds too (names may be minified there).\n *\n * import { installRerenderLens, pullReports, expectWithinBudget } from 'rerender-lens/playwright';\n * await installRerenderLens(page, { trackAllMemoized: true }); // before page.goto\n * await page.goto('/');\n * ...interact...\n * expectWithinBudget(await pullReports(page), { '*': 0, ProductRow: 3 });\n *\n * The library bundle is injected with `page.addInitScript` at document start, exactly like the\n * extension's injection mode, so `init` runs before react-dom.\n */\nimport { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { RenderReport } from './types';\nimport type { SerializableOptions } from './devtools';\nimport { assertWithinBudget, checkBudget, type Budget, type BudgetResult } from './budget';\nimport { rankFixes, formatFixes, type RankedFix } from './fixes';\n\n/** The subset of Playwright's `Page` used here (keeps `@playwright/test` an optional peer). */\nexport interface PageLike {\n addInitScript(script: string | { content?: string }): Promise<void>;\n evaluate<R>(fn: string | ((arg: unknown) => R), arg?: unknown): Promise<R>;\n}\n\nexport interface InstallOptions extends SerializableOptions {\n /** Forward to a relay (`npx rerender-lens panel`) to watch the test in the panel. */\n relay?: string;\n /** Print to the page console (default false in tests). */\n silent?: boolean;\n /** Library source to inject instead of the packaged IIFE bundle (must define `window.RerenderLens`). */\n bundle?: string;\n}\n\nlet bundleCache: string | null = null;\n\n/** The vendor scripts the extension injects, in load order (see scripts/build-vendor.mjs). */\nexport const VENDOR_FILES = ['rerender-lens.core.js', 'rerender-lens.engine.js', 'rerender-lens.js'];\n\n/** The library as one script (`window.RerenderLens`): `dist/rerender-lens.iife.js`, or the vendor parts joined in this repo. */\nexport function libraryBundle(): string {\n if (bundleCache) return bundleCache;\n const here = dirname(fileURLToPath(import.meta.url));\n const candidates = [[join(here, 'rerender-lens.iife.js')], VENDOR_FILES.map((f) => join(here, '..', 'extension', 'vendor', f))];\n for (const files of candidates) {\n try {\n bundleCache = files.map((f) => readFileSync(f, 'utf8')).join('\\n;\\n');\n return bundleCache;\n } catch {\n /* next */\n }\n }\n throw new Error('rerender-lens: library bundle not found (run `npm run build` in the rerender-lens repo, or reinstall the package)');\n}\n\n/** Script that starts the library with `options` before any page script runs. */\nexport function installScript(options: InstallOptions = {}): string {\n const { relay, bundle, ...rest } = options;\n const opts: InstallOptions = { trackAllMemoized: true, silent: true, ...rest };\n return `${bundle ?? libraryBundle()}\\n;(function(){\\n if (window.__RERENDER_LENS_DEVTOOLS__) return;\\n var L = window.RerenderLens;\\n L.ensureDevtoolsHook();\\n var o = ${JSON.stringify(opts)};\\n o.notifier = L.createDevtoolsNotifier(${relay ? JSON.stringify({ relay }) : '{}'});\\n if (o.include) o.include = o.include.map(function (m) { var r = /^\\\\/(.+)\\\\/([a-z]*)$/.exec(m); return r ? new RegExp(r[1], r[2]) : m; });\\n if (o.exclude) o.exclude = o.exclude.map(function (m) { var r = /^\\\\/(.+)\\\\/([a-z]*)$/.exec(m); return r ? new RegExp(r[1], r[2]) : m; });\\n L.init(o);\\n window.__RERENDER_LENS_PLAYWRIGHT__ = true;\\n})();`;\n}\n\n/** Call before `page.goto`. */\nexport async function installRerenderLens(page: PageLike, options: InstallOptions = {}): Promise<void> {\n await page.addInitScript({ content: installScript(options) });\n}\n\n/** Every report buffered in the page so far (serialized: functions are `ƒ name`, elements `{ $type: 'element' }`). */\nexport async function pullReports(page: PageLike): Promise<RenderReport[]> {\n const result = await page.evaluate<{ reports: unknown[] } | null>('(function(){var b=window.__RERENDER_LENS_DEVTOOLS__;return b&&b.pull?b.pull(0):null})()');\n if (!result) throw new Error('rerender-lens is not running in the page: call installRerenderLens(page) before page.goto');\n return result.reports as RenderReport[];\n}\n\n/** Drop the page buffer (between scenarios). */\nexport async function clearReports(page: PageLike): Promise<void> {\n await page.evaluate('(function(){var b=window.__RERENDER_LENS_DEVTOOLS__;if(b)b.clear();})()');\n}\n\nexport { checkBudget, rankFixes, formatFixes };\nexport type { Budget, BudgetResult, RankedFix };\n\n/** Throws with the violations and ranked fixes, like `collector.assertWithinBudget`. */\nexport function expectWithinBudget(reports: RenderReport[], budget: Budget | number): BudgetResult {\n return assertWithinBudget(reports, budget);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../node_modules/tsup/assets/cjs_shims.js","../src/diff.ts","../src/causes.ts","../src/fixes.ts","../src/budget.ts","../src/playwright.ts"],"names":["dirname","fileURLToPath","join","readFileSync"],"mappings":";;;;;;;AAKA,IAAM,gBAAA,GAAmB,MACvB,OAAO,QAAA,KAAa,WAAA,GAChB,IAAI,GAAA,CAAI,CAAA,KAAA,EAAQ,UAAU,CAAA,CAAE,CAAA,CAAE,IAAA,GAC7B,QAAA,CAAS,aAAA,IAAiB,QAAA,CAAS,aAAA,CAAc,OAAA,CAAQ,WAAA,EAAY,KAAM,QAAA,GAC1E,QAAA,CAAS,aAAA,CAAc,GAAA,GACvB,IAAI,GAAA,CAAI,SAAA,EAAW,QAAA,CAAS,OAAO,CAAA,CAAE,IAAA;AAEtC,IAAM,gCAAgC,gBAAA,EAAiB;;;ACqJvD,IAAM,kCAAuC,IAAI,GAAA,CAAgB,CAAC,YAAA,E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2I,IAAA,CAAK,SAAA,CAAU,IAAI,CAAC,CAAA;AAAA,wCAAA,EAA8C,QAAQ,IAAA,CAAK,SAAA,CAAU,EAAE,KAAA,EAAO,IAAI,IAAI,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAA,CAAA;AAC1R;AAGA,eAAsB,mBAAA,CAAoB,IAAA,EAAgB,OAAA,GAA0B,EAAC,EAAkB;AACrG,EAAA,MAAM,KAAK,aAAA,CAAc,EAAE,SAAS,aAAA,CAAc,OAAO,GAAG,CAAA;AAC9D;AAGA,eAAsB,YAAY,IAAA,EAAyC;AACzE,EAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,QAAA,CAAwC,yFAAyF,CAAA;AAC3J,EAAA,IAAI,CAAC,MAAA,EAAQ,MAAM,IAAI,MAAM,2FAA2F,CAAA;AACxH,EAAA,OAAO,MAAA,CAAO,OAAA;AAChB;AAGA,eAAsB,aAAa,IAAA,EAA+B;AAChE,EAAA,MAAM,IAAA,CAAK,SAAS,yEAAyE,CAAA;AAC/F;AAMO,SAAS,kBAAA,CAAmB,SAAyB,MAAA,EAAuC;AACjG,EAAA,OAAO,kBAAA,CAAmB,SAAS,MAAM,CAAA;AAC3C","file":"playwright.cjs","sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import type { Change, ChangeKind } from './types';\n\nconst REACT_ELEMENT = Symbol.for('react.element');\nconst REACT_TRANSITIONAL_ELEMENT = Symbol.for('react.transitional.element');\n\nexport function isReactElement(v: unknown): v is { type: unknown; props: Record<string, unknown>; key: unknown } {\n if (typeof v !== 'object' || v === null) return false;\n const t = (v as { $$typeof?: unknown }).$$typeof;\n return t === REACT_ELEMENT || t === REACT_TRANSITIONAL_ELEMENT;\n}\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n if (typeof v !== 'object' || v === null) return false;\n const proto = Object.getPrototypeOf(v);\n return proto === Object.prototype || proto === null;\n}\n\ntype Seen = Map<object, Set<object>>;\n\nfunction remember(seen: Seen, a: object, b: object): boolean {\n let set = seen.get(a);\n if (!set) {\n set = new Set();\n seen.set(a, set);\n }\n if (set.has(b)) return true;\n set.add(b);\n return false;\n}\n\n/**\n * Bounds the work of one comparison scope (a commit, or one public `deepEqual` call): pairs already\n * compared are memoized, so a large value shared by many components is walked once per commit, and\n * a visit budget turns a huge structure into \"different\" instead of freezing the page.\n */\ninterface DiffScope {\n cache: WeakMap<object, WeakMap<object, boolean>>;\n remaining: number;\n exhausted: boolean;\n}\nlet scope: DiffScope | null = null;\n/** Object visits allowed for one public `deepEqual` call. */\nexport const DEFAULT_DIFF_BUDGET = 50_000;\n\n/** Start a scope (`onCommit` does this per commit); call the returned function to end it. */\nexport function beginDiffScope(budget = 200_000): () => void {\n const previous = scope;\n scope = { cache: new WeakMap(), remaining: budget, exhausted: false };\n return () => {\n scope = previous;\n };\n}\n\n/** True when the current scope gave up on a value because it was too large to walk. */\nexport function diffBudgetExhausted(): boolean {\n return scope?.exhausted === true;\n}\n\n/**\n * Structural equality that understands Map, Set, Date, RegExp, typed arrays,\n * React elements and cyclic references. Functions are equal only by reference.\n */\nexport function deepEqual(a: unknown, b: unknown, seen: Seen = new Map()): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== typeof b) return false;\n if (typeof a !== 'object' || a === null || b === null) return false;\n if (!scope) {\n const end = beginDiffScope(DEFAULT_DIFF_BUDGET);\n try {\n return deepEqual(a, b, seen);\n } finally {\n end();\n }\n }\n const sc = scope;\n const objA = a as object;\n const objB = b as object;\n const hit = sc.cache.get(objA)?.get(objB);\n if (hit !== undefined) return hit;\n if (--sc.remaining < 0) {\n sc.exhausted = true;\n return false;\n }\n const result = deepEqualObjects(objA, objB, seen);\n let m = sc.cache.get(objA);\n if (!m) {\n m = new WeakMap();\n sc.cache.set(objA, m);\n }\n m.set(objB, result);\n return result;\n}\n\nfunction deepEqualObjects(a: object, b: object, seen: Seen): boolean {\n const objA = a;\n const objB = b;\n if (remember(seen, objA, objB)) return true; // cycle: assume equal on this branch\n\n if (a instanceof Date) return b instanceof Date && a.getTime() === b.getTime();\n if (a instanceof RegExp) return b instanceof RegExp && a.source === b.source && a.flags === b.flags;\n\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (!deepEqual(a[i], b[i], seen)) return false;\n return true;\n }\n if (Array.isArray(b)) return false;\n\n if (ArrayBuffer.isView(a)) {\n if (!ArrayBuffer.isView(b) || a.constructor !== b.constructor) return false;\n const ta = a as unknown as ArrayLike<number>;\n const tb = b as unknown as ArrayLike<number>;\n if (ta.length !== tb.length) return false;\n for (let i = 0; i < ta.length; i++) if (ta[i] !== tb[i]) return false;\n return true;\n }\n\n if (a instanceof Map) {\n if (!(b instanceof Map) || a.size !== b.size) return false;\n for (const [k, v] of a) {\n if (!b.has(k) || !deepEqual(v, b.get(k), seen)) return false;\n }\n return true;\n }\n if (a instanceof Set) {\n if (!(b instanceof Set) || a.size !== b.size) return false;\n if (a.size > 50) {\n // Members that are equal-but-not-identical would need O(n²) work; large sets compare by identity.\n for (const v of a) if (!b.has(v)) return false;\n return true;\n }\n outer: for (const v of a) {\n if (b.has(v)) continue;\n for (const w of b) if (deepEqual(v, w, seen)) continue outer;\n return false;\n }\n return true;\n }\n\n if (isReactElement(a)) {\n if (!isReactElement(b)) return false;\n return a.type === b.type && a.key === b.key && deepEqual(a.props, b.props, seen);\n }\n\n if (isPlainObject(a) && isPlainObject(b)) {\n const ka = Object.keys(a);\n const kb = Object.keys(b);\n if (ka.length !== kb.length) return false;\n const rb = b as Record<string, unknown>;\n for (const k of ka) {\n if (!Object.prototype.hasOwnProperty.call(b, k)) return false;\n if (!deepEqual((a as Record<string, unknown>)[k], rb[k], seen)) return false;\n }\n return true;\n }\n\n // Class instances, DOM nodes, promises, etc.: reference equality only.\n return false;\n}\n\n/** Change kinds that mean \"new reference, same contents\": the ones a fix removes. */\nexport const AVOIDABLE_KINDS: ReadonlySet<string> = new Set<ChangeKind>(['deep-equal', 'function', 'element']);\n\n/** Classify why two values differ. Assumes `!Object.is(prev, next)`. */\nexport function classify(prev: unknown, next: unknown): ChangeKind {\n if (typeof prev === 'function' && typeof next === 'function') {\n return prev.name === next.name && prev.toString() === next.toString() ? 'function' : 'different';\n }\n if (isReactElement(prev) && isReactElement(next)) {\n return deepEqual(prev, next) ? 'element' : 'different';\n }\n return deepEqual(prev, next) ? 'deep-equal' : 'different';\n}\n\nfunction joinPath(base: string, key: string | number): string {\n if (typeof key === 'number') return `${base}[${key}]`;\n if (base === '') return key;\n return /^[A-Za-z_$][\\w$]*$/.test(key) ? `${base}.${key}` : `${base}[${JSON.stringify(key)}]`;\n}\n\n/**\n * Shallow-diff two records. Every changed key produces exactly one Change;\n * for `different` values that are plain objects/arrays, the nested path that\n * actually differs is reported in `path` to make the console output actionable.\n */\nexport function diffRecords(\n prev: Record<string, unknown> | undefined | null,\n next: Record<string, unknown> | undefined | null,\n basePath = '',\n): Change[] {\n const p = prev ?? {};\n const n = next ?? {};\n const changes: Change[] = [];\n const keys = new Set([...Object.keys(p), ...Object.keys(n)]);\n for (const key of keys) {\n const inPrev = Object.prototype.hasOwnProperty.call(p, key);\n const inNext = Object.prototype.hasOwnProperty.call(n, key);\n const path = joinPath(basePath, key);\n if (inPrev && !inNext) {\n changes.push({ path, kind: 'removed', prev: p[key], next: undefined });\n continue;\n }\n if (!inPrev && inNext) {\n changes.push({ path, kind: 'added', prev: undefined, next: n[key] });\n continue;\n }\n const a = p[key];\n const b = n[key];\n if (Object.is(a, b)) continue;\n const kind = classify(a, b);\n if (kind === 'different') {\n // Once the budget is gone the nested walk would only burn more time; report the top-level key.\n changes.push({ path: diffBudgetExhausted() ? path : (firstDifferentPath(a, b, path) ?? path), kind, prev: a, next: b });\n } else {\n changes.push({ path, kind, prev: a, next: b });\n }\n }\n return changes;\n}\n\n/**\n * Walk plain objects/arrays to find the deepest path where the values first differ, e.g. `style.color`\n * or `items[2].id`; null when they are deep-equal. Two different values with no path to descend into\n * (primitives at the root) give `(value)`. Works on live values and on the panel's serialized ones.\n */\nexport function firstDifferentPath(a: unknown, b: unknown, path = '', depth = 0): string | null {\n if (depth > 8) return path || '(value)';\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return path ? `${path}.length` : 'length';\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return firstDifferentPath(a[i], b[i], joinPath(path, i), depth + 1);\n }\n return null;\n }\n if (isPlainObject(a) && isPlainObject(b)) {\n const keys = new Set([...Object.keys(a), ...Object.keys(b)]);\n for (const k of keys) {\n if (!deepEqual(a[k], b[k])) return firstDifferentPath(a[k], b[k], joinPath(path, k), depth + 1);\n }\n return null;\n }\n return deepEqual(a, b) ? null : path || '(value)';\n}\n\nexport interface Leaf {\n path: string;\n prev: unknown;\n next: unknown;\n}\n\n/** Every leaf at which two values differ, at most `limit` of them (the panel's diff view of `different` changes). */\nexport function diffLeaves(a: unknown, b: unknown, limit = 20, path = '', out: Leaf[] = []): Leaf[] {\n if (out.length >= limit || Object.is(a, b)) return out;\n if (Array.isArray(a) && Array.isArray(b)) {\n const n = Math.max(a.length, b.length);\n for (let i = 0; i < n && out.length < limit; i++) diffLeaves(a[i], b[i], limit, joinPath(path, i), out);\n return out;\n }\n if (isPlainObject(a) && isPlainObject(b)) {\n for (const k of new Set([...Object.keys(a), ...Object.keys(b)])) {\n if (out.length >= limit) break;\n diffLeaves(a[k], b[k], limit, joinPath(path, k), out);\n }\n return out;\n }\n if (!deepEqual(a, b)) out.push({ path: path || '(value)', prev: a, next: b });\n return out;\n}\n","/**\n * Commit and root-cause analysis: which component's own change started each render cascade, which\n * contexts fanned out to how many consumers, and a nested view of one commit. Reports carry a\n * `commitId` (every report from one React commit shares it) and `parent` links (the nearest ancestor\n * that rendered in the same commit); following those links inside a commit finds the root cause.\n * One implementation for the library (the CLI, the Vitest reporter, `formatFixes`) and the DevTools\n * panel, which adds its own per-commit memoization on top. Typed over `ReportLike`. Pure.\n */\nimport { AVOIDABLE_KINDS } from './diff';\nimport type { RenderReport, ReportLike } from './types';\n\nexport interface RootCause {\n name: string;\n trigger: string;\n /** Avoidable re-renders in the commit that trace back to this component. */\n count: number;\n components: Map<string, number>;\n}\n\nexport interface ContextStat {\n name: string;\n consumers: number;\n avoidable: number;\n components: Map<string, number>;\n commits: Set<number>;\n /** Components rendering the Provider (usually one). */\n providers: Map<string, number>;\n /** Keys that changed in object values, and the largest key count seen. */\n changedKeys: Set<string>;\n totalKeys: number;\n}\n\nexport interface CommitAnalysis<R extends ReportLike = RenderReport> {\n /** The commit id (`commitId` of its reports), 0 when the reports carry none. */\n id: number;\n total: number;\n avoidable: number;\n /** Sum of `selfDuration` over the avoidable reports, in ms. */\n wasted: number;\n roots: RootCause[];\n /** Root cause name of every avoidable report (what `roots` was aggregated from). */\n rootByReport: Map<R, string>;\n contexts: ContextStat[];\n reports: R[];\n}\n\nexport interface CascadeNode<R extends ReportLike = RenderReport> {\n name: string;\n children: Map<string, CascadeNode<R>>;\n report: R | null;\n count?: number;\n avoidable?: number;\n}\n\nexport interface RootSummary<R extends ReportLike = RenderReport, A extends CommitAnalysis<R> = CommitAnalysis<R>> {\n name: string;\n trigger: string;\n /** Newest first. */\n commits: { key: number; analysis: A; count: number; components: Map<string, number> }[];\n /** Avoidable re-renders across every commit. */\n total: number;\n components: Map<string, number>;\n /** The avoidable reports that trace back to this root cause. */\n affected: R[];\n}\n\n/** One root cause across a whole run: how many commits it started and what those cost. */\nexport interface RankedRootCause {\n name: string;\n trigger: string;\n commits: number;\n /** Avoidable re-renders it caused. */\n count: number;\n components: Map<string, number>;\n}\n\nconst isAncestorReport = (anc: ReportLike, r: ReportLike): boolean =>\n anc.path.length < r.path.length && r.path[anc.path.length] === anc.component && anc.path.every((p, i) => r.path[i] === p);\n\nconst bump = (m: Map<string, number>, key: string, n = 1): void => void m.set(key, (m.get(key) || 0) + n);\n\n/** One commit's reports grouped by component name, so a parent lookup is O(same-named reports) instead of O(commit). */\nexport function indexByComponent<R extends ReportLike>(reports: readonly R[]): Map<string, R[]> {\n const index = new Map<string, R[]>();\n for (const r of reports) {\n const list = index.get(r.component);\n if (list) list.push(r);\n else index.set(r.component, [r]);\n }\n return index;\n}\n\n/**\n * Walk `parent` links inside one commit up to the component whose own change started the cascade.\n * Null when `r` started it itself; `report` is null when the root is an ancestor that is not in the\n * commit (untracked), in which case `name`/`trigger` come from the last `parent` link.\n */\nexport function rootCauseOf<R extends ReportLike>(r: R, commitReports: readonly R[], index: Map<string, R[]> = indexByComponent(commitReports)): { name: string; trigger: string; report: R | null } | null {\n let cur = r;\n const seen = new Set<R>([r]);\n while (cur.trigger === 'parent' && cur.parent) {\n const parent = cur.parent;\n const candidates = index.get(parent.name);\n const p = candidates && candidates.find((x) => isAncestorReport(x, cur));\n if (!p || seen.has(p)) return { name: parent.name, trigger: parent.trigger, report: null };\n seen.add(p);\n cur = p;\n }\n return cur === r ? null : { name: cur.component, trigger: cur.trigger, report: cur };\n}\n\n/** Root causes of one commit's avoidable reports, most re-renders first. */\nfunction rootCausesOf<R extends ReportLike>(reports: readonly R[]): Pick<CommitAnalysis<R>, 'roots' | 'rootByReport' | 'avoidable' | 'wasted'> {\n const roots = new Map<string, RootCause>();\n const rootByReport = new Map<R, string>();\n const index = indexByComponent(reports);\n let avoidable = 0;\n let wasted = 0;\n for (const r of reports) {\n if (!r.avoidable) continue;\n avoidable++;\n if (typeof r.selfDuration === 'number') wasted += r.selfDuration;\n const root = rootCauseOf(r, reports, index);\n const name = root ? root.name : (r.parent && r.parent.name) || '(unknown)';\n const trigger = root ? root.trigger : (r.parent && r.parent.trigger) || 'parent';\n rootByReport.set(r, name);\n let agg = roots.get(name);\n if (!agg) {\n agg = { name, trigger, count: 0, components: new Map() };\n roots.set(name, agg);\n }\n agg.count++;\n bump(agg.components, r.component);\n }\n return { roots: [...roots.values()].sort((a, b) => b.count - a.count), rootByReport, avoidable, wasted };\n}\n\n/** Analyze the reports of one commit: what started the cascade, which contexts changed, what it cost. */\nexport function analyzeCommit<R extends ReportLike>(reports: R[]): CommitAnalysis<R> {\n const first = reports[0];\n return {\n id: first && typeof first.commitId === 'number' ? first.commitId : 0,\n total: reports.length,\n ...rootCausesOf(reports),\n contexts: contextAttribution(reports),\n reports,\n };\n}\n\n/** Which contexts changed and how many consumers re-rendered because of them. */\nexport function contextAttribution(reports: readonly ReportLike[]): ContextStat[] {\n const byCtx = new Map<string, ContextStat>();\n for (const r of reports) {\n for (const c of r.hookChanges || []) {\n if (c.hook !== 'useContext' && !/^useContext/.test(c.path)) continue;\n const m = /useContext\\((.*)\\)/.exec(c.path);\n const name = m && m[1] ? m[1] : c.path;\n let agg = byCtx.get(name);\n if (!agg) {\n agg = { name, consumers: 0, avoidable: 0, components: new Map(), commits: new Set(), providers: new Map(), changedKeys: new Set(), totalKeys: 0 };\n byCtx.set(name, agg);\n }\n agg.consumers++;\n if (AVOIDABLE_KINDS.has(c.kind)) agg.avoidable++;\n bump(agg.components, r.component);\n agg.commits.add(typeof r.commitId === 'number' ? r.commitId : 0);\n if (c.provider && c.provider.component) bump(agg.providers, c.provider.component);\n if (c.changedKeys) for (const k of c.changedKeys) agg.changedKeys.add(k);\n if (typeof c.totalKeys === 'number') agg.totalKeys = Math.max(agg.totalKeys, c.totalKeys);\n }\n }\n return [...byCtx.values()].sort((a, b) => b.consumers - a.consumers);\n}\n\n/** Nested cascade for one commit: every report placed under its ancestors (untracked ancestors appear as plain names). */\nexport function cascadeTree<R extends ReportLike>(reports: readonly R[]): CascadeNode<R> {\n const root: CascadeNode<R> = { name: '', children: new Map(), report: null };\n for (const r of reports) {\n let node = root;\n for (const seg of r.path.concat([r.component])) {\n let next = node.children.get(seg);\n if (!next) {\n next = { name: seg, children: new Map(), report: null };\n node.children.set(seg, next);\n }\n node = next;\n }\n if (!node.report || r.avoidable) node.report = r;\n node.count = (node.count || 0) + 1;\n if (r.avoidable) node.avoidable = (node.avoidable || 0) + 1;\n }\n return root;\n}\n\n/**\n * Every commit a component started (as the root cause), across the whole session.\n * `analyze` lets a caller (the panel) pass its per-commit memoized analysis.\n */\nexport function rootCauseSummary<R extends ReportLike>(name: string, commits: Iterable<[number, R[]]>): RootSummary<R>;\nexport function rootCauseSummary<R extends ReportLike, A extends CommitAnalysis<R>>(name: string, commits: Iterable<[number, R[]]>, analyze: (key: number, reports: R[]) => A): RootSummary<R, A>;\nexport function rootCauseSummary<R extends ReportLike, A extends CommitAnalysis<R>>(name: string, commits: Iterable<[number, R[]]>, analyze?: (key: number, reports: R[]) => A): RootSummary<R, A> {\n const analyzeFn = analyze || ((_: number, reports: R[]): A => analyzeCommit(reports) as A);\n const out: RootSummary<R, A> = { name, trigger: 'parent', commits: [], total: 0, components: new Map(), affected: [] };\n for (const [key, reports] of commits) {\n const analysis = analyzeFn(key, reports);\n const root = analysis.roots.find((x) => x.name === name);\n if (!root) continue;\n out.trigger = root.trigger;\n out.commits.push({ key, analysis, count: root.count, components: root.components });\n out.total += root.count;\n for (const [c, n] of root.components) bump(out.components, c, n);\n for (const r of reports) if (r.avoidable && analysis.rootByReport.get(r) === name) out.affected.push(r);\n }\n out.commits.reverse();\n return out;\n}\n\n/** Reports grouped by `commitId` in first-seen order. Reports without one (`useWhyRerender`, protocol 1) are left out. */\nexport function groupByCommit<R extends ReportLike>(reports: readonly R[]): Map<number, R[]> {\n const out = new Map<number, R[]>();\n for (const r of reports) {\n if (typeof r.commitId !== 'number' || r.commitId <= 0) continue;\n const list = out.get(r.commitId);\n if (list) list.push(r);\n else out.set(r.commitId, [r]);\n }\n return out;\n}\n\n/** Root causes across every commit in `reports`, most avoidable re-renders caused first. */\nexport function rankRootCauses(reports: readonly ReportLike[]): RankedRootCause[] {\n const byName = new Map<string, RankedRootCause>();\n for (const commit of groupByCommit(reports).values()) {\n for (const root of rootCausesOf(commit).roots) {\n let agg = byName.get(root.name);\n if (!agg) {\n agg = { name: root.name, trigger: root.trigger, commits: 0, count: 0, components: new Map() };\n byName.set(root.name, agg);\n }\n agg.commits++;\n agg.count += root.count;\n for (const [c, n] of root.components) bump(agg.components, c, n);\n }\n }\n return [...byName.values()].sort((a, b) => b.count - a.count || b.commits - a.commits || a.name.localeCompare(b.name));\n}\n\nconst plural = (n: number, word: string): string => `${n} ${word}${n === 1 ? '' : 's'}`;\n\n/**\n * Multi-line root-cause table for a test failure or a CI log, one line per root cause:\n * `<Page> (state) started 3 commits, 12 avoidable re-renders (<Row> x10, <Toolbar> x2)`.\n * Empty when nothing is avoidable or the reports carry no `commitId`.\n */\nexport function formatRootCauses(reports: readonly ReportLike[], limit = 5): string {\n const ranked = rankRootCauses(reports);\n const lines = ranked\n .slice(0, limit)\n .map((root, i) => `${String(i + 1).padStart(2)}. <${root.name}> (${root.trigger}) started ${plural(root.commits, 'commit')}, ${plural(root.count, 'avoidable re-render')} (${[...root.components].map(([c, n]) => `<${c}>${n > 1 ? ' x' + n : ''}`).join(', ')})`);\n if (ranked.length > limit) lines.push(` … ${ranked.length - limit} more`);\n return lines.join('\\n');\n}\n","/**\n * Concrete fixes derived from reports, ranked by how many avoidable re-renders each one removes.\n * One implementation for the library (tests, CI budgets, the CLI, typed on `RenderReport`) and the\n * DevTools panel (serialized reports): everything here reads only `ReportLike`. Pure.\n */\nimport type { ChangeLike, RenderReport, ReportLike } from './types';\nimport { AVOIDABLE_KINDS } from './diff';\nimport { formatRootCauses } from './causes';\n\nexport { AVOIDABLE_KINDS };\n\nexport type FixKind = 'memo' | 'useCallback' | 'useMemo' | 'useMemoElement' | 'children' | 'contextValue' | 'splitContext' | 'storeSnapshot' | 'bailout';\n\nexport interface Fix {\n kind: FixKind;\n /** Where the change goes (the component that must be edited, or `<Ctx>.Provider`). */\n owner: string;\n /** The component whose re-render this removes. */\n target: string;\n prop: string | null;\n label: string;\n detail: string;\n /** Code sketch of the fix, `// <owner>` on the first line. */\n snippet: string;\n}\n\nexport interface RankedFix<R extends ReportLike = RenderReport> extends Fix {\n key: string;\n /** Avoidable re-renders this fix removes. */\n count: number;\n components: Record<string, number>;\n /** The first (at most 50) reports the fix applies to. */\n reports: R[];\n}\n\nconst MAX_FIX_REPORTS = 50;\nconst rootOf = (path: string): string => path.split(/[.[]/)[0] || path;\nconst identifier = (name: string): string => (/^[A-Za-z_$][\\w$]*$/.test(name) ? name : 'value');\n\n/** `JSON.stringify` cut to `max` characters, for snippets and markdown; never throws. */\nexport function shortValue(v: unknown, max = 60): string {\n let s: string | undefined;\n try {\n s = JSON.stringify(v);\n } catch {\n s = String(v);\n }\n if (s === undefined) s = String(v);\n return s.length > max ? s.slice(0, max - 3) + '...' : s;\n}\n\n/** The concrete fixes one report suggests, each attributed to the component (file) that must change. */\nexport function fixesFor(r: ReportLike): Fix[] {\n const out: Fix[] = [];\n const ownerName = r.owner || (r.parent && r.parent.name) || null;\n const propChanges = r.propChanges || [];\n const changes: ChangeLike[] = [...propChanges, ...(r.stateChanges || []), ...(r.hookChanges || [])];\n // Not memoized: props alone will never stop the re-render, so React.memo comes first (in addition to\n // any prop fixes below). Reports from protocol-1 libraries have no `memoized`; assume memoized then.\n if (r.avoidable && (changes.length === 0 || r.memoized === false)) {\n const identical = changes.length === 0;\n out.push({\n kind: 'memo',\n owner: r.component,\n target: r.component,\n prop: null,\n label: `Wrap <${r.component}> in React.memo`,\n detail: identical\n ? `<${r.component}> re-rendered with identical props because <${(r.parent && r.parent.name) || 'its parent'}> re-rendered.`\n : `<${r.component}> is not memoized: fixing its props alone will not stop the re-render.`,\n snippet: `// ${r.component}\\nimport { memo } from 'react';\\n\\nexport const ${r.component} = memo(function ${r.component}(props) {\\n // ...\\n});\\n// class components: extend PureComponent instead`,\n });\n }\n for (const c of propChanges) {\n if (!AVOIDABLE_KINDS.has(c.kind)) continue;\n const owner = ownerName || '?';\n const root = rootOf(c.path);\n const id = identifier(root);\n if (root === 'children' && (c.kind === 'element' || c.kind === 'deep-equal')) {\n out.push({\n kind: 'children',\n owner,\n target: r.component,\n prop: 'children',\n label: `memoize children of <${r.component}> in <${owner}>`,\n detail: `<${owner}> re-creates the children of <${r.component}> on every render; they have the same types and props each time.`,\n snippet:\n `// ${owner}\\nimport { useMemo } from 'react';\\n\\nconst children = useMemo(() => (\\n <>{/* the same elements */}</>\\n), [/* deps */]);\\n\\n<${r.component}>{children}</${r.component}>\\n\\n` +\n `// static children: hoist them to module scope\\nconst STATIC = <em>hi</em>;`,\n });\n } else if (c.kind === 'function') {\n out.push({\n kind: 'useCallback',\n owner,\n target: r.component,\n prop: root,\n label: `useCallback(${root}) in <${owner}>`,\n detail: `prop \"${c.path}\" of <${r.component}> is a new function on every render of <${owner}>.`,\n snippet: `// ${owner}\\nimport { useCallback } from 'react';\\n\\nconst ${id} = useCallback((/* args */) => {\\n // ...\\n}, [/* deps */]);\\n\\n<${r.component} ${root}={${id}} />`,\n });\n } else if (c.kind === 'element') {\n out.push({\n kind: 'useMemoElement',\n owner,\n target: r.component,\n prop: root,\n label: `memoize element prop ${root} in <${owner}>`,\n detail: `prop \"${c.path}\" of <${r.component}> is a new element with the same type and props on every render of <${owner}>.`,\n snippet: `// ${owner}\\nimport { useMemo } from 'react';\\n\\nconst ${id} = useMemo(() => ${shortValue(c.next, 40)}, [/* deps */]);\\n// or pass it as children from a component that does not re-render`,\n });\n } else {\n const isArray = Array.isArray(c.next);\n out.push({\n kind: 'useMemo',\n owner,\n target: r.component,\n prop: root,\n label: `useMemo(${root}) in <${owner}>`,\n detail: `prop \"${c.path}\" of <${r.component}> is a new ${isArray ? 'array' : 'object'} with the same contents on every render of <${owner}>.`,\n snippet:\n `// ${owner}\\nimport { useMemo } from 'react';\\n\\nconst ${id} = useMemo(() => (${shortValue(c.next, 80)}), [/* deps */]);\\n\\n` +\n `// or, when it never changes, hoist it to module scope:\\nconst ${id.toUpperCase()} = ${shortValue(c.next, 80)};`,\n });\n }\n }\n for (const c of [...(r.stateChanges || []), ...(r.hookChanges || [])]) {\n const isContext = c.hook === 'useContext' || /^useContext/.test(c.path);\n const ctxName = isContext ? (/useContext\\((.*)\\)/.exec(c.path) || [])[1] || 'Context' : '';\n const providerOwner = isContext && c.provider && c.provider.component ? c.provider.component : null;\n // A genuine change of a few keys in an object context still re-renders every consumer.\n if (isContext && c.kind === 'different' && c.changedKeys && typeof c.totalKeys === 'number' && c.changedKeys.length > 0 && c.changedKeys.length < c.totalKeys) {\n out.push({\n kind: 'splitContext',\n owner: providerOwner || `${ctxName}.Provider`,\n target: r.component,\n prop: ctxName,\n label: `split ${ctxName}${providerOwner ? ` in <${providerOwner}>` : ''}: only ${c.changedKeys.join(', ')} changed`,\n detail: `${c.changedKeys.map((k) => `\"${k}\"`).join(', ')} of ${c.totalKeys} keys changed in ${ctxName}, yet every consumer (like <${r.component}>) re-rendered. Consumers that read the other keys re-render for nothing.`,\n snippet:\n `// ${providerOwner || 'Provider'}\\n// one context per independently-changing slice\\nconst ${identifier(ctxName)}Static = createContext(...);\\nconst ${identifier(ctxName)}${c.changedKeys.map((k) => k[0]!.toUpperCase() + k.slice(1)).join('')} = createContext(...);\\n\\n` +\n `// or keep one context and let consumers select a slice:\\nconst ${c.changedKeys[0]} = useContextSelector(${ctxName}, (v) => v.${c.changedKeys[0]});`,\n });\n continue;\n }\n if (!AVOIDABLE_KINDS.has(c.kind)) continue;\n if (isContext) {\n out.push({\n kind: 'contextValue',\n owner: providerOwner || `${ctxName}.Provider`,\n target: r.component,\n prop: ctxName,\n label: `memoize the ${ctxName} provider value${providerOwner ? ` in <${providerOwner}>` : ''}`,\n detail: `<${r.component}> re-rendered because ${ctxName} produced a new value that is deep-equal to the previous one${providerOwner ? ` (Provider rendered by <${providerOwner}>)` : ''}.`,\n snippet: `// ${providerOwner || `where <${ctxName}.Provider> is rendered`}\\nconst value = useMemo(() => ({ /* ... */ }), [/* deps */]);\\n<${ctxName}.Provider value={value}>`,\n });\n } else if (c.hook === 'useSyncExternalStore') {\n const chain = c.custom || [];\n const redux = chain.some((n) => /^use(App)?Selector$/.test(n));\n const zustand = !redux && chain.some((n) => /^use[A-Z]\\w*Store$/.test(n) || n === 'useStore' || n === 'useBoundStore');\n const via = chain.length ? ` via ${chain.join(' › ')}` : '';\n out.push({\n kind: 'storeSnapshot',\n owner: r.component,\n target: r.component,\n prop: c.path,\n label: redux ? `memoize the selector in <${r.component}>` : zustand ? `useShallow in <${r.component}>` : `stable getSnapshot in <${r.component}>`,\n detail: redux\n ? `the selector${via} returns a new object on every call, so the component re-renders on every store change.`\n : zustand\n ? `the store selector${via} returns a new object on every call, so the component re-renders on every store change.`\n : `${c.path}${via} returned a new reference with the same contents; getSnapshot must return a cached value.`,\n snippet: redux\n ? `// ${r.component}\\nimport { shallowEqual } from 'react-redux';\\nconst slice = useSelector(selectSlice, shallowEqual);\\n// or memoize: const selectSlice = createSelector([selectA, selectB], (a, b) => ({ a, b }));`\n : zustand\n ? `// ${r.component}\\nimport { useShallow } from 'zustand/react/shallow';\\nconst { a, b } = useStore(useShallow((s) => ({ a: s.a, b: s.b })));\\n// or select a primitive: const a = useStore((s) => s.a);`\n : `// ${r.component}\\n// getSnapshot must return the same reference while the data is unchanged\\nconst snapshot = useSyncExternalStore(subscribe, store.getSnapshot /* cached */);`,\n });\n } else {\n out.push({\n kind: 'bailout',\n owner: r.component,\n target: r.component,\n prop: c.path,\n label: `bail out before setting ${c.path} in <${r.component}>`,\n detail: `${c.path} was set to a value deep-equal to the current one (new reference).`,\n snippet: `// ${r.component}\\nsetState((prev) => (deepEqual(prev, next) ? prev : next));`,\n });\n }\n }\n return out;\n}\n\nexport const fixKey = (f: Fix): string => `${f.kind}|${f.owner}|${f.prop || f.target}`;\n\n/** Every fix across `reports`, most avoidable re-renders removed first. */\nexport function rankFixes<R extends ReportLike>(reports: readonly R[]): RankedFix<R>[] {\n const byKey = new Map<string, RankedFix<R>>();\n for (const r of reports) {\n if (!r.avoidable) continue;\n for (const f of fixesFor(r)) {\n const key = fixKey(f);\n let agg = byKey.get(key);\n if (!agg) {\n agg = { ...f, key, count: 0, components: {}, reports: [] };\n byKey.set(key, agg);\n }\n agg.count++;\n agg.components[r.component] = (agg.components[r.component] || 0) + 1;\n if (agg.reports.length < MAX_FIX_REPORTS) agg.reports.push(r);\n }\n }\n return [...byKey.values()].sort((a, b) => b.count - a.count || a.label.localeCompare(b.label));\n}\n\n/**\n * Multi-line text for a test failure or a CI log: the ranked fixes, then (when the reports carry\n * `commitId`) a \"Root causes\" section naming the components whose own changes started the cascades.\n */\nexport function formatFixes(reports: readonly ReportLike[], limit = 10): string {\n const ranked = rankFixes(reports);\n if (!ranked.length) return 'No avoidable re-renders.';\n const lines = ranked.slice(0, limit).map((f, i) => `${String(i + 1).padStart(2)}. ${f.label} (removes ${f.count}: ${Object.entries(f.components).map(([c, n]) => `<${c}>${n > 1 ? ' x' + n : ''}`).join(', ')})`);\n if (ranked.length > limit) lines.push(` … ${ranked.length - limit} more`);\n const roots = formatRootCauses(reports, 5);\n if (roots) lines.push('', 'Root causes:', roots);\n return lines.join('\\n');\n}\n","/**\n * Re-render budgets for CI: a JSON baseline of allowed avoidable re-renders per component, checked\n * against a collector's reports (like a bundle-size budget). Pure; reading and writing the file is\n * up to the test runner (`fs`), so this works in Node and in the browser.\n */\nimport type { RenderReport } from './types';\nimport { formatFixes } from './fixes';\n\n/** `{ \"*\": 0, \"ProductRow\": 3 }`: max avoidable re-renders per component; `*` is the default. */\nexport type Budget = Record<string, number>;\n\nexport interface BudgetViolation {\n component: string;\n avoidable: number;\n allowed: number;\n}\n\nexport interface BudgetResult {\n ok: boolean;\n violations: BudgetViolation[];\n /** Components with headroom left, so budgets can be tightened. */\n slack: { component: string; avoidable: number; allowed: number }[];\n counts: Record<string, number>;\n}\n\nexport function avoidableCounts(reports: RenderReport[]): Record<string, number> {\n const counts: Record<string, number> = {};\n for (const r of reports) if (r.avoidable) counts[r.component] = (counts[r.component] || 0) + 1;\n return counts;\n}\n\nexport function checkBudget(reports: RenderReport[], budget: Budget | number): BudgetResult {\n const b: Budget = typeof budget === 'number' ? { '*': budget } : budget;\n const fallback = typeof b['*'] === 'number' ? b['*'] : 0;\n const counts = avoidableCounts(reports);\n const violations: BudgetViolation[] = [];\n const slack: BudgetResult['slack'] = [];\n const names = new Set([...Object.keys(counts), ...Object.keys(b).filter((k) => k !== '*')]);\n for (const component of names) {\n const allowed = typeof b[component] === 'number' ? b[component]! : fallback;\n const avoidable = counts[component] || 0;\n if (avoidable > allowed) violations.push({ component, avoidable, allowed });\n else if (avoidable < allowed) slack.push({ component, avoidable, allowed });\n }\n violations.sort((x, y) => y.avoidable - y.allowed - (x.avoidable - x.allowed));\n return { ok: violations.length === 0, violations, slack, counts };\n}\n\n/** A budget that exactly matches the current counts (the baseline to commit). */\nexport function toBudget(reports: RenderReport[]): Budget {\n return { '*': 0, ...avoidableCounts(reports) };\n}\n\n/** Throws with the violations and the ranked fixes; use it from a test. */\nexport function assertWithinBudget(reports: RenderReport[], budget: Budget | number): BudgetResult {\n const result = checkBudget(reports, budget);\n if (result.ok) return result;\n const lines = result.violations.map((v) => ` <${v.component}>: ${v.avoidable} avoidable re-render${v.avoidable === 1 ? '' : 's'} (budget ${v.allowed})`);\n throw new Error(`Re-render budget exceeded:\\n${lines.join('\\n')}\\n\\nFixes, most impact first:\\n${formatFixes(reports)}`);\n}\n","/**\n * Playwright helper: run rerender-lens inside any page under test, then pull the reports and assert\n * a budget from the test. Works on production-like builds too (names may be minified there).\n *\n * import { installRerenderLens, pullReports, expectWithinBudget } from 'rerender-lens/playwright';\n * await installRerenderLens(page, { trackAllMemoized: true }); // before page.goto\n * await page.goto('/');\n * ...interact...\n * expectWithinBudget(await pullReports(page), { '*': 0, ProductRow: 3 });\n *\n * The library bundle is injected with `page.addInitScript` at document start, exactly like the\n * extension's injection mode, so `init` runs before react-dom.\n */\nimport { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { RenderReport } from './types';\nimport type { SerializableOptions } from './devtools';\nimport { assertWithinBudget, checkBudget, type Budget, type BudgetResult } from './budget';\nimport { rankFixes, formatFixes, type RankedFix } from './fixes';\n\n/** The subset of Playwright's `Page` used here (keeps `@playwright/test` an optional peer). */\nexport interface PageLike {\n addInitScript(script: string | { content?: string }): Promise<void>;\n evaluate<R>(fn: string | ((arg: unknown) => R), arg?: unknown): Promise<R>;\n}\n\nexport interface InstallOptions extends SerializableOptions {\n /** Forward to a relay (`npx rerender-lens panel`) to watch the test in the panel. */\n relay?: string;\n /** Print to the page console (default false in tests). */\n silent?: boolean;\n /** Library source to inject instead of the packaged IIFE bundle (must define `window.RerenderLens`). */\n bundle?: string;\n}\n\nlet bundleCache: string | null = null;\n\n/** The vendor scripts the extension injects, in load order (see scripts/build-vendor.mjs). */\nexport const VENDOR_FILES = ['rerender-lens.core.js', 'rerender-lens.engine.js', 'rerender-lens.js'];\n\n/** The library as one script (`window.RerenderLens`): `dist/rerender-lens.iife.js`, or the vendor parts joined in this repo. */\nexport function libraryBundle(): string {\n if (bundleCache) return bundleCache;\n const here = dirname(fileURLToPath(import.meta.url));\n const candidates = [[join(here, 'rerender-lens.iife.js')], VENDOR_FILES.map((f) => join(here, '..', 'extension', 'vendor', f))];\n for (const files of candidates) {\n try {\n bundleCache = files.map((f) => readFileSync(f, 'utf8')).join('\\n;\\n');\n return bundleCache;\n } catch {\n /* next */\n }\n }\n throw new Error('rerender-lens: library bundle not found (run `npm run build` in the rerender-lens repo, or reinstall the package)');\n}\n\n/** Script that starts the library with `options` before any page script runs. */\nexport function installScript(options: InstallOptions = {}): string {\n const { relay, bundle, ...rest } = options;\n const opts: InstallOptions = { trackAllMemoized: true, silent: true, ...rest };\n return `${bundle ?? libraryBundle()}\\n;(function(){\\n if (window.__RERENDER_LENS_DEVTOOLS__) return;\\n var L = window.RerenderLens;\\n L.ensureDevtoolsHook();\\n var o = ${JSON.stringify(opts)};\\n o.notifier = L.createDevtoolsNotifier(${relay ? JSON.stringify({ relay }) : '{}'});\\n if (o.include) o.include = o.include.map(function (m) { var r = /^\\\\/(.+)\\\\/([a-z]*)$/.exec(m); return r ? new RegExp(r[1], r[2]) : m; });\\n if (o.exclude) o.exclude = o.exclude.map(function (m) { var r = /^\\\\/(.+)\\\\/([a-z]*)$/.exec(m); return r ? new RegExp(r[1], r[2]) : m; });\\n L.init(o);\\n window.__RERENDER_LENS_PLAYWRIGHT__ = true;\\n})();`;\n}\n\n/** Call before `page.goto`. */\nexport async function installRerenderLens(page: PageLike, options: InstallOptions = {}): Promise<void> {\n await page.addInitScript({ content: installScript(options) });\n}\n\n/** Every report buffered in the page so far (serialized: functions are `ƒ name`, elements `{ $type: 'element' }`). */\nexport async function pullReports(page: PageLike): Promise<RenderReport[]> {\n const result = await page.evaluate<{ reports: unknown[] } | null>('(function(){var b=window.__RERENDER_LENS_DEVTOOLS__;return b&&b.pull?b.pull(0):null})()');\n if (!result) throw new Error('rerender-lens is not running in the page: call installRerenderLens(page) before page.goto');\n return result.reports as RenderReport[];\n}\n\n/** Drop the page buffer (between scenarios). */\nexport async function clearReports(page: PageLike): Promise<void> {\n await page.evaluate('(function(){var b=window.__RERENDER_LENS_DEVTOOLS__;if(b)b.clear();})()');\n}\n\nexport { checkBudget, rankFixes, formatFixes };\nexport type { Budget, BudgetResult, RankedFix };\n\n/** Throws with the violations and ranked fixes, like `collector.assertWithinBudget`. */\nexport function expectWithinBudget(reports: RenderReport[], budget: Budget | number): BudgetResult {\n return assertWithinBudget(reports, budget);\n}\n"]}
|
package/dist/playwright.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { R as RenderReport } from './types-
|
|
2
|
-
import { S as SerializableOptions } from './devtools-
|
|
3
|
-
import { B as Budget, a as BudgetResult } from './budget-
|
|
4
|
-
export { R as RankedFix, c as checkBudget, f as formatFixes, r as rankFixes } from './budget-
|
|
1
|
+
import { R as RenderReport } from './types-DwNN5cWe.cjs';
|
|
2
|
+
import { S as SerializableOptions } from './devtools-UwQx2VYS.cjs';
|
|
3
|
+
import { B as Budget, a as BudgetResult } from './budget-CA1MS7lB.cjs';
|
|
4
|
+
export { R as RankedFix, c as checkBudget, f as formatFixes, r as rankFixes } from './budget-CA1MS7lB.cjs';
|
|
5
5
|
|
|
6
6
|
/** The subset of Playwright's `Page` used here (keeps `@playwright/test` an optional peer). */
|
|
7
7
|
interface PageLike {
|
package/dist/playwright.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { R as RenderReport } from './types-
|
|
2
|
-
import { S as SerializableOptions } from './devtools-
|
|
3
|
-
import { B as Budget, a as BudgetResult } from './budget-
|
|
4
|
-
export { R as RankedFix, c as checkBudget, f as formatFixes, r as rankFixes } from './budget-
|
|
1
|
+
import { R as RenderReport } from './types-DwNN5cWe.js';
|
|
2
|
+
import { S as SerializableOptions } from './devtools-Cl5n_52v.js';
|
|
3
|
+
import { B as Budget, a as BudgetResult } from './budget-ok1VDJ4t.js';
|
|
4
|
+
export { R as RankedFix, c as checkBudget, f as formatFixes, r as rankFixes } from './budget-ok1VDJ4t.js';
|
|
5
5
|
|
|
6
6
|
/** The subset of Playwright's `Page` used here (keeps `@playwright/test` an optional peer). */
|
|
7
7
|
interface PageLike {
|