expo-router 3.4.8 → 3.5.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 (151) hide show
  1. package/_ctx-shared.js +4 -0
  2. package/babel.js +3 -1
  3. package/build/ExpoRoot.d.ts +2 -4
  4. package/build/ExpoRoot.d.ts.map +1 -1
  5. package/build/ExpoRoot.js +7 -3
  6. package/build/ExpoRoot.js.map +1 -1
  7. package/build/LocationProvider.d.ts.map +1 -1
  8. package/build/LocationProvider.js +9 -1
  9. package/build/LocationProvider.js.map +1 -1
  10. package/build/Route.d.ts +5 -4
  11. package/build/Route.d.ts.map +1 -1
  12. package/build/Route.js +1 -0
  13. package/build/Route.js.map +1 -1
  14. package/build/fork/NavigationContainer.d.ts +24 -1
  15. package/build/fork/NavigationContainer.d.ts.map +1 -1
  16. package/build/fork/NavigationContainer.js +107 -2
  17. package/build/fork/NavigationContainer.js.map +1 -1
  18. package/build/fork/getPathFromState.d.ts.map +1 -1
  19. package/build/fork/getPathFromState.js +17 -2
  20. package/build/fork/getPathFromState.js.map +1 -1
  21. package/build/fork/getStateFromPath.d.ts +5 -0
  22. package/build/fork/getStateFromPath.d.ts.map +1 -1
  23. package/build/fork/getStateFromPath.js +24 -14
  24. package/build/fork/getStateFromPath.js.map +1 -1
  25. package/build/fork/useLinking.d.ts +54 -2
  26. package/build/fork/useLinking.d.ts.map +1 -1
  27. package/build/fork/useLinking.js +325 -2
  28. package/build/fork/useLinking.js.map +1 -1
  29. package/build/fork/useLinking.native.js.map +1 -1
  30. package/build/getDevServer/index.d.ts +3 -0
  31. package/build/getDevServer/index.d.ts.map +1 -1
  32. package/build/getDevServer/index.js +20 -1
  33. package/build/getDevServer/index.js.map +1 -1
  34. package/build/getLinkingConfig.d.ts +2 -2
  35. package/build/getLinkingConfig.d.ts.map +1 -1
  36. package/build/getLinkingConfig.js +4 -4
  37. package/build/getLinkingConfig.js.map +1 -1
  38. package/build/getRoutes.d.ts +22 -31
  39. package/build/getRoutes.d.ts.map +1 -1
  40. package/build/getRoutes.js +404 -427
  41. package/build/getRoutes.js.map +1 -1
  42. package/build/getServerManifest.d.ts +1 -4
  43. package/build/getServerManifest.d.ts.map +1 -1
  44. package/build/getServerManifest.js +42 -14
  45. package/build/getServerManifest.js.map +1 -1
  46. package/build/global-state/router-store.d.ts +7 -5
  47. package/build/global-state/router-store.d.ts.map +1 -1
  48. package/build/global-state/router-store.js +10 -3
  49. package/build/global-state/router-store.js.map +1 -1
  50. package/build/global-state/routing.d.ts +5 -5
  51. package/build/global-state/routing.d.ts.map +1 -1
  52. package/build/global-state/routing.js +75 -26
  53. package/build/global-state/routing.js.map +1 -1
  54. package/build/global-state/serverLocationContext.d.ts +3 -0
  55. package/build/global-state/serverLocationContext.d.ts.map +1 -0
  56. package/build/global-state/serverLocationContext.js +6 -0
  57. package/build/global-state/serverLocationContext.js.map +1 -0
  58. package/build/head/ExpoHead.android.d.ts +2 -4
  59. package/build/head/ExpoHead.android.d.ts.map +1 -1
  60. package/build/head/ExpoHead.android.js.map +1 -1
  61. package/build/head/ExpoHead.ios.d.ts +1 -3
  62. package/build/head/ExpoHead.ios.d.ts.map +1 -1
  63. package/build/head/ExpoHead.ios.js.map +1 -1
  64. package/build/head/url.js.map +1 -1
  65. package/build/hooks.d.ts +2 -2
  66. package/build/hooks.d.ts.map +1 -1
  67. package/build/hooks.js.map +1 -1
  68. package/build/imperative-api.d.ts +2 -2
  69. package/build/imperative-api.d.ts.map +1 -1
  70. package/build/imperative-api.js.map +1 -1
  71. package/build/layouts/Drawer.d.ts +40 -40
  72. package/build/layouts/Stack.d.ts +48 -48
  73. package/build/layouts/Tabs.d.ts +50 -50
  74. package/build/layouts/Tabs.d.ts.map +1 -1
  75. package/build/layouts/Tabs.js.map +1 -1
  76. package/build/link/Link.d.ts +4 -67
  77. package/build/link/Link.d.ts.map +1 -1
  78. package/build/link/Link.js.map +1 -1
  79. package/build/link/href.d.ts +2 -8
  80. package/build/link/href.d.ts.map +1 -1
  81. package/build/link/href.js +1 -1
  82. package/build/link/href.js.map +1 -1
  83. package/build/link/linking.js +2 -2
  84. package/build/link/linking.js.map +1 -1
  85. package/build/link/useLoadedNavigation.d.ts +4 -2
  86. package/build/link/useLoadedNavigation.d.ts.map +1 -1
  87. package/build/link/useLoadedNavigation.js.map +1 -1
  88. package/build/loadStaticParamsAsync.js.map +1 -1
  89. package/build/matchers.d.ts +8 -0
  90. package/build/matchers.d.ts.map +1 -1
  91. package/build/matchers.js +15 -1
  92. package/build/matchers.js.map +1 -1
  93. package/build/routes-manifest.d.ts +1 -3
  94. package/build/routes-manifest.d.ts.map +1 -1
  95. package/build/routes-manifest.js.map +1 -1
  96. package/build/static/html.d.ts +2 -4
  97. package/build/static/html.d.ts.map +1 -1
  98. package/build/static/html.js.map +1 -1
  99. package/build/testing-library/expect.js +3 -0
  100. package/build/testing-library/expect.js.map +1 -1
  101. package/build/testing-library/index.d.ts +31 -10
  102. package/build/testing-library/index.d.ts.map +1 -1
  103. package/build/testing-library/index.js +52 -28
  104. package/build/testing-library/index.js.map +1 -1
  105. package/build/testing-library/mock-config.d.ts +15 -0
  106. package/build/testing-library/mock-config.d.ts.map +1 -0
  107. package/build/testing-library/mock-config.js +33 -0
  108. package/build/testing-library/mock-config.js.map +1 -0
  109. package/build/testing-library/require-context-ponyfill.d.ts +7 -2
  110. package/build/testing-library/require-context-ponyfill.d.ts.map +1 -1
  111. package/build/testing-library/require-context-ponyfill.js +7 -1
  112. package/build/testing-library/require-context-ponyfill.js.map +1 -1
  113. package/build/typed-routes/generate.d.ts +3 -0
  114. package/build/typed-routes/generate.d.ts.map +1 -0
  115. package/build/typed-routes/generate.js +95 -0
  116. package/build/typed-routes/generate.js.map +1 -0
  117. package/build/typed-routes/index.d.ts +12 -0
  118. package/build/typed-routes/index.d.ts.map +1 -0
  119. package/build/typed-routes/index.js +72 -0
  120. package/build/typed-routes/index.js.map +1 -0
  121. package/build/types.d.ts +0 -21
  122. package/build/types.d.ts.map +1 -1
  123. package/build/types.js.map +1 -1
  124. package/build/useScreens.d.ts +4 -6
  125. package/build/useScreens.d.ts.map +1 -1
  126. package/build/useScreens.js +24 -22
  127. package/build/useScreens.js.map +1 -1
  128. package/build/views/ErrorBoundary.js.map +1 -1
  129. package/build/views/Navigator.d.ts.map +1 -1
  130. package/build/views/Navigator.js +2 -0
  131. package/build/views/Navigator.js.map +1 -1
  132. package/build/views/Screen.d.ts +1 -3
  133. package/build/views/Screen.d.ts.map +1 -1
  134. package/build/views/Screen.js.map +1 -1
  135. package/build/views/Sitemap.d.ts.map +1 -1
  136. package/build/views/Sitemap.js +2 -0
  137. package/build/views/Sitemap.js.map +1 -1
  138. package/build/views/Toast.d.ts +4 -7
  139. package/build/views/Toast.d.ts.map +1 -1
  140. package/build/views/Toast.js.map +1 -1
  141. package/build/views/Try.d.ts +4 -5
  142. package/build/views/Try.d.ts.map +1 -1
  143. package/build/views/Try.js +25 -5
  144. package/build/views/Try.js.map +1 -1
  145. package/build/views/Unmatched.d.ts.map +1 -1
  146. package/build/views/Unmatched.js +2 -0
  147. package/build/views/Unmatched.js.map +1 -1
  148. package/package.json +6 -5
  149. package/server.d.ts +2 -4
  150. package/types/expo-router.d.ts +357 -0
  151. package/types/jest.d.ts +0 -11
