react-render-detective 0.1.3 → 0.3.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/README.md +29 -3
- package/dist/babel.cjs +9 -0
- package/dist/babel.cjs.map +1 -0
- package/dist/babel.d.cts +38 -0
- package/dist/babel.d.ts +38 -0
- package/dist/babel.js +3 -0
- package/dist/babel.js.map +1 -0
- package/dist/{chunk-SKLDIIL6.cjs → chunk-DZ3BZ654.cjs} +94 -6
- package/dist/chunk-DZ3BZ654.cjs.map +1 -0
- package/dist/{chunk-D4G4D5AC.js → chunk-HOTY7J3X.js} +19 -6
- package/dist/chunk-HOTY7J3X.js.map +1 -0
- package/dist/{chunk-U3SAWFCT.cjs → chunk-JD4IJ4MN.cjs} +19 -6
- package/dist/chunk-JD4IJ4MN.cjs.map +1 -0
- package/dist/chunk-MCIQMYNR.js +167 -0
- package/dist/chunk-MCIQMYNR.js.map +1 -0
- package/dist/chunk-PHYYA67T.cjs +169 -0
- package/dist/chunk-PHYYA67T.cjs.map +1 -0
- package/dist/{chunk-27IWHWSM.js → chunk-QOGTEVBP.js} +94 -6
- package/dist/chunk-QOGTEVBP.js.map +1 -0
- package/dist/core.cjs +18 -18
- package/dist/core.d.cts +41 -3
- package/dist/core.d.ts +41 -3
- package/dist/core.js +1 -1
- package/dist/index.cjs +50 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -3
- package/dist/index.d.ts +25 -3
- package/dist/index.js +24 -9
- package/dist/index.js.map +1 -1
- package/dist/overlay.cjs +7 -7
- package/dist/overlay.cjs.map +1 -1
- package/dist/overlay.js +5 -5
- package/dist/overlay.js.map +1 -1
- package/dist/{types-CY61yfhK.d.cts → types-gl13xwmN.d.cts} +12 -0
- package/dist/{types-CY61yfhK.d.ts → types-gl13xwmN.d.ts} +12 -0
- package/dist/vite.cjs +51 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.cts +19 -0
- package/dist/vite.d.ts +19 -0
- package/dist/vite.js +46 -0
- package/dist/vite.js.map +1 -0
- package/package.json +19 -2
- package/dist/chunk-27IWHWSM.js.map +0 -1
- package/dist/chunk-D4G4D5AC.js.map +0 -1
- package/dist/chunk-SKLDIIL6.cjs.map +0 -1
- package/dist/chunk-U3SAWFCT.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
[Guide](docs/GUIDE.md) · [API](docs/API.md) · [Feasibility report](docs/FEASIBILITY.md) ·
|
|
12
12
|
[Benchmarks](docs/BENCHMARKS.md)
|
|
13
13
|
|
|
14
|
-
> **Status: 0.
|
|
14
|
+
> **Status: 0.3.0, early release.** 76 tests pass on React 18 and 19; benchmarks and bundle budgets
|
|
15
15
|
> are green; the packed package is verified in a clean install for ESM, CJS and TypeScript
|
|
16
16
|
> consumers; and the demo dashboard has been driven end to end in Chrome, which found four real
|
|
17
17
|
> defects the jsdom suite had missed (see the [changelog](CHANGELOG.md)). Not yet exercised:
|
|
@@ -135,6 +135,32 @@ Three rules it holds to, which most render-debugging advice does not:
|
|
|
135
135
|
|
|
136
136
|
---
|
|
137
137
|
|
|
138
|
+
## Automatic instrumentation
|
|
139
|
+
|
|
140
|
+
Wrapping by hand only finds problems you already suspected. One line instruments the whole app and
|
|
141
|
+
adds source locations:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
// vite.config.ts
|
|
145
|
+
import { renderDetective } from "react-render-detective/vite";
|
|
146
|
+
export default defineConfig({ plugins: [renderDetective(), react()] });
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
TableRow src/App.tsx:85:7
|
|
151
|
+
|
|
152
|
+
Why?
|
|
153
|
+
100% of updates followed `onSelect` changing by reference while its contents stayed the same.
|
|
154
|
+
|
|
155
|
+
Next step
|
|
156
|
+
Trace `onSelect` back from ProductTable (src/App.tsx:110:1), which passes it to TableRow,
|
|
157
|
+
and stabilise it where it is created (useCallback, or hoist it out of the component).
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Babel is supported too, for Next.js, webpack and Remix — see the
|
|
161
|
+
[guide](docs/GUIDE.md#automatic-instrumentation-recommended). Dev-only; it removes itself from
|
|
162
|
+
production builds.
|
|
163
|
+
|
|
138
164
|
## Integration modes
|
|
139
165
|
|
|
140
166
|
### `withRenderDetective` — most accurate
|
|
@@ -265,8 +291,8 @@ The headlines:
|
|
|
265
291
|
`state-or-external` — we say we cannot tell which, rather than guessing.
|
|
266
292
|
- **`useTrackedState` must be called in an instrumented component.** A hook cannot see its own
|
|
267
293
|
caller, only the nearest instrumented ancestor.
|
|
268
|
-
- **Source locations**
|
|
269
|
-
|
|
294
|
+
- **Source locations** come from the build plugin. Without it there is no runtime way to get them —
|
|
295
|
+
`_debugSource` was removed in React 19.
|
|
270
296
|
- **Self duration** is an upper bound: React exposes subtree time, and we subtract the instrumented
|
|
271
297
|
descendants we know about.
|
|
272
298
|
|
package/dist/babel.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"babel.cjs"}
|
package/dist/babel.d.cts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { types, PluginObject } from '@babel/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Babel plugin: instrument every React component in a file at build time.
|
|
5
|
+
*
|
|
6
|
+
* Why this exists: without it you only learn about components you already
|
|
7
|
+
* suspected, because you have to wrap them by hand. With it, the tool reports
|
|
8
|
+
* on the whole tree — and it can attach a real source location, which React
|
|
9
|
+
* itself no longer exposes at runtime (`_debugSource` was removed in React 19).
|
|
10
|
+
*
|
|
11
|
+
* Build-time only. It must never run in a production build, and it removes
|
|
12
|
+
* itself when `NODE_ENV` is production unless explicitly forced.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface RenderDetectivePluginOptions {
|
|
16
|
+
/** Defaults to `NODE_ENV !== "production"`. */
|
|
17
|
+
enabled?: boolean;
|
|
18
|
+
/** Only instrument files whose path matches. Empty = all files. */
|
|
19
|
+
include?: Array<string | RegExp>;
|
|
20
|
+
/** Skip files whose path matches. Applied after `include`. */
|
|
21
|
+
exclude?: Array<string | RegExp>;
|
|
22
|
+
/**
|
|
23
|
+
* Skip files with no `"use client"` directive. Turn this on for the Next.js
|
|
24
|
+
* app router: server components never render on the client, and wrapping one
|
|
25
|
+
* in a hook-using HOC would break the build.
|
|
26
|
+
*/
|
|
27
|
+
clientOnly?: boolean;
|
|
28
|
+
/** Import specifier for the runtime. Overridable for testing and monorepos. */
|
|
29
|
+
importSource?: string;
|
|
30
|
+
/** Root used to make source locations relative. Defaults to `process.cwd()`. */
|
|
31
|
+
root?: string;
|
|
32
|
+
}
|
|
33
|
+
declare function renderDetectiveBabelPlugin(api: {
|
|
34
|
+
types: typeof types;
|
|
35
|
+
assertVersion?: (v: number | string) => void;
|
|
36
|
+
}): PluginObject;
|
|
37
|
+
|
|
38
|
+
export { type RenderDetectivePluginOptions, renderDetectiveBabelPlugin as default };
|
package/dist/babel.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { types, PluginObject } from '@babel/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Babel plugin: instrument every React component in a file at build time.
|
|
5
|
+
*
|
|
6
|
+
* Why this exists: without it you only learn about components you already
|
|
7
|
+
* suspected, because you have to wrap them by hand. With it, the tool reports
|
|
8
|
+
* on the whole tree — and it can attach a real source location, which React
|
|
9
|
+
* itself no longer exposes at runtime (`_debugSource` was removed in React 19).
|
|
10
|
+
*
|
|
11
|
+
* Build-time only. It must never run in a production build, and it removes
|
|
12
|
+
* itself when `NODE_ENV` is production unless explicitly forced.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface RenderDetectivePluginOptions {
|
|
16
|
+
/** Defaults to `NODE_ENV !== "production"`. */
|
|
17
|
+
enabled?: boolean;
|
|
18
|
+
/** Only instrument files whose path matches. Empty = all files. */
|
|
19
|
+
include?: Array<string | RegExp>;
|
|
20
|
+
/** Skip files whose path matches. Applied after `include`. */
|
|
21
|
+
exclude?: Array<string | RegExp>;
|
|
22
|
+
/**
|
|
23
|
+
* Skip files with no `"use client"` directive. Turn this on for the Next.js
|
|
24
|
+
* app router: server components never render on the client, and wrapping one
|
|
25
|
+
* in a hook-using HOC would break the build.
|
|
26
|
+
*/
|
|
27
|
+
clientOnly?: boolean;
|
|
28
|
+
/** Import specifier for the runtime. Overridable for testing and monorepos. */
|
|
29
|
+
importSource?: string;
|
|
30
|
+
/** Root used to make source locations relative. Defaults to `process.cwd()`. */
|
|
31
|
+
root?: string;
|
|
32
|
+
}
|
|
33
|
+
declare function renderDetectiveBabelPlugin(api: {
|
|
34
|
+
types: typeof types;
|
|
35
|
+
assertVersion?: (v: number | string) => void;
|
|
36
|
+
}): PluginObject;
|
|
37
|
+
|
|
38
|
+
export { type RenderDetectivePluginOptions, renderDetectiveBabelPlugin as default };
|
package/dist/babel.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"babel.js"}
|
|
@@ -326,6 +326,21 @@ function diagnose(input, thresholds) {
|
|
|
326
326
|
function classify(input) {
|
|
327
327
|
const { changedProps, contextChanges, parentRendered, parentUnknown, parentName } = input;
|
|
328
328
|
if (input.phase === "mount") {
|
|
329
|
+
if (input.remounts >= 2) {
|
|
330
|
+
const inline = input.inlineDefinitionSuspected;
|
|
331
|
+
return make(
|
|
332
|
+
"mount",
|
|
333
|
+
inline ? "high" : "medium",
|
|
334
|
+
`${input.componentName} was rebuilt, not re-rendered \u2014 this is remount ${input.remounts + 1}.`,
|
|
335
|
+
[
|
|
336
|
+
`This component has been unmounted and mounted again ${input.remounts}\xD7 \u2014 its DOM and all of its state were discarded each time.`,
|
|
337
|
+
inline ? "Its definition is being re-created repeatedly in a short window, which means it is declared *inside* another component's render body. React sees a new component type on every parent render and cannot reuse anything." : "Its definition is stable, so the remounts come from the element identity changing \u2014 usually a changing `key`, or the component moving between branches of a conditional.",
|
|
338
|
+
"A remount is much more expensive than a re-render, and it resets state."
|
|
339
|
+
],
|
|
340
|
+
true,
|
|
341
|
+
inline ? `Move ${input.componentName} out of its parent's render body to module scope. Defining a component inside another component makes React discard and rebuild the whole subtree on every parent render.` : `Check the \`key\` given to ${input.componentName}, and whether it is being rendered from a different branch each time.`
|
|
342
|
+
);
|
|
343
|
+
}
|
|
329
344
|
return make("mount", "high", `${input.componentName} mounted.`, ["First render of this instance."], false);
|
|
330
345
|
}
|
|
331
346
|
if (input.trackedState.length > 0) {
|
|
@@ -572,6 +587,8 @@ var RingBuffer = class {
|
|
|
572
587
|
|
|
573
588
|
// src/core/store.ts
|
|
574
589
|
var now = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
590
|
+
var INLINE_DEFINITION_WINDOW_MS = 5e3;
|
|
591
|
+
var timestamp = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
575
592
|
var EMPTY_STATE = [];
|
|
576
593
|
var DURATION_SAMPLE = 200;
|
|
577
594
|
var SWEEP_DELAY_MS = 250;
|
|
@@ -595,6 +612,10 @@ var Detective = class {
|
|
|
595
612
|
this.seq = 0;
|
|
596
613
|
this.flushScheduled = false;
|
|
597
614
|
this.nextId = 0;
|
|
615
|
+
/** Mount/unmount history per component name, for remount detection. */
|
|
616
|
+
this.lifecycles = /* @__PURE__ */ new Map();
|
|
617
|
+
/** How often each component *definition* has been wrapped. */
|
|
618
|
+
this.definitions = /* @__PURE__ */ new Map();
|
|
598
619
|
/** Nodes created by `useRenderDiagnostics`, where props/state cannot be separated. */
|
|
599
620
|
this.hookModeNodes = /* @__PURE__ */ new WeakSet();
|
|
600
621
|
this.initialized = false;
|
|
@@ -636,12 +657,13 @@ var Detective = class {
|
|
|
636
657
|
* discards one of the two, and only the surviving fiber's effect attaches —
|
|
637
658
|
* so discarded nodes are simply garbage collected.
|
|
638
659
|
*/
|
|
639
|
-
createNode(name, parent) {
|
|
660
|
+
createNode(name, parent, source) {
|
|
640
661
|
if (!shouldInstrument(name, this.config)) return void 0;
|
|
641
662
|
const sampled = this.config.samplingRate >= 1 || Math.random() < this.config.samplingRate;
|
|
642
663
|
const node = {
|
|
643
664
|
id: `rrd_${++this.nextId}`,
|
|
644
665
|
name,
|
|
666
|
+
source,
|
|
645
667
|
parent,
|
|
646
668
|
depth: parent ? parent.depth + 1 : 0,
|
|
647
669
|
sampled,
|
|
@@ -667,9 +689,66 @@ var Detective = class {
|
|
|
667
689
|
}
|
|
668
690
|
attach(node) {
|
|
669
691
|
this.nodes.set(node.id, node);
|
|
692
|
+
if (node.detached) {
|
|
693
|
+
node.detached = false;
|
|
694
|
+
const existing = this.lifecycles.get(node.name);
|
|
695
|
+
if (existing) existing.unmounts--;
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
if (node.everAttached) return;
|
|
699
|
+
node.everAttached = true;
|
|
700
|
+
const life = this.lifecycleFor(node.name);
|
|
701
|
+
life.mounts++;
|
|
702
|
+
if (life.unmounts > 0) life.remounts++;
|
|
670
703
|
}
|
|
671
704
|
detach(node) {
|
|
672
705
|
this.nodes.delete(node.id);
|
|
706
|
+
if (node.everAttached && !node.detached) {
|
|
707
|
+
node.detached = true;
|
|
708
|
+
this.lifecycleFor(node.name).unmounts++;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
lifecycleFor(name) {
|
|
712
|
+
let life = this.lifecycles.get(name);
|
|
713
|
+
if (!life) this.lifecycles.set(name, life = { mounts: 0, unmounts: 0, remounts: 0 });
|
|
714
|
+
return life;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Called once per `withRenderDetective` call. A component declared at module
|
|
718
|
+
* scope is wrapped once; one declared *inside* a render body is wrapped again
|
|
719
|
+
* on every render of its parent — which also forces React to throw away and
|
|
720
|
+
* rebuild its entire subtree. That is the signal.
|
|
721
|
+
*/
|
|
722
|
+
noteDefinition(name, source, declaredInRender = false) {
|
|
723
|
+
const key = source ?? name;
|
|
724
|
+
const now2 = timestamp();
|
|
725
|
+
const record = this.definitions.get(key);
|
|
726
|
+
if (!record) {
|
|
727
|
+
this.definitions.set(key, { name, count: 1, firstSeen: now2, lastSeen: now2, declaredInRender });
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
record.count++;
|
|
731
|
+
record.lastSeen = now2;
|
|
732
|
+
if (declaredInRender) record.declaredInRender = true;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Is this component declared inside another component's render body?
|
|
736
|
+
*
|
|
737
|
+
* The build plugin answers this statically and exactly. Without it we fall
|
|
738
|
+
* back to a rate heuristic — repeated definitions of the same component in a
|
|
739
|
+
* short window — which is weaker: hot reload also re-defines components, and
|
|
740
|
+
* a user clicking slowly stretches the window. Hence the plugin's answer wins.
|
|
741
|
+
*/
|
|
742
|
+
inlineDefinitionSuspected(name) {
|
|
743
|
+
for (const record of this.definitions.values()) {
|
|
744
|
+
if (record.name !== name) continue;
|
|
745
|
+
if (record.declaredInRender) return true;
|
|
746
|
+
if (record.count >= 3 && record.lastSeen - record.firstSeen < INLINE_DEFINITION_WINDOW_MS) return true;
|
|
747
|
+
}
|
|
748
|
+
return false;
|
|
749
|
+
}
|
|
750
|
+
lifecycleOf(name) {
|
|
751
|
+
return this.lifecycles.get(name) ?? { mounts: 0, unmounts: 0, remounts: 0 };
|
|
673
752
|
}
|
|
674
753
|
/** Hot path. Must stay allocation-free and O(1). */
|
|
675
754
|
recordAttempt(node, props) {
|
|
@@ -826,6 +905,8 @@ var Detective = class {
|
|
|
826
905
|
attempts: rec.attempts,
|
|
827
906
|
committed: true,
|
|
828
907
|
trackedState,
|
|
908
|
+
remounts: this.lifecycleOf(node.name).remounts,
|
|
909
|
+
inlineDefinitionSuspected: this.inlineDefinitionSuspected(node.name),
|
|
829
910
|
priorAvoidableRenders: node.stats.potentiallyAvoidableRenders
|
|
830
911
|
},
|
|
831
912
|
this.config.thresholds
|
|
@@ -833,6 +914,7 @@ var Detective = class {
|
|
|
833
914
|
const componentInfo = {
|
|
834
915
|
id: node.id,
|
|
835
916
|
name: node.name,
|
|
917
|
+
source: node.source,
|
|
836
918
|
parentId: parent?.id,
|
|
837
919
|
depth: node.depth
|
|
838
920
|
};
|
|
@@ -852,7 +934,7 @@ var Detective = class {
|
|
|
852
934
|
},
|
|
853
935
|
changedProps: changed,
|
|
854
936
|
unchangedProps: unchanged,
|
|
855
|
-
parent: parent ? { id: parent.id, name: parent.name, parentId: parent.parent?.id, depth: parent.depth } : void 0,
|
|
937
|
+
parent: parent ? { id: parent.id, name: parent.name, source: parent.source, parentId: parent.parent?.id, depth: parent.depth } : void 0,
|
|
856
938
|
parentRendered,
|
|
857
939
|
selfOriginated: propsReevaluated === false,
|
|
858
940
|
contextChanges: relevantContexts,
|
|
@@ -906,7 +988,7 @@ var Detective = class {
|
|
|
906
988
|
for (const node of this.nodes.values()) {
|
|
907
989
|
if (name && node.name !== name) continue;
|
|
908
990
|
if (node.stats.renderCount === 0 && node.stats.uncommittedAttempts === 0) continue;
|
|
909
|
-
out.push(toStats(node));
|
|
991
|
+
out.push(toStats(node, this.lifecycleOf(node.name)));
|
|
910
992
|
}
|
|
911
993
|
return out;
|
|
912
994
|
}
|
|
@@ -954,6 +1036,8 @@ var Detective = class {
|
|
|
954
1036
|
reset() {
|
|
955
1037
|
this.clear();
|
|
956
1038
|
this.nodes.clear();
|
|
1039
|
+
this.lifecycles.clear();
|
|
1040
|
+
this.definitions.clear();
|
|
957
1041
|
this.listeners.clear();
|
|
958
1042
|
if (this.sweepHandle !== void 0) clearTimeout(this.sweepHandle);
|
|
959
1043
|
this.sweepHandle = void 0;
|
|
@@ -967,14 +1051,16 @@ function percentile(sorted, p) {
|
|
|
967
1051
|
const idx = Math.min(sorted.length - 1, Math.max(0, Math.ceil(p / 100 * sorted.length) - 1));
|
|
968
1052
|
return sorted[idx];
|
|
969
1053
|
}
|
|
970
|
-
function toStats(node) {
|
|
1054
|
+
function toStats(node, lifecycle) {
|
|
971
1055
|
const sorted = [...node.durations].sort((a, b) => a - b);
|
|
972
1056
|
const s = node.stats;
|
|
973
1057
|
return {
|
|
974
1058
|
id: node.id,
|
|
975
1059
|
name: node.name,
|
|
1060
|
+
source: node.source,
|
|
976
1061
|
renderCount: s.renderCount,
|
|
977
1062
|
mountCount: s.mountCount,
|
|
1063
|
+
remountCount: lifecycle.remounts,
|
|
978
1064
|
uncommittedAttempts: s.uncommittedAttempts,
|
|
979
1065
|
devReplays: s.devReplays,
|
|
980
1066
|
totalSelfDuration: s.totalSelfDuration,
|
|
@@ -996,8 +1082,10 @@ function mergeStats(a, b) {
|
|
|
996
1082
|
return {
|
|
997
1083
|
id: a.id,
|
|
998
1084
|
name: a.name,
|
|
1085
|
+
source: a.source ?? b.source,
|
|
999
1086
|
renderCount,
|
|
1000
1087
|
mountCount: a.mountCount + b.mountCount,
|
|
1088
|
+
remountCount: Math.max(a.remountCount, b.remountCount),
|
|
1001
1089
|
uncommittedAttempts: a.uncommittedAttempts + b.uncommittedAttempts,
|
|
1002
1090
|
devReplays: a.devReplays + b.devReplays,
|
|
1003
1091
|
totalSelfDuration: total,
|
|
@@ -1035,5 +1123,5 @@ exports.severityFor = severityFor;
|
|
|
1035
1123
|
exports.shallowEqual = shallowEqual;
|
|
1036
1124
|
exports.shouldInstrument = shouldInstrument;
|
|
1037
1125
|
exports.valueType = valueType;
|
|
1038
|
-
//# sourceMappingURL=chunk-
|
|
1039
|
-
//# sourceMappingURL=chunk-
|
|
1126
|
+
//# sourceMappingURL=chunk-DZ3BZ654.cjs.map
|
|
1127
|
+
//# sourceMappingURL=chunk-DZ3BZ654.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/inspect.ts","../src/core/config.ts","../src/core/compare.ts","../src/core/diagnose.ts","../src/core/ringBuffer.ts","../src/core/store.ts"],"names":["take","keys","evidence","now"],"mappings":";;;AAEA,IAAM,aA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D,oBAAoB,IAAA,CAAK,GAAA,CAAI,CAAA,CAAE,kBAAA,EAAoB,EAAE,kBAAkB,CAAA;AAAA,IACvE,iBAAiB,IAAA,CAAK,GAAA,CAAI,CAAA,CAAE,eAAA,EAAiB,EAAE,eAAe,CAAA;AAAA,IAC9D,iBAAiB,IAAA,CAAK,GAAA,CAAI,CAAA,CAAE,eAAA,EAAiB,EAAE,eAAe,CAAA;AAAA,IAC9D,iBAAiB,IAAA,CAAK,GAAA,CAAI,CAAA,CAAE,eAAA,EAAiB,EAAE,eAAe,CAAA;AAAA,IAC9D,WAAA,EAAa,CAAA,CAAE,WAAA,GAAc,CAAA,CAAE,WAAA;AAAA,IAC/B,2BAAA,EAA6B,CAAA,CAAE,2BAAA,GAA8B,CAAA,CAAE,2BAAA;AAAA,IAC/D;AAAA,GACF;AACF;AAQA,IAAM,GAAA,mBAAM,MAAA,CAAO,GAAA,CAAI,iCAAiC,CAAA;AAGjD,SAAS,YAAA,GAA0B;AACxC,EAAA,MAAM,CAAA,GAAI,UAAA;AACV,EAAA,IAAI,CAAC,EAAE,GAAG,CAAA,IAAK,GAAG,CAAA,GAAI,IAAI,SAAA,EAAU;AACpC,EAAA,OAAO,EAAE,GAAG,CAAA;AACd","file":"chunk-DZ3BZ654.cjs","sourcesContent":["import type { Inspected, InspectionLimits, PropValueType } from \"./types.js\";\n\nconst REACT_ELEMENT = Symbol.for(\"react.element\");\nconst REACT_TRANSITIONAL_ELEMENT = Symbol.for(\"react.transitional.element\");\n\nexport function isReactElement(value: unknown): boolean {\n if (typeof value !== \"object\" || value === null) return false;\n const t = (value as { $$typeof?: symbol }).$$typeof;\n return t === REACT_ELEMENT || t === REACT_TRANSITIONAL_ELEMENT;\n}\n\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null) return false;\n if (Array.isArray(value)) return false;\n if (isReactElement(value)) return false;\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\nexport function valueType(value: unknown): PropValueType {\n if (value === null) return \"null\";\n if (Array.isArray(value)) return \"array\";\n if (isReactElement(value)) return \"element\";\n const t = typeof value;\n if (t === \"object\") return \"object\";\n if (t === \"function\") return \"function\";\n return t as PropValueType;\n}\n\nfunction elementName(value: unknown): string {\n const type = (value as { type?: unknown }).type;\n if (typeof type === \"string\") return type;\n if (typeof type === \"function\") return (type as { displayName?: string; name?: string }).displayName ?? (type as { name?: string }).name ?? \"Anonymous\";\n return \"Element\";\n}\n\n/**\n * Bounded, cycle-safe, non-retaining snapshot.\n *\n * Deliberately not `JSON.stringify`: that throws on cycles and BigInt, drops\n * `undefined`/functions/symbols, and has no size ceiling.\n */\nexport function inspect(value: unknown, limits: InspectionLimits): Inspected {\n const budget = { nodes: limits.maxSerializedNodes };\n try {\n return walk(value, limits, budget, limits.depth, new WeakSet<object>());\n } catch {\n return { t: \"truncated\", hint: \"inspection failed\" };\n }\n}\n\nfunction walk(\n value: unknown,\n limits: InspectionLimits,\n budget: { nodes: number },\n depth: number,\n seen: WeakSet<object>,\n): Inspected {\n if (budget.nodes-- <= 0) return { t: \"truncated\", hint: \"size limit\" };\n\n if (value === undefined) return { t: \"undefined\" };\n if (value === null) return { t: \"primitive\", v: null };\n\n const type = typeof value;\n if (type === \"number\") return Number.isNaN(value) ? { t: \"nan\" } : { t: \"primitive\", v: value as number };\n if (type === \"boolean\") return { t: \"primitive\", v: value as boolean };\n if (type === \"string\") {\n const s = value as string;\n return {\n t: \"primitive\",\n v: s.length > limits.maxStringLength ? `${s.slice(0, limits.maxStringLength)}…(+${s.length - limits.maxStringLength})` : s,\n };\n }\n if (type === \"symbol\") return { t: \"symbol\", v: String(value) };\n if (type === \"bigint\") return { t: \"bigint\", v: `${String(value)}n` };\n if (type === \"function\") {\n const fn = value as { displayName?: string; name?: string };\n return { t: \"function\", name: fn.displayName ?? fn.name ?? \"anonymous\" };\n }\n\n const obj = value as object;\n if (seen.has(obj)) return { t: \"circular\" };\n seen.add(obj);\n\n if (isReactElement(obj)) return { t: \"element\", name: elementName(obj) };\n\n if (Array.isArray(obj)) {\n const length = obj.length;\n if (depth <= 0) return { t: \"array\", length };\n const take = Math.min(length, limits.maxArrayLength);\n const items: Inspected[] = [];\n for (let i = 0; i < take; i++) items.push(walk(obj[i], limits, budget, depth - 1, seen));\n return { t: \"array\", length, items, truncated: take < length };\n }\n\n const ctor = objectTag(obj);\n let keys: string[];\n try {\n keys = Object.keys(obj as Record<string, unknown>);\n } catch {\n return { t: \"object\", ctor };\n }\n if (depth <= 0) {\n return { t: \"object\", ctor, keys: keys.slice(0, limits.maxObjectKeys), truncated: keys.length > limits.maxObjectKeys };\n }\n const take = Math.min(keys.length, limits.maxObjectKeys);\n const entries: Record<string, Inspected> = {};\n for (let i = 0; i < take; i++) {\n const k = keys[i] as string;\n let v: unknown;\n try {\n v = (obj as Record<string, unknown>)[k];\n } catch {\n // A throwing getter must never take down the app being debugged.\n entries[k] = { t: \"truncated\", hint: \"getter threw\" };\n continue;\n }\n entries[k] = walk(v, limits, budget, depth - 1, seen);\n }\n return { t: \"object\", ctor, entries, truncated: take < keys.length };\n}\n\nfunction objectTag(obj: object): string | undefined {\n const proto = Object.getPrototypeOf(obj);\n if (proto === Object.prototype || proto === null) return undefined;\n const name = proto?.constructor?.name;\n return typeof name === \"string\" && name !== \"Object\" ? name : undefined;\n}\n\n/** Single-line rendering for console output. */\nexport function formatInspected(node: Inspected | undefined): string {\n if (!node) return \"…\";\n switch (node.t) {\n case \"primitive\":\n return typeof node.v === \"string\" ? JSON.stringify(node.v) : String(node.v);\n case \"undefined\":\n return \"undefined\";\n case \"nan\":\n return \"NaN\";\n case \"symbol\":\n case \"bigint\":\n return node.v;\n case \"function\":\n return `ƒ ${node.name}()`;\n case \"element\":\n return `<${node.name} />`;\n case \"circular\":\n return \"[Circular]\";\n case \"truncated\":\n return `[… ${node.hint}]`;\n case \"array\": {\n if (!node.items) return `Array(${node.length})`;\n const body = node.items.map(formatInspected).join(\", \");\n return `[${body}${node.truncated ? \", …\" : \"\"}]`;\n }\n case \"object\": {\n const prefix = node.ctor ? `${node.ctor} ` : \"\";\n if (node.entries) {\n const body = Object.entries(node.entries)\n .map(([k, v]) => `${k}: ${formatInspected(v)}`)\n .join(\", \");\n return `${prefix}{ ${body}${node.truncated ? \", …\" : \"\"} }`;\n }\n if (node.keys) return `${prefix}{ ${node.keys.join(\", \")}${node.truncated ? \", …\" : \"\"} }`;\n return `${prefix}{…}`;\n }\n }\n}\n","import type { DetectiveConfig, DetectiveOptions } from \"./types.js\";\n\ndeclare const process: { env?: Record<string, string | undefined> } | undefined;\n\n/**\n * Positive production detection.\n *\n * Deliberately asymmetric: this returns `true` only when it can actually *see*\n * `NODE_ENV === \"production\"`. Anything else — including environments where\n * `process` does not exist at all, such as a Vite dev server in the browser —\n * is \"not known to be production\".\n *\n * The earlier version asked the opposite question (\"is this dev?\") and answered\n * `false` when it could not tell, which meant the documented Vite quick-start\n * turned the tool on and then silently recorded nothing.\n */\nexport function detectProduction(): boolean {\n try {\n const env = typeof process !== \"undefined\" ? process?.env : undefined;\n if (env && env.NODE_ENV) return env.NODE_ENV === \"production\";\n } catch {\n /* ignore */\n }\n return false;\n}\n\n/** @deprecated Use `detectProduction()`. Kept so existing imports keep working. */\nexport function detectDev(): boolean {\n return !detectProduction();\n}\n\nexport const defaultConfig: DetectiveConfig = {\n // Off until `init()` is called, so importing the package costs nothing.\n enabled: false,\n mode: \"console\",\n include: [],\n exclude: [],\n samplingRate: 1,\n maxEvents: 1000,\n slowRenderThreshold: 16,\n thresholds: { monitor: 5, slow: 16, verySlow: 50, critical: 100 },\n inspection: {\n depth: 1,\n maxObjectKeys: 20,\n maxArrayLength: 20,\n maxStringLength: 120,\n maxSerializedNodes: 200,\n },\n compareFunctionSource: false,\n};\n\nexport function mergeConfig(base: DetectiveConfig, options: DetectiveOptions = {}): DetectiveConfig {\n const { thresholds, inspection, ...rest } = options;\n const next: DetectiveConfig = {\n ...base,\n ...(rest as Partial<DetectiveConfig>),\n thresholds: { ...base.thresholds, ...thresholds },\n inspection: { ...base.inspection, ...inspection },\n };\n next.samplingRate = clamp(next.samplingRate, 0, 1);\n next.maxEvents = Math.max(1, Math.floor(next.maxEvents));\n next.inspection.depth = clamp(Math.floor(next.inspection.depth), 0, 6);\n return next;\n}\n\nfunction clamp(n: number, lo: number, hi: number): number {\n if (typeof n !== \"number\" || Number.isNaN(n)) return lo;\n return Math.min(hi, Math.max(lo, n));\n}\n\nexport function matches(name: string, patterns: Array<string | RegExp>): boolean {\n for (const p of patterns) {\n if (typeof p === \"string\" ? p === name : p.test(name)) return true;\n }\n return false;\n}\n\n/** Filter policy: exclude wins over include; empty include means \"everything\". */\nexport function shouldInstrument(name: string, config: DetectiveConfig): boolean {\n if (matches(name, config.exclude)) return false;\n if (config.include.length > 0 && !matches(name, config.include)) return false;\n return true;\n}\n","import { inspect, isPlainObject, isReactElement, valueType } from \"./inspect.js\";\nimport type { DetectiveConfig, Inspected, PropChange } from \"./types.js\";\n\nexport interface PropsDiff {\n changed: PropChange[];\n unchanged: string[];\n}\n\n/** Result of a bounded contents comparison. `undefined` = could not determine. */\ntype ShallowResult = boolean | undefined;\n\nconst EMPTY: Record<string, unknown> = {};\n\nexport function diffProps(\n previous: Record<string, unknown> | undefined,\n current: Record<string, unknown> | undefined,\n config: DetectiveConfig,\n): PropsDiff {\n const prev = previous ?? EMPTY;\n const next = current ?? EMPTY;\n const changed: PropChange[] = [];\n const unchanged: string[] = [];\n\n const keys = new Set<string>();\n for (const k in prev) keys.add(k);\n for (const k in next) keys.add(k);\n\n for (const key of keys) {\n const hadPrev = key in prev;\n const hasNext = key in next;\n const a = prev[key];\n const b = next[key];\n\n if (hadPrev && hasNext && Object.is(a, b)) {\n unchanged.push(key);\n continue;\n }\n if (!hadPrev) {\n changed.push({ key, kind: \"added\", valueType: valueType(b), current: snap(b, config) });\n continue;\n }\n if (!hasNext) {\n changed.push({ key, kind: \"removed\", valueType: valueType(a), previous: snap(a, config) });\n continue;\n }\n changed.push(describeChange(key, a, b, config));\n }\n\n return { changed, unchanged };\n}\n\nfunction describeChange(key: string, a: unknown, b: unknown, config: DetectiveConfig): PropChange {\n const type = valueType(b);\n const base: PropChange = {\n key,\n kind: \"value\",\n valueType: type,\n previous: snap(a, config),\n current: snap(b, config),\n };\n\n if (typeof a === \"function\" && typeof b === \"function\") {\n base.kind = \"reference\";\n if (config.compareFunctionSource) {\n base.sourceEqual = safeSource(a) === safeSource(b);\n }\n return base;\n }\n\n const shallow = shallowEqual(a, b, config);\n if (shallow === true) {\n base.kind = \"reference\";\n base.shallowEqual = true;\n } else if (shallow === false) {\n base.kind = \"value\";\n base.shallowEqual = false;\n }\n return base;\n}\n\n/**\n * Bounded shallow comparison. Returns `undefined` rather than guessing when the\n * values are too large or of a shape we cannot compare cheaply — the diagnostic\n * engine treats that as \"unknown\", never as \"equal\".\n */\nexport function shallowEqual(a: unknown, b: unknown, config: DetectiveConfig): ShallowResult {\n if (Object.is(a, b)) return true;\n if (typeof a !== \"object\" || typeof b !== \"object\" || a === null || b === null) return false;\n\n const { maxObjectKeys, maxArrayLength } = config.inspection;\n\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b)) return false;\n if (a.length !== b.length) return false;\n if (a.length > maxArrayLength) return undefined;\n for (let i = 0; i < a.length; i++) if (!Object.is(a[i], b[i])) return false;\n return true;\n }\n\n if (a instanceof Date || b instanceof Date) {\n return a instanceof Date && b instanceof Date ? a.getTime() === b.getTime() : false;\n }\n\n if (isReactElement(a) && isReactElement(b)) {\n const ea = a as { type: unknown; key: unknown; props: unknown };\n const eb = b as { type: unknown; key: unknown; props: unknown };\n if (ea.type !== eb.type || ea.key !== eb.key) return false;\n return shallowEqual(ea.props, eb.props, config);\n }\n\n if (!isPlainObject(a) || !isPlainObject(b)) return undefined;\n\n const ka = Object.keys(a);\n const kb = Object.keys(b);\n if (ka.length !== kb.length) return false;\n if (ka.length > maxObjectKeys) return undefined;\n for (const k of ka) {\n if (!Object.prototype.hasOwnProperty.call(b, k)) return false;\n if (!Object.is(a[k], b[k])) return false;\n }\n return true;\n}\n\nfunction snap(value: unknown, config: DetectiveConfig): Inspected {\n return inspect(value, config.inspection);\n}\n\nfunction safeSource(fn: unknown): string {\n try {\n return Function.prototype.toString.call(fn);\n } catch {\n return \"\";\n }\n}\n","import { formatInspected } from \"./inspect.js\";\nimport type {\n Confidence,\n ContextChange,\n TrackedStateChange,\n Diagnosis,\n PropChange,\n RenderPhase,\n Thresholds,\n} from \"./types.js\";\n\nexport interface DiagnosisInput {\n componentName: string;\n phase: RenderPhase;\n parentName?: string;\n /** Nearest instrumented ancestor re-rendered in this same commit. */\n parentRendered: boolean;\n /** True when we have no instrumented ancestor, so `parentRendered` is unknown. */\n parentUnknown: boolean;\n /**\n * Did something above re-evaluate this component's props?\n * `true` — the wrapper re-rendered, so the render came from above.\n * `false` — it did not, so the render started here or below.\n * `undefined` — hook mode, where the two cannot be told apart.\n */\n propsReevaluated: boolean | undefined;\n /** An instrumented child re-rendered from above, proving this component rendered. */\n selfRenderProven: boolean;\n changedProps: PropChange[];\n contextChanges: ContextChange[];\n /** Named state updates from `useTrackedState`. Empty unless opted in. */\n trackedState: TrackedStateChange[];\n /** How many times this component has been rebuilt rather than re-rendered. */\n remounts: number;\n /** The component looks like it is declared inside another component's render body. */\n inlineDefinitionSuspected: boolean;\n selfDuration: number;\n attempts: number;\n committed: boolean;\n /** How many times this component already produced a \"no observable change\" render. */\n priorAvoidableRenders: number;\n}\n\nexport function severityFor(duration: number, t: Thresholds): Diagnosis[\"severity\"] {\n if (duration >= t.critical) return \"critical\";\n if (duration >= t.verySlow) return \"very-slow\";\n if (duration >= t.slow) return \"slow\";\n if (duration >= t.monitor) return \"monitor\";\n return \"normal\";\n}\n\n/**\n * Pure. No React, no globals, no I/O — so diagnostic correctness can be tested\n * directly (§70).\n */\nexport function diagnose(input: DiagnosisInput, thresholds: Thresholds): Diagnosis {\n const severity = severityFor(input.selfDuration, thresholds);\n const d = classify(input);\n d.severity = severity;\n\n if (!input.committed) {\n d.evidence.unshift(\n \"This render attempt was not committed — React discarded it (concurrent interruption or a development replay). It is excluded from statistics.\",\n );\n } else if (input.attempts > 1) {\n d.evidence.push(\n `Render function ran ${input.attempts}× for one commit — a development replay (StrictMode double-invoke or a discarded attempt). Not production behaviour.`,\n );\n }\n\n if (severity === \"critical\" || severity === \"very-slow\") {\n d.evidence.push(`Render cost ${fmt(input.selfDuration)} — above the ${thresholds.verySlow}ms threshold.`);\n }\n return d;\n}\n\nfunction classify(input: DiagnosisInput): Diagnosis {\n const { changedProps, contextChanges, parentRendered, parentUnknown, parentName } = input;\n\n if (input.phase === \"mount\") {\n /*\n * A remount is not a render: React threw the previous instance away, along\n * with its DOM and all of its state, and built a new one. It costs far more\n * than any re-render, so it is worth saying loudly — but only when it has\n * actually happened repeatedly, since mounting is also just what happens\n * when a list grows or a route changes.\n */\n if (input.remounts >= 2) {\n const inline = input.inlineDefinitionSuspected;\n return make(\n \"mount\",\n inline ? \"high\" : \"medium\",\n `${input.componentName} was rebuilt, not re-rendered — this is remount ${input.remounts + 1}.`,\n [\n `This component has been unmounted and mounted again ${input.remounts}× — its DOM and all of its state were discarded each time.`,\n inline\n ? \"Its definition is being re-created repeatedly in a short window, which means it is declared *inside* another component's render body. React sees a new component type on every parent render and cannot reuse anything.\"\n : \"Its definition is stable, so the remounts come from the element identity changing — usually a changing `key`, or the component moving between branches of a conditional.\",\n \"A remount is much more expensive than a re-render, and it resets state.\",\n ],\n true,\n inline\n ? `Move ${input.componentName} out of its parent's render body to module scope. Defining a component inside another component makes React discard and rebuild the whole subtree on every parent render.`\n : `Check the \\`key\\` given to ${input.componentName}, and whether it is being rendered from a different branch each time.`,\n );\n }\n return make(\"mount\", \"high\", `${input.componentName} mounted.`, [\"First render of this instance.\"], false);\n }\n\n if (input.trackedState.length > 0) {\n const names = input.trackedState.map((s) => s.name);\n const evidence = input.trackedState.map(\n (s) => `\\`${s.name}\\`: ${formatInspected(s.previous)} → ${formatInspected(s.current)}`,\n );\n if (changedProps.length > 0) {\n evidence.push(`Props also changed: ${changedProps.map((c) => c.key).join(\", \")}.`);\n }\n return make(\n \"state\",\n \"high\",\n `${input.componentName} rendered because its own state changed: ${names.join(\", \")}.`,\n evidence,\n false,\n );\n }\n\n if (changedProps.length > 0) {\n const meaningful = changedProps.filter((c) => c.kind !== \"reference\");\n const referenceOnly = changedProps.filter((c) => c.kind === \"reference\");\n\n if (meaningful.length > 0) {\n const keys = meaningful.map((c) => c.key);\n const evidence = [\n `Props changed with new values: ${keys.join(\", \")}.`,\n ...meaningful.map(describe),\n ];\n if (referenceOnly.length > 0) {\n evidence.push(\n `Also changed by reference only (contents identical): ${referenceOnly.map((c) => c.key).join(\", \")}.`,\n );\n }\n return make(\n \"props\",\n \"high\",\n `${input.componentName} rendered because ${plural(keys.length, \"prop\")} changed: ${keys.join(\", \")}.`,\n evidence,\n false,\n referenceOnly.length > 0 ? stabiliseSuggestion(referenceOnly, parentName) : undefined,\n );\n }\n\n // Every changed prop is a reference change with equal (or unknown) contents.\n const keys = referenceOnly.map((c) => c.key);\n const evidence = [\n `${plural(keys.length, \"prop\")} changed by reference only: ${keys.join(\", \")}.`,\n ...referenceOnly.map(describe),\n ];\n if (parentRendered && parentName) {\n evidence.push(`${parentName} re-rendered in the same commit and recreated ${keys.length > 1 ? \"these values\" : `\\`${keys[0]}\\``}.`);\n }\n const confidence: Confidence = referenceOnly.some((c) => c.shallowEqual === true || c.valueType === \"function\")\n ? \"medium\"\n : \"low\";\n return make(\n \"props\",\n confidence,\n `${input.componentName} rendered because ${keys.join(\", \")} changed by reference — the contents did not.`,\n evidence,\n true,\n stabiliseSuggestion(referenceOnly, parentName),\n );\n }\n\n // Nothing about the props changed.\n if (input.propsReevaluated === false) {\n // The wrapper never re-ran: no new props came from above, so the render\n // began at this component or below it.\n if (contextChanges.length > 0) {\n const c = contextChanges[0] as ContextChange;\n const detail = c.changedKeys.length > 0 ? ` Changed: ${c.changedKeys.join(\", \")}.` : \"\";\n return make(\n \"context\",\n \"medium\",\n `${input.componentName} rendered after ${c.contextName} updated in the same commit.${detail}`,\n [\n \"No new props came from above — the render started at this component.\",\n `Tracked context ${c.contextName} changed in this commit.`,\n c.referenceOnly\n ? `${c.contextName}'s value changed by reference only — its contents are identical.`\n : `${c.contextName}'s contents changed.`,\n \"React does not expose which contexts a component subscribes to, so this is correlation within one commit, not a recorded subscription.\",\n ],\n c.referenceOnly,\n c.referenceOnly\n ? `${c.contextName}'s provider recreates its value every render. Stabilise it with useMemo if consumers are doing real work.`\n : undefined,\n );\n }\n return make(\n \"state-or-external\",\n input.selfRenderProven ? \"high\" : \"medium\",\n `${input.componentName} rendered from inside itself — local state, a store subscription, or a forced update.`,\n [\n \"No new props came from above: the wrapper did not re-render.\",\n input.selfRenderProven\n ? \"An instrumented child re-rendered from above in this commit, which proves this component produced it.\"\n : \"No instrumented descendant rendered in this commit, so an uninstrumented descendant could in principle be the origin instead.\",\n \"React does not expose hook state without private internals, so the exact source is not observable. Use useTrackedState to name it.\",\n ],\n false,\n );\n }\n\n if (input.propsReevaluated === true) {\n // The wrapper re-rendered with identical props — pure propagation.\n const known = parentRendered && parentName;\n return make(\n \"parent\",\n known && contextChanges.length === 0 ? \"high\" : \"medium\",\n `${input.componentName} rendered because its parent rendered — its own inputs did not change.`,\n [\n known\n ? `${parentName} re-rendered in this commit.`\n : \"Something above re-rendered this component, but the nearest instrumented ancestor did not — an uninstrumented component sits in between.\",\n \"Every prop is identical by reference.\",\n contextChanges.length === 0\n ? \"No tracked context changed in this commit.\"\n : `A tracked context also changed (${contextChanges.map((c) => c.contextName).join(\", \")}) — but new props arrived from above, so propagation is the direct cause.`,\n ],\n true,\n memoSuggestion(input),\n );\n }\n\n // Hook mode: props and self-originated renders cannot be told apart.\n if (parentRendered) {\n const evidence = [\n `${parentName ?? \"The nearest instrumented ancestor\"} re-rendered in this commit.`,\n \"Every prop is identical by reference.\",\n contextChanges.length === 0\n ? \"No tracked context changed in this commit.\"\n : `A tracked context also changed (${contextChanges.map((c) => c.contextName).join(\", \")}) — if this component consumes it, that is an alternative cause.`,\n ];\n return make(\n \"parent\",\n contextChanges.length === 0 ? \"high\" : \"medium\",\n `${input.componentName} rendered because its parent rendered — its own inputs did not change.`,\n evidence,\n true,\n memoSuggestion(input),\n );\n }\n\n if (contextChanges.length > 0) {\n const c = contextChanges[0] as ContextChange;\n const detail = c.changedKeys.length > 0 ? ` Changed: ${c.changedKeys.join(\", \")}.` : \"\";\n return make(\n \"context\",\n \"medium\",\n `${input.componentName} rendered after ${c.contextName} updated in the same commit.${detail}`,\n [\n `Props are identical and the parent did not re-render.`,\n `Tracked context ${c.contextName} changed in this commit.`,\n c.referenceOnly\n ? `${c.contextName}'s value changed by reference only — its contents are identical.`\n : `${c.contextName}'s contents changed.`,\n \"React does not expose which contexts a component subscribes to, so this is correlation within one commit, not a recorded subscription.\",\n ],\n c.referenceOnly,\n c.referenceOnly\n ? `${c.contextName}'s provider recreates its value every render. Stabilise it with useMemo if consumers are doing real work.`\n : undefined,\n );\n }\n\n if (parentUnknown) {\n return make(\n \"unknown\",\n \"low\",\n `Cause could not be determined reliably for ${input.componentName}.`,\n [\n \"Props are identical and no tracked context changed.\",\n \"This component has no instrumented ancestor, so a parent-propagated render cannot be ruled out.\",\n \"Instrument the parent, or track the context it consumes, to narrow this down.\",\n ],\n false,\n );\n }\n\n return make(\n \"state-or-external\",\n \"medium\",\n `${input.componentName} rendered from inside itself — local state, a store subscription, or a forced update.`,\n [\n \"Props are identical by reference.\",\n \"The nearest instrumented ancestor did not re-render in this commit.\",\n \"No tracked context changed in this commit.\",\n \"React does not expose hook state without private internals, so the exact source is not observable. Use useTrackedState to name it.\",\n ],\n false,\n );\n}\n\n/**\n * Memoization is a trade, not a default. Only recommend measuring it when the\n * render actually costs something or the pattern has repeated (§50, §52).\n */\nfunction memoSuggestion(input: DiagnosisInput): string {\n const worth = input.selfDuration >= 1 || input.priorAvoidableRenders >= 5;\n return worth\n ? `Check whether ${input.componentName} benefits from React.memo(). It has re-rendered with identical props ${input.priorAvoidableRenders + 1}× at ${fmt(input.selfDuration)} each — measure before and after.`\n : `Props are identical, but this render costs ${fmt(input.selfDuration)}. Memoizing is unlikely to pay for itself yet.`;\n}\n\nfunction stabiliseSuggestion(changes: PropChange[], parentName?: string): string {\n const fns = changes.filter((c) => c.valueType === \"function\").map((c) => c.key);\n const objs = changes.filter((c) => c.valueType === \"object\" || c.valueType === \"array\").map((c) => c.key);\n const where = parentName ? ` in ${parentName}` : \"\";\n const parts: string[] = [];\n if (fns.length > 0) parts.push(`${list(fns)} ${plural(fns.length, \"is\", \"are\")} recreated on every render${where} — useCallback, or hoist it, if a memoized child depends on it`);\n if (objs.length > 0) parts.push(`${list(objs)} ${plural(objs.length, \"is\", \"are\")} a new object each render${where} — useMemo it, or pass the primitive fields you actually use`);\n if (parts.length === 0) return `Find where ${list(changes.map((c) => c.key))} is created${where} and stabilise it.`;\n return `${capitalize(parts.join(\"; \"))}.`;\n}\n\nfunction describe(c: PropChange): string {\n switch (c.kind) {\n case \"added\":\n return `\\`${c.key}\\` was added.`;\n case \"removed\":\n return `\\`${c.key}\\` was removed.`;\n case \"reference\":\n if (c.valueType === \"function\") {\n return c.sourceEqual\n ? `\\`${c.key}\\` is a new function with identical source — an inline closure recreated by the parent.`\n : `\\`${c.key}\\` is a new function reference.`;\n }\n if (c.shallowEqual === true) return `\\`${c.key}\\` is a new ${c.valueType} whose shallow contents are identical.`;\n return `\\`${c.key}\\` changed reference; contents were too large or too exotic to compare cheaply.`;\n case \"value\":\n return `\\`${c.key}\\` changed value.`;\n }\n}\n\nfunction make(\n reason: Diagnosis[\"reason\"],\n confidence: Confidence,\n summary: string,\n evidence: string[],\n potentiallyAvoidable: boolean,\n suggestion?: string,\n): Diagnosis {\n return { reason, confidence, summary, evidence, potentiallyAvoidable, suggestion, severity: \"normal\" };\n}\n\nconst fmt = (ms: number): string => `${ms.toFixed(1)}ms`;\nconst list = (xs: string[]): string => xs.map((x) => `\\`${x}\\``).join(\", \");\nconst capitalize = (s: string): string => s.charAt(0).toUpperCase() + s.slice(1);\nfunction plural(n: number, one: string, many?: string): string {\n if (one === \"is\") return n === 1 ? \"is\" : (many as string);\n return n === 1 ? `${one}` : `${one}s`;\n}\n","/** Fixed-capacity ring buffer. Bounded memory is a hard requirement (§26). */\nexport class RingBuffer<T> {\n private items: Array<T | undefined>;\n private head = 0;\n private count = 0;\n\n constructor(capacity: number) {\n this.items = new Array<T | undefined>(Math.max(1, capacity));\n }\n\n push(item: T): void {\n this.items[this.head] = item;\n this.head = (this.head + 1) % this.items.length;\n if (this.count < this.items.length) this.count++;\n }\n\n get size(): number {\n return this.count;\n }\n\n /** Oldest → newest. */\n toArray(): T[] {\n const out: T[] = [];\n const len = this.items.length;\n const start = (this.head - this.count + len) % len;\n for (let i = 0; i < this.count; i++) {\n const v = this.items[(start + i) % len];\n if (v !== undefined) out.push(v);\n }\n return out;\n }\n\n clear(): void {\n this.items = new Array<T | undefined>(this.items.length);\n this.head = 0;\n this.count = 0;\n }\n\n resize(capacity: number): void {\n const existing = this.toArray();\n this.items = new Array<T | undefined>(Math.max(1, capacity));\n this.head = 0;\n this.count = 0;\n const keep = existing.slice(Math.max(0, existing.length - this.items.length));\n for (const item of keep) this.push(item);\n }\n}\n","import { defaultConfig, detectProduction, mergeConfig, shouldInstrument } from \"./config.js\";\nimport { diffProps } from \"./compare.js\";\nimport { diagnose } from \"./diagnose.js\";\nimport { RingBuffer } from \"./ringBuffer.js\";\nimport type {\n AppStats,\n TrackedStateChange,\n ComponentInfo,\n ComponentStats,\n ContextChange,\n DetectiveConfig,\n DetectiveOptions,\n RenderEvent,\n RenderPhase,\n RenderReason,\n} from \"./types.js\";\n\nconst now = (): number =>\n typeof performance !== \"undefined\" && typeof performance.now === \"function\" ? performance.now() : Date.now();\n\n/** What an instrumentation site reports at commit time. */\nexport interface CommitInput {\n phase: RenderPhase;\n subtreeDuration: number;\n baseDuration: number;\n startTime: number;\n /** `-1` when there is no Profiler; the flush pass resolves it. */\n commitTime: number;\n}\n\nexport interface Lifecycle {\n mounts: number;\n unmounts: number;\n /** Mounts that followed an unmount of the same component. */\n remounts: number;\n}\n\ninterface DefinitionRecord {\n name: string;\n count: number;\n firstSeen: number;\n lastSeen: number;\n /** Reported by the build plugin, which knows this statically. */\n declaredInRender: boolean;\n}\n\n/** Repeated definitions inside this window mean a render loop, not hot reload. */\nconst INLINE_DEFINITION_WINDOW_MS = 5000;\n\nconst timestamp = (): number =>\n typeof performance !== \"undefined\" && typeof performance.now === \"function\" ? performance.now() : Date.now();\n\nconst EMPTY_STATE: TrackedStateChange[] = [];\nconst DURATION_SAMPLE = 200;\nconst SWEEP_DELAY_MS = 250;\n\ninterface NodeRecord {\n id: string;\n name: string;\n /** `File.tsx:12:2` when the build plugin instrumented this component. */\n source?: string;\n /** Nearest instrumented ancestor, held directly so diagnosis never needs the registry. */\n parent?: NodeRecord;\n depth: number;\n sampled: boolean;\n /** Retained so the next render can be diffed. One props object per component. */\n prevProps?: Record<string, unknown>;\n pendingProps?: Record<string, unknown>;\n /** Render-function invocations not yet matched to a commit. */\n attempts: number;\n /** Named state updates reported by `useTrackedState`, consumed at the next commit. */\n pendingState: TrackedStateChange[];\n /** Set as soon as a commit is queued, so mount detection never waits on flush. */\n seenCommit: boolean;\n /** Has this instance ever been attached? Distinguishes a real mount from a StrictMode replay. */\n everAttached?: boolean;\n /** Currently detached. Cleared if the same node re-attaches (StrictMode does exactly that). */\n detached?: boolean;\n /**\n * `useId` of the first component to call `useTrackedState` under this node.\n * Later callers (descendants) cannot claim state attribution from it.\n */\n stateOwner?: string;\n renderNumber: number;\n lastCommitTime: number;\n durations: number[];\n stats: MutableStats;\n}\n\ninterface MutableStats {\n renderCount: number;\n mountCount: number;\n uncommittedAttempts: number;\n devReplays: number;\n totalSelfDuration: number;\n maxSelfDuration: number;\n slowRenders: number;\n potentiallyAvoidableRenders: number;\n reasons: Record<RenderReason, number>;\n}\n\ninterface PendingCommit {\n node: NodeRecord;\n phase: RenderPhase;\n subtreeDuration: number;\n baseDuration: number;\n startTime: number;\n commitTime: number;\n attempts: number;\n /**\n * Props and state are snapshotted **at commit time**, not at flush time.\n * Several commits can land before the deferred pass runs, and reading them\n * later would diff the wrong pair.\n */\n props: Record<string, unknown> | undefined;\n state: TrackedStateChange[];\n seq: number;\n}\n\nconst emptyReasons = (): Record<RenderReason, number> => ({\n mount: 0,\n props: 0,\n state: 0,\n parent: 0,\n context: 0,\n \"state-or-external\": 0,\n unknown: 0,\n});\n\nexport class Detective {\n config: DetectiveConfig = { ...defaultConfig };\n private nodes = new Map<string, NodeRecord>();\n private events: RingBuffer<RenderEvent>;\n private listeners = new Set<(event: RenderEvent) => void>();\n private pending: PendingCommit[] = [];\n private contextChanges: Array<{ change: ContextChange; seq: number }> = [];\n /** Orders renders and context updates so they can be matched without timers. */\n private seq = 0;\n private flushScheduled = false;\n private sweepHandle: ReturnType<typeof setTimeout> | undefined;\n private nextId = 0;\n /** Mount/unmount history per component name, for remount detection. */\n private lifecycles = new Map<string, Lifecycle>();\n /** How often each component *definition* has been wrapped. */\n private definitions = new Map<string, DefinitionRecord>();\n /** Nodes created by `useRenderDiagnostics`, where props/state cannot be separated. */\n readonly hookModeNodes = new WeakSet<NodeRecord>();\n private initialized = false;\n\n constructor() {\n this.events = new RingBuffer<RenderEvent>(this.config.maxEvents);\n }\n\n /**\n * Idempotent: repeated calls reconfigure, they never duplicate anything (§47).\n *\n * Calling `init()` *is* the intent to turn diagnostics on, so `enabled`\n * defaults to true unless a production build is positively detected. Guard\n * the call itself for production safety — that is what the docs show, and it\n * is what lets a bundler drop the whole thing.\n */\n init(options: DetectiveOptions = {}): Detective {\n this.configure({ enabled: !detectProduction(), ...options });\n this.initialized = true;\n return this;\n }\n\n configure(options: DetectiveOptions = {}): void {\n const previousMax = this.config.maxEvents;\n this.config = mergeConfig(this.config, options);\n if (this.config.maxEvents !== previousMax) this.events.resize(this.config.maxEvents);\n }\n\n get isInitialized(): boolean {\n return this.initialized;\n }\n\n get enabled(): boolean {\n return this.config.enabled;\n }\n\n subscribe(listener: (event: RenderEvent) => void): () => void {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n // ---------------------------------------------------------------- registry\n\n /**\n * Creates a node without publishing it. StrictMode's double mount renders\n * discards one of the two, and only the surviving fiber's effect attaches —\n * so discarded nodes are simply garbage collected.\n */\n createNode(name: string, parent: NodeRecord | undefined, source?: string): NodeRecord | undefined {\n if (!shouldInstrument(name, this.config)) return undefined;\n const sampled = this.config.samplingRate >= 1 || Math.random() < this.config.samplingRate;\n const node: NodeRecord = {\n id: `rrd_${++this.nextId}`,\n name,\n source,\n parent,\n depth: parent ? parent.depth + 1 : 0,\n sampled,\n attempts: 0,\n pendingState: [],\n seenCommit: false,\n renderNumber: 0,\n lastCommitTime: -1,\n durations: [],\n stats: {\n renderCount: 0,\n mountCount: 0,\n uncommittedAttempts: 0,\n devReplays: 0,\n totalSelfDuration: 0,\n maxSelfDuration: 0,\n slowRenders: 0,\n potentiallyAvoidableRenders: 0,\n reasons: emptyReasons(),\n },\n };\n return node;\n }\n\n attach(node: NodeRecord): void {\n this.nodes.set(node.id, node);\n\n /*\n * StrictMode simulates an unmount by running effect cleanups and then the\n * effects again on the *same* fiber, so the same node detaches and\n * re-attaches. That is not a remount, and counting it would flag every\n * component in a StrictMode app. A real remount always produces a new node,\n * because `useState` runs afresh.\n */\n if (node.detached) {\n node.detached = false;\n const existing = this.lifecycles.get(node.name);\n if (existing) existing.unmounts--;\n return;\n }\n if (node.everAttached) return;\n node.everAttached = true;\n\n const life = this.lifecycleFor(node.name);\n life.mounts++;\n if (life.unmounts > 0) life.remounts++;\n }\n\n detach(node: NodeRecord): void {\n /*\n * Registry removal only — deliberately NOT clearing `prevProps`. Wiping\n * them here made the first real update after mount diff against `{}` and\n * report every prop as newly added, because StrictMode runs cleanups on\n * components that are still mounted. Memory is bounded by dropping the node\n * from the registry: after a genuine unmount nothing references it.\n */\n this.nodes.delete(node.id);\n if (node.everAttached && !node.detached) {\n node.detached = true;\n this.lifecycleFor(node.name).unmounts++;\n }\n }\n\n private lifecycleFor(name: string): Lifecycle {\n let life = this.lifecycles.get(name);\n if (!life) this.lifecycles.set(name, (life = { mounts: 0, unmounts: 0, remounts: 0 }));\n return life;\n }\n\n /**\n * Called once per `withRenderDetective` call. A component declared at module\n * scope is wrapped once; one declared *inside* a render body is wrapped again\n * on every render of its parent — which also forces React to throw away and\n * rebuild its entire subtree. That is the signal.\n */\n noteDefinition(name: string, source: string | undefined, declaredInRender = false): void {\n const key = source ?? name;\n const now = timestamp();\n const record = this.definitions.get(key);\n if (!record) {\n this.definitions.set(key, { name, count: 1, firstSeen: now, lastSeen: now, declaredInRender });\n return;\n }\n record.count++;\n record.lastSeen = now;\n if (declaredInRender) record.declaredInRender = true;\n }\n\n /**\n * Is this component declared inside another component's render body?\n *\n * The build plugin answers this statically and exactly. Without it we fall\n * back to a rate heuristic — repeated definitions of the same component in a\n * short window — which is weaker: hot reload also re-defines components, and\n * a user clicking slowly stretches the window. Hence the plugin's answer wins.\n */\n inlineDefinitionSuspected(name: string): boolean {\n for (const record of this.definitions.values()) {\n if (record.name !== name) continue;\n if (record.declaredInRender) return true;\n if (record.count >= 3 && record.lastSeen - record.firstSeen < INLINE_DEFINITION_WINDOW_MS) return true;\n }\n return false;\n }\n\n lifecycleOf(name: string): Lifecycle {\n return this.lifecycles.get(name) ?? { mounts: 0, unmounts: 0, remounts: 0 };\n }\n\n /** Hot path. Must stay allocation-free and O(1). */\n recordAttempt(node: NodeRecord, props: Record<string, unknown>): void {\n node.attempts++;\n node.pendingProps = props;\n }\n\n recordStateChange(node: NodeRecord, change: TrackedStateChange): void {\n if (node.pendingState.length < 16) node.pendingState.push(change);\n }\n\n /**\n * Hot path. Called from Profiler#onRender; only enqueues.\n *\n * `attempts` is the number of times the *wrapper* rendered, i.e. how often\n * this component's props were re-evaluated from above. Zero means the render\n * originated at or below this component — the flush pass works out which.\n */\n recordCommit(node: NodeRecord, commit: CommitInput): void {\n this.pending.push({\n ...commit,\n node,\n attempts: node.attempts,\n props: node.pendingProps,\n state: node.pendingState.length > 0 ? node.pendingState : EMPTY_STATE,\n seq: ++this.seq,\n });\n node.seenCommit = true;\n node.attempts = 0;\n node.pendingProps = undefined;\n if (node.pendingState.length > 0) node.pendingState = [];\n node.lastCommitTime = commit.commitTime;\n this.scheduleFlush();\n }\n\n recordContextChange(change: ContextChange): void {\n this.contextChanges.push({ change, seq: ++this.seq });\n this.scheduleFlush();\n }\n\n // ------------------------------------------------------------ deferred work\n\n private scheduleFlush(): void {\n if (this.flushScheduled) return;\n this.flushScheduled = true;\n queueMicrotask(() => {\n this.flushScheduled = false;\n try {\n this.flush();\n } catch {\n /* diagnostics must never break the app (§46) */\n }\n });\n this.scheduleSweep();\n }\n\n private scheduleSweep(): void {\n if (this.sweepHandle !== undefined) return;\n this.sweepHandle = setTimeout(() => {\n this.sweepHandle = undefined;\n try {\n this.sweep();\n } catch {\n /* ignore */\n }\n }, SWEEP_DELAY_MS);\n // Never keep a Node process alive for diagnostics.\n (this.sweepHandle as { unref?: () => void }).unref?.();\n }\n\n /** Attempts that never reached a commit were abandoned or replayed. */\n private sweep(): void {\n for (const node of this.nodes.values()) {\n if (node.attempts > 0) {\n node.stats.uncommittedAttempts += node.attempts;\n node.attempts = 0;\n }\n }\n }\n\n /** Runs after the commit, off the render path. Whole batch is available here. */\n flush(): void {\n if (this.pending.length === 0) {\n this.contextChanges.length = 0;\n return;\n }\n const batch = this.pending;\n this.pending = [];\n const pendingContexts = this.contextChanges;\n this.contextChanges = [];\n const hookMode = this.hookModeNodes;\n\n /*\n * Hook-mode records and context updates are recorded *during* render, so\n * they belong to the next commit that lands after them. Matching on\n * sequence rather than wall-clock keeps that correct even when several\n * commits queue up before this deferred pass runs.\n */\n let nextReal = -1;\n for (let i = batch.length - 1; i >= 0; i--) {\n const rec = batch[i] as PendingCommit;\n if (rec.commitTime >= 0) nextReal = rec.commitTime;\n else if (nextReal >= 0) rec.commitTime = nextReal;\n else rec.commitTime = now();\n }\n const contexts: ContextChange[] = pendingContexts.map(({ change, seq }) => {\n if (change.commitTime >= 0) return change;\n const following = batch.find((r) => r.seq > seq);\n return { ...change, commitTime: following ? following.commitTime : (batch[batch.length - 1]?.commitTime ?? now()) };\n });\n\n // Which nodes rendered in each commit, and how much of a node's subtree\n // time belongs to instrumented descendants.\n const commitMembers = new Map<number, Set<NodeRecord>>();\n const descendantTime = new Map<NodeRecord, number>();\n for (const rec of batch) {\n let set = commitMembers.get(rec.commitTime);\n if (!set) commitMembers.set(rec.commitTime, (set = new Set()));\n set.add(rec.node);\n }\n for (const rec of batch) {\n const parent = rec.node.parent;\n if (!parent) continue;\n if (!commitMembers.get(rec.commitTime)?.has(parent)) continue;\n descendantTime.set(parent, (descendantTime.get(parent) ?? 0) + rec.subtreeDuration);\n }\n\n /*\n * A Profiler fires for every ancestor of the work, so a raw callback is not\n * proof that *this* component rendered. Two facts separate them:\n *\n * attempts > 0 the wrapper re-rendered, so something above re-rendered it.\n * attempts = 0 the work started at or below this component.\n *\n * For the second case, an instrumented child that itself re-rendered from\n * above is proof this component rendered (it produced that child). If some\n * deeper instrumented node fired instead, the origin is down there and this\n * callback is only propagation — counting it would inflate every ancestor.\n */\n const provenSelfRender = new Set<NodeRecord>();\n const hasInstrumentedDescendant = new Set<NodeRecord>();\n for (const rec of batch) {\n const members = commitMembers.get(rec.commitTime);\n if (rec.attempts > 0 && rec.node.parent && members?.has(rec.node.parent)) {\n provenSelfRender.add(rec.node.parent);\n }\n for (let a = rec.node.parent; a; a = a.parent) {\n if (members?.has(a)) hasInstrumentedDescendant.add(a);\n }\n }\n\n for (const rec of batch) {\n if (!rec.node.sampled) continue;\n const counted =\n rec.attempts > 0 ||\n rec.phase === \"mount\" ||\n provenSelfRender.has(rec.node) ||\n !hasInstrumentedDescendant.has(rec.node);\n if (!counted) continue;\n try {\n this.emit(\n this.buildEvent(rec.node, rec, commitMembers, descendantTime, contexts, provenSelfRender, hookMode.has(rec.node)),\n );\n } catch {\n /* one bad event must not lose the batch */\n }\n }\n }\n\n private buildEvent(\n node: NodeRecord,\n rec: PendingCommit,\n commitMembers: Map<number, Set<NodeRecord>>,\n descendantTime: Map<NodeRecord, number>,\n contexts: ContextChange[],\n provenSelfRender: Set<NodeRecord>,\n isHookMode: boolean,\n ): RenderEvent {\n const parent = node.parent;\n const parentRendered = parent ? commitMembers.get(rec.commitTime)?.has(parent) === true : false;\n\n // attempts === 0 means the wrapper never re-ran, so the props object is by\n // definition the same one as last time — there is nothing to diff.\n const propsReevaluated = isHookMode ? undefined : rec.attempts > 0;\n const isMount = rec.phase === \"mount\";\n const props = rec.props ?? node.prevProps ?? {};\n const { changed, unchanged } =\n isMount || propsReevaluated === false\n ? { changed: [], unchanged: Object.keys(props) }\n : diffProps(node.prevProps, props, this.config);\n node.prevProps = props;\n\n const accounted = descendantTime.get(node) ?? 0;\n const selfDuration = Math.max(0, rec.subtreeDuration - accounted);\n const relevantContexts = contexts.filter((c) => c.commitTime === rec.commitTime);\n const trackedState = rec.state;\n\n node.renderNumber++;\n const diagnosis = diagnose(\n {\n componentName: node.name,\n phase: rec.phase,\n parentName: parent?.name,\n parentRendered,\n parentUnknown: !parent,\n propsReevaluated,\n selfRenderProven: provenSelfRender.has(node),\n changedProps: changed,\n contextChanges: relevantContexts,\n selfDuration,\n attempts: rec.attempts,\n committed: true,\n trackedState,\n remounts: this.lifecycleOf(node.name).remounts,\n inlineDefinitionSuspected: this.inlineDefinitionSuspected(node.name),\n priorAvoidableRenders: node.stats.potentiallyAvoidableRenders,\n },\n this.config.thresholds,\n );\n\n const componentInfo: ComponentInfo = {\n id: node.id,\n name: node.name,\n source: node.source,\n parentId: parent?.id,\n depth: node.depth,\n };\n\n const event: RenderEvent = {\n id: `${node.id}#${node.renderNumber}`,\n component: componentInfo,\n timestamp: rec.startTime,\n renderNumber: node.renderNumber,\n phase: rec.phase,\n timings: {\n subtreeDuration: rec.subtreeDuration,\n baseDuration: rec.baseDuration,\n selfDuration,\n accountedDescendantDuration: accounted,\n commitTime: rec.commitTime,\n startTime: rec.startTime,\n },\n changedProps: changed,\n unchangedProps: unchanged,\n parent: parent\n ? { id: parent.id, name: parent.name, source: parent.source, parentId: parent.parent?.id, depth: parent.depth }\n : undefined,\n parentRendered,\n selfOriginated: propsReevaluated === false,\n contextChanges: relevantContexts,\n trackedState,\n committed: true,\n attempts: Math.max(1, rec.attempts),\n devReplay: rec.attempts > 1,\n diagnosis,\n };\n\n this.updateStats(node, event);\n return event;\n }\n\n private updateStats(node: NodeRecord, event: RenderEvent): void {\n const s = node.stats;\n s.renderCount++;\n if (event.phase === \"mount\") s.mountCount++;\n if (event.devReplay) s.devReplays++;\n const d = event.timings.selfDuration;\n s.totalSelfDuration += d;\n if (d > s.maxSelfDuration) s.maxSelfDuration = d;\n if (d >= this.config.slowRenderThreshold) s.slowRenders++;\n if (event.diagnosis.potentiallyAvoidable) s.potentiallyAvoidableRenders++;\n s.reasons[event.diagnosis.reason]++;\n node.durations.push(d);\n if (node.durations.length > DURATION_SAMPLE) node.durations.shift();\n }\n\n private emit(event: RenderEvent): void {\n this.events.push(event);\n const { onEvent } = this.config;\n if (onEvent) {\n try {\n onEvent(event);\n } catch {\n /* ignore */\n }\n }\n for (const listener of this.listeners) {\n try {\n listener(event);\n } catch {\n /* ignore */\n }\n }\n }\n\n // -------------------------------------------------------------------- query\n\n getEvents(): RenderEvent[] {\n this.flush();\n return this.events.toArray();\n }\n\n getComponentStats(name?: string): ComponentStats[] {\n this.flush();\n const out: ComponentStats[] = [];\n for (const node of this.nodes.values()) {\n if (name && node.name !== name) continue;\n if (node.stats.renderCount === 0 && node.stats.uncommittedAttempts === 0) continue;\n out.push(toStats(node, this.lifecycleOf(node.name)));\n }\n return out;\n }\n\n getStats(): AppStats {\n const all = this.getComponentStats();\n const byName = new Map<string, ComponentStats>();\n for (const s of all) {\n const existing = byName.get(s.name);\n byName.set(s.name, existing ? mergeStats(existing, s) : s);\n }\n const merged = [...byName.values()];\n return {\n components: merged.length,\n totalRenders: merged.reduce((a, s) => a + s.renderCount, 0),\n totalRenderTime: merged.reduce((a, s) => a + s.totalSelfDuration, 0),\n slowRenders: merged.reduce((a, s) => a + s.slowRenders, 0),\n potentiallyAvoidableRenders: merged.reduce((a, s) => a + s.potentiallyAvoidableRenders, 0),\n devReplays: merged.reduce((a, s) => a + s.devReplays, 0),\n slowest: [...merged].sort((a, b) => b.maxSelfDuration - a.maxSelfDuration).slice(0, 10),\n mostRendered: [...merged].sort((a, b) => b.renderCount - a.renderCount).slice(0, 10),\n mostExpensive: [...merged].sort((a, b) => b.totalSelfDuration - a.totalSelfDuration).slice(0, 10),\n };\n }\n\n clear(): void {\n this.events.clear();\n this.pending.length = 0;\n this.contextChanges.length = 0;\n for (const node of this.nodes.values()) {\n node.stats = {\n renderCount: 0,\n mountCount: 0,\n uncommittedAttempts: 0,\n devReplays: 0,\n totalSelfDuration: 0,\n maxSelfDuration: 0,\n slowRenders: 0,\n potentiallyAvoidableRenders: 0,\n reasons: emptyReasons(),\n };\n node.durations.length = 0;\n node.renderNumber = 0;\n }\n }\n\n /** Full teardown — used by tests and by HMR disposal. */\n reset(): void {\n this.clear();\n this.nodes.clear();\n this.lifecycles.clear();\n this.definitions.clear();\n this.listeners.clear();\n if (this.sweepHandle !== undefined) clearTimeout(this.sweepHandle);\n this.sweepHandle = undefined;\n this.config = { ...defaultConfig };\n this.events.resize(this.config.maxEvents);\n this.initialized = false;\n }\n}\n\nfunction percentile(sorted: number[], p: number): number {\n if (sorted.length === 0) return 0;\n const idx = Math.min(sorted.length - 1, Math.max(0, Math.ceil((p / 100) * sorted.length) - 1));\n return sorted[idx] as number;\n}\n\nfunction toStats(node: NodeRecord, lifecycle: Lifecycle): ComponentStats {\n const sorted = [...node.durations].sort((a, b) => a - b);\n const s = node.stats;\n return {\n id: node.id,\n name: node.name,\n source: node.source,\n renderCount: s.renderCount,\n mountCount: s.mountCount,\n remountCount: lifecycle.remounts,\n uncommittedAttempts: s.uncommittedAttempts,\n devReplays: s.devReplays,\n totalSelfDuration: s.totalSelfDuration,\n averageSelfDuration: s.renderCount ? s.totalSelfDuration / s.renderCount : 0,\n medianSelfDuration: percentile(sorted, 50),\n p95SelfDuration: percentile(sorted, 95),\n p99SelfDuration: percentile(sorted, 99),\n maxSelfDuration: s.maxSelfDuration,\n slowRenders: s.slowRenders,\n potentiallyAvoidableRenders: s.potentiallyAvoidableRenders,\n reasons: { ...s.reasons },\n };\n}\n\nfunction mergeStats(a: ComponentStats, b: ComponentStats): ComponentStats {\n const renderCount = a.renderCount + b.renderCount;\n const total = a.totalSelfDuration + b.totalSelfDuration;\n const reasons = { ...a.reasons };\n for (const key of Object.keys(b.reasons) as RenderReason[]) reasons[key] += b.reasons[key];\n return {\n id: a.id,\n name: a.name,\n source: a.source ?? b.source,\n renderCount,\n mountCount: a.mountCount + b.mountCount,\n remountCount: Math.max(a.remountCount, b.remountCount),\n uncommittedAttempts: a.uncommittedAttempts + b.uncommittedAttempts,\n devReplays: a.devReplays + b.devReplays,\n totalSelfDuration: total,\n averageSelfDuration: renderCount ? total / renderCount : 0,\n medianSelfDuration: Math.max(a.medianSelfDuration, b.medianSelfDuration),\n p95SelfDuration: Math.max(a.p95SelfDuration, b.p95SelfDuration),\n p99SelfDuration: Math.max(a.p99SelfDuration, b.p99SelfDuration),\n maxSelfDuration: Math.max(a.maxSelfDuration, b.maxSelfDuration),\n slowRenders: a.slowRenders + b.slowRenders,\n potentiallyAvoidableRenders: a.potentiallyAvoidableRenders + b.potentiallyAvoidableRenders,\n reasons,\n };\n}\n\nexport type { NodeRecord };\n\n/**\n * Singleton pinned to globalThis so Fast Refresh / duplicate module instances\n * share one detective instead of stacking three copies of the debugger (§47).\n */\nconst KEY = Symbol.for(\"react-render-detective.instance\");\ntype Global = typeof globalThis & { [KEY]?: Detective };\n\nexport function getDetective(): Detective {\n const g = globalThis as Global;\n if (!g[KEY]) g[KEY] = new Detective();\n return g[KEY] as Detective;\n}\n"]}
|