@symbiote-native/navigation 1.0.0 → 2.0.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 (195) hide show
  1. package/README.md +159 -0
  2. package/package.json +14 -12
  3. package/build/angular/drawer/index.d.ts +0 -76
  4. package/build/angular/drawer/index.js +0 -508
  5. package/build/angular/drawer-screen.directive.d.ts +0 -14
  6. package/build/angular/drawer-screen.directive.js +0 -87
  7. package/build/angular/index.d.ts +0 -23
  8. package/build/angular/index.js +0 -22
  9. package/build/angular/injectors/index.d.ts +0 -13
  10. package/build/angular/injectors/index.js +0 -8
  11. package/build/angular/injectors/inject-drawer-navigation.d.ts +0 -4
  12. package/build/angular/injectors/inject-drawer-navigation.js +0 -12
  13. package/build/angular/injectors/inject-focus-effect.d.ts +0 -2
  14. package/build/angular/injectors/inject-focus-effect.js +0 -29
  15. package/build/angular/injectors/inject-is-focused.d.ts +0 -2
  16. package/build/angular/injectors/inject-is-focused.js +0 -20
  17. package/build/angular/injectors/inject-navigation-state.d.ts +0 -3
  18. package/build/angular/injectors/inject-navigation-state.js +0 -35
  19. package/build/angular/injectors/inject-navigation.d.ts +0 -7
  20. package/build/angular/injectors/inject-navigation.js +0 -16
  21. package/build/angular/injectors/inject-route.d.ts +0 -3
  22. package/build/angular/injectors/inject-route.js +0 -20
  23. package/build/angular/injectors/inject-stack-navigation.d.ts +0 -4
  24. package/build/angular/injectors/inject-stack-navigation.js +0 -15
  25. package/build/angular/injectors/inject-tab-navigation.d.ts +0 -4
  26. package/build/angular/injectors/inject-tab-navigation.js +0 -11
  27. package/build/angular/linking.d.ts +0 -3
  28. package/build/angular/linking.js +0 -43
  29. package/build/angular/navigation-context.service.d.ts +0 -13
  30. package/build/angular/navigation-context.service.js +0 -105
  31. package/build/angular/navigation-scope.directive.d.ts +0 -10
  32. package/build/angular/navigation-scope.directive.js +0 -90
  33. package/build/angular/screen.directive.d.ts +0 -22
  34. package/build/angular/screen.directive.js +0 -90
  35. package/build/angular/search-bar-ref.directive.d.ts +0 -10
  36. package/build/angular/search-bar-ref.directive.js +0 -88
  37. package/build/angular/stack/index.d.ts +0 -55
  38. package/build/angular/stack/index.js +0 -386
  39. package/build/angular/tab-screen.directive.d.ts +0 -14
  40. package/build/angular/tab-screen.directive.js +0 -87
  41. package/build/angular/tabs/index.d.ts +0 -42
  42. package/build/angular/tabs/index.js +0 -263
  43. package/build/core/constants.d.ts +0 -27
  44. package/build/core/constants.js +0 -61
  45. package/build/core/drawer-options/index.d.ts +0 -64
  46. package/build/core/drawer-options/index.js +0 -200
  47. package/build/core/drawer-router-state/index.d.ts +0 -21
  48. package/build/core/drawer-router-state/index.js +0 -40
  49. package/build/core/guards.d.ts +0 -2
  50. package/build/core/guards.js +0 -22
  51. package/build/core/header-bar-buttons.d.ts +0 -9
  52. package/build/core/header-bar-buttons.js +0 -163
  53. package/build/core/index.d.ts +0 -29
  54. package/build/core/index.js +0 -32
  55. package/build/core/linking-config/index.d.ts +0 -13
  56. package/build/core/linking-config/index.js +0 -171
  57. package/build/core/navigation-events/index.d.ts +0 -16
  58. package/build/core/navigation-events/index.js +0 -57
  59. package/build/core/navigator-handles/index.d.ts +0 -30
  60. package/build/core/navigator-handles/index.js +0 -15
  61. package/build/core/navigator-props.d.ts +0 -216
  62. package/build/core/navigator-props.js +0 -7
  63. package/build/core/navigator-state/index.d.ts +0 -36
  64. package/build/core/navigator-state/index.js +0 -81
  65. package/build/core/render-drawer.d.ts +0 -13
  66. package/build/core/render-drawer.js +0 -88
  67. package/build/core/render-stack.d.ts +0 -35
  68. package/build/core/render-stack.js +0 -294
  69. package/build/core/render-tabs.d.ts +0 -20
  70. package/build/core/render-tabs.js +0 -97
  71. package/build/core/screen-options.d.ts +0 -4
  72. package/build/core/screen-options.js +0 -133
  73. package/build/core/search-bar-commands.d.ts +0 -10
  74. package/build/core/search-bar-commands.js +0 -42
  75. package/build/core/state-persistence/index.d.ts +0 -3
  76. package/build/core/state-persistence/index.js +0 -23
  77. package/build/core/tab-options.d.ts +0 -13
  78. package/build/core/tab-options.js +0 -10
  79. package/build/core/tab-router-state/index.d.ts +0 -19
  80. package/build/core/tab-router-state/index.js +0 -51
  81. package/build/react/collect-registry.d.ts +0 -4
  82. package/build/react/collect-registry.js +0 -15
  83. package/build/react/drawer/index.d.ts +0 -29
  84. package/build/react/drawer/index.js +0 -277
  85. package/build/react/drawer-screen.d.ts +0 -14
  86. package/build/react/drawer-screen.js +0 -8
  87. package/build/react/hooks/index.d.ts +0 -12
  88. package/build/react/hooks/index.js +0 -8
  89. package/build/react/hooks/use-drawer-navigation.d.ts +0 -4
  90. package/build/react/hooks/use-drawer-navigation.js +0 -12
  91. package/build/react/hooks/use-focus-effect.d.ts +0 -2
  92. package/build/react/hooks/use-focus-effect.js +0 -29
  93. package/build/react/hooks/use-is-focused.d.ts +0 -1
  94. package/build/react/hooks/use-is-focused.js +0 -22
  95. package/build/react/hooks/use-navigation-state/index.d.ts +0 -2
  96. package/build/react/hooks/use-navigation-state/index.js +0 -39
  97. package/build/react/hooks/use-navigation.d.ts +0 -7
  98. package/build/react/hooks/use-navigation.js +0 -16
  99. package/build/react/hooks/use-route.d.ts +0 -2
  100. package/build/react/hooks/use-route.js +0 -8
  101. package/build/react/hooks/use-stack-navigation.d.ts +0 -4
  102. package/build/react/hooks/use-stack-navigation.js +0 -14
  103. package/build/react/hooks/use-tab-navigation.d.ts +0 -4
  104. package/build/react/hooks/use-tab-navigation.js +0 -12
  105. package/build/react/index.d.ts +0 -24
  106. package/build/react/index.js +0 -21
  107. package/build/react/linking.d.ts +0 -3
  108. package/build/react/linking.js +0 -47
  109. package/build/react/navigation-context.d.ts +0 -10
  110. package/build/react/navigation-context.js +0 -22
  111. package/build/react/screen.d.ts +0 -22
  112. package/build/react/screen.js +0 -7
  113. package/build/react/stack/index.d.ts +0 -13
  114. package/build/react/stack/index.js +0 -202
  115. package/build/react/tab-screen.d.ts +0 -15
  116. package/build/react/tab-screen.js +0 -8
  117. package/build/react/tabs/index.d.ts +0 -12
  118. package/build/react/tabs/index.js +0 -116
  119. package/build/register.d.ts +0 -7
  120. package/build/register.js +0 -58
  121. package/build/vue/composables/index.d.ts +0 -12
  122. package/build/vue/composables/index.js +0 -8
  123. package/build/vue/composables/use-drawer-navigation.d.ts +0 -5
  124. package/build/vue/composables/use-drawer-navigation.js +0 -15
  125. package/build/vue/composables/use-focus-effect.d.ts +0 -1
  126. package/build/vue/composables/use-focus-effect.js +0 -31
  127. package/build/vue/composables/use-is-focused.d.ts +0 -2
  128. package/build/vue/composables/use-is-focused.js +0 -28
  129. package/build/vue/composables/use-navigation-state.d.ts +0 -3
  130. package/build/vue/composables/use-navigation-state.js +0 -29
  131. package/build/vue/composables/use-navigation.d.ts +0 -8
  132. package/build/vue/composables/use-navigation.js +0 -13
  133. package/build/vue/composables/use-route.d.ts +0 -3
  134. package/build/vue/composables/use-route.js +0 -9
  135. package/build/vue/composables/use-stack-navigation.d.ts +0 -5
  136. package/build/vue/composables/use-stack-navigation.js +0 -18
  137. package/build/vue/composables/use-tab-navigation.d.ts +0 -5
  138. package/build/vue/composables/use-tab-navigation.js +0 -15
  139. package/build/vue/drawer/index.d.ts +0 -19
  140. package/build/vue/drawer/index.js +0 -390
  141. package/build/vue/drawer-screen.d.ts +0 -14
  142. package/build/vue/drawer-screen.js +0 -12
  143. package/build/vue/index.d.ts +0 -21
  144. package/build/vue/index.js +0 -19
  145. package/build/vue/linking.d.ts +0 -3
  146. package/build/vue/linking.js +0 -57
  147. package/build/vue/navigation-context.d.ts +0 -16
  148. package/build/vue/navigation-context.js +0 -65
  149. package/build/vue/screen.d.ts +0 -21
  150. package/build/vue/screen.js +0 -12
  151. package/build/vue/stack/index.d.ts +0 -9
  152. package/build/vue/stack/index.js +0 -279
  153. package/build/vue/tab-screen.d.ts +0 -14
  154. package/build/vue/tab-screen.js +0 -11
  155. package/build/vue/tabs/index.d.ts +0 -10
  156. package/build/vue/tabs/index.js +0 -209
  157. package/build-ngc/angular/drawer.d.ts +0 -79
  158. package/build-ngc/angular/drawer.js +0 -475
  159. package/build-ngc/angular/drawer.js.map +0 -1
  160. package/build-ngc/angular/stack.d.ts +0 -58
  161. package/build-ngc/angular/stack.js +0 -402
  162. package/build-ngc/angular/stack.js.map +0 -1
  163. package/build-ngc/angular/tabs.d.ts +0 -45
  164. package/build-ngc/angular/tabs.js +0 -231
  165. package/build-ngc/angular/tabs.js.map +0 -1
  166. package/build-ngc/core/drawer-options.d.ts +0 -64
  167. package/build-ngc/core/drawer-options.js +0 -201
  168. package/build-ngc/core/drawer-options.js.map +0 -1
  169. package/build-ngc/core/drawer-router-state.d.ts +0 -21
  170. package/build-ngc/core/drawer-router-state.js +0 -41
  171. package/build-ngc/core/drawer-router-state.js.map +0 -1
  172. package/build-ngc/core/href.d.ts +0 -16
  173. package/build-ngc/core/href.js +0 -55
  174. package/build-ngc/core/href.js.map +0 -1
  175. package/build-ngc/core/linking-config.d.ts +0 -13
  176. package/build-ngc/core/linking-config.js +0 -172
  177. package/build-ngc/core/linking-config.js.map +0 -1
  178. package/build-ngc/core/navigation-events.d.ts +0 -16
  179. package/build-ngc/core/navigation-events.js +0 -58
  180. package/build-ngc/core/navigation-events.js.map +0 -1
  181. package/build-ngc/core/navigator-handles.d.ts +0 -30
  182. package/build-ngc/core/navigator-handles.js +0 -16
  183. package/build-ngc/core/navigator-handles.js.map +0 -1
  184. package/build-ngc/core/navigator-state.d.ts +0 -36
  185. package/build-ngc/core/navigator-state.js +0 -82
  186. package/build-ngc/core/navigator-state.js.map +0 -1
  187. package/build-ngc/core/search-params.d.ts +0 -9
  188. package/build-ngc/core/search-params.js +0 -60
  189. package/build-ngc/core/search-params.js.map +0 -1
  190. package/build-ngc/core/state-persistence.d.ts +0 -3
  191. package/build-ngc/core/state-persistence.js +0 -24
  192. package/build-ngc/core/state-persistence.js.map +0 -1
  193. package/build-ngc/core/tab-router-state.d.ts +0 -19
  194. package/build-ngc/core/tab-router-state.js +0 -52
  195. package/build-ngc/core/tab-router-state.js.map +0 -1
