@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.
- package/README.md +11 -67
- package/lib/commonjs/highlight-updates/HighlightUpdatesOverlay.js +1 -281
- package/lib/commonjs/highlight-updates/components/HighlightFilterView.js +1 -1474
- package/lib/commonjs/highlight-updates/components/HighlightUpdatesModal.js +1 -641
- package/lib/commonjs/highlight-updates/components/IdentifierBadge.js +1 -273
- package/lib/commonjs/highlight-updates/components/IsolatedRenderList.js +1 -188
- package/lib/commonjs/highlight-updates/components/ModalHeaderContent.js +1 -293
- package/lib/commonjs/highlight-updates/components/RenderCauseBadge.js +1 -508
- package/lib/commonjs/highlight-updates/components/RenderDetailView.js +1 -846
- package/lib/commonjs/highlight-updates/components/RenderHistoryViewer.js +1 -915
- package/lib/commonjs/highlight-updates/components/RenderListItem.js +1 -235
- package/lib/commonjs/highlight-updates/components/RendersCopySettingsView.js +1 -469
- package/lib/commonjs/highlight-updates/components/StatsDisplay.js +1 -73
- package/lib/commonjs/highlight-updates/types/copySettings.js +1 -107
- package/lib/commonjs/highlight-updates/utils/CommitProfiler.js +1 -446
- package/lib/commonjs/highlight-updates/utils/HighlightUpdatesController.js +1 -1920
- package/lib/commonjs/highlight-updates/utils/PerformanceLogger.js +26 -359
- package/lib/commonjs/highlight-updates/utils/ProfilerInterceptor.js +1 -371
- package/lib/commonjs/highlight-updates/utils/RenderCauseDetector.js +5 -1840
- package/lib/commonjs/highlight-updates/utils/RenderTracker.js +1 -952
- package/lib/commonjs/highlight-updates/utils/ViewTypeMapper.js +1 -264
- package/lib/commonjs/highlight-updates/utils/copySettingsStorage.js +1 -32
- package/lib/commonjs/highlight-updates/utils/devtoolsComponentNames.js +1 -188
- package/lib/commonjs/highlight-updates/utils/namedComposite.js +1 -41
- package/lib/commonjs/highlight-updates/utils/ownStateChanged.js +1 -103
- package/lib/commonjs/highlight-updates/utils/rawEventEmitter.js +1 -50
- package/lib/commonjs/highlight-updates/utils/rawEventEmitter.web.js +1 -0
- package/lib/commonjs/highlight-updates/utils/renderExportFormatter.js +1 -58
- package/lib/commonjs/highlight-updates/utils/rendersExportFormatter.js +1 -485
- package/lib/commonjs/highlight-updates/utils/screenElements.js +1 -1248
- package/lib/commonjs/highlight-updates/utils/tapMatch.js +1 -83
- package/lib/commonjs/highlight-updates/utils/testIDs.js +1 -68
- package/lib/commonjs/highlight-updates/utils/touchCapture.js +1 -277
- package/lib/commonjs/index.js +1 -429
- package/lib/commonjs/preset.js +1 -278
- package/lib/commonjs/sync/highlightUpdatesSyncAdapter.js +1 -235
- package/lib/module/highlight-updates/HighlightUpdatesOverlay.js +1 -274
- package/lib/module/highlight-updates/components/HighlightFilterView.js +1 -1468
- package/lib/module/highlight-updates/components/HighlightUpdatesModal.js +1 -634
- package/lib/module/highlight-updates/components/IdentifierBadge.js +1 -265
- package/lib/module/highlight-updates/components/IsolatedRenderList.js +1 -183
- package/lib/module/highlight-updates/components/ModalHeaderContent.js +1 -288
- package/lib/module/highlight-updates/components/RenderCauseBadge.js +1 -499
- package/lib/module/highlight-updates/components/RenderDetailView.js +1 -840
- package/lib/module/highlight-updates/components/RenderHistoryViewer.js +1 -908
- package/lib/module/highlight-updates/components/RenderListItem.js +1 -230
- package/lib/module/highlight-updates/components/RendersCopySettingsView.js +1 -465
- package/lib/module/highlight-updates/components/StatsDisplay.js +1 -70
- package/lib/module/highlight-updates/types/copySettings.js +1 -102
- package/lib/module/highlight-updates/utils/CommitProfiler.js +1 -442
- package/lib/module/highlight-updates/utils/HighlightUpdatesController.js +1 -1916
- package/lib/module/highlight-updates/utils/PerformanceLogger.js +26 -353
- package/lib/module/highlight-updates/utils/ProfilerInterceptor.js +1 -358
- package/lib/module/highlight-updates/utils/RenderCauseDetector.js +5 -1830
- package/lib/module/highlight-updates/utils/RenderTracker.js +1 -949
- package/lib/module/highlight-updates/utils/ViewTypeMapper.js +1 -255
- package/lib/module/highlight-updates/utils/copySettingsStorage.js +1 -26
- package/lib/module/highlight-updates/utils/devtoolsComponentNames.js +1 -178
- package/lib/module/highlight-updates/utils/namedComposite.js +1 -36
- package/lib/module/highlight-updates/utils/ownStateChanged.js +1 -98
- package/lib/module/highlight-updates/utils/rawEventEmitter.js +1 -46
- package/lib/module/highlight-updates/utils/rawEventEmitter.web.js +1 -0
- package/lib/module/highlight-updates/utils/renderExportFormatter.js +1 -54
- package/lib/module/highlight-updates/utils/rendersExportFormatter.js +1 -478
- package/lib/module/highlight-updates/utils/screenElements.js +1 -1242
- package/lib/module/highlight-updates/utils/tapMatch.js +1 -76
- package/lib/module/highlight-updates/utils/testIDs.js +1 -60
- package/lib/module/highlight-updates/utils/touchCapture.js +1 -270
- package/lib/module/index.js +1 -130
- package/lib/module/preset.js +1 -272
- package/lib/module/sync/highlightUpdatesSyncAdapter.js +1 -230
- package/lib/typescript/highlight-updates/utils/HighlightUpdatesController.d.ts +0 -26
- package/lib/typescript/highlight-updates/utils/rawEventEmitter.web.d.ts +3 -0
- package/lib/typescript/highlight-updates/utils/screenElements.d.ts +0 -19
- package/lib/web/index.mjs +38 -0
- package/package.json +34 -14
- package/lib/typescript/highlight-updates/HighlightUpdatesOverlay.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/components/HighlightFilterView.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/components/HighlightUpdatesModal.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/components/IdentifierBadge.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/components/IsolatedRenderList.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/components/ModalHeaderContent.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/components/RenderCauseBadge.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/components/RenderDetailView.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/components/RenderHistoryViewer.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/components/RenderListItem.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/components/RendersCopySettingsView.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/components/StatsDisplay.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/types/copySettings.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/CommitProfiler.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/HighlightUpdatesController.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/PerformanceLogger.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/ProfilerInterceptor.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/RenderCauseDetector.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/RenderTracker.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/ViewTypeMapper.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/copySettingsStorage.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/devtoolsComponentNames.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/namedComposite.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/ownStateChanged.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/rawEventEmitter.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/renderExportFormatter.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/rendersExportFormatter.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/screenElements.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/tapMatch.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/testIDs.d.ts.map +0 -1
- package/lib/typescript/highlight-updates/utils/touchCapture.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/sync/highlightUpdatesSyncAdapter.d.ts.map +0 -1
|
@@ -1,274 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* HighlightUpdatesOverlay
|
|
5
|
-
*
|
|
6
|
-
* Renders colored highlight rectangles for components that have updated.
|
|
7
|
-
* Uses View-based rendering (similar to debug-borders) instead of the
|
|
8
|
-
* native DebuggingOverlay component for better compatibility.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import React, { useEffect, useState, useRef, useCallback, useLayoutEffect } from "react";
|
|
12
|
-
import { View, Text, StyleSheet } from "react-native";
|
|
13
|
-
import { night, monoFont } from "@buoy-gg/shared-ui";
|
|
14
|
-
import HighlightUpdatesController from "./utils/HighlightUpdatesController";
|
|
15
|
-
import { PerformanceLogger, markOverlayRendered } from "./utils/PerformanceLogger";
|
|
16
|
-
import { RenderTracker } from "./utils/RenderTracker";
|
|
17
|
-
|
|
18
|
-
// Declare performance API available in React Native's JavaScript environment
|
|
19
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
-
// How long highlights stay visible (ms)
|
|
21
|
-
const HIGHLIGHT_DURATION = 1000;
|
|
22
|
-
export function HighlightUpdatesOverlay({
|
|
23
|
-
onBadgePress
|
|
24
|
-
} = {}) {
|
|
25
|
-
const [highlights, setHighlights] = useState([]);
|
|
26
|
-
const [isFrozen, setIsFrozen] = useState(() => HighlightUpdatesController.getFrozen());
|
|
27
|
-
const [spotlightTag, setSpotlightTag] = useState(null);
|
|
28
|
-
const cleanupTimerRef = useRef(null);
|
|
29
|
-
const renderStartTimeRef = useRef(0);
|
|
30
|
-
const highlightCountRef = useRef(0);
|
|
31
|
-
const frozenRef = useRef(isFrozen);
|
|
32
|
-
|
|
33
|
-
// Keep ref in sync with state for use in interval callback
|
|
34
|
-
frozenRef.current = isFrozen;
|
|
35
|
-
|
|
36
|
-
// Track render start time
|
|
37
|
-
if (PerformanceLogger.isEnabled()) {
|
|
38
|
-
renderStartTimeRef.current = performance.now();
|
|
39
|
-
highlightCountRef.current = highlights.length;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Measure render completion time using useLayoutEffect (runs after DOM mutations)
|
|
43
|
-
useLayoutEffect(() => {
|
|
44
|
-
if (PerformanceLogger.isEnabled() && renderStartTimeRef.current > 0 && highlightCountRef.current > 0) {
|
|
45
|
-
const renderTime = performance.now() - renderStartTimeRef.current;
|
|
46
|
-
// Mark end-to-end timing (for benchmark recording only - no console logs)
|
|
47
|
-
markOverlayRendered(highlightCountRef.current, renderTime);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Subscribe to freeze state changes
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
const unsubscribe = HighlightUpdatesController.subscribeToFreeze(frozen => {
|
|
54
|
-
setIsFrozen(frozen);
|
|
55
|
-
});
|
|
56
|
-
return unsubscribe;
|
|
57
|
-
}, []);
|
|
58
|
-
|
|
59
|
-
// Subscribe to filter changes - refresh frozen highlights when filters change
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
const unsubscribe = RenderTracker.subscribeToFilters(() => {
|
|
62
|
-
// When filters change, filter out highlights that no longer match
|
|
63
|
-
setHighlights(prev => {
|
|
64
|
-
return prev.filter(highlight => {
|
|
65
|
-
// Look up the render by nativeTag
|
|
66
|
-
const render = RenderTracker.getRender(String(highlight.id));
|
|
67
|
-
if (!render) {
|
|
68
|
-
// If render not found, keep the highlight (it might be from a different source)
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
// Check if the render should still be shown based on new filters
|
|
72
|
-
return RenderTracker.shouldShowRender(render);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
return unsubscribe;
|
|
77
|
-
}, []);
|
|
78
|
-
|
|
79
|
-
// Subscribe to spotlight changes - show which component is being viewed in detail
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
HighlightUpdatesController.setSpotlightCallback(tag => {
|
|
82
|
-
setSpotlightTag(tag);
|
|
83
|
-
});
|
|
84
|
-
return () => {
|
|
85
|
-
HighlightUpdatesController.setSpotlightCallback(null);
|
|
86
|
-
};
|
|
87
|
-
}, []);
|
|
88
|
-
|
|
89
|
-
// Callback to add new highlights
|
|
90
|
-
const addHighlights = useCallback(newRects => {
|
|
91
|
-
const now = Date.now();
|
|
92
|
-
const timestampedRects = newRects.map(rect => ({
|
|
93
|
-
...rect,
|
|
94
|
-
timestamp: now
|
|
95
|
-
}));
|
|
96
|
-
setHighlights(prev => {
|
|
97
|
-
// Merge new highlights, replacing any with same id
|
|
98
|
-
const updated = [...prev];
|
|
99
|
-
for (const newRect of timestampedRects) {
|
|
100
|
-
const existingIndex = updated.findIndex(r => r.id === newRect.id);
|
|
101
|
-
if (existingIndex >= 0) {
|
|
102
|
-
updated[existingIndex] = newRect;
|
|
103
|
-
} else {
|
|
104
|
-
updated.push(newRect);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return updated;
|
|
108
|
-
});
|
|
109
|
-
}, []);
|
|
110
|
-
|
|
111
|
-
// Register the callback with the controller
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
HighlightUpdatesController.setHighlightCallback(addHighlights);
|
|
114
|
-
|
|
115
|
-
// Cleanup timer to remove old highlights
|
|
116
|
-
// When frozen, skip cleanup to keep highlights visible indefinitely
|
|
117
|
-
cleanupTimerRef.current = setInterval(() => {
|
|
118
|
-
// Check frozen state via ref (doesn't cause re-subscription)
|
|
119
|
-
if (frozenRef.current) {
|
|
120
|
-
return; // Skip cleanup when frozen
|
|
121
|
-
}
|
|
122
|
-
const now = Date.now();
|
|
123
|
-
setHighlights(prev => prev.filter(rect => now - rect.timestamp < HIGHLIGHT_DURATION));
|
|
124
|
-
}, 50);
|
|
125
|
-
return () => {
|
|
126
|
-
HighlightUpdatesController.setHighlightCallback(null);
|
|
127
|
-
if (cleanupTimerRef.current) {
|
|
128
|
-
clearInterval(cleanupTimerRef.current);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
}, [addHighlights]);
|
|
132
|
-
|
|
133
|
-
// Check if badge press handling is enabled (via props or controller)
|
|
134
|
-
const hasBadgePressHandler = onBadgePress || HighlightUpdatesController.getBadgePressCallback();
|
|
135
|
-
|
|
136
|
-
// Handle badge press - navigate to detail view for this component
|
|
137
|
-
const handleBadgePress = useCallback(nativeTag => {
|
|
138
|
-
// First try the prop callback
|
|
139
|
-
if (onBadgePress) {
|
|
140
|
-
onBadgePress(nativeTag);
|
|
141
|
-
} else {
|
|
142
|
-
// Fall back to controller callback
|
|
143
|
-
HighlightUpdatesController.handleBadgePress(nativeTag);
|
|
144
|
-
}
|
|
145
|
-
}, [onBadgePress]);
|
|
146
|
-
|
|
147
|
-
// Get spotlight render info if we have a spotlight active
|
|
148
|
-
const spotlightRender = spotlightTag ? RenderTracker.getRender(String(spotlightTag)) : null;
|
|
149
|
-
|
|
150
|
-
// Render nothing if no highlights and no spotlight
|
|
151
|
-
if (highlights.length === 0 && !spotlightRender?.measurements) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
155
|
-
style: styles.overlay,
|
|
156
|
-
pointerEvents: "box-none",
|
|
157
|
-
nativeID: "highlight-updates-overlay",
|
|
158
|
-
children: [spotlightRender?.measurements && /*#__PURE__*/_jsxs(_Fragment, {
|
|
159
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
160
|
-
pointerEvents: "none",
|
|
161
|
-
nativeID: "__spotlight_highlight__",
|
|
162
|
-
style: [styles.spotlightHighlight, {
|
|
163
|
-
// Offset by border width so border renders outside the component bounds
|
|
164
|
-
left: spotlightRender.measurements.x - 3,
|
|
165
|
-
top: spotlightRender.measurements.y - 3,
|
|
166
|
-
width: spotlightRender.measurements.width + 6,
|
|
167
|
-
height: spotlightRender.measurements.height + 6
|
|
168
|
-
}]
|
|
169
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
170
|
-
pointerEvents: "none",
|
|
171
|
-
style: [styles.spotlightLabel, {
|
|
172
|
-
left: spotlightRender.measurements.x,
|
|
173
|
-
top: spotlightRender.measurements.y + spotlightRender.measurements.height + 4
|
|
174
|
-
}],
|
|
175
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
176
|
-
style: styles.spotlightLabelText,
|
|
177
|
-
children: spotlightRender.componentName || spotlightRender.displayName || spotlightRender.viewType
|
|
178
|
-
})
|
|
179
|
-
})]
|
|
180
|
-
}), highlights.map(rect => /*#__PURE__*/_jsx(View, {
|
|
181
|
-
pointerEvents: "box-none",
|
|
182
|
-
nativeID: `__highlight_rect_${rect.id}__`,
|
|
183
|
-
style: [styles.highlight, {
|
|
184
|
-
left: rect.x,
|
|
185
|
-
top: rect.y,
|
|
186
|
-
width: rect.width,
|
|
187
|
-
height: rect.height,
|
|
188
|
-
borderColor: rect.color
|
|
189
|
-
}],
|
|
190
|
-
children: rect.count > 0 && /*#__PURE__*/_jsx(View, {
|
|
191
|
-
style: [styles.badge, {
|
|
192
|
-
backgroundColor: rect.color
|
|
193
|
-
}],
|
|
194
|
-
nativeID: `__highlight_badge_${rect.id}__`,
|
|
195
|
-
pointerEvents: hasBadgePressHandler ? "auto" : "none",
|
|
196
|
-
hitSlop: {
|
|
197
|
-
top: 8,
|
|
198
|
-
bottom: 8,
|
|
199
|
-
left: 8,
|
|
200
|
-
right: 8
|
|
201
|
-
},
|
|
202
|
-
onStartShouldSetResponder: () => !!hasBadgePressHandler
|
|
203
|
-
// Fire on touch-DOWN: on churning screens the badge views are
|
|
204
|
-
// torn down and recreated between finger-down and finger-up
|
|
205
|
-
// (every highlight event rebuilds the boxes), which kills the
|
|
206
|
-
// responder before a release can fire. Grant fires immediately.
|
|
207
|
-
,
|
|
208
|
-
onResponderGrant: () => handleBadgePress(rect.id),
|
|
209
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
210
|
-
style: styles.badgeText,
|
|
211
|
-
nativeID: `__highlight_text_${rect.id}__`,
|
|
212
|
-
children: rect.count
|
|
213
|
-
})
|
|
214
|
-
})
|
|
215
|
-
}, `highlight-${rect.id}`))]
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
const styles = StyleSheet.create({
|
|
219
|
-
overlay: {
|
|
220
|
-
position: "absolute",
|
|
221
|
-
top: 0,
|
|
222
|
-
left: 0,
|
|
223
|
-
right: 0,
|
|
224
|
-
bottom: 0,
|
|
225
|
-
zIndex: 999999,
|
|
226
|
-
elevation: 999999,
|
|
227
|
-
borderWidth: 0
|
|
228
|
-
},
|
|
229
|
-
highlight: {
|
|
230
|
-
position: "absolute",
|
|
231
|
-
borderWidth: 2,
|
|
232
|
-
borderStyle: "solid",
|
|
233
|
-
backgroundColor: "transparent"
|
|
234
|
-
},
|
|
235
|
-
badge: {
|
|
236
|
-
position: "absolute",
|
|
237
|
-
top: 0,
|
|
238
|
-
right: 0,
|
|
239
|
-
height: 14,
|
|
240
|
-
borderRadius: 0,
|
|
241
|
-
justifyContent: "center",
|
|
242
|
-
alignItems: "center",
|
|
243
|
-
paddingHorizontal: 2
|
|
244
|
-
},
|
|
245
|
-
badgeText: {
|
|
246
|
-
color: "#000",
|
|
247
|
-
fontSize: 9,
|
|
248
|
-
fontWeight: "bold"
|
|
249
|
-
},
|
|
250
|
-
// Spotlight highlight styles
|
|
251
|
-
spotlightHighlight: {
|
|
252
|
-
position: "absolute",
|
|
253
|
-
borderWidth: 2,
|
|
254
|
-
borderStyle: "dashed",
|
|
255
|
-
borderColor: night.color.accent,
|
|
256
|
-
backgroundColor: "transparent"
|
|
257
|
-
},
|
|
258
|
-
spotlightLabel: {
|
|
259
|
-
position: "absolute",
|
|
260
|
-
backgroundColor: night.color.surface,
|
|
261
|
-
borderWidth: 1,
|
|
262
|
-
borderColor: night.color.accent,
|
|
263
|
-
paddingHorizontal: 8,
|
|
264
|
-
paddingVertical: 3,
|
|
265
|
-
borderRadius: 4
|
|
266
|
-
},
|
|
267
|
-
spotlightLabelText: {
|
|
268
|
-
color: night.color.accent,
|
|
269
|
-
fontSize: 11,
|
|
270
|
-
fontWeight: "600",
|
|
271
|
-
fontFamily: monoFont
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
export default HighlightUpdatesOverlay;
|
|
1
|
+
"use strict";import V,{useEffect as g,useState as R,useRef as c,useCallback as H,useLayoutEffect as j}from"react";import{View as a,Text as k,StyleSheet as $}from"react-native";import{night as u,monoFont as G}from"@buoy-gg/shared-ui";import o from"./utils/HighlightUpdatesController";import{PerformanceLogger as z,markOverlayRendered as N}from"./utils/PerformanceLogger";import{RenderTracker as p}from"./utils/RenderTracker";import{jsx as s,Fragment as O,jsxs as E}from"react/jsx-runtime";const U=1e3;export function HighlightUpdatesOverlay({onBadgePress:h}={}){const[m,b]=R([]);const[v,F]=R(()=>o.getFrozen());const[S,D]=R(null);const f=c(null);const _=c(0);const y=c(0);const C=c(v);C.current=v;if(z.isEnabled()){_.current=performance.now();y.current=m.length}j(()=>{if(z.isEnabled()&&_.current>0&&y.current>0){const e=performance.now()-_.current;N(y.current,e)}});g(()=>{const e=o.subscribeToFreeze(r=>{F(r)});return e},[]);g(()=>{const e=p.subscribeToFilters(()=>{b(r=>{return r.filter(l=>{const i=p.getRender(String(l.id));if(!i){return true}return p.shouldShowRender(i)})})});return e},[]);g(()=>{o.setSpotlightCallback(e=>{D(e)});return()=>{o.setSpotlightCallback(null)}},[]);const I=H(e=>{const r=Date.now();const l=e.map(i=>({...i,timestamp:r}));b(i=>{const d=[...i];for(const x of l){const w=d.findIndex(W=>W.id===x.id);if(w>=0){d[w]=x}else{d.push(x)}}return d})},[]);g(()=>{o.setHighlightCallback(I);f.current=setInterval(()=>{if(C.current){return}const e=Date.now();b(r=>r.filter(l=>e-l.timestamp<U))},50);return()=>{o.setHighlightCallback(null);if(f.current){clearInterval(f.current)}}},[I]);const T=h||o.getBadgePressCallback();const L=H(e=>{if(h){h(e)}else{o.handleBadgePress(e)}},[h]);const t=S?p.getRender(String(S)):null;if(m.length===0&&!t?.measurements){return null}return E(a,{style:n.overlay,pointerEvents:"box-none",nativeID:"highlight-updates-overlay",children:[t?.measurements&&E(O,{children:[s(a,{pointerEvents:"none",nativeID:"__spotlight_highlight__",style:[n.spotlightHighlight,{left:t.measurements.x-3,top:t.measurements.y-3,width:t.measurements.width+6,height:t.measurements.height+6}]}),s(a,{pointerEvents:"none",style:[n.spotlightLabel,{left:t.measurements.x,top:t.measurements.y+t.measurements.height+4}],children:s(k,{style:n.spotlightLabelText,children:t.componentName||t.displayName||t.viewType})})]}),m.map(e=>s(a,{pointerEvents:"box-none",nativeID:`__highlight_rect_${e.id}__`,style:[n.highlight,{left:e.x,top:e.y,width:e.width,height:e.height,borderColor:e.color}],children:e.count>0&&s(a,{style:[n.badge,{backgroundColor:e.color}],nativeID:`__highlight_badge_${e.id}__`,pointerEvents:T?"auto":"none",hitSlop:{top:8,bottom:8,left:8,right:8},onStartShouldSetResponder:()=>!!T,onResponderGrant:()=>L(e.id),children:s(k,{style:n.badgeText,nativeID:`__highlight_text_${e.id}__`,children:e.count})})},`highlight-${e.id}`))]})}const n=$.create({overlay:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:999999,elevation:999999,borderWidth:0},highlight:{position:"absolute",borderWidth:2,borderStyle:"solid",backgroundColor:"transparent"},badge:{position:"absolute",top:0,right:0,height:14,borderRadius:0,justifyContent:"center",alignItems:"center",paddingHorizontal:2},badgeText:{color:"#000",fontSize:9,fontWeight:"bold"},spotlightHighlight:{position:"absolute",borderWidth:2,borderStyle:"dashed",borderColor:u.color.accent,backgroundColor:"transparent"},spotlightLabel:{position:"absolute",backgroundColor:u.color.surface,borderWidth:1,borderColor:u.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},spotlightLabelText:{color:u.color.accent,fontSize:11,fontWeight:"600",fontFamily:G}});export default HighlightUpdatesOverlay;
|