@buoy-gg/core 1.7.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 (132) hide show
  1. package/README.md +43 -0
  2. package/lib/commonjs/floatingMenu/AppHost.js +410 -0
  3. package/lib/commonjs/floatingMenu/AppHostLogic.js +44 -0
  4. package/lib/commonjs/floatingMenu/DefaultConfigContext.js +45 -0
  5. package/lib/commonjs/floatingMenu/DevToolsSettingsModal.js +2274 -0
  6. package/lib/commonjs/floatingMenu/DevToolsVisibilityContext.js +49 -0
  7. package/lib/commonjs/floatingMenu/DraggableHeader.js +114 -0
  8. package/lib/commonjs/floatingMenu/FloatingDevTools.js +254 -0
  9. package/lib/commonjs/floatingMenu/FloatingMenu.js +364 -0
  10. package/lib/commonjs/floatingMenu/MinimizedToolsContext.js +247 -0
  11. package/lib/commonjs/floatingMenu/MinimizedToolsStack.js +206 -0
  12. package/lib/commonjs/floatingMenu/ToggleStateManager.js +36 -0
  13. package/lib/commonjs/floatingMenu/autoDiscoverPresets.js +241 -0
  14. package/lib/commonjs/floatingMenu/defaultConfig.js +160 -0
  15. package/lib/commonjs/floatingMenu/dial/DialDevTools.js +835 -0
  16. package/lib/commonjs/floatingMenu/dial/DialIcon.js +246 -0
  17. package/lib/commonjs/floatingMenu/dial/OnboardingTooltip.js +249 -0
  18. package/lib/commonjs/floatingMenu/dial/onboardingConstants.js +70 -0
  19. package/lib/commonjs/floatingMenu/floatingTools.js +771 -0
  20. package/lib/commonjs/floatingMenu/settingsBus.js +23 -0
  21. package/lib/commonjs/floatingMenu/types.js +5 -0
  22. package/lib/commonjs/index.js +240 -0
  23. package/lib/commonjs/package.json +1 -0
  24. package/lib/module/floatingMenu/AppHost.js +402 -0
  25. package/lib/module/floatingMenu/AppHostLogic.js +39 -0
  26. package/lib/module/floatingMenu/DefaultConfigContext.js +39 -0
  27. package/lib/module/floatingMenu/DevToolsSettingsModal.js +2273 -0
  28. package/lib/module/floatingMenu/DevToolsVisibilityContext.js +44 -0
  29. package/lib/module/floatingMenu/DraggableHeader.js +110 -0
  30. package/lib/module/floatingMenu/FloatingDevTools.js +249 -0
  31. package/lib/module/floatingMenu/FloatingMenu.js +358 -0
  32. package/lib/module/floatingMenu/MinimizedToolsContext.js +239 -0
  33. package/lib/module/floatingMenu/MinimizedToolsStack.js +202 -0
  34. package/lib/module/floatingMenu/ToggleStateManager.js +32 -0
  35. package/lib/module/floatingMenu/autoDiscoverPresets.js +236 -0
  36. package/lib/module/floatingMenu/defaultConfig.js +151 -0
  37. package/lib/module/floatingMenu/dial/DialDevTools.js +829 -0
  38. package/lib/module/floatingMenu/dial/DialIcon.js +241 -0
  39. package/lib/module/floatingMenu/dial/OnboardingTooltip.js +244 -0
  40. package/lib/module/floatingMenu/dial/onboardingConstants.js +64 -0
  41. package/lib/module/floatingMenu/floatingTools.js +767 -0
  42. package/lib/module/floatingMenu/settingsBus.js +19 -0
  43. package/lib/module/floatingMenu/types.js +3 -0
  44. package/lib/module/index.js +29 -0
  45. package/lib/module/package.json +1 -0
  46. package/lib/typescript/commonjs/floatingMenu/AppHost.d.ts +39 -0
  47. package/lib/typescript/commonjs/floatingMenu/AppHost.d.ts.map +1 -0
  48. package/lib/typescript/commonjs/floatingMenu/AppHostLogic.d.ts +37 -0
  49. package/lib/typescript/commonjs/floatingMenu/AppHostLogic.d.ts.map +1 -0
  50. package/lib/typescript/commonjs/floatingMenu/DefaultConfigContext.d.ts +27 -0
  51. package/lib/typescript/commonjs/floatingMenu/DefaultConfigContext.d.ts.map +1 -0
  52. package/lib/typescript/commonjs/floatingMenu/DevToolsSettingsModal.d.ts +57 -0
  53. package/lib/typescript/commonjs/floatingMenu/DevToolsSettingsModal.d.ts.map +1 -0
  54. package/lib/typescript/commonjs/floatingMenu/DevToolsVisibilityContext.d.ts +25 -0
  55. package/lib/typescript/commonjs/floatingMenu/DevToolsVisibilityContext.d.ts.map +1 -0
  56. package/lib/typescript/commonjs/floatingMenu/DraggableHeader.d.ts +30 -0
  57. package/lib/typescript/commonjs/floatingMenu/DraggableHeader.d.ts.map +1 -0
  58. package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.d.ts +226 -0
  59. package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.d.ts.map +1 -0
  60. package/lib/typescript/commonjs/floatingMenu/FloatingMenu.d.ts +39 -0
  61. package/lib/typescript/commonjs/floatingMenu/FloatingMenu.d.ts.map +1 -0
  62. package/lib/typescript/commonjs/floatingMenu/MinimizedToolsContext.d.ts +95 -0
  63. package/lib/typescript/commonjs/floatingMenu/MinimizedToolsContext.d.ts.map +1 -0
  64. package/lib/typescript/commonjs/floatingMenu/MinimizedToolsStack.d.ts +10 -0
  65. package/lib/typescript/commonjs/floatingMenu/MinimizedToolsStack.d.ts.map +1 -0
  66. package/lib/typescript/commonjs/floatingMenu/ToggleStateManager.d.ts +21 -0
  67. package/lib/typescript/commonjs/floatingMenu/ToggleStateManager.d.ts.map +1 -0
  68. package/lib/typescript/commonjs/floatingMenu/autoDiscoverPresets.d.ts +75 -0
  69. package/lib/typescript/commonjs/floatingMenu/autoDiscoverPresets.d.ts.map +1 -0
  70. package/lib/typescript/commonjs/floatingMenu/defaultConfig.d.ts +120 -0
  71. package/lib/typescript/commonjs/floatingMenu/defaultConfig.d.ts.map +1 -0
  72. package/lib/typescript/commonjs/floatingMenu/dial/DialDevTools.d.ts +35 -0
  73. package/lib/typescript/commonjs/floatingMenu/dial/DialDevTools.d.ts.map +1 -0
  74. package/lib/typescript/commonjs/floatingMenu/dial/DialIcon.d.ts +14 -0
  75. package/lib/typescript/commonjs/floatingMenu/dial/DialIcon.d.ts.map +1 -0
  76. package/lib/typescript/commonjs/floatingMenu/dial/OnboardingTooltip.d.ts +12 -0
  77. package/lib/typescript/commonjs/floatingMenu/dial/OnboardingTooltip.d.ts.map +1 -0
  78. package/lib/typescript/commonjs/floatingMenu/dial/onboardingConstants.d.ts +30 -0
  79. package/lib/typescript/commonjs/floatingMenu/dial/onboardingConstants.d.ts.map +1 -0
  80. package/lib/typescript/commonjs/floatingMenu/floatingTools.d.ts +56 -0
  81. package/lib/typescript/commonjs/floatingMenu/floatingTools.d.ts.map +1 -0
  82. package/lib/typescript/commonjs/floatingMenu/settingsBus.d.ts +10 -0
  83. package/lib/typescript/commonjs/floatingMenu/settingsBus.d.ts.map +1 -0
  84. package/lib/typescript/commonjs/floatingMenu/types.d.ts +56 -0
  85. package/lib/typescript/commonjs/floatingMenu/types.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/index.d.ts +18 -0
  87. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/package.json +1 -0
  89. package/lib/typescript/module/floatingMenu/AppHost.d.ts +39 -0
  90. package/lib/typescript/module/floatingMenu/AppHost.d.ts.map +1 -0
  91. package/lib/typescript/module/floatingMenu/AppHostLogic.d.ts +37 -0
  92. package/lib/typescript/module/floatingMenu/AppHostLogic.d.ts.map +1 -0
  93. package/lib/typescript/module/floatingMenu/DefaultConfigContext.d.ts +27 -0
  94. package/lib/typescript/module/floatingMenu/DefaultConfigContext.d.ts.map +1 -0
  95. package/lib/typescript/module/floatingMenu/DevToolsSettingsModal.d.ts +57 -0
  96. package/lib/typescript/module/floatingMenu/DevToolsSettingsModal.d.ts.map +1 -0
  97. package/lib/typescript/module/floatingMenu/DevToolsVisibilityContext.d.ts +25 -0
  98. package/lib/typescript/module/floatingMenu/DevToolsVisibilityContext.d.ts.map +1 -0
  99. package/lib/typescript/module/floatingMenu/DraggableHeader.d.ts +30 -0
  100. package/lib/typescript/module/floatingMenu/DraggableHeader.d.ts.map +1 -0
  101. package/lib/typescript/module/floatingMenu/FloatingDevTools.d.ts +226 -0
  102. package/lib/typescript/module/floatingMenu/FloatingDevTools.d.ts.map +1 -0
  103. package/lib/typescript/module/floatingMenu/FloatingMenu.d.ts +39 -0
  104. package/lib/typescript/module/floatingMenu/FloatingMenu.d.ts.map +1 -0
  105. package/lib/typescript/module/floatingMenu/MinimizedToolsContext.d.ts +95 -0
  106. package/lib/typescript/module/floatingMenu/MinimizedToolsContext.d.ts.map +1 -0
  107. package/lib/typescript/module/floatingMenu/MinimizedToolsStack.d.ts +10 -0
  108. package/lib/typescript/module/floatingMenu/MinimizedToolsStack.d.ts.map +1 -0
  109. package/lib/typescript/module/floatingMenu/ToggleStateManager.d.ts +21 -0
  110. package/lib/typescript/module/floatingMenu/ToggleStateManager.d.ts.map +1 -0
  111. package/lib/typescript/module/floatingMenu/autoDiscoverPresets.d.ts +75 -0
  112. package/lib/typescript/module/floatingMenu/autoDiscoverPresets.d.ts.map +1 -0
  113. package/lib/typescript/module/floatingMenu/defaultConfig.d.ts +120 -0
  114. package/lib/typescript/module/floatingMenu/defaultConfig.d.ts.map +1 -0
  115. package/lib/typescript/module/floatingMenu/dial/DialDevTools.d.ts +35 -0
  116. package/lib/typescript/module/floatingMenu/dial/DialDevTools.d.ts.map +1 -0
  117. package/lib/typescript/module/floatingMenu/dial/DialIcon.d.ts +14 -0
  118. package/lib/typescript/module/floatingMenu/dial/DialIcon.d.ts.map +1 -0
  119. package/lib/typescript/module/floatingMenu/dial/OnboardingTooltip.d.ts +12 -0
  120. package/lib/typescript/module/floatingMenu/dial/OnboardingTooltip.d.ts.map +1 -0
  121. package/lib/typescript/module/floatingMenu/dial/onboardingConstants.d.ts +30 -0
  122. package/lib/typescript/module/floatingMenu/dial/onboardingConstants.d.ts.map +1 -0
  123. package/lib/typescript/module/floatingMenu/floatingTools.d.ts +56 -0
  124. package/lib/typescript/module/floatingMenu/floatingTools.d.ts.map +1 -0
  125. package/lib/typescript/module/floatingMenu/settingsBus.d.ts +10 -0
  126. package/lib/typescript/module/floatingMenu/settingsBus.d.ts.map +1 -0
  127. package/lib/typescript/module/floatingMenu/types.d.ts +56 -0
  128. package/lib/typescript/module/floatingMenu/types.d.ts.map +1 -0
  129. package/lib/typescript/module/index.d.ts +18 -0
  130. package/lib/typescript/module/index.d.ts.map +1 -0
  131. package/lib/typescript/module/package.json +1 -0
  132. package/package.json +79 -0
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MinimizedToolsStack = MinimizedToolsStack;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _sharedUi = require("@buoy-gg/shared-ui");
10
+ var _MinimizedToolsContext = require("./MinimizedToolsContext.js");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ 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); }
13
+ // ============================================================================
14
+ // Constants
15
+ // ============================================================================
16
+ const PEEK_HEIGHT = 28;
17
+ const TOOLBAR_WIDTH = 44;
18
+ const TOOL_ITEM_SIZE = 32;
19
+ const ICON_GAP = 6;
20
+ const TOOLBAR_PADDING = 8;
21
+ const COLLAPSE_BUTTON_SIZE = 24;
22
+ const STORAGE_KEY_EXPANDED = "@react_buoy_minimized_stack_expanded";
23
+
24
+ // Glitch effect constants
25
+ const GLITCH_DURATION_MS = 80;
26
+ const MIN_GLITCH_DELAY = 2000;
27
+ const MAX_GLITCH_DELAY = 6000;
28
+
29
+ // ============================================================================
30
+ // Glitch Tool Button Component
31
+ // ============================================================================
32
+
33
+ function GlitchToolButton({
34
+ tool,
35
+ onPress,
36
+ index
37
+ }) {
38
+ const glitchX = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
39
+ const glitchOpacity = (0, _react.useRef)(new _reactNative.Animated.Value(1)).current;
40
+ const glitchScale = (0, _react.useRef)(new _reactNative.Animated.Value(1)).current;
41
+ (0, _react.useEffect)(() => {
42
+ let isMounted = true;
43
+ const runGlitch = () => {
44
+ if (!isMounted) return;
45
+ const d = GLITCH_DURATION_MS;
46
+ _reactNative.Animated.parallel([
47
+ // X displacement - quick shake
48
+ _reactNative.Animated.sequence([_reactNative.Animated.timing(glitchX, {
49
+ toValue: 3,
50
+ duration: d * 0.2,
51
+ easing: _reactNative.Easing.linear,
52
+ useNativeDriver: true
53
+ }), _reactNative.Animated.timing(glitchX, {
54
+ toValue: -3,
55
+ duration: d * 0.2,
56
+ easing: _reactNative.Easing.linear,
57
+ useNativeDriver: true
58
+ }), _reactNative.Animated.timing(glitchX, {
59
+ toValue: 2,
60
+ duration: d * 0.2,
61
+ easing: _reactNative.Easing.linear,
62
+ useNativeDriver: true
63
+ }), _reactNative.Animated.timing(glitchX, {
64
+ toValue: -1,
65
+ duration: d * 0.2,
66
+ easing: _reactNative.Easing.linear,
67
+ useNativeDriver: true
68
+ }), _reactNative.Animated.timing(glitchX, {
69
+ toValue: 0,
70
+ duration: d * 0.2,
71
+ easing: _reactNative.Easing.linear,
72
+ useNativeDriver: true
73
+ })]),
74
+ // Opacity flicker
75
+ _reactNative.Animated.sequence([_reactNative.Animated.timing(glitchOpacity, {
76
+ toValue: 0.4,
77
+ duration: d * 0.25,
78
+ useNativeDriver: true
79
+ }), _reactNative.Animated.timing(glitchOpacity, {
80
+ toValue: 1,
81
+ duration: d * 0.25,
82
+ useNativeDriver: true
83
+ }), _reactNative.Animated.timing(glitchOpacity, {
84
+ toValue: 0.6,
85
+ duration: d * 0.25,
86
+ useNativeDriver: true
87
+ }), _reactNative.Animated.timing(glitchOpacity, {
88
+ toValue: 1,
89
+ duration: d * 0.25,
90
+ useNativeDriver: true
91
+ })]),
92
+ // Scale pulse
93
+ _reactNative.Animated.sequence([_reactNative.Animated.timing(glitchScale, {
94
+ toValue: 1.1,
95
+ duration: d * 0.3,
96
+ useNativeDriver: true
97
+ }), _reactNative.Animated.timing(glitchScale, {
98
+ toValue: 0.95,
99
+ duration: d * 0.4,
100
+ useNativeDriver: true
101
+ }), _reactNative.Animated.timing(glitchScale, {
102
+ toValue: 1,
103
+ duration: d * 0.3,
104
+ useNativeDriver: true
105
+ })])]).start();
106
+ };
107
+ const scheduleNextGlitch = () => {
108
+ if (!isMounted) return;
109
+ const delay = MIN_GLITCH_DELAY + Math.random() * (MAX_GLITCH_DELAY - MIN_GLITCH_DELAY) + index * 300;
110
+ setTimeout(() => {
111
+ if (isMounted) {
112
+ runGlitch();
113
+ scheduleNextGlitch();
114
+ }
115
+ }, delay);
116
+ };
117
+ const initialDelay = 500 + Math.random() * 1500 + index * 200;
118
+ const timeoutId = setTimeout(() => {
119
+ if (isMounted) {
120
+ runGlitch();
121
+ scheduleNextGlitch();
122
+ }
123
+ }, initialDelay);
124
+ return () => {
125
+ isMounted = false;
126
+ clearTimeout(timeoutId);
127
+ };
128
+ }, [glitchX, glitchOpacity, glitchScale, index]);
129
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
130
+ onPress: () => onPress(tool),
131
+ activeOpacity: 0.7,
132
+ style: styles.toolButton,
133
+ accessibilityLabel: `Restore ${tool.title}`,
134
+ accessibilityRole: "button",
135
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
136
+ style: {
137
+ opacity: glitchOpacity,
138
+ transform: [{
139
+ translateX: glitchX
140
+ }, {
141
+ scale: glitchScale
142
+ }]
143
+ },
144
+ children: tool.icon
145
+ })
146
+ });
147
+ }
148
+
149
+ // ============================================================================
150
+ // Types
151
+ // ============================================================================
152
+
153
+ // ============================================================================
154
+ // Main Component
155
+ // ============================================================================
156
+
157
+ function MinimizedToolsStack({
158
+ onRestore,
159
+ containerWidth = TOOLBAR_WIDTH
160
+ }) {
161
+ const {
162
+ minimizedTools,
163
+ restore
164
+ } = (0, _MinimizedToolsContext.useMinimizedTools)();
165
+
166
+ // Calculate expanded height based on number of tools
167
+ const expandedHeight = TOOLBAR_PADDING + minimizedTools.length * TOOL_ITEM_SIZE + (minimizedTools.length - 1) * ICON_GAP + ICON_GAP + COLLAPSE_BUTTON_SIZE + 4;
168
+
169
+ // Handle tool press (restore)
170
+ const handleToolPress = (0, _react.useCallback)(tool => {
171
+ const restored = restore(tool.instanceId);
172
+ if (restored && onRestore) {
173
+ onRestore(restored);
174
+ }
175
+ }, [restore, onRestore]);
176
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.ExpandablePopover, {
177
+ hasItems: minimizedTools.length > 0,
178
+ itemCount: minimizedTools.length,
179
+ showCount: true,
180
+ width: containerWidth,
181
+ expandedHeight: expandedHeight,
182
+ persistState: true,
183
+ storageKey: STORAGE_KEY_EXPANDED,
184
+ peekHeight: PEEK_HEIGHT,
185
+ collapsedLabel: `Show ${minimizedTools.length} minimized tools`,
186
+ children: [...minimizedTools].reverse().map((tool, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(GlitchToolButton, {
187
+ tool: tool,
188
+ onPress: handleToolPress,
189
+ index: index
190
+ }, tool.instanceId))
191
+ });
192
+ }
193
+
194
+ // ============================================================================
195
+ // Styles
196
+ // ============================================================================
197
+
198
+ const styles = _reactNative.StyleSheet.create({
199
+ toolButton: {
200
+ width: TOOL_ITEM_SIZE,
201
+ height: TOOL_ITEM_SIZE,
202
+ alignItems: "center",
203
+ justifyContent: "center",
204
+ backgroundColor: "transparent"
205
+ }
206
+ });
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toggleStateManager = void 0;
7
+ /**
8
+ * ToggleStateManager
9
+ *
10
+ * Global event emitter for toggle-only dev tools to notify when their state changes.
11
+ * This allows FloatingMenu to re-render and update icon colors.
12
+ */
13
+
14
+ class ToggleStateManager {
15
+ listeners = new Set();
16
+
17
+ /**
18
+ * Subscribe to any toggle state change
19
+ */
20
+ subscribe(listener) {
21
+ this.listeners.add(listener);
22
+ return () => {
23
+ this.listeners.delete(listener);
24
+ };
25
+ }
26
+
27
+ /**
28
+ * Notify all subscribers that a toggle state changed
29
+ */
30
+ notify() {
31
+ this.listeners.forEach(listener => listener());
32
+ }
33
+ }
34
+
35
+ // Singleton instance
36
+ const toggleStateManager = exports.toggleStateManager = new ToggleStateManager();
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.autoDiscoverPresets = autoDiscoverPresets;
7
+ exports.autoDiscoverPresetsWithCustom = autoDiscoverPresetsWithCustom;
8
+ /**
9
+ * Automatically discovers and loads dev tool presets from installed packages.
10
+ *
11
+ * This function attempts to import presets from known dev tool packages.
12
+ * If a package is installed, its preset will be automatically loaded.
13
+ * If a package is not installed, it will be silently skipped.
14
+ *
15
+ * This enables zero-config setup - just install the packages you want
16
+ * and they'll automatically appear in your dev tools!
17
+ *
18
+ * @returns Array of automatically discovered preset configurations
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * import { FloatingDevTools, autoDiscoverPresets } from '@buoy-gg/core';
23
+ *
24
+ * // Automatically discover and load all installed dev tool presets
25
+ * const autoPresets = autoDiscoverPresets();
26
+ *
27
+ * function App() {
28
+ * return (
29
+ * <FloatingDevTools
30
+ * apps={autoPresets} // That's it! All installed tools load automatically
31
+ * environment="local"
32
+ * userRole="admin"
33
+ * />
34
+ * );
35
+ * }
36
+ * ```
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * // Combine auto-discovery with custom tools
41
+ * const autoPresets = autoDiscoverPresets();
42
+ * const customTools = [
43
+ * {
44
+ * id: "my-custom-tool",
45
+ * name: "CUSTOM",
46
+ * // ... custom config
47
+ * },
48
+ * ];
49
+ *
50
+ * const allTools = [...autoPresets, ...customTools];
51
+ *
52
+ * <FloatingDevTools apps={allTools} />
53
+ * ```
54
+ */
55
+ function autoDiscoverPresets() {
56
+ const discoveredPresets = [];
57
+
58
+ // Try to load each known preset
59
+ // These will only succeed if the package is actually installed
60
+ const presetLoaders = [
61
+ // ENV Tools
62
+ {
63
+ name: "@buoy-gg/env",
64
+ loader: () => {
65
+ try {
66
+ // @ts-ignore - Dynamic import that may not exist
67
+ const {
68
+ envToolPreset
69
+ } = require("@buoy-gg/env");
70
+ return envToolPreset;
71
+ } catch {
72
+ return null;
73
+ }
74
+ }
75
+ },
76
+ // Network Tools
77
+ {
78
+ name: "@buoy-gg/network",
79
+ loader: () => {
80
+ try {
81
+ // @ts-ignore - Dynamic import that may not exist
82
+ const {
83
+ networkToolPreset
84
+ } = require("@buoy-gg/network");
85
+ return networkToolPreset;
86
+ } catch {
87
+ return null;
88
+ }
89
+ }
90
+ },
91
+ // Storage Tools
92
+ {
93
+ name: "@buoy-gg/storage",
94
+ loader: () => {
95
+ try {
96
+ // @ts-ignore - Dynamic import that may not exist
97
+ const {
98
+ storageToolPreset
99
+ } = require("@buoy-gg/storage");
100
+ return storageToolPreset;
101
+ } catch {
102
+ return null;
103
+ }
104
+ }
105
+ },
106
+ // React Query Tools
107
+ {
108
+ name: "@buoy-gg/react-query",
109
+ loader: () => {
110
+ try {
111
+ // @ts-ignore - Dynamic import that may not exist
112
+ const {
113
+ reactQueryToolPreset,
114
+ wifiTogglePreset
115
+ } = require("@buoy-gg/react-query");
116
+ return [reactQueryToolPreset, wifiTogglePreset];
117
+ } catch {
118
+ return null;
119
+ }
120
+ }
121
+ },
122
+ // Route Events
123
+ {
124
+ name: "@buoy-gg/route-events",
125
+ loader: () => {
126
+ try {
127
+ // @ts-ignore - Dynamic import that may not exist
128
+ const {
129
+ routeEventsToolPreset
130
+ } = require("@buoy-gg/route-events");
131
+ return routeEventsToolPreset;
132
+ } catch {
133
+ return null;
134
+ }
135
+ }
136
+ },
137
+ // Debug Borders
138
+ {
139
+ name: "@buoy-gg/debug-borders",
140
+ loader: () => {
141
+ try {
142
+ // @ts-ignore - Dynamic import that may not exist
143
+ const {
144
+ debugBordersToolPreset
145
+ } = require("@buoy-gg/debug-borders");
146
+ return debugBordersToolPreset;
147
+ } catch {
148
+ return null;
149
+ }
150
+ }
151
+ },
152
+ // Highlight Updates (both toggle and modal presets)
153
+ {
154
+ name: "@buoy-gg/highlight-updates",
155
+ loader: () => {
156
+ try {
157
+ // @ts-ignore - Dynamic import that may not exist
158
+ const {
159
+ highlightUpdatesPreset,
160
+ highlightUpdatesModalPreset
161
+ } = require("@buoy-gg/highlight-updates");
162
+ return [highlightUpdatesModalPreset, highlightUpdatesPreset];
163
+ } catch {
164
+ return null;
165
+ }
166
+ }
167
+ },
168
+ // Benchmark Tools
169
+ {
170
+ name: "@buoy-gg/benchmark",
171
+ loader: () => {
172
+ try {
173
+ // @ts-ignore - Dynamic import that may not exist
174
+ const {
175
+ benchmarkPreset
176
+ } = require("@buoy-gg/benchmark");
177
+ return benchmarkPreset;
178
+ } catch {
179
+ return null;
180
+ }
181
+ }
182
+ }];
183
+
184
+ // Attempt to load each preset
185
+ for (const {
186
+ name,
187
+ loader
188
+ } of presetLoaders) {
189
+ try {
190
+ const preset = loader();
191
+ if (preset) {
192
+ if (Array.isArray(preset)) {
193
+ discoveredPresets.push(...preset);
194
+ } else {
195
+ discoveredPresets.push(preset);
196
+ }
197
+ }
198
+ } catch (error) {
199
+ // Silently skip packages that aren't installed
200
+ // This is expected behavior - not all packages will be installed
201
+ }
202
+ }
203
+ return discoveredPresets;
204
+ }
205
+
206
+ /**
207
+ * Merges auto-discovered presets with custom tools, ensuring no duplicates.
208
+ * Custom tools take precedence over auto-discovered ones with the same ID.
209
+ *
210
+ * @param customTools - Array of custom tool configurations
211
+ * @returns Combined array of tools with custom tools taking precedence
212
+ *
213
+ * @example
214
+ * ```tsx
215
+ * import { FloatingDevTools, autoDiscoverPresetsWithCustom } from '@buoy-gg/core';
216
+ * import { createEnvTool } from '@buoy-gg/env';
217
+ *
218
+ * const customTools = [
219
+ * // Override the env preset with custom config
220
+ * createEnvTool({
221
+ * requiredEnvVars: myRequiredVars,
222
+ * }),
223
+ * ];
224
+ *
225
+ * const allTools = autoDiscoverPresetsWithCustom(customTools);
226
+ *
227
+ * <FloatingDevTools apps={allTools} />
228
+ * ```
229
+ */
230
+ function autoDiscoverPresetsWithCustom(customTools) {
231
+ const autoPresets = autoDiscoverPresets();
232
+
233
+ // Create a map of custom tool IDs for quick lookup
234
+ const customToolIds = new Set(customTools.map(tool => tool.id));
235
+
236
+ // Filter out auto-discovered presets that have custom overrides
237
+ const filteredAutoPresets = autoPresets.filter(preset => !customToolIds.has(preset.id));
238
+
239
+ // Custom tools first (higher priority), then auto-discovered
240
+ return [...customTools, ...filteredAutoPresets];
241
+ }
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MAX_DIAL_TOOLS = void 0;
7
+ exports.createDefaultConfig = createDefaultConfig;
8
+ exports.isDialToolId = isDialToolId;
9
+ exports.isFloatingToolId = isFloatingToolId;
10
+ exports.toolIdsToRecord = toolIdsToRecord;
11
+ exports.validateDialConfig = validateDialConfig;
12
+ /**
13
+ * Type-safe default configuration for React Buoy DevTools.
14
+ *
15
+ * This module provides a simple, type-safe way for teams to configure
16
+ * which tools are enabled by default in the floating menu and dial menu.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * import { FloatingDevTools } from '@buoy-gg/core';
21
+ *
22
+ * // Simple: Enable specific tools by default
23
+ * <FloatingDevTools
24
+ * defaultFloatingTools={['env', 'environment', 'network']}
25
+ * defaultDialTools={['env', 'network', 'storage', 'query']}
26
+ * />
27
+ * ```
28
+ */
29
+
30
+ /**
31
+ * All known tool IDs that can appear in the floating menu or dial menu.
32
+ * This is a union type of all auto-discovered tool IDs.
33
+ */
34
+
35
+ // Performance benchmarking (@buoy-gg/benchmark)
36
+
37
+ /**
38
+ * Special floating-only tool IDs that only appear in the floating bubble row.
39
+ */
40
+ // Environment badge indicator
41
+
42
+ /**
43
+ * All tool IDs that can appear in the floating menu (bubble row).
44
+ * Includes all built-in tools plus floating-only tools.
45
+ */
46
+
47
+ /**
48
+ * Tool IDs that can appear in the dial menu.
49
+ * Same as BuiltInToolId (environment badge is floating-only).
50
+ */
51
+
52
+ /**
53
+ * Maximum number of tools allowed in the dial menu.
54
+ */
55
+ const MAX_DIAL_TOOLS = exports.MAX_DIAL_TOOLS = 6;
56
+
57
+ /**
58
+ * Configuration for default floating menu tools.
59
+ * Pass an array of tool IDs to enable by default.
60
+ *
61
+ * @example
62
+ * ```tsx
63
+ * const floatingDefaults: DefaultFloatingConfig = ['env', 'environment', 'network'];
64
+ * ```
65
+ */
66
+
67
+ /**
68
+ * Configuration for default dial menu tools.
69
+ * Pass an array of 1-6 tool IDs to enable by default.
70
+ *
71
+ * @example
72
+ * ```tsx
73
+ * const dialDefaults: DefaultDialConfig = ['env', 'network', 'storage', 'query'];
74
+ * ```
75
+ */
76
+
77
+ /**
78
+ * Validates that a dial configuration doesn't exceed the maximum allowed tools.
79
+ * Throws an error with helpful message if validation fails.
80
+ *
81
+ * @param tools - Array of dial tool IDs to validate
82
+ * @throws Error if more than MAX_DIAL_TOOLS are provided
83
+ *
84
+ * @example
85
+ * ```tsx
86
+ * // This is valid
87
+ * validateDialConfig(['env', 'network', 'storage']);
88
+ *
89
+ * // This throws an error
90
+ * validateDialConfig(['env', 'network', 'storage', 'query', 'route-events', 'debug-borders', 'benchmark']);
91
+ * // Error: "Dial menu default configuration has 7 tools, but maximum is 6..."
92
+ * ```
93
+ */
94
+ function validateDialConfig(tools) {
95
+ if (tools.length > MAX_DIAL_TOOLS) {
96
+ const toolList = tools.map(t => `"${t}"`).join(', ');
97
+ throw new Error(`Dial menu default configuration has ${tools.length} tools, but maximum is ${MAX_DIAL_TOOLS}. ` + `Tools provided: [${toolList}]. ` + `Please remove ${tools.length - MAX_DIAL_TOOLS} tool(s) from defaultDialTools.`);
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Helper to create a type-safe default configuration.
103
+ * Provides autocomplete and validation at compile time.
104
+ *
105
+ * @example
106
+ * ```tsx
107
+ * import { createDefaultConfig } from '@buoy-gg/core';
108
+ *
109
+ * const config = createDefaultConfig({
110
+ * floating: ['env', 'environment', 'network', 'query-wifi-toggle'],
111
+ * dial: ['env', 'network', 'storage', 'query', 'route-events', 'debug-borders'],
112
+ * });
113
+ *
114
+ * <FloatingDevTools
115
+ * defaultFloatingTools={config.floating}
116
+ * defaultDialTools={config.dial}
117
+ * />
118
+ * ```
119
+ */
120
+ function createDefaultConfig(config) {
121
+ // Runtime validation for dial tools
122
+ if (config.dial) {
123
+ validateDialConfig(config.dial);
124
+ }
125
+ return {
126
+ floating: config.floating,
127
+ dial: config.dial
128
+ };
129
+ }
130
+
131
+ /**
132
+ * Type guard to check if a string is a valid FloatingToolId.
133
+ */
134
+ function isFloatingToolId(id) {
135
+ const validIds = ['env', 'network', 'storage', 'query', 'query-wifi-toggle', 'route-events', 'debug-borders', 'highlight-updates', 'highlight-updates-modal', 'benchmark', 'environment'];
136
+ return validIds.includes(id);
137
+ }
138
+
139
+ /**
140
+ * Type guard to check if a string is a valid DialToolId.
141
+ */
142
+ function isDialToolId(id) {
143
+ const validIds = ['env', 'network', 'storage', 'query', 'query-wifi-toggle', 'route-events', 'debug-borders', 'highlight-updates', 'highlight-updates-modal', 'benchmark'];
144
+ return validIds.includes(id);
145
+ }
146
+
147
+ /**
148
+ * Converts an array of tool IDs into a settings record.
149
+ * Used internally to convert default config to DevToolsSettings format.
150
+ *
151
+ * @internal
152
+ */
153
+ function toolIdsToRecord(ids, allPossibleIds) {
154
+ const record = {};
155
+ const enabledSet = new Set(ids);
156
+ for (const id of allPossibleIds) {
157
+ record[id] = enabledSet.has(id);
158
+ }
159
+ return record;
160
+ }