@buoy-gg/core 1.7.5 → 1.7.8

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 (75) hide show
  1. package/lib/commonjs/floatingMenu/AppHost.js +1 -1
  2. package/lib/commonjs/floatingMenu/DevToolsSettingsModal.js +20 -8
  3. package/lib/commonjs/floatingMenu/DevToolsSettingsModal.web.js +746 -0
  4. package/lib/commonjs/floatingMenu/FloatingDevTools.js +16 -4
  5. package/lib/commonjs/floatingMenu/FloatingDevTools.web.js +154 -0
  6. package/lib/commonjs/floatingMenu/FloatingMenu.js +8 -8
  7. package/lib/commonjs/floatingMenu/autoDiscoverPresets.js +15 -0
  8. package/lib/commonjs/floatingMenu/defaultConfig.js +14 -7
  9. package/lib/commonjs/floatingMenu/dial/DialDevTools.js +8 -2
  10. package/lib/commonjs/floatingMenu/dial/DialDevTools.web.js +593 -0
  11. package/lib/commonjs/floatingMenu/dial/OnboardingTooltip.js +2 -2
  12. package/lib/commonjs/floatingMenu/floatingTools.web.js +357 -0
  13. package/lib/commonjs/index.js +2 -2
  14. package/lib/commonjs/index.web.js +131 -0
  15. package/lib/commonjs/utils/autoDiscoverPresets.web.js +181 -0
  16. package/lib/module/floatingMenu/AppHost.js +1 -1
  17. package/lib/module/floatingMenu/DevToolsSettingsModal.js +21 -9
  18. package/lib/module/floatingMenu/DevToolsSettingsModal.web.js +756 -0
  19. package/lib/module/floatingMenu/FloatingDevTools.js +17 -5
  20. package/lib/module/floatingMenu/FloatingDevTools.web.js +150 -0
  21. package/lib/module/floatingMenu/FloatingMenu.js +8 -8
  22. package/lib/module/floatingMenu/autoDiscoverPresets.js +15 -0
  23. package/lib/module/floatingMenu/defaultConfig.js +14 -7
  24. package/lib/module/floatingMenu/dial/DialDevTools.js +8 -2
  25. package/lib/module/floatingMenu/dial/DialDevTools.web.js +590 -0
  26. package/lib/module/floatingMenu/dial/OnboardingTooltip.js +2 -2
  27. package/lib/module/floatingMenu/floatingTools.web.js +357 -0
  28. package/lib/module/index.js +2 -2
  29. package/lib/module/index.web.js +24 -0
  30. package/lib/module/utils/autoDiscoverPresets.web.js +174 -0
  31. package/lib/typescript/commonjs/floatingMenu/DevToolsSettingsModal.d.ts.map +1 -1
  32. package/lib/typescript/commonjs/floatingMenu/DevToolsSettingsModal.web.d.ts +23 -0
  33. package/lib/typescript/commonjs/floatingMenu/DevToolsSettingsModal.web.d.ts.map +1 -0
  34. package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.d.ts +1 -1
  35. package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.web.d.ts +48 -0
  37. package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.web.d.ts.map +1 -0
  38. package/lib/typescript/commonjs/floatingMenu/FloatingMenu.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/floatingMenu/autoDiscoverPresets.d.ts.map +1 -1
  40. package/lib/typescript/commonjs/floatingMenu/defaultConfig.d.ts +8 -7
  41. package/lib/typescript/commonjs/floatingMenu/defaultConfig.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/floatingMenu/dial/DialDevTools.d.ts.map +1 -1
  43. package/lib/typescript/commonjs/floatingMenu/dial/DialDevTools.web.d.ts +26 -0
  44. package/lib/typescript/commonjs/floatingMenu/dial/DialDevTools.web.d.ts.map +1 -0
  45. package/lib/typescript/commonjs/floatingMenu/dial/OnboardingTooltip.d.ts +1 -1
  46. package/lib/typescript/commonjs/floatingMenu/dial/OnboardingTooltip.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/floatingMenu/floatingTools.web.d.ts +27 -0
  48. package/lib/typescript/commonjs/floatingMenu/floatingTools.web.d.ts.map +1 -0
  49. package/lib/typescript/commonjs/index.web.d.ts +20 -0
  50. package/lib/typescript/commonjs/index.web.d.ts.map +1 -0
  51. package/lib/typescript/commonjs/utils/autoDiscoverPresets.web.d.ts +58 -0
  52. package/lib/typescript/commonjs/utils/autoDiscoverPresets.web.d.ts.map +1 -0
  53. package/lib/typescript/module/floatingMenu/DevToolsSettingsModal.d.ts.map +1 -1
  54. package/lib/typescript/module/floatingMenu/DevToolsSettingsModal.web.d.ts +23 -0
  55. package/lib/typescript/module/floatingMenu/DevToolsSettingsModal.web.d.ts.map +1 -0
  56. package/lib/typescript/module/floatingMenu/FloatingDevTools.d.ts +1 -1
  57. package/lib/typescript/module/floatingMenu/FloatingDevTools.d.ts.map +1 -1
  58. package/lib/typescript/module/floatingMenu/FloatingDevTools.web.d.ts +48 -0
  59. package/lib/typescript/module/floatingMenu/FloatingDevTools.web.d.ts.map +1 -0
  60. package/lib/typescript/module/floatingMenu/FloatingMenu.d.ts.map +1 -1
  61. package/lib/typescript/module/floatingMenu/autoDiscoverPresets.d.ts.map +1 -1
  62. package/lib/typescript/module/floatingMenu/defaultConfig.d.ts +8 -7
  63. package/lib/typescript/module/floatingMenu/defaultConfig.d.ts.map +1 -1
  64. package/lib/typescript/module/floatingMenu/dial/DialDevTools.d.ts.map +1 -1
  65. package/lib/typescript/module/floatingMenu/dial/DialDevTools.web.d.ts +26 -0
  66. package/lib/typescript/module/floatingMenu/dial/DialDevTools.web.d.ts.map +1 -0
  67. package/lib/typescript/module/floatingMenu/dial/OnboardingTooltip.d.ts +1 -1
  68. package/lib/typescript/module/floatingMenu/dial/OnboardingTooltip.d.ts.map +1 -1
  69. package/lib/typescript/module/floatingMenu/floatingTools.web.d.ts +27 -0
  70. package/lib/typescript/module/floatingMenu/floatingTools.web.d.ts.map +1 -0
  71. package/lib/typescript/module/index.web.d.ts +20 -0
  72. package/lib/typescript/module/index.web.d.ts.map +1 -0
  73. package/lib/typescript/module/utils/autoDiscoverPresets.web.d.ts +58 -0
  74. package/lib/typescript/module/utils/autoDiscoverPresets.web.d.ts.map +1 -0
  75. package/package.json +5 -4
