@buoy-gg/debug-borders 7.0.41 → 7.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +9 -67
  2. package/lib/commonjs/debug-borders/components/DebugBordersModal.js +1 -236
  3. package/lib/commonjs/debug-borders/components/DebugBordersStandaloneOverlay.js +1 -442
  4. package/lib/commonjs/debug-borders/index.js +1 -51
  5. package/lib/commonjs/debug-borders/types.js +1 -1
  6. package/lib/commonjs/debug-borders/utils/DebugBordersManager.js +1 -121
  7. package/lib/commonjs/debug-borders/utils/ViewTypeMapper.js +1 -264
  8. package/lib/commonjs/debug-borders/utils/colorGeneration.js +1 -76
  9. package/lib/commonjs/debug-borders/utils/componentInfo.js +1 -183
  10. package/lib/commonjs/debug-borders/utils/componentMeasurement.js +1 -111
  11. package/lib/commonjs/debug-borders/utils/fiberTreeTraversal.js +1 -304
  12. package/lib/commonjs/debug-borders/utils/labelPositioning.js +1 -202
  13. package/lib/commonjs/index.js +1 -42
  14. package/lib/commonjs/preset.js +1 -178
  15. package/lib/commonjs/sync/debugBordersSyncAdapter.js +1 -34
  16. package/lib/module/debug-borders/components/DebugBordersModal.js +1 -231
  17. package/lib/module/debug-borders/components/DebugBordersStandaloneOverlay.js +1 -438
  18. package/lib/module/debug-borders/index.js +1 -15
  19. package/lib/module/debug-borders/types.js +1 -1
  20. package/lib/module/debug-borders/utils/DebugBordersManager.js +1 -121
  21. package/lib/module/debug-borders/utils/ViewTypeMapper.js +1 -255
  22. package/lib/module/debug-borders/utils/colorGeneration.js +1 -76
  23. package/lib/module/debug-borders/utils/componentInfo.js +1 -183
  24. package/lib/module/debug-borders/utils/componentMeasurement.js +1 -111
  25. package/lib/module/debug-borders/utils/fiberTreeTraversal.js +1 -304
  26. package/lib/module/debug-borders/utils/labelPositioning.js +1 -202
  27. package/lib/module/index.js +1 -10
  28. package/lib/module/preset.js +1 -166
  29. package/lib/module/sync/debugBordersSyncAdapter.js +1 -30
  30. package/lib/web/index.mjs +1 -2
  31. package/package.json +5 -5
  32. package/lib/typescript/debug-borders/components/DebugBordersModal.d.ts.map +0 -1
  33. package/lib/typescript/debug-borders/components/DebugBordersStandaloneOverlay.d.ts.map +0 -1
  34. package/lib/typescript/debug-borders/index.d.ts.map +0 -1
  35. package/lib/typescript/debug-borders/types.d.ts.map +0 -1
  36. package/lib/typescript/debug-borders/utils/ViewTypeMapper.d.ts.map +0 -1
  37. package/lib/typescript/index.d.ts.map +0 -1
  38. package/lib/typescript/preset.d.ts.map +0 -1
  39. package/lib/typescript/sync/debugBordersSyncAdapter.d.ts.map +0 -1
