expo-router 4.1.0-canary-20250221-ef26fed → 5.0.0-sdk-52-router-patches

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 (117) hide show
  1. package/build/ExpoRoot.d.ts.map +1 -1
  2. package/build/ExpoRoot.js +10 -2
  3. package/build/ExpoRoot.js.map +1 -1
  4. package/build/fork/NavigationContainer.js.map +1 -1
  5. package/build/fork/getPathFromState-forks.d.ts.map +1 -1
  6. package/build/fork/getPathFromState-forks.js +0 -1
  7. package/build/fork/getPathFromState-forks.js.map +1 -1
  8. package/build/fork/getStateFromPath-forks.d.ts.map +1 -1
  9. package/build/fork/getStateFromPath-forks.js +2 -1
  10. package/build/fork/getStateFromPath-forks.js.map +1 -1
  11. package/build/fork/getStateFromPath.d.ts.map +1 -1
  12. package/build/fork/getStateFromPath.js +4 -2
  13. package/build/fork/getStateFromPath.js.map +1 -1
  14. package/build/fork/native-stack/createNativeStackNavigator.d.ts +1 -1
  15. package/build/fork/native-stack/createNativeStackNavigator.d.ts.map +1 -1
  16. package/build/fork/native-stack/createNativeStackNavigator.js +1 -2
  17. package/build/fork/native-stack/createNativeStackNavigator.js.map +1 -1
  18. package/build/fork/useBackButton.d.ts +1 -1
  19. package/build/fork/useBackButton.d.ts.map +1 -1
  20. package/build/fork/useBackButton.js.map +1 -1
  21. package/build/fork/useDocumentTitle.d.ts +1 -1
  22. package/build/fork/useDocumentTitle.d.ts.map +1 -1
  23. package/build/fork/useDocumentTitle.js.map +1 -1
  24. package/build/fork/useLinking.d.ts +1 -1
  25. package/build/fork/useLinking.d.ts.map +1 -1
  26. package/build/fork/useLinking.js.map +1 -1
  27. package/build/getDevServer/index.native.d.ts.map +1 -1
  28. package/build/getDevServer/index.native.js +1 -1
  29. package/build/getDevServer/index.native.js.map +1 -1
  30. package/build/getLinkingConfig.d.ts +8 -2
  31. package/build/getLinkingConfig.d.ts.map +1 -1
  32. package/build/getLinkingConfig.js +10 -2
  33. package/build/getLinkingConfig.js.map +1 -1
  34. package/build/global-state/router-store.d.ts.map +1 -1
  35. package/build/global-state/router-store.js.map +1 -1
  36. package/build/global-state/routing.d.ts +7 -0
  37. package/build/global-state/routing.d.ts.map +1 -1
  38. package/build/global-state/routing.js +7 -25
  39. package/build/global-state/routing.js.map +1 -1
  40. package/build/head/ExpoHead.d.ts +1 -1
  41. package/build/head/ExpoHead.d.ts.map +1 -1
  42. package/build/head/ExpoHead.ios.d.ts.map +1 -1
  43. package/build/head/ExpoHead.ios.js +18 -3
  44. package/build/head/ExpoHead.ios.js.map +1 -1
  45. package/build/head/ExpoHead.js +3 -3
  46. package/build/head/ExpoHead.js.map +1 -1
  47. package/build/layouts/DrawerClient.d.ts +18 -40
  48. package/build/layouts/DrawerClient.d.ts.map +1 -1
  49. package/build/layouts/StackClient.d.ts +37 -43
  50. package/build/layouts/StackClient.d.ts.map +1 -1
  51. package/build/layouts/StackClient.js +176 -5
  52. package/build/layouts/StackClient.js.map +1 -1
  53. package/build/layouts/TabsClient.d.ts +18 -40
  54. package/build/layouts/TabsClient.d.ts.map +1 -1
  55. package/build/layouts/withLayoutContext.d.ts +2 -2
  56. package/build/layouts/withLayoutContext.d.ts.map +1 -1
  57. package/build/layouts/withLayoutContext.js +8 -4
  58. package/build/layouts/withLayoutContext.js.map +1 -1
  59. package/build/link/Link.d.ts +1 -1
  60. package/build/link/Link.d.ts.map +1 -1
  61. package/build/link/Link.js +2 -1
  62. package/build/link/Link.js.map +1 -1
  63. package/build/link/useLinkHooks.d.ts +8 -0
  64. package/build/link/useLinkHooks.d.ts.map +1 -1
  65. package/build/link/useLinkHooks.js.map +1 -1
  66. package/build/rsc/router/client.js +1 -1
  67. package/build/rsc/router/client.js.map +1 -1
  68. package/build/rsc/router/host.d.ts +5 -5
  69. package/build/rsc/router/host.d.ts.map +1 -1
  70. package/build/rsc/router/host.js.map +1 -1
  71. package/build/testing-library/index.d.ts +1 -1
  72. package/build/testing-library/index.d.ts.map +1 -1
  73. package/build/testing-library/index.js.map +1 -1
  74. package/build/testing-library/mock-config.d.ts +7 -2
  75. package/build/testing-library/mock-config.d.ts.map +1 -1
  76. package/build/ui/TabContext.d.ts +29 -19
  77. package/build/ui/TabContext.d.ts.map +1 -1
  78. package/build/ui/TabRouter.d.ts +1 -0
  79. package/build/ui/TabRouter.d.ts.map +1 -1
  80. package/build/ui/Tabs.d.ts +39 -30
  81. package/build/ui/Tabs.d.ts.map +1 -1
  82. package/build/ui/Tabs.js +12 -2
  83. package/build/ui/Tabs.js.map +1 -1
  84. package/build/ui/common.d.ts.map +1 -1
  85. package/build/ui/common.js +6 -8
  86. package/build/ui/common.js.map +1 -1
  87. package/build/ui/useComponent.d.ts +1 -1
  88. package/build/ui/useComponent.d.ts.map +1 -1
  89. package/build/ui/useComponent.js.map +1 -1
  90. package/build/useNavigation.d.ts.map +1 -1
  91. package/build/useNavigation.js +3 -1
  92. package/build/useNavigation.js.map +1 -1
  93. package/build/useScreens.d.ts +6 -4
  94. package/build/useScreens.d.ts.map +1 -1
  95. package/build/useScreens.js +38 -47
  96. package/build/useScreens.js.map +1 -1
  97. package/build/views/Navigator.d.ts +3 -2
  98. package/build/views/Navigator.d.ts.map +1 -1
  99. package/build/views/Navigator.js +3 -2
  100. package/build/views/Navigator.js.map +1 -1
  101. package/build/views/Try.d.ts +1 -1
  102. package/package.json +19 -16
  103. package/vendor/react-helmet-async/LICENSE +201 -0
  104. package/vendor/react-helmet-async/README.md +205 -0
  105. package/vendor/react-helmet-async/lib/Dispatcher.d.ts +23 -0
  106. package/vendor/react-helmet-async/lib/HelmetData.d.ts +26 -0
  107. package/vendor/react-helmet-async/lib/Provider.d.ts +17 -0
  108. package/vendor/react-helmet-async/lib/client.d.ts +3 -0
  109. package/vendor/react-helmet-async/lib/constants.d.ts +58 -0
  110. package/vendor/react-helmet-async/lib/index.d.ts +38 -0
  111. package/vendor/react-helmet-async/lib/index.esm.js +798 -0
  112. package/vendor/react-helmet-async/lib/index.js +829 -0
  113. package/vendor/react-helmet-async/lib/server.d.ts +44 -0
  114. package/vendor/react-helmet-async/lib/types.d.ts +85 -0
  115. package/vendor/react-helmet-async/lib/utils.d.ts +33 -0
  116. package/vendor/react-helmet-async/package_original.json +49 -0
  117. package/vendor/react-helmet-async/vendor.md +3 -0
