@buoy-gg/highlight-updates 2.1.4-beta.2 → 2.1.5

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/lib/commonjs/highlight-updates/HighlightUpdatesOverlay.js +1 -285
  2. package/lib/commonjs/highlight-updates/components/HighlightFilterView.js +1 -1371
  3. package/lib/commonjs/highlight-updates/components/HighlightUpdatesModal.js +1 -592
  4. package/lib/commonjs/highlight-updates/components/IdentifierBadge.js +1 -267
  5. package/lib/commonjs/highlight-updates/components/IsolatedRenderList.js +1 -178
  6. package/lib/commonjs/highlight-updates/components/ModalHeaderContent.js +1 -303
  7. package/lib/commonjs/highlight-updates/components/RenderCauseBadge.js +1 -500
  8. package/lib/commonjs/highlight-updates/components/RenderDetailView.js +1 -830
  9. package/lib/commonjs/highlight-updates/components/RenderHistoryViewer.js +1 -894
  10. package/lib/commonjs/highlight-updates/components/RenderListItem.js +1 -226
  11. package/lib/commonjs/highlight-updates/components/StatsDisplay.js +1 -70
  12. package/lib/commonjs/highlight-updates/components/index.js +1 -97
  13. package/lib/commonjs/highlight-updates/utils/HighlightUpdatesController.js +1 -1427
  14. package/lib/commonjs/highlight-updates/utils/PerformanceLogger.js +1 -359
  15. package/lib/commonjs/highlight-updates/utils/ProfilerInterceptor.js +1 -371
  16. package/lib/commonjs/highlight-updates/utils/RenderCauseDetector.js +1 -1828
  17. package/lib/commonjs/highlight-updates/utils/RenderTracker.js +1 -903
  18. package/lib/commonjs/highlight-updates/utils/ViewTypeMapper.js +1 -264
  19. package/lib/commonjs/highlight-updates/utils/renderExportFormatter.js +1 -58
  20. package/lib/commonjs/index.js +1 -311
  21. package/lib/commonjs/preset.js +1 -278
  22. package/lib/module/highlight-updates/HighlightUpdatesOverlay.js +1 -278
  23. package/lib/module/highlight-updates/components/HighlightFilterView.js +1 -1365
  24. package/lib/module/highlight-updates/components/HighlightUpdatesModal.js +1 -586
  25. package/lib/module/highlight-updates/components/IdentifierBadge.js +1 -259
  26. package/lib/module/highlight-updates/components/IsolatedRenderList.js +1 -174
  27. package/lib/module/highlight-updates/components/ModalHeaderContent.js +1 -298
  28. package/lib/module/highlight-updates/components/RenderCauseBadge.js +1 -491
  29. package/lib/module/highlight-updates/components/RenderDetailView.js +1 -826
  30. package/lib/module/highlight-updates/components/RenderHistoryViewer.js +1 -888
  31. package/lib/module/highlight-updates/components/RenderListItem.js +1 -221
  32. package/lib/module/highlight-updates/components/StatsDisplay.js +1 -67
  33. package/lib/module/highlight-updates/components/index.js +1 -16
  34. package/lib/module/highlight-updates/utils/HighlightUpdatesController.js +1 -1423
  35. package/lib/module/highlight-updates/utils/PerformanceLogger.js +1 -353
  36. package/lib/module/highlight-updates/utils/ProfilerInterceptor.js +1 -358
  37. package/lib/module/highlight-updates/utils/RenderCauseDetector.js +1 -1818
  38. package/lib/module/highlight-updates/utils/RenderTracker.js +1 -900
  39. package/lib/module/highlight-updates/utils/ViewTypeMapper.js +1 -255
  40. package/lib/module/highlight-updates/utils/renderExportFormatter.js +1 -54
  41. package/lib/module/index.js +1 -71
  42. package/lib/module/preset.js +1 -272
  43. package/package.json +7 -7
  44. package/lib/typescript/highlight-updates/HighlightUpdatesOverlay.d.ts.map +0 -1
  45. package/lib/typescript/highlight-updates/components/HighlightFilterView.d.ts.map +0 -1
  46. package/lib/typescript/highlight-updates/components/HighlightUpdatesModal.d.ts.map +0 -1
  47. package/lib/typescript/highlight-updates/components/IdentifierBadge.d.ts.map +0 -1
  48. package/lib/typescript/highlight-updates/components/IsolatedRenderList.d.ts.map +0 -1
  49. package/lib/typescript/highlight-updates/components/ModalHeaderContent.d.ts.map +0 -1
  50. package/lib/typescript/highlight-updates/components/RenderCauseBadge.d.ts.map +0 -1
  51. package/lib/typescript/highlight-updates/components/RenderDetailView.d.ts.map +0 -1
  52. package/lib/typescript/highlight-updates/components/RenderHistoryViewer.d.ts.map +0 -1
  53. package/lib/typescript/highlight-updates/components/RenderListItem.d.ts.map +0 -1
  54. package/lib/typescript/highlight-updates/components/StatsDisplay.d.ts.map +0 -1
  55. package/lib/typescript/highlight-updates/components/index.d.ts.map +0 -1
  56. package/lib/typescript/highlight-updates/utils/HighlightUpdatesController.d.ts.map +0 -1
  57. package/lib/typescript/highlight-updates/utils/PerformanceLogger.d.ts.map +0 -1
  58. package/lib/typescript/highlight-updates/utils/ProfilerInterceptor.d.ts.map +0 -1
  59. package/lib/typescript/highlight-updates/utils/RenderCauseDetector.d.ts.map +0 -1
  60. package/lib/typescript/highlight-updates/utils/RenderTracker.d.ts.map +0 -1
  61. package/lib/typescript/highlight-updates/utils/ViewTypeMapper.d.ts.map +0 -1
  62. package/lib/typescript/highlight-updates/utils/renderExportFormatter.d.ts.map +0 -1
  63. package/lib/typescript/index.d.ts.map +0 -1
  64. package/lib/typescript/preset.d.ts.map +0 -1
