react-render-detective 0.5.0 → 0.6.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +2 -2
  3. package/dist/babel.cjs +2 -2
  4. package/dist/babel.d.cts +11 -0
  5. package/dist/babel.d.ts +11 -0
  6. package/dist/babel.js +1 -1
  7. package/dist/{chunk-DI5STJM4.js → chunk-3TZNM7JO.js} +66 -3
  8. package/dist/chunk-3TZNM7JO.js.map +1 -0
  9. package/dist/{chunk-HOTY7J3X.js → chunk-D7M4UC3Y.js} +26 -2
  10. package/dist/chunk-D7M4UC3Y.js.map +1 -0
  11. package/dist/{chunk-PHYYA67T.cjs → chunk-EXDRRUUQ.cjs} +69 -2
  12. package/dist/chunk-EXDRRUUQ.cjs.map +1 -0
  13. package/dist/{chunk-OSPTERGK.cjs → chunk-LCGXVRJR.cjs} +66 -3
  14. package/dist/chunk-LCGXVRJR.cjs.map +1 -0
  15. package/dist/{chunk-MCIQMYNR.js → chunk-QVHAC7AD.js} +69 -2
  16. package/dist/chunk-QVHAC7AD.js.map +1 -0
  17. package/dist/{chunk-JD4IJ4MN.cjs → chunk-RGT44QQI.cjs} +26 -2
  18. package/dist/chunk-RGT44QQI.cjs.map +1 -0
  19. package/dist/core.cjs +18 -18
  20. package/dist/core.d.cts +13 -3
  21. package/dist/core.d.ts +13 -3
  22. package/dist/core.js +1 -1
  23. package/dist/index.cjs +72 -274
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +35 -115
  26. package/dist/index.d.ts +35 -115
  27. package/dist/index.js +41 -237
  28. package/dist/index.js.map +1 -1
  29. package/dist/interactions.cjs +252 -0
  30. package/dist/interactions.cjs.map +1 -0
  31. package/dist/interactions.d.cts +110 -0
  32. package/dist/interactions.d.ts +110 -0
  33. package/dist/interactions.js +241 -0
  34. package/dist/interactions.js.map +1 -0
  35. package/dist/overlay.cjs +5 -5
  36. package/dist/overlay.js +2 -2
  37. package/dist/testing.d.cts +1 -1
  38. package/dist/testing.d.ts +1 -1
  39. package/dist/{types-gl13xwmN.d.cts → types-CRET8EhB.d.cts} +20 -2
  40. package/dist/{types-gl13xwmN.d.ts → types-CRET8EhB.d.ts} +20 -2
  41. package/dist/vite.cjs +2 -2
  42. package/dist/vite.js +1 -1
  43. package/package.json +6 -1
  44. package/dist/chunk-DI5STJM4.js.map +0 -1
  45. package/dist/chunk-HOTY7J3X.js.map +0 -1
  46. package/dist/chunk-JD4IJ4MN.cjs.map +0 -1
  47. package/dist/chunk-MCIQMYNR.js.map +0 -1
  48. package/dist/chunk-OSPTERGK.cjs.map +0 -1
  49. package/dist/chunk-PHYYA67T.cjs.map +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/console/style.ts","../src/console/reporter.ts","../src/core/interactions.ts","../src/core/opportunities.ts","../src/react/ancestry.ts","../src/react/instrument.tsx","../src/react/withRenderDetective.tsx","../src/react/RenderDetective.tsx","../src/react/hooks.ts","../src/index.ts"],"names":["label","jsx","useContext","useState","componentName"],"mappings":";;;;;;;;;AAkBA,IAAM,OAAA,GAAgC;AAAA,EACpC,KAAA,EAAO,EAAA;AAAA,EACP,GAAA,EAAK,eAAA;AAAA,EACL,MAAA,EAAQ,iBAAA;AAAA,EACR,IAAA,EAAM,eAAA;AAAA,EACN,IAAA,EAAM,eAAA;AAAA,EACN,GAAA,EAAK;AACP,CAAA;AAIA,IAAM,kBAAkB,MAAe;AACrC,EAAA,IAAI;AACF,IAAA,OAAO,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,QAAA,KAAa,WAAA;AAAA,EAC9D,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF,CAAA;AASO,SAAS,OAAO,QAAA,EAA4C;AACjE,EAAA,IAAI,CAAC,iBAAgB,EAAG;AACtB,IAAA,OAAO,CAAC,QAAA,CAAS,GAAA,CAAI,CA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,CAAO,CAAA,GAAI,CAAC,CAAA,CAAE,QAAA,CAAS,CAAC,CAAC,CAAA,EAAA,EAAK,EAAE,IAAA,CAAK,MAAA,CAAO,EAAE,CAAC,CAAA,CAAA,EAAI,OAAO,CAAA,CAAE,WAAW,EAAE,QAAA,CAAS,CAAC,CAAC,CAAA,UAAA,EAAa,EAAE,iBAAA,CACnG,OAAA,CAAQ,CAAC,CAAA,CACT,QAAA,CAAS,CAAC,CAAC,CAAA,SAAA,EAAY,EAAE,mBAAA,CAAoB,OAAA,CAAQ,CAAC,CAAC,CAAA,QAAA,EAAW,EAAE,eAAA,CAAgB,OAAA,CAAQ,CAAC,CAAC,CAAA,GAAA;AAAA,OACnG;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAA,CAAQ,GAAA,CAAI,KAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA;AAC9B;AAGO,IAAM,oBAAA,GAAuB;AAAA,EAClC,IAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,iBAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,iBAAA;AAAA,EACA,gBAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,4BAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["/**\n * Console colouring.\n *\n * Browsers support `%c` styling; terminals print the directive literally, so it\n * is feature-detected and degrades to plain text.\n *\n * Colour never carries meaning on its own. Every line keeps its glyph and its\n * words — `▲`, `12 avoidable`, `rebuilt` — so the output survives being copied\n * into an issue, read by someone with a different colour palette, or printed by\n * a reporter that strips styling.\n */\nexport type Tone = \"plain\" | \"dim\" | \"strong\" | \"good\" | \"warn\" | \"bad\";\n\n/**\n * Mid-tone values, chosen to stay legible against both light and dark console\n * backgrounds — DevTools follows the OS theme and the author does not get to\n * pick which one you use.\n */\nconst PALETTE: Record<Tone, string> = {\n plain: \"\",\n dim: \"color:#8a94a6\",\n strong: \"font-weight:600\",\n good: \"color:#1f9d5b\",\n warn: \"color:#c2820a\",\n bad: \"color:#d1493f;font-weight:600\",\n};\n\nexport type Segment = string | [text: string, tone: Tone];\n\nconst supportsStyling = (): boolean => {\n try {\n return typeof window !== \"undefined\" && typeof document !== \"undefined\";\n } catch {\n return false;\n }\n};\n\n/**\n * Builds `console.log` arguments from tagged segments.\n *\n * The count of `%c` directives and style arguments is guaranteed to match by\n * construction: a mismatch makes the browser print a literal `%c`, which is the\n * usual way this API gets broken.\n */\nexport function styled(segments: Segment[]): [string, ...string[]] {\n if (!supportsStyling()) {\n return [segments.map((s) => (typeof s === \"string\" ? s : s[0])).join(\"\")];\n }\n\n let format = \"\";\n const styles: string[] = [];\n for (const segment of segments) {\n if (typeof segment === \"string\") {\n // Escape any literal % so it cannot be read as a directive.\n format += segment.replace(/%/g, \"%%\");\n continue;\n }\n const [text, tone] = segment;\n format += `%c${text.replace(/%/g, \"%%\")}%c`;\n styles.push(PALETTE[tone], \"\");\n }\n return [format, ...styles];\n}\n\n/** Tone for a render's severity, following the configured thresholds. */\nexport function toneForSeverity(severity: string): Tone {\n switch (severity) {\n case \"critical\":\n case \"very-slow\":\n return \"bad\";\n case \"slow\":\n return \"warn\";\n case \"monitor\":\n return \"dim\";\n default:\n return \"plain\";\n }\n}\n","import { formatInspected } from \"../core/inspect.js\";\nimport { styled } from \"./style.js\";\nimport type { Segment, Tone } from \"./style.js\";\nimport type { Detective } from \"../core/store.js\";\nimport type { PropChange, RenderEvent } from \"../core/types.js\";\n\nconst ICON: Record<string, string> = {\n normal: \"·\",\n monitor: \"•\",\n slow: \"▲\",\n \"very-slow\": \"▲▲\",\n critical: \"■\",\n};\n\n/** Batches are coalesced over this window so a burst prints once. */\nconst BATCH_WINDOW_MS = 400;\n\n/**\n * Console output.\n *\n * `console` mode reports **commits, not renders**. One line per render is\n * unusable in a real application: a 20-row list mounting produced ~200 lines of\n * `FareTile #1 mount 0.1ms`, which Chrome then collapsed into `2×` markers —\n * pure noise that also slowed the app being measured. Worse, it buried the two\n * or three lines that actually mattered.\n *\n * So a batch is summarised, and a batch that contains nothing actionable is not\n * printed at all. `verbose` keeps the old per-render detail for when you have\n * narrowed to one component with `include`.\n */\nexport function attachConsoleReporter(detective: Detective): () => void {\n let pending: RenderEvent[] = [];\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const flush = (): void => {\n timer = undefined;\n const batch = pending;\n pending = [];\n if (batch.length === 0) return;\n try {\n printBatch(batch, detective.config.slowRenderThreshold);\n } catch {\n /* diagnostics must never break the app */\n }\n };\n\n const unsubscribe = detective.subscribe((event) => {\n const mode = detective.config.mode;\n if (mode === \"silent\") return;\n\n if (mode === \"verbose\") {\n try {\n printVerbose(event);\n } catch {\n /* ignore */\n }\n return;\n }\n\n pending.push(event);\n if (timer === undefined) {\n timer = setTimeout(flush, BATCH_WINDOW_MS);\n (timer as { unref?: () => void }).unref?.();\n }\n });\n\n return () => {\n unsubscribe();\n if (timer !== undefined) clearTimeout(timer);\n };\n}\n\ninterface Aggregate {\n name: string;\n source?: string;\n count: number;\n totalMs: number;\n reasons: Map<string, number>;\n /** Reasons of the renders that were actually actionable. */\n notableReasons: Map<string, number>;\n avoidable: number;\n remount: boolean;\n slow: boolean;\n worst?: RenderEvent;\n}\n\nfunction printBatch(batch: RenderEvent[], slowThreshold: number): void {\n const byComponent = new Map<string, Aggregate>();\n let totalMs = 0;\n let avoidable = 0;\n\n for (const event of batch) {\n const key = event.component.name;\n const entry = byComponent.get(key) ?? {\n name: key,\n source: event.component.source,\n count: 0,\n totalMs: 0,\n reasons: new Map<string, number>(),\n notableReasons: new Map<string, number>(),\n avoidable: 0,\n remount: false,\n slow: false,\n };\n entry.count++;\n entry.totalMs += event.timings.selfDuration;\n entry.reasons.set(event.diagnosis.reason, (entry.reasons.get(event.diagnosis.reason) ?? 0) + 1);\n if (event.diagnosis.potentiallyAvoidable || event.timings.selfDuration >= slowThreshold) {\n entry.notableReasons.set(event.diagnosis.reason, (entry.notableReasons.get(event.diagnosis.reason) ?? 0) + 1);\n }\n if (event.diagnosis.potentiallyAvoidable) entry.avoidable++;\n if (event.diagnosis.summary.includes(\"rebuilt\")) entry.remount = true;\n if (event.timings.selfDuration >= slowThreshold) entry.slow = true;\n if (!entry.worst || event.timings.selfDuration > entry.worst.timings.selfDuration) entry.worst = event;\n byComponent.set(key, entry);\n\n totalMs += event.timings.selfDuration;\n if (event.diagnosis.potentiallyAvoidable) avoidable++;\n }\n\n /*\n * Silence is the default. Renders that are cheap and fully explained are\n * normal behaviour, and reporting them trains people to ignore the console.\n */\n const notable = [...byComponent.values()].filter((a) => a.avoidable > 0 || a.slow || a.remount);\n if (notable.length === 0) return;\n\n const ranked = [...notable].sort((a, b) => b.totalMs - a.totalMs);\n const anySlow = ranked.some((a) => a.slow);\n\n const segments: Segment[] = [\n [\"[RRD] \", \"dim\"],\n [`${batch.length} render${batch.length === 1 ? \"\" : \"s\"}`, \"strong\"],\n [` · ${totalMs.toFixed(1)}ms`, \"dim\"],\n ];\n if (avoidable > 0) segments.push([` · ${avoidable} potentially avoidable`, \"warn\"]);\n\n for (const a of ranked.slice(0, 8)) {\n /*\n * Show why the *actionable* renders happened. A batch containing 12 mounts\n * and 12 avoidable updates would otherwise be labelled \"mount\", which is\n * the half nobody can do anything about.\n */\n const reasonSource = a.notableReasons.size > 0 ? a.notableReasons : a.reasons;\n const reason = [...reasonSource.entries()].sort((x, y) => y[1] - x[1])[0]?.[0] ?? \"unknown\";\n\n // Worst-first: a rebuild costs more than a slow render, which costs more\n // than an avoidable one.\n const tone: Tone = a.remount ? \"bad\" : a.slow ? \"warn\" : a.avoidable > 0 ? \"warn\" : \"good\";\n const label = ` ${ICON[a.slow ? \"slow\" : \"normal\"]} ${a.name}${a.count > 1 ? ` ×${a.count}` : \"\"}`;\n\n segments.push(\"\\n\", [label.padEnd(30), tone], [`${a.totalMs.toFixed(1)}ms`, \"plain\"], [` ${reason}`, \"dim\"]);\n if (a.remount) segments.push([\" rebuilt\", \"bad\"]);\n if (a.avoidable > 0) segments.push([` ${a.avoidable} avoidable`, \"warn\"]);\n if (a.source) segments.push([\"\\n \" + a.source, \"dim\"]);\n }\n\n const worst = ranked[0]?.worst;\n segments.push(\n \"\\n\",\n [\n worst?.diagnosis.suggestion\n ? ` → ${worst.diagnosis.suggestion}`\n : \" → rrd.printOpportunities() to rank everything by recoverable time\",\n \"dim\",\n ],\n );\n\n const log = anySlow ? console.warn : console.log;\n log(...styled(segments));\n}\n\nfunction printVerbose(event: RenderEvent): void {\n const { diagnosis, timings } = event;\n const header = `[RRD] ${event.component.name} #${event.renderNumber} — ${diagnosis.summary}`;\n\n const group = diagnosis.severity === \"normal\" ? console.groupCollapsed : console.group;\n group.call(console, header);\n try {\n console.log(`Cause: ${label(event)} (confidence: ${diagnosis.confidence})`);\n if (event.component.source) console.log(`Source: ${event.component.source}`);\n if (event.parent) {\n console.log(\n `Parent: ${event.parent.name}${event.parent.source ? ` (${event.parent.source})` : \"\"}` +\n `${event.parentRendered ? \" — re-rendered in this commit\" : \" — did not re-render\"}`,\n );\n }\n console.log(\n `Cost: self ${timings.selfDuration.toFixed(1)}ms · subtree ${timings.subtreeDuration.toFixed(1)}ms` +\n (timings.accountedDescendantDuration > 0\n ? ` (${timings.accountedDescendantDuration.toFixed(1)}ms in instrumented children)`\n : \"\"),\n );\n\n if (event.changedProps.length > 0) {\n console.groupCollapsed(`Props changed (${event.changedProps.length})`);\n for (const c of event.changedProps) console.log(propLine(c));\n console.groupEnd();\n }\n if (event.unchangedProps.length > 0) console.log(`Props same: ${event.unchangedProps.join(\", \")}`);\n if (event.trackedState.length > 0) {\n console.log(\n `State: ${event.trackedState\n .map((s) => `${s.name}: ${formatInspected(s.previous)} → ${formatInspected(s.current)}`)\n .join(\", \")}`,\n );\n }\n if (event.contextChanges.length > 0) {\n console.log(`Context: ${event.contextChanges.map((c) => c.contextName).join(\", \")} changed in this commit`);\n }\n\n console.groupCollapsed(\"Evidence\");\n for (const line of diagnosis.evidence) console.log(`• ${line}`);\n console.groupEnd();\n\n if (diagnosis.suggestion) console.log(`Next step: ${diagnosis.suggestion}`);\n if (diagnosis.potentiallyAvoidable) console.log(\"Flag: potentially avoidable render\");\n } finally {\n console.groupEnd();\n }\n}\n\nfunction propLine(c: PropChange): string {\n const head = `${c.key} (${c.valueType}) — ${describeKind(c)}`;\n if (c.kind === \"added\") return `${head}: ${formatInspected(c.current)}`;\n if (c.kind === \"removed\") return `${head}: was ${formatInspected(c.previous)}`;\n return `${head}\\n previous: ${formatInspected(c.previous)}\\n current: ${formatInspected(c.current)}`;\n}\n\nfunction describeKind(c: PropChange): string {\n switch (c.kind) {\n case \"added\":\n return \"added\";\n case \"removed\":\n return \"removed\";\n case \"value\":\n return \"value changed\";\n case \"reference\":\n if (c.valueType === \"function\") return c.sourceEqual ? \"new function, identical source\" : \"new function reference\";\n return c.shallowEqual === true ? \"reference changed, contents identical\" : \"reference changed\";\n }\n}\n\nfunction label(event: RenderEvent): string {\n switch (event.diagnosis.reason) {\n case \"mount\":\n return \"mount\";\n case \"props\":\n return event.changedProps.every((c) => c.kind === \"reference\") ? \"prop changed (reference only)\" : \"prop changed\";\n case \"parent\":\n return \"parent rendered\";\n case \"context\":\n return \"context update\";\n case \"state\":\n return \"state changed\";\n case \"state-or-external\":\n return \"state or external store\";\n case \"unknown\":\n return \"undetermined\";\n }\n}\n","import type { Confidence, RenderEvent } from \"./types.js\";\n\n/**\n * Interaction-scoped attribution.\n *\n * Performance is felt per interaction, not in aggregate — and INP is the metric\n * teams are actually judged on. This joins the two halves: the browser says a\n * keystroke took 240ms, and the render events say which components spent it and\n * why.\n *\n * Uses `PerformanceObserver` with `event` timing, a public browser API. Where it\n * is unsupported (older Safari, jsdom) interaction tracking simply stays empty\n * rather than guessing.\n */\nexport interface InteractionRecord {\n id: string;\n /** `click`, `keydown`, `pointerup`… */\n type: string;\n /** Best-effort description of what was interacted with. */\n target?: string;\n startTime: number;\n /** Browser-reported event duration — the number INP is computed from. */\n durationMs: number;\n /**\n * For a manually measured interaction: how long the synchronous action took.\n * Immune to throttling, unlike the full window, which waits on a frame.\n */\n handlerMs?: number;\n /** Renders committed inside this interaction's window. */\n renders: RenderEvent[];\n /** Sum of self durations for those renders. */\n renderTimeMs: number;\n /** Render time that no observable input change explains. */\n avoidableRenderTimeMs: number;\n}\n\nexport interface InteractionSummary {\n interaction: InteractionRecord;\n /** Components ordered by cost within this interaction. */\n contributors: Array<{ component: string; source?: string; renders: number; totalMs: number; cause: string }>;\n headline: string;\n nextStep: string;\n confidence: Confidence;\n}\n\n/** Entries React commits slightly after the event finishes; allow for that. */\nconst COMMIT_SLACK_MS = 100;\n\n/** Used when requestAnimationFrame cannot fire — a hidden tab, or jsdom. */\nconst FALLBACK_CLOSE_MS = 50;\n\ninterface RawEventTiming {\n name: string;\n startTime: number;\n duration: number;\n target?: string;\n handlerMs?: number;\n}\n\nexport class InteractionTracker {\n private records: InteractionRecord[] = [];\n private observer: { disconnect: () => void } | undefined;\n private nextId = 0;\n\n constructor(private capacity = 50) {}\n\n /** Returns false when the browser cannot report event timing. */\n start(): boolean {\n if (this.observer) return true;\n const PO = (globalThis as { PerformanceObserver?: typeof PerformanceObserver }).PerformanceObserver;\n const supported = PO?.supportedEntryTypes?.includes(\"event\");\n if (!PO || !supported) return false;\n\n try {\n const observer = new PO((list) => {\n for (const entry of list.getEntries()) {\n const timing = entry as PerformanceEntry & { duration: number; target?: Element };\n this.record({\n name: timing.name,\n startTime: timing.startTime,\n duration: timing.duration,\n target: describeTarget(timing.target),\n });\n }\n });\n // 16ms: anything that misses a frame is worth attributing.\n observer.observe({ type: \"event\", buffered: true, durationThreshold: 16 } as PerformanceObserverInit);\n this.observer = observer;\n return true;\n } catch {\n return false;\n }\n }\n\n stop(): void {\n this.observer?.disconnect();\n this.observer = undefined;\n }\n\n /** Is the automatic path available in this browser? */\n get automatic(): boolean {\n return this.observer !== undefined;\n }\n\n /**\n * Time an interaction by hand.\n *\n * The automatic path depends on the Event Timing API, which Safari only\n * gained in 16.4 and which does not fire for synthetic input at all — so\n * anything driven by a test harness records nothing. This measures a specific\n * action instead, up to the paint that follows it, and needs no browser\n * support beyond `performance.now`.\n */\n measure<T>(label: string, action: () => T): T {\n const startTime = now();\n let handlerMs = 0;\n let finished = false;\n const finish = (): void => {\n if (finished) return;\n finished = true;\n this.record({ name: label, startTime, duration: now() - startTime, handlerMs });\n };\n\n let result: T;\n try {\n result = action();\n handlerMs = now() - startTime;\n } catch (error) {\n handlerMs = now() - startTime;\n finish();\n throw error;\n }\n\n /*\n * Close the window after the frame in which React commits and paints.\n *\n * The timer is not belt-and-braces: `requestAnimationFrame` does not fire\n * in a hidden tab, and does not exist in jsdom, so without it an\n * interaction would simply never be recorded. Whichever fires first wins;\n * the fallback is long enough that rAF normally does.\n */\n const raf = (globalThis as { requestAnimationFrame?: (cb: () => void) => void }).requestAnimationFrame;\n if (raf) raf(() => raf(finish));\n setTimeout(finish, FALLBACK_CLOSE_MS);\n\n return result;\n }\n\n /** Exposed for tests and for `measure`. */\n record(timing: RawEventTiming): InteractionRecord {\n const record: InteractionRecord = {\n id: `interaction_${++this.nextId}`,\n type: timing.name,\n target: timing.target,\n startTime: timing.startTime,\n durationMs: timing.duration,\n handlerMs: timing.handlerMs,\n renders: [],\n renderTimeMs: 0,\n avoidableRenderTimeMs: 0,\n };\n this.records.push(record);\n if (this.records.length > this.capacity) this.records.shift();\n return record;\n }\n\n clear(): void {\n this.records.length = 0;\n }\n\n /**\n * Joins render events to interactions by commit time. A render belongs to an\n * interaction when it committed between the event starting and shortly after\n * it finished — React commits just after the event handler returns.\n */\n attribute(events: RenderEvent[]): InteractionRecord[] {\n for (const record of this.records) {\n const from = record.startTime;\n const to = record.startTime + record.durationMs + COMMIT_SLACK_MS;\n record.renders = events.filter((e) => e.timings.commitTime >= from && e.timings.commitTime <= to);\n record.renderTimeMs = record.renders.reduce((a, e) => a + e.timings.selfDuration, 0);\n record.avoidableRenderTimeMs = record.renders\n .filter((e) => e.diagnosis.potentiallyAvoidable)\n .reduce((a, e) => a + e.timings.selfDuration, 0);\n }\n return [...this.records].sort((a, b) => b.durationMs - a.durationMs);\n }\n}\n\nexport function summarise(record: InteractionRecord): InteractionSummary {\n const byComponent = new Map<string, { renders: number; totalMs: number; source?: string; cause: string }>();\n for (const event of record.renders) {\n const entry = byComponent.get(event.component.name) ?? {\n renders: 0,\n totalMs: 0,\n source: event.component.source,\n cause: event.diagnosis.reason,\n };\n entry.renders++;\n entry.totalMs += event.timings.selfDuration;\n byComponent.set(event.component.name, entry);\n }\n\n const contributors = [...byComponent.entries()]\n .map(([component, v]) => ({ component, source: v.source, renders: v.renders, totalMs: v.totalMs, cause: v.cause }))\n .sort((a, b) => b.totalMs - a.totalMs);\n\n const top = contributors[0];\n\n /*\n * A manually measured window waits for a frame, and a throttled or hidden tab\n * can stretch that to hundreds of milliseconds of pure idling. Attributing\n * that to the app would be inventing a problem, so when the window is far\n * larger than the work inside it, reason about the work instead.\n */\n const accounted = (record.handlerMs ?? record.durationMs) + record.renderTimeMs;\n const idleWindow = record.handlerMs !== undefined && record.durationMs > accounted * 3 && record.durationMs - accounted > 100;\n const effectiveMs = idleWindow ? accounted : record.durationMs;\n const share = effectiveMs > 0 ? record.renderTimeMs / effectiveMs : 0;\n\n let headline: string;\n let nextStep: string;\n let confidence: Confidence = \"medium\";\n\n if (idleWindow) {\n headline =\n `${record.type}: ${fmt(record.handlerMs ?? 0)} in the handler and ${fmt(record.renderTimeMs)} rendering. ` +\n `The measured window was ${fmt(record.durationMs)}, but most of that was the page waiting for a frame — ignore it.`;\n nextStep =\n record.renderTimeMs > (record.handlerMs ?? 0)\n ? `Rendering dominates the real work${top ? `; start with ${top.component}` : \"\"}.`\n : \"The handler itself costs more than rendering. Profile the handler, not React.\";\n return { interaction: record, contributors, headline, nextStep, confidence: \"medium\" };\n }\n\n if (record.renders.length === 0) {\n headline = `${record.type} took ${fmt(record.durationMs)}, and no instrumented component rendered inside it.`;\n nextStep =\n \"The cost is somewhere other than React rendering — an event handler, a layout, or an uninstrumented component. Instrument more of the tree to narrow it down.\";\n confidence = \"low\";\n } else if (share >= 0.4 && record.avoidableRenderTimeMs > 0) {\n headline =\n `${record.type} took ${fmt(record.durationMs)}; ${fmt(record.renderTimeMs)} of it was rendering, ` +\n `and ${fmt(record.avoidableRenderTimeMs)} of that had no input change to explain it.`;\n nextStep = top\n ? `Start with ${top.component}${top.source ? ` (${top.source})` : \"\"} — ${fmt(top.totalMs)} across ${top.renders} render${top.renders === 1 ? \"\" : \"s\"}.`\n : \"Look at the top contributor below.\";\n confidence = \"high\";\n } else if (share >= 0.4) {\n headline = `${record.type} took ${fmt(record.durationMs)}; ${fmt(record.renderTimeMs)} of it was rendering, all of it explained by real input changes.`;\n nextStep = \"This is genuine work. Make the renders cheaper rather than fewer — or do less of it per interaction.\";\n confidence = \"high\";\n } else {\n headline = `${record.type} took ${fmt(record.durationMs)}, but only ${fmt(record.renderTimeMs)} was React rendering.`;\n nextStep = \"Most of the cost is outside rendering — event handlers, layout or paint. A browser profile will show more than this tool can.\";\n confidence = \"medium\";\n }\n\n return { interaction: record, contributors, headline, nextStep, confidence };\n}\n\nexport function formatInteraction(summary: InteractionSummary): string {\n const { interaction: i } = summary;\n const lines = [\n `${i.type}${i.target ? ` on ${i.target}` : \"\"} ${fmt(i.durationMs)}`,\n \"\",\n summary.headline,\n ];\n\n if (summary.contributors.length > 0) {\n lines.push(\"\", \"Rendering inside this interaction\");\n for (const c of summary.contributors.slice(0, 8)) {\n lines.push(\n ` ${c.component.padEnd(22)} ${String(c.renders).padStart(4)} render(s) ${fmt(c.totalMs).padStart(8)} ${c.cause}`,\n );\n }\n }\n\n lines.push(\"\", `Next step`, ` ${summary.nextStep}`, \"\", `Confidence: ${summary.confidence}`);\n return lines.join(\"\\n\");\n}\n\nfunction describeTarget(target: unknown): string | undefined {\n if (!target || typeof target !== \"object\") return undefined;\n const el = target as { tagName?: string; id?: string; className?: unknown; textContent?: string | null };\n if (!el.tagName) return undefined;\n const tag = el.tagName.toLowerCase();\n if (el.id) return `${tag}#${el.id}`;\n const className = typeof el.className === \"string\" ? el.className.trim().split(/\\s+/)[0] : undefined;\n if (className) return `${tag}.${className}`;\n const text = el.textContent?.trim().slice(0, 20);\n return text ? `${tag} \"${text}\"` : tag;\n}\n\nconst fmt = (ms: number): string => `${ms.toFixed(1)}ms`;\n\nconst now = (): number =>\n typeof performance !== \"undefined\" && typeof performance.now === \"function\" ? performance.now() : Date.now();\n","import { explainEvents } from \"./explain.js\";\nimport type { Confidence, RenderEvent } from \"./types.js\";\n\n/**\n * \"Where should I spend my next hour?\"\n *\n * Render counts answer the wrong question — a component rendering 2 000 times\n * for 0.01ms is not the problem, and one rendering 40 times for 12ms might be.\n * This ranks by **estimated recoverable time**, so the top of the list is the\n * biggest win rather than the noisiest component.\n */\nexport interface Opportunity {\n component: string;\n source?: string;\n /** Milliseconds plausibly recovered by fixing this. The ranking key. */\n estimatedSavingMs: number;\n /** Renders where no observable input changed. */\n avoidableRenders: number;\n /** Times the component was rebuilt rather than re-rendered. */\n remounts: number;\n averageSelfDuration: number;\n /** One line: what to look at. Comes from the diagnostic engine, not from here. */\n summary: string;\n nextStep: string;\n confidence: Confidence;\n}\n\nexport interface OpportunityInput {\n events: RenderEvent[];\n lifecycles: Map<string, { remounts: number }>;\n /** Ignore anything below this. Noise is worse than silence in a ranked list. */\n minSavingMs?: number;\n}\n\nconst DEFAULT_MIN_SAVING_MS = 1;\n\nexport function rankOpportunities({ events, lifecycles, minSavingMs = DEFAULT_MIN_SAVING_MS }: OpportunityInput): Opportunity[] {\n const names = new Set(events.map((e) => e.component.name));\n const out: Opportunity[] = [];\n\n for (const name of names) {\n const lifecycle = lifecycles.get(name);\n const explanation = explainEvents(name, events, lifecycle);\n if (!explanation) continue;\n\n /*\n * A remount is charged at the cost of a mount, because that is what it is:\n * React rebuilds the subtree. Avoidable renders are charged at what they\n * actually cost. Both are estimates and are labelled as such — the point is\n * an ordering, not a promise.\n */\n const mounts = events.filter((e) => e.component.name === name && e.phase === \"mount\");\n const averageMountCost = mounts.length\n ? mounts.reduce((a, e) => a + e.timings.selfDuration, 0) / mounts.length\n : 0;\n const remountSaving = explanation.remounts * averageMountCost;\n const estimatedSavingMs = explanation.estimatedAvoidableTime + remountSaving;\n\n if (estimatedSavingMs < minSavingMs) continue;\n\n out.push({\n component: name,\n source: explanation.source,\n estimatedSavingMs,\n avoidableRenders: explanation.potentiallyAvoidableRenders,\n remounts: explanation.remounts,\n averageSelfDuration: explanation.averageSelfDuration,\n summary: explanation.headline,\n nextStep: explanation.nextStep,\n confidence: explanation.confidence,\n });\n }\n\n return out.sort((a, b) => b.estimatedSavingMs - a.estimatedSavingMs);\n}\n\nexport function formatOpportunities(opportunities: Opportunity[]): string {\n if (opportunities.length === 0) {\n return \"React Render Detective\\n\\nNo measurable render waste found yet. Interact with the app and try again.\";\n }\n\n const lines = [\n \"React Render Detective — where to spend your next hour\",\n \"\",\n \"Ranked by estimated recoverable time. These are estimates, not promises:\",\n \"measure each fix.\",\n \"\",\n ];\n\n for (const [index, o] of opportunities.entries()) {\n lines.push(\n `${String(index + 1).padStart(2)}. ${o.component}${o.source ? ` ${o.source}` : \"\"}`,\n ` ~${o.estimatedSavingMs.toFixed(0)}ms recoverable ` +\n `${o.avoidableRenders} avoidable render${o.avoidableRenders === 1 ? \"\" : \"s\"}` +\n `${o.remounts > 0 ? `, ${o.remounts}× rebuilt` : \"\"} (confidence: ${o.confidence})`,\n ` ${o.summary}`,\n ` → ${o.nextStep}`,\n \"\",\n );\n }\n\n return lines.join(\"\\n\");\n}\n","import { createContext } from \"react\";\nimport type { NodeRecord } from \"../core/store.js\";\n\n/**\n * Carries the nearest instrumented ancestor down the tree.\n *\n * The value is the node object, created once per mounted instance and **never\n * replaced**. That is deliberate: a context value that changed per render would\n * force every instrumented descendant to re-render, defeating `React.memo` and\n * changing the behaviour of the very app we are measuring.\n */\nexport const AncestryContext = createContext<NodeRecord | undefined>(undefined);\nAncestryContext.displayName = \"RenderDetectiveAncestry\";\n","import { Profiler, useCallback, useContext, useLayoutEffect, useState } from \"react\";\nimport type { ProfilerOnRenderCallback, ReactNode } from \"react\";\nimport { getDetective } from \"../core/store.js\";\nimport type { NodeRecord } from \"../core/store.js\";\nimport type { RenderPhase } from \"../core/types.js\";\nimport { AncestryContext } from \"./ancestry.js\";\n\nexport interface TrackOptions {\n /** Overrides the inferred component name. Required for anonymous components. */\n name?: string;\n /**\n * `path/to/File.tsx:12:2`. Supplied automatically by the build plugin; there\n * is no runtime way to obtain it.\n */\n source?: string;\n /**\n * Set by the build plugin when the component is declared inside another\n * function. React sees a new component type on every parent render and\n * rebuilds the whole subtree, so this turns a guess into a fact.\n */\n declaredInRender?: boolean;\n}\n\n/**\n * Registers the current component, records this render attempt, and returns the\n * node plus a Profiler callback. All of it is a no-op when disabled.\n */\nexport function useInstrumentedNode(\n name: string,\n props: Record<string, unknown>,\n source?: string,\n): { node: NodeRecord | undefined; onRender: ProfilerOnRenderCallback } {\n const detective = getDetective();\n const parent = useContext(AncestryContext);\n\n // The active/inactive decision is frozen per instance so the element tree\n // shape never changes underneath a mounted component.\n const [node] = useState<NodeRecord | undefined>(() =>\n detective.enabled ? detective.createNode(name, parent, source) : undefined,\n );\n\n useLayoutEffect(() => {\n if (!node) return;\n detective.attach(node);\n return () => detective.detach(node);\n }, [detective, node]);\n\n if (node) {\n try {\n detective.recordAttempt(node, props);\n } catch {\n /* never break the app being debugged (§46) */\n }\n }\n\n const onRender = useCallback<ProfilerOnRenderCallback>(\n (_id, phase, actualDuration, baseDuration, startTime, commitTime) => {\n if (!node) return;\n try {\n detective.recordCommit(node, {\n phase: phase as RenderPhase,\n subtreeDuration: actualDuration,\n baseDuration,\n startTime,\n commitTime,\n });\n } catch {\n /* ignore */\n }\n },\n [detective, node],\n );\n\n return { node, onRender };\n}\n\nexport function renderInstrumented(\n node: NodeRecord | undefined,\n onRender: ProfilerOnRenderCallback,\n children: ReactNode,\n): ReactNode {\n if (!node) return children;\n return (\n <Profiler id={node.id} onRender={onRender}>\n <AncestryContext.Provider value={node}>{children}</AncestryContext.Provider>\n </Profiler>\n );\n}\n\nexport function componentName(component: unknown, fallback = \"Anonymous\"): string {\n const c = component as { displayName?: string; name?: string; type?: unknown } | null;\n if (!c) return fallback;\n if (typeof c.displayName === \"string\" && c.displayName) return c.displayName;\n if (typeof c.name === \"string\" && c.name) return c.name;\n // React.memo / forwardRef wrappers keep the real component on `.type`.\n if (c.type) return componentName(c.type, fallback);\n return fallback;\n}\n","import type { ComponentType } from \"react\";\nimport { getDetective } from \"../core/store.js\";\n\n/** Marks a component as one of ours, so it is never wrapped twice. */\nconst IS_WRAPPER = Symbol.for(\"react-render-detective.wrapper\");\nimport { componentName, renderInstrumented, useInstrumentedNode } from \"./instrument.js\";\nimport type { TrackOptions } from \"./instrument.js\";\n\n/**\n * Wraps a component with full instrumentation: render counting, prop diffing,\n * parent attribution and Profiler timings.\n *\n * This is the most accurate integration mode — the wrapper's render function\n * runs exactly when the wrapped component re-renders, and it receives the same\n * props, so every diagnosis has first-hand evidence.\n *\n * Ref note: on React 19 `ref` is an ordinary prop and passes through the spread.\n * On React 18 and below, wrap with `forwardRef` yourself if the component needs\n * a ref.\n */\nexport function withRenderDetective<P extends object>(\n Component: ComponentType<P>,\n options: TrackOptions = {},\n): ComponentType<P> {\n /*\n * Wrapping a wrapper would make it render itself. That is unreachable through\n * careful hand-wrapping but trivially reachable once a build plugin is\n * wrapping everything, and the failure mode is a stack overflow before first\n * paint — so return the existing wrapper instead.\n */\n if ((Component as { [IS_WRAPPER]?: boolean })[IS_WRAPPER]) return Component;\n\n const name = options.name ?? componentName(Component);\n\n /*\n * Counted at wrap time, not render time. A component declared at module scope\n * is wrapped once; one declared inside a render body is wrapped again on every\n * parent render, which is the tell for the most expensive mistake in this\n * list — React rebuilds the whole subtree each time.\n */\n getDetective().noteDefinition(name, options.source, options.declaredInRender === true);\n\n function RenderDetected(props: P) {\n const { node, onRender } = useInstrumentedNode(name, props as Record<string, unknown>, options.source);\n return renderInstrumented(node, onRender, <Component {...props} />);\n }\n\n RenderDetected.displayName = `RenderDetective(${name})`;\n (RenderDetected as { [IS_WRAPPER]?: boolean })[IS_WRAPPER] = true;\n return RenderDetected;\n}\n","import type { ReactNode } from \"react\";\nimport { renderInstrumented, useInstrumentedNode } from \"./instrument.js\";\n\nexport interface RenderDetectiveProps {\n name: string;\n children: ReactNode;\n}\n\n/**\n * Zero-refactor integration: drop it around a subtree.\n *\n * <RenderDetective name=\"UserProfile\"><UserProfile /></RenderDetective>\n *\n * Accuracy note: this boundary only sees the `children` **element**, not the\n * wrapped component's props. It therefore reports timings, parent propagation\n * and children-element churn accurately, but it cannot attribute a render to an\n * individual prop. Use `withRenderDetective` when you want per-prop diagnosis.\n */\nexport function RenderDetective({ name, children }: RenderDetectiveProps): ReactNode {\n const { node, onRender } = useInstrumentedNode(name, { children });\n return renderInstrumented(node, onRender, children);\n}\n","import * as React from \"react\";\nimport { useContext, useEffect, useRef, useState } from \"react\";\nimport type { Dispatch, SetStateAction } from \"react\";\nimport { getDetective } from \"../core/store.js\";\nimport { inspect } from \"../core/inspect.js\";\nimport { diffProps, shallowEqual } from \"../core/compare.js\";\nimport type { RenderEvent } from \"../core/types.js\";\nimport { AncestryContext } from \"./ancestry.js\";\n\n/**\n * In-component diagnostics without wrapping.\n *\n * Limitation, by design: a hook cannot install a `<Profiler>` around its own\n * component, so **no duration is available in this mode** — timings are\n * reported as 0. Everything else (render count, prop diffing, parent\n * attribution) is as accurate as the HOC.\n */\nexport function useRenderDiagnostics(name: string, props?: Record<string, unknown>): RenderEvent | undefined {\n const detective = getDetective();\n const parent = useContext(AncestryContext);\n const [node] = useState(() => {\n if (!detective.enabled) return undefined;\n const created = detective.createNode(name, parent);\n if (created) detective.hookModeNodes.add(created);\n return created;\n });\n const last = useRef<RenderEvent | undefined>(undefined);\n\n useEffect(() => {\n if (!node) return;\n detective.attach(node);\n const unsubscribe = detective.subscribe((event) => {\n if (event.component.id === node.id) last.current = event;\n });\n return () => {\n unsubscribe();\n detective.detach(node);\n };\n }, [detective, node]);\n\n if (node) {\n const isMount = !node.seenCommit;\n detective.recordAttempt(node, props ?? {});\n // No Profiler in hook mode: enqueue with a sentinel commit time, which the\n // flush pass resolves to the next real commit that follows this render.\n detective.recordCommit(node, {\n phase: isMount ? \"mount\" : \"update\",\n subtreeDuration: 0,\n baseDuration: 0,\n startTime: 0,\n commitTime: -1,\n });\n }\n\n return last.current;\n}\n\n/**\n * React 18+. Used only to identify *which* component under an instrumented node\n * owns the tracked state; `useId` is stable across StrictMode's double render,\n * which a `useRef` token would not be. Older React simply loses the guard.\n */\nconst useOwnerId: () => string =\n typeof (React as { useId?: () => string }).useId === \"function\"\n ? (React as unknown as { useId: () => string }).useId\n : () => \"\";\n\n/**\n * `useState` with a label. The only reliable way to attribute a render to a\n * specific piece of local state without React internals.\n *\n * **Call this inside a component that is itself instrumented** (wrapped with\n * `withRenderDetective`, or using `useRenderDiagnostics`). A hook cannot see\n * which component called it, only the nearest instrumented ancestor — so state\n * named in an uninstrumented descendant would be reported as the ancestor's.\n * The first caller under a given node claims it and later callers are ignored,\n * which stops a descendant from stealing the attribution, but it cannot rescue\n * the case where the ancestor never tracks state of its own.\n */\nexport function useTrackedState<S>(name: string, initial: S | (() => S)): [S, Dispatch<SetStateAction<S>>] {\n const detective = getDetective();\n const node = useContext(AncestryContext);\n const ownerId = useOwnerId();\n const [state, setState] = useState<S>(initial);\n const previous = useRef<S>(state);\n\n if (node && node.stateOwner === undefined) node.stateOwner = ownerId;\n const owns = !node || node.stateOwner === ownerId;\n\n if (node && owns && !Object.is(previous.current, state)) {\n detective.recordStateChange(node, {\n name,\n previous: inspect(previous.current, detective.config.inspection),\n current: inspect(state, detective.config.inspection),\n });\n previous.current = state;\n } else if (!owns) {\n previous.current = state;\n }\n\n return [state, setState];\n}\n\n/**\n * `useEffect` that reports which of **its own declared** dependencies changed.\n *\n * This does not analyse whether the dependency list is correct — that needs\n * static analysis, not runtime observation (see docs/FEASIBILITY.md §9).\n */\nexport function useTrackedEffect(\n name: string,\n effect: () => void | (() => void),\n deps: unknown[],\n): void {\n const detective = getDetective();\n const previous = useRef<unknown[] | undefined>(undefined);\n const changed = useRef<number[]>([]);\n\n if (detective.enabled) {\n const prev = previous.current;\n changed.current = prev\n ? deps.map((d, i) => (Object.is(d, prev[i]) ? -1 : i)).filter((i) => i >= 0)\n : [];\n previous.current = deps;\n }\n\n useEffect(() => {\n if (detective.enabled && detective.config.mode !== \"silent\" && changed.current.length > 0) {\n // eslint-disable-next-line no-console\n console.debug(`[RRD] effect ${name} ran — deps changed at index ${changed.current.join(\", \")}`);\n }\n return effect();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n}\n\n/**\n * Reports when a context value changes, from inside the provider.\n * Returns the value untouched.\n */\nexport function useTrackedContextValue<T>(contextName: string, value: T): T {\n const detective = getDetective();\n const previous = useRef<T | undefined>(undefined);\n const first = useRef(true);\n\n if (detective.enabled) {\n if (first.current) {\n first.current = false;\n } else if (!Object.is(previous.current, value)) {\n const prev = previous.current;\n const equal = shallowEqual(prev, value, detective.config);\n const changedKeys =\n isRecord(prev) && isRecord(value)\n ? diffProps(prev, value, detective.config).changed.map((c) => c.key)\n : [];\n detective.recordContextChange({\n contextName,\n changedKeys,\n referenceOnly: equal === true,\n commitTime: -1,\n });\n }\n previous.current = value;\n }\n\n return value;\n}\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n","import { attachConsoleReporter } from \"./console/reporter.js\";\nimport { explainEvents, formatExplanation } from \"./core/explain.js\";\nimport { formatInteraction, InteractionTracker, summarise } from \"./core/interactions.js\";\nimport type { InteractionRecord, InteractionSummary } from \"./core/interactions.js\";\nimport { formatOpportunities, rankOpportunities } from \"./core/opportunities.js\";\nimport type { Opportunity } from \"./core/opportunities.js\";\nimport { getDetective } from \"./core/store.js\";\nimport { profileFromEvents } from \"./testing/index.js\";\nimport type { RenderProfile } from \"./testing/index.js\";\nimport type {\n AppStats,\n ComponentStats,\n DetectiveConfig,\n DetectiveOptions,\n RenderEvent,\n} from \"./core/types.js\";\n\nconst REPORTER = Symbol.for(\"react-render-detective.reporter\");\nconst INTERACTIONS = Symbol.for(\"react-render-detective.interactions\");\ntype Global = typeof globalThis & { [REPORTER]?: () => void; [INTERACTIONS]?: InteractionTracker };\n\nfunction tracker(): InteractionTracker {\n const g = globalThis as Global;\n if (!g[INTERACTIONS]) g[INTERACTIONS] = new InteractionTracker();\n return g[INTERACTIONS] as InteractionTracker;\n}\n\n/**\n * Enable diagnostics. Safe to call repeatedly — Fast Refresh, duplicate module\n * copies and re-entrant setup all reconfigure the single instance rather than\n * stacking listeners (§47).\n */\nexport function init(options: DetectiveOptions = {}): void {\n const detective = getDetective();\n detective.init(options);\n\n const g = globalThis as Global;\n g[REPORTER]?.();\n g[REPORTER] = undefined;\n\n if (detective.enabled) {\n // Browsers without `event` timing simply report no interactions.\n tracker().start();\n }\n\n if (detective.enabled && detective.config.mode !== \"silent\") {\n g[REPORTER] = attachConsoleReporter(detective);\n } else if (!detective.enabled) {\n // Never fail silently: a disabled detective looks identical to a broken one.\n console.info(\n \"[RRD] Diagnostics are disabled\" +\n (detective.config.enabled === false ? \" (enabled: false, or a production build was detected).\" : \".\"),\n );\n }\n}\n\n/** Update configuration without re-initialising. */\nexport function configure(options: DetectiveOptions): void {\n getDetective().configure(options);\n}\n\nexport function getConfig(): Readonly<DetectiveConfig> {\n return getDetective().config;\n}\n\nexport function isEnabled(): boolean {\n return getDetective().enabled;\n}\n\n/** Oldest → newest, bounded by `maxEvents`. */\nexport function getEvents(): RenderEvent[] {\n return getDetective().getEvents();\n}\n\nexport function getStats(): AppStats {\n return getDetective().getStats();\n}\n\nexport function getComponentStats(name?: string): ComponentStats[] {\n return getDetective().getComponentStats(name);\n}\n\n/** Live event stream. Returns an unsubscribe function. */\nexport function subscribe(listener: (event: RenderEvent) => void): () => void {\n return getDetective().subscribe(listener);\n}\n\n/** Clears recorded events and statistics; instrumentation stays attached. */\nexport function clear(): void {\n getDetective().clear();\n tracker().clear();\n}\n\n/** Full teardown, including configuration. Mainly for tests and HMR disposal. */\nexport function reset(): void {\n const g = globalThis as Global;\n g[REPORTER]?.();\n g[REPORTER] = undefined;\n g[INTERACTIONS]?.stop();\n g[INTERACTIONS] = undefined;\n getDetective().reset();\n}\n\n/**\n * The flagship answer: aggregate every recorded render of one component into a\n * single, human explanation. Returns `undefined` if nothing was recorded.\n */\nexport function explain(componentName: string): string | undefined {\n const explanation = explainStructured(componentName);\n return explanation ? formatExplanation(explanation) : undefined;\n}\n\n/** Structured form of `explain`, for building UIs on top. */\nexport function explainStructured(componentName: string) {\n return explainEvents(componentName, getEvents(), getDetective().lifecycleOf(componentName));\n}\n\n/** Snapshot render behaviour for regression testing. See `react-render-detective/testing`. */\nexport function getRenderProfile(scenario: string): RenderProfile {\n const remounts: Record<string, number> = {};\n for (const stats of getDetective().getComponentStats()) remounts[stats.name] = stats.remountCount;\n return profileFromEvents(scenario, getEvents(), remounts);\n}\n\n/**\n * Interactions, slowest first, with the renders that happened inside each.\n *\n * This is the bridge from render causality to what a user actually feels: the\n * browser reports how long the interaction took, and the render events say\n * which components spent that time and why.\n */\nexport function getInteractions(): InteractionRecord[] {\n return tracker().attribute(getEvents());\n}\n\n/** Structured analysis of one interaction. Defaults to the slowest recorded. */\nexport function explainInteractionStructured(id?: string): InteractionSummary | undefined {\n const records = getInteractions();\n const record = id ? records.find((r) => r.id === id) : records[0];\n return record ? summarise(record) : undefined;\n}\n\nexport function explainInteraction(id?: string): string | undefined {\n const summary = explainInteractionStructured(id);\n return summary ? formatInteraction(summary) : undefined;\n}\n\nexport function printInteractions(limit = 5): void {\n const records = getInteractions().slice(0, limit);\n if (records.length === 0) {\n console.log(\n tracker().automatic\n ? \"No interactions recorded yet. Event timing is working — nothing has taken longer than 16ms.\\n\" +\n \"Synthetic clicks from a test harness never produce these entries; use measureInteraction() there.\"\n : \"This browser does not report event timing (Safari before 16.4, jsdom).\\n\" +\n \"Use measureInteraction(label, fn) to time interactions by hand.\",\n );\n return;\n }\n console.log(records.map((r) => formatInteraction(summarise(r))).join(\"\\n\\n\"));\n}\n\n/**\n * Time one interaction explicitly, up to the paint that follows it.\n *\n * Needed wherever the automatic path cannot see: Safari before 16.4, and any\n * synthetic input, which never produces Event Timing entries.\n */\nexport function measureInteraction<T>(label: string, action: () => T): T {\n return tracker().measure(label, action);\n}\n\n/**\n * Components ranked by estimated recoverable time — the triage view. Render\n * counts answer the wrong question; this answers \"what should I fix first?\".\n */\nexport function getOpportunities(limit = 10): Opportunity[] {\n const detective = getDetective();\n const lifecycles = new Map<string, { remounts: number }>();\n for (const stats of detective.getComponentStats()) {\n lifecycles.set(stats.name, { remounts: stats.remountCount });\n }\n return rankOpportunities({ events: detective.getEvents(), lifecycles }).slice(0, limit);\n}\n\nexport function printOpportunities(limit = 10): void {\n console.log(formatOpportunities(getOpportunities(limit)));\n}\n\n/** Prints the application-level dashboard (§53). */\nexport function printStats(): void {\n const s = getStats();\n const lines = [\n \"React Render Detective\",\n \"\",\n `Components ${s.components}`,\n `Total renders ${s.totalRenders}`,\n `Total render time ${s.totalRenderTime.toFixed(1)}ms`,\n `Slow renders ${s.slowRenders}`,\n `Potentially avoidable ${s.potentiallyAvoidableRenders}`,\n ];\n const rebuilt = s.mostRendered.filter((c) => c.remountCount >= 2);\n if (rebuilt.length > 0) {\n lines.push(\n \"\",\n \"Rebuilt rather than re-rendered (state and DOM discarded each time)\",\n ...rebuilt.slice(0, 5).map((c) => ` ${c.name.padEnd(22)} ${String(c.remountCount).padStart(5)}× remounted`),\n );\n }\n if (s.devReplays > 0) {\n lines.push(`Development replays ${s.devReplays} (StrictMode / discarded — not counted above)`);\n }\n if (s.mostExpensive.length > 0) {\n lines.push(\"\", \"Top by cumulative render time\");\n for (const [i, c] of s.mostExpensive.slice(0, 5).entries()) {\n lines.push(\n `${String(i + 1).padStart(2)}. ${c.name.padEnd(22)} ${String(c.renderCount).padStart(6)} renders ${c.totalSelfDuration\n .toFixed(1)\n .padStart(8)}ms (avg ${c.averageSelfDuration.toFixed(1)}ms, p95 ${c.p95SelfDuration.toFixed(1)}ms)`,\n );\n }\n }\n console.log(lines.join(\"\\n\"));\n}\n\n/** Namespaced form, matching the documented `ReactRenderDetective.init()` usage. */\nexport const ReactRenderDetective = {\n init,\n configure,\n getConfig,\n isEnabled,\n getEvents,\n getStats,\n getComponentStats,\n subscribe,\n clear,\n reset,\n explain,\n explainStructured,\n getOpportunities,\n printOpportunities,\n getInteractions,\n explainInteraction,\n explainInteractionStructured,\n printInteractions,\n measureInteraction,\n getRenderProfile,\n printStats,\n};\n\nexport { withRenderDetective } from \"./react/withRenderDetective.js\";\nexport { RenderDetective } from \"./react/RenderDetective.js\";\nexport type { RenderDetectiveProps } from \"./react/RenderDetective.js\";\nexport {\n useRenderDiagnostics,\n useTrackedState,\n useTrackedEffect,\n useTrackedContextValue,\n} from \"./react/hooks.js\";\nexport type { TrackOptions } from \"./react/instrument.js\";\nexport { explainEvents, formatExplanation } from \"./core/explain.js\";\nexport { rankOpportunities, formatOpportunities } from \"./core/opportunities.js\";\nexport { InteractionTracker, summarise as summariseInteraction, formatInteraction } from \"./core/interactions.js\";\nexport type { InteractionRecord, InteractionSummary } from \"./core/interactions.js\";\nexport type { Opportunity } from \"./core/opportunities.js\";\nexport type { Explanation } from \"./core/explain.js\";\nexport type * from \"./core/types.js\";\n"]}
