@oxog/react-check 1.3.0 → 1.3.2

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 (48) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +42 -19
  3. package/dist/browser-inject.global.js +5 -5
  4. package/dist/chain.d.cts +1 -1
  5. package/dist/chain.d.ts +1 -1
  6. package/dist/{chunk-7YYMP3PP.js → chunk-35I3PLS3.js} +33 -5
  7. package/dist/chunk-35I3PLS3.js.map +1 -0
  8. package/dist/{chunk-GE2ZX7I7.cjs → chunk-DSXOHC6R.cjs} +34 -6
  9. package/dist/chunk-DSXOHC6R.cjs.map +1 -0
  10. package/dist/{chunk-G7YVIPS7.cjs → chunk-LFY7MUHJ.cjs} +10 -2
  11. package/dist/chunk-LFY7MUHJ.cjs.map +1 -0
  12. package/dist/{chunk-3K2AER5M.cjs → chunk-NLWGB4IE.cjs} +27 -3
  13. package/dist/chunk-NLWGB4IE.cjs.map +1 -0
  14. package/dist/{chunk-27R56V2S.js → chunk-PIXJPQO7.js} +10 -2
  15. package/dist/chunk-PIXJPQO7.js.map +1 -0
  16. package/dist/{chunk-IM6OG2IC.js → chunk-REEPUD73.js} +27 -3
  17. package/dist/chunk-REEPUD73.js.map +1 -0
  18. package/dist/cli.js +236 -109
  19. package/dist/cli.js.map +1 -1
  20. package/dist/detect.cjs +6 -6
  21. package/dist/detect.d.cts +1 -1
  22. package/dist/detect.d.ts +1 -1
  23. package/dist/detect.js +1 -1
  24. package/dist/fix.cjs +2 -2
  25. package/dist/fix.d.cts +7 -1
  26. package/dist/fix.d.ts +7 -1
  27. package/dist/fix.js +1 -1
  28. package/dist/index.cjs +135 -61
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +77 -13
  31. package/dist/index.d.ts +77 -13
  32. package/dist/index.js +111 -37
  33. package/dist/index.js.map +1 -1
  34. package/dist/{scanner-D0mBQGTx.d.ts → scanner-DKxW6s8c.d.ts} +12 -3
  35. package/dist/{scanner-DUBgwztZ.d.cts → scanner-DdlnBlE-.d.cts} +12 -3
  36. package/dist/scanner.cjs +3 -3
  37. package/dist/scanner.d.cts +2 -2
  38. package/dist/scanner.d.ts +2 -2
  39. package/dist/scanner.js +2 -2
  40. package/dist/{types-BZ3OeZ-5.d.ts → types-BhoB9oSH.d.cts} +8 -1
  41. package/dist/{types-BZ3OeZ-5.d.cts → types-BhoB9oSH.d.ts} +8 -1
  42. package/package.json +7 -7
  43. package/dist/chunk-27R56V2S.js.map +0 -1
  44. package/dist/chunk-3K2AER5M.cjs.map +0 -1
  45. package/dist/chunk-7YYMP3PP.js.map +0 -1
  46. package/dist/chunk-G7YVIPS7.cjs.map +0 -1
  47. package/dist/chunk-GE2ZX7I7.cjs.map +0 -1
  48. package/dist/chunk-IM6OG2IC.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,62 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.2] - 2026-12-01
9
+
10
+ ### Fixed
11
+
12
+ - `BrowserLauncher` re-emitted whatever a page threw (`throw 'boom'`) as its `error`
13
+ event, although that event is typed as `Error`. Values that are not `Error`s are now
14
+ wrapped in one (`new Error(String(value))`).
15
+
16
+ ### Changed
17
+
18
+ - Development dependency: puppeteer 23 → 25 (types and the package smoke test). The
19
+ optional peer dependency range (`puppeteer >=21`) is unchanged.
20
+
21
+ ## [1.3.1] - 2026-12-01
22
+
23
+ ### Fixed
24
+
25
+ - **Render chains were never detected in real scans.** The browser script did not send each
26
+ component's parent, so `report.chains` was always empty, the TUI chain view (`c`) and the
27
+ WebUI chains panel stayed blank and the `state-too-high` rule never fired. Renders now carry
28
+ `parent` (new optional `RenderInfo.parent`), which `Scanner.addRender()` uses when no parent
29
+ argument is given; reports also list each component's parent. Mount renders are no longer
30
+ counted as state changes, so `state-too-high` only fires for components whose state changed.
31
+ - **Automatic Puppeteer install looped forever under `npx`.** The CLI installed Puppeteer into
32
+ the current directory, where an `npx`-run ReactCheck cannot resolve it, and restarted itself
33
+ again and again. Puppeteer is now installed once into ReactCheck's own directory
34
+ (`~/.cache/react-check/puppeteer`, `%LOCALAPPDATA%\react-check\puppeteer` on Windows, or
35
+ `$REACTCHECK_PUPPETEER_DIR`) and loaded from there in the same process. The CLI never
36
+ restarts; if Puppeteer still cannot be loaded it exits with code 2 and explains how to install
37
+ it. The check now runs before the TUI starts, so the messages stay visible, and scan errors
38
+ are no longer hidden after the TUI closes.
39
+ - **TypeScript users without Puppeteer got TS2307.** `dist/index.d.ts` imported `puppeteer`
40
+ types although Puppeteer is an optional peer. `BrowserLauncher.getPage()` / `getBrowser()` now
41
+ return the structural `PuppeteerPageLike` / `PuppeteerBrowserLike` types (both exported); pass
42
+ Puppeteer's type for the full API: `getPage<import('puppeteer').Page>()`.
43
+ - **Fix suggestions went stale.** A suggestion kept the numbers and severity from the moment it
44
+ was created (e.g. "9 unnecessary renders out of 10, warning" for a component that ended at
45
+ 100 renders, critical). `getSuggestions()`, `getComponentSuggestions()`, `export()`, CLI
46
+ reports, `--fix` output and `quickScan()` reports now regenerate them from the current stats.
47
+ - `--tui` / `-t` and `--watch` / `-w` were accepted and silently ignored. They are removed from
48
+ the help and rejected with an explanation (the TUI starts automatically in an interactive
49
+ terminal; without `--duration` a scan already runs until you quit).
50
+ - An unknown command word was scanned as a host name (`react-check watch http://x` scanned
51
+ `http://watch`). Unknown commands and extra arguments are rejected with exit code 2.
52
+ - The CLI always logged `React detected: unknown` because the script is injected before React
53
+ loads. The version is detected once React registers with the DevTools hook.
54
+ - The in-page overlay coloured renders with fixed 20/50 thresholds. It now uses the scan's
55
+ `--threshold-warning` / `--threshold-critical` (or `quickScan` thresholds), with the same
56
+ "at or above" meaning as the reports.
57
+ - `react-check detect` reported the Vite `ssr` feature for every project with a
58
+ `vite.config.*`. It now needs real evidence: `vite build --ssr`, an `ssr` option in the Vite
59
+ config, an `entry-server` module, or `vike` / `vite-plugin-ssr`.
60
+ - The CLI banner box was misaligned.
61
+ - README: removed `scanner.getReport()` and `ChainAnalyzer.getChains()` (they never existed),
62
+ the WebUI overlay toggle button, "WebUI alongside TUI" and the `--tui` / `--watch` flags.
63
+
8
64
  ## [1.3.0] - 2026-11-30
9
65
 
10
66
  ### Fixed
package/README.md CHANGED
@@ -36,9 +36,15 @@ npm install --save-dev @oxog/react-check puppeteer
36
36
  - React is **not** a dependency: ReactCheck observes the page through the React DevTools
37
37
  global hook, so it works with React 16.8+ development and production builds (verified with
38
38
  React 18). There is no static source analysis; nothing in your project is parsed.
39
- - When Puppeteer is missing, the CLI offers to install it only in an interactive terminal.
40
- In CI (`CI` set), without a TTY, or with `REACTCHECK_NO_INSTALL=1` it exits with code 2
41
- and tells you what to install instead.
39
+ - When Puppeteer is missing, the CLI installs it once, only in an interactive terminal, into
40
+ its own directory (`~/.cache/react-check/puppeteer`, `%LOCALAPPDATA%\react-check\puppeteer`
41
+ on Windows, or `$REACTCHECK_PUPPETEER_DIR`) and loads it from there, so it also works with
42
+ `npx`. If Puppeteer still cannot be loaded it exits with code 2 and explains what to install.
43
+ In CI (`CI` set), without a TTY, or with `REACTCHECK_NO_INSTALL=1` it does not install
44
+ anything and exits with code 2.
45
+ - The TypeScript declarations do not depend on Puppeteer: `BrowserLauncher.getPage()` returns a
46
+ structural `PuppeteerPageLike`; pass Puppeteer's type for its full API:
47
+ `getPage<import('puppeteer').Page>()`.
42
48
  - Importing `@oxog/react-check` has no side effects and does not touch `window`, so it is safe
43
49
  in Node.js scripts, SSR bundles and test runners. The browser part ships separately as
44
50
  `dist/browser-inject.global.js` and is injected by the CLI.
@@ -154,10 +160,8 @@ General:
154
160
 
155
161
  Mode:
156
162
  -P, --proxy Start a proxy on <port + 1> that injects ReactCheck into any browser
157
- -t, --tui Terminal UI only (no browser)
158
163
  -s, --silent No TUI (for CI/CD)
159
164
  --headless Run browser in headless mode
160
- -w, --watch Keep scanning until quit
161
165
  -W, --webui Enable WebUI dashboard
162
166
  --webui-port <port> WebUI dashboard port (default: 3199)
163
167
 
@@ -177,8 +181,14 @@ Network:
177
181
  -d, --duration <seconds> Stop after this many seconds (otherwise Ctrl+C / q)
178
182
  ```
179
183
 
180
- Unknown options are rejected. Options given on the command line override the config file,
181
- which overrides the defaults.
184
+ Unknown options and unknown commands are rejected (`react-check watch <url>` is an error, not a
185
+ scan of `http://watch`; write `http://<name>` to scan a single-word host name). Options given on
186
+ the command line override the config file, which overrides the defaults.
187
+
188
+ The terminal UI starts automatically in an interactive terminal (not with `--silent`,
189
+ `--proxy` or `--webui`). There is no separate TUI-only or watch flag: without `--duration` a
190
+ scan keeps running until you press `q` or Ctrl+C, and it always needs a browser (Puppeteer, or
191
+ your own browser through `--proxy`).
182
192
 
183
193
  #### Exit codes
184
194
 
@@ -251,15 +261,17 @@ ReactCheck injects a visual overlay into the target page that highlights compone
251
261
  - **Flash Effect**: Components flash with a colored background on each render
252
262
  - **Border Highlight**: Pulsing border shows render boundaries
253
263
  - **Render Badges**: Small badges show component name and render count
254
- - **Severity Colors**: Critical (red), Warning (yellow), Healthy (green)
264
+ - **Severity Colors**: Critical (red), Warning (orange), Healthy (green), using the scan's
265
+ `--threshold-warning` / `--threshold-critical` values
255
266
 
256
267
  ### Toggle Overlay
257
268
 
258
- You can toggle the overlay on/off in several ways:
269
+ You can toggle the overlay on/off:
259
270
 
260
271
  1. **TUI**: Press `o` to toggle overlay visibility
261
272
  2. **Browser Console**: Run `__REACTCHECK__.toggleOverlay()`
262
- 3. **WebUI Dashboard**: Click the overlay toggle button
273
+
274
+ The WebUI dashboard has no overlay toggle.
263
275
 
264
276
  When overlay is disabled, render tracking continues but visual effects are hidden.
265
277
 
@@ -273,15 +285,15 @@ The WebUI dashboard provides a real-time web interface for monitoring React perf
273
285
  - **Render Chains**: Visualization of cascade render chains
274
286
  - **Auto-open**: Dashboard opens automatically in your default browser
275
287
 
288
+ `--webui` replaces the terminal UI (the TUI does not run together with the dashboard); Chrome
289
+ still opens the target page through Puppeteer.
290
+
276
291
  ```bash
277
- # Enable WebUI alongside TUI
292
+ # Scan with the WebUI dashboard instead of the TUI
278
293
  react-check scan http://localhost:3000 --webui
279
294
 
280
295
  # Custom WebUI port
281
296
  react-check scan http://localhost:3000 --webui --webui-port 8080
282
-
283
- # WebUI only (no TUI)
284
- react-check scan http://localhost:3000 --webui --silent
285
297
  ```
286
298
 
287
299
  ## Report Formats
@@ -375,20 +387,31 @@ scanner.on('render', handler);
375
387
  scanner.on('chain', handler);
376
388
  scanner.on('fps-drop', handler);
377
389
  scanner.start();
390
+ scanner.addRender(renderInfo, parentName); // the CLI forwards browser renders here
378
391
  scanner.stop();
