@buoy-gg/highlight-updates 7.0.40 → 7.0.42

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 (110) hide show
  1. package/README.md +11 -67
  2. package/lib/commonjs/highlight-updates/HighlightUpdatesOverlay.js +1 -281
  3. package/lib/commonjs/highlight-updates/components/HighlightFilterView.js +1 -1474
  4. package/lib/commonjs/highlight-updates/components/HighlightUpdatesModal.js +1 -641
  5. package/lib/commonjs/highlight-updates/components/IdentifierBadge.js +1 -273
  6. package/lib/commonjs/highlight-updates/components/IsolatedRenderList.js +1 -188
  7. package/lib/commonjs/highlight-updates/components/ModalHeaderContent.js +1 -293
  8. package/lib/commonjs/highlight-updates/components/RenderCauseBadge.js +1 -508
  9. package/lib/commonjs/highlight-updates/components/RenderDetailView.js +1 -846
  10. package/lib/commonjs/highlight-updates/components/RenderHistoryViewer.js +1 -915
  11. package/lib/commonjs/highlight-updates/components/RenderListItem.js +1 -235
  12. package/lib/commonjs/highlight-updates/components/RendersCopySettingsView.js +1 -469
  13. package/lib/commonjs/highlight-updates/components/StatsDisplay.js +1 -73
  14. package/lib/commonjs/highlight-updates/types/copySettings.js +1 -107
  15. package/lib/commonjs/highlight-updates/utils/CommitProfiler.js +1 -446
  16. package/lib/commonjs/highlight-updates/utils/HighlightUpdatesController.js +1 -1920
  17. package/lib/commonjs/highlight-updates/utils/PerformanceLogger.js +26 -359
  18. package/lib/commonjs/highlight-updates/utils/ProfilerInterceptor.js +1 -371
  19. package/lib/commonjs/highlight-updates/utils/RenderCauseDetector.js +5 -1840
  20. package/lib/commonjs/highlight-updates/utils/RenderTracker.js +1 -952
  21. package/lib/commonjs/highlight-updates/utils/ViewTypeMapper.js +1 -264
  22. package/lib/commonjs/highlight-updates/utils/copySettingsStorage.js +1 -32
  23. package/lib/commonjs/highlight-updates/utils/devtoolsComponentNames.js +1 -188
  24. package/lib/commonjs/highlight-updates/utils/namedComposite.js +1 -41
  25. package/lib/commonjs/highlight-updates/utils/ownStateChanged.js +1 -103
  26. package/lib/commonjs/highlight-updates/utils/rawEventEmitter.js +1 -50
  27. package/lib/commonjs/highlight-updates/utils/rawEventEmitter.web.js +1 -0
  28. package/lib/commonjs/highlight-updates/utils/renderExportFormatter.js +1 -58
  29. package/lib/commonjs/highlight-updates/utils/rendersExportFormatter.js +1 -485
  30. package/lib/commonjs/highlight-updates/utils/screenElements.js +1 -1248
  31. package/lib/commonjs/highlight-updates/utils/tapMatch.js +1 -83
  32. package/lib/commonjs/highlight-updates/utils/testIDs.js +1 -68
  33. package/lib/commonjs/highlight-updates/utils/touchCapture.js +1 -277
  34. package/lib/commonjs/index.js +1 -429
  35. package/lib/commonjs/preset.js +1 -278
  36. package/lib/commonjs/sync/highlightUpdatesSyncAdapter.js +1 -235
  37. package/lib/module/highlight-updates/HighlightUpdatesOverlay.js +1 -274
  38. package/lib/module/highlight-updates/components/HighlightFilterView.js +1 -1468
  39. package/lib/module/highlight-updates/components/HighlightUpdatesModal.js +1 -634
  40. package/lib/module/highlight-updates/components/IdentifierBadge.js +1 -265
  41. package/lib/module/highlight-updates/components/IsolatedRenderList.js +1 -183
  42. package/lib/module/highlight-updates/components/ModalHeaderContent.js +1 -288
  43. package/lib/module/highlight-updates/components/RenderCauseBadge.js +1 -499
  44. package/lib/module/highlight-updates/components/RenderDetailView.js +1 -840
  45. package/lib/module/highlight-updates/components/RenderHistoryViewer.js +1 -908
  46. package/lib/module/highlight-updates/components/RenderListItem.js +1 -230
  47. package/lib/module/highlight-updates/components/RendersCopySettingsView.js +1 -465
  48. package/lib/module/highlight-updates/components/StatsDisplay.js +1 -70
  49. package/lib/module/highlight-updates/types/copySettings.js +1 -102
  50. package/lib/module/highlight-updates/utils/CommitProfiler.js +1 -442
  51. package/lib/module/highlight-updates/utils/HighlightUpdatesController.js +1 -1916
  52. package/lib/module/highlight-updates/utils/PerformanceLogger.js +26 -353
  53. package/lib/module/highlight-updates/utils/ProfilerInterceptor.js +1 -358
  54. package/lib/module/highlight-updates/utils/RenderCauseDetector.js +5 -1830
  55. package/lib/module/highlight-updates/utils/RenderTracker.js +1 -949
  56. package/lib/module/highlight-updates/utils/ViewTypeMapper.js +1 -255
  57. package/lib/module/highlight-updates/utils/copySettingsStorage.js +1 -26
  58. package/lib/module/highlight-updates/utils/devtoolsComponentNames.js +1 -178
  59. package/lib/module/highlight-updates/utils/namedComposite.js +1 -36
  60. package/lib/module/highlight-updates/utils/ownStateChanged.js +1 -98
  61. package/lib/module/highlight-updates/utils/rawEventEmitter.js +1 -46
  62. package/lib/module/highlight-updates/utils/rawEventEmitter.web.js +1 -0
  63. package/lib/module/highlight-updates/utils/renderExportFormatter.js +1 -54
  64. package/lib/module/highlight-updates/utils/rendersExportFormatter.js +1 -478
  65. package/lib/module/highlight-updates/utils/screenElements.js +1 -1242
  66. package/lib/module/highlight-updates/utils/tapMatch.js +1 -76
  67. package/lib/module/highlight-updates/utils/testIDs.js +1 -60
  68. package/lib/module/highlight-updates/utils/touchCapture.js +1 -270
  69. package/lib/module/index.js +1 -130
  70. package/lib/module/preset.js +1 -272
  71. package/lib/module/sync/highlightUpdatesSyncAdapter.js +1 -230
  72. package/lib/typescript/highlight-updates/utils/HighlightUpdatesController.d.ts +0 -26
  73. package/lib/typescript/highlight-updates/utils/rawEventEmitter.web.d.ts +3 -0
  74. package/lib/typescript/highlight-updates/utils/screenElements.d.ts +0 -19
  75. package/lib/web/index.mjs +38 -0
  76. package/package.json +34 -14
  77. package/lib/typescript/highlight-updates/HighlightUpdatesOverlay.d.ts.map +0 -1
  78. package/lib/typescript/highlight-updates/components/HighlightFilterView.d.ts.map +0 -1
  79. package/lib/typescript/highlight-updates/components/HighlightUpdatesModal.d.ts.map +0 -1
  80. package/lib/typescript/highlight-updates/components/IdentifierBadge.d.ts.map +0 -1
  81. package/lib/typescript/highlight-updates/components/IsolatedRenderList.d.ts.map +0 -1
  82. package/lib/typescript/highlight-updates/components/ModalHeaderContent.d.ts.map +0 -1
  83. package/lib/typescript/highlight-updates/components/RenderCauseBadge.d.ts.map +0 -1
  84. package/lib/typescript/highlight-updates/components/RenderDetailView.d.ts.map +0 -1
  85. package/lib/typescript/highlight-updates/components/RenderHistoryViewer.d.ts.map +0 -1
  86. package/lib/typescript/highlight-updates/components/RenderListItem.d.ts.map +0 -1
  87. package/lib/typescript/highlight-updates/components/RendersCopySettingsView.d.ts.map +0 -1
  88. package/lib/typescript/highlight-updates/components/StatsDisplay.d.ts.map +0 -1
  89. package/lib/typescript/highlight-updates/types/copySettings.d.ts.map +0 -1
  90. package/lib/typescript/highlight-updates/utils/CommitProfiler.d.ts.map +0 -1
  91. package/lib/typescript/highlight-updates/utils/HighlightUpdatesController.d.ts.map +0 -1
  92. package/lib/typescript/highlight-updates/utils/PerformanceLogger.d.ts.map +0 -1
  93. package/lib/typescript/highlight-updates/utils/ProfilerInterceptor.d.ts.map +0 -1
  94. package/lib/typescript/highlight-updates/utils/RenderCauseDetector.d.ts.map +0 -1
  95. package/lib/typescript/highlight-updates/utils/RenderTracker.d.ts.map +0 -1
  96. package/lib/typescript/highlight-updates/utils/ViewTypeMapper.d.ts.map +0 -1
  97. package/lib/typescript/highlight-updates/utils/copySettingsStorage.d.ts.map +0 -1
  98. package/lib/typescript/highlight-updates/utils/devtoolsComponentNames.d.ts.map +0 -1
  99. package/lib/typescript/highlight-updates/utils/namedComposite.d.ts.map +0 -1
  100. package/lib/typescript/highlight-updates/utils/ownStateChanged.d.ts.map +0 -1
  101. package/lib/typescript/highlight-updates/utils/rawEventEmitter.d.ts.map +0 -1
  102. package/lib/typescript/highlight-updates/utils/renderExportFormatter.d.ts.map +0 -1
  103. package/lib/typescript/highlight-updates/utils/rendersExportFormatter.d.ts.map +0 -1
  104. package/lib/typescript/highlight-updates/utils/screenElements.d.ts.map +0 -1
  105. package/lib/typescript/highlight-updates/utils/tapMatch.d.ts.map +0 -1
  106. package/lib/typescript/highlight-updates/utils/testIDs.d.ts.map +0 -1
  107. package/lib/typescript/highlight-updates/utils/touchCapture.d.ts.map +0 -1
  108. package/lib/typescript/index.d.ts.map +0 -1
  109. package/lib/typescript/preset.d.ts.map +0 -1
  110. package/lib/typescript/sync/highlightUpdatesSyncAdapter.d.ts.map +0 -1
