one 1.19.4 → 1.19.5
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/hooks.cjs +3 -5
- package/dist/cjs/hooks.native.js +3 -5
- package/dist/cjs/hooks.native.js.map +1 -1
- package/dist/cjs/router/Route.cjs +2 -1
- package/dist/cjs/router/Route.native.js +2 -1
- package/dist/cjs/router/Route.native.js.map +1 -1
- package/dist/cjs/router/path.cjs +73 -0
- package/dist/cjs/router/path.native.js +98 -0
- package/dist/cjs/router/path.native.js.map +1 -0
- package/dist/cjs/router/path.test.cjs +62 -0
- package/dist/cjs/router/path.test.native.js +65 -0
- package/dist/cjs/router/path.test.native.js.map +1 -0
- package/dist/cjs/router/router.cjs +7 -12
- package/dist/cjs/router/router.native.js +7 -12
- package/dist/cjs/router/router.native.js.map +1 -1
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/esm/hooks.mjs +3 -5
- package/dist/esm/hooks.mjs.map +1 -1
- package/dist/esm/hooks.native.js +3 -5
- package/dist/esm/hooks.native.js.map +1 -1
- package/dist/esm/router/Route.mjs +2 -1
- package/dist/esm/router/Route.mjs.map +1 -1
- package/dist/esm/router/Route.native.js +2 -1
- package/dist/esm/router/Route.native.js.map +1 -1
- package/dist/esm/router/path.mjs +42 -0
- package/dist/esm/router/path.mjs.map +1 -0
- package/dist/esm/router/path.native.js +64 -0
- package/dist/esm/router/path.native.js.map +1 -0
- package/dist/esm/router/path.test.mjs +63 -0
- package/dist/esm/router/path.test.mjs.map +1 -0
- package/dist/esm/router/path.test.native.js +63 -0
- package/dist/esm/router/path.test.native.js.map +1 -0
- package/dist/esm/router/router.mjs +4 -10
- package/dist/esm/router/router.mjs.map +1 -1
- package/dist/esm/router/router.native.js +4 -10
- package/dist/esm/router/router.native.js.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/package.json +9 -9
- package/src/hooks.tsx +9 -9
- package/src/router/Route.tsx +5 -6
- package/src/router/path.test.ts +95 -0
- package/src/router/path.ts +69 -0
- package/src/router/router.ts +5 -20
- package/src/vite/plugins/fileSystemRouterPlugin.tsx +1 -2
- package/types/hooks.d.ts.map +1 -1
- package/types/router/Route.d.ts.map +1 -1
- package/types/router/path.d.ts +8 -0
- package/types/router/path.d.ts.map +1 -0
- package/types/router/path.test.d.ts +2 -0
- package/types/router/path.test.d.ts.map +1 -0
- package/types/router/router.d.ts +1 -1
- package/types/router/router.d.ts.map +1 -1
- package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
package/dist/cjs/hooks.cjs
CHANGED
|
@@ -52,6 +52,7 @@ var import_react = __toESM(require("react"), 1);
|
|
|
52
52
|
var import_imperative_api = require("./router/imperative-api.cjs");
|
|
53
53
|
var import_Route = require("./router/Route.cjs");
|
|
54
54
|
var import_params = require("./router/params.cjs");
|
|
55
|
+
var import_path = require("./router/path.cjs");
|
|
55
56
|
var import_RouteInfoContext = require("./router/RouteInfoContext.cjs");
|
|
56
57
|
var import_router = require("./router/router.cjs");
|
|
57
58
|
var import_one_server_only = require("./vite/one-server-only.cjs");
|
|
@@ -87,14 +88,11 @@ function usePathname() {
|
|
|
87
88
|
try {
|
|
88
89
|
const ctx = (0, import_one_server_only.getServerContext)();
|
|
89
90
|
if (ctx?.loaderProps?.path) {
|
|
90
|
-
return
|
|
91
|
+
return (0, import_path.normalizeRoutePathname)(ctx.loaderProps.path);
|
|
91
92
|
}
|
|
92
93
|
} catch {}
|
|
93
94
|
}
|
|
94
|
-
return
|
|
95
|
-
}
|
|
96
|
-
function stripTrailingSlash(path) {
|
|
97
|
-
return path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
|
|
95
|
+
return (0, import_path.getPathnameWithRecoveredDynamicSegment)(routeInfoPathname);
|
|
98
96
|
}
|
|
99
97
|
function useActiveParams() {
|
|
100
98
|
return useRouteInfo().params;
|
package/dist/cjs/hooks.native.js
CHANGED
|
@@ -54,6 +54,7 @@ var import_react = __toESM(require("react"), 1);
|
|
|
54
54
|
var import_imperative_api = require("./router/imperative-api.native.js");
|
|
55
55
|
var import_Route = require("./router/Route.native.js");
|
|
56
56
|
var import_params = require("./router/params.native.js");
|
|
57
|
+
var import_path = require("./router/path.native.js");
|
|
57
58
|
var import_RouteInfoContext = require("./router/RouteInfoContext.native.js");
|
|
58
59
|
var import_router = require("./router/router.native.js");
|
|
59
60
|
var import_one_server_only = require("./vite/one-server-only.native.js");
|
|
@@ -208,14 +209,11 @@ function usePathname() {
|
|
|
208
209
|
var _ctx_loaderProps;
|
|
209
210
|
var ctx = (0, import_one_server_only.getServerContext)();
|
|
210
211
|
if (ctx === null || ctx === void 0 ? void 0 : (_ctx_loaderProps = ctx.loaderProps) === null || _ctx_loaderProps === void 0 ? void 0 : _ctx_loaderProps.path) {
|
|
211
|
-
return
|
|
212
|
+
return (0, import_path.normalizeRoutePathname)(ctx.loaderProps.path);
|
|
212
213
|
}
|
|
213
214
|
} catch (unused) {}
|
|
214
215
|
}
|
|
215
|
-
return
|
|
216
|
-
}
|
|
217
|
-
function stripTrailingSlash(path) {
|
|
218
|
-
return path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
|
|
216
|
+
return (0, import_path.getPathnameWithRecoveredDynamicSegment)(routeInfoPathname);
|
|
219
217
|
}
|
|
220
218
|
function useActiveParams() {
|
|
221
219
|
return useRouteInfo().params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","hooks_exports","__export","FrozeContext","useActiveParams","useGlobalSearchParams","useLocalSearchParams","useNavigationContainerRef","useParams","usePathname","useRootNavigationState","useRouteInfo","useRouter","useSearchParams","useSegments","useUnstableGlobalHref","module","exports","import_react","__toESM","require","import_imperative_api","import_Route","import_params","import_RouteInfoContext","import_router","import_one_server_only","import_meta","_assert_this_initialized","self","ReferenceError","_call_super","_this","derived","args","_get_prototype_of","_possible_constructor_return","_is_native_reflect_construct","Reflect","construct","constructor","apply","_class_call_check","instance","Constructor","TypeError","_construct","Parent","Class","Parent2","args2","Class2","a","push","Function","bind","_set_prototype_of","prototype","arguments","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_create_class","protoProps","staticProps","o","setPrototypeOf","getPrototypeOf","o2","__proto__","_inherits","subClass","superClass","create","_is_native_function","fn","toString","call","indexOf","_type_of","p","p2","obj","Symbol","_wrap_native_super","_cache","Map","wrapNativeSuper","has","get","set","Wrapper"],"sources":["../../src/hooks.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA,YAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA,qBAAA;EAAAC,oBAAA,EAAAA,CAAA,KAAAA,oBAAA;EAAAC,yBAAA,EAAAA,CAAA,KAAAA,yBAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA,SAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,sBAAA,EAAAA,CAAA,KAAAA,sBAAA;EAAAC,YAAA,EAAAA,CAAA,KAAAA,YAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA,SAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAArB,YAAiD,CAAAK,aAAA;AAEjD,IAAAiB,YAAA,GAAAC,OAAA,CAAAC,OAAuB;AACvB,IAAAC,qBAAiD,GAAAD,OAAA;AACjD,IAAAE,YAAA,GAAAF,OAAmC;AACnC,IAAAG,aAAA,
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","hooks_exports","__export","FrozeContext","useActiveParams","useGlobalSearchParams","useLocalSearchParams","useNavigationContainerRef","useParams","usePathname","useRootNavigationState","useRouteInfo","useRouter","useSearchParams","useSegments","useUnstableGlobalHref","module","exports","import_react","__toESM","require","import_imperative_api","import_Route","import_params","import_path","import_RouteInfoContext","import_router","import_one_server_only","import_meta","_assert_this_initialized","self","ReferenceError","_call_super","_this","derived","args","_get_prototype_of","_possible_constructor_return","_is_native_reflect_construct","Reflect","construct","constructor","apply","_class_call_check","instance","Constructor","TypeError","_construct","Parent","Class","Parent2","args2","Class2","a","push","Function","bind","_set_prototype_of","prototype","arguments","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_create_class","protoProps","staticProps","o","setPrototypeOf","getPrototypeOf","o2","__proto__","_inherits","subClass","superClass","create","_is_native_function","fn","toString","call","indexOf","_type_of","p","p2","obj","Symbol","_wrap_native_super","_cache","Map","wrapNativeSuper","has","get","set","Wrapper"],"sources":["../../src/hooks.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA,YAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA,qBAAA;EAAAC,oBAAA,EAAAA,CAAA,KAAAA,oBAAA;EAAAC,yBAAA,EAAAA,CAAA,KAAAA,yBAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA,SAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA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UAAYC,GAAA,kBAAM,eAAa,IAAAA,GAAA;EAErCF,kBAAgB,YAAaG,eAAcA,CAAA7C,MAAA;IACzC,IAAIA,MAAA,KAAW,SAAAgC,mBAAmB,CAAAhC,MAAA,UAAAA,MAAA;IAChC,WAAQA,MAAK;MACf,UAAAN,SAAA;IACF;IAGA,IAAM,OAAAiD,MAAS,KAAS;MAExB,IAAOA,MAAA,CAAAG,GAAA,CAAA9C,MAAA,GAAM,OAAA2C,MAAQ,CAAMI,GAAA,CAAA/C,MAAA;MACzB2C,MAAM,CAAAK,GAAA,CAAAhD,MAAU,EAAAiD,OAAO;IACrB;IACA,SAAOA,OAAMA,CAAA;MAGd,OAAAtD,UAAA,CAAAK,MAAA,EAAAO,SAAA,EAAAvB,iBAAA,OAAAK,WAAA;IACD;IACF4D,OAAI,CAAM3C,SAAC,GAAAW,MAAA,CAAAc,MAAA,CAAA/B,MAAA,CAAAM,SAAA;MACbjB,WAAA","ignoreList":[]}
|
|
@@ -44,6 +44,7 @@ var import_findFocusedRoute = require("../fork/findFocusedRoute.cjs");
|
|
|
44
44
|
var import_linkingConfig = require("./linkingConfig.cjs");
|
|
45
45
|
var import_matchers = require("./matchers.cjs");
|
|
46
46
|
var import_params = require("./params.cjs");
|
|
47
|
+
var import_path = require("./path.cjs");
|
|
47
48
|
var import_router = require("./router.cjs");
|
|
48
49
|
var import_RouteInfoContext = require("./RouteInfoContext.cjs");
|
|
49
50
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -65,7 +66,7 @@ function useContextKey() {
|
|
|
65
66
|
function getParamsFromCurrentUrl(route) {
|
|
66
67
|
const linking = (0, import_linkingConfig.getResolvedLinking)();
|
|
67
68
|
if (!linking?.getStateFromPath) return void 0;
|
|
68
|
-
const path = import_router.routeInfo?.unstable_globalHref
|
|
69
|
+
const path = (0, import_path.getPathWithRecoveredDynamicSegment)([import_router.routeInfo?.unstable_globalHref, route?.path]);
|
|
69
70
|
if (!path) return void 0;
|
|
70
71
|
const state = linking.getStateFromPath(path, linking.config);
|
|
71
72
|
if (!state) return void 0;
|
|
@@ -47,6 +47,7 @@ var import_findFocusedRoute = require("../fork/findFocusedRoute.native.js");
|
|
|
47
47
|
var import_linkingConfig = require("./linkingConfig.native.js");
|
|
48
48
|
var import_matchers = require("./matchers.native.js");
|
|
49
49
|
var import_params = require("./params.native.js");
|
|
50
|
+
var import_path = require("./path.native.js");
|
|
50
51
|
var import_router = require("./router.native.js");
|
|
51
52
|
var import_RouteInfoContext = require("./RouteInfoContext.native.js");
|
|
52
53
|
var RouteParamsContext = /* @__PURE__ */(0, import_react.createContext)({});
|
|
@@ -67,7 +68,7 @@ function useContextKey() {
|
|
|
67
68
|
function getParamsFromCurrentUrl(route) {
|
|
68
69
|
var linking = (0, import_linkingConfig.getResolvedLinking)();
|
|
69
70
|
if (!(linking === null || linking === void 0 ? void 0 : linking.getStateFromPath)) return void 0;
|
|
70
|
-
var path = (import_router.routeInfo === null || import_router.routeInfo === void 0 ? void 0 : import_router.routeInfo.unstable_globalHref
|
|
71
|
+
var path = (0, import_path.getPathWithRecoveredDynamicSegment)([import_router.routeInfo === null || import_router.routeInfo === void 0 ? void 0 : import_router.routeInfo.unstable_globalHref, route === null || route === void 0 ? void 0 : route.path]);
|
|
71
72
|
if (!path) return void 0;
|
|
72
73
|
var state = linking.getStateFromPath(path, linking.config);
|
|
73
74
|
if (!state) return void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Route_exports","__export","Route","RouteParamsContext","useContextKey","useRouteNode","module","exports","import_jsx_runtime","require","import_react","__toESM","import_findFocusedRoute","import_linkingConfig","import_matchers","import_params","import_router","import_RouteInfoContext","createContext","CurrentRouteContext","default","process","env","NODE_ENV","displayName","useContext","node","Error","getContextKey","contextKey","getParamsFromCurrentUrl","route","linking","getResolvedLinking","getStateFromPath","path","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Route_exports","__export","Route","RouteParamsContext","useContextKey","useRouteNode","module","exports","import_jsx_runtime","require","import_react","__toESM","import_findFocusedRoute","import_linkingConfig","import_matchers","import_params","import_path","import_router","import_RouteInfoContext","createContext","CurrentRouteContext","default","process","env","NODE_ENV","displayName","useContext","node","Error","getContextKey","contextKey","getParamsFromCurrentUrl","route","linking","getResolvedLinking","getStateFromPath","path","getPathWithRecoveredDynamicSegment","routeInfo","unstable_globalHref","state","config","focused","findFocusedRoute","params","param","children","parentParams","resolvedParams","useMemo","_node_dynamic","rp","ownParams","dynamic","length","mergeDynamicParams"],"sources":["../../../src/router/Route.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,KAAA,EAAAA,CAAA,KAAAA,KAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA,kBAAA;EAAAC,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,YAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAZ,YAAiE,CAAAK,aAAA;AACjE,IAAAQ,kBAAA,GAAAC,OAAiC;AAKjC,IAAAC,YAAA,GAAAC,OAAA,CAAmCF,OAAA;AACnC,IAAAG,uBAA8B,GAAAH,OAAA;AAC9B,IAAAI,oBAAmC,GAAAJ,OAAA;AACnC,IAAAK,eAAmD,GAAAL,OAAA;AACnD,IAAAM,aAAA,GAA0BN,OAAA;AAC1B,IAAAO,WAAA,GAAAP,OAAA,mBAAyC;AAmMjC,IAAAQ,aAAA,GAAAR,OAAA;AAtFD,IAAAS,uBAAM,GAAAT,OAAqB,gCAEhC;AAEF,IAAAN,kBAAM,kBAAsB,IAAAO,YAAM,CAAAS,aAAoC;AAEtE,IAAIC,mBAAY,kBAAaV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OAAA;IACD,IAAMC,aAAA;IAUN,IAAMC,EAAA,GAAAnB,KAAA,SAAiB,IAAAA,KAAA,UAAM,SAAQ,IAAAA,KAAM,CAAAY,MAAA;IACzC,IAAAQ,SAAW,KAAOF,aAAA,GAAAvB,IAAA,CAAA0B,OAAA,cAAAH,aAAA,uBAAAA,aAAA,CAAAI,MAAA,QAAAvC,aAAA,CAAAwC,kBAAA,EAAAJ,EAAA,EAAAxB,IAAA,CAAA0B,OAAA,EAAAtB,uBAAA,CAAAC,KAAA,KAAAmB,EAAA;IAClB,KAAAJ,YAAM,EAAY,OAAKK,SAAS;IAIhC,IAAI,CAACA,SAAA,SAAcL,YAAO;IAC1B,OAAK;MACL,GAAAA,YAAY;MACV,GAAAK;IAEJ;EAOF,I","ignoreList":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var path_exports = {};
|
|
24
|
+
__export(path_exports, {
|
|
25
|
+
getPathWithRecoveredDynamicSegment: () => getPathWithRecoveredDynamicSegment,
|
|
26
|
+
getPathnameWithRecoveredDynamicSegment: () => getPathnameWithRecoveredDynamicSegment,
|
|
27
|
+
getSafeWindowPath: () => getSafeWindowPath,
|
|
28
|
+
getSafeWindowPathname: () => getSafeWindowPathname,
|
|
29
|
+
hasLostDynamicSegment: () => hasLostDynamicSegment,
|
|
30
|
+
normalizeRoutePathname: () => normalizeRoutePathname,
|
|
31
|
+
stripTrailingSlash: () => stripTrailingSlash
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(path_exports);
|
|
34
|
+
var import_getStateFromPath_mods = require("../fork/getStateFromPath-mods.cjs");
|
|
35
|
+
function stripPathSuffix(path) {
|
|
36
|
+
const queryIndex = path.indexOf("?");
|
|
37
|
+
const hashIndex = path.indexOf("#");
|
|
38
|
+
let end = path.length;
|
|
39
|
+
if (queryIndex >= 0) end = Math.min(end, queryIndex);
|
|
40
|
+
if (hashIndex >= 0) end = Math.min(end, hashIndex);
|
|
41
|
+
return path.slice(0, end);
|
|
42
|
+
}
|
|
43
|
+
function stripTrailingSlash(pathname) {
|
|
44
|
+
return pathname.length > 1 && pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
45
|
+
}
|
|
46
|
+
function normalizeRoutePathname(pathname) {
|
|
47
|
+
return stripTrailingSlash((0, import_getStateFromPath_mods.stripBaseUrl)(stripPathSuffix(pathname)));
|
|
48
|
+
}
|
|
49
|
+
function hasLostDynamicSegment(path) {
|
|
50
|
+
return stripPathSuffix(path).split("/").includes("undefined");
|
|
51
|
+
}
|
|
52
|
+
function getSafeWindowPathname() {
|
|
53
|
+
if (typeof window === "undefined" || !window.location || typeof window.location.pathname !== "string") {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
return window.location.pathname;
|
|
57
|
+
}
|
|
58
|
+
function getSafeWindowPath() {
|
|
59
|
+
const pathname = getSafeWindowPathname();
|
|
60
|
+
if (pathname === void 0) return void 0;
|
|
61
|
+
return pathname + (window.location.search || "");
|
|
62
|
+
}
|
|
63
|
+
function getPathWithRecoveredDynamicSegment(paths, fallbackPath = getSafeWindowPath()) {
|
|
64
|
+
for (const path of paths) {
|
|
65
|
+
if (path !== void 0 && !hasLostDynamicSegment(path)) {
|
|
66
|
+
return path;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return fallbackPath;
|
|
70
|
+
}
|
|
71
|
+
function getPathnameWithRecoveredDynamicSegment(pathname, fallbackPath = getSafeWindowPath()) {
|
|
72
|
+
return normalizeRoutePathname(getPathWithRecoveredDynamicSegment([pathname], fallbackPath) ?? pathname);
|
|
73
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var path_exports = {};
|
|
26
|
+
__export(path_exports, {
|
|
27
|
+
getPathWithRecoveredDynamicSegment: () => getPathWithRecoveredDynamicSegment,
|
|
28
|
+
getPathnameWithRecoveredDynamicSegment: () => getPathnameWithRecoveredDynamicSegment,
|
|
29
|
+
getSafeWindowPath: () => getSafeWindowPath,
|
|
30
|
+
getSafeWindowPathname: () => getSafeWindowPathname,
|
|
31
|
+
hasLostDynamicSegment: () => hasLostDynamicSegment,
|
|
32
|
+
normalizeRoutePathname: () => normalizeRoutePathname,
|
|
33
|
+
stripTrailingSlash: () => stripTrailingSlash
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(path_exports);
|
|
36
|
+
var import_getStateFromPath_mods = require("../fork/getStateFromPath-mods.native.js");
|
|
37
|
+
function stripPathSuffix(path) {
|
|
38
|
+
var queryIndex = path.indexOf("?");
|
|
39
|
+
var hashIndex = path.indexOf("#");
|
|
40
|
+
var end = path.length;
|
|
41
|
+
if (queryIndex >= 0) end = Math.min(end, queryIndex);
|
|
42
|
+
if (hashIndex >= 0) end = Math.min(end, hashIndex);
|
|
43
|
+
return path.slice(0, end);
|
|
44
|
+
}
|
|
45
|
+
function stripTrailingSlash(pathname) {
|
|
46
|
+
return pathname.length > 1 && pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
47
|
+
}
|
|
48
|
+
function normalizeRoutePathname(pathname) {
|
|
49
|
+
return stripTrailingSlash((0, import_getStateFromPath_mods.stripBaseUrl)(stripPathSuffix(pathname)));
|
|
50
|
+
}
|
|
51
|
+
function hasLostDynamicSegment(path) {
|
|
52
|
+
return stripPathSuffix(path).split("/").includes("undefined");
|
|
53
|
+
}
|
|
54
|
+
function getSafeWindowPathname() {
|
|
55
|
+
if (typeof window === "undefined" || !window.location || typeof window.location.pathname !== "string") {
|
|
56
|
+
return void 0;
|
|
57
|
+
}
|
|
58
|
+
return window.location.pathname;
|
|
59
|
+
}
|
|
60
|
+
function getSafeWindowPath() {
|
|
61
|
+
var pathname = getSafeWindowPathname();
|
|
62
|
+
if (pathname === void 0) return void 0;
|
|
63
|
+
return pathname + (window.location.search || "");
|
|
64
|
+
}
|
|
65
|
+
function getPathWithRecoveredDynamicSegment(paths) {
|
|
66
|
+
var fallbackPath = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : getSafeWindowPath();
|
|
67
|
+
var _iteratorNormalCompletion = true,
|
|
68
|
+
_didIteratorError = false,
|
|
69
|
+
_iteratorError = void 0;
|
|
70
|
+
try {
|
|
71
|
+
for (var _iterator = paths[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
72
|
+
var path = _step.value;
|
|
73
|
+
if (path !== void 0 && !hasLostDynamicSegment(path)) {
|
|
74
|
+
return path;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
} catch (err) {
|
|
78
|
+
_didIteratorError = true;
|
|
79
|
+
_iteratorError = err;
|
|
80
|
+
} finally {
|
|
81
|
+
try {
|
|
82
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
83
|
+
_iterator.return();
|
|
84
|
+
}
|
|
85
|
+
} finally {
|
|
86
|
+
if (_didIteratorError) {
|
|
87
|
+
throw _iteratorError;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return fallbackPath;
|
|
92
|
+
}
|
|
93
|
+
function getPathnameWithRecoveredDynamicSegment(pathname) {
|
|
94
|
+
var fallbackPath = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : getSafeWindowPath();
|
|
95
|
+
var _getPathWithRecoveredDynamicSegment;
|
|
96
|
+
return normalizeRoutePathname((_getPathWithRecoveredDynamicSegment = getPathWithRecoveredDynamicSegment([pathname], fallbackPath)) !== null && _getPathWithRecoveredDynamicSegment !== void 0 ? _getPathWithRecoveredDynamicSegment : pathname);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=path.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","path_exports","__export","getPathWithRecoveredDynamicSegment","getPathnameWithRecoveredDynamicSegment","getSafeWindowPath","getSafeWindowPathname","hasLostDynamicSegment","normalizeRoutePathname","stripTrailingSlash","module","exports","import_getStateFromPath_mods","require","stripPathSuffix","path","queryIndex","indexOf","hashIndex","end","length","Math","min","slice","pathname","endsWith","stripBaseUrl","split","includes","window","location","search","paths","fallbackPath","arguments","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","err"],"sources":["../../../src/router/path.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,YAAA;AAAAC,QAAA,CAAAD,YAAA;EAAAE,kCAAA,EAAAA,CAAA,KAAAA,kCAAA;EAAAC,sCAAA,EAAAA,CAAA,KAAAA,sCAAA;EAAAC,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA,qBAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA,qBAAA;EAAAC,sBAAA,EAAAA,CAAA,KAAAA,sBAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAf,YAAA,CAAAK,YAA6B;AAE7B,IAAAW,4BAA+C,GAAAC,OAAA;AAC7C,SAAMC,eAAaA,CAAAC,IAAK;EACxB,IAAAC,UAAM,GAAAD,IAAY,CAAAE,OAAK,IAAQ,CAAG;EAClC,IAAIC,SAAM,GAAKH,IAAA,CAAAE,OAAA;EAEf,IAAIE,GAAA,GAAAJ,IAAA,CAAAK,MAAiB;EACrB,IAAIJ,UAAA,IAAa,CAAG,EAAAG,GAAA,GAAME,IAAK,CAAAC,GAAI,CAAAH,GAAA,EAAKH,UAAS;EAEjD,IAAAE,SAAY,KAAM,EAAAC,GAAG,GAAGE,IAAA,CAAAC,GA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A;QAEO,OAASA,IAAA;MAId;IACE;EACF,SAAA6B,GAAA;IACFR,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var import_vitest = require("vitest");
|
|
2
|
+
var import_path = require("./path.cjs");
|
|
3
|
+
const originalBaseUrl = process.env.EXPO_BASE_URL;
|
|
4
|
+
const originalNodeEnv = process.env.NODE_ENV;
|
|
5
|
+
(0, import_vitest.afterEach)(() => {
|
|
6
|
+
if (originalBaseUrl === void 0) {
|
|
7
|
+
delete process.env.EXPO_BASE_URL;
|
|
8
|
+
} else {
|
|
9
|
+
process.env.EXPO_BASE_URL = originalBaseUrl;
|
|
10
|
+
}
|
|
11
|
+
if (originalNodeEnv === void 0) {
|
|
12
|
+
delete process.env.NODE_ENV;
|
|
13
|
+
} else {
|
|
14
|
+
process.env.NODE_ENV = originalNodeEnv;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
(0, import_vitest.describe)("hasLostDynamicSegment", () => {
|
|
18
|
+
(0, import_vitest.it)('detects a literal "undefined" segment', () => {
|
|
19
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/undefined")).toBe(true);
|
|
20
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/users/undefined/posts")).toBe(true);
|
|
21
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/undefined")).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
(0, import_vitest.it)('does not match "undefined" inside another segment', () => {
|
|
24
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/undefined-things")).toBe(false);
|
|
25
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/notundefined")).toBe(false);
|
|
26
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/foo-undefined-bar")).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
(0, import_vitest.it)("ignores search and hash values", () => {
|
|
29
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/undefined?tab=profile")).toBe(true);
|
|
30
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/mai1015?x=undefined")).toBe(false);
|
|
31
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/mai1015#undefined")).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
(0, import_vitest.describe)("normalizeRoutePathname", () => {
|
|
35
|
+
(0, import_vitest.it)("strips search, hash, and trailing slash", () => {
|
|
36
|
+
(0, import_vitest.expect)((0, import_path.normalizeRoutePathname)("/p/mai1015/?tab=profile#top")).toBe("/p/mai1015");
|
|
37
|
+
(0, import_vitest.expect)((0, import_path.normalizeRoutePathname)("/")).toBe("/");
|
|
38
|
+
});
|
|
39
|
+
(0, import_vitest.it)("strips the production base url", () => {
|
|
40
|
+
process.env.NODE_ENV = "production";
|
|
41
|
+
process.env.EXPO_BASE_URL = "/expo/prefix";
|
|
42
|
+
(0, import_vitest.expect)((0, import_path.normalizeRoutePathname)("/expo/prefix/p/mai1015?tab=profile")).toBe("/p/mai1015");
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
(0, import_vitest.describe)("getPathWithRecoveredDynamicSegment", () => {
|
|
46
|
+
(0, import_vitest.it)("uses the first uncorrupted candidate path", () => {
|
|
47
|
+
(0, import_vitest.expect)((0, import_path.getPathWithRecoveredDynamicSegment)(["/p/undefined", "/p/mai1015?tab=profile"], "/p/browser?tab=profile")).toBe("/p/mai1015?tab=profile");
|
|
48
|
+
});
|
|
49
|
+
(0, import_vitest.it)("keeps an empty uncorrupted candidate path", () => {
|
|
50
|
+
(0, import_vitest.expect)((0, import_path.getPathWithRecoveredDynamicSegment)([""], "/browser")).toBe("");
|
|
51
|
+
});
|
|
52
|
+
(0, import_vitest.it)("falls back when every candidate path is corrupted", () => {
|
|
53
|
+
(0, import_vitest.expect)((0, import_path.getPathWithRecoveredDynamicSegment)(["/p/undefined"], "/p/browser?tab=profile")).toBe("/p/browser?tab=profile");
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
(0, import_vitest.describe)("getPathnameWithRecoveredDynamicSegment", () => {
|
|
57
|
+
(0, import_vitest.it)("normalizes the recovered browser pathname", () => {
|
|
58
|
+
process.env.NODE_ENV = "production";
|
|
59
|
+
process.env.EXPO_BASE_URL = "/expo/prefix";
|
|
60
|
+
(0, import_vitest.expect)((0, import_path.getPathnameWithRecoveredDynamicSegment)("/p/undefined", "/expo/prefix/p/mai1015?tab=profile")).toBe("/p/mai1015");
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var import_vitest = require("vitest");
|
|
4
|
+
var import_path = require("./path.native.js");
|
|
5
|
+
var originalBaseUrl = process.env.EXPO_BASE_URL;
|
|
6
|
+
var originalNodeEnv = process.env.NODE_ENV;
|
|
7
|
+
(0, import_vitest.afterEach)(function () {
|
|
8
|
+
if (originalBaseUrl === void 0) {
|
|
9
|
+
delete process.env.EXPO_BASE_URL;
|
|
10
|
+
} else {
|
|
11
|
+
process.env.EXPO_BASE_URL = originalBaseUrl;
|
|
12
|
+
}
|
|
13
|
+
if (originalNodeEnv === void 0) {
|
|
14
|
+
delete process.env.NODE_ENV;
|
|
15
|
+
} else {
|
|
16
|
+
process.env.NODE_ENV = originalNodeEnv;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
(0, import_vitest.describe)("hasLostDynamicSegment", function () {
|
|
20
|
+
(0, import_vitest.it)('detects a literal "undefined" segment', function () {
|
|
21
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/undefined")).toBe(true);
|
|
22
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/users/undefined/posts")).toBe(true);
|
|
23
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/undefined")).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
(0, import_vitest.it)('does not match "undefined" inside another segment', function () {
|
|
26
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/undefined-things")).toBe(false);
|
|
27
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/notundefined")).toBe(false);
|
|
28
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/foo-undefined-bar")).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
(0, import_vitest.it)("ignores search and hash values", function () {
|
|
31
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/undefined?tab=profile")).toBe(true);
|
|
32
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/mai1015?x=undefined")).toBe(false);
|
|
33
|
+
(0, import_vitest.expect)((0, import_path.hasLostDynamicSegment)("/p/mai1015#undefined")).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
(0, import_vitest.describe)("normalizeRoutePathname", function () {
|
|
37
|
+
(0, import_vitest.it)("strips search, hash, and trailing slash", function () {
|
|
38
|
+
(0, import_vitest.expect)((0, import_path.normalizeRoutePathname)("/p/mai1015/?tab=profile#top")).toBe("/p/mai1015");
|
|
39
|
+
(0, import_vitest.expect)((0, import_path.normalizeRoutePathname)("/")).toBe("/");
|
|
40
|
+
});
|
|
41
|
+
(0, import_vitest.it)("strips the production base url", function () {
|
|
42
|
+
process.env.NODE_ENV = "production";
|
|
43
|
+
process.env.EXPO_BASE_URL = "/expo/prefix";
|
|
44
|
+
(0, import_vitest.expect)((0, import_path.normalizeRoutePathname)("/expo/prefix/p/mai1015?tab=profile")).toBe("/p/mai1015");
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
(0, import_vitest.describe)("getPathWithRecoveredDynamicSegment", function () {
|
|
48
|
+
(0, import_vitest.it)("uses the first uncorrupted candidate path", function () {
|
|
49
|
+
(0, import_vitest.expect)((0, import_path.getPathWithRecoveredDynamicSegment)(["/p/undefined", "/p/mai1015?tab=profile"], "/p/browser?tab=profile")).toBe("/p/mai1015?tab=profile");
|
|
50
|
+
});
|
|
51
|
+
(0, import_vitest.it)("keeps an empty uncorrupted candidate path", function () {
|
|
52
|
+
(0, import_vitest.expect)((0, import_path.getPathWithRecoveredDynamicSegment)([""], "/browser")).toBe("");
|
|
53
|
+
});
|
|
54
|
+
(0, import_vitest.it)("falls back when every candidate path is corrupted", function () {
|
|
55
|
+
(0, import_vitest.expect)((0, import_path.getPathWithRecoveredDynamicSegment)(["/p/undefined"], "/p/browser?tab=profile")).toBe("/p/browser?tab=profile");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
(0, import_vitest.describe)("getPathnameWithRecoveredDynamicSegment", function () {
|
|
59
|
+
(0, import_vitest.it)("normalizes the recovered browser pathname", function () {
|
|
60
|
+
process.env.NODE_ENV = "production";
|
|
61
|
+
process.env.EXPO_BASE_URL = "/expo/prefix";
|
|
62
|
+
(0, import_vitest.expect)((0, import_path.getPathnameWithRecoveredDynamicSegment)("/p/undefined", "/expo/prefix/p/mai1015?tab=profile")).toBe("/p/mai1015");
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=path.test.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["import_vitest","require","import_path","originalBaseUrl","process","env","EXPO_BASE_URL","originalNodeEnv","NODE_ENV","afterEach","describe","it","expect","hasLostDynamicSegment","toBe","normalizeRoutePathname","getPathWithRecoveredDynamicSegment","getPathnameWithRecoveredDynamicSegment"],"sources":["../../../src/router/path.test.ts"],"sourcesContent":[null],"mappings":"AAAA;;AACA,IAAAA,aAAA,GAKOC,OAAA;AAEP,IAAAC,WAAM,GAAAD,OAAkB,mBAAQ;AAChC,IAAAE,eAAM,GAAAC,OAAkB,CAAAC,GAAQ,CAAAC,aAAI;AAAA,IAEpCC,eAAA,GAAAH,OAAU,CAAAC,GAAA,CAAAG,QAAM;AACd,IAAAR,aAAI,CAAAS,SAAo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e,sCAAA,yDAAAH,IAAA;EAE5B;AAAA","ignoreList":[]}
|
|
@@ -29,7 +29,7 @@ __export(router_exports, {
|
|
|
29
29
|
dismiss: () => dismiss,
|
|
30
30
|
dismissAll: () => dismissAll,
|
|
31
31
|
getPreloadHistory: () => getPreloadHistory,
|
|
32
|
-
getSafeWindowPathname: () => getSafeWindowPathname,
|
|
32
|
+
getSafeWindowPathname: () => import_path3.getSafeWindowPathname,
|
|
33
33
|
getSortedRoutes: () => getSortedRoutes,
|
|
34
34
|
getValidationState: () => getValidationState,
|
|
35
35
|
goBack: () => goBack,
|
|
@@ -91,6 +91,7 @@ var import_getRouteInfo = require("./getRouteInfo.cjs");
|
|
|
91
91
|
var import_getRoutes = require("./getRoutes.cjs");
|
|
92
92
|
var import_lastAction = require("./lastAction.cjs");
|
|
93
93
|
var import_linkingConfig = require("./linkingConfig.cjs");
|
|
94
|
+
var import_path2 = require("./path.cjs");
|
|
94
95
|
var import_sortRoutes = require("./sortRoutes.cjs");
|
|
95
96
|
var import_useScreens = require("./useScreens.cjs");
|
|
96
97
|
var import_useViteRoutes = require("./useViteRoutes.cjs");
|
|
@@ -99,6 +100,7 @@ var import_useMatches = require("../useMatches.cjs");
|
|
|
99
100
|
var import_interceptRoutes = require("./interceptRoutes.cjs");
|
|
100
101
|
var import_Navigator = require("../views/Navigator.cjs");
|
|
101
102
|
var import_notFoundState = require("../notFoundState.cjs");
|
|
103
|
+
var import_path3 = require("./path.cjs");
|
|
102
104
|
let routeNode = null;
|
|
103
105
|
let rootComponent;
|
|
104
106
|
const protectedRouteRegistry = /* @__PURE__ */new Map();
|
|
@@ -228,7 +230,7 @@ function cleanUpState() {
|
|
|
228
230
|
}
|
|
229
231
|
function setupLinkingAndRouteInfo(initialLocation, linking) {
|
|
230
232
|
initialState = (0, import_linkingConfig.setupLinking)(routeNode, initialLocation, linking);
|
|
231
|
-
initialPathname = initialLocation?.pathname ?? getSafeWindowPathname();
|
|
233
|
+
initialPathname = initialLocation?.pathname ?? (0, import_path2.getSafeWindowPathname)();
|
|
232
234
|
if (initialState) {
|
|
233
235
|
rootState = initialState;
|
|
234
236
|
routeInfo = (0, import_getRouteInfo.getRouteInfo)(initialState);
|
|
@@ -415,16 +417,9 @@ function rootStateSnapshot() {
|
|
|
415
417
|
function routeInfoSnapshot() {
|
|
416
418
|
return routeInfo;
|
|
417
419
|
}
|
|
418
|
-
function normalizePathname(pathname) {
|
|
419
|
-
return pathname.length > 1 && pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
420
|
-
}
|
|
421
|
-
function getSafeWindowPathname() {
|
|
422
|
-
if (typeof window === "undefined" || !window.location || typeof window.location.pathname !== "string") return;
|
|
423
|
-
return window.location.pathname;
|
|
424
|
-
}
|
|
425
420
|
function getBrowserPathname() {
|
|
426
|
-
const pathname = getSafeWindowPathname();
|
|
427
|
-
return pathname === void 0 ? void 0 :
|
|
421
|
+
const pathname = (0, import_path2.getSafeWindowPathname)();
|
|
422
|
+
return pathname === void 0 ? void 0 : (0, import_path2.normalizeRoutePathname)(pathname);
|
|
428
423
|
}
|
|
429
424
|
function shouldKeepPendingNavigationState(currentState) {
|
|
430
425
|
if (!pendingNavigationPathname) return false;
|
|
@@ -797,7 +792,7 @@ async function linkTo(href, event, options) {
|
|
|
797
792
|
const hash = href.indexOf("#");
|
|
798
793
|
if (currentRootState.key && hash > 0) hashes[currentRootState.key] = href.slice(hash);
|
|
799
794
|
nextOptions = options ?? null;
|
|
800
|
-
pendingNavigationPathname =
|
|
795
|
+
pendingNavigationPathname = (0, import_path2.stripTrailingSlash)((0, import_findRouteNode.extractPathnameFromHref)(href));
|
|
801
796
|
pendingNavigationAction = event === "PUSH" || event === "REPLACE" || event === "NAVIGATE" ? event : void 0;
|
|
802
797
|
lastIntendedPathname = pendingNavigationPathname;
|
|
803
798
|
const freshRootState = navigationRef.getRootState();
|
|
@@ -31,7 +31,7 @@ __export(router_exports, {
|
|
|
31
31
|
dismiss: () => dismiss,
|
|
32
32
|
dismissAll: () => dismissAll,
|
|
33
33
|
getPreloadHistory: () => getPreloadHistory,
|
|
34
|
-
getSafeWindowPathname: () => getSafeWindowPathname,
|
|
34
|
+
getSafeWindowPathname: () => import_path3.getSafeWindowPathname,
|
|
35
35
|
getSortedRoutes: () => getSortedRoutes,
|
|
36
36
|
getValidationState: () => getValidationState,
|
|
37
37
|
goBack: () => goBack,
|
|
@@ -93,6 +93,7 @@ var import_getRouteInfo = require("./getRouteInfo.native.js");
|
|
|
93
93
|
var import_getRoutes = require("./getRoutes.native.js");
|
|
94
94
|
var import_lastAction = require("./lastAction.native.js");
|
|
95
95
|
var import_linkingConfig = require("./linkingConfig.native.js");
|
|
96
|
+
var import_path2 = require("./path.native.js");
|
|
96
97
|
var import_sortRoutes = require("./sortRoutes.native.js");
|
|
97
98
|
var import_useScreens = require("./useScreens.native.js");
|
|
98
99
|
require("./useViteRoutes.native.js");
|
|
@@ -101,6 +102,7 @@ var import_useMatches = require("../useMatches.native.js");
|
|
|
101
102
|
var import_interceptRoutes = require("./interceptRoutes.native.js");
|
|
102
103
|
var import_Navigator = require("../views/Navigator.native.js");
|
|
103
104
|
var import_notFoundState = require("../notFoundState.native.js");
|
|
105
|
+
var import_path3 = require("./path.native.js");
|
|
104
106
|
function _instanceof(left, right) {
|
|
105
107
|
"@swc/helpers - instanceof";
|
|
106
108
|
|
|
@@ -292,7 +294,7 @@ function cleanUpState() {
|
|
|
292
294
|
function setupLinkingAndRouteInfo(initialLocation, linking) {
|
|
293
295
|
var _ref;
|
|
294
296
|
initialState = (0, import_linkingConfig.setupLinking)(routeNode, initialLocation, linking);
|
|
295
|
-
initialPathname = (_ref = initialLocation === null || initialLocation === void 0 ? void 0 : initialLocation.pathname) !== null && _ref !== void 0 ? _ref : getSafeWindowPathname();
|
|
297
|
+
initialPathname = (_ref = initialLocation === null || initialLocation === void 0 ? void 0 : initialLocation.pathname) !== null && _ref !== void 0 ? _ref : (0, import_path2.getSafeWindowPathname)();
|
|
296
298
|
if (initialState) {
|
|
297
299
|
rootState = initialState;
|
|
298
300
|
routeInfo = (0, import_getRouteInfo.getRouteInfo)(initialState);
|
|
@@ -561,16 +563,9 @@ function rootStateSnapshot() {
|
|
|
561
563
|
function routeInfoSnapshot() {
|
|
562
564
|
return routeInfo;
|
|
563
565
|
}
|
|
564
|
-
function normalizePathname(pathname) {
|
|
565
|
-
return pathname.length > 1 && pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
566
|
-
}
|
|
567
|
-
function getSafeWindowPathname() {
|
|
568
|
-
if (typeof window === "undefined" || !window.location || typeof window.location.pathname !== "string") return;
|
|
569
|
-
return window.location.pathname;
|
|
570
|
-
}
|
|
571
566
|
function getBrowserPathname() {
|
|
572
|
-
var pathname = getSafeWindowPathname();
|
|
573
|
-
return pathname === void 0 ? void 0 :
|
|
567
|
+
var pathname = (0, import_path2.getSafeWindowPathname)();
|
|
568
|
+
return pathname === void 0 ? void 0 : (0, import_path2.normalizeRoutePathname)(pathname);
|
|
574
569
|
}
|
|
575
570
|
function shouldKeepPendingNavigationState(currentState) {
|
|
576
571
|
if (!pendingNavigationPathname) return false;
|
|
@@ -816,7 +811,7 @@ async function linkTo(href, event, options) {
|
|
|
816
811
|
var hash = href.indexOf("#");
|
|
817
812
|
if (currentRootState.key && hash > 0) hashes[currentRootState.key] = href.slice(hash);
|
|
818
813
|
nextOptions = options !== null && options !== void 0 ? options : null;
|
|
819
|
-
pendingNavigationPathname =
|
|
814
|
+
pendingNavigationPathname = (0, import_path2.stripTrailingSlash)((0, import_findRouteNode.extractPathnameFromHref)(href));
|
|
820
815
|
pendingNavigationAction = event === "PUSH" || event === "REPLACE" || event === "NAVIGATE" ? event : void 0;
|
|
821
816
|
lastIntendedPathname = pendingNavigationPathname;
|
|
822
817
|
var freshRootState = navigationRef.getRootState();
|