package/_ctx-shared.js ADDED
@@ -0,0 +1,4 @@
1
+ // Ignore root `./+html.js` and API route files `./generate+api.tsx`.
2
+ module.exports = {
3
+ EXPO_ROUTER_CTX_IGNORE: /^(?:\.\/)(?!(?:(?:(?:.*\+api)|(?:\+html)))\.[tj]sx?$).*\.[tj]sx?$/,
4
+ };
package/babel.js CHANGED
@@ -1 +1,3 @@
1
- throw new Error('expo-router/babel is deprecated in favor of babel-preset-expo in SDK 50.');
1
+ throw new Error(
2
+ 'expo-router/babel is deprecated in favor of babel-preset-expo in SDK 50. To fix the issue, remove "expo-router/babel" from "plugins" in your babel.config.js file.'
3
+ );
@@ -1,11 +1,9 @@
1
- import { FunctionComponent, ReactNode } from 'react';
1
+ import { type PropsWithChildren, type ComponentType } from 'react';
2
2
  import { RequireContext } from './types';
3
3
  export type ExpoRootProps = {
4
4
  context: RequireContext;
5
5
  location?: URL;
6
- wrapper?: FunctionComponent<{
7
- children: ReactNode;
8
- }>;
6
+ wrapper?: ComponentType<PropsWithChildren>;
9
7
  };
10
8
  export declare function ExpoRoot({ wrapper: ParentWrapper, ...props }: ExpoRootProps): JSX.Element;
11
9
  //# sourceMappingURL=ExpoRoot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoRoot.d.ts","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":"AAGA,OAAc,EAAE,iBAAiB,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAMtE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,OAAO,CAAC,EAAE,iBAAiB,CAAC;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACtD,CAAC;AAgBF,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAwB,EAAE,GAAG,KAAK,EAAE,EAAE,aAAa,eAqBtF"}
1
+ {"version":3,"file":"ExpoRoot.d.ts","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":"AAKA,OAAc,EAAE,KAAK,iBAAiB,EAAY,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAOpF,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,OAAO,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAC5C,CAAC;AAgBF,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAwB,EAAE,GAAG,KAAK,EAAE,EAAE,aAAa,eAqBtF"}
package/build/ExpoRoot.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  "use strict";
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
@@ -34,6 +35,7 @@ const react_native_1 = require("react-native");
34
35
  const react_native_safe_area_context_1 = require("react-native-safe-area-context");
35
36
  const NavigationContainer_1 = __importDefault(require("./fork/NavigationContainer"));
36
37
  const router_store_1 = require("./global-state/router-store");
38
+ const serverLocationContext_1 = require("./global-state/serverLocationContext");
37
39
  const Splash_1 = require("./views/Splash");
38
40
  const isTestEnv = process.env.NODE_ENV === 'test';
39
41
  const INITIAL_METRICS = react_native_1.Platform.OS === 'web' || isTestEnv