379
- const report = scanner.getReport();
392
+ const components = scanner.getSnapshot();
393
+ const summary = scanner.getSummary();
394
+ const suggestions = scanner.getSuggestions(); // regenerated from the current stats
395
+ const data = scanner.export(); // { stats, suggestions, config }
380
396
  ```
381
397
 
398
+ There is no `getReport()`: `quickScan()` returns a full `SessionReport`, or build one from
399
+ `export()` for the report generators.
400
+
382
401
  #### `ChainAnalyzer`
383
402
 
384
403
  Analyzes render chains and cascade effects.
385
404
 
386
405
  ```typescript
387
- const analyzer = new ChainAnalyzer({ windowSize: 100 });
406
+ const analyzer = new ChainAnalyzer({ windowSize: 16 });
407
+ analyzer.on('chain', (chain) => console.log(chain.trigger, chain.chain.join(' -> ')));
388
408
  analyzer.addRender(renderInfo, parentName);
389
- const chains = analyzer.getChains();
409
+ const path = analyzer.getComponentChain('Leaf'); // e.g. ['App', 'Ticker', 'Leaf']
390
410
  ```
391
411
 
412
+ Chains need parent relationships. Renders recorded by the injected browser script carry
413
+ `render.parent`, which `Scanner.addRender()` uses when no parent argument is given.
414
+
392
415
  #### `FixSuggester`
393
416
 
394
417
  Generates fix suggestions based on component statistics.
@@ -408,8 +431,8 @@ generateMarkdownReport(report);
408
431
 
409
432
  // Framework detection
410
433
  detectFramework(packageJsonPath?);
411
- detectFrameworkFromWindow(window);
412
- getFrameworkTips(framework);
434
+ detectFrameworkFromWindow(); // browser only
435
+ getFrameworkTips(framework, issues);
413
436
 
414
437
  // Formatting utilities
415
438
  formatDuration(ms);
@@ -1,4 +1,4 @@
1
- (function(){'use strict';var M=Object.defineProperty;var z=(r,e,t)=>e in r?M(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t;var l=(r,e,t)=>z(r,typeof e!="symbol"?e+"":e,t);var v=class{constructor(){l(this,"_listeners",new Map);l(this,"_onceListeners",new Map);l(this,"maxListeners",0);}on(e,t){let n=this._listeners.get(e);return n||(n=new Set,this._listeners.set(e,n)),this.maxListeners>0&&n.size>=this.maxListeners&&console.warn(`Warning: Possible EventEmitter memory leak detected. ${n.size+1} listeners added for event "${String(e)}". Use setMaxListeners() to increase limit.`),n.add(t),this}addListener(e,t){return this.on(e,t)}once(e,t){let n=this._onceListeners.get(e);return n||(n=new Set,this._onceListeners.set(e,n)),n.add(t),this}off(e,t){let n=this._listeners.get(e);n&&(n.delete(t),n.size===0&&this._listeners.delete(e));let i=this._onceListeners.get(e);return i&&(i.delete(t),i.size===0&&this._onceListeners.delete(e)),this}removeListener(e,t){return this.off(e,t)}removeAllListeners(e){return e!==void 0?(this._listeners.delete(e),this._onceListeners.delete(e)):(this._listeners.clear(),this._onceListeners.clear()),this}emit(e,t){let n=false,i=this._listeners.get(e);if(i)for(let s of i)try{s(t),n=!0;}catch(a){if(e!=="error")this.emit("error",a);else throw a}let o=this._onceListeners.get(e);if(o){let s=Array.from(o);this._onceListeners.delete(e);for(let a of s)try{a(t),n=!0;}catch(c){if(e!=="error")this.emit("error",c);else throw c}}return n}getListeners(e){let t=this._listeners.get(e),n=this._onceListeners.get(e),i=[];return t&&i.push(...Array.from(t)),n&&i.push(...Array.from(n)),i}listenerCount(e){let t=this._listeners.get(e)?.size??0,n=this._onceListeners.get(e)?.size??0;return t+n}eventNames(){let e=new Set;for(let t of this._listeners.keys())e.add(t);for(let t of this._onceListeners.keys())e.add(t);return Array.from(e)}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}prependListener(e,t){let n=this._listeners.get(e);if(!n)return this.on(e,t);let i=Array.from(n);return i.unshift(t),this._listeners.set(e,new Set(i)),this}prependOnceListener(e,t){let n=this._onceListeners.get(e);if(!n)return this.once(e,t);let i=Array.from(n);return i.unshift(t),this._onceListeners.set(e,new Set(i)),this}waitFor(e,t){return new Promise((n,i)=>{let o,s=a=>{o&&clearTimeout(o),n(a);};this.once(e,s),t!==void 0&&t>0&&(o=setTimeout(()=>{this.off(e,s),i(new Error(`Timeout waiting for event "${String(e)}"`));},t));})}};var d={FunctionComponent:0,ClassComponent:1,HostRoot:3,HostComponent:5,HostText:6,Fragment:7,ContextConsumer:9,ContextProvider:10,ForwardRef:11,Profiler:12,SuspenseComponent:13,MemoComponent:14,SimpleMemoComponent:15,LazyComponent:16,IncompleteClassComponent:17};function b(r){if(!r)return "Unknown";let{type:e,tag:t}=r;switch(t){case d.FunctionComponent:case d.ClassComponent:case d.SimpleMemoComponent:case d.IncompleteClassComponent:return f(e)||"Anonymous";case d.ForwardRef:if(e&&typeof e=="object"){let n=e;if(n.displayName)return n.displayName;if("render"in n&&n.render){let i=f(n.render);if(i&&i!=="Anonymous")return i}}return "ForwardRef";case d.MemoComponent:if(e&&typeof e=="object"&&"type"in e){let n=e.type;return `Memo(${f(n)||"Anonymous"})`}return "Memo";case d.LazyComponent:return "Lazy";case d.ContextConsumer:return "Context.Consumer";case d.ContextProvider:return "Context.Provider";case d.SuspenseComponent:return "Suspense";case d.Fragment:return "Fragment";case d.Profiler:return "Profiler";case d.HostRoot:return "Root";case d.HostComponent:return typeof e=="string"?e:"HostComponent";case d.HostText:return "#text";default:return f(e)||"Unknown"}}function f(r){if(r!=null){if(typeof r=="string")return r;if(typeof r=="function")return r.displayName??r.name??void 0;if(typeof r=="object"){let e=r;return e.displayName??e.name??void 0}}}function k(r){let{tag:e}=r;return e===d.FunctionComponent||e===d.ClassComponent||e===d.MemoComponent||e===d.SimpleMemoComponent||e===d.ForwardRef||e===d.LazyComponent}var C=1;function T(r){let e=r.alternate;if(!e)return true;switch(r.tag){case d.FunctionComponent:case d.ClassComponent:case d.ContextConsumer:case d.ForwardRef:case d.MemoComponent:case d.SimpleMemoComponent:return ((r.flags??r.effectTag??0)&C)===C;default:return e.memoizedProps!==r.memoizedProps||e.memoizedState!==r.memoizedState}}function _(r,e){if(r===e)return [];if(!r||!e)return Object.keys(e??r??{});let t=[],n=new Set([...Object.keys(r),...Object.keys(e)]);for(let i of n)i!=="children"&&r[i]!==e[i]&&t.push(i);return t}function R(r,e,t,n){let i=b(r),o=r.actualDuration??0,s=t?_(t,r.memoizedProps):void 0,a=s&&s.length>0,c=n!==r.memoizedState,p={componentName:i,renderCount:1,renderTime:o,phase:e,necessary:e==="mount"||a||c,timestamp:Date.now()};return s!==void 0&&(p.changedProps=s),c&&(p.changedState=["state"]),p}function x(r){return String(r).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var O={enabled:true,highlightRenders:true,showToolbar:true,highlightDuration:2e3},E={critical:"#ef4444",warning:"#f97316",info:"#3b82f6",healthy:"#22c55e",unnecessary:"#6b7280"},g=class g{constructor(e={}){l(this,"shadowRoot",null);l(this,"host",null);l(this,"config");l(this,"trackedComponents",new Map);l(this,"renderChains",[]);l(this,"toolbar",null);l(this,"visible",true);l(this,"collapsed",false);l(this,"totalRenders",0);l(this,"fps",60);l(this,"startTime",Date.now());l(this,"fadeTimeouts",new Map);l(this,"scrollHandler",null);l(this,"scrollUpdatePending",false);l(this,"statsInterval",null);l(this,"initRetryCount",0);l(this,"initRetryTimer",null);l(this,"documentListeners",null);this.config={...O,...e};}init(){if(!this.host){if(!document.body){this.initRetryCount<10&&this.initRetryTimer===null&&(this.initRetryCount++,this.initRetryTimer=setTimeout(()=>{this.initRetryTimer=null,this.init();},100));return}this.host=document.createElement("div"),this.host.id="reactcheck-overlay-host",this.host.style.cssText=`
1
+ (function(){'use strict';var _=Object.defineProperty;var M=(r,e,t)=>e in r?_(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t;var l=(r,e,t)=>M(r,typeof e!="symbol"?e+"":e,t);var f=class{constructor(){l(this,"_listeners",new Map);l(this,"_onceListeners",new Map);l(this,"maxListeners",0);}on(e,t){let n=this._listeners.get(e);return n||(n=new Set,this._listeners.set(e,n)),this.maxListeners>0&&n.size>=this.maxListeners&&console.warn(`Warning: Possible EventEmitter memory leak detected. ${n.size+1} listeners added for event "${String(e)}". Use setMaxListeners() to increase limit.`),n.add(t),this}addListener(e,t){return this.on(e,t)}once(e,t){let n=this._onceListeners.get(e);return n||(n=new Set,this._onceListeners.set(e,n)),n.add(t),this}off(e,t){let n=this._listeners.get(e);n&&(n.delete(t),n.size===0&&this._listeners.delete(e));let i=this._onceListeners.get(e);return i&&(i.delete(t),i.size===0&&this._onceListeners.delete(e)),this}removeListener(e,t){return this.off(e,t)}removeAllListeners(e){return e!==void 0?(this._listeners.delete(e),this._onceListeners.delete(e)):(this._listeners.clear(),this._onceListeners.clear()),this}emit(e,t){let n=false,i=this._listeners.get(e);if(i)for(let s of i)try{s(t),n=!0;}catch(a){if(e!=="error")this.emit("error",a);else throw a}let o=this._onceListeners.get(e);if(o){let s=Array.from(o);this._onceListeners.delete(e);for(let a of s)try{a(t),n=!0;}catch(c){if(e!=="error")this.emit("error",c);else throw c}}return n}getListeners(e){let t=this._listeners.get(e),n=this._onceListeners.get(e),i=[];return t&&i.push(...Array.from(t)),n&&i.push(...Array.from(n)),i}listenerCount(e){let t=this._listeners.get(e)?.size??0,n=this._onceListeners.get(e)?.size??0;return t+n}eventNames(){let e=new Set;for(let t of this._listeners.keys())e.add(t);for(let t of this._onceListeners.keys())e.add(t);return Array.from(e)}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}prependListener(e,t){let n=this._listeners.get(e);if(!n)return this.on(e,t);let i=Array.from(n);return i.unshift(t),this._listeners.set(e,new Set(i)),this}prependOnceListener(e,t){let n=this._onceListeners.get(e);if(!n)return this.once(e,t);let i=Array.from(n);return i.unshift(t),this._onceListeners.set(e,new Set(i)),this}waitFor(e,t){return new Promise((n,i)=>{let o,s=a=>{o&&clearTimeout(o),n(a);};this.once(e,s),t!==void 0&&t>0&&(o=setTimeout(()=>{this.off(e,s),i(new Error(`Timeout waiting for event "${String(e)}"`));},t));})}};var d={FunctionComponent:0,ClassComponent:1,HostRoot:3,HostComponent:5,HostText:6,Fragment:7,ContextConsumer:9,ContextProvider:10,ForwardRef:11,Profiler:12,SuspenseComponent:13,MemoComponent:14,SimpleMemoComponent:15,LazyComponent:16,IncompleteClassComponent:17};function y(r){if(!r)return "Unknown";let{type:e,tag:t}=r;switch(t){case d.FunctionComponent:case d.ClassComponent:case d.SimpleMemoComponent:case d.IncompleteClassComponent:return b(e)||"Anonymous";case d.ForwardRef:if(e&&typeof e=="object"){let n=e;if(n.displayName)return n.displayName;if("render"in n&&n.render){let i=b(n.render);if(i&&i!=="Anonymous")return i}}return "ForwardRef";case d.MemoComponent:if(e&&typeof e=="object"&&"type"in e){let n=e.type;return `Memo(${b(n)||"Anonymous"})`}return "Memo";case d.LazyComponent:return "Lazy";case d.ContextConsumer:return "Context.Consumer";case d.ContextProvider:return "Context.Provider";case d.SuspenseComponent:return "Suspense";case d.Fragment:return "Fragment";case d.Profiler:return "Profiler";case d.HostRoot:return "Root";case d.HostComponent:return typeof e=="string"?e:"HostComponent";case d.HostText:return "#text";default:return b(e)||"Unknown"}}function b(r){if(r!=null){if(typeof r=="string")return r;if(typeof r=="function")return r.displayName??r.name??void 0;if(typeof r=="object"){let e=r;return e.displayName??e.name??void 0}}}function R(r){let{tag:e}=r;return e===d.FunctionComponent||e===d.ClassComponent||e===d.MemoComponent||e===d.SimpleMemoComponent||e===d.ForwardRef||e===d.LazyComponent}var k=1;function T(r){let e=r.alternate;if(!e)return true;switch(r.tag){case d.FunctionComponent:case d.ClassComponent:case d.ContextConsumer:case d.ForwardRef:case d.MemoComponent:case d.SimpleMemoComponent:return ((r.flags??r.effectTag??0)&k)===k;default:return e.memoizedProps!==r.memoizedProps||e.memoizedState!==r.memoizedState}}function z(r,e){if(r===e)return [];if(!r||!e)return Object.keys(e??r??{});let t=[],n=new Set([...Object.keys(r),...Object.keys(e)]);for(let i of n)i!=="children"&&r[i]!==e[i]&&t.push(i);return t}function E(r,e,t,n){let i=y(r),o=r.actualDuration??0,s=t?z(t,r.memoizedProps):void 0,a=s&&s.length>0,c=e==="update"&&n!==r.memoizedState,p={componentName:i,renderCount:1,renderTime:o,phase:e,necessary:e==="mount"||a||c,timestamp:Date.now()};return s!==void 0&&(p.changedProps=s),c&&(p.changedState=["state"]),p}function x(r){return String(r).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var O={warning:20,critical:50},N={enabled:true,highlightRenders:true,showToolbar:true,highlightDuration:2e3},L={critical:"#ef4444",warning:"#f97316",info:"#3b82f6",healthy:"#22c55e",unnecessary:"#6b7280"},g=class g{constructor(e={}){l(this,"shadowRoot",null);l(this,"host",null);l(this,"config");l(this,"trackedComponents",new Map);l(this,"renderChains",[]);l(this,"toolbar",null);l(this,"visible",true);l(this,"collapsed",false);l(this,"totalRenders",0);l(this,"fps",60);l(this,"startTime",Date.now());l(this,"fadeTimeouts",new Map);l(this,"scrollHandler",null);l(this,"scrollUpdatePending",false);l(this,"statsInterval",null);l(this,"initRetryCount",0);l(this,"initRetryTimer",null);l(this,"documentListeners",null);this.config={...N,...e};}init(){if(!this.host){if(!document.body){this.initRetryCount<10&&this.initRetryTimer===null&&(this.initRetryCount++,this.initRetryTimer=setTimeout(()=>{this.initRetryTimer=null,this.init();},100));return}this.host=document.createElement("div"),this.host.id="reactcheck-overlay-host",this.host.style.cssText=`
2
2
  position: fixed;
3
3
  top: 0;
4
4
  left: 0;
@@ -753,19 +753,19 @@
753
753
  </div>
754
754
  </div>
755
755
  </div>
756
- `,this.shadowRoot.appendChild(this.toolbar),this.setupToolbarEvents(),this.makeDraggable(this.toolbar));}setupToolbarEvents(){if(!this.toolbar||!this.shadowRoot)return;let e=this.shadowRoot.getElementById("rc-collapse");e&&e.addEventListener("click",c=>{c.stopPropagation(),this.toggleCollapse();}),this.toolbar.addEventListener("click",c=>{let h=c.target;this.collapsed&&(h===this.toolbar||h.closest(".panel-icon"))&&this.toggleCollapse();}),this.toolbar.querySelectorAll(".tab").forEach(c=>{c.addEventListener("click",()=>{let h=c.getAttribute("data-tab");this.switchTab(h);});});let n=this.shadowRoot.getElementById("rc-toggle-highlights");n&&n.addEventListener("click",()=>{this.config.highlightRenders=!this.config.highlightRenders,n.classList.toggle("active",this.config.highlightRenders),this.updateHighlightsVisibility();});let i=this.shadowRoot.getElementById("rc-clear");i&&i.addEventListener("click",()=>{this.clear();});let o=this.shadowRoot.getElementById("rc-setting-highlights");o&&o.addEventListener("click",()=>{this.config.highlightRenders=!this.config.highlightRenders,o.classList.toggle("active",this.config.highlightRenders),n?.classList.toggle("active",this.config.highlightRenders),this.updateHighlightsVisibility();});let s=this.shadowRoot.getElementById("rc-setting-duration"),a=this.shadowRoot.getElementById("rc-duration-value");s&&a&&s.addEventListener("input",()=>{let c=parseInt(s.value,10);this.config.highlightDuration=c,a.textContent=c>=1e3?`${c/1e3}s`:`${c}ms`;});}toggleCollapse(){this.collapsed=!this.collapsed,this.toolbar&&this.toolbar.classList.toggle("collapsed",this.collapsed);}switchTab(e){if(!this.toolbar)return;this.toolbar.querySelectorAll(".tab").forEach(i=>{let o=i.getAttribute("data-tab")===e;i.classList.toggle("active",o);}),this.toolbar.querySelectorAll(".tab-content").forEach(i=>{let o=i.getAttribute("data-content")===e;i.classList.toggle("active",o);}),e==="components"?this.updateComponentList():e==="chains"&&this.updateChainList();}updateHighlightsVisibility(){for(let e of this.trackedComponents.values())e.highlightEl.style.display=this.config.highlightRenders?"block":"none";}makeDraggable(e){let t=false,n=0,i=0,o=0,s=0,a=e.querySelector(".panel-header");if(!a)return;a.addEventListener("mousedown",h=>{let p=h;p.target.closest(".panel-btn")||(t=true,n=p.clientX,i=p.clientY,o=e.offsetLeft,s=e.offsetTop);}),this.documentListeners??(this.documentListeners=new AbortController);let{signal:c}=this.documentListeners;document.addEventListener("mousemove",h=>{if(!t)return;let p=h.clientX-n,u=h.clientY-i;e.style.left=`${o+p}px`,e.style.top=`${s+u}px`,e.style.right="auto";},{signal:c}),document.addEventListener("mouseup",()=>{t=false;},{signal:c});}highlight(e,t){if(!this.shadowRoot||!this.visible||g.SKIP_COMPONENTS.has(e.componentName))return;let n=t.getBoundingClientRect();if(n.width===0||n.height===0)return;if(this.trackedComponents.size>=g.MAX_HIGHLIGHTS&&!this.trackedComponents.has(e.componentName)){let c=this.getOldestTrackedComponent();c&&this.removeHighlight(c);}this.totalRenders++;let i=this.getSeverity(e),o=E[i],s=this.trackedComponents.get(e.componentName);if(s){s.count++,s.element=t,s.lastRender=Date.now(),s.severity=i,s.renderTimes.push(e.renderTime),s.renderTimes.length>100&&s.renderTimes.shift(),this.updateHighlightPosition(s,n,o);let c=s.highlightEl.querySelector(".label-count");c&&(c.classList.remove("bump"),c.offsetWidth,c.classList.add("bump"));}else {let c=this.createHighlightElement(e.componentName,n,o);s={element:t,highlightEl:c,lastRender:Date.now(),count:1,severity:i,renderTimes:[e.renderTime]},this.trackedComponents.set(e.componentName,s),this.shadowRoot.appendChild(c);}let a=s.highlightEl.querySelector(".label-count");a&&(a.textContent=`\xD7${s.count}`),this.updateHighlightColor(s.highlightEl,o),this.resetFadeTimeout(e.componentName,s);}addChain(e){this.renderChains.unshift(e),this.renderChains.length>50&&this.renderChains.pop();}updateFps(e){this.fps=e;}createHighlightElement(e,t,n){let i=document.createElement("div");i.className="highlight-container",i.style.cssText=`
756
+ `,this.shadowRoot.appendChild(this.toolbar),this.setupToolbarEvents(),this.makeDraggable(this.toolbar));}setupToolbarEvents(){if(!this.toolbar||!this.shadowRoot)return;let e=this.shadowRoot.getElementById("rc-collapse");e&&e.addEventListener("click",c=>{c.stopPropagation(),this.toggleCollapse();}),this.toolbar.addEventListener("click",c=>{let h=c.target;this.collapsed&&(h===this.toolbar||h.closest(".panel-icon"))&&this.toggleCollapse();}),this.toolbar.querySelectorAll(".tab").forEach(c=>{c.addEventListener("click",()=>{let h=c.getAttribute("data-tab");this.switchTab(h);});});let n=this.shadowRoot.getElementById("rc-toggle-highlights");n&&n.addEventListener("click",()=>{this.config.highlightRenders=!this.config.highlightRenders,n.classList.toggle("active",this.config.highlightRenders),this.updateHighlightsVisibility();});let i=this.shadowRoot.getElementById("rc-clear");i&&i.addEventListener("click",()=>{this.clear();});let o=this.shadowRoot.getElementById("rc-setting-highlights");o&&o.addEventListener("click",()=>{this.config.highlightRenders=!this.config.highlightRenders,o.classList.toggle("active",this.config.highlightRenders),n?.classList.toggle("active",this.config.highlightRenders),this.updateHighlightsVisibility();});let s=this.shadowRoot.getElementById("rc-setting-duration"),a=this.shadowRoot.getElementById("rc-duration-value");s&&a&&s.addEventListener("input",()=>{let c=parseInt(s.value,10);this.config.highlightDuration=c,a.textContent=c>=1e3?`${c/1e3}s`:`${c}ms`;});}toggleCollapse(){this.collapsed=!this.collapsed,this.toolbar&&this.toolbar.classList.toggle("collapsed",this.collapsed);}switchTab(e){if(!this.toolbar)return;this.toolbar.querySelectorAll(".tab").forEach(i=>{let o=i.getAttribute("data-tab")===e;i.classList.toggle("active",o);}),this.toolbar.querySelectorAll(".tab-content").forEach(i=>{let o=i.getAttribute("data-content")===e;i.classList.toggle("active",o);}),e==="components"?this.updateComponentList():e==="chains"&&this.updateChainList();}updateHighlightsVisibility(){for(let e of this.trackedComponents.values())e.highlightEl.style.display=this.config.highlightRenders?"block":"none";}makeDraggable(e){let t=false,n=0,i=0,o=0,s=0,a=e.querySelector(".panel-header");if(!a)return;a.addEventListener("mousedown",h=>{let p=h;p.target.closest(".panel-btn")||(t=true,n=p.clientX,i=p.clientY,o=e.offsetLeft,s=e.offsetTop);}),this.documentListeners??(this.documentListeners=new AbortController);let{signal:c}=this.documentListeners;document.addEventListener("mousemove",h=>{if(!t)return;let p=h.clientX-n,u=h.clientY-i;e.style.left=`${o+p}px`,e.style.top=`${s+u}px`,e.style.right="auto";},{signal:c}),document.addEventListener("mouseup",()=>{t=false;},{signal:c});}highlight(e,t){if(!this.shadowRoot||!this.visible||g.SKIP_COMPONENTS.has(e.componentName))return;let n=t.getBoundingClientRect();if(n.width===0||n.height===0)return;if(this.trackedComponents.size>=g.MAX_HIGHLIGHTS&&!this.trackedComponents.has(e.componentName)){let c=this.getOldestTrackedComponent();c&&this.removeHighlight(c);}this.totalRenders++;let i=this.getSeverity(e),o=L[i],s=this.trackedComponents.get(e.componentName);if(s){s.count++,s.element=t,s.lastRender=Date.now(),s.severity=i,s.renderTimes.push(e.renderTime),s.renderTimes.length>100&&s.renderTimes.shift(),this.updateHighlightPosition(s,n,o);let c=s.highlightEl.querySelector(".label-count");c&&(c.classList.remove("bump"),c.offsetWidth,c.classList.add("bump"));}else {let c=this.createHighlightElement(e.componentName,n,o);s={element:t,highlightEl:c,lastRender:Date.now(),count:1,severity:i,renderTimes:[e.renderTime]},this.trackedComponents.set(e.componentName,s),this.shadowRoot.appendChild(c);}let a=s.highlightEl.querySelector(".label-count");a&&(a.textContent=`\xD7${s.count}`),this.updateHighlightColor(s.highlightEl,o),this.resetFadeTimeout(e.componentName,s);}addChain(e){this.renderChains.unshift(e),this.renderChains.length>50&&this.renderChains.pop();}updateFps(e){this.fps=e;}createHighlightElement(e,t,n){let i=document.createElement("div");i.className="highlight-container",i.style.cssText=`
757
757
  left: ${t.left}px;
758
758
  top: ${t.top}px;
759
759
  width: ${t.width}px;
760
760
  height: ${t.height}px;
761
761
  color: ${n};
762
762
  display: ${this.config.highlightRenders?"block":"none"};
763
- `;let o=document.createElement("div");o.className="highlight-border",i.appendChild(o);let s=document.createElement("div");s.className="label label-name",s.style.background=n,s.textContent=e,i.appendChild(s);let a=document.createElement("div");return a.className="label label-count",a.style.background=n,a.textContent="\xD71",i.appendChild(a),i}updateHighlightPosition(e,t,n){e.highlightEl.style.left=`${t.left}px`,e.highlightEl.style.top=`${t.top}px`,e.highlightEl.style.width=`${t.width}px`,e.highlightEl.style.height=`${t.height}px`,e.highlightEl.style.color=n,e.highlightEl.classList.remove("fade");}updateHighlightColor(e,t){e.style.color=t,e.querySelectorAll(".label").forEach(i=>{i.style.background=t;});}resetFadeTimeout(e,t){let n=this.fadeTimeouts.get(e);if(n&&clearTimeout(n),this.config.highlightDuration>0){let i=setTimeout(()=>{t.highlightEl.classList.add("fade"),this.fadeTimeouts.delete(e);},this.config.highlightDuration);this.fadeTimeouts.set(e,i);}}getOldestTrackedComponent(){let e=null,t=1/0;for(let[n,i]of this.trackedComponents)i.lastRender<t&&(t=i.lastRender,e=n);return e}removeHighlight(e){let t=this.trackedComponents.get(e);if(t){t.highlightEl.remove(),this.trackedComponents.delete(e);let n=this.fadeTimeouts.get(e);n&&(clearTimeout(n),this.fadeTimeouts.delete(e));}}getSeverity(e){return e.necessary?e.renderCount>50?"critical":e.renderCount>20?"warning":"healthy":"unnecessary"}recordRender(e){let t=this.trackedComponents.get(e.componentName);if(t){t.count++,t.lastRender=Date.now(),t.severity=this.getSeverity(e);let n=t.highlightEl.querySelector(".label-count");n&&(n.textContent=`\xD7${t.count}`);}this.totalRenders++;}updateStats(){if(!this.shadowRoot)return;let e=0,t=0,n=0;for(let u of this.trackedComponents.values())u.count>50?e++:u.count>20?t++:n++;let i=this.shadowRoot.getElementById("rc-critical"),o=this.shadowRoot.getElementById("rc-warning"),s=this.shadowRoot.getElementById("rc-healthy"),a=this.shadowRoot.getElementById("rc-renders"),c=this.shadowRoot.getElementById("rc-fps"),h=this.shadowRoot.getElementById("rc-fps-bar"),p=this.shadowRoot.getElementById("rc-duration");if(i&&(i.textContent=String(e)),o&&(o.textContent=String(t)),s&&(s.textContent=String(n)),a&&(a.textContent=String(this.totalRenders)),c&&(c.textContent=String(Math.round(this.fps))),h){let u=Math.min(100,this.fps/60*100);h.style.width=`${u}%`,this.fps>=50?h.style.background="#22c55e":this.fps>=30?h.style.background="#f97316":h.style.background="#ef4444";}if(p){let u=Math.floor((Date.now()-this.startTime)/1e3),H=Math.floor(u/60),F=u%60;p.textContent=`${H}:${F.toString().padStart(2,"0")}`;}}updateComponentList(){if(!this.shadowRoot)return;let e=this.shadowRoot.getElementById("rc-component-list");if(!e)return;let t=Array.from(this.trackedComponents.entries()).sort((n,i)=>i[1].count-n[1].count);if(t.length===0){e.innerHTML=`
763
+ `;let o=document.createElement("div");o.className="highlight-border",i.appendChild(o);let s=document.createElement("div");s.className="label label-name",s.style.background=n,s.textContent=e,i.appendChild(s);let a=document.createElement("div");return a.className="label label-count",a.style.background=n,a.textContent="\xD71",i.appendChild(a),i}updateHighlightPosition(e,t,n){e.highlightEl.style.left=`${t.left}px`,e.highlightEl.style.top=`${t.top}px`,e.highlightEl.style.width=`${t.width}px`,e.highlightEl.style.height=`${t.height}px`,e.highlightEl.style.color=n,e.highlightEl.classList.remove("fade");}updateHighlightColor(e,t){e.style.color=t,e.querySelectorAll(".label").forEach(i=>{i.style.background=t;});}resetFadeTimeout(e,t){let n=this.fadeTimeouts.get(e);if(n&&clearTimeout(n),this.config.highlightDuration>0){let i=setTimeout(()=>{t.highlightEl.classList.add("fade"),this.fadeTimeouts.delete(e);},this.config.highlightDuration);this.fadeTimeouts.set(e,i);}}getOldestTrackedComponent(){let e=null,t=1/0;for(let[n,i]of this.trackedComponents)i.lastRender<t&&(t=i.lastRender,e=n);return e}removeHighlight(e){let t=this.trackedComponents.get(e);if(t){t.highlightEl.remove(),this.trackedComponents.delete(e);let n=this.fadeTimeouts.get(e);n&&(clearTimeout(n),this.fadeTimeouts.delete(e));}}getSeverity(e){return e.necessary?this.severityForCount(e.renderCount):"unnecessary"}severityForCount(e){let{warning:t,critical:n}=this.config.thresholds??O;return e>=n?"critical":e>=t?"warning":"healthy"}recordRender(e){let t=this.trackedComponents.get(e.componentName);if(t){t.count++,t.lastRender=Date.now(),t.severity=this.getSeverity(e);let n=t.highlightEl.querySelector(".label-count");n&&(n.textContent=`\xD7${t.count}`);}this.totalRenders++;}updateStats(){if(!this.shadowRoot)return;let e=0,t=0,n=0;for(let u of this.trackedComponents.values()){let v=this.severityForCount(u.count);v==="critical"?e++:v==="warning"?t++:n++;}let i=this.shadowRoot.getElementById("rc-critical"),o=this.shadowRoot.getElementById("rc-warning"),s=this.shadowRoot.getElementById("rc-healthy"),a=this.shadowRoot.getElementById("rc-renders"),c=this.shadowRoot.getElementById("rc-fps"),h=this.shadowRoot.getElementById("rc-fps-bar"),p=this.shadowRoot.getElementById("rc-duration");if(i&&(i.textContent=String(e)),o&&(o.textContent=String(t)),s&&(s.textContent=String(n)),a&&(a.textContent=String(this.totalRenders)),c&&(c.textContent=String(Math.round(this.fps))),h){let u=Math.min(100,this.fps/60*100);h.style.width=`${u}%`,this.fps>=50?h.style.background="#22c55e":this.fps>=30?h.style.background="#f97316":h.style.background="#ef4444";}if(p){let u=Math.floor((Date.now()-this.startTime)/1e3),v=Math.floor(u/60),F=u%60;p.textContent=`${v}:${F.toString().padStart(2,"0")}`;}}updateComponentList(){if(!this.shadowRoot)return;let e=this.shadowRoot.getElementById("rc-component-list");if(!e)return;let t=Array.from(this.trackedComponents.entries()).sort((n,i)=>i[1].count-n[1].count);if(t.length===0){e.innerHTML=`
764
764
  <div class="empty-state">
765
765
  <svg viewBox="0 0 24 24"><path d="M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"/></svg>
766
766
  <div>No components rendered yet</div>
767
767
  </div>
768
- `;return}e.innerHTML=t.map(([n,i])=>{let o=E[i.severity],s=i.renderTimes.length>0?(i.renderTimes.reduce((h,p)=>h+p,0)/i.renderTimes.length).toFixed(1):"0",a=Math.floor((Date.now()-i.lastRender)/1e3),c=a<60?`${a}s ago`:`${Math.floor(a/60)}m ago`;return `
768
+ `;return}e.innerHTML=t.map(([n,i])=>{let o=L[i.severity],s=i.renderTimes.length>0?(i.renderTimes.reduce((h,p)=>h+p,0)/i.renderTimes.length).toFixed(1):"0",a=Math.floor((Date.now()-i.lastRender)/1e3),c=a<60?`${a}s ago`:`${Math.floor(a/60)}m ago`;return `
769
769
  <div class="component-item">
770
770
  <div class="component-severity" style="background: ${o}"></div>
771
771
  <div class="component-info">
@@ -787,5 +787,5 @@
787
787
  </div>
788
788
  <div class="chain-flow">${n}</div>
789
789
  </div>
790
- `}).join("");}}clear(){for(let e of this.fadeTimeouts.values())clearTimeout(e);this.fadeTimeouts.clear();for(let e of this.trackedComponents.values())e.highlightEl.remove();this.trackedComponents.clear(),this.renderChains=[],this.totalRenders=0,this.startTime=Date.now(),this.updateStats(),this.updateComponentList(),this.updateChainList();}show(){this.host&&(this.host.style.display="block",this.visible=true);}hide(){this.host&&(this.host.style.display="none",this.visible=false);}toggle(){this.visible?this.hide():this.show();}configure(e){this.config={...this.config,...e};}isVisible(){return this.visible}getRenderCounts(){let e=new Map;for(let[t,n]of this.trackedComponents)e.set(t,n.count);return e}};l(g,"MAX_HIGHLIGHTS",50),l(g,"SKIP_COMPONENTS",new Set(["ForwardRef","Anonymous","Unknown","Fragment","Suspense","Context.Provider","Context.Consumer","Profiler","Root","#text"]));var m=g;function L(r,e){let t="",n="";for(let i of e)i==="*"&&n==="*"||(n=i,i==="*"?t+=".*":i==="?"?t+=".":t+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${t}$`).test(r)}var N={trackUnnecessary:true,fpsThreshold:30,highlightRenders:true,animationSpeed:"fast"},y=class extends v{constructor(t={},n){super();l(this,"config");l(this,"running",false);l(this,"reactVersion","unknown");l(this,"renderCounts",new Map);l(this,"originalOnCommitFiberRoot",null);l(this,"win");l(this,"overlay",null);this.config={...N,...t},this.win=n??(typeof window<"u"?window:{});}getDOMElement(t){if(typeof Element>"u")return null;if(t.stateNode instanceof Element)return t.stateNode;let n=t.child;for(;n;){if(n.stateNode instanceof Element)return n.stateNode;if(n.child)n=n.child;else if(n.sibling)n=n.sibling;else {let i=n.return;for(;i&&i!==t&&!i.sibling;)i=i.return;n=i&&i!==t?i.sibling:null;}}return null}enableOverlay(){this.overlay||(this.overlay=new m({enabled:true,highlightRenders:this.config.highlightRenders??true,showToolbar:true}),this.overlay.init());}disableOverlay(){this.overlay&&(this.overlay.destroy(),this.overlay=null);}getOverlay(){return this.overlay}start(){if(!this.running)try{this.hookIntoReact(),this.running=!0;}catch(t){this.emit("error",t instanceof Error?t:new Error(String(t)));}}stop(){this.running&&(this.unhookFromReact(),this.disableOverlay(),this.running=false);}reset(){this.renderCounts.clear();}hookIntoReact(){let t=this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!t){this.installHook();return}let n=t.onCommitFiberRoot;this.originalOnCommitFiberRoot=n,t.onCommitFiberRoot=(i,o,s)=>{n.call(t,i,o,s),this.running&&this.processCommit(o.current);},this.reactVersion=this.detectReactVersion(t),this.emit("ready",{reactVersion:this.reactVersion});}installHook(){let t={renderers:new Map,supportsFiber:true,inject:n=>{let i=t.renderers.size+1;return t.renderers.set(i,n),i},onCommitFiberRoot:(n,i,o)=>{this.running&&this.processCommit(i.current);},onCommitFiberUnmount:()=>{}};this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__=t,this.emit("ready",{reactVersion:"unknown (hook installed)"});}unhookFromReact(){let t=this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__;t&&this.originalOnCommitFiberRoot&&(t.onCommitFiberRoot=this.originalOnCommitFiberRoot,this.originalOnCommitFiberRoot=null);}detectReactVersion(t){if(t.renderers.size===0)return "unknown";let n=t.renderers.values().next().value;return n&&typeof n=="object"&&"version"in n?String(n.version):"unknown"}processCommit(t){let n=[{fiber:t,parent:null}];for(;n.length>0;){let i=n.pop();if(!i)continue;let{fiber:o}=i,s=i.parent;o.sibling&&n.push({fiber:o.sibling,parent:i.parent}),k(o)&&(o.tag!==d.MemoComponent&&T(o)&&this.processFiber(o,s),s=b(o));let a=o.alternate;a&&o!==t&&o.child===a.child||o.child&&n.push({fiber:o.child,parent:s});}}processFiber(t,n){let i=b(t);if(this.shouldFilterComponent(i))return;let o=t.alternate??null,a=R(t,o?"update":"mount",o?o.memoizedProps??{}:null,o?o.memoizedState:void 0),h=(this.renderCounts.get(i)??0)+1;this.renderCounts.set(i,h),a.renderCount=h;let p=this.getDOMElement(t);this.overlay&&this.config.highlightRenders&&(p?this.overlay.highlight(a,p):this.overlay.recordRender(a)),this.emit("render",{render:a,element:p});}shouldFilterComponent(t){if(t.startsWith("__")||t==="Fragment"||t==="Suspense"||t==="Profiler")return true;let{include:n,exclude:i}=this.config;return !!(n&&n.length>0&&!n.some(s=>this.matchPattern(t,s))||i&&i.length>0&&i.some(s=>this.matchPattern(t,s)))}matchPattern(t,n){return L(t,n)}getConfig(){return {...this.config}}configure(t){this.config={...this.config,...t};}isRunning(){return this.running}getReactVersion(){return this.reactVersion}getRenderCount(t){return this.renderCounts.get(t)??0}getAllRenderCounts(){return new Map(this.renderCounts)}};var I=5e3,A=500,D=2e3,w=class{constructor(e){l(this,"scanner");l(this,"overlay");l(this,"ws",null);l(this,"wsPort");l(this,"reconnectTimeout",null);l(this,"initialized",false);l(this,"destroyed",false);l(this,"paused",false);l(this,"pendingCommits",[]);l(this,"messageQueue",[]);l(this,"rafHandle",null);l(this,"restoreHook",null);l(this,"win");this.win=e??window,this.wsPort=this.win.__REACTCHECK_PORT__??3099,this.scanner=new y({trackUnnecessary:true,highlightRenders:true,animationSpeed:"fast"},this.win),this.overlay=new m({enabled:true,highlightRenders:true,showToolbar:true});}handleCommit(e){if(!(this.destroyed||this.paused||!e?.current)){if(!this.initialized){this.pendingCommits.length>=A&&this.pendingCommits.shift(),this.pendingCommits.push(e.current);return}this.scanner.processCommit(e.current);}}init(){if(this.initialized||this.destroyed)return;this.initialized=true,this.overlay.init(),this.setupScannerEvents(),this.connect();let e=this.pendingCommits;this.pendingCommits=[];for(let t of e)this.scanner.processCommit(t);this.startFpsMeasurement(),console.log("[ReactCheck] Initialized");}setupScannerEvents(){this.scanner.on("render",({render:e,element:t})=>{this.send({type:"render",payload:e}),this.overlay.recordRender(e),t&&this.overlay.highlight(e,t);}),this.scanner.on("ready",e=>{this.send({type:"ready",payload:e});}),this.scanner.on("error",e=>{this.send({type:"error",payload:{message:e.message,code:"SCANNER_ERROR"}});});}startFpsMeasurement(){let e=this.win.requestAnimationFrame;if(typeof e!="function")return;let t=0,n=Date.now(),i=()=>{if(this.destroyed)return;t++;let o=Date.now(),s=o-n;if(s>=1e3){let a=Math.round(t*1e3/s);t=0,n=o,this.overlay.updateFps(a),this.paused||this.send({type:"fps",payload:a});}this.rafHandle=e.call(this.win,i);};this.rafHandle=e.call(this.win,i);}connect(){if(!this.destroyed){this.ws&&(this.detachSocket(this.ws),this.ws.close(),this.ws=null);try{let e=new WebSocket(`ws://localhost:${this.wsPort}`);this.ws=e,e.onopen=()=>{console.log("[ReactCheck] Connected to CLI"),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.send({type:"ready",payload:{reactVersion:this.scanner.getReactVersion()}}),this.flushMessageQueue();},e.onmessage=t=>{try{let n=JSON.parse(t.data);this.handleMessage(n);}catch(n){console.warn("[ReactCheck] Invalid message:",n);}},e.onerror=t=>{console.warn("[ReactCheck] WebSocket error:",t);},e.onclose=()=>{console.log("[ReactCheck] Disconnected from CLI"),this.scheduleReconnect();};}catch(e){console.warn("[ReactCheck] Failed to connect:",e),this.scheduleReconnect();}}}detachSocket(e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;}scheduleReconnect(){this.reconnectTimeout||this.destroyed||(this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,!this.destroyed&&(console.log("[ReactCheck] Attempting to reconnect..."),this.connect());},D));}handleMessage(e){switch(e.type){case "start":this.paused=false,this.overlay.show();break;case "stop":this.paused=true;break;case "reset":this.scanner.reset(),this.overlay.clear();break;case "config":this.handleConfig(e.payload);break;case "highlight":break;case "toggle-overlay":this.handleToggleOverlay(e.payload.enabled);break}}handleToggleOverlay(e){e?(this.overlay.show(),this.overlay.configure({highlightRenders:true}),console.log("[ReactCheck] Overlay enabled")):(this.overlay.hide(),this.overlay.configure({highlightRenders:false}),console.log("[ReactCheck] Overlay disabled"));}isOverlayEnabled(){return this.overlay.isVisible()}toggleOverlay(){let e=!this.overlay.isVisible();this.handleToggleOverlay(e);}handleConfig(e){this.scanner.configure(e),e.highlightRenders!==void 0&&this.overlay.configure({highlightRenders:e.highlightRenders});}send(e){this.destroyed||(this.ws&&this.ws.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(e)):(this.messageQueue.length>=I&&this.messageQueue.shift(),this.messageQueue.push(e)));}flushMessageQueue(){if(this.ws&&this.ws.readyState===WebSocket.OPEN&&this.messageQueue.length>0){for(let e of this.messageQueue)this.ws.send(JSON.stringify(e));this.messageQueue=[];}}setHookRestorer(e){this.restoreHook=e;}destroy(){if(!this.destroyed){if(this.destroyed=true,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.rafHandle!==null){let e=this.win.cancelAnimationFrame;typeof e=="function"&&e.call(this.win,this.rafHandle),this.rafHandle=null;}this.ws&&(this.detachSocket(this.ws),this.ws.close(),this.ws=null),this.restoreHook&&(this.restoreHook(),this.restoreHook=null),this.pendingCommits=[],this.messageQueue=[],this.scanner.stop(),this.scanner.removeAllListeners(),this.overlay.destroy(),this.initialized=false;}}};function S(r){let e=r.location.href;if(e==="about:blank"||e.startsWith("chrome://")||e.startsWith("chrome-extension://")||e.startsWith("devtools://")||r.__REACTCHECK_INJECTED__)return null;r.__REACTCHECK_INJECTED__=true;let t=new w(r),n=r.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(n){let o=n.onCommitFiberRoot;n.onCommitFiberRoot=(s,a,c)=>{o.call(n,s,a,c),t.handleCommit(a);},t.setHookRestorer(()=>{n.onCommitFiberRoot=o;}),console.log("[ReactCheck] Wrapped existing DevTools hook");}else {let o={renderers:new Map,supportsFiber:true,inject(s){let a=o.renderers.size+1;return o.renderers.set(a,s),a},onCommitFiberRoot(s,a){t.handleCommit(a);},onCommitFiberUnmount(){}};r.__REACT_DEVTOOLS_GLOBAL_HOOK__=o,t.setHookRestorer(()=>{o.onCommitFiberRoot=()=>{};}),console.log("[ReactCheck] DevTools hook installed");}let i=r.document;return i.readyState==="loading"?i.addEventListener("DOMContentLoaded",()=>{t.init();},{once:true}):t.init(),r.__REACTCHECK__=t,t}typeof window<"u"&&typeof document<"u"&&S(window);
790
+ `}).join("");}}clear(){for(let e of this.fadeTimeouts.values())clearTimeout(e);this.fadeTimeouts.clear();for(let e of this.trackedComponents.values())e.highlightEl.remove();this.trackedComponents.clear(),this.renderChains=[],this.totalRenders=0,this.startTime=Date.now(),this.updateStats(),this.updateComponentList(),this.updateChainList();}show(){this.host&&(this.host.style.display="block",this.visible=true);}hide(){this.host&&(this.host.style.display="none",this.visible=false);}toggle(){this.visible?this.hide():this.show();}configure(e){this.config={...this.config,...e};}isVisible(){return this.visible}getRenderCounts(){let e=new Map;for(let[t,n]of this.trackedComponents)e.set(t,n.count);return e}};l(g,"MAX_HIGHLIGHTS",50),l(g,"SKIP_COMPONENTS",new Set(["ForwardRef","Anonymous","Unknown","Fragment","Suspense","Context.Provider","Context.Consumer","Profiler","Root","#text"]));var m=g;function S(r,e){let t="",n="";for(let i of e)i==="*"&&n==="*"||(n=i,i==="*"?t+=".*":i==="?"?t+=".":t+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${t}$`).test(r)}var A={trackUnnecessary:true,fpsThreshold:30,highlightRenders:true,animationSpeed:"fast"},w=class extends f{constructor(t={},n){super();l(this,"config");l(this,"running",false);l(this,"reactVersion","unknown");l(this,"renderCounts",new Map);l(this,"originalOnCommitFiberRoot",null);l(this,"win");l(this,"overlay",null);this.config={...A,...t},this.win=n??(typeof window<"u"?window:{});}getDOMElement(t){if(typeof Element>"u")return null;if(t.stateNode instanceof Element)return t.stateNode;let n=t.child;for(;n;){if(n.stateNode instanceof Element)return n.stateNode;if(n.child)n=n.child;else if(n.sibling)n=n.sibling;else {let i=n.return;for(;i&&i!==t&&!i.sibling;)i=i.return;n=i&&i!==t?i.sibling:null;}}return null}enableOverlay(){this.overlay||(this.overlay=new m({enabled:true,highlightRenders:this.config.highlightRenders??true,showToolbar:true}),this.overlay.init());}disableOverlay(){this.overlay&&(this.overlay.destroy(),this.overlay=null);}getOverlay(){return this.overlay}start(){if(!this.running)try{this.hookIntoReact(),this.running=!0;}catch(t){this.emit("error",t instanceof Error?t:new Error(String(t)));}}stop(){this.running&&(this.unhookFromReact(),this.disableOverlay(),this.running=false);}reset(){this.renderCounts.clear();}hookIntoReact(){let t=this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!t){this.installHook();return}let n=t.onCommitFiberRoot;this.originalOnCommitFiberRoot=n,t.onCommitFiberRoot=(i,o,s)=>{n.call(t,i,o,s),this.running&&this.processCommit(o.current);},this.reactVersion=this.detectReactVersion(t),this.emit("ready",{reactVersion:this.reactVersion});}installHook(){let t={renderers:new Map,supportsFiber:true,inject:n=>{let i=t.renderers.size+1;return t.renderers.set(i,n),i},onCommitFiberRoot:(n,i,o)=>{this.running&&this.processCommit(i.current);},onCommitFiberUnmount:()=>{}};this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__=t,this.emit("ready",{reactVersion:"unknown (hook installed)"});}unhookFromReact(){let t=this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__;t&&this.originalOnCommitFiberRoot&&(t.onCommitFiberRoot=this.originalOnCommitFiberRoot,this.originalOnCommitFiberRoot=null);}detectReactVersion(t){if(t.renderers.size===0)return "unknown";let n=t.renderers.values().next().value;return n&&typeof n=="object"&&"version"in n?String(n.version):"unknown"}processCommit(t){let n=[{fiber:t,parent:null}];for(;n.length>0;){let i=n.pop();if(!i)continue;let{fiber:o}=i,s=i.parent;o.sibling&&n.push({fiber:o.sibling,parent:i.parent}),R(o)&&(o.tag!==d.MemoComponent&&T(o)&&this.processFiber(o,s),s=y(o));let a=o.alternate;a&&o!==t&&o.child===a.child||o.child&&n.push({fiber:o.child,parent:s});}}processFiber(t,n){let i=y(t);if(this.shouldFilterComponent(i))return;let o=t.alternate??null,a=E(t,o?"update":"mount",o?o.memoizedProps??{}:null,o?o.memoizedState:void 0),h=(this.renderCounts.get(i)??0)+1;this.renderCounts.set(i,h),a.renderCount=h,n&&(a.parent=n);let p=this.getDOMElement(t);this.overlay&&this.config.highlightRenders&&(p?this.overlay.highlight(a,p):this.overlay.recordRender(a)),this.emit("render",{render:a,element:p});}shouldFilterComponent(t){if(t.startsWith("__")||t==="Fragment"||t==="Suspense"||t==="Profiler")return true;let{include:n,exclude:i}=this.config;return !!(n&&n.length>0&&!n.some(s=>this.matchPattern(t,s))||i&&i.length>0&&i.some(s=>this.matchPattern(t,s)))}matchPattern(t,n){return S(t,n)}getConfig(){return {...this.config}}configure(t){this.config={...this.config,...t};}isRunning(){return this.running}getReactVersion(){if(this.reactVersion.startsWith("unknown")){let t=this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t?.renderers instanceof Map){let n=this.detectReactVersion(t);n!=="unknown"&&(this.reactVersion=n);}}return this.reactVersion}getRenderCount(t){return this.renderCounts.get(t)??0}getAllRenderCounts(){return new Map(this.renderCounts)}};var I=5e3,D=500,K=2e3,C=class{constructor(e){l(this,"scanner");l(this,"overlay");l(this,"ws",null);l(this,"wsPort");l(this,"reconnectTimeout",null);l(this,"initialized",false);l(this,"destroyed",false);l(this,"paused",false);l(this,"pendingCommits",[]);l(this,"messageQueue",[]);l(this,"rafHandle",null);l(this,"restoreHook",null);l(this,"win");l(this,"reportedReactVersion","unknown");this.win=e??window,this.wsPort=this.win.__REACTCHECK_PORT__??3099,this.scanner=new w({trackUnnecessary:true,highlightRenders:true,animationSpeed:"fast"},this.win),this.overlay=new m({enabled:true,highlightRenders:true,showToolbar:true});}handleCommit(e){if(!(this.destroyed||this.paused||!e?.current)){if(!this.initialized){this.pendingCommits.length>=D&&this.pendingCommits.shift(),this.pendingCommits.push(e.current);return}this.scanner.processCommit(e.current);}}init(){if(this.initialized||this.destroyed)return;this.initialized=true,this.overlay.init(),this.setupScannerEvents(),this.connect();let e=this.pendingCommits;this.pendingCommits=[];for(let t of e)this.scanner.processCommit(t);this.startFpsMeasurement(),console.log("[ReactCheck] Initialized");}setupScannerEvents(){this.scanner.on("render",({render:e,element:t})=>{this.reportedReactVersion.startsWith("unknown")&&this.ws?.readyState===WebSocket.OPEN&&(this.scanner.getReactVersion().startsWith("unknown")||this.sendReady()),this.send({type:"render",payload:e}),this.overlay.recordRender(e),t&&this.overlay.highlight(e,t);}),this.scanner.on("ready",e=>{this.send({type:"ready",payload:e});}),this.scanner.on("error",e=>{this.send({type:"error",payload:{message:e.message,code:"SCANNER_ERROR"}});});}startFpsMeasurement(){let e=this.win.requestAnimationFrame;if(typeof e!="function")return;let t=0,n=Date.now(),i=()=>{if(this.destroyed)return;t++;let o=Date.now(),s=o-n;if(s>=1e3){let a=Math.round(t*1e3/s);t=0,n=o,this.overlay.updateFps(a),this.paused||this.send({type:"fps",payload:a});}this.rafHandle=e.call(this.win,i);};this.rafHandle=e.call(this.win,i);}connect(){if(!this.destroyed){this.ws&&(this.detachSocket(this.ws),this.ws.close(),this.ws=null);try{let e=new WebSocket(`ws://localhost:${this.wsPort}`);this.ws=e,e.onopen=()=>{console.log("[ReactCheck] Connected to CLI"),this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.sendReady(),this.flushMessageQueue();},e.onmessage=t=>{try{let n=JSON.parse(t.data);this.handleMessage(n);}catch(n){console.warn("[ReactCheck] Invalid message:",n);}},e.onerror=t=>{console.warn("[ReactCheck] WebSocket error:",t);},e.onclose=()=>{console.log("[ReactCheck] Disconnected from CLI"),this.scheduleReconnect();};}catch(e){console.warn("[ReactCheck] Failed to connect:",e),this.scheduleReconnect();}}}detachSocket(e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;}scheduleReconnect(){this.reconnectTimeout||this.destroyed||(this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,!this.destroyed&&(console.log("[ReactCheck] Attempting to reconnect..."),this.connect());},K));}handleMessage(e){switch(e.type){case "start":this.paused=false,this.overlay.show();break;case "stop":this.paused=true;break;case "reset":this.scanner.reset(),this.overlay.clear();break;case "config":this.handleConfig(e.payload);break;case "highlight":break;case "toggle-overlay":this.handleToggleOverlay(e.payload.enabled);break}}handleToggleOverlay(e){e?(this.overlay.show(),this.overlay.configure({highlightRenders:true}),console.log("[ReactCheck] Overlay enabled")):(this.overlay.hide(),this.overlay.configure({highlightRenders:false}),console.log("[ReactCheck] Overlay disabled"));}isOverlayEnabled(){return this.overlay.isVisible()}toggleOverlay(){let e=!this.overlay.isVisible();this.handleToggleOverlay(e);}handleConfig(e){this.scanner.configure(e),e.highlightRenders!==void 0&&this.overlay.configure({highlightRenders:e.highlightRenders});let t=e.thresholds;t&&Number.isFinite(t.warning)&&Number.isFinite(t.critical)&&this.overlay.configure({thresholds:{warning:t.warning,critical:t.critical}});}sendReady(){this.reportedReactVersion=this.scanner.getReactVersion(),this.send({type:"ready",payload:{reactVersion:this.reportedReactVersion}});}send(e){this.destroyed||(this.ws&&this.ws.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(e)):(this.messageQueue.length>=I&&this.messageQueue.shift(),this.messageQueue.push(e)));}flushMessageQueue(){if(this.ws&&this.ws.readyState===WebSocket.OPEN&&this.messageQueue.length>0){for(let e of this.messageQueue)this.ws.send(JSON.stringify(e));this.messageQueue=[];}}setHookRestorer(e){this.restoreHook=e;}destroy(){if(!this.destroyed){if(this.destroyed=true,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.rafHandle!==null){let e=this.win.cancelAnimationFrame;typeof e=="function"&&e.call(this.win,this.rafHandle),this.rafHandle=null;}this.ws&&(this.detachSocket(this.ws),this.ws.close(),this.ws=null),this.restoreHook&&(this.restoreHook(),this.restoreHook=null),this.pendingCommits=[],this.messageQueue=[],this.scanner.stop(),this.scanner.removeAllListeners(),this.overlay.destroy(),this.initialized=false;}}};function H(r){let e=r.location.href;if(e==="about:blank"||e.startsWith("chrome://")||e.startsWith("chrome-extension://")||e.startsWith("devtools://")||r.__REACTCHECK_INJECTED__)return null;r.__REACTCHECK_INJECTED__=true;let t=new C(r),n=r.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(n){let o=n.onCommitFiberRoot;n.onCommitFiberRoot=(s,a,c)=>{o.call(n,s,a,c),t.handleCommit(a);},t.setHookRestorer(()=>{n.onCommitFiberRoot=o;}),console.log("[ReactCheck] Wrapped existing DevTools hook");}else {let o={renderers:new Map,supportsFiber:true,inject(s){let a=o.renderers.size+1;return o.renderers.set(a,s),a},onCommitFiberRoot(s,a){t.handleCommit(a);},onCommitFiberUnmount(){}};r.__REACT_DEVTOOLS_GLOBAL_HOOK__=o,t.setHookRestorer(()=>{o.onCommitFiberRoot=()=>{};}),console.log("[ReactCheck] DevTools hook installed");}let i=r.document;return i.readyState==="loading"?i.addEventListener("DOMContentLoaded",()=>{t.init();},{once:true}):t.init(),r.__REACTCHECK__=t,t}typeof window<"u"&&typeof document<"u"&&H(window);
791
791
  })();
