@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.
- package/README.md +43 -0
- package/lib/commonjs/floatingMenu/AppHost.js +410 -0
- package/lib/commonjs/floatingMenu/AppHostLogic.js +44 -0
- package/lib/commonjs/floatingMenu/DefaultConfigContext.js +45 -0
- package/lib/commonjs/floatingMenu/DevToolsSettingsModal.js +2274 -0
- package/lib/commonjs/floatingMenu/DevToolsVisibilityContext.js +49 -0
- package/lib/commonjs/floatingMenu/DraggableHeader.js +114 -0
- package/lib/commonjs/floatingMenu/FloatingDevTools.js +254 -0
- package/lib/commonjs/floatingMenu/FloatingMenu.js +364 -0
- package/lib/commonjs/floatingMenu/MinimizedToolsContext.js +247 -0
- package/lib/commonjs/floatingMenu/MinimizedToolsStack.js +206 -0
- package/lib/commonjs/floatingMenu/ToggleStateManager.js +36 -0
- package/lib/commonjs/floatingMenu/autoDiscoverPresets.js +241 -0
- package/lib/commonjs/floatingMenu/defaultConfig.js +160 -0
- package/lib/commonjs/floatingMenu/dial/DialDevTools.js +835 -0
- package/lib/commonjs/floatingMenu/dial/DialIcon.js +246 -0
- package/lib/commonjs/floatingMenu/dial/OnboardingTooltip.js +249 -0
- package/lib/commonjs/floatingMenu/dial/onboardingConstants.js +70 -0
- package/lib/commonjs/floatingMenu/floatingTools.js +771 -0
- package/lib/commonjs/floatingMenu/settingsBus.js +23 -0
- package/lib/commonjs/floatingMenu/types.js +5 -0
- package/lib/commonjs/index.js +240 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/floatingMenu/AppHost.js +402 -0
- package/lib/module/floatingMenu/AppHostLogic.js +39 -0
- package/lib/module/floatingMenu/DefaultConfigContext.js +39 -0
- package/lib/module/floatingMenu/DevToolsSettingsModal.js +2273 -0
- package/lib/module/floatingMenu/DevToolsVisibilityContext.js +44 -0
- package/lib/module/floatingMenu/DraggableHeader.js +110 -0
- package/lib/module/floatingMenu/FloatingDevTools.js +249 -0
- package/lib/module/floatingMenu/FloatingMenu.js +358 -0
- package/lib/module/floatingMenu/MinimizedToolsContext.js +239 -0
- package/lib/module/floatingMenu/MinimizedToolsStack.js +202 -0
- package/lib/module/floatingMenu/ToggleStateManager.js +32 -0
- package/lib/module/floatingMenu/autoDiscoverPresets.js +236 -0
- package/lib/module/floatingMenu/defaultConfig.js +151 -0
- package/lib/module/floatingMenu/dial/DialDevTools.js +829 -0
- package/lib/module/floatingMenu/dial/DialIcon.js +241 -0
- package/lib/module/floatingMenu/dial/OnboardingTooltip.js +244 -0
- package/lib/module/floatingMenu/dial/onboardingConstants.js +64 -0
- package/lib/module/floatingMenu/floatingTools.js +767 -0
- package/lib/module/floatingMenu/settingsBus.js +19 -0
- package/lib/module/floatingMenu/types.js +3 -0
- package/lib/module/index.js +29 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/floatingMenu/AppHost.d.ts +39 -0
- package/lib/typescript/commonjs/floatingMenu/AppHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/AppHostLogic.d.ts +37 -0
- package/lib/typescript/commonjs/floatingMenu/AppHostLogic.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/DefaultConfigContext.d.ts +27 -0
- package/lib/typescript/commonjs/floatingMenu/DefaultConfigContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/DevToolsSettingsModal.d.ts +57 -0
- package/lib/typescript/commonjs/floatingMenu/DevToolsSettingsModal.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/DevToolsVisibilityContext.d.ts +25 -0
- package/lib/typescript/commonjs/floatingMenu/DevToolsVisibilityContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/DraggableHeader.d.ts +30 -0
- package/lib/typescript/commonjs/floatingMenu/DraggableHeader.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.d.ts +226 -0
- package/lib/typescript/commonjs/floatingMenu/FloatingDevTools.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/FloatingMenu.d.ts +39 -0
- package/lib/typescript/commonjs/floatingMenu/FloatingMenu.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/MinimizedToolsContext.d.ts +95 -0
- package/lib/typescript/commonjs/floatingMenu/MinimizedToolsContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/MinimizedToolsStack.d.ts +10 -0
- package/lib/typescript/commonjs/floatingMenu/MinimizedToolsStack.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/ToggleStateManager.d.ts +21 -0
- package/lib/typescript/commonjs/floatingMenu/ToggleStateManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/autoDiscoverPresets.d.ts +75 -0
- package/lib/typescript/commonjs/floatingMenu/autoDiscoverPresets.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/defaultConfig.d.ts +120 -0
- package/lib/typescript/commonjs/floatingMenu/defaultConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/dial/DialDevTools.d.ts +35 -0
- package/lib/typescript/commonjs/floatingMenu/dial/DialDevTools.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/dial/DialIcon.d.ts +14 -0
- package/lib/typescript/commonjs/floatingMenu/dial/DialIcon.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/dial/OnboardingTooltip.d.ts +12 -0
- package/lib/typescript/commonjs/floatingMenu/dial/OnboardingTooltip.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/dial/onboardingConstants.d.ts +30 -0
- package/lib/typescript/commonjs/floatingMenu/dial/onboardingConstants.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/floatingTools.d.ts +56 -0
- package/lib/typescript/commonjs/floatingMenu/floatingTools.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/settingsBus.d.ts +10 -0
- package/lib/typescript/commonjs/floatingMenu/settingsBus.d.ts.map +1 -0
- package/lib/typescript/commonjs/floatingMenu/types.d.ts +56 -0
- package/lib/typescript/commonjs/floatingMenu/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +18 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/module/floatingMenu/AppHost.d.ts +39 -0
- package/lib/typescript/module/floatingMenu/AppHost.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/AppHostLogic.d.ts +37 -0
- package/lib/typescript/module/floatingMenu/AppHostLogic.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/DefaultConfigContext.d.ts +27 -0
- package/lib/typescript/module/floatingMenu/DefaultConfigContext.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/DevToolsSettingsModal.d.ts +57 -0
- package/lib/typescript/module/floatingMenu/DevToolsSettingsModal.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/DevToolsVisibilityContext.d.ts +25 -0
- package/lib/typescript/module/floatingMenu/DevToolsVisibilityContext.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/DraggableHeader.d.ts +30 -0
- package/lib/typescript/module/floatingMenu/DraggableHeader.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/FloatingDevTools.d.ts +226 -0
- package/lib/typescript/module/floatingMenu/FloatingDevTools.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/FloatingMenu.d.ts +39 -0
- package/lib/typescript/module/floatingMenu/FloatingMenu.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/MinimizedToolsContext.d.ts +95 -0
- package/lib/typescript/module/floatingMenu/MinimizedToolsContext.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/MinimizedToolsStack.d.ts +10 -0
- package/lib/typescript/module/floatingMenu/MinimizedToolsStack.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/ToggleStateManager.d.ts +21 -0
- package/lib/typescript/module/floatingMenu/ToggleStateManager.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/autoDiscoverPresets.d.ts +75 -0
- package/lib/typescript/module/floatingMenu/autoDiscoverPresets.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/defaultConfig.d.ts +120 -0
- package/lib/typescript/module/floatingMenu/defaultConfig.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/dial/DialDevTools.d.ts +35 -0
- package/lib/typescript/module/floatingMenu/dial/DialDevTools.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/dial/DialIcon.d.ts +14 -0
- package/lib/typescript/module/floatingMenu/dial/DialIcon.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/dial/OnboardingTooltip.d.ts +12 -0
- package/lib/typescript/module/floatingMenu/dial/OnboardingTooltip.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/dial/onboardingConstants.d.ts +30 -0
- package/lib/typescript/module/floatingMenu/dial/onboardingConstants.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/floatingTools.d.ts +56 -0
- package/lib/typescript/module/floatingMenu/floatingTools.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/settingsBus.d.ts +10 -0
- package/lib/typescript/module/floatingMenu/settingsBus.d.ts.map +1 -0
- package/lib/typescript/module/floatingMenu/types.d.ts +56 -0
- package/lib/typescript/module/floatingMenu/types.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +18 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* DevToolsVisibilityContext
|
|
5
|
+
*
|
|
6
|
+
* Tracks when DevTools UI is visible (dial menu, modals, etc.)
|
|
7
|
+
* Used by other tools (like debug borders) to hide when DevTools are active
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { createContext, useContext, useState, useMemo } from "react";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
const DevToolsVisibilityContext = /*#__PURE__*/createContext(null);
|
|
13
|
+
export function DevToolsVisibilityProvider({
|
|
14
|
+
children
|
|
15
|
+
}) {
|
|
16
|
+
const [isDialOpen, setDialOpen] = useState(false);
|
|
17
|
+
const [isToolOpen, setToolOpen] = useState(false);
|
|
18
|
+
const isDevToolsActive = useMemo(() => isDialOpen || isToolOpen, [isDialOpen, isToolOpen]);
|
|
19
|
+
const value = useMemo(() => ({
|
|
20
|
+
isDialOpen,
|
|
21
|
+
isToolOpen,
|
|
22
|
+
isDevToolsActive,
|
|
23
|
+
setDialOpen,
|
|
24
|
+
setToolOpen
|
|
25
|
+
}), [isDialOpen, isToolOpen, isDevToolsActive]);
|
|
26
|
+
return /*#__PURE__*/_jsx(DevToolsVisibilityContext.Provider, {
|
|
27
|
+
value: value,
|
|
28
|
+
children: children
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export function useDevToolsVisibility() {
|
|
32
|
+
const context = useContext(DevToolsVisibilityContext);
|
|
33
|
+
if (!context) {
|
|
34
|
+
// Return safe defaults if not within provider
|
|
35
|
+
return {
|
|
36
|
+
isDialOpen: false,
|
|
37
|
+
isToolOpen: false,
|
|
38
|
+
isDevToolsActive: false,
|
|
39
|
+
setDialOpen: () => {},
|
|
40
|
+
setToolOpen: () => {}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return context;
|
|
44
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useRef, useMemo, memo } from 'react';
|
|
4
|
+
import { View, PanResponder, Dimensions } from 'react-native';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export const DraggableHeader = /*#__PURE__*/memo(function DraggableHeader({
|
|
7
|
+
children,
|
|
8
|
+
position,
|
|
9
|
+
onDragStart,
|
|
10
|
+
onDragEnd,
|
|
11
|
+
onTap,
|
|
12
|
+
containerBounds = Dimensions.get('window'),
|
|
13
|
+
elementSize = {
|
|
14
|
+
width: 100,
|
|
15
|
+
height: 50
|
|
16
|
+
},
|
|
17
|
+
minPosition = {
|
|
18
|
+
x: 0,
|
|
19
|
+
y: 0
|
|
20
|
+
},
|
|
21
|
+
style,
|
|
22
|
+
enabled = true,
|
|
23
|
+
maxOverflowX = 0
|
|
24
|
+
}) {
|
|
25
|
+
const isDraggingRef = useRef(false);
|
|
26
|
+
const dragDistanceRef = useRef(0);
|
|
27
|
+
const touchOffsetRef = useRef({
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0
|
|
30
|
+
});
|
|
31
|
+
const startPositionRef = useRef({
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0
|
|
34
|
+
});
|
|
35
|
+
const panResponder = useMemo(() => PanResponder.create({
|
|
36
|
+
onStartShouldSetPanResponder: () => enabled,
|
|
37
|
+
onMoveShouldSetPanResponder: (_, g) => enabled && (Math.abs(g.dx) > 1 || Math.abs(g.dy) > 1),
|
|
38
|
+
onPanResponderTerminationRequest: () => false,
|
|
39
|
+
onPanResponderGrant: evt => {
|
|
40
|
+
isDraggingRef.current = false;
|
|
41
|
+
dragDistanceRef.current = 0;
|
|
42
|
+
touchOffsetRef.current = {
|
|
43
|
+
x: evt.nativeEvent.locationX,
|
|
44
|
+
y: evt.nativeEvent.locationY
|
|
45
|
+
};
|
|
46
|
+
// Capture starting position in parent coords; avoid relying on window pageX/pageY
|
|
47
|
+
position.stopAnimation(({
|
|
48
|
+
x,
|
|
49
|
+
y
|
|
50
|
+
}) => {
|
|
51
|
+
startPositionRef.current = {
|
|
52
|
+
x,
|
|
53
|
+
y
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
onPanResponderMove: (_evt, gestureState) => {
|
|
58
|
+
const totalDistance = Math.abs(gestureState.dx) + Math.abs(gestureState.dy);
|
|
59
|
+
dragDistanceRef.current = totalDistance;
|
|
60
|
+
if (totalDistance > 5 && !isDraggingRef.current) {
|
|
61
|
+
isDraggingRef.current = true;
|
|
62
|
+
onDragStart?.();
|
|
63
|
+
}
|
|
64
|
+
// Use dx/dy relative movement so parent padding/margins don't affect dragging
|
|
65
|
+
const x = startPositionRef.current.x + gestureState.dx;
|
|
66
|
+
const y = startPositionRef.current.y + gestureState.dy;
|
|
67
|
+
position.setValue({
|
|
68
|
+
x,
|
|
69
|
+
y
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
onPanResponderRelease: () => {
|
|
73
|
+
// Check if this was a tap (minimal movement) before doing anything else
|
|
74
|
+
const wasTap = dragDistanceRef.current <= 5 && !isDraggingRef.current;
|
|
75
|
+
if (wasTap) {
|
|
76
|
+
// For taps, just call the tap handler immediately - no position manipulation needed
|
|
77
|
+
onTap?.();
|
|
78
|
+
isDraggingRef.current = false;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// For drags, get the final position and clamp it
|
|
83
|
+
position.stopAnimation(({
|
|
84
|
+
x: currentX,
|
|
85
|
+
y: currentY
|
|
86
|
+
}) => {
|
|
87
|
+
const maxX = containerBounds.width - elementSize.width + maxOverflowX;
|
|
88
|
+
const clampedX = Math.max(minPosition.x, Math.min(currentX, maxX));
|
|
89
|
+
const clampedY = Math.max(minPosition.y, Math.min(currentY, containerBounds.height - elementSize.height));
|
|
90
|
+
position.setValue({
|
|
91
|
+
x: clampedX,
|
|
92
|
+
y: clampedY
|
|
93
|
+
});
|
|
94
|
+
onDragEnd?.({
|
|
95
|
+
x: clampedX,
|
|
96
|
+
y: clampedY
|
|
97
|
+
});
|
|
98
|
+
isDraggingRef.current = false;
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
onPanResponderTerminate: () => {
|
|
102
|
+
isDraggingRef.current = false;
|
|
103
|
+
}
|
|
104
|
+
}), [enabled, position, onDragStart, onDragEnd, onTap, containerBounds, elementSize, minPosition, maxOverflowX]);
|
|
105
|
+
return /*#__PURE__*/_jsx(View, {
|
|
106
|
+
style: style,
|
|
107
|
+
...panResponder.panHandlers,
|
|
108
|
+
children: children
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useMemo, useCallback, useEffect } from "react";
|
|
4
|
+
import { View, StyleSheet } from "react-native";
|
|
5
|
+
import { AppHostProvider } from "./AppHost.js";
|
|
6
|
+
import { FloatingMenu } from "./FloatingMenu.js";
|
|
7
|
+
import { AppOverlay } from "./AppHost.js";
|
|
8
|
+
import { autoDiscoverPresets, autoDiscoverPresetsWithCustom } from "./autoDiscoverPresets.js";
|
|
9
|
+
import { DevToolsVisibilityProvider } from "./DevToolsVisibilityContext.js";
|
|
10
|
+
import { HintsProvider } from "@buoy-gg/shared-ui";
|
|
11
|
+
import { MinimizedToolsProvider } from "./MinimizedToolsContext.js";
|
|
12
|
+
import { validateDialConfig } from "./defaultConfig.js";
|
|
13
|
+
import { DefaultConfigProvider } from "./DefaultConfigContext.js";
|
|
14
|
+
import { LicenseManager } from "@buoy-gg/license";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Environment variable configuration
|
|
18
|
+
*
|
|
19
|
+
* This type is compatible with RequiredEnvVar from @buoy-gg/env
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* // Simple string (just check existence)
|
|
24
|
+
* "API_URL"
|
|
25
|
+
*
|
|
26
|
+
* // Check for specific type
|
|
27
|
+
* { key: "DEBUG_MODE", expectedType: "boolean" }
|
|
28
|
+
*
|
|
29
|
+
* // Check for specific value
|
|
30
|
+
* { key: "ENVIRONMENT", expectedValue: "development" }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Storage key configuration for monitoring
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Props for FloatingDevTools component.
|
|
40
|
+
* Apps prop is optional - if not provided, all installed dev tools are auto-discovered.
|
|
41
|
+
*/
|
|
42
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
43
|
+
/**
|
|
44
|
+
* Unified floating development tools component with automatic preset discovery.
|
|
45
|
+
*
|
|
46
|
+
* This component combines AppHostProvider, FloatingMenu, and AppOverlay
|
|
47
|
+
* into a single component for simplified setup and better developer experience.
|
|
48
|
+
*
|
|
49
|
+
* **Zero-Config Usage:**
|
|
50
|
+
* ```tsx
|
|
51
|
+
* <FloatingDevTools environment="local" userRole="admin" />
|
|
52
|
+
* // All installed dev tools automatically appear!
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* **With Team Default Configuration (Type-Safe!):**
|
|
56
|
+
* ```tsx
|
|
57
|
+
* // Set which tools are enabled by default for your team
|
|
58
|
+
* <FloatingDevTools
|
|
59
|
+
* // Floating bubble: ENV badge + WiFi toggle
|
|
60
|
+
* defaultFloatingTools={['env', 'environment', 'query-wifi-toggle']}
|
|
61
|
+
* // Dial menu: your team's 6 favorite tools (max 6!)
|
|
62
|
+
* defaultDialTools={['env', 'network', 'storage', 'query', 'route-events', 'debug-borders']}
|
|
63
|
+
* environment="local"
|
|
64
|
+
* userRole="admin"
|
|
65
|
+
* />
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* **With Validation (Super Simple!):**
|
|
69
|
+
* ```tsx
|
|
70
|
+
* <FloatingDevTools
|
|
71
|
+
* requiredEnvVars={[
|
|
72
|
+
* "API_URL", // Just check existence
|
|
73
|
+
* { key: "DEBUG_MODE", expectedType: "boolean" },
|
|
74
|
+
* ]}
|
|
75
|
+
* requiredStorageKeys={[
|
|
76
|
+
* { key: "@app/session", storageType: "async" },
|
|
77
|
+
* ]}
|
|
78
|
+
* environment="local"
|
|
79
|
+
* userRole="admin"
|
|
80
|
+
* />
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* **With Custom Tools:**
|
|
84
|
+
* ```tsx
|
|
85
|
+
* <FloatingDevTools
|
|
86
|
+
* apps={[myCustomTool]}
|
|
87
|
+
* environment="local"
|
|
88
|
+
* userRole="admin"
|
|
89
|
+
* />
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* The component is absolutely positioned to float on top of your application
|
|
93
|
+
* regardless of where it's placed in the component tree.
|
|
94
|
+
*
|
|
95
|
+
* @param props - FloatingDevTools props
|
|
96
|
+
*/
|
|
97
|
+
export const FloatingDevTools = ({
|
|
98
|
+
apps,
|
|
99
|
+
requiredEnvVars,
|
|
100
|
+
requiredStorageKeys,
|
|
101
|
+
children,
|
|
102
|
+
disableHints = false,
|
|
103
|
+
defaultFloatingTools,
|
|
104
|
+
defaultDialTools,
|
|
105
|
+
...props
|
|
106
|
+
}) => {
|
|
107
|
+
// Initialize license manager on mount
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
LicenseManager.initialize();
|
|
110
|
+
}, []);
|
|
111
|
+
|
|
112
|
+
// Validate dial tools configuration on mount (development-time check)
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (defaultDialTools) {
|
|
115
|
+
validateDialConfig(defaultDialTools);
|
|
116
|
+
}
|
|
117
|
+
}, [defaultDialTools]);
|
|
118
|
+
|
|
119
|
+
// Build config overrides if requiredEnvVars or requiredStorageKeys are provided
|
|
120
|
+
const configOverrides = useMemo(() => {
|
|
121
|
+
const overrides = [];
|
|
122
|
+
|
|
123
|
+
// If requiredEnvVars provided, create ENV tool config
|
|
124
|
+
if (requiredEnvVars && requiredEnvVars.length > 0) {
|
|
125
|
+
try {
|
|
126
|
+
const {
|
|
127
|
+
createEnvTool,
|
|
128
|
+
createEnvVarConfig
|
|
129
|
+
} = require("@buoy-gg/env");
|
|
130
|
+
// Convert simple format to the internal format
|
|
131
|
+
overrides.push(createEnvTool({
|
|
132
|
+
requiredEnvVars: createEnvVarConfig(requiredEnvVars)
|
|
133
|
+
}));
|
|
134
|
+
} catch (error) {
|
|
135
|
+
// Package not installed, skip
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// If requiredStorageKeys provided, create Storage tool config
|
|
140
|
+
if (requiredStorageKeys && requiredStorageKeys.length > 0) {
|
|
141
|
+
try {
|
|
142
|
+
const {
|
|
143
|
+
createStorageTool
|
|
144
|
+
} = require("@buoy-gg/storage");
|
|
145
|
+
overrides.push(createStorageTool({
|
|
146
|
+
requiredStorageKeys
|
|
147
|
+
}));
|
|
148
|
+
} catch (error) {
|
|
149
|
+
// Package not installed, skip
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return overrides;
|
|
153
|
+
}, [requiredEnvVars, requiredStorageKeys]);
|
|
154
|
+
|
|
155
|
+
// Combine user apps with config overrides
|
|
156
|
+
const userApps = useMemo(() => {
|
|
157
|
+
if (!apps && configOverrides.length === 0) return undefined;
|
|
158
|
+
return [...(apps || []), ...configOverrides];
|
|
159
|
+
}, [apps, configOverrides]);
|
|
160
|
+
|
|
161
|
+
// Always auto-discover, then merge with any user-provided apps or config overrides
|
|
162
|
+
// User-provided apps and config overrides take precedence (by ID)
|
|
163
|
+
const finalApps = userApps ? autoDiscoverPresetsWithCustom(userApps) : autoDiscoverPresets();
|
|
164
|
+
|
|
165
|
+
// Check if debug-borders is installed and auto-render the overlay
|
|
166
|
+
const DebugBordersOverlay = useMemo(() => {
|
|
167
|
+
try {
|
|
168
|
+
// @ts-ignore - Dynamic import that may not exist
|
|
169
|
+
const {
|
|
170
|
+
DebugBordersStandaloneOverlay
|
|
171
|
+
} = require("@buoy-gg/debug-borders");
|
|
172
|
+
return DebugBordersStandaloneOverlay;
|
|
173
|
+
} catch {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
}, []);
|
|
177
|
+
|
|
178
|
+
// Check if highlight-updates is installed and auto-render the overlay
|
|
179
|
+
const HighlightUpdatesOverlay = useMemo(() => {
|
|
180
|
+
try {
|
|
181
|
+
// @ts-ignore - Dynamic import that may not exist
|
|
182
|
+
const {
|
|
183
|
+
HighlightUpdatesOverlay: Overlay
|
|
184
|
+
} = require("@buoy-gg/highlight-updates");
|
|
185
|
+
return Overlay;
|
|
186
|
+
} catch {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
}, []);
|
|
190
|
+
|
|
191
|
+
// Check if route-events is installed and auto-render the RouteTracker
|
|
192
|
+
// This enables automatic route tracking without requiring users to add <RouteTracker /> manually
|
|
193
|
+
const RouteTracker = useMemo(() => {
|
|
194
|
+
try {
|
|
195
|
+
// @ts-ignore - Dynamic import that may not exist
|
|
196
|
+
const {
|
|
197
|
+
RouteTracker: Tracker
|
|
198
|
+
} = require("@buoy-gg/route-events");
|
|
199
|
+
return Tracker;
|
|
200
|
+
} catch {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
}, []);
|
|
204
|
+
|
|
205
|
+
// Get tool icon helper for the MinimizedToolsProvider
|
|
206
|
+
const getToolIcon = useCallback(id => {
|
|
207
|
+
const tool = finalApps.find(app => app.id === id);
|
|
208
|
+
if (!tool) return null;
|
|
209
|
+
if (typeof tool.icon === "function") {
|
|
210
|
+
return tool.icon({
|
|
211
|
+
slot: "dial",
|
|
212
|
+
size: 20
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return tool.icon;
|
|
216
|
+
}, [finalApps]);
|
|
217
|
+
return /*#__PURE__*/_jsx(DefaultConfigProvider, {
|
|
218
|
+
defaultFloatingTools: defaultFloatingTools,
|
|
219
|
+
defaultDialTools: defaultDialTools,
|
|
220
|
+
children: /*#__PURE__*/_jsx(HintsProvider, {
|
|
221
|
+
disableHints: disableHints,
|
|
222
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
223
|
+
style: styles.container,
|
|
224
|
+
pointerEvents: "box-none",
|
|
225
|
+
children: /*#__PURE__*/_jsxs(DevToolsVisibilityProvider, {
|
|
226
|
+
children: [/*#__PURE__*/_jsx(AppHostProvider, {
|
|
227
|
+
children: /*#__PURE__*/_jsxs(MinimizedToolsProvider, {
|
|
228
|
+
getToolIcon: getToolIcon,
|
|
229
|
+
children: [/*#__PURE__*/_jsx(FloatingMenu, {
|
|
230
|
+
...props,
|
|
231
|
+
apps: finalApps
|
|
232
|
+
}), /*#__PURE__*/_jsx(AppOverlay, {})]
|
|
233
|
+
})
|
|
234
|
+
}), children, DebugBordersOverlay && /*#__PURE__*/_jsx(DebugBordersOverlay, {}), HighlightUpdatesOverlay && /*#__PURE__*/_jsx(HighlightUpdatesOverlay, {}), RouteTracker && /*#__PURE__*/_jsx(RouteTracker, {})]
|
|
235
|
+
})
|
|
236
|
+
})
|
|
237
|
+
})
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
const styles = StyleSheet.create({
|
|
241
|
+
container: {
|
|
242
|
+
position: "absolute",
|
|
243
|
+
top: 0,
|
|
244
|
+
left: 0,
|
|
245
|
+
right: 0,
|
|
246
|
+
bottom: 0,
|
|
247
|
+
zIndex: 9999
|
|
248
|
+
}
|
|
249
|
+
});
|