@oxog/reactscope 1.0.0 → 1.1.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 (102) hide show
  1. package/README.md +47 -15
  2. package/dist/{chunk-IFCS6ABF.cjs → chunk-33CBEAOF.cjs} +106 -32
  3. package/dist/chunk-33CBEAOF.cjs.map +1 -0
  4. package/dist/{chunk-JESQX3XO.js → chunk-3Q6YBIBW.js} +28 -2
  5. package/dist/chunk-3Q6YBIBW.js.map +1 -0
  6. package/dist/{chunk-6L3WUS6V.cjs → chunk-6ALDCO2Q.cjs} +28 -2
  7. package/dist/chunk-6ALDCO2Q.cjs.map +1 -0
  8. package/dist/{chunk-4TZAECHG.cjs → chunk-7MVKPUC4.cjs} +5 -21
  9. package/dist/chunk-7MVKPUC4.cjs.map +1 -0
  10. package/dist/chunk-ACLEEAEC.cjs +83 -0
  11. package/dist/chunk-ACLEEAEC.cjs.map +1 -0
  12. package/dist/{chunk-LZO35OCP.js → chunk-AZ6OARKV.js} +2 -2
  13. package/dist/{chunk-LZO35OCP.js.map → chunk-AZ6OARKV.js.map} +1 -1
  14. package/dist/{chunk-KCUWALXE.cjs → chunk-C3IBGU7L.cjs} +5 -2
  15. package/dist/chunk-C3IBGU7L.cjs.map +1 -0
  16. package/dist/{chunk-M65L55OT.js → chunk-C4LJVRF5.js} +11 -8
  17. package/dist/chunk-C4LJVRF5.js.map +1 -0
  18. package/dist/{chunk-MPOQNCGP.js → chunk-E4PZKXY7.js} +5 -21
  19. package/dist/chunk-E4PZKXY7.js.map +1 -0
  20. package/dist/chunk-E7W2FVWO.js +78 -0
  21. package/dist/chunk-E7W2FVWO.js.map +1 -0
  22. package/dist/{chunk-H4W4UBLZ.cjs → chunk-EUYOAT56.cjs} +11 -8
  23. package/dist/chunk-EUYOAT56.cjs.map +1 -0
  24. package/dist/{chunk-RYAIO3BO.js → chunk-F3KDHISM.js} +5 -4
  25. package/dist/chunk-F3KDHISM.js.map +1 -0
  26. package/dist/{chunk-I427KZYN.cjs → chunk-KRRXA4SI.cjs} +2 -2
  27. package/dist/{chunk-I427KZYN.cjs.map → chunk-KRRXA4SI.cjs.map} +1 -1
  28. package/dist/{chunk-U2OPUU5R.js → chunk-MBFJ6ULY.js} +40 -18
  29. package/dist/chunk-MBFJ6ULY.js.map +1 -0
  30. package/dist/chunk-OMETOKM7.cjs +86 -0
  31. package/dist/chunk-OMETOKM7.cjs.map +1 -0
  32. package/dist/chunk-QT2GSPHP.js +21 -0
  33. package/dist/chunk-QT2GSPHP.js.map +1 -0
  34. package/dist/{chunk-OJGWFS55.cjs → chunk-U3TL6KFZ.cjs} +41 -19
  35. package/dist/chunk-U3TL6KFZ.cjs.map +1 -0
  36. package/dist/chunk-UQFSIGZW.cjs +24 -0
  37. package/dist/chunk-UQFSIGZW.cjs.map +1 -0
  38. package/dist/{chunk-6LHJL6MV.js → chunk-W7SGZQRF.js} +106 -32
  39. package/dist/chunk-W7SGZQRF.js.map +1 -0
  40. package/dist/{chunk-ZTO5ZZVE.js → chunk-XWZXCGPY.js} +5 -2
  41. package/dist/chunk-XWZXCGPY.js.map +1 -0
  42. package/dist/chunk-YG5FHHRH.js +80 -0
  43. package/dist/chunk-YG5FHHRH.js.map +1 -0
  44. package/dist/{chunk-QYMRRTSN.cjs → chunk-YL2LJ27D.cjs} +6 -5
  45. package/dist/chunk-YL2LJ27D.cjs.map +1 -0
  46. package/dist/index.cjs +428 -369
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +33 -7
  49. package/dist/index.d.ts +33 -7
  50. package/dist/index.js +403 -343
  51. package/dist/index.js.map +1 -1
  52. package/dist/plugins/console-reporter/index.d.cts +1 -1
  53. package/dist/plugins/console-reporter/index.d.ts +1 -1
  54. package/dist/plugins/dashboard-ui/index.cjs +4 -3
  55. package/dist/plugins/dashboard-ui/index.d.cts +5 -1
  56. package/dist/plugins/dashboard-ui/index.d.ts +5 -1
  57. package/dist/plugins/dashboard-ui/index.js +2 -1
  58. package/dist/plugins/json-exporter/index.cjs +5 -3
  59. package/dist/plugins/json-exporter/index.d.cts +1 -1
  60. package/dist/plugins/json-exporter/index.d.ts +1 -1
  61. package/dist/plugins/json-exporter/index.js +3 -1
  62. package/dist/plugins/lifecycle-tracker/index.cjs +4 -3
  63. package/dist/plugins/lifecycle-tracker/index.d.cts +8 -1
  64. package/dist/plugins/lifecycle-tracker/index.d.ts +8 -1
  65. package/dist/plugins/lifecycle-tracker/index.js +2 -1
  66. package/dist/plugins/memory-tracker/index.d.cts +1 -1
  67. package/dist/plugins/memory-tracker/index.d.ts +1 -1
  68. package/dist/plugins/network-correlator/index.cjs +4 -4
  69. package/dist/plugins/network-correlator/index.d.cts +5 -1
  70. package/dist/plugins/network-correlator/index.d.ts +5 -1
  71. package/dist/plugins/network-correlator/index.js +2 -2
  72. package/dist/plugins/props-differ/index.cjs +4 -3
  73. package/dist/plugins/props-differ/index.d.cts +1 -1
  74. package/dist/plugins/props-differ/index.d.ts +1 -1
  75. package/dist/plugins/props-differ/index.js +2 -1
  76. package/dist/plugins/render-tracker/index.d.cts +1 -1
  77. package/dist/plugins/render-tracker/index.d.ts +1 -1
  78. package/dist/plugins/timeline-recorder/index.cjs +5 -4
  79. package/dist/plugins/timeline-recorder/index.d.cts +1 -1
  80. package/dist/plugins/timeline-recorder/index.d.ts +1 -1
  81. package/dist/plugins/timeline-recorder/index.js +3 -2
  82. package/dist/plugins/wasted-render-detector/index.cjs +4 -3
  83. package/dist/plugins/wasted-render-detector/index.d.cts +5 -8
  84. package/dist/plugins/wasted-render-detector/index.d.ts +5 -8
  85. package/dist/plugins/wasted-render-detector/index.js +2 -1
  86. package/dist/{types-DKPG_emi.d.ts → types-DNhmA1Tk.d.cts} +22 -1
  87. package/dist/{types-DKPG_emi.d.cts → types-DNhmA1Tk.d.ts} +22 -1
  88. package/package.json +20 -9
  89. package/dist/chunk-4TZAECHG.cjs.map +0 -1
  90. package/dist/chunk-6L3WUS6V.cjs.map +0 -1
  91. package/dist/chunk-6LHJL6MV.js.map +0 -1
  92. package/dist/chunk-H4W4UBLZ.cjs.map +0 -1
  93. package/dist/chunk-IFCS6ABF.cjs.map +0 -1
  94. package/dist/chunk-JESQX3XO.js.map +0 -1
  95. package/dist/chunk-KCUWALXE.cjs.map +0 -1
  96. package/dist/chunk-M65L55OT.js.map +0 -1
  97. package/dist/chunk-MPOQNCGP.js.map +0 -1
  98. package/dist/chunk-OJGWFS55.cjs.map +0 -1
  99. package/dist/chunk-QYMRRTSN.cjs.map +0 -1
  100. package/dist/chunk-RYAIO3BO.js.map +0 -1
  101. package/dist/chunk-U2OPUU5R.js.map +0 -1
  102. package/dist/chunk-ZTO5ZZVE.js.map +0 -1
