@tanstack/react-router 0.0.1-beta.274 → 0.0.1-beta.275
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/build/cjs/Matches.js.map +1 -1
- package/build/cjs/fileRoute.js.map +1 -1
- package/build/cjs/redirects.js.map +1 -1
- package/build/cjs/route.js.map +1 -1
- package/build/cjs/router.js +14 -6
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +14 -6
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +351 -351
- package/build/types/Matches.d.ts +2 -1
- package/build/types/fileRoute.d.ts +2 -2
- package/build/types/redirects.d.ts +1 -1
- package/build/types/route.d.ts +22 -22
- package/build/types/routeInfo.d.ts +1 -1
- package/build/umd/index.development.js +14 -6
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/Matches.tsx +2 -1
- package/src/fileRoute.ts +3 -0
- package/src/redirects.ts +1 -1
- package/src/route.ts +29 -18
- package/src/routeInfo.ts +2 -0
- package/src/router.ts +15 -6
package/build/types/Matches.d.ts
CHANGED
|
@@ -26,8 +26,9 @@ export interface RouteMatch<TRouteTree extends AnyRoute = AnyRoute, TRouteId ext
|
|
|
26
26
|
shouldReloadDeps: any;
|
|
27
27
|
abortController: AbortController;
|
|
28
28
|
cause: 'preload' | 'enter' | 'stay';
|
|
29
|
+
loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps'];
|
|
29
30
|
}
|
|
30
|
-
export type AnyRouteMatch = RouteMatch<any>;
|
|
31
|
+
export type AnyRouteMatch = RouteMatch<any, any>;
|
|
31
32
|
export declare function Matches(): React.JSX.Element;
|
|
32
33
|
export declare function Match({ matchId }: {
|
|
33
34
|
matchId: string;
|
|
@@ -13,7 +13,7 @@ export type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends strin
|
|
|
13
13
|
export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = TFilePath, TPath extends RouteConstraints['TPath'] = FileRoutePath<TParentRoute, TFilePath>, TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, RemoveUnderScores<TPath>>> {
|
|
14
14
|
path: TFilePath;
|
|
15
15
|
constructor(path: TFilePath);
|
|
16
|
-
createRoute: <TSearchSchema extends import("./route").AnySearchSchema = {}, TFullSearchSchema extends import("./route").AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = Expand<Record<ParsePathParams<TPath>, string>>, TAllParams extends Record<string, any> = MergeFromFromParent<TParentRoute["types"]["allParams"], TParams>, TRouteContext extends RouteContext = RouteContext, TContext extends Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>>, TRouterContext extends AnyContext = AnyContext, TLoaderData extends unknown = unknown, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options?: (Omit<RouteOptions<TParentRoute, string, TPath, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TContext, TLoaderData>, "path" | "id" | "getParentRoute"> & {
|
|
16
|
+
createRoute: <TSearchSchema extends import("./route").AnySearchSchema = {}, TFullSearchSchema extends import("./route").AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = Expand<Record<ParsePathParams<TPath>, string>>, TAllParams extends Record<string, any> = MergeFromFromParent<TParentRoute["types"]["allParams"], TParams>, TRouteContext extends RouteContext = RouteContext, TContext extends Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute["types"]["allContext"], {}>, TRouteContext>>, TRouterContext extends AnyContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends unknown = unknown, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options?: (Omit<RouteOptions<TParentRoute, string, TPath, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TContext, TLoaderDeps, TLoaderData>, "path" | "id" | "getParentRoute"> & {
|
|
17
17
|
meta?: import("./route").RouteMeta | undefined;
|
|
18
18
|
} & {
|
|
19
19
|
caseSensitive?: boolean | undefined;
|
|
@@ -29,6 +29,6 @@ export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParent
|
|
|
29
29
|
onEnter?: ((match: import("./Matches").AnyRouteMatch) => void) | undefined;
|
|
30
30
|
onStay?: ((match: import("./Matches").AnyRouteMatch) => void) | undefined;
|
|
31
31
|
onLeave?: ((match: import("./Matches").AnyRouteMatch) => void) | undefined;
|
|
32
|
-
}) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TContext, TRouterContext, TLoaderData, TChildren, TRouteTree>;
|
|
32
|
+
}) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TContext, TRouterContext, TLoaderDeps, TLoaderData, TChildren, TRouteTree>;
|
|
33
33
|
}
|
|
34
34
|
export {};
|
|
@@ -2,7 +2,7 @@ import { NavigateOptions } from './link';
|
|
|
2
2
|
import { AnyRoute } from './route';
|
|
3
3
|
import { RoutePaths } from './routeInfo';
|
|
4
4
|
import { RegisteredRouter } from './router';
|
|
5
|
-
export type AnyRedirect = Redirect<any, any, any>;
|
|
5
|
+
export type AnyRedirect = Redirect<any, any, any, any, any>;
|
|
6
6
|
export type Redirect<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''> = {
|
|
7
7
|
code?: number;
|
|
8
8
|
throw?: any;
|
package/build/types/route.d.ts
CHANGED
|
@@ -29,9 +29,9 @@ export type MetaOptions = keyof PickRequired<RouteMeta> extends never ? {
|
|
|
29
29
|
} : {
|
|
30
30
|
meta: RouteMeta;
|
|
31
31
|
};
|
|
32
|
-
export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchema extends Record<string, any> = {}, TFullSearchSchema extends Record<string, any> = TSearchSchema, TParams extends AnyPathParams = AnyPathParams, TAllParams extends AnyPathParams = TParams, TRouteContext extends RouteContext = RouteContext, TAllContext extends Record<string, any> = AnyContext, TLoaderData extends any = unknown> = BaseRouteOptions<TParentRoute, TCustomId, TPath, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TAllContext, TLoaderData> & UpdatableRouteOptions<NoInfer<TFullSearchSchema>>;
|
|
32
|
+
export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchema extends Record<string, any> = {}, TFullSearchSchema extends Record<string, any> = TSearchSchema, TParams extends AnyPathParams = AnyPathParams, TAllParams extends AnyPathParams = TParams, TRouteContext extends RouteContext = RouteContext, TAllContext extends Record<string, any> = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends any = unknown> = BaseRouteOptions<TParentRoute, TCustomId, TPath, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TAllContext, TLoaderDeps, TLoaderData> & UpdatableRouteOptions<NoInfer<TFullSearchSchema>>;
|
|
33
33
|
export type ParamsFallback<TPath extends string, TParams> = unknown extends TParams ? Record<ParsePathParams<TPath>, string> : TParams;
|
|
34
|
-
export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchema extends Record<string, any> = {}, TFullSearchSchema extends Record<string, any> = TSearchSchema, TParams extends AnyPathParams = {}, TAllParams = ParamsFallback<TPath, TParams>, TRouteContext extends RouteContext = RouteContext, TAllContext extends Record<string, any> = AnyContext, TLoaderData extends any = unknown> = RoutePathOptions<TCustomId, TPath> & {
|
|
34
|
+
export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchema extends Record<string, any> = {}, TFullSearchSchema extends Record<string, any> = TSearchSchema, TParams extends AnyPathParams = {}, TAllParams = ParamsFallback<TPath, TParams>, TRouteContext extends RouteContext = RouteContext, TAllContext extends Record<string, any> = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends any = unknown> = RoutePathOptions<TCustomId, TPath> & {
|
|
35
35
|
getParentRoute: () => TParentRoute;
|
|
36
36
|
validateSearch?: SearchSchemaValidator<TSearchSchema>;
|
|
37
37
|
shouldReload?: boolean | ((match: LoaderFnContext<TAllParams, TFullSearchSchema, TAllContext, TRouteContext>) => any);
|
|
@@ -40,11 +40,10 @@ export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId
|
|
|
40
40
|
} : {
|
|
41
41
|
beforeLoad: BeforeLoadFn<TFullSearchSchema, TParentRoute, TAllParams, TRouteContext>;
|
|
42
42
|
}) & {
|
|
43
|
-
|
|
43
|
+
loaderDeps?: (opts: {
|
|
44
44
|
search: TFullSearchSchema;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
loader?: RouteLoaderFn<TAllParams, TFullSearchSchema, NoInfer<TAllContext>, NoInfer<TRouteContext>, TLoaderData>;
|
|
45
|
+
}) => TLoaderDeps;
|
|
46
|
+
loader?: RouteLoaderFn<TAllParams, NoInfer<TLoaderDeps>, NoInfer<TAllContext>, NoInfer<TRouteContext>, TLoaderData>;
|
|
48
47
|
} & ({
|
|
49
48
|
parseParams?: (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams extends Record<ParsePathParams<TPath>, any> ? TParams : 'parseParams must return an object';
|
|
50
49
|
stringifyParams?: (params: NoInfer<ParamsFallback<TPath, TParams>>) => Record<ParsePathParams<TPath>, string>;
|
|
@@ -92,14 +91,14 @@ export type DefinedPathParamWarning = 'Path params cannot be redefined by child
|
|
|
92
91
|
export type ParentParams<TParentParams> = AnyPathParams extends TParentParams ? {} : {
|
|
93
92
|
[Key in keyof TParentParams]?: DefinedPathParamWarning;
|
|
94
93
|
};
|
|
95
|
-
export type RouteLoaderFn<TAllParams = {},
|
|
96
|
-
export interface LoaderFnContext<TAllParams = {},
|
|
94
|
+
export type RouteLoaderFn<TAllParams = {}, TLoaderDeps extends Record<string, any> = {}, TAllContext extends Record<string, any> = AnyContext, TRouteContext extends Record<string, any> = AnyContext, TLoaderData extends any = unknown> = (match: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext, TRouteContext>) => Promise<TLoaderData> | TLoaderData;
|
|
95
|
+
export interface LoaderFnContext<TAllParams = {}, TLoaderDeps extends Record<string, any> = {}, TAllContext extends Record<string, any> = AnyContext, TRouteContext extends Record<string, any> = AnyContext> {
|
|
97
96
|
abortController: AbortController;
|
|
98
97
|
preload: boolean;
|
|
99
98
|
params: TAllParams;
|
|
100
|
-
|
|
99
|
+
deps: TLoaderDeps;
|
|
101
100
|
context: Expand<Assign<TAllContext, TRouteContext>>;
|
|
102
|
-
location: ParsedLocation
|
|
101
|
+
location: ParsedLocation;
|
|
103
102
|
navigate: (opts: NavigateOptions<AnyRoute>) => Promise<void>;
|
|
104
103
|
parentMatchPromise?: Promise<void>;
|
|
105
104
|
cause: 'preload' | 'enter' | 'stay';
|
|
@@ -114,7 +113,7 @@ export type InferFullSearchSchema<TRoute> = TRoute extends {
|
|
|
114
113
|
};
|
|
115
114
|
} ? TFullSearchSchema : {};
|
|
116
115
|
export type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = Expand<Assign<InferFullSearchSchema<TParentRoute>, TSearchSchema>>;
|
|
117
|
-
export interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
|
|
116
|
+
export interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
|
|
118
117
|
}
|
|
119
118
|
export type MergeFromFromParent<T, U> = IsAny<T, U, T & U>;
|
|
120
119
|
export type ResolveAllParams<TParentRoute extends AnyRoute, TParams extends AnyPathParams> = Record<never, string> extends TParentRoute['types']['allParams'] ? TParams : Expand<UnionToIntersection<TParentRoute['types']['allParams'] & TParams> & {}>;
|
|
@@ -156,9 +155,9 @@ export declare class RouteApi<TId extends RouteIds<RegisteredRouter['routeTree']
|
|
|
156
155
|
select?: ((search: TLoaderData) => TSelected) | undefined;
|
|
157
156
|
} | undefined) => TSelected;
|
|
158
157
|
}
|
|
159
|
-
export declare class Route<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends RouteConstraints['TParams'] = Expand<Record<ParsePathParams<TPath>, string>>, TAllParams extends RouteConstraints['TAllParams'] = ResolveAllParams<TParentRoute, TParams>, TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext, TAllContext extends Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TLoaderData extends any = unknown, TChildren extends RouteConstraints['TChildren'] = unknown, TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute> {
|
|
158
|
+
export declare class Route<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends RouteConstraints['TParams'] = Expand<Record<ParsePathParams<TPath>, string>>, TAllParams extends RouteConstraints['TAllParams'] = ResolveAllParams<TParentRoute, TParams>, TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext, TAllContext extends Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends any = unknown, TChildren extends RouteConstraints['TChildren'] = unknown, TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute> {
|
|
160
159
|
isRoot: TParentRoute extends Route<any> ? true : false;
|
|
161
|
-
options: RouteOptions<TParentRoute, TCustomId, TPath, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TAllContext, TLoaderData>;
|
|
160
|
+
options: RouteOptions<TParentRoute, TCustomId, TPath, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TAllContext, TLoaderDeps, TLoaderData>;
|
|
162
161
|
test: Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>>;
|
|
163
162
|
parentRoute: TParentRoute;
|
|
164
163
|
id: TId;
|
|
@@ -169,7 +168,7 @@ export declare class Route<TParentRoute extends RouteConstraints['TParentRoute']
|
|
|
169
168
|
originalIndex?: number;
|
|
170
169
|
router?: AnyRouter;
|
|
171
170
|
rank: number;
|
|
172
|
-
constructor(options: RouteOptions<TParentRoute, TCustomId, TPath, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TAllContext, TLoaderData>);
|
|
171
|
+
constructor(options: RouteOptions<TParentRoute, TCustomId, TPath, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TAllContext, TLoaderDeps, TLoaderData>);
|
|
173
172
|
types: {
|
|
174
173
|
parentRoute: TParentRoute;
|
|
175
174
|
path: TPath;
|
|
@@ -187,11 +186,12 @@ export declare class Route<TParentRoute extends RouteConstraints['TParentRoute']
|
|
|
187
186
|
routeTree: TRouteTree;
|
|
188
187
|
routerContext: TRouterContext;
|
|
189
188
|
loaderData: TLoaderData;
|
|
189
|
+
loaderDeps: TLoaderDeps;
|
|
190
190
|
};
|
|
191
191
|
init: (opts: {
|
|
192
192
|
originalIndex: number;
|
|
193
193
|
}) => void;
|
|
194
|
-
addChildren: <TNewChildren extends AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TAllContext, TRouterContext, TNewChildren, TRouteTree
|
|
194
|
+
addChildren: <TNewChildren extends AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderData, TNewChildren, TRouteTree>;
|
|
195
195
|
update: (options: UpdatableRouteOptions<TFullSearchSchema>) => this;
|
|
196
196
|
useMatch: <TSelected = TAllContext>(opts?: {
|
|
197
197
|
select?: ((search: TAllContext) => TSelected) | undefined;
|
|
@@ -209,9 +209,9 @@ export declare class Route<TParentRoute extends RouteConstraints['TParentRoute']
|
|
|
209
209
|
select?: ((search: TLoaderData) => TSelected) | undefined;
|
|
210
210
|
} | undefined) => TSelected;
|
|
211
211
|
}
|
|
212
|
-
export type AnyRootRoute = RootRoute<any, any, any>;
|
|
213
|
-
export declare function rootRouteWithContext<TRouterContext extends {}>(): <TSearchSchema extends Record<string, any> = {}, TRouteContext extends RouteContext = RouteContext, TLoaderData extends unknown = unknown>(options?: Omit<RouteOptions<AnyRoute, "__root__", "", TSearchSchema, TSearchSchema, {}, {}, TRouteContext, Assign<TRouterContext, TRouteContext>, TLoaderData>, "path" | "id" | "getParentRoute" | "stringifyParams" | "parseParams" | "caseSensitive"> | undefined) => RootRoute<TSearchSchema, TRouteContext, TRouterContext, unknown>;
|
|
214
|
-
export declare class RootRoute<TSearchSchema extends Record<string, any> = {}, TRouteContext extends RouteContext = RouteContext, TRouterContext extends {} = {}, TLoaderData extends any = unknown> extends Route<any, // TParentRoute
|
|
212
|
+
export type AnyRootRoute = RootRoute<any, any, any, any>;
|
|
213
|
+
export declare function rootRouteWithContext<TRouterContext extends {}>(): <TSearchSchema extends Record<string, any> = {}, TRouteContext extends RouteContext = RouteContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends unknown = unknown>(options?: Omit<RouteOptions<AnyRoute, "__root__", "", TSearchSchema, TSearchSchema, {}, {}, TRouteContext, Assign<TRouterContext, TRouteContext>, TLoaderDeps, TLoaderData>, "path" | "id" | "getParentRoute" | "stringifyParams" | "parseParams" | "caseSensitive"> | undefined) => RootRoute<TSearchSchema, TRouteContext, TRouterContext, {}, unknown>;
|
|
214
|
+
export declare class RootRoute<TSearchSchema extends Record<string, any> = {}, TRouteContext extends RouteContext = RouteContext, TRouterContext extends {} = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends any = unknown> extends Route<any, // TParentRoute
|
|
215
215
|
'/', // TPath
|
|
216
216
|
'/', // TFullPath
|
|
217
217
|
string, // TCustomId
|
|
@@ -223,7 +223,7 @@ TSearchSchema, // TFullSearchSchema
|
|
|
223
223
|
TRouteContext, // TRouteContext
|
|
224
224
|
Expand<Assign<TRouterContext, TRouteContext>>, // TAllContext
|
|
225
225
|
TRouterContext, // TRouterContext
|
|
226
|
-
TLoaderData, any, // TChildren
|
|
226
|
+
TLoaderDeps, TLoaderData, any, // TChildren
|
|
227
227
|
any> {
|
|
228
228
|
constructor(options?: Omit<RouteOptions<AnyRoute, // TParentRoute
|
|
229
229
|
RootRouteId, // TCustomId
|
|
@@ -234,7 +234,7 @@ any> {
|
|
|
234
234
|
{}, // TAllParams
|
|
235
235
|
TRouteContext, // TRouteContext
|
|
236
236
|
Assign<TRouterContext, TRouteContext>, // TAllContext
|
|
237
|
-
TLoaderData>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams'>);
|
|
237
|
+
TLoaderDeps, TLoaderData>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams'>);
|
|
238
238
|
}
|
|
239
239
|
export type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;
|
|
240
240
|
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;
|
|
@@ -267,7 +267,7 @@ export type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {
|
|
|
267
267
|
};
|
|
268
268
|
export type RouteComponent<TProps = any> = SyncRouteComponent<TProps> & AsyncRouteComponent<TProps>;
|
|
269
269
|
export type ErrorRouteComponent = RouteComponent<ErrorRouteProps>;
|
|
270
|
-
export declare class NotFoundRoute<TParentRoute extends AnyRootRoute, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext, TAllContext extends Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TLoaderData extends any = unknown, TChildren extends RouteConstraints['TChildren'] = unknown, TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute> extends Route<TParentRoute, '/404', '/404', '404', '404', TSearchSchema, TFullSearchSchema, {}, {}, TRouteContext, TAllContext, TRouterContext, TLoaderData, TChildren, TRouteTree> {
|
|
271
|
-
constructor(options: Omit<RouteOptions<TParentRoute, string, string, TSearchSchema, TFullSearchSchema, {}, {}, TRouteContext, TAllContext, TLoaderData>, 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'path' | 'id'>);
|
|
270
|
+
export declare class NotFoundRoute<TParentRoute extends AnyRootRoute, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext, TAllContext extends Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>> = Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderData extends any = unknown, TChildren extends RouteConstraints['TChildren'] = unknown, TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute> extends Route<TParentRoute, '/404', '/404', '404', '404', TSearchSchema, TFullSearchSchema, {}, {}, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderData, TChildren, TRouteTree> {
|
|
271
|
+
constructor(options: Omit<RouteOptions<TParentRoute, string, string, TSearchSchema, TFullSearchSchema, {}, {}, TRouteContext, TAllContext, TLoaderDeps, TLoaderData>, 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'path' | 'id'>);
|
|
272
272
|
}
|
|
273
273
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyRoute, Route } from './route';
|
|
2
2
|
import { Expand, UnionToIntersection } from './utils';
|
|
3
3
|
export type ParseRoute<TRouteTree extends AnyRoute> = TRouteTree | ParseRouteChildren<TRouteTree>;
|
|
4
|
-
export type ParseRouteChildren<TRouteTree extends AnyRoute> = TRouteTree extends Route<any, any, any, any, any, any, any, any, any, any, any, any, infer TChildren, any> ? unknown extends TChildren ? never : TChildren extends AnyRoute[] ? {
|
|
4
|
+
export type ParseRouteChildren<TRouteTree extends AnyRoute> = TRouteTree extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, infer TChildren, any> ? unknown extends TChildren ? never : TChildren extends AnyRoute[] ? {
|
|
5
5
|
[TId in TChildren[number]['id'] as string]: ParseRoute<TChildren[number]>;
|
|
6
6
|
}[string] : never : never;
|
|
7
7
|
export type RoutesById<TRouteTree extends AnyRoute> = {
|
|
@@ -2265,11 +2265,18 @@
|
|
|
2265
2265
|
return [parentSearch, searchError];
|
|
2266
2266
|
}
|
|
2267
2267
|
})();
|
|
2268
|
+
|
|
2269
|
+
// This is where we need to call route.options.loaderDeps() to get any additional
|
|
2270
|
+
// deps that the route's loader function might need to run. We need to do this
|
|
2271
|
+
// before we create the match so that we can pass the deps to the route's
|
|
2272
|
+
// potential key function which is used to uniquely identify the route match in state
|
|
2273
|
+
|
|
2274
|
+
const loaderDeps = route.options.loaderDeps?.({
|
|
2275
|
+
search: preMatchSearch
|
|
2276
|
+
}) ?? '';
|
|
2277
|
+
const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : '';
|
|
2268
2278
|
const interpolatedPath = interpolatePath(route.fullPath, routeParams);
|
|
2269
|
-
const matchId = interpolatePath(route.id, routeParams, true) +
|
|
2270
|
-
search: preMatchSearch,
|
|
2271
|
-
location: this.state.location
|
|
2272
|
-
}) ?? '');
|
|
2279
|
+
const matchId = interpolatePath(route.id, routeParams, true) + loaderDepsHash;
|
|
2273
2280
|
|
|
2274
2281
|
// Waste not, want not. If we already have a match for this route,
|
|
2275
2282
|
// reuse it. This is important for layout routes, which might stick
|
|
@@ -2301,7 +2308,8 @@
|
|
|
2301
2308
|
abortController: new AbortController(),
|
|
2302
2309
|
shouldReloadDeps: undefined,
|
|
2303
2310
|
fetchCount: 0,
|
|
2304
|
-
cause
|
|
2311
|
+
cause,
|
|
2312
|
+
loaderDeps
|
|
2305
2313
|
};
|
|
2306
2314
|
|
|
2307
2315
|
// Regardless of whether we're reusing an existing match or creating
|
|
@@ -2625,7 +2633,7 @@
|
|
|
2625
2633
|
} else {
|
|
2626
2634
|
const loaderContext = {
|
|
2627
2635
|
params: match.params,
|
|
2628
|
-
|
|
2636
|
+
deps: match.loaderDeps,
|
|
2629
2637
|
preload: !!preload,
|
|
2630
2638
|
parentMatchPromise,
|
|
2631
2639
|
abortController: match.abortController,
|