@@ -1,14 +1,14 @@
1
- /// <reference types="react" />
2
- import { ParamListBase, StackNavigationState } from '@react-navigation/native';
1
+ import { ParamListBase, StackRouter as RNStackRouter, StackNavigationState } from '@react-navigation/native';
3
2
  import { NativeStackNavigationEventMap, NativeStackNavigationOptions } from '@react-navigation/native-stack';
4
- export declare const Stack: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/native-stack").NativeStackNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenOptions" | "screenListeners" | "screenLayout" | "UNSTABLE_getStateForRouteNamesChange"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
3
+ import { ComponentProps } from 'react';
4
+ declare const RNStack: import("react").ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/native-stack").NativeStackNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
5
5
  children: import("react").ReactNode;
6
6
  layout?: ((props: {
7
7
  state: StackNavigationState<ParamListBase>;
8
8
  navigation: import("@react-navigation/native").NavigationHelpers<ParamListBase, {}>;
9
9
  descriptors: Record<string, import("@react-navigation/native").Descriptor<NativeStackNavigationOptions, import("@react-navigation/native").NavigationProp<ParamListBase, string, string | undefined, StackNavigationState<ParamListBase>, NativeStackNavigationOptions, NativeStackNavigationEventMap>, import("@react-navigation/native").RouteProp<ParamListBase, string>>>;
10
10
  children: import("react").ReactNode;
11
- }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) | undefined;
11
+ }) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>) | undefined;
12
12
  screenListeners?: Partial<{
13
13
  transitionStart: import("@react-navigation/native").EventListenerCallback<NativeStackNavigationEventMap & import("@react-navigation/native").EventMapCore<StackNavigationState<ParamListBase>>, "transitionStart", unknown>;
14
14
  transitionEnd: import("@react-navigation/native").EventListenerCallback<NativeStackNavigationEventMap & import("@react-navigation/native").EventMapCore<StackNavigationState<ParamListBase>>, "transitionEnd", unknown>;
@@ -40,35 +40,24 @@ export declare const Stack: import("react").ForwardRefExoticComponent<Omit<Omit<
40
40
  route: import("@react-navigation/native").RouteProp<ParamListBase, string>;
41
41
  navigation: import("@react-navigation/native-stack").NativeStackNavigationProp<ParamListBase, string, undefined>;
42
42
  theme: ReactNavigation.Theme;
43
- children: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
44
- }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) | undefined;
45
- UNSTABLE_getStateForRouteNamesChange?: ((state: Readonly<{
46
- key: string;
47
- index: number;
48
- routeNames: string[];
49
- history?: unknown[] | undefined;
50
- routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
43
+ children: import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
44
+ }) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>) | undefined;
45
+ UNSTABLE_router?: (<Action extends Readonly<{
51
46
  type: string;
52
- stale: false;
53
- }>) => import("@react-navigation/native").PartialState<Readonly<{
54
- key: string;
55
- index: number;
56
- routeNames: string[];
57
- history?: unknown[] | undefined;
58
- routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
59
- type: string;
60
- stale: false;
61
- }>> | undefined) | undefined;
47
+ payload?: object | undefined;
48
+ source?: string | undefined;
49
+ target?: string | undefined;
50
+ }>>(original: import("@react-navigation/native").Router<StackNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<StackNavigationState<ParamListBase>, Action>>) | undefined;
62
51
  } & {
63
52
  id?: undefined;
64
- }, "children"> & Partial<Pick<Omit<import("@react-navigation/native-stack").NativeStackNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenOptions" | "screenListeners" | "screenLayout" | "UNSTABLE_getStateForRouteNamesChange"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
53
+ }, "children"> & Partial<Pick<Omit<import("@react-navigation/native-stack").NativeStackNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
65
54
  children: import("react").ReactNode;
66
55
  layout?: ((props: {
67
56
  state: StackNavigationState<ParamListBase>;
68
57
  navigation: import("@react-navigation/native").NavigationHelpers<ParamListBase, {}>;
69
58
  descriptors: Record<string, import("@react-navigation/native").Descriptor<NativeStackNavigationOptions, import("@react-navigation/native").NavigationProp<ParamListBase, string, string | undefined, StackNavigationState<ParamListBase>, NativeStackNavigationOptions, NativeStackNavigationEventMap>, import("@react-navigation/native").RouteProp<ParamListBase, string>>>;
70
59
  children: import("react").ReactNode;
71
- }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) | undefined;
60
+ }) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>) | undefined;
72
61
  screenListeners?: Partial<{
73
62
  transitionStart: import("@react-navigation/native").EventListenerCallback<NativeStackNavigationEventMap & import("@react-navigation/native").EventMapCore<StackNavigationState<ParamListBase>>, "transitionStart", unknown>;
74
63
  transitionEnd: import("@react-navigation/native").EventListenerCallback<NativeStackNavigationEventMap & import("@react-navigation/native").EventMapCore<StackNavigationState<ParamListBase>>, "transitionEnd", unknown>;
@@ -100,29 +89,34 @@ export declare const Stack: import("react").ForwardRefExoticComponent<Omit<Omit<
100
89
  route: import("@react-navigation/native").RouteProp<ParamListBase, string>;
101
90
  navigation: import("@react-navigation/native-stack").NativeStackNavigationProp<ParamListBase, string, undefined>;
102
91
  theme: ReactNavigation.Theme;
103
- children: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
104
- }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) | undefined;
105
- UNSTABLE_getStateForRouteNamesChange?: ((state: Readonly<{
106
- key: string;
107
- index: number;
108
- routeNames: string[];
109
- history?: unknown[] | undefined;
110
- routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
111
- type: string;
112
- stale: false;
113
- }>) => import("@react-navigation/native").PartialState<Readonly<{
114
- key: string;
115
- index: number;
116
- routeNames: string[];
117
- history?: unknown[] | undefined;
118
- routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
92
+ children: import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
93
+ }) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>) | undefined;
94
+ UNSTABLE_router?: (<Action extends Readonly<{
119
95
  type: string;
120
- stale: false;
121
- }>> | undefined) | undefined;
96
+ payload?: object | undefined;
97
+ source?: string | undefined;
98
+ target?: string | undefined;
99
+ }>>(original: import("@react-navigation/native").Router<StackNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<StackNavigationState<ParamListBase>, Action>>) | undefined;
122
100
  } & {
123
101
  id?: undefined;
124
102
  }, "children">> & import("react").RefAttributes<unknown>> & {
125
- Screen: (props: import("..").ScreenProps<NativeStackNavigationOptions, StackNavigationState<ParamListBase>, NativeStackNavigationEventMap>) => null;
103
+ Screen: (props: import("../useScreens").ScreenProps<NativeStackNavigationOptions, StackNavigationState<ParamListBase>, NativeStackNavigationEventMap>) => null;
104
+ };
105
+ /**
106
+ * React Navigation matches a screen by its name or a 'getID' function that uniquely identifies a screen.
107
+ * When a screen has been uniquely identified, the Stack can only have one instance of that screen.
108
+ *
109
+ * Expo Router allows for a screen to be matched by name and path params, a 'getID' function or a singular id.
110
+ *
111
+ * Instead of reimplementing the entire StackRouter, we can override the getStateForAction method to handle the singular screen logic.
112
+ *
113
+ */
114
+ export declare const stackRouterOverride: NonNullable<ComponentProps<typeof RNStack>['UNSTABLE_router']>;
115
+ declare const Stack: ((props: ComponentProps<typeof RNStack>) => import("react").JSX.Element) & {
116
+ Screen: (props: ComponentProps<typeof RNStack.Screen> & {
117
+ singular?: boolean;
118
+ }) => null;
126
119
  };
