@oxog/react-check 1.2.0 → 1.3.0

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