@@ -1,14 +0,0 @@
1
- import type { FC, ReactElement } from 'react';
2
- import type { IDrawerNavigatorHandle, IDrawerScreenOptions, IRoute } from '../core';
3
- export type IDrawerScreenOptionsArgs = {
4
- route: IRoute<unknown>;
5
- navigation: IDrawerNavigatorHandle;
6
- };
7
- export type IDrawerScreenOptionsResolver = (args: IDrawerScreenOptionsArgs) => IDrawerScreenOptions;
8
- export type IDrawerScreenProps = {
9
- name: string;
10
- component: FC;
11
- options?: IDrawerScreenOptions | IDrawerScreenOptionsResolver;
12
- initialParams?: unknown;
13
- };
14
- export declare function DrawerScreen(_props: IDrawerScreenProps): ReactElement | null;
@@ -1,8 +0,0 @@
1
- // Drawer.Screen: a declarative marker, never rendered on its own - Drawer reads its props via
2
- // React.Children to build the static name -> {component, options} registry, then mounts the
3
- // FOCUSED route's component. Mirrors react/tab-screen.ts (Tab's twin - the closer sibling, both
4
- // are fixed-route-list/no-push navigators) and react/screen.ts (Stack's twin); see CLAUDE.md
5
- // <third_party_rn_packages_are_react_only> - this and Drawer import nothing from react-native.
6
- export function DrawerScreen(_props) {
7
- return null;
8
- }
@@ -1,12 +0,0 @@
1
- export { useNavigation } from './use-navigation';
2
- export type { INavigationHandle } from './use-navigation';
3
- export { useStackNavigation } from './use-stack-navigation';
4
- export type { IStackNavigationHandle } from './use-stack-navigation';
5
- export { useTabNavigation } from './use-tab-navigation';
6
- export type { ITabNavigationHandle } from './use-tab-navigation';
7
- export { useDrawerNavigation } from './use-drawer-navigation';
8
- export type { IDrawerNavigationHandle } from './use-drawer-navigation';
9
- export { useRoute } from './use-route';
10
- export { useIsFocused } from './use-is-focused';
11
- export { useFocusEffect } from './use-focus-effect';
12
- export { useNavigationState } from './use-navigation-state';
@@ -1,8 +0,0 @@
1
- export { useNavigation } from './use-navigation.js';
2
- export { useStackNavigation } from './use-stack-navigation.js';
3
- export { useTabNavigation } from './use-tab-navigation.js';
4
- export { useDrawerNavigation } from './use-drawer-navigation.js';
5
- export { useRoute } from './use-route.js';
6
- export { useIsFocused } from './use-is-focused.js';
7
- export { useFocusEffect } from './use-focus-effect.js';
8
- export { useNavigationState } from './use-navigation-state/index.js';
@@ -1,4 +0,0 @@
1
- import type { IDrawerNavigatorHandle } from '../../core';
2
- import type { INavigationHandle } from './use-navigation';
3
- export type IDrawerNavigationHandle = IDrawerNavigatorHandle & Pick<INavigationHandle, 'addListener' | 'getParent'>;
4
- export declare function useDrawerNavigation(): IDrawerNavigationHandle;
@@ -1,12 +0,0 @@
1
- // Twin of use-stack-navigation.ts, narrowing to a Drawer handle instead. See that file's header
2
- // for why this exists: it hides the union-narrowing guard inside the library instead of every call site.
3
- import { isDrawerNavigatorHandle } from '../../core/index.js';
4
- import { useNavigation } from './use-navigation.js';
5
- export function useDrawerNavigation() {
6
- const navigation = useNavigation();
7
- if (!isDrawerNavigatorHandle(navigation)) {
8
- throw new Error('useDrawerNavigation() was called from a component whose nearest navigator is not a Drawer. ' +
9
- 'Use useNavigation() instead if this component can render under more than one navigator kind.');
10
- }
11
- return navigation;
12
- }
@@ -1,2 +0,0 @@
1
- import type { EffectCallback } from 'react';
2
- export declare function useFocusEffect(effect: EffectCallback): void;
@@ -1,29 +0,0 @@
1
- // Thin useEffect wrapper: runs `effect` while the route is focused and runs its own returned
2
- // cleanup on blur - exactly React.useEffect's contract, just re-armed on every focus/blur pair
3
- // instead of once on mount - mirrors @react-navigation's useFocusEffect. Callers should memoize
4
- // `effect` (React.useCallback), same requirement the upstream hook documents, since a new
5
- // `effect` identity re-subscribes here like any other useEffect dependency change.
6
- import { useEffect } from 'react';
7
- import { NAVIGATION_EVENT_BLUR, NAVIGATION_EVENT_FOCUS } from '../../core/index.js';
8
- import { useRequiredNavigationContext } from '../navigation-context.js';
9
- export function useFocusEffect(effect) {
10
- const context = useRequiredNavigationContext('useFocusEffect');
11
- const { emitter } = context;
12
- useEffect(() => {
13
- let cleanup;
14
- const runEffect = () => {
15
- cleanup = effect();
16
- };
17
- const runCleanup = () => {
18
- cleanup?.();
19
- cleanup = undefined;
20
- };
21
- const unsubscribeFocus = emitter.addListener(NAVIGATION_EVENT_FOCUS, runEffect);
22
- const unsubscribeBlur = emitter.addListener(NAVIGATION_EVENT_BLUR, runCleanup);
23
- return () => {
24
- unsubscribeFocus();
25
- unsubscribeBlur();
26
- runCleanup();
27
- };
28
- }, [emitter, effect]);
29
- }
@@ -1 +0,0 @@
1
- export declare function useIsFocused(): boolean;
@@ -1,22 +0,0 @@
1
- // Thin useEffect wrapper: subscribes to the route's focus/blur pair and returns whether it's
2
- // currently focused, re-rendering on change - mirrors @react-navigation's useIsFocused. Starts
3
- // `false` rather than guessing from stack position: the route's emitter only fires 'focus' once
4
- // RNSScreen's native onAppear actually lands (stack.ts), so a screen genuinely isn't focused yet
5
- // at the instant it mounts - same async gap real native transitions have.
6
- import { useEffect, useState } from 'react';
7
- import { NAVIGATION_EVENT_BLUR, NAVIGATION_EVENT_FOCUS } from '../../core/index.js';
8
- import { useRequiredNavigationContext } from '../navigation-context.js';
9
- export function useIsFocused() {
10
- const context = useRequiredNavigationContext('useIsFocused');
11
- const { emitter } = context;
12
- const [isFocused, setIsFocused] = useState(false);
13
- useEffect(() => {
14
- const unsubscribeFocus = emitter.addListener(NAVIGATION_EVENT_FOCUS, () => setIsFocused(true));
15
- const unsubscribeBlur = emitter.addListener(NAVIGATION_EVENT_BLUR, () => setIsFocused(false));
16
- return () => {
17
- unsubscribeFocus();
18
- unsubscribeBlur();
19
- };
20
- }, [emitter]);
21
- return isFocused;
22
- }
@@ -1,2 +0,0 @@
1
- import type { INavigatorState } from '../../../core';
2
- export declare function useNavigationState<TResult>(selector: (state: INavigatorState) => TResult): TResult;
@@ -1,39 +0,0 @@
1
- // Thin selector wrapper: subscribes to the router's `state` broadcast (stack.ts's render loop
2
- // re-emits the full INavigatorState to every route's emitter after each commit) and returns
3
- // `selector(state)`, re-rendering only when the emitted state changes - mirrors
4
- // @react-navigation's useNavigationState. The reducer/dispatch machinery it selects over lives in
5
- // core/navigator-state.ts; this hook only wires the subscription + local re-render.
6
- //
7
- // Seeded from a single-route snapshot ({ routes: [route] }) rather than left undefined: the real
8
- // broadcast lands a tick later (post-commit useEffect), so a selector reading e.g.
9
- // `state.routes.at(-1)?.name` still resolves correctly on first paint for the common single-route
10
- // case, closing the same async gap useIsFocused documents.
11
- //
12
- // Live updates currently only arrive under <Stack> - it's the only navigator that emits
13
- // NAVIGATION_EVENT_STATE (its post-commit useEffect in stack.ts); <Tab>/<Drawer> don't broadcast
14
- // it, so under those this hook silently stays on its initial snapshot.
15
- import { useEffect, useRef, useState } from 'react';
16
- import { NAVIGATION_EVENT_STATE, isRecord } from '../../../core/index.js';
17
- import { useRequiredNavigationContext } from '../../navigation-context.js';
18
- export function useNavigationState(selector) {
19
- const context = useRequiredNavigationContext('useNavigationState');
20
- const { route, emitter } = context;
21
- const [result, setResult] = useState(() => selector({ routes: [route] }));
22
- // selector is typically an inline arrow at the call site (`useNavigationState(s => ...)`), a
23
- // fresh identity every render - read through a ref so the effect below doesn't need `selector`
24
- // in its deps, and doesn't unsubscribe/resubscribe on every render because of it (the same trap
25
- // useFocusEffect's own comment documents for its `effect` argument).
26
- const selectorRef = useRef(selector);
27
- selectorRef.current = selector;
28
- useEffect(() => {
29
- return emitter.addListener(NAVIGATION_EVENT_STATE, (state) => {
30
- if (!isNavigatorState(state))
31
- return;
32
- setResult(selectorRef.current(state));
33
- });
34
- }, [emitter]);
35
- return result;
36
- }
37
- function isNavigatorState(value) {
38
- return isRecord(value) && Array.isArray(value.routes);
39
- }
@@ -1,7 +0,0 @@
1
- import type { INavigationEventListener, INavigationEventName } from '../../core';
2
- import type { IAnyNavigatorHandle } from '../navigation-context';
3
- export type INavigationHandle = IAnyNavigatorHandle & {
4
- addListener: (event: INavigationEventName, listener: INavigationEventListener) => () => void;
5
- getParent: () => IAnyNavigatorHandle | undefined;
6
- };
7
- export declare function useNavigation(): INavigationHandle;
@@ -1,16 +0,0 @@
1
- // Thin lifecycle wrapper: returns the current screen's navigator handle (push/pop/replace/... for a
2
- // Stack screen, jumpTo/setParams for a Tab screen, openDrawer/... for a Drawer screen) plus
3
- // addListener bound to that route's own emitter - mirrors @react-navigation's
4
- // `navigation.addListener('focus', cb)` surface. All pub/sub logic lives in
5
- // ../../core/navigation-events; this hook only reads NavigationContext and binds identity.
6
- import { useMemo } from 'react';
7
- import { useRequiredNavigationContext } from '../navigation-context.js';
8
- export function useNavigation() {
9
- const context = useRequiredNavigationContext('useNavigation');
10
- const { navigation, emitter, parent } = context;
11
- return useMemo(() => ({
12
- ...navigation,
13
- addListener: emitter.addListener,
14
- getParent: () => parent?.navigation,
15
- }), [navigation, emitter, parent]);
16
- }
@@ -1,2 +0,0 @@
1
- import type { IRoute } from '../../core';
2
- export declare function useRoute(): IRoute<unknown>;
@@ -1,8 +0,0 @@
1
- // Thin lifecycle wrapper: returns the current screen's IRoute from NavigationContext - mirrors
2
- // @react-navigation's useRoute. Zero logic of its own; the route object itself is built by
3
- // stack.ts's render loop from the core reducer's state.
4
- import { useRequiredNavigationContext } from '../navigation-context.js';
5
- export function useRoute() {
6
- const context = useRequiredNavigationContext('useRoute');
7
- return context.route;
8
- }
@@ -1,4 +0,0 @@
1
- import type { INavigatorHandle } from '../../core';
2
- import type { INavigationHandle } from './use-navigation';
3
- export type IStackNavigationHandle = INavigatorHandle & Pick<INavigationHandle, 'addListener' | 'getParent'>;
4
- export declare function useStackNavigation(): IStackNavigationHandle;
@@ -1,14 +0,0 @@
1
- // useNavigation() returns a union (IAnyNavigatorHandle) since it doesn't know which navigator
2
- // mounted the calling component. When a component genuinely knows it only ever renders under a
3
- // Stack (the common case for anything nested a few levels below a Stack screen), this hook
4
- // narrows that union ONCE, here, so call sites never write their own 'push' in navigation check.
5
- import { isStackNavigatorHandle } from '../../core/index.js';
6
- import { useNavigation } from './use-navigation.js';
7
- export function useStackNavigation() {
8
- const navigation = useNavigation();
9
- if (!isStackNavigatorHandle(navigation)) {
10
- throw new Error('useStackNavigation() was called from a component whose nearest navigator is not a Stack. ' +
11
- 'Use useNavigation() instead if this component can render under more than one navigator kind.');
12
- }
13
- return navigation;
14
- }
@@ -1,4 +0,0 @@
1
- import type { ITabNavigatorHandle } from '../../core';
2
- import type { INavigationHandle } from './use-navigation';
3
- export type ITabNavigationHandle = ITabNavigatorHandle & Pick<INavigationHandle, 'addListener' | 'getParent'>;
4
- export declare function useTabNavigation(): ITabNavigationHandle;
@@ -1,12 +0,0 @@
1
- // Twin of use-stack-navigation.ts, narrowing to a Tab handle instead. See that file's header for
2
- // why this exists: it hides the union-narrowing guard inside the library instead of every call site.
3
- import { isTabNavigatorHandle } from '../../core/index.js';
4
- import { useNavigation } from './use-navigation.js';
5
- export function useTabNavigation() {
6
- const navigation = useNavigation();
7
- if (!isTabNavigatorHandle(navigation)) {
8
- throw new Error('useTabNavigation() was called from a component whose nearest navigator is not a Tab. ' +
9
- 'Use useNavigation() instead if this component can render under more than one navigator kind.');
10
- }
11
- return navigation;
12
- }
@@ -1,24 +0,0 @@
1
- import '../register';
2
- export { Stack } from './stack';
3
- export type { INavigatorHandle, IStackProps } from './stack';
4
- export { Screen } from './screen';
5
- export type { IScreenOptionsArgs, IScreenOptionsResolver, IScreenProps } from './screen';
6
- export type { IScreenOptions, IStackAnimation, IStackPresentation } from '../core';
7
- export { useNavigation, useRoute, useIsFocused, useFocusEffect, useNavigationState } from './hooks';
8
- export type { INavigationHandle } from './hooks';
9
- export { useStackNavigation, useTabNavigation, useDrawerNavigation } from './hooks';
10
- export type { IStackNavigationHandle, ITabNavigationHandle, IDrawerNavigationHandle, } from './hooks';
11
- export { NavigationContext } from './navigation-context';
12
- export type { INavigationContextValue, IAnyNavigatorHandle } from './navigation-context';
13
- export { useLinkingIntegration } from './linking';
14
- export type { ILinkingConfig, IScreenLinkingConfig } from '../core';
15
- export { Tab } from './tabs';
16
- export type { ITabNavigatorHandle, ITabProps } from './tabs';
17
- export { TabScreen } from './tab-screen';
18
- export type { ITabScreenOptionsArgs, ITabScreenOptionsResolver, ITabScreenProps, } from './tab-screen';
19
- export type { ITabOptions, ITabBarIcon } from '../core';
20
- export { Drawer } from './drawer';
21
- export type { IDrawerNavigatorHandle, IDrawerProps, IDrawerDescriptorMap } from './drawer';
22
- export { DrawerScreen } from './drawer-screen';
23
- export type { IDrawerScreenOptionsArgs, IDrawerScreenOptionsResolver, IDrawerScreenProps, } from './drawer-screen';
24
- export type { IDrawerOptions, IDrawerScreenOptions, IDrawerType, IDrawerPosition } from '../core';
@@ -1,21 +0,0 @@
1
- // @symbiote-native/navigation/react: the React native-stack navigator over react-native-screens'
2
- // native view primitives. Importing this barrel first registers the native views' ViewConfigs
3
- // (../register, a side-effect import of the three codegen specs - never react-native-screens' own
4
- // React components), then exposes Stack (with Stack.Screen attached) and the navigator handle.
5
- import '../register';
6
- export { Stack } from './stack/index.js';
7
- export { Screen } from './screen.js';
8
- export { useNavigation, useRoute, useIsFocused, useFocusEffect, useNavigationState } from './hooks/index.js';
9
- export { useStackNavigation, useTabNavigation, useDrawerNavigation } from './hooks/index.js';
10
- export { NavigationContext } from './navigation-context.js';
11
- export { useLinkingIntegration } from './linking.js';
12
- // Tab: the bottom-tabs navigator, a PURE-JS UI (no react-native-screens views involved, so no
13
- // extra ViewConfig registration is needed beyond the ../register import above).
14
- export { Tab } from './tabs/index.js';
15
- export { TabScreen } from './tab-screen.js';
16
- // Drawer: the swipeable drawer navigator, a PURE-JS UI (PanResponder + Animated, no
17
- // react-native-screens views involved, so no extra ViewConfig registration is needed beyond the
18
- // ../register import above). See react/drawer.ts's header for the feasibility note re:
19
- // react-native-gesture-handler / react-native-reanimated parity gaps.
20
- export { Drawer } from './drawer/index.js';
21
- export { DrawerScreen } from './drawer-screen.js';
@@ -1,3 +0,0 @@
1
- import type { ILinkingConfig } from '../core';
2
- import type { INavigatorHandle } from '../core';
3
- export declare function useLinkingIntegration(config: ILinkingConfig, navigatorHandle: INavigatorHandle): void;
@@ -1,47 +0,0 @@
1
- // useLinkingIntegration: wires the framework-agnostic linking config (../core's
2
- // resolveRouteFromUrl) onto an existing Stack ref's INavigatorHandle. Deliberately NOT called
3
- // from inside stack.ts - app code owns the wiring (a <Stack ref={...}> plus this hook alongside
4
- // it), the same top-level-prop shape @react-navigation keeps `linking` in on NavigationContainer
5
- // rather than baking it into the router itself.
6
- import { useEffect, useRef } from 'react';
7
- import { Linking, dlog } from '@symbiote-native/engine';
8
- import { resolveRouteFromUrl } from '../core/index.js';
9
- export function useLinkingIntegration(config, navigatorHandle) {
10
- // Refs, not effect deps: `navigatorHandle` is re-created by Stack on every push/pop
11
- // (see stack.ts's useMemo deps including `state.routes.length`), so depending on it directly
12
- // would resubscribe on every navigation instead of once on mount.
13
- const configRef = useRef(config);
14
- configRef.current = config;
15
- const handleRef = useRef(navigatorHandle);
16
- handleRef.current = navigatorHandle;
17
- useEffect(() => {
18
- function applyRoute(url, dispatch) {
19
- const route = resolveRouteFromUrl(configRef.current, url);
20
- if (route === null) {
21
- dlog(`useLinkingIntegration: no route resolved for "${url}"`);
22
- return;
23
- }
24
- dispatch(route.name, route.params);
25
- }
26
- let cancelled = false;
27
- Linking.getInitialURL()
28
- .then(url => {
29
- if (cancelled || url === null)
30
- return;
31
- dlog(`useLinkingIntegration: initial URL "${url}"`);
32
- applyRoute(url, handleRef.current.replace);
33
- })
34
- .catch((error) => {
35
- dlog(`useLinkingIntegration: getInitialURL failed: ${String(error)}`);
36
- });
37
- const subscription = Linking.addEventListener('url', (event) => {
38
- dlog(`useLinkingIntegration: url event "${event.url}"`);
39
- applyRoute(event.url, handleRef.current.push);
40
- });
41
- return () => {
42
- cancelled = true;
43
- subscription.remove();
44
- };
45
- // Mount-once: freshness of config/navigatorHandle is read through the refs above.
46
- }, []);
47
- }
@@ -1,10 +0,0 @@
1
- import type { INavigationEmitter, IRoute, IAnyNavigatorHandle } from '../core';
2
- export type { IAnyNavigatorHandle } from '../core';
3
- export type INavigationContextValue = {
4
- route: IRoute<unknown>;
5
- navigation: IAnyNavigatorHandle;
6
- emitter: INavigationEmitter;
7
- parent?: INavigationContextValue;
8
- };
9
- export declare const NavigationContext: import("react").Context<INavigationContextValue | undefined>;
10
- export declare function useRequiredNavigationContext(hookName: string): INavigationContextValue;
@@ -1,22 +0,0 @@
1
- // The lifecycle half of the framework-agnostic emitter (../core/navigation-events): a plain
2
- // React Context so a screen's subtree can read its own route, navigator handle, and per-route
3
- // emitter without prop-drilling - the same role @react-navigation's NavigationContext /
4
- // NavigationRouteContext play, collapsed into one context since a symbiote screen only ever needs
5
- // its OWN route (no per-navigator param-list generics in v1 scope - see screen.ts). Provided
6
- // per-screen by each of stack.ts/tabs.ts/drawer.ts's render loop, consumed by the hooks in
7
- // ./hooks. `parent` threads the ambient context a navigator read on ITS OWN mount (undefined at
8
- // the root) into the value it provides to its own screens, forming a linked list - this is what
9
- // lets a screen nested inside e.g. a Stack-screen-renders-a-Tab composition reach the enclosing
10
- // Stack via useNavigation().getParent().
11
- import { createContext, useContext } from 'react';
12
- export const NavigationContext = createContext(undefined);
13
- // Every hook in ./hooks needs the same `useContext(NavigationContext)` + missing-provider throw,
14
- // so it's co-located here instead of repeated per hook. `hookName` keeps each hook's own name in
15
- // the thrown message.
16
- export function useRequiredNavigationContext(hookName) {
17
- const context = useContext(NavigationContext);
18
- if (!context) {
19
- throw new Error(`${hookName} must be used within a screen rendered by <Stack>, <Tab>, or <Drawer>`);
20
- }
21
- return context;
22
- }
@@ -1,22 +0,0 @@
1
- import type { FC, ReactElement, RefObject } from 'react';
2
- import type { IRoute } from '../core';
3
- import type { ISearchBarCommands, ISearchBarOptions, IScreenOptions } from '../core';
4
- import type { INavigatorHandle } from '../core';
5
- export type IReactSearchBarOptions = ISearchBarOptions & {
6
- ref?: RefObject<ISearchBarCommands | null>;
7
- };
8
- export type IReactScreenOptions = Omit<IScreenOptions, 'headerSearchBarOptions'> & {
9
- headerSearchBarOptions?: IReactSearchBarOptions;
10
- };
11
- export type IScreenOptionsArgs = {
12
- route: IRoute<unknown>;
13
- navigation: INavigatorHandle;
14
- };
15
- export type IScreenOptionsResolver = (args: IScreenOptionsArgs) => IReactScreenOptions;
16
- export type IScreenProps = {
17
- name: string;
18
- component: FC;
19
- options?: IReactScreenOptions | IScreenOptionsResolver;
20
- initialParams?: unknown;
21
- };
22
- export declare function Screen(_props: IScreenProps): ReactElement | null;
@@ -1,7 +0,0 @@
1
- // Stack.Screen: a declarative marker, never rendered on its own - Stack reads its props via
2
- // React.Children to build the static name -> {component, options} registry, then mounts the
3
- // registered component itself for each pushed route. Mirrors @react-navigation's JSX-config
4
- // screens, minus the linking/param-list generics (v1 scope).
5
- export function Screen(_props) {
6
- return null;
7
- }
@@ -1,13 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import type { INavigatorHandle } from '../../core';
3
- import { Screen } from '../screen';
4
- import type { IReactScreenOptions } from '../screen';
5
- export type { INavigatorHandle } from '../../core';
6
- export type IStackProps = {
7
- initialRouteName?: string;
8
- screenOptions?: IReactScreenOptions;
9
- children?: ReactNode;
10
- };
11
- export declare const Stack: import("react").ForwardRefExoticComponent<IStackProps & import("react").RefAttributes<INavigatorHandle>> & {
12
- Screen: typeof Screen;
13
- };