@oxog/react-check 1.2.0 → 1.3.1

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 (64) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/README.md +177 -62
  3. package/dist/browser-inject.global.js +13 -13
  4. package/dist/chain.cjs +8 -531
  5. package/dist/chain.cjs.map +1 -1
  6. package/dist/chain.d.cts +2 -2
  7. package/dist/chain.d.ts +2 -2
  8. package/dist/chain.js +2 -533
  9. package/dist/chain.js.map +1 -1
  10. package/dist/chunk-35I3PLS3.js +751 -0
  11. package/dist/chunk-35I3PLS3.js.map +1 -0
  12. package/dist/chunk-7R4KKJTW.cjs +255 -0
  13. package/dist/chunk-7R4KKJTW.cjs.map +1 -0
  14. package/dist/chunk-DSXOHC6R.cjs +755 -0
  15. package/dist/chunk-DSXOHC6R.cjs.map +1 -0
  16. package/dist/chunk-DWM55ACO.cjs +294 -0
  17. package/dist/chunk-DWM55ACO.cjs.map +1 -0
  18. package/dist/chunk-GS7T56RP.cjs +9 -0
  19. package/dist/chunk-GS7T56RP.cjs.map +1 -0
  20. package/dist/chunk-LFY7MUHJ.cjs +483 -0
  21. package/dist/chunk-LFY7MUHJ.cjs.map +1 -0
  22. package/dist/chunk-NLWGB4IE.cjs +380 -0
  23. package/dist/chunk-NLWGB4IE.cjs.map +1 -0
  24. package/dist/chunk-PIXJPQO7.js +481 -0
  25. package/dist/chunk-PIXJPQO7.js.map +1 -0
  26. package/dist/chunk-REEPUD73.js +362 -0
  27. package/dist/chunk-REEPUD73.js.map +1 -0
  28. package/dist/chunk-RQYHXWUC.js +292 -0
  29. package/dist/chunk-RQYHXWUC.js.map +1 -0
  30. package/dist/chunk-WLN7ZVO4.js +253 -0
  31. package/dist/chunk-WLN7ZVO4.js.map +1 -0
  32. package/dist/cli.js +1195 -297
  33. package/dist/cli.js.map +1 -1
  34. package/dist/detect.cjs +22 -324
  35. package/dist/detect.cjs.map +1 -1
  36. package/dist/detect.d.cts +8 -2
  37. package/dist/detect.d.ts +8 -2
  38. package/dist/detect.js +1 -324
  39. package/dist/detect.js.map +1 -1
  40. package/dist/{event-emitter-CxKUDo9q.d.cts → event-emitter-BVYUPYLd.d.cts} +3 -2
  41. package/dist/{event-emitter-CxKUDo9q.d.ts → event-emitter-BVYUPYLd.d.ts} +3 -2
  42. package/dist/fix.cjs +6 -715
  43. package/dist/fix.cjs.map +1 -1
  44. package/dist/fix.d.cts +8 -2
  45. package/dist/fix.d.ts +8 -2
  46. package/dist/fix.js +2 -719
  47. package/dist/fix.js.map +1 -1
  48. package/dist/index.cjs +1400 -3075
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +237 -57
  51. package/dist/index.d.ts +237 -57
  52. package/dist/index.js +1222 -2970
  53. package/dist/index.js.map +1 -1
  54. package/dist/{scanner-Cc2187fH.d.ts → scanner-BJFA0354.d.ts} +33 -4
  55. package/dist/{scanner-S7BtVIpW.d.cts → scanner-DZL2rIFv.d.cts} +33 -4
  56. package/dist/scanner.cjs +8 -1652
  57. package/dist/scanner.cjs.map +1 -1
  58. package/dist/scanner.d.cts +3 -3
  59. package/dist/scanner.d.ts +3 -3
  60. package/dist/scanner.js +4 -1656
  61. package/dist/scanner.js.map +1 -1
  62. package/dist/{types-DuZyBVVV.d.cts → types-BMDemwIs.d.cts} +35 -10
  63. package/dist/{types-DuZyBVVV.d.ts → types-BMDemwIs.d.ts} +35 -10
  64. package/package.json +16 -9