@@ -1,442 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DebugBordersStandaloneOverlay = DebugBordersStandaloneOverlay;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
- var _sharedUi = require("@buoy-gg/shared-ui");
10
- var _dataViewer = require("@buoy-gg/shared-ui/dataViewer");
11
- var _utils = require("@buoy-gg/shared-ui/utils");
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
- /**
15
- * Standalone Debug Borders Overlay
16
- *
17
- * This component renders debug borders independently of the Provider.
18
- * It should be rendered at the root level of the app to ensure it appears on top.
19
- *
20
- * Supports two display modes:
21
- * - "borders" - Shows colored borders only
22
- * - "labels" - Shows colored borders with component labels
23
- *
24
- * Automatically hides borders when DevTools modals are open to avoid visual clutter.
25
- */
26
-
27
- const infoModalKey = _sharedUi.devToolsStorageKeys.debugBorders.infoModal();
28
- const DebugBordersManager = require("../utils/DebugBordersManager");
29
- const {
30
- getAllHostComponentInstances
31
- } = require("../utils/fiberTreeTraversal");
32
- const {
33
- measureInstances
34
- } = require("../utils/componentMeasurement");
35
- const {
36
- getColorForDepth
37
- } = require("../utils/colorGeneration");
38
- const {
39
- getShortLabel
40
- } = require("../utils/componentInfo");
41
- const {
42
- resolveOverlappingLabels
43
- } = require("../utils/labelPositioning");
44
-
45
- // Import DevToolsVisibility context to detect when DevTools are open.
46
- //
47
- // Resolved lazily (on first render) instead of at module load to avoid a
48
- // require cycle: @buoy-gg/core -> FloatingDevTools -> autoExternalSync ->
49
- // @buoy-gg/debug-borders -> preset -> this file -> @buoy-gg/core.
50
- // Deferring the require breaks the cycle while keeping the optional dependency.
51
-
52
- let useDevToolsVisibility;
53
- function resolveUseDevToolsVisibility() {
54
- if (useDevToolsVisibility !== undefined) {
55
- return useDevToolsVisibility;
56
- }
57
- try {
58
- // Optional import - will gracefully fail if not available
59
- const coreModule = (0, _utils.loadToolModule)("@buoy-gg/core");
60
- useDevToolsVisibility = coreModule.useDevToolsVisibility ?? null;
61
- } catch (e) {
62
- // DevToolsVisibility not available, that's ok - borders will always work
63
- useDevToolsVisibility = null;
64
- }
65
- return useDevToolsVisibility ?? null;
66
- }
67
- // Row component for displaying info
68
- function InfoRow({
69
- label,
70
- value,
71
- color
72
- }) {
73
- if (value === null || value === undefined) return null;
74
- let displayValue;
75
- if (typeof value === "object") {
76
- try {
77
- displayValue = JSON.stringify(value, null, 2);
78
- } catch {
79
- displayValue = String(value);
80
- }
81
- } else {
82
- displayValue = String(value);
83
- }
84
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
85
- style: modalStyles.row,
86
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
87
- style: modalStyles.label,
88
- children: label
89
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
90
- style: [modalStyles.value, color ? {
91
- color
92
- } : null],
93
- children: displayValue
94
- })]
95
- });
96
- }
97
-
98
- // Simple header with just title (no hints)
99
- function SimpleHeader({
100
- title
101
- }) {
102
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
103
- style: headerStyles.container,
104
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
105
- style: headerStyles.title,
106
- numberOfLines: 1,
107
- children: title
108
- })
109
- });
110
- }
111
-
112
- // Component Info Modal Content
113
- function ComponentInfoContent({
114
- info,
115
- rect
116
- }) {
117
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
118
- style: modalStyles.content,
119
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
120
- style: modalStyles.sectionTitle,
121
- children: "Identifiers"
122
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
123
- label: "testID",
124
- value: info.testID,
125
- color: "#10b981"
126
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
127
- label: "accessibilityLabel",
128
- value: info.accessibilityLabel,
129
- color: "#ec4899"
130
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
131
- label: "nativeID",
132
- value: info.nativeID,
133
- color: "#f59e0b"
134
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
135
- label: "key",
136
- value: info.fiberKey
137
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
138
- style: modalStyles.sectionTitle,
139
- children: "Component"
140
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
141
- label: "Component Name",
142
- value: info.componentName,
143
- color: "#a855f7"
144
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
145
- label: "Parent Component",
146
- value: info.parentComponentName
147
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
148
- label: "Display Name",
149
- value: info.displayName
150
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
151
- label: "Native View Type",
152
- value: info.viewType
153
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
154
- label: "Fiber Tag",
155
- value: info.fiberTag
156
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
157
- style: modalStyles.sectionTitle,
158
- children: "Position & Size"
159
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
160
- label: "X",
161
- value: Math.round(rect.x)
162
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
163
- label: "Y",
164
- value: Math.round(rect.y)
165
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
166
- label: "Width",
167
- value: Math.round(rect.width)
168
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
169
- label: "Height",
170
- value: Math.round(rect.height)
171
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
172
- label: "Depth",
173
- value: rect.depth
174
- }), (info.accessibilityRole || info.accessibilityHint || info.accessibilityState) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
175
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
176
- style: modalStyles.sectionTitle,
177
- children: "Accessibility"
178
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
179
- label: "Role",
180
- value: info.accessibilityRole
181
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
182
- label: "Hint",
183
- value: info.accessibilityHint
184
- }), info.accessibilityState && _dataViewer.DataViewer ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataViewer.DataViewer, {
185
- title: "",
186
- data: info.accessibilityState,
187
- showTypeFilter: true,
188
- rawMode: true,
189
- initialExpanded: true
190
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
191
- label: "State",
192
- value: info.accessibilityState
193
- })]
194
- }), info.styleInfo && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
195
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
196
- style: modalStyles.sectionTitle,
197
- children: "Styles"
198
- }), _dataViewer.DataViewer ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataViewer.DataViewer, {
199
- title: "",
200
- data: info.styleInfo,
201
- showTypeFilter: true,
202
- rawMode: true,
203
- initialExpanded: true
204
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
205
- style: modalStyles.codeBlock,
206
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
207
- style: modalStyles.codeText,
208
- children: JSON.stringify(info.styleInfo, null, 2)
209
- })
210
- })]
211
- })]
212
- });
213
- }
214
- function DebugBordersStandaloneOverlay() {
215
- const [mode, setMode] = (0, _react.useState)("off");
216
- const [rectangles, setRectangles] = (0, _react.useState)([]);
217
- const [selectedRect, setSelectedRect] = (0, _react.useState)(null);
218
- const [modalVisible, setModalVisible] = (0, _react.useState)(false);
219
- const measuringRef = _react.default.useRef(false); // Prevent overlapping measurements
220
-
221
- // Check if any DevTools are open (if context is available).
222
- // The hook reference is resolved lazily but is stable for the app's lifetime,
223
- // so calling it conditionally here is safe across renders.
224
- const isDevToolsActive = resolveUseDevToolsVisibility()?.()?.isDevToolsActive ?? false;
225
- const handleLabelPress = (0, _react.useCallback)(rect => {
226
- setSelectedRect(rect);
227
- setModalVisible(true);
228
- }, []);
229
- const handleCloseModal = (0, _react.useCallback)(() => {
230
- setModalVisible(false);
231
- setSelectedRect(null);
232
- }, []);
233
-
234
- // Effective enabled state: user enabled AND no DevTools active
235
- const isEnabled = mode !== "off" && !isDevToolsActive;
236
- const showLabels = mode === "labels" && !isDevToolsActive;
237
-
238
- // Subscribe to manager
239
- (0, _react.useEffect)(() => {
240
- const unsubscribe = DebugBordersManager.subscribe(newMode => {
241
- setMode(newMode);
242
- });
243
- return unsubscribe;
244
- }, []);
245
-
246
- // Update measurements when enabled
247
- (0, _react.useEffect)(() => {
248
- if (!isEnabled) {
249
- setRectangles([]);
250
- return;
251
- }
252
- let mounted = true;
253
- let timer;
254
- const updateMeasurements = async () => {
255
- if (!mounted || measuringRef.current) {
256
- return;
257
- }
258
- measuringRef.current = true;
259
- try {
260
- const instances = getAllHostComponentInstances();
261
- if (instances.length === 0) {
262
- measuringRef.current = false;
263
- return;
264
- }
265
- const measurements = await measureInstances(instances);
266
- if (mounted) {
267
- // Resolve overlapping labels when in labels mode
268
- const processedMeasurements = showLabels ? resolveOverlappingLabels(measurements) : measurements;
269
- setRectangles(processedMeasurements);
270
- }
271
- } catch (error) {
272
- console.error("[DebugBorders] Error updating measurements:", error);
273
- } finally {
274
- measuringRef.current = false;
275
- }
276
- };
277
-
278
- // Initial measurement with delay to let UI settle
279
- const initialTimer = setTimeout(() => {
280
- updateMeasurements();
281
- }, 500);
282
-
283
- // Periodic updates (less frequent to avoid performance issues)
284
- timer = setInterval(updateMeasurements, 2000);
285
- return () => {
286
- mounted = false;
287
- clearTimeout(initialTimer);
288
- clearInterval(timer);
289
- measuringRef.current = false;
290
- };
291
- }, [isEnabled, showLabels, rectangles.length]);
292
- if (!isEnabled) {
293
- return null;
294
- }
295
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
296
- style: styles.overlay,
297
- pointerEvents: "box-none"
298
- // @ts-ignore - custom prop to identify this as debug overlay
299
- ,
300
- dataSet: {
301
- debugOverlay: "true"
302
- },
303
- nativeID: "debug-borders-overlay",
304
- children: [rectangles.map((rect, index) => {
305
- const info = rect.componentInfo;
306
- const hasValidLabel = info && (info.testID || info.accessibilityLabel);
307
-
308
- // In labels mode, only show components with testID or accessibilityLabel
309
- if (showLabels && !hasValidLabel) {
310
- return null;
311
- }
312
-
313
- // Use label color for border when in labels mode, otherwise use depth-based color
314
- const borderColor = showLabels && info ? info.primaryColor : getColorForDepth(rect.depth);
315
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
316
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
317
- pointerEvents: "none",
318
- style: [styles.border, {
319
- left: rect.x,
320
- top: rect.y,
321
- width: rect.width,
322
- height: rect.height,
323
- borderColor: borderColor
324
- }]
325
- }), showLabels && hasValidLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
326
- activeOpacity: 0.7,
327
- onPress: () => handleLabelPress(rect),
328
- style: [styles.labelContainer, {
329
- left: rect.x,
330
- top: rect.y - 10 - (rect.labelOffsetY || 0),
331
- backgroundColor: info.primaryColor
332
- }],
333
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
334
- style: styles.labelText,
335
- numberOfLines: 1,
336
- children: info.primaryLabel
337
- })
338
- })]
339
- }, `border-${index}`);
340
- }), _sharedUi.JsModal && selectedRect?.componentInfo && /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.JsModal, {
341
- visible: modalVisible,
342
- onClose: handleCloseModal,
343
- initialMode: "bottomSheet",
344
- header: {
345
- customContent: /*#__PURE__*/(0, _jsxRuntime.jsx)(SimpleHeader, {
346
- title: selectedRect.componentInfo.primaryLabel
347
- })
348
- },
349
- persistenceKey: infoModalKey,
350
- enablePersistence: false,
351
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ComponentInfoContent, {
352
- info: selectedRect.componentInfo,
353
- rect: selectedRect
354
- })
355
- })]
356
- });
357
- }
358
- const styles = _reactNative.StyleSheet.create({
359
- overlay: {
360
- position: "absolute",
361
- top: 0,
362
- left: 0,
363
- right: 0,
364
- bottom: 0,
365
- // Use z-index below floating dev tools (9999-10001) but above normal app content
366
- zIndex: 9000,
367
- elevation: 9000
368
- },
369
- border: {
370
- position: "absolute",
371
- borderWidth: 1,
372
- borderStyle: "solid"
373
- },
374
- labelContainer: {
375
- position: "absolute",
376
- paddingHorizontal: 4,
377
- paddingVertical: 1,
378
- borderRadius: 2
379
- },
380
- labelText: {
381
- fontSize: 8,
382
- fontWeight: "700",
383
- fontFamily: _sharedUi.monoFont,
384
- color: "#ffffff"
385
- }
386
- });
387
- const headerStyles = _reactNative.StyleSheet.create({
388
- container: {
389
- paddingHorizontal: 16,
390
- paddingVertical: 8,
391
- alignItems: "center"
392
- },
393
- title: {
394
- fontSize: 16,
395
- fontWeight: "600",
396
- color: "#ffffff",
397
- fontFamily: _sharedUi.monoFont
398
- }
399
- });
400
- const modalStyles = _reactNative.StyleSheet.create({
401
- content: {
402
- padding: 16
403
- },
404
- sectionTitle: {
405
- fontSize: 12,
406
- fontWeight: "700",
407
- color: "#6b7280",
408
- marginTop: 16,
409
- marginBottom: 8,
410
- textTransform: "uppercase",
411
- letterSpacing: 1
412
- },
413
- row: {
414
- flexDirection: "row",
415
- paddingVertical: 8,
416
- borderBottomWidth: 1,
417
- borderBottomColor: "rgba(255, 255, 255, 0.1)"
418
- },
419
- label: {
420
- fontSize: 13,
421
- color: "#9ca3af",
422
- width: 140,
423
- fontFamily: _sharedUi.monoFont
424
- },
425
- value: {
426
- fontSize: 13,
427
- color: "#ffffff",
428
- flex: 1,
429
- fontFamily: _sharedUi.monoFont
430
- },
431
- codeBlock: {
432
- backgroundColor: "rgba(0, 0, 0, 0.3)",
433
- padding: 12,
434
- borderRadius: 8,
435
- marginTop: 4
436
- },
437
- codeText: {
438
- fontSize: 11,
439
- color: "#e5e7eb",
440
- fontFamily: _sharedUi.monoFont
441
- }
442
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DebugBordersStandaloneOverlay=DebugBordersStandaloneOverlay;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _utils=require("@buoy-gg/shared-ui/utils");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,r){if("function"==typeof WeakMap)var c=new WeakMap,s=new WeakMap;return(_interopRequireWildcard=function(t,f){if(!f&&t&&t.__esModule)return t;var a,u,o={__proto__:null,default:t};if(null===t||"object"!=typeof t&&"function"!=typeof t)return o;if(a=f?s:c){if(a.has(t))return a.get(t);a.set(t,o)}for(const i in t)"default"!==i&&{}.hasOwnProperty.call(t,i)&&((u=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(t,i))&&(u.get||u.set)?a(o,i,u):o[i]=t[i]);return o})(e,r)}const infoModalKey=_sharedUi.devToolsStorageKeys.debugBorders.infoModal();const DebugBordersManager=require("../utils/DebugBordersManager");const{getAllHostComponentInstances}=require("../utils/fiberTreeTraversal");const{measureInstances}=require("../utils/componentMeasurement");const{getColorForDepth}=require("../utils/colorGeneration");const{getShortLabel}=require("../utils/componentInfo");const{resolveOverlappingLabels}=require("../utils/labelPositioning");let useDevToolsVisibility;function resolveUseDevToolsVisibility(){if(useDevToolsVisibility!==void 0){return useDevToolsVisibility}try{const e=(0,_utils.loadToolModule)("@buoy-gg/core");useDevToolsVisibility=e.useDevToolsVisibility??null}catch(e){useDevToolsVisibility=null}return useDevToolsVisibility??null}function InfoRow({label:e,value:r,color:c}){if(r===null||r===void 0)return null;let s;if(typeof r==="object"){try{s=JSON.stringify(r,null,2)}catch{s=String(r)}}else{s=String(r)}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:modalStyles.row,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:modalStyles.label,children:e}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[modalStyles.value,c?{color:c}:null],children:s})]})}function SimpleHeader({title:e}){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:headerStyles.container,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:headerStyles.title,numberOfLines:1,children:e})})}function ComponentInfoContent({info:e,rect:r}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:modalStyles.content,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:modalStyles.sectionTitle,children:"Identifiers"}),(0,_jsxRuntime.jsx)(InfoRow,{label:"testID",value:e.testID,color:"#10b981"}),(0,_jsxRuntime.jsx)(InfoRow,{label:"accessibilityLabel",value:e.accessibilityLabel,color:"#ec4899"}),(0,_jsxRuntime.jsx)(InfoRow,{label:"nativeID",value:e.nativeID,color:"#f59e0b"}),(0,_jsxRuntime.jsx)(InfoRow,{label:"key",value:e.fiberKey}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:modalStyles.sectionTitle,children:"Component"}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Component Name",value:e.componentName,color:"#a855f7"}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Parent Component",value:e.parentComponentName}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Display Name",value:e.displayName}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Native View Type",value:e.viewType}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Fiber Tag",value:e.fiberTag}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:modalStyles.sectionTitle,children:"Position & Size"}),(0,_jsxRuntime.jsx)(InfoRow,{label:"X",value:Math.round(r.x)}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Y",value:Math.round(r.y)}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Width",value:Math.round(r.width)}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Height",value:Math.round(r.height)}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Depth",value:r.depth}),(e.accessibilityRole||e.accessibilityHint||e.accessibilityState)&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:modalStyles.sectionTitle,children:"Accessibility"}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Role",value:e.accessibilityRole}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Hint",value:e.accessibilityHint}),e.accessibilityState&&_dataViewer.DataViewer?(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:e.accessibilityState,showTypeFilter:true,rawMode:true,initialExpanded:true}):(0,_jsxRuntime.jsx)(InfoRow,{label:"State",value:e.accessibilityState})]}),e.styleInfo&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:modalStyles.sectionTitle,children:"Styles"}),_dataViewer.DataViewer?(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:e.styleInfo,showTypeFilter:true,rawMode:true,initialExpanded:true}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:modalStyles.codeBlock,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:modalStyles.codeText,children:JSON.stringify(e.styleInfo,null,2)})})]})]})}function DebugBordersStandaloneOverlay(){const[e,r]=(0,_react.useState)("off");const[c,s]=(0,_react.useState)([]);const[t,f]=(0,_react.useState)(null);const[a,u]=(0,_react.useState)(false);const o=_react.default.useRef(false);const i=resolveUseDevToolsVisibility()?.()?.isDevToolsActive??false;const m=(0,_react.useCallback)(l=>{f(l);u(true)},[]);const g=(0,_react.useCallback)(()=>{u(false);f(null)},[]);const h=e!=="off"&&!i;const y=e==="labels"&&!i;(0,_react.useEffect)(()=>{const l=DebugBordersManager.subscribe(d=>{r(d)});return l},[]);(0,_react.useEffect)(()=>{if(!h){s([]);return}let l=true;let d;const n=async()=>{if(!l||o.current){return}o.current=true;try{const b=getAllHostComponentInstances();if(b.length===0){o.current=false;return}const x=await measureInstances(b);if(l){const v=y?resolveOverlappingLabels(x):x;s(v)}}catch(b){console.error("[DebugBorders] Error updating measurements:",b)}finally{o.current=false}};const p=setTimeout(()=>{n()},500);d=setInterval(n,2e3);return()=>{l=false;clearTimeout(p);clearInterval(d);o.current=false}},[h,y,c.length]);if(!h){return null}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.overlay,pointerEvents:"box-none",dataSet:{debugOverlay:"true"},nativeID:"debug-borders-overlay",children:[c.map((l,d)=>{const n=l.componentInfo;const p=n&&(n.testID||n.accessibilityLabel);if(y&&!p){return null}const b=y&&n?n.primaryColor:getColorForDepth(l.depth);return(0,_jsxRuntime.jsxs)(_react.default.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[styles.border,{left:l.x,top:l.y,width:l.width,height:l.height,borderColor:b}]}),y&&p&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>m(l),style:[styles.labelContainer,{left:l.x,top:l.y-10-(l.labelOffsetY||0),backgroundColor:n.primaryColor}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.labelText,numberOfLines:1,children:n.primaryLabel})})]},`border-${d}`)}),_sharedUi.JsModal&&t?.componentInfo&&(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:a,onClose:g,initialMode:"bottomSheet",header:{customContent:(0,_jsxRuntime.jsx)(SimpleHeader,{title:t.componentInfo.primaryLabel})},persistenceKey:infoModalKey,enablePersistence:false,children:(0,_jsxRuntime.jsx)(ComponentInfoContent,{info:t.componentInfo,rect:t})})]})}const styles=_reactNative.StyleSheet.create({overlay:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:9e3,elevation:9e3},border:{position:"absolute",borderWidth:1,borderStyle:"solid"},labelContainer:{position:"absolute",paddingHorizontal:4,paddingVertical:1,borderRadius:2},labelText:{fontSize:8,fontWeight:"700",fontFamily:_sharedUi.monoFont,color:"#ffffff"}});const headerStyles=_reactNative.StyleSheet.create({container:{paddingHorizontal:16,paddingVertical:8,alignItems:"center"},title:{fontSize:16,fontWeight:"600",color:"#ffffff",fontFamily:_sharedUi.monoFont}});const modalStyles=_reactNative.StyleSheet.create({content:{padding:16},sectionTitle:{fontSize:12,fontWeight:"700",color:"#6b7280",marginTop:16,marginBottom:8,textTransform:"uppercase",letterSpacing:1},row:{flexDirection:"row",paddingVertical:8,borderBottomWidth:1,borderBottomColor:"rgba(255, 255, 255, 0.1)"},label:{fontSize:13,color:"#9ca3af",width:140,fontFamily:_sharedUi.monoFont},value:{fontSize:13,color:"#ffffff",flex:1,fontFamily:_sharedUi.monoFont},codeBlock:{backgroundColor:"rgba(0, 0, 0, 0.3)",padding:12,borderRadius:8,marginTop:4},codeText:{fontSize:11,color:"#e5e7eb",fontFamily:_sharedUi.monoFont}});
@@ -1,51 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- DebugBordersManager: true,
8
- fiberTreeTraversal: true,
9
- componentMeasurement: true,
10
- colorGeneration: true,
11
- DebugBordersModal: true,
12
- DebugBordersStandaloneOverlay: true
13
- };
14
- exports.DebugBordersManager = void 0;
15
- Object.defineProperty(exports, "DebugBordersModal", {
16
- enumerable: true,
17
- get: function () {
18
- return _DebugBordersModal.DebugBordersModal;
19
- }
20
- });
21
- Object.defineProperty(exports, "DebugBordersStandaloneOverlay", {
22
- enumerable: true,
23
- get: function () {
24
- return _DebugBordersStandaloneOverlay.DebugBordersStandaloneOverlay;
25
- }
26
- });
27
- exports.fiberTreeTraversal = exports.componentMeasurement = exports.colorGeneration = void 0;
28
- var _types = require("./types");
29
- Object.keys(_types).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
32
- if (key in exports && exports[key] === _types[key]) return;
33
- Object.defineProperty(exports, key, {
34
- enumerable: true,
35
- get: function () {
36
- return _types[key];
37
- }
38
- });
39
- });
40
- var _DebugBordersModal = require("./components/DebugBordersModal");
41
- var _DebugBordersStandaloneOverlay = require("./components/DebugBordersStandaloneOverlay");
42
- // Export types
43
-
44
- // Export components
45
-
46
- // Export utilities (JS modules - will be typed when converted to TS)
47
- // Note: These are CommonJS modules, so we use require for now
48
- const DebugBordersManager = exports.DebugBordersManager = require("./utils/DebugBordersManager");
49
- const fiberTreeTraversal = exports.fiberTreeTraversal = require("./utils/fiberTreeTraversal");
50
- const componentMeasurement = exports.componentMeasurement = require("./utils/componentMeasurement");
51
- const colorGeneration = exports.colorGeneration = require("./utils/colorGeneration");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});var _exportNames={DebugBordersManager:true,fiberTreeTraversal:true,componentMeasurement:true,colorGeneration:true,DebugBordersModal:true,DebugBordersStandaloneOverlay:true};exports.DebugBordersManager=void 0;Object.defineProperty(exports,"DebugBordersModal",{enumerable:true,get:function(){return _DebugBordersModal.DebugBordersModal}});Object.defineProperty(exports,"DebugBordersStandaloneOverlay",{enumerable:true,get:function(){return _DebugBordersStandaloneOverlay.DebugBordersStandaloneOverlay}});exports.fiberTreeTraversal=exports.componentMeasurement=exports.colorGeneration=void 0;var _types=require("./types");Object.keys(_types).forEach(function(e){if(e==="default"||e==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,e))return;if(e in exports&&exports[e]===_types[e])return;Object.defineProperty(exports,e,{enumerable:true,get:function(){return _types[e]}})});var _DebugBordersModal=require("./components/DebugBordersModal");var _DebugBordersStandaloneOverlay=require("./components/DebugBordersStandaloneOverlay");const DebugBordersManager=exports.DebugBordersManager=require("./utils/DebugBordersManager");const fiberTreeTraversal=exports.fiberTreeTraversal=require("./utils/fiberTreeTraversal");const componentMeasurement=exports.componentMeasurement=require("./utils/componentMeasurement");const colorGeneration=exports.colorGeneration=require("./utils/colorGeneration");
@@ -1 +1 @@
1
- "use strict";
1
+ "use strict";
@@ -1,121 +1 @@
1
- "use strict";
2
-
3
- var _utils = require("@buoy-gg/shared-ui/utils");
4
- "use strict";
5
- let globalMode = "off";
6
- const listeners = new Set();
7
- const MODE_CYCLE_FULL = ["off", "borders", "labels"];
8
- const MODE_CYCLE_FREE = ["off", "borders"];
9
- let _isPro = null;
10
- let _licenseLoadAttempted = false;
11
- function loadLicenseModule() {
12
- if (_licenseLoadAttempted) return;
13
- _licenseLoadAttempted = true;
14
- try {
15
- const mod = (0, _utils.loadToolModule)("@buoy-gg/license");
16
- if (mod && typeof mod.isPro === "function") {
17
- _isPro = mod.isPro;
18
- }
19
- } catch {
20
- _isPro = null;
21
- }
22
- }
23
- function checkIsPro() {
24
- loadLicenseModule();
25
- if (_isPro) {
26
- try {
27
- return _isPro();
28
- } catch {
29
- return false;
30
- }
31
- }
32
- return false;
33
- }
34
- function getModeCycle() {
35
- return checkIsPro() ? MODE_CYCLE_FULL : MODE_CYCLE_FREE;
36
- }
37
- const MODE_CYCLE = MODE_CYCLE_FULL;
38
- function subscribe(listener) {
39
- listeners.add(listener);
40
- listener(globalMode);
41
- return () => {
42
- listeners.delete(listener);
43
- };
44
- }
45
- function notifyListeners() {
46
- listeners.forEach(listener => {
47
- try {
48
- listener(globalMode);
49
- } catch (error) {
50
- console.error("[DebugBorders] Error in listener:", error);
51
- }
52
- });
53
- }
54
- function setMode(mode) {
55
- if (globalMode === mode) {
56
- return true;
57
- }
58
- if (mode === "labels" && !checkIsPro()) {
59
- console.warn("[DebugBorders] Labels mode requires React Buoy Pro. Upgrade at https://buoy.gg/pro");
60
- return false;
61
- }
62
- globalMode = mode;
63
- notifyListeners();
64
- return true;
65
- }
66
- function getMode() {
67
- return globalMode;
68
- }
69
- function cycle() {
70
- const availableModes = getModeCycle();
71
- const currentIndex = availableModes.indexOf(globalMode);
72
- if (currentIndex === -1) {
73
- setMode("off");
74
- return;
75
- }
76
- const nextIndex = (currentIndex + 1) % availableModes.length;
77
- setMode(availableModes[nextIndex]);
78
- }
79
- function enable() {
80
- setMode("borders");
81
- }
82
- function disable() {
83
- setMode("off");
84
- }
85
- function toggle() {
86
- cycle();
87
- }
88
- function isEnabled() {
89
- return globalMode !== "off";
90
- }
91
- function showLabels() {
92
- return globalMode === "labels" && checkIsPro();
93
- }
94
- function isProEnabled() {
95
- return checkIsPro();
96
- }
97
- function getAvailableModes() {
98
- return getModeCycle();
99
- }
100
- function setEnabled(enabled) {
101
- if (enabled) {
102
- enable();
103
- } else {
104
- disable();
105
- }
106
- }
107
- module.exports = {
108
- subscribe,
109
- enable,
110
- disable,
111
- toggle,
112
- cycle,
113
- isEnabled,
114
- showLabels,
115
- setEnabled,
116
- getMode,
117
- setMode,
118
- isProEnabled,
119
- getAvailableModes,
120
- MODE_CYCLE
121
- };
1
+ "use strict";var _utils=require("@buoy-gg/shared-ui/utils");"use strict";let globalMode="off";const listeners=new Set;const MODE_CYCLE_FULL=["off","borders","labels"];const MODE_CYCLE_FREE=["off","borders"];let _isPro=null;let _licenseLoadAttempted=false;function loadLicenseModule(){if(_licenseLoadAttempted)return;_licenseLoadAttempted=true;try{const e=(0,_utils.loadToolModule)("@buoy-gg/license");if(e&&typeof e.isPro==="function"){_isPro=e.isPro}}catch{_isPro=null}}function checkIsPro(){loadLicenseModule();if(_isPro){try{return _isPro()}catch{return false}}return false}function getModeCycle(){return checkIsPro()?MODE_CYCLE_FULL:MODE_CYCLE_FREE}const MODE_CYCLE=MODE_CYCLE_FULL;function subscribe(e){listeners.add(e);e(globalMode);return()=>{listeners.delete(e)}}function notifyListeners(){listeners.forEach(e=>{try{e(globalMode)}catch(t){console.error("[DebugBorders] Error in listener:",t)}})}function setMode(e){if(globalMode===e){return true}if(e==="labels"&&!checkIsPro()){console.warn("[DebugBorders] Labels mode requires React Buoy Pro. Upgrade at https://buoy.gg/pro");return false}globalMode=e;notifyListeners();return true}function getMode(){return globalMode}function cycle(){const e=getModeCycle();const t=e.indexOf(globalMode);if(t===-1){setMode("off");return}const n=(t+1)%e.length;setMode(e[n])}function enable(){setMode("borders")}function disable(){setMode("off")}function toggle(){cycle()}function isEnabled(){return globalMode!=="off"}function showLabels(){return globalMode==="labels"&&checkIsPro()}function isProEnabled(){return checkIsPro()}function getAvailableModes(){return getModeCycle()}function setEnabled(e){if(e){enable()}else{disable()}}module.exports={subscribe,enable,disable,toggle,cycle,isEnabled,showLabels,setEnabled,getMode,setMode,isProEnabled,getAvailableModes,MODE_CYCLE};