one 1.1.298 → 1.1.299

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. package/dist/cjs/vite/replaceLoader.js +7 -1
  2. package/dist/cjs/vite/replaceLoader.js.map +1 -1
  3. package/dist/cjs/vite/replaceLoader.native.js +7 -1
  4. package/dist/cjs/vite/replaceLoader.native.js.map +1 -1
  5. package/dist/esm/Root.native.js +110 -104
  6. package/dist/esm/Root.native.js.map +6 -1
  7. package/dist/esm/Route.native.js +12 -10
  8. package/dist/esm/Route.native.js.map +6 -1
  9. package/dist/esm/cleanUrl.native.js +12 -13
  10. package/dist/esm/cleanUrl.native.js.map +6 -1
  11. package/dist/esm/cli/label-process.native.js +5 -4
  12. package/dist/esm/cli/label-process.native.js.map +6 -1
  13. package/dist/esm/cli/main.native.js +8 -13
  14. package/dist/esm/cli/main.native.js.map +6 -1
  15. package/dist/esm/cli/prebuild.native.js +5 -5
  16. package/dist/esm/cli/prebuild.native.js.map +6 -1
  17. package/dist/esm/cli/run.native.js +21 -28
  18. package/dist/esm/cli/run.native.js.map +6 -1
  19. package/dist/esm/cli.native.js +119 -148
  20. package/dist/esm/cli.native.js.map +6 -1
  21. package/dist/esm/clientLoaderResolver.native.js +9 -6
  22. package/dist/esm/clientLoaderResolver.native.js.map +6 -1
  23. package/dist/esm/config.native.js +12 -11
  24. package/dist/esm/config.native.js.map +6 -1
  25. package/dist/esm/constants.native.js +7 -5
  26. package/dist/esm/constants.native.js.map +6 -1
  27. package/dist/esm/createApp.native.js +13 -9
  28. package/dist/esm/createApp.native.js.map +6 -1
  29. package/dist/esm/createHandleRequest.native.js +55 -64
  30. package/dist/esm/createHandleRequest.native.js.map +6 -1
  31. package/dist/esm/createRoute.native.js +16 -16
  32. package/dist/esm/createRoute.native.js.map +6 -1
  33. package/dist/esm/fallbackViews/Sitemap.native.js +6 -3
  34. package/dist/esm/fallbackViews/Sitemap.native.js.map +6 -1
  35. package/dist/esm/fallbackViews/Unmatched.native.js +5 -3
  36. package/dist/esm/fallbackViews/Unmatched.native.js.map +6 -1
  37. package/dist/esm/fork/NavigationContainer.native.js +24 -31
  38. package/dist/esm/fork/NavigationContainer.native.js.map +6 -1
  39. package/dist/esm/fork/createMemoryHistory.native.js +99 -115
  40. package/dist/esm/fork/createMemoryHistory.native.js.map +6 -1
  41. package/dist/esm/fork/extractPathFromURL.native.js +16 -15
  42. package/dist/esm/fork/extractPathFromURL.native.js.map +6 -1
  43. package/dist/esm/fork/findFocusedRoute.native.js +6 -5
  44. package/dist/esm/fork/findFocusedRoute.native.js.map +6 -1
  45. package/dist/esm/fork/getPathFromState.native.js +127 -140
  46. package/dist/esm/fork/getPathFromState.native.js.map +6 -1
  47. package/dist/esm/fork/getStateFromPath.native.js +292 -288
  48. package/dist/esm/fork/getStateFromPath.native.js.map +6 -1
  49. package/dist/esm/fork/useLinking.native.js +70 -61
  50. package/dist/esm/fork/useLinking.native.js.map +6 -1
  51. package/dist/esm/fork/validatePathConfig.native.js +15 -9
  52. package/dist/esm/fork/validatePathConfig.native.js.map +6 -1
  53. package/dist/esm/getLinkingConfig.native.js +11 -6
  54. package/dist/esm/getLinkingConfig.native.js.map +6 -1
  55. package/dist/esm/getReactNavigationConfig.native.js +28 -20
  56. package/dist/esm/getReactNavigationConfig.native.js.map +6 -1
  57. package/dist/esm/getRoutes.native.js +249 -229
  58. package/dist/esm/getRoutes.native.js.map +6 -1
  59. package/dist/esm/getURL.native.js +4 -4
  60. package/dist/esm/getURL.native.js.map +6 -1
  61. package/dist/esm/head/Head.android.js +5 -3
  62. package/dist/esm/head/Head.android.js.map +6 -1
  63. package/dist/esm/head/Head.ios.js +144 -132
  64. package/dist/esm/head/Head.ios.js.map +6 -1
  65. package/dist/esm/head/Head.native.js +7 -7
  66. package/dist/esm/head/Head.native.js.map +6 -1
  67. package/dist/esm/head/HeadModule.native.js +6 -6
  68. package/dist/esm/head/HeadModule.native.js.map +6 -1
  69. package/dist/esm/head/index.native.js +2 -2
  70. package/dist/esm/head/index.native.js.map +6 -1
  71. package/dist/esm/head/types.native.js +1 -2
  72. package/dist/esm/head/types.native.js.map +6 -1
  73. package/dist/esm/head/url.native.js +10 -8
  74. package/dist/esm/head/url.native.js.map +6 -1
  75. package/dist/esm/hooks.native.js +53 -34
  76. package/dist/esm/hooks.native.js.map +6 -1
  77. package/dist/esm/imperative-api.native.js +9 -6
  78. package/dist/esm/imperative-api.native.js.map +6 -1
  79. package/dist/esm/import-mode/index.android.js +4 -3
  80. package/dist/esm/import-mode/index.android.js.map +6 -1
  81. package/dist/esm/import-mode/index.ios.js +4 -3
  82. package/dist/esm/import-mode/index.ios.js.map +6 -1
  83. package/dist/esm/import-mode/index.native.js +3 -1
  84. package/dist/esm/import-mode/index.native.js.map +6 -1
  85. package/dist/esm/index.native.js +65 -27
  86. package/dist/esm/index.native.js.map +6 -1
  87. package/dist/esm/interfaces/router.native.js +4 -2
  88. package/dist/esm/interfaces/router.native.js.map +6 -1
  89. package/dist/esm/layouts/Drawer.native.js +7 -6
  90. package/dist/esm/layouts/Drawer.native.js.map +6 -1
  91. package/dist/esm/layouts/Stack.native.js +7 -6
  92. package/dist/esm/layouts/Stack.native.js.map +6 -1
  93. package/dist/esm/layouts/Tabs.native.js +42 -39
  94. package/dist/esm/layouts/Tabs.native.js.map +6 -1
  95. package/dist/esm/layouts/withLayoutContext.native.js +51 -48
  96. package/dist/esm/layouts/withLayoutContext.native.js.map +6 -1
  97. package/dist/esm/link/Link.native.js +62 -53
  98. package/dist/esm/link/Link.native.js.map +6 -1
  99. package/dist/esm/link/Redirect.native.js +8 -9
  100. package/dist/esm/link/Redirect.native.js.map +6 -1
  101. package/dist/esm/link/href.native.js +28 -27
  102. package/dist/esm/link/href.native.js.map +6 -1
  103. package/dist/esm/link/linking.native.js +51 -40
  104. package/dist/esm/link/linking.native.js.map +6 -1
  105. package/dist/esm/link/path.native.js +28 -19
  106. package/dist/esm/link/path.native.js.map +6 -1
  107. package/dist/esm/link/useLinkTo.native.js +22 -20
  108. package/dist/esm/link/useLinkTo.native.js.map +6 -1
  109. package/dist/esm/link/useLoadedNavigation.native.js +30 -23
  110. package/dist/esm/link/useLoadedNavigation.native.js.map +6 -1
  111. package/dist/esm/matchers.native.js +16 -3
  112. package/dist/esm/matchers.native.js.map +6 -1
  113. package/dist/esm/platform.native.js +4 -2
  114. package/dist/esm/platform.native.js.map +6 -1
  115. package/dist/esm/polyfills-mobile.native.js +4 -5
  116. package/dist/esm/polyfills-mobile.native.js.map +6 -1
  117. package/dist/esm/polyfills-server.native.js +1 -1
  118. package/dist/esm/polyfills-server.native.js.map +6 -1
  119. package/dist/esm/render.native.js +3 -1
  120. package/dist/esm/render.native.js.map +6 -1
  121. package/dist/esm/router/RouterStore.native.js +1 -2
  122. package/dist/esm/router/RouterStore.native.js.map +6 -1
  123. package/dist/esm/router/constants.native.js +4 -2
  124. package/dist/esm/router/constants.native.js.map +6 -1
  125. package/dist/esm/router/getNormalizedStatePath.native.js +18 -17
  126. package/dist/esm/router/getNormalizedStatePath.native.js.map +6 -1
  127. package/dist/esm/router/lastAction.native.js +10 -9
  128. package/dist/esm/router/lastAction.native.js.map +6 -1
  129. package/dist/esm/router/router.native.js +135 -114
  130. package/dist/esm/router/router.native.js.map +6 -1
  131. package/dist/esm/router/serverLocationContext.native.js +4 -2
  132. package/dist/esm/router/serverLocationContext.native.js.map +6 -1
  133. package/dist/esm/router/useInitializeOneRouter.native.js +8 -5
  134. package/dist/esm/router/useInitializeOneRouter.native.js.map +6 -1
  135. package/dist/esm/serve.native.js +77 -104
  136. package/dist/esm/serve.native.js.map +6 -1
  137. package/dist/esm/server/createRoutesManifest.native.js +14 -11
  138. package/dist/esm/server/createRoutesManifest.native.js.map +6 -1
  139. package/dist/esm/server/getServerManifest.native.js +61 -67
  140. package/dist/esm/server/getServerManifest.native.js.map +6 -1
  141. package/dist/esm/server-render.native.js +9 -10
  142. package/dist/esm/server-render.native.js.map +6 -1
  143. package/dist/esm/sortRoutes.native.js +27 -17
  144. package/dist/esm/sortRoutes.native.js.map +6 -1
  145. package/dist/esm/typed-routes/generateRouteTypes.native.js +10 -11
  146. package/dist/esm/typed-routes/generateRouteTypes.native.js.map +6 -1
  147. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js +38 -37
  148. package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js.map +6 -1
  149. package/dist/esm/types.native.js +1 -2
  150. package/dist/esm/types.native.js.map +6 -1
  151. package/dist/esm/useFocusEffect.native.js +25 -22
  152. package/dist/esm/useFocusEffect.native.js.map +6 -1
  153. package/dist/esm/useLoader.native.js +50 -50
  154. package/dist/esm/useLoader.native.js.map +6 -1
  155. package/dist/esm/useNavigation.native.js +23 -19
  156. package/dist/esm/useNavigation.native.js.map +6 -1
  157. package/dist/esm/useScreens.native.js +143 -160
  158. package/dist/esm/useScreens.native.js.map +6 -1
  159. package/dist/esm/useViteRoutes.native.js +25 -28
  160. package/dist/esm/useViteRoutes.native.js.map +6 -1
  161. package/dist/esm/utils/assertIsReady.native.js +6 -3
  162. package/dist/esm/utils/assertIsReady.native.js.map +6 -1
  163. package/dist/esm/utils/dynamicImport.native.js +5 -3
  164. package/dist/esm/utils/dynamicImport.native.js.map +6 -1
  165. package/dist/esm/utils/existsAsync.native.js +6 -4
  166. package/dist/esm/utils/existsAsync.native.js.map +6 -1
  167. package/dist/esm/utils/getPageExport.native.js +12 -11
  168. package/dist/esm/utils/getPageExport.native.js.map +6 -1
  169. package/dist/esm/utils/globDir.native.js +5 -3
  170. package/dist/esm/utils/globDir.native.js.map +6 -1
  171. package/dist/esm/utils/hashString.native.js +4 -2
  172. package/dist/esm/utils/hashString.native.js.map +6 -1
  173. package/dist/esm/utils/isResponse.native.js +4 -2
  174. package/dist/esm/utils/isResponse.native.js.map +6 -1
  175. package/dist/esm/utils/isStatus.native.js +4 -2
  176. package/dist/esm/utils/isStatus.native.js.map +6 -1
  177. package/dist/esm/utils/promiseWithResolvers.native.js +7 -7
  178. package/dist/esm/utils/promiseWithResolvers.native.js.map +6 -1
  179. package/dist/esm/utils/rand.native.js +5 -3
  180. package/dist/esm/utils/rand.native.js.map +6 -1
  181. package/dist/esm/utils/redirect.native.js +7 -5
  182. package/dist/esm/utils/redirect.native.js.map +6 -1
  183. package/dist/esm/utils/removeSearch.native.js +4 -2
  184. package/dist/esm/utils/removeSearch.native.js.map +6 -1
  185. package/dist/esm/utils/removeUndefined.native.js +6 -3
  186. package/dist/esm/utils/removeUndefined.native.js.map +6 -1
  187. package/dist/esm/utils/requireResolve.native.js +4 -2
  188. package/dist/esm/utils/requireResolve.native.js.map +6 -1
  189. package/dist/esm/utils/url.native.js +6 -2
  190. package/dist/esm/utils/url.native.js.map +6 -1
  191. package/dist/esm/utils/weakKey.native.js +11 -10
  192. package/dist/esm/utils/weakKey.native.js.map +6 -1
  193. package/dist/esm/utils/weakMemo.native.js +8 -8
  194. package/dist/esm/utils/weakMemo.native.js.map +6 -1
  195. package/dist/esm/views/EmptyRoute.native.js +5 -3
  196. package/dist/esm/views/EmptyRoute.native.js.map +6 -1
  197. package/dist/esm/views/ErrorBoundary.native.js +5 -8
  198. package/dist/esm/views/ErrorBoundary.native.js.map +6 -1
  199. package/dist/esm/views/LoadProgressBar.native.js +58 -57
  200. package/dist/esm/views/LoadProgressBar.native.js.map +6 -1
  201. package/dist/esm/views/Navigator.native.js +54 -71
  202. package/dist/esm/views/Navigator.native.js.map +6 -1
  203. package/dist/esm/views/PreloadLinks.native.js +3 -1
  204. package/dist/esm/views/PreloadLinks.native.js.map +6 -1
  205. package/dist/esm/views/RootErrorBoundary.native.js +39 -29
  206. package/dist/esm/views/RootErrorBoundary.native.js.map +6 -1
  207. package/dist/esm/views/Screen.native.js +12 -12
  208. package/dist/esm/views/Screen.native.js.map +6 -1
  209. package/dist/esm/views/ScrollRestoration.native.js +27 -27
  210. package/dist/esm/views/ScrollRestoration.native.js.map +6 -1
  211. package/dist/esm/views/Try.native.js +40 -37
  212. package/dist/esm/views/Try.native.js.map +6 -1
  213. package/dist/esm/vite/build.native.js +260 -295
  214. package/dist/esm/vite/build.native.js.map +6 -1
  215. package/dist/esm/vite/clientTreeShakePlugin.native.js +34 -33
  216. package/dist/esm/vite/clientTreeShakePlugin.native.js.map +6 -1
  217. package/dist/esm/vite/constants.native.js +6 -4
  218. package/dist/esm/vite/constants.native.js.map +6 -1
  219. package/dist/esm/vite/createFileSystemRouter.native.js +99 -130
  220. package/dist/esm/vite/createFileSystemRouter.native.js.map +6 -1
  221. package/dist/esm/vite/customNodeExternals.native.js +9 -10
  222. package/dist/esm/vite/customNodeExternals.native.js.map +6 -1
  223. package/dist/esm/vite/ensureTsConfig.native.js +7 -5
  224. package/dist/esm/vite/ensureTsConfig.native.js.map +6 -1
  225. package/dist/esm/vite/findDepsToOptimize.native.js +27 -19
  226. package/dist/esm/vite/findDepsToOptimize.native.js.map +6 -1
  227. package/dist/esm/vite/fixDependenciesPlugin.native.js +5 -3
  228. package/dist/esm/vite/fixDependenciesPlugin.native.js.map +6 -1
  229. package/dist/esm/vite/generateTypesForRoutes.native.js +9 -9
  230. package/dist/esm/vite/generateTypesForRoutes.native.js.map +6 -1
  231. package/dist/esm/vite/getManifest.native.js +6 -4
  232. package/dist/esm/vite/getManifest.native.js.map +6 -1
  233. package/dist/esm/vite/headers.native.js +11 -5
  234. package/dist/esm/vite/headers.native.js.map +6 -1
  235. package/dist/esm/vite/loadEnv.native.js +7 -6
  236. package/dist/esm/vite/loadEnv.native.js.map +6 -1
  237. package/dist/esm/vite/makePluginWebOnly.native.js +9 -5
  238. package/dist/esm/vite/makePluginWebOnly.native.js.map +6 -1
  239. package/dist/esm/vite/one.native.js +142 -127
  240. package/dist/esm/vite/one.native.js.map +6 -1
  241. package/dist/esm/vite/removeReactNativeWebAnimatedPlugin.native.js +14 -11
  242. package/dist/esm/vite/removeReactNativeWebAnimatedPlugin.native.js.map +6 -1
  243. package/dist/esm/vite/replaceLoader.js +7 -1
  244. package/dist/esm/vite/replaceLoader.js.map +1 -1
  245. package/dist/esm/vite/replaceLoader.mjs +5 -1
  246. package/dist/esm/vite/replaceLoader.mjs.map +1 -1
  247. package/dist/esm/vite/replaceLoader.native.js +13 -10
  248. package/dist/esm/vite/replaceLoader.native.js.map +6 -1
  249. package/dist/esm/vite/resolveAPIRequest.native.js +44 -47
  250. package/dist/esm/vite/resolveAPIRequest.native.js.map +6 -1
  251. package/dist/esm/vite/server.native.js +5 -4
  252. package/dist/esm/vite/server.native.js.map +6 -1
  253. package/dist/esm/vite/types.native.js +1 -2
  254. package/dist/esm/vite/types.native.js.map +6 -1
  255. package/dist/esm/vite/virtualEntryPlugin.native.js +21 -16
  256. package/dist/esm/vite/virtualEntryPlugin.native.js.map +6 -1
  257. package/dist/esm/vite/vitePluginSsrCss.native.js +61 -50
  258. package/dist/esm/vite/vitePluginSsrCss.native.js.map +6 -1
  259. package/dist/esm/vite.native.js +19 -10
  260. package/dist/esm/vite.native.js.map +6 -1
  261. package/dist/esm/zero/getQueryKey.native.js +5 -3
  262. package/dist/esm/zero/getQueryKey.native.js.map +6 -1
  263. package/dist/esm/zero/isZeroQuery.native.js +4 -2
  264. package/dist/esm/zero/isZeroQuery.native.js.map +6 -1
  265. package/dist/esm/zero/resolveQuery.native.js +9 -8
  266. package/dist/esm/zero/resolveQuery.native.js.map +6 -1
  267. package/dist/esm/zero/subscribeToQuery.native.js +5 -3
  268. package/dist/esm/zero/subscribeToQuery.native.js.map +6 -1
  269. package/dist/esm/zero/types.native.js +1 -2
  270. package/dist/esm/zero/types.native.js.map +6 -1
  271. package/dist/esm/zero/useQuery.native.js +12 -12
  272. package/dist/esm/zero/useQuery.native.js.map +6 -1
  273. package/dist/esm/zero/useQueryZero.native.js +24 -20
  274. package/dist/esm/zero/useQueryZero.native.js.map +6 -1
  275. package/dist/esm/zero.native.js +9 -5
  276. package/dist/esm/zero.native.js.map +6 -1
  277. package/package.json +7 -7
  278. package/src/vite/replaceLoader.ts +7 -1
  279. package/types/vite/replaceLoader.d.ts.map +1 -1
