@oxog/react-check 1.1.6 → 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 +115 -1
- package/README.md +149 -51
- package/dist/browser-inject.global.js +705 -158
- 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 +1443 -207
- 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 +2380 -3308
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +255 -88
- package/dist/index.d.ts +255 -88
- package/dist/index.js +2289 -3290
- package/dist/index.js.map +1 -1
- package/dist/{scanner-CTBraprQ.d.ts → scanner-D0mBQGTx.d.ts} +23 -3
- package/dist/{scanner-5j2LEM-q.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-xAXT9cir.d.cts → types-BZ3OeZ-5.d.cts} +28 -10
- package/dist/{types-xAXT9cir.d.ts → types-BZ3OeZ-5.d.ts} +28 -10
- package/package.json +20 -11
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { F as FiberNode, R as RenderInfo, a as ReactDevToolsHook, S as SessionReport, b as ReportOptions, C as CLIMessage, B as BrowserMessage, c as ScannerConfig, W as WindowWithReactDevTools } from './types-
|
|
2
|
-
export {
|
|
3
|
-
import { S as Scanner } from './scanner-
|
|
4
|
-
export { b as ScannerEvents, a as StatsCollector, c as StatsEvents } from './scanner-
|
|
1
|
+
import { F as FiberNode, R as RenderInfo, a as ReactDevToolsHook, S as SessionReport, b as ReportOptions, C as CLIMessage, B as BrowserMessage, c as RenderChainInfo, d as ScannerConfig, W as WindowWithReactDevTools } from './types-BZ3OeZ-5.cjs';
|
|
2
|
+
export { r as ComponentNode, h as ComponentStats, E as ErrorCode, u as FiberType, g as FixSuggestion, e as FixType, k as FrameworkInfo, m as FrameworkOptions, O as OverlayOptions, q as ReactCheckConfig, s as ReactCheckError, t as ReactCheckEvents, p as ReactCheckOptions, n as RuleLevel, o as RuleOptions, i as SessionInfo, j as SessionSummary, f as Severity, l as ThresholdOptions, T as TimelineEvent } from './types-BZ3OeZ-5.cjs';
|
|
3
|
+
import { S as Scanner } from './scanner-DUBgwztZ.cjs';
|
|
4
|
+
export { b as ScannerEvents, a as StatsCollector, c as StatsEvents } from './scanner-DUBgwztZ.cjs';
|
|
5
5
|
export { ChainAnalyzer, ChainEvents } from './chain.cjs';
|
|
6
6
|
export { FixEvents, FixSuggester } from './fix.cjs';
|
|
7
7
|
export { detectFramework, detectFrameworkFromWindow, frameworkDetectors, getFrameworkTips } from './detect.cjs';
|
|
8
|
-
import { E as EventEmitter } from './event-emitter-
|
|
8
|
+
import { E as EventEmitter } from './event-emitter-BVYUPYLd.cjs';
|
|
9
9
|
import * as node_net from 'node:net';
|
|
10
10
|
import * as puppeteer from 'puppeteer';
|
|
11
11
|
|
|
@@ -626,6 +626,19 @@ declare class Logger {
|
|
|
626
626
|
group(label: string, fn: () => void): void;
|
|
627
627
|
}
|
|
628
628
|
|
|
629
|
+
/**
|
|
630
|
+
* Component name pattern matching
|
|
631
|
+
* @packageDocumentation
|
|
632
|
+
*/
|
|
633
|
+
/**
|
|
634
|
+
* Match a component name against a simple glob pattern (`*` = any characters,
|
|
635
|
+
* `?` = one character). All other characters match literally.
|
|
636
|
+
* @param name - Component name
|
|
637
|
+
* @param pattern - Glob pattern
|
|
638
|
+
* @returns true if the name matches
|
|
639
|
+
*/
|
|
640
|
+
declare function matchComponentPattern(name: string, pattern: string): boolean;
|
|
641
|
+
|
|
629
642
|
/**
|
|
630
643
|
* WebSocket client connection
|
|
631
644
|
*/
|
|
@@ -759,6 +772,12 @@ declare class WebSocketServer extends EventEmitter<WebSocketServerEvents> {
|
|
|
759
772
|
* Stop the server
|
|
760
773
|
*/
|
|
761
774
|
stop(): Promise<void>;
|
|
775
|
+
/**
|
|
776
|
+
* Get the port the server listens on (the real port after start() when
|
|
777
|
+
* constructed with port 0)
|
|
778
|
+
* @returns Port number
|
|
779
|
+
*/
|
|
780
|
+
getPort(): number;
|
|
762
781
|
/**
|
|
763
782
|
* Broadcast message to all clients
|
|
764
783
|
* @param message - Message to broadcast
|
|
@@ -839,18 +858,13 @@ declare class ProxyServer extends EventEmitter<ProxyServerEvents> {
|
|
|
839
858
|
private options;
|
|
840
859
|
/** Target URL parsed */
|
|
841
860
|
private targetUrl;
|
|
842
|
-
/** Injection script */
|
|
861
|
+
/** Injection script (loaded from the bundled browser script on start() when not provided) */
|
|
843
862
|
private injectionScript;
|
|
844
863
|
/**
|
|
845
864
|
* Create a new proxy server
|
|
846
865
|
* @param options - Proxy options
|
|
847
866
|
*/
|
|
848
867
|
constructor(options: ProxyOptions);
|
|
849
|
-
/**
|
|
850
|
-
* Build the injection script
|
|
851
|
-
* @returns Injection script string
|
|
852
|
-
*/
|
|
853
|
-
private buildInjectionScript;
|
|
854
868
|
/**
|
|
855
869
|
* Handle incoming request
|
|
856
870
|
* @param req - Client request
|
|
@@ -1033,6 +1047,14 @@ declare class BrowserLauncher extends EventEmitter<BrowserEvents> {
|
|
|
1033
1047
|
*/
|
|
1034
1048
|
declare function isPuppeteerAvailable(): Promise<boolean>;
|
|
1035
1049
|
|
|
1050
|
+
/**
|
|
1051
|
+
* Load the browser injection script and prepend the WebSocket port setting
|
|
1052
|
+
* @param wsPort - Port of the CLI WebSocket server the page should connect to
|
|
1053
|
+
* @returns Script source ready for `evaluateOnNewDocument` or a `<script>` tag
|
|
1054
|
+
* @throws Error when the bundle cannot be found (broken installation)
|
|
1055
|
+
*/
|
|
1056
|
+
declare function loadInjectionScript(wsPort: number): Promise<string>;
|
|
1057
|
+
|
|
1036
1058
|
/**
|
|
1037
1059
|
* Browser overlay for render visualization
|
|
1038
1060
|
* @packageDocumentation
|
|
@@ -1046,12 +1068,10 @@ interface OverlayConfig {
|
|
|
1046
1068
|
enabled: boolean;
|
|
1047
1069
|
/** Whether to highlight renders */
|
|
1048
1070
|
highlightRenders: boolean;
|
|
1049
|
-
/** Animation speed */
|
|
1050
|
-
animationSpeed: 'slow' | 'fast' | 'off';
|
|
1051
|
-
/** Whether to show badges */
|
|
1052
|
-
showBadges: boolean;
|
|
1053
1071
|
/** Whether to show toolbar */
|
|
1054
1072
|
showToolbar: boolean;
|
|
1073
|
+
/** Highlight duration in ms (0 = persistent until cleared) */
|
|
1074
|
+
highlightDuration: number;
|
|
1055
1075
|
}
|
|
1056
1076
|
/**
|
|
1057
1077
|
* Overlay for visualizing React renders in the browser
|
|
@@ -1063,21 +1083,41 @@ declare class Overlay {
|
|
|
1063
1083
|
private host;
|
|
1064
1084
|
/** Overlay configuration */
|
|
1065
1085
|
private config;
|
|
1066
|
-
/**
|
|
1067
|
-
private
|
|
1068
|
-
/**
|
|
1069
|
-
private
|
|
1070
|
-
/** Render counts for badges */
|
|
1071
|
-
private renderCounts;
|
|
1086
|
+
/** Tracked components (deduplication) */
|
|
1087
|
+
private trackedComponents;
|
|
1088
|
+
/** Render chains */
|
|
1089
|
+
private renderChains;
|
|
1072
1090
|
/** Toolbar element */
|
|
1073
1091
|
private toolbar;
|
|
1074
1092
|
/** Whether overlay is visible */
|
|
1075
1093
|
private visible;
|
|
1094
|
+
/** Whether panel is collapsed to icon */
|
|
1095
|
+
private collapsed;
|
|
1096
|
+
/** Total render count */
|
|
1097
|
+
private totalRenders;
|
|
1098
|
+
/** FPS value */
|
|
1099
|
+
private fps;
|
|
1100
|
+
/** Scan start time */
|
|
1101
|
+
private startTime;
|
|
1102
|
+
/** Fade timeout handles */
|
|
1103
|
+
private fadeTimeouts;
|
|
1104
|
+
/** Bound scroll handler for cleanup */
|
|
1105
|
+
private scrollHandler;
|
|
1106
|
+
/** Scroll update pending flag (for throttling) */
|
|
1107
|
+
private scrollUpdatePending;
|
|
1108
|
+
/** Stats update interval */
|
|
1109
|
+
private statsInterval;
|
|
1076
1110
|
/**
|
|
1077
1111
|
* Create a new overlay
|
|
1078
1112
|
* @param config - Overlay configuration
|
|
1079
1113
|
*/
|
|
1080
1114
|
constructor(config?: Partial<OverlayConfig>);
|
|
1115
|
+
/** Retry count for init */
|
|
1116
|
+
private initRetryCount;
|
|
1117
|
+
/** Pending init retry timer (document.body not ready yet) */
|
|
1118
|
+
private initRetryTimer;
|
|
1119
|
+
/** Aborts document-level listeners (drag handling) on destroy */
|
|
1120
|
+
private documentListeners;
|
|
1081
1121
|
/**
|
|
1082
1122
|
* Initialize the overlay
|
|
1083
1123
|
*/
|
|
@@ -1086,67 +1126,102 @@ declare class Overlay {
|
|
|
1086
1126
|
* Destroy the overlay
|
|
1087
1127
|
*/
|
|
1088
1128
|
destroy(): void;
|
|
1129
|
+
/**
|
|
1130
|
+
* Handle scroll/resize events - update all highlight positions
|
|
1131
|
+
*/
|
|
1132
|
+
private onScroll;
|
|
1133
|
+
/**
|
|
1134
|
+
* Update positions of all tracked highlights
|
|
1135
|
+
*/
|
|
1136
|
+
private updateAllPositions;
|
|
1089
1137
|
/**
|
|
1090
1138
|
* Inject CSS styles into shadow DOM
|
|
1091
1139
|
*/
|
|
1092
1140
|
private injectStyles;
|
|
1093
1141
|
/**
|
|
1094
|
-
* Create the floating
|
|
1142
|
+
* Create the floating panel
|
|
1095
1143
|
*/
|
|
1096
1144
|
private createToolbar;
|
|
1097
1145
|
/**
|
|
1098
1146
|
* Set up toolbar event listeners
|
|
1099
1147
|
*/
|
|
1100
1148
|
private setupToolbarEvents;
|
|
1149
|
+
/**
|
|
1150
|
+
* Toggle collapse state
|
|
1151
|
+
*/
|
|
1152
|
+
private toggleCollapse;
|
|
1153
|
+
/**
|
|
1154
|
+
* Switch active tab
|
|
1155
|
+
*/
|
|
1156
|
+
private switchTab;
|
|
1157
|
+
/**
|
|
1158
|
+
* Update highlights visibility
|
|
1159
|
+
*/
|
|
1160
|
+
private updateHighlightsVisibility;
|
|
1101
1161
|
/**
|
|
1102
1162
|
* Make an element draggable
|
|
1103
|
-
* @param element - Element to make draggable
|
|
1104
1163
|
*/
|
|
1105
1164
|
private makeDraggable;
|
|
1165
|
+
/** Maximum number of highlights to show at once */
|
|
1166
|
+
private static readonly MAX_HIGHLIGHTS;
|
|
1167
|
+
/** Component names to skip (generic/internal) */
|
|
1168
|
+
private static readonly SKIP_COMPONENTS;
|
|
1106
1169
|
/**
|
|
1107
|
-
* Highlight a component render
|
|
1108
|
-
* @param render - Render information
|
|
1109
|
-
* @param element - DOM element to highlight
|
|
1170
|
+
* Highlight a component render
|
|
1110
1171
|
*/
|
|
1111
1172
|
highlight(render: RenderInfo, element: Element): void;
|
|
1112
1173
|
/**
|
|
1113
|
-
*
|
|
1114
|
-
* @param rect - Element bounding rectangle
|
|
1115
|
-
* @param color - Flash color
|
|
1174
|
+
* Add a render chain
|
|
1116
1175
|
*/
|
|
1117
|
-
|
|
1176
|
+
addChain(chain: RenderChainInfo): void;
|
|
1118
1177
|
/**
|
|
1119
|
-
* Update
|
|
1120
|
-
* @param render - Render information
|
|
1121
|
-
* @param rect - Bounding rectangle
|
|
1122
|
-
* @param color - Badge color
|
|
1178
|
+
* Update FPS value
|
|
1123
1179
|
*/
|
|
1124
|
-
|
|
1180
|
+
updateFps(fps: number): void;
|
|
1125
1181
|
/**
|
|
1126
|
-
*
|
|
1127
|
-
|
|
1128
|
-
|
|
1182
|
+
* Create a highlight element
|
|
1183
|
+
*/
|
|
1184
|
+
private createHighlightElement;
|
|
1185
|
+
/**
|
|
1186
|
+
* Update highlight position
|
|
1187
|
+
*/
|
|
1188
|
+
private updateHighlightPosition;
|
|
1189
|
+
/**
|
|
1190
|
+
* Update highlight color
|
|
1191
|
+
*/
|
|
1192
|
+
private updateHighlightColor;
|
|
1193
|
+
/**
|
|
1194
|
+
* Reset fade timeout
|
|
1195
|
+
*/
|
|
1196
|
+
private resetFadeTimeout;
|
|
1197
|
+
/**
|
|
1198
|
+
* Get the oldest tracked component by last render time
|
|
1199
|
+
*/
|
|
1200
|
+
private getOldestTrackedComponent;
|
|
1201
|
+
/**
|
|
1202
|
+
* Remove a highlight by component name
|
|
1203
|
+
*/
|
|
1204
|
+
private removeHighlight;
|
|
1205
|
+
/**
|
|
1206
|
+
* Get severity level
|
|
1129
1207
|
*/
|
|
1130
1208
|
private getSeverity;
|
|
1131
1209
|
/**
|
|
1132
|
-
* Record a render event
|
|
1133
|
-
* @param render - Render information
|
|
1210
|
+
* Record a render event
|
|
1134
1211
|
*/
|
|
1135
1212
|
recordRender(render: RenderInfo): void;
|
|
1136
|
-
/** Total render count */
|
|
1137
|
-
private totalRenders;
|
|
1138
1213
|
/**
|
|
1139
|
-
* Update
|
|
1214
|
+
* Update all stats
|
|
1140
1215
|
*/
|
|
1141
1216
|
private updateStats;
|
|
1142
1217
|
/**
|
|
1143
|
-
*
|
|
1218
|
+
* Update component list in Components tab
|
|
1144
1219
|
*/
|
|
1145
|
-
|
|
1220
|
+
private updateComponentList;
|
|
1146
1221
|
/**
|
|
1147
|
-
*
|
|
1222
|
+
* Update chain list in Chains tab
|
|
1148
1223
|
*/
|
|
1149
|
-
|
|
1224
|
+
private updateChainList;
|
|
1150
1225
|
/**
|
|
1151
1226
|
* Clear all visualizations
|
|
1152
1227
|
*/
|
|
@@ -1165,14 +1240,16 @@ declare class Overlay {
|
|
|
1165
1240
|
toggle(): void;
|
|
1166
1241
|
/**
|
|
1167
1242
|
* Update configuration
|
|
1168
|
-
* @param config - Partial configuration
|
|
1169
1243
|
*/
|
|
1170
1244
|
configure(config: Partial<OverlayConfig>): void;
|
|
1171
1245
|
/**
|
|
1172
1246
|
* Check if overlay is visible
|
|
1173
|
-
* @returns true if visible
|
|
1174
1247
|
*/
|
|
1175
1248
|
isVisible(): boolean;
|
|
1249
|
+
/**
|
|
1250
|
+
* Get render counts
|
|
1251
|
+
*/
|
|
1252
|
+
getRenderCounts(): Map<string, number>;
|
|
1176
1253
|
}
|
|
1177
1254
|
|
|
1178
1255
|
/**
|
|
@@ -1214,8 +1291,6 @@ declare class BrowserScanner extends EventEmitter<BrowserScannerEvents> {
|
|
|
1214
1291
|
private running;
|
|
1215
1292
|
/** React version detected */
|
|
1216
1293
|
private reactVersion;
|
|
1217
|
-
/** Previous fiber states for comparison */
|
|
1218
|
-
private prevFiberStates;
|
|
1219
1294
|
/** Component render counts */
|
|
1220
1295
|
private renderCounts;
|
|
1221
1296
|
/** Original DevTools hook methods */
|
|
@@ -1282,16 +1357,14 @@ declare class BrowserScanner extends EventEmitter<BrowserScannerEvents> {
|
|
|
1282
1357
|
*/
|
|
1283
1358
|
private detectReactVersion;
|
|
1284
1359
|
/**
|
|
1285
|
-
* Process a fiber commit (public for IIFE hook integration)
|
|
1286
|
-
*
|
|
1360
|
+
* Process a fiber commit (public for IIFE hook integration).
|
|
1361
|
+
*
|
|
1362
|
+
* Only components that actually rendered in this commit are reported: React
|
|
1363
|
+
* reuses untouched subtrees (their `child` pointer is shared with the
|
|
1364
|
+
* alternate) and bailed-out components do not get the `PerformedWork` flag.
|
|
1365
|
+
* @param rootFiber - Root fiber of the committed tree (`root.current`)
|
|
1287
1366
|
*/
|
|
1288
1367
|
processCommit(rootFiber: FiberNode): void;
|
|
1289
|
-
/**
|
|
1290
|
-
* Walk the fiber tree
|
|
1291
|
-
* @param fiber - Current fiber
|
|
1292
|
-
* @param parent - Parent component name
|
|
1293
|
-
*/
|
|
1294
|
-
private walkFiber;
|
|
1295
1368
|
/**
|
|
1296
1369
|
* Process a single fiber
|
|
1297
1370
|
* @param fiber - Fiber to process
|
|
@@ -1345,8 +1418,13 @@ declare class BrowserScanner extends EventEmitter<BrowserScannerEvents> {
|
|
|
1345
1418
|
}
|
|
1346
1419
|
|
|
1347
1420
|
/**
|
|
1348
|
-
* Browser
|
|
1349
|
-
*
|
|
1421
|
+
* Browser-side injector: coordinates the BrowserScanner, the Overlay and the
|
|
1422
|
+
* WebSocket connection to the CLI.
|
|
1423
|
+
*
|
|
1424
|
+
* This module has NO side effects when imported, so it is safe to import from
|
|
1425
|
+
* Node.js, SSR bundles and tests. The self-installing IIFE lives in
|
|
1426
|
+
* `inject.ts`, which is only built into `dist/browser-inject.global.js`.
|
|
1427
|
+
*
|
|
1350
1428
|
* @packageDocumentation
|
|
1351
1429
|
*/
|
|
1352
1430
|
|
|
@@ -1366,10 +1444,33 @@ declare class ReactCheckInjector {
|
|
|
1366
1444
|
private reconnectTimeout;
|
|
1367
1445
|
/** Whether initialized */
|
|
1368
1446
|
private initialized;
|
|
1447
|
+
/** Whether destroyed (no more reconnects, commits are ignored) */
|
|
1448
|
+
private destroyed;
|
|
1449
|
+
/** Whether commit processing is paused (CLI sent `stop`) */
|
|
1450
|
+
private paused;
|
|
1451
|
+
/** Commits received before `init()` */
|
|
1452
|
+
private pendingCommits;
|
|
1453
|
+
/** Message queue for messages sent before connection */
|
|
1454
|
+
private messageQueue;
|
|
1455
|
+
/** requestAnimationFrame handle for FPS measurement */
|
|
1456
|
+
private rafHandle;
|
|
1457
|
+
/** Restores the React DevTools hook to its state before installation */
|
|
1458
|
+
private restoreHook;
|
|
1459
|
+
/** Window reference */
|
|
1460
|
+
private win;
|
|
1369
1461
|
/**
|
|
1370
1462
|
* Create the injector
|
|
1463
|
+
* @param win - Window object (defaults to the global window)
|
|
1464
|
+
*/
|
|
1465
|
+
constructor(win?: WindowWithReactDevTools);
|
|
1466
|
+
/**
|
|
1467
|
+
* Feed a committed fiber root to the scanner. Called from the React DevTools
|
|
1468
|
+
* hook installed by {@link installReactCheck}.
|
|
1469
|
+
* @param root - Fiber root passed to `onCommitFiberRoot`
|
|
1371
1470
|
*/
|
|
1372
|
-
|
|
1471
|
+
handleCommit(root: {
|
|
1472
|
+
current: FiberNode;
|
|
1473
|
+
} | null | undefined): void;
|
|
1373
1474
|
/**
|
|
1374
1475
|
* Initialize the injector
|
|
1375
1476
|
*/
|
|
@@ -1378,10 +1479,20 @@ declare class ReactCheckInjector {
|
|
|
1378
1479
|
* Set up scanner event handlers
|
|
1379
1480
|
*/
|
|
1380
1481
|
private setupScannerEvents;
|
|
1482
|
+
/**
|
|
1483
|
+
* Measure frames per second with requestAnimationFrame and report it
|
|
1484
|
+
*/
|
|
1485
|
+
private startFpsMeasurement;
|
|
1381
1486
|
/**
|
|
1382
1487
|
* Connect to CLI WebSocket server
|
|
1383
1488
|
*/
|
|
1384
1489
|
private connect;
|
|
1490
|
+
/**
|
|
1491
|
+
* Remove event handlers from a socket so that closing it does not trigger
|
|
1492
|
+
* reconnects
|
|
1493
|
+
* @param ws - Socket
|
|
1494
|
+
*/
|
|
1495
|
+
private detachSocket;
|
|
1385
1496
|
/**
|
|
1386
1497
|
* Schedule a reconnection attempt
|
|
1387
1498
|
*/
|
|
@@ -1410,8 +1521,6 @@ declare class ReactCheckInjector {
|
|
|
1410
1521
|
* @param config - New configuration
|
|
1411
1522
|
*/
|
|
1412
1523
|
private handleConfig;
|
|
1413
|
-
/** Message queue for messages sent before connection */
|
|
1414
|
-
private messageQueue;
|
|
1415
1524
|
/**
|
|
1416
1525
|
* Send message to CLI
|
|
1417
1526
|
* @param message - Browser message
|
|
@@ -1422,10 +1531,85 @@ declare class ReactCheckInjector {
|
|
|
1422
1531
|
*/
|
|
1423
1532
|
private flushMessageQueue;
|
|
1424
1533
|
/**
|
|
1425
|
-
*
|
|
1534
|
+
* Register a function that restores the DevTools hook on destroy
|
|
1535
|
+
* @param restore - Restore callback
|
|
1536
|
+
*/
|
|
1537
|
+
setHookRestorer(restore: () => void): void;
|
|
1538
|
+
/**
|
|
1539
|
+
* Destroy the injector: stops reconnecting, closes the socket, restores the
|
|
1540
|
+
* React DevTools hook, removes the overlay and cancels all timers.
|
|
1426
1541
|
*/
|
|
1427
1542
|
destroy(): void;
|
|
1428
1543
|
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Install ReactCheck into a page: hooks the React DevTools global hook (creating
|
|
1546
|
+
* it when React has not loaded yet), creates the injector and initialises it
|
|
1547
|
+
* once the DOM is ready. Returns `null` on internal pages or when ReactCheck is
|
|
1548
|
+
* already installed.
|
|
1549
|
+
*
|
|
1550
|
+
* @param win - Window object
|
|
1551
|
+
* @returns The injector instance, or null when nothing was installed
|
|
1552
|
+
*/
|
|
1553
|
+
declare function installReactCheck(win: WindowWithReactDevTools): ReactCheckInjector | null;
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* Package version (kept in sync with package.json; checked by tests)
|
|
1557
|
+
* @packageDocumentation
|
|
1558
|
+
*/
|
|
1559
|
+
declare const VERSION = "1.3.0";
|
|
1560
|
+
|
|
1561
|
+
/**
|
|
1562
|
+
* One-call programmatic scan of a URL
|
|
1563
|
+
* @packageDocumentation
|
|
1564
|
+
*/
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* Options for {@link quickScan}
|
|
1568
|
+
*/
|
|
1569
|
+
interface QuickScanOptions {
|
|
1570
|
+
/** How long to observe the page, in milliseconds (default: 30000) */
|
|
1571
|
+
duration?: number;
|
|
1572
|
+
/** Run the browser headless (default: true) */
|
|
1573
|
+
headless?: boolean;
|
|
1574
|
+
/** Directory to write reports to (no files are written when omitted) */
|
|
1575
|
+
output?: string;
|
|
1576
|
+
/** Report formats to write when `output` is set (default: html, json) */
|
|
1577
|
+
formats?: Array<'html' | 'json' | 'md'>;
|
|
1578
|
+
/** Render-count thresholds */
|
|
1579
|
+
thresholds?: {
|
|
1580
|
+
critical?: number;
|
|
1581
|
+
warning?: number;
|
|
1582
|
+
fps?: number;
|
|
1583
|
+
};
|
|
1584
|
+
/** Only track components matching these glob patterns */
|
|
1585
|
+
include?: string[];
|
|
1586
|
+
/** Ignore components matching these glob patterns */
|
|
1587
|
+
exclude?: string[];
|
|
1588
|
+
/** Port for the internal WebSocket server (default: a free ephemeral port) */
|
|
1589
|
+
port?: number;
|
|
1590
|
+
/** Extra Chrome arguments passed to Puppeteer */
|
|
1591
|
+
browserArgs?: string[];
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* Quick scan a URL and generate a report. Launches Chrome through Puppeteer
|
|
1595
|
+
* (an optional peer dependency), injects the ReactCheck browser script, records
|
|
1596
|
+
* renders for `duration` milliseconds and returns the session report.
|
|
1597
|
+
*
|
|
1598
|
+
* @example
|
|
1599
|
+
* ```typescript
|
|
1600
|
+
* import { quickScan } from '@oxog/react-check';
|
|
1601
|
+
*
|
|
1602
|
+
* const report = await quickScan('http://localhost:3000', {
|
|
1603
|
+
* duration: 30000,
|
|
1604
|
+
* headless: true,
|
|
1605
|
+
* });
|
|
1606
|
+
*
|
|
1607
|
+
* console.log(`Found ${report.summary.criticalIssues} critical issues`);
|
|
1608
|
+
* ```
|
|
1609
|
+
* @throws ReactCheckError BROWSER_LAUNCH_FAILED when Puppeteer is missing or the
|
|
1610
|
+
* browser cannot start, REACT_NOT_FOUND when no React render was observed
|
|
1611
|
+
*/
|
|
1612
|
+
declare function quickScan(url: string, options?: QuickScanOptions): Promise<SessionReport>;
|
|
1429
1613
|
|
|
1430
1614
|
/**
|
|
1431
1615
|
* ReactCheck - Zero-dependency React Performance Scanner
|
|
@@ -1435,7 +1619,6 @@ declare class ReactCheckInjector {
|
|
|
1435
1619
|
* @packageDocumentation
|
|
1436
1620
|
*/
|
|
1437
1621
|
|
|
1438
|
-
declare const VERSION = "1.0.0";
|
|
1439
1622
|
/**
|
|
1440
1623
|
* Create a new ReactCheck scanner instance with default options
|
|
1441
1624
|
*
|
|
@@ -1458,7 +1641,12 @@ declare function createScanner(options?: {
|
|
|
1458
1641
|
thresholds?: {
|
|
1459
1642
|
critical?: number;
|
|
1460
1643
|
warning?: number;
|
|
1644
|
+
fps?: number;
|
|
1461
1645
|
};
|
|
1646
|
+
/** Only track components matching one of these glob patterns */
|
|
1647
|
+
include?: string[];
|
|
1648
|
+
/** Ignore components matching one of these glob patterns */
|
|
1649
|
+
exclude?: string[];
|
|
1462
1650
|
}): Scanner;
|
|
1463
1651
|
/**
|
|
1464
1652
|
* Create a new report generator
|
|
@@ -1480,26 +1668,5 @@ declare function createReportGenerator(options?: {
|
|
|
1480
1668
|
output?: string;
|
|
1481
1669
|
includeSourceCode?: boolean;
|
|
1482
1670
|
}): ReportGenerator;
|
|
1483
|
-
/**
|
|
1484
|
-
* Quick scan a URL and generate a report
|
|
1485
|
-
*
|
|
1486
|
-
* @example
|
|
1487
|
-
* ```typescript
|
|
1488
|
-
* import { quickScan } from '@oxog/react-check';
|
|
1489
|
-
*
|
|
1490
|
-
* const report = await quickScan('http://localhost:3000', {
|
|
1491
|
-
* duration: 30000,
|
|
1492
|
-
* headless: true,
|
|
1493
|
-
* });
|
|
1494
|
-
*
|
|
1495
|
-
* console.log(`Found ${report.summary.criticalIssues} critical issues`);
|
|
1496
|
-
* ```
|
|
1497
|
-
*/
|
|
1498
|
-
declare function quickScan(url: string, options?: {
|
|
1499
|
-
duration?: number;
|
|
1500
|
-
headless?: boolean;
|
|
1501
|
-
output?: string;
|
|
1502
|
-
formats?: Array<'html' | 'json' | 'md'>;
|
|
1503
|
-
}): Promise<SessionReport>;
|
|
1504
1671
|
|
|
1505
|
-
export { type BrowserEvents, type BrowserLaunchOptions, BrowserLauncher, BrowserMessage, BrowserScanner, type BrowserScannerEvents, CLIMessage, EventEmitter, FiberNode, FiberTag, LogLevel, Logger, Overlay, type OverlayConfig, type ProxyOptions, ProxyServer, type ProxyServerEvents, ReactCheckInjector, ReactDevToolsHook, RenderInfo, type ReportFormat, ReportGenerator, ReportOptions, Scanner, ScannerConfig, SessionReport, VERSION, WebSocketClient, WebSocketServer, type WebSocketServerEvents, WindowWithReactDevTools, colors, createRenderInfo, createReportGenerator, createScanner, ensureDir, escapeHtml, exists, findFiberByName, findUp, formatBytes, formatDuration, formatNumber, formatPercent, formatRenderTime, generateHTMLReport, generateJSONReport, generateMarkdownReport, generateReport, getBaseName, getChangedProps, getComponentName, getComponentPath, getDirName, getExtension, getFiberDOMNode, getOwner, getParentFiber, getReactVersion, handleBrowserMessages, isHostComponent, isMemoized, isPuppeteerAvailable, isUserComponent, joinPath, pad, parseJSONReport, quickScan, readJsonFile, readTextFile, resolvePath, saveReport, saveReports, shallowEqual, stripAnsi, supportsColor, truncate, validateJSONReport, walkFiberTree, writeJsonFile, writeTextFile };
|
|
1672
|
+
export { type BrowserEvents, type BrowserLaunchOptions, BrowserLauncher, BrowserMessage, BrowserScanner, type BrowserScannerEvents, CLIMessage, EventEmitter, FiberNode, FiberTag, LogLevel, Logger, Overlay, type OverlayConfig, type ProxyOptions, ProxyServer, type ProxyServerEvents, type QuickScanOptions, ReactCheckInjector, ReactDevToolsHook, RenderChainInfo, RenderInfo, type ReportFormat, ReportGenerator, ReportOptions, Scanner, ScannerConfig, SessionReport, VERSION, WebSocketClient, WebSocketServer, type WebSocketServerEvents, WindowWithReactDevTools, colors, createRenderInfo, createReportGenerator, createScanner, ensureDir, escapeHtml, exists, findFiberByName, findUp, formatBytes, formatDuration, formatNumber, formatPercent, formatRenderTime, generateHTMLReport, generateJSONReport, generateMarkdownReport, generateReport, getBaseName, getChangedProps, getComponentName, getComponentPath, getDirName, getExtension, getFiberDOMNode, getOwner, getParentFiber, getReactVersion, handleBrowserMessages, installReactCheck, isHostComponent, isMemoized, isPuppeteerAvailable, isUserComponent, joinPath, loadInjectionScript, matchComponentPattern, pad, parseJSONReport, quickScan, readJsonFile, readTextFile, resolvePath, saveReport, saveReports, shallowEqual, stripAnsi, supportsColor, truncate, validateJSONReport, walkFiberTree, writeJsonFile, writeTextFile };
|