@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.
Files changed (64) hide show
  1. package/CHANGELOG.md +115 -1
  2. package/README.md +149 -51
  3. package/dist/browser-inject.global.js +705 -158
  4. package/dist/chain.cjs +8 -531
  5. package/dist/chain.cjs.map +1 -1
  6. package/dist/chain.d.cts +2 -2
  7. package/dist/chain.d.ts +2 -2
  8. package/dist/chain.js +2 -533
  9. package/dist/chain.js.map +1 -1
  10. package/dist/chunk-27R56V2S.js +473 -0
  11. package/dist/chunk-27R56V2S.js.map +1 -0
  12. package/dist/chunk-3K2AER5M.cjs +356 -0
  13. package/dist/chunk-3K2AER5M.cjs.map +1 -0
  14. package/dist/chunk-7R4KKJTW.cjs +255 -0
  15. package/dist/chunk-7R4KKJTW.cjs.map +1 -0
  16. package/dist/chunk-7YYMP3PP.js +723 -0
  17. package/dist/chunk-7YYMP3PP.js.map +1 -0
  18. package/dist/chunk-DWM55ACO.cjs +294 -0
  19. package/dist/chunk-DWM55ACO.cjs.map +1 -0
  20. package/dist/chunk-G7YVIPS7.cjs +475 -0
  21. package/dist/chunk-G7YVIPS7.cjs.map +1 -0
  22. package/dist/chunk-GE2ZX7I7.cjs +727 -0
  23. package/dist/chunk-GE2ZX7I7.cjs.map +1 -0
  24. package/dist/chunk-GS7T56RP.cjs +9 -0
  25. package/dist/chunk-GS7T56RP.cjs.map +1 -0
  26. package/dist/chunk-IM6OG2IC.js +338 -0
  27. package/dist/chunk-IM6OG2IC.js.map +1 -0
  28. package/dist/chunk-RQYHXWUC.js +292 -0
  29. package/dist/chunk-RQYHXWUC.js.map +1 -0
  30. package/dist/chunk-WLN7ZVO4.js +253 -0
  31. package/dist/chunk-WLN7ZVO4.js.map +1 -0
  32. package/dist/cli.js +1443 -207
  33. package/dist/cli.js.map +1 -1
  34. package/dist/detect.cjs +22 -324
  35. package/dist/detect.cjs.map +1 -1
  36. package/dist/detect.d.cts +8 -2
  37. package/dist/detect.d.ts +8 -2
  38. package/dist/detect.js +1 -324
  39. package/dist/detect.js.map +1 -1
  40. package/dist/{event-emitter-CxKUDo9q.d.cts → event-emitter-BVYUPYLd.d.cts} +3 -2
  41. package/dist/{event-emitter-CxKUDo9q.d.ts → event-emitter-BVYUPYLd.d.ts} +3 -2
  42. package/dist/fix.cjs +6 -715
  43. package/dist/fix.cjs.map +1 -1
  44. package/dist/fix.d.cts +2 -2
  45. package/dist/fix.d.ts +2 -2
  46. package/dist/fix.js +2 -719
  47. package/dist/fix.js.map +1 -1
  48. package/dist/index.cjs +2380 -3308
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +255 -88
  51. package/dist/index.d.ts +255 -88
  52. package/dist/index.js +2289 -3290
  53. package/dist/index.js.map +1 -1
  54. package/dist/{scanner-CTBraprQ.d.ts → scanner-D0mBQGTx.d.ts} +23 -3
  55. package/dist/{scanner-5j2LEM-q.d.cts → scanner-DUBgwztZ.d.cts} +23 -3
  56. package/dist/scanner.cjs +8 -1652
  57. package/dist/scanner.cjs.map +1 -1
  58. package/dist/scanner.d.cts +3 -3
  59. package/dist/scanner.d.ts +3 -3
  60. package/dist/scanner.js +4 -1656
  61. package/dist/scanner.js.map +1 -1
  62. package/dist/{types-xAXT9cir.d.cts → types-BZ3OeZ-5.d.cts} +28 -10
  63. package/dist/{types-xAXT9cir.d.ts → types-BZ3OeZ-5.d.ts} +28 -10
  64. package/package.json +20 -11
