@tanstack/router-core 1.131.38 → 1.131.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +4 -2
- package/dist/cjs/process-route-tree.cjs +139 -0
- package/dist/cjs/process-route-tree.cjs.map +1 -0
- package/dist/cjs/process-route-tree.d.cts +10 -0
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +12 -0
- package/dist/cjs/router.cjs +2 -133
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -22
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/process-route-tree.d.ts +10 -0
- package/dist/esm/process-route-tree.js +139 -0
- package/dist/esm/process-route-tree.js.map +1 -0
- package/dist/esm/route.d.ts +12 -0
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +1 -22
- package/dist/esm/router.js +3 -134
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -3
- package/src/process-route-tree.ts +228 -0
- package/src/route.ts +13 -0
- package/src/router.ts +3 -231
package/dist/cjs/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const path = require("./path.cjs");
|
|
|
8
8
|
const qss = require("./qss.cjs");
|
|
9
9
|
const root = require("./root.cjs");
|
|
10
10
|
const route = require("./route.cjs");
|
|
11
|
+
const processRouteTree = require("./process-route-tree.cjs");
|
|
11
12
|
const router = require("./router.cjs");
|
|
12
13
|
const searchMiddleware = require("./searchMiddleware.cjs");
|
|
13
14
|
const searchParams = require("./searchParams.cjs");
|
|
@@ -39,6 +40,7 @@ exports.rootRouteId = root.rootRouteId;
|
|
|
39
40
|
exports.BaseRootRoute = route.BaseRootRoute;
|
|
40
41
|
exports.BaseRoute = route.BaseRoute;
|
|
41
42
|
exports.BaseRouteApi = route.BaseRouteApi;
|
|
43
|
+
exports.processRouteTree = processRouteTree.processRouteTree;
|
|
42
44
|
exports.PathParamError = router.PathParamError;
|
|
43
45
|
exports.RouterCore = router.RouterCore;
|
|
44
46
|
exports.SearchParamError = router.SearchParamError;
|
|
@@ -47,7 +49,6 @@ exports.getInitialRouterState = router.getInitialRouterState;
|
|
|
47
49
|
exports.getLocationChangeInfo = router.getLocationChangeInfo;
|
|
48
50
|
exports.getMatchedRoutes = router.getMatchedRoutes;
|
|
49
51
|
exports.lazyFn = router.lazyFn;
|
|
50
|
-
exports.processRouteTree = router.processRouteTree;
|
|
51
52
|
exports.retainSearchParams = searchMiddleware.retainSearchParams;
|
|
52
53
|
exports.stripSearchParams = searchMiddleware.stripSearchParams;
|
|
53
54
|
exports.defaultParseSearch = searchParams.defaultParseSearch;
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -17,8 +17,10 @@ export { rootRouteId } from './root.cjs';
|
|
|
17
17
|
export type { RootRouteId } from './root.cjs';
|
|
18
18
|
export { BaseRoute, BaseRouteApi, BaseRootRoute } from './route.cjs';
|
|
19
19
|
export type { AnyPathParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, SearchFilter, SearchMiddlewareContext, SearchMiddleware, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, InferAllParams, InferAllContext, MetaDescriptor, RouteLinkEntry, SearchValidator, AnySearchValidator, DefaultSearchValidator, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, ResolveParams, ParseParamsFn, StringifyParamsFn, ParamsOptions, UpdatableStaticRouteOption, ContextReturnType, ContextAsyncReturnType, ResolveRouteContext, ResolveLoaderData, RoutePrefix, TrimPath, TrimPathLeft, TrimPathRight, ResolveSearchSchemaFnInput, ResolveSearchSchemaInput, ResolveSearchSchemaFn, ResolveSearchSchema, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, ResolveAllContext, BeforeLoadContextParameter, RouteContextParameter, ResolveAllParamsFromParent, AnyRoute, Route, RouteTypes, FullSearchSchemaOption, RemountDepsOptions, MakeRemountDepsOptionsUnion, ResolveFullPath, AnyRouteWithContext, RouteOptions, FileBaseRouteOptions, BaseRouteOptions, UpdatableRouteOptions, RouteLoaderFn, LoaderFnContext, RouteContextFn, BeforeLoadFn, ContextOptions, RouteContextOptions, BeforeLoadContextOptions, RootRouteOptions, RootRouteOptionsExtensions, UpdatableRouteOptionsExtensions, RouteConstraints, RouteTypesById, RouteMask, RouteExtensions, RouteLazyFn, RouteAddChildrenFn, RouteAddFileChildrenFn, RouteAddFileTypesFn, ResolveOptionalParams, ResolveRequiredParams, RootRoute, } from './route.cjs';
|
|
20
|
-
export {
|
|
21
|
-
export type {
|
|
20
|
+
export { processRouteTree } from './process-route-tree.cjs';
|
|
21
|
+
export type { ProcessRouteTreeResult } from './process-route-tree.cjs';
|
|
22
|
+
export { defaultSerializeError, getLocationChangeInfo, RouterCore, lazyFn, SearchParamError, PathParamError, getInitialRouterState, getMatchedRoutes, } from './router.cjs';
|
|
23
|
+
export type { ViewTransitionOptions, TrailingSlashOption, Register, AnyRouter, AnyRouterWithContext, RegisteredRouter, RouterState, BuildNextOptions, RouterListener, RouterEvent, ListenerFn, RouterEvents, MatchRoutesOpts, RouterOptionsExtensions, DefaultRemountDepsFn, PreloadRouteFn, MatchRouteFn, RouterContextOptions, RouterOptions, RouterConstructorOptions, UpdateFn, ParseLocationFn, InvalidateFn, ControllablePromise, InjectedHtmlEntry, EmitFn, LoadFn, GetMatchFn, SubscribeFn, UpdateMatchFn, CommitLocationFn, GetMatchRoutesFn, MatchRoutesFn, StartTransitionFn, LoadRouteChunkFn, ClearCacheFn, CreateRouterFn, } from './router.cjs';
|
|
22
24
|
export type { MatchLocation, CommitLocationOptions, NavigateFn, BuildLocationFn, } from './RouterProvider.cjs';
|
|
23
25
|
export { retainSearchParams, stripSearchParams } from './searchMiddleware.cjs';
|
|
24
26
|
export { defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, } from './searchParams.cjs';
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const invariant = require("tiny-invariant");
|
|
4
|
+
const path = require("./path.cjs");
|
|
5
|
+
const REQUIRED_PARAM_BASE_SCORE = 0.5;
|
|
6
|
+
const OPTIONAL_PARAM_BASE_SCORE = 0.4;
|
|
7
|
+
const WILDCARD_PARAM_BASE_SCORE = 0.25;
|
|
8
|
+
const BOTH_PRESENCE_BASE_SCORE = 0.05;
|
|
9
|
+
const PREFIX_PRESENCE_BASE_SCORE = 0.02;
|
|
10
|
+
const SUFFIX_PRESENCE_BASE_SCORE = 0.01;
|
|
11
|
+
const PREFIX_LENGTH_SCORE_MULTIPLIER = 2e-4;
|
|
12
|
+
const SUFFIX_LENGTH_SCORE_MULTIPLIER = 1e-4;
|
|
13
|
+
function handleParam(segment, baseScore) {
|
|
14
|
+
if (segment.prefixSegment && segment.suffixSegment) {
|
|
15
|
+
return baseScore + BOTH_PRESENCE_BASE_SCORE + PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length + SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length;
|
|
16
|
+
}
|
|
17
|
+
if (segment.prefixSegment) {
|
|
18
|
+
return baseScore + PREFIX_PRESENCE_BASE_SCORE + PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length;
|
|
19
|
+
}
|
|
20
|
+
if (segment.suffixSegment) {
|
|
21
|
+
return baseScore + SUFFIX_PRESENCE_BASE_SCORE + SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length;
|
|
22
|
+
}
|
|
23
|
+
return baseScore;
|
|
24
|
+
}
|
|
25
|
+
function sortRoutes(routes) {
|
|
26
|
+
const scoredRoutes = [];
|
|
27
|
+
routes.forEach((d, i) => {
|
|
28
|
+
var _a;
|
|
29
|
+
if (d.isRoot || !d.path) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const trimmed = path.trimPathLeft(d.fullPath);
|
|
33
|
+
let parsed = path.parsePathname(trimmed);
|
|
34
|
+
let skip = 0;
|
|
35
|
+
while (parsed.length > skip + 1 && ((_a = parsed[skip]) == null ? void 0 : _a.value) === "/") {
|
|
36
|
+
skip++;
|
|
37
|
+
}
|
|
38
|
+
if (skip > 0) parsed = parsed.slice(skip);
|
|
39
|
+
let optionalParamCount = 0;
|
|
40
|
+
let hasStaticAfter = false;
|
|
41
|
+
const scores = parsed.map((segment, index) => {
|
|
42
|
+
if (segment.value === "/") {
|
|
43
|
+
return 0.75;
|
|
44
|
+
}
|
|
45
|
+
let baseScore = void 0;
|
|
46
|
+
if (segment.type === path.SEGMENT_TYPE_PARAM) {
|
|
47
|
+
baseScore = REQUIRED_PARAM_BASE_SCORE;
|
|
48
|
+
} else if (segment.type === path.SEGMENT_TYPE_OPTIONAL_PARAM) {
|
|
49
|
+
baseScore = OPTIONAL_PARAM_BASE_SCORE;
|
|
50
|
+
optionalParamCount++;
|
|
51
|
+
} else if (segment.type === path.SEGMENT_TYPE_WILDCARD) {
|
|
52
|
+
baseScore = WILDCARD_PARAM_BASE_SCORE;
|
|
53
|
+
}
|
|
54
|
+
if (baseScore) {
|
|
55
|
+
for (let i2 = index + 1; i2 < parsed.length; i2++) {
|
|
56
|
+
const nextSegment = parsed[i2];
|
|
57
|
+
if (nextSegment.type === path.SEGMENT_TYPE_PATHNAME && nextSegment.value !== "/") {
|
|
58
|
+
hasStaticAfter = true;
|
|
59
|
+
return handleParam(segment, baseScore + 0.2);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return handleParam(segment, baseScore);
|
|
63
|
+
}
|
|
64
|
+
return 1;
|
|
65
|
+
});
|
|
66
|
+
scoredRoutes.push({
|
|
67
|
+
child: d,
|
|
68
|
+
trimmed,
|
|
69
|
+
parsed,
|
|
70
|
+
index: i,
|
|
71
|
+
scores,
|
|
72
|
+
optionalParamCount,
|
|
73
|
+
hasStaticAfter
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
const flatRoutes = scoredRoutes.sort((a, b) => {
|
|
77
|
+
const minLength = Math.min(a.scores.length, b.scores.length);
|
|
78
|
+
for (let i = 0; i < minLength; i++) {
|
|
79
|
+
if (a.scores[i] !== b.scores[i]) {
|
|
80
|
+
return b.scores[i] - a.scores[i];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (a.scores.length !== b.scores.length) {
|
|
84
|
+
if (a.optionalParamCount !== b.optionalParamCount) {
|
|
85
|
+
if (a.hasStaticAfter === b.hasStaticAfter) {
|
|
86
|
+
return a.optionalParamCount - b.optionalParamCount;
|
|
87
|
+
} else if (a.hasStaticAfter && !b.hasStaticAfter) {
|
|
88
|
+
return -1;
|
|
89
|
+
} else if (!a.hasStaticAfter && b.hasStaticAfter) {
|
|
90
|
+
return 1;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return b.scores.length - a.scores.length;
|
|
94
|
+
}
|
|
95
|
+
for (let i = 0; i < minLength; i++) {
|
|
96
|
+
if (a.parsed[i].value !== b.parsed[i].value) {
|
|
97
|
+
return a.parsed[i].value > b.parsed[i].value ? 1 : -1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return a.index - b.index;
|
|
101
|
+
}).map((d, i) => {
|
|
102
|
+
d.child.rank = i;
|
|
103
|
+
return d.child;
|
|
104
|
+
});
|
|
105
|
+
return flatRoutes;
|
|
106
|
+
}
|
|
107
|
+
function processRouteTree({
|
|
108
|
+
routeTree,
|
|
109
|
+
initRoute
|
|
110
|
+
}) {
|
|
111
|
+
const routesById = {};
|
|
112
|
+
const routesByPath = {};
|
|
113
|
+
const recurseRoutes = (childRoutes) => {
|
|
114
|
+
childRoutes.forEach((childRoute, i) => {
|
|
115
|
+
initRoute == null ? void 0 : initRoute(childRoute, i);
|
|
116
|
+
const existingRoute = routesById[childRoute.id];
|
|
117
|
+
invariant(
|
|
118
|
+
!existingRoute,
|
|
119
|
+
`Duplicate routes found with id: ${String(childRoute.id)}`
|
|
120
|
+
);
|
|
121
|
+
routesById[childRoute.id] = childRoute;
|
|
122
|
+
if (!childRoute.isRoot && childRoute.path) {
|
|
123
|
+
const trimmedFullPath = path.trimPathRight(childRoute.fullPath);
|
|
124
|
+
if (!routesByPath[trimmedFullPath] || childRoute.fullPath.endsWith("/")) {
|
|
125
|
+
routesByPath[trimmedFullPath] = childRoute;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const children = childRoute.children;
|
|
129
|
+
if (children == null ? void 0 : children.length) {
|
|
130
|
+
recurseRoutes(children);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
recurseRoutes([routeTree]);
|
|
135
|
+
const flatRoutes = sortRoutes(Object.values(routesById));
|
|
136
|
+
return { routesById, routesByPath, flatRoutes };
|
|
137
|
+
}
|
|
138
|
+
exports.processRouteTree = processRouteTree;
|
|
139
|
+
//# sourceMappingURL=process-route-tree.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-route-tree.cjs","sources":["../../src/process-route-tree.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport {\n SEGMENT_TYPE_OPTIONAL_PARAM,\n SEGMENT_TYPE_PARAM,\n SEGMENT_TYPE_PATHNAME,\n SEGMENT_TYPE_WILDCARD,\n parsePathname,\n trimPathLeft,\n trimPathRight,\n} from './path'\nimport type { Segment } from './path'\nimport type { RouteLike } from './route'\n\nconst REQUIRED_PARAM_BASE_SCORE = 0.5\nconst OPTIONAL_PARAM_BASE_SCORE = 0.4\nconst WILDCARD_PARAM_BASE_SCORE = 0.25\nconst BOTH_PRESENCE_BASE_SCORE = 0.05\nconst PREFIX_PRESENCE_BASE_SCORE = 0.02\nconst SUFFIX_PRESENCE_BASE_SCORE = 0.01\nconst PREFIX_LENGTH_SCORE_MULTIPLIER = 0.0002\nconst SUFFIX_LENGTH_SCORE_MULTIPLIER = 0.0001\n\nfunction handleParam(segment: Segment, baseScore: number) {\n if (segment.prefixSegment && segment.suffixSegment) {\n return (\n baseScore +\n BOTH_PRESENCE_BASE_SCORE +\n PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length +\n SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length\n )\n }\n\n if (segment.prefixSegment) {\n return (\n baseScore +\n PREFIX_PRESENCE_BASE_SCORE +\n PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length\n )\n }\n\n if (segment.suffixSegment) {\n return (\n baseScore +\n SUFFIX_PRESENCE_BASE_SCORE +\n SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length\n )\n }\n\n return baseScore\n}\n\nfunction sortRoutes<TRouteLike extends RouteLike>(\n routes: ReadonlyArray<TRouteLike>,\n): Array<TRouteLike> {\n const scoredRoutes: Array<{\n child: TRouteLike\n trimmed: string\n parsed: ReadonlyArray<Segment>\n index: number\n scores: Array<number>\n hasStaticAfter: boolean\n optionalParamCount: number\n }> = []\n\n routes.forEach((d, i) => {\n if (d.isRoot || !d.path) {\n return\n }\n\n const trimmed = trimPathLeft(d.fullPath)\n let parsed = parsePathname(trimmed)\n\n // Removes the leading slash if it is not the only remaining segment\n let skip = 0\n while (parsed.length > skip + 1 && parsed[skip]?.value === '/') {\n skip++\n }\n if (skip > 0) parsed = parsed.slice(skip)\n\n let optionalParamCount = 0\n let hasStaticAfter = false\n const scores = parsed.map((segment, index) => {\n if (segment.value === '/') {\n return 0.75\n }\n\n let baseScore: number | undefined = undefined\n if (segment.type === SEGMENT_TYPE_PARAM) {\n baseScore = REQUIRED_PARAM_BASE_SCORE\n } else if (segment.type === SEGMENT_TYPE_OPTIONAL_PARAM) {\n baseScore = OPTIONAL_PARAM_BASE_SCORE\n optionalParamCount++\n } else if (segment.type === SEGMENT_TYPE_WILDCARD) {\n baseScore = WILDCARD_PARAM_BASE_SCORE\n }\n\n if (baseScore) {\n // if there is any static segment (that is not an index) after a required / optional param,\n // we will boost this param so it ranks higher than a required/optional param without a static segment after it\n // JUST FOR SORTING, NOT FOR MATCHING\n for (let i = index + 1; i < parsed.length; i++) {\n const nextSegment = parsed[i]!\n if (\n nextSegment.type === SEGMENT_TYPE_PATHNAME &&\n nextSegment.value !== '/'\n ) {\n hasStaticAfter = true\n return handleParam(segment, baseScore + 0.2)\n }\n }\n\n return handleParam(segment, baseScore)\n }\n\n return 1\n })\n\n scoredRoutes.push({\n child: d,\n trimmed,\n parsed,\n index: i,\n scores,\n optionalParamCount,\n hasStaticAfter,\n })\n })\n\n const flatRoutes = scoredRoutes\n .sort((a, b) => {\n const minLength = Math.min(a.scores.length, b.scores.length)\n\n // Sort by segment-by-segment score comparison ONLY for the common prefix\n for (let i = 0; i < minLength; i++) {\n if (a.scores[i] !== b.scores[i]) {\n return b.scores[i]! - a.scores[i]!\n }\n }\n\n // If all common segments have equal scores, then consider length and specificity\n if (a.scores.length !== b.scores.length) {\n // If different number of optional parameters, fewer optional parameters wins (more specific)\n // only if both or none of the routes has static segments after the params\n if (a.optionalParamCount !== b.optionalParamCount) {\n if (a.hasStaticAfter === b.hasStaticAfter) {\n return a.optionalParamCount - b.optionalParamCount\n } else if (a.hasStaticAfter && !b.hasStaticAfter) {\n return -1\n } else if (!a.hasStaticAfter && b.hasStaticAfter) {\n return 1\n }\n }\n\n // If same number of optional parameters, longer path wins (for static segments)\n return b.scores.length - a.scores.length\n }\n\n // Sort by min available parsed value for alphabetical ordering\n for (let i = 0; i < minLength; i++) {\n if (a.parsed[i]!.value !== b.parsed[i]!.value) {\n return a.parsed[i]!.value > b.parsed[i]!.value ? 1 : -1\n }\n }\n\n // Sort by original index\n return a.index - b.index\n })\n .map((d, i) => {\n d.child.rank = i\n return d.child\n })\n\n return flatRoutes\n}\n\nexport type ProcessRouteTreeResult<TRouteLike extends RouteLike> = {\n routesById: Record<string, TRouteLike>\n routesByPath: Record<string, TRouteLike>\n flatRoutes: Array<TRouteLike>\n}\n\nexport function processRouteTree<TRouteLike extends RouteLike>({\n routeTree,\n initRoute,\n}: {\n routeTree: TRouteLike\n initRoute?: (route: TRouteLike, index: number) => void\n}): ProcessRouteTreeResult<TRouteLike> {\n const routesById = {} as Record<string, TRouteLike>\n const routesByPath = {} as Record<string, TRouteLike>\n\n const recurseRoutes = (childRoutes: Array<TRouteLike>) => {\n childRoutes.forEach((childRoute, i) => {\n initRoute?.(childRoute, i)\n\n const existingRoute = routesById[childRoute.id]\n\n invariant(\n !existingRoute,\n `Duplicate routes found with id: ${String(childRoute.id)}`,\n )\n\n routesById[childRoute.id] = childRoute\n\n if (!childRoute.isRoot && childRoute.path) {\n const trimmedFullPath = trimPathRight(childRoute.fullPath)\n if (\n !routesByPath[trimmedFullPath] ||\n childRoute.fullPath.endsWith('/')\n ) {\n routesByPath[trimmedFullPath] = childRoute\n }\n }\n\n const children = childRoute.children as Array<TRouteLike>\n\n if (children?.length) {\n recurseRoutes(children)\n }\n })\n }\n\n recurseRoutes([routeTree])\n\n const flatRoutes = sortRoutes(Object.values(routesById))\n\n return { routesById, routesByPath, flatRoutes }\n}\n"],"names":["trimPathLeft","parsePathname","SEGMENT_TYPE_PARAM","SEGMENT_TYPE_OPTIONAL_PARAM","SEGMENT_TYPE_WILDCARD","i","SEGMENT_TYPE_PATHNAME","trimPathRight"],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RouteLike } from './route.cjs';
|
|
2
|
+
export type ProcessRouteTreeResult<TRouteLike extends RouteLike> = {
|
|
3
|
+
routesById: Record<string, TRouteLike>;
|
|
4
|
+
routesByPath: Record<string, TRouteLike>;
|
|
5
|
+
flatRoutes: Array<TRouteLike>;
|
|
6
|
+
};
|
|
7
|
+
export declare function processRouteTree<TRouteLike extends RouteLike>({ routeTree, initRoute, }: {
|
|
8
|
+
routeTree: TRouteLike;
|
|
9
|
+
initRoute?: (route: TRouteLike, index: number) => void;
|
|
10
|
+
}): ProcessRouteTreeResult<TRouteLike>;
|
package/dist/cjs/route.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.cjs","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport { joinPaths, trimPathLeft } from './path'\nimport { notFound } from './not-found'\nimport { rootRouteId } from './root'\nimport type { LazyRoute } from './fileRoute'\nimport type { NotFoundError } from './not-found'\nimport type { NavigateOptions, ParsePathParams } from './link'\nimport type { ParsedLocation } from './location'\nimport type {\n AnyRouteMatch,\n MakePreValidationErrorHandlingRouteMatchUnion,\n MakeRouteMatchFromRoute,\n MakeRouteMatchUnion,\n RouteMatch,\n} from './Matches'\nimport type { RootRouteId } from './root'\nimport type { ParseRoute, RouteById, RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { BuildLocationFn, NavigateFn } from './RouterProvider'\nimport type {\n Assign,\n Awaitable,\n Constrain,\n Expand,\n IntersectAssign,\n LooseAsyncReturnType,\n LooseReturnType,\n NoInfer,\n} from './utils'\nimport type {\n AnySchema,\n AnyStandardSchemaValidator,\n AnyValidator,\n AnyValidatorAdapter,\n AnyValidatorObj,\n DefaultValidator,\n ResolveSearchValidatorInput,\n ResolveValidatorOutput,\n StandardSchemaValidator,\n ValidatorAdapter,\n ValidatorFn,\n ValidatorObj,\n} from './validators'\n\nexport type AnyPathParams = {}\n\nexport type SearchSchemaInput = {\n __TSearchSchemaInput__: 'TSearchSchemaInput'\n}\n\nexport type AnyContext = {}\n\nexport interface RouteContext {}\n\nexport type PreloadableObj = { preload?: () => Promise<void> }\n\nexport type RoutePathOptions<TCustomId, TPath> =\n | {\n path: TPath\n }\n | {\n id: TCustomId\n }\n\nexport interface StaticDataRouteOption {}\n\nexport type RoutePathOptionsIntersection<TCustomId, TPath> = {\n path: TPath\n id: TCustomId\n}\n\nexport type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult\n\nexport type SearchMiddlewareContext<TSearchSchema> = {\n search: TSearchSchema\n next: (newSearch: TSearchSchema) => TSearchSchema\n}\n\nexport type SearchMiddleware<TSearchSchema> = (\n ctx: SearchMiddlewareContext<TSearchSchema>,\n) => TSearchSchema\n\nexport type ResolveId<\n TParentRoute,\n TCustomId extends string,\n TPath extends string,\n> = TParentRoute extends { id: infer TParentId extends string }\n ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>\n : RootRouteId\n\nexport type InferFullSearchSchema<TRoute> = TRoute extends {\n types: {\n fullSearchSchema: infer TFullSearchSchema\n }\n}\n ? TFullSearchSchema\n : {}\n\nexport type InferFullSearchSchemaInput<TRoute> = TRoute extends {\n types: {\n fullSearchSchemaInput: infer TFullSearchSchemaInput\n }\n}\n ? TFullSearchSchemaInput\n : {}\n\nexport type InferAllParams<TRoute> = TRoute extends {\n types: {\n allParams: infer TAllParams\n }\n}\n ? TAllParams\n : {}\n\nexport type InferAllContext<TRoute> = unknown extends TRoute\n ? TRoute\n : TRoute extends {\n types: {\n allContext: infer TAllContext\n }\n }\n ? TAllContext\n : {}\n\nexport type ResolveSearchSchemaFnInput<TSearchValidator> =\n TSearchValidator extends (input: infer TSearchSchemaInput) => any\n ? TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : ResolveSearchSchemaFn<TSearchValidator>\n : AnySchema\n\nexport type ResolveSearchSchemaInput<TSearchValidator> =\n TSearchValidator extends AnyStandardSchemaValidator\n ? NonNullable<TSearchValidator['~standard']['types']>['input']\n : TSearchValidator extends AnyValidatorAdapter\n ? TSearchValidator['types']['input']\n : TSearchValidator extends AnyValidatorObj\n ? ResolveSearchSchemaFnInput<TSearchValidator['parse']>\n : ResolveSearchSchemaFnInput<TSearchValidator>\n\nexport type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (\n ...args: any\n) => infer TSearchSchema\n ? TSearchSchema\n : AnySchema\n\nexport type ResolveSearchSchema<TSearchValidator> =\n unknown extends TSearchValidator\n ? TSearchValidator\n : TSearchValidator extends AnyStandardSchemaValidator\n ? NonNullable<TSearchValidator['~standard']['types']>['output']\n : TSearchValidator extends AnyValidatorAdapter\n ? TSearchValidator['types']['output']\n : TSearchValidator extends AnyValidatorObj\n ? ResolveSearchSchemaFn<TSearchValidator['parse']>\n : ResolveSearchSchemaFn<TSearchValidator>\n\nexport type ResolveRequiredParams<TPath extends string, T> = {\n [K in ParsePathParams<TPath>['required']]: T\n}\n\nexport type ResolveOptionalParams<TPath extends string, T> = {\n [K in ParsePathParams<TPath>['optional']]?: T\n}\n\nexport type ResolveParams<\n TPath extends string,\n T = string,\n> = ResolveRequiredParams<TPath, T> & ResolveOptionalParams<TPath, T>\n\nexport type ParseParamsFn<in out TPath extends string, in out TParams> = (\n rawParams: Expand<ResolveParams<TPath>>,\n) => TParams extends ResolveParams<TPath, any>\n ? TParams\n : ResolveParams<TPath, any>\n\nexport type StringifyParamsFn<in out TPath extends string, in out TParams> = (\n params: TParams,\n) => ResolveParams<TPath>\n\nexport type ParamsOptions<in out TPath extends string, in out TParams> = {\n params?: {\n parse?: ParseParamsFn<TPath, TParams>\n stringify?: StringifyParamsFn<TPath, TParams>\n }\n\n /** \n @deprecated Use params.parse instead\n */\n parseParams?: ParseParamsFn<TPath, TParams>\n\n /** \n @deprecated Use params.stringify instead\n */\n stringifyParams?: StringifyParamsFn<TPath, TParams>\n}\n\ninterface RequiredStaticDataRouteOption {\n staticData: StaticDataRouteOption\n}\n\ninterface OptionalStaticDataRouteOption {\n staticData?: StaticDataRouteOption\n}\n\nexport type UpdatableStaticRouteOption = {} extends StaticDataRouteOption\n ? OptionalStaticDataRouteOption\n : RequiredStaticDataRouteOption\n\nexport type MetaDescriptor =\n | { charSet: 'utf-8' }\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { httpEquiv: string; content: string }\n | { 'script:ld+json': LdJsonObject }\n | { tagName: 'meta' | 'link'; [name: string]: string }\n | Record<string, unknown>\n\ntype LdJsonObject = { [Key in string]: LdJsonValue } & {\n [Key in string]?: LdJsonValue | undefined\n}\ntype LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>\ntype LdJsonPrimitive = string | number | boolean | null\ntype LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray\n\nexport type RouteLinkEntry = {}\n\nexport type SearchValidator<TInput, TOutput> =\n | ValidatorObj<TInput, TOutput>\n | ValidatorFn<TInput, TOutput>\n | ValidatorAdapter<TInput, TOutput>\n | StandardSchemaValidator<TInput, TOutput>\n | undefined\n\nexport type AnySearchValidator = SearchValidator<any, any>\n\nexport type DefaultSearchValidator = SearchValidator<\n Record<string, unknown>,\n AnySchema\n>\n\nexport type RoutePrefix<\n TPrefix extends string,\n TPath extends string,\n> = string extends TPath\n ? RootRouteId\n : TPath extends string\n ? TPrefix extends RootRouteId\n ? TPath extends '/'\n ? '/'\n : `/${TrimPath<TPath>}`\n : `${TPrefix}/${TPath}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`\n : never\n\nexport type TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\nexport type TrimPathLeft<T extends string> =\n T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\n\nexport type TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport type ContextReturnType<TContextFn> = unknown extends TContextFn\n ? TContextFn\n : LooseReturnType<TContextFn> extends never\n ? AnyContext\n : LooseReturnType<TContextFn>\n\nexport type ContextAsyncReturnType<TContextFn> = unknown extends TContextFn\n ? TContextFn\n : LooseAsyncReturnType<TContextFn> extends never\n ? AnyContext\n : LooseAsyncReturnType<TContextFn>\n\nexport type ResolveRouteContext<TRouteContextFn, TBeforeLoadFn> = Assign<\n ContextReturnType<TRouteContextFn>,\n ContextAsyncReturnType<TBeforeLoadFn>\n>\n\nexport type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn\n ? TLoaderFn\n : LooseAsyncReturnType<TLoaderFn> extends never\n ? undefined\n : LooseAsyncReturnType<TLoaderFn>\n\nexport type ResolveFullSearchSchema<\n TParentRoute extends AnyRoute,\n TSearchValidator,\n> = unknown extends TParentRoute\n ? ResolveValidatorOutput<TSearchValidator>\n : IntersectAssign<\n InferFullSearchSchema<TParentRoute>,\n ResolveValidatorOutput<TSearchValidator>\n >\n\nexport type ResolveFullSearchSchemaInput<\n TParentRoute extends AnyRoute,\n TSearchValidator,\n> = IntersectAssign<\n InferFullSearchSchemaInput<TParentRoute>,\n ResolveSearchValidatorInput<TSearchValidator>\n>\n\nexport type ResolveAllParamsFromParent<\n TParentRoute extends AnyRoute,\n TParams,\n> = Assign<InferAllParams<TParentRoute>, TParams>\n\nexport type RouteContextParameter<\n TParentRoute extends AnyRoute,\n TRouterContext,\n> = unknown extends TParentRoute\n ? TRouterContext\n : Assign<TRouterContext, InferAllContext<TParentRoute>>\n\nexport type BeforeLoadContextParameter<\n TParentRoute extends AnyRoute,\n TRouterContext,\n TRouteContextFn,\n> = Assign<\n RouteContextParameter<TParentRoute, TRouterContext>,\n ContextReturnType<TRouteContextFn>\n>\n\nexport type ResolveAllContext<\n TParentRoute extends AnyRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n> = Assign<\n BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>,\n ContextAsyncReturnType<TBeforeLoadFn>\n>\nexport interface FullSearchSchemaOption<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n> {\n search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n}\n\nexport interface RemountDepsOptions<\n in out TRouteId,\n in out TFullSearchSchema,\n in out TAllParams,\n in out TLoaderDeps,\n> {\n routeId: TRouteId\n search: TFullSearchSchema\n params: TAllParams\n loaderDeps: TLoaderDeps\n}\n\nexport type MakeRemountDepsOptionsUnion<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n> =\n ParseRoute<TRouteTree> extends infer TRoute extends AnyRoute\n ? TRoute extends any\n ? RemountDepsOptions<\n TRoute['id'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps']\n >\n : never\n : never\n\nexport interface RouteTypes<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps,\n in out TLoaderFn,\n in out TChildren,\n in out TFileRouteTypes,\n> {\n parentRoute: TParentRoute\n path: TPath\n to: TrimPathRight<TFullPath>\n fullPath: TFullPath\n customId: TCustomId\n id: TId\n searchSchema: ResolveValidatorOutput<TSearchValidator>\n searchSchemaInput: ResolveSearchValidatorInput<TSearchValidator>\n searchValidator: TSearchValidator\n fullSearchSchema: ResolveFullSearchSchema<TParentRoute, TSearchValidator>\n fullSearchSchemaInput: ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchValidator\n >\n params: TParams\n allParams: ResolveAllParamsFromParent<TParentRoute, TParams>\n routerContext: TRouterContext\n routeContext: ResolveRouteContext<TRouteContextFn, TBeforeLoadFn>\n routeContextFn: TRouteContextFn\n beforeLoadFn: TBeforeLoadFn\n allContext: ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n children: TChildren\n loaderData: ResolveLoaderData<TLoaderFn>\n loaderDeps: TLoaderDeps\n fileRouteTypes: TFileRouteTypes\n}\n\nexport type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\nexport interface RouteExtensions<in out TId, in out TFullPath> {\n id: TId\n fullPath: TFullPath\n}\n\nexport type RouteLazyFn<TRoute extends AnyRoute> = (\n lazyFn: () => Promise<LazyRoute<TRoute>>,\n) => TRoute\n\nexport type RouteAddChildrenFn<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps extends Record<string, any>,\n in out TLoaderFn,\n in out TFileRouteTypes,\n> = <const TNewChildren>(\n children: Constrain<\n TNewChildren,\n ReadonlyArray<AnyRoute> | Record<string, AnyRoute>\n >,\n) => Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n>\n\nexport type RouteAddFileChildrenFn<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps extends Record<string, any>,\n in out TLoaderFn,\n in out TFileRouteTypes,\n> = <const TNewChildren>(\n children: TNewChildren,\n) => Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n>\n\nexport type RouteAddFileTypesFn<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TFullPath extends string,\n TCustomId extends string,\n TId extends string,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps extends Record<string, any>,\n TLoaderFn,\n TChildren,\n> = <TNewFileRouteTypes>() => Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TNewFileRouteTypes\n>\n\nexport interface Route<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps extends Record<string, any>,\n in out TLoaderFn,\n in out TChildren,\n in out TFileRouteTypes,\n> extends RouteExtensions<TId, TFullPath> {\n path: TPath\n parentRoute: TParentRoute\n children?: TChildren\n types: RouteTypes<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n isRoot: TParentRoute extends AnyRoute ? true : false\n /** @internal */\n _componentsPromise?: Promise<void>\n /** @internal */\n _componentsLoaded?: boolean\n lazyFn?: () => Promise<\n LazyRoute<\n Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n >\n >\n /** @internal */\n _lazyPromise?: Promise<void>\n /** @internal */\n _lazyLoaded?: boolean\n rank: number\n to: TrimPathRight<TFullPath>\n init: (opts: { originalIndex: number }) => void\n update: (\n options: UpdatableRouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => this\n lazy: RouteLazyFn<\n Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n >\n addChildren: RouteAddChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n >\n _addFileChildren: RouteAddFileChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n >\n _addFileTypes: RouteAddFileTypesFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n >\n}\n\nexport type AnyRoute = Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n>\n\nexport type AnyRouteWithContext<TContext> = AnyRoute & {\n types: { allContext: TContext }\n}\n\nexport type RouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TId extends string = string,\n TCustomId extends string = string,\n TFullPath extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = AnyPathParams,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = BaseRouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n> &\n UpdatableRouteOptions<\n NoInfer<TParentRoute>,\n NoInfer<TCustomId>,\n NoInfer<TFullPath>,\n NoInfer<TParams>,\n NoInfer<TSearchValidator>,\n NoInfer<TLoaderFn>,\n NoInfer<TLoaderDeps>,\n NoInfer<TRouterContext>,\n NoInfer<TRouteContextFn>,\n NoInfer<TBeforeLoadFn>\n >\n\nexport type RouteContextFn<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n> = (\n ctx: RouteContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext\n >,\n) => any\n\nexport type BeforeLoadFn<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n> = (\n ctx: BeforeLoadContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn\n >,\n) => any\n\nexport type FileBaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TId extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TRemountDepsFn = AnyContext,\n> = ParamsOptions<TPath, TParams> & {\n validateSearch?: Constrain<TSearchValidator, AnyValidator, DefaultValidator>\n\n shouldReload?:\n | boolean\n | ((\n match: LoaderFnContext<\n TParentRoute,\n TId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => any)\n\n context?: Constrain<\n TRouteContextFn,\n (\n ctx: RouteContextOptions<\n TParentRoute,\n TParams,\n TRouterContext,\n TLoaderDeps\n >,\n ) => any\n >\n\n ssr?:\n | undefined\n | boolean\n | 'data-only'\n | ((\n ctx: SsrContextOptions<TParentRoute, TSearchValidator, TParams>,\n ) => Awaitable<undefined | boolean | 'data-only'>)\n\n // This async function is called before a route is loaded.\n // If an error is thrown here, the route's loader will not be called.\n // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.\n // If thrown during a preload event, the error will be logged to the console.\n beforeLoad?: Constrain<\n TBeforeLoadFn,\n (\n ctx: BeforeLoadContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn\n >,\n ) => any\n >\n\n loaderDeps?: (\n opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>,\n ) => TLoaderDeps\n\n remountDeps?: Constrain<\n TRemountDepsFn,\n (\n opt: RemountDepsOptions<\n TId,\n FullSearchSchemaOption<TParentRoute, TSearchValidator>,\n Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,\n TLoaderDeps\n >,\n ) => any\n >\n\n loader?: Constrain<\n TLoaderFn,\n (\n ctx: LoaderFnContext<\n TParentRoute,\n TId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => any\n >\n}\n\nexport type BaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TId extends string = string,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = RoutePathOptions<TCustomId, TPath> &\n FileBaseRouteOptions<\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > & {\n getParentRoute: () => TParentRoute\n }\n\nexport interface ContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TParams,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n location: ParsedLocation\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: NavigateFn\n buildLocation: BuildLocationFn\n cause: 'preload' | 'enter' | 'stay'\n matches: Array<MakeRouteMatchUnion>\n}\n\nexport interface RouteContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TParams,\n in out TRouterContext,\n in out TLoaderDeps,\n> extends ContextOptions<TParentRoute, TParams> {\n deps: TLoaderDeps\n context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>\n}\n\nexport interface SsrContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n> {\n params:\n | {\n status: 'success'\n value: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n }\n | { status: 'error'; error: unknown }\n search:\n | {\n status: 'success'\n value: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n }\n | { status: 'error'; error: unknown }\n location: ParsedLocation\n matches: Array<MakePreValidationErrorHandlingRouteMatchUnion>\n}\n\nexport interface BeforeLoadContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n> extends ContextOptions<TParentRoute, TParams>,\n FullSearchSchemaOption<TParentRoute, TSearchValidator> {\n context: Expand<\n BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>\n >\n}\n\ntype AssetFnContextOptions<\n in out TRouteId,\n in out TFullPath,\n in out TParentRoute extends AnyRoute,\n in out TParams,\n in out TSearchValidator,\n in out TLoaderFn,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps,\n> = {\n matches: Array<\n RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >\n >\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >\n params: ResolveAllParamsFromParent<TParentRoute, TParams>\n loaderData?: ResolveLoaderData<TLoaderFn>\n}\n\nexport interface DefaultUpdatableRouteOptionsExtensions {\n component?: unknown\n errorComponent?: unknown\n notFoundComponent?: unknown\n pendingComponent?: unknown\n}\n\nexport interface UpdatableRouteOptionsExtensions\n extends DefaultUpdatableRouteOptionsExtensions {}\n\nexport interface UpdatableRouteOptions<\n in out TParentRoute extends AnyRoute,\n in out TRouteId,\n in out TFullPath,\n in out TParams,\n in out TSearchValidator,\n in out TLoaderFn,\n in out TLoaderDeps,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n> extends UpdatableStaticRouteOption,\n UpdatableRouteOptionsExtensions {\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n // If true, this route will be forcefully wrapped in a suspense boundary\n wrapInSuspense?: boolean\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n\n pendingMs?: number\n pendingMinMs?: number\n staleTime?: number\n gcTime?: number\n preload?: boolean\n preloadStaleTime?: number\n preloadGcTime?: number\n search?: {\n middlewares?: Array<\n SearchMiddleware<\n ResolveFullSearchSchemaInput<TParentRoute, TSearchValidator>\n >\n >\n }\n /** \n @deprecated Use search.middlewares instead\n */\n preSearchFilters?: Array<\n SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n >\n /** \n @deprecated Use search.middlewares instead\n */\n postSearchFilters?: Array<\n SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n >\n onCatch?: (error: Error) => void\n onError?: (err: any) => void\n // These functions are called as route matches are loaded, stick around and leave the active\n // matches\n onEnter?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n onStay?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n onLeave?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n headers?: (\n ctx: AssetFnContextOptions<\n TRouteId,\n TFullPath,\n TParentRoute,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps\n >,\n ) => Awaitable<Record<string, string>>\n head?: (\n ctx: AssetFnContextOptions<\n TRouteId,\n TFullPath,\n TParentRoute,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps\n >,\n ) => Awaitable<{\n links?: AnyRouteMatch['links']\n scripts?: AnyRouteMatch['headScripts']\n meta?: AnyRouteMatch['meta']\n styles?: AnyRouteMatch['styles']\n }>\n scripts?: (\n ctx: AssetFnContextOptions<\n TRouteId,\n TFullPath,\n TParentRoute,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps\n >,\n ) => Awaitable<AnyRouteMatch['scripts']>\n codeSplitGroupings?: Array<\n Array<\n | 'loader'\n | 'component'\n | 'pendingComponent'\n | 'notFoundComponent'\n | 'errorComponent'\n >\n >\n}\n\nexport type RouteLoaderFn<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TId extends string = string,\n in out TParams = {},\n in out TLoaderDeps = {},\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n> = (\n match: LoaderFnContext<\n TParentRoute,\n TId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n) => any\n\nexport interface LoaderFnContext<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TId extends string = string,\n in out TParams = {},\n in out TLoaderDeps = {},\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n deps: TLoaderDeps\n context: Expand<\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\n location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void> | void\n // root route does not have a parent match\n parentMatchPromise: TId extends RootRouteId\n ? never\n : Promise<MakeRouteMatchFromRoute<TParentRoute>>\n cause: 'preload' | 'enter' | 'stay'\n route: AnyRoute\n}\n\nexport interface DefaultRootRouteOptionsExtensions {\n shellComponent?: unknown\n}\n\nexport interface RootRouteOptionsExtensions\n extends DefaultRootRouteOptionsExtensions {}\n\nexport type RootRouteOptions<\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n> = Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId, // TId\n RootRouteId, // TCustomId\n '', // TFullPath\n '', // TPath\n TSearchValidator,\n {}, // TParams\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n> &\n RootRouteOptionsExtensions\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySchema\n TFullSearchSchema: AnySchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport type RouteTypesById<TRouter extends AnyRouter, TId> = RouteById<\n TRouter['routeTree'],\n TId\n>['types']\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\n}\n\n/**\n * @deprecated Use `ErrorComponentProps` instead.\n */\nexport type ErrorRouteProps = {\n error: unknown\n info?: { componentStack: string }\n reset: () => void\n}\n\nexport type ErrorComponentProps<TError = Error> = {\n error: TError\n info?: { componentStack: string }\n reset: () => void\n}\nexport type NotFoundRouteProps = {\n // TODO: Make sure this is `| null | undefined` (this is for global not-founds)\n data: unknown\n}\n\nexport class BaseRoute<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TPath extends string = '/',\n in out TFullPath extends string = ResolveFullPath<TParentRoute, TPath>,\n in out TCustomId extends string = string,\n in out TId extends string = ResolveId<TParentRoute, TCustomId, TPath>,\n in out TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> {\n isRoot: TParentRoute extends AnyRoute ? true : false\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n\n // The following properties are set up in this.init()\n parentRoute!: TParentRoute\n private _id!: TId\n private _path!: TPath\n private _fullPath!: TFullPath\n private _to!: TrimPathRight<TFullPath>\n\n public get to() {\n return this._to\n }\n\n public get id() {\n return this._id\n }\n\n public get path() {\n return this._path\n }\n\n public get fullPath() {\n return this._fullPath\n }\n\n // Optional\n children?: TChildren\n originalIndex?: number\n rank!: number\n lazyFn?: () => Promise<\n LazyRoute<\n Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n >\n >\n /** @internal */\n _lazyPromise?: Promise<void>\n /** @internal */\n _componentsPromise?: Promise<void>\n\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) {\n this.options = (options as any) || {}\n this.isRoot = !options?.getParentRoute as any\n\n if ((options as any)?.id && (options as any)?.path) {\n throw new Error(`Route cannot have both an 'id' and a 'path' option.`)\n }\n }\n\n types!: RouteTypes<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n\n init = (opts: { originalIndex: number }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\n this.parentRoute = this.options.getParentRoute?.()\n\n if (isRoot) {\n this._path = rootRouteId as TPath\n } else if (!this.parentRoute) {\n invariant(\n false,\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options?.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPathLeft(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this._path = path as TPath\n this._id = id as TId\n this._fullPath = fullPath as TFullPath\n this._to = fullPath as TrimPathRight<TFullPath>\n }\n\n clone = (other: typeof this) => {\n this._path = other._path\n this._id = other._id\n this._fullPath = other._fullPath\n this._to = other._to\n this.options.getParentRoute = other.options.getParentRoute\n this.children = other.children\n }\n\n addChildren: RouteAddChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n return this._addFileChildren(children) as any\n }\n\n _addFileChildren: RouteAddFileChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n if (Array.isArray(children)) {\n this.children = children as TChildren\n }\n\n if (typeof children === 'object' && children !== null) {\n this.children = Object.values(children) as TChildren\n }\n\n return this as any\n }\n\n _addFileTypes: RouteAddFileTypesFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n > = () => {\n return this as any\n }\n\n updateLoader = <TNewLoaderFn>(options: {\n loader: Constrain<\n TNewLoaderFn,\n RouteLoaderFn<\n TParentRoute,\n TCustomId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\n }) => {\n Object.assign(this.options, options)\n return this as unknown as BaseRoute<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TNewLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy: RouteLazyFn<\n Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n > = (lazyFn) => {\n this.lazyFn = lazyFn\n return this\n }\n}\n\nexport class BaseRouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {\n id: TId\n\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\nexport interface RootRoute<\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchValidator, // TSearchValidator\n {}, // TParams\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren, // TChildren\n TFileRouteTypes\n > {}\n\nexport class BaseRootRoute<\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> extends BaseRoute<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchValidator, // TSearchValidator\n {}, // TParams\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren, // TChildren\n TFileRouteTypes\n> {\n constructor(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) {\n super(options as any)\n }\n}\n\n//\n"],"names":["options","rootRouteId","path","trimPathLeft","joinPaths","notFound"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"route.cjs","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport { joinPaths, trimPathLeft } from './path'\nimport { notFound } from './not-found'\nimport { rootRouteId } from './root'\nimport type { LazyRoute } from './fileRoute'\nimport type { NotFoundError } from './not-found'\nimport type { NavigateOptions, ParsePathParams } from './link'\nimport type { ParsedLocation } from './location'\nimport type {\n AnyRouteMatch,\n MakePreValidationErrorHandlingRouteMatchUnion,\n MakeRouteMatchFromRoute,\n MakeRouteMatchUnion,\n RouteMatch,\n} from './Matches'\nimport type { RootRouteId } from './root'\nimport type { ParseRoute, RouteById, RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { BuildLocationFn, NavigateFn } from './RouterProvider'\nimport type {\n Assign,\n Awaitable,\n Constrain,\n Expand,\n IntersectAssign,\n LooseAsyncReturnType,\n LooseReturnType,\n NoInfer,\n} from './utils'\nimport type {\n AnySchema,\n AnyStandardSchemaValidator,\n AnyValidator,\n AnyValidatorAdapter,\n AnyValidatorObj,\n DefaultValidator,\n ResolveSearchValidatorInput,\n ResolveValidatorOutput,\n StandardSchemaValidator,\n ValidatorAdapter,\n ValidatorFn,\n ValidatorObj,\n} from './validators'\n\nexport type AnyPathParams = {}\n\nexport type SearchSchemaInput = {\n __TSearchSchemaInput__: 'TSearchSchemaInput'\n}\n\nexport type AnyContext = {}\n\nexport interface RouteContext {}\n\nexport type PreloadableObj = { preload?: () => Promise<void> }\n\nexport type RoutePathOptions<TCustomId, TPath> =\n | {\n path: TPath\n }\n | {\n id: TCustomId\n }\n\nexport interface StaticDataRouteOption {}\n\nexport type RoutePathOptionsIntersection<TCustomId, TPath> = {\n path: TPath\n id: TCustomId\n}\n\nexport type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult\n\nexport type SearchMiddlewareContext<TSearchSchema> = {\n search: TSearchSchema\n next: (newSearch: TSearchSchema) => TSearchSchema\n}\n\nexport type SearchMiddleware<TSearchSchema> = (\n ctx: SearchMiddlewareContext<TSearchSchema>,\n) => TSearchSchema\n\nexport type ResolveId<\n TParentRoute,\n TCustomId extends string,\n TPath extends string,\n> = TParentRoute extends { id: infer TParentId extends string }\n ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>\n : RootRouteId\n\nexport type InferFullSearchSchema<TRoute> = TRoute extends {\n types: {\n fullSearchSchema: infer TFullSearchSchema\n }\n}\n ? TFullSearchSchema\n : {}\n\nexport type InferFullSearchSchemaInput<TRoute> = TRoute extends {\n types: {\n fullSearchSchemaInput: infer TFullSearchSchemaInput\n }\n}\n ? TFullSearchSchemaInput\n : {}\n\nexport type InferAllParams<TRoute> = TRoute extends {\n types: {\n allParams: infer TAllParams\n }\n}\n ? TAllParams\n : {}\n\nexport type InferAllContext<TRoute> = unknown extends TRoute\n ? TRoute\n : TRoute extends {\n types: {\n allContext: infer TAllContext\n }\n }\n ? TAllContext\n : {}\n\nexport type ResolveSearchSchemaFnInput<TSearchValidator> =\n TSearchValidator extends (input: infer TSearchSchemaInput) => any\n ? TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : ResolveSearchSchemaFn<TSearchValidator>\n : AnySchema\n\nexport type ResolveSearchSchemaInput<TSearchValidator> =\n TSearchValidator extends AnyStandardSchemaValidator\n ? NonNullable<TSearchValidator['~standard']['types']>['input']\n : TSearchValidator extends AnyValidatorAdapter\n ? TSearchValidator['types']['input']\n : TSearchValidator extends AnyValidatorObj\n ? ResolveSearchSchemaFnInput<TSearchValidator['parse']>\n : ResolveSearchSchemaFnInput<TSearchValidator>\n\nexport type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (\n ...args: any\n) => infer TSearchSchema\n ? TSearchSchema\n : AnySchema\n\nexport type ResolveSearchSchema<TSearchValidator> =\n unknown extends TSearchValidator\n ? TSearchValidator\n : TSearchValidator extends AnyStandardSchemaValidator\n ? NonNullable<TSearchValidator['~standard']['types']>['output']\n : TSearchValidator extends AnyValidatorAdapter\n ? TSearchValidator['types']['output']\n : TSearchValidator extends AnyValidatorObj\n ? ResolveSearchSchemaFn<TSearchValidator['parse']>\n : ResolveSearchSchemaFn<TSearchValidator>\n\nexport type ResolveRequiredParams<TPath extends string, T> = {\n [K in ParsePathParams<TPath>['required']]: T\n}\n\nexport type ResolveOptionalParams<TPath extends string, T> = {\n [K in ParsePathParams<TPath>['optional']]?: T\n}\n\nexport type ResolveParams<\n TPath extends string,\n T = string,\n> = ResolveRequiredParams<TPath, T> & ResolveOptionalParams<TPath, T>\n\nexport type ParseParamsFn<in out TPath extends string, in out TParams> = (\n rawParams: Expand<ResolveParams<TPath>>,\n) => TParams extends ResolveParams<TPath, any>\n ? TParams\n : ResolveParams<TPath, any>\n\nexport type StringifyParamsFn<in out TPath extends string, in out TParams> = (\n params: TParams,\n) => ResolveParams<TPath>\n\nexport type ParamsOptions<in out TPath extends string, in out TParams> = {\n params?: {\n parse?: ParseParamsFn<TPath, TParams>\n stringify?: StringifyParamsFn<TPath, TParams>\n }\n\n /** \n @deprecated Use params.parse instead\n */\n parseParams?: ParseParamsFn<TPath, TParams>\n\n /** \n @deprecated Use params.stringify instead\n */\n stringifyParams?: StringifyParamsFn<TPath, TParams>\n}\n\ninterface RequiredStaticDataRouteOption {\n staticData: StaticDataRouteOption\n}\n\ninterface OptionalStaticDataRouteOption {\n staticData?: StaticDataRouteOption\n}\n\nexport type UpdatableStaticRouteOption = {} extends StaticDataRouteOption\n ? OptionalStaticDataRouteOption\n : RequiredStaticDataRouteOption\n\nexport type MetaDescriptor =\n | { charSet: 'utf-8' }\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { httpEquiv: string; content: string }\n | { 'script:ld+json': LdJsonObject }\n | { tagName: 'meta' | 'link'; [name: string]: string }\n | Record<string, unknown>\n\ntype LdJsonObject = { [Key in string]: LdJsonValue } & {\n [Key in string]?: LdJsonValue | undefined\n}\ntype LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>\ntype LdJsonPrimitive = string | number | boolean | null\ntype LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray\n\nexport type RouteLinkEntry = {}\n\nexport type SearchValidator<TInput, TOutput> =\n | ValidatorObj<TInput, TOutput>\n | ValidatorFn<TInput, TOutput>\n | ValidatorAdapter<TInput, TOutput>\n | StandardSchemaValidator<TInput, TOutput>\n | undefined\n\nexport type AnySearchValidator = SearchValidator<any, any>\n\nexport type DefaultSearchValidator = SearchValidator<\n Record<string, unknown>,\n AnySchema\n>\n\nexport type RoutePrefix<\n TPrefix extends string,\n TPath extends string,\n> = string extends TPath\n ? RootRouteId\n : TPath extends string\n ? TPrefix extends RootRouteId\n ? TPath extends '/'\n ? '/'\n : `/${TrimPath<TPath>}`\n : `${TPrefix}/${TPath}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`\n : never\n\nexport type TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\nexport type TrimPathLeft<T extends string> =\n T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\n\nexport type TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport type ContextReturnType<TContextFn> = unknown extends TContextFn\n ? TContextFn\n : LooseReturnType<TContextFn> extends never\n ? AnyContext\n : LooseReturnType<TContextFn>\n\nexport type ContextAsyncReturnType<TContextFn> = unknown extends TContextFn\n ? TContextFn\n : LooseAsyncReturnType<TContextFn> extends never\n ? AnyContext\n : LooseAsyncReturnType<TContextFn>\n\nexport type ResolveRouteContext<TRouteContextFn, TBeforeLoadFn> = Assign<\n ContextReturnType<TRouteContextFn>,\n ContextAsyncReturnType<TBeforeLoadFn>\n>\n\nexport type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn\n ? TLoaderFn\n : LooseAsyncReturnType<TLoaderFn> extends never\n ? undefined\n : LooseAsyncReturnType<TLoaderFn>\n\nexport type ResolveFullSearchSchema<\n TParentRoute extends AnyRoute,\n TSearchValidator,\n> = unknown extends TParentRoute\n ? ResolveValidatorOutput<TSearchValidator>\n : IntersectAssign<\n InferFullSearchSchema<TParentRoute>,\n ResolveValidatorOutput<TSearchValidator>\n >\n\nexport type ResolveFullSearchSchemaInput<\n TParentRoute extends AnyRoute,\n TSearchValidator,\n> = IntersectAssign<\n InferFullSearchSchemaInput<TParentRoute>,\n ResolveSearchValidatorInput<TSearchValidator>\n>\n\nexport type ResolveAllParamsFromParent<\n TParentRoute extends AnyRoute,\n TParams,\n> = Assign<InferAllParams<TParentRoute>, TParams>\n\nexport type RouteContextParameter<\n TParentRoute extends AnyRoute,\n TRouterContext,\n> = unknown extends TParentRoute\n ? TRouterContext\n : Assign<TRouterContext, InferAllContext<TParentRoute>>\n\nexport type BeforeLoadContextParameter<\n TParentRoute extends AnyRoute,\n TRouterContext,\n TRouteContextFn,\n> = Assign<\n RouteContextParameter<TParentRoute, TRouterContext>,\n ContextReturnType<TRouteContextFn>\n>\n\nexport type ResolveAllContext<\n TParentRoute extends AnyRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n> = Assign<\n BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>,\n ContextAsyncReturnType<TBeforeLoadFn>\n>\nexport interface FullSearchSchemaOption<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n> {\n search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n}\n\nexport interface RemountDepsOptions<\n in out TRouteId,\n in out TFullSearchSchema,\n in out TAllParams,\n in out TLoaderDeps,\n> {\n routeId: TRouteId\n search: TFullSearchSchema\n params: TAllParams\n loaderDeps: TLoaderDeps\n}\n\nexport type MakeRemountDepsOptionsUnion<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n> =\n ParseRoute<TRouteTree> extends infer TRoute extends AnyRoute\n ? TRoute extends any\n ? RemountDepsOptions<\n TRoute['id'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps']\n >\n : never\n : never\n\nexport interface RouteTypes<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps,\n in out TLoaderFn,\n in out TChildren,\n in out TFileRouteTypes,\n> {\n parentRoute: TParentRoute\n path: TPath\n to: TrimPathRight<TFullPath>\n fullPath: TFullPath\n customId: TCustomId\n id: TId\n searchSchema: ResolveValidatorOutput<TSearchValidator>\n searchSchemaInput: ResolveSearchValidatorInput<TSearchValidator>\n searchValidator: TSearchValidator\n fullSearchSchema: ResolveFullSearchSchema<TParentRoute, TSearchValidator>\n fullSearchSchemaInput: ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchValidator\n >\n params: TParams\n allParams: ResolveAllParamsFromParent<TParentRoute, TParams>\n routerContext: TRouterContext\n routeContext: ResolveRouteContext<TRouteContextFn, TBeforeLoadFn>\n routeContextFn: TRouteContextFn\n beforeLoadFn: TBeforeLoadFn\n allContext: ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n children: TChildren\n loaderData: ResolveLoaderData<TLoaderFn>\n loaderDeps: TLoaderDeps\n fileRouteTypes: TFileRouteTypes\n}\n\nexport type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\nexport interface RouteExtensions<in out TId, in out TFullPath> {\n id: TId\n fullPath: TFullPath\n}\n\nexport type RouteLazyFn<TRoute extends AnyRoute> = (\n lazyFn: () => Promise<LazyRoute<TRoute>>,\n) => TRoute\n\nexport type RouteAddChildrenFn<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps extends Record<string, any>,\n in out TLoaderFn,\n in out TFileRouteTypes,\n> = <const TNewChildren>(\n children: Constrain<\n TNewChildren,\n ReadonlyArray<AnyRoute> | Record<string, AnyRoute>\n >,\n) => Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n>\n\nexport type RouteAddFileChildrenFn<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps extends Record<string, any>,\n in out TLoaderFn,\n in out TFileRouteTypes,\n> = <const TNewChildren>(\n children: TNewChildren,\n) => Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n>\n\nexport type RouteAddFileTypesFn<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TFullPath extends string,\n TCustomId extends string,\n TId extends string,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps extends Record<string, any>,\n TLoaderFn,\n TChildren,\n> = <TNewFileRouteTypes>() => Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TNewFileRouteTypes\n>\n\nexport interface Route<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps extends Record<string, any>,\n in out TLoaderFn,\n in out TChildren,\n in out TFileRouteTypes,\n> extends RouteExtensions<TId, TFullPath> {\n path: TPath\n parentRoute: TParentRoute\n children?: TChildren\n types: RouteTypes<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n isRoot: TParentRoute extends AnyRoute ? true : false\n /** @internal */\n _componentsPromise?: Promise<void>\n /** @internal */\n _componentsLoaded?: boolean\n lazyFn?: () => Promise<\n LazyRoute<\n Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n >\n >\n /** @internal */\n _lazyPromise?: Promise<void>\n /** @internal */\n _lazyLoaded?: boolean\n rank: number\n to: TrimPathRight<TFullPath>\n init: (opts: { originalIndex: number }) => void\n update: (\n options: UpdatableRouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => this\n lazy: RouteLazyFn<\n Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n >\n addChildren: RouteAddChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n >\n _addFileChildren: RouteAddFileChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n >\n _addFileTypes: RouteAddFileTypesFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n >\n}\n\nexport type AnyRoute = Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n>\n\nexport type AnyRouteWithContext<TContext> = AnyRoute & {\n types: { allContext: TContext }\n}\n\nexport type RouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TId extends string = string,\n TCustomId extends string = string,\n TFullPath extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = AnyPathParams,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = BaseRouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n> &\n UpdatableRouteOptions<\n NoInfer<TParentRoute>,\n NoInfer<TCustomId>,\n NoInfer<TFullPath>,\n NoInfer<TParams>,\n NoInfer<TSearchValidator>,\n NoInfer<TLoaderFn>,\n NoInfer<TLoaderDeps>,\n NoInfer<TRouterContext>,\n NoInfer<TRouteContextFn>,\n NoInfer<TBeforeLoadFn>\n >\n\nexport type RouteContextFn<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n> = (\n ctx: RouteContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext\n >,\n) => any\n\nexport type BeforeLoadFn<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n> = (\n ctx: BeforeLoadContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn\n >,\n) => any\n\nexport type FileBaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TId extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TRemountDepsFn = AnyContext,\n> = ParamsOptions<TPath, TParams> & {\n validateSearch?: Constrain<TSearchValidator, AnyValidator, DefaultValidator>\n\n shouldReload?:\n | boolean\n | ((\n match: LoaderFnContext<\n TParentRoute,\n TId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => any)\n\n context?: Constrain<\n TRouteContextFn,\n (\n ctx: RouteContextOptions<\n TParentRoute,\n TParams,\n TRouterContext,\n TLoaderDeps\n >,\n ) => any\n >\n\n ssr?:\n | undefined\n | boolean\n | 'data-only'\n | ((\n ctx: SsrContextOptions<TParentRoute, TSearchValidator, TParams>,\n ) => Awaitable<undefined | boolean | 'data-only'>)\n\n // This async function is called before a route is loaded.\n // If an error is thrown here, the route's loader will not be called.\n // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.\n // If thrown during a preload event, the error will be logged to the console.\n beforeLoad?: Constrain<\n TBeforeLoadFn,\n (\n ctx: BeforeLoadContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn\n >,\n ) => any\n >\n\n loaderDeps?: (\n opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>,\n ) => TLoaderDeps\n\n remountDeps?: Constrain<\n TRemountDepsFn,\n (\n opt: RemountDepsOptions<\n TId,\n FullSearchSchemaOption<TParentRoute, TSearchValidator>,\n Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,\n TLoaderDeps\n >,\n ) => any\n >\n\n loader?: Constrain<\n TLoaderFn,\n (\n ctx: LoaderFnContext<\n TParentRoute,\n TId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => any\n >\n}\n\nexport type BaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TId extends string = string,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = RoutePathOptions<TCustomId, TPath> &\n FileBaseRouteOptions<\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > & {\n getParentRoute: () => TParentRoute\n }\n\nexport interface ContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TParams,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n location: ParsedLocation\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: NavigateFn\n buildLocation: BuildLocationFn\n cause: 'preload' | 'enter' | 'stay'\n matches: Array<MakeRouteMatchUnion>\n}\n\nexport interface RouteContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TParams,\n in out TRouterContext,\n in out TLoaderDeps,\n> extends ContextOptions<TParentRoute, TParams> {\n deps: TLoaderDeps\n context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>\n}\n\nexport interface SsrContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n> {\n params:\n | {\n status: 'success'\n value: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n }\n | { status: 'error'; error: unknown }\n search:\n | {\n status: 'success'\n value: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n }\n | { status: 'error'; error: unknown }\n location: ParsedLocation\n matches: Array<MakePreValidationErrorHandlingRouteMatchUnion>\n}\n\nexport interface BeforeLoadContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n> extends ContextOptions<TParentRoute, TParams>,\n FullSearchSchemaOption<TParentRoute, TSearchValidator> {\n context: Expand<\n BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>\n >\n}\n\ntype AssetFnContextOptions<\n in out TRouteId,\n in out TFullPath,\n in out TParentRoute extends AnyRoute,\n in out TParams,\n in out TSearchValidator,\n in out TLoaderFn,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps,\n> = {\n matches: Array<\n RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >\n >\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >\n params: ResolveAllParamsFromParent<TParentRoute, TParams>\n loaderData?: ResolveLoaderData<TLoaderFn>\n}\n\nexport interface DefaultUpdatableRouteOptionsExtensions {\n component?: unknown\n errorComponent?: unknown\n notFoundComponent?: unknown\n pendingComponent?: unknown\n}\n\nexport interface UpdatableRouteOptionsExtensions\n extends DefaultUpdatableRouteOptionsExtensions {}\n\nexport interface UpdatableRouteOptions<\n in out TParentRoute extends AnyRoute,\n in out TRouteId,\n in out TFullPath,\n in out TParams,\n in out TSearchValidator,\n in out TLoaderFn,\n in out TLoaderDeps,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n> extends UpdatableStaticRouteOption,\n UpdatableRouteOptionsExtensions {\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n // If true, this route will be forcefully wrapped in a suspense boundary\n wrapInSuspense?: boolean\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n\n pendingMs?: number\n pendingMinMs?: number\n staleTime?: number\n gcTime?: number\n preload?: boolean\n preloadStaleTime?: number\n preloadGcTime?: number\n search?: {\n middlewares?: Array<\n SearchMiddleware<\n ResolveFullSearchSchemaInput<TParentRoute, TSearchValidator>\n >\n >\n }\n /** \n @deprecated Use search.middlewares instead\n */\n preSearchFilters?: Array<\n SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n >\n /** \n @deprecated Use search.middlewares instead\n */\n postSearchFilters?: Array<\n SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n >\n onCatch?: (error: Error) => void\n onError?: (err: any) => void\n // These functions are called as route matches are loaded, stick around and leave the active\n // matches\n onEnter?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n onStay?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n onLeave?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n headers?: (\n ctx: AssetFnContextOptions<\n TRouteId,\n TFullPath,\n TParentRoute,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps\n >,\n ) => Awaitable<Record<string, string>>\n head?: (\n ctx: AssetFnContextOptions<\n TRouteId,\n TFullPath,\n TParentRoute,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps\n >,\n ) => Awaitable<{\n links?: AnyRouteMatch['links']\n scripts?: AnyRouteMatch['headScripts']\n meta?: AnyRouteMatch['meta']\n styles?: AnyRouteMatch['styles']\n }>\n scripts?: (\n ctx: AssetFnContextOptions<\n TRouteId,\n TFullPath,\n TParentRoute,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps\n >,\n ) => Awaitable<AnyRouteMatch['scripts']>\n codeSplitGroupings?: Array<\n Array<\n | 'loader'\n | 'component'\n | 'pendingComponent'\n | 'notFoundComponent'\n | 'errorComponent'\n >\n >\n}\n\nexport type RouteLoaderFn<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TId extends string = string,\n in out TParams = {},\n in out TLoaderDeps = {},\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n> = (\n match: LoaderFnContext<\n TParentRoute,\n TId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n) => any\n\nexport interface LoaderFnContext<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TId extends string = string,\n in out TParams = {},\n in out TLoaderDeps = {},\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n deps: TLoaderDeps\n context: Expand<\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\n location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void> | void\n // root route does not have a parent match\n parentMatchPromise: TId extends RootRouteId\n ? never\n : Promise<MakeRouteMatchFromRoute<TParentRoute>>\n cause: 'preload' | 'enter' | 'stay'\n route: AnyRoute\n}\n\nexport interface DefaultRootRouteOptionsExtensions {\n shellComponent?: unknown\n}\n\nexport interface RootRouteOptionsExtensions\n extends DefaultRootRouteOptionsExtensions {}\n\nexport type RootRouteOptions<\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n> = Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId, // TId\n RootRouteId, // TCustomId\n '', // TFullPath\n '', // TPath\n TSearchValidator,\n {}, // TParams\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n> &\n RootRouteOptionsExtensions\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySchema\n TFullSearchSchema: AnySchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport type RouteTypesById<TRouter extends AnyRouter, TId> = RouteById<\n TRouter['routeTree'],\n TId\n>['types']\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\n}\n\n/**\n * @deprecated Use `ErrorComponentProps` instead.\n */\nexport type ErrorRouteProps = {\n error: unknown\n info?: { componentStack: string }\n reset: () => void\n}\n\nexport type ErrorComponentProps<TError = Error> = {\n error: TError\n info?: { componentStack: string }\n reset: () => void\n}\nexport type NotFoundRouteProps = {\n // TODO: Make sure this is `| null | undefined` (this is for global not-founds)\n data: unknown\n}\n\nexport class BaseRoute<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TPath extends string = '/',\n in out TFullPath extends string = ResolveFullPath<TParentRoute, TPath>,\n in out TCustomId extends string = string,\n in out TId extends string = ResolveId<TParentRoute, TCustomId, TPath>,\n in out TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> {\n isRoot: TParentRoute extends AnyRoute ? true : false\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n\n // The following properties are set up in this.init()\n parentRoute!: TParentRoute\n private _id!: TId\n private _path!: TPath\n private _fullPath!: TFullPath\n private _to!: TrimPathRight<TFullPath>\n\n public get to() {\n return this._to\n }\n\n public get id() {\n return this._id\n }\n\n public get path() {\n return this._path\n }\n\n public get fullPath() {\n return this._fullPath\n }\n\n // Optional\n children?: TChildren\n originalIndex?: number\n rank!: number\n lazyFn?: () => Promise<\n LazyRoute<\n Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n >\n >\n /** @internal */\n _lazyPromise?: Promise<void>\n /** @internal */\n _componentsPromise?: Promise<void>\n\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) {\n this.options = (options as any) || {}\n this.isRoot = !options?.getParentRoute as any\n\n if ((options as any)?.id && (options as any)?.path) {\n throw new Error(`Route cannot have both an 'id' and a 'path' option.`)\n }\n }\n\n types!: RouteTypes<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n\n init = (opts: { originalIndex: number }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\n this.parentRoute = this.options.getParentRoute?.()\n\n if (isRoot) {\n this._path = rootRouteId as TPath\n } else if (!this.parentRoute) {\n invariant(\n false,\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options?.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPathLeft(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this._path = path as TPath\n this._id = id as TId\n this._fullPath = fullPath as TFullPath\n this._to = fullPath as TrimPathRight<TFullPath>\n }\n\n clone = (other: typeof this) => {\n this._path = other._path\n this._id = other._id\n this._fullPath = other._fullPath\n this._to = other._to\n this.options.getParentRoute = other.options.getParentRoute\n this.children = other.children\n }\n\n addChildren: RouteAddChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n return this._addFileChildren(children) as any\n }\n\n _addFileChildren: RouteAddFileChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n if (Array.isArray(children)) {\n this.children = children as TChildren\n }\n\n if (typeof children === 'object' && children !== null) {\n this.children = Object.values(children) as TChildren\n }\n\n return this as any\n }\n\n _addFileTypes: RouteAddFileTypesFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n > = () => {\n return this as any\n }\n\n updateLoader = <TNewLoaderFn>(options: {\n loader: Constrain<\n TNewLoaderFn,\n RouteLoaderFn<\n TParentRoute,\n TCustomId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\n }) => {\n Object.assign(this.options, options)\n return this as unknown as BaseRoute<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TNewLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy: RouteLazyFn<\n Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n > = (lazyFn) => {\n this.lazyFn = lazyFn\n return this\n }\n}\n\nexport class BaseRouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {\n id: TId\n\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\nexport interface RootRoute<\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchValidator, // TSearchValidator\n {}, // TParams\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren, // TChildren\n TFileRouteTypes\n > {}\n\nexport class BaseRootRoute<\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> extends BaseRoute<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchValidator, // TSearchValidator\n {}, // TParams\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren, // TChildren\n TFileRouteTypes\n> {\n constructor(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) {\n super(options as any)\n }\n}\n\n//\n\nexport interface RouteLike {\n id: string\n isRoot?: boolean\n path?: string\n fullPath: string\n rank?: number\n parentRoute?: RouteLike\n children?: Array<RouteLike>\n options?: {\n caseSensitive?: boolean\n }\n}\n"],"names":["options","rootRouteId","path","trimPathLeft","joinPaths","notFound"],"mappings":"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"}
|
package/dist/cjs/route.d.cts
CHANGED
|
@@ -445,4 +445,16 @@ TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildre
|
|
|
445
445
|
TFileRouteTypes> {
|
|
446
446
|
constructor(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>);
|
|
447
447
|
}
|
|
448
|
+
export interface RouteLike {
|
|
449
|
+
id: string;
|
|
450
|
+
isRoot?: boolean;
|
|
451
|
+
path?: string;
|
|
452
|
+
fullPath: string;
|
|
453
|
+
rank?: number;
|
|
454
|
+
parentRoute?: RouteLike;
|
|
455
|
+
children?: Array<RouteLike>;
|
|
456
|
+
options?: {
|
|
457
|
+
caseSensitive?: boolean;
|
|
458
|
+
};
|
|
459
|
+
}
|
|
448
460
|
export {};
|
package/dist/cjs/router.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const store = require("@tanstack/store");
|
|
4
4
|
const history = require("@tanstack/history");
|
|
5
|
-
const invariant = require("tiny-invariant");
|
|
6
5
|
const utils = require("./utils.cjs");
|
|
6
|
+
const processRouteTree = require("./process-route-tree.cjs");
|
|
7
7
|
const path = require("./path.cjs");
|
|
8
8
|
const notFound = require("./not-found.cjs");
|
|
9
9
|
const scrollRestoration = require("./scroll-restoration.cjs");
|
|
@@ -112,7 +112,7 @@ class RouterCore {
|
|
|
112
112
|
);
|
|
113
113
|
};
|
|
114
114
|
this.buildRouteTree = () => {
|
|
115
|
-
const { routesById, routesByPath, flatRoutes } = processRouteTree({
|
|
115
|
+
const { routesById, routesByPath, flatRoutes } = processRouteTree.processRouteTree({
|
|
116
116
|
routeTree: this.routeTree,
|
|
117
117
|
initRoute: (route, i) => {
|
|
118
118
|
route.init({
|
|
@@ -1146,136 +1146,6 @@ function validateSearch(validateSearch2, input) {
|
|
|
1146
1146
|
}
|
|
1147
1147
|
return {};
|
|
1148
1148
|
}
|
|
1149
|
-
const REQUIRED_PARAM_BASE_SCORE = 0.5;
|
|
1150
|
-
const OPTIONAL_PARAM_BASE_SCORE = 0.4;
|
|
1151
|
-
const WILDCARD_PARAM_BASE_SCORE = 0.25;
|
|
1152
|
-
const BOTH_PRESENCE_BASE_SCORE = 0.05;
|
|
1153
|
-
const PREFIX_PRESENCE_BASE_SCORE = 0.02;
|
|
1154
|
-
const SUFFIX_PRESENCE_BASE_SCORE = 0.01;
|
|
1155
|
-
const PREFIX_LENGTH_SCORE_MULTIPLIER = 2e-4;
|
|
1156
|
-
const SUFFIX_LENGTH_SCORE_MULTIPLIER = 1e-4;
|
|
1157
|
-
function handleParam(segment, baseScore) {
|
|
1158
|
-
if (segment.prefixSegment && segment.suffixSegment) {
|
|
1159
|
-
return baseScore + BOTH_PRESENCE_BASE_SCORE + PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length + SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length;
|
|
1160
|
-
}
|
|
1161
|
-
if (segment.prefixSegment) {
|
|
1162
|
-
return baseScore + PREFIX_PRESENCE_BASE_SCORE + PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length;
|
|
1163
|
-
}
|
|
1164
|
-
if (segment.suffixSegment) {
|
|
1165
|
-
return baseScore + SUFFIX_PRESENCE_BASE_SCORE + SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length;
|
|
1166
|
-
}
|
|
1167
|
-
return baseScore;
|
|
1168
|
-
}
|
|
1169
|
-
function processRouteTree({
|
|
1170
|
-
routeTree,
|
|
1171
|
-
initRoute
|
|
1172
|
-
}) {
|
|
1173
|
-
const routesById = {};
|
|
1174
|
-
const routesByPath = {};
|
|
1175
|
-
const recurseRoutes = (childRoutes) => {
|
|
1176
|
-
childRoutes.forEach((childRoute, i) => {
|
|
1177
|
-
initRoute == null ? void 0 : initRoute(childRoute, i);
|
|
1178
|
-
const existingRoute = routesById[childRoute.id];
|
|
1179
|
-
invariant(
|
|
1180
|
-
!existingRoute,
|
|
1181
|
-
`Duplicate routes found with id: ${String(childRoute.id)}`
|
|
1182
|
-
);
|
|
1183
|
-
routesById[childRoute.id] = childRoute;
|
|
1184
|
-
if (!childRoute.isRoot && childRoute.path) {
|
|
1185
|
-
const trimmedFullPath = path.trimPathRight(childRoute.fullPath);
|
|
1186
|
-
if (!routesByPath[trimmedFullPath] || childRoute.fullPath.endsWith("/")) {
|
|
1187
|
-
routesByPath[trimmedFullPath] = childRoute;
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
const children = childRoute.children;
|
|
1191
|
-
if (children == null ? void 0 : children.length) {
|
|
1192
|
-
recurseRoutes(children);
|
|
1193
|
-
}
|
|
1194
|
-
});
|
|
1195
|
-
};
|
|
1196
|
-
recurseRoutes([routeTree]);
|
|
1197
|
-
const scoredRoutes = [];
|
|
1198
|
-
const routes = Object.values(routesById);
|
|
1199
|
-
routes.forEach((d, i) => {
|
|
1200
|
-
var _a;
|
|
1201
|
-
if (d.isRoot || !d.path) {
|
|
1202
|
-
return;
|
|
1203
|
-
}
|
|
1204
|
-
const trimmed = path.trimPathLeft(d.fullPath);
|
|
1205
|
-
let parsed = path.parsePathname(trimmed);
|
|
1206
|
-
let skip = 0;
|
|
1207
|
-
while (parsed.length > skip + 1 && ((_a = parsed[skip]) == null ? void 0 : _a.value) === "/") {
|
|
1208
|
-
skip++;
|
|
1209
|
-
}
|
|
1210
|
-
if (skip > 0) parsed = parsed.slice(skip);
|
|
1211
|
-
let optionalParamCount = 0;
|
|
1212
|
-
let hasStaticAfter = false;
|
|
1213
|
-
const scores = parsed.map((segment, index) => {
|
|
1214
|
-
if (segment.value === "/") {
|
|
1215
|
-
return 0.75;
|
|
1216
|
-
}
|
|
1217
|
-
let baseScore = void 0;
|
|
1218
|
-
if (segment.type === path.SEGMENT_TYPE_PARAM) {
|
|
1219
|
-
baseScore = REQUIRED_PARAM_BASE_SCORE;
|
|
1220
|
-
} else if (segment.type === path.SEGMENT_TYPE_OPTIONAL_PARAM) {
|
|
1221
|
-
baseScore = OPTIONAL_PARAM_BASE_SCORE;
|
|
1222
|
-
optionalParamCount++;
|
|
1223
|
-
} else if (segment.type === path.SEGMENT_TYPE_WILDCARD) {
|
|
1224
|
-
baseScore = WILDCARD_PARAM_BASE_SCORE;
|
|
1225
|
-
}
|
|
1226
|
-
if (baseScore) {
|
|
1227
|
-
for (let i2 = index + 1; i2 < parsed.length; i2++) {
|
|
1228
|
-
const nextSegment = parsed[i2];
|
|
1229
|
-
if (nextSegment.type === path.SEGMENT_TYPE_PATHNAME && nextSegment.value !== "/") {
|
|
1230
|
-
hasStaticAfter = true;
|
|
1231
|
-
return handleParam(segment, baseScore + 0.2);
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
return handleParam(segment, baseScore);
|
|
1235
|
-
}
|
|
1236
|
-
return 1;
|
|
1237
|
-
});
|
|
1238
|
-
scoredRoutes.push({
|
|
1239
|
-
child: d,
|
|
1240
|
-
trimmed,
|
|
1241
|
-
parsed,
|
|
1242
|
-
index: i,
|
|
1243
|
-
scores,
|
|
1244
|
-
optionalParamCount,
|
|
1245
|
-
hasStaticAfter
|
|
1246
|
-
});
|
|
1247
|
-
});
|
|
1248
|
-
const flatRoutes = scoredRoutes.sort((a, b) => {
|
|
1249
|
-
const minLength = Math.min(a.scores.length, b.scores.length);
|
|
1250
|
-
for (let i = 0; i < minLength; i++) {
|
|
1251
|
-
if (a.scores[i] !== b.scores[i]) {
|
|
1252
|
-
return b.scores[i] - a.scores[i];
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
if (a.scores.length !== b.scores.length) {
|
|
1256
|
-
if (a.optionalParamCount !== b.optionalParamCount) {
|
|
1257
|
-
if (a.hasStaticAfter === b.hasStaticAfter) {
|
|
1258
|
-
return a.optionalParamCount - b.optionalParamCount;
|
|
1259
|
-
} else if (a.hasStaticAfter && !b.hasStaticAfter) {
|
|
1260
|
-
return -1;
|
|
1261
|
-
} else if (!a.hasStaticAfter && b.hasStaticAfter) {
|
|
1262
|
-
return 1;
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
return b.scores.length - a.scores.length;
|
|
1266
|
-
}
|
|
1267
|
-
for (let i = 0; i < minLength; i++) {
|
|
1268
|
-
if (a.parsed[i].value !== b.parsed[i].value) {
|
|
1269
|
-
return a.parsed[i].value > b.parsed[i].value ? 1 : -1;
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
return a.index - b.index;
|
|
1273
|
-
}).map((d, i) => {
|
|
1274
|
-
d.child.rank = i;
|
|
1275
|
-
return d.child;
|
|
1276
|
-
});
|
|
1277
|
-
return { routesById, routesByPath, flatRoutes };
|
|
1278
|
-
}
|
|
1279
1149
|
function getMatchedRoutes({
|
|
1280
1150
|
pathname,
|
|
1281
1151
|
routePathname,
|
|
@@ -1422,5 +1292,4 @@ exports.getInitialRouterState = getInitialRouterState;
|
|
|
1422
1292
|
exports.getLocationChangeInfo = getLocationChangeInfo;
|
|
1423
1293
|
exports.getMatchedRoutes = getMatchedRoutes;
|
|
1424
1294
|
exports.lazyFn = lazyFn;
|
|
1425
|
-
exports.processRouteTree = processRouteTree;
|
|
1426
1295
|
//# sourceMappingURL=router.cjs.map
|