@tanstack/router-core 1.121.20 → 1.121.27
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/Matches.cjs +13 -0
- package/dist/cjs/Matches.cjs.map +1 -0
- package/dist/cjs/Matches.d.cts +109 -0
- package/dist/cjs/RouterProvider.d.cts +26 -0
- package/dist/cjs/defer.cjs +25 -0
- package/dist/cjs/defer.cjs.map +1 -0
- package/dist/cjs/defer.d.cts +20 -0
- package/dist/cjs/fileRoute.d.cts +23 -0
- package/dist/cjs/history.d.cts +8 -0
- package/dist/cjs/index.cjs +79 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +41 -0
- package/dist/cjs/link.cjs +5 -0
- package/dist/cjs/link.cjs.map +1 -0
- package/dist/cjs/link.d.cts +212 -0
- package/dist/cjs/location.d.cts +12 -0
- package/dist/cjs/manifest.d.cts +24 -0
- package/dist/cjs/not-found.cjs +13 -0
- package/dist/cjs/not-found.cjs.map +1 -0
- package/dist/cjs/not-found.d.cts +20 -0
- package/dist/cjs/path.cjs +412 -0
- package/dist/cjs/path.cjs.map +1 -0
- package/dist/cjs/path.d.cts +56 -0
- package/dist/cjs/qss.cjs +36 -0
- package/dist/cjs/qss.cjs.map +1 -0
- package/dist/cjs/qss.d.cts +31 -0
- package/dist/cjs/redirect.cjs +42 -0
- package/dist/cjs/redirect.cjs.map +1 -0
- package/dist/cjs/redirect.d.cts +41 -0
- package/dist/cjs/root.cjs +5 -0
- package/dist/cjs/root.cjs.map +1 -0
- package/dist/cjs/root.d.cts +2 -0
- package/dist/cjs/route.cjs +119 -0
- package/dist/cjs/route.cjs.map +1 -0
- package/dist/cjs/route.d.cts +432 -0
- package/dist/cjs/routeInfo.d.cts +54 -0
- package/dist/cjs/router.cjs +1805 -0
- package/dist/cjs/router.cjs.map +1 -0
- package/dist/cjs/router.d.cts +627 -0
- package/dist/cjs/scroll-restoration.cjs +207 -0
- package/dist/cjs/scroll-restoration.cjs.map +1 -0
- package/dist/cjs/scroll-restoration.d.cts +38 -0
- package/dist/cjs/searchMiddleware.cjs +42 -0
- package/dist/cjs/searchMiddleware.cjs.map +1 -0
- package/dist/cjs/searchMiddleware.d.cts +5 -0
- package/dist/cjs/searchParams.cjs +61 -0
- package/dist/cjs/searchParams.cjs.map +1 -0
- package/dist/cjs/searchParams.d.cts +7 -0
- package/dist/cjs/serializer.d.cts +22 -0
- package/dist/cjs/structuralSharing.d.cts +4 -0
- package/dist/cjs/typePrimitives.d.cts +65 -0
- package/dist/cjs/useLoaderData.d.cts +5 -0
- package/dist/cjs/useLoaderDeps.d.cts +5 -0
- package/dist/cjs/useNavigate.d.cts +3 -0
- package/dist/cjs/useParams.d.cts +5 -0
- package/dist/cjs/useRouteContext.d.cts +9 -0
- package/dist/cjs/useSearch.d.cts +5 -0
- package/dist/cjs/utils.cjs +165 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +94 -0
- package/dist/cjs/validators.d.cts +51 -0
- package/dist/esm/Matches.d.ts +109 -0
- package/dist/esm/Matches.js +13 -0
- package/dist/esm/Matches.js.map +1 -0
- package/dist/esm/RouterProvider.d.ts +26 -0
- package/dist/esm/defer.d.ts +20 -0
- package/dist/esm/defer.js +25 -0
- package/dist/esm/defer.js.map +1 -0
- package/dist/esm/fileRoute.d.ts +23 -0
- package/dist/esm/history.d.ts +8 -0
- package/dist/esm/index.d.ts +41 -0
- package/dist/esm/index.js +79 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/link.d.ts +212 -0
- package/dist/esm/link.js +5 -0
- package/dist/esm/link.js.map +1 -0
- package/dist/esm/location.d.ts +12 -0
- package/dist/esm/manifest.d.ts +24 -0
- package/dist/esm/not-found.d.ts +20 -0
- package/dist/esm/not-found.js +13 -0
- package/dist/esm/not-found.js.map +1 -0
- package/dist/esm/path.d.ts +56 -0
- package/dist/esm/path.js +412 -0
- package/dist/esm/path.js.map +1 -0
- package/dist/esm/qss.d.ts +31 -0
- package/dist/esm/qss.js +36 -0
- package/dist/esm/qss.js.map +1 -0
- package/dist/esm/redirect.d.ts +41 -0
- package/dist/esm/redirect.js +42 -0
- package/dist/esm/redirect.js.map +1 -0
- package/dist/esm/root.d.ts +2 -0
- package/dist/esm/root.js +5 -0
- package/dist/esm/root.js.map +1 -0
- package/dist/esm/route.d.ts +432 -0
- package/dist/esm/route.js +119 -0
- package/dist/esm/route.js.map +1 -0
- package/dist/esm/routeInfo.d.ts +54 -0
- package/dist/esm/router.d.ts +627 -0
- package/dist/esm/router.js +1805 -0
- package/dist/esm/router.js.map +1 -0
- package/dist/esm/scroll-restoration.d.ts +38 -0
- package/dist/esm/scroll-restoration.js +207 -0
- package/dist/esm/scroll-restoration.js.map +1 -0
- package/dist/esm/searchMiddleware.d.ts +5 -0
- package/dist/esm/searchMiddleware.js +42 -0
- package/dist/esm/searchMiddleware.js.map +1 -0
- package/dist/esm/searchParams.d.ts +7 -0
- package/dist/esm/searchParams.js +61 -0
- package/dist/esm/searchParams.js.map +1 -0
- package/dist/esm/serializer.d.ts +22 -0
- package/dist/esm/structuralSharing.d.ts +4 -0
- package/dist/esm/typePrimitives.d.ts +65 -0
- package/dist/esm/useLoaderData.d.ts +5 -0
- package/dist/esm/useLoaderDeps.d.ts +5 -0
- package/dist/esm/useNavigate.d.ts +3 -0
- package/dist/esm/useParams.d.ts +5 -0
- package/dist/esm/useRouteContext.d.ts +9 -0
- package/dist/esm/useSearch.d.ts +5 -0
- package/dist/esm/utils.d.ts +94 -0
- package/dist/esm/utils.js +165 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/validators.d.ts +51 -0
- package/package.json +2 -2
- package/src/index.ts +6 -1
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { LazyRoute } from './fileRoute.js';
|
|
2
|
+
import { NotFoundError } from './not-found.js';
|
|
3
|
+
import { NavigateOptions, ParsePathParams } from './link.js';
|
|
4
|
+
import { ParsedLocation } from './location.js';
|
|
5
|
+
import { AnyRouteMatch, MakeRouteMatchFromRoute, MakeRouteMatchUnion, RouteMatch } from './Matches.js';
|
|
6
|
+
import { RootRouteId } from './root.js';
|
|
7
|
+
import { ParseRoute, RouteById, RoutePaths } from './routeInfo.js';
|
|
8
|
+
import { AnyRouter, RegisteredRouter } from './router.js';
|
|
9
|
+
import { BuildLocationFn, NavigateFn } from './RouterProvider.js';
|
|
10
|
+
import { Assign, Awaitable, Constrain, Expand, IntersectAssign, LooseAsyncReturnType, LooseReturnType, NoInfer } from './utils.js';
|
|
11
|
+
import { AnySchema, AnyStandardSchemaValidator, AnyValidator, AnyValidatorAdapter, AnyValidatorObj, DefaultValidator, ResolveSearchValidatorInput, ResolveValidatorOutput, StandardSchemaValidator, ValidatorAdapter, ValidatorFn, ValidatorObj } from './validators.js';
|
|
12
|
+
export type AnyPathParams = {};
|
|
13
|
+
export type SearchSchemaInput = {
|
|
14
|
+
__TSearchSchemaInput__: 'TSearchSchemaInput';
|
|
15
|
+
};
|
|
16
|
+
export type AnyContext = {};
|
|
17
|
+
export interface RouteContext {
|
|
18
|
+
}
|
|
19
|
+
export type PreloadableObj = {
|
|
20
|
+
preload?: () => Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
export type RoutePathOptions<TCustomId, TPath> = {
|
|
23
|
+
path: TPath;
|
|
24
|
+
} | {
|
|
25
|
+
id: TCustomId;
|
|
26
|
+
};
|
|
27
|
+
export interface StaticDataRouteOption {
|
|
28
|
+
}
|
|
29
|
+
export type RoutePathOptionsIntersection<TCustomId, TPath> = {
|
|
30
|
+
path: TPath;
|
|
31
|
+
id: TCustomId;
|
|
32
|
+
};
|
|
33
|
+
export type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult;
|
|
34
|
+
export type SearchMiddlewareContext<TSearchSchema> = {
|
|
35
|
+
search: TSearchSchema;
|
|
36
|
+
next: (newSearch: TSearchSchema) => TSearchSchema;
|
|
37
|
+
};
|
|
38
|
+
export type SearchMiddleware<TSearchSchema> = (ctx: SearchMiddlewareContext<TSearchSchema>) => TSearchSchema;
|
|
39
|
+
export type ResolveId<TParentRoute, TCustomId extends string, TPath extends string> = TParentRoute extends {
|
|
40
|
+
id: infer TParentId extends string;
|
|
41
|
+
} ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId> : RootRouteId;
|
|
42
|
+
export type InferFullSearchSchema<TRoute> = TRoute extends {
|
|
43
|
+
types: {
|
|
44
|
+
fullSearchSchema: infer TFullSearchSchema;
|
|
45
|
+
};
|
|
46
|
+
} ? TFullSearchSchema : {};
|
|
47
|
+
export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
|
|
48
|
+
types: {
|
|
49
|
+
fullSearchSchemaInput: infer TFullSearchSchemaInput;
|
|
50
|
+
};
|
|
51
|
+
} ? TFullSearchSchemaInput : {};
|
|
52
|
+
export type InferAllParams<TRoute> = TRoute extends {
|
|
53
|
+
types: {
|
|
54
|
+
allParams: infer TAllParams;
|
|
55
|
+
};
|
|
56
|
+
} ? TAllParams : {};
|
|
57
|
+
export type InferAllContext<TRoute> = unknown extends TRoute ? TRoute : TRoute extends {
|
|
58
|
+
types: {
|
|
59
|
+
allContext: infer TAllContext;
|
|
60
|
+
};
|
|
61
|
+
} ? TAllContext : {};
|
|
62
|
+
export type ResolveSearchSchemaFnInput<TSearchValidator> = TSearchValidator extends (input: infer TSearchSchemaInput) => any ? TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, keyof SearchSchemaInput> : ResolveSearchSchemaFn<TSearchValidator> : AnySchema;
|
|
63
|
+
export type ResolveSearchSchemaInput<TSearchValidator> = TSearchValidator extends AnyStandardSchemaValidator ? NonNullable<TSearchValidator['~standard']['types']>['input'] : TSearchValidator extends AnyValidatorAdapter ? TSearchValidator['types']['input'] : TSearchValidator extends AnyValidatorObj ? ResolveSearchSchemaFnInput<TSearchValidator['parse']> : ResolveSearchSchemaFnInput<TSearchValidator>;
|
|
64
|
+
export type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (...args: any) => infer TSearchSchema ? TSearchSchema : AnySchema;
|
|
65
|
+
export type ResolveSearchSchema<TSearchValidator> = unknown extends TSearchValidator ? TSearchValidator : TSearchValidator extends AnyStandardSchemaValidator ? NonNullable<TSearchValidator['~standard']['types']>['output'] : TSearchValidator extends AnyValidatorAdapter ? TSearchValidator['types']['output'] : TSearchValidator extends AnyValidatorObj ? ResolveSearchSchemaFn<TSearchValidator['parse']> : ResolveSearchSchemaFn<TSearchValidator>;
|
|
66
|
+
export type ResolveRequiredParams<TPath extends string, T> = {
|
|
67
|
+
[K in ParsePathParams<TPath>['required']]: T;
|
|
68
|
+
};
|
|
69
|
+
export type ResolveOptionalParams<TPath extends string, T> = {
|
|
70
|
+
[K in ParsePathParams<TPath>['optional']]?: T;
|
|
71
|
+
};
|
|
72
|
+
export type ResolveParams<TPath extends string, T = string> = ResolveRequiredParams<TPath, T> & ResolveOptionalParams<TPath, T>;
|
|
73
|
+
export type ParseParamsFn<in out TPath extends string, in out TParams> = (rawParams: Expand<ResolveParams<TPath>>) => TParams extends ResolveParams<TPath, any> ? TParams : ResolveParams<TPath, any>;
|
|
74
|
+
export type StringifyParamsFn<in out TPath extends string, in out TParams> = (params: TParams) => ResolveParams<TPath>;
|
|
75
|
+
export type ParamsOptions<in out TPath extends string, in out TParams> = {
|
|
76
|
+
params?: {
|
|
77
|
+
parse?: ParseParamsFn<TPath, TParams>;
|
|
78
|
+
stringify?: StringifyParamsFn<TPath, TParams>;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
@deprecated Use params.parse instead
|
|
82
|
+
*/
|
|
83
|
+
parseParams?: ParseParamsFn<TPath, TParams>;
|
|
84
|
+
/**
|
|
85
|
+
@deprecated Use params.stringify instead
|
|
86
|
+
*/
|
|
87
|
+
stringifyParams?: StringifyParamsFn<TPath, TParams>;
|
|
88
|
+
};
|
|
89
|
+
interface RequiredStaticDataRouteOption {
|
|
90
|
+
staticData: StaticDataRouteOption;
|
|
91
|
+
}
|
|
92
|
+
interface OptionalStaticDataRouteOption {
|
|
93
|
+
staticData?: StaticDataRouteOption;
|
|
94
|
+
}
|
|
95
|
+
export type UpdatableStaticRouteOption = {} extends StaticDataRouteOption ? OptionalStaticDataRouteOption : RequiredStaticDataRouteOption;
|
|
96
|
+
export type MetaDescriptor = {
|
|
97
|
+
charSet: 'utf-8';
|
|
98
|
+
} | {
|
|
99
|
+
title: string;
|
|
100
|
+
} | {
|
|
101
|
+
name: string;
|
|
102
|
+
content: string;
|
|
103
|
+
} | {
|
|
104
|
+
property: string;
|
|
105
|
+
content: string;
|
|
106
|
+
} | {
|
|
107
|
+
httpEquiv: string;
|
|
108
|
+
content: string;
|
|
109
|
+
} | {
|
|
110
|
+
'script:ld+json': LdJsonObject;
|
|
111
|
+
} | {
|
|
112
|
+
tagName: 'meta' | 'link';
|
|
113
|
+
[name: string]: string;
|
|
114
|
+
} | Record<string, unknown>;
|
|
115
|
+
type LdJsonObject = {
|
|
116
|
+
[Key in string]: LdJsonValue;
|
|
117
|
+
} & {
|
|
118
|
+
[Key in string]?: LdJsonValue | undefined;
|
|
119
|
+
};
|
|
120
|
+
type LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>;
|
|
121
|
+
type LdJsonPrimitive = string | number | boolean | null;
|
|
122
|
+
type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
|
|
123
|
+
export type RouteLinkEntry = {};
|
|
124
|
+
export type SearchValidator<TInput, TOutput> = ValidatorObj<TInput, TOutput> | ValidatorFn<TInput, TOutput> | ValidatorAdapter<TInput, TOutput> | StandardSchemaValidator<TInput, TOutput> | undefined;
|
|
125
|
+
export type AnySearchValidator = SearchValidator<any, any>;
|
|
126
|
+
export type DefaultSearchValidator = SearchValidator<Record<string, unknown>, AnySchema>;
|
|
127
|
+
export type RoutePrefix<TPrefix extends string, TPath extends string> = string extends TPath ? RootRouteId : TPath extends string ? TPrefix extends RootRouteId ? TPath extends '/' ? '/' : `/${TrimPath<TPath>}` : `${TPrefix}/${TPath}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}` : never;
|
|
128
|
+
export type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
|
|
129
|
+
export type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
|
|
130
|
+
export type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
|
|
131
|
+
export type ContextReturnType<TContextFn> = unknown extends TContextFn ? TContextFn : LooseReturnType<TContextFn> extends never ? AnyContext : LooseReturnType<TContextFn>;
|
|
132
|
+
export type ContextAsyncReturnType<TContextFn> = unknown extends TContextFn ? TContextFn : LooseAsyncReturnType<TContextFn> extends never ? AnyContext : LooseAsyncReturnType<TContextFn>;
|
|
133
|
+
export type ResolveRouteContext<TRouteContextFn, TBeforeLoadFn> = Assign<ContextReturnType<TRouteContextFn>, ContextAsyncReturnType<TBeforeLoadFn>>;
|
|
134
|
+
export type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn ? TLoaderFn : LooseAsyncReturnType<TLoaderFn> extends never ? undefined : LooseAsyncReturnType<TLoaderFn>;
|
|
135
|
+
export type ResolveFullSearchSchema<TParentRoute extends AnyRoute, TSearchValidator> = unknown extends TParentRoute ? ResolveValidatorOutput<TSearchValidator> : IntersectAssign<InferFullSearchSchema<TParentRoute>, ResolveValidatorOutput<TSearchValidator>>;
|
|
136
|
+
export type ResolveFullSearchSchemaInput<TParentRoute extends AnyRoute, TSearchValidator> = IntersectAssign<InferFullSearchSchemaInput<TParentRoute>, ResolveSearchValidatorInput<TSearchValidator>>;
|
|
137
|
+
export type ResolveAllParamsFromParent<TParentRoute extends AnyRoute, TParams> = Assign<InferAllParams<TParentRoute>, TParams>;
|
|
138
|
+
export type RouteContextParameter<TParentRoute extends AnyRoute, TRouterContext> = unknown extends TParentRoute ? TRouterContext : Assign<TRouterContext, InferAllContext<TParentRoute>>;
|
|
139
|
+
export type BeforeLoadContextParameter<TParentRoute extends AnyRoute, TRouterContext, TRouteContextFn> = Assign<RouteContextParameter<TParentRoute, TRouterContext>, ContextReturnType<TRouteContextFn>>;
|
|
140
|
+
export type ResolveAllContext<TParentRoute extends AnyRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn> = Assign<BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>, ContextAsyncReturnType<TBeforeLoadFn>>;
|
|
141
|
+
export interface FullSearchSchemaOption<in out TParentRoute extends AnyRoute, in out TSearchValidator> {
|
|
142
|
+
search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>;
|
|
143
|
+
}
|
|
144
|
+
export interface RemountDepsOptions<in out TRouteId, in out TFullSearchSchema, in out TAllParams, in out TLoaderDeps> {
|
|
145
|
+
routeId: TRouteId;
|
|
146
|
+
search: TFullSearchSchema;
|
|
147
|
+
params: TAllParams;
|
|
148
|
+
loaderDeps: TLoaderDeps;
|
|
149
|
+
}
|
|
150
|
+
export type MakeRemountDepsOptionsUnion<TRouteTree extends AnyRoute = RegisteredRouter['routeTree']> = ParseRoute<TRouteTree> extends infer TRoute extends AnyRoute ? TRoute extends any ? RemountDepsOptions<TRoute['id'], TRoute['types']['fullSearchSchema'], TRoute['types']['allParams'], TRoute['types']['loaderDeps']> : never : never;
|
|
151
|
+
export interface RouteTypes<in out TParentRoute extends AnyRoute, in out TPath extends string, in out TFullPath extends string, in out TCustomId extends string, in out TId extends string, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps, in out TLoaderFn, in out TChildren, in out TFileRouteTypes> {
|
|
152
|
+
parentRoute: TParentRoute;
|
|
153
|
+
path: TPath;
|
|
154
|
+
to: TrimPathRight<TFullPath>;
|
|
155
|
+
fullPath: TFullPath;
|
|
156
|
+
customId: TCustomId;
|
|
157
|
+
id: TId;
|
|
158
|
+
searchSchema: ResolveValidatorOutput<TSearchValidator>;
|
|
159
|
+
searchSchemaInput: ResolveSearchValidatorInput<TSearchValidator>;
|
|
160
|
+
searchValidator: TSearchValidator;
|
|
161
|
+
fullSearchSchema: ResolveFullSearchSchema<TParentRoute, TSearchValidator>;
|
|
162
|
+
fullSearchSchemaInput: ResolveFullSearchSchemaInput<TParentRoute, TSearchValidator>;
|
|
163
|
+
params: TParams;
|
|
164
|
+
allParams: ResolveAllParamsFromParent<TParentRoute, TParams>;
|
|
165
|
+
routerContext: TRouterContext;
|
|
166
|
+
routeContext: ResolveRouteContext<TRouteContextFn, TBeforeLoadFn>;
|
|
167
|
+
routeContextFn: TRouteContextFn;
|
|
168
|
+
beforeLoadFn: TBeforeLoadFn;
|
|
169
|
+
allContext: ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>;
|
|
170
|
+
children: TChildren;
|
|
171
|
+
loaderData: ResolveLoaderData<TLoaderFn>;
|
|
172
|
+
loaderDeps: TLoaderDeps;
|
|
173
|
+
fileRouteTypes: TFileRouteTypes;
|
|
174
|
+
}
|
|
175
|
+
export type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;
|
|
176
|
+
export interface RouteExtensions<in out TId, in out TFullPath> {
|
|
177
|
+
id: TId;
|
|
178
|
+
fullPath: TFullPath;
|
|
179
|
+
}
|
|
180
|
+
export type RouteLazyFn<TRoute extends AnyRoute> = (lazyFn: () => Promise<LazyRoute<TRoute>>) => TRoute;
|
|
181
|
+
export type RouteAddChildrenFn<in out TParentRoute extends AnyRoute, in out TPath extends string, in out TFullPath extends string, in out TCustomId extends string, in out TId extends string, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps extends Record<string, any>, in out TLoaderFn, in out TFileRouteTypes> = <const TNewChildren>(children: Constrain<TNewChildren, ReadonlyArray<AnyRoute> | Record<string, AnyRoute>>) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
|
|
182
|
+
export type RouteAddFileChildrenFn<in out TParentRoute extends AnyRoute, in out TPath extends string, in out TFullPath extends string, in out TCustomId extends string, in out TId extends string, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps extends Record<string, any>, in out TLoaderFn, in out TFileRouteTypes> = <const TNewChildren>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
|
|
183
|
+
export type RouteAddFileTypesFn<TParentRoute extends AnyRoute, TPath extends string, TFullPath extends string, TCustomId extends string, TId extends string, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps extends Record<string, any>, TLoaderFn, TChildren> = <TNewFileRouteTypes>() => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TNewFileRouteTypes>;
|
|
184
|
+
export interface Route<in out TParentRoute extends AnyRoute, in out TPath extends string, in out TFullPath extends string, in out TCustomId extends string, in out TId extends string, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps extends Record<string, any>, in out TLoaderFn, in out TChildren, in out TFileRouteTypes> extends RouteExtensions<TId, TFullPath> {
|
|
185
|
+
path: TPath;
|
|
186
|
+
parentRoute: TParentRoute;
|
|
187
|
+
children?: TChildren;
|
|
188
|
+
types: RouteTypes<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>;
|
|
189
|
+
options: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>;
|
|
190
|
+
isRoot: TParentRoute extends AnyRoute ? true : false;
|
|
191
|
+
_componentsPromise?: Promise<Array<void>>;
|
|
192
|
+
lazyFn?: () => Promise<LazyRoute<Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>>>;
|
|
193
|
+
_lazyPromise?: Promise<void>;
|
|
194
|
+
rank: number;
|
|
195
|
+
to: TrimPathRight<TFullPath>;
|
|
196
|
+
init: (opts: {
|
|
197
|
+
originalIndex: number;
|
|
198
|
+
defaultSsr?: boolean;
|
|
199
|
+
}) => void;
|
|
200
|
+
update: (options: UpdatableRouteOptions<TParentRoute, TCustomId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => this;
|
|
201
|
+
lazy: RouteLazyFn<Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>>;
|
|
202
|
+
addChildren: RouteAddChildrenFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TFileRouteTypes>;
|
|
203
|
+
_addFileChildren: RouteAddFileChildrenFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TFileRouteTypes>;
|
|
204
|
+
_addFileTypes: RouteAddFileTypesFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren>;
|
|
205
|
+
}
|
|
206
|
+
export type AnyRoute = Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any>;
|
|
207
|
+
export type AnyRouteWithContext<TContext> = AnyRoute & {
|
|
208
|
+
types: {
|
|
209
|
+
allContext: TContext;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TId extends string = string, TCustomId extends string = string, TFullPath extends string = string, TPath extends string = string, TSearchValidator = undefined, TParams = AnyPathParams, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext> = BaseRouteOptions<TParentRoute, TId, TCustomId, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn> & UpdatableRouteOptions<NoInfer<TParentRoute>, NoInfer<TCustomId>, NoInfer<TFullPath>, NoInfer<TParams>, NoInfer<TSearchValidator>, NoInfer<TLoaderFn>, NoInfer<TLoaderDeps>, NoInfer<TRouterContext>, NoInfer<TRouteContextFn>, NoInfer<TBeforeLoadFn>>;
|
|
213
|
+
export type RouteContextFn<in out TParentRoute extends AnyRoute, in out TSearchValidator, in out TParams, in out TRouterContext> = (ctx: RouteContextOptions<TParentRoute, TSearchValidator, TParams, TRouterContext>) => any;
|
|
214
|
+
export type BeforeLoadFn<in out TParentRoute extends AnyRoute, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn> = (ctx: BeforeLoadContextOptions<TParentRoute, TSearchValidator, TParams, TRouterContext, TRouteContextFn>) => any;
|
|
215
|
+
export type FileBaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TId extends string = string, TPath extends string = string, TSearchValidator = undefined, TParams = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TRemountDepsFn = AnyContext> = ParamsOptions<TPath, TParams> & {
|
|
216
|
+
validateSearch?: Constrain<TSearchValidator, AnyValidator, DefaultValidator>;
|
|
217
|
+
shouldReload?: boolean | ((match: LoaderFnContext<TParentRoute, TId, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => any);
|
|
218
|
+
context?: Constrain<TRouteContextFn, (ctx: RouteContextOptions<TParentRoute, TParams, TRouterContext, TLoaderDeps>) => any>;
|
|
219
|
+
beforeLoad?: Constrain<TBeforeLoadFn, (ctx: BeforeLoadContextOptions<TParentRoute, TSearchValidator, TParams, TRouterContext, TRouteContextFn>) => any>;
|
|
220
|
+
loaderDeps?: (opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>) => TLoaderDeps;
|
|
221
|
+
remountDeps?: Constrain<TRemountDepsFn, (opt: RemountDepsOptions<TId, FullSearchSchemaOption<TParentRoute, TSearchValidator>, Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>, TLoaderDeps>) => any>;
|
|
222
|
+
loader?: Constrain<TLoaderFn, (ctx: LoaderFnContext<TParentRoute, TId, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => any>;
|
|
223
|
+
};
|
|
224
|
+
export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TId extends string = string, TCustomId extends string = string, TPath extends string = string, TSearchValidator = undefined, TParams = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext> = RoutePathOptions<TCustomId, TPath> & FileBaseRouteOptions<TParentRoute, TId, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn> & {
|
|
225
|
+
getParentRoute: () => TParentRoute;
|
|
226
|
+
};
|
|
227
|
+
export interface ContextOptions<in out TParentRoute extends AnyRoute, in out TParams> {
|
|
228
|
+
abortController: AbortController;
|
|
229
|
+
preload: boolean;
|
|
230
|
+
params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>;
|
|
231
|
+
location: ParsedLocation;
|
|
232
|
+
/**
|
|
233
|
+
* @deprecated Use `throw redirect({ to: '/somewhere' })` instead
|
|
234
|
+
**/
|
|
235
|
+
navigate: NavigateFn;
|
|
236
|
+
buildLocation: BuildLocationFn;
|
|
237
|
+
cause: 'preload' | 'enter' | 'stay';
|
|
238
|
+
matches: Array<MakeRouteMatchUnion>;
|
|
239
|
+
}
|
|
240
|
+
export interface RouteContextOptions<in out TParentRoute extends AnyRoute, in out TParams, in out TRouterContext, in out TLoaderDeps> extends ContextOptions<TParentRoute, TParams> {
|
|
241
|
+
deps: TLoaderDeps;
|
|
242
|
+
context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>;
|
|
243
|
+
}
|
|
244
|
+
export interface BeforeLoadContextOptions<in out TParentRoute extends AnyRoute, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn> extends ContextOptions<TParentRoute, TParams>, FullSearchSchemaOption<TParentRoute, TSearchValidator> {
|
|
245
|
+
context: Expand<BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>>;
|
|
246
|
+
}
|
|
247
|
+
type AssetFnContextOptions<in out TRouteId, in out TFullPath, in out TParentRoute extends AnyRoute, in out TParams, in out TSearchValidator, in out TLoaderFn, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps> = {
|
|
248
|
+
matches: Array<RouteMatch<TRouteId, TFullPath, ResolveAllParamsFromParent<TParentRoute, TParams>, ResolveFullSearchSchema<TParentRoute, TSearchValidator>, ResolveLoaderData<TLoaderFn>, ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>, TLoaderDeps>>;
|
|
249
|
+
match: RouteMatch<TRouteId, TFullPath, ResolveAllParamsFromParent<TParentRoute, TParams>, ResolveFullSearchSchema<TParentRoute, TSearchValidator>, ResolveLoaderData<TLoaderFn>, ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>, TLoaderDeps>;
|
|
250
|
+
params: ResolveAllParamsFromParent<TParentRoute, TParams>;
|
|
251
|
+
loaderData?: ResolveLoaderData<TLoaderFn>;
|
|
252
|
+
};
|
|
253
|
+
export interface DefaultUpdatableRouteOptionsExtensions {
|
|
254
|
+
component?: unknown;
|
|
255
|
+
errorComponent?: unknown;
|
|
256
|
+
notFoundComponent?: unknown;
|
|
257
|
+
pendingComponent?: unknown;
|
|
258
|
+
}
|
|
259
|
+
export interface UpdatableRouteOptionsExtensions extends DefaultUpdatableRouteOptionsExtensions {
|
|
260
|
+
}
|
|
261
|
+
export interface UpdatableRouteOptions<in out TParentRoute extends AnyRoute, in out TRouteId, in out TFullPath, in out TParams, in out TSearchValidator, in out TLoaderFn, in out TLoaderDeps, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn> extends UpdatableStaticRouteOption, UpdatableRouteOptionsExtensions {
|
|
262
|
+
caseSensitive?: boolean;
|
|
263
|
+
wrapInSuspense?: boolean;
|
|
264
|
+
pendingMs?: number;
|
|
265
|
+
pendingMinMs?: number;
|
|
266
|
+
staleTime?: number;
|
|
267
|
+
gcTime?: number;
|
|
268
|
+
preload?: boolean;
|
|
269
|
+
preloadStaleTime?: number;
|
|
270
|
+
preloadGcTime?: number;
|
|
271
|
+
search?: {
|
|
272
|
+
middlewares?: Array<SearchMiddleware<ResolveFullSearchSchemaInput<TParentRoute, TSearchValidator>>>;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
@deprecated Use search.middlewares instead
|
|
276
|
+
*/
|
|
277
|
+
preSearchFilters?: Array<SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>>;
|
|
278
|
+
/**
|
|
279
|
+
@deprecated Use search.middlewares instead
|
|
280
|
+
*/
|
|
281
|
+
postSearchFilters?: Array<SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>>;
|
|
282
|
+
onCatch?: (error: Error) => void;
|
|
283
|
+
onError?: (err: any) => void;
|
|
284
|
+
onEnter?: (match: RouteMatch<TRouteId, TFullPath, ResolveAllParamsFromParent<TParentRoute, TParams>, ResolveFullSearchSchema<TParentRoute, TSearchValidator>, ResolveLoaderData<TLoaderFn>, ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>, TLoaderDeps>) => void;
|
|
285
|
+
onStay?: (match: RouteMatch<TRouteId, TFullPath, ResolveAllParamsFromParent<TParentRoute, TParams>, ResolveFullSearchSchema<TParentRoute, TSearchValidator>, ResolveLoaderData<TLoaderFn>, ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>, TLoaderDeps>) => void;
|
|
286
|
+
onLeave?: (match: RouteMatch<TRouteId, TFullPath, ResolveAllParamsFromParent<TParentRoute, TParams>, ResolveFullSearchSchema<TParentRoute, TSearchValidator>, ResolveLoaderData<TLoaderFn>, ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>, TLoaderDeps>) => void;
|
|
287
|
+
headers?: (ctx: AssetFnContextOptions<TRouteId, TFullPath, TParentRoute, TParams, TSearchValidator, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps>) => Awaitable<Record<string, string>>;
|
|
288
|
+
head?: (ctx: AssetFnContextOptions<TRouteId, TFullPath, TParentRoute, TParams, TSearchValidator, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps>) => Awaitable<{
|
|
289
|
+
links?: AnyRouteMatch['links'];
|
|
290
|
+
scripts?: AnyRouteMatch['headScripts'];
|
|
291
|
+
meta?: AnyRouteMatch['meta'];
|
|
292
|
+
}>;
|
|
293
|
+
scripts?: (ctx: AssetFnContextOptions<TRouteId, TFullPath, TParentRoute, TParams, TSearchValidator, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps>) => Awaitable<AnyRouteMatch['scripts']>;
|
|
294
|
+
ssr?: boolean;
|
|
295
|
+
codeSplitGroupings?: Array<Array<'loader' | 'component' | 'pendingComponent' | 'notFoundComponent' | 'errorComponent'>>;
|
|
296
|
+
}
|
|
297
|
+
export type RouteLoaderFn<in out TParentRoute extends AnyRoute = AnyRoute, in out TId extends string = string, in out TParams = {}, in out TLoaderDeps = {}, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext> = (match: LoaderFnContext<TParentRoute, TId, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => any;
|
|
298
|
+
export interface LoaderFnContext<in out TParentRoute extends AnyRoute = AnyRoute, in out TId extends string = string, in out TParams = {}, in out TLoaderDeps = {}, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext> {
|
|
299
|
+
abortController: AbortController;
|
|
300
|
+
preload: boolean;
|
|
301
|
+
params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>;
|
|
302
|
+
deps: TLoaderDeps;
|
|
303
|
+
context: Expand<ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>>;
|
|
304
|
+
location: ParsedLocation;
|
|
305
|
+
/**
|
|
306
|
+
* @deprecated Use `throw redirect({ to: '/somewhere' })` instead
|
|
307
|
+
**/
|
|
308
|
+
navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void> | void;
|
|
309
|
+
parentMatchPromise: TId extends RootRouteId ? never : Promise<MakeRouteMatchFromRoute<TParentRoute>>;
|
|
310
|
+
cause: 'preload' | 'enter' | 'stay';
|
|
311
|
+
route: AnyRoute;
|
|
312
|
+
}
|
|
313
|
+
export type RootRouteOptions<TSearchValidator = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined> = Omit<RouteOptions<any, // TParentRoute
|
|
314
|
+
RootRouteId, // TId
|
|
315
|
+
RootRouteId, // TCustomId
|
|
316
|
+
'', // TFullPath
|
|
317
|
+
'', // TPath
|
|
318
|
+
TSearchValidator, {}, // TParams
|
|
319
|
+
TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'params'>;
|
|
320
|
+
export type RouteConstraints = {
|
|
321
|
+
TParentRoute: AnyRoute;
|
|
322
|
+
TPath: string;
|
|
323
|
+
TFullPath: string;
|
|
324
|
+
TCustomId: string;
|
|
325
|
+
TId: string;
|
|
326
|
+
TSearchSchema: AnySchema;
|
|
327
|
+
TFullSearchSchema: AnySchema;
|
|
328
|
+
TParams: Record<string, any>;
|
|
329
|
+
TAllParams: Record<string, any>;
|
|
330
|
+
TParentContext: AnyContext;
|
|
331
|
+
TRouteContext: RouteContext;
|
|
332
|
+
TAllContext: AnyContext;
|
|
333
|
+
TRouterContext: AnyContext;
|
|
334
|
+
TChildren: unknown;
|
|
335
|
+
TRouteTree: AnyRoute;
|
|
336
|
+
};
|
|
337
|
+
export type RouteTypesById<TRouter extends AnyRouter, TId> = RouteById<TRouter['routeTree'], TId>['types'];
|
|
338
|
+
export type RouteMask<TRouteTree extends AnyRoute> = {
|
|
339
|
+
routeTree: TRouteTree;
|
|
340
|
+
from: RoutePaths<TRouteTree>;
|
|
341
|
+
to?: any;
|
|
342
|
+
params?: any;
|
|
343
|
+
search?: any;
|
|
344
|
+
hash?: any;
|
|
345
|
+
state?: any;
|
|
346
|
+
unmaskOnReload?: boolean;
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* @deprecated Use `ErrorComponentProps` instead.
|
|
350
|
+
*/
|
|
351
|
+
export type ErrorRouteProps = {
|
|
352
|
+
error: unknown;
|
|
353
|
+
info?: {
|
|
354
|
+
componentStack: string;
|
|
355
|
+
};
|
|
356
|
+
reset: () => void;
|
|
357
|
+
};
|
|
358
|
+
export type ErrorComponentProps = {
|
|
359
|
+
error: Error;
|
|
360
|
+
info?: {
|
|
361
|
+
componentStack: string;
|
|
362
|
+
};
|
|
363
|
+
reset: () => void;
|
|
364
|
+
};
|
|
365
|
+
export type NotFoundRouteProps = {
|
|
366
|
+
data: unknown;
|
|
367
|
+
};
|
|
368
|
+
export declare class BaseRoute<in out TParentRoute extends AnyRoute = AnyRoute, in out TPath extends string = '/', in out TFullPath extends string = ResolveFullPath<TParentRoute, TPath>, in out TCustomId extends string = string, in out TId extends string = ResolveId<TParentRoute, TCustomId, TPath>, in out TSearchValidator = undefined, in out TParams = ResolveParams<TPath>, in out TRouterContext = AnyContext, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown> {
|
|
369
|
+
isRoot: TParentRoute extends AnyRoute ? true : false;
|
|
370
|
+
options: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>;
|
|
371
|
+
parentRoute: TParentRoute;
|
|
372
|
+
private _id;
|
|
373
|
+
private _path;
|
|
374
|
+
private _fullPath;
|
|
375
|
+
private _to;
|
|
376
|
+
private _ssr;
|
|
377
|
+
get to(): TrimPathRight<TFullPath>;
|
|
378
|
+
get id(): TId;
|
|
379
|
+
get path(): TPath;
|
|
380
|
+
get fullPath(): TFullPath;
|
|
381
|
+
get ssr(): boolean;
|
|
382
|
+
children?: TChildren;
|
|
383
|
+
originalIndex?: number;
|
|
384
|
+
rank: number;
|
|
385
|
+
lazyFn?: () => Promise<LazyRoute<Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>>>;
|
|
386
|
+
_lazyPromise?: Promise<void>;
|
|
387
|
+
_componentsPromise?: Promise<Array<void>>;
|
|
388
|
+
constructor(options?: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>);
|
|
389
|
+
types: RouteTypes<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>;
|
|
390
|
+
init: (opts: {
|
|
391
|
+
originalIndex: number;
|
|
392
|
+
defaultSsr?: boolean;
|
|
393
|
+
}) => void;
|
|
394
|
+
clone: (other: typeof this) => void;
|
|
395
|
+
addChildren: RouteAddChildrenFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TFileRouteTypes>;
|
|
396
|
+
_addFileChildren: RouteAddFileChildrenFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TFileRouteTypes>;
|
|
397
|
+
_addFileTypes: RouteAddFileTypesFn<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren>;
|
|
398
|
+
updateLoader: <TNewLoaderFn>(options: {
|
|
399
|
+
loader: Constrain<TNewLoaderFn, RouteLoaderFn<TParentRoute, TCustomId, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>>;
|
|
400
|
+
}) => BaseRoute<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TNewLoaderFn, TChildren, TFileRouteTypes>;
|
|
401
|
+
update: (options: UpdatableRouteOptions<TParentRoute, TCustomId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => this;
|
|
402
|
+
lazy: RouteLazyFn<Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>>;
|
|
403
|
+
}
|
|
404
|
+
export declare class BaseRouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {
|
|
405
|
+
id: TId;
|
|
406
|
+
constructor({ id }: {
|
|
407
|
+
id: TId;
|
|
408
|
+
});
|
|
409
|
+
notFound: (opts?: NotFoundError) => NotFoundError;
|
|
410
|
+
}
|
|
411
|
+
export interface RootRoute<in out TSearchValidator = undefined, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown> extends Route<any, // TParentRoute
|
|
412
|
+
'/', // TPath
|
|
413
|
+
'/', // TFullPath
|
|
414
|
+
string, // TCustomId
|
|
415
|
+
RootRouteId, // TId
|
|
416
|
+
TSearchValidator, // TSearchValidator
|
|
417
|
+
{}, // TParams
|
|
418
|
+
TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, // TChildren
|
|
419
|
+
TFileRouteTypes> {
|
|
420
|
+
}
|
|
421
|
+
export declare class BaseRootRoute<in out TSearchValidator = undefined, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown> extends BaseRoute<any, // TParentRoute
|
|
422
|
+
'/', // TPath
|
|
423
|
+
'/', // TFullPath
|
|
424
|
+
string, // TCustomId
|
|
425
|
+
RootRouteId, // TId
|
|
426
|
+
TSearchValidator, // TSearchValidator
|
|
427
|
+
{}, // TParams
|
|
428
|
+
TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, // TChildren
|
|
429
|
+
TFileRouteTypes> {
|
|
430
|
+
constructor(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>);
|
|
431
|
+
}
|
|
432
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import invariant from "tiny-invariant";
|
|
2
|
+
import { trimPathLeft, joinPaths } from "./path.js";
|
|
3
|
+
import { notFound } from "./not-found.js";
|
|
4
|
+
import { rootRouteId } from "./root.js";
|
|
5
|
+
class BaseRoute {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.init = (opts) => {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
this.originalIndex = opts.originalIndex;
|
|
10
|
+
const options2 = this.options;
|
|
11
|
+
const isRoot = !(options2 == null ? void 0 : options2.path) && !(options2 == null ? void 0 : options2.id);
|
|
12
|
+
this.parentRoute = (_b = (_a = this.options).getParentRoute) == null ? void 0 : _b.call(_a);
|
|
13
|
+
if (isRoot) {
|
|
14
|
+
this._path = rootRouteId;
|
|
15
|
+
} else if (!this.parentRoute) {
|
|
16
|
+
invariant(
|
|
17
|
+
false,
|
|
18
|
+
`Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
let path = isRoot ? rootRouteId : options2 == null ? void 0 : options2.path;
|
|
22
|
+
if (path && path !== "/") {
|
|
23
|
+
path = trimPathLeft(path);
|
|
24
|
+
}
|
|
25
|
+
const customId = (options2 == null ? void 0 : options2.id) || path;
|
|
26
|
+
let id = isRoot ? rootRouteId : joinPaths([
|
|
27
|
+
this.parentRoute.id === rootRouteId ? "" : this.parentRoute.id,
|
|
28
|
+
customId
|
|
29
|
+
]);
|
|
30
|
+
if (path === rootRouteId) {
|
|
31
|
+
path = "/";
|
|
32
|
+
}
|
|
33
|
+
if (id !== rootRouteId) {
|
|
34
|
+
id = joinPaths(["/", id]);
|
|
35
|
+
}
|
|
36
|
+
const fullPath = id === rootRouteId ? "/" : joinPaths([this.parentRoute.fullPath, path]);
|
|
37
|
+
this._path = path;
|
|
38
|
+
this._id = id;
|
|
39
|
+
this._fullPath = fullPath;
|
|
40
|
+
this._to = fullPath;
|
|
41
|
+
this._ssr = (options2 == null ? void 0 : options2.ssr) ?? opts.defaultSsr ?? true;
|
|
42
|
+
};
|
|
43
|
+
this.clone = (other) => {
|
|
44
|
+
this._path = other._path;
|
|
45
|
+
this._id = other._id;
|
|
46
|
+
this._fullPath = other._fullPath;
|
|
47
|
+
this._to = other._to;
|
|
48
|
+
this._ssr = other._ssr;
|
|
49
|
+
this.options.getParentRoute = other.options.getParentRoute;
|
|
50
|
+
this.children = other.children;
|
|
51
|
+
};
|
|
52
|
+
this.addChildren = (children) => {
|
|
53
|
+
return this._addFileChildren(children);
|
|
54
|
+
};
|
|
55
|
+
this._addFileChildren = (children) => {
|
|
56
|
+
if (Array.isArray(children)) {
|
|
57
|
+
this.children = children;
|
|
58
|
+
}
|
|
59
|
+
if (typeof children === "object" && children !== null) {
|
|
60
|
+
this.children = Object.values(children);
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
};
|
|
64
|
+
this._addFileTypes = () => {
|
|
65
|
+
return this;
|
|
66
|
+
};
|
|
67
|
+
this.updateLoader = (options2) => {
|
|
68
|
+
Object.assign(this.options, options2);
|
|
69
|
+
return this;
|
|
70
|
+
};
|
|
71
|
+
this.update = (options2) => {
|
|
72
|
+
Object.assign(this.options, options2);
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
75
|
+
this.lazy = (lazyFn) => {
|
|
76
|
+
this.lazyFn = lazyFn;
|
|
77
|
+
return this;
|
|
78
|
+
};
|
|
79
|
+
this.options = options || {};
|
|
80
|
+
this.isRoot = !(options == null ? void 0 : options.getParentRoute);
|
|
81
|
+
if ((options == null ? void 0 : options.id) && (options == null ? void 0 : options.path)) {
|
|
82
|
+
throw new Error(`Route cannot have both an 'id' and a 'path' option.`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
get to() {
|
|
86
|
+
return this._to;
|
|
87
|
+
}
|
|
88
|
+
get id() {
|
|
89
|
+
return this._id;
|
|
90
|
+
}
|
|
91
|
+
get path() {
|
|
92
|
+
return this._path;
|
|
93
|
+
}
|
|
94
|
+
get fullPath() {
|
|
95
|
+
return this._fullPath;
|
|
96
|
+
}
|
|
97
|
+
get ssr() {
|
|
98
|
+
return this._ssr;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
class BaseRouteApi {
|
|
102
|
+
constructor({ id }) {
|
|
103
|
+
this.notFound = (opts) => {
|
|
104
|
+
return notFound({ routeId: this.id, ...opts });
|
|
105
|
+
};
|
|
106
|
+
this.id = id;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
class BaseRootRoute extends BaseRoute {
|
|
110
|
+
constructor(options) {
|
|
111
|
+
super(options);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
BaseRootRoute,
|
|
116
|
+
BaseRoute,
|
|
117
|
+
BaseRouteApi
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=route.js.map
|