@@ -108,16 +108,20 @@ const FloatingDevTools = ({
108
108
  defaultDialTools,
109
109
  ...props
110
110
  }) => {
111
+ // Check Pro status for production gating
112
+ const isPro = (0, _license.useIsPro)();
113
+
111
114
  // Initialize license manager on mount
112
115
  (0, _react.useEffect)(() => {
113
116
  _license.LicenseManager.initialize();
114
117
  }, []);
115
118
 
116
- // Validate dial tools configuration on mount (development-time check)
117
- (0, _react.useEffect)(() => {
119
+ // Normalize dial tools configuration (truncates to max 6 with warning if needed)
120
+ const normalizedDialTools = (0, _react.useMemo)(() => {
118
121
  if (defaultDialTools) {
119
- (0, _defaultConfig.validateDialConfig)(defaultDialTools);
122
+ return (0, _defaultConfig.validateDialConfig)(defaultDialTools);
120
123
  }
124
+ return defaultDialTools;
121
125
  }, [defaultDialTools]);
122
126
 
123
127
  // Build config overrides if requiredEnvVars or requiredStorageKeys are provided
@@ -218,9 +222,17 @@ const FloatingDevTools = ({
218
222
  }
219
223
  return tool.icon;
220
224
  }, [finalApps]);
225
+
226
+ // Gate: Free tier only works in development mode
227
+ // Pro users can use DevTools everywhere (dev + production)
228
+ const isDevelopment = typeof __DEV__ !== "undefined" && __DEV__;
229
+ if (!isDevelopment && !isPro) {
230
+ // Free user in production - don't render DevTools
231
+ return null;
232
+ }
221
233
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DefaultConfigContext.DefaultConfigProvider, {
222
234
  defaultFloatingTools: defaultFloatingTools,
223
- defaultDialTools: defaultDialTools,
235
+ defaultDialTools: normalizedDialTools,
224
236
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.HintsProvider, {
225
237
  disableHints: disableHints,
226
238
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FloatingDevTools = FloatingDevTools;
7
+ var _react = require("react");
8
+ var _floatingToolsReact = require("@buoy-gg/floating-tools-react");
9
+ var _autoDiscoverPresetsWeb = require("../utils/autoDiscoverPresets.web.js");
10
+ var _floatingToolsWeb = require("./floatingTools.web.js");
11
+ var _DialDevToolsWeb = require("./dial/DialDevTools.web.js");
12
+ var _DevToolsSettingsModalWeb = require("./DevToolsSettingsModal.web.js");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ /**
15
+ * FloatingDevTools - Unified dev tools component for React DOM Web.
16
+ *
17
+ * Matches the mobile FloatingDevTools API exactly:
18
+ * - Self-contained (doesn't wrap your app)
19
+ * - Auto-discovers installed tool packages
20
+ * - Manages dial menu and settings modal state internally
21
+ *
22
+ * Usage (same as mobile):
23
+ * ```tsx
24
+ * <>
25
+ * <YourApp />
26
+ * <FloatingDevTools environment="qa" userRole="admin" />
27
+ * </>
28
+ * ```
29
+ *
30
+ * @platform React DOM Web (Vite, CRA, Next.js, Electron)
31
+ */
32
+
33
+ // =============================
34
+ // Types
35
+ // =============================
36
+
37
+ // =============================
38
+ // Main Component
39
+ // =============================
40
+
41
+ /**
42
+ * Unified FloatingDevTools component - self-contained, no wrapping required.
43
+ *
44
+ * Matches mobile API exactly:
45
+ * ```tsx
46
+ * // Mobile
47
+ * <FloatingDevTools environment="qa" userRole={userRole} />
48
+ *
49
+ * // Web (this component)
50
+ * <FloatingDevTools environment="qa" userRole="admin" />
51
+ * ```
52
+ */
53
+ function FloatingDevTools({
54
+ environment: _environment,
55
+ userRole,
56
+ availableEnvironments: _availableEnvironments,
57
+ onEnvironmentSwitch: _onEnvironmentSwitch,
58
+ apps,
59
+ disableHints: _disableHints
60
+ }) {
61
+ // Internal state for dial and settings
62
+ const [isDialOpen, setIsDialOpen] = (0, _react.useState)(false);
63
+ const [isSettingsOpen, setIsSettingsOpen] = (0, _react.useState)(false);
64
+
65
+ // Auto-discover tools and merge with custom apps
66
+ const tools = (0, _react.useMemo)(() => (0, _autoDiscoverPresetsWeb.autoDiscoverWithCustom)(apps), [apps]);
67
+
68
+ // Convert to available tools config for settings
69
+ const availableToolsConfig = (0, _react.useMemo)(() => tools.map(tool => ({
70
+ id: tool.id,
71
+ name: tool.name,
72
+ description: tool.description,
73
+ slot: tool.slot
74
+ })), [tools]);
75
+
76
+ // Use shared settings hook
77
+ const {
78
+ settings
79
+ } = (0, _floatingToolsReact.useSettings)({
80
+ availableTools: availableToolsConfig
81
+ });
82
+
83
+ // Build dial icons from enabled dial tools
84
+ const dialIcons = (0, _react.useMemo)(() => {
85
+ const dialTools = (0, _autoDiscoverPresetsWeb.getToolsBySlot)(tools, 'dial');
86
+ const enabledDialIds = Object.entries(settings.dialTools).filter(([_, enabled]) => enabled).map(([id]) => id);
87
+ return dialTools.filter(tool => enabledDialIds.includes(tool.id)).map(tool => {
88
+ const color = tool.color || (0, _floatingToolsReact.getToolColor)(tool.id);
89
+ // Handle icon - can be string (emoji) or function (size) => ReactNode
90
+ let icon;
91
+ if (typeof tool.icon === 'string') {
92
+ icon = tool.icon;
93
+ } else if (typeof tool.icon === 'function') {
94
+ // It's a render function - call it with size
95
+ icon = tool.icon(32);
96
+ } else {
97
+ icon = '🔧';
98
+ }
99
+ return {
100
+ id: tool.id,
101
+ name: (0, _floatingToolsReact.getToolLabel)(tool.id),
102
+ icon,
103
+ color,
104
+ onPress: () => {
105
+ tool.onPress?.();
106
+ setIsDialOpen(false);
107
+ }
108
+ };
109
+ });
110
+ }, [tools, settings.dialTools]);
111
+
112
+ // Build available tools for settings modal
113
+ const availableTools = (0, _react.useMemo)(() => tools.map(tool => ({
114
+ id: tool.id,
115
+ name: tool.name || (0, _floatingToolsReact.getToolLabel)(tool.id),
116
+ description: tool.description || (0, _floatingToolsReact.getToolDescription)(tool.id),
117
+ slot: tool.slot
118
+ })), [tools]);
119
+
120
+ // Callbacks
121
+ const handleOpenDial = (0, _react.useCallback)(() => setIsDialOpen(true), []);
122
+ const handleCloseDial = (0, _react.useCallback)(() => setIsDialOpen(false), []);
123
+ const handleOpenSettings = (0, _react.useCallback)(() => {
124
+ setIsDialOpen(false);
125
+ setIsSettingsOpen(true);
126
+ }, []);
127
+ const handleCloseSettings = (0, _react.useCallback)(() => setIsSettingsOpen(false), []);
128
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
129
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_floatingToolsWeb.FloatingTools, {
130
+ enablePositionPersistence: true,
131
+ children: userRole && /*#__PURE__*/(0, _jsxRuntime.jsx)(_floatingToolsWeb.UserStatus, {
132
+ userRole: userRole,
133
+ onPress: handleOpenDial
134
+ })
135
+ }), isDialOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialDevToolsWeb.DialMenu, {
136
+ icons: dialIcons,
137
+ onClose: handleCloseDial,
138
+ centerLabel: "BUOY",
139
+ onCenterPress: handleOpenSettings
140
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_DevToolsSettingsModalWeb.SettingsModal, {
141
+ visible: isSettingsOpen,
142
+ onClose: handleCloseSettings,
143
+ availableTools: availableTools,
144
+ onSettingsChange: newSettings => {
145
+ // Settings are already saved by the hook
146
+ console.log('Settings updated:', newSettings);
147
+ }
148
+ })]
149
+ });
150
+ }
151
+
152
+ // =============================
153
+ // Re-exports for convenience
154
+ // =============================
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.FloatingMenu = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
- var _floatingTools = require("./floatingTools.js");
10
- var _DialDevTools = require("./dial/DialDevTools.js");
9
+ var _floatingTools = require("./floatingTools");
10
+ var _DialDevTools = require("./dial/DialDevTools");
11
11
  var _sharedUi = require("@buoy-gg/shared-ui");
