@buoy-gg/route-events 2.1.3 → 2.1.4-beta.1
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/lib/commonjs/RouteTracker.js +32 -5
- package/lib/commonjs/components/NavigationStack.js +24 -33
- package/lib/commonjs/components/ReactNavigationRoutes.js +829 -0
- package/lib/commonjs/components/RouteEventsModalWithTabs.js +83 -6
- package/lib/commonjs/components/RoutesSitemap.js +1 -2
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/useNavigationStack.js +201 -104
- package/lib/commonjs/useRouteObserver.js +4 -4
- package/lib/commonjs/useRouteObserverReactNavigation.js +109 -0
- package/lib/module/RouteTracker.js +32 -5
- package/lib/module/components/NavigationStack.js +24 -33
- package/lib/module/components/ReactNavigationRoutes.js +825 -0
- package/lib/module/components/RouteEventsModalWithTabs.js +85 -7
- package/lib/module/components/RoutesSitemap.js +2 -2
- package/lib/module/index.js +1 -0
- package/lib/module/useNavigationStack.js +203 -106
- package/lib/module/useRouteObserver.js +4 -4
- package/lib/module/useRouteObserverReactNavigation.js +106 -0
- package/lib/typescript/RouteTracker.d.ts +18 -5
- package/lib/typescript/RouteTracker.d.ts.map +1 -1
- package/lib/typescript/components/NavigationStack.d.ts.map +1 -1
- package/lib/typescript/components/ReactNavigationRoutes.d.ts +14 -0
- package/lib/typescript/components/ReactNavigationRoutes.d.ts.map +1 -0
- package/lib/typescript/components/RouteEventsModalWithTabs.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/useNavigationStack.d.ts +9 -3
- package/lib/typescript/useNavigationStack.d.ts.map +1 -1
- package/lib/typescript/useRouteObserver.d.ts.map +1 -1
- package/lib/typescript/useRouteObserverReactNavigation.d.ts +19 -0
- package/lib/typescript/useRouteObserverReactNavigation.d.ts.map +1 -0
- package/package.json +6 -6
- package/lib/commonjs/utils/safeExpoRouter.js +0 -129
- package/lib/module/utils/safeExpoRouter.js +0 -120
- package/lib/typescript/utils/safeExpoRouter.d.ts +0 -13
- package/lib/typescript/utils/safeExpoRouter.d.ts.map +0 -1
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* RouteTracker - A component to place inside your navigation tree
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Automatically detects whether Expo Router or React Navigation is available
|
|
7
|
+
* and uses the appropriate route observation method.
|
|
8
8
|
*
|
|
9
9
|
* IMPORTANT: This component MUST be placed inside your navigation tree
|
|
10
|
-
* (as a child of Stack, Tabs, or
|
|
10
|
+
* (as a child of Stack, Tabs, Slot, or NavigationContainer) for route tracking to work.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```tsx
|
|
14
|
-
* //
|
|
14
|
+
* // Expo Router - in your _layout.tsx
|
|
15
15
|
* import { RouteTracker } from '@buoy-gg/route-events';
|
|
16
16
|
*
|
|
17
17
|
* export default function RootLayout() {
|
|
@@ -25,11 +25,38 @@
|
|
|
25
25
|
* </>
|
|
26
26
|
* );
|
|
27
27
|
* }
|
|
28
|
+
*
|
|
29
|
+
* // React Navigation (RN CLI) - inside NavigationContainer
|
|
30
|
+
* import { RouteTracker } from '@buoy-gg/route-events';
|
|
31
|
+
*
|
|
32
|
+
* function App() {
|
|
33
|
+
* return (
|
|
34
|
+
* <NavigationContainer>
|
|
35
|
+
* <RootNavigator />
|
|
36
|
+
* <RouteTracker />
|
|
37
|
+
* <FloatingDevTools ... />
|
|
38
|
+
* </NavigationContainer>
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
28
41
|
* ```
|
|
29
42
|
*/
|
|
30
43
|
|
|
44
|
+
import { isExpoRouterAvailable } from "@buoy-gg/shared-ui";
|
|
31
45
|
import { useRouteObserver } from "./useRouteObserver";
|
|
32
|
-
|
|
46
|
+
import { useRouteObserverReactNavigation } from "./useRouteObserverReactNavigation";
|
|
47
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
48
|
+
function ExpoRouteTracker() {
|
|
33
49
|
useRouteObserver();
|
|
34
50
|
return null;
|
|
51
|
+
}
|
|
52
|
+
function ReactNavigationRouteTracker() {
|
|
53
|
+
useRouteObserverReactNavigation();
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
export function RouteTracker() {
|
|
57
|
+
const hasExpo = isExpoRouterAvailable();
|
|
58
|
+
if (hasExpo) {
|
|
59
|
+
return /*#__PURE__*/_jsx(ExpoRouteTracker, {});
|
|
60
|
+
}
|
|
61
|
+
return /*#__PURE__*/_jsx(ReactNavigationRouteTracker, {});
|
|
35
62
|
}
|
|
@@ -13,7 +13,6 @@ import { ChevronDown, ChevronRight, Info, InlineCopyButton, ProUpgradeModal, buo
|
|
|
13
13
|
import { useIsPro } from "@buoy-gg/license";
|
|
14
14
|
import { DataViewer } from "@buoy-gg/shared-ui/dataViewer";
|
|
15
15
|
import { useNavigationStack } from "../useNavigationStack";
|
|
16
|
-
import { useRouter } from "expo-router";
|
|
17
16
|
|
|
18
17
|
// ============================================================================
|
|
19
18
|
// Types
|
|
@@ -37,7 +36,6 @@ export function NavigationStack({
|
|
|
37
36
|
goBack,
|
|
38
37
|
popToTop
|
|
39
38
|
} = useNavigationStack();
|
|
40
|
-
const router = useRouter();
|
|
41
39
|
const [expandedIndex, setExpandedIndex] = useState(null);
|
|
42
40
|
const [showHelp, setShowHelp] = useState(false);
|
|
43
41
|
const [showUpgradeModal, setShowUpgradeModal] = useState(false);
|
|
@@ -226,7 +224,9 @@ export function NavigationStack({
|
|
|
226
224
|
})]
|
|
227
225
|
}), /*#__PURE__*/_jsx(ScrollView, {
|
|
228
226
|
style: styles.stackScroll,
|
|
229
|
-
contentContainerStyle: styles.stackContent,
|
|
227
|
+
contentContainerStyle: [styles.stackContent, {
|
|
228
|
+
paddingBottom: showHelp ? 72 : 56
|
|
229
|
+
}],
|
|
230
230
|
children: [...stack].reverse().map((item, reverseIndex) => {
|
|
231
231
|
const actualIndex = stack.length - 1 - reverseIndex;
|
|
232
232
|
const isExpanded = expandedIndex === actualIndex;
|
|
@@ -255,17 +255,16 @@ export function NavigationStack({
|
|
|
255
255
|
}), /*#__PURE__*/_jsx(InlineCopyButton, {
|
|
256
256
|
value: item.pathname,
|
|
257
257
|
buttonStyle: styles.copyRouteButton
|
|
258
|
-
}),
|
|
259
|
-
style: styles.
|
|
258
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
259
|
+
style: [styles.statusBadge, {
|
|
260
|
+
backgroundColor: item.isFocused ? `${buoyColors.success}15` : "#3B82F615",
|
|
261
|
+
borderColor: item.isFocused ? `${buoyColors.success}40` : "#3B82F640"
|
|
262
|
+
}],
|
|
260
263
|
children: /*#__PURE__*/_jsx(Text, {
|
|
261
|
-
style: styles.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
style: styles.memoryBadge,
|
|
266
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
267
|
-
style: styles.memoryBadgeText,
|
|
268
|
-
children: "MEMORY"
|
|
264
|
+
style: [styles.statusBadgeText, {
|
|
265
|
+
color: item.isFocused ? buoyColors.success : "#3B82F6"
|
|
266
|
+
}],
|
|
267
|
+
children: item.isFocused ? "FOCUSED" : "MOUNTED"
|
|
269
268
|
})
|
|
270
269
|
})]
|
|
271
270
|
}), isExpanded && /*#__PURE__*/_jsxs(View, {
|
|
@@ -472,28 +471,15 @@ const styles = StyleSheet.create({
|
|
|
472
471
|
padding: 4,
|
|
473
472
|
marginLeft: 4
|
|
474
473
|
},
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
paddingHorizontal:
|
|
478
|
-
paddingVertical:
|
|
479
|
-
|
|
480
|
-
},
|
|
481
|
-
focusedBadgeText: {
|
|
482
|
-
fontSize: 9,
|
|
483
|
-
fontWeight: "700",
|
|
484
|
-
color: buoyColors.base,
|
|
485
|
-
fontFamily: "monospace"
|
|
486
|
-
},
|
|
487
|
-
memoryBadge: {
|
|
488
|
-
backgroundColor: buoyColors.input,
|
|
489
|
-
paddingHorizontal: 8,
|
|
490
|
-
paddingVertical: 3,
|
|
491
|
-
borderRadius: 4
|
|
474
|
+
statusBadge: {
|
|
475
|
+
borderRadius: 4,
|
|
476
|
+
paddingHorizontal: 6,
|
|
477
|
+
paddingVertical: 2,
|
|
478
|
+
borderWidth: 1
|
|
492
479
|
},
|
|
493
|
-
|
|
494
|
-
fontSize:
|
|
480
|
+
statusBadgeText: {
|
|
481
|
+
fontSize: 10,
|
|
495
482
|
fontWeight: "600",
|
|
496
|
-
color: buoyColors.textSecondary,
|
|
497
483
|
fontFamily: "monospace"
|
|
498
484
|
},
|
|
499
485
|
expandedContent: {
|
|
@@ -523,8 +509,13 @@ const styles = StyleSheet.create({
|
|
|
523
509
|
marginBottom: 8
|
|
524
510
|
},
|
|
525
511
|
actionsContainer: {
|
|
512
|
+
position: "absolute",
|
|
513
|
+
left: 0,
|
|
514
|
+
right: 0,
|
|
515
|
+
bottom: 0,
|
|
526
516
|
borderTopWidth: 1,
|
|
527
517
|
borderTopColor: buoyColors.border,
|
|
518
|
+
backgroundColor: buoyColors.base,
|
|
528
519
|
paddingHorizontal: 8,
|
|
529
520
|
paddingTop: 8,
|
|
530
521
|
paddingBottom: 8
|