@buoy-gg/debug-borders 2.0.2

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 (43) hide show
  1. package/README.md +334 -0
  2. package/lib/commonjs/debug-borders/components/DebugBordersModal.js +234 -0
  3. package/lib/commonjs/debug-borders/components/DebugBordersStandaloneOverlay.js +436 -0
  4. package/lib/commonjs/debug-borders/index.js +51 -0
  5. package/lib/commonjs/debug-borders/types.js +1 -0
  6. package/lib/commonjs/debug-borders/utils/DebugBordersManager.js +119 -0
  7. package/lib/commonjs/debug-borders/utils/ViewTypeMapper.js +264 -0
  8. package/lib/commonjs/debug-borders/utils/colorGeneration.js +76 -0
  9. package/lib/commonjs/debug-borders/utils/componentInfo.js +183 -0
  10. package/lib/commonjs/debug-borders/utils/componentMeasurement.js +111 -0
  11. package/lib/commonjs/debug-borders/utils/fiberTreeTraversal.js +309 -0
  12. package/lib/commonjs/debug-borders/utils/labelPositioning.js +202 -0
  13. package/lib/commonjs/index.js +34 -0
  14. package/lib/commonjs/package.json +1 -0
  15. package/lib/commonjs/preset.js +178 -0
  16. package/lib/module/debug-borders/components/DebugBordersModal.js +229 -0
  17. package/lib/module/debug-borders/components/DebugBordersStandaloneOverlay.js +432 -0
  18. package/lib/module/debug-borders/index.js +15 -0
  19. package/lib/module/debug-borders/types.js +1 -0
  20. package/lib/module/debug-borders/utils/DebugBordersManager.js +119 -0
  21. package/lib/module/debug-borders/utils/ViewTypeMapper.js +255 -0
  22. package/lib/module/debug-borders/utils/colorGeneration.js +76 -0
  23. package/lib/module/debug-borders/utils/componentInfo.js +183 -0
  24. package/lib/module/debug-borders/utils/componentMeasurement.js +111 -0
  25. package/lib/module/debug-borders/utils/fiberTreeTraversal.js +309 -0
  26. package/lib/module/debug-borders/utils/labelPositioning.js +202 -0
  27. package/lib/module/index.js +7 -0
  28. package/lib/module/preset.js +166 -0
  29. package/lib/typescript/debug-borders/components/DebugBordersModal.d.ts +11 -0
  30. package/lib/typescript/debug-borders/components/DebugBordersModal.d.ts.map +1 -0
  31. package/lib/typescript/debug-borders/components/DebugBordersStandaloneOverlay.d.ts +15 -0
  32. package/lib/typescript/debug-borders/components/DebugBordersStandaloneOverlay.d.ts.map +1 -0
  33. package/lib/typescript/debug-borders/index.d.ts +8 -0
  34. package/lib/typescript/debug-borders/index.d.ts.map +1 -0
  35. package/lib/typescript/debug-borders/types.d.ts +45 -0
  36. package/lib/typescript/debug-borders/types.d.ts.map +1 -0
  37. package/lib/typescript/debug-borders/utils/ViewTypeMapper.d.ts +66 -0
  38. package/lib/typescript/debug-borders/utils/ViewTypeMapper.d.ts.map +1 -0
  39. package/lib/typescript/index.d.ts +3 -0
  40. package/lib/typescript/index.d.ts.map +1 -0
  41. package/lib/typescript/preset.d.ts +108 -0
  42. package/lib/typescript/preset.d.ts.map +1 -0
  43. package/package.json +72 -0
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Standalone Debug Borders Overlay
3
+ *
4
+ * This component renders debug borders independently of the Provider.
5
+ * It should be rendered at the root level of the app to ensure it appears on top.
6
+ *
7
+ * Supports two display modes:
8
+ * - "borders" - Shows colored borders only
9
+ * - "labels" - Shows colored borders with component labels
10
+ *
11
+ * Automatically hides borders when DevTools modals are open to avoid visual clutter.
12
+ */
13
+ import React from "react";
14
+ export declare function DebugBordersStandaloneOverlay(): React.JSX.Element | null;
15
+ //# sourceMappingURL=DebugBordersStandaloneOverlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DebugBordersStandaloneOverlay.d.ts","sourceRoot":"","sources":["../../../../src/debug-borders/components/DebugBordersStandaloneOverlay.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAA2C,MAAM,OAAO,CAAC;AAiMhE,wBAAgB,6BAA6B,6BAmL5C"}
@@ -0,0 +1,8 @@
1
+ export * from "./types";
2
+ export { DebugBordersModal } from "./components/DebugBordersModal";
3
+ export { DebugBordersStandaloneOverlay } from "./components/DebugBordersStandaloneOverlay";
4
+ export declare const DebugBordersManager: any;
5
+ export declare const fiberTreeTraversal: any;
6
+ export declare const componentMeasurement: any;
7
+ export declare const colorGeneration: any;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/debug-borders/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAI3F,eAAO,MAAM,mBAAmB,KAAyC,CAAC;AAC1E,eAAO,MAAM,kBAAkB,KAAwC,CAAC;AACxE,eAAO,MAAM,oBAAoB,KAA0C,CAAC;AAC5E,eAAO,MAAM,eAAe,KAAqC,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Type definitions for debug-borders package
3
+ */
4
+ /**
5
+ * Props for the DebugBordersModal component
6
+ */
7
+ export interface DebugBordersModalProps {
8
+ /** Enable shared modal dimensions */
9
+ enableSharedModalDimensions?: boolean;
10
+ }
11
+ /**
12
+ * Debug Borders Manager API
13
+ */
14
+ export interface DebugBordersManagerAPI {
15
+ /** Enable debug borders */
16
+ enable: () => void;
17
+ /** Disable debug borders */
18
+ disable: () => void;
19
+ /** Toggle debug borders on/off */
20
+ toggle: () => void;
21
+ /** Check if debug borders are enabled */
22
+ isEnabled: () => boolean;
23
+ /** Set enabled state */
24
+ setEnabled: (enabled: boolean) => void;
25
+ /** Subscribe to state changes */
26
+ subscribe: (callback: (enabled: boolean) => void) => () => void;
27
+ }
28
+ /**
29
+ * Rectangle measurement data
30
+ */
31
+ export interface RectangleMeasurement {
32
+ x: number;
33
+ y: number;
34
+ width: number;
35
+ height: number;
36
+ depth: number;
37
+ }
38
+ /**
39
+ * Component instance with fiber node reference
40
+ */
41
+ export interface ComponentInstance {
42
+ node: any;
43
+ depth: number;
44
+ }
45
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/debug-borders/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,qCAAqC;IACrC,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,2BAA2B;IAC3B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,kCAAkC;IAClC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,yCAAyC;IACzC,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,wBAAwB;IACxB,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,iCAAiC;IACjC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CACjE;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * ViewTypeMapper
3
+ *
4
+ * Maps native view class names (e.g., "RCTView", "RCTText") to their
5
+ * developer-friendly React Native component names (e.g., "View", "Text").
6
+ *
7
+ * This makes the render tracking UI more understandable since developers
8
+ * work with component names, not native class names.
9
+ *
10
+ * Sources:
11
+ * - React Native core: packages/react-native/Libraries/Components/*
12
+ * - React Native Android: ReactAndroid/src/main/java/com/facebook/react/views/*
13
+ * - FabricNameComponentMapping.kt
14
+ * - Common third-party libraries (react-native-svg, gesture-handler, etc.)
15
+ */
16
+ /**
17
+ * Mapping from native view class names to React component names.
18
+ *
19
+ * Format: { "NativeClassName": "ComponentName" }
20
+ */
21
+ export declare const VIEW_TYPE_MAP: Record<string, string>;
22
+ /**
23
+ * Get the developer-friendly component name for a native view type.
24
+ * Returns the original viewType if no mapping exists.
25
+ *
26
+ * @param viewType - The native view class name (e.g., "RCTView")
27
+ * @returns The component name (e.g., "View")
28
+ */
29
+ export declare function getComponentDisplayName(viewType: string): string;
30
+ /**
31
+ * Get the native view class name for a component name (reverse lookup).
32
+ * Returns null if no mapping exists.
33
+ *
34
+ * @param componentName - The component name (e.g., "View")
35
+ * @returns The native view class name (e.g., "RCTView") or null
36
+ */
37
+ export declare function getNativeViewType(componentName: string): string | null;
38
+ /**
39
+ * Check if a view type is a known native component.
40
+ *
41
+ * @param viewType - The native view class name
42
+ * @returns true if it's a known component
43
+ */
44
+ export declare function isKnownViewType(viewType: string): boolean;
45
+ /**
46
+ * Get all known view types (useful for autocomplete/suggestions).
47
+ *
48
+ * @returns Array of all native view class names
49
+ */
50
+ export declare function getAllNativeViewTypes(): string[];
51
+ /**
52
+ * Get all known component names (useful for autocomplete/suggestions).
53
+ *
54
+ * @returns Array of all component display names
55
+ */
56
+ export declare function getAllComponentNames(): string[];
57
+ declare const _default: {
58
+ VIEW_TYPE_MAP: Record<string, string>;
59
+ getComponentDisplayName: typeof getComponentDisplayName;
60
+ getNativeViewType: typeof getNativeViewType;
61
+ isKnownViewType: typeof isKnownViewType;
62
+ getAllNativeViewTypes: typeof getAllNativeViewTypes;
63
+ getAllComponentNames: typeof getAllComponentNames;
64
+ };
65
+ export default _default;
66
+ //# sourceMappingURL=ViewTypeMapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewTypeMapper.d.ts","sourceRoot":"","sources":["../../../../src/debug-borders/utils/ViewTypeMapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA6LhD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOtE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAE/C;;;;;;;;;AAED,wBAOE"}
@@ -0,0 +1,3 @@
1
+ export { debugBordersToolPreset, createDebugBordersTool } from "./preset";
2
+ export * from "./debug-borders";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAG1E,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Pre-configured debug borders tool for FloatingDevTools
3
+ *
4
+ * This preset provides a zero-config way to add visual layout debugging to your dev tools.
5
+ * Just import and add it to your apps array! Tap the icon to cycle through modes:
6
+ * - Off (gray icon)
7
+ * - Borders only (green icon)
8
+ * - Borders + Labels (cyan icon)
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import { debugBordersToolPreset } from '@buoy-gg/debug-borders';
13
+ *
14
+ * const installedApps = [
15
+ * debugBordersToolPreset, // That's it!
16
+ * // ...other tools
17
+ * ];
18
+ * ```
19
+ */
20
+ import React from "react";
21
+ /**
22
+ * Icon component that changes color based on display mode.
23
+ *
24
+ * ⚠️ IMPORTANT - DO NOT MODIFY THIS COMPONENT ⚠️
25
+ * This component MUST use useState and useEffect hooks to subscribe to the manager.
26
+ * It is rendered as a JSX component (<IconComponent />) in FloatingMenu and DialIcon,
27
+ * which allows hooks to work properly.
28
+ *
29
+ * If you remove the hooks or change this to read getMode() directly,
30
+ * the icon color will NOT update when the toggle is pressed.
31
+ */
32
+ declare function BordersIcon({ size }: {
33
+ size: number;
34
+ }): React.JSX.Element;
35
+ /**
36
+ * Empty component for toggle-only tools (no modal needed)
37
+ */
38
+ declare function EmptyComponent(): null;
39
+ /**
40
+ * Pre-configured debug borders tool for FloatingDevTools.
41
+ * Tap the icon to cycle through modes: Off → Borders → Labels → Off
42
+ *
43
+ * Features:
44
+ * - Visual layout debugging with colored borders
45
+ * - Optional component labels showing testID, nativeID, component name, etc.
46
+ * - Automatic component tracking
47
+ * - Real-time updates every 2 seconds
48
+ * - Icon changes color: gray (off), green (borders), cyan (labels)
49
+ */
50
+ export declare const debugBordersToolPreset: {
51
+ id: string;
52
+ name: string;
53
+ description: string;
54
+ slot: "menu";
55
+ icon: typeof BordersIcon;
56
+ component: typeof EmptyComponent;
57
+ props: {};
58
+ launchMode: "toggle-only";
59
+ onPress: () => void;
60
+ };
61
+ /**
62
+ * Create a custom debug borders tool configuration.
63
+ * Use this if you want to override default settings.
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * import { createDebugBordersTool } from '@buoy-gg/debug-borders';
68
+ *
69
+ * const myBordersTool = createDebugBordersTool({
70
+ * name: "LAYOUT",
71
+ * offColor: "#9ca3af",
72
+ * bordersColor: "#ec4899",
73
+ * labelsColor: "#8b5cf6",
74
+ * });
75
+ * ```
76
+ */
77
+ export declare function createDebugBordersTool(options?: {
78
+ /** Tool name (default: "BORDERS") */
79
+ name?: string;
80
+ /** Tool description */
81
+ description?: string;
82
+ /** Icon color when off (default: "#6b7280" - gray) */
83
+ offColor?: string;
84
+ /** Icon color in borders mode (default: "#10b981" - green) */
85
+ bordersColor?: string;
86
+ /** Icon color in labels mode (default: "#06b6d4" - cyan) */
87
+ labelsColor?: string;
88
+ /** Custom tool ID (default: "debug-borders") */
89
+ id?: string;
90
+ }): {
91
+ id: string;
92
+ name: string;
93
+ description: string;
94
+ slot: "menu";
95
+ icon: ({ size }: {
96
+ size: number;
97
+ }) => React.JSX.Element;
98
+ component: typeof EmptyComponent;
99
+ props: {};
100
+ launchMode: "toggle-only";
101
+ onPress: () => void;
102
+ };
103
+ /**
104
+ * Export the standalone overlay for manual integration
105
+ * Use this if you want to control debug borders outside of FloatingDevTools
106
+ */
107
+ export { DebugBordersStandaloneOverlay } from "./debug-borders/components/DebugBordersStandaloneOverlay";
108
+ //# sourceMappingURL=preset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../src/preset.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAA8B,MAAM,OAAO,CAAC;AAmBnD;;;;;;;;;;GAUG;AACH,iBAAS,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,qBAW9C;AAED;;GAEG;AACH,iBAAS,cAAc,SAEtB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;CAalC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE;IAC/C,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;;;;;qBAcsC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;;;;;EA4BtD;AAED;;;GAGG;AACH,OAAO,EAAE,6BAA6B,EAAE,MAAM,0DAA0D,CAAC"}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@buoy-gg/debug-borders",
3
+ "version": "2.0.2",
4
+ "description": "debug-borders package",
5
+ "main": "lib/commonjs/index.js",
6
+ "module": "lib/module/index.js",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index.tsx",
9
+ "source": "src/index.tsx",
10
+ "files": [
11
+ "lib"
12
+ ],
13
+ "sideEffects": false,
14
+ "scripts": {
15
+ "build": "bob build",
16
+ "typecheck": "tsc --noEmit",
17
+ "prepublishOnly": "bob build",
18
+ "clean": "rimraf lib",
19
+ "test": "pnpm run typecheck"
20
+ },
21
+ "dependencies": {
22
+ "@buoy-gg/core": "workspace:*",
23
+ "@buoy-gg/shared-ui": "workspace:*"
24
+ },
25
+ "peerDependencies": {
26
+ "react": "*",
27
+ "react-native": "*",
28
+ "@buoy-gg/license": "*"
29
+ },
30
+ "peerDependenciesMeta": {
31
+ "@buoy-gg/license": {
32
+ "optional": true
33
+ }
34
+ },
35
+ "devDependencies": {
36
+ "@types/react": "^19.1.0",
37
+ "@types/react-native": "^0.73.0",
38
+ "typescript": "~5.8.3"
39
+ },
40
+ "react-native-builder-bob": {
41
+ "source": "src",
42
+ "output": "lib",
43
+ "targets": [
44
+ [
45
+ "commonjs",
46
+ {
47
+ "sourceMaps": false
48
+ }
49
+ ],
50
+ [
51
+ "module",
52
+ {
53
+ "sourceMaps": false
54
+ }
55
+ ],
56
+ "typescript"
57
+ ]
58
+ },
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "https://github.com/LovesWorking/react-native-buoy.git",
62
+ "directory": "packages/debug-borders"
63
+ },
64
+ "bugs": {
65
+ "url": "https://github.com/LovesWorking/react-native-buoy/issues"
66
+ },
67
+ "homepage": "https://github.com/LovesWorking/react-native-buoy/tree/main/packages/debug-borders#readme",
68
+ "publishConfig": {
69
+ "access": "public",
70
+ "tag": "latest"
71
+ }
72
+ }