12
- var _DevToolsSettingsModal = require("./DevToolsSettingsModal.js");
12
+ var _DevToolsSettingsModal = require("./DevToolsSettingsModal");
13
13
  var _AppHost = require("./AppHost.js");
14
14
  var _DevToolsVisibilityContext = require("./DevToolsVisibilityContext.js");
15
15
  var _ToggleStateManager = require("./ToggleStateManager.js");
@@ -37,7 +37,7 @@ const FloatingMenu = ({
37
37
  actions,
38
38
  hidden,
39
39
  environment,
40
- userRole,
40
+ userRole = "admin",
41
41
  availableEnvironments,
42
42
  onEnvironmentSwitch
43
43
  }) => {
@@ -164,7 +164,7 @@ const FloatingMenu = ({
164
164
  // Filter function for floating tools based on settings
165
165
  const isFloatingEnabled = id => {
166
166
  if (!devToolsSettings) return false;
167
- // Default to disabled for tools without explicit preferences
167
+ // Floating tools require explicit opt-in (unlike dial tools which auto-enable)
168
168
  return devToolsSettings.floatingTools[id] ?? false;
169
169
  };
170
170
 
@@ -228,8 +228,8 @@ const FloatingMenu = ({
228
228
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_OnboardingTooltip.OnboardingTooltip, {
229
229
  visible: true,
230
230
  onDismiss: handleOnboardingDismiss,
231
- title: "Welcome to Buoy Dev Tools!",
232
- message: "Grab and position this menu wherever you want, then tap the icon to open your dev tools."
231
+ title: "Welcome to Buoy!",
232
+ message: "Grab and position this menu wherever you want, then tap the icon to open your tools."
233
233
  })]
234
234
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
235
235
  nativeID: "floating-devtools-root",
@@ -252,7 +252,7 @@ const FloatingMenu = ({
252
252
  availableEnvironments: availableEnvironments,
253
253
  onEnvironmentSwitch: onEnvironmentSwitch,
254
254
  showEnvironmentSelector: showEnvironmentSelector && devToolsSettings?.floatingTools?.environment,
255
- children: [devToolsSettings?.floatingTools?.environment && environment && !showEnvironmentSelector ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.EnvironmentIndicator, {
255
+ children: [environment && devToolsSettings?.floatingTools?.environment !== false && !showEnvironmentSelector ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.EnvironmentIndicator, {
256
256
  environment: environment
257
257
  }) : null, userRole ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_floatingTools.UserStatus, {
258
258
  userRole: userRole,
@@ -179,6 +179,21 @@ function autoDiscoverPresets() {
179
179
  return null;
180
180
  }
181
181
  }
182
+ },
183
+ // Redux DevTools
184
+ {
185
+ name: "@buoy-gg/redux",
186
+ loader: () => {
187
+ try {
188
+ // @ts-ignore - Dynamic import that may not exist
189
+ const {
190
+ reduxToolPreset
191
+ } = require("@buoy-gg/redux");
192
+ return reduxToolPreset;
193
+ } catch {
194
+ return null;
195
+ }
196
+ }
182
197
  }];
183
198
 
184
199
  // Attempt to load each preset
@@ -75,27 +75,34 @@ const MAX_DIAL_TOOLS = exports.MAX_DIAL_TOOLS = 6;
75
75
  */
76
76
 
77
77
  /**
78
- * Validates that a dial configuration doesn't exceed the maximum allowed tools.
79
- * Throws an error with helpful message if validation fails.
78
+ * Validates and normalizes a dial configuration to not exceed the maximum allowed tools.
79
+ * If more than MAX_DIAL_TOOLS are provided, logs a warning and truncates to first 6 tools.
80
80
  *
81
81
  * @param tools - Array of dial tool IDs to validate
82
- * @throws Error if more than MAX_DIAL_TOOLS are provided
82
+ * @returns The original array if valid, or truncated array if too many tools
83
83
  *
84
84
  * @example
85
85
  * ```tsx
86
- * // This is valid
86
+ * // This returns as-is
87
87
  * validateDialConfig(['env', 'network', 'storage']);
88
+ * // Returns: ['env', 'network', 'storage']
88
89
  *
89
- * // This throws an error
90
+ * // This truncates and warns
90
91
  * validateDialConfig(['env', 'network', 'storage', 'query', 'route-events', 'debug-borders', 'benchmark']);
91
- * // Error: "Dial menu default configuration has 7 tools, but maximum is 6..."
92
+ * // Console warning, returns: ['env', 'network', 'storage', 'query', 'route-events', 'debug-borders']
92
93
  * ```
93
94
  */
94
95
  function validateDialConfig(tools) {
95
96
  if (tools.length > MAX_DIAL_TOOLS) {
96
97
  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
+ // console.warn(
99
+ // `[React Buoy] Dial menu configuration has ${tools.length} tools, but maximum is ${MAX_DIAL_TOOLS}. ` +
100
+ // `Tools provided: [${toolList}]. ` +
101
+ // `Only the first ${MAX_DIAL_TOOLS} tools will be shown.`
102
+ // );
103
+ return tools.slice(0, MAX_DIAL_TOOLS);
98
104
  }
105
+ return tools;
99
106
  }
100
107
 
101
108
  /**
@@ -8,7 +8,7 @@ var _react = require("react");
8
8
  var _reactNative = require("react-native");
9
9
  var _DialIcon = require("./DialIcon.js");
10
10
  var _sharedUi = require("@buoy-gg/shared-ui");
11
- var _DevToolsSettingsModal = require("../DevToolsSettingsModal.js");
11
+ var _DevToolsSettingsModal = require("../DevToolsSettingsModal");
12
12
  var _license = require("@buoy-gg/license");
13
13
  var _AppHost = require("../AppHost.js");
14
14
  var _OnboardingTooltip = require("./OnboardingTooltip.js");
@@ -158,8 +158,14 @@ const DialDevTools = ({
158
158
 
159
159
  // Map data-driven apps to dial icons, inserting empty slots for disabled items
160
160
  const dialApps = apps.filter(a => (a.slot ?? "both") !== "row");
161
+
162
+ // Check if settings are "virgin" (user hasn't customized dial tools yet)
163
+ // If no explicit settings exist, auto-enable all dial tools by default
164
+ const dialToolsKeys = settings?.dialTools ? Object.keys(settings.dialTools) : [];
165
+ const hasDialSettings = dialToolsKeys.length > 0;
161
166
  const isDialEnabled = id => {
162
- if (!settings) return false;
167
+ // No settings or empty dialTools = auto-enable all dial tools by default
168
+ if (!settings?.dialTools || !hasDialSettings) return true;
163
169
  return settings.dialTools[id] ?? false;
164
170
  };
165
171
  const createEmptySlot = slotIndex => ({