@@ -1,3 +1,5 @@
1
- export { JSONExporterPlugin, createJSONExporterPlugin } from '../../chunk-M65L55OT.js';
1
+ export { JSONExporterPlugin, createJSONExporterPlugin } from '../../chunk-C4LJVRF5.js';
2
+ import '../../chunk-YG5FHHRH.js';
3
+ import '../../chunk-E7W2FVWO.js';
2
4
  //# sourceMappingURL=index.js.map
3
5
  //# sourceMappingURL=index.js.map
@@ -1,16 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunk6L3WUS6V_cjs = require('../../chunk-6L3WUS6V.cjs');
3
+ var chunk6ALDCO2Q_cjs = require('../../chunk-6ALDCO2Q.cjs');
4
+ require('../../chunk-UQFSIGZW.cjs');
4
5
 
5
6
 
6
7
 
7
8
  Object.defineProperty(exports, "LifecycleTrackerPlugin", {
8
9
  enumerable: true,
9
- get: function () { return chunk6L3WUS6V_cjs.LifecycleTrackerPlugin; }
10
+ get: function () { return chunk6ALDCO2Q_cjs.LifecycleTrackerPlugin; }
10
11
  });
11
12
  Object.defineProperty(exports, "createLifecycleTrackerPlugin", {
12
13
  enumerable: true,
13
- get: function () { return chunk6L3WUS6V_cjs.createLifecycleTrackerPlugin; }
14
+ get: function () { return chunk6ALDCO2Q_cjs.createLifecycleTrackerPlugin; }
14
15
  });
15
16
  //# sourceMappingURL=index.cjs.map
16
17
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import { c as Plugin, w as LifecycleEvent, k as MountEvent, l as UnmountEvent, a as Kernel } from '../../types-DKPG_emi.cjs';
1
+ import { c as Plugin, w as LifecycleEvent, k as MountEvent, l as UnmountEvent, a as Kernel } from '../../types-DNhmA1Tk.cjs';
2
2
 