@@ -1,1423 +1 @@
1
- /**
2
- * Highlight Updates Controller
3
- *
4
- * Standalone implementation that replicates React DevTools' "Highlight updates
5
- * when components render" feature WITHOUT requiring DevTools to be connected.
6
- *
7
- * Architecture:
8
- * This controller directly enables the DevTools backend's traceUpdates feature
9
- * by calling setTraceUpdatesEnabled(true) on each renderer interface. This is
10
- * the same function that DevTools' frontend calls when you check the
11
- * "Highlight updates when components render" checkbox.
12
- *
13
- * Key insight: The rendererInterfaces are available on the global hook even
14
- * without DevTools frontend connected. We just need to enable tracing directly.
15
- *
16
- * Flow:
17
- * 1. User enables highlights via toggle()
18
- * 2. We call rendererInterface.setTraceUpdatesEnabled(true) on all renderers
19
- * 3. DevTools backend now tracks renders and emits 'traceUpdates' events
20
- * 4. We subscribe to 'traceUpdates' via hook.sub()
21
- * 5. When components re-render, we receive the Set of host stateNodes
22
- * 6. We measure each node and render colored border highlights
23
- *
24
- * This gives us 100% accuracy with DevTools behavior because we're using the
25
- * exact same detection code - we're just enabling it programmatically.
26
- */
27
-
28
- "use strict";
29
-
30
- import { installProfilerInterceptor, uninstallProfilerInterceptor, setComparisonCallback } from "./ProfilerInterceptor";
31
- import { RenderTracker } from "./RenderTracker";
32
- import { PerformanceLogger, markEventReceived } from "./PerformanceLogger";
33
- import { detectRenderCause, clearRenderCauseState } from "./RenderCauseDetector";
34
- import { notifySubscriberCountChange } from "@buoy-gg/shared-ui";
35
- // State
36
- let globalEnabled = false; // User-controlled toggle for visual highlights
37
- let backgroundTrackingEnabled = false; // Auto-enabled when event callbacks exist (Events tool)
38
- let initialized = false;
39
- let hook = null;
40
- let highlightCallback = null;
41
- let badgePressCallback = null;
42
- let traceUpdatesUnsubscribe = null;
43
- let isProcessing = false;
44
-
45
- // Freeze frame state
46
- let isFrozen = false;
47
- const freezeListeners = new Set();
48
- const stateListeners = new Set();
49
-
50
- // Track render counts per node (for color assignment like DevTools)
51
- // Map from nativeTag to render count - nativeTag is stable across re-renders
52
- const nodeRenderCounts = new Map();
53
-
54
- // Color palette for highlights (same as DevTools)
55
- // From: react-devtools-core/dist/backend.js line 6361
56
- const COLORS = ["#37afa9", "#63b19e", "#80b393", "#97b488", "#abb67d", "#beb771", "#cfb965", "#dfba57", "#efbb49", "#febc38"];
57
-
58
- // Set to true for verbose debugging of our implementation
59
- // Disabled for now to focus on profiler logs only
60
- const DEBUG = false;
61
- function debugLog(message, data) {
62
- if (!DEBUG) return;
63
- if (data !== undefined) {
64
- console.log(`[HighlightUpdates] ${message}`, data);
65
- } else {
66
- console.log(`[HighlightUpdates] ${message}`);
67
- }
68
- }
69
-
70
- /**
71
- * Get the public instance from a stateNode (the node passed in traceUpdates)
72
- */
73
- function getPublicInstance(stateNode) {
74
- if (!stateNode) return null;
75
- const node = stateNode;
76
-
77
- // Fabric: stateNode.canonical.publicInstance
78
- if (node.canonical?.publicInstance) {
79
- return node.canonical.publicInstance;
80
- }
81
-
82
- // Legacy Fabric: stateNode.canonical with measure
83
- if (node.canonical && typeof node.canonical.measure === "function") {
84
- return node.canonical;
85
- }
86
-
87
- // Legacy renderer: stateNode has measure directly
88
- if (typeof node.measure === "function") {
89
- return node;
90
- }
91
- return null;
92
- }
93
-
94
- /**
95
- * Get native tag from public instance or stateNode
96
- */
97
- function getNativeTag(instance) {
98
- const inst = instance;
99
-
100
- // Try direct properties
101
- if (inst.__nativeTag != null) return inst.__nativeTag;
102
- if (inst._nativeTag != null) return inst._nativeTag;
103
- if (inst.nativeTag != null) return inst.nativeTag;
104
-
105
- // Try canonical
106
- if (inst.canonical) {
107
- if (inst.canonical.__nativeTag != null) return inst.canonical.__nativeTag;
108
- if (inst.canonical._nativeTag != null) return inst.canonical._nativeTag;
109
- }
110
- return null;
111
- }
112
-
113
- /**
114
- * Extract component info from a stateNode for RenderTracker
115
- */
116
- function extractComponentInfo(stateNode) {
117
- const node = stateNode;
118
- const info = {
119
- viewType: "Unknown"
120
- };
121
-
122
- // Get viewType from viewConfig
123
- if (node?.canonical?.viewConfig?.uiViewClassName) {
124
- info.viewType = node.canonical.viewConfig.uiViewClassName;
125
- } else if (node?.viewConfig?.uiViewClassName) {
126
- info.viewType = node.viewConfig.uiViewClassName;
127
- }
128
-
129
- // Try to get props from various locations
130
- // Fabric: canonical.internalInstanceHandle, Paper: _internalInstanceHandle, RN CLI DEV: _internalFiberInstanceHandleDEV
131
- const fiber = node?.canonical?.internalInstanceHandle || node?._internalInstanceHandle || node?._internalFiberInstanceHandleDEV;
132
- const currentProps = node?.canonical?.currentProps;
133
- const pendingProps = node?.canonical?.pendingProps;
134
- const fiberPendingProps = fiber?.pendingProps;
135
- const fiberMemoizedProps = fiber?.memoizedProps;
136
-
137
- // Extract testID
138
- info.testID = currentProps?.testID || pendingProps?.testID || fiberPendingProps?.testID || fiberMemoizedProps?.testID || undefined;
139
-
140
- // Extract nativeID
141
- info.nativeID = currentProps?.nativeID || pendingProps?.nativeID || fiberPendingProps?.nativeID || fiberMemoizedProps?.nativeID || undefined;
142
-
143
- // Extract accessibilityLabel
144
- info.accessibilityLabel = currentProps?.accessibilityLabel || pendingProps?.accessibilityLabel || fiberPendingProps?.accessibilityLabel || fiberMemoizedProps?.accessibilityLabel || undefined;
145
-
146
- // Extract componentName - use getOwningComponentName to get the React component
147
- // that rendered this host component
148
- info.componentName = getOwningComponentName(fiber) || undefined;
149
- return info;
150
- }
151
-
152
- /**
153
- * Describe a node for logging (extensive version for debugging)
154
- */
155
- function describeNodeForLog(stateNode) {
156
- const node = stateNode;
157
- const publicInstance = getPublicInstance(stateNode);
158
- const nativeTag = getNativeTag(stateNode) || getNativeTag(publicInstance);
159
- const info = {
160
- nativeTag: nativeTag ?? "unknown",
161
- type: node?.canonical ? "Fabric" : "Legacy",
162
- hasMeasure: typeof publicInstance?.measure === "function"
163
- };
164
-
165
- // Extract as much info as possible from the stateNode
166
- if (node) {
167
- // Direct properties on stateNode
168
- info.stateNodeKeys = Object.keys(node).slice(0, 20);
169
-
170
- // Check the 'node' property (might have useful info)
171
- if (node.node) {
172
- info.nodeKeys = Object.keys(node.node).slice(0, 20);
173
- }
174
-
175
- // Check for viewConfig (contains component type info)
176
- if (node.viewConfig) {
177
- info.viewConfig = {
178
- uiViewClassName: node.viewConfig.uiViewClassName,
179
- validAttributes: node.viewConfig.validAttributes ? Object.keys(node.viewConfig.validAttributes).slice(0, 10) : undefined
180
- };
181
- }
182
-
183
- // Check canonical structure (Fabric)
184
- if (node.canonical) {
185
- const canonical = node.canonical;
186
- info.canonicalKeys = Object.keys(canonical).slice(0, 20);
187
- if (canonical.viewConfig) {
188
- info.canonicalViewConfig = {
189
- uiViewClassName: canonical.viewConfig.uiViewClassName
190
- };
191
- }
192
- if (canonical.nativeTag != null) {
193
- info.canonicalNativeTag = canonical.nativeTag;
194
- }
195
-
196
- // Check internalInstanceHandle (THE FIBER!)
197
- if (canonical.internalInstanceHandle) {
198
- const fiber = canonical.internalInstanceHandle;
199
- info.fiberKeys = Object.keys(fiber).slice(0, 30);
200
-
201
- // Component type info
202
- if (fiber.type) {
203
- info.fiberType = typeof fiber.type === "function" ? fiber.type.name || fiber.type.displayName || "function" : fiber.type;
204
- }
205
- if (fiber.elementType) {
206
- info.fiberElementType = typeof fiber.elementType === "function" ? fiber.elementType.name || fiber.elementType.displayName || "function" : fiber.elementType;
207
- }
208
-
209
- // Debug info on fiber
210
- if (fiber._debugOwner) {
211
- const owner = fiber._debugOwner;
212
- info.fiberDebugOwner = owner.type?.name || owner.type?.displayName || owner.elementType?.name || "unknown";
213
- }
214
- if (fiber._debugSource) {
215
- info.fiberDebugSource = fiber._debugSource;
216
- }
217
-
218
- // Fiber tag (tells us what kind of fiber it is)
219
- if (fiber.tag != null) {
220
- info.fiberTag = fiber.tag;
221
- }
222
-
223
- // pendingProps on fiber might have testID/nativeID
224
- if (fiber.pendingProps) {
225
- if (fiber.pendingProps.nativeID) info.fiberPendingNativeID = fiber.pendingProps.nativeID;
226
- if (fiber.pendingProps.testID) info.fiberPendingTestID = fiber.pendingProps.testID;
227
- }
228
- if (fiber.memoizedProps) {
229
- if (fiber.memoizedProps.nativeID) info.fiberMemoizedNativeID = fiber.memoizedProps.nativeID;
230
- if (fiber.memoizedProps.testID) info.fiberMemoizedTestID = fiber.memoizedProps.testID;
231
- }
232
- }
233
-
234
- // Check publicInstance
235
- if (canonical.publicInstance) {
236
- const pub = canonical.publicInstance;
237
- info.publicInstanceKeys = Object.keys(pub).slice(0, 20);
238
-
239
- // Look for nativeID
240
- if (pub.nativeID != null) info.nativeID = pub.nativeID;
241
- if (pub._nativeID != null) info._nativeID = pub._nativeID;
242
-
243
- // Look for props
244
- if (pub.props) {
245
- info.publicInstanceProps = Object.keys(pub.props).slice(0, 15);
246
- if (pub.props.nativeID) info.propsNativeID = pub.props.nativeID;
247
- if (pub.props.testID) info.propsTestID = pub.props.testID;
248
- if (pub.props.accessibilityLabel) info.accessibilityLabel = pub.props.accessibilityLabel;
249
- }
250
- }
251
-
252
- // Check for currentProps - log actual VALUES
253
- if (canonical.currentProps) {
254
- info.currentPropsKeys = Object.keys(canonical.currentProps).slice(0, 15);
255
- // Log actual values of identifying props
256
- if (canonical.currentProps.nativeID != null) info.currentPropsNativeID = canonical.currentProps.nativeID;
257
- if (canonical.currentProps.testID != null) info.currentPropsTestID = canonical.currentProps.testID;
258
- if (canonical.currentProps.accessibilityLabel != null) info.currentPropsAccessLabel = canonical.currentProps.accessibilityLabel;
259
- }
260
-
261
- // Check for pendingProps
262
- if (canonical.pendingProps) {
263
- info.pendingPropsKeys = Object.keys(canonical.pendingProps).slice(0, 15);
264
- if (canonical.pendingProps.nativeID != null) info.pendingPropsNativeID = canonical.pendingProps.nativeID;
265
- if (canonical.pendingProps.testID != null) info.pendingPropsTestID = canonical.pendingProps.testID;
266
- }
267
- }
268
-
269
- // Check for fiber reference directly on node
270
- if (node._debugOwner) {
271
- const owner = node._debugOwner;
272
- info.debugOwnerType = owner.type?.name || owner.type?.displayName || typeof owner.type;
273
- }
274
- if (node._debugSource) {
275
- info.debugSource = node._debugSource;
276
- }
277
- }
278
- return info;
279
- }
280
-
281
- // Set to true to enable debug logging
282
- const DEBUG_LOGGING = false;
283
-
284
- // Lock to prevent infinite loops when rendering our overlay
285
- let renderingLock = false;
286
- let renderingLockTimeout = null;
287
-
288
- // How long to ignore new events after starting a render (ms)
289
- // Should match HIGHLIGHT_DURATION in the overlay to prevent false triggers
290
- const RENDER_LOCK_DURATION = 350;
291
-
292
- // Track nativeTags of components we're currently highlighting
293
- // This helps us identify (and skip) our own overlay Views if they re-render
294
- const renderedOverlayTags = new Set();
295
-
296
- /**
297
- * Check if a nativeTag belongs to our overlay (was rendered by us previously)
298
- */
299
- function isOurOverlayTag(nativeTag) {
300
- if (nativeTag == null) return false;
301
- return renderedOverlayTags.has(nativeTag);
302
- }
303
-
304
- // ============================================================================
305
- // OPTIMIZED DEV TOOLS DETECTION
306
- // ============================================================================
307
- // Performance optimizations applied:
308
- // 1. Result caching by nativeTag (same tag = same result)
309
- // 2. Set-based O(1) lookups instead of multiple string comparisons
310
- // 3. Component name check FIRST (appears early in tree, ~depth 5-8)
311
- // 4. Early exit on first match
312
- // 5. Cached property access to avoid repeated traversal
313
- // ============================================================================
314
-
315
- // Components that MUST always be excluded to prevent infinite loops.
316
- // Includes the Highlight Updates overlay AND the Events tool (which subscribes
317
- // to render callbacks via RenderTracker.onRenderEvent - tracking its renders
318
- // would create an infinite callback loop).
319
- const HIGHLIGHT_OVERLAY_COMPONENTS = new Set([
320
- // Highlight Updates overlay components
321
- "HighlightUpdatesOverlay", "HighlightUpdatesModal", "HighlightFilterView", "RenderDetailView", "RenderListItem", "RenderListItemInner", "RenderHistoryViewer", "RenderHistoryFooter", "RenderCauseBadge", "TwoLevelCauseBadge", "EnhancedCauseDisplay", "IsolatedRenderList", "IsolatedRenderListInner", "StatsDisplay", "StatsDisplayInner", "CurrentStateView", "EventStepperFooter",
322
- // Events tool components - subscribes to onRenderEvent, tracking these causes infinite loops
323
- "EventsModal", "UnifiedEventList", "UnifiedEventItem", "UnifiedEventDetail", "UnifiedEventFilters", "UnifiedEventViewer", "ReactQueryEventDetail", "EventsCopySettingsView"]);
324
-
325
- // Native IDs that MUST always be excluded (highlight overlay)
326
- const HIGHLIGHT_OVERLAY_NATIVE_IDS = new Set(["highlight-updates-overlay", "__rn_buoy__highlight-modal"]);
327
-
328
- // Prefixes for always-excluded components (highlight overlay + events tool)
329
- const HIGHLIGHT_OVERLAY_PREFIXES = ["HighlightUpdates", "RenderList", "RenderDetail", "RenderHistory", "RenderCause", "EventStepper",
330
- // Events tool - subscribes to onRenderEvent, must always be excluded
331
- "UnifiedEvent", "EventsModal", "EventsCopy"];
332
-
333
- // Other dev tools components - can be toggled via excludeDevTools setting
334
- const OTHER_DEV_TOOLS_COMPONENTS = new Set([
335
- // React Buoy devtools components
336
- "JsModalComponent", "JsModal", "TypePicker", "PatternInput", "PatternChip", "DetectedItemsSection", "DetectedCategoryBadge", "IdentifierBadge", "CategoryBadge", "AppRenderer", "AppOverlay", "FloatingTools", "DialDevTools", "DevToolsVisibilityProvider", "AppHostProvider", "MinimizedToolsProvider",
337
- // Shared UI components used in modals
338
- "ModalHeader", "TabSelector", "SectionHeader", "DraggableHeader", "WindowControls",
339
- // Shared UI data viewer components (JSON diff viewers, etc.)
340
- "TreeDiffViewer", "DataViewer", "SplitDiffViewer", "VirtualizedDataExplorer", "DiffSummary", "TypeLegend", "IndentGuides", "IndentGuidesOverlay", "CyberpunkInput", "DiffView", "AnswerCard", "DetailsSection", "DetailRow", "QuickActionsSection", "FilterOptionCard",
341
- // Modal header sub-components
342
- "SearchSection", "SearchSectionInner", "HeaderActions", "HeaderActionsInner", "MainListHeader", "FilterViewHeader", "DetailViewHeader",
343
- // Floating menu components (minimized tools, dial, etc.)
344
- "FloatingMenu", "FloatingDevTools", "MinimizedToolsStack", "MinimizedToolsContext", "GlitchToolButton", "ExpandablePopover", "CollapsedPeek", "ExpandedWrapper", "DialIcon", "DialMenu", "DialIconItem", "OnboardingTooltip", "MenuLauncherIcon", "DevToolsSettingsModal", "SettingsModal", "ToolCard", "ToolIcon", "GripVerticalIcon", "UserStatus", "Divider",
345
- // Shared UI icon components (Chevrons, etc.)
346
- "ChevronDown", "ChevronUp", "ChevronLeft", "ChevronRight", "ChevronDownIcon", "ChevronUpIcon", "ChevronLeftIcon", "ChevronRightIcon",
347
- // React Native LogBox components (shown on reload/errors)
348
- "LogBox", "LogBoxLog", "LogBoxLogNotification", "LogBoxNotificationContainer", "_LogBoxNotificationContainer", "LogBoxInspector", "LogBoxInspectorContainer", "LogBoxInspectorHeader", "LogBoxInspectorBody", "LogBoxInspectorFooter", "LogBoxInspectorMessageHeader", "LogBoxInspectorStackFrame", "LogBoxInspectorSection", "LogBoxButton", "LogBoxMessage"]);
349
-
350
- // Other dev tools prefixes - can be toggled via excludeDevTools setting
351
- const OTHER_DEV_TOOLS_PREFIXES = ["JsModal", "TreeDiff", "DataViewer", "DiffView", "DiffSummary", "Virtualized",
352
- // Floating menu prefixes
353
- "Floating", "Minimized", "Dial", "Expandable", "Chevron", "Glitch", "Settings", "Onboarding", "DevTools"];
354
-
355
- // Other dev tools native IDs - can be toggled
356
- const OTHER_DEV_TOOLS_NATIVE_IDS = new Set(["jsmodal-root",
357
- // LogBox native IDs
358
- "logbox_inspector", "logbox"]);
359
-
360
- // Cache: nativeTag -> isDevTools (avoid re-walking tree for same node)
361
- const devToolsNodeCache = new Map();
362
- const CACHE_MAX_SIZE = 500;
363
-
364
- /**
365
- * Clear the devtools node cache.
366
- * Call this when the excludeDevTools setting changes to re-evaluate all nodes.
367
- */
368
- function clearDevToolsCache() {
369
- devToolsNodeCache.clear();
370
- }
371
-
372
- /**
373
- * Check if a nativeID belongs to highlight overlay (always excluded)
374
- */
375
- function isHighlightOverlayNativeID(nativeID) {
376
- if (!nativeID) return false;
377
- // Direct Set lookup (O(1))
378
- if (HIGHLIGHT_OVERLAY_NATIVE_IDS.has(nativeID)) return true;
379
- // Prefix check for highlight overlay
380
- if (nativeID.startsWith("__highlight_")) return true;
381
- return false;
382
- }
383
-
384
- /**
385
- * Check if a nativeID belongs to other dev tools (optionally excluded)
386
- */
387
- function isOtherDevToolsNativeID(nativeID) {
388
- if (!nativeID) return false;
389
- // Direct Set lookup (O(1))
390
- if (OTHER_DEV_TOOLS_NATIVE_IDS.has(nativeID)) return true;
391
- // Prefix checks for other devtools nativeIDs
392
- const firstChar = nativeID.charCodeAt(0);
393
- if (firstChar === 95) {
394
- // '_' = 95
395
- if (nativeID.startsWith("__rn_buoy__")) return true;
396
- }
397
- // Check for LogBox nativeIDs (start with 'l')
398
- if (firstChar === 108 && nativeID.startsWith("logbox")) {
399
- // 'l' = 108
400
- return true;
401
- }
402
- return false;
403
- }
404
-
405
- /**
406
- * Get component name from fiber (cached property access pattern)
407
- * For host components (RCTView, RCTText), returns the native type.
408
- * Use getOwningComponentName to get the React component that rendered it.
409
- */
410
- function getComponentName(fiber) {
411
- if (!fiber) return null;
412
- // Most common: type.name
413
- const type = fiber.type;
414
- if (type) {
415
- if (typeof type === 'string') return type;
416
- if (type.name) return type.name;
417
- if (type.displayName) return type.displayName;
418
- }
419
- // Fallback: elementType
420
- const elementType = fiber.elementType;
421
- if (elementType) {
422
- if (elementType.name) return elementType.name;
423
- if (elementType.displayName) return elementType.displayName;
424
- }
425
- return null;
426
- }
427
-
428
- // Common React Native internal component names to skip when finding user components
429
- const INTERNAL_COMPONENT_NAMES = new Set([
430
- // React Native core
431
- 'View', 'Text', 'TextImpl', 'Image', 'ScrollView', 'FlatList', 'SectionList', 'TouchableOpacity', 'TouchableHighlight', 'TouchableWithoutFeedback', 'Pressable', 'TextInput', 'Switch', 'ActivityIndicator', 'Modal', 'StatusBar', 'KeyboardAvoidingView',
432
- // Animated components
433
- 'AnimatedComponent', 'AnimatedComponentWrapper',
434
- // React Navigation / Screens
435
- 'ScreenContainer', 'ScreenStack', 'Screen', 'ScreenContentWrapper',
436
- // SVG components
437
- 'Svg', 'G', 'Path', 'Rect', 'Circle', 'Line', 'Polygon', 'Polyline', 'Ellipse', 'Text as SVGText', 'TSpan', 'TextPath', 'Use', 'Symbol', 'Defs', 'ClipPath', 'LinearGradient', 'RadialGradient', 'Stop', 'Mask', 'Pattern', 'Image as SVGImage',
438
- // SafeArea
439
- 'SafeAreaProvider', 'SafeAreaView', 'SafeAreaListener',
440
- // Gesture Handler
441
- 'GestureHandlerRootView', 'GestureDetector',
442
- // Reanimated
443
- 'ReanimatedView', 'ReanimatedText', 'ReanimatedImage', 'ReanimatedScrollView',
444
- // Common wrapper names
445
- 'Fragment', 'Suspense', 'Provider', 'Consumer', 'Context', 'ForwardRef']);
446
-
447
- /**
448
- * Check if a component name is an internal/wrapper component that should be skipped
449
- */
450
- function isInternalComponent(name) {
451
- if (!name) return true;
452
- if (INTERNAL_COMPONENT_NAMES.has(name)) return true;
453
- // Skip anonymous components and common patterns
454
- if (name === 'Unknown' || name === 'Component') return true;
455
- // Skip Animated.* wrappers
456
- if (name.startsWith('Animated')) return true;
457
- return false;
458
- }
459
-
460
- /**
461
- * Get the owning React component name for a host fiber.
462
- * Walks up the fiber tree to find the first user-defined component,
463
- * skipping React Native internal components.
464
- */
465
- function getOwningComponentName(fiber) {
466
- if (!fiber) return null;
467
-
468
- // Walk up the fiber tree looking for a user-defined component
469
- let current = fiber._debugOwner || fiber.return;
470
- let depth = 0;
471
- let firstNonHostName = null;
472
- while (current && depth < 30) {
473
- const name = getComponentName(current);
474
-
475
- // Skip host components (their type is a string like "RCTView")
476
- if (name && typeof current.type !== 'string') {
477
- // Remember the first non-host component as fallback
478
- if (!firstNonHostName) {
479
- firstNonHostName = name;
480
- }
481
- // Return this component if it's not an internal wrapper
482
- if (!isInternalComponent(name)) {
483
- return name;
484
- }
485
- }
486
- current = current.return;
487
- depth++;
488
- }
489
-
490
- // Fallback to first non-host component found (even if internal)
491
- return firstNonHostName;
492
- }
493
-
494
- /**
495
- * Check if a stateNode belongs to our dev tools.
496
- *
497
- * OPTIMIZED: Uses caching, O(1) Set lookups, and early exit patterns.
498
- * Walks up fiber tree checking component names (fast) before nativeIDs.
499
- *
500
- * When excludeDevTools setting is false, only the Highlight Updates overlay
501
- * is excluded (to prevent infinite loops). Other dev tools will be highlighted.
502
- */
503
- function isOurOverlayNode(stateNode) {
504
- const node = stateNode;
505
- // Fabric: fiber is at canonical.internalInstanceHandle
506
- // Paper/Legacy: fiber is at _internalInstanceHandle directly on stateNode
507
- // RN CLI DEV: fiber is at _internalFiberInstanceHandleDEV
508
- const fiber = node?.canonical?.internalInstanceHandle || node?._internalInstanceHandle || node?._internalFiberInstanceHandleDEV;
509
-
510
- // Get nativeTag for caching
511
- const nativeTag = getNativeTag(stateNode) || getNativeTag(node?.canonical?.publicInstance);
512
-
513
- // Check if we should exclude all dev tools or just highlight overlay
514
- const excludeDevTools = RenderTracker.getSettings().excludeDevTools;
515
-
516
- // Check cache first (O(1)) - but only for the current excludeDevTools setting
517
- // When excludeDevTools is false, skip cache to re-evaluate all nodes
518
- if (nativeTag != null && excludeDevTools) {
519
- const cached = devToolsNodeCache.get(nativeTag);
520
- if (cached !== undefined) {
521
- return cached;
522
- }
523
- }
524
- let result = false;
525
-
526
- // Fast path: check direct nativeID
527
- const directNativeID = fiber?.pendingProps?.nativeID || fiber?.memoizedProps?.nativeID || node?.canonical?.currentProps?.nativeID || null;
528
-
529
- // Always check highlight overlay nativeIDs first (must always be excluded)
530
- if (isHighlightOverlayNativeID(directNativeID)) {
531
- result = true;
532
- } else if (excludeDevTools && isOtherDevToolsNativeID(directNativeID)) {
533
- // Only check other dev tools if excludeDevTools is enabled
534
- result = true;
535
- }
536
- if (!result && fiber) {
537
- // Walk up fiber tree - check component names FIRST (they appear early)
538
- let current = fiber;
539
- let depth = 0;
540
-
541
- // Reduced max depth - component names appear by depth 15 typically
542
- while (current && depth < 30) {
543
- // Component name check FIRST (faster, appears earlier in tree)
544
- const name = getComponentName(current);
545
- if (name) {
546
- // Always check highlight overlay components (must always be excluded)
547
- if (HIGHLIGHT_OVERLAY_COMPONENTS.has(name)) {
548
- result = true;
549
- break;
550
- }
551
- // Check highlight overlay prefixes
552
- for (const prefix of HIGHLIGHT_OVERLAY_PREFIXES) {
553
- if (name.startsWith(prefix)) {
554
- result = true;
555
- break;
556
- }
557
- }
558
- if (result) break;
559
-
560
- // Only check other dev tools if excludeDevTools is enabled
561
- if (excludeDevTools) {
562
- if (OTHER_DEV_TOOLS_COMPONENTS.has(name)) {
563
- result = true;
564
- break;
565
- }
566
- // Check other dev tools prefixes
567
- for (const prefix of OTHER_DEV_TOOLS_PREFIXES) {
568
- if (name.startsWith(prefix)) {
569
- result = true;
570
- break;
571
- }
572
- }
573
- if (result) break;
574
- }
575
- }
576
-
577
- // NativeID check (only if component name didn't match)
578
- const nativeID = current.pendingProps?.nativeID || current.memoizedProps?.nativeID;
579
- if (isHighlightOverlayNativeID(nativeID)) {
580
- result = true;
581
- break;
582
- }
583
- if (excludeDevTools && isOtherDevToolsNativeID(nativeID)) {
584
- result = true;
585
- break;
586
- }
587
- current = current.return;
588
- depth++;
589
- }
590
- }
591
-
592
- // Only cache positive results when excludeDevTools is true (default mode)
593
- // Don't cache when excludeDevTools is false to avoid complex cache invalidation
594
- if (result && nativeTag != null && excludeDevTools) {
595
- if (devToolsNodeCache.size >= CACHE_MAX_SIZE) {
596
- // Clear oldest entries (simple strategy - clear half)
597
- const entries = Array.from(devToolsNodeCache.keys());
598
- for (let i = 0; i < CACHE_MAX_SIZE / 2; i++) {
599
- devToolsNodeCache.delete(entries[i]);
600
- }
601
- }
602
- devToolsNodeCache.set(nativeTag, result);
603
- }
604
- return result;
605
- }
606
-
607
- /**
608
- * Get color based on render count (same algorithm as DevTools)
609
- * More renders = warmer color (cyan → yellow)
610
- */
611
- function getColorForRenderCount(count) {
612
- // Clamp to color array bounds
613
- const index = Math.min(count - 1, COLORS.length - 1);
614
- return COLORS[Math.max(0, index)];
615
- }
616
-
617
- /**
618
- * Handle traceUpdates event from DevTools backend
619
- * This is called with a Set of stateNodes that should be highlighted
620
- *
621
- * Strategy to prevent infinite loops:
622
- * 1. Use a rendering lock while rendering highlights
623
- * 2. Use an isProcessing flag to prevent concurrent processing
624
- * 3. If Chrome DevTools agent is available, use native overlay (faster, no React)
625
- * 4. Otherwise, use our React overlay with locks to prevent cascading renders
626
- */
627
- function handleTraceUpdates(nodes) {
628
- if (nodes.size === 0) {
629
- return;
630
- }
631
-
632
- // Skip if neither visual toggle nor background tracking is enabled
633
- if (!globalEnabled && !backgroundTrackingEnabled) {
634
- return;
635
- }
636
-
637
- // Skip processing when paused - don't count renders or show highlights
638
- const trackerState = RenderTracker.getState();
639
- if (trackerState.isPaused) {
640
- return;
641
- }
642
-
643
- // Mark event received for end-to-end timing
644
- if (PerformanceLogger.isEnabled()) {
645
- markEventReceived();
646
- }
647
-
648
- // Start performance timing
649
- const batchSize = RenderTracker.getBatchSize();
650
- const perfTimer = PerformanceLogger.startBatch(nodes.size, batchSize);
651
-
652
- // NOTE: Lock-based skipping disabled - relying on nativeID filtering instead
653
- // If nativeID filtering doesn't work, re-enable this:
654
- //
655
- // if (renderingLock || isProcessing) {
656
- // if (DEBUG_LOGGING) {
657
- // console.log(`[HighlightUpdates] SKIPPED - lock:${renderingLock} processing:${isProcessing}`);
658
- // }
659
- // return;
660
- // }
661
- // isProcessing = true;
662
-
663
- // Process nodes: track render counts and assign colors
664
- // Filter out our own overlay nodes to prevent infinite loop
665
- // Also apply user-defined filters to both overlay AND tracking
666
- const nodesToDraw = [];
667
- let skippedOverlayCount = 0;
668
- let skippedByFilterCount = 0;
669
- const hasActiveFilters = RenderTracker.hasActiveFilters();
670
- for (const stateNode of nodes) {
671
- if (stateNode && typeof stateNode === "object") {
672
- // Skip our own overlay nodes (identified by nativeID)
673
- if (isOurOverlayNode(stateNode)) {
674
- skippedOverlayCount++;
675
- continue;
676
- }
677
-
678
- // Get nativeTag for tracking render counts
679
- const publicInstance = getPublicInstance(stateNode);
680
- const nativeTag = getNativeTag(stateNode) || getNativeTag(publicInstance);
681
- if (nativeTag == null) {
682
- continue;
683
- }
684
-
685
- // Extract component info for filtering
686
- const componentInfo = extractComponentInfo(stateNode);
687
-
688
- // Apply user-defined filters - skip components that don't pass filters
689
- // This affects BOTH the overlay highlights AND the render list
690
- if (hasActiveFilters && !RenderTracker.passesFilters(componentInfo)) {
691
- skippedByFilterCount++;
692
- continue;
693
- }
694
-
695
- // Check if render counting is enabled
696
- const showRenderCount = RenderTracker.getSettings().showRenderCount;
697
- let newCount;
698
- let color;
699
- if (showRenderCount) {
700
- // Get current render count and increment (using nativeTag as stable key)
701
- const currentCount = nodeRenderCounts.get(nativeTag) || 0;
702
- newCount = currentCount + 1;
703
- nodeRenderCounts.set(nativeTag, newCount);
704
- // Assign color based on render count
705
- color = getColorForRenderCount(newCount);
706
- } else {
707
- // Skip counting - use fixed color and count of 0
708
- newCount = 0;
709
- color = COLORS[0]; // Use first color (cyan)
710
- }
711
- nodesToDraw.push({
712
- node: stateNode,
713
- color,
714
- count: newCount
715
- });
716
- }
717
- }
718
-
719
- // Mark filtering phase complete (includes both overlay nodes and user-filtered nodes)
720
- perfTimer.markFilteringComplete(skippedOverlayCount + skippedByFilterCount, nodesToDraw.length);
721
-
722
- // Only log if there are real updates (not just overlay re-renders)
723
- if (nodesToDraw.length === 0) {
724
- // All nodes were overlay nodes - silently skip
725
- perfTimer.finish(); // Still log the batch even if empty
726
- return;
727
- }
728
-
729
- // Log actual component updates
730
- if (DEBUG_LOGGING) {
731
- console.log(`[HighlightUpdates] ${nodesToDraw.length} component(s) re-rendered`);
732
- }
733
-
734
- // NOTE: We prefer our React overlay for standalone operation.
735
- // The native overlay only works when Chrome DevTools profiler is actively enabled.
736
- // Uncomment below to use native overlay when available:
737
- //
738
- // const agent = hook?.reactDevtoolsAgent;
739
- // if (agent?.emit) {
740
- // if (DEBUG_LOGGING) {
741
- // console.log(`[HighlightUpdates] Using native overlay (agent available)`);
742
- // }
743
- // agent.emit("drawTraceUpdates", nodesToDraw);
744
- // isProcessing = false;
745
- // return;
746
- // }
747
-
748
- // Check if we should process - either we have a visual callback OR event callbacks
749
- const hasEventCallbacks = RenderTracker.getRenderEventCallbackCount() > 0;
750
- if (!highlightCallback && !hasEventCallbacks) {
751
- if (DEBUG_LOGGING) {
752
- console.log(`[HighlightUpdates] No highlightCallback and no event callbacks - skipping render`);
753
- }
754
- isProcessing = false;
755
- return;
756
- }
757
-
758
- // NOTE: Lock disabled - relying on nativeID filtering instead
759
-
760
- // Measure each node and call the highlight callback
761
- // Use batch size from RenderTracker settings (default: 150)
762
- // Note: batchSize already retrieved above for perfTimer
763
- perfTimer.markMeasurementStart();
764
- const measurePromises = nodesToDraw.slice(0, batchSize).map(({
765
- node: stateNode,
766
- color,
767
- count
768
- }) => new Promise(resolve => {
769
- const publicInstance = getPublicInstance(stateNode);
770
- if (!publicInstance) {
771
- resolve({
772
- rect: null,
773
- stateNode,
774
- color,
775
- count
776
- });
777
- return;
778
- }
779
- const nativeTag = getNativeTag(stateNode) || getNativeTag(publicInstance);
780
- if (nativeTag == null) {
781
- resolve({
782
- rect: null,
783
- stateNode,
784
- color,
785
- count
786
- });
787
- return;
788
- }
789
- try {
790
- publicInstance.measure((x, y, width, height, pageX, pageY) => {
791
- if (pageX == null || pageY == null || width == null || height == null) {
792
- resolve({
793
- rect: null,
794
- stateNode,
795
- color,
796
- count
797
- });
798
- return;
799
- }
800
- resolve({
801
- rect: {
802
- id: nativeTag,
803
- x: pageX,
804
- y: pageY,
805
- width,
806
- height,
807
- color,
808
- count
809
- },
810
- stateNode,
811
- color,
812
- count
813
- });
814
- });
815
- } catch (error) {
816
- resolve({
817
- rect: null,
818
- stateNode,
819
- color,
820
- count
821
- });
822
- }
823
- }));
824
- Promise.all(measurePromises).then(results => {
825
- const validResults = results.filter(r => r.rect !== null);
826
- const rects = validResults.map(r => r.rect);
827
-
828
- // Mark measurement phase complete
829
- perfTimer.markMeasurementComplete(validResults.length, results.length - validResults.length);
830
-
831
- // Track renders - behavior differs based on what's enabled:
832
- // - globalEnabled (visual tool): full tracking with storage and list updates
833
- // - backgroundTrackingEnabled only (Events tool): emit events only, no storage
834
- const settings = RenderTracker.getSettings();
835
- const trackCauses = settings.trackRenderCauses && settings.showRenderCount;
836
- let batchNativeTags = null;
837
- if (trackCauses) {
838
- batchNativeTags = new Set();
839
- for (const {
840
- rect
841
- } of validResults) {
842
- if (rect) {
843
- batchNativeTags.add(rect.id);
844
- }
845
- }
846
- }
847
- if (globalEnabled) {
848
- // Visual tool is on - full tracking with storage and list notifications
849
- RenderTracker.startBatch();
850
- for (const {
851
- rect,
852
- stateNode,
853
- color,
854
- count
855
- } of validResults) {
856
- if (rect) {
857
- const componentInfo = extractComponentInfo(stateNode);
858
- let renderCause;
859
- if (trackCauses && batchNativeTags) {
860
- const node = stateNode;
861
- const fiber = node?.canonical?.internalInstanceHandle;
862
- renderCause = detectRenderCause(rect.id, fiber, batchNativeTags, settings.debugLogLevel);
863
- }
864
- RenderTracker.trackRender({
865
- nativeTag: rect.id,
866
- viewType: componentInfo.viewType,
867
- testID: componentInfo.testID,
868
- nativeID: componentInfo.nativeID,
869
- accessibilityLabel: componentInfo.accessibilityLabel,
870
- componentName: componentInfo.componentName,
871
- measurements: {
872
- x: rect.x,
873
- y: rect.y,
874
- width: rect.width,
875
- height: rect.height
876
- },
877
- color,
878
- count,
879
- renderCause
880
- });
881
- }
882
- }
883
- RenderTracker.endBatch();
884
- } else {
885
- // Only background tracking (Events tool) - emit events without storage
886
- for (const {
887
- rect,
888
- stateNode,
889
- color,
890
- count
891
- } of validResults) {
892
- if (rect) {
893
- const componentInfo = extractComponentInfo(stateNode);
894
- let renderCause;
895
- if (trackCauses && batchNativeTags) {
896
- const node = stateNode;
897
- const fiber = node?.canonical?.internalInstanceHandle;
898
- renderCause = detectRenderCause(rect.id, fiber, batchNativeTags, settings.debugLogLevel);
899
- }
900
- RenderTracker.emitRenderEvent({
901
- nativeTag: rect.id,
902
- viewType: componentInfo.viewType,
903
- testID: componentInfo.testID,
904
- nativeID: componentInfo.nativeID,
905
- accessibilityLabel: componentInfo.accessibilityLabel,
906
- componentName: componentInfo.componentName,
907
- measurements: {
908
- x: rect.x,
909
- y: rect.y,
910
- width: rect.width,
911
- height: rect.height
912
- },
913
- color,
914
- count,
915
- renderCause
916
- });
917
- }
918
- }
919
- }
920
-
921
- // Mark tracking phase complete
922
- perfTimer.markTrackingComplete();
923
-
924
- // Only show visual highlights when the visual tool is enabled (not just background tracking)
925
- if (rects.length > 0 && highlightCallback && globalEnabled) {
926
- highlightCallback(rects);
927
- }
928
-
929
- // Mark callback phase complete and finish timing
930
- perfTimer.markCallbackComplete();
931
- perfTimer.finish();
932
- }).catch(error => {
933
- console.error("[HighlightUpdates] Error in measurement pipeline:", error);
934
- perfTimer.finish(); // Still log timing even on error
935
- });
936
- }
937
-
938
- /**
939
- * Enable or disable trace updates on all renderer interfaces.
940
- * This is the key function that makes standalone tracing work!
941
- *
942
- * The rendererInterfaces map contains the renderer backend for each React root.
943
- * Each renderer has a setTraceUpdatesEnabled function that controls whether
944
- * it emits 'traceUpdates' events when components re-render.
945
- *
946
- * See: react-devtools-core/dist/backend.js line 15487-15489
947
- */
948
- function setTraceUpdatesOnRenderers(enabled) {
949
- if (!hook?.rendererInterfaces) {
950
- debugLog("No rendererInterfaces available");
951
- return;
952
- }
953
- let count = 0;
954
- hook.rendererInterfaces.forEach((rendererInterface, rendererId) => {
955
- if (typeof rendererInterface.setTraceUpdatesEnabled === "function") {
956
- try {
957
- rendererInterface.setTraceUpdatesEnabled(enabled);
958
- count++;
959
- debugLog(`Renderer ${rendererId}: setTraceUpdatesEnabled(${enabled})`);
960
- } catch (error) {
961
- debugLog(`Renderer ${rendererId}: error setting trace updates`, error);
962
- }
963
- } else {
964
- debugLog(`Renderer ${rendererId}: no setTraceUpdatesEnabled method`);
965
- }
966
- });
967
- debugLog(`Set trace updates ${enabled ? "enabled" : "disabled"} on ${count} renderer(s)`);
968
-
969
- // Also try the agent if available (in case DevTools is connected)
970
- if (hook.reactDevtoolsAgent?.setTraceUpdatesEnabled) {
971
- try {
972
- hook.reactDevtoolsAgent.setTraceUpdatesEnabled(enabled);
973
- debugLog("Also set trace updates on agent");
974
- } catch (error) {
975
- debugLog("Error setting trace updates on agent", error);
976
- }
977
- }
978
- }
979
-
980
- /**
981
- * Subscribe to the traceUpdates event from the hook
982
- */
983
- function subscribeToTraceUpdates() {
984
- if (!hook) return;
985
- if (traceUpdatesUnsubscribe) return; // Already subscribed
986
-
987
- debugLog("Subscribing to traceUpdates event");
988
-
989
- // The hook uses EventEmitter pattern with 'sub' method
990
- // See: react-devtools-core/dist/backend.js line 17526
991
- // hook.sub('traceUpdates', agent.onTraceUpdates)
992
- if (typeof hook.sub === "function") {
993
- traceUpdatesUnsubscribe = hook.sub("traceUpdates", handleTraceUpdates);
994
- debugLog("Subscribed using hook.sub()");
995
- } else {
996
- debugLog("hook.sub not available, traceUpdates may not work");
997
- }
998
-
999
- // CRITICAL: Enable trace updates on all renderers
1000
- // Without this, the renderers won't emit traceUpdates events
1001
- setTraceUpdatesOnRenderers(true);
1002
- }
1003
-
1004
- /**
1005
- * Unsubscribe from the traceUpdates event
1006
- */
1007
- function unsubscribeFromTraceUpdates() {
1008
- // Disable trace updates on renderers first
1009
- setTraceUpdatesOnRenderers(false);
1010
- if (traceUpdatesUnsubscribe) {
1011
- traceUpdatesUnsubscribe();
1012
- traceUpdatesUnsubscribe = null;
1013
- debugLog("Unsubscribed from traceUpdates event");
1014
- }
1015
- }
1016
-
1017
- /**
1018
- * Set the callback for rendering highlights
1019
- */
1020
- function setHighlightCallback(callback) {
1021
- highlightCallback = callback;
1022
- debugLog(`Highlight callback ${callback ? "set" : "cleared"}`);
1023
- }
1024
-
1025
- /**
1026
- * Set the callback for when a badge is pressed.
1027
- * This is used to navigate to the detail view when a user taps a render count badge.
1028
- */
1029
- function setBadgePressCallback(callback) {
1030
- badgePressCallback = callback;
1031
- debugLog(`Badge press callback ${callback ? "set" : "cleared"}`);
1032
- }
1033
-
1034
- /**
1035
- * Get the current badge press callback.
1036
- * Used by the overlay to check if badge presses should be handled.
1037
- */
1038
- function getBadgePressCallback() {
1039
- return badgePressCallback;
1040
- }
1041
-
1042
- /**
1043
- * Handle a badge press event.
1044
- * Calls the registered callback with the nativeTag of the component.
1045
- */
1046
- function handleBadgePress(nativeTag) {
1047
- if (badgePressCallback) {
1048
- badgePressCallback(nativeTag);
1049
- }
1050
- }
1051
-
1052
- // Spotlight highlight state - for showing which component is being viewed in detail
1053
-
1054
- let spotlightCallback = null;
1055
- let currentSpotlightTag = null;
1056
-
1057
- /**
1058
- * Set the callback for spotlight highlighting.
1059
- * Used by the overlay to show a special highlight for the component being viewed.
1060
- */
1061
- function setSpotlightCallback(callback) {
1062
- spotlightCallback = callback;
1063
- // If there's an existing spotlight, notify the new callback
1064
- if (callback && currentSpotlightTag !== null) {
1065
- callback(currentSpotlightTag);
1066
- }
1067
- }
1068
-
1069
- /**
1070
- * Set a spotlight highlight on a specific component.
1071
- * This is used when viewing a component's detail to show which one it is.
1072
- */
1073
- function setSpotlight(nativeTag) {
1074
- currentSpotlightTag = nativeTag;
1075
- if (spotlightCallback) {
1076
- spotlightCallback(nativeTag);
1077
- }
1078
- }
1079
-
1080
- /**
1081
- * Get the current spotlight nativeTag.
1082
- */
1083
- function getSpotlight() {
1084
- return currentSpotlightTag;
1085
- }
1086
- function notifyStateListeners() {
1087
- stateListeners.forEach(listener => {
1088
- try {
1089
- listener(globalEnabled);
1090
- } catch (error) {
1091
- console.error("[HighlightUpdates] Error in state listener:", error);
1092
- }
1093
- });
1094
- }
1095
- function subscribe(listener) {
1096
- stateListeners.add(listener);
1097
- listener(globalEnabled);
1098
- return () => {
1099
- stateListeners.delete(listener);
1100
- };
1101
- }
1102
- function initialize() {
1103
- if (typeof __DEV__ !== "undefined" && !__DEV__) {
1104
- debugLog("Only available in development builds");
1105
- return false;
1106
- }
1107
- if (initialized) {
1108
- return true;
1109
- }
1110
- hook = window?.__REACT_DEVTOOLS_GLOBAL_HOOK__ || null;
1111
- if (!hook) {
1112
- debugLog("React DevTools hook not found");
1113
- return false;
1114
- }
1115
- debugLog("Hook found");
1116
- debugLog(`Hook has sub: ${typeof hook.sub === "function"}`);
1117
- debugLog(`Hook has on: ${typeof hook.on === "function"}`);
1118
- debugLog(`Hook has emit: ${typeof hook.emit === "function"}`);
1119
-
1120
- // Install profiler interceptor to capture what DevTools detects
1121
- // This allows us to compare profiler data with our detection
1122
- installProfilerInterceptor();
1123
-
1124
- // Comparison callback available for future use when we re-enable our implementation
1125
- // setComparisonCallback((profilerNodes: Set<unknown>) => {
1126
- // debugLog(`[COMPARISON] Profiler detected ${profilerNodes.size} nodes`);
1127
- // });
1128
-
1129
- if (hook.rendererInterfaces && hook.rendererInterfaces.size > 0) {
1130
- initialized = true;
1131
- debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s)`);
1132
- exposeGlobally();
1133
- return true;
1134
- }
1135
-
1136
- // Wait for renderer to be available
1137
- const checkInterval = setInterval(() => {
1138
- if (hook?.rendererInterfaces && hook.rendererInterfaces.size > 0) {
1139
- clearInterval(checkInterval);
1140
- initialized = true;
1141
- debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s) (delayed)`);
1142
- exposeGlobally();
1143
- }
1144
- }, 100);
1145
- setTimeout(() => clearInterval(checkInterval), 10000);
1146
- return false;
1147
- }
1148
- function exposeGlobally() {
1149
- if (typeof window !== "undefined") {
1150
- window.__HIGHLIGHT_UPDATES_CONTROLLER__ = {
1151
- enable,
1152
- disable,
1153
- toggle,
1154
- isEnabled,
1155
- setEnabled,
1156
- subscribe,
1157
- initialize,
1158
- destroy,
1159
- isInitialized: () => initialized,
1160
- setHighlightCallback
1161
- };
1162
- }
1163
- }
1164
- function enable() {
1165
- if (typeof __DEV__ !== "undefined" && !__DEV__) return;
1166
- if (!initialized) {
1167
- initialize();
1168
- }
1169
- if (globalEnabled) {
1170
- return;
1171
- }
1172
- debugLog("Enabling highlights");
1173
-
1174
- // Only subscribe if not already subscribed via background tracking
1175
- if (!backgroundTrackingEnabled) {
1176
- subscribeToTraceUpdates();
1177
- }
1178
-
1179
- // Start tracking renders
1180
- RenderTracker.start();
1181
-
1182
- // Note: profiler logging disabled for normal operation
1183
- // enableProfilerLogging();
1184
-
1185
- globalEnabled = true;
1186
- notifyStateListeners();
1187
- notifySubscriberCountChange('render');
1188
- }
1189
- function disable() {
1190
- if (typeof __DEV__ !== "undefined" && !__DEV__) return;
1191
- if (!globalEnabled) {
1192
- return;
1193
- }
1194
- debugLog("Disabling highlights");
1195
-
1196
- // Clear any pending locks/state
1197
- renderingLock = false;
1198
- isProcessing = false;
1199
- if (renderingLockTimeout) {
1200
- clearTimeout(renderingLockTimeout);
1201
- renderingLockTimeout = null;
1202
- }
1203
- renderedOverlayTags.clear();
1204
- devToolsNodeCache.clear(); // Clear detection cache
1205
- clearRenderCauseState(); // Clear render cause state to prevent memory leaks
1206
-
1207
- // Only unsubscribe if background tracking doesn't need it
1208
- if (!backgroundTrackingEnabled) {
1209
- unsubscribeFromTraceUpdates();
1210
- }
1211
-
1212
- // Stop tracking renders
1213
- RenderTracker.stop();
1214
-
1215
- // Note: profiler logging disabled for normal operation
1216
- // disableProfilerLogging();
1217
-
1218
- globalEnabled = false;
1219
- notifyStateListeners();
1220
- notifySubscriberCountChange('render');
1221
- }
1222
-
1223
- /**
1224
- * Enable background render tracking (for Events tool).
1225
- * This enables render interception WITHOUT affecting the visual toggle state.
1226
- * The visual highlight toggle remains independent.
1227
- */
1228
- function enableBackgroundTracking() {
1229
- if (typeof __DEV__ !== "undefined" && !__DEV__) return;
1230
- if (backgroundTrackingEnabled) {
1231
- return;
1232
- }
1233
- if (!initialized) {
1234
- initialize();
1235
- }
1236
- debugLog("Enabling background tracking");
1237
-
1238
- // Only subscribe if not already subscribed via main toggle
1239
- if (!globalEnabled) {
1240
- subscribeToTraceUpdates();
1241
- }
1242
- backgroundTrackingEnabled = true;
1243
- }
1244
-
1245
- /**
1246
- * Disable background render tracking (for Events tool).
1247
- * Only actually unsubscribes if the main toggle is also off.
1248
- */
1249
- function disableBackgroundTracking() {
1250
- if (typeof __DEV__ !== "undefined" && !__DEV__) return;
1251
- if (!backgroundTrackingEnabled) {
1252
- return;
1253
- }
1254
- debugLog("Disabling background tracking");
1255
- backgroundTrackingEnabled = false;
1256
-
1257
- // Only unsubscribe if main toggle is also off
1258
- if (!globalEnabled) {
1259
- unsubscribeFromTraceUpdates();
1260
- }
1261
- }
1262
-
1263
- /**
1264
- * Check if background tracking is enabled (for debugging)
1265
- */
1266
- function isBackgroundTrackingEnabled() {
1267
- return backgroundTrackingEnabled;
1268
- }
1269
- function toggle() {
1270
- if (typeof __DEV__ !== "undefined" && !__DEV__) return;
1271
- if (globalEnabled) {
1272
- disable();
1273
- } else {
1274
- enable();
1275
- }
1276
- }
1277
-
1278
- /**
1279
- * Clear all render counts and tracked data
1280
- */
1281
- function clearRenderCounts() {
1282
- nodeRenderCounts.clear();
1283
- RenderTracker.clear();
1284
- debugLog("Cleared render counts");
1285
- }
1286
- function isEnabled() {
1287
- return globalEnabled;
1288
- }
1289
- function setEnabled(enabled) {
1290
- if (enabled) enable();else disable();
1291
- }
1292
- function isInitialized() {
1293
- return initialized;
1294
- }
1295
-
1296
- // ============================================================================
1297
- // FREEZE FRAME MODE
1298
- // ============================================================================
1299
-
1300
- /**
1301
- * Notify all freeze state listeners of a change
1302
- */
1303
- function notifyFreezeListeners() {
1304
- freezeListeners.forEach(listener => {
1305
- try {
1306
- listener(isFrozen);
1307
- } catch (error) {
1308
- console.error("[HighlightUpdates] Error in freeze listener:", error);
1309
- }
1310
- });
1311
- }
1312
-
1313
- /**
1314
- * Subscribe to freeze state changes
1315
- */
1316
- function subscribeToFreeze(listener) {
1317
- freezeListeners.add(listener);
1318
- listener(isFrozen);
1319
- return () => {
1320
- freezeListeners.delete(listener);
1321
- };
1322
- }
1323
-
1324
- /**
1325
- * Freeze highlights - prevents highlights from fading away.
1326
- * New renders are still captured but old highlights don't clear.
1327
- */
1328
- function freeze() {
1329
- if (typeof __DEV__ !== "undefined" && !__DEV__) return;
1330
- if (isFrozen) return;
1331
- isFrozen = true;
1332
- debugLog("Freeze mode enabled");
1333
- notifyFreezeListeners();
1334
- }
1335
-
1336
- /**
1337
- * Unfreeze highlights - resumes normal cleanup behavior.
1338
- * Clears all current highlights when unfreezing.
1339
- */
1340
- function unfreeze() {
1341
- if (typeof __DEV__ !== "undefined" && !__DEV__) return;
1342
- if (!isFrozen) return;
1343
- isFrozen = false;
1344
- debugLog("Freeze mode disabled");
1345
-
1346
- // Clear all current highlights when unfreezing
1347
- if (highlightCallback) {
1348
- highlightCallback([]);
1349
- }
1350
- notifyFreezeListeners();
1351
- }
1352
-
1353
- /**
1354
- * Toggle freeze state
1355
- */
1356
- function toggleFreeze() {
1357
- if (isFrozen) {
1358
- unfreeze();
1359
- } else {
1360
- freeze();
1361
- }
1362
- }
1363
-
1364
- /**
1365
- * Check if freeze mode is active
1366
- */
1367
- function getFrozen() {
1368
- return isFrozen;
1369
- }
1370
- function destroy() {
1371
- if (!initialized) return;
1372
- unsubscribeFromTraceUpdates();
1373
-
1374
- // Uninstall profiler interceptor
1375
- uninstallProfilerInterceptor();
1376
- setComparisonCallback(null);
1377
-
1378
- // Reset freeze state
1379
- isFrozen = false;
1380
- freezeListeners.clear();
1381
- globalEnabled = false;
1382
- hook = null;
1383
- highlightCallback = null;
1384
- initialized = false;
1385
- if (typeof window !== "undefined") {
1386
- delete window.__HIGHLIGHT_UPDATES_CONTROLLER__;
1387
- }
1388
- debugLog("Destroyed");
1389
- }
1390
- const HighlightUpdatesController = {
1391
- subscribe,
1392
- enable,
1393
- disable,
1394
- toggle,
1395
- isEnabled,
1396
- setEnabled,
1397
- initialize,
1398
- destroy,
1399
- isInitialized,
1400
- setHighlightCallback,
1401
- clearRenderCounts,
1402
- // Freeze frame mode
1403
- freeze,
1404
- unfreeze,
1405
- toggleFreeze,
1406
- getFrozen,
1407
- subscribeToFreeze,
1408
- // Badge press callback for "Click Overlay Badge → Jump to Detail"
1409
- setBadgePressCallback,
1410
- getBadgePressCallback,
1411
- handleBadgePress,
1412
- // Spotlight highlight for detail view
1413
- setSpotlightCallback,
1414
- setSpotlight,
1415
- getSpotlight,
1416
- // Cache management for excludeDevTools toggle
1417
- clearDevToolsCache,
1418
- // Background tracking for Events tool (separate from visual toggle)
1419
- enableBackgroundTracking,
1420
- disableBackgroundTracking,
1421
- isBackgroundTrackingEnabled
1422
- };
1423
- export default HighlightUpdatesController;
1
+ "use strict";import{installProfilerInterceptor,uninstallProfilerInterceptor,setComparisonCallback}from"./ProfilerInterceptor";import{RenderTracker}from"./RenderTracker";import{PerformanceLogger,markEventReceived}from"./PerformanceLogger";import{detectRenderCause,clearRenderCauseState}from"./RenderCauseDetector";import{notifySubscriberCountChange}from"@buoy-gg/shared-ui";let globalEnabled=!1,backgroundTrackingEnabled=!1,initialized=!1,hook=null,highlightCallback=null,badgePressCallback=null,traceUpdatesUnsubscribe=null,isProcessing=!1,isFrozen=!1;const freezeListeners=new Set,stateListeners=new Set,nodeRenderCounts=new Map,COLORS=["#37afa9","#63b19e","#80b393","#97b488","#abb67d","#beb771","#cfb965","#dfba57","#efbb49","#febc38"],DEBUG=!1;function debugLog(e,n){}function getPublicInstance(e){if(!e)return null;const n=e;return n.canonical?.publicInstance?n.canonical.publicInstance:n.canonical&&"function"==typeof n.canonical.measure?n.canonical:"function"==typeof n.measure?n:null}function getNativeTag(e){if(null==e)return null;const n=e;if(null!=n.__nativeTag)return n.__nativeTag;if(null!=n._nativeTag)return n._nativeTag;if(null!=n.nativeTag)return n.nativeTag;if(n.canonical){if(null!=n.canonical.__nativeTag)return n.canonical.__nativeTag;if(null!=n.canonical._nativeTag)return n.canonical._nativeTag}return null}function extractComponentInfo(e){const n=e,t={viewType:"Unknown"};n?.canonical?.viewConfig?.uiViewClassName?t.viewType=n.canonical.viewConfig.uiViewClassName:n?.viewConfig?.uiViewClassName&&(t.viewType=n.viewConfig.uiViewClassName);const i=n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV,a=n?.canonical?.currentProps,r=n?.canonical?.pendingProps,o=i?.pendingProps,s=i?.memoizedProps;return t.testID=a?.testID||r?.testID||o?.testID||s?.testID||void 0,t.nativeID=a?.nativeID||r?.nativeID||o?.nativeID||s?.nativeID||void 0,t.accessibilityLabel=a?.accessibilityLabel||r?.accessibilityLabel||o?.accessibilityLabel||s?.accessibilityLabel||void 0,t.componentName=getOwningComponentName(i)||void 0,t}function describeNodeForLog(e){const n=e,t=getPublicInstance(e),i={nativeTag:(getNativeTag(e)||getNativeTag(t))??"unknown",type:n?.canonical?"Fabric":"Legacy",hasMeasure:"function"==typeof t?.measure};if(n){if(i.stateNodeKeys=Object.keys(n).slice(0,20),n.node&&(i.nodeKeys=Object.keys(n.node).slice(0,20)),n.viewConfig&&(i.viewConfig={uiViewClassName:n.viewConfig.uiViewClassName,validAttributes:n.viewConfig.validAttributes?Object.keys(n.viewConfig.validAttributes).slice(0,10):void 0}),n.canonical){const e=n.canonical;if(i.canonicalKeys=Object.keys(e).slice(0,20),e.viewConfig&&(i.canonicalViewConfig={uiViewClassName:e.viewConfig.uiViewClassName}),null!=e.nativeTag&&(i.canonicalNativeTag=e.nativeTag),e.internalInstanceHandle){const n=e.internalInstanceHandle;if(i.fiberKeys=Object.keys(n).slice(0,30),n.type&&(i.fiberType="function"==typeof n.type?n.type.name||n.type.displayName||"function":n.type),n.elementType&&(i.fiberElementType="function"==typeof n.elementType?n.elementType.name||n.elementType.displayName||"function":n.elementType),n._debugOwner){const e=n._debugOwner;i.fiberDebugOwner=e.type?.name||e.type?.displayName||e.elementType?.name||"unknown"}n._debugSource&&(i.fiberDebugSource=n._debugSource),null!=n.tag&&(i.fiberTag=n.tag),n.pendingProps&&(n.pendingProps.nativeID&&(i.fiberPendingNativeID=n.pendingProps.nativeID),n.pendingProps.testID&&(i.fiberPendingTestID=n.pendingProps.testID)),n.memoizedProps&&(n.memoizedProps.nativeID&&(i.fiberMemoizedNativeID=n.memoizedProps.nativeID),n.memoizedProps.testID&&(i.fiberMemoizedTestID=n.memoizedProps.testID))}if(e.publicInstance){const n=e.publicInstance;i.publicInstanceKeys=Object.keys(n).slice(0,20),null!=n.nativeID&&(i.nativeID=n.nativeID),null!=n._nativeID&&(i._nativeID=n._nativeID),n.props&&(i.publicInstanceProps=Object.keys(n.props).slice(0,15),n.props.nativeID&&(i.propsNativeID=n.props.nativeID),n.props.testID&&(i.propsTestID=n.props.testID),n.props.accessibilityLabel&&(i.accessibilityLabel=n.props.accessibilityLabel))}e.currentProps&&(i.currentPropsKeys=Object.keys(e.currentProps).slice(0,15),null!=e.currentProps.nativeID&&(i.currentPropsNativeID=e.currentProps.nativeID),null!=e.currentProps.testID&&(i.currentPropsTestID=e.currentProps.testID),null!=e.currentProps.accessibilityLabel&&(i.currentPropsAccessLabel=e.currentProps.accessibilityLabel)),e.pendingProps&&(i.pendingPropsKeys=Object.keys(e.pendingProps).slice(0,15),null!=e.pendingProps.nativeID&&(i.pendingPropsNativeID=e.pendingProps.nativeID),null!=e.pendingProps.testID&&(i.pendingPropsTestID=e.pendingProps.testID))}if(n._debugOwner){const e=n._debugOwner;i.debugOwnerType=e.type?.name||e.type?.displayName||typeof e.type}n._debugSource&&(i.debugSource=n._debugSource)}return i}const DEBUG_LOGGING=!1;let renderingLock=!1,renderingLockTimeout=null;const RENDER_LOCK_DURATION=350,renderedOverlayTags=new Set;function isOurOverlayTag(e){return null!=e&&renderedOverlayTags.has(e)}const HIGHLIGHT_OVERLAY_COMPONENTS=new Set(["HighlightUpdatesOverlay","HighlightUpdatesModal","HighlightFilterView","RenderDetailView","RenderListItem","RenderListItemInner","RenderHistoryViewer","RenderHistoryFooter","RenderCauseBadge","TwoLevelCauseBadge","EnhancedCauseDisplay","IsolatedRenderList","IsolatedRenderListInner","StatsDisplay","StatsDisplayInner","CurrentStateView","EventStepperFooter","EventsModal","UnifiedEventList","UnifiedEventItem","UnifiedEventDetail","UnifiedEventFilters","UnifiedEventViewer","ReactQueryEventDetail","EventsCopySettingsView"]),HIGHLIGHT_OVERLAY_NATIVE_IDS=new Set(["highlight-updates-overlay","__rn_buoy__highlight-modal"]),HIGHLIGHT_OVERLAY_PREFIXES=["HighlightUpdates","RenderList","RenderDetail","RenderHistory","RenderCause","EventStepper","UnifiedEvent","EventsModal","EventsCopy"],OTHER_DEV_TOOLS_COMPONENTS=new Set(["JsModalComponent","JsModal","TypePicker","PatternInput","PatternChip","DetectedItemsSection","DetectedCategoryBadge","IdentifierBadge","CategoryBadge","AppRenderer","AppOverlay","FloatingTools","DialDevTools","DevToolsVisibilityProvider","AppHostProvider","MinimizedToolsProvider","ModalHeader","TabSelector","SectionHeader","DraggableHeader","WindowControls","TreeDiffViewer","DataViewer","SplitDiffViewer","VirtualizedDataExplorer","DiffSummary","TypeLegend","IndentGuides","IndentGuidesOverlay","CyberpunkInput","DiffView","AnswerCard","DetailsSection","DetailRow","QuickActionsSection","FilterOptionCard","SearchSection","SearchSectionInner","HeaderActions","HeaderActionsInner","MainListHeader","FilterViewHeader","DetailViewHeader","FloatingMenu","FloatingDevTools","MinimizedToolsStack","MinimizedToolsContext","GlitchToolButton","ExpandablePopover","CollapsedPeek","ExpandedWrapper","DialIcon","DialMenu","DialIconItem","OnboardingTooltip","MenuLauncherIcon","DevToolsSettingsModal","SettingsModal","ToolCard","ToolIcon","GripVerticalIcon","UserStatus","Divider","ChevronDown","ChevronUp","ChevronLeft","ChevronRight","ChevronDownIcon","ChevronUpIcon","ChevronLeftIcon","ChevronRightIcon","LogBox","LogBoxLog","LogBoxLogNotification","LogBoxNotificationContainer","_LogBoxNotificationContainer","LogBoxInspector","LogBoxInspectorContainer","LogBoxInspectorHeader","LogBoxInspectorBody","LogBoxInspectorFooter","LogBoxInspectorMessageHeader","LogBoxInspectorStackFrame","LogBoxInspectorSection","LogBoxButton","LogBoxMessage"]),OTHER_DEV_TOOLS_PREFIXES=["JsModal","TreeDiff","DataViewer","DiffView","DiffSummary","Virtualized","Floating","Minimized","Dial","Expandable","Chevron","Glitch","Settings","Onboarding","DevTools"],OTHER_DEV_TOOLS_NATIVE_IDS=new Set(["jsmodal-root","logbox_inspector","logbox"]),devToolsNodeCache=new Map,CACHE_MAX_SIZE=500;function clearDevToolsCache(){devToolsNodeCache.clear()}function isHighlightOverlayNativeID(e){return!(!e||!HIGHLIGHT_OVERLAY_NATIVE_IDS.has(e)&&!e.startsWith("__highlight_"))}function isOtherDevToolsNativeID(e){if(!e)return!1;if(OTHER_DEV_TOOLS_NATIVE_IDS.has(e))return!0;const n=e.charCodeAt(0);return!(95!==n||!e.startsWith("__rn_buoy__"))||!(108!==n||!e.startsWith("logbox"))}function getComponentName(e){if(!e)return null;const n=e.type;if(n){if("string"==typeof n)return n;if(n.name)return n.name;if(n.displayName)return n.displayName}const t=e.elementType;if(t){if(t.name)return t.name;if(t.displayName)return t.displayName}return null}const INTERNAL_COMPONENT_NAMES=new Set(["View","Text","TextImpl","Image","ScrollView","FlatList","SectionList","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","Pressable","TextInput","Switch","ActivityIndicator","Modal","StatusBar","KeyboardAvoidingView","AnimatedComponent","AnimatedComponentWrapper","ScreenContainer","ScreenStack","Screen","ScreenContentWrapper","Svg","G","Path","Rect","Circle","Line","Polygon","Polyline","Ellipse","Text as SVGText","TSpan","TextPath","Use","Symbol","Defs","ClipPath","LinearGradient","RadialGradient","Stop","Mask","Pattern","Image as SVGImage","SafeAreaProvider","SafeAreaView","SafeAreaListener","GestureHandlerRootView","GestureDetector","ReanimatedView","ReanimatedText","ReanimatedImage","ReanimatedScrollView","Fragment","Suspense","Provider","Consumer","Context","ForwardRef"]);function isInternalComponent(e){return!e||!!INTERNAL_COMPONENT_NAMES.has(e)||"Unknown"===e||"Component"===e||!!e.startsWith("Animated")}function getOwningComponentName(e){if(!e)return null;let n=e._debugOwner||e.return,t=0,i=null;for(;n&&t<30;){const e=getComponentName(n);if(e&&"string"!=typeof n.type&&(i||(i=e),!isInternalComponent(e)))return e;n=n.return,t++}return i}function isOurOverlayNode(e){const n=e,t=n?.canonical?.internalInstanceHandle||n?._internalInstanceHandle||n?._internalFiberInstanceHandleDEV,i=getNativeTag(e)||getNativeTag(n?.canonical?.publicInstance),a=RenderTracker.getSettings().excludeDevTools;if(null!=i&&a){const e=devToolsNodeCache.get(i);if(void 0!==e)return e}let r=!1;const o=t?.pendingProps?.nativeID||t?.memoizedProps?.nativeID||n?.canonical?.currentProps?.nativeID||null;if((isHighlightOverlayNativeID(o)||a&&isOtherDevToolsNativeID(o))&&(r=!0),!r&&t){let e=t,n=0;for(;e&&n<30;){const t=getComponentName(e);if(t){if(HIGHLIGHT_OVERLAY_COMPONENTS.has(t)){r=!0;break}for(const e of HIGHLIGHT_OVERLAY_PREFIXES)if(t.startsWith(e)){r=!0;break}if(r)break;if(a){if(OTHER_DEV_TOOLS_COMPONENTS.has(t)){r=!0;break}for(const e of OTHER_DEV_TOOLS_PREFIXES)if(t.startsWith(e)){r=!0;break}if(r)break}}const i=e.pendingProps?.nativeID||e.memoizedProps?.nativeID;if(isHighlightOverlayNativeID(i)){r=!0;break}if(a&&isOtherDevToolsNativeID(i)){r=!0;break}e=e.return,n++}}if(r&&null!=i&&a){if(devToolsNodeCache.size>=500){const e=Array.from(devToolsNodeCache.keys());for(let n=0;n<250;n++)devToolsNodeCache.delete(e[n])}devToolsNodeCache.set(i,r)}return r}function getColorForRenderCount(e){const n=Math.min(e-1,COLORS.length-1);return COLORS[Math.max(0,n)]}function handleTraceUpdates(e){if(0===e.size)return;if(!globalEnabled&&!backgroundTrackingEnabled)return;if(RenderTracker.getState().isPaused)return;PerformanceLogger.isEnabled()&&markEventReceived();const n=RenderTracker.getBatchSize(),t=PerformanceLogger.startBatch(e.size,n),i=[];let a=0,r=0;const o=RenderTracker.hasActiveFilters();for(const n of e)if(n&&"object"==typeof n){if(isOurOverlayNode(n)){a++;continue}const e=getPublicInstance(n),t=getNativeTag(n)||getNativeTag(e);if(null==t)continue;const s=extractComponentInfo(n);if(o&&!RenderTracker.passesFilters(s)){r++;continue}let l,c;RenderTracker.getSettings().showRenderCount?(l=(nodeRenderCounts.get(t)||0)+1,nodeRenderCounts.set(t,l),c=getColorForRenderCount(l)):(l=0,c=COLORS[0]),i.push({node:n,color:c,count:l})}if(t.markFilteringComplete(a+r,i.length),0===i.length)return void t.finish();const s=RenderTracker.getRenderEventCallbackCount()>0;if(!highlightCallback&&!s)return void(isProcessing=!1);t.markMeasurementStart();const l=i.slice(0,n).map(({node:e,color:n,count:t})=>new Promise(i=>{const a=getPublicInstance(e);if(!a)return void i({rect:null,stateNode:e,color:n,count:t});const r=getNativeTag(e)||getNativeTag(a);if(null!=r)try{a.measure((a,o,s,l,c,d)=>{i(null!=c&&null!=d&&null!=s&&null!=l?{rect:{id:r,x:c,y:d,width:s,height:l,color:n,count:t},stateNode:e,color:n,count:t}:{rect:null,stateNode:e,color:n,count:t})})}catch(a){i({rect:null,stateNode:e,color:n,count:t})}else i({rect:null,stateNode:e,color:n,count:t})}));Promise.all(l).then(e=>{const n=e.filter(e=>null!==e.rect),i=n.map(e=>e.rect);t.markMeasurementComplete(n.length,e.length-n.length);const a=RenderTracker.getSettings(),r=a.trackRenderCauses&&a.showRenderCount;let o=null;if(r){o=new Set;for(const{rect:e}of n)e&&o.add(e.id)}if(globalEnabled){RenderTracker.startBatch();for(const{rect:e,stateNode:t,color:i,count:s}of n)if(e){const n=extractComponentInfo(t);let l;if(r&&o){const n=t,i=n?.canonical?.internalInstanceHandle;l=detectRenderCause(e.id,i,o,a.debugLogLevel)}RenderTracker.trackRender({nativeTag:e.id,viewType:n.viewType,testID:n.testID,nativeID:n.nativeID,accessibilityLabel:n.accessibilityLabel,componentName:n.componentName,measurements:{x:e.x,y:e.y,width:e.width,height:e.height},color:i,count:s,renderCause:l})}RenderTracker.endBatch()}else for(const{rect:e,stateNode:t,color:i,count:s}of n)if(e){const n=extractComponentInfo(t);let l;if(r&&o){const n=t,i=n?.canonical?.internalInstanceHandle;l=detectRenderCause(e.id,i,o,a.debugLogLevel)}RenderTracker.emitRenderEvent({nativeTag:e.id,viewType:n.viewType,testID:n.testID,nativeID:n.nativeID,accessibilityLabel:n.accessibilityLabel,componentName:n.componentName,measurements:{x:e.x,y:e.y,width:e.width,height:e.height},color:i,count:s,renderCause:l})}t.markTrackingComplete(),i.length>0&&highlightCallback&&globalEnabled&&highlightCallback(i),t.markCallbackComplete(),t.finish()}).catch(e=>{console.error("[HighlightUpdates] Error in measurement pipeline:",e),t.finish()})}function setTraceUpdatesOnRenderers(e){if(!hook?.rendererInterfaces)return void debugLog("No rendererInterfaces available");let n=0;if(hook.rendererInterfaces.forEach((t,i)=>{if("function"==typeof t.setTraceUpdatesEnabled)try{t.setTraceUpdatesEnabled(e),n++,debugLog(`Renderer ${i}: setTraceUpdatesEnabled(${e})`)}catch(e){debugLog(`Renderer ${i}: error setting trace updates`,e)}else debugLog(`Renderer ${i}: no setTraceUpdatesEnabled method`)}),debugLog(`Set trace updates ${e?"enabled":"disabled"} on ${n} renderer(s)`),hook.reactDevtoolsAgent?.setTraceUpdatesEnabled)try{hook.reactDevtoolsAgent.setTraceUpdatesEnabled(e),debugLog("Also set trace updates on agent")}catch(e){debugLog("Error setting trace updates on agent",e)}}function subscribeToTraceUpdates(){hook&&(traceUpdatesUnsubscribe||(debugLog("Subscribing to traceUpdates event"),"function"==typeof hook.sub?(traceUpdatesUnsubscribe=hook.sub("traceUpdates",handleTraceUpdates),debugLog("Subscribed using hook.sub()")):debugLog("hook.sub not available, traceUpdates may not work"),setTraceUpdatesOnRenderers(!0)))}function unsubscribeFromTraceUpdates(){setTraceUpdatesOnRenderers(!1),traceUpdatesUnsubscribe&&(traceUpdatesUnsubscribe(),traceUpdatesUnsubscribe=null,debugLog("Unsubscribed from traceUpdates event"))}function setHighlightCallback(e){highlightCallback=e,debugLog("Highlight callback "+(e?"set":"cleared"))}function setBadgePressCallback(e){badgePressCallback=e,debugLog("Badge press callback "+(e?"set":"cleared"))}function getBadgePressCallback(){return badgePressCallback}function handleBadgePress(e){badgePressCallback&&badgePressCallback(e)}let spotlightCallback=null,currentSpotlightTag=null;function setSpotlightCallback(e){spotlightCallback=e,e&&null!==currentSpotlightTag&&e(currentSpotlightTag)}function setSpotlight(e){currentSpotlightTag=e,spotlightCallback&&spotlightCallback(e)}function getSpotlight(){return currentSpotlightTag}function notifyStateListeners(){stateListeners.forEach(e=>{try{e(globalEnabled)}catch(e){console.error("[HighlightUpdates] Error in state listener:",e)}})}function subscribe(e){return stateListeners.add(e),e(globalEnabled),()=>{stateListeners.delete(e)}}function initialize(){if("undefined"!=typeof __DEV__&&!__DEV__)return debugLog("Only available in development builds"),!1;if(initialized)return!0;if(hook=window?.__REACT_DEVTOOLS_GLOBAL_HOOK__||null,!hook)return debugLog("React DevTools hook not found"),!1;if(debugLog("Hook found"),debugLog(`Hook has sub: ${"function"==typeof hook.sub}`),debugLog(`Hook has on: ${"function"==typeof hook.on}`),debugLog(`Hook has emit: ${"function"==typeof hook.emit}`),installProfilerInterceptor(),hook.rendererInterfaces&&hook.rendererInterfaces.size>0)return initialized=!0,debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s)`),exposeGlobally(),!0;const e=setInterval(()=>{hook?.rendererInterfaces&&hook.rendererInterfaces.size>0&&(clearInterval(e),initialized=!0,debugLog(`Initialized with ${hook.rendererInterfaces.size} renderer(s) (delayed)`),exposeGlobally())},100);return setTimeout(()=>clearInterval(e),1e4),!1}function exposeGlobally(){"undefined"!=typeof window&&(window.__HIGHLIGHT_UPDATES_CONTROLLER__={enable:enable,disable:disable,toggle:toggle,isEnabled:isEnabled,setEnabled:setEnabled,subscribe:subscribe,initialize:initialize,destroy:destroy,isInitialized:()=>initialized,setHighlightCallback:setHighlightCallback})}function enable(){("undefined"==typeof __DEV__||__DEV__)&&(initialized||initialize(),globalEnabled||(debugLog("Enabling highlights"),backgroundTrackingEnabled||subscribeToTraceUpdates(),RenderTracker.start(),globalEnabled=!0,notifyStateListeners(),notifySubscriberCountChange("render")))}function disable(){("undefined"==typeof __DEV__||__DEV__)&&globalEnabled&&(debugLog("Disabling highlights"),renderingLock=!1,isProcessing=!1,renderingLockTimeout&&(clearTimeout(renderingLockTimeout),renderingLockTimeout=null),renderedOverlayTags.clear(),devToolsNodeCache.clear(),clearRenderCauseState(),backgroundTrackingEnabled||unsubscribeFromTraceUpdates(),RenderTracker.stop(),globalEnabled=!1,notifyStateListeners(),notifySubscriberCountChange("render"))}function enableBackgroundTracking(){("undefined"==typeof __DEV__||__DEV__)&&(backgroundTrackingEnabled||(initialized||initialize(),debugLog("Enabling background tracking"),globalEnabled||subscribeToTraceUpdates(),backgroundTrackingEnabled=!0))}function disableBackgroundTracking(){("undefined"==typeof __DEV__||__DEV__)&&backgroundTrackingEnabled&&(debugLog("Disabling background tracking"),backgroundTrackingEnabled=!1,globalEnabled||unsubscribeFromTraceUpdates())}function isBackgroundTrackingEnabled(){return backgroundTrackingEnabled}function toggle(){("undefined"==typeof __DEV__||__DEV__)&&(globalEnabled?disable():enable())}function clearRenderCounts(){nodeRenderCounts.clear(),RenderTracker.clear(),debugLog("Cleared render counts")}function isEnabled(){return globalEnabled}function setEnabled(e){e?enable():disable()}function isInitialized(){return initialized}function notifyFreezeListeners(){freezeListeners.forEach(e=>{try{e(isFrozen)}catch(e){console.error("[HighlightUpdates] Error in freeze listener:",e)}})}function subscribeToFreeze(e){return freezeListeners.add(e),e(isFrozen),()=>{freezeListeners.delete(e)}}function freeze(){("undefined"==typeof __DEV__||__DEV__)&&(isFrozen||(isFrozen=!0,debugLog("Freeze mode enabled"),notifyFreezeListeners()))}function unfreeze(){("undefined"==typeof __DEV__||__DEV__)&&isFrozen&&(isFrozen=!1,debugLog("Freeze mode disabled"),highlightCallback&&highlightCallback([]),notifyFreezeListeners())}function toggleFreeze(){isFrozen?unfreeze():freeze()}function getFrozen(){return isFrozen}function destroy(){initialized&&(unsubscribeFromTraceUpdates(),uninstallProfilerInterceptor(),setComparisonCallback(null),isFrozen=!1,freezeListeners.clear(),globalEnabled=!1,hook=null,highlightCallback=null,initialized=!1,"undefined"!=typeof window&&delete window.__HIGHLIGHT_UPDATES_CONTROLLER__,debugLog("Destroyed"))}const HighlightUpdatesController={subscribe:subscribe,enable:enable,disable:disable,toggle:toggle,isEnabled:isEnabled,setEnabled:setEnabled,initialize:initialize,destroy:destroy,isInitialized:isInitialized,setHighlightCallback:setHighlightCallback,clearRenderCounts:clearRenderCounts,freeze:freeze,unfreeze:unfreeze,toggleFreeze:toggleFreeze,getFrozen:getFrozen,subscribeToFreeze:subscribeToFreeze,setBadgePressCallback:setBadgePressCallback,getBadgePressCallback:getBadgePressCallback,handleBadgePress:handleBadgePress,setSpotlightCallback:setSpotlightCallback,setSpotlight:setSpotlight,getSpotlight:getSpotlight,clearDevToolsCache:clearDevToolsCache,enableBackgroundTracking:enableBackgroundTracking,disableBackgroundTracking:disableBackgroundTracking,isBackgroundTrackingEnabled:isBackgroundTrackingEnabled};export default HighlightUpdatesController;