@oxog/react-check 1.0.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.
@@ -0,0 +1,1444 @@
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-CVcIoqzs.cjs';
2
+ export { q as ComponentNode, h as ComponentStats, E as ErrorCode, t as FiberType, g as FixSuggestion, e as FixType, k as FrameworkInfo, m as FrameworkOptions, O as OverlayOptions, p as ReactCheckConfig, r as ReactCheckError, s as ReactCheckEvents, o as ReactCheckOptions, d as RenderChainInfo, n as RuleOptions, i as SessionInfo, j as SessionSummary, f as Severity, l as ThresholdOptions, T as TimelineEvent } from './types-CVcIoqzs.cjs';
3
+ import { S as Scanner } from './scanner-BsBnFki5.cjs';
4
+ export { b as ScannerEvents, a as StatsCollector, c as StatsEvents } from './scanner-BsBnFki5.cjs';
5
+ export { ChainAnalyzer, ChainEvents } from './chain.cjs';
6
+ export { FixEvents, FixSuggester } from './fix.cjs';
7
+ export { detectFramework, detectFrameworkFromWindow, frameworkDetectors, getFrameworkTips } from './detect.cjs';
8
+ import { E as EventEmitter } from './event-emitter-CxKUDo9q.cjs';
9
+ import * as node_net from 'node:net';
10
+ import * as puppeteer from 'puppeteer';
11
+
12
+ /**
13
+ * React Fiber utilities for interacting with React internals
14
+ * @packageDocumentation
15
+ */
16
+
17
+ /**
18
+ * Fiber tag constants (from React source)
19
+ */
20
+ declare const FiberTag: {
21
+ readonly FunctionComponent: 0;
22
+ readonly ClassComponent: 1;
23
+ readonly IndeterminateComponent: 2;
24
+ readonly HostRoot: 3;
25
+ readonly HostPortal: 4;
26
+ readonly HostComponent: 5;
27
+ readonly HostText: 6;
28
+ readonly Fragment: 7;
29
+ readonly Mode: 8;
30
+ readonly ContextConsumer: 9;
31
+ readonly ContextProvider: 10;
32
+ readonly ForwardRef: 11;
33
+ readonly Profiler: 12;
34
+ readonly SuspenseComponent: 13;
35
+ readonly MemoComponent: 14;
36
+ readonly SimpleMemoComponent: 15;
37
+ readonly LazyComponent: 16;
38
+ readonly IncompleteClassComponent: 17;
39
+ readonly DehydratedFragment: 18;
40
+ readonly SuspenseListComponent: 19;
41
+ readonly ScopeComponent: 21;
42
+ readonly OffscreenComponent: 22;
43
+ readonly LegacyHiddenComponent: 23;
44
+ readonly CacheComponent: 24;
45
+ };
46
+ /**
47
+ * Get the display name of a component from its fiber
48
+ * @param fiber - Fiber node
49
+ * @returns Component name or 'Unknown'
50
+ */
51
+ declare function getComponentName(fiber: FiberNode): string;
52
+ /**
53
+ * Check if a fiber represents a user component (not a host element)
54
+ * @param fiber - Fiber node
55
+ * @returns true if user component
56
+ */
57
+ declare function isUserComponent(fiber: FiberNode): boolean;
58
+ /**
59
+ * Check if a fiber represents a host element (DOM node)
60
+ * @param fiber - Fiber node
61
+ * @returns true if host element
62
+ */
63
+ declare function isHostComponent(fiber: FiberNode): boolean;
64
+ /**
65
+ * Get the DOM node associated with a fiber
66
+ * @param fiber - Fiber node
67
+ * @returns DOM node or null
68
+ */
69
+ declare function getFiberDOMNode(fiber: FiberNode): Element | null;
70
+ /**
71
+ * Get the parent component of a fiber
72
+ * @param fiber - Fiber node
73
+ * @returns Parent fiber or null
74
+ */
75
+ declare function getParentFiber(fiber: FiberNode): FiberNode | null;
76
+ /**
77
+ * Walk the fiber tree and call a function for each user component
78
+ * @param root - Root fiber
79
+ * @param callback - Function to call for each component
80
+ */
81
+ declare function walkFiberTree(root: FiberNode, callback: (fiber: FiberNode) => void | boolean): void;
82
+ /**
83
+ * Compare props to detect changes
84
+ * @param prevProps - Previous props
85
+ * @param nextProps - Next props
86
+ * @returns Array of changed prop names
87
+ */
88
+ declare function getChangedProps(prevProps: Record<string, unknown> | null, nextProps: Record<string, unknown> | null): string[];
89
+ /**
90
+ * Shallow compare two objects
91
+ * @param a - First object
92
+ * @param b - Second object
93
+ * @returns true if shallow equal
94
+ */
95
+ declare function shallowEqual(a: Record<string, unknown> | null, b: Record<string, unknown> | null): boolean;
96
+ /**
97
+ * Create render info from a fiber commit
98
+ * @param fiber - Fiber that rendered
99
+ * @param phase - Render phase
100
+ * @param prevProps - Previous props (for comparison)
101
+ * @param prevState - Previous state (for comparison)
102
+ * @returns Render info
103
+ */
104
+ declare function createRenderInfo(fiber: FiberNode, phase: 'mount' | 'update', prevProps?: Record<string, unknown> | null, prevState?: unknown): RenderInfo;
105
+ /**
106
+ * Get React version from DevTools hook
107
+ * @param hook - DevTools global hook
108
+ * @returns React version string
109
+ */
110
+ declare function getReactVersion(hook: ReactDevToolsHook): string;
111
+ /**
112
+ * Check if fiber is memoized (React.memo or PureComponent)
113
+ * @param fiber - Fiber node
114
+ * @returns true if memoized
115
+ */
116
+ declare function isMemoized(fiber: FiberNode): boolean;
117
+ /**
118
+ * Get the owner (parent that rendered this) of a fiber
119
+ * @param fiber - Fiber node
120
+ * @returns Owner fiber or null
121
+ */
122
+ declare function getOwner(fiber: FiberNode): FiberNode | null;
123
+ /**
124
+ * Build a component path from root to fiber
125
+ * @param fiber - Target fiber
126
+ * @returns Array of component names
127
+ */
128
+ declare function getComponentPath(fiber: FiberNode): string[];
129
+ /**
130
+ * Find fiber by component name
131
+ * @param root - Root fiber
132
+ * @param name - Component name to find
133
+ * @returns Matching fiber or null
134
+ */
135
+ declare function findFiberByName(root: FiberNode, name: string): FiberNode | null;
136
+
137
+ /**
138
+ * JSON report generator
139
+ * @packageDocumentation
140
+ */
141
+
142
+ /**
143
+ * Generate a JSON report
144
+ * @param report - Session report data
145
+ * @param pretty - Whether to format with indentation
146
+ * @returns JSON string
147
+ */
148
+ declare function generateJSONReport(report: SessionReport, pretty?: boolean): string;
149
+ /**
150
+ * Parse a JSON report
151
+ * @param json - JSON string
152
+ * @returns Parsed session report
153
+ */
154
+ declare function parseJSONReport(json: string): SessionReport;
155
+ /**
156
+ * Validate a JSON report structure
157
+ * @param data - Parsed JSON data
158
+ * @returns Validation errors (empty if valid)
159
+ */
160
+ declare function validateJSONReport(data: unknown): string[];
161
+
162
+ /**
163
+ * Markdown report generator
164
+ * @packageDocumentation
165
+ */
166
+
167
+ /**
168
+ * Generate a Markdown report
169
+ * @param report - Session report data
170
+ * @returns Markdown string
171
+ */
172
+ declare function generateMarkdownReport(report: SessionReport): string;
173
+
174
+ /**
175
+ * HTML report generator
176
+ * @packageDocumentation
177
+ */
178
+
179
+ /**
180
+ * Generate an HTML report
181
+ * @param report - Session report data
182
+ * @returns HTML string
183
+ */
184
+ declare function generateHTMLReport(report: SessionReport): string;
185
+
186
+ /**
187
+ * Report module exports
188
+ * @packageDocumentation
189
+ */
190
+
191
+ /**
192
+ * Report format type
193
+ */
194
+ type ReportFormat = 'html' | 'json' | 'md';
195
+ /**
196
+ * Generate report in specified format
197
+ * @param report - Session report data
198
+ * @param format - Output format
199
+ * @returns Report content string
200
+ */
201
+ declare function generateReport(report: SessionReport, format: ReportFormat): string;
202
+ /**
203
+ * Save report to file
204
+ * @param report - Session report data
205
+ * @param format - Output format
206
+ * @param outputDir - Output directory
207
+ * @param filename - Base filename (without extension)
208
+ * @returns Path to saved file
209
+ */
210
+ declare function saveReport(report: SessionReport, format: ReportFormat, outputDir: string, filename?: string): Promise<string>;
211
+ /**
212
+ * Save reports in multiple formats
213
+ * @param report - Session report data
214
+ * @param options - Report options
215
+ * @returns Paths to saved files
216
+ */
217
+ declare function saveReports(report: SessionReport, options: ReportOptions): Promise<string[]>;
218
+ /**
219
+ * Report generator class for more control
220
+ */
221
+ declare class ReportGenerator {
222
+ /** Report options */
223
+ private options;
224
+ /**
225
+ * Create a new report generator
226
+ * @param options - Report options
227
+ */
228
+ constructor(options?: Partial<ReportOptions>);
229
+ /**
230
+ * Generate report content
231
+ * @param report - Session report data
232
+ * @param format - Output format
233
+ * @returns Report content
234
+ */
235
+ generate(report: SessionReport, format: ReportFormat): string;
236
+ /**
237
+ * Generate all configured report formats
238
+ * @param report - Session report data
239
+ * @returns Map of format to content
240
+ */
241
+ generateAll(report: SessionReport): Map<ReportFormat, string>;
242
+ /**
243
+ * Save report to file
244
+ * @param report - Session report data
245
+ * @param format - Output format
246
+ * @returns Path to saved file
247
+ */
248
+ save(report: SessionReport, format: ReportFormat): Promise<string>;
249
+ /**
250
+ * Save all configured report formats
251
+ * @param report - Session report data
252
+ * @returns Paths to saved files
253
+ */
254
+ saveAll(report: SessionReport): Promise<string[]>;
255
+ /**
256
+ * Get report options
257
+ * @returns Current options
258
+ */
259
+ getOptions(): ReportOptions;
260
+ /**
261
+ * Update report options
262
+ * @param options - Partial options to update
263
+ */
264
+ configure(options: Partial<ReportOptions>): void;
265
+ }
266
+
267
+ /**
268
+ * ANSI color codes for terminal output
269
+ * @packageDocumentation
270
+ */
271
+ /**
272
+ * Whether the current terminal supports ANSI colors
273
+ */
274
+ declare const supportsColor: boolean;
275
+ /**
276
+ * ANSI escape codes for text formatting
277
+ */
278
+ declare const colors: {
279
+ readonly reset: "" | "\u001B[0m";
280
+ readonly bold: "" | "\u001B[1m";
281
+ readonly dim: "" | "\u001B[2m";
282
+ readonly italic: "" | "\u001B[3m";
283
+ readonly underline: "" | "\u001B[4m";
284
+ readonly blink: "" | "\u001B[5m";
285
+ readonly inverse: "" | "\u001B[7m";
286
+ readonly hidden: "" | "\u001B[8m";
287
+ readonly strikethrough: "" | "\u001B[9m";
288
+ readonly black: "" | "\u001B[30m";
289
+ readonly red: "" | "\u001B[31m";
290
+ readonly green: "" | "\u001B[32m";
291
+ readonly yellow: "" | "\u001B[33m";
292
+ readonly blue: "" | "\u001B[34m";
293
+ readonly magenta: "" | "\u001B[35m";
294
+ readonly cyan: "" | "\u001B[36m";
295
+ readonly white: "" | "\u001B[37m";
296
+ readonly gray: "" | "\u001B[90m";
297
+ readonly grey: "" | "\u001B[90m";
298
+ readonly brightRed: "" | "\u001B[91m";
299
+ readonly brightGreen: "" | "\u001B[92m";
300
+ readonly brightYellow: "" | "\u001B[93m";
301
+ readonly brightBlue: "" | "\u001B[94m";
302
+ readonly brightMagenta: "" | "\u001B[95m";
303
+ readonly brightCyan: "" | "\u001B[96m";
304
+ readonly brightWhite: "" | "\u001B[97m";
305
+ readonly bgBlack: "" | "\u001B[40m";
306
+ readonly bgRed: "" | "\u001B[41m";
307
+ readonly bgGreen: "" | "\u001B[42m";
308
+ readonly bgYellow: "" | "\u001B[43m";
309
+ readonly bgBlue: "" | "\u001B[44m";
310
+ readonly bgMagenta: "" | "\u001B[45m";
311
+ readonly bgCyan: "" | "\u001B[46m";
312
+ readonly bgWhite: "" | "\u001B[47m";
313
+ readonly bgGray: "" | "\u001B[100m";
314
+ readonly bgBrightRed: "" | "\u001B[101m";
315
+ readonly bgBrightGreen: "" | "\u001B[102m";
316
+ readonly bgBrightYellow: "" | "\u001B[103m";
317
+ readonly bgBrightBlue: "" | "\u001B[104m";
318
+ readonly bgBrightMagenta: "" | "\u001B[105m";
319
+ readonly bgBrightCyan: "" | "\u001B[106m";
320
+ readonly bgBrightWhite: "" | "\u001B[107m";
321
+ };
322
+ /**
323
+ * Strip ANSI codes from text
324
+ * @param text - Text with ANSI codes
325
+ * @returns Text without ANSI codes
326
+ */
327
+ declare function stripAnsi(text: string): string;
328
+
329
+ /**
330
+ * Formatting utilities
331
+ * @packageDocumentation
332
+ */
333
+ /**
334
+ * Format a number with thousands separators
335
+ * @param num - Number to format
336
+ * @param locale - Locale for formatting (default: 'en-US')
337
+ * @returns Formatted string
338
+ */
339
+ declare function formatNumber(num: number, locale?: string): string;
340
+ /**
341
+ * Format bytes to human-readable string
342
+ * @param bytes - Number of bytes
343
+ * @param decimals - Number of decimal places
344
+ * @returns Formatted string (e.g., "1.5 MB")
345
+ */
346
+ declare function formatBytes(bytes: number, decimals?: number): string;
347
+ /**
348
+ * Format milliseconds to human-readable duration
349
+ * @param ms - Duration in milliseconds
350
+ * @param options - Formatting options
351
+ * @returns Formatted string (e.g., "2m 34s", "1.5s", "150ms")
352
+ */
353
+ declare function formatDuration(ms: number, options?: {
354
+ short?: boolean;
355
+ decimals?: number;
356
+ }): string;
357
+ /**
358
+ * Format a percentage
359
+ * @param value - Value (0-1 or 0-100)
360
+ * @param options - Formatting options
361
+ * @returns Formatted string (e.g., "75%", "75.5%")
362
+ */
363
+ declare function formatPercent(value: number, options?: {
364
+ decimals?: number;
365
+ normalized?: boolean;
366
+ }): string;
367
+ /**
368
+ * Format a render time with appropriate unit
369
+ * @param ms - Time in milliseconds
370
+ * @returns Formatted string with color indicator
371
+ */
372
+ declare function formatRenderTime(ms: number): string;
373
+ /**
374
+ * Pad a string to a specific length
375
+ * @param str - String to pad
376
+ * @param length - Target length
377
+ * @param char - Padding character
378
+ * @param position - 'left' or 'right'
379
+ * @returns Padded string
380
+ */
381
+ declare function pad(str: string, length: number, char?: string, position?: 'left' | 'right'): string;
382
+ /**
383
+ * Truncate a string with ellipsis
384
+ * @param str - String to truncate
385
+ * @param maxLength - Maximum length
386
+ * @param suffix - Suffix to add when truncated
387
+ * @returns Truncated string
388
+ */
389
+ declare function truncate(str: string, maxLength: number, suffix?: string): string;
390
+ /**
391
+ * Escape HTML special characters
392
+ * @param str - String to escape
393
+ * @returns Escaped string
394
+ */
395
+ declare function escapeHtml(str: string): string;
396
+
397
+ /**
398
+ * File system utilities
399
+ * @packageDocumentation
400
+ */
401
+ /**
402
+ * Check if a file or directory exists
403
+ * @param path - Path to check
404
+ * @returns true if exists
405
+ */
406
+ declare function exists(path: string): Promise<boolean>;
407
+ /**
408
+ * Read a text file
409
+ * @param path - File path
410
+ * @param encoding - Text encoding
411
+ * @returns File contents
412
+ */
413
+ declare function readTextFile(path: string, encoding?: BufferEncoding): Promise<string>;
414
+ /**
415
+ * Write a text file
416
+ * @param path - File path
417
+ * @param content - File contents
418
+ * @param encoding - Text encoding
419
+ */
420
+ declare function writeTextFile(path: string, content: string, encoding?: BufferEncoding): Promise<void>;
421
+ /**
422
+ * Read a JSON file
423
+ * @param path - File path
424
+ * @returns Parsed JSON
425
+ */
426
+ declare function readJsonFile<T = unknown>(path: string): Promise<T>;
427
+ /**
428
+ * Write a JSON file
429
+ * @param path - File path
430
+ * @param data - Data to write
431
+ * @param pretty - Whether to format with indentation
432
+ */
433
+ declare function writeJsonFile(path: string, data: unknown, pretty?: boolean): Promise<void>;
434
+ /**
435
+ * Ensure a directory exists, creating it if necessary
436
+ * @param path - Directory path
437
+ */
438
+ declare function ensureDir(path: string): Promise<void>;
439
+ /**
440
+ * Get file extension
441
+ * @param path - File path
442
+ * @returns Extension without dot
443
+ */
444
+ declare function getExtension(path: string): string;
445
+ /**
446
+ * Get file name without extension
447
+ * @param path - File path
448
+ * @returns Filename without extension
449
+ */
450
+ declare function getBaseName(path: string): string;
451
+ /**
452
+ * Resolve a path relative to a base
453
+ * @param base - Base path
454
+ * @param paths - Path segments
455
+ * @returns Resolved path
456
+ */
457
+ declare function resolvePath(base: string, ...paths: string[]): string;
458
+ /**
459
+ * Join path segments
460
+ * @param paths - Path segments
461
+ * @returns Joined path
462
+ */
463
+ declare function joinPath(...paths: string[]): string;
464
+ /**
465
+ * Get directory name
466
+ * @param path - File path
467
+ * @returns Directory name
468
+ */
469
+ declare function getDirName(path: string): string;
470
+ /**
471
+ * Find a file by walking up the directory tree
472
+ * @param filename - File to find
473
+ * @param startDir - Starting directory
474
+ * @returns File path if found, null otherwise
475
+ */
476
+ declare function findUp(filename: string, startDir?: string): Promise<string | null>;
477
+
478
+ /**
479
+ * Logging utility for ReactCheck
480
+ * @packageDocumentation
481
+ */
482
+ /**
483
+ * Log levels
484
+ */
485
+ declare enum LogLevel {
486
+ DEBUG = 0,
487
+ INFO = 1,
488
+ WARN = 2,
489
+ ERROR = 3,
490
+ SILENT = 4
491
+ }
492
+ /**
493
+ * Logger options
494
+ */
495
+ interface LoggerOptions {
496
+ /** Logger prefix/namespace */
497
+ prefix?: string;
498
+ /** Minimum log level to output */
499
+ level?: LogLevel;
500
+ /** Whether to show timestamps */
501
+ showTimestamp?: boolean;
502
+ /** Whether to show log level */
503
+ showLevel?: boolean;
504
+ /** Custom output stream (defaults to console) */
505
+ output?: {
506
+ log: (message: string) => void;
507
+ warn: (message: string) => void;
508
+ error: (message: string) => void;
509
+ };
510
+ }
511
+ /**
512
+ * Logger class for structured logging
513
+ */
514
+ declare class Logger {
515
+ private prefix;
516
+ private level;
517
+ private showTimestamp;
518
+ private showLevel;
519
+ private output;
520
+ /**
521
+ * Create a new Logger instance
522
+ * @param options - Logger configuration
523
+ */
524
+ constructor(options?: LoggerOptions);
525
+ /**
526
+ * Format a log message
527
+ * @param level - Log level
528
+ * @param message - Message to format
529
+ * @returns Formatted message
530
+ */
531
+ private format;
532
+ /**
533
+ * Log a debug message
534
+ * @param message - Message to log
535
+ * @param args - Additional arguments to log
536
+ */
537
+ debug(message: string, ...args: unknown[]): void;
538
+ /**
539
+ * Log an info message
540
+ * @param message - Message to log
541
+ * @param args - Additional arguments to log
542
+ */
543
+ info(message: string, ...args: unknown[]): void;
544
+ /**
545
+ * Log a warning message
546
+ * @param message - Message to log
547
+ * @param args - Additional arguments to log
548
+ */
549
+ warn(message: string, ...args: unknown[]): void;
550
+ /**
551
+ * Log an error message
552
+ * @param message - Message to log
553
+ * @param args - Additional arguments to log
554
+ */
555
+ error(message: string, ...args: unknown[]): void;
556
+ /**
557
+ * Log a success message (always shown unless silent)
558
+ * @param message - Message to log
559
+ */
560
+ success(message: string): void;
561
+ /**
562
+ * Log a failure message (always shown unless silent)
563
+ * @param message - Message to log
564
+ */
565
+ fail(message: string): void;
566
+ /**
567
+ * Create a child logger with a sub-prefix
568
+ * @param prefix - Sub-prefix for the child logger
569
+ * @returns New Logger instance
570
+ */
571
+ child(prefix: string): Logger;
572
+ /**
573
+ * Set the log level
574
+ * @param level - New log level
575
+ */
576
+ setLevel(level: LogLevel): void;
577
+ /**
578
+ * Get the current log level
579
+ * @returns Current log level
580
+ */
581
+ getLevel(): LogLevel;
582
+ /**
583
+ * Check if a log level is enabled
584
+ * @param level - Level to check
585
+ * @returns true if the level would be logged
586
+ */
587
+ isLevelEnabled(level: LogLevel): boolean;
588
+ /**
589
+ * Create a timer for performance logging
590
+ * @param label - Timer label
591
+ * @returns Object with end() method to log duration
592
+ */
593
+ time(label: string): {
594
+ end: () => void;
595
+ };
596
+ /**
597
+ * Log a table of data
598
+ * @param data - Array of objects to display
599
+ * @param columns - Optional column names to show
600
+ */
601
+ table(data: Record<string, unknown>[], columns?: string[]): void;
602
+ /**
603
+ * Log a progress message (overwrites previous line)
604
+ * @param message - Progress message
605
+ */
606
+ progress(message: string): void;
607
+ /**
608
+ * Clear the progress line
609
+ */
610
+ clearProgress(): void;
611
+ /**
612
+ * Log a newline
613
+ */
614
+ newline(): void;
615
+ /**
616
+ * Log a horizontal rule
617
+ * @param char - Character to use for the rule
618
+ * @param width - Width of the rule
619
+ */
620
+ hr(char?: string, width?: number): void;
621
+ /**
622
+ * Group related log messages
623
+ * @param label - Group label
624
+ * @param fn - Function containing log calls
625
+ */
626
+ group(label: string, fn: () => void): void;
627
+ }
628
+
629
+ /**
630
+ * WebSocket client connection
631
+ */
632
+ declare class WebSocketClient extends EventEmitter<{
633
+ message: string;
634
+ binary: Buffer;
635
+ close: {
636
+ code: number;
637
+ reason: string;
638
+ };
639
+ error: Error;
640
+ pong: void;
641
+ }> {
642
+ /** Socket connection */
643
+ private socket;
644
+ /** Whether connection is open */
645
+ private isOpen;
646
+ /** Partial frame buffer */
647
+ private frameBuffer;
648
+ /**
649
+ * Create a new WebSocket client
650
+ * @param socket - TCP socket
651
+ */
652
+ constructor(socket: node_net.Socket);
653
+ /**
654
+ * Set up socket event handlers
655
+ */
656
+ private setupSocketHandlers;
657
+ /**
658
+ * Process received frames
659
+ */
660
+ private processFrames;
661
+ /**
662
+ * Parse a WebSocket frame
663
+ * @returns Parsed frame or null if incomplete
664
+ */
665
+ private parseFrame;
666
+ /**
667
+ * Handle close frame
668
+ * @param payload - Close frame payload
669
+ */
670
+ private handleClose;
671
+ /**
672
+ * Send a pong frame
673
+ * @param payload - Pong payload (echo of ping)
674
+ */
675
+ private sendPong;
676
+ /**
677
+ * Send a WebSocket frame
678
+ * @param opcode - Frame opcode
679
+ * @param payload - Frame payload
680
+ */
681
+ private sendFrame;
682
+ /**
683
+ * Send a text message
684
+ * @param message - Message to send
685
+ */
686
+ send(message: string): void;
687
+ /**
688
+ * Send a binary message
689
+ * @param data - Binary data to send
690
+ */
691
+ sendBinary(data: Buffer): void;
692
+ /**
693
+ * Send a ping frame
694
+ * @param payload - Optional ping payload
695
+ */
696
+ ping(payload?: Buffer): void;
697
+ /**
698
+ * Close the connection
699
+ * @param code - Close code
700
+ * @param reason - Close reason
701
+ */
702
+ close(code?: number, reason?: string): void;
703
+ /**
704
+ * Check if connection is open
705
+ * @returns true if open
706
+ */
707
+ isConnected(): boolean;
708
+ }
709
+ /**
710
+ * WebSocket server events
711
+ */
712
+ interface WebSocketServerEvents {
713
+ /** Index signature for EventMap compatibility */
714
+ [key: string]: unknown;
715
+ connection: WebSocketClient;
716
+ error: Error;
717
+ listening: {
718
+ port: number;
719
+ };
720
+ close: void;
721
+ }
722
+ /**
723
+ * WebSocket server
724
+ */
725
+ declare class WebSocketServer extends EventEmitter<WebSocketServerEvents> {
726
+ /** HTTP server */
727
+ private server;
728
+ /** Connected clients */
729
+ private clients;
730
+ /** Server port */
731
+ private port;
732
+ /**
733
+ * Create a new WebSocket server
734
+ * @param port - Port to listen on
735
+ */
736
+ constructor(port: number);
737
+ /**
738
+ * Set up HTTP server for WebSocket upgrade
739
+ */
740
+ private setupServer;
741
+ /**
742
+ * Handle WebSocket upgrade request
743
+ * @param req - HTTP request
744
+ * @param socket - TCP socket
745
+ * @param head - Upgrade head
746
+ */
747
+ private handleUpgrade;
748
+ /**
749
+ * Generate WebSocket accept key
750
+ * @param key - Client key
751
+ * @returns Accept key
752
+ */
753
+ private generateAcceptKey;
754
+ /**
755
+ * Start the server
756
+ */
757
+ start(): Promise<void>;
758
+ /**
759
+ * Stop the server
760
+ */
761
+ stop(): Promise<void>;
762
+ /**
763
+ * Broadcast message to all clients
764
+ * @param message - Message to broadcast
765
+ */
766
+ broadcast(message: string): void;
767
+ /**
768
+ * Broadcast CLI message to all clients
769
+ * @param message - CLI message to broadcast
770
+ */
771
+ broadcastCLIMessage(message: CLIMessage): void;
772
+ /**
773
+ * Get connected client count
774
+ * @returns Number of connected clients
775
+ */
776
+ getClientCount(): number;
777
+ /**
778
+ * Get all connected clients
779
+ * @returns Array of connected clients
780
+ */
781
+ getClients(): WebSocketClient[];
782
+ }
783
+ /**
784
+ * Create a typed message handler
785
+ * @param client - WebSocket client
786
+ * @param handler - Message handler function
787
+ */
788
+ declare function handleBrowserMessages(client: WebSocketClient, handler: (message: BrowserMessage) => void): void;
789
+
790
+ /**
791
+ * HTTP proxy server for script injection
792
+ * @packageDocumentation
793
+ */
794
+
795
+ /**
796
+ * Proxy server events
797
+ */
798
+ interface ProxyServerEvents {
799
+ /** Index signature for EventMap compatibility */
800
+ [key: string]: unknown;
801
+ /** Server started listening */
802
+ listening: {
803
+ port: number;
804
+ };
805
+ /** Request received */
806
+ request: {
807
+ url: string;
808
+ method: string;
809
+ };
810
+ /** HTML page served with injection */
811
+ inject: {
812
+ url: string;
813
+ };
814
+ /** Error occurred */
815
+ error: Error;
816
+ /** Server closed */
817
+ close: void;
818
+ }
819
+ /**
820
+ * Proxy server options
821
+ */
822
+ interface ProxyOptions {
823
+ /** Target URL to proxy */
824
+ target: string;
825
+ /** Port to listen on */
826
+ port: number;
827
+ /** WebSocket port for injection script */
828
+ wsPort: number;
829
+ /** Injection script content (optional, will use built-in if not provided) */
830
+ injectionScript?: string;
831
+ }
832
+ /**
833
+ * HTTP proxy server that injects ReactCheck scanner into HTML pages
834
+ */
835
+ declare class ProxyServer extends EventEmitter<ProxyServerEvents> {
836
+ /** HTTP server instance */
837
+ private server;
838
+ /** Proxy options */
839
+ private options;
840
+ /** Target URL parsed */
841
+ private targetUrl;
842
+ /** Injection script */
843
+ private injectionScript;
844
+ /**
845
+ * Create a new proxy server
846
+ * @param options - Proxy options
847
+ */
848
+ constructor(options: ProxyOptions);
849
+ /**
850
+ * Build the injection script
851
+ * @returns Injection script string
852
+ */
853
+ private buildInjectionScript;
854
+ /**
855
+ * Handle incoming request
856
+ * @param req - Client request
857
+ * @param res - Server response
858
+ */
859
+ private handleRequest;
860
+ /**
861
+ * Handle ReactCheck special routes
862
+ * @param url - Request URL
863
+ * @param res - Server response
864
+ */
865
+ private handleReactCheckRoute;
866
+ /**
867
+ * Proxy a request to the target
868
+ * @param req - Client request
869
+ * @param res - Server response
870
+ * @param targetUrl - Target URL
871
+ */
872
+ private proxyRequest;
873
+ /**
874
+ * Inject script and respond with modified HTML
875
+ * @param proxyRes - Proxy response
876
+ * @param res - Client response
877
+ * @param url - Request URL
878
+ */
879
+ private injectAndRespond;
880
+ /**
881
+ * Start the proxy server
882
+ */
883
+ start(): Promise<void>;
884
+ /**
885
+ * Stop the proxy server
886
+ */
887
+ stop(): Promise<void>;
888
+ /**
889
+ * Get the proxy URL
890
+ * @returns Local proxy URL
891
+ */
892
+ getProxyUrl(): string;
893
+ /**
894
+ * Update injection script
895
+ * @param script - New injection script
896
+ */
897
+ setInjectionScript(script: string): void;
898
+ }
899
+
900
+ /**
901
+ * Browser launch options
902
+ */
903
+ interface BrowserLaunchOptions {
904
+ /** URL to navigate to */
905
+ url: string;
906
+ /** Run in headless mode */
907
+ headless?: boolean;
908
+ /** Browser window width */
909
+ width?: number;
910
+ /** Browser window height */
911
+ height?: number;
912
+ /** WebSocket port for injection */
913
+ wsPort?: number;
914
+ /** Additional Chrome arguments */
915
+ args?: string[];
916
+ /** Slow down operations by specified ms */
917
+ slowMo?: number;
918
+ /** Timeout for operations in ms */
919
+ timeout?: number;
920
+ }
921
+ /**
922
+ * Browser events
923
+ */
924
+ interface BrowserEvents {
925
+ /** Index signature for EventMap compatibility */
926
+ [key: string]: unknown;
927
+ /** Browser launched successfully */
928
+ launched: void;
929
+ /** Page navigated */
930
+ navigated: {
931
+ url: string;
932
+ };
933
+ /** Page loaded */
934
+ loaded: void;
935
+ /** Console message from page */
936
+ console: {
937
+ type: string;
938
+ text: string;
939
+ };
940
+ /** Error occurred */
941
+ error: Error;
942
+ /** Browser closed */
943
+ closed: void;
944
+ }
945
+ type Browser = puppeteer.Browser;
946
+ type Page = puppeteer.Page;
947
+ /**
948
+ * Browser launcher wrapper around Puppeteer
949
+ */
950
+ declare class BrowserLauncher extends EventEmitter<BrowserEvents> {
951
+ /** Puppeteer browser instance */
952
+ private browser;
953
+ /** Active page */
954
+ private page;
955
+ /** Launch options */
956
+ private options;
957
+ /** Injection script */
958
+ private injectionScript;
959
+ /**
960
+ * Create a new browser launcher
961
+ * @param options - Launch options
962
+ */
963
+ constructor(options: BrowserLaunchOptions);
964
+ /**
965
+ * Set the injection script
966
+ * @param script - Script to inject before page loads
967
+ */
968
+ setInjectionScript(script: string): void;
969
+ /**
970
+ * Launch the browser
971
+ */
972
+ launch(): Promise<void>;
973
+ /**
974
+ * Set up page event handlers
975
+ */
976
+ private setupPageHandlers;
977
+ /**
978
+ * Navigate to a URL
979
+ * @param url - URL to navigate to
980
+ */
981
+ navigate(url: string): Promise<void>;
982
+ /**
983
+ * Execute script in page context
984
+ * @param script - Script to execute
985
+ * @returns Script result
986
+ */
987
+ evaluate<T>(script: string | (() => T)): Promise<T>;
988
+ /**
989
+ * Wait for selector
990
+ * @param selector - CSS selector
991
+ * @param timeout - Timeout in ms
992
+ */
993
+ waitForSelector(selector: string, timeout?: number): Promise<void>;
994
+ /**
995
+ * Take a screenshot
996
+ * @param path - File path to save screenshot
997
+ */
998
+ screenshot(path: string): Promise<void>;
999
+ /**
1000
+ * Reload the page
1001
+ */
1002
+ reload(): Promise<void>;
1003
+ /**
1004
+ * Get current URL
1005
+ * @returns Current page URL
1006
+ */
1007
+ getUrl(): string | null;
1008
+ /**
1009
+ * Close the browser
1010
+ */
1011
+ close(): Promise<void>;
1012
+ /**
1013
+ * Check if browser is open
1014
+ * @returns true if browser is open
1015
+ */
1016
+ isOpen(): boolean;
1017
+ /**
1018
+ * Get the page instance (for advanced usage)
1019
+ * @returns Puppeteer page or null
1020
+ */
1021
+ getPage(): Page | null;
1022
+ /**
1023
+ * Get the browser instance (for advanced usage)
1024
+ * @returns Puppeteer browser or null
1025
+ */
1026
+ getBrowser(): Browser | null;
1027
+ }
1028
+ /**
1029
+ * Check if Puppeteer is available
1030
+ * @returns true if Puppeteer can be imported
1031
+ */
1032
+ declare function isPuppeteerAvailable(): Promise<boolean>;
1033
+
1034
+ /**
1035
+ * Browser-side scanner for React render tracking
1036
+ * @packageDocumentation
1037
+ */
1038
+
1039
+ /**
1040
+ * Browser scanner events
1041
+ */
1042
+ interface BrowserScannerEvents {
1043
+ /** Index signature for EventMap compatibility */
1044
+ [key: string]: unknown;
1045
+ /** Emitted on each render */
1046
+ render: RenderInfo;
1047
+ /** Emitted when scanner is ready */
1048
+ ready: {
1049
+ reactVersion: string;
1050
+ };
1051
+ /** Emitted on error */
1052
+ error: Error;
1053
+ }
1054
+ /**
1055
+ * Browser-side scanner that hooks into React to track renders
1056
+ */
1057
+ declare class BrowserScanner extends EventEmitter<BrowserScannerEvents> {
1058
+ /** Scanner configuration */
1059
+ private config;
1060
+ /** Whether scanner is running */
1061
+ private running;
1062
+ /** React version detected */
1063
+ private reactVersion;
1064
+ /** Previous fiber states for comparison */
1065
+ private prevFiberStates;
1066
+ /** Component render counts */
1067
+ private renderCounts;
1068
+ /** Original DevTools hook methods */
1069
+ private originalOnCommitFiberRoot;
1070
+ /** Window reference */
1071
+ private win;
1072
+ /**
1073
+ * Create a new browser scanner
1074
+ * @param config - Scanner configuration
1075
+ * @param win - Window object (for testing)
1076
+ */
1077
+ constructor(config?: Partial<ScannerConfig>, win?: WindowWithReactDevTools);
1078
+ /**
1079
+ * Start the scanner
1080
+ */
1081
+ start(): void;
1082
+ /**
1083
+ * Stop the scanner
1084
+ */
1085
+ stop(): void;
1086
+ /**
1087
+ * Reset the scanner state
1088
+ */
1089
+ reset(): void;
1090
+ /**
1091
+ * Hook into React DevTools global hook
1092
+ */
1093
+ private hookIntoReact;
1094
+ /**
1095
+ * Install our own hook if DevTools hook is not present
1096
+ */
1097
+ private installHook;
1098
+ /**
1099
+ * Unhook from React
1100
+ */
1101
+ private unhookFromReact;
1102
+ /**
1103
+ * Detect React version from hook
1104
+ * @param hook - DevTools hook
1105
+ * @returns React version string
1106
+ */
1107
+ private detectReactVersion;
1108
+ /**
1109
+ * Process a fiber commit
1110
+ * @param rootFiber - Root fiber of the committed tree
1111
+ */
1112
+ private processCommit;
1113
+ /**
1114
+ * Walk the fiber tree
1115
+ * @param fiber - Current fiber
1116
+ * @param parent - Parent component name
1117
+ */
1118
+ private walkFiber;
1119
+ /**
1120
+ * Process a single fiber
1121
+ * @param fiber - Fiber to process
1122
+ * @param parent - Parent component name
1123
+ */
1124
+ private processFiber;
1125
+ /**
1126
+ * Check if component should be filtered out
1127
+ * @param name - Component name
1128
+ * @returns true if should be filtered
1129
+ */
1130
+ private shouldFilterComponent;
1131
+ /**
1132
+ * Simple glob pattern matching
1133
+ * @param name - Component name
1134
+ * @param pattern - Glob pattern
1135
+ * @returns true if matches
1136
+ */
1137
+ private matchPattern;
1138
+ /**
1139
+ * Get current configuration
1140
+ * @returns Scanner configuration
1141
+ */
1142
+ getConfig(): ScannerConfig;
1143
+ /**
1144
+ * Update configuration
1145
+ * @param config - Partial configuration
1146
+ */
1147
+ configure(config: Partial<ScannerConfig>): void;
1148
+ /**
1149
+ * Check if scanner is running
1150
+ * @returns true if running
1151
+ */
1152
+ isRunning(): boolean;
1153
+ /**
1154
+ * Get detected React version
1155
+ * @returns React version string
1156
+ */
1157
+ getReactVersion(): string;
1158
+ /**
1159
+ * Get render count for a component
1160
+ * @param name - Component name
1161
+ * @returns Render count
1162
+ */
1163
+ getRenderCount(name: string): number;
1164
+ /**
1165
+ * Get all render counts
1166
+ * @returns Map of component names to render counts
1167
+ */
1168
+ getAllRenderCounts(): Map<string, number>;
1169
+ }
1170
+
1171
+ /**
1172
+ * Browser overlay for render visualization
1173
+ * @packageDocumentation
1174
+ */
1175
+
1176
+ /**
1177
+ * Overlay configuration
1178
+ */
1179
+ interface OverlayConfig {
1180
+ /** Whether overlay is enabled */
1181
+ enabled: boolean;
1182
+ /** Whether to highlight renders */
1183
+ highlightRenders: boolean;
1184
+ /** Animation speed */
1185
+ animationSpeed: 'slow' | 'fast' | 'off';
1186
+ /** Whether to show badges */
1187
+ showBadges: boolean;
1188
+ /** Whether to show toolbar */
1189
+ showToolbar: boolean;
1190
+ }
1191
+ /**
1192
+ * Overlay for visualizing React renders in the browser
1193
+ */
1194
+ declare class Overlay {
1195
+ /** Shadow root for isolation */
1196
+ private shadowRoot;
1197
+ /** Host element */
1198
+ private host;
1199
+ /** Overlay configuration */
1200
+ private config;
1201
+ /** Highlight elements */
1202
+ private highlights;
1203
+ /** Badge elements */
1204
+ private badges;
1205
+ /** Render counts for badges */
1206
+ private renderCounts;
1207
+ /** Toolbar element */
1208
+ private toolbar;
1209
+ /** Whether overlay is visible */
1210
+ private visible;
1211
+ /**
1212
+ * Create a new overlay
1213
+ * @param config - Overlay configuration
1214
+ */
1215
+ constructor(config?: Partial<OverlayConfig>);
1216
+ /**
1217
+ * Initialize the overlay
1218
+ */
1219
+ init(): void;
1220
+ /**
1221
+ * Destroy the overlay
1222
+ */
1223
+ destroy(): void;
1224
+ /**
1225
+ * Inject CSS styles into shadow DOM
1226
+ */
1227
+ private injectStyles;
1228
+ /**
1229
+ * Create the floating toolbar
1230
+ */
1231
+ private createToolbar;
1232
+ /**
1233
+ * Set up toolbar event listeners
1234
+ */
1235
+ private setupToolbarEvents;
1236
+ /**
1237
+ * Make an element draggable
1238
+ * @param element - Element to make draggable
1239
+ */
1240
+ private makeDraggable;
1241
+ /**
1242
+ * Highlight a component render
1243
+ * @param render - Render information
1244
+ * @param element - DOM element to highlight
1245
+ */
1246
+ highlight(render: RenderInfo, element: Element): void;
1247
+ /**
1248
+ * Update or create a badge for a component
1249
+ * @param render - Render information
1250
+ * @param rect - Bounding rectangle
1251
+ * @param color - Badge color
1252
+ */
1253
+ private updateBadge;
1254
+ /**
1255
+ * Get severity level for a render
1256
+ * @param render - Render information
1257
+ * @returns Severity level
1258
+ */
1259
+ private getSeverity;
1260
+ /**
1261
+ * Update toolbar stats
1262
+ */
1263
+ private updateStats;
1264
+ /**
1265
+ * Clear all highlights
1266
+ */
1267
+ clearHighlights(): void;
1268
+ /**
1269
+ * Clear all badges
1270
+ */
1271
+ clearBadges(): void;
1272
+ /**
1273
+ * Clear all visualizations
1274
+ */
1275
+ clear(): void;
1276
+ /**
1277
+ * Show the overlay
1278
+ */
1279
+ show(): void;
1280
+ /**
1281
+ * Hide the overlay
1282
+ */
1283
+ hide(): void;
1284
+ /**
1285
+ * Toggle overlay visibility
1286
+ */
1287
+ toggle(): void;
1288
+ /**
1289
+ * Update configuration
1290
+ * @param config - Partial configuration
1291
+ */
1292
+ configure(config: Partial<OverlayConfig>): void;
1293
+ /**
1294
+ * Check if overlay is visible
1295
+ * @returns true if visible
1296
+ */
1297
+ isVisible(): boolean;
1298
+ }
1299
+
1300
+ /**
1301
+ * Browser injection script - main entry point for browser-side code
1302
+ * This file is bundled as an IIFE for injection into target pages
1303
+ * @packageDocumentation
1304
+ */
1305
+
1306
+ /**
1307
+ * Main injector class that coordinates browser-side scanning
1308
+ */
1309
+ declare class ReactCheckInjector {
1310
+ /** Browser scanner instance */
1311
+ private scanner;
1312
+ /** Overlay instance */
1313
+ private overlay;
1314
+ /** WebSocket connection to CLI */
1315
+ private ws;
1316
+ /** WebSocket port */
1317
+ private wsPort;
1318
+ /** Reconnect timeout handle */
1319
+ private reconnectTimeout;
1320
+ /** Whether initialized */
1321
+ private initialized;
1322
+ /**
1323
+ * Create the injector
1324
+ */
1325
+ constructor();
1326
+ /**
1327
+ * Initialize the injector
1328
+ */
1329
+ init(): void;
1330
+ /**
1331
+ * Set up scanner event handlers
1332
+ */
1333
+ private setupScannerEvents;
1334
+ /**
1335
+ * Connect to CLI WebSocket server
1336
+ */
1337
+ private connect;
1338
+ /**
1339
+ * Schedule a reconnection attempt
1340
+ */
1341
+ private scheduleReconnect;
1342
+ /**
1343
+ * Handle message from CLI
1344
+ * @param message - CLI message
1345
+ */
1346
+ private handleMessage;
1347
+ /**
1348
+ * Handle config update
1349
+ * @param config - New configuration
1350
+ */
1351
+ private handleConfig;
1352
+ /**
1353
+ * Send message to CLI
1354
+ * @param message - Browser message
1355
+ */
1356
+ private send;
1357
+ /**
1358
+ * Find DOM element for a component
1359
+ * @param componentName - Component name
1360
+ * @returns DOM element or null
1361
+ */
1362
+ private findDOMElement;
1363
+ /**
1364
+ * Destroy the injector
1365
+ */
1366
+ destroy(): void;
1367
+ }
1368
+
1369
+ /**
1370
+ * ReactCheck - Zero-dependency React Performance Scanner
1371
+ *
1372
+ * A comprehensive tool for scanning, diagnosing, and fixing React performance issues.
1373
+ *
1374
+ * @packageDocumentation
1375
+ */
1376
+
1377
+ declare const VERSION = "1.0.0";
1378
+ /**
1379
+ * Create a new ReactCheck scanner instance with default options
1380
+ *
1381
+ * @example
1382
+ * ```typescript
1383
+ * import { createScanner } from '@oxog/react-check';
1384
+ *
1385
+ * const scanner = createScanner({
1386
+ * thresholds: { critical: 50, warning: 20 }
1387
+ * });
1388
+ *
1389
+ * scanner.on('render', (info) => {
1390
+ * console.log(`${info.componentName} rendered`);
1391
+ * });
1392
+ *
1393
+ * scanner.start();
1394
+ * ```
1395
+ */
1396
+ declare function createScanner(options?: {
1397
+ thresholds?: {
1398
+ critical?: number;
1399
+ warning?: number;
1400
+ };
1401
+ }): Scanner;
1402
+ /**
1403
+ * Create a new report generator
1404
+ *
1405
+ * @example
1406
+ * ```typescript
1407
+ * import { createReportGenerator } from '@oxog/react-check';
1408
+ *
1409
+ * const generator = createReportGenerator({
1410
+ * formats: ['html', 'json'],
1411
+ * output: './reports',
1412
+ * });
1413
+ *
1414
+ * const paths = await generator.saveAll(report);
1415
+ * ```
1416
+ */
1417
+ declare function createReportGenerator(options?: {
1418
+ formats?: Array<'html' | 'json' | 'md'>;
1419
+ output?: string;
1420
+ includeSourceCode?: boolean;
1421
+ }): ReportGenerator;
1422
+ /**
1423
+ * Quick scan a URL and generate a report
1424
+ *
1425
+ * @example
1426
+ * ```typescript
1427
+ * import { quickScan } from '@oxog/react-check';
1428
+ *
1429
+ * const report = await quickScan('http://localhost:3000', {
1430
+ * duration: 30000,
1431
+ * headless: true,
1432
+ * });
1433
+ *
1434
+ * console.log(`Found ${report.summary.criticalIssues} critical issues`);
1435
+ * ```
1436
+ */
1437
+ declare function quickScan(url: string, options?: {
1438
+ duration?: number;
1439
+ headless?: boolean;
1440
+ output?: string;
1441
+ formats?: Array<'html' | 'json' | 'md'>;
1442
+ }): Promise<SessionReport>;
1443
+
1444
+ 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 };