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
@@ -23,189 +23,105 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
23
23
|
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
24
24
|
var getStateFromPath_exports = {};
|
25
25
|
__export(getStateFromPath_exports, {
|
26
|
-
|
27
|
-
getMatchableRouteConfigs: () => getMatchableRouteConfigs,
|
28
|
-
getUrlWithReactNavigationConcessions: () => getUrlWithReactNavigationConcessions,
|
29
|
-
stripBaseUrl: () => stripBaseUrl
|
26
|
+
getStateFromPath: () => getStateFromPath
|
30
27
|
});
|
31
28
|
module.exports = __toCommonJS(getStateFromPath_exports);
|
32
|
-
var import_escape_string_regexp = __toESM(require("escape-string-regexp"), 1),
|
33
|
-
function
|
34
|
-
var
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
};
|
29
|
+
var import_escape_string_regexp = __toESM(require("escape-string-regexp"), 1), import_findFocusedRoute = require("./findFocusedRoute"), import_validatePathConfig = require("./validatePathConfig"), import_getStateFromPath_mods = require("./getStateFromPath-mods");
|
30
|
+
function getStateFromPath(path, options) {
|
31
|
+
var _options_path, { initialRoutes, configs, configWithRegexes } = getConfigResources(options), screens = options == null ? void 0 : options.screens, pathData = (0, import_getStateFromPath_mods.getUrlWithReactNavigationConcessions)(path), remaining = pathData.nonstandardPathname.replace(/\/+/g, "/").replace(/^\//, "").replace(/\?.*$/, "");
|
32
|
+
remaining = remaining.endsWith("/") ? remaining : `${remaining}/`;
|
33
|
+
var prefix = options == null || (_options_path = options.path) === null || _options_path === void 0 ? void 0 : _options_path.replace(/^\//, "");
|
34
|
+
if (prefix) {
|
35
|
+
var normalizedPrefix = prefix.endsWith("/") ? prefix : `${prefix}/`;
|
36
|
+
if (!remaining.startsWith(normalizedPrefix))
|
37
|
+
return;
|
38
|
+
remaining = remaining.replace(normalizedPrefix, "");
|
43
39
|
}
|
44
|
-
|
40
|
+
if (screens === void 0) {
|
41
|
+
var routes = remaining.split("/").filter(Boolean).map(function(segment) {
|
42
|
+
var name = decodeURIComponent(segment);
|
43
|
+
return {
|
44
|
+
name
|
45
|
+
};
|
46
|
+
});
|
47
|
+
return routes.length ? createNestedStateObject(pathData, routes, initialRoutes, [], pathData.url.hash) : void 0;
|
48
|
+
}
|
49
|
+
if (remaining === "/") {
|
50
|
+
var match = (0, import_getStateFromPath_mods.matchForEmptyPath)(configWithRegexes);
|
51
|
+
return match ? createNestedStateObject(
|
52
|
+
pathData,
|
53
|
+
// @modified: pass pathData instead of path
|
54
|
+
match.routeNames.map(function(name) {
|
55
|
+
return {
|
56
|
+
name
|
57
|
+
};
|
58
|
+
}),
|
59
|
+
initialRoutes,
|
60
|
+
configs
|
61
|
+
) : void 0;
|
62
|
+
}
|
63
|
+
var result, current, { routes: routes1, remainingPath } = matchAgainstConfigs(remaining, configWithRegexes);
|
64
|
+
if (routes1 !== void 0 && (current = createNestedStateObject(pathData, routes1, initialRoutes, configs), remaining = remainingPath, result = current), !(current == null || result == null))
|
65
|
+
return result;
|
66
|
+
}
|
67
|
+
var cachedConfigResources = /* @__PURE__ */ new WeakMap();
|
68
|
+
function getConfigResources(options) {
|
69
|
+
if (!options) return prepareConfigResources();
|
70
|
+
var cached = cachedConfigResources.get(options);
|
71
|
+
if (cached) return cached;
|
72
|
+
var resources = prepareConfigResources(options);
|
73
|
+
return cachedConfigResources.set(options, resources), resources;
|
74
|
+
}
|
75
|
+
function prepareConfigResources(options, previousSegments) {
|
76
|
+
options && (0, import_validatePathConfig.validatePathConfig)(options);
|
77
|
+
var initialRoutes = getInitialRoutes(options), configs = getNormalizedConfigs(initialRoutes, options == null ? void 0 : options.screens, previousSegments);
|
78
|
+
checkForDuplicatedConfigs(configs);
|
79
|
+
var configWithRegexes = getConfigsWithRegexes(configs);
|
45
80
|
return {
|
46
|
-
|
47
|
-
|
48
|
-
|
81
|
+
initialRoutes,
|
82
|
+
configs,
|
83
|
+
configWithRegexes
|
49
84
|
};
|
50
85
|
}
|
51
|
-
function
|
52
|
-
var { initialRoutes, configs } = getMatchableRouteConfigs(options);
|
53
|
-
return getStateFromPathWithConfigs(path, configs, initialRoutes);
|
54
|
-
}
|
55
|
-
function getMatchableRouteConfigs(options) {
|
56
|
-
options && (0, import_validatePathConfig.default)(options);
|
57
|
-
var screens = options == null ? void 0 : options.screens;
|
58
|
-
if (!screens)
|
59
|
-
throw Error("You must pass a 'screens' object to 'getStateFromPath' to generate a path.");
|
86
|
+
function getInitialRoutes(options) {
|
60
87
|
var initialRoutes = [];
|
61
|
-
options != null && options.initialRouteName && initialRoutes.push({
|
88
|
+
return options != null && options.initialRouteName && initialRoutes.push({
|
62
89
|
initialRouteName: options.initialRouteName,
|
63
90
|
parentScreens: []
|
64
|
-
});
|
65
|
-
var converted = Object.keys(screens).flatMap(function(key) {
|
66
|
-
return createNormalizedConfigs(key, screens, [], initialRoutes);
|
67
|
-
}).flat(), resolvedInitialPatterns = initialRoutes.map(function(route) {
|
68
|
-
return joinPaths(...route.parentScreens, route.initialRouteName);
|
69
|
-
}), convertedWithInitial = converted.map(function(config) {
|
70
|
-
return {
|
71
|
-
...config,
|
72
|
-
// TODO: Probably a safer way to do this
|
73
|
-
// Mark initial routes to give them potential priority over other routes that match.
|
74
|
-
isInitial: resolvedInitialPatterns.includes(config.routeNames.join("/"))
|
75
|
-
};
|
76
|
-
}), configs = convertedWithInitial.sort(sortConfigs);
|
77
|
-
return assertConfigDuplicates(configs), {
|
78
|
-
configs,
|
79
|
-
initialRoutes
|
80
|
-
};
|
91
|
+
}), initialRoutes;
|
81
92
|
}
|
82
|
-
function
|
93
|
+
function getNormalizedConfigs(initialRoutes) {
|
94
|
+
var screens = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, previousSegments = arguments.length > 2 ? arguments[2] : void 0;
|
95
|
+
return [].concat(...Object.keys(screens).map(function(key) {
|
96
|
+
return createNormalizedConfigs(key, screens, [], initialRoutes, []);
|
97
|
+
})).map((0, import_getStateFromPath_mods.appendIsInitial)(initialRoutes)).sort((0, import_getStateFromPath_mods.getRouteConfigSorter)(previousSegments));
|
98
|
+
}
|
99
|
+
function checkForDuplicatedConfigs(configs) {
|
83
100
|
configs.reduce(function(acc, config) {
|
84
|
-
|
85
|
-
|
86
|
-
var a = alpha.routeNames, b = config.routeNames, intersects = a.length > b.length ? b.every(function(it, i) {
|
101
|
+
if (acc[config.pattern]) {
|
102
|
+
var a = acc[config.pattern].routeNames, b = config.routeNames, intersects = a.length > b.length ? b.every(function(it, i) {
|
87
103
|
return a[i] === it;
|
88
104
|
}) : a.every(function(it, i) {
|
89
105
|
return b[i] === it;
|
90
106
|
});
|
91
|
-
if (!intersects)
|
92
|
-
|
93
|
-
if (!(last != null && last.match(/^\*not-found$/))) {
|
94
|
-
var routeType = last != null && last.startsWith(":") ? "dynamic route" : last != null && last.startsWith("*") ? "dynamic-rest route" : "route";
|
95
|
-
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.`);
|
96
|
-
}
|
97
|
-
}
|
107
|
+
if (!intersects)
|
108
|
+
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.`);
|
98
109
|
}
|
99
110
|
return Object.assign(acc, {
|
100
|
-
[
|
111
|
+
[config.pattern]: config
|
101
112
|
});
|
102
113
|
}, {});
|
103
114
|
}
|
104
|
-
function
|
105
|
-
|
106
|
-
return b.routeNames.join(">").localeCompare(a.routeNames.join(">"));
|
107
|
-
if (a.pattern.startsWith(b.pattern) && // NOTE: This is a hack to make sure that `*` is always at the end
|
108
|
-
b.screen !== "index")
|
109
|
-
return -1;
|
110
|
-
if (b.pattern.startsWith(a.pattern) && a.screen !== "index")
|
111
|
-
return 1;
|
112
|
-
var aParts = a.pattern.split("/").filter(function(part) {
|
113
|
-
return (0, import_matchers.matchGroupName)(part) == null;
|
114
|
-
});
|
115
|
-
(a.screen === "index" || a.screen.match(/\/index$/)) && aParts.push("index");
|
116
|
-
var bParts = b.pattern.split("/").filter(function(part) {
|
117
|
-
return (0, import_matchers.matchGroupName)(part) == null;
|
118
|
-
});
|
119
|
-
(b.screen === "index" || b.screen.match(/\/index$/)) && bParts.push("index");
|
120
|
-
for (var i = 0; i < Math.max(aParts.length, bParts.length); i++) {
|
121
|
-
if (aParts[i] == null)
|
122
|
-
return 1;
|
123
|
-
if (bParts[i] == null)
|
124
|
-
return -1;
|
125
|
-
var aWildCard = aParts[i].startsWith("*"), bWildCard = bParts[i].startsWith("*");
|
126
|
-
if (aWildCard && bWildCard) {
|
127
|
-
var aNotFound = aParts[i].match(/^[*]not-found$/), bNotFound = bParts[i].match(/^[*]not-found$/);
|
128
|
-
if (aNotFound && bNotFound)
|
129
|
-
continue;
|
130
|
-
if (aNotFound)
|
131
|
-
return 1;
|
132
|
-
if (bNotFound)
|
133
|
-
return -1;
|
134
|
-
continue;
|
135
|
-
}
|
136
|
-
if (aWildCard)
|
137
|
-
return 1;
|
138
|
-
if (bWildCard)
|
139
|
-
return -1;
|
140
|
-
var aSlug = aParts[i].startsWith(":"), bSlug = bParts[i].startsWith(":");
|
141
|
-
if (aSlug && bSlug) {
|
142
|
-
var aNotFound1 = aParts[i].match(/^[*]not-found$/), bNotFound1 = bParts[i].match(/^[*]not-found$/);
|
143
|
-
if (aNotFound1 && bNotFound1)
|
144
|
-
continue;
|
145
|
-
if (aNotFound1)
|
146
|
-
return 1;
|
147
|
-
if (bNotFound1)
|
148
|
-
return -1;
|
149
|
-
continue;
|
150
|
-
}
|
151
|
-
if (aSlug)
|
152
|
-
return 1;
|
153
|
-
if (bSlug)
|
154
|
-
return -1;
|
155
|
-
}
|
156
|
-
return a.isInitial && !b.isInitial ? -1 : !a.isInitial && b.isInitial ? 1 : bParts.length - aParts.length;
|
157
|
-
}
|
158
|
-
function getStateFromEmptyPathWithConfigs(path, hash, configs, initialRoutes) {
|
159
|
-
var leafNodes = configs.filter(function(config) {
|
160
|
-
return !config.hasChildren;
|
161
|
-
}).map(function(value) {
|
115
|
+
function getConfigsWithRegexes(configs) {
|
116
|
+
return configs.map(function(c) {
|
162
117
|
return {
|
163
|
-
...
|
164
|
-
//
|
165
|
-
//
|
166
|
-
|
118
|
+
...c,
|
119
|
+
// Add `$` to the regex to make sure it matches till end of the path and not just beginning
|
120
|
+
// @modified - start
|
121
|
+
// regex: c.regex ? new RegExp(c.regex.source + '$') : undefined,
|
122
|
+
regex: c.pattern ? new RegExp(`^(${c.pattern.split("/").map(import_getStateFromPath_mods.formatRegexPattern).join("")})$`) : void 0
|
167
123
|
};
|
168
|
-
})
|
169
|
-
return (
|
170
|
-
// NOTE: Test leaf node index routes that either don't have a regex or match an empty string.
|
171
|
-
config.path === "" && (!config.regex || config.regex.test(""))
|
172
|
-
);
|
173
|
-
})) !== null && _leafNodes_find !== void 0 ? _leafNodes_find : leafNodes.find(function(config) {
|
174
|
-
return (
|
175
|
-
// NOTE: Test leaf node dynamic routes that match an empty string.
|
176
|
-
config.path.startsWith(":") && config.regex.test("")
|
177
|
-
);
|
178
|
-
})) !== null && _ref !== void 0 ? _ref : (
|
179
|
-
// NOTE: Test leaf node deep dynamic routes that match a slash.
|
180
|
-
// This should be done last to enable dynamic routes having a higher priority.
|
181
|
-
leafNodes.find(function(config) {
|
182
|
-
return config.path.startsWith("*") && config.regex.test("/");
|
183
|
-
})
|
184
|
-
);
|
185
|
-
if (match) {
|
186
|
-
var routes = match.routeNames.map(function(name) {
|
187
|
-
return match._route ? {
|
188
|
-
name,
|
189
|
-
_route: match._route
|
190
|
-
} : {
|
191
|
-
name
|
192
|
-
};
|
193
|
-
});
|
194
|
-
return createNestedStateObject(path, hash, routes, configs, initialRoutes);
|
195
|
-
}
|
196
|
-
}
|
197
|
-
function getStateFromPathWithConfigs(path, configs, initialRoutes) {
|
198
|
-
var baseUrl = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : process.env.EXPO_BASE_URL, formattedPaths = getUrlWithReactNavigationConcessions(path);
|
199
|
-
if (!formattedPaths.url) {
|
200
|
-
console.warn(`No url found for ${path}`);
|
201
|
-
return;
|
202
|
-
}
|
203
|
-
var cleanPath = stripBaseUrl((0, import_matchers.stripGroupSegmentsFromPath)(formattedPaths.url.pathname), baseUrl) + formattedPaths.url.search;
|
204
|
-
if (path.startsWith("/") || (cleanPath = cleanPath.slice(1)), formattedPaths.nonstandardPathname === "/")
|
205
|
-
return getStateFromEmptyPathWithConfigs(cleanPath, formattedPaths.url.hash.slice(1), configs, initialRoutes);
|
206
|
-
var routes = matchAgainstConfigs(formattedPaths.nonstandardPathname, configs);
|
207
|
-
if (routes != null)
|
208
|
-
return createNestedStateObject(cleanPath, formattedPaths.url.hash.slice(1), routes, configs, initialRoutes);
|
124
|
+
});
|
209
125
|
}
|
210
126
|
var joinPaths = function() {
|
211
127
|
for (var _len = arguments.length, paths = new Array(_len), _key = 0; _key < _len; _key++)
|
@@ -213,67 +129,60 @@ var joinPaths = function() {
|
|
213
129
|
return [].concat(...paths.map(function(p) {
|
214
130
|
return p.split("/");
|
215
131
|
})).filter(Boolean).join("/");
|
216
|
-
}
|
217
|
-
|
218
|
-
var routes, remainingPath = remaining, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
132
|
+
}, matchAgainstConfigs = function(remaining, configs) {
|
133
|
+
var routes, remainingPath = remaining, allParams = /* @__PURE__ */ Object.create(null), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
219
134
|
try {
|
220
135
|
for (var _loop = function() {
|
221
|
-
var config = _step.value
|
136
|
+
var config = _step.value;
|
222
137
|
if (!config.regex)
|
223
138
|
return "continue";
|
224
139
|
var match = remainingPath.match(config.regex);
|
225
|
-
if (
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
140
|
+
if (match) {
|
141
|
+
var _config_pattern, matchResult = (_config_pattern = config.pattern) === null || _config_pattern === void 0 ? void 0 : _config_pattern.split("/").reduce(
|
142
|
+
// Position of the current path param segment in the path (e.g in pattern `a/:b/:c`, `:a` is 0 and `:b` is 1)
|
143
|
+
// The extracted params
|
144
|
+
function(acc, p, index) {
|
145
|
+
if (!p.startsWith(":"))
|
146
|
+
return acc;
|
147
|
+
acc.pos += 1;
|
148
|
+
var decodedParamSegment = (0, import_getStateFromPath_mods.decodeURIComponentSafe)(
|
149
|
+
// @modified: use decodeURIComponent**Safe**
|
150
|
+
// The param segments appear every second item starting from 2 in the regex match result
|
151
|
+
match[(acc.pos + 1) * 2].replace(/\/$/, "")
|
152
|
+
);
|
153
|
+
return Object.assign(acc.matchedParams, {
|
154
|
+
[p]: Object.assign(acc.matchedParams[p] || {}, {
|
155
|
+
[index]: decodedParamSegment
|
156
|
+
})
|
157
|
+
}), acc;
|
158
|
+
},
|
159
|
+
{
|
160
|
+
pos: -1,
|
161
|
+
matchedParams: {}
|
162
|
+
}
|
163
|
+
), matchedParams = matchResult.matchedParams || {};
|
164
|
+
return routes = config.routeNames.map(function(name) {
|
165
|
+
var _routeConfig_pattern_replace, routeConfig = configs.find(function(c) {
|
166
|
+
return c.screen === name && config.pattern.startsWith(c.pattern);
|
167
|
+
}), normalizedPath = routeConfig == null ? void 0 : routeConfig.path.split("/").filter(Boolean).join("/"), numInitialSegments = routeConfig == null || (_routeConfig_pattern_replace = routeConfig.pattern.replace(new RegExp(`${(0, import_escape_string_regexp.default)(normalizedPath)}$`), "")) === null || _routeConfig_pattern_replace === void 0 ? void 0 : _routeConfig_pattern_replace.split("/").length, params = normalizedPath == null ? void 0 : normalizedPath.split("/").reduce(function(acc, p, index) {
|
168
|
+
var _matchedParams_p;
|
169
|
+
if (!p.startsWith(":"))
|
170
|
+
return acc;
|
171
|
+
var offset = numInitialSegments ? numInitialSegments - 1 : 0, value = (0, import_getStateFromPath_mods.getParamValue)(p, (_matchedParams_p = matchedParams[p]) === null || _matchedParams_p === void 0 ? void 0 : _matchedParams_p[index + offset]);
|
172
|
+
if (value) {
|
173
|
+
var _routeConfig_parse, key = p.replace(/^:/, "").replace(/\?$/, "");
|
174
|
+
acc[key] = !(routeConfig == null || (_routeConfig_parse = routeConfig.parse) === null || _routeConfig_parse === void 0) && _routeConfig_parse[key] ? routeConfig.parse[key](value) : value;
|
175
|
+
}
|
176
|
+
return acc;
|
177
|
+
}, {});
|
178
|
+
return params && Object.keys(params).length ? {
|
179
|
+
name,
|
180
|
+
params
|
181
|
+
} : {
|
243
182
|
name
|
244
183
|
};
|
245
|
-
|
246
|
-
|
247
|
-
return p.match(/^[:*]/);
|
248
|
-
}).forEach(function(p) {
|
249
|
-
var value = matchedParams[p];
|
250
|
-
if (value) {
|
251
|
-
var _config_parse;
|
252
|
-
p.match(/^\*/) && (value = value == null ? void 0 : value.split("/").filter(Boolean));
|
253
|
-
var key = p.replace(/^[:*]/, "").replace(/\?$/, "");
|
254
|
-
params[key] = !((_config_parse = config2.parse) === null || _config_parse === void 0) && _config_parse[key] ? config2.parse[key](value) : value;
|
255
|
-
}
|
256
|
-
}), params && Object.keys(params).length ? {
|
257
|
-
name,
|
258
|
-
params
|
259
|
-
} : {
|
260
|
-
name
|
261
|
-
};
|
262
|
-
};
|
263
|
-
routes = config.routeNames.map(function(name) {
|
264
|
-
return config._route ? {
|
265
|
-
...routeFromName(name),
|
266
|
-
_route: config._route
|
267
|
-
} : {
|
268
|
-
...routeFromName(name)
|
269
|
-
};
|
270
|
-
});
|
271
|
-
var combinedParams = routes.reduce(function(acc, r) {
|
272
|
-
return Object.assign(acc, r.params);
|
273
|
-
}, {}), hasCombinedParams = Object.keys(combinedParams).length > 0;
|
274
|
-
return routes = routes.map(function(r) {
|
275
|
-
return hasCombinedParams && (r.params = combinedParams), r;
|
276
|
-
}), remainingPath = remainingPath.replace(match[1], ""), "break";
|
184
|
+
}), remainingPath = remainingPath.replace(match[1], ""), "break";
|
185
|
+
}
|
277
186
|
}, _iterator = configs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
278
187
|
var _ret = _loop();
|
279
188
|
if (_ret === "break") break;
|
@@ -288,30 +197,23 @@ function matchAgainstConfigs(remaining, configs) {
|
|
288
197
|
throw _iteratorError;
|
289
198
|
}
|
290
199
|
}
|
291
|
-
return routes
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
if (a[i].localeCompare(b[i]) !== 0)
|
298
|
-
return !1;
|
299
|
-
return !0;
|
300
|
-
}
|
301
|
-
var createNormalizedConfigs = function(screen, routeConfig) {
|
302
|
-
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 = [];
|
200
|
+
return (0, import_getStateFromPath_mods.populateParams)(routes, allParams), {
|
201
|
+
routes,
|
202
|
+
remainingPath
|
203
|
+
};
|
204
|
+
}, createNormalizedConfigs = function(screen, routeConfig) {
|
205
|
+
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 = [];
|
303
206
|
routeNames.push(screen), parentScreens.push(screen);
|
304
207
|
var config = routeConfig[screen];
|
305
208
|
if (typeof config == "string") {
|
306
209
|
var pattern = parentPattern ? joinPaths(parentPattern, config) : config;
|
307
|
-
configs.push(createConfigItem(screen, routeNames, pattern, config
|
210
|
+
configs.push(createConfigItem(screen, routeNames, pattern, config));
|
308
211
|
} else if (typeof config == "object") {
|
309
|
-
var pattern1
|
212
|
+
var pattern1;
|
310
213
|
if (typeof config.path == "string") {
|
311
|
-
var _Object_keys;
|
312
214
|
if (config.exact && config.path === void 0)
|
313
215
|
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: ''`.");
|
314
|
-
pattern1 = config.exact !== !0 ? joinPaths(parentPattern || "", config.path || "") : config.path || "", configs.push(createConfigItem(screen, routeNames, pattern1, config.path, config.
|
216
|
+
pattern1 = config.exact !== !0 ? joinPaths(parentPattern || "", config.path || "") : config.path || "", configs.push(createConfigItem(screen, routeNames, pattern1, config.path, config.parse, config));
|
315
217
|
}
|
316
218
|
config.screens && (config.initialRouteName && initials.push({
|
317
219
|
initialRouteName: config.initialRouteName,
|
@@ -324,13 +226,12 @@ var createNormalizedConfigs = function(screen, routeConfig) {
|
|
324
226
|
}));
|
325
227
|
}
|
326
228
|
return routeNames.pop(), configs;
|
327
|
-
}
|
328
|
-
|
329
|
-
return it = it.replace(" ", "%20"), it.startsWith(":") ? `(([^/]+\\/)${it.endsWith("?") ? "?" : ""})` : it.startsWith("*") ? `((.*\\/)${it.endsWith("?") ? "?" : ""})` : (0, import_matchers.matchGroupName)(it) != null ? `(?:${(0, import_escape_string_regexp.default)(it)}\\/)?` : (0, import_escape_string_regexp.default)(it) + "\\/";
|
330
|
-
}
|
331
|
-
var createConfigItem = function(screen, routeNames, pattern, path, hasChildren, parse, _route) {
|
229
|
+
}, createConfigItem = function(screen, routeNames, pattern, path) {
|
230
|
+
var parse = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : void 0, config = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {};
|
332
231
|
pattern = pattern.split("/").filter(Boolean).join("/");
|
333
|
-
var regex = pattern ? new RegExp(`^(${pattern.split("/").map(
|
232
|
+
var regex = pattern ? new RegExp(`^(${pattern.split("/").map(function(it) {
|
233
|
+
return it.startsWith(":") ? `(([^/]+\\/)${it.endsWith("?") ? "?" : ""})` : `${it === "*" ? ".*" : (0, import_escape_string_regexp.default)(it)}\\/`;
|
234
|
+
}).join("")})`) : void 0;
|
334
235
|
return {
|
335
236
|
screen,
|
336
237
|
regex,
|
@@ -341,17 +242,13 @@ var createConfigItem = function(screen, routeNames, pattern, path, hasChildren,
|
|
341
242
|
...routeNames
|
342
243
|
],
|
343
244
|
parse,
|
344
|
-
|
345
|
-
|
346
|
-
path || screen
|
347
|
-
].join("/"),
|
348
|
-
hasChildren: !!hasChildren,
|
349
|
-
_route
|
245
|
+
// @modified - start
|
246
|
+
...(0, import_getStateFromPath_mods.createConfigItemAdditionalProperties)(screen, pattern, routeNames, config)
|
350
247
|
};
|
351
|
-
}, findParseConfigForRoute = function(routeName,
|
248
|
+
}, findParseConfigForRoute = function(routeName, flatConfig) {
|
352
249
|
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
353
250
|
try {
|
354
|
-
for (var _iterator =
|
251
|
+
for (var _iterator = flatConfig[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
355
252
|
var config = _step.value;
|
356
253
|
if (routeName === config.routeNames[config.routeNames.length - 1])
|
357
254
|
return config.parse;
|
@@ -371,8 +268,15 @@ var createConfigItem = function(screen, routeNames, pattern, path, hasChildren,
|
|
371
268
|
try {
|
372
269
|
for (var _iterator = initialRoutes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
373
270
|
var config = _step.value;
|
374
|
-
if (
|
375
|
-
|
271
|
+
if (parentScreens.length === config.parentScreens.length) {
|
272
|
+
for (var sameParents = !0, i = 0; i < parentScreens.length; i++)
|
273
|
+
if (parentScreens[i].localeCompare(config.parentScreens[i]) !== 0) {
|
274
|
+
sameParents = !1;
|
275
|
+
break;
|
276
|
+
}
|
277
|
+
if (sameParents)
|
278
|
+
return routeName !== config.initialRouteName ? config.initialRouteName : void 0;
|
279
|
+
}
|
376
280
|
}
|
377
281
|
} catch (err) {
|
378
282
|
_didIteratorError = !0, _iteratorError = err;
|
@@ -384,7 +288,7 @@ var createConfigItem = function(screen, routeNames, pattern, path, hasChildren,
|
|
384
288
|
throw _iteratorError;
|
385
289
|
}
|
386
290
|
}
|
387
|
-
}, createStateObject = function(route, isEmpty
|
291
|
+
}, createStateObject = function(initialRoute, route, isEmpty) {
|
388
292
|
return isEmpty ? initialRoute ? {
|
389
293
|
index: 1,
|
390
294
|
routes: [
|
@@ -420,69 +324,25 @@ var createConfigItem = function(screen, routeNames, pattern, path, hasChildren,
|
|
420
324
|
}
|
421
325
|
]
|
422
326
|
};
|
423
|
-
}, createNestedStateObject = function(
|
424
|
-
var route = routes.shift(), parentScreens = [], initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
|
327
|
+
}, createNestedStateObject = function(param, routes, initialRoutes, flatConfig, hash) {
|
328
|
+
var { path, ...restPathData } = param, route = routes.shift(), parentScreens = [], initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
|
425
329
|
parentScreens.push(route.name);
|
426
|
-
var state = createStateObject(route, routes.length === 0
|
330
|
+
var state = createStateObject(initialRoute, route, routes.length === 0);
|
427
331
|
if (routes.length > 0)
|
428
332
|
for (var nestedState = state; route = routes.shift(); ) {
|
429
333
|
initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
|
430
334
|
var nestedStateIndex = nestedState.index || nestedState.routes.length - 1;
|
431
|
-
nestedState.routes[nestedStateIndex].state = createStateObject(route, routes.length === 0
|
432
|
-
}
|
433
|
-
route = (0, import_findFocusedRoute.findFocusedRoute)(state), route.path = path;
|
434
|
-
var params = parseQueryParams(route.path, findParseConfigForRoute(route.name, routeConfigs));
|
435
|
-
if (params) {
|
436
|
-
route.params = Object.assign(/* @__PURE__ */ Object.create(null), route.params);
|
437
|
-
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
438
|
-
try {
|
439
|
-
for (var _iterator = Object.entries(params)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
440
|
-
var [name, value] = _step.value, _route_params, _route_params1;
|
441
|
-
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])) {
|
442
|
-
route.params[name] = value;
|
443
|
-
continue;
|
444
|
-
}
|
445
|
-
}
|
446
|
-
} catch (err) {
|
447
|
-
_didIteratorError = !0, _iteratorError = err;
|
448
|
-
} finally {
|
449
|
-
try {
|
450
|
-
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
451
|
-
} finally {
|
452
|
-
if (_didIteratorError)
|
453
|
-
throw _iteratorError;
|
454
|
-
}
|
335
|
+
nestedState.routes[nestedStateIndex].state = createStateObject(initialRoute, route, routes.length === 0), routes.length > 0 && (nestedState = nestedState.routes[nestedStateIndex].state), parentScreens.push(route.name);
|
455
336
|
}
|
456
|
-
|
457
|
-
|
458
|
-
return
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
);
|
464
|
-
return parseConfig && Object.keys(params).forEach(function(name) {
|
465
|
-
Object.hasOwnProperty.call(parseConfig, name) && typeof params[name] == "string" && (params[name] = parseConfig[name](params[name]));
|
466
|
-
}), Object.keys(params).length ? params : void 0;
|
467
|
-
}, baseUrlCache = /* @__PURE__ */ new Map();
|
468
|
-
function getBaseUrlRegex(baseUrl) {
|
469
|
-
if (baseUrlCache.has(baseUrl))
|
470
|
-
return baseUrlCache.get(baseUrl);
|
471
|
-
var regex = new RegExp(`^\\/?${(0, import_escape_string_regexp.default)(baseUrl)}`, "g");
|
472
|
-
return baseUrlCache.set(baseUrl, regex), regex;
|
473
|
-
}
|
474
|
-
function stripBaseUrl(path) {
|
475
|
-
var baseUrl = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : process.env.EXPO_BASE_URL;
|
476
|
-
if (process.env.NODE_ENV !== "development" && baseUrl) {
|
477
|
-
var reg = getBaseUrlRegex(baseUrl);
|
478
|
-
return path.replace(/^\/+/g, "/").replace(reg, "");
|
479
|
-
}
|
480
|
-
return path;
|
481
|
-
}
|
337
|
+
route = (0, import_findFocusedRoute.findFocusedRoute)(state), route.path = restPathData.pathWithoutGroups;
|
338
|
+
var params = (0, import_getStateFromPath_mods.parseQueryParamsExtended)(path, route, flatConfig ? findParseConfigForRoute(route.name, flatConfig) : void 0, hash);
|
339
|
+
return params && (route.params = {
|
340
|
+
...route.params,
|
341
|
+
...params
|
342
|
+
}), state;
|
343
|
+
};
|
482
344
|
// Annotate the CommonJS export names for ESM import in node:
|
483
345
|
0 && (module.exports = {
|
484
|
-
|
485
|
-
getUrlWithReactNavigationConcessions,
|
486
|
-
stripBaseUrl
|
346
|
+
getStateFromPath
|
487
347
|
});
|
488
348
|
//# sourceMappingURL=getStateFromPath.js.map
|