one 1.1.390 → 1.1.392
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Root.cjs +6 -17
- package/dist/cjs/Root.js +9 -13
- package/dist/cjs/Root.js.map +1 -1
- package/dist/cjs/Root.native.js +4 -12
- package/dist/cjs/Root.native.js.map +1 -1
- package/dist/cjs/cli/build.cjs +2 -3
- package/dist/cjs/cli/build.js +2 -3
- package/dist/cjs/cli/build.js.map +1 -1
- package/dist/cjs/cli/build.native.js +2 -3
- package/dist/cjs/cli/build.native.js.map +2 -2
- package/dist/cjs/constants.cjs +9 -1
- package/dist/cjs/constants.js +7 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/constants.native.js +9 -1
- package/dist/cjs/constants.native.js.map +2 -2
- package/dist/cjs/fork/NavigationContainer.cjs +49 -31
- package/dist/cjs/fork/NavigationContainer.js +40 -21
- package/dist/cjs/fork/NavigationContainer.js.map +2 -2
- package/dist/cjs/fork/NavigationContainer.native.js +51 -29
- package/dist/cjs/fork/NavigationContainer.native.js.map +2 -2
- package/dist/cjs/fork/createMemoryHistory.cjs +4 -3
- package/dist/cjs/fork/createMemoryHistory.js +3 -2
- package/dist/cjs/fork/createMemoryHistory.js.map +1 -1
- package/dist/cjs/fork/createMemoryHistory.native.js +8 -4
- package/dist/cjs/fork/createMemoryHistory.native.js.map +2 -2
- package/dist/cjs/fork/extractPathFromURL.cjs +48 -28
- package/dist/cjs/fork/extractPathFromURL.js +44 -21
- package/dist/cjs/fork/extractPathFromURL.js.map +2 -2
- package/dist/cjs/fork/extractPathFromURL.native.js +58 -26
- package/dist/cjs/fork/extractPathFromURL.native.js.map +2 -2
- package/dist/cjs/fork/findFocusedRoute.js.map +1 -1
- package/dist/cjs/fork/findFocusedRoute.native.js.map +1 -1
- package/dist/cjs/fork/getPathFromState-mods.cjs +65 -0
- package/dist/cjs/fork/getPathFromState-mods.js +56 -0
- package/dist/cjs/fork/getPathFromState-mods.js.map +6 -0
- package/dist/cjs/fork/getPathFromState-mods.native.js +70 -0
- package/dist/cjs/fork/getPathFromState-mods.native.js.map +6 -0
- package/dist/cjs/fork/getPathFromState.cjs +75 -224
- package/dist/cjs/fork/getPathFromState.js +68 -223
- package/dist/cjs/fork/getPathFromState.js.map +2 -2
- package/dist/cjs/fork/getPathFromState.native.js +79 -261
- package/dist/cjs/fork/getPathFromState.native.js.map +2 -2
- package/dist/cjs/fork/getStateFromPath-mods.cjs +187 -0
- package/dist/cjs/fork/getStateFromPath-mods.js +199 -0
- package/dist/cjs/fork/getStateFromPath-mods.js.map +6 -0
- package/dist/cjs/fork/getStateFromPath-mods.native.js +284 -0
- package/dist/cjs/fork/getStateFromPath-mods.native.js.map +6 -0
- package/dist/cjs/fork/getStateFromPath.cjs +181 -263
- package/dist/cjs/fork/getStateFromPath.js +148 -264
- package/dist/cjs/fork/getStateFromPath.js.map +2 -2
- package/dist/cjs/fork/getStateFromPath.native.js +164 -304
- package/dist/cjs/fork/getStateFromPath.native.js.map +2 -2
- package/dist/cjs/fork/useBackButton.js.map +1 -1
- package/dist/cjs/fork/useBackButton.native.js.map +1 -1
- package/dist/cjs/fork/useDocumentTitle.js +4 -1
- package/dist/cjs/fork/useDocumentTitle.js.map +1 -1
- package/dist/cjs/fork/useDocumentTitle.native.js +1 -1
- package/dist/cjs/fork/useDocumentTitle.native.js.map +2 -2
- package/dist/cjs/fork/useLinking.cjs +21 -24
- package/dist/cjs/fork/useLinking.js +21 -25
- package/dist/cjs/fork/useLinking.js.map +2 -2
- package/dist/cjs/fork/useLinking.native.js +68 -66
- package/dist/cjs/fork/useLinking.native.js.map +2 -2
- package/dist/cjs/fork/useThenable.js.map +1 -1
- package/dist/cjs/fork/useThenable.native.js.map +1 -1
- package/dist/cjs/fork/validatePathConfig.cjs +32 -11
- package/dist/cjs/fork/validatePathConfig.js +41 -11
- package/dist/cjs/fork/validatePathConfig.js.map +1 -1
- package/dist/cjs/fork/validatePathConfig.native.js +47 -18
- package/dist/cjs/fork/validatePathConfig.native.js.map +2 -2
- package/dist/cjs/layouts/withLayoutContext.cjs +1 -1
- package/dist/cjs/layouts/withLayoutContext.js +1 -1
- package/dist/cjs/layouts/withLayoutContext.js.map +1 -1
- package/dist/cjs/layouts/withLayoutContext.native.js +1 -1
- package/dist/cjs/layouts/withLayoutContext.native.js.map +1 -1
- package/dist/cjs/link/linking.cjs +4 -4
- package/dist/cjs/link/linking.js +3 -3
- package/dist/cjs/link/linking.js.map +2 -2
- package/dist/cjs/link/linking.native.js +3 -3
- package/dist/cjs/link/linking.native.js.map +1 -1
- package/dist/cjs/link/useLinkTo.cjs +2 -2
- package/dist/cjs/link/useLinkTo.js +2 -2
- package/dist/cjs/link/useLinkTo.js.map +1 -1
- package/dist/cjs/link/useLinkTo.native.js +2 -2
- package/dist/cjs/link/useLinkTo.native.js.map +1 -1
- package/dist/cjs/router/getNormalizedStatePath.cjs +2 -2
- package/dist/cjs/router/getNormalizedStatePath.js +2 -2
- package/dist/cjs/router/getNormalizedStatePath.js.map +1 -1
- package/dist/cjs/router/getNormalizedStatePath.native.js +2 -2
- package/dist/cjs/router/getNormalizedStatePath.native.js.map +1 -1
- package/dist/cjs/router/router.cjs +19 -3
- package/dist/cjs/router/router.js +25 -3
- package/dist/cjs/router/router.js.map +1 -1
- package/dist/cjs/router/router.native.js +39 -3
- package/dist/cjs/router/router.native.js.map +2 -2
- package/dist/cjs/utils/serverContext.cjs +7 -7
- package/dist/cjs/utils/serverContext.js +7 -7
- package/dist/cjs/utils/serverContext.js.map +1 -1
- package/dist/cjs/utils/serverContext.native.js +5 -5
- package/dist/cjs/utils/serverContext.native.js.map +2 -2
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +6 -6
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js +3 -4
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js.map +2 -2
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +3 -4
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +2 -2
- package/dist/esm/Root.js +6 -2
- package/dist/esm/Root.js.map +1 -1
- package/dist/esm/Root.mjs +1 -1
- package/dist/esm/Root.mjs.map +1 -1
- package/dist/esm/Root.native.js +1 -1
- package/dist/esm/Root.native.js.map +2 -2
- package/dist/esm/cli/build.js +2 -3
- package/dist/esm/cli/build.js.map +1 -1
- package/dist/esm/cli/build.mjs +2 -3
- package/dist/esm/cli/build.mjs.map +1 -1
- package/dist/esm/cli/build.native.js +2 -3
- package/dist/esm/cli/build.native.js.map +2 -2
- package/dist/esm/constants.js +7 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/constants.mjs +8 -2
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +7 -1
- package/dist/esm/constants.native.js.map +2 -2
- package/dist/esm/fork/NavigationContainer.js +43 -20
- package/dist/esm/fork/NavigationContainer.js.map +1 -1
- package/dist/esm/fork/NavigationContainer.mjs +42 -24
- package/dist/esm/fork/NavigationContainer.mjs.map +1 -1
- package/dist/esm/fork/NavigationContainer.native.js +44 -24
- package/dist/esm/fork/NavigationContainer.native.js.map +2 -2
- package/dist/esm/fork/createMemoryHistory.js +3 -2
- package/dist/esm/fork/createMemoryHistory.js.map +1 -1
- package/dist/esm/fork/createMemoryHistory.mjs +4 -3
- package/dist/esm/fork/createMemoryHistory.mjs.map +1 -1
- package/dist/esm/fork/createMemoryHistory.native.js +4 -4
- package/dist/esm/fork/createMemoryHistory.native.js.map +2 -2
- package/dist/esm/fork/extractPathFromURL.js +42 -11
- package/dist/esm/fork/extractPathFromURL.js.map +1 -1
- package/dist/esm/fork/extractPathFromURL.mjs +39 -11
- package/dist/esm/fork/extractPathFromURL.mjs.map +1 -1
- package/dist/esm/fork/extractPathFromURL.native.js +52 -15
- package/dist/esm/fork/extractPathFromURL.native.js.map +2 -2
- package/dist/esm/fork/findFocusedRoute.js.map +1 -1
- package/dist/esm/fork/findFocusedRoute.mjs.map +1 -1
- package/dist/esm/fork/findFocusedRoute.native.js.map +1 -1
- package/dist/esm/fork/getPathFromState-mods.js +40 -0
- package/dist/esm/fork/getPathFromState-mods.js.map +6 -0
- package/dist/esm/fork/getPathFromState-mods.mjs +40 -0
- package/dist/esm/fork/getPathFromState-mods.mjs.map +1 -0
- package/dist/esm/fork/getPathFromState-mods.native.js +47 -0
- package/dist/esm/fork/getPathFromState-mods.native.js.map +6 -0
- package/dist/esm/fork/getPathFromState.js +71 -228
- package/dist/esm/fork/getPathFromState.js.map +2 -2
- package/dist/esm/fork/getPathFromState.mjs +73 -221
- package/dist/esm/fork/getPathFromState.mjs.map +1 -1
- package/dist/esm/fork/getPathFromState.native.js +79 -260
- package/dist/esm/fork/getPathFromState.native.js.map +2 -2
- package/dist/esm/fork/getStateFromPath-mods.js +176 -0
- package/dist/esm/fork/getStateFromPath-mods.js.map +6 -0
- package/dist/esm/fork/getStateFromPath-mods.mjs +143 -0
- package/dist/esm/fork/getStateFromPath-mods.mjs.map +1 -0
- package/dist/esm/fork/getStateFromPath-mods.native.js +246 -0
- package/dist/esm/fork/getStateFromPath-mods.native.js.map +6 -0
- package/dist/esm/fork/getStateFromPath.js +160 -265
- package/dist/esm/fork/getStateFromPath.js.map +2 -2
- package/dist/esm/fork/getStateFromPath.mjs +181 -260
- package/dist/esm/fork/getStateFromPath.mjs.map +1 -1
- package/dist/esm/fork/getStateFromPath.native.js +164 -302
- package/dist/esm/fork/getStateFromPath.native.js.map +2 -2
- package/dist/esm/fork/useBackButton.js.map +1 -1
- package/dist/esm/fork/useBackButton.mjs.map +1 -1
- package/dist/esm/fork/useBackButton.native.js.map +1 -1
- package/dist/esm/fork/useDocumentTitle.js +4 -1
- package/dist/esm/fork/useDocumentTitle.js.map +1 -1
- package/dist/esm/fork/useDocumentTitle.mjs.map +1 -1
- package/dist/esm/fork/useDocumentTitle.native.js +1 -1
- package/dist/esm/fork/useDocumentTitle.native.js.map +2 -2
- package/dist/esm/fork/useLinking.js +22 -26
- package/dist/esm/fork/useLinking.js.map +1 -1
- package/dist/esm/fork/useLinking.mjs +20 -23
- package/dist/esm/fork/useLinking.mjs.map +1 -1
- package/dist/esm/fork/useLinking.native.js +65 -67
- package/dist/esm/fork/useLinking.native.js.map +2 -2
- package/dist/esm/fork/useThenable.js.map +1 -1
- package/dist/esm/fork/useThenable.mjs.map +1 -1
- package/dist/esm/fork/useThenable.native.js.map +1 -1
- package/dist/esm/fork/validatePathConfig.js +41 -11
- package/dist/esm/fork/validatePathConfig.js.map +1 -1
- package/dist/esm/fork/validatePathConfig.mjs +32 -11
- package/dist/esm/fork/validatePathConfig.mjs.map +1 -1
- package/dist/esm/fork/validatePathConfig.native.js +43 -18
- package/dist/esm/fork/validatePathConfig.native.js.map +2 -2
- package/dist/esm/layouts/withLayoutContext.js +1 -1
- package/dist/esm/layouts/withLayoutContext.js.map +1 -1
- package/dist/esm/layouts/withLayoutContext.mjs +1 -1
- package/dist/esm/layouts/withLayoutContext.mjs.map +1 -1
- package/dist/esm/layouts/withLayoutContext.native.js +1 -1
- package/dist/esm/layouts/withLayoutContext.native.js.map +1 -1
- package/dist/esm/link/linking.js +2 -2
- package/dist/esm/link/linking.js.map +1 -1
- package/dist/esm/link/linking.mjs +2 -2
- package/dist/esm/link/linking.mjs.map +1 -1
- package/dist/esm/link/linking.native.js +2 -2
- package/dist/esm/link/linking.native.js.map +1 -1
- package/dist/esm/link/useLinkTo.js +1 -1
- package/dist/esm/link/useLinkTo.mjs +1 -1
- package/dist/esm/link/useLinkTo.native.js +1 -1
- package/dist/esm/router/getNormalizedStatePath.js +1 -1
- package/dist/esm/router/getNormalizedStatePath.mjs +1 -1
- package/dist/esm/router/getNormalizedStatePath.native.js +1 -1
- package/dist/esm/router/router.js +24 -2
- package/dist/esm/router/router.js.map +1 -1
- package/dist/esm/router/router.mjs +18 -2
- package/dist/esm/router/router.mjs.map +1 -1
- package/dist/esm/router/router.native.js +38 -2
- package/dist/esm/router/router.native.js.map +2 -2
- package/dist/esm/utils/serverContext.js +2 -1
- package/dist/esm/utils/serverContext.js.map +1 -1
- package/dist/esm/utils/serverContext.mjs +1 -1
- package/dist/esm/utils/serverContext.mjs.map +1 -1
- package/dist/esm/utils/serverContext.native.js +2 -1
- package/dist/esm/utils/serverContext.native.js.map +2 -2
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.js +3 -3
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.js.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +3 -3
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +3 -3
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +2 -2
- package/package.json +8 -9
- package/src/Root.tsx +6 -2
- package/src/cli/build.ts +2 -3
- package/src/constants.ts +8 -0
- package/src/fork/NavigationContainer.tsx +101 -39
- package/src/fork/createMemoryHistory.tsx +15 -13
- package/src/fork/extractPathFromURL.ts +85 -40
- package/src/fork/findFocusedRoute.tsx +9 -1
- package/src/fork/getPathFromState-mods.ts +142 -0
- package/src/fork/getPathFromState.ts +244 -501
- package/src/fork/getStateFromPath-mods.ts +400 -0
- package/src/fork/getStateFromPath.ts +447 -538
- package/src/fork/useBackButton.native.tsx +16 -2
- package/src/fork/useBackButton.tsx +11 -2
- package/src/fork/useDocumentTitle.native.tsx +9 -4
- package/src/fork/useDocumentTitle.tsx +12 -7
- package/src/fork/useLinking.native.ts +71 -63
- package/src/fork/useLinking.ts +75 -40
- package/src/fork/useThenable.tsx +7 -1
- package/src/fork/validatePathConfig.ts +64 -12
- package/src/layouts/withLayoutContext.tsx +1 -1
- package/src/link/linking.ts +2 -2
- package/src/link/useLinkTo.tsx +1 -1
- package/src/router/getNormalizedStatePath.tsx +1 -1
- package/src/router/router.ts +41 -2
- package/src/utils/serverContext.tsx +3 -1
- package/src/vite/plugins/fileSystemRouterPlugin.tsx +3 -3
- package/types/Root.d.ts.map +1 -1
- package/types/cli/build.d.ts.map +1 -1
- package/types/constants.d.ts +2 -0
- package/types/constants.d.ts.map +1 -1
- package/types/fork/NavigationContainer.d.ts +19 -8
- package/types/fork/NavigationContainer.d.ts.map +1 -1
- package/types/fork/createMemoryHistory.d.ts +10 -1
- package/types/fork/createMemoryHistory.d.ts.map +1 -1
- package/types/fork/extractPathFromURL.d.ts +7 -1
- package/types/fork/extractPathFromURL.d.ts.map +1 -1
- package/types/fork/findFocusedRoute.d.ts +9 -0
- package/types/fork/findFocusedRoute.d.ts.map +1 -1
- package/types/fork/getPathFromState-mods.d.ts +23 -0
- package/types/fork/getPathFromState-mods.d.ts.map +1 -0
- package/types/fork/getPathFromState.d.ts +15 -14
- package/types/fork/getPathFromState.d.ts.map +1 -1
- package/types/fork/getStateFromPath-mods.d.ts +58 -0
- package/types/fork/getStateFromPath-mods.d.ts.map +1 -0
- package/types/fork/getStateFromPath.d.ts +28 -29
- package/types/fork/getStateFromPath.d.ts.map +1 -1
- package/types/fork/useBackButton.d.ts +6 -0
- package/types/fork/useBackButton.d.ts.map +1 -1
- package/types/fork/useBackButton.native.d.ts +9 -1
- package/types/fork/useBackButton.native.d.ts.map +1 -1
- package/types/fork/useDocumentTitle.d.ts +8 -6
- package/types/fork/useDocumentTitle.d.ts.map +1 -1
- package/types/fork/useDocumentTitle.native.d.ts +5 -2
- package/types/fork/useDocumentTitle.native.d.ts.map +1 -1
- package/types/fork/useLinking.d.ts +8 -1
- package/types/fork/useLinking.d.ts.map +1 -1
- package/types/fork/useLinking.native.d.ts +9 -2
- package/types/fork/useLinking.native.d.ts.map +1 -1
- package/types/fork/useThenable.d.ts +6 -0
- package/types/fork/useThenable.d.ts.map +1 -1
- package/types/fork/validatePathConfig.d.ts +8 -1
- package/types/fork/validatePathConfig.d.ts.map +1 -1
- package/types/link/linking.d.ts +2 -2
- package/types/link/linking.d.ts.map +1 -1
- package/types/utils/serverContext.d.ts.map +1 -1
- package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
@@ -1,183 +1,102 @@
|
|
1
1
|
import escape from "escape-string-regexp";
|
2
|
-
import { matchGroupName, stripGroupSegmentsFromPath } from "../router/matchers";
|
3
2
|
import { findFocusedRoute } from "./findFocusedRoute";
|
4
|
-
import validatePathConfig from "./validatePathConfig";
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
import { validatePathConfig } from "./validatePathConfig";
|
4
|
+
import { appendIsInitial, createConfigItemAdditionalProperties, decodeURIComponentSafe, formatRegexPattern, getParamValue, getRouteConfigSorter, getUrlWithReactNavigationConcessions, matchForEmptyPath, parseQueryParamsExtended, populateParams } from "./getStateFromPath-mods";
|
5
|
+
function getStateFromPath(path, options) {
|
6
|
+
var _options_path, { initialRoutes, configs, configWithRegexes } = getConfigResources(options), screens = options?.screens, pathData = getUrlWithReactNavigationConcessions(path), remaining = pathData.nonstandardPathname.replace(/\/+/g, "/").replace(/^\//, "").replace(/\?.*$/, "");
|
7
|
+
remaining = remaining.endsWith("/") ? remaining : `${remaining}/`;
|
8
|
+
var prefix = options == null || (_options_path = options.path) === null || _options_path === void 0 ? void 0 : _options_path.replace(/^\//, "");
|
9
|
+
if (prefix) {
|
10
|
+
var normalizedPrefix = prefix.endsWith("/") ? prefix : `${prefix}/`;
|
11
|
+
if (!remaining.startsWith(normalizedPrefix))
|
12
|
+
return;
|
13
|
+
remaining = remaining.replace(normalizedPrefix, "");
|
15
14
|
}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
if (screens === void 0) {
|
16
|
+
var routes = remaining.split("/").filter(Boolean).map(function(segment) {
|
17
|
+
var name = decodeURIComponent(segment);
|
18
|
+
return {
|
19
|
+
name
|
20
|
+
};
|
21
|
+
});
|
22
|
+
return routes.length ? createNestedStateObject(pathData, routes, initialRoutes, [], pathData.url.hash) : void 0;
|
23
|
+
}
|
24
|
+
if (remaining === "/") {
|
25
|
+
var match = matchForEmptyPath(configWithRegexes);
|
26
|
+
return match ? createNestedStateObject(
|
27
|
+
pathData,
|
28
|
+
// @modified: pass pathData instead of path
|
29
|
+
match.routeNames.map(function(name) {
|
30
|
+
return {
|
31
|
+
name
|
32
|
+
};
|
33
|
+
}),
|
34
|
+
initialRoutes,
|
35
|
+
configs
|
36
|
+
) : void 0;
|
37
|
+
}
|
38
|
+
var result, current, { routes: routes1, remainingPath } = matchAgainstConfigs(remaining, configWithRegexes);
|
39
|
+
if (routes1 !== void 0 && (current = createNestedStateObject(pathData, routes1, initialRoutes, configs), remaining = remainingPath, result = current), !(current == null || result == null))
|
40
|
+
return result;
|
22
41
|
}
|
23
|
-
|
24
|
-
|
25
|
-
|
42
|
+
var cachedConfigResources = /* @__PURE__ */ new WeakMap();
|
43
|
+
function getConfigResources(options) {
|
44
|
+
if (!options) return prepareConfigResources();
|
45
|
+
var cached = cachedConfigResources.get(options);
|
46
|
+
if (cached) return cached;
|
47
|
+
var resources = prepareConfigResources(options);
|
48
|
+
return cachedConfigResources.set(options, resources), resources;
|
26
49
|
}
|
27
|
-
function
|
50
|
+
function prepareConfigResources(options, previousSegments) {
|
28
51
|
options && validatePathConfig(options);
|
29
|
-
var
|
30
|
-
|
31
|
-
|
52
|
+
var initialRoutes = getInitialRoutes(options), configs = getNormalizedConfigs(initialRoutes, options?.screens, previousSegments);
|
53
|
+
checkForDuplicatedConfigs(configs);
|
54
|
+
var configWithRegexes = getConfigsWithRegexes(configs);
|
55
|
+
return {
|
56
|
+
initialRoutes,
|
57
|
+
configs,
|
58
|
+
configWithRegexes
|
59
|
+
};
|
60
|
+
}
|
61
|
+
function getInitialRoutes(options) {
|
32
62
|
var initialRoutes = [];
|
33
|
-
options?.initialRouteName && initialRoutes.push({
|
63
|
+
return options?.initialRouteName && initialRoutes.push({
|
34
64
|
initialRouteName: options.initialRouteName,
|
35
65
|
parentScreens: []
|
36
|
-
});
|
37
|
-
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
|
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);
|
49
|
-
return assertConfigDuplicates(configs), {
|
50
|
-
configs,
|
51
|
-
initialRoutes
|
52
|
-
};
|
66
|
+
}), initialRoutes;
|
67
|
+
}
|
68
|
+
function getNormalizedConfigs(initialRoutes) {
|
69
|
+
var screens = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, previousSegments = arguments.length > 2 ? arguments[2] : void 0;
|
70
|
+
return [].concat(...Object.keys(screens).map(function(key) {
|
71
|
+
return createNormalizedConfigs(key, screens, [], initialRoutes, []);
|
72
|
+
})).map(appendIsInitial(initialRoutes)).sort(getRouteConfigSorter(previousSegments));
|
53
73
|
}
|
54
|
-
function
|
74
|
+
function checkForDuplicatedConfigs(configs) {
|
55
75
|
configs.reduce(function(acc, config) {
|
56
|
-
|
57
|
-
|
58
|
-
var a = alpha.routeNames, b = config.routeNames, intersects = a.length > b.length ? b.every(function(it, i) {
|
76
|
+
if (acc[config.pattern]) {
|
77
|
+
var a = acc[config.pattern].routeNames, b = config.routeNames, intersects = a.length > b.length ? b.every(function(it, i) {
|
59
78
|
return a[i] === it;
|
60
79
|
}) : a.every(function(it, i) {
|
61
80
|
return b[i] === it;
|
62
81
|
});
|
63
|
-
if (!intersects)
|
64
|
-
|
65
|
-
if (!last?.match(/^\*not-found$/)) {
|
66
|
-
var routeType = last?.startsWith(":") ? "dynamic route" : last?.startsWith("*") ? "dynamic-rest route" : "route";
|
67
|
-
throw new Error(`The ${routeType} pattern '${config.pattern || "/"}' resolves to both '${alpha.userReadableName}' and '${config.userReadableName}'. Patterns must be unique and cannot resolve to more than one route.`);
|
68
|
-
}
|
69
|
-
}
|
82
|
+
if (!intersects)
|
83
|
+
throw new Error(`Found conflicting screens with the same pattern. The pattern '${config.pattern}' resolves to both '${a.join(" > ")}' and '${b.join(" > ")}'. Patterns must be unique and cannot resolve to more than one screen.`);
|
70
84
|
}
|
71
85
|
return Object.assign(acc, {
|
72
|
-
[
|
86
|
+
[config.pattern]: config
|
73
87
|
});
|
74
88
|
}, {});
|
75
89
|
}
|
76
|
-
function
|
77
|
-
|
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) {
|
85
|
-
return matchGroupName(part) == null;
|
86
|
-
});
|
87
|
-
(a.screen === "index" || a.screen.match(/\/index$/)) && aParts.push("index");
|
88
|
-
var bParts = b.pattern.split("/").filter(function(part) {
|
89
|
-
return matchGroupName(part) == null;
|
90
|
-
});
|
91
|
-
(b.screen === "index" || b.screen.match(/\/index$/)) && bParts.push("index");
|
92
|
-
for (var i = 0; i < Math.max(aParts.length, bParts.length); i++) {
|
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("*");
|
98
|
-
if (aWildCard && bWildCard) {
|
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;
|
106
|
-
continue;
|
107
|
-
}
|
108
|
-
if (aWildCard)
|
109
|
-
return 1;
|
110
|
-
if (bWildCard)
|
111
|
-
return -1;
|
112
|
-
var aSlug = aParts[i].startsWith(":"), bSlug = bParts[i].startsWith(":");
|
113
|
-
if (aSlug && bSlug) {
|
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;
|
121
|
-
continue;
|
122
|
-
}
|
123
|
-
if (aSlug)
|
124
|
-
return 1;
|
125
|
-
if (bSlug)
|
126
|
-
return -1;
|
127
|
-
}
|
128
|
-
return a.isInitial && !b.isInitial ? -1 : !a.isInitial && b.isInitial ? 1 : bParts.length - aParts.length;
|
129
|
-
}
|
130
|
-
function getStateFromEmptyPathWithConfigs(path, hash, configs, initialRoutes) {
|
131
|
-
var leafNodes = configs.filter(function(config) {
|
132
|
-
return !config.hasChildren;
|
133
|
-
}).map(function(value) {
|
90
|
+
function getConfigsWithRegexes(configs) {
|
91
|
+
return configs.map(function(c) {
|
134
92
|
return {
|
135
|
-
...
|
136
|
-
//
|
137
|
-
//
|
138
|
-
|
93
|
+
...c,
|
94
|
+
// Add `$` to the regex to make sure it matches till end of the path and not just beginning
|
95
|
+
// @modified - start
|
96
|
+
// regex: c.regex ? new RegExp(c.regex.source + '$') : undefined,
|
97
|
+
regex: c.pattern ? new RegExp(`^(${c.pattern.split("/").map(formatRegexPattern).join("")})$`) : void 0
|
139
98
|
};
|
140
|
-
})
|
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 : (
|
151
|
-
// NOTE: Test leaf node deep dynamic routes that match a slash.
|
152
|
-
// This should be done last to enable dynamic routes having a higher priority.
|
153
|
-
leafNodes.find(function(config) {
|
154
|
-
return config.path.startsWith("*") && config.regex.test("/");
|
155
|
-
})
|
156
|
-
);
|
157
|
-
if (match) {
|
158
|
-
var routes = match.routeNames.map(function(name) {
|
159
|
-
return match._route ? {
|
160
|
-
name,
|
161
|
-
_route: match._route
|
162
|
-
} : {
|
163
|
-
name
|
164
|
-
};
|
165
|
-
});
|
166
|
-
return createNestedStateObject(path, hash, routes, configs, initialRoutes);
|
167
|
-
}
|
168
|
-
}
|
169
|
-
function getStateFromPathWithConfigs(path, configs, initialRoutes) {
|
170
|
-
var baseUrl = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : process.env.EXPO_BASE_URL, formattedPaths = getUrlWithReactNavigationConcessions(path);
|
171
|
-
if (!formattedPaths.url) {
|
172
|
-
console.warn(`No url found for ${path}`);
|
173
|
-
return;
|
174
|
-
}
|
175
|
-
var cleanPath = stripBaseUrl(stripGroupSegmentsFromPath(formattedPaths.url.pathname), baseUrl) + formattedPaths.url.search;
|
176
|
-
if (path.startsWith("/") || (cleanPath = cleanPath.slice(1)), formattedPaths.nonstandardPathname === "/")
|
177
|
-
return getStateFromEmptyPathWithConfigs(cleanPath, formattedPaths.url.hash.slice(1), configs, initialRoutes);
|
178
|
-
var routes = matchAgainstConfigs(formattedPaths.nonstandardPathname, configs);
|
179
|
-
if (routes != null)
|
180
|
-
return createNestedStateObject(cleanPath, formattedPaths.url.hash.slice(1), routes, configs, initialRoutes);
|
99
|
+
});
|
181
100
|
}
|
182
101
|
var joinPaths = function() {
|
183
102
|
for (var _len = arguments.length, paths = new Array(_len), _key = 0; _key < _len; _key++)
|
@@ -185,67 +104,60 @@ var joinPaths = function() {
|
|
185
104
|
return [].concat(...paths.map(function(p) {
|
186
105
|
return p.split("/");
|
187
106
|
})).filter(Boolean).join("/");
|
188
|
-
}
|
189
|
-
|
190
|
-
var routes, remainingPath = remaining, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
107
|
+
}, matchAgainstConfigs = function(remaining, configs) {
|
108
|
+
var routes, remainingPath = remaining, allParams = /* @__PURE__ */ Object.create(null), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
191
109
|
try {
|
192
110
|
for (var _loop = function() {
|
193
|
-
var config = _step.value
|
111
|
+
var config = _step.value;
|
194
112
|
if (!config.regex)
|
195
113
|
return "continue";
|
196
114
|
var match = remainingPath.match(config.regex);
|
197
|
-
if (
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
115
|
+
if (match) {
|
116
|
+
var _config_pattern, matchResult = (_config_pattern = config.pattern) === null || _config_pattern === void 0 ? void 0 : _config_pattern.split("/").reduce(
|
117
|
+
// Position of the current path param segment in the path (e.g in pattern `a/:b/:c`, `:a` is 0 and `:b` is 1)
|
118
|
+
// The extracted params
|
119
|
+
function(acc, p, index) {
|
120
|
+
if (!p.startsWith(":"))
|
121
|
+
return acc;
|
122
|
+
acc.pos += 1;
|
123
|
+
var decodedParamSegment = decodeURIComponentSafe(
|
124
|
+
// @modified: use decodeURIComponent**Safe**
|
125
|
+
// The param segments appear every second item starting from 2 in the regex match result
|
126
|
+
match[(acc.pos + 1) * 2].replace(/\/$/, "")
|
127
|
+
);
|
128
|
+
return Object.assign(acc.matchedParams, {
|
129
|
+
[p]: Object.assign(acc.matchedParams[p] || {}, {
|
130
|
+
[index]: decodedParamSegment
|
131
|
+
})
|
132
|
+
}), acc;
|
133
|
+
},
|
134
|
+
{
|
135
|
+
pos: -1,
|
136
|
+
matchedParams: {}
|
137
|
+
}
|
138
|
+
), matchedParams = matchResult.matchedParams || {};
|
139
|
+
return routes = config.routeNames.map(function(name) {
|
140
|
+
var _routeConfig_pattern_replace, routeConfig = configs.find(function(c) {
|
141
|
+
return c.screen === name && config.pattern.startsWith(c.pattern);
|
142
|
+
}), normalizedPath = routeConfig?.path.split("/").filter(Boolean).join("/"), numInitialSegments = routeConfig == null || (_routeConfig_pattern_replace = routeConfig.pattern.replace(new RegExp(`${escape(normalizedPath)}$`), "")) === null || _routeConfig_pattern_replace === void 0 ? void 0 : _routeConfig_pattern_replace.split("/").length, params = normalizedPath?.split("/").reduce(function(acc, p, index) {
|
143
|
+
var _matchedParams_p;
|
144
|
+
if (!p.startsWith(":"))
|
145
|
+
return acc;
|
146
|
+
var offset = numInitialSegments ? numInitialSegments - 1 : 0, value = getParamValue(p, (_matchedParams_p = matchedParams[p]) === null || _matchedParams_p === void 0 ? void 0 : _matchedParams_p[index + offset]);
|
147
|
+
if (value) {
|
148
|
+
var _routeConfig_parse, key = p.replace(/^:/, "").replace(/\?$/, "");
|
149
|
+
acc[key] = !(routeConfig == null || (_routeConfig_parse = routeConfig.parse) === null || _routeConfig_parse === void 0) && _routeConfig_parse[key] ? routeConfig.parse[key](value) : value;
|
150
|
+
}
|
151
|
+
return acc;
|
152
|
+
}, {});
|
153
|
+
return params && Object.keys(params).length ? {
|
154
|
+
name,
|
155
|
+
params
|
156
|
+
} : {
|
215
157
|
name
|
216
158
|
};
|
217
|
-
|
218
|
-
|
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";
|
159
|
+
}), remainingPath = remainingPath.replace(match[1], ""), "break";
|
160
|
+
}
|
249
161
|
}, _iterator = configs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
250
162
|
var _ret = _loop();
|
251
163
|
if (_ret === "break") break;
|
@@ -260,30 +172,23 @@ function matchAgainstConfigs(remaining, configs) {
|
|
260
172
|
throw _iteratorError;
|
261
173
|
}
|
262
174
|
}
|
263
|
-
return routes
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
if (a[i].localeCompare(b[i]) !== 0)
|
270
|
-
return !1;
|
271
|
-
return !0;
|
272
|
-
}
|
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 = [];
|
175
|
+
return populateParams(routes, allParams), {
|
176
|
+
routes,
|
177
|
+
remainingPath
|
178
|
+
};
|
179
|
+
}, createNormalizedConfigs = function(screen, routeConfig) {
|
180
|
+
var routeNames = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], initials = arguments.length > 3 ? arguments[3] : void 0, parentScreens = arguments.length > 4 ? arguments[4] : void 0, parentPattern = arguments.length > 5 ? arguments[5] : void 0, configs = [];
|
275
181
|
routeNames.push(screen), parentScreens.push(screen);
|
276
182
|
var config = routeConfig[screen];
|
277
183
|
if (typeof config == "string") {
|
278
184
|
var pattern = parentPattern ? joinPaths(parentPattern, config) : config;
|
279
|
-
configs.push(createConfigItem(screen, routeNames, pattern, config
|
185
|
+
configs.push(createConfigItem(screen, routeNames, pattern, config));
|
280
186
|
} else if (typeof config == "object") {
|
281
|
-
var pattern1
|
187
|
+
var pattern1;
|
282
188
|
if (typeof config.path == "string") {
|
283
|
-
var _Object_keys;
|
284
189
|
if (config.exact && config.path === void 0)
|
285
190
|
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: ''`.");
|
286
|
-
pattern1 = config.exact !== !0 ? joinPaths(parentPattern || "", config.path || "") : config.path || "", configs.push(createConfigItem(screen, routeNames, pattern1, config.path, config.
|
191
|
+
pattern1 = config.exact !== !0 ? joinPaths(parentPattern || "", config.path || "") : config.path || "", configs.push(createConfigItem(screen, routeNames, pattern1, config.path, config.parse, config));
|
287
192
|
}
|
288
193
|
config.screens && (config.initialRouteName && initials.push({
|
289
194
|
initialRouteName: config.initialRouteName,
|
@@ -296,13 +201,12 @@ var createNormalizedConfigs = function(screen, routeConfig) {
|
|
296
201
|
}));
|
297
202
|
}
|
298
203
|
return routeNames.pop(), configs;
|
299
|
-
}
|
300
|
-
|
301
|
-
return it = it.replace(" ", "%20"), it.startsWith(":") ? `(([^/]+\\/)${it.endsWith("?") ? "?" : ""})` : it.startsWith("*") ? `((.*\\/)${it.endsWith("?") ? "?" : ""})` : matchGroupName(it) != null ? `(?:${escape(it)}\\/)?` : escape(it) + "\\/";
|
302
|
-
}
|
303
|
-
var createConfigItem = function(screen, routeNames, pattern, path, hasChildren, parse, _route) {
|
204
|
+
}, createConfigItem = function(screen, routeNames, pattern, path) {
|
205
|
+
var parse = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : void 0, config = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {};
|
304
206
|
pattern = pattern.split("/").filter(Boolean).join("/");
|
305
|
-
var regex = pattern ? new RegExp(`^(${pattern.split("/").map(
|
207
|
+
var regex = pattern ? new RegExp(`^(${pattern.split("/").map(function(it) {
|
208
|
+
return it.startsWith(":") ? `(([^/]+\\/)${it.endsWith("?") ? "?" : ""})` : `${it === "*" ? ".*" : escape(it)}\\/`;
|
209
|
+
}).join("")})`) : void 0;
|
306
210
|
return {
|
307
211
|
screen,
|
308
212
|
regex,
|
@@ -313,17 +217,13 @@ var createConfigItem = function(screen, routeNames, pattern, path, hasChildren,
|
|
313
217
|
...routeNames
|
314
218
|
],
|
315
219
|
parse,
|
316
|
-
|
317
|
-
|
318
|
-
path || screen
|
319
|
-
].join("/"),
|
320
|
-
hasChildren: !!hasChildren,
|
321
|
-
_route
|
220
|
+
// @modified - start
|
221
|
+
...createConfigItemAdditionalProperties(screen, pattern, routeNames, config)
|
322
222
|
};
|
323
|
-
}, findParseConfigForRoute = function(routeName,
|
223
|
+
}, findParseConfigForRoute = function(routeName, flatConfig) {
|
324
224
|
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
325
225
|
try {
|
326
|
-
for (var _iterator =
|
226
|
+
for (var _iterator = flatConfig[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
327
227
|
var config = _step.value;
|
328
228
|
if (routeName === config.routeNames[config.routeNames.length - 1])
|
329
229
|
return config.parse;
|
@@ -343,8 +243,15 @@ var createConfigItem = function(screen, routeNames, pattern, path, hasChildren,
|
|
343
243
|
try {
|
344
244
|
for (var _iterator = initialRoutes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
345
245
|
var config = _step.value;
|
346
|
-
if (
|
347
|
-
|
246
|
+
if (parentScreens.length === config.parentScreens.length) {
|
247
|
+
for (var sameParents = !0, i = 0; i < parentScreens.length; i++)
|
248
|
+
if (parentScreens[i].localeCompare(config.parentScreens[i]) !== 0) {
|
249
|
+
sameParents = !1;
|
250
|
+
break;
|
251
|
+
}
|
252
|
+
if (sameParents)
|
253
|
+
return routeName !== config.initialRouteName ? config.initialRouteName : void 0;
|
254
|
+
}
|
348
255
|
}
|
349
256
|
} catch (err) {
|
350
257
|
_didIteratorError = !0, _iteratorError = err;
|
@@ -356,7 +263,7 @@ var createConfigItem = function(screen, routeNames, pattern, path, hasChildren,
|
|
356
263
|
throw _iteratorError;
|
357
264
|
}
|
358
265
|
}
|
359
|
-
}, createStateObject = function(route, isEmpty
|
266
|
+
}, createStateObject = function(initialRoute, route, isEmpty) {
|
360
267
|
return isEmpty ? initialRoute ? {
|
361
268
|
index: 1,
|
362
269
|
routes: [
|
@@ -392,69 +299,24 @@ var createConfigItem = function(screen, routeNames, pattern, path, hasChildren,
|
|
392
299
|
}
|
393
300
|
]
|
394
301
|
};
|
395
|
-
}, createNestedStateObject = function(
|
396
|
-
var route = routes.shift(), parentScreens = [], initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
|
302
|
+
}, createNestedStateObject = function(param, routes, initialRoutes, flatConfig, hash) {
|
303
|
+
var { path, ...restPathData } = param, route = routes.shift(), parentScreens = [], initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
|
397
304
|
parentScreens.push(route.name);
|
398
|
-
var state = createStateObject(route, routes.length === 0
|
305
|
+
var state = createStateObject(initialRoute, route, routes.length === 0);
|
399
306
|
if (routes.length > 0)
|
400
307
|
for (var nestedState = state; route = routes.shift(); ) {
|
401
308
|
initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
|
402
309
|
var nestedStateIndex = nestedState.index || nestedState.routes.length - 1;
|
403
|
-
nestedState.routes[nestedStateIndex].state = createStateObject(route, routes.length === 0
|
310
|
+
nestedState.routes[nestedStateIndex].state = createStateObject(initialRoute, route, routes.length === 0), routes.length > 0 && (nestedState = nestedState.routes[nestedStateIndex].state), parentScreens.push(route.name);
|
404
311
|
}
|
405
|
-
route = findFocusedRoute(state), route.path =
|
406
|
-
var params =
|
407
|
-
|
408
|
-
route.params
|
409
|
-
|
410
|
-
|
411
|
-
|
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;
|
416
|
-
}
|
417
|
-
}
|
418
|
-
} catch (err) {
|
419
|
-
_didIteratorError = !0, _iteratorError = err;
|
420
|
-
} finally {
|
421
|
-
try {
|
422
|
-
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
423
|
-
} finally {
|
424
|
-
if (_didIteratorError)
|
425
|
-
throw _iteratorError;
|
426
|
-
}
|
427
|
-
}
|
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();
|
440
|
-
function getBaseUrlRegex(baseUrl) {
|
441
|
-
if (baseUrlCache.has(baseUrl))
|
442
|
-
return baseUrlCache.get(baseUrl);
|
443
|
-
var regex = new RegExp(`^\\/?${escape(baseUrl)}`, "g");
|
444
|
-
return baseUrlCache.set(baseUrl, regex), regex;
|
445
|
-
}
|
446
|
-
function stripBaseUrl(path) {
|
447
|
-
var baseUrl = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : process.env.EXPO_BASE_URL;
|
448
|
-
if (process.env.NODE_ENV !== "development" && baseUrl) {
|
449
|
-
var reg = getBaseUrlRegex(baseUrl);
|
450
|
-
return path.replace(/^\/+/g, "/").replace(reg, "");
|
451
|
-
}
|
452
|
-
return path;
|
453
|
-
}
|
312
|
+
route = findFocusedRoute(state), route.path = restPathData.pathWithoutGroups;
|
313
|
+
var params = parseQueryParamsExtended(path, route, flatConfig ? findParseConfigForRoute(route.name, flatConfig) : void 0, hash);
|
314
|
+
return params && (route.params = {
|
315
|
+
...route.params,
|
316
|
+
...params
|
317
|
+
}), state;
|
318
|
+
};
|
454
319
|
export {
|
455
|
-
getStateFromPath
|
456
|
-
getMatchableRouteConfigs,
|
457
|
-
getUrlWithReactNavigationConcessions,
|
458
|
-
stripBaseUrl
|
320
|
+
getStateFromPath
|
459
321
|
};
|
460
322
|
//# sourceMappingURL=getStateFromPath.js.map
|