@oxog/react-check 1.2.0 → 1.3.1

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 +129 -0
  2. package/README.md +177 -62
  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-35I3PLS3.js +751 -0
  11. package/dist/chunk-35I3PLS3.js.map +1 -0
  12. package/dist/chunk-7R4KKJTW.cjs +255 -0
  13. package/dist/chunk-7R4KKJTW.cjs.map +1 -0
  14. package/dist/chunk-DSXOHC6R.cjs +755 -0
  15. package/dist/chunk-DSXOHC6R.cjs.map +1 -0
  16. package/dist/chunk-DWM55ACO.cjs +294 -0
  17. package/dist/chunk-DWM55ACO.cjs.map +1 -0
  18. package/dist/chunk-GS7T56RP.cjs +9 -0
  19. package/dist/chunk-GS7T56RP.cjs.map +1 -0
  20. package/dist/chunk-LFY7MUHJ.cjs +483 -0
  21. package/dist/chunk-LFY7MUHJ.cjs.map +1 -0
  22. package/dist/chunk-NLWGB4IE.cjs +380 -0
  23. package/dist/chunk-NLWGB4IE.cjs.map +1 -0
  24. package/dist/chunk-PIXJPQO7.js +481 -0
  25. package/dist/chunk-PIXJPQO7.js.map +1 -0
  26. package/dist/chunk-REEPUD73.js +362 -0
  27. package/dist/chunk-REEPUD73.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 +1195 -297
  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 +8 -2
  45. package/dist/fix.d.ts +8 -2
  46. package/dist/fix.js +2 -719
  47. package/dist/fix.js.map +1 -1
  48. package/dist/index.cjs +1400 -3075
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +237 -57
  51. package/dist/index.d.ts +237 -57
  52. package/dist/index.js +1222 -2970
  53. package/dist/index.js.map +1 -1
  54. package/dist/{scanner-Cc2187fH.d.ts → scanner-BJFA0354.d.ts} +33 -4
  55. package/dist/{scanner-S7BtVIpW.d.cts → scanner-DZL2rIFv.d.cts} +33 -4
  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-BMDemwIs.d.cts} +35 -10
  63. package/dist/{types-DuZyBVVV.d.ts → types-BMDemwIs.d.ts} +35 -10
  64. package/package.json +16 -9
@@ -1,5 +1,5 @@
1
- import { h as ComponentStats, f as Severity, l as ThresholdOptions, R as RenderInfo, j as SessionSummary, c as RenderChainInfo, g as FixSuggestion, d as ScannerConfig } from './types-DuZyBVVV.js';
2
- import { E as EventEmitter } from './event-emitter-CxKUDo9q.js';
1
+ import { h as ComponentStats, f as Severity, l as ThresholdOptions, R as RenderInfo, j as SessionSummary, c as RenderChainInfo, g as FixSuggestion, d as ScannerConfig, o as RuleOptions } from './types-BMDemwIs.js';
2
+ import { E as EventEmitter } from './event-emitter-BVYUPYLd.js';
3
3
 
4
4
  /**
5
5
  * Statistics collector for component render data
@@ -208,6 +208,8 @@ declare class Scanner extends EventEmitter<ScannerEvents> {
208
208
  private chainAnalyzer;
209
209
  /** Fix suggester */
210
210
  private fixSuggester;
211
+ /** Components whose stats changed since their suggestions were last generated */
212
+ private staleSuggestions;
211
213
  /** Scanner configuration */
212
214
  private config;
213
215
  /** Whether scanner is currently running */
