one 1.1.298 → 1.1.299
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/vite/replaceLoader.js +7 -1
- package/dist/cjs/vite/replaceLoader.js.map +1 -1
- package/dist/cjs/vite/replaceLoader.native.js +7 -1
- package/dist/cjs/vite/replaceLoader.native.js.map +1 -1
- package/dist/esm/Root.native.js +110 -104
- package/dist/esm/Root.native.js.map +6 -1
- package/dist/esm/Route.native.js +12 -10
- package/dist/esm/Route.native.js.map +6 -1
- package/dist/esm/cleanUrl.native.js +12 -13
- package/dist/esm/cleanUrl.native.js.map +6 -1
- package/dist/esm/cli/label-process.native.js +5 -4
- package/dist/esm/cli/label-process.native.js.map +6 -1
- package/dist/esm/cli/main.native.js +8 -13
- package/dist/esm/cli/main.native.js.map +6 -1
- package/dist/esm/cli/prebuild.native.js +5 -5
- package/dist/esm/cli/prebuild.native.js.map +6 -1
- package/dist/esm/cli/run.native.js +21 -28
- package/dist/esm/cli/run.native.js.map +6 -1
- package/dist/esm/cli.native.js +119 -148
- package/dist/esm/cli.native.js.map +6 -1
- package/dist/esm/clientLoaderResolver.native.js +9 -6
- package/dist/esm/clientLoaderResolver.native.js.map +6 -1
- package/dist/esm/config.native.js +12 -11
- package/dist/esm/config.native.js.map +6 -1
- package/dist/esm/constants.native.js +7 -5
- package/dist/esm/constants.native.js.map +6 -1
- package/dist/esm/createApp.native.js +13 -9
- package/dist/esm/createApp.native.js.map +6 -1
- package/dist/esm/createHandleRequest.native.js +55 -64
- package/dist/esm/createHandleRequest.native.js.map +6 -1
- package/dist/esm/createRoute.native.js +16 -16
- package/dist/esm/createRoute.native.js.map +6 -1
- package/dist/esm/fallbackViews/Sitemap.native.js +6 -3
- package/dist/esm/fallbackViews/Sitemap.native.js.map +6 -1
- package/dist/esm/fallbackViews/Unmatched.native.js +5 -3
- package/dist/esm/fallbackViews/Unmatched.native.js.map +6 -1
- package/dist/esm/fork/NavigationContainer.native.js +24 -31
- package/dist/esm/fork/NavigationContainer.native.js.map +6 -1
- package/dist/esm/fork/createMemoryHistory.native.js +99 -115
- package/dist/esm/fork/createMemoryHistory.native.js.map +6 -1
- package/dist/esm/fork/extractPathFromURL.native.js +16 -15
- package/dist/esm/fork/extractPathFromURL.native.js.map +6 -1
- package/dist/esm/fork/findFocusedRoute.native.js +6 -5
- package/dist/esm/fork/findFocusedRoute.native.js.map +6 -1
- package/dist/esm/fork/getPathFromState.native.js +127 -140
- package/dist/esm/fork/getPathFromState.native.js.map +6 -1
- package/dist/esm/fork/getStateFromPath.native.js +292 -288
- package/dist/esm/fork/getStateFromPath.native.js.map +6 -1
- package/dist/esm/fork/useLinking.native.js +70 -61
- package/dist/esm/fork/useLinking.native.js.map +6 -1
- package/dist/esm/fork/validatePathConfig.native.js +15 -9
- package/dist/esm/fork/validatePathConfig.native.js.map +6 -1
- package/dist/esm/getLinkingConfig.native.js +11 -6
- package/dist/esm/getLinkingConfig.native.js.map +6 -1
- package/dist/esm/getReactNavigationConfig.native.js +28 -20
- package/dist/esm/getReactNavigationConfig.native.js.map +6 -1
- package/dist/esm/getRoutes.native.js +249 -229
- package/dist/esm/getRoutes.native.js.map +6 -1
- package/dist/esm/getURL.native.js +4 -4
- package/dist/esm/getURL.native.js.map +6 -1
- package/dist/esm/head/Head.android.js +5 -3
- package/dist/esm/head/Head.android.js.map +6 -1
- package/dist/esm/head/Head.ios.js +144 -132
- package/dist/esm/head/Head.ios.js.map +6 -1
- package/dist/esm/head/Head.native.js +7 -7
- package/dist/esm/head/Head.native.js.map +6 -1
- package/dist/esm/head/HeadModule.native.js +6 -6
- package/dist/esm/head/HeadModule.native.js.map +6 -1
- package/dist/esm/head/index.native.js +2 -2
- package/dist/esm/head/index.native.js.map +6 -1
- package/dist/esm/head/types.native.js +1 -2
- package/dist/esm/head/types.native.js.map +6 -1
- package/dist/esm/head/url.native.js +10 -8
- package/dist/esm/head/url.native.js.map +6 -1
- package/dist/esm/hooks.native.js +53 -34
- package/dist/esm/hooks.native.js.map +6 -1
- package/dist/esm/imperative-api.native.js +9 -6
- package/dist/esm/imperative-api.native.js.map +6 -1
- package/dist/esm/import-mode/index.android.js +4 -3
- package/dist/esm/import-mode/index.android.js.map +6 -1
- package/dist/esm/import-mode/index.ios.js +4 -3
- package/dist/esm/import-mode/index.ios.js.map +6 -1
- package/dist/esm/import-mode/index.native.js +3 -1
- package/dist/esm/import-mode/index.native.js.map +6 -1
- package/dist/esm/index.native.js +65 -27
- package/dist/esm/index.native.js.map +6 -1
- package/dist/esm/interfaces/router.native.js +4 -2
- package/dist/esm/interfaces/router.native.js.map +6 -1
- package/dist/esm/layouts/Drawer.native.js +7 -6
- package/dist/esm/layouts/Drawer.native.js.map +6 -1
- package/dist/esm/layouts/Stack.native.js +7 -6
- package/dist/esm/layouts/Stack.native.js.map +6 -1
- package/dist/esm/layouts/Tabs.native.js +42 -39
- package/dist/esm/layouts/Tabs.native.js.map +6 -1
- package/dist/esm/layouts/withLayoutContext.native.js +51 -48
- package/dist/esm/layouts/withLayoutContext.native.js.map +6 -1
- package/dist/esm/link/Link.native.js +62 -53
- package/dist/esm/link/Link.native.js.map +6 -1
- package/dist/esm/link/Redirect.native.js +8 -9
- package/dist/esm/link/Redirect.native.js.map +6 -1
- package/dist/esm/link/href.native.js +28 -27
- package/dist/esm/link/href.native.js.map +6 -1
- package/dist/esm/link/linking.native.js +51 -40
- package/dist/esm/link/linking.native.js.map +6 -1
- package/dist/esm/link/path.native.js +28 -19
- package/dist/esm/link/path.native.js.map +6 -1
- package/dist/esm/link/useLinkTo.native.js +22 -20
- package/dist/esm/link/useLinkTo.native.js.map +6 -1
- package/dist/esm/link/useLoadedNavigation.native.js +30 -23
- package/dist/esm/link/useLoadedNavigation.native.js.map +6 -1
- package/dist/esm/matchers.native.js +16 -3
- package/dist/esm/matchers.native.js.map +6 -1
- package/dist/esm/platform.native.js +4 -2
- package/dist/esm/platform.native.js.map +6 -1
- package/dist/esm/polyfills-mobile.native.js +4 -5
- package/dist/esm/polyfills-mobile.native.js.map +6 -1
- package/dist/esm/polyfills-server.native.js +1 -1
- package/dist/esm/polyfills-server.native.js.map +6 -1
- package/dist/esm/render.native.js +3 -1
- package/dist/esm/render.native.js.map +6 -1
- package/dist/esm/router/RouterStore.native.js +1 -2
- package/dist/esm/router/RouterStore.native.js.map +6 -1
- package/dist/esm/router/constants.native.js +4 -2
- package/dist/esm/router/constants.native.js.map +6 -1
- package/dist/esm/router/getNormalizedStatePath.native.js +18 -17
- package/dist/esm/router/getNormalizedStatePath.native.js.map +6 -1
- package/dist/esm/router/lastAction.native.js +10 -9
- package/dist/esm/router/lastAction.native.js.map +6 -1
- package/dist/esm/router/router.native.js +135 -114
- package/dist/esm/router/router.native.js.map +6 -1
- package/dist/esm/router/serverLocationContext.native.js +4 -2
- package/dist/esm/router/serverLocationContext.native.js.map +6 -1
- package/dist/esm/router/useInitializeOneRouter.native.js +8 -5
- package/dist/esm/router/useInitializeOneRouter.native.js.map +6 -1
- package/dist/esm/serve.native.js +77 -104
- package/dist/esm/serve.native.js.map +6 -1
- package/dist/esm/server/createRoutesManifest.native.js +14 -11
- package/dist/esm/server/createRoutesManifest.native.js.map +6 -1
- package/dist/esm/server/getServerManifest.native.js +61 -67
- package/dist/esm/server/getServerManifest.native.js.map +6 -1
- package/dist/esm/server-render.native.js +9 -10
- package/dist/esm/server-render.native.js.map +6 -1
- package/dist/esm/sortRoutes.native.js +27 -17
- package/dist/esm/sortRoutes.native.js.map +6 -1
- package/dist/esm/typed-routes/generateRouteTypes.native.js +10 -11
- package/dist/esm/typed-routes/generateRouteTypes.native.js.map +6 -1
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js +38 -37
- package/dist/esm/typed-routes/getTypedRoutesDeclarationFile.native.js.map +6 -1
- package/dist/esm/types.native.js +1 -2
- package/dist/esm/types.native.js.map +6 -1
- package/dist/esm/useFocusEffect.native.js +25 -22
- package/dist/esm/useFocusEffect.native.js.map +6 -1
- package/dist/esm/useLoader.native.js +50 -50
- package/dist/esm/useLoader.native.js.map +6 -1
- package/dist/esm/useNavigation.native.js +23 -19
- package/dist/esm/useNavigation.native.js.map +6 -1
- package/dist/esm/useScreens.native.js +143 -160
- package/dist/esm/useScreens.native.js.map +6 -1
- package/dist/esm/useViteRoutes.native.js +25 -28
- package/dist/esm/useViteRoutes.native.js.map +6 -1
- package/dist/esm/utils/assertIsReady.native.js +6 -3
- package/dist/esm/utils/assertIsReady.native.js.map +6 -1
- package/dist/esm/utils/dynamicImport.native.js +5 -3
- package/dist/esm/utils/dynamicImport.native.js.map +6 -1
- package/dist/esm/utils/existsAsync.native.js +6 -4
- package/dist/esm/utils/existsAsync.native.js.map +6 -1
- package/dist/esm/utils/getPageExport.native.js +12 -11
- package/dist/esm/utils/getPageExport.native.js.map +6 -1
- package/dist/esm/utils/globDir.native.js +5 -3
- package/dist/esm/utils/globDir.native.js.map +6 -1
- package/dist/esm/utils/hashString.native.js +4 -2
- package/dist/esm/utils/hashString.native.js.map +6 -1
- package/dist/esm/utils/isResponse.native.js +4 -2
- package/dist/esm/utils/isResponse.native.js.map +6 -1
- package/dist/esm/utils/isStatus.native.js +4 -2
- package/dist/esm/utils/isStatus.native.js.map +6 -1
- package/dist/esm/utils/promiseWithResolvers.native.js +7 -7
- package/dist/esm/utils/promiseWithResolvers.native.js.map +6 -1
- package/dist/esm/utils/rand.native.js +5 -3
- package/dist/esm/utils/rand.native.js.map +6 -1
- package/dist/esm/utils/redirect.native.js +7 -5
- package/dist/esm/utils/redirect.native.js.map +6 -1
- package/dist/esm/utils/removeSearch.native.js +4 -2
- package/dist/esm/utils/removeSearch.native.js.map +6 -1
- package/dist/esm/utils/removeUndefined.native.js +6 -3
- package/dist/esm/utils/removeUndefined.native.js.map +6 -1
- package/dist/esm/utils/requireResolve.native.js +4 -2
- package/dist/esm/utils/requireResolve.native.js.map +6 -1
- package/dist/esm/utils/url.native.js +6 -2
- package/dist/esm/utils/url.native.js.map +6 -1
- package/dist/esm/utils/weakKey.native.js +11 -10
- package/dist/esm/utils/weakKey.native.js.map +6 -1
- package/dist/esm/utils/weakMemo.native.js +8 -8
- package/dist/esm/utils/weakMemo.native.js.map +6 -1
- package/dist/esm/views/EmptyRoute.native.js +5 -3
- package/dist/esm/views/EmptyRoute.native.js.map +6 -1
- package/dist/esm/views/ErrorBoundary.native.js +5 -8
- package/dist/esm/views/ErrorBoundary.native.js.map +6 -1
- package/dist/esm/views/LoadProgressBar.native.js +58 -57
- package/dist/esm/views/LoadProgressBar.native.js.map +6 -1
- package/dist/esm/views/Navigator.native.js +54 -71
- package/dist/esm/views/Navigator.native.js.map +6 -1
- package/dist/esm/views/PreloadLinks.native.js +3 -1
- package/dist/esm/views/PreloadLinks.native.js.map +6 -1
- package/dist/esm/views/RootErrorBoundary.native.js +39 -29
- package/dist/esm/views/RootErrorBoundary.native.js.map +6 -1
- package/dist/esm/views/Screen.native.js +12 -12
- package/dist/esm/views/Screen.native.js.map +6 -1
- package/dist/esm/views/ScrollRestoration.native.js +27 -27
- package/dist/esm/views/ScrollRestoration.native.js.map +6 -1
- package/dist/esm/views/Try.native.js +40 -37
- package/dist/esm/views/Try.native.js.map +6 -1
- package/dist/esm/vite/build.native.js +260 -295
- package/dist/esm/vite/build.native.js.map +6 -1
- package/dist/esm/vite/clientTreeShakePlugin.native.js +34 -33
- package/dist/esm/vite/clientTreeShakePlugin.native.js.map +6 -1
- package/dist/esm/vite/constants.native.js +6 -4
- package/dist/esm/vite/constants.native.js.map +6 -1
- package/dist/esm/vite/createFileSystemRouter.native.js +99 -130
- package/dist/esm/vite/createFileSystemRouter.native.js.map +6 -1
- package/dist/esm/vite/customNodeExternals.native.js +9 -10
- package/dist/esm/vite/customNodeExternals.native.js.map +6 -1
- package/dist/esm/vite/ensureTsConfig.native.js +7 -5
- package/dist/esm/vite/ensureTsConfig.native.js.map +6 -1
- package/dist/esm/vite/findDepsToOptimize.native.js +27 -19
- package/dist/esm/vite/findDepsToOptimize.native.js.map +6 -1
- package/dist/esm/vite/fixDependenciesPlugin.native.js +5 -3
- package/dist/esm/vite/fixDependenciesPlugin.native.js.map +6 -1
- package/dist/esm/vite/generateTypesForRoutes.native.js +9 -9
- package/dist/esm/vite/generateTypesForRoutes.native.js.map +6 -1
- package/dist/esm/vite/getManifest.native.js +6 -4
- package/dist/esm/vite/getManifest.native.js.map +6 -1
- package/dist/esm/vite/headers.native.js +11 -5
- package/dist/esm/vite/headers.native.js.map +6 -1
- package/dist/esm/vite/loadEnv.native.js +7 -6
- package/dist/esm/vite/loadEnv.native.js.map +6 -1
- package/dist/esm/vite/makePluginWebOnly.native.js +9 -5
- package/dist/esm/vite/makePluginWebOnly.native.js.map +6 -1
- package/dist/esm/vite/one.native.js +142 -127
- package/dist/esm/vite/one.native.js.map +6 -1
- package/dist/esm/vite/removeReactNativeWebAnimatedPlugin.native.js +14 -11
- package/dist/esm/vite/removeReactNativeWebAnimatedPlugin.native.js.map +6 -1
- package/dist/esm/vite/replaceLoader.js +7 -1
- package/dist/esm/vite/replaceLoader.js.map +1 -1
- package/dist/esm/vite/replaceLoader.mjs +5 -1
- package/dist/esm/vite/replaceLoader.mjs.map +1 -1
- package/dist/esm/vite/replaceLoader.native.js +13 -10
- package/dist/esm/vite/replaceLoader.native.js.map +6 -1
- package/dist/esm/vite/resolveAPIRequest.native.js +44 -47
- package/dist/esm/vite/resolveAPIRequest.native.js.map +6 -1
- package/dist/esm/vite/server.native.js +5 -4
- package/dist/esm/vite/server.native.js.map +6 -1
- package/dist/esm/vite/types.native.js +1 -2
- package/dist/esm/vite/types.native.js.map +6 -1
- package/dist/esm/vite/virtualEntryPlugin.native.js +21 -16
- package/dist/esm/vite/virtualEntryPlugin.native.js.map +6 -1
- package/dist/esm/vite/vitePluginSsrCss.native.js +61 -50
- package/dist/esm/vite/vitePluginSsrCss.native.js.map +6 -1
- package/dist/esm/vite.native.js +19 -10
- package/dist/esm/vite.native.js.map +6 -1
- package/dist/esm/zero/getQueryKey.native.js +5 -3
- package/dist/esm/zero/getQueryKey.native.js.map +6 -1
- package/dist/esm/zero/isZeroQuery.native.js +4 -2
- package/dist/esm/zero/isZeroQuery.native.js.map +6 -1
- package/dist/esm/zero/resolveQuery.native.js +9 -8
- package/dist/esm/zero/resolveQuery.native.js.map +6 -1
- package/dist/esm/zero/subscribeToQuery.native.js +5 -3
- package/dist/esm/zero/subscribeToQuery.native.js.map +6 -1
- package/dist/esm/zero/types.native.js +1 -2
- package/dist/esm/zero/types.native.js.map +6 -1
- package/dist/esm/zero/useQuery.native.js +12 -12
- package/dist/esm/zero/useQuery.native.js.map +6 -1
- package/dist/esm/zero/useQueryZero.native.js +24 -20
- package/dist/esm/zero/useQueryZero.native.js.map +6 -1
- package/dist/esm/zero.native.js +9 -5
- package/dist/esm/zero.native.js.map +6 -1
- package/package.json +7 -7
- package/src/vite/replaceLoader.ts +7 -1
- 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
|
3
|
-
import { findFocusedRoute } from "./findFocusedRoute
|
4
|
-
import validatePathConfig from "./validatePathConfig
|
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)
|
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
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
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
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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)
|
89
|
-
|
90
|
-
// NOTE: This is a hack to make sure that `*` is always at the end
|
91
|
-
b.screen !== "index")
|
92
|
-
|
93
|
-
|
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
|
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)
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
109
|
-
|
110
|
-
if (aNotFound)
|
111
|
-
|
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)
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
121
|
-
|
122
|
-
if (aNotFound1)
|
123
|
-
|
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)
|
127
|
-
|
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
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
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
|
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
|
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 === "/")
|
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)
|
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++)
|
186
|
-
|
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
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
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
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
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)
|
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)
|
272
|
-
|
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
|
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)
|
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
|
300
|
-
var result = createNormalizedConfigs(nestedConfig, config.screens, routeNames, initials, [
|
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
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
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
|
-
|
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
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
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
|
-
|
345
|
-
|
346
|
-
_didIteratorError = !1,
|
347
|
-
_iteratorError = void 0;
|
349
|
+
} catch (err) {
|
350
|
+
_didIteratorError = !0, _iteratorError = err;
|
351
|
+
} finally {
|
348
352
|
try {
|
349
|
-
|
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
|
-
|
357
|
-
|
358
|
-
} finally {
|
359
|
-
if (_didIteratorError) throw _iteratorError;
|
360
|
-
}
|
355
|
+
if (_didIteratorError)
|
356
|
+
throw _iteratorError;
|
361
357
|
}
|
362
|
-
}
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
358
|
+
}
|
359
|
+
}, createStateObject = function(route, isEmpty, initialRoute) {
|
360
|
+
return isEmpty ? initialRoute ? {
|
361
|
+
index: 1,
|
362
|
+
routes: [
|
363
|
+
{
|
367
364
|
name: initialRoute
|
368
|
-
},
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
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
|
-
|
383
|
+
}
|
384
|
+
]
|
385
|
+
} : {
|
386
|
+
routes: [
|
387
|
+
{
|
383
388
|
...route,
|
384
389
|
state: {
|
385
390
|
routes: []
|
386
391
|
}
|
387
|
-
}
|
388
|
-
|
389
|
-
}
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
var
|
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
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
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
|
-
}
|
419
|
-
|
417
|
+
}
|
418
|
+
} catch (err) {
|
419
|
+
_didIteratorError = !0, _iteratorError = err;
|
420
|
+
} finally {
|
421
|
+
try {
|
422
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
420
423
|
} finally {
|
421
|
-
|
422
|
-
|
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
|
-
|
430
|
-
}
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
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))
|
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 {
|
456
|
-
|
454
|
+
export {
|
455
|
+
getStateFromPath as default,
|
456
|
+
getMatchableRouteConfigs,
|
457
|
+
getUrlWithReactNavigationConcessions,
|
458
|
+
stripBaseUrl
|
459
|
+
};
|
460
|
+
//# sourceMappingURL=getStateFromPath.js.map
|