@@ -86,9 +88,11 @@ function ContextNavigator({ context, location: initialLocation = initialUrl, wra
86
88
  return (<NavigationContainer_1.default ref={store.navigationRef} initialState={store.initialState} linking={store.linking} onUnhandledAction={onUnhandledAction} documentTitle={{
87
89
  enabled: false,
88
90
  }}>
89
- <WrapperComponent>
90
- <Component />
91
- </WrapperComponent>
91
+ <serverLocationContext_1.ServerLocationContext.Provider value={initialLocation}>
92
+ <WrapperComponent>
93
+ <Component />
94
+ </WrapperComponent>
95
+ </serverLocationContext_1.ServerLocationContext.Provider>
92
96
  </NavigationContainer_1.default>);
93
97
  }
94
98
  let onUnhandledAction;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoRoot.js","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oEAAuC;AACvC,qDAA4C;AAC5C,+CAAsE;AACtE,+CAAwC;AACxC,mFAAkE;AAElE,qFAAqE;AACrE,8DAAsE;AAEtE,2CAA8C;AAQ9C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC;AAElD,MAAM,eAAe,GACnB,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EAAE;QAC/C,MAAM,OAAO,GAAoC,MAAM,CAAC,OAAO,CAAC;QAEhE,IAAI,OAAO,GAAG,eAAe,MAAM,CAAC,IAAI,IACtC,OAAO,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAChE,oCAAoC,CAAC;QAErC,QAAQ,MAAM,CAAC,IAAI,EAAE;YACnB,KAAK,UAAU,CAAC;YAChB,KAAK,MAAM,CAAC;YACZ,KAAK,SAAS,CAAC;YACf,KAAK,SAAS;gBACZ,IAAI,OAAO,EAAE,IAAI,EAAE;oBACjB,OAAO,IAAI,kCAAkC,OAAO,CAAC,IAAI,IAAI,CAAC;iBAC/D;qBAAM;oBACL,OAAO,IAAI,gFAAgF,CAAC;iBAC7F;gBAED,MAAM;YACR,KAAK,SAAS,CAAC;YACf,KAAK,KAAK,CAAC;YACX,KAAK,YAAY;gBACf,OAAO,IAAI,wCAAwC,CAAC;gBACpD,MAAM;YACR,KAAK,aAAa,CAAC;YACnB,KAAK,cAAc,CAAC;YACpB,KAAK,eAAe;gBAClB,OAAO,IAAI,+CAA+C,CAAC;gBAC3D,MAAM;SACT;QAED,OAAO,IAAI,0EAA0E,CAAC;QAEtF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;SAC1B;QACD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC;CACH;KAAM;IACL,iBAAiB,GAAG,cAAa,CAAC,CAAC;CACpC","sourcesContent":["import { NavigationAction } from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport { StatusBar } from 'expo-status-bar';\nimport React, { FunctionComponent, ReactNode, Fragment } from 'react';\nimport { Platform } from 'react-native';\nimport { SafeAreaProvider } from 'react-native-safe-area-context';\n\nimport UpstreamNavigationContainer from './fork/NavigationContainer';\nimport { useInitializeExpoRouter } from './global-state/router-store';\nimport { RequireContext } from './types';\nimport { SplashScreen } from './views/Splash';\n\nexport type ExpoRootProps = {\n context: RequireContext;\n location?: URL;\n wrapper?: FunctionComponent<{ children: ReactNode }>;\n};\n\nconst isTestEnv = process.env.NODE_ENV === 'test';\n\nconst INITIAL_METRICS =\n Platform.OS === 'web' || isTestEnv\n ? {\n frame: { x: 0, y: 0, width: 0, height: 0 },\n insets: { top: 0, left: 0, right: 0, bottom: 0 },\n }\n : undefined;\n\nconst hasViewControllerBasedStatusBarAppearance =\n Platform.OS === 'ios' &&\n !!Constants.expoConfig?.ios?.infoPlist?.UIViewControllerBasedStatusBarAppearance;\n\nexport function ExpoRoot({ wrapper: ParentWrapper = Fragment, ...props }: ExpoRootProps) {\n /*\n * Due to static rendering we need to wrap these top level views in second wrapper\n * View's like <SafeAreaProvider /> generate a <div> so if the parent wrapper\n * is a HTML document, we need to ensure its inside the <body>\n */\n const wrapper = ({ children }) => {\n return (\n <ParentWrapper>\n <SafeAreaProvider\n // SSR support\n initialMetrics={INITIAL_METRICS}>\n {children}\n {/* Users can override this by adding another StatusBar element anywhere higher in the component tree. */}\n {!hasViewControllerBasedStatusBarAppearance && <StatusBar style=\"auto\" />}\n </SafeAreaProvider>\n </ParentWrapper>\n );\n };\n\n return <ContextNavigator {...props} wrapper={wrapper} />;\n}\n\nconst initialUrl =\n Platform.OS === 'web' && typeof window !== 'undefined'\n ? new URL(window.location.href)\n : undefined;\n\nfunction ContextNavigator({\n context,\n location: initialLocation = initialUrl,\n wrapper: WrapperComponent = Fragment,\n}: ExpoRootProps) {\n const store = useInitializeExpoRouter(context, initialLocation);\n\n if (store.shouldShowTutorial()) {\n SplashScreen.hideAsync();\n if (process.env.NODE_ENV === 'development') {\n const Tutorial = require('./onboard/Tutorial').Tutorial;\n return (\n <WrapperComponent>\n <Tutorial />\n </WrapperComponent>\n );\n } else {\n // Ensure tutorial styles are stripped in production.\n return null;\n }\n }\n\n const Component = store.rootComponent;\n\n return (\n <UpstreamNavigationContainer\n ref={store.navigationRef}\n initialState={store.initialState}\n linking={store.linking}\n onUnhandledAction={onUnhandledAction}\n documentTitle={{\n enabled: false,\n }}>\n <WrapperComponent>\n <Component />\n </WrapperComponent>\n </UpstreamNavigationContainer>\n );\n}\n\nlet onUnhandledAction: (action: NavigationAction) => void;\n\nif (process.env.NODE_ENV !== 'production') {\n onUnhandledAction = (action: NavigationAction) => {\n const payload: Record<string, any> | undefined = action.payload;\n\n let message = `The action '${action.type}'${\n payload ? ` with payload ${JSON.stringify(action.payload)}` : ''\n } was not handled by any navigator.`;\n\n switch (action.type) {\n case 'NAVIGATE':\n case 'PUSH':\n case 'REPLACE':\n case 'JUMP_TO':\n if (payload?.name) {\n message += `\\n\\nDo you have a route named '${payload.name}'?`;\n } else {\n message += `\\n\\nYou need to pass the name of the screen to navigate to. This may be a bug.`;\n }\n\n break;\n case 'GO_BACK':\n case 'POP':\n case 'POP_TO_TOP':\n message += `\\n\\nIs there any screen to go back to?`;\n break;\n case 'OPEN_DRAWER':\n case 'CLOSE_DRAWER':\n case 'TOGGLE_DRAWER':\n message += `\\n\\nIs your screen inside a Drawer navigator?`;\n break;\n }\n\n message += `\\n\\nThis is a development-only warning and won't be shown in production.`;\n\n if (process.env.NODE_ENV === 'test') {\n throw new Error(message);\n }\n console.error(message);\n };\n} else {\n onUnhandledAction = function () {};\n}\n"]}
1
+ {"version":3,"file":"ExpoRoot.js","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGb,oEAAuC;AACvC,qDAA4C;AAC5C,+CAAoF;AACpF,+CAAwC;AACxC,mFAAkE;AAElE,qFAAqE;AACrE,8DAAsE;AACtE,gFAA6E;AAE7E,2CAA8C;AAQ9C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC;AAElD,MAAM,eAAe,GACnB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iBAAqD,CAAC;AAE1D,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,iBAAiB,GAAG,CAAC,MAAwB,EAAE,EAAE;QAC/C,MAAM,OAAO,GAAoC,MAAM,CAAC,OAAO,CAAC;QAEhE,IAAI,OAAO,GAAG,eAAe,MAAM,CAAC,IAAI,IACtC,OAAO,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAChE,oCAAoC,CAAC;QAErC,QAAQ,MAAM,CAAC,IAAI,EAAE;YACnB,KAAK,UAAU,CAAC;YAChB,KAAK,MAAM,CAAC;YACZ,KAAK,SAAS,CAAC;YACf,KAAK,SAAS;gBACZ,IAAI,OAAO,EAAE,IAAI,EAAE;oBACjB,OAAO,IAAI,kCAAkC,OAAO,CAAC,IAAI,IAAI,CAAC;iBAC/D;qBAAM;oBACL,OAAO,IAAI,gFAAgF,CAAC;iBAC7F;gBAED,MAAM;YACR,KAAK,SAAS,CAAC;YACf,KAAK,KAAK,CAAC;YACX,KAAK,YAAY;gBACf,OAAO,IAAI,wCAAwC,CAAC;gBACpD,MAAM;YACR,KAAK,aAAa,CAAC;YACnB,KAAK,cAAc,CAAC;YACpB,KAAK,eAAe;gBAClB,OAAO,IAAI,+CAA+C,CAAC;gBAC3D,MAAM;SACT;QAED,OAAO,IAAI,0EAA0E,CAAC;QAEtF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;SAC1B;QACD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC;CACH;KAAM;IACL,iBAAiB,GAAG,cAAa,CAAC,CAAC;CACpC","sourcesContent":["'use client';\n\nimport { NavigationAction } from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport { StatusBar } from 'expo-status-bar';\nimport React, { type PropsWithChildren, Fragment, type ComponentType } from 'react';\nimport { Platform } from 'react-native';\nimport { SafeAreaProvider } from 'react-native-safe-area-context';\n\nimport UpstreamNavigationContainer from './fork/NavigationContainer';\nimport { useInitializeExpoRouter } from './global-state/router-store';\nimport { ServerLocationContext } from './global-state/serverLocationContext';\nimport { RequireContext } from './types';\nimport { SplashScreen } from './views/Splash';\n\nexport type ExpoRootProps = {\n context: RequireContext;\n location?: URL;\n wrapper?: ComponentType<PropsWithChildren>;\n};\n\nconst isTestEnv = process.env.NODE_ENV === 'test';\n\nconst INITIAL_METRICS =\n Platform.OS === 'web' || isTestEnv\n ? {\n frame: { x: 0, y: 0, width: 0, height: 0 },\n insets: { top: 0, left: 0, right: 0, bottom: 0 },\n }\n : undefined;\n\nconst hasViewControllerBasedStatusBarAppearance =\n Platform.OS === 'ios' &&\n !!Constants.expoConfig?.ios?.infoPlist?.UIViewControllerBasedStatusBarAppearance;\n\nexport function ExpoRoot({ wrapper: ParentWrapper = Fragment, ...props }: ExpoRootProps) {\n /*\n * Due to static rendering we need to wrap these top level views in second wrapper\n * View's like <SafeAreaProvider /> generate a <div> so if the parent wrapper\n * is a HTML document, we need to ensure its inside the <body>\n */\n const wrapper = ({ children }: PropsWithChildren) => {\n return (\n <ParentWrapper>\n <SafeAreaProvider\n // SSR support\n initialMetrics={INITIAL_METRICS}>\n {children}\n {/* Users can override this by adding another StatusBar element anywhere higher in the component tree. */}\n {!hasViewControllerBasedStatusBarAppearance && <StatusBar style=\"auto\" />}\n </SafeAreaProvider>\n </ParentWrapper>\n );\n };\n\n return <ContextNavigator {...props} wrapper={wrapper} />;\n}\n\nconst initialUrl =\n Platform.OS === 'web' && typeof window !== 'undefined'\n ? new URL(window.location.href)\n : undefined;\n\nfunction ContextNavigator({\n context,\n location: initialLocation = initialUrl,\n wrapper: WrapperComponent = Fragment,\n}: ExpoRootProps) {\n const store = useInitializeExpoRouter(context, initialLocation);\n\n if (store.shouldShowTutorial()) {\n SplashScreen.hideAsync();\n if (process.env.NODE_ENV === 'development') {\n const Tutorial = require('./onboard/Tutorial').Tutorial;\n return (\n <WrapperComponent>\n <Tutorial />\n </WrapperComponent>\n );\n } else {\n // Ensure tutorial styles are stripped in production.\n return null;\n }\n }\n\n const Component = store.rootComponent;\n\n return (\n <UpstreamNavigationContainer\n ref={store.navigationRef}\n initialState={store.initialState}\n linking={store.linking}\n onUnhandledAction={onUnhandledAction}\n documentTitle={{\n enabled: false,\n }}>\n <ServerLocationContext.Provider value={initialLocation}>\n <WrapperComponent>\n <Component />\n </WrapperComponent>\n </ServerLocationContext.Provider>\n </UpstreamNavigationContainer>\n );\n}\n\nlet onUnhandledAction: (action: NavigationAction) => void;\n\nif (process.env.NODE_ENV !== 'production') {\n onUnhandledAction = (action: NavigationAction) => {\n const payload: Record<string, any> | undefined = action.payload;\n\n let message = `The action '${action.type}'${\n payload ? ` with payload ${JSON.stringify(action.payload)}` : ''\n } was not handled by any navigator.`;\n\n switch (action.type) {\n case 'NAVIGATE':\n case 'PUSH':\n case 'REPLACE':\n case 'JUMP_TO':\n if (payload?.name) {\n message += `\\n\\nDo you have a route named '${payload.name}'?`;\n } else {\n message += `\\n\\nYou need to pass the name of the screen to navigate to. This may be a bug.`;\n }\n\n break;\n case 'GO_BACK':\n case 'POP':\n case 'POP_TO_TOP':\n message += `\\n\\nIs there any screen to go back to?`;\n break;\n case 'OPEN_DRAWER':\n case 'CLOSE_DRAWER':\n case 'TOGGLE_DRAWER':\n message += `\\n\\nIs your screen inside a Drawer navigator?`;\n break;\n }\n\n message += `\\n\\nThis is a development-only warning and won't be shown in production.`;\n\n if (process.env.NODE_ENV === 'test') {\n throw new Error(message);\n }\n console.error(message);\n };\n} else {\n onUnhandledAction = function () {};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"LocationProvider.d.ts","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,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BAAqB,CACnC,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,KAAK;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,EAClF,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,MAAM,GACf,SAAS,CAWX;AA0BD,wBAAgB,sBAAsB,CACpC,EACE,IAAI,EAAE,SAAS,EACf,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;CACb,EACD,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,QAAQ,CAAC,CA0BxC"}
@@ -19,10 +19,18 @@ function isIndexPath(state) {
19
19
  if (route.state) {
20
20
  return isIndexPath(route.state);
21
21
  }
22
- // router.params is typed as 'object', so this usual syntax is to please TypeScript
22
+ // Index routes on the same level as a layout do not have `index` in their name
23
23
  if (route.params && 'screen' in route.params) {
24
24
  return route.params.screen === 'index';
25
25
  }
26
+ // The `params` key will not exist if there are no params
27
+ // So we need to do a positive lookahead to check if the route ends with /index
28
+ // Nested routes that are hoisted will have a name ending with /index
29
+ // e.g name could be /user/[id]/index
30
+ if (route.name.match(/.+\/index$/))
31
+ return true;
32
+ // The state will either have params (because there are multiple _layout) or it will be hoisted with a name
33
+ // If we don't match the above cases, then it's not an index route
26
34
  return false;
27
35
  }
28
36
  // TODO: Split up getPathFromState to return all this info at once.
@@ -1 +1 @@
1
- {"version":3,"file":"LocationProvider.js","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":";;;AACA,8DAAuD;AAYvD,SAAgB,qBAAqB,CACnC,gBAAkF,EAClF,KAAY,EACZ,OAAgB;IAEhB,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAI,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AAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC3D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACxB,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE;oBAClC,IAAI;wBACF,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;qBAC9B;oBAAC,MAAM;wBACN,OAAO,CAAC,CAAC;qBACV;gBACH,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,IAAI;oBACF,IAAI,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAe,CAAC,CAAC;iBACjD;gBAAC,MAAM;oBACN,IAAI,CAAC,GAAG,CAAC,GAAG,KAAe,CAAC;iBAC7B;aACF;YACD,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,EAAkB,CAAC;KACvB,CAAC;AACJ,CAAC;AAnCD,wDAmCC","sourcesContent":["import type { State } from './fork/getPathFromState';\nimport { stripBaseUrl } from './fork/getStateFromPath';\n\ntype SearchParams = Record<string, string | string[]>;\n\nexport type UrlObject = {\n unstable_globalHref: string;\n pathname: string;\n readonly params: SearchParams;\n segments: string[];\n isIndex: boolean;\n};\n\nexport function getRouteInfoFromState(\n getPathFromState: (state: State, asPath: boolean) => { path: string; params: any },\n state: State,\n baseUrl?: string\n): UrlObject {\n const { path } = getPathFromState(state, false);\n const qualified = getPathFromState(state, true);\n\n return {\n // TODO: This may have a predefined origin attached in the future.\n unstable_globalHref: path,\n pathname: stripBaseUrl(path, baseUrl).split('?')['0'],\n isIndex: isIndexPath(state),\n ...getNormalizedStatePath(qualified, baseUrl),\n };\n}\n\nfunction isIndexPath(state: State) {\n const route = state.routes[state.index ?? state.routes.length - 1];\n if (route.state) {\n return isIndexPath(route.state);\n }\n // router.params is typed as 'object', so this usual syntax is to please TypeScript\n if (route.params && 'screen' in route.params) {\n return route.params.screen === 'index';\n }\n return false;\n}\n\n// TODO: Split up getPathFromState to return all this info at once.\nexport function getNormalizedStatePath(\n {\n path: statePath,\n params,\n }: {\n path: string;\n params: any;\n },\n baseUrl?: string\n): Pick<UrlObject, 'segments' | 'params'> {\n const [pathname] = statePath.split('?');\n return {\n // Strip empty path at the start\n segments: stripBaseUrl(pathname, baseUrl).split('/').filter(Boolean).map(decodeURIComponent),\n // TODO: This is not efficient, we should generate based on the state instead\n // of converting to string then back to object\n params: Object.entries(params).reduce((prev, [key, value]) => {\n if (Array.isArray(value)) {\n prev[key] = value.map((v: string) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n });\n } else {\n try {\n prev[key] = decodeURIComponent(value as string);\n } catch {\n prev[key] = value as string;\n }\n }\n return prev;\n }, {} as SearchParams),\n };\n}\n"]}
1
+ {"version":3,"file":"LocationProvider.js","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":";;;AACA,8DAAuD;AAYvD,SAAgB,qBAAqB,CACnC,gBAAkF,EAClF,KAAY,EACZ,OAAgB;IAEhB,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEhD,OAAO;QACL,kEAAkE;QAClE,mBAAmB,EAAE,IAAI;QACzB,QAAQ,EAAE,IAAA,+BAAY,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;QACrD,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC;QAC3B,GAAG,sBAAsB,CAAC,SAAS,EAAE,OAAO,CAAC;KAC9C,CAAC;AACJ,CAAC;AAfD,sDAeC;AAED,SAAS,WAAW,CAAC,KAAY;IAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnE,IAAI,KA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CAAC;aACJ;iBAAM;gBACL,IAAI;oBACF,IAAI,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAe,CAAC,CAAC;iBACjD;gBAAC,MAAM;oBACN,IAAI,CAAC,GAAG,CAAC,GAAG,KAAe,CAAC;iBAC7B;aACF;YACD,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,EAAkB,CAAC;KACvB,CAAC;AACJ,CAAC;AAnCD,wDAmCC","sourcesContent":["import type { State } from './fork/getPathFromState';\nimport { stripBaseUrl } from './fork/getStateFromPath';\n\ntype SearchParams = Record<string, string | string[]>;\n\nexport type UrlObject = {\n unstable_globalHref: string;\n pathname: string;\n readonly params: SearchParams;\n segments: string[];\n isIndex: boolean;\n};\n\nexport function getRouteInfoFromState(\n getPathFromState: (state: State, asPath: boolean) => { path: string; params: any },\n state: State,\n baseUrl?: string\n): UrlObject {\n const { path } = getPathFromState(state, false);\n const qualified = getPathFromState(state, true);\n\n return {\n // TODO: This may have a predefined origin attached in the future.\n unstable_globalHref: path,\n pathname: stripBaseUrl(path, baseUrl).split('?')['0'],\n isIndex: isIndexPath(state),\n ...getNormalizedStatePath(qualified, baseUrl),\n };\n}\n\nfunction isIndexPath(state: State) {\n const route = state.routes[state.index ?? state.routes.length - 1];\n if (route.state) {\n return isIndexPath(route.state);\n }\n\n // Index routes on the same level as a layout do not have `index` in their name\n if (route.params && 'screen' in route.params) {\n return route.params.screen === 'index';\n }\n\n // The `params` key will not exist if there are no params\n // So we need to do a positive lookahead to check if the route ends with /index\n // Nested routes that are hoisted will have a name ending with /index\n // e.g name could be /user/[id]/index\n if (route.name.match(/.+\\/index$/)) return true;\n\n // The state will either have params (because there are multiple _layout) or it will be hoisted with a name\n // If we don't match the above cases, then it's not an index route\n\n return false;\n}\n\n// TODO: Split up getPathFromState to return all this info at once.\nexport function getNormalizedStatePath(\n {\n path: statePath,\n params,\n }: {\n path: string;\n params: any;\n },\n baseUrl?: string\n): Pick<UrlObject, 'segments' | 'params'> {\n const [pathname] = statePath.split('?');\n return {\n // Strip empty path at the start\n segments: stripBaseUrl(pathname, baseUrl).split('/').filter(Boolean).map(decodeURIComponent),\n // TODO: This is not efficient, we should generate based on the state instead\n // of converting to string then back to object\n params: Object.entries(params).reduce((prev, [key, value]) => {\n if (Array.isArray(value)) {\n prev[key] = value.map((v: string) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n });\n } else {\n try {\n prev[key] = decodeURIComponent(value as string);\n } catch {\n prev[key] = value as string;\n }\n }\n return prev;\n }, {} as SearchParams),\n };\n}\n"]}
package/build/Route.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react';
1
+ import React, { type PropsWithChildren } from 'react';
2
2
  import type { ErrorBoundaryProps } from './exports';
3
3
  import { sortRoutesWithInitial, sortRoutes } from './sortRoutes';
4
4
  export type DynamicConvention = {
@@ -16,6 +16,8 @@ export type LoadedRoute = {
16
16
  }) => Record<string, string | string[]>[];
17
17
  };
18
18
  export type RouteNode = {
19
+ /** The type of RouteNode */
20
+ type: 'route' | 'api' | 'layout';
19
21
  /** Load a route into memory. Returns the exports from a route. */
20
22
  loadRoute: () => Partial<LoadedRoute>;
21
23
  /** Loaded initial route name. */
@@ -39,9 +41,8 @@ export type RouteNode = {
39
41
  export declare function useRouteNode(): RouteNode | null;
40
42
  export declare function useContextKey(): string;
41
43
  /** Provides the matching routes and filename to the children. */
42
- export declare function Route({ children, node }: {
43
- children: ReactNode;
44
+ export declare function Route({ children, node }: PropsWithChildren<{
44
45
  node: RouteNode;
45
- }): JSX.Element;
46
+ }>): JSX.Element;
46
47
  export { sortRoutesWithInitial, sortRoutes };
47
48
  //# sourceMappingURL=Route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EA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GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,4BAA4B;IAC5B,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IACjC,kEAAkE;IAClE,SAAS,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IACtC,iCAAiC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB;IACpB,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,kCAAkC;IAClC,OAAO,EAAE,IAAI,GAAG,iBAAiB,EAAE,CAAC;IACpC,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wFAAwF;IACxF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oLAAoL;IACpL,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAQF,+DAA+D;AAC/D,wBAAgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAE/C;AAED,wBAAgB,aAAa,IAAI,MAAM,CAMtC;AAED,iEAAiE;AACjE,wBAAgB,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,iBAAiB,CAAC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,eAE/E;AAED,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,CAAC"}
package/build/Route.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  "use strict";
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
@@ -1 +1 @@
1
- {"version":3,"file":"Route.js","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AAGrD,yCAA2C;AAC3C,6CAAiE;AA2DxD,sGA3DA,kCAAqB,OA2DA;AAAE,2FA3DA,uBAAU,OA2DA;AAxB1C,MAAM,mBAAmB,GAAG,eAAK,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAC;AAExE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,mBAAmB,CAAC,WAAW,GAAG,WAAW,CAAC;CAC/C;AAED,+DAA+D;AAC/D,SAAgB,YAAY;IAC1B,OAAO,IAAA,kBAAU,EAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC;AAFD,oCAEC;AAED,SAAgB,aAAa;IAC3B,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC;IAC5B,IAAI,IAAI,IAAI,IAAI,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;KAC5E;IACD,OAAO,IAAA,wBAAa,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC;AAND,sCAMC;AAED,iEAAiE;AACjE,SAAgB,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAA4C;IAChF,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAFD,sBAEC","sourcesContent":["import React, { ReactNode, useContext } from 'react';\n\nimport type { ErrorBoundaryProps } from './exports';\nimport { getContextKey } from './matchers';\nimport { sortRoutesWithInitial, sortRoutes } from './sortRoutes';\n\nexport type DynamicConvention = { name: string; deep: boolean; notFound?: boolean };\n\nexport type LoadedRoute = {\n ErrorBoundary?: React.ComponentType<ErrorBoundaryProps>;\n default?: React.ComponentType<any>;\n unstable_settings?: Record<string, any>;\n getNavOptions?: (args: any) => any;\n generateStaticParams?: (props: {\n params?: Record<string, string | string[]>;\n }) => Record<string, string | string[]>[];\n};\n\nexport type RouteNode = {\n /** Load a route into memory. Returns the exports from a route. */\n loadRoute: () => Partial<LoadedRoute>;\n /** Loaded initial route name. */\n initialRouteName?: string;\n /** nested routes */\n children: RouteNode[];\n /** Is the route a dynamic path */\n dynamic: null | DynamicConvention[];\n /** `index`, `error-boundary`, etc. */\n route: string;\n /** Context Module ID, used for matching children. */\n contextKey: string;\n /** Added in-memory */\n generated?: boolean;\n /** Internal screens like the directory or the auto 404 should be marked as internal. */\n internal?: boolean;\n /** File paths for async entry modules that should be included in the initial chunk request to ensure the runtime JavaScript matches the statically rendered HTML representation. */\n entryPoints?: string[];\n};\n\nconst CurrentRouteContext = React.createContext<RouteNode | null>(null);\n\nif (process.env.NODE_ENV !== 'production') {\n CurrentRouteContext.displayName = 'RouteNode';\n}\n\n/** Return the RouteNode at the current contextual boundary. */\nexport function useRouteNode(): RouteNode | null {\n return useContext(CurrentRouteContext);\n}\n\nexport function useContextKey(): string {\n const node = useRouteNode();\n if (node == null) {\n throw new Error('No filename found. This is likely a bug in expo-router.');\n }\n return getContextKey(node.contextKey);\n}\n\n/** Provides the matching routes and filename to the children. */\nexport function Route({ children, node }: { children: ReactNode; node: RouteNode }) {\n return <CurrentRouteContext.Provider value={node}>{children}</CurrentRouteContext.Provider>;\n}\n\nexport { sortRoutesWithInitial, sortRoutes };\n"]}
1
+ {"version":3,"file":"Route.js","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,+CAAkE;AAGlE,yCAA2C;AAC3C,6CAAiE;AA6DxD,sGA7DA,kCAAqB,OA6DA;AAAE,2FA7DA,uBAAU,OA6DA;AAxB1C,MAAM,mBAAmB,GAAG,eAAK,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAC;AAExE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,mBAAmB,CAAC,WAAW,GAAG,WAAW,CAAC;CAC/C;AAED,+DAA+D;AAC/D,SAAgB,YAAY;IAC1B,OAAO,IAAA,kBAAU,EAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC;AAFD,oCAEC;AAED,SAAgB,aAAa;IAC3B,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC;IAC5B,IAAI,IAAI,IAAI,IAAI,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;KAC5E;IACD,OAAO,IAAA,wBAAa,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC;AAND,sCAMC;AAED,iEAAiE;AACjE,SAAgB,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAA0C;IAC9E,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAFD,sBAEC","sourcesContent":["'use client';\n\nimport React, { type PropsWithChildren, useContext } from 'react';\n\nimport type { ErrorBoundaryProps } from './exports';\nimport { getContextKey } from './matchers';\nimport { sortRoutesWithInitial, sortRoutes } from './sortRoutes';\n\nexport type DynamicConvention = { name: string; deep: boolean; notFound?: boolean };\n\nexport type LoadedRoute = {\n ErrorBoundary?: React.ComponentType<ErrorBoundaryProps>;\n default?: React.ComponentType<any>;\n unstable_settings?: Record<string, any>;\n getNavOptions?: (args: any) => any;\n generateStaticParams?: (props: {\n params?: Record<string, string | string[]>;\n }) => Record<string, string | string[]>[];\n};\n\nexport type RouteNode = {\n /** The type of RouteNode */\n type: 'route' | 'api' | 'layout';\n /** Load a route into memory. Returns the exports from a route. */\n loadRoute: () => Partial<LoadedRoute>;\n /** Loaded initial route name. */\n initialRouteName?: string;\n /** nested routes */\n children: RouteNode[];\n /** Is the route a dynamic path */\n dynamic: null | DynamicConvention[];\n /** `index`, `error-boundary`, etc. */\n route: string;\n /** Context Module ID, used for matching children. */\n contextKey: string;\n /** Added in-memory */\n generated?: boolean;\n /** Internal screens like the directory or the auto 404 should be marked as internal. */\n internal?: boolean;\n /** File paths for async entry modules that should be included in the initial chunk request to ensure the runtime JavaScript matches the statically rendered HTML representation. */\n entryPoints?: string[];\n};\n\nconst CurrentRouteContext = React.createContext<RouteNode | null>(null);\n\nif (process.env.NODE_ENV !== 'production') {\n CurrentRouteContext.displayName = 'RouteNode';\n}\n\n/** Return the RouteNode at the current contextual boundary. */\nexport function useRouteNode(): RouteNode | null {\n return useContext(CurrentRouteContext);\n}\n\nexport function useContextKey(): string {\n const node = useRouteNode();\n if (node == null) {\n throw new Error('No filename found. This is likely a bug in expo-router.');\n }\n return getContextKey(node.contextKey);\n}\n\n/** Provides the matching routes and filename to the children. */\nexport function Route({ children, node }: PropsWithChildren<{ node: RouteNode }>) {\n return <CurrentRouteContext.Provider value={node}>{children}</CurrentRouteContext.Provider>;\n}\n\nexport { sortRoutesWithInitial, sortRoutes };\n"]}
@@ -1,3 +1,26 @@
1
- import { NavigationContainer } from '@react-navigation/native';
1
+ import { NavigationContainerProps, NavigationContainerRef } from '@react-navigation/core';
2
+ import { DocumentTitleOptions, LinkingOptions, Theme } from '@react-navigation/native';
3
+ import * as React from 'react';
4
+ declare global {
5
+ var REACT_NAVIGATION_DEVTOOLS: WeakMap<NavigationContainerRef<any>, {
6
+ readonly linking: LinkingOptions<any>;
7
+ }>;
8
+ }
9
+ type Props<ParamList extends object> = NavigationContainerProps & {
10
+ theme?: Theme;
11
+ linking?: LinkingOptions<ParamList>;
12
+ fallback?: React.ReactNode;
13
+ documentTitle?: DocumentTitleOptions;
14
+ onReady?: () => void;
15
+ };
16
+ declare const NavigationContainer: <RootParamList extends object = ReactNavigation.RootParamList>(props: NavigationContainerProps & {
17
+ theme?: Theme | undefined;
18
+ linking?: LinkingOptions<RootParamList> | undefined;
19
+ fallback?: React.ReactNode;
20
+ documentTitle?: DocumentTitleOptions | undefined;
21
+ onReady?: (() => void) | undefined;
22
+ } & {
23
+ ref?: React.Ref<NavigationContainerRef<RootParamList>> | undefined;
24
+ }) => React.ReactElement;
2
25
  export default NavigationContainer;
3
26
  //# sourceMappingURL=NavigationContainer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationContainer.d.ts","sourceRoot":"","sources":["../../src/fork/NavigationContainer.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"NavigationContainer.d.ts","sourceRoot":"","sources":["../../src/fork/NavigationContainer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,wBAAwB,EACxB,sBAAsB,EAGvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,oBAAoB,EACpB,cAAc,EAEd,KAAK,EACN,MAAM,0BAA0B,CAAC;AAIlC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,yBAAyB,EAAE,OAAO,CACpC,sBAAsB,CAAC,GAAG,CAAC,EAC3B;QAAE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,CAAA;KAAE,CAC1C,CAAC;CACH;AAID,KAAK,KAAK,CAAC,SAAS,SAAS,MAAM,IAAI,wBAAwB,GAAG;IAChE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAuGF,QAAA,MAAM,mBAAmB;;;eA1GZ,MAAM,SAAS;;qBAEV,IAAI;;;MA8GjB,MAAM,YAAY,CAAC;AAExB,eAAe,mBAAmB,CAAC"}
@@ -1,6 +1,111 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
2
28
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // We only need to fork on native to support any prefixes.
29
+ // Forked from React Navigation in order to use a custom `useLinking` function.
30
+ // https://github.com/react-navigation/react-navigation/blob/6.x/packages/native/src/NavigationContainer.tsx
31
+ const core_1 = require("@react-navigation/core");
4
32
  const native_1 = require("@react-navigation/native");
5
- exports.default = native_1.NavigationContainer;
33
+ const useBackButton_1 = __importDefault(require("@react-navigation/native/src/useBackButton"));
34
+ const useDocumentTitle_1 = __importDefault(require("@react-navigation/native/src/useDocumentTitle"));
35
+ const useThenable_1 = __importDefault(require("@react-navigation/native/src/useThenable"));
36
+ const React = __importStar(require("react"));
37
+ const useLinking_1 = __importDefault(require("./useLinking"));
38
+ global.REACT_NAVIGATION_DEVTOOLS = new WeakMap();
39
+ /**
40
+ * Container component which holds the navigation state designed for React Native apps.
41
+ * This should be rendered at the root wrapping the whole app.
42
+ *
43
+ * @param props.initialState Initial state object for the navigation tree. When deep link handling is enabled, this will override deep links when specified. Make sure that you don't specify an `initialState` when there's a deep link (`Linking.getInitialURL()`).
44
+ * @param props.onReady Callback which is called after the navigation tree mounts.
45
+ * @param props.onStateChange Callback which is called with the latest navigation state when it changes.
46
+ * @param props.theme Theme object for the navigators.
47
+ * @param props.linking Options for deep linking. Deep link handling is enabled when this prop is provided, unless `linking.enabled` is `false`.
48
+ * @param props.fallback Fallback component to render until we have finished getting initial state when linking is enabled. Defaults to `null`.
49
+ * @param props.documentTitle Options to configure the document title on Web. Updating document title is handled by default unless `documentTitle.enabled` is `false`.
50
+ * @param props.children Child elements to render the content.
51
+ * @param props.ref Ref object which refers to the navigation object containing helper methods.
52
+ */
53
+ function NavigationContainerInner({ theme = native_1.DefaultTheme, linking, fallback = null, documentTitle, onReady, ...rest }, ref) {
54
+ const isLinkingEnabled = linking ? linking.enabled !== false : false;
55
+ if (linking?.config) {
56
+ (0, core_1.validatePathConfig)(linking.config);
57
+ }
58
+ const refContainer = React.useRef(null);
59
+ (0, useBackButton_1.default)(refContainer);
60
+ (0, useDocumentTitle_1.default)(refContainer, documentTitle);
61
+ const { getInitialState } = (0, useLinking_1.default)(refContainer, {
62
+ independent: rest.independent,
63
+ enabled: isLinkingEnabled,
64
+ prefixes: [],
65
+ ...linking,
66
+ });
67
+ // Add additional linking related info to the ref
68
+ // This will be used by the devtools
69
+ React.useEffect(() => {
70
+ if (refContainer.current) {
71
+ REACT_NAVIGATION_DEVTOOLS.set(refContainer.current, {
72
+ get linking() {
73
+ return {
74
+ ...linking,
75
+ enabled: isLinkingEnabled,
76
+ prefixes: linking?.prefixes ?? [],
77
+ getStateFromPath: linking?.getStateFromPath ?? core_1.getStateFromPath,
78
+ getPathFromState: linking?.getPathFromState ?? core_1.getPathFromState,
79
+ getActionFromState: linking?.getActionFromState ?? core_1.getActionFromState,
80
+ };
81
+ },
82
+ });
83
+ }
84
+ });
85
+ const [isResolved, initialState] = (0, useThenable_1.default)(getInitialState);
86
+ React.useImperativeHandle(ref, () => refContainer.current);
87
+ const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);
88
+ const isReady = rest.initialState != null || !isLinkingEnabled || isResolved;
89
+ const onReadyRef = React.useRef(onReady);
90
+ React.useEffect(() => {
91
+ onReadyRef.current = onReady;
92
+ });
93
+ React.useEffect(() => {
94
+ if (isReady) {
95
+ onReadyRef.current?.();
96
+ }
97
+ }, [isReady]);
98
+ if (!isReady) {
99
+ // This is temporary until we have Suspense for data-fetching
100
+ // Then the fallback will be handled by a parent `Suspense` component
101
+ return fallback;
102
+ }
103
+ return (<native_1.LinkingContext.Provider value={linkingContext}>
104
+ <native_1.ThemeProvider value={theme}>
105
+ <core_1.BaseNavigationContainer {...rest} initialState={rest.initialState == null ? initialState : rest.initialState} ref={refContainer}/>
106
+ </native_1.ThemeProvider>
107
+ </native_1.LinkingContext.Provider>);
108
+ }
109
+ const NavigationContainer = React.forwardRef(NavigationContainerInner);
110
+ exports.default = NavigationContainer;
6
111
  //# sourceMappingURL=NavigationContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationContainer.js","sourceRoot":"","sources":["../../src/fork/NavigationContainer.tsx"],"names":[],"mappings":";;AAAA,0DAA0D;AAC1D,qDAA+D;AAE/D,kBAAe,4BAAmB,CAAC","sourcesContent":["// We only need to fork on native to support any prefixes.\nimport { NavigationContainer } from '@react-navigation/native';\n\nexport default NavigationContainer;\n"]}
1
+ {"version":3,"file":"NavigationContainer.js","sourceRoot":"","sources":["../../src/fork/NavigationContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,4GAA4G;AAC5G,iDASgC;AAChC,qDAOkC;AAClC,+FAAuE;AACvE,qGAA6E;AAC7E,2FAAmE;AACnE,6CAA+B;AAE/B,8DAAsC;AAUtC,MAAM,CAAC,yBAAyB,GAAG,IAAI,OAAO,EAAE,CAAC;AAUjD;;;;;;;;;;;;;GAaG;AACH,S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Aa,CACjB;IAAA,EAAE,uBAAc,CAAC,QAAQ,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED,MAAM,mBAAmB,GAAG,KAAK,CAAC,UAAU,CAAC,wBAAwB,CAM9C,CAAC;AAExB,kBAAe,mBAAmB,CAAC","sourcesContent":["// Forked from React Navigation in order to use a custom `useLinking` function.\n// https://github.com/react-navigation/react-navigation/blob/6.x/packages/native/src/NavigationContainer.tsx\nimport {\n BaseNavigationContainer,\n getActionFromState,\n getPathFromState,\n getStateFromPath,\n NavigationContainerProps,\n NavigationContainerRef,\n ParamListBase,\n validatePathConfig,\n} from '@react-navigation/core';\nimport {\n DefaultTheme,\n ThemeProvider,\n DocumentTitleOptions,\n LinkingOptions,\n LinkingContext,\n Theme,\n} from '@react-navigation/native';\nimport useBackButton from '@react-navigation/native/src/useBackButton';\nimport useDocumentTitle from '@react-navigation/native/src/useDocumentTitle';\nimport useThenable from '@react-navigation/native/src/useThenable';\nimport * as React from 'react';\n\nimport useLinking from './useLinking';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var REACT_NAVIGATION_DEVTOOLS: WeakMap<\n NavigationContainerRef<any>,\n { readonly linking: LinkingOptions<any> }\n >;\n}\n\nglobal.REACT_NAVIGATION_DEVTOOLS = new WeakMap();\n\ntype Props<ParamList extends object> = NavigationContainerProps & {\n theme?: Theme;\n linking?: LinkingOptions<ParamList>;\n fallback?: React.ReactNode;\n documentTitle?: DocumentTitleOptions;\n onReady?: () => void;\n};\n\n/**\n * Container component which holds the navigation state designed for React Native apps.\n * This should be rendered at the root wrapping the whole app.\n *\n * @param props.initialState Initial state object for the navigation tree. When deep link handling is enabled, this will override deep links when specified. Make sure that you don't specify an `initialState` when there's a deep link (`Linking.getInitialURL()`).\n * @param props.onReady Callback which is called after the navigation tree mounts.\n * @param props.onStateChange Callback which is called with the latest navigation state when it changes.\n * @param props.theme Theme object for the navigators.\n * @param props.linking Options for deep linking. Deep link handling is enabled when this prop is provided, unless `linking.enabled` is `false`.\n * @param props.fallback Fallback component to render until we have finished getting initial state when linking is enabled. Defaults to `null`.\n * @param props.documentTitle Options to configure the document title on Web. Updating document title is handled by default unless `documentTitle.enabled` is `false`.\n * @param props.children Child elements to render the content.\n * @param props.ref Ref object which refers to the navigation object containing helper methods.\n */\nfunction NavigationContainerInner(\n {\n theme = DefaultTheme,\n linking,\n fallback = null,\n documentTitle,\n onReady,\n ...rest\n }: Props<ParamListBase>,\n ref?: React.Ref<NavigationContainerRef<ParamListBase> | null>\n) {\n const isLinkingEnabled = linking ? linking.enabled !== false : false;\n\n if (linking?.config) {\n validatePathConfig(linking.config);\n }\n\n const refContainer = React.useRef<NavigationContainerRef<ParamListBase>>(null);\n\n useBackButton(refContainer);\n useDocumentTitle(refContainer, documentTitle);\n\n const { getInitialState } = useLinking(refContainer, {\n independent: rest.independent,\n enabled: isLinkingEnabled,\n prefixes: [],\n ...linking,\n });\n\n // Add additional linking related info to the ref\n // This will be used by the devtools\n React.useEffect(() => {\n if (refContainer.current) {\n REACT_NAVIGATION_DEVTOOLS.set(refContainer.current, {\n get linking() {\n return {\n ...linking,\n enabled: isLinkingEnabled,\n prefixes: linking?.prefixes ?? [],\n getStateFromPath: linking?.getStateFromPath ?? getStateFromPath,\n getPathFromState: linking?.getPathFromState ?? getPathFromState,\n getActionFromState: linking?.getActionFromState ?? getActionFromState,\n };\n },\n });\n }\n });\n\n const [isResolved, initialState] = useThenable(getInitialState);\n\n React.useImperativeHandle(ref, () => refContainer.current);\n\n const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);\n\n const isReady = rest.initialState != null || !isLinkingEnabled || isResolved;\n\n const onReadyRef = React.useRef(onReady);\n\n React.useEffect(() => {\n onReadyRef.current = onReady;\n });\n\n React.useEffect(() => {\n if (isReady) {\n onReadyRef.current?.();\n }\n }, [isReady]);\n\n if (!isReady) {\n // This is temporary until we have Suspense for data-fetching\n // Then the fallback will be handled by a parent `Suspense` component\n return fallback as React.ReactElement;\n }\n\n return (\n <LinkingContext.Provider value={linkingContext}>\n <ThemeProvider value={theme}>\n <BaseNavigationContainer\n {...rest}\n initialState={rest.initialState == null ? initialState : rest.initialState}\n ref={refContainer}\n />\n </ThemeProvider>\n </LinkingContext.Provider>\n );\n}\n\nconst NavigationContainer = React.forwardRef(NavigationContainerInner) as <\n RootParamList extends object = ReactNavigation.RootParamList,\n>(\n props: Props<RootParamList> & {\n ref?: React.Ref<NavigationContainerRef<RootParamList>>;\n }\n) => React.ReactElement;\n\nexport default NavigationContainer;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getPathFromState.d.ts","sourceRoot":"","sources":["../../src/fork/getPathFromState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAsB,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAS,MAAM,2BAA2B,CAAC;AAStF,KAAK,OAAO,CAAC,SAAS,SAAS,MAAM,IAAI;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC;AAkEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,SAAS,SAAS,MAAM,EAC/D,KAAK,EAAE,KAAK,EACZ,QAAQ,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,GACA,MAAM,CAER;AAED,wBAAgB,oBAAoB,CAAC,SAAS,SAAS,MAAM,EAC3D,KAAK,EAAE,KAAK,EACZ,QAAQ,GAAE,OAAO,CAAC,SAAS,CAAC,GAAG;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB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AAE,GAAG,WAqCvC;AAicD,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAM,GAAG,SAAqC,UAQxD"}
@@ -141,6 +141,7 @@ function walkConfigItems(route, focusedRoute, configs, { preserveDynamicRoutes,
141
141
  }
142
142
  let pattern = null;
143
143
  let focusedParams;
144
+ let hash;
144
145
  const collectedParams = {};
145
146
  while (route.name in configs) {
146
147
  const configItem = configs[route.name];
@@ -151,6 +152,10 @@ function walkConfigItems(route, focusedRoute, configs, { preserveDynamicRoutes,
151
152
  }
152
153
  pattern = inputPattern;
153
154
  if (route.params) {
155
+ if (route.params['#']) {
156
+ hash = route.params['#'];
157
+ delete route.params['#'];
158
+ }
154
159
  const params = processParamsWithUserSettings(configItem, route.params);
155
160
  if (pattern !== undefined && pattern !== null) {
156
161
  Object.assign(collectedParams, params);
@@ -231,12 +236,14 @@ function walkConfigItems(route, focusedRoute, configs, { preserveDynamicRoutes,
231
236
  pattern,
232
237
  nextRoute: route,
233
238
  focusedParams,
239
+ hash,
234
240
  params: collectedParams,
235
241
  };
236
242
  }
237
243
  function getPathFromResolvedState(state, configs, { preserveGroups, preserveDynamicRoutes, }) {
238
244
  let path = '';
239
245
  let current = state;
246
+ let hash;
240
247
  const allParams = {};
241
248
  while (current) {
242
249
  path += '/';
@@ -247,7 +254,10 @@ function getPathFromResolvedState(state, configs, { preserveGroups, preserveDyna
247
254
  if (!route.state && isInvalidParams(route.params)) {
248
255
  route.state = createFakeState(route.params);
249
256
  }
250
- const { pattern, params, nextRoute, focusedParams } = walkConfigItems(route, getActiveRoute(current), { ...configs }, { preserveDynamicRoutes });
257
+ const { pattern, params, nextRoute, focusedParams, hash: $hash, } = walkConfigItems(route, getActiveRoute(current), { ...configs }, { preserveDynamicRoutes });
258
+ if ($hash) {
259
+ hash = $hash;
260
+ }
251
261
  Object.assign(allParams, params);
252
262
  path += getPathWithConventionsCollapsed({
253
263
  pattern,
@@ -285,7 +295,12 @@ function getPathFromResolvedState(state, configs, { preserveGroups, preserveDyna
285
295
  break;
286
296
  }
287
297
  }
288
- return { path: appendBaseUrl(basicSanitizePath(path)), params: decodeParams(allParams) };
298
+ if (hash) {
299
+ allParams['#'] = hash;
300
+ path += `#${hash}`;
301
+ }
302
+ const params = decodeParams(allParams);
303
+ return { path: appendBaseUrl(basicSanitizePath(path)), params };
289
304
  }
290
305
  function decodeParams(params) {
291
306
  const parsed = {};