@@ -230,6 +232,8 @@ declare class Scanner extends EventEmitter<ScannerEvents> {
230
232
  constructor(options?: {
231
233
  config?: Partial<ScannerConfig>;
232
234
  thresholds?: Partial<ThresholdOptions>;
235
+ /** Fix-suggestion rule levels by rule id (`off` disables a rule) */
236
+ rules?: RuleOptions;
233
237
  });
234
238
  /**
235
239
  * Set up event forwarding from sub-modules
@@ -250,13 +254,32 @@ declare class Scanner extends EventEmitter<ScannerEvents> {
250
254
  /**
251
255
  * Process a render event
252
256
  * @param render - Render information
253
- * @param parent - Optional parent component name
257
+ * @param parent - Optional parent component name (defaults to `render.parent`,
258
+ * which the injected browser script fills in from the fiber tree)
254
259
  */
255
260
  addRender(render: RenderInfo, parent?: string): void;
256
261
  /**
257
- * Record a frame for FPS calculation
262
+ * Check a component name against the configured include/exclude patterns
263
+ * @param name - Component name
264
+ * @returns true if renders of this component should be tracked
265
+ */
266
+ isComponentIncluded(name: string): boolean;
267
+ /**
268
+ * Record a painted frame for FPS calculation (the scanner derives FPS from
269
+ * frames recorded during each one-second window)
258
270
  */
259
271
  recordFrame(): void;
272
+ /**
273
+ * Record an FPS sample measured elsewhere (e.g. by requestAnimationFrame in
274
+ * the browser)
275
+ * @param fps - Frames per second
276
+ */
277
+ recordFps(fps: number): void;
278
+ /**
279
+ * FPS threshold below which `fps-drop` is emitted
280
+ * @returns Threshold
281
+ */
282
+ private getFpsThreshold;
260
283
  /**
261
284
  * Schedule batch processing
262
285
  */
@@ -335,6 +358,12 @@ declare class Scanner extends EventEmitter<ScannerEvents> {
335
358
  * @returns All suggestions
336
359
  */
337
360
  getSuggestions(): FixSuggestion[];
361
+ /**
362
+ * Re-generate cached suggestions whose component received renders since they
363
+ * were created, so their text, numbers and severity match the current stats
364
+ * @param componentName - Only refresh this component (all when omitted)
365
+ */
366
+ private refreshSuggestions;
338
367
  /**
339
368
  * Get suggestions for a specific component
340
369
  * @param componentName - Component name
@@ -1,5 +1,5 @@
1
- import { h as ComponentStats, f as Severity, l as ThresholdOptions, R as RenderInfo, j as SessionSummary, c as RenderChainInfo, g as FixSuggestion, d as ScannerConfig } from './types-DuZyBVVV.cjs';
2
- import { E as EventEmitter } from './event-emitter-CxKUDo9q.cjs';
1
+ import { h as ComponentStats, f as Severity, l as ThresholdOptions, R as RenderInfo, j as SessionSummary, c as RenderChainInfo, g as FixSuggestion, d as ScannerConfig, o as RuleOptions } from './types-BMDemwIs.cjs';
2
+ import { E as EventEmitter } from './event-emitter-BVYUPYLd.cjs';
3
3
 
4
4
  /**
5
5
  * Statistics collector for component render data
@@ -208,6 +208,8 @@ declare class Scanner extends EventEmitter<ScannerEvents> {
208
208
  private chainAnalyzer;
209
209
  /** Fix suggester */
210
210
  private fixSuggester;
211
+ /** Components whose stats changed since their suggestions were last generated */
212
+ private staleSuggestions;
211
213
  /** Scanner configuration */
212
214
  private config;
213
215
  /** Whether scanner is currently running */
@@ -230,6 +232,8 @@ declare class Scanner extends EventEmitter<ScannerEvents> {
230
232
  constructor(options?: {
231
233
  config?: Partial<ScannerConfig>;
232
234
  thresholds?: Partial<ThresholdOptions>;
235
+ /** Fix-suggestion rule levels by rule id (`off` disables a rule) */
236
+ rules?: RuleOptions;
233
237
  });
234
238
  /**
235
239
  * Set up event forwarding from sub-modules
@@ -250,13 +254,32 @@ declare class Scanner extends EventEmitter<ScannerEvents> {
250
254
  /**
251
255
  * Process a render event
252
256
  * @param render - Render information
253
- * @param parent - Optional parent component name
257
+ * @param parent - Optional parent component name (defaults to `render.parent`,
258
+ * which the injected browser script fills in from the fiber tree)
254
259
  */
255
260
  addRender(render: RenderInfo, parent?: string): void;
256
261
  /**
257
- * Record a frame for FPS calculation
262
+ * Check a component name against the configured include/exclude patterns
263
+ * @param name - Component name
264
+ * @returns true if renders of this component should be tracked
265
+ */
266
+ isComponentIncluded(name: string): boolean;
267
+ /**
268
+ * Record a painted frame for FPS calculation (the scanner derives FPS from
269
+ * frames recorded during each one-second window)
258
270
  */
259
271
  recordFrame(): void;
272
+ /**
273
+ * Record an FPS sample measured elsewhere (e.g. by requestAnimationFrame in
274
+ * the browser)
275
+ * @param fps - Frames per second
276
+ */
277
+ recordFps(fps: number): void;
278
+ /**
279
+ * FPS threshold below which `fps-drop` is emitted
280
+ * @returns Threshold
281
+ */
282
+ private getFpsThreshold;
260
283
  /**
261
284
  * Schedule batch processing
262
285
  */
@@ -335,6 +358,12 @@ declare class Scanner extends EventEmitter<ScannerEvents> {
335
358
  * @returns All suggestions
336
359
  */
337
360
  getSuggestions(): FixSuggestion[];
361
+ /**
362
+ * Re-generate cached suggestions whose component received renders since they
363
+ * were created, so their text, numbers and severity match the current stats
364
+ * @param componentName - Only refresh this component (all when omitted)
365
+ */
366
+ private refreshSuggestions;
338
367
  /**
339
368
  * Get suggestions for a specific component
340
369
  * @param componentName - Component name