127
120
  export default Stack;
121
+ export declare const StackRouter: typeof RNStackRouter;
128
122
  //# sourceMappingURL=StackClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StackClient.d.ts","sourceRoot":"","sources":["../../src/layouts/StackClient.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC7B,MAAM,gCAAgC,CAAC;AAOxC,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKK,CAAC;AAExB,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"StackClient.d.ts","sourceRoot":"","sources":["../../src/layouts/StackClient.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,aAAa,EAKb,WAAW,IAAI,aAAa,EAE5B,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAE7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AASvC,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKU,CAAC;AAcxB;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,cAAc,CAAC,OAAO,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAyG9F,CAAC;AAoEF,QAAA,MAAM,KAAK,WACD,eAAe,cAAc,CAAC;oBAK3B,eAAe,OAAO,cAAc,CAAC,GAAG;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAClE,IAAI;CAEZ,CAAC;AAEF,eAAe,KAAK,CAAC;AAErB,eAAO,MAAM,WAAW,EAAE,OAAO,aAMhC,CAAC"}
@@ -1,10 +1,181 @@
1
1
  'use client';
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Stack = void 0;
4
+ exports.StackRouter = exports.stackRouterOverride = void 0;
5
+ const native_1 = require("@react-navigation/native");
6
+ const native_stack_1 = require("@react-navigation/native-stack");
5
7
  const withLayoutContext_1 = require("./withLayoutContext");
6
- const createNativeStackNavigator_1 = require("../fork/native-stack/createNativeStackNavigator");
7
- const NativeStackNavigator = (0, createNativeStackNavigator_1.createNativeStackNavigator)().Navigator;
8
- exports.Stack = (0, withLayoutContext_1.withLayoutContext)(NativeStackNavigator);
9
- exports.default = exports.Stack;
8
+ const useScreens_1 = require("../useScreens");
9
+ const NativeStackNavigator = (0, native_stack_1.createNativeStackNavigator)().Navigator;
10
+ const RNStack = (0, withLayoutContext_1.withLayoutContext)(NativeStackNavigator);
11
+ function isStackAction(action) {
12
+ return (action.type === 'PUSH' ||
13
+ action.type === 'NAVIGATE' ||
14
+ action.type === 'POP' ||
15
+ action.type === 'POP_TO_TOP' ||
16
+ action.type === 'REPLACE');
17
+ }
18
+ /**
19
+ * React Navigation matches a screen by its name or a 'getID' function that uniquely identifies a screen.
20
+ * When a screen has been uniquely identified, the Stack can only have one instance of that screen.
21
+ *
22
+ * Expo Router allows for a screen to be matched by name and path params, a 'getID' function or a singular id.
23
+ *
24
+ * Instead of reimplementing the entire StackRouter, we can override the getStateForAction method to handle the singular screen logic.
25
+ *
26
+ */
27
+ const stackRouterOverride = (original) => {
28
+ return {
29
+ getStateForAction: (state, action, options) => {
30
+ if (action.target && action.target !== state.key) {
31
+ return null;
32
+ }
33
+ if (!isStackAction(action)) {
34
+ return original.getStateForAction(state, action, options);
35
+ }
36
+ // The dynamic getId added to an action, `router.push('screen', { singular: true })`
37
+ const actionSingularOptions = action.payload && 'singular' in action.payload
38
+ ? action.payload.singular
39
+ : undefined;
40
+ // Handle if 'getID' or 'singular' is set.
41
+ function getIdFunction(fn) {
42
+ // Actions can be fired by the user, so we do need to validate their structure.
43
+ if (!('payload' in action) ||
44
+ !action.payload ||
45
+ !('name' in action.payload) ||
46
+ typeof action.payload.name !== 'string') {
47
+ return;
48
+ }
49
+ const name = action.payload.name;
50
+ return (
51
+ // The dynamic singular added to an action, `router.push('screen', { singular: () => 'id' })`
52
+ getActionSingularIdFn(actionSingularOptions, name) ||
53
+ // The static getId added as a prop to `<Screen singular />` or `<Screen getId={} />`
54
+ options.routeGetIdList[name] ||
55
+ // The custom singular added by Expo Router to support its concept of `navigate`
56
+ fn);
57
+ }
58
+ switch (action.type) {
59
+ case 'PUSH': {
60
+ /**
61
+ * PUSH should always push
62
+ *
63
+ * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,
64
+ * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.
65
+ */
66
+ const nextState = original.getStateForAction(state, action, {
67
+ ...options,
68
+ routeGetIdList: {
69
+ ...options.routeGetIdList,
70
+ [action.payload.name]: getIdFunction(),
71
+ },
72
+ });
73
+ /**
74
+ * React Navigation doesn't support dynamic getId function on the action. Because of this,
75
+ * can you enter a state where the screen is pushed multiple times but the normal getStateForAction
76
+ * doesn't remove the duplicates. We need to filter the state to only have singular screens.
77
+ */
78
+ return actionSingularOptions
79
+ ? filterSingular(nextState, actionSingularOptions)
80
+ : nextState;
81
+ }
82
+ case 'NAVIGATE': {
83
+ /**
84
+ * NAVIGATE should push unless the current name & route params of the current and target screen match.
85
+ * Search params and hashes should be ignored.
86
+ *
87
+ * If the name, route params & search params match, no action is taken.
88
+ * If both the name and route params match, the screen is replaced.
89
+ * If the name / route params do not match, the screen is pushed.
90
+ *
91
+ * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,
92
+ * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.
93
+ */
94
+ const nextState = original.getStateForAction(state, action, {
95
+ ...options,
96
+ routeGetIdList: {
97
+ ...options.routeGetIdList,
98
+ [action.payload.name]: getIdFunction((options) => {
99
+ return (0, useScreens_1.getSingularId)(action.payload.name, options);
100
+ }),
101
+ },
102
+ });
103
+ /**
104
+ * React Navigation doesn't support dynamic getId function on the action. Because of this,
105
+ * can you enter a state where the screen is pushed multiple times but the normal getStateForAction
106
+ * doesn't remove the duplicates. We need to filter the state to only have singular screens.
107
+ */
108
+ return actionSingularOptions
109
+ ? filterSingular(nextState, actionSingularOptions)
110
+ : nextState;
111
+ }
112
+ default: {
113
+ return original.getStateForAction(state, action, options);
114
+ }
115
+ }
116
+ },
117
+ };
118
+ };
119
+ exports.stackRouterOverride = stackRouterOverride;
120
+ function getActionSingularIdFn(actionGetId, name) {
121
+ if (typeof actionGetId === 'function') {
122
+ return (options) => actionGetId(name, options.params ?? {});
123
+ }
124
+ else if (actionGetId === true) {
125
+ return (options) => (0, useScreens_1.getSingularId)(name, options);
126
+ }
127
+ return undefined;
128
+ }
129
+ /**
130
+ * If there is a dynamic singular on an action, then we need to filter the state to only have singular screens.
131
+ * As multiples may have been added before we did the singular navigation.
132
+ */
133
+ function filterSingular(state, singular) {
134
+ if (!state || !singular) {
135
+ return state;
136
+ }
137
+ if (!state.routes) {
138
+ return state;
139
+ }
140
+ const currentIndex = state.index || state.routes.length - 1;
141
+ const current = state.routes[currentIndex];
142
+ const name = current.name;
143
+ const getId = getActionSingularIdFn(singular, name);
144
+ if (!getId) {
145
+ return state;
146
+ }
147
+ const id = getId({ params: current.params });
148
+ if (!id) {
149
+ return state;
150
+ }
151
+ // TypeScript needs a type assertion here for the filter to work.
152
+ let routes = state.routes;
153
+ routes = routes.filter((route, index) => {
154
+ // If the route is the current route, keep it.
155
+ if (index === currentIndex) {
156
+ return true;
157
+ }
158
+ // Remove all other routes with the same name and id.
159
+ return name !== route.name || id !== getId({ params: route.params });
160
+ });
161
+ return {
162
+ ...state,
163
+ index: routes.length - 1,
164
+ routes,
165
+ };
166
+ }
167
+ const Stack = Object.assign((props) => {
168
+ return <RNStack {...props} UNSTABLE_router={exports.stackRouterOverride}/>;
169
+ }, {
170
+ Screen: RNStack.Screen,
171
+ });
172
+ exports.default = Stack;
173
+ const StackRouter = (options) => {
174
+ const router = (0, native_1.StackRouter)(options);
175
+ return {
176
+ ...router,
177
+ ...(0, exports.stackRouterOverride)(router),
178
+ };
179
+ };
180
+ exports.StackRouter = StackRouter;
10
181
  //# sourceMappingURL=StackClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StackClient.js","sourceRoot":"","sources":["../../src/layouts/StackClient.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;AAOb,2DAAwD;AACxD,gGAA6F;AAE7F,MAAM,oBAAoB,GAAG,IAAA,uDAA0B,GAAE,CAAC,SAAS,CAAC;AAEvD,QAAA,KAAK,GAAG,IAAA,qCAAiB,EAKpC,oBAAoB,CAAC,CAAC;AAExB,kBAAe,aAAK,CAAC","sourcesContent":["'use client';\nimport { ParamListBase, StackNavigationState } from '@react-navigation/native';\nimport {\n NativeStackNavigationEventMap,\n NativeStackNavigationOptions,\n} from '@react-navigation/native-stack';\n\nimport { withLayoutContext } from './withLayoutContext';\nimport { createNativeStackNavigator } from '../fork/native-stack/createNativeStackNavigator';\n\nconst NativeStackNavigator = createNativeStackNavigator().Navigator;\n\nexport const Stack = withLayoutContext<\n NativeStackNavigationOptions,\n typeof NativeStackNavigator,\n StackNavigationState<ParamListBase>,\n NativeStackNavigationEventMap\n>(NativeStackNavigator);\n\nexport default Stack;\n"]}