3
3
  interface LifecycleTrackerAPI {
4
4
  [key: string]: unknown;
@@ -22,6 +22,8 @@ declare class LifecycleTrackerPlugin implements Plugin {
22
22
  private kernel;
23
23
  private lifecycleHistory;
24
24
  private maxHistorySize;
25
+ /** Unmounted component ids, oldest first; the oldest are evicted past the limit. */
26
+ private unmounted;
25
27
  readonly api: LifecycleTrackerAPI;
26
28
  readonly hooks: {
27
29
  onMount: (event: MountEvent) => void;
@@ -31,6 +33,11 @@ declare class LifecycleTrackerPlugin implements Plugin {
31
33
  uninstall(): void;
32
34
  private trackMount;
33
35
  private trackUnmount;
36
+ /**
37
+ * Keep metrics of at most `maxHistorySize` unmounted components, so apps that
38
+ * keep mounting new component instances (lists, routes) do not grow without bound.
39
+ */
40
+ private evictUnmounted;
34
41
  private recordLifecycleEvent;
35
42
  private recordLifetime;
36
43
  }
@@ -1,4 +1,4 @@
1
- import { c as Plugin, w as LifecycleEvent, k as MountEvent, l as UnmountEvent, a as Kernel } from '../../types-DKPG_emi.js';
1
+ import { c as Plugin, w as LifecycleEvent, k as MountEvent, l as UnmountEvent, a as Kernel } from '../../types-DNhmA1Tk.js';
2
2
 
3
3
  interface LifecycleTrackerAPI {
4
4
  [key: string]: unknown;
@@ -22,6 +22,8 @@ declare class LifecycleTrackerPlugin implements Plugin {
22
22
  private kernel;
23
23
  private lifecycleHistory;
24
24
  private maxHistorySize;
25
+ /** Unmounted component ids, oldest first; the oldest are evicted past the limit. */
26
+ private unmounted;
25
27
  readonly api: LifecycleTrackerAPI;
26
28
  readonly hooks: {
27
29
  onMount: (event: MountEvent) => void;
@@ -31,6 +33,11 @@ declare class LifecycleTrackerPlugin implements Plugin {
31
33
  uninstall(): void;
32
34
  private trackMount;
33
35
  private trackUnmount;
36
+ /**
37
+ * Keep metrics of at most `maxHistorySize` unmounted components, so apps that
38
+ * keep mounting new component instances (lists, routes) do not grow without bound.
39
+ */
40
+ private evictUnmounted;
34
41
  private recordLifecycleEvent;
35
42
  private recordLifetime;
36
43
  }
@@ -1,3 +1,4 @@
1
- export { LifecycleTrackerPlugin, createLifecycleTrackerPlugin } from '../../chunk-JESQX3XO.js';
1
+ export { LifecycleTrackerPlugin, createLifecycleTrackerPlugin } from '../../chunk-3Q6YBIBW.js';
2
+ import '../../chunk-QT2GSPHP.js';
2
3
  //# sourceMappingURL=index.js.map
3
4
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { c as Plugin, x as MemorySnapshot, z as PotentialLeak, y as MemoryStats, a as Kernel } from '../../types-DKPG_emi.cjs';
1
+ import { c as Plugin, x as MemorySnapshot, z as PotentialLeak, y as MemoryStats, a as Kernel } from '../../types-DNhmA1Tk.cjs';
2
2
 
3
3
  interface MemoryTrackerAPI {
4
4
  [key: string]: unknown;
@@ -1,4 +1,4 @@
1
- import { c as Plugin, x as MemorySnapshot, z as PotentialLeak, y as MemoryStats, a as Kernel } from '../../types-DKPG_emi.js';
1
+ import { c as Plugin, x as MemorySnapshot, z as PotentialLeak, y as MemoryStats, a as Kernel } from '../../types-DNhmA1Tk.js';
2
2
 
3
3
  interface MemoryTrackerAPI {
4
4
  [key: string]: unknown;
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunkOJGWFS55_cjs = require('../../chunk-OJGWFS55.cjs');
4
- require('../../chunk-I427KZYN.cjs');
3
+ var chunkU3TL6KFZ_cjs = require('../../chunk-U3TL6KFZ.cjs');
4
+ require('../../chunk-KRRXA4SI.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "NetworkCorrelatorPlugin", {
9
9
  enumerable: true,
10
- get: function () { return chunkOJGWFS55_cjs.NetworkCorrelatorPlugin; }
10
+ get: function () { return chunkU3TL6KFZ_cjs.NetworkCorrelatorPlugin; }
11
11
  });
12
12
  Object.defineProperty(exports, "createNetworkCorrelatorPlugin", {
13
13
  enumerable: true,
14
- get: function () { return chunkOJGWFS55_cjs.createNetworkCorrelatorPlugin; }
14
+ get: function () { return chunkU3TL6KFZ_cjs.createNetworkCorrelatorPlugin; }
15
15
  });
16
16
  //# sourceMappingURL=index.cjs.map
17
17
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import { c as Plugin, N as NetworkRequest, j as RenderEvent, A as Correlation, B as RequestStats, a as Kernel } from '../../types-DKPG_emi.cjs';
1
+ import { c as Plugin, N as NetworkRequest, j as RenderEvent, A as Correlation, B as RequestStats, a as Kernel } from '../../types-DNhmA1Tk.cjs';
2
2
 
3
3
  interface NetworkCorrelatorAPI {
4
4
  [key: string]: unknown;
@@ -36,7 +36,11 @@ declare class NetworkCorrelatorPlugin implements Plugin {
36
36
  private stopCapturing;
37
37
  private recordRequest;
38
38
  private recordRenderEvent;
39
+ /** Render events carry `Date.now()` timestamps; requests use `performance.now()` time. */
40
+ private toPerformanceTime;
41
+ private isInWindow;
39
42
  private findCorrelations;
43
+ private addCorrelation;
40
44
  private getRequestsForComponent;
41
45
  private getStats;
42
46
  }
@@ -1,4 +1,4 @@
1
- import { c as Plugin, N as NetworkRequest, j as RenderEvent, A as Correlation, B as RequestStats, a as Kernel } from '../../types-DKPG_emi.js';
1
+ import { c as Plugin, N as NetworkRequest, j as RenderEvent, A as Correlation, B as RequestStats, a as Kernel } from '../../types-DNhmA1Tk.js';
2
2
 
3
3
  interface NetworkCorrelatorAPI {
4
4
  [key: string]: unknown;
@@ -36,7 +36,11 @@ declare class NetworkCorrelatorPlugin implements Plugin {
36
36
  private stopCapturing;
37
37
  private recordRequest;
38
38
  private recordRenderEvent;
39
+ /** Render events carry `Date.now()` timestamps; requests use `performance.now()` time. */
40
+ private toPerformanceTime;
41
+ private isInWindow;
39
42
  private findCorrelations;
43
+ private addCorrelation;
40
44
  private getRequestsForComponent;
41
45
  private getStats;
42
46
  }
@@ -1,4 +1,4 @@
1
- export { NetworkCorrelatorPlugin, createNetworkCorrelatorPlugin } from '../../chunk-U2OPUU5R.js';
2
- import '../../chunk-LZO35OCP.js';
1
+ export { NetworkCorrelatorPlugin, createNetworkCorrelatorPlugin } from '../../chunk-MBFJ6ULY.js';
2
+ import '../../chunk-AZ6OARKV.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
@@ -1,16 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunkKCUWALXE_cjs = require('../../chunk-KCUWALXE.cjs');
3
+ var chunkC3IBGU7L_cjs = require('../../chunk-C3IBGU7L.cjs');
4
+ require('../../chunk-UQFSIGZW.cjs');
4
5
 
5
6
 
6
7
 
7
8
  Object.defineProperty(exports, "PropsDifferPlugin", {
8
9
  enumerable: true,
9
- get: function () { return chunkKCUWALXE_cjs.PropsDifferPlugin; }
10
+ get: function () { return chunkC3IBGU7L_cjs.PropsDifferPlugin; }
10
11
  });
11
12
  Object.defineProperty(exports, "createPropsDifferPlugin", {
12
13
  enumerable: true,
13
- get: function () { return chunkKCUWALXE_cjs.createPropsDifferPlugin; }
14
+ get: function () { return chunkC3IBGU7L_cjs.createPropsDifferPlugin; }
14
15
  });
15
16
  //# sourceMappingURL=index.cjs.map
16
17
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import { c as Plugin, r as PropsSnapshot, q as PropsDiff, s as PropChangeStats, m as PropsChangeEvent, a as Kernel } from '../../types-DKPG_emi.cjs';
1
+ import { c as Plugin, r as PropsSnapshot, q as PropsDiff, s as PropChangeStats, m as PropsChangeEvent, a as Kernel } from '../../types-DNhmA1Tk.cjs';
2
2
 
3
3
  interface PropsDifferAPI {
4
4
  [key: string]: unknown;
@@ -1,4 +1,4 @@
1
- import { c as Plugin, r as PropsSnapshot, q as PropsDiff, s as PropChangeStats, m as PropsChangeEvent, a as Kernel } from '../../types-DKPG_emi.js';
1
+ import { c as Plugin, r as PropsSnapshot, q as PropsDiff, s as PropChangeStats, m as PropsChangeEvent, a as Kernel } from '../../types-DNhmA1Tk.js';
2
2
 
3
3
  interface PropsDifferAPI {
4
4
  [key: string]: unknown;
@@ -1,3 +1,4 @@
1
- export { PropsDifferPlugin, createPropsDifferPlugin } from '../../chunk-ZTO5ZZVE.js';
1
+ export { PropsDifferPlugin, createPropsDifferPlugin } from '../../chunk-XWZXCGPY.js';
2
+ import '../../chunk-QT2GSPHP.js';
2
3
  //# sourceMappingURL=index.js.map
3
4
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { c as Plugin, d as RenderRecord, j as RenderEvent, a as Kernel } from '../../types-DKPG_emi.cjs';
1
+ import { c as Plugin, d as RenderRecord, j as RenderEvent, a as Kernel } from '../../types-DNhmA1Tk.cjs';
2
2
 
3
3
  interface RenderTrackerAPI {
4
4
  [key: string]: unknown;
@@ -1,4 +1,4 @@
1
- import { c as Plugin, d as RenderRecord, j as RenderEvent, a as Kernel } from '../../types-DKPG_emi.js';
1
+ import { c as Plugin, d as RenderRecord, j as RenderEvent, a as Kernel } from '../../types-DNhmA1Tk.js';
2
2
 
3
3
  interface RenderTrackerAPI {
4
4
  [key: string]: unknown;
@@ -1,17 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var chunkQYMRRTSN_cjs = require('../../chunk-QYMRRTSN.cjs');
4
- require('../../chunk-I427KZYN.cjs');
3
+ var chunkYL2LJ27D_cjs = require('../../chunk-YL2LJ27D.cjs');
4
+ require('../../chunk-KRRXA4SI.cjs');
5
+ require('../../chunk-ACLEEAEC.cjs');
5
6
 
6
7
 
7
8
 
8
9
  Object.defineProperty(exports, "TimelineRecorderPlugin", {
9
10
  enumerable: true,
10
- get: function () { return chunkQYMRRTSN_cjs.TimelineRecorderPlugin; }
11
+ get: function () { return chunkYL2LJ27D_cjs.TimelineRecorderPlugin; }
11
12
  });
12
13
  Object.defineProperty(exports, "createTimelineRecorderPlugin", {
13
14
  enumerable: true,
14
- get: function () { return chunkQYMRRTSN_cjs.createTimelineRecorderPlugin; }
15
+ get: function () { return chunkYL2LJ27D_cjs.createTimelineRecorderPlugin; }
15
16
  });
16
17
  //# sourceMappingURL=index.cjs.map
17
18
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import { c as Plugin, G as TimelineRecording, F as TimestampedEvent, i as KernelEvent, a as Kernel } from '../../types-DKPG_emi.cjs';
1
+ import { c as Plugin, G as TimelineRecording, F as TimestampedEvent, i as KernelEvent, a as Kernel } from '../../types-DNhmA1Tk.cjs';
2
2
 
3
3
  interface TimelineRecorderAPI {
4
4
  [key: string]: unknown;
@@ -1,4 +1,4 @@
1
- import { c as Plugin, G as TimelineRecording, F as TimestampedEvent, i as KernelEvent, a as Kernel } from '../../types-DKPG_emi.js';
1
+ import { c as Plugin, G as TimelineRecording, F as TimestampedEvent, i as KernelEvent, a as Kernel } from '../../types-DNhmA1Tk.js';
2
2
 
3
3
  interface TimelineRecorderAPI {
4
4
  [key: string]: unknown;
@@ -1,4 +1,5 @@
1
- export { TimelineRecorderPlugin, createTimelineRecorderPlugin } from '../../chunk-RYAIO3BO.js';
2
- import '../../chunk-LZO35OCP.js';
1
+ export { TimelineRecorderPlugin, createTimelineRecorderPlugin } from '../../chunk-F3KDHISM.js';
2
+ import '../../chunk-AZ6OARKV.js';
3
+ import '../../chunk-YG5FHHRH.js';
3
4
  //# sourceMappingURL=index.js.map
4
5
  //# sourceMappingURL=index.js.map
@@ -1,16 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunk4TZAECHG_cjs = require('../../chunk-4TZAECHG.cjs');
3
+ var chunk7MVKPUC4_cjs = require('../../chunk-7MVKPUC4.cjs');
4
+ require('../../chunk-UQFSIGZW.cjs');
4
5
 
5
6
 
6
7
 
7
8
  Object.defineProperty(exports, "WastedRenderDetectorPlugin", {
8
9
  enumerable: true,
9
- get: function () { return chunk4TZAECHG_cjs.WastedRenderDetectorPlugin; }
10
+ get: function () { return chunk7MVKPUC4_cjs.WastedRenderDetectorPlugin; }
10
11
  });
11
12
  Object.defineProperty(exports, "createWastedRenderDetectorPlugin", {
12
13
  enumerable: true,
13
- get: function () { return chunk4TZAECHG_cjs.createWastedRenderDetectorPlugin; }
14
+ get: function () { return chunk7MVKPUC4_cjs.createWastedRenderDetectorPlugin; }
14
15
  });
15
16
  //# sourceMappingURL=index.cjs.map
16
17
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import { c as Plugin, u as WastedRender, v as WastedRenderStats, t as WastedRenderReason, j as RenderEvent, m as PropsChangeEvent, a as Kernel } from '../../types-DKPG_emi.cjs';
1
+ import { c as Plugin, u as WastedRender, v as WastedRenderStats, t as WastedRenderReason, a as Kernel } from '../../types-DNhmA1Tk.cjs';
2
2
 
3
3
  interface WastedRenderDetectorAPI {
4
4
  [key: string]: unknown;
@@ -12,23 +12,20 @@ interface WastedRenderDetectorAPI {
12
12
  }
13
13
  /**
14
14
  * Wasted Render Detector Plugin
15
- * Detects renders where props/state didn't actually change.
15
+ * Records renders where props/state didn't actually change.
16
+ *
17
+ * `withScope` reports re-renders with identical props automatically. Other
18
+ * integrations can call `api.markAsWasted()` or `checkAndMarkWasted()`.
16
19
  */
17
20
  declare class WastedRenderDetectorPlugin implements Plugin {
18
21
  readonly name = "wasted-render-detector";
19
22
  readonly version = "1.0.0";
20
23
  private kernel;
21
24
  private wastedRenders;
22
- private lastPropsChange;
23
25
  private maxHistorySize;
24
26
  readonly api: WastedRenderDetectorAPI;
25
- readonly hooks: {
26
- onRender: (event: RenderEvent) => void;
27
- onPropsChange: (event: PropsChangeEvent) => void;
28
- };
29
27
  install(kernel: Kernel): void;
30
28
  uninstall(): void;
31
- private checkForWastedRender;
32
29
  private recordWastedRender;
33
30
  /**
34
31
  * Check if the last render was wasted based on props comparison.
@@ -1,4 +1,4 @@
1
- import { c as Plugin, u as WastedRender, v as WastedRenderStats, t as WastedRenderReason, j as RenderEvent, m as PropsChangeEvent, a as Kernel } from '../../types-DKPG_emi.js';
1
+ import { c as Plugin, u as WastedRender, v as WastedRenderStats, t as WastedRenderReason, a as Kernel } from '../../types-DNhmA1Tk.js';
2
2
 
3
3
  interface WastedRenderDetectorAPI {
4
4
  [key: string]: unknown;
@@ -12,23 +12,20 @@ interface WastedRenderDetectorAPI {
12
12
  }
13
13
  /**
14
14
  * Wasted Render Detector Plugin
15
- * Detects renders where props/state didn't actually change.
15
+ * Records renders where props/state didn't actually change.
16
+ *
17
+ * `withScope` reports re-renders with identical props automatically. Other
18
+ * integrations can call `api.markAsWasted()` or `checkAndMarkWasted()`.
16
19
  */
17
20
  declare class WastedRenderDetectorPlugin implements Plugin {
18
21
  readonly name = "wasted-render-detector";
19
22
  readonly version = "1.0.0";
20
23
  private kernel;
21
24
  private wastedRenders;
22
- private lastPropsChange;
23
25
  private maxHistorySize;
24
26
  readonly api: WastedRenderDetectorAPI;
25
- readonly hooks: {
26
- onRender: (event: RenderEvent) => void;
27
- onPropsChange: (event: PropsChangeEvent) => void;
28
- };
29
27
  install(kernel: Kernel): void;
30
28
  uninstall(): void;
31
- private checkForWastedRender;
32
29
  private recordWastedRender;
33
30
  /**
34
31
  * Check if the last render was wasted based on props comparison.
@@ -1,3 +1,4 @@
1
- export { WastedRenderDetectorPlugin, createWastedRenderDetectorPlugin } from '../../chunk-MPOQNCGP.js';
1
+ export { WastedRenderDetectorPlugin, createWastedRenderDetectorPlugin } from '../../chunk-E4PZKXY7.js';
2
+ import '../../chunk-QT2GSPHP.js';
2
3
  //# sourceMappingURL=index.js.map
3
4
  //# sourceMappingURL=index.js.map
@@ -214,7 +214,10 @@ interface SerializableMetrics {
214
214
  };
215
215
  }
216
216
  interface SerializableTree {
217
+ /** First top-level component (kept for backwards compatibility). */
217
218
  root: SerializableTreeNode | null;
219
+ /** Every top-level component, in mount order. */
220
+ roots?: SerializableTreeNode[];
218
221
  }
219
222
  interface SerializableTreeNode {
220
223
  id: string;
@@ -241,8 +244,14 @@ interface PluginHooks {
241
244
  }
242
245
  interface KernelOptions {
243
246
  enabled?: boolean;
247
+ /**
248
+ * @deprecated Reserved, has no effect. Only components wrapped with
249
+ * `useScope`, `<Scope>` or `withScope` are tracked.
250
+ */
244
251
  trackAllComponents?: boolean;
252
+ /** Fraction (0-1) of render events forwarded to plugins. */
245
253
  sampleRate?: number;
254
+ /** Upper bound for every history buffer (timeline, render history, ...). */
246
255
  maxHistorySize?: number;
247
256
  }
248
257
  interface Kernel {
@@ -288,7 +297,7 @@ interface EventBus {
288
297
  on<T extends KernelEvent['type']>(eventType: T, handler: (event: Extract<KernelEvent, {
289
298
  type: T;
290
299
  }>) => void): () => void;
291
- off(eventType: string, handler: Function): void;
300
+ off(eventType: string, handler: (...args: never[]) => unknown): void;
292
301
  once<T extends KernelEvent['type']>(eventType: T, handler: (event: Extract<KernelEvent, {
293
302
  type: T;
294
303
  }>) => void): () => void;
@@ -314,12 +323,22 @@ interface ScopeProps {
314
323
  children: React.ReactNode;
315
324
  name?: string;
316
325
  onRender?: (metrics: ComponentMetrics) => void;
326
+ /** @deprecated Has no effect: `<Scope>` cannot see its children's props. Use `withScope` instead. */
317
327
  trackProps?: boolean;
328
+ /** @deprecated Reserved, has no effect. */
318
329
  trackState?: boolean;
319
330
  }
320
331
  interface UseScopeOptions {
332
+ /**
333
+ * The component's props. When given together with `trackProps: true`, changed
334
+ * props are reported as `props-change` events after every committed render.
335
+ */
336
+ props?: Record<string, unknown>;
337
+ /** Report props changes; requires `props`. */
321
338
  trackProps?: boolean;
339
+ /** @deprecated Reserved, has no effect. */
322
340
  trackState?: boolean;
341
+ /** Called after every committed render with the component's metrics. */
323
342
  onRender?: (metrics: ComponentMetrics) => void;
324
343
  }
325
344
  interface ScopeHandle {
@@ -334,7 +353,9 @@ interface ScopeHandle {
334
353
  }
335
354
  interface WithScopeOptions {
336
355
  name?: string;
356
+ /** Report which props changed between renders as `props-change` events. */
337
357
  trackProps?: boolean;
358
+ /** @deprecated Reserved, has no effect. */
338
359
  trackState?: boolean;
339
360
  onRender?: (metrics: ComponentMetrics) => void;
340
361
  }
@@ -214,7 +214,10 @@ interface SerializableMetrics {
214
214
  };
215
215
  }
216
216
  interface SerializableTree {
217
+ /** First top-level component (kept for backwards compatibility). */
217
218
  root: SerializableTreeNode | null;
219
+ /** Every top-level component, in mount order. */
220
+ roots?: SerializableTreeNode[];
218
221
  }
219
222
  interface SerializableTreeNode {
220
223
  id: string;
@@ -241,8 +244,14 @@ interface PluginHooks {
241
244
  }
242
245
  interface KernelOptions {
243
246
  enabled?: boolean;
247
+ /**
248
+ * @deprecated Reserved, has no effect. Only components wrapped with
249
+ * `useScope`, `<Scope>` or `withScope` are tracked.
250
+ */
244
251
  trackAllComponents?: boolean;
252
+ /** Fraction (0-1) of render events forwarded to plugins. */
245
253
  sampleRate?: number;
254
+ /** Upper bound for every history buffer (timeline, render history, ...). */
246
255
  maxHistorySize?: number;
247
256
  }
248
257
  interface Kernel {
@@ -288,7 +297,7 @@ interface EventBus {
288
297
  on<T extends KernelEvent['type']>(eventType: T, handler: (event: Extract<KernelEvent, {
289
298
  type: T;
290
299
  }>) => void): () => void;
291
- off(eventType: string, handler: Function): void;
300
+ off(eventType: string, handler: (...args: never[]) => unknown): void;
292
301
  once<T extends KernelEvent['type']>(eventType: T, handler: (event: Extract<KernelEvent, {
293
302
  type: T;
294
303
  }>) => void): () => void;
@@ -314,12 +323,22 @@ interface ScopeProps {
314
323
  children: React.ReactNode;
315
324
  name?: string;
316
325
  onRender?: (metrics: ComponentMetrics) => void;
326
+ /** @deprecated Has no effect: `<Scope>` cannot see its children's props. Use `withScope` instead. */
317
327
  trackProps?: boolean;
328
+ /** @deprecated Reserved, has no effect. */
318
329
  trackState?: boolean;
319
330
  }
320
331
  interface UseScopeOptions {
332
+ /**
333
+ * The component's props. When given together with `trackProps: true`, changed
334
+ * props are reported as `props-change` events after every committed render.
335
+ */
336
+ props?: Record<string, unknown>;
337
+ /** Report props changes; requires `props`. */
321
338
  trackProps?: boolean;
339
+ /** @deprecated Reserved, has no effect. */
322
340
  trackState?: boolean;
341
+ /** Called after every committed render with the component's metrics. */
323
342
  onRender?: (metrics: ComponentMetrics) => void;
324
343
  }
325
344
  interface ScopeHandle {
@@ -334,7 +353,9 @@ interface ScopeHandle {
334
353
  }
335
354
  interface WithScopeOptions {
336
355
  name?: string;
356
+ /** Report which props changed between renders as `props-change` events. */
337
357
  trackProps?: boolean;
358
+ /** @deprecated Reserved, has no effect. */
338
359
  trackState?: boolean;
339
360
  onRender?: (metrics: ComponentMetrics) => void;
340
361
  }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@oxog/reactscope",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Zero-dependency React performance profiler with micro-kernel plugin architecture",
5
5
  "author": "ersinkoc",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/ersinkoc/reactscope.git"
9
+ "url": "git+https://github.com/ersinkoc/ReactScope.git"
10
10
  },
11
11
  "homepage": "https://reactscope.oxog.dev",
12
12
  "bugs": {
13
- "url": "https://github.com/ersinkoc/reactscope/issues"
13
+ "url": "https://github.com/ersinkoc/ReactScope/issues"
14
14
  },
15
15
  "keywords": [
16
16
  "react",
@@ -135,7 +135,8 @@
135
135
  "types": "./dist/plugins/network-correlator/index.d.cts",
136
136
  "default": "./dist/plugins/network-correlator/index.cjs"
137
137
  }
138
- }
138
+ },
139
+ "./package.json": "./package.json"
139
140
  },
140
141
  "sideEffects": false,
141
142
  "files": [
@@ -149,25 +150,35 @@
149
150
  "test": "vitest run",
150
151
  "test:watch": "vitest",
151
152
  "test:coverage": "vitest run --coverage",
152
- "lint": "tsc --noEmit",
153
- "prepublishOnly": "npm run build && npm run test"
153
+ "test:package": "node scripts/check-package.mjs",
154
+ "lint": "eslint src tests --max-warnings=0",
155
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
156
+ "check": "npm run lint && npm run typecheck && npm run test:coverage",
157
+ "prepublishOnly": "npm run check && npm run build && npm run test:package"
154
158
  },
155
159
  "peerDependencies": {
156
160
  "react": ">=17.0.0",
157
161
  "react-dom": ">=17.0.0"
158
162
  },
163
+ "engines": {
164
+ "node": ">=18"
165
+ },
159
166
  "devDependencies": {
167
+ "@eslint/js": "^9.39.5",
160
168
  "@testing-library/jest-dom": "^6.4.2",
161
169
  "@testing-library/react": "^14.2.1",
170
+ "@types/node": "^20.19.43",
162
171
  "@types/react": "^18.2.55",
163
172
  "@types/react-dom": "^18.2.19",
164
173
  "@vitest/coverage-v8": "^1.2.2",
165
- "happy-dom": "^13.3.8",
174
+ "eslint": "^9.39.5",
175
+ "eslint-plugin-react-hooks": "^5.2.0",
176
+ "happy-dom": "^21.0.4",
166
177
  "react": "^18.2.0",
167
178
  "react-dom": "^18.2.0",
168
179
  "tsup": "^8.0.2",
169
180
  "typescript": "^5.3.3",
181
+ "typescript-eslint": "^8.74.0",
170
182
  "vitest": "^1.2.2"
171
- },
172
- "dependencies": {}
183
+ }
173
184
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/plugins/wasted-render-detector/wasted-render-detector.ts"],"names":[],"mappings":";;;AAyBO,IAAM,6BAAN,MAAmD;AAAA,EAAnD,WAAA,GAAA;AACL,IAAA,IAAA,CAAS,IAAA,GAAO,wBAAA;AAChB,IAAA,IAAA,CAAS,OAAA,GAAU,OAAA;AAEnB,IAAA,IAAA,CAAQ,MAAA,GAAwB,IAAA;AAChC,IAAA,IAAA,CAAQ,aAAA,uBAAoB,GAAA,EAA4B;AACxD,IAAA,IAAA,CAAQ,eAAA,uBAAsB,GAAA,EAAoB;AAClD,IAAA,IAAA,CAAQ,cAAA,GAAiB,GAAA;AAEzB,IAAA,IAAA,CAAS,GAAA,GAA+B;AAAA,MACtC,gBAAA,EAAkB,CAAC,WAA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AAA,IACT;AAEA,IAAA,IAAI,OAAO,MAAM,QAAA,IAAY,OAAO,MAAM,QAAA,IAAY,CAAA,KAAM,IAAA,IAAQ,CAAA,KAAM,IAAA,EAAM;AAC9E,MAAA,OAAO,KAAA;AAAA,IACT;AAEA,IAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,IAAA,CAAK,CAAW,CAAA;AACrC,IAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,IAAA,CAAK,CAAW,CAAA;AAErC,IAAA,IAAI,KAAA,CAAM,MAAA,KAAW,KAAA,CAAM,MAAA,EAAQ;AACjC,MAAA,OAAO,KAAA;AAAA,IACT;AAEA,IAAA,MAAM,IAAA,GAAO,CAAA;AACb,IAAA,MAAM,IAAA,GAAO,CAAA;AAEb,IAAA,KAAA,MAAW,OAAO,KAAA,EAAO;AACvB,MAAA,IAAI,CAAC,MAAA,CAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,MAAM,GAAG,CAAA,IAAK,CAAC,MAAA,CAAO,GAAG,IAAA,CAAK,GAAG,GAAG,IAAA,CAAK,GAAG,CAAC,CAAA,EAAG;AACxF,QAAA,OAAO,KAAA;AAAA,MACT;AAAA,IACF;AAEA,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAKO,SAAS,gCAAA,GAA+D;AAC7E,EAAA,OAAO,IAAI,0BAAA,EAA2B;AACxC","file":"chunk-4TZAECHG.cjs","sourcesContent":["import type {\n Kernel,\n Plugin,\n RenderEvent,\n PropsChangeEvent,\n WastedRender,\n WastedRenderStats,\n WastedRenderReason,\n} from '../../types'\n\nexport interface WastedRenderDetectorAPI {\n [key: string]: unknown\n getWastedRenders(componentId: string): WastedRender[]\n getWastedRenderCount(componentId: string): number\n getWastedRenderPercentage(componentId: string): number\n getAllWastedRenders(): Map<string, WastedRender[]>\n getMostWastefulComponents(limit?: number): WastedRenderStats[]\n clearWastedRenders(componentId?: string): void\n markAsWasted(componentId: string, reason: WastedRenderReason, details?: string): void\n}\n\n/**\n * Wasted Render Detector Plugin\n * Detects renders where props/state didn't actually change.\n */\nexport class WastedRenderDetectorPlugin implements Plugin {\n readonly name = 'wasted-render-detector'\n readonly version = '1.0.0'\n\n private kernel: Kernel | null = null\n private wastedRenders = new Map<string, WastedRender[]>()\n private lastPropsChange = new Map<string, number>()\n private maxHistorySize = 100\n\n readonly api: WastedRenderDetectorAPI = {\n getWastedRenders: (componentId: string) => {\n return this.wastedRenders.get(componentId) ?? []\n },\n\n getWastedRenderCount: (componentId: string) => {\n return this.wastedRenders.get(componentId)?.length ?? 0\n },\n\n getWastedRenderPercentage: (componentId: string) => {\n const metrics = this.kernel?.getMetrics().get(componentId)\n if (!metrics || metrics.renderCount === 0) {\n return 0\n }\n const wastedCount = this.wastedRenders.get(componentId)?.length ?? 0\n return (wastedCount / metrics.renderCount) * 100\n },\n\n getAllWastedRenders: () => {\n return new Map(this.wastedRenders)\n },\n\n getMostWastefulComponents: (limit = 10) => {\n const stats: WastedRenderStats[] = []\n\n for (const [componentId, wasted] of this.wastedRenders) {\n const metrics = this.kernel?.getMetrics().get(componentId)\n if (!metrics) continue\n\n stats.push({\n componentId,\n componentName: metrics.componentName,\n wastedCount: wasted.length,\n wastedPercentage: metrics.renderCount > 0 ? (wasted.length / metrics.renderCount) * 100 : 0,\n })\n }\n\n return stats.sort((a, b) => b.wastedCount - a.wastedCount).slice(0, limit)\n },\n\n clearWastedRenders: (componentId?: string) => {\n if (componentId) {\n this.wastedRenders.delete(componentId)\n } else {\n this.wastedRenders.clear()\n }\n },\n\n markAsWasted: (componentId: string, reason: WastedRenderReason, details?: string) => {\n this.recordWastedRender(componentId, reason, details ?? '')\n },\n }\n\n readonly hooks = {\n onRender: (event: RenderEvent) => {\n this.checkForWastedRender(event)\n },\n\n onPropsChange: (event: PropsChangeEvent) => {\n this.lastPropsChange.set(event.componentId, event.timestamp)\n },\n }\n\n install(kernel: Kernel): void {\n this.kernel = kernel\n this.maxHistorySize = kernel.getOptions().maxHistorySize ?? 100\n }\n\n uninstall(): void {\n this.kernel = null\n this.wastedRenders.clear()\n this.lastPropsChange.clear()\n }\n\n private checkForWastedRender(event: RenderEvent): void {\n if (!this.kernel) return\n\n // Skip mount phase - first render is never wasted\n if (event.phase === 'mount') {\n return\n }\n\n const lastChange = this.lastPropsChange.get(event.componentId)\n\n // If there's been no props change since the last render, this might be wasted\n // We use a small time window to account for timing differences\n const timeWindow = 5 // ms\n\n if (!lastChange || event.timestamp - lastChange > timeWindow) {\n // No recent props change - this render might be wasted\n // However, state changes or context changes could also cause renders\n // For now, we'll be conservative and only mark as wasted if explicitly told\n // or if we can verify props were unchanged\n\n // We'll mark this as potentially wasted based on no recent props changes\n // The actual determination should be done at the component level\n }\n }\n\n private recordWastedRender(\n componentId: string,\n reason: WastedRenderReason,\n details: string\n ): void {\n if (!this.kernel) return\n\n const metrics = this.kernel.getMetrics().get(componentId)\n\n const wastedRender: WastedRender = {\n timestamp: Date.now(),\n reason,\n details,\n componentId,\n componentName: metrics?.componentName ?? 'Unknown',\n }\n\n let wasted = this.wastedRenders.get(componentId)\n if (!wasted) {\n wasted = []\n this.wastedRenders.set(componentId, wasted)\n }\n\n wasted.push(wastedRender)\n\n // Limit history size\n if (wasted.length > this.maxHistorySize) {\n this.wastedRenders.set(componentId, wasted.slice(-this.maxHistorySize))\n }\n\n // Update metrics\n this.kernel.updateMetrics(componentId, {\n wastedRenderCount: (metrics?.wastedRenderCount ?? 0) + 1,\n })\n\n // Update render history to mark as wasted\n if (metrics && metrics.renderHistory.length > 0) {\n const lastRecord = metrics.renderHistory[metrics.renderHistory.length - 1]\n if (lastRecord) {\n lastRecord.wasWasted = true\n }\n }\n }\n\n /**\n * Check if the last render was wasted based on props comparison.\n */\n checkAndMarkWasted(\n componentId: string,\n prevProps: unknown,\n nextProps: unknown,\n prevState?: unknown,\n nextState?: unknown\n ): boolean {\n // Check props\n if (prevProps === nextProps || this.shallowEqual(prevProps, nextProps)) {\n // Check state if provided\n if (prevState === undefined && nextState === undefined) {\n this.recordWastedRender(componentId, 'props-unchanged', 'Props are shallow equal')\n return true\n }\n\n if (prevState === nextState || this.shallowEqual(prevState, nextState)) {\n this.recordWastedRender(\n componentId,\n 'props-unchanged',\n 'Both props and state are shallow equal'\n )\n return true\n }\n }\n\n return false\n }\n\n private shallowEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) {\n return true\n }\n\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {\n return false\n }\n\n const keysA = Object.keys(a as object)\n const keysB = Object.keys(b as object)\n\n if (keysA.length !== keysB.length) {\n return false\n }\n\n const objA = a as Record<string, unknown>\n const objB = b as Record<string, unknown>\n\n for (const key of keysA) {\n if (!Object.prototype.hasOwnProperty.call(objB, key) || !Object.is(objA[key], objB[key])) {\n return false\n }\n }\n\n return true\n }\n}\n\n/**\n * Create a new wasted render detector plugin instance.\n */\nexport function createWastedRenderDetectorPlugin(): WastedRenderDetectorPlugin {\n return new WastedRenderDetectorPlugin()\n}\n"]}