@oxog/react-check 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -0
- package/README.md +142 -50
- package/dist/browser-inject.global.js +13 -13
- package/dist/chain.cjs +8 -531
- package/dist/chain.cjs.map +1 -1
- package/dist/chain.d.cts +2 -2
- package/dist/chain.d.ts +2 -2
- package/dist/chain.js +2 -533
- package/dist/chain.js.map +1 -1
- package/dist/chunk-27R56V2S.js +473 -0
- package/dist/chunk-27R56V2S.js.map +1 -0
- package/dist/chunk-3K2AER5M.cjs +356 -0
- package/dist/chunk-3K2AER5M.cjs.map +1 -0
- package/dist/chunk-7R4KKJTW.cjs +255 -0
- package/dist/chunk-7R4KKJTW.cjs.map +1 -0
- package/dist/chunk-7YYMP3PP.js +723 -0
- package/dist/chunk-7YYMP3PP.js.map +1 -0
- package/dist/chunk-DWM55ACO.cjs +294 -0
- package/dist/chunk-DWM55ACO.cjs.map +1 -0
- package/dist/chunk-G7YVIPS7.cjs +475 -0
- package/dist/chunk-G7YVIPS7.cjs.map +1 -0
- package/dist/chunk-GE2ZX7I7.cjs +727 -0
- package/dist/chunk-GE2ZX7I7.cjs.map +1 -0
- package/dist/chunk-GS7T56RP.cjs +9 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -0
- package/dist/chunk-IM6OG2IC.js +338 -0
- package/dist/chunk-IM6OG2IC.js.map +1 -0
- package/dist/chunk-RQYHXWUC.js +292 -0
- package/dist/chunk-RQYHXWUC.js.map +1 -0
- package/dist/chunk-WLN7ZVO4.js +253 -0
- package/dist/chunk-WLN7ZVO4.js.map +1 -0
- package/dist/cli.js +975 -204
- package/dist/cli.js.map +1 -1
- package/dist/detect.cjs +22 -324
- package/dist/detect.cjs.map +1 -1
- package/dist/detect.d.cts +8 -2
- package/dist/detect.d.ts +8 -2
- package/dist/detect.js +1 -324
- package/dist/detect.js.map +1 -1
- package/dist/{event-emitter-CxKUDo9q.d.cts → event-emitter-BVYUPYLd.d.cts} +3 -2
- package/dist/{event-emitter-CxKUDo9q.d.ts → event-emitter-BVYUPYLd.d.ts} +3 -2
- package/dist/fix.cjs +6 -715
- package/dist/fix.cjs.map +1 -1
- package/dist/fix.d.cts +2 -2
- package/dist/fix.d.ts +2 -2
- package/dist/fix.js +2 -719
- package/dist/fix.js.map +1 -1
- package/dist/index.cjs +1238 -2987
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +166 -50
- package/dist/index.d.ts +166 -50
- package/dist/index.js +1137 -2959
- package/dist/index.js.map +1 -1
- package/dist/{scanner-Cc2187fH.d.ts → scanner-D0mBQGTx.d.ts} +23 -3
- package/dist/{scanner-S7BtVIpW.d.cts → scanner-DUBgwztZ.d.cts} +23 -3
- package/dist/scanner.cjs +8 -1652
- package/dist/scanner.cjs.map +1 -1
- package/dist/scanner.d.cts +3 -3
- package/dist/scanner.d.ts +3 -3
- package/dist/scanner.js +4 -1656
- package/dist/scanner.js.map +1 -1
- package/dist/{types-DuZyBVVV.d.cts → types-BZ3OeZ-5.d.cts} +28 -10
- package/dist/{types-DuZyBVVV.d.ts → types-BZ3OeZ-5.d.ts} +28 -10
- package/package.json +16 -9
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,92 @@ 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.0] - 2026-11-30
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **Importing the package crashed in Node.js.** `import`/`require('@oxog/react-check')` threw
|
|
13
|
+
`ReferenceError: window is not defined` in 1.2.0 (ESM and CommonJS) because the browser
|
|
14
|
+
injection script, including its self-installing IIFE, was bundled into the main entry. The
|
|
15
|
+
entry is now side-effect free and safe for Node.js, SSR and test runners; the IIFE only lives
|
|
16
|
+
in `dist/browser-inject.global.js`.
|
|
17
|
+
- **Render counts were wrong.** Every commit was processed twice (the injected hook and
|
|
18
|
+
`BrowserScanner.start()` both forwarded it) and the whole fiber tree was walked each time, so
|
|
19
|
+
every mounted component was reported as rendering on every commit (e.g. a memoized child that
|
|
20
|
+
rendered once was reported 61 times and flagged critical). Only fibers that actually rendered
|
|
21
|
+
are counted now (React's `PerformedWork` flag, untouched subtrees skipped), `React.memo`
|
|
22
|
+
wrappers are not double counted, and "unnecessary" renders are judged against the previous
|
|
23
|
+
committed fiber instead of stale state. Works with development and production React builds.
|
|
24
|
+
- `quickScan()` never worked: it launched the browser without the ReactCheck script and always
|
|
25
|
+
failed with `REACT_NOT_FOUND`. It now runs the same pipeline as the CLI (internal WebSocket
|
|
26
|
+
server on a free port, injected script, scanner) and returns a real report.
|
|
27
|
+
- `--proxy` mode printed a `<script>` URL that nothing served. The CLI now starts the proxy on
|
|
28
|
+
`--port + 1`, which serves the real browser script and injects it at the start of `<head>`.
|
|
29
|
+
`ProxyServer` also served a stub instead of the scanner, injected after `</body>` (too late
|
|
30
|
+
for React) and forwarded `Transfer-Encoding: chunked` together with `Content-Length`, which
|
|
31
|
+
produced invalid HTTP responses for chunked upstream pages.
|
|
32
|
+
- Config file values (`thresholds`, `report.output`, `report.formats`) were always overridden
|
|
33
|
+
by the CLI's built-in defaults. Precedence is now: command-line flag > config file > default.
|
|
34
|
+
Config `include`/`exclude` and `rules` are applied too.
|
|
35
|
+
- Config file lookup (`findUp`) only checked the current directory and its parent; it now
|
|
36
|
+
walks up to the filesystem root.
|
|
37
|
+
- `react-check detect` and `react-check report` (documented in the README) did not exist: the
|
|
38
|
+
words were treated as URLs and a browser was launched at `http://detect`. Both commands are
|
|
39
|
+
implemented.
|
|
40
|
+
- `--format html,json` (documented) was rejected; comma-separated formats are accepted.
|
|
41
|
+
- Unknown options and options missing a value were silently ignored (`--duraton 30` scanned
|
|
42
|
+
forever in CI); they now exit with code 2. Non-http(s) targets are rejected.
|
|
43
|
+
- `--version` printed 1.1.6 and reports were stamped `1.1.6`; the exported `VERSION` was
|
|
44
|
+
`1.0.0`. All now come from one constant that a test keeps equal to `package.json`.
|
|
45
|
+
- "Avg FPS" was renders per second (e.g. 232). FPS is now measured in the page with
|
|
46
|
+
`requestAnimationFrame`; `Scanner.recordFps()` accepts external samples.
|
|
47
|
+
- `createScanner({ include, exclude })` ignored both options.
|
|
48
|
+
- Framework detection: `rsc` was reported for every Next.js version (and `^9.5.0` was parsed
|
|
49
|
+
as 95), Gatsby 4 was reported as `v5`, and `middleware.js` / `vite.config.js` were never
|
|
50
|
+
detected (`Promise || Promise`).
|
|
51
|
+
- Render chains were missed at random when two renders 1 ms apart straddled a 16 ms bucket.
|
|
52
|
+
- Browser cleanup: `ReactCheckInjector.destroy()` reconnected right after closing the socket,
|
|
53
|
+
left the DevTools hook wrapped and timers running; `Overlay.destroy()` left document
|
|
54
|
+
listeners behind and a pending init retry could re-create the overlay; `BrowserScanner.stop()`
|
|
55
|
+
kept processing commits when it had installed its own hook and restored a bound copy of the
|
|
56
|
+
original hook function. The offline message queue is now bounded.
|
|
57
|
+
- Very wide component trees (100k siblings) overflowed the stack; traversal is iterative.
|
|
58
|
+
- Component names and chain triggers were inserted into the overlay HTML unescaped.
|
|
59
|
+
- The WebSocket server buffered frames of any announced size; frames over 16 MiB now close
|
|
60
|
+
the connection. Handler exceptions are no longer hidden by the JSON parse `try`.
|
|
61
|
+
- `Scanner` timers no longer keep a Node.js process alive.
|
|
62
|
+
- `EventEmitter<T>` rejected plain `interface` event maps (index signature required).
|
|
63
|
+
- `FiberType` rejected class components; `ReactDevToolsHook` lacked the optional React hooks;
|
|
64
|
+
`RuleOptions` only allowed three rule ids that did not exist.
|
|
65
|
+
- A leftover debug `console.log` ("Overlay check") was printed during every scan.
|
|
66
|
+
|
|
67
|
+
### Added
|
|
68
|
+
|
|
69
|
+
- `react-check detect [path] [--json]` and `react-check report <file.json>` commands.
|
|
70
|
+
- Exit codes are documented: `0` clean, `1` critical issues found, `2` usage or runtime error.
|
|
71
|
+
- `quickScan` options `thresholds`, `include`, `exclude`, `port`, `browserArgs`.
|
|
72
|
+
- `installReactCheck(window)`, `loadInjectionScript(port)`, `matchComponentPattern()` and
|
|
73
|
+
`Scanner.recordFps()` / `isComponentIncluded()` exports; `WebSocketServer` and
|
|
74
|
+
`ProxyServer` accept port `0` and report the real port.
|
|
75
|
+
- `"./package.json"` export.
|
|
76
|
+
|
|
77
|
+
### Changed
|
|
78
|
+
|
|
79
|
+
- Puppeteer is only auto-installed in an interactive terminal outside CI. In CI, without a
|
|
80
|
+
TTY, or with `REACTCHECK_NO_INSTALL=1` the scan exits with code 2 and explains what to
|
|
81
|
+
install. Missing `browser-inject.global.js` is now an error instead of a silent no-op script.
|
|
82
|
+
- Shared code is split into chunks, so `@oxog/react-check` and its subpath entries
|
|
83
|
+
(`/scanner`, `/chain`, `/fix`, `/detect`) share one copy of each class (`instanceof` works
|
|
84
|
+
across entries).
|
|
85
|
+
- `--output` or `--format` imply `--report`.
|
|
86
|
+
- `BrowserLauncher`/`ProxyServer` no longer print debug-level logs.
|
|
87
|
+
- Fix-suggestion rule ids in generated configs are the real ones
|
|
88
|
+
(`unnecessary-rerenders-memo`, `function-prop-stability`, ...).
|
|
89
|
+
- Tooling: lint covers `src` and `tests` with zero warnings, tests are type-checked, coverage
|
|
90
|
+
thresholds are enforced, `npm run test:package` verifies the packed archive (ESM, CJS,
|
|
91
|
+
NodeNext types, CLI bins, and an end-to-end scan when Chrome is available), CI runs on
|
|
92
|
+
Node 18–24 and publishing is a manual workflow.
|
|
93
|
+
|
|
8
94
|
## [1.2.0] - 2025-12-31
|
|
9
95
|
|
|
10
96
|
### 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/
|
|
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,26 @@ 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
|
-
|
|
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 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.
|
|
42
|
+
- Importing `@oxog/react-check` has no side effects and does not touch `window`, so it is safe
|
|
43
|
+
in Node.js scripts, SSR bundles and test runners. The browser part ships separately as
|
|
44
|
+
`dist/browser-inject.global.js` and is injected by the CLI.
|
|
45
|
+
|
|
35
46
|
## Quick Start
|
|
36
47
|
|
|
37
48
|
### CLI Usage
|
|
@@ -42,11 +53,11 @@ Scan a React application:
|
|
|
42
53
|
npx react-check scan http://localhost:3000
|
|
43
54
|
```
|
|
44
55
|
|
|
45
|
-
With options:
|
|
56
|
+
With options (durations are in **seconds**):
|
|
46
57
|
|
|
47
58
|
```bash
|
|
48
59
|
npx react-check scan http://localhost:3000 \
|
|
49
|
-
--duration
|
|
60
|
+
--duration 60 \
|
|
50
61
|
--output ./reports \
|
|
51
62
|
--format html,json \
|
|
52
63
|
--headless
|
|
@@ -64,15 +75,25 @@ WebUI + custom port:
|
|
|
64
75
|
npx react-check scan http://localhost:3000 --webui --webui-port 8080
|
|
65
76
|
```
|
|
66
77
|
|
|
78
|
+
In CI:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npx react-check http://localhost:3000 --silent --headless --duration 30 --format json --output ./reactcheck-reports
|
|
82
|
+
```
|
|
83
|
+
|
|
67
84
|
### Programmatic Usage
|
|
68
85
|
|
|
86
|
+
`Scanner` aggregates render events (`RenderInfo`) that you feed it, computes per-component
|
|
87
|
+
statistics, severities, render chains and fix suggestions. The CLI and `quickScan()` feed it
|
|
88
|
+
from the browser; you can also feed it yourself.
|
|
89
|
+
|
|
69
90
|
```typescript
|
|
70
91
|
import { createScanner, generateHTMLReport } from '@oxog/react-check';
|
|
71
92
|
|
|
72
93
|
// Create a scanner instance
|
|
73
94
|
const scanner = createScanner({
|
|
74
95
|
thresholds: { critical: 50, warning: 20 },
|
|
75
|
-
include: ['MyComponent*'],
|
|
96
|
+
include: ['MyComponent*'], // glob patterns: * and ?
|
|
76
97
|
exclude: ['DebugPanel'],
|
|
77
98
|
});
|
|
78
99
|
|
|
@@ -81,16 +102,24 @@ scanner.on('render', (info) => {
|
|
|
81
102
|
console.log(`${info.componentName} rendered in ${info.renderTime}ms`);
|
|
82
103
|
});
|
|
83
104
|
|
|
84
|
-
// Start scanning
|
|
85
105
|
scanner.start();
|
|
106
|
+
scanner.addRender({
|
|
107
|
+
componentName: 'MyComponentList',
|
|
108
|
+
renderCount: 1,
|
|
109
|
+
renderTime: 2.4,
|
|
110
|
+
phase: 'update',
|
|
111
|
+
necessary: false,
|
|
112
|
+
timestamp: Date.now(),
|
|
113
|
+
});
|
|
114
|
+
scanner.stop();
|
|
86
115
|
|
|
87
|
-
//
|
|
88
|
-
const report = scanner.getReport();
|
|
89
|
-
const html = generateHTMLReport(report);
|
|
116
|
+
console.log(scanner.getSnapshot()); // per-component stats, sorted by severity
|
|
90
117
|
```
|
|
91
118
|
|
|
92
119
|
### Quick Scan API
|
|
93
120
|
|
|
121
|
+
Requires Puppeteer and Chrome. `duration` is in milliseconds here.
|
|
122
|
+
|
|
94
123
|
```typescript
|
|
95
124
|
import { quickScan } from '@oxog/react-check';
|
|
96
125
|
|
|
@@ -104,29 +133,68 @@ const report = await quickScan('http://localhost:3000', {
|
|
|
104
133
|
console.log(`Found ${report.summary.criticalIssues} critical issues`);
|
|
105
134
|
```
|
|
106
135
|
|
|
136
|
+
`quickScan` throws a `ReactCheckError` with code `BROWSER_LAUNCH_FAILED` when Puppeteer or
|
|
137
|
+
the page is unavailable and `REACT_NOT_FOUND` when no React render was observed.
|
|
138
|
+
|
|
107
139
|
## CLI Commands
|
|
108
140
|
|
|
109
|
-
### `scan <url>`
|
|
141
|
+
### `scan <url>` (default command)
|
|
110
142
|
|
|
111
|
-
Scan a React application for performance issues.
|
|
143
|
+
Scan a React application for performance issues. `react-check <url>` is the same as
|
|
144
|
+
`react-check scan <url>`; without a URL in an interactive terminal a setup wizard starts.
|
|
112
145
|
|
|
113
146
|
```bash
|
|
114
147
|
react-check scan <url> [options]
|
|
115
148
|
|
|
116
|
-
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
|
|
120
|
-
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
--
|
|
124
|
-
--
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
149
|
+
General:
|
|
150
|
+
-h, --help Show help message
|
|
151
|
+
-v, --version Show version number
|
|
152
|
+
--verbose Include detailed output
|
|
153
|
+
-c, --config <path> Config file path
|
|
154
|
+
|
|
155
|
+
Mode:
|
|
156
|
+
-P, --proxy Start a proxy on <port + 1> that injects ReactCheck into any browser
|
|
157
|
+
-t, --tui Terminal UI only (no browser)
|
|
158
|
+
-s, --silent No TUI (for CI/CD)
|
|
159
|
+
--headless Run browser in headless mode
|
|
160
|
+
-w, --watch Keep scanning until quit
|
|
161
|
+
-W, --webui Enable WebUI dashboard
|
|
162
|
+
--webui-port <port> WebUI dashboard port (default: 3199)
|
|
163
|
+
|
|
164
|
+
Report:
|
|
165
|
+
-r, --report Generate reports (implied by --format / --output)
|
|
166
|
+
-f, --format <formats> html, json, md, all or a comma-separated list (default: all)
|
|
167
|
+
-o, --output <dir> Report output directory (default: ./reactcheck-reports)
|
|
168
|
+
--fix Show fix suggestions
|
|
169
|
+
|
|
170
|
+
Thresholds:
|
|
171
|
+
--threshold-critical <n> Render count for critical (default: 50)
|
|
172
|
+
--threshold-warning <n> Render count for warning (default: 20)
|
|
173
|
+
--fps-threshold <n> FPS drop threshold (default: 30)
|
|
174
|
+
|
|
175
|
+
Network:
|
|
176
|
+
-p, --port <port> WebSocket server port (default: 3099)
|
|
177
|
+
-d, --duration <seconds> Stop after this many seconds (otherwise Ctrl+C / q)
|
|
128
178
|
```
|
|
129
179
|
|
|
180
|
+
Unknown options are rejected. Options given on the command line override the config file,
|
|
181
|
+
which overrides the defaults.
|
|
182
|
+
|
|
183
|
+
#### Exit codes
|
|
184
|
+
|
|
185
|
+
| Code | Meaning |
|
|
186
|
+
|------|---------|
|
|
187
|
+
| `0` | Scan finished without critical issues |
|
|
188
|
+
| `1` | Scan finished and found critical issues |
|
|
189
|
+
| `2` | Invalid usage, or the scan could not run (browser, port or page problems) |
|
|
190
|
+
|
|
191
|
+
#### Proxy mode
|
|
192
|
+
|
|
193
|
+
`react-check <url> --proxy` starts a proxy on `--port + 1` (default 3100). Open
|
|
194
|
+
`http://localhost:3100/<path>` in any browser; the proxy injects ReactCheck into every HTML
|
|
195
|
+
page. Alternatively add `<script src="http://localhost:3100/__reactcheck__/scanner.js"></script>`
|
|
196
|
+
to your page before React loads.
|
|
197
|
+
|
|
130
198
|
### `report <input>`
|
|
131
199
|
|
|
132
200
|
Generate reports from a JSON scan result.
|
|
@@ -137,7 +205,8 @@ react-check report scan-results.json --format html,md --output ./reports
|
|
|
137
205
|
|
|
138
206
|
### `detect [path]`
|
|
139
207
|
|
|
140
|
-
Detect the React framework
|
|
208
|
+
Detect the React framework of a project (path to a directory or a `package.json`; `--json`
|
|
209
|
+
prints machine-readable output).
|
|
141
210
|
|
|
142
211
|
```bash
|
|
143
212
|
react-check detect ./my-react-app
|
|
@@ -252,26 +321,36 @@ GitHub-friendly Markdown report suitable for issue tracking or documentation.
|
|
|
252
321
|
|
|
253
322
|
## Configuration
|
|
254
323
|
|
|
255
|
-
|
|
324
|
+
ReactCheck looks for `reactcheck.config.{js,mjs,cjs,json}`, `.reactcheckrc`,
|
|
325
|
+
`.reactcheckrc.js` or `.reactcheckrc.json` in the current directory and its parents
|
|
326
|
+
(`react-check init` creates one).
|
|
256
327
|
|
|
257
328
|
```typescript
|
|
258
|
-
|
|
259
|
-
|
|
329
|
+
/** @type {import('@oxog/react-check').ReactCheckConfig} */
|
|
330
|
+
export default {
|
|
331
|
+
// Component name patterns (* and ?)
|
|
332
|
+
include: [],
|
|
333
|
+
exclude: ['DebugPanel'],
|
|
260
334
|
thresholds: {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
335
|
+
critical: 50, // render count for critical severity
|
|
336
|
+
warning: 20, // render count for warning severity
|
|
337
|
+
fps: 30, // FPS drop threshold
|
|
338
|
+
},
|
|
339
|
+
report: {
|
|
340
|
+
formats: ['html', 'json'],
|
|
341
|
+
output: './reactcheck-reports',
|
|
342
|
+
},
|
|
343
|
+
// Fix-suggestion rules: 'off' disables a rule
|
|
344
|
+
rules: {
|
|
345
|
+
'state-too-high': 'off',
|
|
346
|
+
},
|
|
347
|
+
};
|
|
273
348
|
```
|
|
274
349
|
|
|
350
|
+
Rule ids: `unnecessary-rerenders-memo`, `expensive-computation-memo`,
|
|
351
|
+
`function-prop-stability`, `context-over-subscription`, `state-too-high`,
|
|
352
|
+
`extract-heavy-child`.
|
|
353
|
+
|
|
275
354
|
### Fix Categories
|
|
276
355
|
|
|
277
356
|
ReactCheck provides fix suggestions in these categories:
|
|
@@ -344,19 +423,30 @@ formatRenderTime(ms);
|
|
|
344
423
|
### Manual Injection
|
|
345
424
|
|
|
346
425
|
```typescript
|
|
347
|
-
import {
|
|
426
|
+
import { installReactCheck } from '@oxog/react-check';
|
|
348
427
|
|
|
349
|
-
|
|
350
|
-
const
|
|
428
|
+
// Must run before React loads; connects to a CLI started with --proxy or a scan
|
|
429
|
+
const injector = installReactCheck(window);
|
|
351
430
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
431
|
+
// Later: restores the React DevTools hook, removes the overlay, stops reconnecting
|
|
432
|
+
injector?.destroy();
|
|
433
|
+
```
|
|
355
434
|
|
|
356
|
-
scanner
|
|
357
|
-
|
|
435
|
+
Or use the scanner directly:
|
|
436
|
+
|
|
437
|
+
```typescript
|
|
438
|
+
import { BrowserScanner } from '@oxog/react-check';
|
|
439
|
+
|
|
440
|
+
const scanner = new BrowserScanner({ exclude: ['DevTools*'] }, window);
|
|
441
|
+
scanner.on('render', ({ render, element }) => {
|
|
442
|
+
console.log(render.componentName, render.necessary ? '' : '(unnecessary)', element);
|
|
443
|
+
});
|
|
444
|
+
scanner.start(); // hooks into React; stop() unhooks
|
|
358
445
|
```
|
|
359
446
|
|
|
447
|
+
Only components that actually rendered in a commit are reported; React.memo bail-outs and
|
|
448
|
+
untouched subtrees are not counted.
|
|
449
|
+
|
|
360
450
|
### Proxy Server
|
|
361
451
|
|
|
362
452
|
```typescript
|
|
@@ -370,7 +460,7 @@ const proxy = new ProxyServer({
|
|
|
370
460
|
});
|
|
371
461
|
|
|
372
462
|
await wsServer.start();
|
|
373
|
-
await proxy.start();
|
|
463
|
+
await proxy.start(); // serves the bundled browser script at /__reactcheck__/scanner.js
|
|
374
464
|
|
|
375
465
|
// Open http://localhost:8080 in browser
|
|
376
466
|
```
|
|
@@ -398,6 +488,8 @@ src/
|
|
|
398
488
|
│ ├── stats.ts # Statistics collector
|
|
399
489
|
│ └── fiber.ts # React fiber utilities
|
|
400
490
|
├── browser/ # Browser-side modules
|
|
491
|
+
│ ├── injector.ts # Page injector (side-effect free)
|
|
492
|
+
│ ├── inject.ts # IIFE entry -> dist/browser-inject.global.js
|
|
401
493
|
│ ├── scanner.ts # Browser scanner
|
|
402
494
|
│ └── overlay.ts # Visual overlay
|
|
403
495
|
├── server/ # Node.js server modules
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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=`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -6,7 +6,7 @@ var ReactCheckInjector=(function(exports){'use strict';var E=Object.defineProper
|
|
|
6
6
|
height: 100%;
|
|
7
7
|
pointer-events: none;
|
|
8
8
|
z-index: 2147483647;
|
|
9
|
-
`,this.shadowRoot=this.host.attachShadow({mode:"closed"}),this.injectStyles(),this.config.showToolbar&&this.createToolbar(),document.body.appendChild(this.host),this.scrollHandler=()=>this.onScroll(),window.addEventListener("scroll",this.scrollHandler,{passive:true,capture:true}),window.addEventListener("resize",this.scrollHandler,{passive:true}),this.statsInterval=setInterval(()=>this.updateStats(),500),console.log("[ReactCheck] Overlay initialized");}}destroy(){this.statsInterval&&(clearInterval(this.statsInterval),this.statsInterval=null),this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler,{capture:true}),window.removeEventListener("resize",this.scrollHandler),this.scrollHandler=null);for(let e of this.fadeTimeouts.values())clearTimeout(e);this.fadeTimeouts.clear(),this.trackedComponents.clear(),this.renderChains=[],this.host&&(this.host.remove(),this.host=null),this.shadowRoot=null,this.toolbar=null;}onScroll(){this.scrollUpdatePending||(this.scrollUpdatePending=true,requestAnimationFrame(()=>{this.updateAllPositions(),this.scrollUpdatePending=false;}));}updateAllPositions(){for(let e of this.trackedComponents.values()){let t=e.element.getBoundingClientRect();if(t.width===0||t.height===0){e.highlightEl.style.display="none";continue}e.highlightEl.style.display=this.config.highlightRenders?"block":"none",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`;}}injectStyles(){if(!this.shadowRoot)return;let e=document.createElement("style");e.textContent=`
|
|
9
|
+
`,this.shadowRoot=this.host.attachShadow({mode:"closed"}),this.injectStyles(),this.config.showToolbar&&this.createToolbar(),document.body.appendChild(this.host),this.scrollHandler=()=>this.onScroll(),window.addEventListener("scroll",this.scrollHandler,{passive:true,capture:true}),window.addEventListener("resize",this.scrollHandler,{passive:true}),this.statsInterval=setInterval(()=>this.updateStats(),500),console.log("[ReactCheck] Overlay initialized");}}destroy(){this.initRetryTimer!==null&&(clearTimeout(this.initRetryTimer),this.initRetryTimer=null),this.documentListeners&&(this.documentListeners.abort(),this.documentListeners=null),this.statsInterval&&(clearInterval(this.statsInterval),this.statsInterval=null),this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler,{capture:true}),window.removeEventListener("resize",this.scrollHandler),this.scrollHandler=null);for(let e of this.fadeTimeouts.values())clearTimeout(e);this.fadeTimeouts.clear(),this.trackedComponents.clear(),this.renderChains=[],this.host&&(this.host.remove(),this.host=null),this.shadowRoot=null,this.toolbar=null;}onScroll(){this.scrollUpdatePending||(this.scrollUpdatePending=true,requestAnimationFrame(()=>{this.updateAllPositions(),this.scrollUpdatePending=false;}));}updateAllPositions(){for(let e of this.trackedComponents.values()){let t=e.element.getBoundingClientRect();if(t.width===0||t.height===0){e.highlightEl.style.display="none";continue}e.highlightEl.style.display=this.config.highlightRenders?"block":"none",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`;}}injectStyles(){if(!this.shadowRoot)return;let e=document.createElement("style");e.textContent=`
|
|
10
10
|
* {
|
|
11
11
|
box-sizing: border-box;
|
|
12
12
|
margin: 0;
|
|
@@ -753,39 +753,39 @@ var ReactCheckInjector=(function(exports){'use strict';var E=Object.defineProper
|
|
|
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",
|
|
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=`
|
|
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
|
|
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=`
|
|
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
|
|
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 `
|
|
769
769
|
<div class="component-item">
|
|
770
|
-
<div class="component-severity" style="background: ${
|
|
770
|
+
<div class="component-severity" style="background: ${o}"></div>
|
|
771
771
|
<div class="component-info">
|
|
772
|
-
<div class="component-name">${n}</div>
|
|
773
|
-
<div class="component-meta">${
|
|
772
|
+
<div class="component-name">${x(n)}</div>
|
|
773
|
+
<div class="component-meta">${s}ms avg \xB7 ${c}</div>
|
|
774
774
|
</div>
|
|
775
|
-
<div class="component-count" style="color: ${
|
|
775
|
+
<div class="component-count" style="color: ${o}">${i.count}</div>
|
|
776
776
|
</div>
|
|
777
777
|
`}).join("");}updateChainList(){if(!this.shadowRoot)return;let e=this.shadowRoot.getElementById("rc-chain-list");if(e){if(this.renderChains.length===0){e.innerHTML=`
|
|
778
778
|
<div class="empty-state">
|
|
779
779
|
<svg viewBox="0 0 24 24"><path d="M17 7h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1 0 1.43-.98 2.63-2.31 2.98l1.46 1.46C20.88 15.61 22 13.95 22 12c0-2.76-2.24-5-5-5z"/></svg>
|
|
780
780
|
<div>No render chains detected</div>
|
|
781
781
|
</div>
|
|
782
|
-
`;return}e.innerHTML=this.renderChains.slice(0,10).map(t=>{let n=t.chain.map(i=>`<span class="chain-node">${i}</span>`).join('<span class="chain-arrow">\u2192</span>');return `
|
|
782
|
+
`;return}e.innerHTML=this.renderChains.slice(0,10).map(t=>{let n=t.chain.map(i=>`<span class="chain-node">${x(i)}</span>`).join('<span class="chain-arrow">\u2192</span>');return `
|
|
783
783
|
<div class="chain-item">
|
|
784
784
|
<div class="chain-header">
|
|
785
|
-
<span class="chain-trigger">${t.trigger}</span>
|
|
785
|
+
<span class="chain-trigger">${x(t.trigger)}</span>
|
|
786
786
|
<span class="chain-count">${t.chain.length} components</span>
|
|
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(u,"MAX_HIGHLIGHTS",50),l(u,"SKIP_COMPONENTS",new Set(["ForwardRef","Anonymous","Unknown","Fragment","Suspense","Context.Provider","Context.Consumer","Profiler","Root","#text"]));var v=u;var H={trackUnnecessary:true,fpsThreshold:30,highlightRenders:true,animationSpeed:"fast"},y=class extends m{constructor(t={},n){super();l(this,"config");l(this,"running",false);l(this,"reactVersion","unknown");l(this,"prevFiberStates",new WeakMap);l(this,"renderCounts",new Map);l(this,"originalOnCommitFiberRoot",null);l(this,"win");l(this,"overlay",null);this.config={...H,...t},this.win=n??(typeof window<"u"?window:{});}getDOMElement(t){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 v({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(),this.prevFiberStates=new WeakMap;}hookIntoReact(){let t=this.win.__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!t){this.installHook();return}this.originalOnCommitFiberRoot=t.onCommitFiberRoot.bind(t),t.onCommitFiberRoot=(n,i,a)=>{this.originalOnCommitFiberRoot&&this.originalOnCommitFiberRoot(n,i,a),this.processCommit(i.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,a)=>{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){this.walkFiber(t,null);}walkFiber(t,n){t&&(x(t)&&(this.processFiber(t,n),n=b(t)),this.walkFiber(t.child,n),this.walkFiber(t.sibling,n));}processFiber(t,n){let i=b(t);if(this.shouldFilterComponent(i))return;let a=this.prevFiberStates.get(t),r=C(t,a?"update":"mount",a?.props,a?.state),d=(this.renderCounts.get(i)??0)+1;this.renderCounts.set(i,d),r.renderCount=d,this.prevFiberStates.set(t,{props:t.memoizedProps,state:t.memoizedState});let p=this.getDOMElement(t);this.overlay&&this.config.highlightRenders&&(p?this.overlay.highlight(r,p):this.overlay.recordRender(r)),this.emit("render",{render:r,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(o=>this.matchPattern(t,o))||i&&i.length>0&&i.some(o=>this.matchPattern(t,o)))}matchPattern(t,n){let i=n.replace(/\*/g,".*").replace(/\?/g,".");try{return new RegExp(`^${i}$`).test(t)}catch{return false}}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 w=class{constructor(){l(this,"scanner");l(this,"overlay");l(this,"ws",null);l(this,"wsPort");l(this,"reconnectTimeout",null);l(this,"initialized",false);l(this,"messageQueue",[]);let e=window;this.wsPort=e.__REACTCHECK_PORT__??3099,this.scanner=new y({trackUnnecessary:true,highlightRenders:true,animationSpeed:"fast"},e),this.overlay=new v({enabled:true,highlightRenders:true,showToolbar:true});}init(){if(this.initialized)return;this.initialized=true,this.overlay.init(),this.setupScannerEvents(),this.connect();let e=this._markHookReady;e&&e(),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"}});});}connect(){this.ws&&this.ws.close();try{this.ws=new WebSocket(`ws://localhost:${this.wsPort}`),this.ws.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();},this.ws.onmessage=e=>{try{let t=JSON.parse(e.data);this.handleMessage(t);}catch(t){console.warn("[ReactCheck] Invalid message:",t);}},this.ws.onerror=e=>{console.warn("[ReactCheck] WebSocket error:",e);},this.ws.onclose=()=>{console.log("[ReactCheck] Disconnected from CLI"),this.scheduleReconnect();};}catch(e){console.warn("[ReactCheck] Failed to connect:",e),this.scheduleReconnect();}}scheduleReconnect(){this.reconnectTimeout||(this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,console.log("[ReactCheck] Attempting to reconnect..."),this.connect();},2e3));}handleMessage(e){switch(e.type){case "start":this.scanner.start(),this.overlay.show();break;case "stop":this.scanner.stop();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.ws&&this.ws.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(e)):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=[];}}destroy(){this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.ws&&this.ws.close(),this.scanner.stop(),this.overlay.destroy(),this.initialized=false;}};(function(){let c=window.location.href;if(c==="about:blank"||c.startsWith("chrome://")||c.startsWith("chrome-extension://")||c.startsWith("devtools://"))return;let e=window;if(e.__REACTCHECK_INJECTED__)return;e.__REACTCHECK_INJECTED__=true;let t=new w,n=[],i=false,a=r=>{if(i){let s=t.scanner;if(s){let d=r.current;s.processCommit(d);}}else n.push({rendererID:0,root:r});},o=()=>{i=true;let r=t.scanner;if(r){for(let{root:s}of n)r.processCommit(s.current);n.length=0;}};if(e.__REACT_DEVTOOLS_GLOBAL_HOOK__){let r=e.__REACT_DEVTOOLS_GLOBAL_HOOK__,s=r.onCommitFiberRoot.bind(r);r.onCommitFiberRoot=(d,p,g)=>{s(d,p,g),a(p);},console.log("[ReactCheck] Wrapped existing DevTools hook");}else {let r={renderers:new Map,supportsFiber:true,inject:function(s){let d=this.renderers.size+1;return this.renderers.set(d,s),d},onCommitFiberRoot:function(s,d){a(d);},onCommitFiberUnmount:function(){}};e.__REACT_DEVTOOLS_GLOBAL_HOOK__=r,console.log("[ReactCheck] DevTools hook installed");}t._markHookReady=()=>{o();},document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{t.init();}):t.init(),window.__REACTCHECK__=t;})();
|
|
791
|
-
|
|
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);
|
|
791
|
+
})();
|