@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.
Files changed (36) hide show
  1. package/lib/commonjs/RouteTracker.js +32 -5
  2. package/lib/commonjs/components/NavigationStack.js +24 -33
  3. package/lib/commonjs/components/ReactNavigationRoutes.js +829 -0
  4. package/lib/commonjs/components/RouteEventsModalWithTabs.js +83 -6
  5. package/lib/commonjs/components/RoutesSitemap.js +1 -2
  6. package/lib/commonjs/index.js +7 -0
  7. package/lib/commonjs/useNavigationStack.js +201 -104
  8. package/lib/commonjs/useRouteObserver.js +4 -4
  9. package/lib/commonjs/useRouteObserverReactNavigation.js +109 -0
  10. package/lib/module/RouteTracker.js +32 -5
  11. package/lib/module/components/NavigationStack.js +24 -33
  12. package/lib/module/components/ReactNavigationRoutes.js +825 -0
  13. package/lib/module/components/RouteEventsModalWithTabs.js +85 -7
  14. package/lib/module/components/RoutesSitemap.js +2 -2
  15. package/lib/module/index.js +1 -0
  16. package/lib/module/useNavigationStack.js +203 -106
  17. package/lib/module/useRouteObserver.js +4 -4
  18. package/lib/module/useRouteObserverReactNavigation.js +106 -0
  19. package/lib/typescript/RouteTracker.d.ts +18 -5
  20. package/lib/typescript/RouteTracker.d.ts.map +1 -1
  21. package/lib/typescript/components/NavigationStack.d.ts.map +1 -1
  22. package/lib/typescript/components/ReactNavigationRoutes.d.ts +14 -0
  23. package/lib/typescript/components/ReactNavigationRoutes.d.ts.map +1 -0
  24. package/lib/typescript/components/RouteEventsModalWithTabs.d.ts.map +1 -1
  25. package/lib/typescript/index.d.ts +1 -0
  26. package/lib/typescript/index.d.ts.map +1 -1
  27. package/lib/typescript/useNavigationStack.d.ts +9 -3
  28. package/lib/typescript/useNavigationStack.d.ts.map +1 -1
  29. package/lib/typescript/useRouteObserver.d.ts.map +1 -1
  30. package/lib/typescript/useRouteObserverReactNavigation.d.ts +19 -0
  31. package/lib/typescript/useRouteObserverReactNavigation.d.ts.map +1 -0
  32. package/package.json +6 -6
  33. package/lib/commonjs/utils/safeExpoRouter.js +0 -129
  34. package/lib/module/utils/safeExpoRouter.js +0 -120
  35. package/lib/typescript/utils/safeExpoRouter.d.ts +0 -13
  36. package/lib/typescript/utils/safeExpoRouter.d.ts.map +0 -1
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * RouteTracker - A component to place inside your navigation tree
3
3
  *
4
- * This component calls useRouteObserver() which uses expo-router hooks
5
- * (usePathname, useSegments, etc.) to track navigation changes.
4
+ * Automatically detects whether Expo Router or React Navigation is available
5
+ * and uses the appropriate route observation method.
6
6
  *
7
7
  * IMPORTANT: This component MUST be placed inside your navigation tree
8
- * (as a child of Stack, Tabs, or Slot) for route tracking to work.
8
+ * (as a child of Stack, Tabs, Slot, or NavigationContainer) for route tracking to work.
9
9
  *
10
10
  * @example
11
11
  * ```tsx
12
- * // In your _layout.tsx
12
+ * // Expo Router - in your _layout.tsx
13
13
  * import { RouteTracker } from '@buoy-gg/route-events';
14
14
  *
15
15
  * export default function RootLayout() {
@@ -23,7 +23,20 @@
23
23
  * </>
24
24
  * );
25
25
  * }
26
+ *
27
+ * // React Navigation (RN CLI) - inside NavigationContainer
28
+ * import { RouteTracker } from '@buoy-gg/route-events';
29
+ *
30
+ * function App() {
31
+ * return (
32
+ * <NavigationContainer>
33
+ * <RootNavigator />
34
+ * <RouteTracker />
35
+ * <FloatingDevTools ... />
36
+ * </NavigationContainer>
37
+ * );
38
+ * }
26
39
  * ```
27
40
  */