1
+ {"version":3,"file":"StackClient.js","sourceRoot":"","sources":["../../src/layouts/StackClient.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;AACb,qDAWkC;AAClC,iEAIwC;AAGxC,2DAAwD;AACxD,8CAA+D;AAI/D,MAAM,oBAAoB,G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AI,CAAC,EAAE,EAAE;QACP,OAAO,KAAK,CAAC;KACd;IAED,iEAAiE;IACjE,IAAI,MAAM,GAAG,KAAK,CAAC,MAA2D,CAAC;IAC/E,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACtC,8CAA8C;QAC9C,IAAI,KAAK,KAAK,YAAY,EAAE;YAC1B,OAAO,IAAI,CAAC;SACb;QAED,qDAAqD;QACrD,OAAO,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,KAAK;QACR,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC;QACxB,MAAM;KACP,CAAC;AACJ,CAAC;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,CAAC,KAAqC,EAAE,EAAE;IACxC,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,2BAAmB,CAAC,EAAG,CAAC;AACtE,CAAC,EACD;IACE,MAAM,EAAE,OAAO,CAAC,MAEP;CACV,CACF,CAAC;AAEF,kBAAe,KAAK,CAAC;AAEd,MAAM,WAAW,GAAyB,CAAC,OAAO,EAAE,EAAE;IAC3D,MAAM,MAAM,GAAG,IAAA,oBAAa,EAAC,OAAO,CAAC,CAAC;IACtC,OAAO;QACL,GAAG,MAAM;QACT,GAAG,IAAA,2BAAmB,EAAC,MAAM,CAAC;KAC/B,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB","sourcesContent":["'use client';\nimport {\n CommonNavigationAction,\n NavigationAction,\n ParamListBase,\n PartialRoute,\n PartialState,\n Route,\n RouterConfigOptions,\n StackRouter as RNStackRouter,\n StackActionType,\n StackNavigationState,\n} from '@react-navigation/native';\nimport {\n NativeStackNavigationEventMap,\n NativeStackNavigationOptions,\n createNativeStackNavigator,\n} from '@react-navigation/native-stack';\nimport { ComponentProps } from 'react';\n\nimport { withLayoutContext } from './withLayoutContext';\nimport { SingularOptions, getSingularId } from '../useScreens';\n\ntype GetId = NonNullable<RouterConfigOptions['routeGetIdList'][string]>;\n\nconst NativeStackNavigator = createNativeStackNavigator().Navigator;\n\nconst RNStack = withLayoutContext<\n NativeStackNavigationOptions,\n typeof NativeStackNavigator,\n StackNavigationState<ParamListBase>,\n NativeStackNavigationEventMap\n>(NativeStackNavigator);\n\nfunction isStackAction(\n action: NavigationAction\n): action is StackActionType | Extract<CommonNavigationAction, { type: 'NAVIGATE' }> {\n return (\n action.type === 'PUSH' ||\n action.type === 'NAVIGATE' ||\n action.type === 'POP' ||\n action.type === 'POP_TO_TOP' ||\n action.type === 'REPLACE'\n );\n}\n\n/**\n * React Navigation matches a screen by its name or a 'getID' function that uniquely identifies a screen.\n * When a screen has been uniquely identified, the Stack can only have one instance of that screen.\n *\n * Expo Router allows for a screen to be matched by name and path params, a 'getID' function or a singular id.\n *\n * Instead of reimplementing the entire StackRouter, we can override the getStateForAction method to handle the singular screen logic.\n *\n */\nexport const stackRouterOverride: NonNullable<ComponentProps<typeof RNStack>['UNSTABLE_router']> = (\n original\n) => {\n return {\n getStateForAction: (state, action, options) => {\n if (action.target && action.target !== state.key) {\n return null;\n }\n\n if (!isStackAction(action)) {\n return original.getStateForAction(state, action, options);\n }\n\n // The dynamic getId added to an action, `router.push('screen', { singular: true })`\n const actionSingularOptions =\n action.payload && 'singular' in action.payload\n ? (action.payload.singular as SingularOptions)\n : undefined;\n\n // Handle if 'getID' or 'singular' is set.\n function getIdFunction(fn?: GetId): GetId | undefined {\n // Actions can be fired by the user, so we do need to validate their structure.\n if (\n !('payload' in action) ||\n !action.payload ||\n !('name' in action.payload) ||\n typeof action.payload.name !== 'string'\n ) {\n return;\n }\n\n const name = action.payload.name;\n\n return (\n // The dynamic singular added to an action, `router.push('screen', { singular: () => 'id' })`\n getActionSingularIdFn(actionSingularOptions, name) ||\n // The static getId added as a prop to `<Screen singular />` or `<Screen getId={} />`\n options.routeGetIdList[name] ||\n // The custom singular added by Expo Router to support its concept of `navigate`\n fn\n );\n }\n\n switch (action.type) {\n case 'PUSH': {\n /**\n * PUSH should always push\n *\n * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,\n * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.\n */\n const nextState = original.getStateForAction(state, action, {\n ...options,\n routeGetIdList: {\n ...options.routeGetIdList,\n [action.payload.name]: getIdFunction(),\n },\n });\n\n /**\n * React Navigation doesn't support dynamic getId function on the action. Because of this,\n * can you enter a state where the screen is pushed multiple times but the normal getStateForAction\n * doesn't remove the duplicates. We need to filter the state to only have singular screens.\n */\n return actionSingularOptions\n ? filterSingular(nextState, actionSingularOptions)\n : nextState;\n }\n case 'NAVIGATE': {\n /**\n * NAVIGATE should push unless the current name & route params of the current and target screen match.\n * Search params and hashes should be ignored.\n *\n * If the name, route params & search params match, no action is taken.\n * If both the name and route params match, the screen is replaced.\n * If the name / route params do not match, the screen is pushed.\n *\n * If 'getID' or 'singular' is set and a match is found, instead of pushing a new screen,\n * the existing screen will be moved to the HEAD of the stack. If there are multiple matches, the rest will be removed.\n */\n const nextState = original.getStateForAction(state, action, {\n ...options,\n routeGetIdList: {\n ...options.routeGetIdList,\n [action.payload.name]: getIdFunction((options) => {\n return getSingularId(action.payload.name, options);\n }),\n },\n });\n\n /**\n * React Navigation doesn't support dynamic getId function on the action. Because of this,\n * can you enter a state where the screen is pushed multiple times but the normal getStateForAction\n * doesn't remove the duplicates. We need to filter the state to only have singular screens.\n */\n return actionSingularOptions\n ? filterSingular(nextState, actionSingularOptions)\n : nextState;\n }\n default: {\n return original.getStateForAction(state, action, options);\n }\n }\n },\n };\n};\n\nfunction getActionSingularIdFn(\n actionGetId: SingularOptions | undefined,\n name: string\n): GetId | undefined {\n if (typeof actionGetId === 'function') {\n return (options) => actionGetId(name, options.params ?? {});\n } else if (actionGetId === true) {\n return (options) => getSingularId(name, options);\n }\n\n return undefined;\n}\n\n/**\n * If there is a dynamic singular on an action, then we need to filter the state to only have singular screens.\n * As multiples may have been added before we did the singular navigation.\n */\nfunction filterSingular<\n T extends\n | StackNavigationState<ParamListBase>\n | PartialState<StackNavigationState<ParamListBase>>\n | null,\n>(state: T, singular: SingularOptions): T {\n if (!state || !singular) {\n return state;\n }\n\n if (!state.routes) {\n return state;\n }\n\n const currentIndex = state.index || state.routes.length - 1;\n const current = state.routes[currentIndex];\n const name = current.name;\n\n const getId = getActionSingularIdFn(singular, name);\n\n if (!getId) {\n return state;\n }\n\n const id = getId({ params: current.params });\n\n if (!id) {\n return state;\n }\n\n // TypeScript needs a type assertion here for the filter to work.\n let routes = state.routes as PartialRoute<Route<string, object | undefined>>[];\n routes = routes.filter((route, index) => {\n // If the route is the current route, keep it.\n if (index === currentIndex) {\n return true;\n }\n\n // Remove all other routes with the same name and id.\n return name !== route.name || id !== getId({ params: route.params });\n });\n\n return {\n ...state,\n index: routes.length - 1,\n routes,\n };\n}\n\nconst Stack = Object.assign(\n (props: ComponentProps<typeof RNStack>) => {\n return <RNStack {...props} UNSTABLE_router={stackRouterOverride} />;\n },\n {\n Screen: RNStack.Screen as (\n props: ComponentProps<typeof RNStack.Screen> & { singular?: boolean }\n ) => null,\n }\n);\n\nexport default Stack;\n\nexport const StackRouter: typeof RNStackRouter = (options) => {\n const router = RNStackRouter(options);\n return {\n ...router,\n ...stackRouterOverride(router),\n };\n};\n"]}
@@ -5,14 +5,14 @@ import { Href } from '../types';
5
5
  type TabsProps = BottomTabNavigationOptions & {
6
6
  href?: Href | null;
7
7
  };
8
- export declare const Tabs: React.ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/bottom-tabs").BottomTabNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenOptions" | "screenListeners" | "screenLayout" | "UNSTABLE_getStateForRouteNamesChange"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
8
+ export declare const Tabs: React.ForwardRefExoticComponent<Omit<Omit<import("@react-navigation/bottom-tabs").BottomTabNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
9
9
  children: React.ReactNode;
10
10
  layout?: ((props: {
11
11
  state: TabNavigationState<ParamListBase>;
12
12
  navigation: import("@react-navigation/native").NavigationHelpers<ParamListBase, {}>;
13
13
  descriptors: Record<string, import("@react-navigation/native").Descriptor<BottomTabNavigationOptions, import("@react-navigation/native").NavigationProp<ParamListBase, string, string | undefined, TabNavigationState<ParamListBase>, BottomTabNavigationOptions, BottomTabNavigationEventMap>, import("@react-navigation/native").RouteProp<ParamListBase, string>>>;
14
14
  children: React.ReactNode;
15
- }) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
15
+ }) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>) | undefined;
16
16
  screenListeners?: Partial<{
17
17
  tabPress: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "tabPress", true>;
18
18
  tabLongPress: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "tabLongPress", unknown>;
@@ -44,35 +44,24 @@ export declare const Tabs: React.ForwardRefExoticComponent<Omit<Omit<import("@re
44
44
  route: import("@react-navigation/native").RouteProp<ParamListBase, string>;
45
45
  navigation: import("@react-navigation/bottom-tabs").BottomTabNavigationProp<ParamListBase, string, undefined>;
46
46
  theme: ReactNavigation.Theme;
47
- children: React.ReactElement<any, string | React.JSXElementConstructor<any>>;
48
- }) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
49
- UNSTABLE_getStateForRouteNamesChange?: ((state: Readonly<{
50
- key: string;
51
- index: number;
52
- routeNames: string[];
53
- history?: unknown[] | undefined;
54
- routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
47
+ children: React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
48
+ }) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>) | undefined;
49
+ UNSTABLE_router?: (<Action extends Readonly<{
55
50
  type: string;
56
- stale: false;
57
- }>) => import("@react-navigation/native").PartialState<Readonly<{
58
- key: string;
59
- index: number;
60
- routeNames: string[];
61
- history?: unknown[] | undefined;
62
- routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
63
- type: string;
64
- stale: false;
65
- }>> | undefined) | undefined;
51
+ payload?: object | undefined;
52
+ source?: string | undefined;
53
+ target?: string | undefined;
54
+ }>>(original: import("@react-navigation/native").Router<TabNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<TabNavigationState<ParamListBase>, Action>>) | undefined;
66
55
  } & {
67
56
  id?: undefined;
68
- }, "children"> & Partial<Pick<Omit<import("@react-navigation/bottom-tabs").BottomTabNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenOptions" | "screenListeners" | "screenLayout" | "UNSTABLE_getStateForRouteNamesChange"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
57
+ }, "children"> & Partial<Pick<Omit<import("@react-navigation/bottom-tabs").BottomTabNavigatorProps, "initialRouteName" | "children" | "layout" | "id" | "screenListeners" | "screenOptions" | "screenLayout" | "UNSTABLE_router"> & import("@react-navigation/native").DefaultRouterOptions<string> & {
69
58
  children: React.ReactNode;
70
59
  layout?: ((props: {
71
60
  state: TabNavigationState<ParamListBase>;
72
61
  navigation: import("@react-navigation/native").NavigationHelpers<ParamListBase, {}>;
73
62
  descriptors: Record<string, import("@react-navigation/native").Descriptor<BottomTabNavigationOptions, import("@react-navigation/native").NavigationProp<ParamListBase, string, string | undefined, TabNavigationState<ParamListBase>, BottomTabNavigationOptions, BottomTabNavigationEventMap>, import("@react-navigation/native").RouteProp<ParamListBase, string>>>;
74
63
  children: React.ReactNode;
75
- }) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
64
+ }) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>) | undefined;
76
65
  screenListeners?: Partial<{
77
66
  tabPress: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "tabPress", true>;
78
67
  tabLongPress: import("@react-navigation/native").EventListenerCallback<BottomTabNavigationEventMap & import("@react-navigation/native").EventMapCore<TabNavigationState<ParamListBase>>, "tabLongPress", unknown>;
@@ -104,25 +93,14 @@ export declare const Tabs: React.ForwardRefExoticComponent<Omit<Omit<import("@re
104
93
  route: import("@react-navigation/native").RouteProp<ParamListBase, string>;
105
94
  navigation: import("@react-navigation/bottom-tabs").BottomTabNavigationProp<ParamListBase, string, undefined>;
106
95
  theme: ReactNavigation.Theme;
107
- children: React.ReactElement<any, string | React.JSXElementConstructor<any>>;
108
- }) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
109
- UNSTABLE_getStateForRouteNamesChange?: ((state: Readonly<{
110
- key: string;
111
- index: number;
112
- routeNames: string[];
113
- history?: unknown[] | undefined;
114
- routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
115
- type: string;
116
- stale: false;
117
- }>) => import("@react-navigation/native").PartialState<Readonly<{
118
- key: string;
119
- index: number;
120
- routeNames: string[];
121
- history?: unknown[] | undefined;
122
- routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
96
+ children: React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
97
+ }) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>) | undefined;
98
+ UNSTABLE_router?: (<Action extends Readonly<{
123
99
  type: string;
124
- stale: false;
125
- }>> | undefined) | undefined;
100
+ payload?: object | undefined;
101
+ source?: string | undefined;
102
+ target?: string | undefined;
103
+ }>>(original: import("@react-navigation/native").Router<TabNavigationState<ParamListBase>, Action>) => Partial<import("@react-navigation/native").Router<TabNavigationState<ParamListBase>, Action>>) | undefined;
126
104
  } & {
127
105
  id?: undefined;
128
106
  }, "children">> & React.RefAttributes<unknown>> & {
@@ -1 +1 @@
1
- {"version":3,"file":"TabsClient.d.ts","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAE3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKhC,KAAK,SAAS,GAAG,0BAA0B,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC;AAErE,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCf,CAAC;AAEH,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"TabsClient.d.ts","sourceRoot":"","sources":["../../src/layouts/TabsClient.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAE3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKhC,KAAK,SAAS,GAAG,0BAA0B,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC;AAErE,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCf,CAAC;AAEH,eAAe,IAAI,CAAC"}
@@ -7,7 +7,7 @@ export declare function useFilterScreenChildren(children: ReactNode, { isCustomN
7
7
  /** Used for sending developer hints */
8
8
  contextKey?: string;
9
9
  }): {
10
- screens: any[] | null | undefined;
10
+ screens: ScreenProps[] | undefined;
11
11
  children: any[];
12
12
  };
13
13
  /**
@@ -40,7 +40,7 @@ export declare function useFilterScreenChildren(children: ReactNode, { isCustomN
40
40
  * }
41
41
  * ```
42
42
  */
43
- export declare function withLayoutContext<TOptions extends object, T extends ComponentType<any>, TState extends NavigationState, TEventMap extends EventMapBase>(Nav: T, processor?: (options: ScreenProps<TOptions, TState, TEventMap>[]) => ScreenProps<TOptions, TState, TEventMap>[]): React.ForwardRefExoticComponent<React.PropsWithoutRef<PickPartial<React.ComponentProps<T>, "children">> & React.RefAttributes<unknown>> & {
43
+ export declare function withLayoutContext<TOptions extends object, T extends ComponentType<any>, TState extends NavigationState, TEventMap extends EventMapBase>(Nav: T, processor?: (options: ScreenProps[]) => ScreenProps[]): React.ForwardRefExoticComponent<React.PropsWithoutRef<PickPartial<React.ComponentProps<T>, "children">> & React.RefAttributes<unknown>> & {
44
44
  Screen: (props: ScreenProps<TOptions, TState, TEventMap>) => null;
45
45
  };
46
46
  //# sourceMappingURL=withLayoutContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withLayoutContext.d.ts","sourceRoot":"","sources":["../../src/layouts/withLayoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,EAIZ,aAAa,EAGb,SAAS,EAIV,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAoB,WAAW,EAAE,MAAM,eAAe,CAAC;AAG9D,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,SAAS,EACnB,EACE,iBAA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,MAAM,SAAS,eAAe,EAC9B,SAAS,SAAS,YAAY,EAC9B,GAAG,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE;oBA0B3C,YAAY,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,KAAK,IAAI;EAEpE"}
@@ -33,11 +33,14 @@ function useFilterScreenChildren(children, { isCustomNavigator, contextKey, } =
33
33
  const customChildren = [];
34
34
  const screens = react_1.Children.map(children, (child) => {
35
35
  if ((0, react_1.isValidElement)(child) && child && child.type === Screen_1.Screen) {
36
- if (!child.props.name) {
36
+ if (typeof child.props === 'object' &&
37
+ child.props &&
38
+ 'name' in child.props &&
39
+ !child.props.name) {
37
40
  throw new Error(`<Screen /> component in \`default export\` at \`app${contextKey}/_layout\` must have a \`name\` prop when used as a child of a Layout Route.`);
38
41
  }
39
42
  if (process.env.NODE_ENV !== 'production') {
40
- if (['children', 'component', 'getComponent'].some((key) => key in child.props)) {
43
+ if (['children', 'component', 'getComponent'].some((key) => child.props && typeof child.props === 'object' && key in child.props)) {
41
44
  throw new Error(`<Screen /> component in \`default export\` at \`app${contextKey}/_layout\` must not have a \`children\`, \`component\`, or \`getComponent\` prop when used as a child of a Layout Route`);
42
45
  }
43
46
  }
@@ -50,12 +53,13 @@ function useFilterScreenChildren(children, { isCustomNavigator, contextKey, } =
50
53
  else {
51
54
  console.warn(`Layout children must be of type Screen, all other children are ignored. To use custom children, create a custom <Layout />. Update Layout Route at: "app${contextKey}/_layout"`);
52
55
  }
56
+ return null;
53
57
  }
54
- });
58
+ })?.filter((screen) => Boolean(screen));
55
59
  // Add an assertion for development
56
60
  if (process.env.NODE_ENV !== 'production') {
57
61
  // Assert if names are not unique
58
- const names = screens?.map((screen) => screen.name);
62
+ const names = screens?.map((screen) => screen && typeof screen === 'object' && 'name' in screen && screen.name);
59
63
  if (names && new Set(names).size !== names.length) {
60
64
  throw new Error('Screen names must be unique: ' + names);
61
65
  }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AQ,CAAC,CAAC,MAAM,CAAC,EAAG,CAAC;IACxE,CAAC,CAAC,EACF;QACE,MAAM,EAAN,eAAM;KACP,CAKF,CAAC;AACJ,CAAC;AAtCD,8CAsCC","sourcesContent":["import { EventMapBase, NavigationState } from '@react-navigation/native';\nimport React, {\n Children,\n forwardRef,\n ComponentProps,\n ComponentType,\n ForwardRefExoticComponent,\n PropsWithoutRef,\n ReactNode,\n RefAttributes,\n isValidElement,\n useMemo,\n} from 'react';\n\nimport { useContextKey } from '../Route';\nimport { PickPartial } from '../types';\nimport { useSortedScreens, ScreenProps } from '../useScreens';\nimport { Screen } from '../views/Screen';\n\nexport function useFilterScreenChildren(\n children: ReactNode,\n {\n isCustomNavigator,\n contextKey,\n }: {\n isCustomNavigator?: boolean;\n /** Used for sending developer hints */\n contextKey?: string;\n } = {}\n) {\n return useMemo(() => {\n const customChildren: any[] = [];\n const screens = Children.map(children, (child) => {\n if (isValidElement(child) && child && child.type === Screen) {\n if (!child.props.name) {\n throw new Error(\n `<Screen /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must have a \\`name\\` prop when used as a child of a Layout Route.`\n );\n }\n if (process.env.NODE_ENV !== 'production') {\n if (['children', 'component', 'getComponent'].some((key) => key in child.props)) {\n throw new Error(\n `<Screen /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must not have a \\`children\\`, \\`component\\`, or \\`getComponent\\` prop when used as a child of a Layout Route`\n );\n }\n }\n return child.props;\n } else {\n if (isCustomNavigator) {\n customChildren.push(child);\n } else {\n console.warn(\n `Layout children must be of type Screen, all other children are ignored. To use custom children, create a custom <Layout />. Update Layout Route at: \"app${contextKey}/_layout\"`\n );\n }\n }\n });\n\n // Add an assertion for development\n if (process.env.NODE_ENV !== 'production') {\n // Assert if names are not unique\n const names = screens?.map((screen) => screen.name);\n if (names && new Set(names).size !== names.length) {\n throw new Error('Screen names must be unique: ' + names);\n }\n }\n\n return {\n screens,\n children: customChildren,\n };\n }, [children]);\n}\n\n/**\n * Returns a navigator that automatically injects matched routes and renders nothing when there are no children.\n * Return type with `children` prop optional.\n * \n * Enables use of other built-in React Navigation navigators and other navigators built with the React Navigation custom navigator API.\n *\n * @example\n * ```tsx app/_layout.tsx\n * import { ParamListBase, TabNavigationState } from \"@react-navigation/native\";\n * import {\n * createMaterialTopTabNavigator,\n * MaterialTopTabNavigationOptions,\n * MaterialTopTabNavigationEventMap,\n * } from \"@react-navigation/material-top-tabs\";\n * import { withLayoutContext } from \"expo-router\";\n * \n * const MaterialTopTabs = createMaterialTopTabNavigator();\n * \n * const ExpoRouterMaterialTopTabs = withLayoutContext<\n * MaterialTopTabNavigationOptions,\n * typeof MaterialTopTabs.Navigator,\n * TabNavigationState<ParamListBase>,\n * MaterialTopTabNavigationEventMap\n * >(MaterialTopTabs.Navigator);\n\n * export default function TabLayout() {\n * return <ExpoRouterMaterialTopTabs />;\n * }\n * ```\n */\nexport function withLayoutContext<\n TOptions extends object,\n T extends ComponentType<any>,\n TState extends NavigationState,\n TEventMap extends EventMapBase,\n>(\n Nav: T,\n processor?: (\n options: ScreenProps<TOptions, TState, TEventMap>[]\n ) => ScreenProps<TOptions, TState, TEventMap>[]\n) {\n return Object.assign(\n forwardRef(({ children: userDefinedChildren, ...props }: any, ref) => {\n const contextKey = useContextKey();\n\n const { screens } = useFilterScreenChildren(userDefinedChildren, {\n contextKey,\n });\n\n const processed = processor ? processor(screens ?? []) : screens;\n\n const sorted = useSortedScreens(processed ?? []);\n\n // Prevent throwing an error when there are no screens.\n if (!sorted.length) {\n return null;\n }\n\n return <Nav {...props} id={contextKey} ref={ref} children={sorted} />;\n }),\n {\n Screen,\n }\n ) as ForwardRefExoticComponent<\n PropsWithoutRef<PickPartial<ComponentProps<T>, 'children'>> & RefAttributes<unknown>\n > & {\n Screen: (props: ScreenProps<TOptions, TState, TEventMap>) => null;\n };\n}\n"]}
1
+ {"version":3,"file":"withLayoutContext.js","sourceRoot":"","sources":["../../src/layouts/withLayoutContext.tsx"],"names":[],"m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EAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QAEjD,uDAAuD;QACvD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAClB,OAAO,IAAI,CAAC;SACb;QAED,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAG,CAAC;IACxE,CAAC,CAAC,EACF;QACE,MAAM,EAAN,eAAM;KACP,CAKF,CAAC;AACJ,CAAC;AAjCD,8CAiCC","sourcesContent":["import { EventMapBase, NavigationState } from '@react-navigation/native';\nimport React, {\n Children,\n forwardRef,\n ComponentProps,\n ComponentType,\n ForwardRefExoticComponent,\n PropsWithoutRef,\n ReactNode,\n RefAttributes,\n isValidElement,\n useMemo,\n} from 'react';\n\nimport { useContextKey } from '../Route';\nimport { PickPartial } from '../types';\nimport { useSortedScreens, ScreenProps } from '../useScreens';\nimport { Screen } from '../views/Screen';\n\nexport function useFilterScreenChildren(\n children: ReactNode,\n {\n isCustomNavigator,\n contextKey,\n }: {\n isCustomNavigator?: boolean;\n /** Used for sending developer hints */\n contextKey?: string;\n } = {}\n) {\n return useMemo(() => {\n const customChildren: any[] = [];\n const screens = Children.map(children, (child) => {\n if (isValidElement(child) && child && child.type === Screen) {\n if (\n typeof child.props === 'object' &&\n child.props &&\n 'name' in child.props &&\n !child.props.name\n ) {\n throw new Error(\n `<Screen /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must have a \\`name\\` prop when used as a child of a Layout Route.`\n );\n }\n if (process.env.NODE_ENV !== 'production') {\n if (\n ['children', 'component', 'getComponent'].some(\n (key) => child.props && typeof child.props === 'object' && key in child.props\n )\n ) {\n throw new Error(\n `<Screen /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must not have a \\`children\\`, \\`component\\`, or \\`getComponent\\` prop when used as a child of a Layout Route`\n );\n }\n }\n return child.props as ScreenProps;\n } else {\n if (isCustomNavigator) {\n customChildren.push(child);\n } else {\n console.warn(\n `Layout children must be of type Screen, all other children are ignored. To use custom children, create a custom <Layout />. Update Layout Route at: \"app${contextKey}/_layout\"`\n );\n }\n\n return null;\n }\n })?.filter((screen): screen is ScreenProps => Boolean(screen));\n\n // Add an assertion for development\n if (process.env.NODE_ENV !== 'production') {\n // Assert if names are not unique\n const names = screens?.map(\n (screen) => screen && typeof screen === 'object' && 'name' in screen && screen.name\n );\n if (names && new Set(names).size !== names.length) {\n throw new Error('Screen names must be unique: ' + names);\n }\n }\n\n return {\n screens,\n children: customChildren,\n };\n }, [children]);\n}\n\n/**\n * Returns a navigator that automatically injects matched routes and renders nothing when there are no children.\n * Return type with `children` prop optional.\n * \n * Enables use of other built-in React Navigation navigators and other navigators built with the React Navigation custom navigator API.\n *\n * @example\n * ```tsx app/_layout.tsx\n * import { ParamListBase, TabNavigationState } from \"@react-navigation/native\";\n * import {\n * createMaterialTopTabNavigator,\n * MaterialTopTabNavigationOptions,\n * MaterialTopTabNavigationEventMap,\n * } from \"@react-navigation/material-top-tabs\";\n * import { withLayoutContext } from \"expo-router\";\n * \n * const MaterialTopTabs = createMaterialTopTabNavigator();\n * \n * const ExpoRouterMaterialTopTabs = withLayoutContext<\n * MaterialTopTabNavigationOptions,\n * typeof MaterialTopTabs.Navigator,\n * TabNavigationState<ParamListBase>,\n * MaterialTopTabNavigationEventMap\n * >(MaterialTopTabs.Navigator);\n\n * export default function TabLayout() {\n * return <ExpoRouterMaterialTopTabs />;\n * }\n * ```\n */\nexport function withLayoutContext<\n TOptions extends object,\n T extends ComponentType<any>,\n TState extends NavigationState,\n TEventMap extends EventMapBase,\n>(Nav: T, processor?: (options: ScreenProps[]) => ScreenProps[]) {\n return Object.assign(\n forwardRef(({ children: userDefinedChildren, ...props }: any, ref) => {\n const contextKey = useContextKey();\n\n const { screens } = useFilterScreenChildren(userDefinedChildren, {\n contextKey,\n });\n\n const processed = processor ? processor(screens ?? []) : screens;\n\n const sorted = useSortedScreens(processed ?? []);\n\n // Prevent throwing an error when there are no screens.\n if (!sorted.length) {\n return null;\n }\n\n return <Nav {...props} id={contextKey} ref={ref} children={sorted} />;\n }),\n {\n Screen,\n }\n ) as ForwardRefExoticComponent<\n PropsWithoutRef<PickPartial<ComponentProps<T>, 'children'>> & RefAttributes<unknown>\n > & {\n Screen: (props: ScreenProps<TOptions, TState, TEventMap>) => null;\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren } from 'react';
1
+ import { PropsWithChildren, JSX } from 'react';
2
2
  import { Href } from '../types';
3
3
  import { LinkProps, WebAnchorProps } from './useLinkHooks';
4
4
  export interface LinkComponent {
@@ -1 +1 @@
1
- {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAiD,MAAM,OAAO,CAAC;AAMzF,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAqC,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG9F,MAAM,WAAW,aAAa;IAC5B,CAAC,KAAK,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;IACnD,6DAA6D;IAC7D,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;CACrC;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,EAAE,IAAI,CAAC;IAEX;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,UAAU,EAAE,EAAE,aAAa,QAUhF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,IAAI,eAAyD,CAAC;AAyE3E,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/link/Link.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAiD,GAAG,EAAE,MAAM,OAAO,CAAC;AAM9F,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAqC,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG9F,MAAM,WAAW,aAAa;IAC5B,CAAC,KAAK,EAAE,iBAAiB,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;IACnD,6DAA6D;IAC7D,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;CACrC;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,EAAE,IAAI,CAAC;IAEX;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,UAAU,EAAE,EAAE,aAAa,QAUhF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,IAAI,eAAyD,CAAC;AA2E3E,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
@@ -81,7 +81,7 @@ exports.Link = (0, react_1.forwardRef)(ExpoRouterLink);
81
81
  exports.Link.resolveHref = href_1.resolveHref;
82
82
  function ExpoRouterLink({ href, replace, push, dismissTo,
83
83
  // TODO: This does not prevent default on the anchor tag.
84
- relativeToDirectory, asChild, rel, target, download, withAnchor, ...rest }, ref) {
84
+ relativeToDirectory, asChild, rel, target, download, withAnchor, dangerouslySingular: singular, ...rest }, ref) {
85
85
  // Mutate the style prop to add the className on web.
86
86
  const style = (0, useLinkHooks_1.useInteropClassName)(rest);
87
87
  // If not passing asChild, we need to forward the props to the anchor tag using React Native Web's `hrefAttrs`.
@@ -104,6 +104,7 @@ relativeToDirectory, asChild, rel, target, download, withAnchor, ...rest }, ref)
104
104
  event,
105
105
  relativeToDirectory,
106
106
  withAnchor,
107
+ dangerouslySingular: singular,
107
108
  });
108
109
  const onPress = (e) => {
109
110
  if ('onPress' in rest) {