@@ -1,353 +1,26 @@
1
- /**
2
- * PerformanceLogger
3
- *
4
- * Dedicated performance measurement utility for the Highlight Updates feature.
5
- * Tracks timing metrics across the render detection pipeline to identify bottlenecks
6
- * and measure optimization improvements.
7
- *
8
- * Usage:
9
- * PerformanceLogger.setEnabled(true); // Enable logging
10
- * const batch = PerformanceLogger.startBatch(nodesReceived);
11
- * batch.markFilteringComplete(nodesFiltered, nodesToProcess);
12
- * batch.markMeasurementComplete(successCount, failCount);
13
- * batch.markTrackingComplete();
14
- * batch.markCallbackComplete();
15
- * batch.finish(); // Logs the complete metrics
16
- */
17
-
18
- "use strict";
19
-
20
- // Declare performance API available in React Native's JavaScript environment
21
- // Track the last event timestamp to measure end-to-end latency
22
- let lastEventTimestamp = 0;
23
- let pendingBatchId = null;
24
-
25
- /**
26
- * Call this when a traceUpdates event is received to track end-to-end latency
27
- */
28
- export function markEventReceived() {
29
- lastEventTimestamp = performance.now();
30
- return lastEventTimestamp;
31
- }
32
-
33
- /**
34
- * Call this from the overlay when highlights are actually rendered
35
- */
36
- export function markOverlayRendered(highlightCount, renderTime) {
37
- if (lastEventTimestamp > 0 && highlightCount > 0) {
38
- // Reset to avoid double-counting (end-to-end logging removed - silent by default)
39
- lastEventTimestamp = 0;
40
- }
41
- }
42
-
43
- // Rolling statistics for summary logging
44
-
45
- class PerformanceLoggerSingleton {
46
- enabled = false;
47
- batchCounter = 0;
48
- listeners = new Set();
49
-
50
- // Rolling stats for periodic summaries
51
- rollingStats = {
52
- batchCount: 0,
53
- totalNodes: 0,
54
- totalFiltered: 0,
55
- totalProcessed: 0,
56
- totalTime: 0,
57
- maxTime: 0,
58
- minTime: Infinity,
59
- avgMeasurementTime: 0
60
- };
61
-
62
- // Recent batch history for analysis
63
- recentBatches = [];
64
- MAX_HISTORY = 100;
65
-
66
- // Summary logging interval
67
- summaryInterval = null;
68
- SUMMARY_INTERVAL_MS = 10000; // Log summary every 10s
69
-
70
- /**
71
- * Enable or disable performance logging
72
- */
73
- setEnabled(enabled) {
74
- const wasEnabled = this.enabled;
75
- this.enabled = enabled;
76
- if (enabled && !wasEnabled) {
77
- this.resetStats();
78
- // Summary interval removed - no periodic logging
79
- } else if (!enabled && wasEnabled) {
80
- this.stopSummaryInterval();
81
- }
82
- // Silent enable/disable - no console logs
83
- }
84
-
85
- /**
86
- * Check if logging is enabled
87
- */
88
- isEnabled() {
89
- return this.enabled;
90
- }
91
-
92
- /**
93
- * Start timing a new batch of render updates
94
- */
95
- startBatch(nodesReceived, batchSize) {
96
- const batchId = `batch_${++this.batchCounter}`;
97
- const startTime = performance.now();
98
- let filteringEndTime = null;
99
- let measurementStartTime = null;
100
- let measurementEndTime = null;
101
- let trackingEndTime = null;
102
- let callbackEndTime = null;
103
- let nodesFiltered = 0;
104
- let nodesToProcess = 0;
105
- let measurementSuccessCount = 0;
106
- let measurementFailCount = 0;
107
- let overlayRenderTime;
108
- const timer = {
109
- markFilteringComplete: (filtered, toProcess) => {
110
- filteringEndTime = performance.now();
111
- nodesFiltered = filtered;
112
- nodesToProcess = toProcess;
113
- },
114
- markMeasurementStart: () => {
115
- measurementStartTime = performance.now();
116
- },
117
- markMeasurementComplete: (success, fail) => {
118
- measurementEndTime = performance.now();
119
- measurementSuccessCount = success;
120
- measurementFailCount = fail;
121
- },
122
- markTrackingComplete: () => {
123
- trackingEndTime = performance.now();
124
- },
125
- markCallbackComplete: () => {
126
- callbackEndTime = performance.now();
127
- },
128
- setOverlayRenderTime: timeMs => {
129
- overlayRenderTime = timeMs;
130
- },
131
- getBatchId: () => batchId,
132
- finish: () => {
133
- const endTime = performance.now();
134
- const metrics = {
135
- batchId,
136
- timestamp: Date.now(),
137
- nodesReceived,
138
- nodesFiltered,
139
- nodesToProcess,
140
- batchSize,
141
- nodesInBatch: Math.min(nodesToProcess, batchSize),
142
- filteringTime: filteringEndTime ? filteringEndTime - startTime : 0,
143
- measurementTime: measurementStartTime && measurementEndTime ? measurementEndTime - measurementStartTime : 0,
144
- trackingTime: measurementEndTime && trackingEndTime ? trackingEndTime - measurementEndTime : 0,
145
- callbackTime: trackingEndTime && callbackEndTime ? callbackEndTime - trackingEndTime : 0,
146
- totalTime: endTime - startTime,
147
- measurementSuccessCount,
148
- measurementFailCount,
149
- overlayRenderTime
150
- };
151
- if (this.enabled) {
152
- this.recordMetrics(metrics);
153
- }
154
- return metrics;
155
- }
156
- };
157
- return timer;
158
- }
159
-
160
- /**
161
- * Record metrics and log them
162
- */
163
- recordMetrics(metrics) {
164
- // Update rolling stats
165
- this.rollingStats.batchCount++;
166
- this.rollingStats.totalNodes += metrics.nodesReceived;
167
- this.rollingStats.totalFiltered += metrics.nodesFiltered;
168
- this.rollingStats.totalProcessed += metrics.nodesInBatch;
169
- this.rollingStats.totalTime += metrics.totalTime;
170
- this.rollingStats.maxTime = Math.max(this.rollingStats.maxTime, metrics.totalTime);
171
- this.rollingStats.minTime = Math.min(this.rollingStats.minTime, metrics.totalTime);
172
-
173
- // Update rolling average for measurement time
174
- const prevAvg = this.rollingStats.avgMeasurementTime;
175
- const n = this.rollingStats.batchCount;
176
- this.rollingStats.avgMeasurementTime = prevAvg + (metrics.measurementTime - prevAvg) / n;
177
-
178
- // Store in history
179
- this.recentBatches.push(metrics);
180
- if (this.recentBatches.length > this.MAX_HISTORY) {
181
- this.recentBatches.shift();
182
- }
183
-
184
- // Notify listeners
185
- this.notifyListeners(metrics);
186
- }
187
-
188
- /**
189
- * Log a single batch's metrics
190
- */
191
- logBatch(metrics) {
192
- const {
193
- batchId,
194
- nodesReceived,
195
- nodesFiltered,
196
- nodesInBatch,
197
- batchSize,
198
- filteringTime,
199
- measurementTime,
200
- trackingTime,
201
- callbackTime,
202
- totalTime,
203
- measurementSuccessCount,
204
- measurementFailCount,
205
- overlayRenderTime
206
- } = metrics;
207
-
208
- // Compact single-line log for quick scanning
209
- console.log(`[HighlightPerf] ${batchId} | ` + `In:${nodesReceived} Filt:${nodesFiltered} Proc:${nodesInBatch}/${batchSize} | ` + `Filter:${filteringTime.toFixed(1)}ms Measure:${measurementTime.toFixed(1)}ms ` + `Track:${trackingTime.toFixed(1)}ms Callback:${callbackTime.toFixed(1)}ms | ` + `Total:${totalTime.toFixed(1)}ms` + (overlayRenderTime ? ` Render:${overlayRenderTime.toFixed(1)}ms` : "") + ` | Success:${measurementSuccessCount} Fail:${measurementFailCount}`);
210
-
211
- // Flag slow batches
212
- if (totalTime > 100) {
213
- console.warn(`[HighlightPerf] ⚠️ SLOW BATCH: ${totalTime.toFixed(1)}ms - ` + `Measurement phase: ${measurementTime.toFixed(1)}ms (${(measurementTime / totalTime * 100).toFixed(0)}%)`);
214
- }
215
- }
216
-
217
- /**
218
- * Log periodic summary stats
219
- */
220
- logSummary() {
221
- if (this.rollingStats.batchCount === 0) return;
222
- const stats = this.rollingStats;
223
- const avgTime = stats.totalTime / stats.batchCount;
224
- const avgNodes = stats.totalNodes / stats.batchCount;
225
- console.log(`\n[HighlightPerf] ════════ SUMMARY (last ${this.SUMMARY_INTERVAL_MS / 1000}s) ════════\n` + ` Batches: ${stats.batchCount}\n` + ` Avg nodes/batch: ${avgNodes.toFixed(1)} (filtered: ${(stats.totalFiltered / stats.batchCount).toFixed(1)})\n` + ` Avg total time: ${avgTime.toFixed(1)}ms\n` + ` Avg measurement time: ${stats.avgMeasurementTime.toFixed(1)}ms\n` + ` Min/Max time: ${stats.minTime.toFixed(1)}ms / ${stats.maxTime.toFixed(1)}ms\n` + `══════════════════════════════════════════════\n`);
226
-
227
- // Reset rolling stats for next interval
228
- this.resetStats();
229
- }
230
-
231
- /**
232
- * Reset rolling statistics
233
- */
234
- resetStats() {
235
- this.rollingStats = {
236
- batchCount: 0,
237
- totalNodes: 0,
238
- totalFiltered: 0,
239
- totalProcessed: 0,
240
- totalTime: 0,
241
- maxTime: 0,
242
- minTime: Infinity,
243
- avgMeasurementTime: 0
244
- };
245
- }
246
-
247
- /**
248
- * Start the summary logging interval
249
- */
250
- startSummaryInterval() {
251
- this.stopSummaryInterval();
252
- this.summaryInterval = setInterval(() => {
253
- this.logSummary();
254
- }, this.SUMMARY_INTERVAL_MS);
255
- }
256
-
257
- /**
258
- * Stop the summary logging interval
259
- */
260
- stopSummaryInterval() {
261
- if (this.summaryInterval) {
262
- clearInterval(this.summaryInterval);
263
- this.summaryInterval = null;
264
- }
265
- }
266
-
267
- /**
268
- * Subscribe to metrics updates
269
- */
270
- subscribe(listener) {
271
- this.listeners.add(listener);
272
- return () => {
273
- this.listeners.delete(listener);
274
- };
275
- }
276
-
277
- /**
278
- * Notify all listeners of new metrics
279
- */
280
- notifyListeners(metrics) {
281
- for (const listener of this.listeners) {
282
- try {
283
- listener(metrics);
284
- } catch (error) {
285
- console.error("[HighlightPerf] Error in metrics listener:", error);
286
- }
287
- }
288
- }
289
-
290
- /**
291
- * Get recent batch history
292
- */
293
- getRecentBatches() {
294
- return [...this.recentBatches];
295
- }
296
-
297
- /**
298
- * Get current rolling stats
299
- */
300
- getRollingStats() {
301
- return {
302
- ...this.rollingStats
303
- };
304
- }
305
-
306
- /**
307
- * Clear all history and stats
308
- */
309
- clear() {
310
- this.recentBatches = [];
311
- this.resetStats();
312
- this.batchCounter = 0;
313
- }
314
-
315
- /**
316
- * Generate a detailed report of recent performance
317
- */
318
- generateReport() {
319
- const batches = this.recentBatches;
320
- if (batches.length === 0) {
321
- return "No performance data collected yet.";
322
- }
323
- const totalTime = batches.reduce((sum, b) => sum + b.totalTime, 0);
324
- const avgTime = totalTime / batches.length;
325
- const totalMeasureTime = batches.reduce((sum, b) => sum + b.measurementTime, 0);
326
- const avgMeasureTime = totalMeasureTime / batches.length;
327
- const slowBatches = batches.filter(b => b.totalTime > 100);
328
- const fastBatches = batches.filter(b => b.totalTime < 20);
329
- const report = `
330
- ╔══════════════════════════════════════════════════════════════╗
331
- ║ HIGHLIGHT UPDATES PERFORMANCE REPORT ║
332
- ╠══════════════════════════════════════════════════════════════╣
333
- ║ Total batches analyzed: ${batches.length.toString().padStart(5)} ║
334
- ║ Average total time: ${avgTime.toFixed(1).padStart(5)}ms ║
335
- ║ Average measure time: ${avgMeasureTime.toFixed(1).padStart(5)}ms (${(avgMeasureTime / avgTime * 100).toFixed(0)}% of total) ║
336
- ╠══════════════════════════════════════════════════════════════╣
337
- ║ Fast batches (<20ms): ${fastBatches.length.toString().padStart(5)} (${(fastBatches.length / batches.length * 100).toFixed(0)}%) ║
338
- ║ Slow batches (>100ms): ${slowBatches.length.toString().padStart(5)} (${(slowBatches.length / batches.length * 100).toFixed(0)}%) ║
339
- ╠══════════════════════════════════════════════════════════════╣
340
- ║ Time breakdown (avg): ║
341
- ║ Filtering: ${batches.reduce((s, b) => s + b.filteringTime, 0 / batches.length).toFixed(1).padStart(6)}ms ║
342
- ║ Measurement: ${avgMeasureTime.toFixed(1).padStart(6)}ms ← Primary bottleneck ║
343
- ║ Tracking: ${(batches.reduce((s, b) => s + b.trackingTime, 0) / batches.length).toFixed(1).padStart(6)}ms ║
344
- ║ Callback: ${(batches.reduce((s, b) => s + b.callbackTime, 0) / batches.length).toFixed(1).padStart(6)}ms ║
345
- ╚══════════════════════════════════════════════════════════════╝
346
- `;
347
- return report;
348
- }
349
- }
350
-
351
- // Export singleton instance
352
- export const PerformanceLogger = new PerformanceLoggerSingleton();
353
- export default PerformanceLogger;
1
+ "use strict";let S=0;let p=null;export function markEventReceived(){S=performance.now();return S}export function markOverlayRendered(f,t){if(S>0&&f>0){S=0}}class b{enabled=false;batchCounter=0;listeners=new Set;rollingStats={batchCount:0,totalNodes:0,totalFiltered:0,totalProcessed:0,totalTime:0,maxTime:0,minTime:Infinity,avgMeasurementTime:0};recentBatches=[];MAX_HISTORY=100;summaryInterval=null;SUMMARY_INTERVAL_MS=1e4;setEnabled(t){const a=this.enabled;this.enabled=t;if(t&&!a){this.resetStats()}else if(!t&&a){this.stopSummaryInterval()}}isEnabled(){return this.enabled}startBatch(t,a){const i=`batch_${++this.batchCounter}`;const h=performance.now();let o=null;let l=null;let r=null;let s=null;let e=null;let n=0;let m=0;let u=0;let T=0;let g;const F={markFilteringComplete:(c,d)=>{o=performance.now();n=c;m=d},markMeasurementStart:()=>{l=performance.now()},markMeasurementComplete:(c,d)=>{r=performance.now();u=c;T=d},markTrackingComplete:()=>{s=performance.now()},markCallbackComplete:()=>{e=performance.now()},setOverlayRenderTime:c=>{g=c},getBatchId:()=>i,finish:()=>{const c=performance.now();const d={batchId:i,timestamp:Date.now(),nodesReceived:t,nodesFiltered:n,nodesToProcess:m,batchSize:a,nodesInBatch:Math.min(m,a),filteringTime:o?o-h:0,measurementTime:l&&r?r-l:0,trackingTime:r&&s?s-r:0,callbackTime:s&&e?e-s:0,totalTime:c-h,measurementSuccessCount:u,measurementFailCount:T,overlayRenderTime:g};if(this.enabled){this.recordMetrics(d)}return d}};return F}recordMetrics(t){this.rollingStats.batchCount++;this.rollingStats.totalNodes+=t.nodesReceived;this.rollingStats.totalFiltered+=t.nodesFiltered;this.rollingStats.totalProcessed+=t.nodesInBatch;this.rollingStats.totalTime+=t.totalTime;this.rollingStats.maxTime=Math.max(this.rollingStats.maxTime,t.totalTime);this.rollingStats.minTime=Math.min(this.rollingStats.minTime,t.totalTime);const a=this.rollingStats.avgMeasurementTime;const i=this.rollingStats.batchCount;this.rollingStats.avgMeasurementTime=a+(t.measurementTime-a)/i;this.recentBatches.push(t);if(this.recentBatches.length>this.MAX_HISTORY){this.recentBatches.shift()}this.notifyListeners(t)}logBatch(t){const{batchId:a,nodesReceived:i,nodesFiltered:h,nodesInBatch:o,batchSize:l,filteringTime:r,measurementTime:s,trackingTime:e,callbackTime:n,totalTime:m,measurementSuccessCount:u,measurementFailCount:T,overlayRenderTime:g}=t;console.log(`[HighlightPerf] ${a} | In:${i} Filt:${h} Proc:${o}/${l} | Filter:${r.toFixed(1)}ms Measure:${s.toFixed(1)}ms Track:${e.toFixed(1)}ms Callback:${n.toFixed(1)}ms | Total:${m.toFixed(1)}ms`+(g?` Render:${g.toFixed(1)}ms`:"")+` | Success:${u} Fail:${T}`);if(m>100){console.warn(`[HighlightPerf] \u26A0\uFE0F SLOW BATCH: ${m.toFixed(1)}ms - Measurement phase: ${s.toFixed(1)}ms (${(s/m*100).toFixed(0)}%)`)}}logSummary(){if(this.rollingStats.batchCount===0)return;const t=this.rollingStats;const a=t.totalTime/t.batchCount;const i=t.totalNodes/t.batchCount;console.log(`
2
+ [HighlightPerf] \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 SUMMARY (last ${this.SUMMARY_INTERVAL_MS/1e3}s) \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
3
+ Batches: ${t.batchCount}
4
+ Avg nodes/batch: ${i.toFixed(1)} (filtered: ${(t.totalFiltered/t.batchCount).toFixed(1)})
5
+ Avg total time: ${a.toFixed(1)}ms
6
+ Avg measurement time: ${t.avgMeasurementTime.toFixed(1)}ms
7
+ Min/Max time: ${t.minTime.toFixed(1)}ms / ${t.maxTime.toFixed(1)}ms
8
+ \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9
+ `);this.resetStats()}resetStats(){this.rollingStats={batchCount:0,totalNodes:0,totalFiltered:0,totalProcessed:0,totalTime:0,maxTime:0,minTime:Infinity,avgMeasurementTime:0}}startSummaryInterval(){this.stopSummaryInterval();this.summaryInterval=setInterval(()=>{this.logSummary()},this.SUMMARY_INTERVAL_MS)}stopSummaryInterval(){if(this.summaryInterval){clearInterval(this.summaryInterval);this.summaryInterval=null}}subscribe(t){this.listeners.add(t);return()=>{this.listeners.delete(t)}}notifyListeners(t){for(const a of this.listeners){try{a(t)}catch(i){console.error("[HighlightPerf] Error in metrics listener:",i)}}}getRecentBatches(){return[...this.recentBatches]}getRollingStats(){return{...this.rollingStats}}clear(){this.recentBatches=[];this.resetStats();this.batchCounter=0}generateReport(){const t=this.recentBatches;if(t.length===0){return"No performance data collected yet."}const a=t.reduce((e,n)=>e+n.totalTime,0);const i=a/t.length;const h=t.reduce((e,n)=>e+n.measurementTime,0);const o=h/t.length;const l=t.filter(e=>e.totalTime>100);const r=t.filter(e=>e.totalTime<20);const s=`
10
+ \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
11
+ \u2551 HIGHLIGHT UPDATES PERFORMANCE REPORT \u2551
12
+ \u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563
13
+ \u2551 Total batches analyzed: ${t.length.toString().padStart(5)} \u2551
14
+ \u2551 Average total time: ${i.toFixed(1).padStart(5)}ms \u2551
15
+ \u2551 Average measure time: ${o.toFixed(1).padStart(5)}ms (${(o/i*100).toFixed(0)}% of total) \u2551
16
+ \u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563
17
+ \u2551 Fast batches (<20ms): ${r.length.toString().padStart(5)} (${(r.length/t.length*100).toFixed(0)}%) \u2551
18
+ \u2551 Slow batches (>100ms): ${l.length.toString().padStart(5)} (${(l.length/t.length*100).toFixed(0)}%) \u2551
19
+ \u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563
20
+ \u2551 Time breakdown (avg): \u2551
21
+ \u2551 Filtering: ${t.reduce((e,n)=>e+n.filteringTime,0/t.length).toFixed(1).padStart(6)}ms \u2551
22
+ \u2551 Measurement: ${o.toFixed(1).padStart(6)}ms \u2190 Primary bottleneck \u2551
23
+ \u2551 Tracking: ${(t.reduce((e,n)=>e+n.trackingTime,0)/t.length).toFixed(1).padStart(6)}ms \u2551
24
+ \u2551 Callback: ${(t.reduce((e,n)=>e+n.callbackTime,0)/t.length).toFixed(1).padStart(6)}ms \u2551
25
+ \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
26
+ `;return s}}export const PerformanceLogger=new b;export default PerformanceLogger;