28
- export declare function RouteTracker(): null;
41
+ export declare function RouteTracker(): import("react").JSX.Element;
29
42
  //# sourceMappingURL=RouteTracker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RouteTracker.d.ts","sourceRoot":"","sources":["../../src/RouteTracker.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,wBAAgB,YAAY,IAAI,IAAI,CAGnC"}
1
+ {"version":3,"file":"RouteTracker.d.ts","sourceRoot":"","sources":["../../src/RouteTracker.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAgBH,wBAAgB,YAAY,gCAM3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationStack.d.ts","sourceRoot":"","sources":["../../../src/components/NavigationStack.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AA6BH,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAMD,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,EAAE,oBAAoB,+BAyZ9D"}
1
+ {"version":3,"file":"NavigationStack.d.ts","sourceRoot":"","sources":["../../../src/components/NavigationStack.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4BH,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAMD,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,EAAE,oBAAoB,+BAya9D"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * ReactNavigationRoutes - Visual sitemap of all screens in a React Navigation app
3
+ *
4
+ * Discovers all registered screens by walking the navigation state tree.
5
+ * Each navigator's state includes a `routeNames` array listing ALL screens
6
+ * registered with it — even ones not currently mounted in the stack.
7
+ *
8
+ * Provides navigation to any discovered screen using nested screen/params actions.
9
+ */
10
+ export interface ReactNavigationRoutesProps {
11
+ style?: any;
12
+ }
13
+ export declare function ReactNavigationRoutes({ style }: ReactNavigationRoutesProps): import("react").JSX.Element;
14
+ //# sourceMappingURL=ReactNavigationRoutes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactNavigationRoutes.d.ts","sourceRoot":"","sources":["../../../src/components/ReactNavigationRoutes.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA8BH,MAAM,WAAW,0BAA0B;IACzC,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAkHD,wBAAgB,qBAAqB,CAAC,EAAE,KAAK,EAAE,EAAE,0BAA0B,+BAmS1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"RouteEventsModalWithTabs.d.ts","sourceRoot":"","sources":["../../../src/components/RouteEventsModalWithTabs.tsx"],"names":[],"mappings":"AA8CA,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,KAAK,IAAI,CAAC;IACvC,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAID,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,OAAO,EACP,MAAM,EACN,UAAU,EACV,2BAAmC,GACpC,EAAE,6BAA6B,sCAigB/B"}
1
+ {"version":3,"file":"RouteEventsModalWithTabs.d.ts","sourceRoot":"","sources":["../../../src/components/RouteEventsModalWithTabs.tsx"],"names":[],"mappings":"AAoDA,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,KAAK,IAAI,CAAC;IACvC,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AA8CD,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,OAAO,EACP,MAAM,EACN,UAAU,EACV,2BAAmC,GACpC,EAAE,6BAA6B,sCA8hB/B"}
@@ -19,6 +19,7 @@ export type { RouteEventItemCompactProps } from "./components/RouteEventItemComp
19
19
  export { RouteEventExpandedContent } from "./components/RouteEventExpandedContent";
20
20
  export type { RouteEventExpandedContentProps } from "./components/RouteEventExpandedContent";
21
21
  export { useRouteObserver } from "./useRouteObserver";
22
+ export { useRouteObserverReactNavigation } from "./useRouteObserverReactNavigation";
22
23
  export { useRouteEvents } from "./hooks/useRouteEvents";
23
24
  export type { UseRouteEventsOptions, UseRouteEventsResult, } from "./hooks/useRouteEvents";
24
25
  export { useRouteSitemap, useRoute, useParentRoutes } from "./useRouteSitemap";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAKxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,YAAY,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAK3F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,YAAY,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,YAAY,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAK7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EACV,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/E,YAAY,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EACV,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAK9B,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD,qEAAqE;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,qEAAqE;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,YAAY,EACV,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAKxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,YAAY,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAK3F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,YAAY,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,YAAY,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAK7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EACV,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/E,YAAY,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EACV,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAK9B,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD,qEAAqE;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,qEAAqE;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,YAAY,EACV,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
@@ -1,10 +1,13 @@
1
1
  /**
2
2
  * useNavigationStack - Hook to access current navigation stack state
3
3
  *
4
- * Provides real-time access to the navigation stack from Expo Router,
4
+ * Provides real-time access to the navigation stack,
5
5
  * showing what screens are currently mounted in memory and which is visible.
6
6
  *
7
- * Data source: @react-navigation/native
7
+ * Supports both Expo Router and React Navigation (RN CLI).
8
+ *
9
+ * - Expo Router: uses useNavigation/useNavigationState (inside navigator context)
10
+ * - RN CLI: uses NavigationContainerRefContext (works as sibling of navigators)
8
11
  */
9
12
  export interface StackDisplayItem {
10
13
  key: string;
@@ -29,7 +32,10 @@ export interface UseNavigationStackResult {
29
32
  popToTop: () => void;
30
33
  }
31
34
  /**
32
- * Access the current navigation stack from Expo Router
35
+ * Access the current navigation stack.
36
+ *
37
+ * Works in both Expo Router and RN CLI apps. On RN CLI, uses the
38
+ * NavigationContainer ref context so it works even as a sibling of navigators.
33
39
  *
34
40
  * @example
35
41
  * ```tsx
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigationStack.d.ts","sourceRoot":"","sources":["../../src/useNavigationStack.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IAEvC,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAGlB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAGpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAsED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,IAAI,wBAAwB,CAkK7D"}
1
+ {"version":3,"file":"useNavigationStack.d.ts","sourceRoot":"","sources":["../../src/useNavigationStack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAsBH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IAEvC,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAGlB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAGpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAuKD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,IAAI,wBAAwB,CAqK7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"useRouteObserver.d.ts","sourceRoot":"","sources":["../../src/useRouteObserver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEvE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,QAyC5E"}
1
+ {"version":3,"file":"useRouteObserver.d.ts","sourceRoot":"","sources":["../../src/useRouteObserver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEvE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,QA0C5E"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * useRouteObserverReactNavigation - React hook for observing route changes
3
+ * using @react-navigation/native APIs.
4
+ *
5
+ * This is the React Navigation (RN CLI) counterpart to useRouteObserver.ts
6
+ * which uses Expo Router hooks. Both emit to the same routeObserver singleton.
7
+ *
8
+ * Uses NavigationContainerRefContext so it works anywhere inside
9
+ * a NavigationContainer — does NOT need to be inside a navigator.
10
+ */
11
+ import { type RouteChangeEvent } from "./RouteObserver";
12
+ /**
13
+ * Hook to observe route changes via @react-navigation/native.
14
+ * Automatically emits events to the global RouteObserver.
15
+ *
16
+ * Works anywhere inside a NavigationContainer (does not need to be inside a navigator).
17
+ */
18
+ export declare function useRouteObserverReactNavigation(callback?: (event: RouteChangeEvent) => void): void;
19
+ //# sourceMappingURL=useRouteObserverReactNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRouteObserverReactNavigation.d.ts","sourceRoot":"","sources":["../../src/useRouteObserverReactNavigation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAwEvE;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,QAmC7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/route-events",
3
- "version": "2.1.3",
3
+ "version": "2.1.4-beta.1",
4
4
  "description": "route-events package",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -26,11 +26,11 @@
26
26
  ],
27
27
  "sideEffects": false,
28
28
  "dependencies": {
29
- "@buoy-gg/floating-tools-core": "2.1.3",
30
- "@buoy-gg/shared-ui": "2.1.3"
29
+ "@buoy-gg/floating-tools-core": "2.1.4-beta.1",
30
+ "@buoy-gg/shared-ui": "2.1.4-beta.1"
31
31
  },
32
32
  "peerDependencies": {
33
- "@buoy-gg/license": "*",
33
+ "@buoy-gg/license": "2.1.4-beta.1",
34
34
  "@react-native-async-storage/async-storage": "*",
35
35
  "@react-navigation/native": "*",
36
36
  "expo-router": "*",
@@ -38,7 +38,7 @@
38
38
  "react-native": "*"
39
39
  },
40
40
  "peerDependenciesMeta": {
41
- "@buoy-gg/license": {
41
+ "expo-router": {
42
42
  "optional": true
43
43
  }
44
44
  },
@@ -49,7 +49,7 @@
49
49
  "@types/react-native": "^0.73.0",
50
50
  "expo-router": "~5.0.7",
51
51
  "typescript": "~5.8.3",
52
- "@buoy-gg/license": "2.1.3"
52
+ "@buoy-gg/license": "2.1.4-beta.1"
53
53
  },
54
54
  "react-native-builder-bob": {
55
55
  "source": "src",
@@ -1,129 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getSafeRouter = getSafeRouter;
7
- exports.isExpoRouterAvailable = isExpoRouterAvailable;
8
- exports.useSafeGlobalSearchParams = useSafeGlobalSearchParams;
9
- exports.useSafePathname = useSafePathname;
10
- exports.useSafeRouter = useSafeRouter;
11
- exports.useSafeSegments = useSafeSegments;
12
- /**
13
- * Safe wrapper for expo-router
14
- *
15
- * Provides optional imports for expo-router hooks and utilities.
16
- * Falls back to no-op implementations when expo-router is not installed.
17
- */
18
-
19
- let expoRouter = null;
20
- let isAvailable = false;
21
- let checkedAvailability = false;
22
- function checkExpoRouterAvailability() {
23
- if (checkedAvailability) return isAvailable;
24
- try {
25
- expoRouter = require("expo-router");
26
- isAvailable = expoRouter != null;
27
- } catch (error) {
28
- isAvailable = false;
29
- expoRouter = null;
30
- }
31
- checkedAvailability = true;
32
- return isAvailable;
33
- }
34
-
35
- // ============================================================================
36
- // No-op implementations when expo-router is not available
37
- // ============================================================================
38
-
39
- function noOpUseRouter() {
40
- return {
41
- push: () => console.warn("[route-events] expo-router not installed: push() unavailable"),
42
- replace: () => console.warn("[route-events] expo-router not installed: replace() unavailable"),
43
- back: () => console.warn("[route-events] expo-router not installed: back() unavailable"),
44
- canGoBack: () => false,
45
- setParams: () => console.warn("[route-events] expo-router not installed: setParams() unavailable"),
46
- navigate: () => console.warn("[route-events] expo-router not installed: navigate() unavailable")
47
- };
48
- }
49
- function noOpUsePathname() {
50
- return "/";
51
- }
52
- function noOpUseSegments() {
53
- return [];
54
- }
55
- function noOpUseGlobalSearchParams() {
56
- return {};
57
- }
58
-
59
- // ============================================================================
60
- // Safe hook exports
61
- // ============================================================================
62
-
63
- function useSafeRouter() {
64
- if (!checkExpoRouterAvailability()) {
65
- return noOpUseRouter();
66
- }
67
- try {
68
- return expoRouter.useRouter();
69
- } catch (error) {
70
- console.warn("[route-events] Failed to use expo-router.useRouter:", error);
71
- return noOpUseRouter();
72
- }
73
- }
74
- function useSafePathname() {
75
- if (!checkExpoRouterAvailability()) {
76
- return noOpUsePathname();
77
- }
78
- try {
79
- return expoRouter.usePathname();
80
- } catch (error) {
81
- console.warn("[route-events] Failed to use expo-router.usePathname:", error);
82
- return noOpUsePathname();
83
- }
84
- }
85
- function useSafeSegments() {
86
- if (!checkExpoRouterAvailability()) {
87
- return noOpUseSegments();
88
- }
89
- try {
90
- return expoRouter.useSegments();
91
- } catch (error) {
92
- console.warn("[route-events] Failed to use expo-router.useSegments:", error);
93
- return noOpUseSegments();
94
- }
95
- }
96
- function useSafeGlobalSearchParams() {
97
- if (!checkExpoRouterAvailability()) {
98
- return noOpUseGlobalSearchParams();
99
- }
100
- try {
101
- return expoRouter.useGlobalSearchParams();
102
- } catch (error) {
103
- console.warn("[route-events] Failed to use expo-router.useGlobalSearchParams:", error);
104
- return noOpUseGlobalSearchParams();
105
- }
106
- }
107
-
108
- // ============================================================================
109
- // Router instance getter (for imperative navigation)
110
- // ============================================================================
111
-
112
- function getSafeRouter() {
113
- if (!checkExpoRouterAvailability()) {
114
- return null;
115
- }
116
- try {
117
- return expoRouter.router || null;
118
- } catch (error) {
119
- return null;
120
- }
121
- }
122
-
123
- // ============================================================================
124
- // Availability check
125
- // ============================================================================
126
-
127
- function isExpoRouterAvailable() {
128
- return checkExpoRouterAvailability();
129
- }
@@ -1,120 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Safe wrapper for expo-router
5
- *
6
- * Provides optional imports for expo-router hooks and utilities.
7
- * Falls back to no-op implementations when expo-router is not installed.
8
- */
9
-
10
- let expoRouter = null;
11
- let isAvailable = false;
12
- let checkedAvailability = false;
13
- function checkExpoRouterAvailability() {
14
- if (checkedAvailability) return isAvailable;
15
- try {
16
- expoRouter = require("expo-router");
17
- isAvailable = expoRouter != null;
18
- } catch (error) {
19
- isAvailable = false;
20
- expoRouter = null;
21
- }
22
- checkedAvailability = true;
23
- return isAvailable;
24
- }
25
-
26
- // ============================================================================
27
- // No-op implementations when expo-router is not available
28
- // ============================================================================
29
-
30
- function noOpUseRouter() {
31
- return {
32
- push: () => console.warn("[route-events] expo-router not installed: push() unavailable"),
33
- replace: () => console.warn("[route-events] expo-router not installed: replace() unavailable"),
34
- back: () => console.warn("[route-events] expo-router not installed: back() unavailable"),
35
- canGoBack: () => false,
36
- setParams: () => console.warn("[route-events] expo-router not installed: setParams() unavailable"),
37
- navigate: () => console.warn("[route-events] expo-router not installed: navigate() unavailable")
38
- };
39
- }
40
- function noOpUsePathname() {
41
- return "/";
42
- }
43
- function noOpUseSegments() {
44
- return [];
45
- }
46
- function noOpUseGlobalSearchParams() {
47
- return {};
48
- }
49
-
50
- // ============================================================================
51
- // Safe hook exports
52
- // ============================================================================
53
-
54
- export function useSafeRouter() {
55
- if (!checkExpoRouterAvailability()) {
56
- return noOpUseRouter();
57
- }
58
- try {
59
- return expoRouter.useRouter();
60
- } catch (error) {
61
- console.warn("[route-events] Failed to use expo-router.useRouter:", error);
62
- return noOpUseRouter();
63
- }
64
- }
65
- export function useSafePathname() {
66
- if (!checkExpoRouterAvailability()) {
67
- return noOpUsePathname();
68
- }
69
- try {
70
- return expoRouter.usePathname();
71
- } catch (error) {
72
- console.warn("[route-events] Failed to use expo-router.usePathname:", error);
73
- return noOpUsePathname();
74
- }
75
- }
76
- export function useSafeSegments() {
77
- if (!checkExpoRouterAvailability()) {
78
- return noOpUseSegments();
79
- }
80
- try {
81
- return expoRouter.useSegments();
82
- } catch (error) {
83
- console.warn("[route-events] Failed to use expo-router.useSegments:", error);
84
- return noOpUseSegments();
85
- }
86
- }
87
- export function useSafeGlobalSearchParams() {
88
- if (!checkExpoRouterAvailability()) {
89
- return noOpUseGlobalSearchParams();
90
- }
91
- try {
92
- return expoRouter.useGlobalSearchParams();
93
- } catch (error) {
94
- console.warn("[route-events] Failed to use expo-router.useGlobalSearchParams:", error);
95
- return noOpUseGlobalSearchParams();
96
- }
97
- }
98
-
99
- // ============================================================================
100
- // Router instance getter (for imperative navigation)
101
- // ============================================================================
102
-
103
- export function getSafeRouter() {
104
- if (!checkExpoRouterAvailability()) {
105
- return null;
106
- }
107
- try {
108
- return expoRouter.router || null;
109
- } catch (error) {
110
- return null;
111
- }
112
- }
113
-
114
- // ============================================================================
115
- // Availability check
116
- // ============================================================================
117
-
118
- export function isExpoRouterAvailable() {
119
- return checkExpoRouterAvailability();
120
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Safe wrapper for expo-router
3
- *
4
- * Provides optional imports for expo-router hooks and utilities.
5
- * Falls back to no-op implementations when expo-router is not installed.
6
- */
7
- export declare function useSafeRouter(): any;
8
- export declare function useSafePathname(): string;
9
- export declare function useSafeSegments(): string[];
10
- export declare function useSafeGlobalSearchParams(): Record<string, string | string[]>;
11
- export declare function getSafeRouter(): any;
12
- export declare function isExpoRouterAvailable(): boolean;
13
- //# sourceMappingURL=safeExpoRouter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safeExpoRouter.d.ts","sourceRoot":"","sources":["../../../src/utils/safeExpoRouter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoDH,wBAAgB,aAAa,QAW5B;AAED,wBAAgB,eAAe,IAAI,MAAM,CAWxC;AAED,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAW1C;AAED,wBAAgB,yBAAyB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAW7E;AAMD,wBAAgB,aAAa,QAU5B;AAMD,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C"}