@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.
- package/LICENSE +21 -0
- package/README.md +343 -0
- package/dist/browser-inject.global.js +182 -0
- package/dist/chain.cjs +537 -0
- package/dist/chain.cjs.map +1 -0
- package/dist/chain.d.cts +145 -0
- package/dist/chain.d.ts +145 -0
- package/dist/chain.js +535 -0
- package/dist/chain.js.map +1 -0
- package/dist/cli.js +5591 -0
- package/dist/cli.js.map +1 -0
- package/dist/detect.cjs +331 -0
- package/dist/detect.cjs.map +1 -0
- package/dist/detect.d.cts +68 -0
- package/dist/detect.d.ts +68 -0
- package/dist/detect.js +326 -0
- package/dist/detect.js.map +1 -0
- package/dist/event-emitter-CxKUDo9q.d.cts +119 -0
- package/dist/event-emitter-CxKUDo9q.d.ts +119 -0
- package/dist/fix.cjs +723 -0
- package/dist/fix.cjs.map +1 -0
- package/dist/fix.d.cts +93 -0
- package/dist/fix.d.ts +93 -0
- package/dist/fix.js +721 -0
- package/dist/fix.js.map +1 -0
- package/dist/index.cjs +5647 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1444 -0
- package/dist/index.d.ts +1444 -0
- package/dist/index.js +5579 -0
- package/dist/index.js.map +1 -0
- package/dist/scanner-BsBnFki5.d.cts +383 -0
- package/dist/scanner-bpT7eMcv.d.ts +383 -0
- package/dist/scanner.cjs +1660 -0
- package/dist/scanner.cjs.map +1 -0
- package/dist/scanner.d.cts +3 -0
- package/dist/scanner.d.ts +3 -0
- package/dist/scanner.js +1658 -0
- package/dist/scanner.js.map +1 -0
- package/dist/types-CVcIoqzs.d.cts +474 -0
- package/dist/types-CVcIoqzs.d.ts +474 -0
- package/package.json +127 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { h as ComponentStats, f as Severity, l as ThresholdOptions, R as RenderInfo, j as SessionSummary, d as RenderChainInfo, g as FixSuggestion, c as ScannerConfig } from './types-CVcIoqzs.cjs';
|
|
2
|
+
import { E as EventEmitter } from './event-emitter-CxKUDo9q.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Statistics collector for component render data
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Events emitted by StatsCollector
|
|
11
|
+
*/
|
|
12
|
+
interface StatsEvents {
|
|
13
|
+
/** Index signature for EventMap compatibility */
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
/** Emitted when component stats are updated */
|
|
16
|
+
update: ComponentStats;
|
|
17
|
+
/** Emitted when severity changes */
|
|
18
|
+
severityChange: {
|
|
19
|
+
component: string;
|
|
20
|
+
from: Severity | 'healthy';
|
|
21
|
+
to: Severity | 'healthy';
|
|
22
|
+
};
|
|
23
|
+
/** Emitted when a critical threshold is crossed */
|
|
24
|
+
critical: ComponentStats;
|
|
25
|
+
/** Emitted when a warning threshold is crossed */
|
|
26
|
+
warning: ComponentStats;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Statistics collector that aggregates render data into meaningful stats
|
|
30
|
+
*/
|
|
31
|
+
declare class StatsCollector extends EventEmitter<StatsEvents> {
|
|
32
|
+
/** Map of component names to their statistics */
|
|
33
|
+
private components;
|
|
34
|
+
/** Threshold configuration */
|
|
35
|
+
private thresholds;
|
|
36
|
+
/** Session start time */
|
|
37
|
+
private sessionStart;
|
|
38
|
+
/** Total render count across all components */
|
|
39
|
+
private totalRenders;
|
|
40
|
+
/** FPS samples for averaging */
|
|
41
|
+
private fpsSamples;
|
|
42
|
+
/** Maximum FPS samples to keep */
|
|
43
|
+
private readonly maxFpsSamples;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new StatsCollector
|
|
46
|
+
* @param thresholds - Threshold configuration
|
|
47
|
+
*/
|
|
48
|
+
constructor(thresholds?: Partial<ThresholdOptions>);
|
|
49
|
+
/**
|
|
50
|
+
* Add a render event to the statistics
|
|
51
|
+
* @param render - Render information
|
|
52
|
+
*/
|
|
53
|
+
addRender(render: RenderInfo): void;
|
|
54
|
+
/**
|
|
55
|
+
* Record an FPS sample
|
|
56
|
+
* @param fps - FPS value
|
|
57
|
+
*/
|
|
58
|
+
addFpsSample(fps: number): void;
|
|
59
|
+
/**
|
|
60
|
+
* Get or create stats for a component
|
|
61
|
+
* @param name - Component name
|
|
62
|
+
* @returns Component stats
|
|
63
|
+
*/
|
|
64
|
+
private getOrCreateStats;
|
|
65
|
+
/**
|
|
66
|
+
* Create empty stats for a component
|
|
67
|
+
* @param name - Component name
|
|
68
|
+
* @returns Empty component stats
|
|
69
|
+
*/
|
|
70
|
+
private createEmptyStats;
|
|
71
|
+
/**
|
|
72
|
+
* Update severity for a component based on thresholds
|
|
73
|
+
* @param stats - Component stats to update
|
|
74
|
+
*/
|
|
75
|
+
private updateSeverity;
|
|
76
|
+
/**
|
|
77
|
+
* Get stats for a specific component
|
|
78
|
+
* @param name - Component name
|
|
79
|
+
* @returns Component stats or undefined
|
|
80
|
+
*/
|
|
81
|
+
getComponentStats(name: string): ComponentStats | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Get all component stats
|
|
84
|
+
* @returns Array of component stats
|
|
85
|
+
*/
|
|
86
|
+
getAllStats(): ComponentStats[];
|
|
87
|
+
/**
|
|
88
|
+
* Get a snapshot of all stats sorted by severity/render count
|
|
89
|
+
* @returns Sorted array of component stats
|
|
90
|
+
*/
|
|
91
|
+
getSnapshot(): ComponentStats[];
|
|
92
|
+
/**
|
|
93
|
+
* Get components by severity
|
|
94
|
+
* @param severity - Severity level to filter
|
|
95
|
+
* @returns Array of matching component stats
|
|
96
|
+
*/
|
|
97
|
+
getComponentsBySeverity(severity: Severity | 'healthy'): ComponentStats[];
|
|
98
|
+
/**
|
|
99
|
+
* Get session summary
|
|
100
|
+
* @returns Session summary statistics
|
|
101
|
+
*/
|
|
102
|
+
getSummary(): SessionSummary;
|
|
103
|
+
/**
|
|
104
|
+
* Get the most problematic components
|
|
105
|
+
* @param limit - Maximum number to return
|
|
106
|
+
* @returns Top problematic components
|
|
107
|
+
*/
|
|
108
|
+
getTopProblems(limit?: number): ComponentStats[];
|
|
109
|
+
/**
|
|
110
|
+
* Update chain information for a component
|
|
111
|
+
* @param componentName - Component name
|
|
112
|
+
* @param chain - Render chain
|
|
113
|
+
*/
|
|
114
|
+
setComponentChain(componentName: string, chain: string[]): void;
|
|
115
|
+
/**
|
|
116
|
+
* Update parent information for a component
|
|
117
|
+
* @param componentName - Component name
|
|
118
|
+
* @param parentName - Parent component name
|
|
119
|
+
*/
|
|
120
|
+
setComponentParent(componentName: string, parentName: string): void;
|
|
121
|
+
/**
|
|
122
|
+
* Reset all statistics
|
|
123
|
+
*/
|
|
124
|
+
reset(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Update threshold configuration
|
|
127
|
+
* @param thresholds - New thresholds
|
|
128
|
+
*/
|
|
129
|
+
setThresholds(thresholds: Partial<ThresholdOptions>): void;
|
|
130
|
+
/**
|
|
131
|
+
* Get current thresholds
|
|
132
|
+
* @returns Current threshold configuration
|
|
133
|
+
*/
|
|
134
|
+
getThresholds(): ThresholdOptions;
|
|
135
|
+
/**
|
|
136
|
+
* Get session duration in milliseconds
|
|
137
|
+
* @returns Session duration
|
|
138
|
+
*/
|
|
139
|
+
getSessionDuration(): number;
|
|
140
|
+
/**
|
|
141
|
+
* Get total render count
|
|
142
|
+
* @returns Total renders across all components
|
|
143
|
+
*/
|
|
144
|
+
getTotalRenders(): number;
|
|
145
|
+
/**
|
|
146
|
+
* Get component count
|
|
147
|
+
* @returns Number of tracked components
|
|
148
|
+
*/
|
|
149
|
+
getComponentCount(): number;
|
|
150
|
+
/**
|
|
151
|
+
* Check if FPS is below threshold
|
|
152
|
+
* @returns true if average FPS is below threshold
|
|
153
|
+
*/
|
|
154
|
+
isFpsBelowThreshold(): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Export stats for serialization
|
|
157
|
+
* @returns Serializable stats object
|
|
158
|
+
*/
|
|
159
|
+
export(): {
|
|
160
|
+
components: ComponentStats[];
|
|
161
|
+
summary: SessionSummary;
|
|
162
|
+
thresholds: ThresholdOptions;
|
|
163
|
+
sessionDuration: number;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Core scanner implementation for tracking React renders
|
|
169
|
+
* @packageDocumentation
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Events emitted by Scanner
|
|
174
|
+
*/
|
|
175
|
+
interface ScannerEvents {
|
|
176
|
+
/** Index signature for EventMap compatibility */
|
|
177
|
+
[key: string]: unknown;
|
|
178
|
+
/** Emitted on each render */
|
|
179
|
+
render: RenderInfo;
|
|
180
|
+
/** Emitted when a render chain is detected */
|
|
181
|
+
chain: RenderChainInfo;
|
|
182
|
+
/** Emitted when FPS drops below threshold */
|
|
183
|
+
'fps-drop': number;
|
|
184
|
+
/** Emitted when a fix suggestion is generated */
|
|
185
|
+
fix: FixSuggestion;
|
|
186
|
+
/** Emitted when component stats are updated */
|
|
187
|
+
stats: ComponentStats;
|
|
188
|
+
/** Emitted when scanner starts */
|
|
189
|
+
start: void;
|
|
190
|
+
/** Emitted when scanner stops */
|
|
191
|
+
stop: void;
|
|
192
|
+
/** Emitted when scanner is reset */
|
|
193
|
+
reset: void;
|
|
194
|
+
/** Emitted when severity changes for a component */
|
|
195
|
+
severityChange: {
|
|
196
|
+
component: string;
|
|
197
|
+
from: string;
|
|
198
|
+
to: string;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Core scanner class that coordinates render tracking and analysis
|
|
203
|
+
*/
|
|
204
|
+
declare class Scanner extends EventEmitter<ScannerEvents> {
|
|
205
|
+
/** Statistics collector */
|
|
206
|
+
private stats;
|
|
207
|
+
/** Chain analyzer */
|
|
208
|
+
private chainAnalyzer;
|
|
209
|
+
/** Fix suggester */
|
|
210
|
+
private fixSuggester;
|
|
211
|
+
/** Scanner configuration */
|
|
212
|
+
private config;
|
|
213
|
+
/** Whether scanner is currently running */
|
|
214
|
+
private running;
|
|
215
|
+
/** Last recorded FPS */
|
|
216
|
+
private lastFps;
|
|
217
|
+
/** FPS tracking */
|
|
218
|
+
private frameCount;
|
|
219
|
+
private lastFpsUpdate;
|
|
220
|
+
private fpsInterval;
|
|
221
|
+
/** Batch processing */
|
|
222
|
+
private renderBatch;
|
|
223
|
+
private batchTimeout;
|
|
224
|
+
private readonly batchSize;
|
|
225
|
+
private readonly batchDelay;
|
|
226
|
+
/**
|
|
227
|
+
* Create a new Scanner instance
|
|
228
|
+
* @param options - Configuration options
|
|
229
|
+
*/
|
|
230
|
+
constructor(options?: {
|
|
231
|
+
config?: Partial<ScannerConfig>;
|
|
232
|
+
thresholds?: Partial<ThresholdOptions>;
|
|
233
|
+
});
|
|
234
|
+
/**
|
|
235
|
+
* Set up event forwarding from sub-modules
|
|
236
|
+
*/
|
|
237
|
+
private setupEventForwarding;
|
|
238
|
+
/**
|
|
239
|
+
* Start the scanner
|
|
240
|
+
*/
|
|
241
|
+
start(): void;
|
|
242
|
+
/**
|
|
243
|
+
* Stop the scanner
|
|
244
|
+
*/
|
|
245
|
+
stop(): void;
|
|
246
|
+
/**
|
|
247
|
+
* Reset the scanner, clearing all data
|
|
248
|
+
*/
|
|
249
|
+
reset(): void;
|
|
250
|
+
/**
|
|
251
|
+
* Process a render event
|
|
252
|
+
* @param render - Render information
|
|
253
|
+
* @param parent - Optional parent component name
|
|
254
|
+
*/
|
|
255
|
+
addRender(render: RenderInfo, parent?: string): void;
|
|
256
|
+
/**
|
|
257
|
+
* Record a frame for FPS calculation
|
|
258
|
+
*/
|
|
259
|
+
recordFrame(): void;
|
|
260
|
+
/**
|
|
261
|
+
* Schedule batch processing
|
|
262
|
+
*/
|
|
263
|
+
private scheduleBatchProcessing;
|
|
264
|
+
/**
|
|
265
|
+
* Flush the render batch
|
|
266
|
+
*/
|
|
267
|
+
private flushBatch;
|
|
268
|
+
/**
|
|
269
|
+
* Process a batch of renders for patterns
|
|
270
|
+
* @param batch - Render batch
|
|
271
|
+
*/
|
|
272
|
+
private processBatch;
|
|
273
|
+
/**
|
|
274
|
+
* Start FPS monitoring
|
|
275
|
+
*/
|
|
276
|
+
private startFpsMonitoring;
|
|
277
|
+
/**
|
|
278
|
+
* Stop FPS monitoring
|
|
279
|
+
*/
|
|
280
|
+
private stopFpsMonitoring;
|
|
281
|
+
/**
|
|
282
|
+
* Get current FPS
|
|
283
|
+
* @returns Current FPS value
|
|
284
|
+
*/
|
|
285
|
+
getFps(): number;
|
|
286
|
+
/**
|
|
287
|
+
* Check if scanner is running
|
|
288
|
+
* @returns true if running
|
|
289
|
+
*/
|
|
290
|
+
isRunning(): boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Get scanner configuration
|
|
293
|
+
* @returns Current configuration
|
|
294
|
+
*/
|
|
295
|
+
getConfig(): ScannerConfig;
|
|
296
|
+
/**
|
|
297
|
+
* Update scanner configuration
|
|
298
|
+
* @param config - Partial configuration to update
|
|
299
|
+
*/
|
|
300
|
+
configure(config: Partial<ScannerConfig>): void;
|
|
301
|
+
/**
|
|
302
|
+
* Update threshold configuration
|
|
303
|
+
* @param thresholds - New thresholds
|
|
304
|
+
*/
|
|
305
|
+
setThresholds(thresholds: Partial<ThresholdOptions>): void;
|
|
306
|
+
/**
|
|
307
|
+
* Get current thresholds
|
|
308
|
+
* @returns Current threshold configuration
|
|
309
|
+
*/
|
|
310
|
+
getThresholds(): ThresholdOptions;
|
|
311
|
+
/**
|
|
312
|
+
* Get component statistics
|
|
313
|
+
* @param name - Component name (optional, returns all if not specified)
|
|
314
|
+
* @returns Component stats
|
|
315
|
+
*/
|
|
316
|
+
getStats(name?: string): ComponentStats | ComponentStats[] | undefined;
|
|
317
|
+
/**
|
|
318
|
+
* Get a snapshot of all stats sorted by severity
|
|
319
|
+
* @returns Sorted stats array
|
|
320
|
+
*/
|
|
321
|
+
getSnapshot(): ComponentStats[];
|
|
322
|
+
/**
|
|
323
|
+
* Get session summary
|
|
324
|
+
* @returns Session summary statistics
|
|
325
|
+
*/
|
|
326
|
+
getSummary(): ReturnType<StatsCollector['getSummary']>;
|
|
327
|
+
/**
|
|
328
|
+
* Get top problematic components
|
|
329
|
+
* @param limit - Maximum number to return
|
|
330
|
+
* @returns Top problems
|
|
331
|
+
*/
|
|
332
|
+
getTopProblems(limit?: number): ComponentStats[];
|
|
333
|
+
/**
|
|
334
|
+
* Get all fix suggestions
|
|
335
|
+
* @returns All suggestions
|
|
336
|
+
*/
|
|
337
|
+
getSuggestions(): FixSuggestion[];
|
|
338
|
+
/**
|
|
339
|
+
* Get suggestions for a specific component
|
|
340
|
+
* @param componentName - Component name
|
|
341
|
+
* @returns Component suggestions
|
|
342
|
+
*/
|
|
343
|
+
getComponentSuggestions(componentName: string): FixSuggestion[];
|
|
344
|
+
/**
|
|
345
|
+
* Set parent relationship for a component
|
|
346
|
+
* @param child - Child component name
|
|
347
|
+
* @param parent - Parent component name
|
|
348
|
+
*/
|
|
349
|
+
setParent(child: string, parent: string): void;
|
|
350
|
+
/**
|
|
351
|
+
* Get the render chain for a component
|
|
352
|
+
* @param componentName - Component name
|
|
353
|
+
* @returns Render chain
|
|
354
|
+
*/
|
|
355
|
+
getComponentChain(componentName: string): string[];
|
|
356
|
+
/**
|
|
357
|
+
* Get session duration
|
|
358
|
+
* @returns Duration in milliseconds
|
|
359
|
+
*/
|
|
360
|
+
getSessionDuration(): number;
|
|
361
|
+
/**
|
|
362
|
+
* Export scanner data for reporting
|
|
363
|
+
* @returns Exportable data object
|
|
364
|
+
*/
|
|
365
|
+
export(): {
|
|
366
|
+
stats: ReturnType<StatsCollector['export']>;
|
|
367
|
+
suggestions: FixSuggestion[];
|
|
368
|
+
config: ScannerConfig;
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* Analyze a specific component and generate suggestions
|
|
372
|
+
* @param componentName - Component name
|
|
373
|
+
* @returns Fix suggestions for the component
|
|
374
|
+
*/
|
|
375
|
+
analyzeComponent(componentName: string): FixSuggestion[];
|
|
376
|
+
/**
|
|
377
|
+
* Analyze all components and generate suggestions
|
|
378
|
+
* @returns All fix suggestions
|
|
379
|
+
*/
|
|
380
|
+
analyzeAll(): FixSuggestion[];
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export { Scanner as S, StatsCollector as a, type ScannerEvents as b, type StatsEvents as c };
|