package/CHANGELOG.md CHANGED
@@ -5,6 +5,135 @@ 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.1] - 2026-12-01
9
+
10
+ ### Fixed
11
+
12
+ - **Render chains were never detected in real scans.** The browser script did not send each
13
+ component's parent, so `report.chains` was always empty, the TUI chain view (`c`) and the
14
+ WebUI chains panel stayed blank and the `state-too-high` rule never fired. Renders now carry
15
+ `parent` (new optional `RenderInfo.parent`), which `Scanner.addRender()` uses when no parent
16
+ argument is given; reports also list each component's parent. Mount renders are no longer
17
+ counted as state changes, so `state-too-high` only fires for components whose state changed.
18
+ - **Automatic Puppeteer install looped forever under `npx`.** The CLI installed Puppeteer into
19
+ the current directory, where an `npx`-run ReactCheck cannot resolve it, and restarted itself
20
+ again and again. Puppeteer is now installed once into ReactCheck's own directory
21
+ (`~/.cache/react-check/puppeteer`, `%LOCALAPPDATA%\react-check\puppeteer` on Windows, or
22
+ `$REACTCHECK_PUPPETEER_DIR`) and loaded from there in the same process. The CLI never
23
+ restarts; if Puppeteer still cannot be loaded it exits with code 2 and explains how to install
24
+ it. The check now runs before the TUI starts, so the messages stay visible, and scan errors
25
+ are no longer hidden after the TUI closes.
26
+ - **TypeScript users without Puppeteer got TS2307.** `dist/index.d.ts` imported `puppeteer`
27
+ types although Puppeteer is an optional peer. `BrowserLauncher.getPage()` / `getBrowser()` now
28
+ return the structural `PuppeteerPageLike` / `PuppeteerBrowserLike` types (both exported); pass
29
+ Puppeteer's type for the full API: `getPage<import('puppeteer').Page>()`.
30
+ - **Fix suggestions went stale.** A suggestion kept the numbers and severity from the moment it
31
+ was created (e.g. "9 unnecessary renders out of 10, warning" for a component that ended at
32
+ 100 renders, critical). `getSuggestions()`, `getComponentSuggestions()`, `export()`, CLI
33
+ reports, `--fix` output and `quickScan()` reports now regenerate them from the current stats.
34
+ - `--tui` / `-t` and `--watch` / `-w` were accepted and silently ignored. They are removed from
35
+ the help and rejected with an explanation (the TUI starts automatically in an interactive
36
+ terminal; without `--duration` a scan already runs until you quit).
37
+ - An unknown command word was scanned as a host name (`react-check watch http://x` scanned
38
+ `http://watch`). Unknown commands and extra arguments are rejected with exit code 2.
39
+ - The CLI always logged `React detected: unknown` because the script is injected before React
40
+ loads. The version is detected once React registers with the DevTools hook.
41
+ - The in-page overlay coloured renders with fixed 20/50 thresholds. It now uses the scan's
42
+ `--threshold-warning` / `--threshold-critical` (or `quickScan` thresholds), with the same
43
+ "at or above" meaning as the reports.
44
+ - `react-check detect` reported the Vite `ssr` feature for every project with a
45
+ `vite.config.*`. It now needs real evidence: `vite build --ssr`, an `ssr` option in the Vite
46
+ config, an `entry-server` module, or `vike` / `vite-plugin-ssr`.
47
+ - The CLI banner box was misaligned.
48
+ - README: removed `scanner.getReport()` and `ChainAnalyzer.getChains()` (they never existed),
49
+ the WebUI overlay toggle button, "WebUI alongside TUI" and the `--tui` / `--watch` flags.
50
+
51
+ ## [1.3.0] - 2026-11-30
52
+
53
+ ### Fixed
54
+
55
+ - **Importing the package crashed in Node.js.** `import`/`require('@oxog/react-check')` threw
56
+ `ReferenceError: window is not defined` in 1.2.0 (ESM and CommonJS) because the browser
57
+ injection script, including its self-installing IIFE, was bundled into the main entry. The
58
+ entry is now side-effect free and safe for Node.js, SSR and test runners; the IIFE only lives
59
+ in `dist/browser-inject.global.js`.
60
+ - **Render counts were wrong.** Every commit was processed twice (the injected hook and
61
+ `BrowserScanner.start()` both forwarded it) and the whole fiber tree was walked each time, so
62
+ every mounted component was reported as rendering on every commit (e.g. a memoized child that
63
+ rendered once was reported 61 times and flagged critical). Only fibers that actually rendered
64
+ are counted now (React's `PerformedWork` flag, untouched subtrees skipped), `React.memo`
65
+ wrappers are not double counted, and "unnecessary" renders are judged against the previous
66
+ committed fiber instead of stale state. Works with development and production React builds.
67
+ - `quickScan()` never worked: it launched the browser without the ReactCheck script and always
68
+ failed with `REACT_NOT_FOUND`. It now runs the same pipeline as the CLI (internal WebSocket
69
+ server on a free port, injected script, scanner) and returns a real report.
70
+ - `--proxy` mode printed a `<script>` URL that nothing served. The CLI now starts the proxy on
71
+ `--port + 1`, which serves the real browser script and injects it at the start of `<head>`.
72
+ `ProxyServer` also served a stub instead of the scanner, injected after `</body>` (too late
73
+ for React) and forwarded `Transfer-Encoding: chunked` together with `Content-Length`, which
74
+ produced invalid HTTP responses for chunked upstream pages.
75
+ - Config file values (`thresholds`, `report.output`, `report.formats`) were always overridden
76
+ by the CLI's built-in defaults. Precedence is now: command-line flag > config file > default.
77
+ Config `include`/`exclude` and `rules` are applied too.
78
+ - Config file lookup (`findUp`) only checked the current directory and its parent; it now
79
+ walks up to the filesystem root.
80
+ - `react-check detect` and `react-check report` (documented in the README) did not exist: the
81
+ words were treated as URLs and a browser was launched at `http://detect`. Both commands are
82
+ implemented.
83
+ - `--format html,json` (documented) was rejected; comma-separated formats are accepted.
84
+ - Unknown options and options missing a value were silently ignored (`--duraton 30` scanned
85
+ forever in CI); they now exit with code 2. Non-http(s) targets are rejected.
86
+ - `--version` printed 1.1.6 and reports were stamped `1.1.6`; the exported `VERSION` was
87
+ `1.0.0`. All now come from one constant that a test keeps equal to `package.json`.
88
+ - "Avg FPS" was renders per second (e.g. 232). FPS is now measured in the page with
89
+ `requestAnimationFrame`; `Scanner.recordFps()` accepts external samples.
90
+ - `createScanner({ include, exclude })` ignored both options.
91
+ - Framework detection: `rsc` was reported for every Next.js version (and `^9.5.0` was parsed
92
+ as 95), Gatsby 4 was reported as `v5`, and `middleware.js` / `vite.config.js` were never
93
+ detected (`Promise || Promise`).
94
+ - Render chains were missed at random when two renders 1 ms apart straddled a 16 ms bucket.
95
+ - Browser cleanup: `ReactCheckInjector.destroy()` reconnected right after closing the socket,
96
+ left the DevTools hook wrapped and timers running; `Overlay.destroy()` left document
97
+ listeners behind and a pending init retry could re-create the overlay; `BrowserScanner.stop()`
98
+ kept processing commits when it had installed its own hook and restored a bound copy of the
99
+ original hook function. The offline message queue is now bounded.
100
+ - Very wide component trees (100k siblings) overflowed the stack; traversal is iterative.
101
+ - Component names and chain triggers were inserted into the overlay HTML unescaped.
102
+ - The WebSocket server buffered frames of any announced size; frames over 16 MiB now close
103
+ the connection. Handler exceptions are no longer hidden by the JSON parse `try`.
104
+ - `Scanner` timers no longer keep a Node.js process alive.
105
+ - `EventEmitter<T>` rejected plain `interface` event maps (index signature required).
106
+ - `FiberType` rejected class components; `ReactDevToolsHook` lacked the optional React hooks;
107
+ `RuleOptions` only allowed three rule ids that did not exist.
108
+ - A leftover debug `console.log` ("Overlay check") was printed during every scan.
109
+
110
+ ### Added
111
+
112
+ - `react-check detect [path] [--json]` and `react-check report <file.json>` commands.
113
+ - Exit codes are documented: `0` clean, `1` critical issues found, `2` usage or runtime error.
114
+ - `quickScan` options `thresholds`, `include`, `exclude`, `port`, `browserArgs`.
115
+ - `installReactCheck(window)`, `loadInjectionScript(port)`, `matchComponentPattern()` and
116
+ `Scanner.recordFps()` / `isComponentIncluded()` exports; `WebSocketServer` and
117
+ `ProxyServer` accept port `0` and report the real port.
118
+ - `"./package.json"` export.
119
+
120
+ ### Changed
121
+
122
+ - Puppeteer is only auto-installed in an interactive terminal outside CI. In CI, without a
123
+ TTY, or with `REACTCHECK_NO_INSTALL=1` the scan exits with code 2 and explains what to
124
+ install. Missing `browser-inject.global.js` is now an error instead of a silent no-op script.
125
+ - Shared code is split into chunks, so `@oxog/react-check` and its subpath entries
126
+ (`/scanner`, `/chain`, `/fix`, `/detect`) share one copy of each class (`instanceof` works
127
+ across entries).
128
+ - `--output` or `--format` imply `--report`.
129
+ - `BrowserLauncher`/`ProxyServer` no longer print debug-level logs.
130
+ - Fix-suggestion rule ids in generated configs are the real ones
131
+ (`unnecessary-rerenders-memo`, `function-prop-stability`, ...).
132
+ - Tooling: lint covers `src` and `tests` with zero warnings, tests are type-checked, coverage
133
+ thresholds are enforced, `npm run test:package` verifies the packed archive (ESM, CJS,
134
+ NodeNext types, CLI bins, and an end-to-end scan when Chrome is available), CI runs on
135
+ Node 18–24 and publishing is a manual workflow.
136
+
8
137
  ## [1.2.0] - 2025-12-31
9
138
 
10
139
  ### Added
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  A zero-dependency React performance scanner that detects unnecessary re-renders, analyzes render chains, and provides actionable fix suggestions.
8
8
 
9
- **[Documentation](https://reactcheck.oxog.dev)** | **[npm](https://www.npmjs.com/package/@oxog/react-check)** | **[GitHub](https://github.com/ersinkoc/react-check)**
9
+ **[Documentation](https://reactcheck.oxog.dev)** | **[npm](https://www.npmjs.com/package/@oxog/react-check)** | **[GitHub](https://github.com/ersinkoc/ReactCheck)**
10
10
 
11
11
  ## Features
12
12
 
@@ -23,15 +23,32 @@ A zero-dependency React performance scanner that detects unnecessary re-renders,
23
23
  ## Installation
24
24
 
25
25
  ```bash
26
- npm install @oxog/react-check
26
+ npm install --save-dev @oxog/react-check
27
27
  ```
28
28
 
29
- For CLI usage with browser automation:
29
+ Scanning a URL launches Chrome through [Puppeteer](https://pptr.dev), an optional peer dependency:
30
30
 
31
31
  ```bash
32
- npm install @oxog/react-check puppeteer
32
+ npm install --save-dev @oxog/react-check puppeteer
33
33
  ```
34
34
 
35
+ - Node.js 18 or newer. The package ships ESM and CommonJS builds with TypeScript types.
36
+ - React is **not** a dependency: ReactCheck observes the page through the React DevTools
37
+ global hook, so it works with React 16.8+ development and production builds (verified with
38
+ React 18). There is no static source analysis; nothing in your project is parsed.
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>()`.
48
+ - Importing `@oxog/react-check` has no side effects and does not touch `window`, so it is safe
49
+ in Node.js scripts, SSR bundles and test runners. The browser part ships separately as
50
+ `dist/browser-inject.global.js` and is injected by the CLI.
51
+
35
52
  ## Quick Start
36
53
 
37
54
  ### CLI Usage
@@ -42,11 +59,11 @@ Scan a React application:
42
59
  npx react-check scan http://localhost:3000
43
60
  ```
44
61
 
45
- With options:
62
+ With options (durations are in **seconds**):
46
63
 
47
64
  ```bash
48
65
  npx react-check scan http://localhost:3000 \
49
- --duration 60000 \
66
+ --duration 60 \
50
67
  --output ./reports \
51
68
  --format html,json \
52
69
  --headless
@@ -64,15 +81,25 @@ WebUI + custom port:
64
81
  npx react-check scan http://localhost:3000 --webui --webui-port 8080
65
82
  ```
66
83
 
84
+ In CI:
85
+
86
+ ```bash
87
+ npx react-check http://localhost:3000 --silent --headless --duration 30 --format json --output ./reactcheck-reports
88
+ ```
89
+
67
90
  ### Programmatic Usage
68
91
 
92
+ `Scanner` aggregates render events (`RenderInfo`) that you feed it, computes per-component
93
+ statistics, severities, render chains and fix suggestions. The CLI and `quickScan()` feed it
94
+ from the browser; you can also feed it yourself.
95
+
69
96
  ```typescript
70
97
  import { createScanner, generateHTMLReport } from '@oxog/react-check';
71
98
 
72
99
  // Create a scanner instance
73
100
  const scanner = createScanner({
74
101
  thresholds: { critical: 50, warning: 20 },
75
- include: ['MyComponent*'],
102
+ include: ['MyComponent*'], // glob patterns: * and ?
76
103
  exclude: ['DebugPanel'],
77
104
  });
78
105
 
@@ -81,16 +108,24 @@ scanner.on('render', (info) => {
81
108
  console.log(`${info.componentName} rendered in ${info.renderTime}ms`);
82
109
  });
83
110
 
84
- // Start scanning
85
111
  scanner.start();
112
+ scanner.addRender({
113
+ componentName: 'MyComponentList',
114
+ renderCount: 1,
115
+ renderTime: 2.4,
116
+ phase: 'update',
117
+ necessary: false,
118
+ timestamp: Date.now(),
119
+ });
120
+ scanner.stop();
86
121
 
87
- // Later: get report and generate HTML
88
- const report = scanner.getReport();
89
- const html = generateHTMLReport(report);
122
+ console.log(scanner.getSnapshot()); // per-component stats, sorted by severity
90
123
  ```
91
124
 
92
125
  ### Quick Scan API
93
126
 
127
+ Requires Puppeteer and Chrome. `duration` is in milliseconds here.
128
+
94
129
  ```typescript
95
130
  import { quickScan } from '@oxog/react-check';
96
131
 
@@ -104,29 +139,72 @@ const report = await quickScan('http://localhost:3000', {
104
139
  console.log(`Found ${report.summary.criticalIssues} critical issues`);
105
140
  ```
106
141
 
142
+ `quickScan` throws a `ReactCheckError` with code `BROWSER_LAUNCH_FAILED` when Puppeteer or
143
+ the page is unavailable and `REACT_NOT_FOUND` when no React render was observed.
144
+
107
145
  ## CLI Commands
108
146
 
109
- ### `scan <url>`
147
+ ### `scan <url>` (default command)
110
148
 
111
- Scan a React application for performance issues.
149
+ Scan a React application for performance issues. `react-check <url>` is the same as
150
+ `react-check scan <url>`; without a URL in an interactive terminal a setup wizard starts.
112
151
 
113
152
  ```bash
114
153
  react-check scan <url> [options]
115
154
 
116
- Options:
117
- -d, --duration <ms> Scan duration in milliseconds (default: 30000)
118
- -o, --output <dir> Output directory for reports
119
- -f, --format <formats> Report formats: html,json,md (default: html,json)
120
- -t, --threshold <n> Render count threshold for warnings (default: 20)
121
- -c, --critical <n> Render count threshold for critical (default: 50)
122
- --headless Run browser in headless mode
123
- --include <patterns> Component patterns to include
124
- --exclude <patterns> Component patterns to exclude
125
- --no-tui Disable TUI, use simple output
126
- -W, --webui Enable WebUI dashboard
127
- --webui-port <port> WebUI dashboard port (default: 3199)
155
+ General:
156
+ -h, --help Show help message
157
+ -v, --version Show version number
158
+ --verbose Include detailed output
159
+ -c, --config <path> Config file path
160
+
161
+ Mode:
162
+ -P, --proxy Start a proxy on <port + 1> that injects ReactCheck into any browser
163
+ -s, --silent No TUI (for CI/CD)
164
+ --headless Run browser in headless mode
165
+ -W, --webui Enable WebUI dashboard
166
+ --webui-port <port> WebUI dashboard port (default: 3199)
167
+
168
+ Report:
169
+ -r, --report Generate reports (implied by --format / --output)
170
+ -f, --format <formats> html, json, md, all or a comma-separated list (default: all)
171
+ -o, --output <dir> Report output directory (default: ./reactcheck-reports)
172
+ --fix Show fix suggestions
173
+
174
+ Thresholds:
175
+ --threshold-critical <n> Render count for critical (default: 50)
176
+ --threshold-warning <n> Render count for warning (default: 20)
177
+ --fps-threshold <n> FPS drop threshold (default: 30)
178
+
179
+ Network:
180
+ -p, --port <port> WebSocket server port (default: 3099)
181
+ -d, --duration <seconds> Stop after this many seconds (otherwise Ctrl+C / q)
128
182
  ```
129
183
 
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`).
192
+
193
+ #### Exit codes
194
+
195
+ | Code | Meaning |
196
+ |------|---------|
197
+ | `0` | Scan finished without critical issues |
198
+ | `1` | Scan finished and found critical issues |
199
+ | `2` | Invalid usage, or the scan could not run (browser, port or page problems) |
200
+
201
+ #### Proxy mode
202
+
203
+ `react-check <url> --proxy` starts a proxy on `--port + 1` (default 3100). Open
204
+ `http://localhost:3100/<path>` in any browser; the proxy injects ReactCheck into every HTML
205
+ page. Alternatively add `<script src="http://localhost:3100/__reactcheck__/scanner.js"></script>`
206
+ to your page before React loads.
207
+
130
208
  ### `report <input>`
131
209
 
132
210
  Generate reports from a JSON scan result.
@@ -137,7 +215,8 @@ react-check report scan-results.json --format html,md --output ./reports
137
215
 
138
216
  ### `detect [path]`
139
217
 
140
- Detect the React framework in use.
218
+ Detect the React framework of a project (path to a directory or a `package.json`; `--json`
219
+ prints machine-readable output).
141
220
 
142
221
  ```bash
143
222
  react-check detect ./my-react-app
@@ -182,15 +261,17 @@ ReactCheck injects a visual overlay into the target page that highlights compone
182
261
  - **Flash Effect**: Components flash with a colored background on each render
183
262
  - **Border Highlight**: Pulsing border shows render boundaries
184
263
  - **Render Badges**: Small badges show component name and render count
185
- - **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
186
266
 
187
267
  ### Toggle Overlay
188
268
 
189
- You can toggle the overlay on/off in several ways:
269
+ You can toggle the overlay on/off:
190
270
 
191
271
  1. **TUI**: Press `o` to toggle overlay visibility
192
272
  2. **Browser Console**: Run `__REACTCHECK__.toggleOverlay()`
193
- 3. **WebUI Dashboard**: Click the overlay toggle button
273
+
274
+ The WebUI dashboard has no overlay toggle.
194
275
 
195
276
  When overlay is disabled, render tracking continues but visual effects are hidden.
196
277
 
@@ -204,15 +285,15 @@ The WebUI dashboard provides a real-time web interface for monitoring React perf
204
285
  - **Render Chains**: Visualization of cascade render chains
205
286
  - **Auto-open**: Dashboard opens automatically in your default browser
206
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
+
207
291
  ```bash
208
- # Enable WebUI alongside TUI
292
+ # Scan with the WebUI dashboard instead of the TUI
209
293
  react-check scan http://localhost:3000 --webui
210
294
 
211
295
  # Custom WebUI port
212
296
  react-check scan http://localhost:3000 --webui --webui-port 8080
213
-
214
- # WebUI only (no TUI)
215
- react-check scan http://localhost:3000 --webui --silent
216
297
  ```
217
298
 
218
299
  ## Report Formats
@@ -252,26 +333,36 @@ GitHub-friendly Markdown report suitable for issue tracking or documentation.
252
333
 
253
334
  ## Configuration
254
335
 
255
- ### Scanner Options
336
+ ReactCheck looks for `reactcheck.config.{js,mjs,cjs,json}`, `.reactcheckrc`,
337
+ `.reactcheckrc.js` or `.reactcheckrc.json` in the current directory and its parents
338
+ (`react-check init` creates one).
256
339
 
257
340
  ```typescript
258
- interface ScannerConfig {
259
- // Render count thresholds
341
+ /** @type {import('@oxog/react-check').ReactCheckConfig} */
342
+ export default {
343
+ // Component name patterns (* and ?)
344
+ include: [],
345
+ exclude: ['DebugPanel'],
260
346
  thresholds: {
261
- warning: number; // Default: 20
262
- critical: number; // Default: 50
263
- };
264
- // Component name patterns to include
265
- include?: string[];
266
- // Component name patterns to exclude
267
- exclude?: string[];
268
- // Enable render chain analysis
269
- chainAnalysis?: boolean;
270
- // Window size for render grouping (ms)
271
- windowSize?: number;
272
- }
347
+ critical: 50, // render count for critical severity
348
+ warning: 20, // render count for warning severity
349
+ fps: 30, // FPS drop threshold
350
+ },
351
+ report: {
352
+ formats: ['html', 'json'],
353
+ output: './reactcheck-reports',
354
+ },
355
+ // Fix-suggestion rules: 'off' disables a rule
356
+ rules: {
357
+ 'state-too-high': 'off',
358
+ },
359
+ };
273
360
  ```
274
361
 
362
+ Rule ids: `unnecessary-rerenders-memo`, `expensive-computation-memo`,
363
+ `function-prop-stability`, `context-over-subscription`, `state-too-high`,
364
+ `extract-heavy-child`.
365
+
275
366
  ### Fix Categories
276
367
 
277
368
  ReactCheck provides fix suggestions in these categories:
@@ -296,20 +387,31 @@ scanner.on('render', handler);
296
387
  scanner.on('chain', handler);
297
388
  scanner.on('fps-drop', handler);
298
389
  scanner.start();
390
+ scanner.addRender(renderInfo, parentName); // the CLI forwards browser renders here
299
391
  scanner.stop();
300
- 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 }
301
396
  ```
302
397
 
398
+ There is no `getReport()`: `quickScan()` returns a full `SessionReport`, or build one from
399
+ `export()` for the report generators.
400
+
303
401
  #### `ChainAnalyzer`
304
402
 
305
403
  Analyzes render chains and cascade effects.
306
404
 
307
405
  ```typescript
308
- 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(' -> ')));
309
408
  analyzer.addRender(renderInfo, parentName);
310
- const chains = analyzer.getChains();
409
+ const path = analyzer.getComponentChain('Leaf'); // e.g. ['App', 'Ticker', 'Leaf']
311
410
  ```
312
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
+
313
415
  #### `FixSuggester`
314
416
 
315
417
  Generates fix suggestions based on component statistics.
@@ -329,8 +431,8 @@ generateMarkdownReport(report);
329
431
 
330
432
  // Framework detection
331
433
  detectFramework(packageJsonPath?);
332
- detectFrameworkFromWindow(window);
333
- getFrameworkTips(framework);
434
+ detectFrameworkFromWindow(); // browser only
435
+ getFrameworkTips(framework, issues);
334
436
 
335
437
  // Formatting utilities
336
438
  formatDuration(ms);
@@ -344,19 +446,30 @@ formatRenderTime(ms);
344
446
  ### Manual Injection
345
447
 
346
448
  ```typescript
347
- import { BrowserScanner, Overlay } from '@oxog/react-check';
449
+ import { installReactCheck } from '@oxog/react-check';
348
450
 
349
- const scanner = new BrowserScanner(window, config);
350
- const overlay = new Overlay(config);
451
+ // Must run before React loads; connects to a CLI started with --proxy or a scan
452
+ const injector = installReactCheck(window);
351
453
 
352
- scanner.on('render', (info) => {
353
- overlay.update(info);
354
- });
454
+ // Later: restores the React DevTools hook, removes the overlay, stops reconnecting
455
+ injector?.destroy();
456
+ ```
355
457
 
356
- scanner.start();
357
- overlay.show();
458
+ Or use the scanner directly:
459
+
460
+ ```typescript
461
+ import { BrowserScanner } from '@oxog/react-check';
462
+
463
+ const scanner = new BrowserScanner({ exclude: ['DevTools*'] }, window);
464
+ scanner.on('render', ({ render, element }) => {
465
+ console.log(render.componentName, render.necessary ? '' : '(unnecessary)', element);
466
+ });
467
+ scanner.start(); // hooks into React; stop() unhooks
358
468
  ```
359
469
 
470
+ Only components that actually rendered in a commit are reported; React.memo bail-outs and
471
+ untouched subtrees are not counted.
472
+
360
473
  ### Proxy Server
361
474
 
362
475
  ```typescript
@@ -370,7 +483,7 @@ const proxy = new ProxyServer({
370
483
  });
371
484
 
372
485
  await wsServer.start();
373
- await proxy.start();
486
+ await proxy.start(); // serves the bundled browser script at /__reactcheck__/scanner.js
374
487
 
375
488
  // Open http://localhost:8080 in browser
376
489
  ```
@@ -398,6 +511,8 @@ src/
398
511
  │ ├── stats.ts # Statistics collector
399
512
  │ └── fiber.ts # React fiber utilities
400
513
  ├── browser/ # Browser-side modules
514
+ │ ├── injector.ts # Page injector (side-effect free)
515
+ │ ├── inject.ts # IIFE entry -> dist/browser-inject.global.js
401
516
  │ ├── scanner.ts # Browser scanner
402
517
  │ └── overlay.ts # Visual overlay
403
518
  ├── server/ # Node.js server modules