@@ -0,0 +1,727 @@
1
+ 'use strict';
2
+
3
+ var chunkDWM55ACO_cjs = require('./chunk-DWM55ACO.cjs');
4
+ var chunkG7YVIPS7_cjs = require('./chunk-G7YVIPS7.cjs');
5
+ var chunk7R4KKJTW_cjs = require('./chunk-7R4KKJTW.cjs');
6
+
7
+ // src/core/stats.ts
8
+ var DEFAULT_THRESHOLDS = {
9
+ critical: 50,
10
+ warning: 20,
11
+ fps: 30
12
+ };
13
+ var StatsCollector = class extends chunk7R4KKJTW_cjs.EventEmitter {
14
+ /** Map of component names to their statistics */
15
+ components = /* @__PURE__ */ new Map();
16
+ /** Threshold configuration */
17
+ thresholds;
18
+ /** Session start time */
19
+ sessionStart;
20
+ /** Total render count across all components */
21
+ totalRenders = 0;
22
+ /** FPS samples for averaging */
23
+ fpsSamples = [];
24
+ /** Maximum FPS samples to keep */
25
+ maxFpsSamples = 100;
26
+ /**
27
+ * Create a new StatsCollector
28
+ * @param thresholds - Threshold configuration
29
+ */
30
+ constructor(thresholds = {}) {
31
+ super();
32
+ this.thresholds = { ...DEFAULT_THRESHOLDS, ...thresholds };
33
+ this.sessionStart = Date.now();
34
+ }
35
+ /**
36
+ * Add a render event to the statistics
37
+ * @param render - Render information
38
+ */
39
+ addRender(render) {
40
+ const stats = this.getOrCreateStats(render.componentName);
41
+ const previousSeverity = stats.severity;
42
+ stats.renders++;
43
+ this.totalRenders++;
44
+ stats.totalRenderTime += render.renderTime;
45
+ stats.avgRenderTime = stats.totalRenderTime / stats.renders;
46
+ stats.maxRenderTime = Math.max(stats.maxRenderTime, render.renderTime);
47
+ stats.minRenderTime = Math.min(stats.minRenderTime, render.renderTime);
48
+ if (!render.necessary) {
49
+ stats.unnecessary++;
50
+ }
51
+ if (stats.firstRender === 0) {
52
+ stats.firstRender = render.timestamp;
53
+ }
54
+ stats.lastRender = render.timestamp;
55
+ if (render.changedProps && render.changedProps.length > 0) {
56
+ stats.propsChanged = true;
57
+ }
58
+ if (render.changedState && render.changedState.length > 0) {
59
+ stats.stateChanged = true;
60
+ }
61
+ const sessionDuration = Date.now() - this.sessionStart;
62
+ const sessionMinutes = sessionDuration / 6e4;
63
+ stats.expectedRenders = Math.max(1, Math.ceil(sessionMinutes * 5));
64
+ this.updateSeverity(stats);
65
+ this.emit("update", stats);
66
+ if (stats.severity !== previousSeverity) {
67
+ this.emit("severityChange", {
68
+ component: stats.name,
69
+ from: previousSeverity,
70
+ to: stats.severity
71
+ });
72
+ if (stats.severity === "critical" && previousSeverity !== "critical") {
73
+ this.emit("critical", stats);
74
+ } else if (stats.severity === "warning" && previousSeverity === "healthy") {
75
+ this.emit("warning", stats);
76
+ }
77
+ }
78
+ }
79
+ /**
80
+ * Record an FPS sample
81
+ * @param fps - FPS value
82
+ */
83
+ addFpsSample(fps) {
84
+ this.fpsSamples.push(fps);
85
+ if (this.fpsSamples.length > this.maxFpsSamples) {
86
+ this.fpsSamples.shift();
87
+ }
88
+ }
89
+ /**
90
+ * Get or create stats for a component
91
+ * @param name - Component name
92
+ * @returns Component stats
93
+ */
94
+ getOrCreateStats(name) {
95
+ let stats = this.components.get(name);
96
+ if (!stats) {
97
+ stats = this.createEmptyStats(name);
98
+ this.components.set(name, stats);
99
+ }
100
+ return stats;
101
+ }
102
+ /**
103
+ * Create empty stats for a component
104
+ * @param name - Component name
105
+ * @returns Empty component stats
106
+ */
107
+ createEmptyStats(name) {
108
+ return {
109
+ name,
110
+ renders: 0,
111
+ expectedRenders: 1,
112
+ avgRenderTime: 0,
113
+ maxRenderTime: 0,
114
+ minRenderTime: Infinity,
115
+ totalRenderTime: 0,
116
+ unnecessary: 0,
117
+ severity: "healthy",
118
+ chain: [],
119
+ fixes: [],
120
+ firstRender: 0,
121
+ lastRender: 0,
122
+ propsChanged: false,
123
+ stateChanged: false
124
+ };
125
+ }
126
+ /**
127
+ * Update severity for a component based on thresholds
128
+ * @param stats - Component stats to update
129
+ */
130
+ updateSeverity(stats) {
131
+ if (stats.renders >= this.thresholds.critical) {
132
+ stats.severity = "critical";
133
+ } else if (stats.renders >= this.thresholds.warning) {
134
+ stats.severity = "warning";
135
+ } else {
136
+ stats.severity = "healthy";
137
+ }
138
+ }
139
+ /**
140
+ * Get stats for a specific component
141
+ * @param name - Component name
142
+ * @returns Component stats or undefined
143
+ */
144
+ getComponentStats(name) {
145
+ return this.components.get(name);
146
+ }
147
+ /**
148
+ * Get all component stats
149
+ * @returns Array of component stats
150
+ */
151
+ getAllStats() {
152
+ return Array.from(this.components.values());
153
+ }
154
+ /**
155
+ * Get a snapshot of all stats sorted by severity/render count
156
+ * @returns Sorted array of component stats
157
+ */
158
+ getSnapshot() {
159
+ return this.getAllStats().sort((a, b) => {
160
+ const severityOrder = {
161
+ critical: 0,
162
+ warning: 1,
163
+ info: 2,
164
+ healthy: 3
165
+ };
166
+ const severityDiff = severityOrder[a.severity] - severityOrder[b.severity];
167
+ if (severityDiff !== 0) return severityDiff;
168
+ return b.renders - a.renders;
169
+ });
170
+ }
171
+ /**
172
+ * Get components by severity
173
+ * @param severity - Severity level to filter
174
+ * @returns Array of matching component stats
175
+ */
176
+ getComponentsBySeverity(severity) {
177
+ return this.getAllStats().filter((s) => s.severity === severity);
178
+ }
179
+ /**
180
+ * Get session summary
181
+ * @returns Session summary statistics
182
+ */
183
+ getSummary() {
184
+ const stats = this.getAllStats();
185
+ const criticalCount = stats.filter((s) => s.severity === "critical").length;
186
+ const warningCount = stats.filter((s) => s.severity === "warning").length;
187
+ const healthyCount = stats.filter((s) => s.severity === "healthy").length;
188
+ const unnecessaryCount = stats.reduce((sum, s) => sum + s.unnecessary, 0);
189
+ let avgFps = 60;
190
+ let minFps = 60;
191
+ if (this.fpsSamples.length > 0) {
192
+ avgFps = this.fpsSamples.reduce((a, b) => a + b, 0) / this.fpsSamples.length;
193
+ minFps = Math.min(...this.fpsSamples);
194
+ }
195
+ return {
196
+ totalComponents: stats.length,
197
+ totalRenders: this.totalRenders,
198
+ criticalIssues: criticalCount,
199
+ warnings: warningCount,
200
+ healthy: healthyCount,
201
+ avgFps: Math.round(avgFps),
202
+ minFps: Math.round(minFps),
203
+ unnecessaryRenders: unnecessaryCount
204
+ };
205
+ }
206
+ /**
207
+ * Get the most problematic components
208
+ * @param limit - Maximum number to return
209
+ * @returns Top problematic components
210
+ */
211
+ getTopProblems(limit = 10) {
212
+ return this.getSnapshot().filter((s) => s.severity !== "healthy").slice(0, limit);
213
+ }
214
+ /**
215
+ * Update chain information for a component
216
+ * @param componentName - Component name
217
+ * @param chain - Render chain
218
+ */
219
+ setComponentChain(componentName, chain) {
220
+ const stats = this.components.get(componentName);
221
+ if (stats) {
222
+ stats.chain = chain;
223
+ }
224
+ }
225
+ /**
226
+ * Update parent information for a component
227
+ * @param componentName - Component name
228
+ * @param parentName - Parent component name
229
+ */
230
+ setComponentParent(componentName, parentName) {
231
+ const stats = this.components.get(componentName);
232
+ if (stats) {
233
+ stats.parent = parentName;
234
+ }
235
+ }
236
+ /**
237
+ * Reset all statistics
238
+ */
239
+ reset() {
240
+ this.components.clear();
241
+ this.totalRenders = 0;
242
+ this.fpsSamples = [];
243
+ this.sessionStart = Date.now();
244
+ }
245
+ /**
246
+ * Update threshold configuration
247
+ * @param thresholds - New thresholds
248
+ */
249
+ setThresholds(thresholds) {
250
+ this.thresholds = { ...this.thresholds, ...thresholds };
251
+ for (const stats of this.components.values()) {
252
+ const previousSeverity = stats.severity;
253
+ this.updateSeverity(stats);
254
+ if (stats.severity !== previousSeverity) {
255
+ this.emit("severityChange", {
256
+ component: stats.name,
257
+ from: previousSeverity,
258
+ to: stats.severity
259
+ });
260
+ }
261
+ }
262
+ }
263
+ /**
264
+ * Get current thresholds
265
+ * @returns Current threshold configuration
266
+ */
267
+ getThresholds() {
268
+ return { ...this.thresholds };
269
+ }
270
+ /**
271
+ * Get session duration in milliseconds
272
+ * @returns Session duration
273
+ */
274
+ getSessionDuration() {
275
+ return Date.now() - this.sessionStart;
276
+ }
277
+ /**
278
+ * Get total render count
279
+ * @returns Total renders across all components
280
+ */
281
+ getTotalRenders() {
282
+ return this.totalRenders;
283
+ }
284
+ /**
285
+ * Get component count
286
+ * @returns Number of tracked components
287
+ */
288
+ getComponentCount() {
289
+ return this.components.size;
290
+ }
291
+ /**
292
+ * Check if FPS is below threshold
293
+ * @returns true if average FPS is below threshold
294
+ */
295
+ isFpsBelowThreshold() {
296
+ if (this.fpsSamples.length === 0) return false;
297
+ const avgFps = this.fpsSamples.reduce((a, b) => a + b, 0) / this.fpsSamples.length;
298
+ return avgFps < this.thresholds.fps;
299
+ }
300
+ /**
301
+ * Export stats for serialization
302
+ * @returns Serializable stats object
303
+ */
304
+ export() {
305
+ return {
306
+ components: this.getSnapshot(),
307
+ summary: this.getSummary(),
308
+ thresholds: this.getThresholds(),
309
+ sessionDuration: this.getSessionDuration()
310
+ };
311
+ }
312
+ };
313
+
314
+ // src/utils/pattern.ts
315
+ function matchComponentPattern(name, pattern) {
316
+ let source = "";
317
+ let prev = "";
318
+ for (const ch of pattern) {
319
+ if (ch === "*" && prev === "*") continue;
320
+ prev = ch;
321
+ if (ch === "*") source += ".*";
322
+ else if (ch === "?") source += ".";
323
+ else source += ch.replace(/[.+^${}()|[\]\\]/g, "\\$&");
324
+ }
325
+ return new RegExp(`^${source}$`).test(name);
326
+ }
327
+
328
+ // src/core/scanner.ts
329
+ function toRuleLevels(rules) {
330
+ const levels = {};
331
+ for (const [id, setting] of Object.entries(rules)) {
332
+ const level = Array.isArray(setting) ? setting[0] : setting;
333
+ if (level === "off" || level === "warn" || level === "error") {
334
+ levels[id] = level;
335
+ }
336
+ }
337
+ return levels;
338
+ }
339
+ var DEFAULT_CONFIG = {
340
+ trackUnnecessary: true,
341
+ fpsThreshold: 30,
342
+ highlightRenders: true,
343
+ animationSpeed: "fast"
344
+ };
345
+ var DEFAULT_THRESHOLDS2 = {
346
+ critical: 50,
347
+ warning: 20,
348
+ fps: 30
349
+ };
350
+ var Scanner = class extends chunk7R4KKJTW_cjs.EventEmitter {
351
+ /** Statistics collector */
352
+ stats;
353
+ /** Chain analyzer */
354
+ chainAnalyzer;
355
+ /** Fix suggester */
356
+ fixSuggester;
357
+ /** Scanner configuration */
358
+ config;
359
+ /** Whether scanner is currently running */
360
+ running = false;
361
+ /** Last recorded FPS */
362
+ lastFps = 60;
363
+ /** FPS tracking */
364
+ frameCount = 0;
365
+ lastFpsUpdate = 0;
366
+ fpsInterval = null;
367
+ /** Batch processing */
368
+ renderBatch = [];
369
+ batchTimeout = null;
370
+ batchSize = 10;
371
+ batchDelay = 100;
372
+ /**
373
+ * Create a new Scanner instance
374
+ * @param options - Configuration options
375
+ */
376
+ constructor(options = {}) {
377
+ super();
378
+ this.config = { ...DEFAULT_CONFIG, ...options.config };
379
+ const thresholds = { ...DEFAULT_THRESHOLDS2, ...options.thresholds };
380
+ this.stats = new StatsCollector(thresholds);
381
+ this.chainAnalyzer = new chunkDWM55ACO_cjs.ChainAnalyzer();
382
+ this.fixSuggester = new chunkG7YVIPS7_cjs.FixSuggester(options.rules ? { rules: toRuleLevels(options.rules) } : {});
383
+ this.setupEventForwarding();
384
+ }
385
+ /**
386
+ * Set up event forwarding from sub-modules
387
+ */
388
+ setupEventForwarding() {
389
+ this.stats.on("update", (stats) => {
390
+ this.emit("stats", stats);
391
+ });
392
+ this.stats.on("severityChange", (change) => {
393
+ this.emit("severityChange", change);
394
+ const stats = this.stats.getComponentStats(change.component);
395
+ if (stats && (change.to === "critical" || change.to === "warning")) {
396
+ const suggestions = this.fixSuggester.analyze(stats);
397
+ for (const suggestion of suggestions) {
398
+ this.emit("fix", suggestion);
399
+ }
400
+ }
401
+ });
402
+ this.chainAnalyzer.on("chain", (chain) => {
403
+ this.emit("chain", chain);
404
+ for (const componentName of chain.chain) {
405
+ this.stats.setComponentChain(componentName, chain.chain);
406
+ }
407
+ });
408
+ }
409
+ /**
410
+ * Start the scanner
411
+ */
412
+ start() {
413
+ if (this.running) return;
414
+ this.running = true;
415
+ this.lastFpsUpdate = Date.now();
416
+ this.frameCount = 0;
417
+ this.startFpsMonitoring();
418
+ this.emit("start", void 0);
419
+ }
420
+ /**
421
+ * Stop the scanner
422
+ */
423
+ stop() {
424
+ if (!this.running) return;
425
+ this.running = false;
426
+ this.stopFpsMonitoring();
427
+ this.flushBatch();
428
+ this.emit("stop", void 0);
429
+ }
430
+ /**
431
+ * Reset the scanner, clearing all data
432
+ */
433
+ reset() {
434
+ this.stop();
435
+ this.stats.reset();
436
+ this.chainAnalyzer.reset();
437
+ this.fixSuggester.clearSuggestions();
438
+ this.renderBatch = [];
439
+ this.emit("reset", void 0);
440
+ }
441
+ /**
442
+ * Process a render event
443
+ * @param render - Render information
444
+ * @param parent - Optional parent component name
445
+ */
446
+ addRender(render, parent) {
447
+ if (!this.running) return;
448
+ if (!this.isComponentIncluded(render.componentName)) return;
449
+ this.renderBatch.push(render);
450
+ this.stats.addRender(render);
451
+ this.chainAnalyzer.addRender(render, parent);
452
+ this.emit("render", render);
453
+ this.scheduleBatchProcessing();
454
+ }
455
+ /**
456
+ * Check a component name against the configured include/exclude patterns
457
+ * @param name - Component name
458
+ * @returns true if renders of this component should be tracked
459
+ */
460
+ isComponentIncluded(name) {
461
+ const { include, exclude } = this.config;
462
+ if (include && include.length > 0 && !include.some((p) => matchComponentPattern(name, p))) {
463
+ return false;
464
+ }
465
+ if (exclude && exclude.length > 0 && exclude.some((p) => matchComponentPattern(name, p))) {
466
+ return false;
467
+ }
468
+ return true;
469
+ }
470
+ /**
471
+ * Record a painted frame for FPS calculation (the scanner derives FPS from
472
+ * frames recorded during each one-second window)
473
+ */
474
+ recordFrame() {
475
+ this.frameCount++;
476
+ }
477
+ /**
478
+ * Record an FPS sample measured elsewhere (e.g. by requestAnimationFrame in
479
+ * the browser)
480
+ * @param fps - Frames per second
481
+ */
482
+ recordFps(fps) {
483
+ if (!this.running || !Number.isFinite(fps) || fps < 0) return;
484
+ this.lastFps = Math.round(fps);
485
+ this.stats.addFpsSample(this.lastFps);
486
+ if (this.lastFps < this.getFpsThreshold()) {
487
+ this.emit("fps-drop", this.lastFps);
488
+ }
489
+ }
490
+ /**
491
+ * FPS threshold below which `fps-drop` is emitted
492
+ * @returns Threshold
493
+ */
494
+ getFpsThreshold() {
495
+ return this.stats.getThresholds().fps ?? this.config.fpsThreshold;
496
+ }
497
+ /**
498
+ * Schedule batch processing
499
+ */
500
+ scheduleBatchProcessing() {
501
+ if (this.batchTimeout) return;
502
+ if (this.renderBatch.length >= this.batchSize) {
503
+ this.flushBatch();
504
+ } else {
505
+ this.batchTimeout = setTimeout(() => {
506
+ this.flushBatch();
507
+ }, this.batchDelay);
508
+ const timer = this.batchTimeout;
509
+ timer.unref?.();
510
+ }
511
+ }
512
+ /**
513
+ * Flush the render batch
514
+ */
515
+ flushBatch() {
516
+ if (this.batchTimeout) {
517
+ clearTimeout(this.batchTimeout);
518
+ this.batchTimeout = null;
519
+ }
520
+ if (this.renderBatch.length === 0) return;
521
+ this.processBatch(this.renderBatch);
522
+ this.renderBatch = [];
523
+ }
524
+ /**
525
+ * Process a batch of renders for patterns
526
+ * @param batch - Render batch
527
+ */
528
+ processBatch(batch) {
529
+ const byComponent = /* @__PURE__ */ new Map();
530
+ for (const render of batch) {
531
+ const existing = byComponent.get(render.componentName) ?? [];
532
+ existing.push(render);
533
+ byComponent.set(render.componentName, existing);
534
+ }
535
+ for (const [componentName, renders] of byComponent) {
536
+ if (renders.length >= 3) {
537
+ const stats = this.stats.getComponentStats(componentName);
538
+ if (stats) {
539
+ const suggestions = this.fixSuggester.analyze(stats);
540
+ for (const suggestion of suggestions) {
541
+ this.emit("fix", suggestion);
542
+ }
543
+ }
544
+ }
545
+ }
546
+ }
547
+ /**
548
+ * Start FPS monitoring
549
+ */
550
+ startFpsMonitoring() {
551
+ this.fpsInterval = setInterval(() => {
552
+ const now = Date.now();
553
+ const elapsed = now - this.lastFpsUpdate;
554
+ const frames = this.frameCount;
555
+ this.frameCount = 0;
556
+ this.lastFpsUpdate = now;
557
+ if (elapsed > 0 && frames > 0) {
558
+ this.recordFps(frames * 1e3 / elapsed);
559
+ }
560
+ }, 1e3);
561
+ const interval = this.fpsInterval;
562
+ interval.unref?.();
563
+ }
564
+ /**
565
+ * Stop FPS monitoring
566
+ */
567
+ stopFpsMonitoring() {
568
+ if (this.fpsInterval) {
569
+ clearInterval(this.fpsInterval);
570
+ this.fpsInterval = null;
571
+ }
572
+ }
573
+ /**
574
+ * Get current FPS
575
+ * @returns Current FPS value
576
+ */
577
+ getFps() {
578
+ return this.lastFps;
579
+ }
580
+ /**
581
+ * Check if scanner is running
582
+ * @returns true if running
583
+ */
584
+ isRunning() {
585
+ return this.running;
586
+ }
587
+ /**
588
+ * Get scanner configuration
589
+ * @returns Current configuration
590
+ */
591
+ getConfig() {
592
+ return { ...this.config };
593
+ }
594
+ /**
595
+ * Update scanner configuration
596
+ * @param config - Partial configuration to update
597
+ */
598
+ configure(config) {
599
+ this.config = { ...this.config, ...config };
600
+ }
601
+ /**
602
+ * Update threshold configuration
603
+ * @param thresholds - New thresholds
604
+ */
605
+ setThresholds(thresholds) {
606
+ this.stats.setThresholds(thresholds);
607
+ }
608
+ /**
609
+ * Get current thresholds
610
+ * @returns Current threshold configuration
611
+ */
612
+ getThresholds() {
613
+ return this.stats.getThresholds();
614
+ }
615
+ /**
616
+ * Get component statistics
617
+ * @param name - Component name (optional, returns all if not specified)
618
+ * @returns Component stats
619
+ */
620
+ getStats(name) {
621
+ if (name) {
622
+ return this.stats.getComponentStats(name);
623
+ }
624
+ return this.stats.getAllStats();
625
+ }
626
+ /**
627
+ * Get a snapshot of all stats sorted by severity
628
+ * @returns Sorted stats array
629
+ */
630
+ getSnapshot() {
631
+ return this.stats.getSnapshot();
632
+ }
633
+ /**
634
+ * Get session summary
635
+ * @returns Session summary statistics
636
+ */
637
+ getSummary() {
638
+ return this.stats.getSummary();
639
+ }
640
+ /**
641
+ * Get top problematic components
642
+ * @param limit - Maximum number to return
643
+ * @returns Top problems
644
+ */
645
+ getTopProblems(limit = 10) {
646
+ return this.stats.getTopProblems(limit);
647
+ }
648
+ /**
649
+ * Get all fix suggestions
650
+ * @returns All suggestions
651
+ */
652
+ getSuggestions() {
653
+ return this.fixSuggester.getAllSuggestions();
654
+ }
655
+ /**
656
+ * Get suggestions for a specific component
657
+ * @param componentName - Component name
658
+ * @returns Component suggestions
659
+ */
660
+ getComponentSuggestions(componentName) {
661
+ return this.fixSuggester.getSuggestions(componentName);
662
+ }
663
+ /**
664
+ * Set parent relationship for a component
665
+ * @param child - Child component name
666
+ * @param parent - Parent component name
667
+ */
668
+ setParent(child, parent) {
669
+ this.chainAnalyzer.setParent(child, parent);
670
+ this.stats.setComponentParent(child, parent);
671
+ }
672
+ /**
673
+ * Get the render chain for a component
674
+ * @param componentName - Component name
675
+ * @returns Render chain
676
+ */
677
+ getComponentChain(componentName) {
678
+ return this.chainAnalyzer.getComponentChain(componentName);
679
+ }
680
+ /**
681
+ * Get session duration
682
+ * @returns Duration in milliseconds
683
+ */
684
+ getSessionDuration() {
685
+ return this.stats.getSessionDuration();
686
+ }
687
+ /**
688
+ * Export scanner data for reporting
689
+ * @returns Exportable data object
690
+ */
691
+ export() {
692
+ return {
693
+ stats: this.stats.export(),
694
+ suggestions: this.getSuggestions(),
695
+ config: this.getConfig()
696
+ };
697
+ }
698
+ /**
699
+ * Analyze a specific component and generate suggestions
700
+ * @param componentName - Component name
701
+ * @returns Fix suggestions for the component
702
+ */
703
+ analyzeComponent(componentName) {
704
+ const stats = this.stats.getComponentStats(componentName);
705
+ if (!stats) return [];
706
+ return this.fixSuggester.analyze(stats);
707
+ }
708
+ /**
709
+ * Analyze all components and generate suggestions
710
+ * @returns All fix suggestions
711
+ */
712
+ analyzeAll() {
713
+ const allStats = this.stats.getAllStats();
714
+ const allSuggestions = [];
715
+ for (const stats of allStats) {
716
+ const suggestions = this.fixSuggester.analyze(stats);
717
+ allSuggestions.push(...suggestions);
718
+ }
719
+ return allSuggestions;
720
+ }
721
+ };
722
+
723
+ exports.Scanner = Scanner;
724
+ exports.StatsCollector = StatsCollector;
725
+ exports.matchComponentPattern = matchComponentPattern;
726
+ //# sourceMappingURL=chunk-GE2ZX7I7.cjs.map
727
+ //# sourceMappingURL=chunk-GE2ZX7I7.cjs.map