@@ -1,10 +1,9 @@
1
1
  import escape from "escape-string-regexp";
2
- import { matchGroupName, stripGroupSegmentsFromPath } from "../matchers.native.js";
3
- import { findFocusedRoute } from "./findFocusedRoute.native.js";
4
- import validatePathConfig from "./validatePathConfig.native.js";
2
+ import { matchGroupName, stripGroupSegmentsFromPath } from "../matchers";
3
+ import { findFocusedRoute } from "./findFocusedRoute";
4
+ import validatePathConfig from "./validatePathConfig";
5
5
  function getUrlWithReactNavigationConcessions(path) {
6
- var baseUrl = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : process.env.EXPO_BASE_URL,
7
- parsed;
6
+ var baseUrl = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : process.env.EXPO_BASE_URL, parsed;
8
7
  try {
9
8
  parsed = new URL(path, baseUrl || "http://phony.example");
10
9
  } catch (err) {
@@ -22,55 +21,45 @@ function getUrlWithReactNavigationConcessions(path) {
22
21
  };
23
22
  }
24
23
  function getStateFromPath(path, options) {
25
- var {
26
- initialRoutes,
27
- configs
28
- } = getMatchableRouteConfigs(options);
24
+ var { initialRoutes, configs } = getMatchableRouteConfigs(options);
29
25
  return getStateFromPathWithConfigs(path, configs, initialRoutes);
30
26
  }
31
27
  function getMatchableRouteConfigs(options) {
32
28
  options && validatePathConfig(options);
33
29
  var screens = options?.screens;
34
- if (!screens) throw Error("You must pass a 'screens' object to 'getStateFromPath' to generate a path.");
30
+ if (!screens)
31
+ throw Error("You must pass a 'screens' object to 'getStateFromPath' to generate a path.");
35
32
  var initialRoutes = [];
36
33
  options?.initialRouteName && initialRoutes.push({
37
34
  initialRouteName: options.initialRouteName,
38
35
  parentScreens: []
39
36
  });
40
- var converted = Object.keys(screens).flatMap(function (key) {
41
- return createNormalizedConfigs(key, screens, [], initialRoutes);
42
- }).flat(),
43
- resolvedInitialPatterns = initialRoutes.map(function (route) {
44
- return joinPaths(...route.parentScreens, route.initialRouteName);
45
- }),
46
- convertedWithInitial = converted.map(function (config) {
47
- return {
48
- ...config,
49
- // TODO: Probably a safer way to do this
50
- // Mark initial routes to give them potential priority over other routes that match.
51
- isInitial: resolvedInitialPatterns.includes(config.routeNames.join("/"))
52
- };
53
- }),
54
- configs = convertedWithInitial.sort(sortConfigs);
37
+ var converted = Object.keys(screens).flatMap(function(key) {
38
+ return createNormalizedConfigs(key, screens, [], initialRoutes);
39
+ }).flat(), resolvedInitialPatterns = initialRoutes.map(function(route) {
40
+ return joinPaths(...route.parentScreens, route.initialRouteName);
41
+ }), convertedWithInitial = converted.map(function(config) {
42
+ return {
43
+ ...config,
44
+ // TODO: Probably a safer way to do this
45
+ // Mark initial routes to give them potential priority over other routes that match.
46
+ isInitial: resolvedInitialPatterns.includes(config.routeNames.join("/"))
47
+ };
48
+ }), configs = convertedWithInitial.sort(sortConfigs);
55
49
  return assertConfigDuplicates(configs), {
56
50
  configs,
57
51
  initialRoutes
58
52
  };
59
53
  }
60
54
  function assertConfigDuplicates(configs) {
61
- configs.reduce(function (acc, config) {
62
- var _config_regex,
63
- _config_regex_toString,
64
- indexedKey = (_config_regex_toString = (_config_regex = config.regex) === null || _config_regex === void 0 ? void 0 : _config_regex.toString()) !== null && _config_regex_toString !== void 0 ? _config_regex_toString : config.pattern,
65
- alpha = acc[indexedKey];
55
+ configs.reduce(function(acc, config) {
56
+ var _config_regex, _config_regex_toString, indexedKey = (_config_regex_toString = (_config_regex = config.regex) === null || _config_regex === void 0 ? void 0 : _config_regex.toString()) !== null && _config_regex_toString !== void 0 ? _config_regex_toString : config.pattern, alpha = acc[indexedKey];
66
57
  if (alpha && !alpha.hasChildren && !config.hasChildren) {
67
- var a = alpha.routeNames,
68
- b = config.routeNames,
69
- intersects = a.length > b.length ? b.every(function (it, i) {
70
- return a[i] === it;
71
- }) : a.every(function (it, i) {
72
- return b[i] === it;
73
- });
58
+ var a = alpha.routeNames, b = config.routeNames, intersects = a.length > b.length ? b.every(function(it, i) {
59
+ return a[i] === it;
60
+ }) : a.every(function(it, i) {
61
+ return b[i] === it;
62
+ });
74
63
  if (!intersects) {
75
64
  var last = config.pattern.split("/").pop();
76
65
  if (!last?.match(/^\*not-found$/)) {
@@ -85,80 +74,88 @@ function assertConfigDuplicates(configs) {
85
74
  }, {});
86
75
  }
87
76
  function sortConfigs(a, b) {
88
- if (a.pattern === b.pattern) return b.routeNames.join(">").localeCompare(a.routeNames.join(">"));
89
- if (a.pattern.startsWith(b.pattern) &&
90
- // NOTE: This is a hack to make sure that `*` is always at the end
91
- b.screen !== "index") return -1;
92
- if (b.pattern.startsWith(a.pattern) && a.screen !== "index") return 1;
93
- var aParts = a.pattern.split("/").filter(function (part) {
77
+ if (a.pattern === b.pattern)
78
+ return b.routeNames.join(">").localeCompare(a.routeNames.join(">"));
79
+ if (a.pattern.startsWith(b.pattern) && // NOTE: This is a hack to make sure that `*` is always at the end
80
+ b.screen !== "index")
81
+ return -1;
82
+ if (b.pattern.startsWith(a.pattern) && a.screen !== "index")
83
+ return 1;
84
+ var aParts = a.pattern.split("/").filter(function(part) {
94
85
  return matchGroupName(part) == null;
95
86
  });
96
87
  (a.screen === "index" || a.screen.match(/\/index$/)) && aParts.push("index");
97
- var bParts = b.pattern.split("/").filter(function (part) {
88
+ var bParts = b.pattern.split("/").filter(function(part) {
98
89
  return matchGroupName(part) == null;
99
90
  });
100
91
  (b.screen === "index" || b.screen.match(/\/index$/)) && bParts.push("index");
101
92
  for (var i = 0; i < Math.max(aParts.length, bParts.length); i++) {
102
- if (aParts[i] == null) return 1;
103
- if (bParts[i] == null) return -1;
104
- var aWildCard = aParts[i].startsWith("*"),
105
- bWildCard = bParts[i].startsWith("*");
93
+ if (aParts[i] == null)
94
+ return 1;
95
+ if (bParts[i] == null)
96
+ return -1;
97
+ var aWildCard = aParts[i].startsWith("*"), bWildCard = bParts[i].startsWith("*");
106
98
  if (aWildCard && bWildCard) {
107
- var aNotFound = aParts[i].match(/^[*]not-found$/),
108
- bNotFound = bParts[i].match(/^[*]not-found$/);
109
- if (aNotFound && bNotFound) continue;
110
- if (aNotFound) return 1;
111
- if (bNotFound) return -1;
99
+ var aNotFound = aParts[i].match(/^[*]not-found$/), bNotFound = bParts[i].match(/^[*]not-found$/);
100
+ if (aNotFound && bNotFound)
101
+ continue;
102
+ if (aNotFound)
103
+ return 1;
104
+ if (bNotFound)
105
+ return -1;
112
106
  continue;
113
107
  }
114
- if (aWildCard) return 1;
115
- if (bWildCard) return -1;
116
- var aSlug = aParts[i].startsWith(":"),
117
- bSlug = bParts[i].startsWith(":");
108
+ if (aWildCard)
109
+ return 1;
110
+ if (bWildCard)
111
+ return -1;
112
+ var aSlug = aParts[i].startsWith(":"), bSlug = bParts[i].startsWith(":");
118
113
  if (aSlug && bSlug) {
119
- var aNotFound1 = aParts[i].match(/^[*]not-found$/),
120
- bNotFound1 = bParts[i].match(/^[*]not-found$/);
121
- if (aNotFound1 && bNotFound1) continue;
122
- if (aNotFound1) return 1;
123
- if (bNotFound1) return -1;
114
+ var aNotFound1 = aParts[i].match(/^[*]not-found$/), bNotFound1 = bParts[i].match(/^[*]not-found$/);
115
+ if (aNotFound1 && bNotFound1)
116
+ continue;
117
+ if (aNotFound1)
118
+ return 1;
119
+ if (bNotFound1)
120
+ return -1;
124
121
  continue;
125
122
  }
126
- if (aSlug) return 1;
127
- if (bSlug) return -1;
123
+ if (aSlug)
124
+ return 1;
125
+ if (bSlug)
126
+ return -1;
128
127
  }
129
128
  return a.isInitial && !b.isInitial ? -1 : !a.isInitial && b.isInitial ? 1 : bParts.length - aParts.length;
130
129
  }
131
130
  function getStateFromEmptyPathWithConfigs(path, hash, configs, initialRoutes) {
132
- var leafNodes = configs.filter(function (config) {
133
- return !config.hasChildren;
134
- }).map(function (value) {
135
- return {
136
- ...value,
137
- // Collapse all levels of group segments before testing.
138
- // This enables `app/(one)/(two)/index.js` to be matched.
139
- path: stripGroupSegmentsFromPath(value.path)
140
- };
141
- }),
142
- _leafNodes_find,
143
- _ref,
144
- match = (_ref = (_leafNodes_find = leafNodes.find(function (config) {
145
- return (
146
- // NOTE: Test leaf node index routes that either don't have a regex or match an empty string.
147
- config.path === "" && (!config.regex || config.regex.test(""))
148
- );
149
- })) !== null && _leafNodes_find !== void 0 ? _leafNodes_find : leafNodes.find(function (config) {
150
- return (
151
- // NOTE: Test leaf node dynamic routes that match an empty string.
152
- config.path.startsWith(":") && config.regex.test("")
153
- );
154
- })) !== null && _ref !== void 0 ? _ref :
131
+ var leafNodes = configs.filter(function(config) {
132
+ return !config.hasChildren;
133
+ }).map(function(value) {
134
+ return {
135
+ ...value,
136
+ // Collapse all levels of group segments before testing.
137
+ // This enables `app/(one)/(two)/index.js` to be matched.
138
+ path: stripGroupSegmentsFromPath(value.path)
139
+ };
140
+ }), _leafNodes_find, _ref, match = (_ref = (_leafNodes_find = leafNodes.find(function(config) {
141
+ return (
142
+ // NOTE: Test leaf node index routes that either don't have a regex or match an empty string.
143
+ config.path === "" && (!config.regex || config.regex.test(""))
144
+ );
145
+ })) !== null && _leafNodes_find !== void 0 ? _leafNodes_find : leafNodes.find(function(config) {
146
+ return (
147
+ // NOTE: Test leaf node dynamic routes that match an empty string.
148
+ config.path.startsWith(":") && config.regex.test("")
149
+ );
150
+ })) !== null && _ref !== void 0 ? _ref : (
155
151
  // NOTE: Test leaf node deep dynamic routes that match a slash.
156
152
  // This should be done last to enable dynamic routes having a higher priority.
157
- leafNodes.find(function (config) {
153
+ leafNodes.find(function(config) {
158
154
  return config.path.startsWith("*") && config.regex.test("/");
159
- });
155
+ })
156
+ );
160
157
  if (match) {
161
- var routes = match.routeNames.map(function (name) {
158
+ var routes = match.routeNames.map(function(name) {
162
159
  return match._route ? {
163
160
  name,
164
161
  _route: match._route
@@ -170,89 +167,86 @@ function getStateFromEmptyPathWithConfigs(path, hash, configs, initialRoutes) {
170
167
  }
171
168
  }
172
169
  function getStateFromPathWithConfigs(path, configs, initialRoutes) {
173
- var baseUrl = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : process.env.EXPO_BASE_URL,
174
- formattedPaths = getUrlWithReactNavigationConcessions(path);
170
+ var baseUrl = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : process.env.EXPO_BASE_URL, formattedPaths = getUrlWithReactNavigationConcessions(path);
175
171
  if (!formattedPaths.url) {
176
172
  console.warn(`No url found for ${path}`);
177
173
  return;
178
174
  }
179
175
  var cleanPath = stripBaseUrl(stripGroupSegmentsFromPath(formattedPaths.url.pathname), baseUrl) + formattedPaths.url.search;
180
- if (path.startsWith("/") || (cleanPath = cleanPath.slice(1)), formattedPaths.nonstandardPathname === "/") return getStateFromEmptyPathWithConfigs(cleanPath, formattedPaths.url.hash.slice(1), configs, initialRoutes);
176
+ if (path.startsWith("/") || (cleanPath = cleanPath.slice(1)), formattedPaths.nonstandardPathname === "/")
177
+ return getStateFromEmptyPathWithConfigs(cleanPath, formattedPaths.url.hash.slice(1), configs, initialRoutes);
181
178
  var routes = matchAgainstConfigs(formattedPaths.nonstandardPathname, configs);
182
- if (routes != null) return createNestedStateObject(cleanPath, formattedPaths.url.hash.slice(1), routes, configs, initialRoutes);
179
+ if (routes != null)
180
+ return createNestedStateObject(cleanPath, formattedPaths.url.hash.slice(1), routes, configs, initialRoutes);
183
181
  }
184
- var joinPaths = function () {
185
- for (var _len = arguments.length, paths = new Array(_len), _key = 0; _key < _len; _key++) paths[_key] = arguments[_key];
186
- return [].concat(...paths.map(function (p) {
182
+ var joinPaths = function() {
183
+ for (var _len = arguments.length, paths = new Array(_len), _key = 0; _key < _len; _key++)
184
+ paths[_key] = arguments[_key];
185
+ return [].concat(...paths.map(function(p) {
187
186
  return p.split("/");
188
187
  })).filter(Boolean).join("/");
189
188
  };
190
189
  function matchAgainstConfigs(remaining, configs) {
191
- var routes,
192
- remainingPath = remaining,
193
- _iteratorNormalCompletion = !0,
194
- _didIteratorError = !1,
195
- _iteratorError = void 0;
190
+ var routes, remainingPath = remaining, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
196
191
  try {
197
- for (var _loop = function () {
198
- var config = _step.value,
199
- _config_pattern;
200
- if (!config.regex) return "continue";
201
- var match = remainingPath.match(config.regex);
202
- if (!match) return "continue";
203
- var matchedParams = (_config_pattern = config.pattern) === null || _config_pattern === void 0 ? void 0 : _config_pattern.split("/").filter(function (p) {
204
- return p.match(/^[:*]/);
205
- }).reduce(function (acc, p, i) {
206
- var _match_;
207
- return p.match(/^\*/) ? {
208
- ...acc,
209
- [p]: match[(i + 1) * 2]
210
- } : Object.assign(acc, {
211
- [p]: (_match_ = match[(i + 1) * 2]) === null || _match_ === void 0 ? void 0 : _match_.replace(/\//, "")
212
- });
213
- }, {}),
214
- routeFromName = function (name) {
215
- var config2 = configs.find(function (c) {
216
- return c.screen === name;
217
- });
218
- if (!config2?.path) return {
219
- name
220
- };
221
- var segments = config2.path.split("/"),
222
- params = {};
223
- return segments.filter(function (p) {
224
- return p.match(/^[:*]/);
225
- }).forEach(function (p) {
226
- var value = matchedParams[p];
227
- if (value) {
228
- var _config_parse;
229
- p.match(/^\*/) && (value = value?.split("/").filter(Boolean));
230
- var key = p.replace(/^[:*]/, "").replace(/\?$/, "");
231
- params[key] = !((_config_parse = config2.parse) === null || _config_parse === void 0) && _config_parse[key] ? config2.parse[key](value) : value;
232
- }
233
- }), params && Object.keys(params).length ? {
234
- name,
235
- params
236
- } : {
237
- name
238
- };
239
- };
240
- routes = config.routeNames.map(function (name) {
241
- return config._route ? {
242
- ...routeFromName(name),
243
- _route: config._route
244
- } : {
245
- ...routeFromName(name)
246
- };
192
+ for (var _loop = function() {
193
+ var config = _step.value, _config_pattern;
194
+ if (!config.regex)
195
+ return "continue";
196
+ var match = remainingPath.match(config.regex);
197
+ if (!match)
198
+ return "continue";
199
+ var matchedParams = (_config_pattern = config.pattern) === null || _config_pattern === void 0 ? void 0 : _config_pattern.split("/").filter(function(p) {
200
+ return p.match(/^[:*]/);
201
+ }).reduce(function(acc, p, i) {
202
+ var _match_;
203
+ return p.match(/^\*/) ? {
204
+ ...acc,
205
+ [p]: match[(i + 1) * 2]
206
+ } : Object.assign(acc, {
207
+ [p]: (_match_ = match[(i + 1) * 2]) === null || _match_ === void 0 ? void 0 : _match_.replace(/\//, "")
208
+ });
209
+ }, {}), routeFromName = function(name) {
210
+ var config2 = configs.find(function(c) {
211
+ return c.screen === name;
247
212
  });
248
- var combinedParams = routes.reduce(function (acc, r) {
249
- return Object.assign(acc, r.params);
250
- }, {}),
251
- hasCombinedParams = Object.keys(combinedParams).length > 0;
252
- return routes = routes.map(function (r) {
253
- return hasCombinedParams && (r.params = combinedParams), r;
254
- }), remainingPath = remainingPath.replace(match[1], ""), "break";
255
- }, _iterator = configs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
213
+ if (!config2?.path)
214
+ return {
215
+ name
216
+ };
217
+ var segments = config2.path.split("/"), params = {};
218
+ return segments.filter(function(p) {
219
+ return p.match(/^[:*]/);
220
+ }).forEach(function(p) {
221
+ var value = matchedParams[p];
222
+ if (value) {
223
+ var _config_parse;
224
+ p.match(/^\*/) && (value = value?.split("/").filter(Boolean));
225
+ var key = p.replace(/^[:*]/, "").replace(/\?$/, "");
226
+ params[key] = !((_config_parse = config2.parse) === null || _config_parse === void 0) && _config_parse[key] ? config2.parse[key](value) : value;
227
+ }
228
+ }), params && Object.keys(params).length ? {
229
+ name,
230
+ params
231
+ } : {
232
+ name
233
+ };
234
+ };
235
+ routes = config.routeNames.map(function(name) {
236
+ return config._route ? {
237
+ ...routeFromName(name),
238
+ _route: config._route
239
+ } : {
240
+ ...routeFromName(name)
241
+ };
242
+ });
243
+ var combinedParams = routes.reduce(function(acc, r) {
244
+ return Object.assign(acc, r.params);
245
+ }, {}), hasCombinedParams = Object.keys(combinedParams).length > 0;
246
+ return routes = routes.map(function(r) {
247
+ return hasCombinedParams && (r.params = combinedParams), r;
248
+ }), remainingPath = remainingPath.replace(match[1], ""), "break";
249
+ }, _iterator = configs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
256
250
  var _ret = _loop();
257
251
  if (_ret === "break") break;
258
252
  }
@@ -262,42 +256,42 @@ function matchAgainstConfigs(remaining, configs) {
262
256
  try {
263
257
  !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
264
258
  } finally {
265
- if (_didIteratorError) throw _iteratorError;
259
+ if (_didIteratorError)
260
+ throw _iteratorError;
266
261
  }
267
262
  }
268
263
  return routes;
269
264
  }
270
265
  function equalHeritage(a, b) {
271
- if (a.length !== b.length) return !1;
272
- for (var i = 0; i < a.length; i++) if (a[i].localeCompare(b[i]) !== 0) return !1;
266
+ if (a.length !== b.length)
267
+ return !1;
268
+ for (var i = 0; i < a.length; i++)
269
+ if (a[i].localeCompare(b[i]) !== 0)
270
+ return !1;
273
271
  return !0;
274
272
  }
275
- var createNormalizedConfigs = function (screen, routeConfig) {
276
- var routeNames = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [],
277
- initials = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [],
278
- parentScreens = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : [],
279
- parentPattern = arguments.length > 5 ? arguments[5] : void 0,
280
- configs = [];
273
+ var createNormalizedConfigs = function(screen, routeConfig) {
274
+ var routeNames = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], initials = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [], parentScreens = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : [], parentPattern = arguments.length > 5 ? arguments[5] : void 0, configs = [];
281
275
  routeNames.push(screen), parentScreens.push(screen);
282
276
  var config = routeConfig[screen];
283
277
  if (typeof config == "string") {
284
278
  var pattern = parentPattern ? joinPaths(parentPattern, config) : config;
285
279
  configs.push(createConfigItem(screen, routeNames, pattern, config, !1));
286
280
  } else if (typeof config == "object") {
287
- var pattern1,
288
- {
289
- _route
290
- } = config;
281
+ var pattern1, { _route } = config;
291
282
  if (typeof config.path == "string") {
292
283
  var _Object_keys;
293
- if (config.exact && config.path === void 0) throw new Error("A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.");
284
+ if (config.exact && config.path === void 0)
285
+ throw new Error("A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.");
294
286
  pattern1 = config.exact !== !0 ? joinPaths(parentPattern || "", config.path || "") : config.path || "", configs.push(createConfigItem(screen, routeNames, pattern1, config.path, config.screens ? !!(!((_Object_keys = Object.keys(config.screens)) === null || _Object_keys === void 0) && _Object_keys.length) : !1, config.parse, _route));
295
287
  }
296
288
  config.screens && (config.initialRouteName && initials.push({
297
289
  initialRouteName: config.initialRouteName,
298
290
  parentScreens
299
- }), Object.keys(config.screens).forEach(function (nestedConfig) {
300
- var result = createNormalizedConfigs(nestedConfig, config.screens, routeNames, initials, [...parentScreens], pattern1 ?? parentPattern);
291
+ }), Object.keys(config.screens).forEach(function(nestedConfig) {
292
+ var result = createNormalizedConfigs(nestedConfig, config.screens, routeNames, initials, [
293
+ ...parentScreens
294
+ ], pattern1 ?? parentPattern);
301
295
  configs.push(...result);
302
296
  }));
303
297
  }
@@ -306,141 +300,146 @@ var createNormalizedConfigs = function (screen, routeConfig) {
306
300
  function formatRegexPattern(it) {
307
301
  return it = it.replace(" ", "%20"), it.startsWith(":") ? `(([^/]+\\/)${it.endsWith("?") ? "?" : ""})` : it.startsWith("*") ? `((.*\\/)${it.endsWith("?") ? "?" : ""})` : matchGroupName(it) != null ? `(?:${escape(it)}\\/)?` : escape(it) + "\\/";
308
302
  }
309
- var createConfigItem = function (screen, routeNames, pattern, path, hasChildren, parse, _route) {
310
- pattern = pattern.split("/").filter(Boolean).join("/");
311
- var regex = pattern ? new RegExp(`^(${pattern.split("/").map(formatRegexPattern).join("")})$`) : void 0;
312
- return {
313
- screen,
314
- regex,
315
- pattern,
316
- path,
317
- // The routeNames array is mutated, so copy it to keep the current state
318
- routeNames: [...routeNames],
319
- parse,
320
- userReadableName: [...routeNames.slice(0, -1), path || screen].join("/"),
321
- hasChildren: !!hasChildren,
322
- _route
323
- };
324
- },
325
- findParseConfigForRoute = function (routeName, routeConfigs) {
326
- var _iteratorNormalCompletion = !0,
327
- _didIteratorError = !1,
328
- _iteratorError = void 0;
303
+ var createConfigItem = function(screen, routeNames, pattern, path, hasChildren, parse, _route) {
304
+ pattern = pattern.split("/").filter(Boolean).join("/");
305
+ var regex = pattern ? new RegExp(`^(${pattern.split("/").map(formatRegexPattern).join("")})$`) : void 0;
306
+ return {
307
+ screen,
308
+ regex,
309
+ pattern,
310
+ path,
311
+ // The routeNames array is mutated, so copy it to keep the current state
312
+ routeNames: [
313
+ ...routeNames
314
+ ],
315
+ parse,
316
+ userReadableName: [
317
+ ...routeNames.slice(0, -1),
318
+ path || screen
319
+ ].join("/"),
320
+ hasChildren: !!hasChildren,
321
+ _route
322
+ };
323
+ }, findParseConfigForRoute = function(routeName, routeConfigs) {
324
+ var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
325
+ try {
326
+ for (var _iterator = routeConfigs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
327
+ var config = _step.value;
328
+ if (routeName === config.routeNames[config.routeNames.length - 1])
329
+ return config.parse;
330
+ }
331
+ } catch (err) {
332
+ _didIteratorError = !0, _iteratorError = err;
333
+ } finally {
329
334
  try {
330
- for (var _iterator = routeConfigs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
331
- var config = _step.value;
332
- if (routeName === config.routeNames[config.routeNames.length - 1]) return config.parse;
333
- }
334
- } catch (err) {
335
- _didIteratorError = !0, _iteratorError = err;
335
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
336
336
  } finally {
337
- try {
338
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
339
- } finally {
340
- if (_didIteratorError) throw _iteratorError;
341
- }
337
+ if (_didIteratorError)
338
+ throw _iteratorError;
339
+ }
340
+ }
341
+ }, findInitialRoute = function(routeName, parentScreens, initialRoutes) {
342
+ var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
343
+ try {
344
+ for (var _iterator = initialRoutes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
345
+ var config = _step.value;
346
+ if (equalHeritage(parentScreens, config.parentScreens))
347
+ return routeName !== config.initialRouteName ? config.initialRouteName : void 0;
342
348
  }
343
- },
344
- findInitialRoute = function (routeName, parentScreens, initialRoutes) {
345
- var _iteratorNormalCompletion = !0,
346
- _didIteratorError = !1,
347
- _iteratorError = void 0;
349
+ } catch (err) {
350
+ _didIteratorError = !0, _iteratorError = err;
351
+ } finally {
348
352
  try {
349
- for (var _iterator = initialRoutes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
350
- var config = _step.value;
351
- if (equalHeritage(parentScreens, config.parentScreens)) return routeName !== config.initialRouteName ? config.initialRouteName : void 0;
352
- }
353
- } catch (err) {
354
- _didIteratorError = !0, _iteratorError = err;
353
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
355
354
  } finally {
356
- try {
357
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
358
- } finally {
359
- if (_didIteratorError) throw _iteratorError;
360
- }
355
+ if (_didIteratorError)
356
+ throw _iteratorError;
361
357
  }
362
- },
363
- createStateObject = function (route, isEmpty, initialRoute) {
364
- return isEmpty ? initialRoute ? {
365
- index: 1,
366
- routes: [{
358
+ }
359
+ }, createStateObject = function(route, isEmpty, initialRoute) {
360
+ return isEmpty ? initialRoute ? {
361
+ index: 1,
362
+ routes: [
363
+ {
367
364
  name: initialRoute
368
- }, route]
369
- } : {
370
- routes: [route]
371
- } : initialRoute ? {
372
- index: 1,
373
- routes: [{
365
+ },
366
+ route
367
+ ]
368
+ } : {
369
+ routes: [
370
+ route
371
+ ]
372
+ } : initialRoute ? {
373
+ index: 1,
374
+ routes: [
375
+ {
374
376
  name: initialRoute
375
- }, {
377
+ },
378
+ {
376
379
  ...route,
377
380
  state: {
378
381
  routes: []
379
382
  }
380
- }]
381
- } : {
382
- routes: [{
383
+ }
384
+ ]
385
+ } : {
386
+ routes: [
387
+ {
383
388
  ...route,
384
389
  state: {
385
390
  routes: []
386
391
  }
387
- }]
388
- };
389
- },
390
- createNestedStateObject = function (path, hash, routes, routeConfigs, initialRoutes) {
391
- var route = routes.shift(),
392
- parentScreens = [],
393
- initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
394
- parentScreens.push(route.name);
395
- var state = createStateObject(route, routes.length === 0, initialRoute);
396
- if (routes.length > 0) for (var nestedState = state; route = routes.shift();) {
392
+ }
393
+ ]
394
+ };
395
+ }, createNestedStateObject = function(path, hash, routes, routeConfigs, initialRoutes) {
396
+ var route = routes.shift(), parentScreens = [], initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
397
+ parentScreens.push(route.name);
398
+ var state = createStateObject(route, routes.length === 0, initialRoute);
399
+ if (routes.length > 0)
400
+ for (var nestedState = state; route = routes.shift(); ) {
397
401
  initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
398
402
  var nestedStateIndex = nestedState.index || nestedState.routes.length - 1;
399
403
  nestedState.routes[nestedStateIndex].state = createStateObject(route, routes.length === 0, initialRoute), routes.length > 0 && (nestedState = nestedState.routes[nestedStateIndex].state), parentScreens.push(route.name);
400
404
  }
401
- route = findFocusedRoute(state), route.path = path;
402
- var params = parseQueryParams(route.path, findParseConfigForRoute(route.name, routeConfigs));
403
- if (params) {
404
- route.params = Object.assign(/* @__PURE__ */Object.create(null), route.params);
405
- var _iteratorNormalCompletion = !0,
406
- _didIteratorError = !1,
407
- _iteratorError = void 0;
408
- try {
409
- for (var _iterator = Object.entries(params)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
410
- var [name, value] = _step.value,
411
- _route_params,
412
- _route_params1;
413
- if (!((_route_params = route.params) === null || _route_params === void 0) && _route_params[name] && process.env.NODE_ENV !== "production" && console.warn(`Route '/${route.name}' with param '${name}' was specified both in the path and as a param, removing from path`), !(!((_route_params1 = route.params) === null || _route_params1 === void 0) && _route_params1[name])) {
414
- route.params[name] = value;
415
- continue;
416
- }
405
+ route = findFocusedRoute(state), route.path = path;
406
+ var params = parseQueryParams(route.path, findParseConfigForRoute(route.name, routeConfigs));
407
+ if (params) {
408
+ route.params = Object.assign(/* @__PURE__ */ Object.create(null), route.params);
409
+ var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
410
+ try {
411
+ for (var _iterator = Object.entries(params)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
412
+ var [name, value] = _step.value, _route_params, _route_params1;
413
+ if (!((_route_params = route.params) === null || _route_params === void 0) && _route_params[name] && process.env.NODE_ENV !== "production" && console.warn(`Route '/${route.name}' with param '${name}' was specified both in the path and as a param, removing from path`), !(!((_route_params1 = route.params) === null || _route_params1 === void 0) && _route_params1[name])) {
414
+ route.params[name] = value;
415
+ continue;
417
416
  }
418
- } catch (err) {
419
- _didIteratorError = !0, _iteratorError = err;
417
+ }
418
+ } catch (err) {
419
+ _didIteratorError = !0, _iteratorError = err;
420
+ } finally {
421
+ try {
422
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
420
423
  } finally {
421
- try {
422
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
423
- } finally {
424
- if (_didIteratorError) throw _iteratorError;
425
- }
424
+ if (_didIteratorError)
425
+ throw _iteratorError;
426
426
  }
427
- Object.keys(route.params).length === 0 && delete route.params;
428
427
  }
429
- return hash && (route.params = Object.assign(/* @__PURE__ */Object.create(null), route.params), route.params["#"] = hash), state;
430
- },
431
- parseQueryParams = function (path, parseConfig) {
432
- var query = path.split("?")[1],
433
- searchParams = new URLSearchParams(query),
434
- params = Object.fromEntries(
435
- // @ts-ignore: [Symbol.iterator] is indeed, available on every platform.
436
- searchParams);
437
- return parseConfig && Object.keys(params).forEach(function (name) {
438
- Object.hasOwnProperty.call(parseConfig, name) && typeof params[name] == "string" && (params[name] = parseConfig[name](params[name]));
439
- }), Object.keys(params).length ? params : void 0;
440
- },
441
- baseUrlCache = /* @__PURE__ */new Map();
428
+ Object.keys(route.params).length === 0 && delete route.params;
429
+ }
430
+ return hash && (route.params = Object.assign(/* @__PURE__ */ Object.create(null), route.params), route.params["#"] = hash), state;
431
+ }, parseQueryParams = function(path, parseConfig) {
432
+ var query = path.split("?")[1], searchParams = new URLSearchParams(query), params = Object.fromEntries(
433
+ // @ts-ignore: [Symbol.iterator] is indeed, available on every platform.
434
+ searchParams
435
+ );
436
+ return parseConfig && Object.keys(params).forEach(function(name) {
437
+ Object.hasOwnProperty.call(parseConfig, name) && typeof params[name] == "string" && (params[name] = parseConfig[name](params[name]));
438
+ }), Object.keys(params).length ? params : void 0;
439
+ }, baseUrlCache = /* @__PURE__ */ new Map();
442
440
  function getBaseUrlRegex(baseUrl) {
443
- if (baseUrlCache.has(baseUrl)) return baseUrlCache.get(baseUrl);
441
+ if (baseUrlCache.has(baseUrl))
442
+ return baseUrlCache.get(baseUrl);
444
443
  var regex = new RegExp(`^\\/?${escape(baseUrl)}`, "g");
445
444
  return baseUrlCache.set(baseUrl, regex), regex;
446
445
  }
@@ -452,5 +451,10 @@ function stripBaseUrl(path) {
452
451
  }
453
452
  return path;
454
453
  }
455
- export { getStateFromPath as default, getMatchableRouteConfigs, getUrlWithReactNavigationConcessions, stripBaseUrl };
456
- //# sourceMappingURL=getStateFromPath.native.js.map
454
+ export {
455
+ getStateFromPath as default,
456
+ getMatchableRouteConfigs,
457
+ getUrlWithReactNavigationConcessions,
458
+ stripBaseUrl
459
+ };
460
+ //# sourceMappingURL=getStateFromPath.js.map