1
+ {"version":3,"sources":["../src/console/style.ts","../src/console/reporter.ts","../src/core/opportunities.ts","../src/react/ancestry.ts","../src/react/instrument.tsx","../src/react/withRenderDetective.tsx","../src/react/RenderDetective.tsx","../src/react/selector.ts","../src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AAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,iBAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,iBAAA;AAAA,EACA,gBAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["/**\n * Console colouring.\n *\n * Browsers support `%c` styling; terminals print the directive literally, so it\n * is feature-detected and degrades to plain text.\n *\n * Colour never carries meaning on its own. Every line keeps its glyph and its\n * words — `▲`, `12 avoidable`, `rebuilt` — so the output survives being copied\n * into an issue, read by someone with a different colour palette, or printed by\n * a reporter that strips styling.\n */\nexport type Tone = \"plain\" | \"dim\" | \"strong\" | \"good\" | \"warn\" | \"bad\";\n\n/**\n * Mid-tone values, chosen to stay legible against both light and dark console\n * backgrounds — DevTools follows the OS theme and the author does not get to\n * pick which one you use.\n */\nconst PALETTE: Record<Tone, string> = {\n plain: \"\",\n dim: \"color:#8a94a6\",\n strong: \"font-weight:600\",\n good: \"color:#1f9d5b\",\n warn: \"color:#c2820a\",\n bad: \"color:#d1493f;font-weight:600\",\n};\n\nexport type Segment = string | [text: string, tone: Tone];\n\nconst supportsStyling = (): boolean => {\n try {\n return typeof window !== \"undefined\" && typeof document !== \"undefined\";\n } catch {\n return false;\n }\n};\n\n/**\n * Builds `console.log` arguments from tagged segments.\n *\n * The count of `%c` directives and style arguments is guaranteed to match by\n * construction: a mismatch makes the browser print a literal `%c`, which is the\n * usual way this API gets broken.\n */\nexport function styled(segments: Segment[]): [string, ...string[]] {\n if (!supportsStyling()) {\n return [segments.map((s) => (typeof s === \"string\" ? s : s[0])).join(\"\")];\n }\n\n let format = \"\";\n const styles: string[] = [];\n for (const segment of segments) {\n if (typeof segment === \"string\") {\n // Escape any literal % so it cannot be read as a directive.\n format += segment.replace(/%/g, \"%%\");\n continue;\n }\n const [text, tone] = segment;\n format += `%c${text.replace(/%/g, \"%%\")}%c`;\n styles.push(PALETTE[tone], \"\");\n }\n return [format, ...styles];\n}\n\n/** Tone for a render's severity, following the configured thresholds. */\nexport function toneForSeverity(severity: string): Tone {\n switch (severity) {\n case \"critical\":\n case \"very-slow\":\n return \"bad\";\n case \"slow\":\n return \"warn\";\n case \"monitor\":\n return \"dim\";\n default:\n return \"plain\";\n }\n}\n","import { formatInspected } from \"../core/inspect.js\";\nimport { styled } from \"./style.js\";\nimport type { Segment, Tone } from \"./style.js\";\nimport type { Detective } from \"../core/store.js\";\nimport type { PropChange, RenderEvent } from \"../core/types.js\";\n\nconst ICON: Record<string, string> = {\n normal: \"·\",\n monitor: \"•\",\n slow: \"▲\",\n \"very-slow\": \"▲▲\",\n critical: \"■\",\n};\n\n/** Batches are coalesced over this window so a burst prints once. */\nconst BATCH_WINDOW_MS = 400;\n\n/**\n * Console output.\n *\n * `console` mode reports **commits, not renders**. One line per render is\n * unusable in a real application: a 20-row list mounting produced ~200 lines of\n * `FareTile #1 mount 0.1ms`, which Chrome then collapsed into `2×` markers —\n * pure noise that also slowed the app being measured. Worse, it buried the two\n * or three lines that actually mattered.\n *\n * So a batch is summarised, and a batch that contains nothing actionable is not\n * printed at all. `verbose` keeps the old per-render detail for when you have\n * narrowed to one component with `include`.\n */\nexport function attachConsoleReporter(detective: Detective): () => void {\n let pending: RenderEvent[] = [];\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const flush = (): void => {\n timer = undefined;\n const batch = pending;\n pending = [];\n if (batch.length === 0) return;\n try {\n printBatch(batch, detective.config.slowRenderThreshold);\n } catch {\n /* diagnostics must never break the app */\n }\n };\n\n const unsubscribe = detective.subscribe((event) => {\n const mode = detective.config.mode;\n if (mode === \"silent\") return;\n\n if (mode === \"verbose\") {\n try {\n printVerbose(event);\n } catch {\n /* ignore */\n }\n return;\n }\n\n pending.push(event);\n if (timer === undefined) {\n timer = setTimeout(flush, BATCH_WINDOW_MS);\n (timer as { unref?: () => void }).unref?.();\n }\n });\n\n return () => {\n unsubscribe();\n if (timer !== undefined) clearTimeout(timer);\n };\n}\n\ninterface Aggregate {\n name: string;\n source?: string;\n count: number;\n totalMs: number;\n reasons: Map<string, number>;\n /** Reasons of the renders that were actually actionable. */\n notableReasons: Map<string, number>;\n avoidable: number;\n remount: boolean;\n slow: boolean;\n worst?: RenderEvent;\n}\n\nfunction printBatch(batch: RenderEvent[], slowThreshold: number): void {\n const byComponent = new Map<string, Aggregate>();\n let totalMs = 0;\n let avoidable = 0;\n\n for (const event of batch) {\n const key = event.component.name;\n const entry = byComponent.get(key) ?? {\n name: key,\n source: event.component.source,\n count: 0,\n totalMs: 0,\n reasons: new Map<string, number>(),\n notableReasons: new Map<string, number>(),\n avoidable: 0,\n remount: false,\n slow: false,\n };\n entry.count++;\n entry.totalMs += event.timings.selfDuration;\n entry.reasons.set(event.diagnosis.reason, (entry.reasons.get(event.diagnosis.reason) ?? 0) + 1);\n if (event.diagnosis.potentiallyAvoidable || event.timings.selfDuration >= slowThreshold) {\n entry.notableReasons.set(event.diagnosis.reason, (entry.notableReasons.get(event.diagnosis.reason) ?? 0) + 1);\n }\n if (event.diagnosis.potentiallyAvoidable) entry.avoidable++;\n if (event.diagnosis.summary.includes(\"rebuilt\")) entry.remount = true;\n if (event.timings.selfDuration >= slowThreshold) entry.slow = true;\n if (!entry.worst || event.timings.selfDuration > entry.worst.timings.selfDuration) entry.worst = event;\n byComponent.set(key, entry);\n\n totalMs += event.timings.selfDuration;\n if (event.diagnosis.potentiallyAvoidable) avoidable++;\n }\n\n /*\n * Silence is the default. Renders that are cheap and fully explained are\n * normal behaviour, and reporting them trains people to ignore the console.\n */\n const notable = [...byComponent.values()].filter((a) => a.avoidable > 0 || a.slow || a.remount);\n if (notable.length === 0) return;\n\n const ranked = [...notable].sort((a, b) => b.totalMs - a.totalMs);\n const anySlow = ranked.some((a) => a.slow);\n\n const segments: Segment[] = [\n [\"[RRD] \", \"dim\"],\n [`${batch.length} render${batch.length === 1 ? \"\" : \"s\"}`, \"strong\"],\n [` · ${totalMs.toFixed(1)}ms`, \"dim\"],\n ];\n if (avoidable > 0) segments.push([` · ${avoidable} potentially avoidable`, \"warn\"]);\n\n for (const a of ranked.slice(0, 8)) {\n /*\n * Show why the *actionable* renders happened. A batch containing 12 mounts\n * and 12 avoidable updates would otherwise be labelled \"mount\", which is\n * the half nobody can do anything about.\n */\n const reasonSource = a.notableReasons.size > 0 ? a.notableReasons : a.reasons;\n const reason = [...reasonSource.entries()].sort((x, y) => y[1] - x[1])[0]?.[0] ?? \"unknown\";\n\n // Worst-first: a rebuild costs more than a slow render, which costs more\n // than an avoidable one.\n const tone: Tone = a.remount ? \"bad\" : a.slow ? \"warn\" : a.avoidable > 0 ? \"warn\" : \"good\";\n const label = ` ${ICON[a.slow ? \"slow\" : \"normal\"]} ${a.name}${a.count > 1 ? ` ×${a.count}` : \"\"}`;\n\n segments.push(\"\\n\", [label.padEnd(30), tone], [`${a.totalMs.toFixed(1)}ms`, \"plain\"], [` ${reason}`, \"dim\"]);\n if (a.remount) segments.push([\" rebuilt\", \"bad\"]);\n if (a.avoidable > 0) segments.push([` ${a.avoidable} avoidable`, \"warn\"]);\n if (a.source) segments.push([\"\\n \" + a.source, \"dim\"]);\n }\n\n const worst = ranked[0]?.worst;\n segments.push(\n \"\\n\",\n [\n worst?.diagnosis.suggestion\n ? ` → ${worst.diagnosis.suggestion}`\n : \" → rrd.printOpportunities() to rank everything by recoverable time\",\n \"dim\",\n ],\n );\n\n const log = anySlow ? console.warn : console.log;\n log(...styled(segments));\n}\n\nfunction printVerbose(event: RenderEvent): void {\n const { diagnosis, timings } = event;\n const header = `[RRD] ${event.component.name} #${event.renderNumber} — ${diagnosis.summary}`;\n\n const group = diagnosis.severity === \"normal\" ? console.groupCollapsed : console.group;\n group.call(console, header);\n try {\n console.log(`Cause: ${label(event)} (confidence: ${diagnosis.confidence})`);\n if (event.component.source) console.log(`Source: ${event.component.source}`);\n if (event.parent) {\n console.log(\n `Parent: ${event.parent.name}${event.parent.source ? ` (${event.parent.source})` : \"\"}` +\n `${event.parentRendered ? \" — re-rendered in this commit\" : \" — did not re-render\"}`,\n );\n }\n console.log(\n `Cost: self ${timings.selfDuration.toFixed(1)}ms · subtree ${timings.subtreeDuration.toFixed(1)}ms` +\n (timings.accountedDescendantDuration > 0\n ? ` (${timings.accountedDescendantDuration.toFixed(1)}ms in instrumented children)`\n : \"\"),\n );\n\n if (event.changedProps.length > 0) {\n console.groupCollapsed(`Props changed (${event.changedProps.length})`);\n for (const c of event.changedProps) console.log(propLine(c));\n console.groupEnd();\n }\n if (event.unchangedProps.length > 0) console.log(`Props same: ${event.unchangedProps.join(\", \")}`);\n if (event.trackedState.length > 0) {\n console.log(\n `State: ${event.trackedState\n .map((s) => `${s.name}: ${formatInspected(s.previous)} → ${formatInspected(s.current)}`)\n .join(\", \")}`,\n );\n }\n if (event.contextChanges.length > 0) {\n console.log(`Context: ${event.contextChanges.map((c) => c.contextName).join(\", \")} changed in this commit`);\n }\n\n console.groupCollapsed(\"Evidence\");\n for (const line of diagnosis.evidence) console.log(`• ${line}`);\n console.groupEnd();\n\n if (diagnosis.suggestion) console.log(`Next step: ${diagnosis.suggestion}`);\n if (diagnosis.potentiallyAvoidable) console.log(\"Flag: potentially avoidable render\");\n } finally {\n console.groupEnd();\n }\n}\n\nfunction propLine(c: PropChange): string {\n const head = `${c.key} (${c.valueType}) — ${describeKind(c)}`;\n if (c.kind === \"added\") return `${head}: ${formatInspected(c.current)}`;\n if (c.kind === \"removed\") return `${head}: was ${formatInspected(c.previous)}`;\n return `${head}\\n previous: ${formatInspected(c.previous)}\\n current: ${formatInspected(c.current)}`;\n}\n\nfunction describeKind(c: PropChange): string {\n switch (c.kind) {\n case \"added\":\n return \"added\";\n case \"removed\":\n return \"removed\";\n case \"value\":\n return \"value changed\";\n case \"reference\":\n if (c.valueType === \"function\") return c.sourceEqual ? \"new function, identical source\" : \"new function reference\";\n return c.shallowEqual === true ? \"reference changed, contents identical\" : \"reference changed\";\n }\n}\n\nfunction label(event: RenderEvent): string {\n switch (event.diagnosis.reason) {\n case \"mount\":\n return \"mount\";\n case \"props\":\n return event.changedProps.every((c) => c.kind === \"reference\") ? \"prop changed (reference only)\" : \"prop changed\";\n case \"parent\":\n return \"parent rendered\";\n case \"context\":\n return \"context update\";\n case \"state\":\n return \"state changed\";\n case \"store\":\n return \"store update\";\n case \"state-or-external\":\n return \"state or external store\";\n case \"unknown\":\n return \"undetermined\";\n }\n}\n","import { explainEvents } from \"./explain.js\";\nimport type { Confidence, RenderEvent } from \"./types.js\";\n\n/**\n * \"Where should I spend my next hour?\"\n *\n * Render counts answer the wrong question — a component rendering 2 000 times\n * for 0.01ms is not the problem, and one rendering 40 times for 12ms might be.\n * This ranks by **estimated recoverable time**, so the top of the list is the\n * biggest win rather than the noisiest component.\n */\nexport interface Opportunity {\n component: string;\n source?: string;\n /** Milliseconds plausibly recovered by fixing this. The ranking key. */\n estimatedSavingMs: number;\n /** Renders where no observable input changed. */\n avoidableRenders: number;\n /** Times the component was rebuilt rather than re-rendered. */\n remounts: number;\n averageSelfDuration: number;\n /** One line: what to look at. Comes from the diagnostic engine, not from here. */\n summary: string;\n nextStep: string;\n confidence: Confidence;\n}\n\nexport interface OpportunityInput {\n events: RenderEvent[];\n lifecycles: Map<string, { remounts: number }>;\n /** Ignore anything below this. Noise is worse than silence in a ranked list. */\n minSavingMs?: number;\n}\n\nconst DEFAULT_MIN_SAVING_MS = 1;\n\nexport function rankOpportunities({ events, lifecycles, minSavingMs = DEFAULT_MIN_SAVING_MS }: OpportunityInput): Opportunity[] {\n const names = new Set(events.map((e) => e.component.name));\n const out: Opportunity[] = [];\n\n for (const name of names) {\n const lifecycle = lifecycles.get(name);\n const explanation = explainEvents(name, events, lifecycle);\n if (!explanation) continue;\n\n /*\n * A remount is charged at the cost of a mount, because that is what it is:\n * React rebuilds the subtree. Avoidable renders are charged at what they\n * actually cost. Both are estimates and are labelled as such — the point is\n * an ordering, not a promise.\n */\n const mounts = events.filter((e) => e.component.name === name && e.phase === \"mount\");\n const averageMountCost = mounts.length\n ? mounts.reduce((a, e) => a + e.timings.selfDuration, 0) / mounts.length\n : 0;\n const remountSaving = explanation.remounts * averageMountCost;\n const estimatedSavingMs = explanation.estimatedAvoidableTime + remountSaving;\n\n if (estimatedSavingMs < minSavingMs) continue;\n\n out.push({\n component: name,\n source: explanation.source,\n estimatedSavingMs,\n avoidableRenders: explanation.potentiallyAvoidableRenders,\n remounts: explanation.remounts,\n averageSelfDuration: explanation.averageSelfDuration,\n summary: explanation.headline,\n nextStep: explanation.nextStep,\n confidence: explanation.confidence,\n });\n }\n\n return out.sort((a, b) => b.estimatedSavingMs - a.estimatedSavingMs);\n}\n\nexport function formatOpportunities(opportunities: Opportunity[]): string {\n if (opportunities.length === 0) {\n return \"React Render Detective\\n\\nNo measurable render waste found yet. Interact with the app and try again.\";\n }\n\n const lines = [\n \"React Render Detective — where to spend your next hour\",\n \"\",\n \"Ranked by estimated recoverable time. These are estimates, not promises:\",\n \"measure each fix.\",\n \"\",\n ];\n\n for (const [index, o] of opportunities.entries()) {\n lines.push(\n `${String(index + 1).padStart(2)}. ${o.component}${o.source ? ` ${o.source}` : \"\"}`,\n ` ~${o.estimatedSavingMs.toFixed(0)}ms recoverable ` +\n `${o.avoidableRenders} avoidable render${o.avoidableRenders === 1 ? \"\" : \"s\"}` +\n `${o.remounts > 0 ? `, ${o.remounts}× rebuilt` : \"\"} (confidence: ${o.confidence})`,\n ` ${o.summary}`,\n ` → ${o.nextStep}`,\n \"\",\n );\n }\n\n return lines.join(\"\\n\");\n}\n","import { createContext } from \"react\";\nimport type { NodeRecord } from \"../core/store.js\";\n\n/**\n * Carries the nearest instrumented ancestor down the tree.\n *\n * The value is the node object, created once per mounted instance and **never\n * replaced**. That is deliberate: a context value that changed per render would\n * force every instrumented descendant to re-render, defeating `React.memo` and\n * changing the behaviour of the very app we are measuring.\n */\nexport const AncestryContext = createContext<NodeRecord | undefined>(undefined);\nAncestryContext.displayName = \"RenderDetectiveAncestry\";\n","import { Profiler, useCallback, useContext, useLayoutEffect, useState } from \"react\";\nimport type { ProfilerOnRenderCallback, ReactNode } from \"react\";\nimport { getDetective } from \"../core/store.js\";\nimport type { NodeRecord } from \"../core/store.js\";\nimport type { RenderPhase } from \"../core/types.js\";\nimport { AncestryContext } from \"./ancestry.js\";\n\nexport interface TrackOptions {\n /** Overrides the inferred component name. Required for anonymous components. */\n name?: string;\n /**\n * `path/to/File.tsx:12:2`. Supplied automatically by the build plugin; there\n * is no runtime way to obtain it.\n */\n source?: string;\n /**\n * Set by the build plugin when the component is declared inside another\n * function. React sees a new component type on every parent render and\n * rebuilds the whole subtree, so this turns a guess into a fact.\n */\n declaredInRender?: boolean;\n}\n\n/**\n * Registers the current component, records this render attempt, and returns the\n * node plus a Profiler callback. All of it is a no-op when disabled.\n */\nexport function useInstrumentedNode(\n name: string,\n props: Record<string, unknown>,\n source?: string,\n): { node: NodeRecord | undefined; onRender: ProfilerOnRenderCallback } {\n const detective = getDetective();\n const parent = useContext(AncestryContext);\n\n // The active/inactive decision is frozen per instance so the element tree\n // shape never changes underneath a mounted component.\n const [node] = useState<NodeRecord | undefined>(() =>\n detective.enabled ? detective.createNode(name, parent, source) : undefined,\n );\n\n useLayoutEffect(() => {\n if (!node) return;\n detective.attach(node);\n return () => detective.detach(node);\n }, [detective, node]);\n\n if (node) {\n try {\n detective.recordAttempt(node, props);\n } catch {\n /* never break the app being debugged (§46) */\n }\n }\n\n const onRender = useCallback<ProfilerOnRenderCallback>(\n (_id, phase, actualDuration, baseDuration, startTime, commitTime) => {\n if (!node) return;\n try {\n detective.recordCommit(node, {\n phase: phase as RenderPhase,\n subtreeDuration: actualDuration,\n baseDuration,\n startTime,\n commitTime,\n });\n } catch {\n /* ignore */\n }\n },\n [detective, node],\n );\n\n return { node, onRender };\n}\n\nexport function renderInstrumented(\n node: NodeRecord | undefined,\n onRender: ProfilerOnRenderCallback,\n children: ReactNode,\n): ReactNode {\n if (!node) return children;\n return (\n <Profiler id={node.id} onRender={onRender}>\n <AncestryContext.Provider value={node}>{children}</AncestryContext.Provider>\n </Profiler>\n );\n}\n\nexport function componentName(component: unknown, fallback = \"Anonymous\"): string {\n const c = component as { displayName?: string; name?: string; type?: unknown } | null;\n if (!c) return fallback;\n if (typeof c.displayName === \"string\" && c.displayName) return c.displayName;\n if (typeof c.name === \"string\" && c.name) return c.name;\n // React.memo / forwardRef wrappers keep the real component on `.type`.\n if (c.type) return componentName(c.type, fallback);\n return fallback;\n}\n","import type { ComponentType } from \"react\";\nimport { getDetective } from \"../core/store.js\";\n\n/** Marks a component as one of ours, so it is never wrapped twice. */\nconst IS_WRAPPER = Symbol.for(\"react-render-detective.wrapper\");\nimport { componentName, renderInstrumented, useInstrumentedNode } from \"./instrument.js\";\nimport type { TrackOptions } from \"./instrument.js\";\n\n/**\n * Wraps a component with full instrumentation: render counting, prop diffing,\n * parent attribution and Profiler timings.\n *\n * This is the most accurate integration mode — the wrapper's render function\n * runs exactly when the wrapped component re-renders, and it receives the same\n * props, so every diagnosis has first-hand evidence.\n *\n * Ref note: on React 19 `ref` is an ordinary prop and passes through the spread.\n * On React 18 and below, wrap with `forwardRef` yourself if the component needs\n * a ref.\n */\nexport function withRenderDetective<P extends object>(\n Component: ComponentType<P>,\n options: TrackOptions = {},\n): ComponentType<P> {\n /*\n * Wrapping a wrapper would make it render itself. That is unreachable through\n * careful hand-wrapping but trivially reachable once a build plugin is\n * wrapping everything, and the failure mode is a stack overflow before first\n * paint — so return the existing wrapper instead.\n */\n if ((Component as { [IS_WRAPPER]?: boolean })[IS_WRAPPER]) return Component;\n\n const name = options.name ?? componentName(Component);\n\n /*\n * Counted at wrap time, not render time. A component declared at module scope\n * is wrapped once; one declared inside a render body is wrapped again on every\n * parent render, which is the tell for the most expensive mistake in this\n * list — React rebuilds the whole subtree each time.\n */\n getDetective().noteDefinition(name, options.source, options.declaredInRender === true);\n\n function RenderDetected(props: P) {\n const { node, onRender } = useInstrumentedNode(name, props as Record<string, unknown>, options.source);\n return renderInstrumented(node, onRender, <Component {...props} />);\n }\n\n RenderDetected.displayName = `RenderDetective(${name})`;\n (RenderDetected as { [IS_WRAPPER]?: boolean })[IS_WRAPPER] = true;\n return RenderDetected;\n}\n","import type { ReactNode } from \"react\";\nimport { renderInstrumented, useInstrumentedNode } from \"./instrument.js\";\n\nexport interface RenderDetectiveProps {\n name: string;\n children: ReactNode;\n}\n\n/**\n * Zero-refactor integration: drop it around a subtree.\n *\n * <RenderDetective name=\"UserProfile\"><UserProfile /></RenderDetective>\n *\n * Accuracy note: this boundary only sees the `children` **element**, not the\n * wrapped component's props. It therefore reports timings, parent propagation\n * and children-element churn accurately, but it cannot attribute a render to an\n * individual prop. Use `withRenderDetective` when you want per-prop diagnosis.\n */\nexport function RenderDetective({ name, children }: RenderDetectiveProps): ReactNode {\n const { node, onRender } = useInstrumentedNode(name, { children });\n return renderInstrumented(node, onRender, children);\n}\n","/**\n * External-store attribution.\n *\n * Without this, a Redux or Zustand render can only ever be reported as\n * \"state or an external store\" — the tool proves the render started inside the\n * component but cannot say which value caused it. On a real application that\n * covered 84% of one component's renders, which is where the whole product\n * stopped being useful.\n *\n * `useSelector` is a public hook from a public package, so wrapping it needs no\n * internals: every value it returns is observable, including the one that\n * matters most — a selector that builds a new object on every call, which makes\n * the component re-render on *every* store update.\n */\nimport * as React from \"react\";\nimport { useContext, useRef } from \"react\";\nimport { shallowEqual } from \"../core/compare.js\";\nimport { inspect } from \"../core/inspect.js\";\nimport { getDetective } from \"../core/store.js\";\nimport { AncestryContext } from \"./ancestry.js\";\n\n/** React 18+. Identifies the calling component so a descendant cannot steal attribution. */\nconst useOwnerId: () => string =\n typeof (React as { useId?: () => string }).useId === \"function\"\n ? (React as unknown as { useId: () => string }).useId\n : () => \"\";\n\nexport interface TrackSelectorOptions {\n /** Readable label — a property path where one could be derived, else the call site. */\n name?: string;\n /** `File.tsx:12:3` of the call, supplied by the build plugin. */\n source?: string;\n}\n\n/**\n * Records a store value and returns it untouched.\n *\n * Pass-through by construction: the value is returned as given, and nothing\n * here can change what the component receives.\n */\nexport function trackSelector<T>(value: T, options: TrackSelectorOptions = {}): T {\n const detective = getDetective();\n const node = useContext(AncestryContext);\n const ownerId = useOwnerId();\n const previous = useRef<{ value: T } | undefined>(undefined);\n\n if (!detective.enabled) return value;\n\n // Same ownership rule as useTrackedState: the first caller under a node claims\n // it, so a selector in an uninstrumented descendant cannot be reported as the\n // ancestor's. Several selectors in one component share its id, so they all pass.\n if (node && node.stateOwner === undefined) node.stateOwner = ownerId;\n const owns = !node || node.stateOwner === ownerId;\n\n const prior = previous.current;\n previous.current = { value };\n\n if (!prior || !node || !owns) return value;\n if (Object.is(prior.value, value)) return value;\n\n try {\n const equal = shallowEqual(prior.value, value, detective.config);\n detective.recordSelectorChange(node, {\n name: options.name ?? options.source ?? \"selector\",\n source: options.source,\n referenceOnly: equal === true,\n previous: inspect(prior.value, detective.config.inspection),\n current: inspect(value, detective.config.inspection),\n });\n } catch {\n /* diagnostics must never break the app */\n }\n\n return value;\n}\n\n/**\n * Wraps a store hook so its results are attributed. Signature-preserving: extra\n * arguments (react-redux's equality function, for instance) pass straight\n * through, because changing them would change the app's behaviour.\n *\n * const useSelector = createTrackedSelectorHook(useReduxSelector);\n *\n * The build plugin rewrites `useSelector` imports for you; use this directly for\n * a custom store hook, or where the plugin cannot run.\n */\nexport function createTrackedSelectorHook<A extends unknown[], R>(\n hook: (...args: A) => R,\n options: TrackSelectorOptions = {},\n): (...args: A) => R {\n return function useTrackedSelector(...args: A): R {\n // Hook order is fixed: the wrapped hook, then the recorder. Both always run.\n const value = hook(...args);\n return trackSelector(value, options);\n };\n}\n","import * as React from \"react\";\nimport { useContext, useEffect, useRef, useState } from \"react\";\nimport type { Dispatch, SetStateAction } from \"react\";\nimport { getDetective } from \"../core/store.js\";\nimport { inspect } from \"../core/inspect.js\";\nimport { diffProps, shallowEqual } from \"../core/compare.js\";\nimport type { RenderEvent } from \"../core/types.js\";\nimport { AncestryContext } from \"./ancestry.js\";\n\n/**\n * In-component diagnostics without wrapping.\n *\n * Limitation, by design: a hook cannot install a `<Profiler>` around its own\n * component, so **no duration is available in this mode** — timings are\n * reported as 0. Everything else (render count, prop diffing, parent\n * attribution) is as accurate as the HOC.\n */\nexport function useRenderDiagnostics(name: string, props?: Record<string, unknown>): RenderEvent | undefined {\n const detective = getDetective();\n const parent = useContext(AncestryContext);\n const [node] = useState(() => {\n if (!detective.enabled) return undefined;\n const created = detective.createNode(name, parent);\n if (created) detective.hookModeNodes.add(created);\n return created;\n });\n const last = useRef<RenderEvent | undefined>(undefined);\n\n useEffect(() => {\n if (!node) return;\n detective.attach(node);\n const unsubscribe = detective.subscribe((event) => {\n if (event.component.id === node.id) last.current = event;\n });\n return () => {\n unsubscribe();\n detective.detach(node);\n };\n }, [detective, node]);\n\n if (node) {\n const isMount = !node.seenCommit;\n detective.recordAttempt(node, props ?? {});\n // No Profiler in hook mode: enqueue with a sentinel commit time, which the\n // flush pass resolves to the next real commit that follows this render.\n detective.recordCommit(node, {\n phase: isMount ? \"mount\" : \"update\",\n subtreeDuration: 0,\n baseDuration: 0,\n startTime: 0,\n commitTime: -1,\n });\n }\n\n return last.current;\n}\n\n/**\n * React 18+. Used only to identify *which* component under an instrumented node\n * owns the tracked state; `useId` is stable across StrictMode's double render,\n * which a `useRef` token would not be. Older React simply loses the guard.\n */\nconst useOwnerId: () => string =\n typeof (React as { useId?: () => string }).useId === \"function\"\n ? (React as unknown as { useId: () => string }).useId\n : () => \"\";\n\n/**\n * `useState` with a label. The only reliable way to attribute a render to a\n * specific piece of local state without React internals.\n *\n * **Call this inside a component that is itself instrumented** (wrapped with\n * `withRenderDetective`, or using `useRenderDiagnostics`). A hook cannot see\n * which component called it, only the nearest instrumented ancestor — so state\n * named in an uninstrumented descendant would be reported as the ancestor's.\n * The first caller under a given node claims it and later callers are ignored,\n * which stops a descendant from stealing the attribution, but it cannot rescue\n * the case where the ancestor never tracks state of its own.\n */\nexport function useTrackedState<S>(name: string, initial: S | (() => S)): [S, Dispatch<SetStateAction<S>>] {\n const detective = getDetective();\n const node = useContext(AncestryContext);\n const ownerId = useOwnerId();\n const [state, setState] = useState<S>(initial);\n const previous = useRef<S>(state);\n\n if (node && node.stateOwner === undefined) node.stateOwner = ownerId;\n const owns = !node || node.stateOwner === ownerId;\n\n if (node && owns && !Object.is(previous.current, state)) {\n detective.recordStateChange(node, {\n name,\n previous: inspect(previous.current, detective.config.inspection),\n current: inspect(state, detective.config.inspection),\n });\n previous.current = state;\n } else if (!owns) {\n previous.current = state;\n }\n\n return [state, setState];\n}\n\n/**\n * `useEffect` that reports which of **its own declared** dependencies changed.\n *\n * This does not analyse whether the dependency list is correct — that needs\n * static analysis, not runtime observation (see docs/FEASIBILITY.md §9).\n */\nexport function useTrackedEffect(\n name: string,\n effect: () => void | (() => void),\n deps: unknown[],\n): void {\n const detective = getDetective();\n const previous = useRef<unknown[] | undefined>(undefined);\n const changed = useRef<number[]>([]);\n\n if (detective.enabled) {\n const prev = previous.current;\n changed.current = prev\n ? deps.map((d, i) => (Object.is(d, prev[i]) ? -1 : i)).filter((i) => i >= 0)\n : [];\n previous.current = deps;\n }\n\n useEffect(() => {\n if (detective.enabled && detective.config.mode !== \"silent\" && changed.current.length > 0) {\n // eslint-disable-next-line no-console\n console.debug(`[RRD] effect ${name} ran — deps changed at index ${changed.current.join(\", \")}`);\n }\n return effect();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n}\n\n/**\n * Reports when a context value changes, from inside the provider.\n * Returns the value untouched.\n */\nexport function useTrackedContextValue<T>(contextName: string, value: T): T {\n const detective = getDetective();\n const previous = useRef<T | undefined>(undefined);\n const first = useRef(true);\n\n if (detective.enabled) {\n if (first.current) {\n first.current = false;\n } else if (!Object.is(previous.current, value)) {\n const prev = previous.current;\n const equal = shallowEqual(prev, value, detective.config);\n const changedKeys =\n isRecord(prev) && isRecord(value)\n ? diffProps(prev, value, detective.config).changed.map((c) => c.key)\n : [];\n detective.recordContextChange({\n contextName,\n changedKeys,\n referenceOnly: equal === true,\n commitTime: -1,\n });\n }\n previous.current = value;\n }\n\n return value;\n}\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n","import { attachConsoleReporter } from \"./console/reporter.js\";\nimport { explainEvents, formatExplanation } from \"./core/explain.js\";\nimport { formatOpportunities, rankOpportunities } from \"./core/opportunities.js\";\nimport type { Opportunity } from \"./core/opportunities.js\";\nimport { getDetective } from \"./core/store.js\";\nimport { profileFromEvents } from \"./testing/index.js\";\nimport type { RenderProfile } from \"./testing/index.js\";\nimport type {\n AppStats,\n ComponentStats,\n DetectiveConfig,\n DetectiveOptions,\n RenderEvent,\n} from \"./core/types.js\";\n\nconst REPORTER = Symbol.for(\"react-render-detective.reporter\");\ntype Global = typeof globalThis & { [REPORTER]?: () => void };\n\n/**\n * Enable diagnostics. Safe to call repeatedly — Fast Refresh, duplicate module\n * copies and re-entrant setup all reconfigure the single instance rather than\n * stacking listeners (§47).\n */\nexport function init(options: DetectiveOptions = {}): void {\n const detective = getDetective();\n detective.init(options);\n\n const g = globalThis as Global;\n g[REPORTER]?.();\n g[REPORTER] = undefined;\n\n if (detective.enabled && detective.config.mode !== \"silent\") {\n g[REPORTER] = attachConsoleReporter(detective);\n } else if (!detective.enabled) {\n // Never fail silently: a disabled detective looks identical to a broken one.\n console.info(\n \"[RRD] Diagnostics are disabled\" +\n (detective.config.enabled === false ? \" (enabled: false, or a production build was detected).\" : \".\"),\n );\n }\n}\n\n/** Update configuration without re-initialising. */\nexport function configure(options: DetectiveOptions): void {\n getDetective().configure(options);\n}\n\nexport function getConfig(): Readonly<DetectiveConfig> {\n return getDetective().config;\n}\n\nexport function isEnabled(): boolean {\n return getDetective().enabled;\n}\n\n/** Oldest → newest, bounded by `maxEvents`. */\nexport function getEvents(): RenderEvent[] {\n return getDetective().getEvents();\n}\n\nexport function getStats(): AppStats {\n return getDetective().getStats();\n}\n\nexport function getComponentStats(name?: string): ComponentStats[] {\n return getDetective().getComponentStats(name);\n}\n\n/** Live event stream. Returns an unsubscribe function. */\nexport function subscribe(listener: (event: RenderEvent) => void): () => void {\n return getDetective().subscribe(listener);\n}\n\n/** Clears recorded events and statistics; instrumentation stays attached. */\nexport function clear(): void {\n getDetective().clear();\n}\n\n/** Full teardown, including configuration. Mainly for tests and HMR disposal. */\nexport function reset(): void {\n const g = globalThis as Global;\n g[REPORTER]?.();\n g[REPORTER] = undefined;\n getDetective().reset();\n}\n\n/**\n * The flagship answer: aggregate every recorded render of one component into a\n * single, human explanation. Returns `undefined` if nothing was recorded.\n */\nexport function explain(componentName: string): string | undefined {\n const explanation = explainStructured(componentName);\n return explanation ? formatExplanation(explanation) : undefined;\n}\n\n/** Structured form of `explain`, for building UIs on top. */\nexport function explainStructured(componentName: string) {\n return explainEvents(componentName, getEvents(), getDetective().lifecycleOf(componentName));\n}\n\n/** Snapshot render behaviour for regression testing. See `react-render-detective/testing`. */\nexport function getRenderProfile(scenario: string): RenderProfile {\n const remounts: Record<string, number> = {};\n for (const stats of getDetective().getComponentStats()) remounts[stats.name] = stats.remountCount;\n return profileFromEvents(scenario, getEvents(), remounts);\n}\n\n/**\n * Components ranked by estimated recoverable time — the triage view. Render\n * counts answer the wrong question; this answers \"what should I fix first?\".\n */\nexport function getOpportunities(limit = 10): Opportunity[] {\n const detective = getDetective();\n const lifecycles = new Map<string, { remounts: number }>();\n for (const stats of detective.getComponentStats()) {\n lifecycles.set(stats.name, { remounts: stats.remountCount });\n }\n return rankOpportunities({ events: detective.getEvents(), lifecycles }).slice(0, limit);\n}\n\nexport function printOpportunities(limit = 10): void {\n console.log(formatOpportunities(getOpportunities(limit)));\n}\n\n/** Prints the application-level dashboard (§53). */\nexport function printStats(): void {\n const s = getStats();\n const lines = [\n \"React Render Detective\",\n \"\",\n `Components ${s.components}`,\n `Total renders ${s.totalRenders}`,\n `Total render time ${s.totalRenderTime.toFixed(1)}ms`,\n `Slow renders ${s.slowRenders}`,\n `Potentially avoidable ${s.potentiallyAvoidableRenders}`,\n ];\n const rebuilt = s.mostRendered.filter((c) => c.remountCount >= 2);\n if (rebuilt.length > 0) {\n lines.push(\n \"\",\n \"Rebuilt rather than re-rendered (state and DOM discarded each time)\",\n ...rebuilt.slice(0, 5).map((c) => ` ${c.name.padEnd(22)} ${String(c.remountCount).padStart(5)}× remounted`),\n );\n }\n if (s.devReplays > 0) {\n lines.push(`Development replays ${s.devReplays} (StrictMode / discarded — not counted above)`);\n }\n if (s.mostExpensive.length > 0) {\n lines.push(\"\", \"Top by cumulative render time\");\n for (const [i, c] of s.mostExpensive.slice(0, 5).entries()) {\n lines.push(\n `${String(i + 1).padStart(2)}. ${c.name.padEnd(22)} ${String(c.renderCount).padStart(6)} renders ${c.totalSelfDuration\n .toFixed(1)\n .padStart(8)}ms (avg ${c.averageSelfDuration.toFixed(1)}ms, p95 ${c.p95SelfDuration.toFixed(1)}ms)`,\n );\n }\n }\n console.log(lines.join(\"\\n\"));\n}\n\n/** Namespaced form, matching the documented `ReactRenderDetective.init()` usage. */\nexport const ReactRenderDetective = {\n init,\n configure,\n getConfig,\n isEnabled,\n getEvents,\n getStats,\n getComponentStats,\n subscribe,\n clear,\n reset,\n explain,\n explainStructured,\n getOpportunities,\n printOpportunities,\n getRenderProfile,\n printStats,\n};\n\nexport { withRenderDetective } from \"./react/withRenderDetective.js\";\nexport { RenderDetective } from \"./react/RenderDetective.js\";\nexport type { RenderDetectiveProps } from \"./react/RenderDetective.js\";\nexport { trackSelector, createTrackedSelectorHook } from \"./react/selector.js\";\nexport type { TrackSelectorOptions } from \"./react/selector.js\";\nexport {\n useRenderDiagnostics,\n useTrackedState,\n useTrackedEffect,\n useTrackedContextValue,\n} from \"./react/hooks.js\";\nexport type { TrackOptions } from \"./react/instrument.js\";\nexport { explainEvents, formatExplanation } from \"./core/explain.js\";\nexport { rankOpportunities, formatOpportunities } from \"./core/opportunities.js\";\nexport type { Opportunity } from \"./core/opportunities.js\";\nexport type { Explanation } from \"./core/explain.js\";\nexport type * from \"./core/types.js\";\n"]}
@@ -0,0 +1,252 @@
1
+ 'use strict';
2
+
3
+ var chunkLCGXVRJR_cjs = require('./chunk-LCGXVRJR.cjs');
4
+
5
+ // src/core/interactions.ts
6
+ var COMMIT_SLACK_MS = 100;
7
+ var FALLBACK_CLOSE_MS = 50;
8
+ var InteractionTracker = class {
9
+ constructor(capacity = 50) {
10
+ this.capacity = capacity;
11
+ this.records = [];
12
+ this.nextId = 0;
13
+ }
14
+ /** Returns false when the browser cannot report event timing. */
15
+ start() {
16
+ if (this.observer) return true;
17
+ const PO = globalThis.PerformanceObserver;
18
+ const supported = PO?.supportedEntryTypes?.includes("event");
19
+ if (!PO || !supported) return false;
20
+ try {
21
+ const observer = new PO((list) => {
22
+ for (const entry of list.getEntries()) {
23
+ const timing = entry;
24
+ this.record({
25
+ name: timing.name,
26
+ startTime: timing.startTime,
27
+ duration: timing.duration,
28
+ target: describeTarget(timing.target)
29
+ });
30
+ }
31
+ });
32
+ observer.observe({ type: "event", buffered: true, durationThreshold: 16 });
33
+ this.observer = observer;
34
+ return true;
35
+ } catch {
36
+ return false;
37
+ }
38
+ }
39
+ stop() {
40
+ this.observer?.disconnect();
41
+ this.observer = void 0;
42
+ }
43
+ /** Is the automatic path available in this browser? */
44
+ get automatic() {
45
+ return this.observer !== void 0;
46
+ }
47
+ /**
48
+ * Time an interaction by hand.
49
+ *
50
+ * The automatic path depends on the Event Timing API, which Safari only
51
+ * gained in 16.4 and which does not fire for synthetic input at all — so
52
+ * anything driven by a test harness records nothing. This measures a specific
53
+ * action instead, up to the paint that follows it, and needs no browser
54
+ * support beyond `performance.now`.
55
+ */
56
+ measure(label, action) {
57
+ const startTime = now();
58
+ let handlerMs = 0;
59
+ let finished = false;
60
+ const finish = () => {
61
+ if (finished) return;
62
+ finished = true;
63
+ this.record({ name: label, startTime, duration: now() - startTime, handlerMs });
64
+ };
65
+ let result;
66
+ try {
67
+ result = action();
68
+ handlerMs = now() - startTime;
69
+ } catch (error) {
70
+ handlerMs = now() - startTime;
71
+ finish();
72
+ throw error;
73
+ }
74
+ const raf = globalThis.requestAnimationFrame;
75
+ if (raf) raf(() => raf(finish));
76
+ setTimeout(finish, FALLBACK_CLOSE_MS);
77
+ return result;
78
+ }
79
+ /** Exposed for tests and for `measure`. */
80
+ record(timing) {
81
+ const record = {
82
+ id: `interaction_${++this.nextId}`,
83
+ type: timing.name,
84
+ target: timing.target,
85
+ startTime: timing.startTime,
86
+ durationMs: timing.duration,
87
+ handlerMs: timing.handlerMs,
88
+ renders: [],
89
+ renderTimeMs: 0,
90
+ avoidableRenderTimeMs: 0
91
+ };
92
+ this.records.push(record);
93
+ if (this.records.length > this.capacity) this.records.shift();
94
+ return record;
95
+ }
96
+ clear() {
97
+ this.records.length = 0;
98
+ }
99
+ /**
100
+ * Joins render events to interactions by commit time. A render belongs to an
101
+ * interaction when it committed between the event starting and shortly after
102
+ * it finished — React commits just after the event handler returns.
103
+ */
104
+ attribute(events) {
105
+ for (const record of this.records) {
106
+ const from = record.startTime;
107
+ const to = record.startTime + record.durationMs + COMMIT_SLACK_MS;
108
+ record.renders = events.filter((e) => e.timings.commitTime >= from && e.timings.commitTime <= to);
109
+ record.renderTimeMs = record.renders.reduce((a, e) => a + e.timings.selfDuration, 0);
110
+ record.avoidableRenderTimeMs = record.renders.filter((e) => e.diagnosis.potentiallyAvoidable).reduce((a, e) => a + e.timings.selfDuration, 0);
111
+ }
112
+ return [...this.records].sort((a, b) => b.durationMs - a.durationMs);
113
+ }
114
+ };
115
+ function summarise(record) {
116
+ const byComponent = /* @__PURE__ */ new Map();
117
+ for (const event of record.renders) {
118
+ const entry = byComponent.get(event.component.name) ?? {
119
+ renders: 0,
120
+ totalMs: 0,
121
+ source: event.component.source,
122
+ cause: event.diagnosis.reason
123
+ };
124
+ entry.renders++;
125
+ entry.totalMs += event.timings.selfDuration;
126
+ byComponent.set(event.component.name, entry);
127
+ }
128
+ const contributors = [...byComponent.entries()].map(([component, v]) => ({ component, source: v.source, renders: v.renders, totalMs: v.totalMs, cause: v.cause })).sort((a, b) => b.totalMs - a.totalMs);
129
+ const top = contributors[0];
130
+ const accounted = (record.handlerMs ?? record.durationMs) + record.renderTimeMs;
131
+ const idleWindow = record.handlerMs !== void 0 && record.durationMs > accounted * 3 && record.durationMs - accounted > 100;
132
+ const effectiveMs = idleWindow ? accounted : record.durationMs;
133
+ const share = effectiveMs > 0 ? record.renderTimeMs / effectiveMs : 0;
134
+ let headline;
135
+ let nextStep;
136
+ let confidence = "medium";
137
+ if (idleWindow) {
138
+ headline = `${record.type}: ${fmt(record.handlerMs ?? 0)} in the handler and ${fmt(record.renderTimeMs)} rendering. The measured window was ${fmt(record.durationMs)}, but most of that was the page waiting for a frame \u2014 ignore it.`;
139
+ nextStep = record.renderTimeMs > (record.handlerMs ?? 0) ? `Rendering dominates the real work${top ? `; start with ${top.component}` : ""}.` : "The handler itself costs more than rendering. Profile the handler, not React.";
140
+ return { interaction: record, contributors, headline, nextStep, confidence: "medium" };
141
+ }
142
+ if (record.renders.length === 0) {
143
+ headline = `${record.type} took ${fmt(record.durationMs)}, and no instrumented component rendered inside it.`;
144
+ nextStep = "The cost is somewhere other than React rendering \u2014 an event handler, a layout, or an uninstrumented component. Instrument more of the tree to narrow it down.";
145
+ confidence = "low";
146
+ } else if (share >= 0.4 && record.avoidableRenderTimeMs > 0) {
147
+ headline = `${record.type} took ${fmt(record.durationMs)}; ${fmt(record.renderTimeMs)} of it was rendering, and ${fmt(record.avoidableRenderTimeMs)} of that had no input change to explain it.`;
148
+ nextStep = top ? `Start with ${top.component}${top.source ? ` (${top.source})` : ""} \u2014 ${fmt(top.totalMs)} across ${top.renders} render${top.renders === 1 ? "" : "s"}.` : "Look at the top contributor below.";
149
+ confidence = "high";
150
+ } else if (share >= 0.4) {
151
+ headline = `${record.type} took ${fmt(record.durationMs)}; ${fmt(record.renderTimeMs)} of it was rendering, all of it explained by real input changes.`;
152
+ nextStep = "This is genuine work. Make the renders cheaper rather than fewer \u2014 or do less of it per interaction.";
153
+ confidence = "high";
154
+ } else {
155
+ headline = `${record.type} took ${fmt(record.durationMs)}, but only ${fmt(record.renderTimeMs)} was React rendering.`;
156
+ nextStep = "Most of the cost is outside rendering \u2014 event handlers, layout or paint. A browser profile will show more than this tool can.";
157
+ confidence = "medium";
158
+ }
159
+ return { interaction: record, contributors, headline, nextStep, confidence };
160
+ }
161
+ function formatInteraction(summary) {
162
+ const { interaction: i } = summary;
163
+ const lines = [
164
+ `${i.type}${i.target ? ` on ${i.target}` : ""} ${fmt(i.durationMs)}`,
165
+ "",
166
+ summary.headline
167
+ ];
168
+ if (summary.contributors.length > 0) {
169
+ lines.push("", "Rendering inside this interaction");
170
+ for (const c of summary.contributors.slice(0, 8)) {
171
+ lines.push(
172
+ ` ${c.component.padEnd(22)} ${String(c.renders).padStart(4)} render(s) ${fmt(c.totalMs).padStart(8)} ${c.cause}`
173
+ );
174
+ }
175
+ }
176
+ lines.push("", `Next step`, ` ${summary.nextStep}`, "", `Confidence: ${summary.confidence}`);
177
+ return lines.join("\n");
178
+ }
179
+ function describeTarget(target) {
180
+ if (!target || typeof target !== "object") return void 0;
181
+ const el = target;
182
+ if (!el.tagName) return void 0;
183
+ const tag = el.tagName.toLowerCase();
184
+ if (el.id) return `${tag}#${el.id}`;
185
+ const className = typeof el.className === "string" ? el.className.trim().split(/\s+/)[0] : void 0;
186
+ if (className) return `${tag}.${className}`;
187
+ const text = el.textContent?.trim().slice(0, 20);
188
+ return text ? `${tag} "${text}"` : tag;
189
+ }
190
+ var fmt = (ms) => `${ms.toFixed(1)}ms`;
191
+ var now = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
192
+
193
+ // src/interactions/index.ts
194
+ var TRACKER = /* @__PURE__ */ Symbol.for("react-render-detective.interactions");
195
+ function tracker() {
196
+ const g = globalThis;
197
+ if (!g[TRACKER]) {
198
+ const created = new InteractionTracker();
199
+ g[TRACKER] = created;
200
+ const detective = chunkLCGXVRJR_cjs.getDetective();
201
+ detective.registerClearHook(() => created.clear());
202
+ detective.registerResetHook(() => {
203
+ created.stop();
204
+ globalThis[TRACKER] = void 0;
205
+ });
206
+ }
207
+ return g[TRACKER];
208
+ }
209
+ function startInteractionTracking() {
210
+ return tracker().start();
211
+ }
212
+ function stopInteractionTracking() {
213
+ tracker().stop();
214
+ }
215
+ function getInteractions() {
216
+ return tracker().attribute(chunkLCGXVRJR_cjs.getDetective().getEvents());
217
+ }
218
+ function explainInteractionStructured(id) {
219
+ const records = getInteractions();
220
+ const record = id ? records.find((r) => r.id === id) : records[0];
221
+ return record ? summarise(record) : void 0;
222
+ }
223
+ function explainInteraction(id) {
224
+ const summary = explainInteractionStructured(id);
225
+ return summary ? formatInteraction(summary) : void 0;
226
+ }
227
+ function printInteractions(limit = 5) {
228
+ const records = getInteractions().slice(0, limit);
229
+ if (records.length === 0) {
230
+ console.log(
231
+ tracker().automatic ? "No interactions recorded yet. Event timing is working \u2014 nothing has taken longer than 16ms.\nSynthetic clicks from a test harness never produce these entries; use measureInteraction() there." : "This browser does not report event timing (Safari before 16.4, jsdom), or tracking was never started.\nCall startInteractionTracking(), or use measureInteraction(label, fn) to time interactions by hand."
232
+ );
233
+ return;
234
+ }
235
+ console.log(records.map((r) => formatInteraction(summarise(r))).join("\n\n"));
236
+ }
237
+ function measureInteraction(label, action) {
238
+ return tracker().measure(label, action);
239
+ }
240
+
241
+ exports.InteractionTracker = InteractionTracker;
242
+ exports.explainInteraction = explainInteraction;
243
+ exports.explainInteractionStructured = explainInteractionStructured;
244
+ exports.formatInteraction = formatInteraction;
245
+ exports.getInteractions = getInteractions;
246
+ exports.measureInteraction = measureInteraction;
247
+ exports.printInteractions = printInteractions;
248
+ exports.startInteractionTracking = startInteractionTracking;
249
+ exports.stopInteractionTracking = stopInteractionTracking;
250
+ exports.summariseInteraction = summarise;
251
+ //# sourceMappingURL=interactions.cjs.map
252
+ //# sourceMappingURL=interactions.cjs.map