package/dist/chain.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as RenderChainInfo, R as RenderInfo } from './types-BZ3OeZ-5.cjs';
1
+ import { c as RenderChainInfo, R as RenderInfo } from './types-BhoB9oSH.cjs';
2
2
  import { E as EventEmitter } from './event-emitter-BVYUPYLd.cjs';
3
3
 
4
4
  /**
package/dist/chain.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as RenderChainInfo, R as RenderInfo } from './types-BZ3OeZ-5.js';
1
+ import { c as RenderChainInfo, R as RenderInfo } from './types-BhoB9oSH.js';
2
2
  import { E as EventEmitter } from './event-emitter-BVYUPYLd.js';
3
3
 
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { ChainAnalyzer } from './chunk-RQYHXWUC.js';
2
- import { FixSuggester } from './chunk-27R56V2S.js';
2
+ import { FixSuggester } from './chunk-PIXJPQO7.js';
3
3
  import { EventEmitter } from './chunk-WLN7ZVO4.js';
4
4
 
5
5
  // src/core/stats.ts
@@ -352,6 +352,8 @@ var Scanner = class extends EventEmitter {
352
352
  chainAnalyzer;
353
353
  /** Fix suggester */
354
354
  fixSuggester;
355
+ /** Components whose stats changed since their suggestions were last generated */
356
+ staleSuggestions = /* @__PURE__ */ new Set();
355
357
  /** Scanner configuration */
