@luwiostack/router 0.1.0 → 0.2.0
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/README.md +126 -7
- package/dist/index.cjs +86 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +67 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +385 -1274
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -5,70 +5,70 @@ import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/w
|
|
|
5
5
|
import { Locale } from "@luwiostack/locale/react";
|
|
6
6
|
import { Locale as Locale$1 } from "@luwiostack/locale";
|
|
7
7
|
import { collectModules, createModuleRegistry } from "@luwiostack/registry";
|
|
8
|
-
//#region ../../node_modules/.pnpm/@tanstack+router
|
|
8
|
+
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.31_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@tanstack/react-router/dist/esm/utils.js
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* React.use if available (React 19+), undefined otherwise.
|
|
11
|
+
* Use dynamic lookup to avoid Webpack compilation errors with React 18.
|
|
12
|
+
*/
|
|
13
|
+
var reactUse = React$1["use"];
|
|
14
|
+
var useLayoutEffect = React$1.useLayoutEffect;
|
|
15
|
+
/**
|
|
16
|
+
* React hook to wrap `IntersectionObserver`.
|
|
11
17
|
*
|
|
12
|
-
*
|
|
13
|
-
* Use `routeId` to target a specific route's not-found boundary. If `throw`
|
|
14
|
-
* is true, the error is thrown instead of returned.
|
|
18
|
+
* This hook will create an `IntersectionObserver` and observe the ref passed to it.
|
|
15
19
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
20
|
+
* When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.
|
|
21
|
+
*
|
|
22
|
+
* @param ref - The ref to observe
|
|
23
|
+
* @param callback - The callback to call when the intersection changes
|
|
24
|
+
* @param disabled - Whether observation is disabled
|
|
25
|
+
* @returns The IntersectionObserver instance
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const MyComponent = () => {
|
|
29
|
+
* const ref = React.useRef<HTMLDivElement>(null)
|
|
30
|
+
* useIntersectionObserver(
|
|
31
|
+
* ref,
|
|
32
|
+
* (entry) => { doSomething(entry) },
|
|
33
|
+
* false
|
|
34
|
+
* )
|
|
35
|
+
* return <div ref={ref} />
|
|
36
|
+
* ```
|
|
19
37
|
*/
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
function useIntersectionObserver(ref, callback, disabled) {
|
|
39
|
+
React$1.useEffect(() => {
|
|
40
|
+
if (!ref.current || disabled || typeof IntersectionObserver !== "function") return () => callback();
|
|
41
|
+
const observer = new IntersectionObserver((entries) => {
|
|
42
|
+
callback(entries.pop());
|
|
43
|
+
}, { rootMargin: "100px" });
|
|
44
|
+
observer.observe(ref.current);
|
|
45
|
+
return () => {
|
|
46
|
+
observer.disconnect();
|
|
47
|
+
callback();
|
|
48
|
+
};
|
|
49
|
+
}, [
|
|
50
|
+
callback,
|
|
51
|
+
disabled,
|
|
52
|
+
ref
|
|
53
|
+
]);
|
|
28
54
|
}
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/root.js
|
|
31
|
-
/** Stable identifier used for the root route in a route tree. */
|
|
32
|
-
const rootRouteId = "__root__";
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/redirect.js
|
|
35
55
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* Use from route `loader`/`beforeLoad` or server functions to trigger a
|
|
39
|
-
* navigation. If `throw: true` is set, the redirect is thrown instead of
|
|
40
|
-
* returned. When an absolute `href` is supplied and `reloadDocument` is not
|
|
41
|
-
* set, a full-document navigation is inferred.
|
|
56
|
+
* React hook to take a `React.ForwardedRef` and returns a `ref` that can be used on a DOM element.
|
|
42
57
|
*
|
|
43
|
-
* @param
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
58
|
+
* @param ref - The forwarded ref
|
|
59
|
+
* @returns The inner ref returned by `useRef`
|
|
60
|
+
* @example
|
|
61
|
+
* ```tsx
|
|
62
|
+
* const MyComponent = React.forwardRef((props, ref) => {
|
|
63
|
+
* const innerRef = useForwardedRef(ref)
|
|
64
|
+
* return <div ref={innerRef} />
|
|
65
|
+
* })
|
|
66
|
+
* ```
|
|
51
67
|
*/
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
opts.reloadDocument = true;
|
|
57
|
-
} catch {}
|
|
58
|
-
const headers = new Headers(opts.headers);
|
|
59
|
-
if (opts.href && headers.get("Location") === null) headers.set("Location", opts.href);
|
|
60
|
-
const response = new Response(null, {
|
|
61
|
-
status: opts.statusCode,
|
|
62
|
-
headers
|
|
63
|
-
});
|
|
64
|
-
response.options = opts;
|
|
65
|
-
if (opts.throw) throw response;
|
|
66
|
-
return response;
|
|
67
|
-
}
|
|
68
|
-
/** Check whether a value is a TanStack Router redirect Response. */
|
|
69
|
-
/** Check whether a value is a TanStack Router redirect Response. */
|
|
70
|
-
function isRedirect(obj) {
|
|
71
|
-
return obj instanceof Response && !!obj.options;
|
|
68
|
+
function useForwardedRef(ref) {
|
|
69
|
+
const innerRef = React$1.useRef(null);
|
|
70
|
+
React$1.useImperativeHandle(ref, () => innerRef.current, []);
|
|
71
|
+
return innerRef;
|
|
72
72
|
}
|
|
73
73
|
//#endregion
|
|
74
74
|
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/utils.js
|
|
@@ -102,7 +102,6 @@ const nullReplaceEqualDeep = (prev, next) => replaceEqualDeep(prev, next, create
|
|
|
102
102
|
* Do not use this with signals
|
|
103
103
|
*/
|
|
104
104
|
function replaceEqualDeep(prev, _next, _makeObj = () => ({}), _depth = 0) {
|
|
105
|
-
if (isServer) return _next;
|
|
106
105
|
if (prev === _next) return prev;
|
|
107
106
|
if (_depth > 500) return _next;
|
|
108
107
|
const next = _next;
|
|
@@ -425,11 +424,6 @@ function createLRUCache(max) {
|
|
|
425
424
|
};
|
|
426
425
|
}
|
|
427
426
|
//#endregion
|
|
428
|
-
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/invariant.js
|
|
429
|
-
function invariant() {
|
|
430
|
-
throw new Error("Invariant failed");
|
|
431
|
-
}
|
|
432
|
-
//#endregion
|
|
433
427
|
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/new-process-route-tree.js
|
|
434
428
|
const SEGMENT_TYPE_INDEX = 4;
|
|
435
429
|
const SEGMENT_TYPE_PATHLESS = 5;
|
|
@@ -763,10 +757,7 @@ function processRouteTree(routeTree, caseSensitive = false, initRoute) {
|
|
|
763
757
|
let index = 0;
|
|
764
758
|
parseSegments(caseSensitive, data, routeTree, 1, segmentTree, 0, dynamicListsToSort, (route) => {
|
|
765
759
|
initRoute?.(route, index);
|
|
766
|
-
if (route.id in routesById) {
|
|
767
|
-
if (process.env.NODE_ENV !== "production") throw new Error(`Invariant failed: Duplicate routes found with id: ${String(route.id)}`);
|
|
768
|
-
invariant();
|
|
769
|
-
}
|
|
760
|
+
if (route.id in routesById) throw new Error(`Invariant failed: Duplicate routes found with id: ${String(route.id)}`);
|
|
770
761
|
routesById[route.id] = route;
|
|
771
762
|
if (index !== 0 && route.path) {
|
|
772
763
|
const trimmedFullPath = trimPathRight$1(route.fullPath);
|
|
@@ -1217,47 +1208,6 @@ function interpolatePath({ path, params, decoder, ...rest }) {
|
|
|
1217
1208
|
usedParams,
|
|
1218
1209
|
isMissingParams
|
|
1219
1210
|
};
|
|
1220
|
-
if (isServer ?? rest.server) {
|
|
1221
|
-
if (path.indexOf("{") === -1) {
|
|
1222
|
-
const length = path.length;
|
|
1223
|
-
let cursor = 0;
|
|
1224
|
-
let joined = "";
|
|
1225
|
-
while (cursor < length) {
|
|
1226
|
-
while (cursor < length && path.charCodeAt(cursor) === 47) cursor++;
|
|
1227
|
-
if (cursor >= length) break;
|
|
1228
|
-
const start = cursor;
|
|
1229
|
-
let end = path.indexOf("/", cursor);
|
|
1230
|
-
if (end === -1) end = length;
|
|
1231
|
-
cursor = end;
|
|
1232
|
-
const part = path.substring(start, end);
|
|
1233
|
-
if (!part) continue;
|
|
1234
|
-
if (part.charCodeAt(0) === 36) if (part.length === 1) {
|
|
1235
|
-
const splat = params._splat;
|
|
1236
|
-
usedParams._splat = splat;
|
|
1237
|
-
usedParams["*"] = splat;
|
|
1238
|
-
if (!splat) {
|
|
1239
|
-
isMissingParams = true;
|
|
1240
|
-
continue;
|
|
1241
|
-
}
|
|
1242
|
-
const value = encodeParam("_splat", params, decoder);
|
|
1243
|
-
joined += "/" + value;
|
|
1244
|
-
} else {
|
|
1245
|
-
const key = part.substring(1);
|
|
1246
|
-
if (!isMissingParams && !(key in params)) isMissingParams = true;
|
|
1247
|
-
usedParams[key] = params[key];
|
|
1248
|
-
const value = encodeParam(key, params, decoder) ?? "undefined";
|
|
1249
|
-
joined += "/" + value;
|
|
1250
|
-
}
|
|
1251
|
-
else joined += "/" + part;
|
|
1252
|
-
}
|
|
1253
|
-
if (path.endsWith("/")) joined += "/";
|
|
1254
|
-
return {
|
|
1255
|
-
usedParams,
|
|
1256
|
-
interpolatedPath: joined || "/",
|
|
1257
|
-
isMissingParams
|
|
1258
|
-
};
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
1211
|
const length = path.length;
|
|
1262
1212
|
let cursor = 0;
|
|
1263
1213
|
let segment;
|
|
@@ -1322,6 +1272,28 @@ function encodePathParam(value, decoder) {
|
|
|
1322
1272
|
return decoder?.(encoded) ?? encoded;
|
|
1323
1273
|
}
|
|
1324
1274
|
//#endregion
|
|
1275
|
+
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/not-found.js
|
|
1276
|
+
/**
|
|
1277
|
+
* Create a not-found error object recognized by TanStack Router.
|
|
1278
|
+
*
|
|
1279
|
+
* Throw this from loaders/actions to trigger the nearest `notFoundComponent`.
|
|
1280
|
+
* Use `routeId` to target a specific route's not-found boundary. If `throw`
|
|
1281
|
+
* is true, the error is thrown instead of returned.
|
|
1282
|
+
*
|
|
1283
|
+
* @param options Optional settings including `routeId`, `headers`, and `throw`.
|
|
1284
|
+
* @returns A not-found error object that can be thrown or returned.
|
|
1285
|
+
* @link https://tanstack.com/router/latest/docs/router/framework/react/api/router/notFoundFunction
|
|
1286
|
+
*/
|
|
1287
|
+
function notFound(options = {}) {
|
|
1288
|
+
options.isNotFound = true;
|
|
1289
|
+
if (options.throw) throw options;
|
|
1290
|
+
return options;
|
|
1291
|
+
}
|
|
1292
|
+
/** Determine if a value is a TanStack Router not-found error. */
|
|
1293
|
+
function isNotFound(obj) {
|
|
1294
|
+
return obj?.isNotFound === true;
|
|
1295
|
+
}
|
|
1296
|
+
//#endregion
|
|
1325
1297
|
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/scroll-restoration.js
|
|
1326
1298
|
function getSafeSessionStorage() {
|
|
1327
1299
|
try {
|
|
@@ -1343,7 +1315,7 @@ function persistScrollRestorationCache() {
|
|
|
1343
1315
|
try {
|
|
1344
1316
|
safeSessionStorage?.setItem(storageKey, JSON.stringify(scrollRestorationCache));
|
|
1345
1317
|
} catch {
|
|
1346
|
-
|
|
1318
|
+
console.warn("[ts-router] Could not persist scroll restoration state to sessionStorage.");
|
|
1347
1319
|
}
|
|
1348
1320
|
}
|
|
1349
1321
|
const scrollRestorationCache = /* @__PURE__ */ createScrollRestorationCache();
|
|
@@ -1393,7 +1365,6 @@ function setupScrollRestoration(router, force) {
|
|
|
1393
1365
|
const shouldSetupScrollRestoration = force ?? router.options.scrollRestoration;
|
|
1394
1366
|
const scroll = router._scroll;
|
|
1395
1367
|
if (shouldSetupScrollRestoration) scroll.restoring = true;
|
|
1396
|
-
if (isServer ?? router.isServer) return;
|
|
1397
1368
|
const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
|
|
1398
1369
|
const trackedScrollTargets = /* @__PURE__ */ new Set();
|
|
1399
1370
|
const snapshotCurrentScrollTargets = (restoreKey) => {
|
|
@@ -1631,6 +1602,50 @@ function stringifySearchWith(stringify, parser) {
|
|
|
1631
1602
|
};
|
|
1632
1603
|
}
|
|
1633
1604
|
//#endregion
|
|
1605
|
+
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/root.js
|
|
1606
|
+
/** Stable identifier used for the root route in a route tree. */
|
|
1607
|
+
const rootRouteId = "__root__";
|
|
1608
|
+
//#endregion
|
|
1609
|
+
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/redirect.js
|
|
1610
|
+
/**
|
|
1611
|
+
* Create a redirect Response understood by TanStack Router.
|
|
1612
|
+
*
|
|
1613
|
+
* Use from route `loader`/`beforeLoad` or server functions to trigger a
|
|
1614
|
+
* navigation. If `throw: true` is set, the redirect is thrown instead of
|
|
1615
|
+
* returned. When an absolute `href` is supplied and `reloadDocument` is not
|
|
1616
|
+
* set, a full-document navigation is inferred.
|
|
1617
|
+
*
|
|
1618
|
+
* @param opts Options for the redirect. Common fields:
|
|
1619
|
+
* - `href`: absolute URL for external redirects; infers `reloadDocument`.
|
|
1620
|
+
* - `statusCode`: HTTP status code to use (defaults to 307).
|
|
1621
|
+
* - `headers`: additional headers to include on the Response.
|
|
1622
|
+
* - Standard navigation options like `to`, `params`, `search`, `replace`,
|
|
1623
|
+
* and `reloadDocument` for internal redirects.
|
|
1624
|
+
* @returns A Response augmented with router navigation options.
|
|
1625
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/redirectFunction
|
|
1626
|
+
*/
|
|
1627
|
+
function redirect(opts) {
|
|
1628
|
+
opts.statusCode = opts.statusCode || opts.code || 307;
|
|
1629
|
+
if (!opts.reloadDocument && typeof opts.href === "string") try {
|
|
1630
|
+
new URL(opts.href);
|
|
1631
|
+
opts.reloadDocument = true;
|
|
1632
|
+
} catch {}
|
|
1633
|
+
const headers = new Headers(opts.headers);
|
|
1634
|
+
if (opts.href && headers.get("Location") === null) headers.set("Location", opts.href);
|
|
1635
|
+
const response = new Response(null, {
|
|
1636
|
+
status: opts.statusCode,
|
|
1637
|
+
headers
|
|
1638
|
+
});
|
|
1639
|
+
response.options = opts;
|
|
1640
|
+
if (opts.throw) throw response;
|
|
1641
|
+
return response;
|
|
1642
|
+
}
|
|
1643
|
+
/** Check whether a value is a TanStack Router redirect Response. */
|
|
1644
|
+
/** Check whether a value is a TanStack Router redirect Response. */
|
|
1645
|
+
function isRedirect(obj) {
|
|
1646
|
+
return obj instanceof Response && !!obj.options;
|
|
1647
|
+
}
|
|
1648
|
+
//#endregion
|
|
1634
1649
|
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/rewrite.js
|
|
1635
1650
|
/** Compose multiple rewrite pairs into a single in/out rewrite. */
|
|
1636
1651
|
function composeRewrites(rewrites) {
|
|
@@ -1686,26 +1701,6 @@ function executeRewriteOutput(rewrite, url) {
|
|
|
1686
1701
|
}
|
|
1687
1702
|
return url;
|
|
1688
1703
|
}
|
|
1689
|
-
//#endregion
|
|
1690
|
-
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/stores.js
|
|
1691
|
-
/** SSR non-reactive createMutableStore */
|
|
1692
|
-
function createNonReactiveMutableStore(initialValue) {
|
|
1693
|
-
let value = initialValue;
|
|
1694
|
-
return {
|
|
1695
|
-
get() {
|
|
1696
|
-
return value;
|
|
1697
|
-
},
|
|
1698
|
-
set(nextOrUpdater) {
|
|
1699
|
-
value = functionalUpdate(nextOrUpdater, value);
|
|
1700
|
-
}
|
|
1701
|
-
};
|
|
1702
|
-
}
|
|
1703
|
-
/** SSR non-reactive createReadonlyStore */
|
|
1704
|
-
function createNonReactiveReadonlyStore(read) {
|
|
1705
|
-
return { get() {
|
|
1706
|
-
return read();
|
|
1707
|
-
} };
|
|
1708
|
-
}
|
|
1709
1704
|
function createRouterStores(initialLocation, config) {
|
|
1710
1705
|
const { createMutableStore, createReadonlyStore, batch } = config;
|
|
1711
1706
|
const byRoute = /* @__PURE__ */ new Map();
|
|
@@ -2109,7 +2104,7 @@ function defaultSerializeError(err) {
|
|
|
2109
2104
|
name: err.name,
|
|
2110
2105
|
message: err.message
|
|
2111
2106
|
};
|
|
2112
|
-
|
|
2107
|
+
obj.stack = err.stack;
|
|
2113
2108
|
return obj;
|
|
2114
2109
|
}
|
|
2115
2110
|
return { data: err };
|
|
@@ -2172,9 +2167,7 @@ var RouterCore = class {
|
|
|
2172
2167
|
return false;
|
|
2173
2168
|
};
|
|
2174
2169
|
this.update = (newOptions) => {
|
|
2175
|
-
if (
|
|
2176
|
-
if (newOptions.notFoundRoute) console.warn("The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info.");
|
|
2177
|
-
}
|
|
2170
|
+
if (newOptions.notFoundRoute) console.warn("The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info.");
|
|
2178
2171
|
const prevOptions = this.options;
|
|
2179
2172
|
const prevBasepath = this.basepath ?? prevOptions?.basepath ?? "/";
|
|
2180
2173
|
const basepathWasUnset = this.basepath === void 0;
|
|
@@ -2183,39 +2176,27 @@ var RouterCore = class {
|
|
|
2183
2176
|
...prevOptions,
|
|
2184
2177
|
...newOptions
|
|
2185
2178
|
};
|
|
2186
|
-
this.isServer = this.options.isServer ??
|
|
2179
|
+
this.isServer = this.options.isServer ?? false ?? typeof document === "undefined";
|
|
2187
2180
|
this.protocolAllowlist = new Set(this.options.protocolAllowlist);
|
|
2188
2181
|
if (this.options.pathParamsAllowedCharacters) this.pathParamsDecoder = compileDecodeCharMap(this.options.pathParamsAllowedCharacters);
|
|
2189
|
-
if (!this.history || this.options.history && this.options.history !== this.history) if (!this.options.history)
|
|
2190
|
-
|
|
2191
|
-
} else this.history = this.options.history;
|
|
2182
|
+
if (!this.history || this.options.history && this.options.history !== this.history) if (!this.options.history) this.history = createBrowserHistory();
|
|
2183
|
+
else this.history = this.options.history;
|
|
2192
2184
|
this.origin = this.options.origin;
|
|
2193
|
-
if (!this.origin) if (
|
|
2185
|
+
if (!this.origin) if (window?.origin && window.origin !== "null") this.origin = window.origin;
|
|
2194
2186
|
else this.origin = "http://localhost";
|
|
2195
2187
|
if (this.history) this.updateLatestLocation();
|
|
2196
2188
|
if (this.options.routeTree !== this.routeTree) {
|
|
2197
2189
|
this.routeTree = this.options.routeTree;
|
|
2198
2190
|
let processRouteTreeResult;
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
this.resolvePathCache = cached.resolvePathCache;
|
|
2202
|
-
processRouteTreeResult = cached.processRouteTreeResult;
|
|
2203
|
-
} else {
|
|
2204
|
-
this.resolvePathCache = createLRUCache(1e3);
|
|
2205
|
-
processRouteTreeResult = this.buildRouteTree();
|
|
2206
|
-
if ((isServer ?? this.isServer) && process.env.NODE_ENV !== "development" && globalThis.__TSR_CACHE__ === void 0) globalThis.__TSR_CACHE__ = {
|
|
2207
|
-
routeTree: this.routeTree,
|
|
2208
|
-
processRouteTreeResult,
|
|
2209
|
-
resolvePathCache: this.resolvePathCache
|
|
2210
|
-
};
|
|
2211
|
-
}
|
|
2191
|
+
this.resolvePathCache = createLRUCache(1e3);
|
|
2192
|
+
processRouteTreeResult = this.buildRouteTree();
|
|
2212
2193
|
this.setRoutes(processRouteTreeResult);
|
|
2213
2194
|
}
|
|
2214
2195
|
if (!this.stores && this.latestLocation) {
|
|
2215
2196
|
const config = this.getStoreConfig(this);
|
|
2216
2197
|
this.batch = config.batch;
|
|
2217
2198
|
this.stores = createRouterStores(this.latestLocation, config);
|
|
2218
|
-
|
|
2199
|
+
setupScrollRestoration(this);
|
|
2219
2200
|
}
|
|
2220
2201
|
const nextBasepath = this.options.basepath ?? "/";
|
|
2221
2202
|
const nextRewriteOption = this.options.rewrite;
|
|
@@ -2341,7 +2322,7 @@ var RouterCore = class {
|
|
|
2341
2322
|
}
|
|
2342
2323
|
const currentLocation = dest._fromLocation || this._pendingLocation || this.latestLocation;
|
|
2343
2324
|
const lightweightResult = this.matchRoutesLightweight(currentLocation);
|
|
2344
|
-
if (dest.from &&
|
|
2325
|
+
if (dest.from && dest._isNavigate) {
|
|
2345
2326
|
const [allFromMatches] = this.getMatchedRoutes(dest.from);
|
|
2346
2327
|
const matchedFrom = findLast(lightweightResult[0], (d) => {
|
|
2347
2328
|
return comparePaths(d.fullPath, dest.from);
|
|
@@ -2380,7 +2361,7 @@ var RouterCore = class {
|
|
|
2380
2361
|
decoder: this.pathParamsDecoder,
|
|
2381
2362
|
server: this.isServer
|
|
2382
2363
|
}).interpolatedPath).path;
|
|
2383
|
-
if (
|
|
2364
|
+
if (destRoute && !opts.leaveParams) try {
|
|
2384
2365
|
const foundRoute = this.getMatchedRoutes(nextPathname)[2];
|
|
2385
2366
|
if (foundRoute?.id !== destRoute.id) console.warn(`Generated path "${nextPathname}" for route "${destRoute.id}" matched route "${foundRoute?.id}" instead. This can happen when multiple route templates resolve to the same URL. Use the route template that matches the intended route, or adjust params.stringify if it changed the target path.`);
|
|
2386
2367
|
} catch {}
|
|
@@ -2535,7 +2516,7 @@ var RouterCore = class {
|
|
|
2535
2516
|
}
|
|
2536
2517
|
const reloadHref = !hrefIsUrl && publicHref ? publicHref : href;
|
|
2537
2518
|
if (isDangerousProtocol(reloadHref, this.protocolAllowlist)) {
|
|
2538
|
-
|
|
2519
|
+
console.warn(`Blocked navigation to dangerous protocol: ${reloadHref}`);
|
|
2539
2520
|
return;
|
|
2540
2521
|
}
|
|
2541
2522
|
if (!rest.ignoreBlocker) {
|
|
@@ -2560,7 +2541,6 @@ var RouterCore = class {
|
|
|
2560
2541
|
});
|
|
2561
2542
|
};
|
|
2562
2543
|
this.load = async (opts) => {
|
|
2563
|
-
if (isServer ?? this.isServer) return loadServerRoute(this, opts);
|
|
2564
2544
|
this.updateLatestLocation();
|
|
2565
2545
|
if (opts?.action) this._scroll.hash = opts.action.type === "PUSH" || opts.action.type === "REPLACE";
|
|
2566
2546
|
await loadClientRoute(this, opts);
|
|
@@ -2568,7 +2548,7 @@ var RouterCore = class {
|
|
|
2568
2548
|
this.startViewTransition = (fn) => {
|
|
2569
2549
|
const shouldViewTransition = this.shouldViewTransition ?? this.options.defaultViewTransition;
|
|
2570
2550
|
this.shouldViewTransition = void 0;
|
|
2571
|
-
if (shouldViewTransition &&
|
|
2551
|
+
if (shouldViewTransition && typeof document.startViewTransition === "function") {
|
|
2572
2552
|
let startViewTransitionParams;
|
|
2573
2553
|
if (typeof shouldViewTransition === "object" && window.CSS?.supports?.("selector(:active-view-transition-type(a))")) {
|
|
2574
2554
|
const next = this.latestLocation;
|
|
@@ -2639,7 +2619,7 @@ var RouterCore = class {
|
|
|
2639
2619
|
redirect.headers.set("Location", href);
|
|
2640
2620
|
}
|
|
2641
2621
|
} catch {}
|
|
2642
|
-
if (redirect.options.href && isDangerousProtocol(redirect.options.href, this.protocolAllowlist)) throw new Error(
|
|
2622
|
+
if (redirect.options.href && isDangerousProtocol(redirect.options.href, this.protocolAllowlist)) throw new Error(`Redirect blocked: unsafe protocol in href "${redirect.options.href}". Allowed protocols: ${Array.from(this.protocolAllowlist).join(", ")}.`);
|
|
2643
2623
|
if (!redirect.headers.get("Location")) redirect.headers.set("Location", redirect.options.href);
|
|
2644
2624
|
return redirect;
|
|
2645
2625
|
};
|
|
@@ -2704,7 +2684,7 @@ var RouterCore = class {
|
|
|
2704
2684
|
parseSearch: options.parseSearch ?? defaultParseSearch,
|
|
2705
2685
|
protocolAllowlist: options.protocolAllowlist ?? DEFAULT_PROTOCOL_ALLOWLIST
|
|
2706
2686
|
});
|
|
2707
|
-
|
|
2687
|
+
self.__TSR_ROUTER__ = this;
|
|
2708
2688
|
}
|
|
2709
2689
|
isShell() {
|
|
2710
2690
|
return !!this.options.isShell;
|
|
@@ -2789,7 +2769,7 @@ var RouterCore = class {
|
|
|
2789
2769
|
});
|
|
2790
2770
|
const matchId = route.id + interpolatedPath + loaderDepsHash;
|
|
2791
2771
|
const previousMatch = previousAt(route, index);
|
|
2792
|
-
const existingMatch =
|
|
2772
|
+
const existingMatch = opts?._rematerialize ? void 0 : this._cache.get(matchId) ?? (previousMatch?.id === matchId ? previousMatch : void 0);
|
|
2793
2773
|
strictParams = existingMatch?._strictParams ?? Object.assign(usedParams, strictParams);
|
|
2794
2774
|
let paramsError;
|
|
2795
2775
|
if (!existingMatch) try {
|
|
@@ -2812,7 +2792,7 @@ var RouterCore = class {
|
|
|
2812
2792
|
const status = routeNeedsLoad(route) ? "pending" : "success";
|
|
2813
2793
|
match = {
|
|
2814
2794
|
id: matchId,
|
|
2815
|
-
ssr:
|
|
2795
|
+
ssr: route.options.ssr,
|
|
2816
2796
|
index,
|
|
2817
2797
|
routeId: route.id,
|
|
2818
2798
|
params: previousMatch?.params ?? strictParams,
|
|
@@ -2885,26 +2865,19 @@ var RouterCore = class {
|
|
|
2885
2865
|
return result;
|
|
2886
2866
|
}
|
|
2887
2867
|
};
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
RouterCore.prototype._replaceRouteChunk = replaceRouteChunk;
|
|
2895
|
-
RouterCore.prototype._refreshRoute = async function() {
|
|
2896
|
-
this._serverResult = void 0;
|
|
2897
|
-
this.updateLatestLocation();
|
|
2898
|
-
await refreshClientRoute(this);
|
|
2899
|
-
};
|
|
2900
|
-
}
|
|
2868
|
+
RouterCore.prototype._replaceRouteChunk = replaceRouteChunk;
|
|
2869
|
+
RouterCore.prototype._refreshRoute = async function() {
|
|
2870
|
+
this._serverResult = void 0;
|
|
2871
|
+
this.updateLatestLocation();
|
|
2872
|
+
await refreshClientRoute(this);
|
|
2873
|
+
};
|
|
2901
2874
|
/** Error thrown when search parameter validation fails. */
|
|
2902
2875
|
var SearchParamError = class extends Error {};
|
|
2903
2876
|
/** Error thrown when path parameter parsing/validation fails. */
|
|
2904
2877
|
var PathParamError = class extends Error {};
|
|
2905
|
-
const normalize$
|
|
2878
|
+
const normalize$1 = (str) => str.endsWith("/") && str.length > 1 ? str.slice(0, -1) : str;
|
|
2906
2879
|
function comparePaths(a, b) {
|
|
2907
|
-
return normalize$
|
|
2880
|
+
return normalize$1(a) === normalize$1(b);
|
|
2908
2881
|
}
|
|
2909
2882
|
function validateSearch(validateSearch, input) {
|
|
2910
2883
|
if (validateSearch == null) return {};
|
|
@@ -3021,13 +2994,13 @@ function loadRouteChunk(route, componentType, onPendingReady) {
|
|
|
3021
2994
|
if (current) return current === true ? afterLazy() : current.then(afterLazy);
|
|
3022
2995
|
if (!route.lazyFn) return afterLazy();
|
|
3023
2996
|
const promise = route.lazyFn().then((lazyRoute) => {
|
|
3024
|
-
if (
|
|
2997
|
+
if (route._lazy === promise) {
|
|
3025
2998
|
const { id: _id, ...options } = lazyRoute.options;
|
|
3026
2999
|
Object.assign(route.options, options);
|
|
3027
3000
|
route._lazy = true;
|
|
3028
3001
|
}
|
|
3029
3002
|
}, (error) => {
|
|
3030
|
-
if (
|
|
3003
|
+
if (route._lazy === promise) route._lazy = void 0;
|
|
3031
3004
|
throw error;
|
|
3032
3005
|
});
|
|
3033
3006
|
route._lazy = promise;
|
|
@@ -3054,15 +3027,15 @@ function _getAssetMatches(matches) {
|
|
|
3054
3027
|
}
|
|
3055
3028
|
return end < matches.length ? matches.slice(0, end) : matches;
|
|
3056
3029
|
}
|
|
3057
|
-
const SUCCESS
|
|
3058
|
-
const ERROR
|
|
3059
|
-
const NOT_FOUND
|
|
3060
|
-
const REDIRECTED
|
|
3030
|
+
const SUCCESS = 0;
|
|
3031
|
+
const ERROR = 1;
|
|
3032
|
+
const NOT_FOUND = 2;
|
|
3033
|
+
const REDIRECTED = 3;
|
|
3061
3034
|
const CANCELED_OUTCOME = [4];
|
|
3062
3035
|
function isControl(result) {
|
|
3063
3036
|
return typeof result[0] === "number";
|
|
3064
3037
|
}
|
|
3065
|
-
function waitFor
|
|
3038
|
+
function waitFor(value, signal) {
|
|
3066
3039
|
if (signal.aborted) return Promise.race([Promise.reject(signal), value]);
|
|
3067
3040
|
return new Promise((resolve, reject) => {
|
|
3068
3041
|
const abort = () => reject(signal);
|
|
@@ -3070,39 +3043,39 @@ function waitFor$1(value, signal) {
|
|
|
3070
3043
|
Promise.resolve(value).then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
3071
3044
|
});
|
|
3072
3045
|
}
|
|
3073
|
-
function getRoute
|
|
3046
|
+
function getRoute(router, match) {
|
|
3074
3047
|
return router.routesById[match.routeId];
|
|
3075
3048
|
}
|
|
3076
|
-
function normalize
|
|
3077
|
-
if (isRedirect(value)) return [REDIRECTED
|
|
3049
|
+
function normalize(value, rejected, routeId) {
|
|
3050
|
+
if (isRedirect(value)) return [REDIRECTED, value];
|
|
3078
3051
|
if (isNotFound(value)) {
|
|
3079
3052
|
value.routeId ||= routeId;
|
|
3080
|
-
return [NOT_FOUND
|
|
3053
|
+
return [NOT_FOUND, value];
|
|
3081
3054
|
}
|
|
3082
3055
|
if (rejected && typeof value?.then === "function") value = new Error("A Promise was thrown", { cause: value });
|
|
3083
|
-
return rejected ? [ERROR
|
|
3056
|
+
return rejected ? [ERROR, value] : [SUCCESS, value];
|
|
3084
3057
|
}
|
|
3085
|
-
function normalizeError
|
|
3086
|
-
let outcome = normalize
|
|
3087
|
-
if (outcome[0] !== ERROR
|
|
3058
|
+
function normalizeError(route, cause) {
|
|
3059
|
+
let outcome = normalize(cause, true, route.id);
|
|
3060
|
+
if (outcome[0] !== ERROR) return outcome;
|
|
3088
3061
|
try {
|
|
3089
3062
|
route.options.onError?.(outcome[1]);
|
|
3090
3063
|
} catch (onErrorCause) {
|
|
3091
|
-
outcome = normalize
|
|
3064
|
+
outcome = normalize(onErrorCause, true, route.id);
|
|
3092
3065
|
}
|
|
3093
3066
|
return outcome;
|
|
3094
3067
|
}
|
|
3095
3068
|
function normalizeLaneError(router, lane, route, cause, options) {
|
|
3096
3069
|
if (options[0].signal.aborted) return CANCELED_OUTCOME;
|
|
3097
|
-
return materializeRedirect
|
|
3070
|
+
return materializeRedirect(router, lane, route, normalizeError(route, cause), options);
|
|
3098
3071
|
}
|
|
3099
|
-
async function contextualize
|
|
3072
|
+
async function contextualize(router, lane, options, end, planSuccessfulLane, retainedEnd) {
|
|
3100
3073
|
const [location, matches] = lane;
|
|
3101
3074
|
const signal = options[0].signal;
|
|
3102
3075
|
const preload = !!options[3];
|
|
3103
3076
|
for (let index = options[6] ?? 0; index < end; index++) {
|
|
3104
3077
|
const match = matches[index];
|
|
3105
|
-
const route = getRoute
|
|
3078
|
+
const route = getRoute(router, match);
|
|
3106
3079
|
match.abortController = options[0];
|
|
3107
3080
|
const parentContext = matches[index - 1]?.context ?? router.options.context ?? {};
|
|
3108
3081
|
const common = {
|
|
@@ -3157,10 +3130,10 @@ async function contextualize$1(router, lane, options, end, planSuccessfulLane, r
|
|
|
3157
3130
|
}
|
|
3158
3131
|
try {
|
|
3159
3132
|
setFetching(router, match, "beforeLoad", options[0]);
|
|
3160
|
-
const result = await waitFor
|
|
3133
|
+
const result = await waitFor(beforeLoad(beforeLoadContext), signal);
|
|
3161
3134
|
if (signal.aborted) return [index, CANCELED_OUTCOME];
|
|
3162
|
-
const outcome = materializeRedirect
|
|
3163
|
-
if (outcome[0] !== SUCCESS
|
|
3135
|
+
const outcome = materializeRedirect(router, lane, route, normalize(result, false, route.id), options);
|
|
3136
|
+
if (outcome[0] !== SUCCESS) {
|
|
3164
3137
|
releaseFlight(router, match);
|
|
3165
3138
|
return [index, outcome];
|
|
3166
3139
|
}
|
|
@@ -3225,7 +3198,7 @@ function setFetching(router, match, value, owner) {
|
|
|
3225
3198
|
isFetching: value
|
|
3226
3199
|
});
|
|
3227
3200
|
}
|
|
3228
|
-
function getLoaderContext
|
|
3201
|
+
function getLoaderContext(router, lane, match, route, controller, parentMatchPromise, preload) {
|
|
3229
3202
|
const location = lane[0];
|
|
3230
3203
|
return {
|
|
3231
3204
|
params: match.params,
|
|
@@ -3248,19 +3221,19 @@ async function loadResource(router, lane, match, route, loader, parentMatchPromi
|
|
|
3248
3221
|
const owner = options[0];
|
|
3249
3222
|
const signal = owner.signal;
|
|
3250
3223
|
if (signal.aborted) return CANCELED_OUTCOME;
|
|
3251
|
-
if (!loader) return [SUCCESS
|
|
3224
|
+
if (!loader) return [SUCCESS, void 0];
|
|
3252
3225
|
let flight = match._flight;
|
|
3253
3226
|
setFetching(router, match, "loader", owner);
|
|
3254
3227
|
try {
|
|
3255
3228
|
if (!flight) {
|
|
3256
3229
|
const controller = new AbortController();
|
|
3257
3230
|
flight = [
|
|
3258
|
-
Promise.resolve().then(() => loader(getLoaderContext
|
|
3259
|
-
if (result[0] !== SUCCESS
|
|
3231
|
+
Promise.resolve().then(() => loader(getLoaderContext(router, lane, match, route, controller, parentMatchPromise, !!options[3]))).then((value) => normalize(value, false, route.id), (cause) => normalize(cause, true, route.id)).then((result) => {
|
|
3232
|
+
if (result[0] !== SUCCESS && router._flights?.get(match.id) === flight) {
|
|
3260
3233
|
router._flights.delete(match.id);
|
|
3261
3234
|
if (!flight[2]) controller.abort();
|
|
3262
3235
|
}
|
|
3263
|
-
return result[0] === ERROR
|
|
3236
|
+
return result[0] === ERROR && flight[2] ? normalizeError(route, result[1]) : result;
|
|
3264
3237
|
}),
|
|
3265
3238
|
controller,
|
|
3266
3239
|
1
|
|
@@ -3269,7 +3242,7 @@ async function loadResource(router, lane, match, route, loader, parentMatchPromi
|
|
|
3269
3242
|
}
|
|
3270
3243
|
match._flight = flight;
|
|
3271
3244
|
match.abortController = flight[1];
|
|
3272
|
-
return materializeRedirect
|
|
3245
|
+
return materializeRedirect(router, lane, route, await waitFor(flight[0], signal), options);
|
|
3273
3246
|
} catch (cause) {
|
|
3274
3247
|
if (cause !== signal || !signal.aborted) throw cause;
|
|
3275
3248
|
releaseFlight(router, match);
|
|
@@ -3279,14 +3252,14 @@ async function loadResource(router, lane, match, route, loader, parentMatchPromi
|
|
|
3279
3252
|
}
|
|
3280
3253
|
}
|
|
3281
3254
|
function settleInto(match, result, preload) {
|
|
3282
|
-
if (result[0] === SUCCESS
|
|
3255
|
+
if (result[0] === SUCCESS) {
|
|
3283
3256
|
match.loaderData = result[1];
|
|
3284
3257
|
match.error = void 0;
|
|
3285
3258
|
match.status = "success";
|
|
3286
3259
|
match.invalid = false;
|
|
3287
3260
|
match.updatedAt = Date.now();
|
|
3288
3261
|
match.preload = preload;
|
|
3289
|
-
} else if (result[0] !== REDIRECTED
|
|
3262
|
+
} else if (result[0] !== REDIRECTED) {
|
|
3290
3263
|
match.status = "success";
|
|
3291
3264
|
match.error = void 0;
|
|
3292
3265
|
match.invalid = true;
|
|
@@ -3305,17 +3278,17 @@ function cacheLoaderMatch(router, match, planned) {
|
|
|
3305
3278
|
if (current) releaseFlight(router, current);
|
|
3306
3279
|
}
|
|
3307
3280
|
function getParentSnapshot(match, outcome) {
|
|
3308
|
-
if (outcome[0] === ERROR
|
|
3281
|
+
if (outcome[0] === ERROR || outcome[0] === NOT_FOUND) return {
|
|
3309
3282
|
...match,
|
|
3310
|
-
status: outcome[0] === ERROR
|
|
3283
|
+
status: outcome[0] === ERROR ? "error" : "notFound",
|
|
3311
3284
|
error: outcome[1],
|
|
3312
3285
|
_flight: void 0
|
|
3313
3286
|
};
|
|
3314
3287
|
return match;
|
|
3315
3288
|
}
|
|
3316
|
-
function createLoaderTask
|
|
3289
|
+
function createLoaderTask(router, lane, index, tasks, semanticParent, options, retainedEnd) {
|
|
3317
3290
|
const match = lane[1][index];
|
|
3318
|
-
const route = getRoute
|
|
3291
|
+
const route = getRoute(router, match);
|
|
3319
3292
|
const preload = !!options[3];
|
|
3320
3293
|
const plannedCacheMatch = router._cache.get(match.id);
|
|
3321
3294
|
let configured;
|
|
@@ -3324,7 +3297,7 @@ function createLoaderTask$1(router, lane, index, tasks, semanticParent, options,
|
|
|
3324
3297
|
try {
|
|
3325
3298
|
if (match.status === "success") {
|
|
3326
3299
|
configured = route.options.shouldReload;
|
|
3327
|
-
if (typeof configured === "function") configured = configured(getLoaderContext
|
|
3300
|
+
if (typeof configured === "function") configured = configured(getLoaderContext(router, lane, match, route, options[0], semanticParent, preload));
|
|
3328
3301
|
if (options[0].signal.aborted) reloadFailure = CANCELED_OUTCOME;
|
|
3329
3302
|
}
|
|
3330
3303
|
if (!reloadFailure) if (match.status !== "success") reload = true;
|
|
@@ -3339,7 +3312,7 @@ function createLoaderTask$1(router, lane, index, tasks, semanticParent, options,
|
|
|
3339
3312
|
}
|
|
3340
3313
|
const routeLoader = route.options.loader;
|
|
3341
3314
|
const loader = typeof routeLoader === "function" ? routeLoader : routeLoader?.handler;
|
|
3342
|
-
let donor = (!preload || route.options.preload !== false) && routeLoader && !
|
|
3315
|
+
let donor = (!preload || route.options.preload !== false) && routeLoader && !router._tx?.[6] ? router._flights?.get(match.id) : void 0;
|
|
3343
3316
|
if (donor === match._flight || reloadFailure) donor = void 0;
|
|
3344
3317
|
else if (donor && !reload && !preload && configured === void 0) reload = true;
|
|
3345
3318
|
else if (!reload) donor = void 0;
|
|
@@ -3361,18 +3334,18 @@ function createLoaderTask$1(router, lane, index, tasks, semanticParent, options,
|
|
|
3361
3334
|
onReady?.();
|
|
3362
3335
|
}
|
|
3363
3336
|
if (!loaded) match.isFetching = false;
|
|
3364
|
-
const outcome = (reloadFailure ? Promise.resolve(reloadFailure) : !blocking ? Promise.resolve([SUCCESS
|
|
3337
|
+
const outcome = (reloadFailure ? Promise.resolve(reloadFailure) : !blocking ? Promise.resolve([SUCCESS, match.loaderData]) : loadResource(router, lane, match, route, loader, semanticParent, options)).then((result) => {
|
|
3365
3338
|
if (blocking) {
|
|
3366
3339
|
settleInto(match, result, preload);
|
|
3367
|
-
if (result[0] === SUCCESS
|
|
3340
|
+
if (result[0] === SUCCESS) {
|
|
3368
3341
|
if (routeLoader && !options[0].signal.aborted) cacheLoaderMatch(router, match, plannedCacheMatch);
|
|
3369
3342
|
if (index >= retainedEnd) match.status = "pending";
|
|
3370
3343
|
}
|
|
3371
3344
|
}
|
|
3372
3345
|
return result;
|
|
3373
3346
|
});
|
|
3374
|
-
const chunkFailure = waitFor
|
|
3375
|
-
if (blocking && !failure && result[0] === SUCCESS
|
|
3347
|
+
const chunkFailure = waitFor(Promise.resolve().then(() => loadRouteChunk(route, void 0, onLazyReady)), options[0].signal).then(() => void 0, (cause) => lane[1].some((candidate, candidateIndex) => candidateIndex <= index && (candidate.status === "error" || candidate.status === "notFound" || candidate._notFound)) ? void 0 : [index, normalizeLaneError(router, lane, route, cause, options)]).then((failure) => outcome.then((result) => {
|
|
3348
|
+
if (blocking && !failure && result[0] === SUCCESS && match.status === "pending" && !options[0].signal.aborted) {
|
|
3376
3349
|
match.status = "success";
|
|
3377
3350
|
onReady?.();
|
|
3378
3351
|
}
|
|
@@ -3405,15 +3378,15 @@ function createLoaderTask$1(router, lane, index, tasks, semanticParent, options,
|
|
|
3405
3378
|
]);
|
|
3406
3379
|
return backgroundOutcome.then((result) => getParentSnapshot(candidate, result));
|
|
3407
3380
|
}
|
|
3408
|
-
async function getNotFoundBoundary
|
|
3381
|
+
async function getNotFoundBoundary(router, matches, indexed, signal, fallback = 0) {
|
|
3409
3382
|
const cause = indexed?.[1][1];
|
|
3410
3383
|
let index = cause?.routeId ? matches.findIndex((match) => match.routeId === cause.routeId) : indexed?.[0] ?? matches.length - 1;
|
|
3411
3384
|
if (index < 0) index = 0;
|
|
3412
3385
|
for (let i = index; i >= 0; i--) {
|
|
3413
|
-
const route = getRoute
|
|
3386
|
+
const route = getRoute(router, matches[i]);
|
|
3414
3387
|
try {
|
|
3415
3388
|
const loading = loadRouteChunk(route, false);
|
|
3416
|
-
if (loading) await waitFor
|
|
3389
|
+
if (loading) await waitFor(loading, signal);
|
|
3417
3390
|
} catch (cause) {
|
|
3418
3391
|
if (cause === signal && signal.aborted) throw cause;
|
|
3419
3392
|
}
|
|
@@ -3433,13 +3406,13 @@ async function settleTasks(tasks, serialFailure, redirectTasks, gate) {
|
|
|
3433
3406
|
await Promise.all(tasks.map((task) => task[1].then(async (outcome) => {
|
|
3434
3407
|
const taskIndex = task[0];
|
|
3435
3408
|
if (gate && taskIndex >= await gate) return;
|
|
3436
|
-
if (outcome[0] >= REDIRECTED
|
|
3437
|
-
if (!loaderFailure && outcome[0] !== SUCCESS
|
|
3409
|
+
if (outcome[0] >= REDIRECTED) throw [taskIndex, outcome];
|
|
3410
|
+
if (!loaderFailure && outcome[0] !== SUCCESS) {
|
|
3438
3411
|
loaderFailure = [taskIndex, outcome];
|
|
3439
3412
|
await Promise.all((redirectTasks ?? []).map((nextTask) => {
|
|
3440
3413
|
if (nextTask[0] <= taskIndex) return;
|
|
3441
3414
|
return nextTask[1].then((nextOutcome) => {
|
|
3442
|
-
if (nextOutcome[0] === REDIRECTED
|
|
3415
|
+
if (nextOutcome[0] === REDIRECTED) throw [nextTask[0], nextOutcome];
|
|
3443
3416
|
});
|
|
3444
3417
|
}));
|
|
3445
3418
|
}
|
|
@@ -3449,8 +3422,8 @@ async function settleTasks(tasks, serialFailure, redirectTasks, gate) {
|
|
|
3449
3422
|
}
|
|
3450
3423
|
return serialFailure ?? loaderFailure;
|
|
3451
3424
|
}
|
|
3452
|
-
function materializeRedirect
|
|
3453
|
-
while (outcome[0] === REDIRECTED
|
|
3425
|
+
function materializeRedirect(router, lane, route, outcome, options, failed) {
|
|
3426
|
+
while (outcome[0] === REDIRECTED) {
|
|
3454
3427
|
const redirect = outcome[1];
|
|
3455
3428
|
if (redirect.options.reloadDocument ? options[3] : options[1] >= 20) return outcome;
|
|
3456
3429
|
try {
|
|
@@ -3459,7 +3432,7 @@ function materializeRedirect$1(router, lane, route, outcome, options, failed) {
|
|
|
3459
3432
|
return outcome;
|
|
3460
3433
|
}
|
|
3461
3434
|
return [
|
|
3462
|
-
REDIRECTED
|
|
3435
|
+
REDIRECTED,
|
|
3463
3436
|
redirect,
|
|
3464
3437
|
router.buildLocation({
|
|
3465
3438
|
...redirect.options,
|
|
@@ -3468,7 +3441,7 @@ function materializeRedirect$1(router, lane, route, outcome, options, failed) {
|
|
|
3468
3441
|
})
|
|
3469
3442
|
];
|
|
3470
3443
|
} catch (cause) {
|
|
3471
|
-
outcome = failed ? [ERROR
|
|
3444
|
+
outcome = failed ? [ERROR, cause] : normalizeError(route, cause);
|
|
3472
3445
|
failed = true;
|
|
3473
3446
|
}
|
|
3474
3447
|
}
|
|
@@ -3479,15 +3452,15 @@ async function reduceLane(router, lane, tasks, controller, settlement, onReady)
|
|
|
3479
3452
|
let failure = await settlement;
|
|
3480
3453
|
let redirectLimitExceeded = false;
|
|
3481
3454
|
const plannedBoundary = matches.findIndex((match) => match._notFound);
|
|
3482
|
-
const boundaryOf = (found) => found[1][0] === NOT_FOUND
|
|
3455
|
+
const boundaryOf = (found) => found[1][0] === NOT_FOUND ? getNotFoundBoundary(router, matches, found, controller.signal) : found[0];
|
|
3483
3456
|
let readinessEnd = plannedBoundary < 0 ? matches.length : plannedBoundary;
|
|
3484
|
-
if ((failure?.[1][0] ?? 0) >= REDIRECTED
|
|
3457
|
+
if ((failure?.[1][0] ?? 0) >= REDIRECTED) readinessEnd = 0;
|
|
3485
3458
|
else if (failure) {
|
|
3486
3459
|
readinessEnd = failure[2] ??= await boundaryOf(failure);
|
|
3487
3460
|
for (const task of tasks) {
|
|
3488
3461
|
if (task[0] >= readinessEnd) break;
|
|
3489
3462
|
const outcome = await task[1];
|
|
3490
|
-
if (outcome[0] !== SUCCESS
|
|
3463
|
+
if (outcome[0] !== SUCCESS && outcome[0] < REDIRECTED && !("loaderData" in matches[task[0]])) {
|
|
3491
3464
|
failure = [task[0], outcome];
|
|
3492
3465
|
readinessEnd = failure[2] = await boundaryOf(failure);
|
|
3493
3466
|
break;
|
|
@@ -3501,14 +3474,14 @@ async function reduceLane(router, lane, tasks, controller, settlement, onReady)
|
|
|
3501
3474
|
failure = chunkFailure;
|
|
3502
3475
|
break;
|
|
3503
3476
|
}
|
|
3504
|
-
if ((failure?.[1][0] ?? 0) >= REDIRECTED
|
|
3477
|
+
if ((failure?.[1][0] ?? 0) >= REDIRECTED) {
|
|
3505
3478
|
const outcome = failure[1];
|
|
3506
|
-
if (outcome[0] !== REDIRECTED
|
|
3479
|
+
if (outcome[0] !== REDIRECTED || outcome[1].options.reloadDocument || outcome[2]) {
|
|
3507
3480
|
discardBackground(router, lane);
|
|
3508
3481
|
return outcome;
|
|
3509
3482
|
}
|
|
3510
3483
|
redirectLimitExceeded = true;
|
|
3511
|
-
failure = [0, [ERROR
|
|
3484
|
+
failure = [0, [ERROR, /* @__PURE__ */ new Error("Too many redirects")]];
|
|
3512
3485
|
}
|
|
3513
3486
|
const boundary = failure ? failure[2] ?? await boundaryOf(failure) : plannedBoundary;
|
|
3514
3487
|
if (boundary >= 0) {
|
|
@@ -3519,7 +3492,7 @@ async function reduceLane(router, lane, tasks, controller, settlement, onReady)
|
|
|
3519
3492
|
const install = () => {
|
|
3520
3493
|
if (outcome) {
|
|
3521
3494
|
match._notFound = void 0;
|
|
3522
|
-
if (kind === ERROR
|
|
3495
|
+
if (kind === ERROR) match.status = "error";
|
|
3523
3496
|
else {
|
|
3524
3497
|
cause.routeId = match.routeId;
|
|
3525
3498
|
if (match.routeId === router.routeTree.id) {
|
|
@@ -3533,9 +3506,9 @@ async function reduceLane(router, lane, tasks, controller, settlement, onReady)
|
|
|
3533
3506
|
};
|
|
3534
3507
|
install();
|
|
3535
3508
|
if (!outcome) onReady?.();
|
|
3536
|
-
const route = getRoute
|
|
3509
|
+
const route = getRoute(router, match);
|
|
3537
3510
|
try {
|
|
3538
|
-
await waitFor
|
|
3511
|
+
await waitFor(outcome ? Promise.resolve().then(() => loadRouteChunk(route, kind === ERROR ? "errorComponent" : "notFoundComponent")) : Promise.all([loadRouteChunk(route), loadRouteChunk(route, "notFoundComponent")]), controller.signal);
|
|
3539
3512
|
} catch (cause) {
|
|
3540
3513
|
if (cause === controller.signal && controller.signal.aborted) {
|
|
3541
3514
|
discardBackground(router, lane);
|
|
@@ -3557,11 +3530,11 @@ async function reduceLane(router, lane, tasks, controller, settlement, onReady)
|
|
|
3557
3530
|
}
|
|
3558
3531
|
return lane;
|
|
3559
3532
|
}
|
|
3560
|
-
async function projectLane
|
|
3533
|
+
async function projectLane(router, lane, signal, start = 0, end = lane[1].length) {
|
|
3561
3534
|
const matches = lane[1];
|
|
3562
3535
|
for (let index = start; index < end; index++) {
|
|
3563
3536
|
const match = matches[index];
|
|
3564
|
-
const routeOptions = getRoute
|
|
3537
|
+
const routeOptions = getRoute(router, match).options;
|
|
3565
3538
|
if (routeOptions.head || routeOptions.scripts) try {
|
|
3566
3539
|
const context = {
|
|
3567
3540
|
ssr: router.options.ssr,
|
|
@@ -3570,7 +3543,7 @@ async function projectLane$1(router, lane, signal, start = 0, end = lane[1].leng
|
|
|
3570
3543
|
params: match.params,
|
|
3571
3544
|
loaderData: match.loaderData
|
|
3572
3545
|
};
|
|
3573
|
-
const [head, scripts] = await waitFor
|
|
3546
|
+
const [head, scripts] = await waitFor(Promise.all([routeOptions.head?.(context), routeOptions.scripts?.(context)]), signal);
|
|
3574
3547
|
match.meta = head?.meta;
|
|
3575
3548
|
match.links = head?.links;
|
|
3576
3549
|
match.headScripts = head?.scripts;
|
|
@@ -3592,7 +3565,7 @@ async function executeClientLane(router, location, matches, options) {
|
|
|
3592
3565
|
const presented = router.stores.matches.get();
|
|
3593
3566
|
let plannedBoundary = matches.findIndex((match) => match._notFound);
|
|
3594
3567
|
if (router.options.notFoundMode !== "root" && plannedBoundary >= 0) {
|
|
3595
|
-
const boundary = await getNotFoundBoundary
|
|
3568
|
+
const boundary = await getNotFoundBoundary(router, matched[1], void 0, signal, plannedBoundary);
|
|
3596
3569
|
if (boundary !== plannedBoundary) {
|
|
3597
3570
|
matches[plannedBoundary]._notFound = void 0;
|
|
3598
3571
|
matches[boundary]._notFound = true;
|
|
@@ -3614,18 +3587,18 @@ async function executeClientLane(router, location, matches, options) {
|
|
|
3614
3587
|
const planSuccessfulLane = () => {
|
|
3615
3588
|
for (let index = start; index < end; index++) {
|
|
3616
3589
|
if (signal.aborted) break;
|
|
3617
|
-
semanticParent = createLoaderTask
|
|
3590
|
+
semanticParent = createLoaderTask(router, matched, index, tasks, semanticParent, options, retainedEnd);
|
|
3618
3591
|
}
|
|
3619
3592
|
};
|
|
3620
|
-
const failure = await contextualize
|
|
3593
|
+
const failure = await contextualize(router, matched, options, end, planSuccessfulLane, retainedEnd);
|
|
3621
3594
|
if (failure) {
|
|
3622
3595
|
options[4] = true;
|
|
3623
3596
|
end = failure[0];
|
|
3624
|
-
if (failure[1][0] === NOT_FOUND
|
|
3625
|
-
const boundary = await getNotFoundBoundary
|
|
3597
|
+
if (failure[1][0] === NOT_FOUND) {
|
|
3598
|
+
const boundary = await getNotFoundBoundary(router, matched[1], failure, signal);
|
|
3626
3599
|
failure[2] = boundary;
|
|
3627
3600
|
end = Math.min(end, boundary + 1);
|
|
3628
|
-
} else if (failure[1][0] >= REDIRECTED
|
|
3601
|
+
} else if (failure[1][0] >= REDIRECTED) end = 0;
|
|
3629
3602
|
planSuccessfulLane();
|
|
3630
3603
|
}
|
|
3631
3604
|
if (!signal.aborted && !options[3]) {
|
|
@@ -3645,7 +3618,7 @@ async function executeClientLane(router, location, matches, options) {
|
|
|
3645
3618
|
throw cause;
|
|
3646
3619
|
}
|
|
3647
3620
|
if (isControl(reduced)) return reduced;
|
|
3648
|
-
return projectLane
|
|
3621
|
+
return projectLane(router, reduced, signal, options[6] === reduced[1].length ? options[6] : 0);
|
|
3649
3622
|
}
|
|
3650
3623
|
/**
|
|
3651
3624
|
* Waits for `pendingMs`, then presents the complete lane. Rendering applies the
|
|
@@ -3663,7 +3636,7 @@ function offerPending(router, tx) {
|
|
|
3663
3636
|
const success = match.status === "success" && !match._notFound;
|
|
3664
3637
|
const presentedPending = presented[index]?.id === match.id && presented[index]?.status === "pending";
|
|
3665
3638
|
if (success && !presentedPending) continue;
|
|
3666
|
-
const route = getRoute
|
|
3639
|
+
const route = getRoute(router, match);
|
|
3667
3640
|
const delay = success && presentedPending || match.invalid ? 0 : route.options.pendingMs ?? router.options.defaultPendingMs;
|
|
3668
3641
|
const component = route.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
3669
3642
|
if (!component || typeof delay !== "number" || delay === Infinity) {
|
|
@@ -3733,7 +3706,7 @@ async function awaitPendingMinimum(router, tx) {
|
|
|
3733
3706
|
if (!session[4] || remaining <= 0 || !_getRenderedMatches(tx[3]).some((match) => match.id === session[1])) return;
|
|
3734
3707
|
let timer;
|
|
3735
3708
|
try {
|
|
3736
|
-
await waitFor
|
|
3709
|
+
await waitFor(new Promise((resolve) => {
|
|
3737
3710
|
timer = setTimeout(resolve, remaining);
|
|
3738
3711
|
}), tx[0].signal);
|
|
3739
3712
|
} catch {}
|
|
@@ -3752,11 +3725,11 @@ function commitMatches(router, tx, matches, resolvedPrefix) {
|
|
|
3752
3725
|
}
|
|
3753
3726
|
const cut = _getRenderedMatches(matches).length;
|
|
3754
3727
|
const cached = /* @__PURE__ */ new Map();
|
|
3755
|
-
if (
|
|
3728
|
+
if (!tx[6]) {
|
|
3756
3729
|
const now = Date.now();
|
|
3757
3730
|
for (const match of [...previous, ...previousCached.values()]) {
|
|
3758
3731
|
if (match.status !== "success" || matches.some((candidate, index) => candidate.id === match.id && (index < cut || candidate.status === "success"))) continue;
|
|
3759
|
-
const route = getRoute
|
|
3732
|
+
const route = getRoute(router, match);
|
|
3760
3733
|
if (!route.options.loader || now - match.updatedAt >= (match.preload ? route.options.preloadGcTime ?? router.options.defaultPreloadGcTime ?? 3e5 : route.options.gcTime ?? router.options.defaultGcTime ?? 3e5)) continue;
|
|
3761
3734
|
cached.set(match.id, previousCached.get(match.id) === match ? match : {
|
|
3762
3735
|
...match,
|
|
@@ -3770,7 +3743,7 @@ function commitMatches(router, tx, matches, resolvedPrefix) {
|
|
|
3770
3743
|
router._cache = cached;
|
|
3771
3744
|
publishMatches(router, matches);
|
|
3772
3745
|
transferMatchResources(router, [...previousCached.values(), ...previous], [...matches, ...cached.values()]);
|
|
3773
|
-
|
|
3746
|
+
{
|
|
3774
3747
|
const handoff = tx[6]?.[0];
|
|
3775
3748
|
if (handoff && router._handoff === handoff) handoff[1]();
|
|
3776
3749
|
}
|
|
@@ -3836,10 +3809,10 @@ async function runBackground(router, tx, base, tasks, settlement) {
|
|
|
3836
3809
|
}
|
|
3837
3810
|
if (isControl(reduced)) {
|
|
3838
3811
|
transferMatchResources(router, next);
|
|
3839
|
-
if (reduced[0] === REDIRECTED
|
|
3812
|
+
if (reduced[0] === REDIRECTED && router._tx === tx && router._committed === base) await followRedirect(router, tx, reduced);
|
|
3840
3813
|
return;
|
|
3841
3814
|
}
|
|
3842
|
-
const projected = await projectLane
|
|
3815
|
+
const projected = await projectLane(router, reduced, tx[0].signal);
|
|
3843
3816
|
if (router._tx !== tx || router._committed !== base) {
|
|
3844
3817
|
transferMatchResources(router, projected[1]);
|
|
3845
3818
|
return;
|
|
@@ -3867,7 +3840,7 @@ async function runClientTransaction(router, tx, forceStaleReload, onReady, sync,
|
|
|
3867
3840
|
];
|
|
3868
3841
|
const result = await executeClientLane(router, tx[2], tx[3], options);
|
|
3869
3842
|
if (isControl(result)) {
|
|
3870
|
-
const follow = result[0] === REDIRECTED
|
|
3843
|
+
const follow = result[0] === REDIRECTED && router._tx === tx;
|
|
3871
3844
|
if (!follow || result[1].options.reloadDocument) finishPending(router, tx);
|
|
3872
3845
|
transferMatchResources(router, tx[3]);
|
|
3873
3846
|
tx[3] = [];
|
|
@@ -3876,7 +3849,7 @@ async function runClientTransaction(router, tx, forceStaleReload, onReady, sync,
|
|
|
3876
3849
|
finishPending(router, tx);
|
|
3877
3850
|
return;
|
|
3878
3851
|
}
|
|
3879
|
-
if (
|
|
3852
|
+
if (tx[6]) router._refreshNextLoad = true;
|
|
3880
3853
|
await followRedirect(router, tx, result);
|
|
3881
3854
|
return;
|
|
3882
3855
|
}
|
|
@@ -3924,7 +3897,7 @@ async function runClientTransaction(router, tx, forceStaleReload, onReady, sync,
|
|
|
3924
3897
|
});
|
|
3925
3898
|
};
|
|
3926
3899
|
const rendered = await router.startTransition(commit, result[1]);
|
|
3927
|
-
if (
|
|
3900
|
+
if (tx[6]) tx[6] = void 0;
|
|
3928
3901
|
if (router._tx !== tx) {
|
|
3929
3902
|
discardBackground(router, result);
|
|
3930
3903
|
return;
|
|
@@ -3949,7 +3922,7 @@ async function runClientTransaction(router, tx, forceStaleReload, onReady, sync,
|
|
|
3949
3922
|
}
|
|
3950
3923
|
async function loadClientRoute(router, opts) {
|
|
3951
3924
|
let rematerialize = false;
|
|
3952
|
-
|
|
3925
|
+
rematerialize = !!router._refreshNextLoad || !!router._tx?.[6];
|
|
3953
3926
|
const previousOwner = router._tx;
|
|
3954
3927
|
const resolvedLocation = router.stores.resolvedLocation.get();
|
|
3955
3928
|
const previousLocation = resolvedLocation ?? router.stores.location.get();
|
|
@@ -3982,7 +3955,7 @@ async function loadClientRoute(router, opts) {
|
|
|
3982
3955
|
}
|
|
3983
3956
|
const sameHref = previousLocation.href === location.href;
|
|
3984
3957
|
let controller = preflight;
|
|
3985
|
-
const matches =
|
|
3958
|
+
const matches = rematerialize ? router.matchRoutes(location, {
|
|
3986
3959
|
_controller: preflight,
|
|
3987
3960
|
_rematerialize: true
|
|
3988
3961
|
}) : router.matchRoutes(location, { _controller: preflight });
|
|
@@ -4004,7 +3977,7 @@ async function loadClientRoute(router, opts) {
|
|
|
4004
3977
|
Date.now(),
|
|
4005
3978
|
Promise.resolve().then(() => runClientTransaction(router, tx, sameHref, () => offerPending(router, tx), opts?.sync, resolvedPrefix)).then()
|
|
4006
3979
|
];
|
|
4007
|
-
if (
|
|
3980
|
+
if (rematerialize) {
|
|
4008
3981
|
tx[6] = [handoff];
|
|
4009
3982
|
router._refreshNextLoad = void 0;
|
|
4010
3983
|
}
|
|
@@ -4043,7 +4016,7 @@ async function refreshClientRoute(router) {
|
|
|
4043
4016
|
await loadClientRoute(router, { sync: true });
|
|
4044
4017
|
}
|
|
4045
4018
|
async function preloadClientRoute(router, opts, redirects = 0, builtLocation) {
|
|
4046
|
-
if (
|
|
4019
|
+
if (router._refreshNextLoad || router._tx?.[6]) return;
|
|
4047
4020
|
const location = builtLocation ?? router.buildLocation(opts);
|
|
4048
4021
|
const base = router._committed;
|
|
4049
4022
|
const controller = new AbortController();
|
|
@@ -4073,700 +4046,44 @@ async function preloadClientRoute(router, opts, redirects = 0, builtLocation) {
|
|
|
4073
4046
|
controller.abort();
|
|
4074
4047
|
}
|
|
4075
4048
|
if (!isControl(result)) return result[1];
|
|
4076
|
-
if (active && result[0] === REDIRECTED
|
|
4049
|
+
if (active && result[0] === REDIRECTED && !result[1].options.reloadDocument) return preloadClientRoute(router, result[1].options, redirects + 1, result[2]);
|
|
4077
4050
|
} catch (cause) {
|
|
4078
4051
|
if (!isNotFound(cause)) console.error(cause);
|
|
4079
4052
|
}
|
|
4080
4053
|
}
|
|
4081
4054
|
//#endregion
|
|
4082
|
-
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
const
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
}
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
}
|
|
4115
|
-
function normalizeError(router, lane, route, cause, signal, notify = true) {
|
|
4116
|
-
signal?.throwIfAborted();
|
|
4117
|
-
let outcome = normalize(cause, true);
|
|
4118
|
-
if (outcome[0] !== ERROR) return materializeRedirect(router, lane, route, outcome, signal, notify);
|
|
4119
|
-
try {
|
|
4120
|
-
route.options.onError?.(outcome[1]);
|
|
4121
|
-
} catch (onErrorCause) {
|
|
4122
|
-
outcome = normalize(onErrorCause, true);
|
|
4123
|
-
}
|
|
4124
|
-
signal?.throwIfAborted();
|
|
4125
|
-
return materializeRedirect(router, lane, route, outcome, signal, notify);
|
|
4126
|
-
}
|
|
4127
|
-
function materializeRedirect(router, lane, route, outcome, signal, notify = true) {
|
|
4128
|
-
if (outcome[0] !== REDIRECTED) return outcome;
|
|
4129
|
-
signal?.throwIfAborted();
|
|
4130
|
-
try {
|
|
4131
|
-
outcome[1].options._fromLocation = lane.location;
|
|
4132
|
-
router.resolveRedirect(outcome[1]);
|
|
4133
|
-
signal?.throwIfAborted();
|
|
4134
|
-
return outcome;
|
|
4135
|
-
} catch (cause) {
|
|
4136
|
-
signal?.throwIfAborted();
|
|
4137
|
-
return notify ? normalizeError(router, lane, route, cause, signal, false) : [ERROR, cause];
|
|
4138
|
-
}
|
|
4139
|
-
}
|
|
4140
|
-
function maybe(value, cause) {
|
|
4141
|
-
if (cause !== void 0) return {
|
|
4142
|
-
status: "error",
|
|
4143
|
-
error: cause
|
|
4144
|
-
};
|
|
4145
|
-
return {
|
|
4146
|
-
status: "success",
|
|
4147
|
-
value
|
|
4148
|
-
};
|
|
4149
|
-
}
|
|
4150
|
-
function navigateFrom(router, location) {
|
|
4151
|
-
return (options) => router.navigate({
|
|
4152
|
-
...options,
|
|
4153
|
-
_fromLocation: location
|
|
4154
|
-
});
|
|
4155
|
-
}
|
|
4156
|
-
function waitFor(value, signal) {
|
|
4157
|
-
return signal ? waitForReason(value, signal) : value;
|
|
4158
|
-
}
|
|
4159
|
-
async function resolveSsr(router, lane, index) {
|
|
4160
|
-
const match = lane.matches[index];
|
|
4161
|
-
const route = getRoute(router, match);
|
|
4162
|
-
const parentSsr = lane.matches[index - 1]?.ssr;
|
|
4163
|
-
if (router.isShell()) return route.id === rootRouteId;
|
|
4164
|
-
if (parentSsr === false) return false;
|
|
4165
|
-
const inherit = (value) => {
|
|
4166
|
-
return value === true && parentSsr === "data-only" ? "data-only" : value;
|
|
4167
|
-
};
|
|
4168
|
-
const defaultSsr = router.options.defaultSsr ?? true;
|
|
4169
|
-
const inheritedDefault = inherit(defaultSsr);
|
|
4170
|
-
match.ssr = inheritedDefault;
|
|
4171
|
-
const option = route.options.ssr;
|
|
4172
|
-
if (option === void 0) return inheritedDefault;
|
|
4173
|
-
if (typeof option !== "function") return inherit(option);
|
|
4174
|
-
return inherit(await option({
|
|
4175
|
-
search: maybe(match.search, match.searchError),
|
|
4176
|
-
params: maybe(match.params, match.paramsError),
|
|
4177
|
-
location: lane.location,
|
|
4178
|
-
matches: lane.matches.map((candidate) => ({
|
|
4179
|
-
index: candidate.index,
|
|
4180
|
-
pathname: candidate.pathname,
|
|
4181
|
-
fullPath: candidate.fullPath,
|
|
4182
|
-
staticData: candidate.staticData,
|
|
4183
|
-
id: candidate.id,
|
|
4184
|
-
routeId: candidate.routeId,
|
|
4185
|
-
search: maybe(candidate.search, candidate.searchError),
|
|
4186
|
-
params: maybe(candidate.params, candidate.paramsError),
|
|
4187
|
-
ssr: candidate.ssr
|
|
4188
|
-
}))
|
|
4189
|
-
}) ?? defaultSsr);
|
|
4190
|
-
}
|
|
4191
|
-
function stampNotFound(match, outcome) {
|
|
4192
|
-
if (outcome[0] === NOT_FOUND && !outcome[1].routeId) outcome[1].routeId = match.routeId;
|
|
4193
|
-
return outcome;
|
|
4194
|
-
}
|
|
4195
|
-
async function contextualize(router, lane, signal) {
|
|
4196
|
-
const globalBoundary = lane.matches.findIndex((match) => match._notFound);
|
|
4197
|
-
let end = globalBoundary < 0 ? lane.matches.length : globalBoundary + 1;
|
|
4198
|
-
let failure;
|
|
4199
|
-
let parentContext = { ...router.options.context ?? {} };
|
|
4200
|
-
for (let index = 0; index < end; index++) {
|
|
4201
|
-
const match = lane.matches[index];
|
|
4202
|
-
const route = getRoute(router, match);
|
|
4203
|
-
try {
|
|
4204
|
-
match.ssr = await resolveSsr(router, lane, index);
|
|
4205
|
-
} catch (cause) {
|
|
4206
|
-
signal?.throwIfAborted();
|
|
4207
|
-
failure = [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
|
|
4208
|
-
end = index;
|
|
4209
|
-
}
|
|
4210
|
-
signal?.throwIfAborted();
|
|
4211
|
-
if (failure?.[1][0] === REDIRECTED) break;
|
|
4212
|
-
match.__beforeLoadContext = void 0;
|
|
4213
|
-
let context = parentContext;
|
|
4214
|
-
try {
|
|
4215
|
-
let routeContext;
|
|
4216
|
-
if (route.options.context) {
|
|
4217
|
-
const routeContextOptions = {
|
|
4218
|
-
deps: match.loaderDeps,
|
|
4219
|
-
params: match.params,
|
|
4220
|
-
context: parentContext,
|
|
4221
|
-
location: lane.location,
|
|
4222
|
-
navigate: navigateFrom(router, lane.location),
|
|
4223
|
-
buildLocation: router.buildLocation,
|
|
4224
|
-
cause: match.cause,
|
|
4225
|
-
abortController: match.abortController,
|
|
4226
|
-
preload: false,
|
|
4227
|
-
matches: lane.matches,
|
|
4228
|
-
routeId: route.id
|
|
4229
|
-
};
|
|
4230
|
-
routeContext = route.options.context(routeContextOptions) ?? void 0;
|
|
4231
|
-
}
|
|
4232
|
-
context = {
|
|
4233
|
-
...parentContext,
|
|
4234
|
-
...routeContext
|
|
4235
|
-
};
|
|
4236
|
-
match.context = context;
|
|
4237
|
-
} catch (cause) {
|
|
4238
|
-
signal?.throwIfAborted();
|
|
4239
|
-
if (!failure) failure = [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
|
|
4240
|
-
end = index;
|
|
4241
|
-
break;
|
|
4242
|
-
}
|
|
4243
|
-
signal?.throwIfAborted();
|
|
4244
|
-
if (failure) break;
|
|
4245
|
-
const validationError = match.paramsError ?? match.searchError;
|
|
4246
|
-
if (validationError !== void 0) {
|
|
4247
|
-
failure = [index, stampNotFound(match, normalizeError(router, lane, route, validationError, signal))];
|
|
4248
|
-
end = index;
|
|
4249
|
-
break;
|
|
4250
|
-
}
|
|
4251
|
-
signal?.throwIfAborted();
|
|
4252
|
-
if (match.ssr === false || !route.options.beforeLoad) {
|
|
4253
|
-
parentContext = context;
|
|
4254
|
-
continue;
|
|
4255
|
-
}
|
|
4256
|
-
const abortController = match.abortController;
|
|
4257
|
-
const options = {
|
|
4258
|
-
search: match.search,
|
|
4259
|
-
abortController,
|
|
4260
|
-
params: match.params,
|
|
4261
|
-
preload: false,
|
|
4262
|
-
context,
|
|
4263
|
-
location: lane.location,
|
|
4264
|
-
navigate: navigateFrom(router, lane.location),
|
|
4265
|
-
buildLocation: router.buildLocation,
|
|
4266
|
-
cause: match.cause,
|
|
4267
|
-
matches: lane.matches,
|
|
4268
|
-
routeId: route.id,
|
|
4269
|
-
...router.options.additionalContext
|
|
4270
|
-
};
|
|
4271
|
-
try {
|
|
4272
|
-
const beforeLoadContext = await route.options.beforeLoad(options);
|
|
4273
|
-
signal?.throwIfAborted();
|
|
4274
|
-
const outcome = stampNotFound(match, materializeRedirect(router, lane, route, normalize(beforeLoadContext, false), signal));
|
|
4275
|
-
if (outcome[0] !== SUCCESS) {
|
|
4276
|
-
failure = [index, outcome];
|
|
4277
|
-
end = index;
|
|
4278
|
-
break;
|
|
4279
|
-
}
|
|
4280
|
-
match.__beforeLoadContext = beforeLoadContext;
|
|
4281
|
-
match.context = {
|
|
4282
|
-
...context,
|
|
4283
|
-
...beforeLoadContext
|
|
4284
|
-
};
|
|
4285
|
-
parentContext = match.context;
|
|
4286
|
-
} catch (cause) {
|
|
4287
|
-
signal?.throwIfAborted();
|
|
4288
|
-
failure = [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
|
|
4289
|
-
end = index;
|
|
4290
|
-
break;
|
|
4291
|
-
}
|
|
4292
|
-
}
|
|
4293
|
-
return {
|
|
4294
|
-
location: lane.location,
|
|
4295
|
-
matches: lane.matches,
|
|
4296
|
-
end,
|
|
4297
|
-
failure
|
|
4298
|
-
};
|
|
4299
|
-
}
|
|
4300
|
-
function getLoaderContext(router, lane, match, route, index, tasks) {
|
|
4301
|
-
return {
|
|
4302
|
-
params: match.params,
|
|
4303
|
-
deps: match.loaderDeps,
|
|
4304
|
-
preload: false,
|
|
4305
|
-
parentMatchPromise: tasks[index - 1]?.match,
|
|
4306
|
-
abortController: match.abortController,
|
|
4307
|
-
context: match.context,
|
|
4308
|
-
location: lane.location,
|
|
4309
|
-
navigate: navigateFrom(router, lane.location),
|
|
4310
|
-
cause: match.cause,
|
|
4311
|
-
route,
|
|
4312
|
-
...router.options.additionalContext
|
|
4313
|
-
};
|
|
4314
|
-
}
|
|
4315
|
-
function createLoaderTask(router, lane, index, tasks, signal) {
|
|
4316
|
-
const match = lane.matches[index];
|
|
4317
|
-
const route = getRoute(router, match);
|
|
4318
|
-
let outcome;
|
|
4319
|
-
if (match.ssr === false) outcome = Promise.resolve([SKIPPED]);
|
|
4320
|
-
else {
|
|
4321
|
-
const routeLoader = route.options.loader;
|
|
4322
|
-
const loader = typeof routeLoader === "function" ? routeLoader : routeLoader?.handler;
|
|
4323
|
-
if (!loader) outcome = Promise.resolve([SUCCESS, void 0]);
|
|
4324
|
-
else outcome = Promise.resolve().then(() => loader(getLoaderContext(router, lane, match, route, index, tasks))).then((result) => normalize(result, false), (cause) => normalize(cause, true)).then((result) => {
|
|
4325
|
-
if (signal?.aborted || match.abortController.signal.reason === lane) return [SKIPPED];
|
|
4326
|
-
if (result[0] === ERROR) result = normalizeError(router, lane, route, result[1], signal);
|
|
4327
|
-
else result = materializeRedirect(router, lane, route, result, signal);
|
|
4328
|
-
return stampNotFound(match, result);
|
|
4329
|
-
});
|
|
4330
|
-
}
|
|
4331
|
-
const parentMatch = outcome.then((result) => {
|
|
4332
|
-
const snapshot = { ...match };
|
|
4333
|
-
if (result[0] === SUCCESS) {
|
|
4334
|
-
snapshot.loaderData = result[1];
|
|
4335
|
-
snapshot.status = "success";
|
|
4336
|
-
snapshot.error = void 0;
|
|
4337
|
-
snapshot.invalid = false;
|
|
4338
|
-
snapshot.isFetching = false;
|
|
4339
|
-
} else if (result[0] === ERROR) {
|
|
4340
|
-
snapshot.status = "error";
|
|
4341
|
-
snapshot.error = result[1];
|
|
4342
|
-
} else if (result[0] === NOT_FOUND) {
|
|
4343
|
-
snapshot.status = "notFound";
|
|
4344
|
-
snapshot.error = result[1];
|
|
4345
|
-
}
|
|
4346
|
-
return snapshot;
|
|
4347
|
-
});
|
|
4348
|
-
return {
|
|
4349
|
-
index,
|
|
4350
|
-
outcome,
|
|
4351
|
-
match: parentMatch
|
|
4352
|
-
};
|
|
4353
|
-
}
|
|
4354
|
-
async function getNotFoundBoundary(router, matches, indexed, signal, fallback = 0) {
|
|
4355
|
-
const cause = indexed?.[1][1];
|
|
4356
|
-
let index = cause?.routeId ? matches.findIndex((match) => match.routeId === cause.routeId) : indexed?.[0] ?? matches.length - 1;
|
|
4357
|
-
if (index < 0) index = 0;
|
|
4358
|
-
for (let candidate = index; candidate >= 0; candidate--) {
|
|
4359
|
-
const route = getRoute(router, matches[candidate]);
|
|
4360
|
-
try {
|
|
4361
|
-
const loading = loadRouteChunk(route, false);
|
|
4362
|
-
if (loading) await loading;
|
|
4363
|
-
} catch {
|
|
4364
|
-
signal?.throwIfAborted();
|
|
4365
|
-
}
|
|
4366
|
-
signal?.throwIfAborted();
|
|
4367
|
-
if (route.options.notFoundComponent) return candidate;
|
|
4368
|
-
}
|
|
4369
|
-
return cause?.routeId ? index : fallback;
|
|
4370
|
-
}
|
|
4371
|
-
function abortMatches(matches, start = 0, reason) {
|
|
4372
|
-
for (let index = start; index < matches.length; index++) matches[index].abortController.abort(reason);
|
|
4373
|
-
}
|
|
4374
|
-
async function applyFailure(router, lane, indexed, signal) {
|
|
4375
|
-
if (!indexed) {
|
|
4376
|
-
const boundary = lane.matches.findIndex((match) => match._notFound);
|
|
4377
|
-
if (boundary >= 0) {
|
|
4378
|
-
abortMatches(lane.matches, boundary + 1);
|
|
4379
|
-
return {
|
|
4380
|
-
status: 404,
|
|
4381
|
-
boundary,
|
|
4382
|
-
kind: NOT_FOUND
|
|
4383
|
-
};
|
|
4384
|
-
}
|
|
4385
|
-
return { status: 200 };
|
|
4386
|
-
}
|
|
4387
|
-
const [index, outcome] = indexed;
|
|
4388
|
-
if (outcome[0] === ERROR) {
|
|
4389
|
-
const match = lane.matches[index];
|
|
4390
|
-
match._notFound = void 0;
|
|
4391
|
-
match.status = "error";
|
|
4392
|
-
match.error = outcome[1];
|
|
4393
|
-
match.isFetching = false;
|
|
4394
|
-
abortMatches(lane.matches, index + 1);
|
|
4395
|
-
return {
|
|
4396
|
-
status: 500,
|
|
4397
|
-
boundary: index,
|
|
4398
|
-
kind: ERROR
|
|
4399
|
-
};
|
|
4400
|
-
}
|
|
4401
|
-
const boundary = indexed[2] ?? await getNotFoundBoundary(router, lane.matches, indexed, signal);
|
|
4402
|
-
const match = lane.matches[boundary];
|
|
4403
|
-
const cause = outcome[1];
|
|
4404
|
-
cause.routeId = match.routeId;
|
|
4405
|
-
match._notFound = void 0;
|
|
4406
|
-
if (match.routeId === router.routeTree.id) {
|
|
4407
|
-
match.status = "success";
|
|
4408
|
-
match._notFound = true;
|
|
4409
|
-
match.error = cause;
|
|
4410
|
-
} else {
|
|
4411
|
-
match.status = "notFound";
|
|
4412
|
-
match.error = cause;
|
|
4413
|
-
}
|
|
4414
|
-
match.isFetching = false;
|
|
4415
|
-
abortMatches(lane.matches, boundary + 1);
|
|
4416
|
-
return {
|
|
4417
|
-
status: 404,
|
|
4418
|
-
boundary,
|
|
4419
|
-
kind: NOT_FOUND
|
|
4420
|
-
};
|
|
4421
|
-
}
|
|
4422
|
-
async function loadNormalChunks(router, lane, end, signal) {
|
|
4423
|
-
const chunks = [];
|
|
4424
|
-
for (let index = 0; index < lane.matches.length; index++) {
|
|
4425
|
-
const match = lane.matches[index];
|
|
4426
|
-
if (index >= end || match.ssr !== true || match.status !== "success") continue;
|
|
4427
|
-
const route = getRoute(router, match);
|
|
4428
|
-
try {
|
|
4429
|
-
const loading = loadRouteChunk(route);
|
|
4430
|
-
if (loading) {
|
|
4431
|
-
const chunk = loading.then(() => {
|
|
4432
|
-
signal?.throwIfAborted();
|
|
4433
|
-
}, (cause) => {
|
|
4434
|
-
signal?.throwIfAborted();
|
|
4435
|
-
return [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
|
|
4436
|
-
});
|
|
4437
|
-
chunk.catch(() => {});
|
|
4438
|
-
chunks.push(chunk);
|
|
4439
|
-
}
|
|
4440
|
-
} catch (cause) {
|
|
4441
|
-
signal?.throwIfAborted();
|
|
4442
|
-
chunks.push([index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))]);
|
|
4443
|
-
}
|
|
4444
|
-
}
|
|
4445
|
-
for (const chunk of chunks) {
|
|
4446
|
-
const indexed = Array.isArray(chunk) ? chunk : await chunk;
|
|
4447
|
-
if (indexed) return indexed;
|
|
4448
|
-
}
|
|
4449
|
-
}
|
|
4450
|
-
async function projectLane(router, lane, signal) {
|
|
4451
|
-
for (const match of lane.matches) {
|
|
4452
|
-
const routeOptions = getRoute(router, match).options;
|
|
4453
|
-
if (routeOptions.head || routeOptions.scripts || routeOptions.headers) {
|
|
4454
|
-
const context = {
|
|
4455
|
-
ssr: router.options.ssr,
|
|
4456
|
-
matches: lane.matches,
|
|
4457
|
-
match,
|
|
4458
|
-
params: match.params,
|
|
4459
|
-
loaderData: match.loaderData
|
|
4460
|
-
};
|
|
4461
|
-
try {
|
|
4462
|
-
const [head, scripts, headers] = await Promise.all([
|
|
4463
|
-
routeOptions.head?.(context),
|
|
4464
|
-
routeOptions.scripts?.(context),
|
|
4465
|
-
routeOptions.headers?.(context)
|
|
4466
|
-
]);
|
|
4467
|
-
signal?.throwIfAborted();
|
|
4468
|
-
match.meta = head?.meta;
|
|
4469
|
-
match.links = head?.links;
|
|
4470
|
-
match.headScripts = head?.scripts;
|
|
4471
|
-
match.styles = head?.styles;
|
|
4472
|
-
match.scripts = scripts;
|
|
4473
|
-
match.headers = headers;
|
|
4474
|
-
} catch (cause) {
|
|
4475
|
-
signal?.throwIfAborted();
|
|
4476
|
-
console.error(cause);
|
|
4477
|
-
}
|
|
4478
|
-
}
|
|
4479
|
-
if (match.ssr === false || match.status !== "success" || match._notFound) break;
|
|
4480
|
-
}
|
|
4481
|
-
}
|
|
4482
|
-
async function executeServerLane(router, location, matchedMatches, signal) {
|
|
4483
|
-
const matched = {
|
|
4484
|
-
location,
|
|
4485
|
-
matches: matchedMatches.map((match) => ({
|
|
4486
|
-
...match,
|
|
4487
|
-
__beforeLoadContext: void 0,
|
|
4488
|
-
context: {},
|
|
4489
|
-
isFetching: false,
|
|
4490
|
-
abortController: new AbortController()
|
|
4491
|
-
}))
|
|
4492
|
-
};
|
|
4493
|
-
const abortLane = () => abortMatches(matched.matches, 0, signal?.reason);
|
|
4494
|
-
if (signal?.aborted) {
|
|
4495
|
-
abortLane();
|
|
4496
|
-
signal.throwIfAborted();
|
|
4497
|
-
}
|
|
4498
|
-
signal?.addEventListener("abort", abortLane, { once: true });
|
|
4499
|
-
try {
|
|
4500
|
-
const plannedGlobalBoundary = matched.matches.findIndex((match) => match._notFound);
|
|
4501
|
-
if (router.options.notFoundMode !== "root" && plannedGlobalBoundary >= 0) {
|
|
4502
|
-
const boundary = await getNotFoundBoundary(router, matched.matches, void 0, signal, plannedGlobalBoundary);
|
|
4503
|
-
if (boundary !== plannedGlobalBoundary) {
|
|
4504
|
-
matched.matches[plannedGlobalBoundary]._notFound = void 0;
|
|
4505
|
-
matched.matches[boundary]._notFound = true;
|
|
4506
|
-
}
|
|
4507
|
-
}
|
|
4508
|
-
const lane = await contextualize(router, matched, signal);
|
|
4509
|
-
signal?.throwIfAborted();
|
|
4510
|
-
let loaderEnd = lane.end;
|
|
4511
|
-
if (lane.failure?.[1][0] === REDIRECTED) loaderEnd = 0;
|
|
4512
|
-
else if (lane.failure?.[1][0] === NOT_FOUND) {
|
|
4513
|
-
lane.failure[2] = await getNotFoundBoundary(router, lane.matches, lane.failure, signal);
|
|
4514
|
-
loaderEnd = Math.min(loaderEnd, lane.failure[2] + 1);
|
|
4515
|
-
}
|
|
4516
|
-
const tasks = [];
|
|
4517
|
-
for (let index = 0; index < loaderEnd; index++) {
|
|
4518
|
-
const task = createLoaderTask(router, lane, index, tasks, signal);
|
|
4519
|
-
tasks.push(task);
|
|
4520
|
-
}
|
|
4521
|
-
let loaderFailure;
|
|
4522
|
-
let control = lane.failure?.[1][0] === REDIRECTED ? lane.failure : void 0;
|
|
4523
|
-
try {
|
|
4524
|
-
await Promise.all(tasks.map((task) => task.outcome.then((loadedOutcome) => {
|
|
4525
|
-
const match = lane.matches[task.index];
|
|
4526
|
-
const outcome = loadedOutcome;
|
|
4527
|
-
if (outcome[0] === SUCCESS) {
|
|
4528
|
-
match.loaderData = outcome[1];
|
|
4529
|
-
match.status = "success";
|
|
4530
|
-
match.error = void 0;
|
|
4531
|
-
match.invalid = false;
|
|
4532
|
-
match.isFetching = false;
|
|
4533
|
-
match.updatedAt = Date.now();
|
|
4534
|
-
} else if (outcome[0] === REDIRECTED) {
|
|
4535
|
-
control = [task.index, outcome];
|
|
4536
|
-
throw control;
|
|
4537
|
-
} else {
|
|
4538
|
-
if (match.ssr !== false) {
|
|
4539
|
-
match.status = "success";
|
|
4540
|
-
match.error = void 0;
|
|
4541
|
-
match.invalid = true;
|
|
4542
|
-
match.isFetching = false;
|
|
4543
|
-
}
|
|
4544
|
-
if (!loaderFailure && outcome[0] !== SKIPPED) loaderFailure = [task.index, outcome];
|
|
4545
|
-
}
|
|
4546
|
-
})));
|
|
4547
|
-
} catch (cause) {
|
|
4548
|
-
if (!Array.isArray(cause)) throw cause;
|
|
4549
|
-
control = cause;
|
|
4550
|
-
}
|
|
4551
|
-
signal?.throwIfAborted();
|
|
4552
|
-
if (control?.[1][0] === REDIRECTED) {
|
|
4553
|
-
abortMatches(lane.matches, 0, lane);
|
|
4554
|
-
return {
|
|
4555
|
-
type: "redirect",
|
|
4556
|
-
redirect: control[1][1]
|
|
4557
|
-
};
|
|
4558
|
-
}
|
|
4559
|
-
let failure = lane.failure ?? loaderFailure;
|
|
4560
|
-
const plannedBoundary = lane.matches.findIndex((match) => match._notFound);
|
|
4561
|
-
let readinessEnd;
|
|
4562
|
-
if (failure) {
|
|
4563
|
-
const outcomeEnd = failure[2] ??= failure[1][0] === NOT_FOUND ? await getNotFoundBoundary(router, lane.matches, failure, signal) : failure[0];
|
|
4564
|
-
for (const task of tasks) {
|
|
4565
|
-
if (task.index >= outcomeEnd) break;
|
|
4566
|
-
const outcome = await task.outcome;
|
|
4567
|
-
if (outcome[0] !== SUCCESS && outcome[0] < REDIRECTED && !("loaderData" in lane.matches[task.index])) {
|
|
4568
|
-
failure = [task.index, outcome];
|
|
4569
|
-
failure[2] = outcome[0] === NOT_FOUND ? await getNotFoundBoundary(router, lane.matches, failure, signal) : task.index;
|
|
4570
|
-
break;
|
|
4571
|
-
}
|
|
4572
|
-
}
|
|
4573
|
-
readinessEnd = failure[2];
|
|
4574
|
-
} else readinessEnd = plannedBoundary < 0 ? lane.matches.length : plannedBoundary;
|
|
4575
|
-
const requiredFailure = await loadNormalChunks(router, lane, readinessEnd, signal);
|
|
4576
|
-
signal?.throwIfAborted();
|
|
4577
|
-
if (requiredFailure) {
|
|
4578
|
-
if (requiredFailure[1][0] === REDIRECTED) {
|
|
4579
|
-
abortMatches(lane.matches);
|
|
4580
|
-
return {
|
|
4581
|
-
type: "redirect",
|
|
4582
|
-
redirect: requiredFailure[1][1]
|
|
4583
|
-
};
|
|
4584
|
-
}
|
|
4585
|
-
failure = requiredFailure;
|
|
4586
|
-
}
|
|
4587
|
-
const terminal = await applyFailure(router, lane, failure, signal);
|
|
4588
|
-
if (terminal.boundary !== void 0) {
|
|
4589
|
-
const match = lane.matches[terminal.boundary];
|
|
4590
|
-
if (match.ssr === true) {
|
|
4591
|
-
const route = getRoute(router, match);
|
|
4592
|
-
try {
|
|
4593
|
-
if (terminal.kind === ERROR) await loadRouteChunk(route, "errorComponent");
|
|
4594
|
-
else if (match._notFound) await Promise.all([loadRouteChunk(route), loadRouteChunk(route, "notFoundComponent")]);
|
|
4595
|
-
else await loadRouteChunk(route, "notFoundComponent");
|
|
4596
|
-
} catch {}
|
|
4597
|
-
signal?.throwIfAborted();
|
|
4598
|
-
}
|
|
4599
|
-
}
|
|
4600
|
-
signal?.throwIfAborted();
|
|
4601
|
-
await projectLane(router, {
|
|
4602
|
-
location: lane.location,
|
|
4603
|
-
matches: lane.matches
|
|
4604
|
-
}, signal);
|
|
4605
|
-
signal?.throwIfAborted();
|
|
4606
|
-
router.serverSsr?.onCleanup(abortLane);
|
|
4607
|
-
return {
|
|
4608
|
-
type: "render",
|
|
4609
|
-
status: terminal.status,
|
|
4610
|
-
matches: lane.matches
|
|
4611
|
-
};
|
|
4612
|
-
} finally {
|
|
4613
|
-
signal?.removeEventListener("abort", abortLane);
|
|
4614
|
-
}
|
|
4615
|
-
}
|
|
4616
|
-
async function loadServerRoute(router, opts) {
|
|
4617
|
-
router.updateLatestLocation();
|
|
4618
|
-
const next = router.latestLocation;
|
|
4619
|
-
const previous = router._committed;
|
|
4620
|
-
let result;
|
|
4621
|
-
try {
|
|
4622
|
-
const canonical = router.buildLocation({
|
|
4623
|
-
to: next.pathname,
|
|
4624
|
-
search: true,
|
|
4625
|
-
params: true,
|
|
4626
|
-
hash: true,
|
|
4627
|
-
state: true,
|
|
4628
|
-
_includeValidateSearch: true
|
|
4629
|
-
});
|
|
4630
|
-
if (next.publicHref !== canonical.publicHref) throw redirect({ href: canonical.publicHref || "/" });
|
|
4631
|
-
const changeInfo = getLocationChangeInfo(next, router.stores.resolvedLocation.get());
|
|
4632
|
-
router.emit({
|
|
4633
|
-
type: "onBeforeNavigate",
|
|
4634
|
-
...changeInfo
|
|
4635
|
-
});
|
|
4636
|
-
router.emit({
|
|
4637
|
-
type: "onBeforeLoad",
|
|
4638
|
-
...changeInfo
|
|
4639
|
-
});
|
|
4640
|
-
opts?._signal?.throwIfAborted();
|
|
4641
|
-
result = await waitFor(executeServerLane(router, next, router.matchRoutes(next), opts?._signal), opts?._signal);
|
|
4642
|
-
opts?._signal?.throwIfAborted();
|
|
4643
|
-
} catch (cause) {
|
|
4644
|
-
opts?._signal?.throwIfAborted();
|
|
4645
|
-
if (!isRedirect(cause)) throw cause;
|
|
4646
|
-
cause.options._fromLocation = next;
|
|
4647
|
-
result = {
|
|
4648
|
-
type: "redirect",
|
|
4649
|
-
redirect: router.resolveRedirect(cause)
|
|
4650
|
-
};
|
|
4651
|
-
}
|
|
4652
|
-
router._serverResult = result;
|
|
4653
|
-
router.batch(() => {
|
|
4654
|
-
router.stores.location.set(next);
|
|
4655
|
-
router.stores.status.set("idle");
|
|
4656
|
-
if (result.type === "render") {
|
|
4657
|
-
router.stores.setMatches(result.matches);
|
|
4658
|
-
router.stores.resolvedLocation.set(next);
|
|
4659
|
-
}
|
|
4660
|
-
});
|
|
4661
|
-
if (result.type === "render") {
|
|
4662
|
-
router._committed = result.matches;
|
|
4663
|
-
runRouteLifecycle(router, previous, result.matches);
|
|
4664
|
-
}
|
|
4665
|
-
router._commitPromise?.resolve();
|
|
4666
|
-
router._commitPromise = void 0;
|
|
4667
|
-
}
|
|
4668
|
-
//#endregion
|
|
4669
|
-
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/isServer/server.js
|
|
4670
|
-
const isServer = process.env.NODE_ENV === "test" ? void 0 : true;
|
|
4671
|
-
//#endregion
|
|
4672
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.31_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@tanstack/react-router/dist/esm/utils.js
|
|
4673
|
-
/**
|
|
4674
|
-
* React.use if available (React 19+), undefined otherwise.
|
|
4675
|
-
* Use dynamic lookup to avoid Webpack compilation errors with React 18.
|
|
4676
|
-
*/
|
|
4677
|
-
var reactUse = React$1["use"];
|
|
4678
|
-
var useLayoutEffect = isServer ?? typeof window === "undefined" ? React$1.useEffect : React$1.useLayoutEffect;
|
|
4679
|
-
/**
|
|
4680
|
-
* React hook to wrap `IntersectionObserver`.
|
|
4681
|
-
*
|
|
4682
|
-
* This hook will create an `IntersectionObserver` and observe the ref passed to it.
|
|
4683
|
-
*
|
|
4684
|
-
* When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.
|
|
4685
|
-
*
|
|
4686
|
-
* @param ref - The ref to observe
|
|
4687
|
-
* @param callback - The callback to call when the intersection changes
|
|
4688
|
-
* @param disabled - Whether observation is disabled
|
|
4689
|
-
* @returns The IntersectionObserver instance
|
|
4690
|
-
* @example
|
|
4691
|
-
* ```tsx
|
|
4692
|
-
* const MyComponent = () => {
|
|
4693
|
-
* const ref = React.useRef<HTMLDivElement>(null)
|
|
4694
|
-
* useIntersectionObserver(
|
|
4695
|
-
* ref,
|
|
4696
|
-
* (entry) => { doSomething(entry) },
|
|
4697
|
-
* false
|
|
4698
|
-
* )
|
|
4699
|
-
* return <div ref={ref} />
|
|
4700
|
-
* ```
|
|
4701
|
-
*/
|
|
4702
|
-
function useIntersectionObserver(ref, callback, disabled) {
|
|
4703
|
-
React$1.useEffect(() => {
|
|
4704
|
-
if (!ref.current || disabled || typeof IntersectionObserver !== "function") return () => callback();
|
|
4705
|
-
const observer = new IntersectionObserver((entries) => {
|
|
4706
|
-
callback(entries.pop());
|
|
4707
|
-
}, { rootMargin: "100px" });
|
|
4708
|
-
observer.observe(ref.current);
|
|
4709
|
-
return () => {
|
|
4710
|
-
observer.disconnect();
|
|
4711
|
-
callback();
|
|
4712
|
-
};
|
|
4713
|
-
}, [
|
|
4714
|
-
callback,
|
|
4715
|
-
disabled,
|
|
4716
|
-
ref
|
|
4717
|
-
]);
|
|
4718
|
-
}
|
|
4719
|
-
/**
|
|
4720
|
-
* React hook to take a `React.ForwardedRef` and returns a `ref` that can be used on a DOM element.
|
|
4721
|
-
*
|
|
4722
|
-
* @param ref - The forwarded ref
|
|
4723
|
-
* @returns The inner ref returned by `useRef`
|
|
4724
|
-
* @example
|
|
4725
|
-
* ```tsx
|
|
4726
|
-
* const MyComponent = React.forwardRef((props, ref) => {
|
|
4727
|
-
* const innerRef = useForwardedRef(ref)
|
|
4728
|
-
* return <div ref={innerRef} />
|
|
4729
|
-
* })
|
|
4730
|
-
* ```
|
|
4731
|
-
*/
|
|
4732
|
-
function useForwardedRef(ref) {
|
|
4733
|
-
const innerRef = React$1.useRef(null);
|
|
4734
|
-
React$1.useImperativeHandle(ref, () => innerRef.current, []);
|
|
4735
|
-
return innerRef;
|
|
4736
|
-
}
|
|
4737
|
-
//#endregion
|
|
4738
|
-
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/defer.js
|
|
4739
|
-
/**
|
|
4740
|
-
* Well-known symbol used by {@link defer} to tag a promise with
|
|
4741
|
-
* its deferred state. Consumers can read `promise[TSR_DEFERRED_PROMISE]`
|
|
4742
|
-
* to access `status`, `data`, or `error`.
|
|
4743
|
-
*/
|
|
4744
|
-
const TSR_DEFERRED_PROMISE = Symbol.for("TSR_DEFERRED_PROMISE");
|
|
4745
|
-
/**
|
|
4746
|
-
* Wrap a promise with a deferred state for use with `<Await>` and `useAwaited`.
|
|
4747
|
-
*
|
|
4748
|
-
* The returned promise is augmented with internal state (status/data/error)
|
|
4749
|
-
* so UI can read progress or suspend until it settles.
|
|
4750
|
-
*
|
|
4751
|
-
* @param _promise The promise to wrap.
|
|
4752
|
-
* @param options Optional config. Provide `serializeError` to customize how
|
|
4753
|
-
* errors are serialized for transfer.
|
|
4754
|
-
* @returns The same promise with attached deferred metadata.
|
|
4755
|
-
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/deferFunction
|
|
4756
|
-
*/
|
|
4757
|
-
function defer(_promise, options) {
|
|
4758
|
-
const promise = _promise;
|
|
4759
|
-
if (promise[TSR_DEFERRED_PROMISE]) return promise;
|
|
4760
|
-
promise[TSR_DEFERRED_PROMISE] = { status: "pending" };
|
|
4761
|
-
promise.then((data) => {
|
|
4762
|
-
promise[TSR_DEFERRED_PROMISE].status = "success";
|
|
4763
|
-
promise[TSR_DEFERRED_PROMISE].data = data;
|
|
4764
|
-
}).catch((error) => {
|
|
4765
|
-
promise[TSR_DEFERRED_PROMISE].status = "error";
|
|
4766
|
-
promise[TSR_DEFERRED_PROMISE].error = {
|
|
4767
|
-
data: (options?.serializeError ?? defaultSerializeError)(error),
|
|
4768
|
-
__isServerError: true
|
|
4769
|
-
};
|
|
4055
|
+
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/defer.js
|
|
4056
|
+
/**
|
|
4057
|
+
* Well-known symbol used by {@link defer} to tag a promise with
|
|
4058
|
+
* its deferred state. Consumers can read `promise[TSR_DEFERRED_PROMISE]`
|
|
4059
|
+
* to access `status`, `data`, or `error`.
|
|
4060
|
+
*/
|
|
4061
|
+
const TSR_DEFERRED_PROMISE = Symbol.for("TSR_DEFERRED_PROMISE");
|
|
4062
|
+
/**
|
|
4063
|
+
* Wrap a promise with a deferred state for use with `<Await>` and `useAwaited`.
|
|
4064
|
+
*
|
|
4065
|
+
* The returned promise is augmented with internal state (status/data/error)
|
|
4066
|
+
* so UI can read progress or suspend until it settles.
|
|
4067
|
+
*
|
|
4068
|
+
* @param _promise The promise to wrap.
|
|
4069
|
+
* @param options Optional config. Provide `serializeError` to customize how
|
|
4070
|
+
* errors are serialized for transfer.
|
|
4071
|
+
* @returns The same promise with attached deferred metadata.
|
|
4072
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/deferFunction
|
|
4073
|
+
*/
|
|
4074
|
+
function defer(_promise, options) {
|
|
4075
|
+
const promise = _promise;
|
|
4076
|
+
if (promise[TSR_DEFERRED_PROMISE]) return promise;
|
|
4077
|
+
promise[TSR_DEFERRED_PROMISE] = { status: "pending" };
|
|
4078
|
+
promise.then((data) => {
|
|
4079
|
+
promise[TSR_DEFERRED_PROMISE].status = "success";
|
|
4080
|
+
promise[TSR_DEFERRED_PROMISE].data = data;
|
|
4081
|
+
}).catch((error) => {
|
|
4082
|
+
promise[TSR_DEFERRED_PROMISE].status = "error";
|
|
4083
|
+
promise[TSR_DEFERRED_PROMISE].error = {
|
|
4084
|
+
data: (options?.serializeError ?? defaultSerializeError)(error),
|
|
4085
|
+
__isServerError: true
|
|
4086
|
+
};
|
|
4770
4087
|
});
|
|
4771
4088
|
return promise;
|
|
4772
4089
|
}
|
|
@@ -4845,10 +4162,7 @@ var BaseRoute = class {
|
|
|
4845
4162
|
const isRoot = !options?.path && !options?.id;
|
|
4846
4163
|
this.parentRoute = this.options.getParentRoute?.();
|
|
4847
4164
|
if (isRoot) this._path = rootRouteId;
|
|
4848
|
-
else if (!this.parentRoute)
|
|
4849
|
-
if (process.env.NODE_ENV !== "production") throw new Error(`Invariant failed: Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);
|
|
4850
|
-
invariant();
|
|
4851
|
-
}
|
|
4165
|
+
else if (!this.parentRoute) throw new Error(`Invariant failed: Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);
|
|
4852
4166
|
let path = isRoot ? rootRouteId : options?.path;
|
|
4853
4167
|
if (path && path !== "/") path = trimPathLeft(path);
|
|
4854
4168
|
const customId = options?.id || path;
|
|
@@ -4926,7 +4240,7 @@ function AwaitInner(props) {
|
|
|
4926
4240
|
}
|
|
4927
4241
|
//#endregion
|
|
4928
4242
|
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.31_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@tanstack/react-router/dist/esm/nonRouteComponentContext.js
|
|
4929
|
-
var nonRouteComponentContext =
|
|
4243
|
+
var nonRouteComponentContext = React$1.createContext(void 0);
|
|
4930
4244
|
function wrapInNonRouteComponentContext(element, component) {
|
|
4931
4245
|
return /* @__PURE__ */ jsx(nonRouteComponentContext.Provider, {
|
|
4932
4246
|
value: component,
|
|
@@ -4959,18 +4273,15 @@ var CatchBoundary = class extends React$1.Component {
|
|
|
4959
4273
|
}
|
|
4960
4274
|
render() {
|
|
4961
4275
|
const error = this.state.error;
|
|
4962
|
-
if (error) {
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
});
|
|
4967
|
-
return process.env.NODE_ENV !== "production" ? wrapInNonRouteComponentContext(element, "errorComponent") : element;
|
|
4968
|
-
}
|
|
4276
|
+
if (error) return wrapInNonRouteComponentContext(React$1.createElement(this.props.errorComponent ?? ErrorComponent, {
|
|
4277
|
+
error,
|
|
4278
|
+
reset: this.reset
|
|
4279
|
+
}), "errorComponent");
|
|
4969
4280
|
return this.props.children;
|
|
4970
4281
|
}
|
|
4971
4282
|
};
|
|
4972
4283
|
function ErrorComponent({ error }) {
|
|
4973
|
-
const [show, setShow] = React$1.useState(
|
|
4284
|
+
const [show, setShow] = React$1.useState(true);
|
|
4974
4285
|
return /* @__PURE__ */ jsxs("div", {
|
|
4975
4286
|
style: {
|
|
4976
4287
|
padding: ".5rem",
|
|
@@ -5078,9 +4389,7 @@ var routerContext = React$1.createContext(null);
|
|
|
5078
4389
|
*/
|
|
5079
4390
|
function useRouter$1(opts) {
|
|
5080
4391
|
const value = React$1.useContext(routerContext);
|
|
5081
|
-
if (
|
|
5082
|
-
if ((opts?.warn ?? true) && !value) console.warn("Warning: useRouter must be used inside a <RouterProvider> component!");
|
|
5083
|
-
}
|
|
4392
|
+
if ((opts?.warn ?? true) && !value) console.warn("Warning: useRouter must be used inside a <RouterProvider> component!");
|
|
5084
4393
|
return value;
|
|
5085
4394
|
}
|
|
5086
4395
|
//#endregion
|
|
@@ -5468,24 +4777,10 @@ function useMatch(opts) {
|
|
|
5468
4777
|
const nearestRouteId = React$1.useContext(opts.from ? dummyMatchContext : matchContext);
|
|
5469
4778
|
const routeId = opts.from ?? nearestRouteId;
|
|
5470
4779
|
const matchStore = router.stores.getMatchStore(routeId);
|
|
5471
|
-
if (isServer ?? router.isServer) {
|
|
5472
|
-
const match = matchStore.get();
|
|
5473
|
-
if (!match) {
|
|
5474
|
-
if (opts.shouldThrow ?? true) {
|
|
5475
|
-
if (process.env.NODE_ENV !== "production") throw new Error(`Invariant failed: Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`);
|
|
5476
|
-
invariant();
|
|
5477
|
-
}
|
|
5478
|
-
return;
|
|
5479
|
-
}
|
|
5480
|
-
return opts.select ? opts.select(match) : match;
|
|
5481
|
-
}
|
|
5482
4780
|
const selector = useStructuralSharing(opts, router);
|
|
5483
4781
|
const matchSelection = useStore(matchStore, (match) => match ? selector(match) : dummyMatch);
|
|
5484
4782
|
if (matchSelection !== dummyMatch) return matchSelection;
|
|
5485
|
-
if (opts.shouldThrow ?? true) {
|
|
5486
|
-
if (process.env.NODE_ENV !== "production") throw new Error(`Invariant failed: Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`);
|
|
5487
|
-
invariant();
|
|
5488
|
-
}
|
|
4783
|
+
if (opts.shouldThrow ?? true) throw new Error(`Invariant failed: Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`);
|
|
5489
4784
|
}
|
|
5490
4785
|
//#endregion
|
|
5491
4786
|
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.31_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@tanstack/react-router/dist/esm/useLoaderData.js
|
|
@@ -5629,7 +4924,7 @@ function compareLinkState(a, b) {
|
|
|
5629
4924
|
function resolveExternalLink(hrefOption, to, protocolAllowlist) {
|
|
5630
4925
|
if (hrefOption?.external) {
|
|
5631
4926
|
if (isDangerousProtocol(hrefOption.href, protocolAllowlist)) {
|
|
5632
|
-
|
|
4927
|
+
console.warn(`Blocked Link with dangerous protocol: ${hrefOption.href}`);
|
|
5633
4928
|
return;
|
|
5634
4929
|
}
|
|
5635
4930
|
return hrefOption.href;
|
|
@@ -5639,7 +4934,7 @@ function resolveExternalLink(hrefOption, to, protocolAllowlist) {
|
|
|
5639
4934
|
try {
|
|
5640
4935
|
new URL(to);
|
|
5641
4936
|
if (isDangerousProtocol(to, protocolAllowlist)) {
|
|
5642
|
-
|
|
4937
|
+
console.warn(`Blocked Link with dangerous protocol: ${to}`);
|
|
5643
4938
|
return;
|
|
5644
4939
|
}
|
|
5645
4940
|
return to;
|
|
@@ -5679,134 +4974,6 @@ function useLinkProps(options, forwardedRef) {
|
|
|
5679
4974
|
const router = useRouter$1();
|
|
5680
4975
|
const innerRef = useForwardedRef(forwardedRef);
|
|
5681
4976
|
const { activeProps, inactiveProps, activeOptions, to, preload: userPreload, preloadDelay: userPreloadDelay, preloadIntentProximity: _preloadIntentProximity, hashScrollIntoView, replace, startTransition, resetScroll, viewTransition, children, target, disabled, style, className, onClick, onBlur, onFocus, onMouseEnter, onMouseLeave, onTouchStart, ignoreBlocker, params: _params, search: _search, hash: _hash, state: _state, mask: _mask, reloadDocument: _reloadDocument, unsafeRelative: _unsafeRelative, from: _from, _fromLocation, ...propsSafeToSpread } = options;
|
|
5682
|
-
if (isServer ?? router.isServer) {
|
|
5683
|
-
const safeInternal = isSafeInternal(to);
|
|
5684
|
-
if (typeof to === "string" && !safeInternal && to.indexOf(":") > -1) try {
|
|
5685
|
-
new URL(to);
|
|
5686
|
-
if (isDangerousProtocol(to, router.protocolAllowlist)) {
|
|
5687
|
-
if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${to}`);
|
|
5688
|
-
return {
|
|
5689
|
-
...propsSafeToSpread,
|
|
5690
|
-
ref: innerRef,
|
|
5691
|
-
href: void 0,
|
|
5692
|
-
...children && { children },
|
|
5693
|
-
...target && { target },
|
|
5694
|
-
...disabled && { disabled },
|
|
5695
|
-
...style && { style },
|
|
5696
|
-
...className && { className }
|
|
5697
|
-
};
|
|
5698
|
-
}
|
|
5699
|
-
return {
|
|
5700
|
-
...propsSafeToSpread,
|
|
5701
|
-
ref: innerRef,
|
|
5702
|
-
href: to,
|
|
5703
|
-
...children && { children },
|
|
5704
|
-
...target && { target },
|
|
5705
|
-
...disabled && { disabled },
|
|
5706
|
-
...style && { style },
|
|
5707
|
-
...className && { className }
|
|
5708
|
-
};
|
|
5709
|
-
} catch {}
|
|
5710
|
-
const next = router.buildLocation({
|
|
5711
|
-
...options,
|
|
5712
|
-
from: options.from
|
|
5713
|
-
});
|
|
5714
|
-
const hrefOption = getHrefOption(next.maskedLocation ? next.maskedLocation.publicHref : next.publicHref, next.maskedLocation ? next.maskedLocation.external : next.external, router.history, disabled);
|
|
5715
|
-
const externalLink = (() => {
|
|
5716
|
-
if (hrefOption?.external) {
|
|
5717
|
-
if (isDangerousProtocol(hrefOption.href, router.protocolAllowlist)) {
|
|
5718
|
-
if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${hrefOption.href}`);
|
|
5719
|
-
return;
|
|
5720
|
-
}
|
|
5721
|
-
return hrefOption.href;
|
|
5722
|
-
}
|
|
5723
|
-
if (safeInternal) return void 0;
|
|
5724
|
-
if (typeof to === "string" && to.indexOf(":") > -1) try {
|
|
5725
|
-
new URL(to);
|
|
5726
|
-
if (isDangerousProtocol(to, router.protocolAllowlist)) {
|
|
5727
|
-
if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${to}`);
|
|
5728
|
-
return;
|
|
5729
|
-
}
|
|
5730
|
-
return to;
|
|
5731
|
-
} catch {}
|
|
5732
|
-
})();
|
|
5733
|
-
const isActive = (() => {
|
|
5734
|
-
if (externalLink) return false;
|
|
5735
|
-
const currentLocation = router.stores.location.get();
|
|
5736
|
-
const exact = activeOptions?.exact ?? false;
|
|
5737
|
-
if (exact) {
|
|
5738
|
-
if (!exactPathTest(currentLocation.pathname, next.pathname, router.basepath)) return false;
|
|
5739
|
-
} else {
|
|
5740
|
-
const currentPathSplit = removeTrailingSlash(currentLocation.pathname, router.basepath);
|
|
5741
|
-
const nextPathSplit = removeTrailingSlash(next.pathname, router.basepath);
|
|
5742
|
-
if (!(currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/"))) return false;
|
|
5743
|
-
}
|
|
5744
|
-
if (activeOptions?.includeSearch ?? true) {
|
|
5745
|
-
if (currentLocation.search !== next.search) {
|
|
5746
|
-
const currentSearchEmpty = !currentLocation.search || typeof currentLocation.search === "object" && !hasKeys(currentLocation.search);
|
|
5747
|
-
const nextSearchEmpty = !next.search || typeof next.search === "object" && !hasKeys(next.search);
|
|
5748
|
-
if (!(currentSearchEmpty && nextSearchEmpty)) {
|
|
5749
|
-
if (!deepEqual(currentLocation.search, next.search, {
|
|
5750
|
-
partial: !exact,
|
|
5751
|
-
ignoreUndefined: !activeOptions?.explicitUndefined
|
|
5752
|
-
})) return false;
|
|
5753
|
-
}
|
|
5754
|
-
}
|
|
5755
|
-
}
|
|
5756
|
-
if (activeOptions?.includeHash) return false;
|
|
5757
|
-
return true;
|
|
5758
|
-
})();
|
|
5759
|
-
if (externalLink) return {
|
|
5760
|
-
...propsSafeToSpread,
|
|
5761
|
-
ref: innerRef,
|
|
5762
|
-
href: externalLink,
|
|
5763
|
-
...children && { children },
|
|
5764
|
-
...target && { target },
|
|
5765
|
-
...disabled && { disabled },
|
|
5766
|
-
...style && { style },
|
|
5767
|
-
...className && { className }
|
|
5768
|
-
};
|
|
5769
|
-
const resolvedActiveProps = isActive ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
|
|
5770
|
-
const resolvedInactiveProps = isActive ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
|
|
5771
|
-
const resolvedStyle = (() => {
|
|
5772
|
-
const baseStyle = style;
|
|
5773
|
-
const activeStyle = resolvedActiveProps.style;
|
|
5774
|
-
const inactiveStyle = resolvedInactiveProps.style;
|
|
5775
|
-
if (!baseStyle && !activeStyle && !inactiveStyle) return;
|
|
5776
|
-
if (baseStyle && !activeStyle && !inactiveStyle) return baseStyle;
|
|
5777
|
-
if (!baseStyle && activeStyle && !inactiveStyle) return activeStyle;
|
|
5778
|
-
if (!baseStyle && !activeStyle && inactiveStyle) return inactiveStyle;
|
|
5779
|
-
return {
|
|
5780
|
-
...baseStyle,
|
|
5781
|
-
...activeStyle,
|
|
5782
|
-
...inactiveStyle
|
|
5783
|
-
};
|
|
5784
|
-
})();
|
|
5785
|
-
const resolvedClassName = (() => {
|
|
5786
|
-
const baseClassName = className;
|
|
5787
|
-
const activeClassName = resolvedActiveProps.className;
|
|
5788
|
-
const inactiveClassName = resolvedInactiveProps.className;
|
|
5789
|
-
if (!baseClassName && !activeClassName && !inactiveClassName) return "";
|
|
5790
|
-
let out = "";
|
|
5791
|
-
if (baseClassName) out = baseClassName;
|
|
5792
|
-
if (activeClassName) out = out ? `${out} ${activeClassName}` : activeClassName;
|
|
5793
|
-
if (inactiveClassName) out = out ? `${out} ${inactiveClassName}` : inactiveClassName;
|
|
5794
|
-
return out;
|
|
5795
|
-
})();
|
|
5796
|
-
return {
|
|
5797
|
-
...propsSafeToSpread,
|
|
5798
|
-
...resolvedActiveProps,
|
|
5799
|
-
...resolvedInactiveProps,
|
|
5800
|
-
href: hrefOption?.href,
|
|
5801
|
-
ref: innerRef,
|
|
5802
|
-
disabled: !!disabled,
|
|
5803
|
-
target,
|
|
5804
|
-
...resolvedStyle && { style: resolvedStyle },
|
|
5805
|
-
...resolvedClassName && { className: resolvedClassName },
|
|
5806
|
-
...disabled && STATIC_DISABLED_PROPS,
|
|
5807
|
-
...isActive && STATIC_ACTIVE_PROPS
|
|
5808
|
-
};
|
|
5809
|
-
}
|
|
5810
4977
|
const isHydrated = useHydrated();
|
|
5811
4978
|
const stableSearch = useValueStable(options.search);
|
|
5812
4979
|
const stableParams = useValueStable(options.params);
|
|
@@ -6183,10 +5350,8 @@ function lazyRouteComponent(importer, exportName) {
|
|
|
6183
5350
|
if (!loadPromise) {
|
|
6184
5351
|
error = void 0;
|
|
6185
5352
|
loadPromise = importer().then((res) => {
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
lazyComp.preload = void 0;
|
|
6189
|
-
}
|
|
5353
|
+
loadPromise = void 0;
|
|
5354
|
+
lazyComp.preload = void 0;
|
|
6190
5355
|
comp = res[exportName ?? "default"];
|
|
6191
5356
|
}).catch((err) => {
|
|
6192
5357
|
loadPromise = void 0;
|
|
@@ -6197,7 +5362,7 @@ function lazyRouteComponent(importer, exportName) {
|
|
|
6197
5362
|
};
|
|
6198
5363
|
const lazyComp = function Lazy(props) {
|
|
6199
5364
|
if (error) {
|
|
6200
|
-
if (isModuleNotFoundError(error) &&
|
|
5365
|
+
if (isModuleNotFoundError(error) && typeof sessionStorage !== "undefined") {
|
|
6201
5366
|
const storageKey = `tanstack_router_reload:${error.message}`;
|
|
6202
5367
|
if (!sessionStorage.getItem(storageKey)) {
|
|
6203
5368
|
sessionStorage.setItem(storageKey, "1");
|
|
@@ -6218,21 +5383,6 @@ function lazyRouteComponent(importer, exportName) {
|
|
|
6218
5383
|
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.31_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@tanstack/react-router/dist/esm/not-found.js
|
|
6219
5384
|
function CatchNotFound(props) {
|
|
6220
5385
|
const router = useRouter$1();
|
|
6221
|
-
if (isServer ?? router.isServer) {
|
|
6222
|
-
const resetKey = `not-found-${router.stores.location.get().pathname}-${router.stores.status.get()}`;
|
|
6223
|
-
return /* @__PURE__ */ jsx(CatchBoundary, {
|
|
6224
|
-
getResetKey: () => resetKey,
|
|
6225
|
-
onCatch: (error, errorInfo) => {
|
|
6226
|
-
if (isNotFound(error)) props.onCatch?.(error, errorInfo);
|
|
6227
|
-
else throw error;
|
|
6228
|
-
},
|
|
6229
|
-
errorComponent: ({ error }) => {
|
|
6230
|
-
if (isNotFound(error)) return props.fallback?.(error);
|
|
6231
|
-
else throw error;
|
|
6232
|
-
},
|
|
6233
|
-
children: props.children
|
|
6234
|
-
});
|
|
6235
|
-
}
|
|
6236
5386
|
const resetKey = `not-found-${useStore(router.stores.location, (location) => location.pathname)}-${useStore(router.stores.status, (status) => status)}`;
|
|
6237
5387
|
return /* @__PURE__ */ jsx(CatchBoundary, {
|
|
6238
5388
|
getResetKey: () => resetKey,
|
|
@@ -6251,19 +5401,6 @@ function DefaultGlobalNotFound() {
|
|
|
6251
5401
|
return /* @__PURE__ */ jsx("p", { children: "Not Found" });
|
|
6252
5402
|
}
|
|
6253
5403
|
//#endregion
|
|
6254
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.31_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@tanstack/react-router/dist/esm/ScriptOnce.js
|
|
6255
|
-
/**
|
|
6256
|
-
* Server-only helper to emit a script tag exactly once during SSR.
|
|
6257
|
-
*/
|
|
6258
|
-
function ScriptOnce({ children }) {
|
|
6259
|
-
const router = useRouter$1();
|
|
6260
|
-
if (!(isServer ?? router.isServer)) return null;
|
|
6261
|
-
return /* @__PURE__ */ jsx("script", {
|
|
6262
|
-
nonce: router.options.ssr?.nonce,
|
|
6263
|
-
dangerouslySetInnerHTML: { __html: children + ";document.currentScript.remove()" }
|
|
6264
|
-
});
|
|
6265
|
-
}
|
|
6266
|
-
//#endregion
|
|
6267
5404
|
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.31_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@tanstack/react-router/dist/esm/SafeFragment.js
|
|
6268
5405
|
function SafeFragment(props) {
|
|
6269
5406
|
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
@@ -6280,60 +5417,23 @@ function SafeFragment(props) {
|
|
|
6280
5417
|
*/
|
|
6281
5418
|
function renderRouteNotFound(router, route, data) {
|
|
6282
5419
|
if (!route.options.notFoundComponent) {
|
|
6283
|
-
if (router.options.defaultNotFoundComponent) {
|
|
6284
|
-
|
|
6285
|
-
return process.env.NODE_ENV !== "production" ? wrapInNonRouteComponentContext(notFoundElement, "notFoundComponent") : notFoundElement;
|
|
6286
|
-
}
|
|
6287
|
-
if (process.env.NODE_ENV !== "production") {
|
|
6288
|
-
if (!route.options.notFoundComponent) console.warn(`Warning: A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`);
|
|
6289
|
-
}
|
|
5420
|
+
if (router.options.defaultNotFoundComponent) return wrapInNonRouteComponentContext(/* @__PURE__ */ jsx(router.options.defaultNotFoundComponent, { ...data }), "notFoundComponent");
|
|
5421
|
+
if (!route.options.notFoundComponent) console.warn(`Warning: A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`);
|
|
6290
5422
|
return /* @__PURE__ */ jsx(DefaultGlobalNotFound, {});
|
|
6291
5423
|
}
|
|
6292
|
-
|
|
6293
|
-
return process.env.NODE_ENV !== "production" ? wrapInNonRouteComponentContext(notFoundElement, "notFoundComponent") : notFoundElement;
|
|
6294
|
-
}
|
|
6295
|
-
//#endregion
|
|
6296
|
-
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/scroll-restoration-inline.js
|
|
6297
|
-
var scroll_restoration_inline_default = "function(a,f){let l;try{l=JSON.parse(sessionStorage.getItem(a)||\"{}\")}catch{return}const n=l?.[f||history.state?.__TSR_key];let c=!1;for(const t in n){const e=n[t],o=e?.scrollX,s=e?.scrollY;if(Number.isFinite(o)&&Number.isFinite(s)){if(t===\"window\")scrollTo(o,s),c=!0;else if(t)try{const r=document.querySelector(t);r&&(r.scrollLeft=o,r.scrollTop=s)}catch{}}}if(c)return;const i=location.hash.slice(1);if(i){const t=history.state?.__hashScrollIntoViewOptions??!0;if(t){const e=document.getElementById(i);e&&e.scrollIntoView(t)}return}scrollTo(0,0)}";
|
|
6298
|
-
//#endregion
|
|
6299
|
-
//#region ../../node_modules/.pnpm/@tanstack+router-core@1.171.26/node_modules/@tanstack/router-core/dist/esm/scroll-restoration-script/server.js
|
|
6300
|
-
const defaultInlineScrollRestorationScript = `(${scroll_restoration_inline_default})(${escapeHtml(JSON.stringify(storageKey))})`;
|
|
6301
|
-
function getScrollRestorationScript(key) {
|
|
6302
|
-
if (key === void 0) return defaultInlineScrollRestorationScript;
|
|
6303
|
-
return `(${scroll_restoration_inline_default})(${escapeHtml(JSON.stringify(storageKey))},${escapeHtml(JSON.stringify(key))})`;
|
|
6304
|
-
}
|
|
6305
|
-
function getScrollRestorationScriptForRouter(router) {
|
|
6306
|
-
if (typeof router.options.scrollRestoration === "function" && !router.options.scrollRestoration({ location: router.latestLocation })) return null;
|
|
6307
|
-
const getKey = router.options.getScrollRestorationKey;
|
|
6308
|
-
if (!getKey) return defaultInlineScrollRestorationScript;
|
|
6309
|
-
const location = router.latestLocation;
|
|
6310
|
-
const userKey = getKey(location);
|
|
6311
|
-
if (userKey === defaultGetScrollRestorationKey(location)) return defaultInlineScrollRestorationScript;
|
|
6312
|
-
return getScrollRestorationScript(userKey);
|
|
6313
|
-
}
|
|
6314
|
-
//#endregion
|
|
6315
|
-
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.31_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@tanstack/react-router/dist/esm/scroll-restoration.js
|
|
6316
|
-
function ScrollRestoration() {
|
|
6317
|
-
const script = getScrollRestorationScriptForRouter(useRouter$1());
|
|
6318
|
-
if (!script) return null;
|
|
6319
|
-
return /* @__PURE__ */ jsx(ScriptOnce, { children: script });
|
|
5424
|
+
return wrapInNonRouteComponentContext(/* @__PURE__ */ jsx(route.options.notFoundComponent, { ...data }), "notFoundComponent");
|
|
6320
5425
|
}
|
|
6321
5426
|
//#endregion
|
|
6322
5427
|
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.31_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@tanstack/react-router/dist/esm/Match.js
|
|
6323
5428
|
function renderPending(router, route) {
|
|
6324
5429
|
const PendingComponent = route?.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
6325
5430
|
if (!PendingComponent) return null;
|
|
6326
|
-
|
|
6327
|
-
return process.env.NODE_ENV !== "production" ? wrapInNonRouteComponentContext(pendingElement, "pendingComponent") : pendingElement;
|
|
5431
|
+
return wrapInNonRouteComponentContext(/* @__PURE__ */ jsx(PendingComponent, {}), "pendingComponent");
|
|
6328
5432
|
}
|
|
6329
5433
|
var outletMatchSelectionEqual = (a, b) => a[0] === b[0] && a[1] === b[1];
|
|
6330
|
-
var canWrapInSuspense = (router, route, ssr) => !route.isRoot || route.options.shellComponent || route.options.wrapInSuspense || ssr === false || ssr === "data-only" || !
|
|
5434
|
+
var canWrapInSuspense = (router, route, ssr) => !route.isRoot || route.options.shellComponent || route.options.wrapInSuspense || ssr === false || ssr === "data-only" || !router.ssr;
|
|
6331
5435
|
var Match = React$1.memo(function MatchImpl({ routeId }) {
|
|
6332
5436
|
const router = useRouter$1();
|
|
6333
|
-
if (isServer ?? router.isServer) return /* @__PURE__ */ jsx(MatchView, {
|
|
6334
|
-
router,
|
|
6335
|
-
match: router.stores.byRoute.get(routeId).get()
|
|
6336
|
-
});
|
|
6337
5437
|
return /* @__PURE__ */ jsx(MatchView, {
|
|
6338
5438
|
router,
|
|
6339
5439
|
match: useStore(router.stores.getMatchStore(routeId), (value) => value)
|
|
@@ -6361,15 +5461,14 @@ function MatchView({ router, match }) {
|
|
|
6361
5461
|
error.routeId ??= match.routeId;
|
|
6362
5462
|
throw error;
|
|
6363
5463
|
}
|
|
6364
|
-
|
|
5464
|
+
console.warn(`Warning: Error in route match: ${match.id}`);
|
|
6365
5465
|
routeOnCatch?.(error, errorInfo);
|
|
6366
5466
|
},
|
|
6367
5467
|
children: /* @__PURE__ */ jsx(ResolvedNotFoundBoundary, {
|
|
6368
5468
|
fallback: (error) => {
|
|
6369
5469
|
error.routeId ??= match.routeId;
|
|
6370
5470
|
if (error.routeId !== match.routeId) throw error;
|
|
6371
|
-
|
|
6372
|
-
return process.env.NODE_ENV !== "production" ? wrapInNonRouteComponentContext(notFoundElement, "notFoundComponent") : notFoundElement;
|
|
5471
|
+
return wrapInNonRouteComponentContext(React$1.createElement(routeNotFoundComponent, error), "notFoundComponent");
|
|
6373
5472
|
},
|
|
6374
5473
|
children: resolvedNoSsr ? /* @__PURE__ */ jsx(ClientOnly, {
|
|
6375
5474
|
fallback: pendingElement,
|
|
@@ -6378,7 +5477,7 @@ function MatchView({ router, match }) {
|
|
|
6378
5477
|
})
|
|
6379
5478
|
})
|
|
6380
5479
|
})
|
|
6381
|
-
}),
|
|
5480
|
+
}), null] });
|
|
6382
5481
|
}
|
|
6383
5482
|
var MatchInner = React$1.memo(function MatchInnerImpl({ match }) {
|
|
6384
5483
|
const router = useRouter$1();
|
|
@@ -6414,17 +5513,7 @@ var MatchInner = React$1.memo(function MatchInnerImpl({ match }) {
|
|
|
6414
5513
|
return renderPending(router, route);
|
|
6415
5514
|
}
|
|
6416
5515
|
if (match.status === "notFound") return renderRouteNotFound(router, route, match.error);
|
|
6417
|
-
if (match.status === "error")
|
|
6418
|
-
if (isServer ?? router.isServer) {
|
|
6419
|
-
const errorElement = /* @__PURE__ */ jsx((route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent, {
|
|
6420
|
-
error: match.error,
|
|
6421
|
-
reset: void 0,
|
|
6422
|
-
info: { componentStack: "" }
|
|
6423
|
-
});
|
|
6424
|
-
return process.env.NODE_ENV !== "production" ? wrapInNonRouteComponentContext(errorElement, "errorComponent") : errorElement;
|
|
6425
|
-
}
|
|
6426
|
-
throw match.error;
|
|
6427
|
-
}
|
|
5516
|
+
if (match.status === "error") throw match.error;
|
|
6428
5517
|
return out;
|
|
6429
5518
|
});
|
|
6430
5519
|
/**
|
|
@@ -6434,7 +5523,7 @@ var MatchInner = React$1.memo(function MatchInnerImpl({ match }) {
|
|
|
6434
5523
|
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent
|
|
6435
5524
|
*/
|
|
6436
5525
|
var Outlet = React$1.memo(function OutletImpl() {
|
|
6437
|
-
|
|
5526
|
+
{
|
|
6438
5527
|
const nonRouteComponent = React$1.useContext(nonRouteComponentContext);
|
|
6439
5528
|
if (nonRouteComponent) console.warn(`Warning: An <Outlet /> was rendered inside a ${nonRouteComponent}. <Outlet /> should only be rendered inside a route component.`);
|
|
6440
5529
|
}
|
|
@@ -6443,14 +5532,7 @@ var Outlet = React$1.memo(function OutletImpl() {
|
|
|
6443
5532
|
let parentGlobalNotFound;
|
|
6444
5533
|
let parentNotFoundError;
|
|
6445
5534
|
let childRouteId;
|
|
6446
|
-
|
|
6447
|
-
const matches = router.stores.matches.get();
|
|
6448
|
-
const parentIndex = matches.findIndex((match) => match.routeId === routeId);
|
|
6449
|
-
const parentMatch = matches[parentIndex];
|
|
6450
|
-
parentGlobalNotFound = !!parentMatch._notFound;
|
|
6451
|
-
parentNotFoundError = parentMatch.error;
|
|
6452
|
-
childRouteId = matches[parentIndex + 1]?.routeId;
|
|
6453
|
-
} else {
|
|
5535
|
+
{
|
|
6454
5536
|
const parentMatchStore = router.stores.getMatchStore(routeId);
|
|
6455
5537
|
[parentGlobalNotFound, parentNotFoundError] = useStore(parentMatchStore, (match) => [!!match._notFound, match.error], outletMatchSelectionEqual);
|
|
6456
5538
|
childRouteId = useStore(router.stores.ids, (ids) => {
|
|
@@ -6476,7 +5558,7 @@ function settleOwner(owner, rendered) {
|
|
|
6476
5558
|
function Transitioner({ t }) {
|
|
6477
5559
|
const router = useRouter$1();
|
|
6478
5560
|
const acknowledgement = router._rendered ??= [];
|
|
6479
|
-
const mounted =
|
|
5561
|
+
const mounted = React$1.useRef(false);
|
|
6480
5562
|
router.startTransition = (fn, expected) => new Promise((resolve) => {
|
|
6481
5563
|
settleOwner(acknowledgement, false);
|
|
6482
5564
|
acknowledgement.push(expected, resolve);
|
|
@@ -6527,8 +5609,8 @@ function Matches() {
|
|
|
6527
5609
|
const router = useRouter$1();
|
|
6528
5610
|
const rootRoute = router.routesById[rootRouteId];
|
|
6529
5611
|
const pendingElement = renderPending(router, rootRoute);
|
|
6530
|
-
const ResolvedSuspense =
|
|
6531
|
-
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5612
|
+
const ResolvedSuspense = router.ssr ? SafeFragment : React$1.Suspense;
|
|
5613
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Transitioner, { t: React$1.useState()[1] }), /* @__PURE__ */ jsx(ResolvedSuspense, {
|
|
6532
5614
|
fallback: pendingElement,
|
|
6533
5615
|
children: /* @__PURE__ */ jsx(MatchesInner, {})
|
|
6534
5616
|
})] });
|
|
@@ -6537,7 +5619,7 @@ function Matches() {
|
|
|
6537
5619
|
function MatchesInner() {
|
|
6538
5620
|
const router = useRouter$1();
|
|
6539
5621
|
const acknowledgement = router._rendered;
|
|
6540
|
-
const matches =
|
|
5622
|
+
const matches = useStore(router.stores.matches, (value) => acknowledgement[0] ?? value);
|
|
6541
5623
|
const match = matches[0];
|
|
6542
5624
|
const routeId = match?.routeId;
|
|
6543
5625
|
useLayoutEffect(() => {
|
|
@@ -6548,10 +5630,10 @@ function MatchesInner() {
|
|
|
6548
5630
|
value: routeId,
|
|
6549
5631
|
children: router.options.disableGlobalCatchBoundary ? matchComponent : /* @__PURE__ */ jsx(CatchBoundary, {
|
|
6550
5632
|
getResetKey: () => match,
|
|
6551
|
-
onCatch:
|
|
5633
|
+
onCatch: (error) => {
|
|
6552
5634
|
console.warn(`Warning: The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`);
|
|
6553
5635
|
console.warn(`Warning: ${error.message || error.toString()}`);
|
|
6554
|
-
}
|
|
5636
|
+
},
|
|
6555
5637
|
children: matchComponent
|
|
6556
5638
|
})
|
|
6557
5639
|
});
|
|
@@ -6559,11 +5641,6 @@ function MatchesInner() {
|
|
|
6559
5641
|
//#endregion
|
|
6560
5642
|
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.31_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@tanstack/react-router/dist/esm/routerStores.js
|
|
6561
5643
|
var getStoreFactory = (opts) => {
|
|
6562
|
-
if (isServer ?? opts.isServer) return {
|
|
6563
|
-
createMutableStore: createNonReactiveMutableStore,
|
|
6564
|
-
createReadonlyStore: createNonReactiveReadonlyStore,
|
|
6565
|
-
batch: (fn) => fn()
|
|
6566
|
-
};
|
|
6567
5644
|
return {
|
|
6568
5645
|
createMutableStore: createAtom,
|
|
6569
5646
|
createReadonlyStore: createAtom,
|
|
@@ -6646,10 +5723,6 @@ function RouterProvider({ router, ...rest }) {
|
|
|
6646
5723
|
function useRouterState(opts) {
|
|
6647
5724
|
const contextRouter = useRouter$1({ warn: opts?.router === void 0 });
|
|
6648
5725
|
const router = opts?.router || contextRouter;
|
|
6649
|
-
if (isServer ?? router.isServer) {
|
|
6650
|
-
const state = router.stores.__store.get();
|
|
6651
|
-
return opts?.select ? opts.select(state) : state;
|
|
6652
|
-
}
|
|
6653
5726
|
return useStore(router.stores.__store, useStructuralSharing(opts, router));
|
|
6654
5727
|
}
|
|
6655
5728
|
//#endregion
|
|
@@ -6667,16 +5740,11 @@ function useRouterState(opts) {
|
|
|
6667
5740
|
*/
|
|
6668
5741
|
function useLocation(opts) {
|
|
6669
5742
|
const router = useRouter$1();
|
|
6670
|
-
if (isServer ?? router.isServer) {
|
|
6671
|
-
const location = router.stores.location.get();
|
|
6672
|
-
return opts?.select ? opts.select(location) : location;
|
|
6673
|
-
}
|
|
6674
5743
|
return useStore(router.stores.location, useStructuralSharing(opts, router));
|
|
6675
5744
|
}
|
|
6676
5745
|
//#endregion
|
|
6677
5746
|
//#region ../../node_modules/.pnpm/@tanstack+react-router@1.170.31_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@tanstack/react-router/dist/esm/Asset.js
|
|
6678
5747
|
var INLINE_CSS_HYDRATION_ATTR = "data-tsr-inline-css";
|
|
6679
|
-
var noopScriptHandler = () => {};
|
|
6680
5748
|
function setScriptAttrs(script, attrs) {
|
|
6681
5749
|
if (!attrs) return;
|
|
6682
5750
|
for (const [key, value] of Object.entries(attrs)) if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) script.setAttribute(key, typeof value === "boolean" ? "" : String(value));
|
|
@@ -6700,7 +5768,7 @@ function Asset(asset) {
|
|
|
6700
5768
|
suppressHydrationWarning: true
|
|
6701
5769
|
});
|
|
6702
5770
|
case "style":
|
|
6703
|
-
if (asset.inlineCss && (process.env.TSS_INLINE_CSS_ENABLED === "true" || process.env.TSS_INLINE_CSS_ENABLED === void 0 &&
|
|
5771
|
+
if (asset.inlineCss && (process.env.TSS_INLINE_CSS_ENABLED === "true" || process.env.TSS_INLINE_CSS_ENABLED === void 0 && false)) return /* @__PURE__ */ jsx(InlineCssStyle, {
|
|
6704
5772
|
attrs,
|
|
6705
5773
|
nonce,
|
|
6706
5774
|
children
|
|
@@ -6734,10 +5802,10 @@ function InlineCssStyle({ attrs, children, nonce }) {
|
|
|
6734
5802
|
});
|
|
6735
5803
|
}
|
|
6736
5804
|
function Script({ attrs, children, preventScriptHoist }) {
|
|
6737
|
-
|
|
5805
|
+
useRouter$1();
|
|
6738
5806
|
const hydrated = useHydrated();
|
|
6739
5807
|
const dataScript = typeof attrs?.type === "string" && attrs.type !== "" && attrs.type !== "text/javascript" && attrs.type !== "module";
|
|
6740
|
-
if (
|
|
5808
|
+
if (attrs?.src && typeof children === "string" && children.trim().length) console.warn("[TanStack Router] <Script> received both `src` and `children`. The `children` content will be ignored. Remove `children` or remove `src`.");
|
|
6741
5809
|
React$1.useEffect(() => {
|
|
6742
5810
|
if (dataScript) return;
|
|
6743
5811
|
if (attrs?.src) {
|
|
@@ -6775,25 +5843,6 @@ function Script({ attrs, children, preventScriptHoist }) {
|
|
|
6775
5843
|
children,
|
|
6776
5844
|
dataScript
|
|
6777
5845
|
]);
|
|
6778
|
-
if (isServer ?? router.isServer) {
|
|
6779
|
-
if (attrs?.src) {
|
|
6780
|
-
if (!preventScriptHoist) return /* @__PURE__ */ jsx("script", {
|
|
6781
|
-
...attrs,
|
|
6782
|
-
suppressHydrationWarning: true
|
|
6783
|
-
});
|
|
6784
|
-
return /* @__PURE__ */ jsx("script", {
|
|
6785
|
-
...attrs,
|
|
6786
|
-
onLoad: noopScriptHandler,
|
|
6787
|
-
suppressHydrationWarning: true
|
|
6788
|
-
});
|
|
6789
|
-
}
|
|
6790
|
-
if (typeof children === "string") return /* @__PURE__ */ jsx("script", {
|
|
6791
|
-
...attrs,
|
|
6792
|
-
dangerouslySetInnerHTML: { __html: children },
|
|
6793
|
-
suppressHydrationWarning: true
|
|
6794
|
-
});
|
|
6795
|
-
return null;
|
|
6796
|
-
}
|
|
6797
5846
|
if (dataScript && typeof children === "string") return /* @__PURE__ */ jsx("script", {
|
|
6798
5847
|
...attrs,
|
|
6799
5848
|
suppressHydrationWarning: true,
|
|
@@ -6940,7 +5989,6 @@ function buildTagsFromMatches(router, nonce, matches, assetCrossOrigin) {
|
|
|
6940
5989
|
var useTags = (assetCrossOrigin) => {
|
|
6941
5990
|
const router = useRouter$1();
|
|
6942
5991
|
const nonce = router.options.ssr?.nonce;
|
|
6943
|
-
if (isServer ?? router.isServer) return buildTagsFromMatches(router, nonce, router.stores.matches.get(), assetCrossOrigin);
|
|
6944
5992
|
const selectTags = React$1.useCallback((matches) => buildTagsFromMatches(router, nonce, matches, assetCrossOrigin), [
|
|
6945
5993
|
assetCrossOrigin,
|
|
6946
5994
|
nonce,
|
|
@@ -7001,14 +6049,9 @@ var Scripts = () => {
|
|
|
7001
6049
|
}
|
|
7002
6050
|
return scripts;
|
|
7003
6051
|
};
|
|
7004
|
-
if (isServer ?? router.isServer) return renderScripts(router, getScripts(router.stores.matches.get()));
|
|
7005
6052
|
return renderScripts(router, useStore(router.stores.matches, getScripts, deepEqual));
|
|
7006
6053
|
};
|
|
7007
6054
|
function renderScripts(router, scripts) {
|
|
7008
|
-
if ((isServer ?? router.isServer) && router.serverSsr) {
|
|
7009
|
-
const serverBufferedScript = router.serverSsr.takeBufferedScripts();
|
|
7010
|
-
if (serverBufferedScript) scripts.unshift(serverBufferedScript);
|
|
7011
|
-
}
|
|
7012
6055
|
return /* @__PURE__ */ jsx(Fragment, { children: scripts.map((asset, i) => /* @__PURE__ */ createElement(Asset, {
|
|
7013
6056
|
...asset,
|
|
7014
6057
|
key: `tsr-scripts-${asset.tag}-${i}`
|
|
@@ -7025,8 +6068,20 @@ function setRouterMeta(router, meta) {
|
|
|
7025
6068
|
function getRouterMeta(router) {
|
|
7026
6069
|
return store.get(router);
|
|
7027
6070
|
}
|
|
6071
|
+
const tags = /* @__PURE__ */ new WeakMap();
|
|
6072
|
+
/** Tag a built route with the route id + locale it came from. Called by {@link createRouter}. */
|
|
6073
|
+
function tagRoute(route, tag) {
|
|
6074
|
+
tags.set(route, tag);
|
|
6075
|
+
}
|
|
6076
|
+
/** The route id + locale a built route came from, or `undefined` for a synthetic route. */
|
|
6077
|
+
function getRouteTag(route) {
|
|
6078
|
+
return route ? tags.get(route) : void 0;
|
|
6079
|
+
}
|
|
7028
6080
|
//#endregion
|
|
7029
6081
|
//#region src/use-router.ts
|
|
6082
|
+
/** The query param the referrer travels in. */
|
|
6083
|
+
const REFERRER = "referrer";
|
|
6084
|
+
const SAME_ORIGIN = "http://same-origin.invalid";
|
|
7030
6085
|
const fillSegment = (seg, params, id) => {
|
|
7031
6086
|
if (seg === "$") return params["*"] ?? "";
|
|
7032
6087
|
if (!seg.startsWith("$")) return seg;
|
|
@@ -7113,53 +6168,66 @@ function routerApi(input) {
|
|
|
7113
6168
|
const { registry, config, mounted, active, activeId, getTanstack } = input;
|
|
7114
6169
|
const toLocale = (l) => l == null ? active : typeof l !== "string" ? l : config.locales.find((x) => x.code === l) ?? Locale$1.new({ languageOrLocale: l });
|
|
7115
6170
|
const path = ({ id, locale, params }) => routePath(registry, config, id, toLocale(locale), params);
|
|
7116
|
-
const
|
|
6171
|
+
const latest = () => getTanstack()?.latestLocation;
|
|
6172
|
+
const withReferrer = (query, referrer) => {
|
|
6173
|
+
const current = referrer ? latest()?.href : void 0;
|
|
6174
|
+
return current === void 0 ? query : {
|
|
6175
|
+
...query,
|
|
6176
|
+
[REFERRER]: current
|
|
6177
|
+
};
|
|
6178
|
+
};
|
|
6179
|
+
const href = ({ id, locale, params, query, hash, referrer }) => path({
|
|
7117
6180
|
id,
|
|
7118
6181
|
locale,
|
|
7119
6182
|
params
|
|
7120
|
-
}) + suffix(query, hash);
|
|
6183
|
+
}) + suffix(withReferrer(query, referrer), hash);
|
|
7121
6184
|
const absolute = ({ baseUrl, ...rest }) => resolveOrigin(config, baseUrl) + href(rest);
|
|
7122
6185
|
const liveRouter = () => {
|
|
7123
6186
|
const t = getTanstack();
|
|
7124
6187
|
if (!t) throw new Error("router: navigation is unavailable in this context (no live router yet).");
|
|
7125
6188
|
return t;
|
|
7126
6189
|
};
|
|
7127
|
-
const navigate = async ({ id, from, params, query, hash, locale, replace, state, target }) => {
|
|
6190
|
+
const navigate = async ({ id, from, params, query, hash, locale, replace, state, target, referrer }) => {
|
|
7128
6191
|
if (target === "_blank") {
|
|
7129
6192
|
if (typeof window !== "undefined") window.open(absolute({
|
|
7130
6193
|
id,
|
|
7131
6194
|
locale,
|
|
7132
6195
|
params,
|
|
7133
6196
|
query,
|
|
7134
|
-
hash
|
|
6197
|
+
hash,
|
|
6198
|
+
referrer
|
|
7135
6199
|
}), "_blank");
|
|
7136
6200
|
return;
|
|
7137
6201
|
}
|
|
6202
|
+
const search = withReferrer(query, referrer);
|
|
7138
6203
|
await liveRouter().navigate({
|
|
7139
6204
|
to: path({
|
|
7140
6205
|
id,
|
|
7141
6206
|
locale,
|
|
7142
6207
|
params
|
|
7143
6208
|
}),
|
|
7144
|
-
search:
|
|
6209
|
+
search: search ? cleanSearch(search) : void 0,
|
|
7145
6210
|
hash,
|
|
7146
6211
|
replace,
|
|
7147
6212
|
state,
|
|
7148
6213
|
from
|
|
7149
6214
|
});
|
|
7150
6215
|
};
|
|
7151
|
-
const buildRedirect = (opts) =>
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
6216
|
+
const buildRedirect = (opts) => {
|
|
6217
|
+
const search = withReferrer(opts.query, opts.referrer);
|
|
6218
|
+
return redirect({
|
|
6219
|
+
to: path({
|
|
6220
|
+
id: opts.id,
|
|
6221
|
+
locale: opts.locale,
|
|
6222
|
+
params: opts.params
|
|
6223
|
+
}),
|
|
6224
|
+
search: search ? cleanSearch(search) : void 0,
|
|
6225
|
+
hash: opts.hash,
|
|
6226
|
+
replace: opts.replace,
|
|
6227
|
+
...opts.statusCode != null ? { statusCode: opts.statusCode } : {},
|
|
6228
|
+
...opts.state ? { state: opts.state } : {}
|
|
6229
|
+
});
|
|
6230
|
+
};
|
|
7163
6231
|
const redirect$1 = (params) => buildRedirect(params);
|
|
7164
6232
|
const notFound$1 = (options) => notFound(options);
|
|
7165
6233
|
const forbidden = (params) => buildRedirect({
|
|
@@ -7170,8 +6238,38 @@ function routerApi(input) {
|
|
|
7170
6238
|
hash: params?.hash,
|
|
7171
6239
|
replace: params?.replace,
|
|
7172
6240
|
statusCode: params?.statusCode ?? 403,
|
|
7173
|
-
state: { status: 403 }
|
|
6241
|
+
state: { status: 403 },
|
|
6242
|
+
referrer: params?.referrer ?? true
|
|
7174
6243
|
});
|
|
6244
|
+
const referrer = (options) => {
|
|
6245
|
+
const raw = options && "from" in options ? options.from : new URLSearchParams(latest()?.searchStr ?? "").get(REFERRER);
|
|
6246
|
+
if (typeof raw !== "string" || !raw.startsWith("/") || /^\/[/\\]/.test(raw)) return void 0;
|
|
6247
|
+
let url;
|
|
6248
|
+
try {
|
|
6249
|
+
url = new URL(raw, SAME_ORIGIN);
|
|
6250
|
+
} catch {
|
|
6251
|
+
return;
|
|
6252
|
+
}
|
|
6253
|
+
if (url.origin !== SAME_ORIGIN) return void 0;
|
|
6254
|
+
const live = getTanstack();
|
|
6255
|
+
if (!live) return void 0;
|
|
6256
|
+
const [, rawParams, foundRoute] = live.getMatchedRoutes(url.pathname);
|
|
6257
|
+
const tag = getRouteTag(foundRoute);
|
|
6258
|
+
if (!tag) return void 0;
|
|
6259
|
+
if (tag.id === activeId || Object.values(config.statusPages).includes(tag.id)) return void 0;
|
|
6260
|
+
const { _splat: _, ...params } = rawParams;
|
|
6261
|
+
url.searchParams.delete(REFERRER);
|
|
6262
|
+
const query = Object.fromEntries(url.searchParams);
|
|
6263
|
+
const hash = url.hash.slice(1);
|
|
6264
|
+
const inActive = availableLocales(registry, config, tag.id).some((l) => l.code === active.code);
|
|
6265
|
+
return {
|
|
6266
|
+
id: tag.id,
|
|
6267
|
+
params,
|
|
6268
|
+
...Object.keys(query).length > 0 ? { query } : {},
|
|
6269
|
+
...hash ? { hash } : {},
|
|
6270
|
+
...inActive ? {} : { locale: tag.locale }
|
|
6271
|
+
};
|
|
6272
|
+
};
|
|
7175
6273
|
return {
|
|
7176
6274
|
locale: active,
|
|
7177
6275
|
routeId: activeId,
|
|
@@ -7189,6 +6287,15 @@ function routerApi(input) {
|
|
|
7189
6287
|
redirect: redirect$1,
|
|
7190
6288
|
notFound: notFound$1,
|
|
7191
6289
|
forbidden,
|
|
6290
|
+
referrer,
|
|
6291
|
+
canGoToReferrer: (options) => referrer(options) !== void 0,
|
|
6292
|
+
goToReferrer: async ({ replace, ...options } = {}) => {
|
|
6293
|
+
const target = referrer(options);
|
|
6294
|
+
if (target) await navigate({
|
|
6295
|
+
...target,
|
|
6296
|
+
replace
|
|
6297
|
+
});
|
|
6298
|
+
},
|
|
7192
6299
|
reload: () => liveRouter().invalidate(),
|
|
7193
6300
|
goBack: async () => {
|
|
7194
6301
|
liveRouter().history.back();
|
|
@@ -7400,6 +6507,10 @@ function createRouter(registry, config) {
|
|
|
7400
6507
|
...userLoader ? { loader: guardLoadPhase(userLoader, apiCtx, locale) } : {},
|
|
7401
6508
|
...head ? { head } : {}
|
|
7402
6509
|
});
|
|
6510
|
+
if (!b.layout) tagRoute(route, {
|
|
6511
|
+
id: b.id,
|
|
6512
|
+
locale
|
|
6513
|
+
});
|
|
7403
6514
|
const children = build(b.id, route);
|
|
7404
6515
|
return children.length ? route.addChildren(children) : route;
|
|
7405
6516
|
});
|