356
358
  config;
357
359
  /** Whether scanner is currently running */
@@ -385,6 +387,7 @@ var Scanner = class extends EventEmitter {
385
387
  */
386
388
  setupEventForwarding() {
387
389
  this.stats.on("update", (stats) => {
390
+ this.staleSuggestions.add(stats.name);
388
391
  this.emit("stats", stats);
389
392
  });
390
393
  this.stats.on("severityChange", (change) => {
@@ -433,20 +436,26 @@ var Scanner = class extends EventEmitter {
433
436
  this.stats.reset();
434
437
  this.chainAnalyzer.reset();
435
438
  this.fixSuggester.clearSuggestions();
439
+ this.staleSuggestions.clear();
436
440
  this.renderBatch = [];
437
441
  this.emit("reset", void 0);
438
442
  }
439
443
  /**
440
444
  * Process a render event
441
445
  * @param render - Render information
442
- * @param parent - Optional parent component name
446
+ * @param parent - Optional parent component name (defaults to `render.parent`,
447
+ * which the injected browser script fills in from the fiber tree)
443
448
  */
444
449
  addRender(render, parent) {
445
450
  if (!this.running) return;
446
451
  if (!this.isComponentIncluded(render.componentName)) return;
452
+ const parentName = parent ?? (typeof render.parent === "string" && render.parent !== "" ? render.parent : void 0);
447
453
  this.renderBatch.push(render);
448
454
  this.stats.addRender(render);
449
- this.chainAnalyzer.addRender(render, parent);
455
+ if (parentName !== void 0) {
456
+ this.stats.setComponentParent(render.componentName, parentName);
457
+ }
458
+ this.chainAnalyzer.addRender(render, parentName);
450
459
  this.emit("render", render);
451
460
  this.scheduleBatchProcessing();
452
461
  }
@@ -648,14 +657,33 @@ var Scanner = class extends EventEmitter {
648
657
  * @returns All suggestions
649
658
  */
650
659
  getSuggestions() {
660
+ this.refreshSuggestions();
651
661
  return this.fixSuggester.getAllSuggestions();
652
662
  }
663
+ /**
664
+ * Re-generate cached suggestions whose component received renders since they
665
+ * were created, so their text, numbers and severity match the current stats
666
+ * @param componentName - Only refresh this component (all when omitted)
667
+ */
668
+ refreshSuggestions(componentName) {
669
+ const names = componentName !== void 0 ? [componentName] : [...this.staleSuggestions];
670
+ for (const name of names) {
671
+ if (!this.staleSuggestions.has(name)) continue;
672
+ this.staleSuggestions.delete(name);
673
+ if (!this.fixSuggester.hasSuggestions(name)) continue;
674
+ const stats = this.stats.getComponentStats(name);
675
+ if (stats) {
676
+ this.fixSuggester.analyze(stats);
677
+ }
678
+ }
679
+ }
653
680
  /**
654
681
  * Get suggestions for a specific component
655
682
  * @param componentName - Component name
656
683
  * @returns Component suggestions
657
684
  */
658
685
  getComponentSuggestions(componentName) {
686
+ this.refreshSuggestions(componentName);
659
687
  return this.fixSuggester.getSuggestions(componentName);
660
688
  }
661
689
  /**
@@ -719,5 +747,5 @@ var Scanner = class extends EventEmitter {
719
747
  };
720
748
 
721
749
  export { Scanner, StatsCollector, matchComponentPattern };
722
- //# sourceMappingURL=chunk-7YYMP3PP.js.map
723
- //# sourceMappingURL=chunk-7YYMP3PP.js.map
750
+ //# sourceMappingURL=chunk-35I3PLS3.js.map
751
+ //# sourceMappingURL=chunk-35I3PLS3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/stats.ts","../src/utils/pattern.ts","../src/core/scanner.ts"],"names":["DEFAULT_THRESHOLDS"],"mappings":";;;;;AAiCA,IAAM,kBAAA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AAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,iBAAiB,aAAA,EAAwC;AACvD,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,iBAAA,CAAkB,aAAa,CAAA;AACxD,IAAA,IAAI,CAAC,KAAA,EAAO,OAAO,EAAC;AACpB,IAAA,OAAO,IAAA,CAAK,YAAA,CAAa,OAAA,CAAQ,KAAK,CAAA;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAA,GAA8B;AAC5B,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,KAAA,CAAM,WAAA,EAAY;AACxC,IAAA,MAAM,iBAAkC,EAAC;AAEzC,IAAA,KAAA,MAAW,SAAS,QAAA,EAAU;AAC5B,MAAA,MAAM,WAAA,GAAc,IAAA,CAAK,YAAA,CAAa,OAAA,CAAQ,KAAK,CAAA;AACnD,MAAA,cAAA,CAAe,IAAA,CAAK,GAAG,WAAW,CAAA;AAAA,IACpC;AAEA,IAAA,OAAO,cAAA;AAAA,EACT;AACF","file":"chunk-35I3PLS3.js","sourcesContent":["/**\n * Statistics collector for component render data\n * @packageDocumentation\n */\n\nimport type {\n RenderInfo,\n ComponentStats,\n Severity,\n ThresholdOptions,\n SessionSummary,\n} from '../types.js';\nimport { EventEmitter } from '../utils/event-emitter.js';\n\n/**\n * Events emitted by StatsCollector\n */\nexport interface StatsEvents {\n /** Index signature for EventMap compatibility */\n [key: string]: unknown;\n /** Emitted when component stats are updated */\n update: ComponentStats;\n /** Emitted when severity changes */\n severityChange: { component: string; from: Severity | 'healthy'; to: Severity | 'healthy' };\n /** Emitted when a critical threshold is crossed */\n critical: ComponentStats;\n /** Emitted when a warning threshold is crossed */\n warning: ComponentStats;\n}\n\n/**\n * Default threshold values\n */\nconst DEFAULT_THRESHOLDS: ThresholdOptions = {\n critical: 50,\n warning: 20,\n fps: 30,\n};\n\n/**\n * Statistics collector that aggregates render data into meaningful stats\n */\nexport class StatsCollector extends EventEmitter<StatsEvents> {\n /** Map of component names to their statistics */\n private components: Map<string, ComponentStats> = new Map();\n\n /** Threshold configuration */\n private thresholds: ThresholdOptions;\n\n /** Session start time */\n private sessionStart: number;\n\n /** Total render count across all components */\n private totalRenders: number = 0;\n\n /** FPS samples for averaging */\n private fpsSamples: number[] = [];\n\n /** Maximum FPS samples to keep */\n private readonly maxFpsSamples: number = 100;\n\n /**\n * Create a new StatsCollector\n * @param thresholds - Threshold configuration\n */\n constructor(thresholds: Partial<ThresholdOptions> = {}) {\n super();\n this.thresholds = { ...DEFAULT_THRESHOLDS, ...thresholds };\n this.sessionStart = Date.now();\n }\n\n /**\n * Add a render event to the statistics\n * @param render - Render information\n */\n addRender(render: RenderInfo): void {\n const stats = this.getOrCreateStats(render.componentName);\n const previousSeverity = stats.severity;\n\n // Update basic stats\n stats.renders++;\n this.totalRenders++;\n\n // Update render times\n stats.totalRenderTime += render.renderTime;\n stats.avgRenderTime = stats.totalRenderTime / stats.renders;\n stats.maxRenderTime = Math.max(stats.maxRenderTime, render.renderTime);\n stats.minRenderTime = Math.min(stats.minRenderTime, render.renderTime);\n\n // Update unnecessary renders\n if (!render.necessary) {\n stats.unnecessary++;\n }\n\n // Update timestamps\n if (stats.firstRender === 0) {\n stats.firstRender = render.timestamp;\n }\n stats.lastRender = render.timestamp;\n\n // Update prop/state change tracking\n if (render.changedProps && render.changedProps.length > 0) {\n stats.propsChanged = true;\n }\n if (render.changedState && render.changedState.length > 0) {\n stats.stateChanged = true;\n }\n\n // Calculate expected renders (heuristic based on session duration)\n const sessionDuration = Date.now() - this.sessionStart;\n const sessionMinutes = sessionDuration / 60000;\n stats.expectedRenders = Math.max(1, Math.ceil(sessionMinutes * 5)); // ~5 renders per minute baseline\n\n // Update severity\n this.updateSeverity(stats);\n\n // Emit events\n this.emit('update', stats);\n\n if (stats.severity !== previousSeverity) {\n this.emit('severityChange', {\n component: stats.name,\n from: previousSeverity,\n to: stats.severity,\n });\n\n if (stats.severity === 'critical' && previousSeverity !== 'critical') {\n this.emit('critical', stats);\n } else if (stats.severity === 'warning' && previousSeverity === 'healthy') {\n this.emit('warning', stats);\n }\n }\n }\n\n /**\n * Record an FPS sample\n * @param fps - FPS value\n */\n addFpsSample(fps: number): void {\n this.fpsSamples.push(fps);\n if (this.fpsSamples.length > this.maxFpsSamples) {\n this.fpsSamples.shift();\n }\n }\n\n /**\n * Get or create stats for a component\n * @param name - Component name\n * @returns Component stats\n */\n private getOrCreateStats(name: string): ComponentStats {\n let stats = this.components.get(name);\n if (!stats) {\n stats = this.createEmptyStats(name);\n this.components.set(name, stats);\n }\n return stats;\n }\n\n /**\n * Create empty stats for a component\n * @param name - Component name\n * @returns Empty component stats\n */\n private createEmptyStats(name: string): ComponentStats {\n return {\n name,\n renders: 0,\n expectedRenders: 1,\n avgRenderTime: 0,\n maxRenderTime: 0,\n minRenderTime: Infinity,\n totalRenderTime: 0,\n unnecessary: 0,\n severity: 'healthy',\n chain: [],\n fixes: [],\n firstRender: 0,\n lastRender: 0,\n propsChanged: false,\n stateChanged: false,\n };\n }\n\n /**\n * Update severity for a component based on thresholds\n * @param stats - Component stats to update\n */\n private updateSeverity(stats: ComponentStats): void {\n if (stats.renders >= this.thresholds.critical) {\n stats.severity = 'critical';\n } else if (stats.renders >= this.thresholds.warning) {\n stats.severity = 'warning';\n } else {\n stats.severity = 'healthy';\n }\n }\n\n /**\n * Get stats for a specific component\n * @param name - Component name\n * @returns Component stats or undefined\n */\n getComponentStats(name: string): ComponentStats | undefined {\n return this.components.get(name);\n }\n\n /**\n * Get all component stats\n * @returns Array of component stats\n */\n getAllStats(): ComponentStats[] {\n return Array.from(this.components.values());\n }\n\n /**\n * Get a snapshot of all stats sorted by severity/render count\n * @returns Sorted array of component stats\n */\n getSnapshot(): ComponentStats[] {\n return this.getAllStats().sort((a, b) => {\n // Sort by severity first (critical > warning > healthy)\n const severityOrder: Record<Severity | 'healthy', number> = {\n critical: 0,\n warning: 1,\n info: 2,\n healthy: 3,\n };\n const severityDiff = severityOrder[a.severity] - severityOrder[b.severity];\n if (severityDiff !== 0) return severityDiff;\n\n // Then by render count (descending)\n return b.renders - a.renders;\n });\n }\n\n /**\n * Get components by severity\n * @param severity - Severity level to filter\n * @returns Array of matching component stats\n */\n getComponentsBySeverity(severity: Severity | 'healthy'): ComponentStats[] {\n return this.getAllStats().filter((s) => s.severity === severity);\n }\n\n /**\n * Get session summary\n * @returns Session summary statistics\n */\n getSummary(): SessionSummary {\n const stats = this.getAllStats();\n const criticalCount = stats.filter((s) => s.severity === 'critical').length;\n const warningCount = stats.filter((s) => s.severity === 'warning').length;\n const healthyCount = stats.filter((s) => s.severity === 'healthy').length;\n const unnecessaryCount = stats.reduce((sum, s) => sum + s.unnecessary, 0);\n\n // Calculate FPS stats\n let avgFps = 60;\n let minFps = 60;\n if (this.fpsSamples.length > 0) {\n avgFps = this.fpsSamples.reduce((a, b) => a + b, 0) / this.fpsSamples.length;\n minFps = Math.min(...this.fpsSamples);\n }\n\n return {\n totalComponents: stats.length,\n totalRenders: this.totalRenders,\n criticalIssues: criticalCount,\n warnings: warningCount,\n healthy: healthyCount,\n avgFps: Math.round(avgFps),\n minFps: Math.round(minFps),\n unnecessaryRenders: unnecessaryCount,\n };\n }\n\n /**\n * Get the most problematic components\n * @param limit - Maximum number to return\n * @returns Top problematic components\n */\n getTopProblems(limit: number = 10): ComponentStats[] {\n return this.getSnapshot()\n .filter((s) => s.severity !== 'healthy')\n .slice(0, limit);\n }\n\n /**\n * Update chain information for a component\n * @param componentName - Component name\n * @param chain - Render chain\n */\n setComponentChain(componentName: string, chain: string[]): void {\n const stats = this.components.get(componentName);\n if (stats) {\n stats.chain = chain;\n }\n }\n\n /**\n * Update parent information for a component\n * @param componentName - Component name\n * @param parentName - Parent component name\n */\n setComponentParent(componentName: string, parentName: string): void {\n const stats = this.components.get(componentName);\n if (stats) {\n stats.parent = parentName;\n }\n }\n\n /**\n * Reset all statistics\n */\n reset(): void {\n this.components.clear();\n this.totalRenders = 0;\n this.fpsSamples = [];\n this.sessionStart = Date.now();\n }\n\n /**\n * Update threshold configuration\n * @param thresholds - New thresholds\n */\n setThresholds(thresholds: Partial<ThresholdOptions>): void {\n this.thresholds = { ...this.thresholds, ...thresholds };\n\n // Re-evaluate all severities\n for (const stats of this.components.values()) {\n const previousSeverity = stats.severity;\n this.updateSeverity(stats);\n if (stats.severity !== previousSeverity) {\n this.emit('severityChange', {\n component: stats.name,\n from: previousSeverity,\n to: stats.severity,\n });\n }\n }\n }\n\n /**\n * Get current thresholds\n * @returns Current threshold configuration\n */\n getThresholds(): ThresholdOptions {\n return { ...this.thresholds };\n }\n\n /**\n * Get session duration in milliseconds\n * @returns Session duration\n */\n getSessionDuration(): number {\n return Date.now() - this.sessionStart;\n }\n\n /**\n * Get total render count\n * @returns Total renders across all components\n */\n getTotalRenders(): number {\n return this.totalRenders;\n }\n\n /**\n * Get component count\n * @returns Number of tracked components\n */\n getComponentCount(): number {\n return this.components.size;\n }\n\n /**\n * Check if FPS is below threshold\n * @returns true if average FPS is below threshold\n */\n isFpsBelowThreshold(): boolean {\n if (this.fpsSamples.length === 0) return false;\n const avgFps = this.fpsSamples.reduce((a, b) => a + b, 0) / this.fpsSamples.length;\n return avgFps < this.thresholds.fps;\n }\n\n /**\n * Export stats for serialization\n * @returns Serializable stats object\n */\n export(): {\n components: ComponentStats[];\n summary: SessionSummary;\n thresholds: ThresholdOptions;\n sessionDuration: number;\n } {\n return {\n components: this.getSnapshot(),\n summary: this.getSummary(),\n thresholds: this.getThresholds(),\n sessionDuration: this.getSessionDuration(),\n };\n }\n}\n","/**\n * Component name pattern matching\n * @packageDocumentation\n */\n\n/**\n * Match a component name against a simple glob pattern (`*` = any characters,\n * `?` = one character). All other characters match literally.\n * @param name - Component name\n * @param pattern - Glob pattern\n * @returns true if the name matches\n */\nexport function matchComponentPattern(name: string, pattern: string): boolean {\n let source = '';\n let prev = '';\n for (const ch of pattern) {\n // Collapse runs of '*' so patterns like '****' cannot cause heavy backtracking\n if (ch === '*' && prev === '*') continue;\n prev = ch;\n if (ch === '*') source += '.*';\n else if (ch === '?') source += '.';\n else source += ch.replace(/[.+^${}()|[\\]\\\\]/g, '\\\\$&');\n }\n return new RegExp(`^${source}$`).test(name);\n}\n","/**\n * Core scanner implementation for tracking React renders\n * @packageDocumentation\n */\n\nimport type {\n RenderInfo,\n RenderChainInfo,\n ThresholdOptions,\n ScannerConfig,\n ComponentStats,\n FixSuggestion,\n RuleLevel,\n RuleOptions,\n} from '../types.js';\nimport { EventEmitter } from '../utils/event-emitter.js';\nimport { StatsCollector } from './stats.js';\nimport { ChainAnalyzer } from './chain.js';\nimport { FixSuggester } from './fix.js';\nimport { matchComponentPattern } from '../utils/pattern.js';\n\n/**\n * Events emitted by Scanner\n */\nexport interface ScannerEvents {\n /** Index signature for EventMap compatibility */\n [key: string]: unknown;\n /** Emitted on each render */\n render: RenderInfo;\n /** Emitted when a render chain is detected */\n chain: RenderChainInfo;\n /** Emitted when FPS drops below threshold */\n 'fps-drop': number;\n /** Emitted when a fix suggestion is generated */\n fix: FixSuggestion;\n /** Emitted when component stats are updated */\n stats: ComponentStats;\n /** Emitted when scanner starts */\n start: void;\n /** Emitted when scanner stops */\n stop: void;\n /** Emitted when scanner is reset */\n reset: void;\n /** Emitted when severity changes for a component */\n severityChange: { component: string; from: string; to: string };\n}\n\n/**\n * Normalise rule settings (`'warn'` or `['warn', {...}]`) to plain levels\n * @param rules - Rule options\n * @returns Rule levels by id\n */\nfunction toRuleLevels(rules: RuleOptions): Record<string, RuleLevel> {\n const levels: Record<string, RuleLevel> = {};\n for (const [id, setting] of Object.entries(rules)) {\n const level = Array.isArray(setting) ? setting[0] : setting;\n if (level === 'off' || level === 'warn' || level === 'error') {\n levels[id] = level;\n }\n }\n return levels;\n}\n\n/**\n * Default scanner configuration\n */\nconst DEFAULT_CONFIG: ScannerConfig = {\n trackUnnecessary: true,\n fpsThreshold: 30,\n highlightRenders: true,\n animationSpeed: 'fast',\n};\n\n/**\n * Default threshold configuration\n */\nconst DEFAULT_THRESHOLDS: ThresholdOptions = {\n critical: 50,\n warning: 20,\n fps: 30,\n};\n\n/**\n * Core scanner class that coordinates render tracking and analysis\n */\nexport class Scanner extends EventEmitter<ScannerEvents> {\n /** Statistics collector */\n private stats: StatsCollector;\n\n /** Chain analyzer */\n private chainAnalyzer: ChainAnalyzer;\n\n /** Fix suggester */\n private fixSuggester: FixSuggester;\n\n /** Components whose stats changed since their suggestions were last generated */\n private staleSuggestions: Set<string> = new Set();\n\n /** Scanner configuration */\n private config: ScannerConfig;\n\n /** Whether scanner is currently running */\n private running: boolean = false;\n\n /** Last recorded FPS */\n private lastFps: number = 60;\n\n /** FPS tracking */\n private frameCount: number = 0;\n private lastFpsUpdate: number = 0;\n private fpsInterval: ReturnType<typeof setInterval> | null = null;\n\n /** Batch processing */\n private renderBatch: RenderInfo[] = [];\n private batchTimeout: ReturnType<typeof setTimeout> | null = null;\n private readonly batchSize: number = 10;\n private readonly batchDelay: number = 100;\n\n /**\n * Create a new Scanner instance\n * @param options - Configuration options\n */\n constructor(\n options: {\n config?: Partial<ScannerConfig>;\n thresholds?: Partial<ThresholdOptions>;\n /** Fix-suggestion rule levels by rule id (`off` disables a rule) */\n rules?: RuleOptions;\n } = {}\n ) {\n super();\n\n this.config = { ...DEFAULT_CONFIG, ...options.config };\n const thresholds = { ...DEFAULT_THRESHOLDS, ...options.thresholds };\n\n // Initialize sub-modules\n this.stats = new StatsCollector(thresholds);\n this.chainAnalyzer = new ChainAnalyzer();\n this.fixSuggester = new FixSuggester(options.rules ? { rules: toRuleLevels(options.rules) } : {});\n\n // Wire up event forwarding\n this.setupEventForwarding();\n }\n\n /**\n * Set up event forwarding from sub-modules\n */\n private setupEventForwarding(): void {\n // Forward stats events\n this.stats.on('update', (stats) => {\n this.staleSuggestions.add(stats.name);\n this.emit('stats', stats);\n });\n\n this.stats.on('severityChange', (change) => {\n this.emit('severityChange', change);\n\n // Generate fix suggestions on severity change\n const stats = this.stats.getComponentStats(change.component);\n if (stats && (change.to === 'critical' || change.to === 'warning')) {\n const suggestions = this.fixSuggester.analyze(stats);\n for (const suggestion of suggestions) {\n this.emit('fix', suggestion);\n }\n }\n });\n\n // Forward chain events\n this.chainAnalyzer.on('chain', (chain) => {\n this.emit('chain', chain);\n\n // Update component chains in stats\n for (const componentName of chain.chain) {\n this.stats.setComponentChain(componentName, chain.chain);\n }\n });\n }\n\n /**\n * Start the scanner\n */\n start(): void {\n if (this.running) return;\n\n this.running = true;\n this.lastFpsUpdate = Date.now();\n this.frameCount = 0;\n\n // Start FPS monitoring\n this.startFpsMonitoring();\n\n this.emit('start', undefined);\n }\n\n /**\n * Stop the scanner\n */\n stop(): void {\n if (!this.running) return;\n\n this.running = false;\n\n // Stop FPS monitoring\n this.stopFpsMonitoring();\n\n // Flush any pending batches\n this.flushBatch();\n\n this.emit('stop', undefined);\n }\n\n /**\n * Reset the scanner, clearing all data\n */\n reset(): void {\n this.stop();\n\n this.stats.reset();\n this.chainAnalyzer.reset();\n this.fixSuggester.clearSuggestions();\n this.staleSuggestions.clear();\n this.renderBatch = [];\n\n this.emit('reset', undefined);\n }\n\n /**\n * Process a render event\n * @param render - Render information\n * @param parent - Optional parent component name (defaults to `render.parent`,\n * which the injected browser script fills in from the fiber tree)\n */\n addRender(render: RenderInfo, parent?: string): void {\n if (!this.running) return;\n if (!this.isComponentIncluded(render.componentName)) return;\n\n const parentName = parent ?? (typeof render.parent === 'string' && render.parent !== '' ? render.parent : undefined);\n\n // Add to batch\n this.renderBatch.push(render);\n\n // Update stats immediately\n this.stats.addRender(render);\n if (parentName !== undefined) {\n this.stats.setComponentParent(render.componentName, parentName);\n }\n\n // Add to chain analyzer\n this.chainAnalyzer.addRender(render, parentName);\n\n // Emit render event\n this.emit('render', render);\n\n // Schedule batch processing\n this.scheduleBatchProcessing();\n }\n\n /**\n * Check a component name against the configured include/exclude patterns\n * @param name - Component name\n * @returns true if renders of this component should be tracked\n */\n isComponentIncluded(name: string): boolean {\n const { include, exclude } = this.config;\n if (include && include.length > 0 && !include.some((p) => matchComponentPattern(name, p))) {\n return false;\n }\n if (exclude && exclude.length > 0 && exclude.some((p) => matchComponentPattern(name, p))) {\n return false;\n }\n return true;\n }\n\n /**\n * Record a painted frame for FPS calculation (the scanner derives FPS from\n * frames recorded during each one-second window)\n */\n recordFrame(): void {\n this.frameCount++;\n }\n\n /**\n * Record an FPS sample measured elsewhere (e.g. by requestAnimationFrame in\n * the browser)\n * @param fps - Frames per second\n */\n recordFps(fps: number): void {\n if (!this.running || !Number.isFinite(fps) || fps < 0) return;\n this.lastFps = Math.round(fps);\n this.stats.addFpsSample(this.lastFps);\n if (this.lastFps < this.getFpsThreshold()) {\n this.emit('fps-drop', this.lastFps);\n }\n }\n\n /**\n * FPS threshold below which `fps-drop` is emitted\n * @returns Threshold\n */\n private getFpsThreshold(): number {\n return this.stats.getThresholds().fps ?? this.config.fpsThreshold;\n }\n\n /**\n * Schedule batch processing\n */\n private scheduleBatchProcessing(): void {\n if (this.batchTimeout) return;\n\n if (this.renderBatch.length >= this.batchSize) {\n this.flushBatch();\n } else {\n this.batchTimeout = setTimeout(() => {\n this.flushBatch();\n }, this.batchDelay);\n const timer = this.batchTimeout as unknown as { unref?: () => void };\n timer.unref?.();\n }\n }\n\n /**\n * Flush the render batch\n */\n private flushBatch(): void {\n if (this.batchTimeout) {\n clearTimeout(this.batchTimeout);\n this.batchTimeout = null;\n }\n\n if (this.renderBatch.length === 0) return;\n\n // Process batch for pattern detection\n this.processBatch(this.renderBatch);\n this.renderBatch = [];\n }\n\n /**\n * Process a batch of renders for patterns\n * @param batch - Render batch\n */\n private processBatch(batch: RenderInfo[]): void {\n // Group by component for analysis\n const byComponent = new Map<string, RenderInfo[]>();\n\n for (const render of batch) {\n const existing = byComponent.get(render.componentName) ?? [];\n existing.push(render);\n byComponent.set(render.componentName, existing);\n }\n\n // Check for high-frequency renders\n for (const [componentName, renders] of byComponent) {\n if (renders.length >= 3) {\n // Component rendered 3+ times in one batch - potential issue\n const stats = this.stats.getComponentStats(componentName);\n if (stats) {\n const suggestions = this.fixSuggester.analyze(stats);\n for (const suggestion of suggestions) {\n this.emit('fix', suggestion);\n }\n }\n }\n }\n }\n\n /**\n * Start FPS monitoring\n */\n private startFpsMonitoring(): void {\n this.fpsInterval = setInterval(() => {\n const now = Date.now();\n const elapsed = now - this.lastFpsUpdate;\n const frames = this.frameCount;\n\n this.frameCount = 0;\n this.lastFpsUpdate = now;\n\n // Only frames explicitly recorded via recordFrame() count; renders are not frames.\n if (elapsed > 0 && frames > 0) {\n this.recordFps((frames * 1000) / elapsed);\n }\n }, 1000);\n // Never keep a Node.js process alive just for FPS sampling\n const interval = this.fpsInterval as unknown as { unref?: () => void };\n interval.unref?.();\n }\n\n /**\n * Stop FPS monitoring\n */\n private stopFpsMonitoring(): void {\n if (this.fpsInterval) {\n clearInterval(this.fpsInterval);\n this.fpsInterval = null;\n }\n }\n\n /**\n * Get current FPS\n * @returns Current FPS value\n */\n getFps(): number {\n return this.lastFps;\n }\n\n /**\n * Check if scanner is running\n * @returns true if running\n */\n isRunning(): boolean {\n return this.running;\n }\n\n /**\n * Get scanner configuration\n * @returns Current configuration\n */\n getConfig(): ScannerConfig {\n return { ...this.config };\n }\n\n /**\n * Update scanner configuration\n * @param config - Partial configuration to update\n */\n configure(config: Partial<ScannerConfig>): void {\n this.config = { ...this.config, ...config };\n }\n\n /**\n * Update threshold configuration\n * @param thresholds - New thresholds\n */\n setThresholds(thresholds: Partial<ThresholdOptions>): void {\n this.stats.setThresholds(thresholds);\n }\n\n /**\n * Get current thresholds\n * @returns Current threshold configuration\n */\n getThresholds(): ThresholdOptions {\n return this.stats.getThresholds();\n }\n\n /**\n * Get component statistics\n * @param name - Component name (optional, returns all if not specified)\n * @returns Component stats\n */\n getStats(name?: string): ComponentStats | ComponentStats[] | undefined {\n if (name) {\n return this.stats.getComponentStats(name);\n }\n return this.stats.getAllStats();\n }\n\n /**\n * Get a snapshot of all stats sorted by severity\n * @returns Sorted stats array\n */\n getSnapshot(): ComponentStats[] {\n return this.stats.getSnapshot();\n }\n\n /**\n * Get session summary\n * @returns Session summary statistics\n */\n getSummary(): ReturnType<StatsCollector['getSummary']> {\n return this.stats.getSummary();\n }\n\n /**\n * Get top problematic components\n * @param limit - Maximum number to return\n * @returns Top problems\n */\n getTopProblems(limit: number = 10): ComponentStats[] {\n return this.stats.getTopProblems(limit);\n }\n\n /**\n * Get all fix suggestions\n * @returns All suggestions\n */\n getSuggestions(): FixSuggestion[] {\n this.refreshSuggestions();\n return this.fixSuggester.getAllSuggestions();\n }\n\n /**\n * Re-generate cached suggestions whose component received renders since they\n * were created, so their text, numbers and severity match the current stats\n * @param componentName - Only refresh this component (all when omitted)\n */\n private refreshSuggestions(componentName?: string): void {\n const names = componentName !== undefined ? [componentName] : [...this.staleSuggestions];\n for (const name of names) {\n if (!this.staleSuggestions.has(name)) continue;\n this.staleSuggestions.delete(name);\n if (!this.fixSuggester.hasSuggestions(name)) continue;\n const stats = this.stats.getComponentStats(name);\n if (stats) {\n this.fixSuggester.analyze(stats);\n }\n }\n }\n\n /**\n * Get suggestions for a specific component\n * @param componentName - Component name\n * @returns Component suggestions\n */\n getComponentSuggestions(componentName: string): FixSuggestion[] {\n this.refreshSuggestions(componentName);\n return this.fixSuggester.getSuggestions(componentName);\n }\n\n /**\n * Set parent relationship for a component\n * @param child - Child component name\n * @param parent - Parent component name\n */\n setParent(child: string, parent: string): void {\n this.chainAnalyzer.setParent(child, parent);\n this.stats.setComponentParent(child, parent);\n }\n\n /**\n * Get the render chain for a component\n * @param componentName - Component name\n * @returns Render chain\n */\n getComponentChain(componentName: string): string[] {\n return this.chainAnalyzer.getComponentChain(componentName);\n }\n\n /**\n * Get session duration\n * @returns Duration in milliseconds\n */\n getSessionDuration(): number {\n return this.stats.getSessionDuration();\n }\n\n /**\n * Export scanner data for reporting\n * @returns Exportable data object\n */\n export(): {\n stats: ReturnType<StatsCollector['export']>;\n suggestions: FixSuggestion[];\n config: ScannerConfig;\n } {\n return {\n stats: this.stats.export(),\n suggestions: this.getSuggestions(),\n config: this.getConfig(),\n };\n }\n\n /**\n * Analyze a specific component and generate suggestions\n * @param componentName - Component name\n * @returns Fix suggestions for the component\n */\n analyzeComponent(componentName: string): FixSuggestion[] {\n const stats = this.stats.getComponentStats(componentName);\n if (!stats) return [];\n return this.fixSuggester.analyze(stats);\n }\n\n /**\n * Analyze all components and generate suggestions\n * @returns All fix suggestions\n */\n analyzeAll(): FixSuggestion[] {\n const allStats = this.stats.getAllStats();\n const allSuggestions: FixSuggestion[] = [];\n\n for (const stats of allStats) {\n const suggestions = this.fixSuggester.analyze(stats);\n allSuggestions.push(...suggestions);\n }\n\n return allSuggestions;\n }\n}\n"]}