@tanstack/react-router 1.31.29 → 1.32.2
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.d.cts +6 -9
- package/dist/cjs/RouterProvider.d.cts +6 -6
- package/dist/cjs/awaited.d.cts +1 -1
- package/dist/cjs/defer.d.cts +1 -0
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +38 -79
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +4 -3
- package/dist/cjs/lazyRouteComponent.d.cts +2 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +56 -50
- package/dist/cjs/location.d.cts +3 -2
- package/dist/cjs/not-found.d.cts +2 -2
- package/dist/cjs/path.d.cts +3 -2
- package/dist/cjs/redirects.d.cts +5 -4
- package/dist/cjs/route.cjs +1 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +59 -52
- package/dist/cjs/routeInfo.d.cts +12 -11
- package/dist/cjs/router.cjs +2 -2
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +19 -20
- package/dist/cjs/routerContext.d.cts +1 -1
- package/dist/cjs/scroll-restoration.d.cts +2 -1
- package/dist/cjs/searchParams.d.cts +2 -1
- package/dist/cjs/useBlocker.d.cts +3 -2
- package/dist/cjs/useLocation.cjs +10 -0
- package/dist/cjs/useLocation.cjs.map +1 -0
- package/dist/cjs/useLocation.d.cts +5 -0
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useNavigate.d.cts +5 -4
- package/dist/cjs/useParams.d.cts +5 -5
- package/dist/cjs/useRouteContext.d.cts +5 -4
- package/dist/cjs/useRouter.d.cts +2 -1
- package/dist/cjs/useRouterState.d.cts +2 -1
- package/dist/cjs/useSearch.d.cts +5 -4
- package/dist/esm/Matches.d.ts +6 -9
- package/dist/esm/RouterProvider.d.ts +6 -6
- package/dist/esm/awaited.d.ts +1 -1
- package/dist/esm/defer.d.ts +1 -0
- package/dist/esm/fileRoute.d.ts +38 -79
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lazyRouteComponent.d.ts +2 -1
- package/dist/esm/link.d.ts +56 -50
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/location.d.ts +3 -2
- package/dist/esm/not-found.d.ts +2 -2
- package/dist/esm/path.d.ts +3 -2
- package/dist/esm/redirects.d.ts +5 -4
- package/dist/esm/route.d.ts +59 -52
- package/dist/esm/route.js +1 -1
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/routeInfo.d.ts +12 -11
- package/dist/esm/router.d.ts +19 -20
- package/dist/esm/router.js +2 -2
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.d.ts +1 -1
- package/dist/esm/scroll-restoration.d.ts +2 -1
- package/dist/esm/searchParams.d.ts +2 -1
- package/dist/esm/useBlocker.d.ts +3 -2
- package/dist/esm/useLocation.d.ts +5 -0
- package/dist/esm/useLocation.js +10 -0
- package/dist/esm/useLocation.js.map +1 -0
- package/dist/esm/useNavigate.d.ts +5 -4
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.d.ts +5 -5
- package/dist/esm/useRouteContext.d.ts +5 -4
- package/dist/esm/useRouter.d.ts +2 -1
- package/dist/esm/useRouterState.d.ts +2 -1
- package/dist/esm/useSearch.d.ts +5 -4
- package/package.json +2 -10
- package/src/fileRoute.ts +26 -104
- package/src/index.tsx +1 -8
- package/src/link.tsx +205 -156
- package/src/route.ts +121 -106
- package/src/routeInfo.ts +24 -22
- package/src/useLocation.tsx +15 -0
- package/src/useNavigate.tsx +2 -2
package/dist/cjs/route.d.cts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { UseNavigateResult } from './useNavigate.cjs';
|
|
2
|
+
import { MakeRouteMatch, RouteMatch } from './Matches.cjs';
|
|
3
|
+
import { NavigateOptions, ParsePathParams, ToSubOptions } from './link.cjs';
|
|
4
|
+
import { ParsedLocation } from './location.cjs';
|
|
5
|
+
import { RouteById, RouteIds, RoutePaths } from './routeInfo.cjs';
|
|
6
|
+
import { AnyRouter, RegisteredRouter, Router } from './router.cjs';
|
|
7
|
+
import { Assign, Expand, IsAny, NoInfer, PickRequired, UnionToIntersection } from './utils.cjs';
|
|
8
|
+
import { BuildLocationFn, NavigateFn } from './RouterProvider.cjs';
|
|
9
|
+
import { NotFoundError } from './not-found.cjs';
|
|
10
|
+
import { LazyRoute } from './fileRoute.cjs';
|
|
11
|
+
|
|
2
12
|
import type * as React from 'react';
|
|
3
|
-
import type { MakeRouteMatch, RouteMatch } from './Matches.cjs';
|
|
4
|
-
import type { NavigateOptions, ParsePathParams, ToSubOptions } from './link.cjs';
|
|
5
|
-
import type { ParsedLocation } from './location.cjs';
|
|
6
|
-
import type { RouteById, RouteIds, RoutePaths } from './routeInfo.cjs';
|
|
7
|
-
import type { AnyRouter, RegisteredRouter, Router } from './router.cjs';
|
|
8
|
-
import type { Assign, Expand, IsAny, NoInfer, PickRequired, UnionToIntersection } from './utils.cjs';
|
|
9
|
-
import type { BuildLocationFn, NavigateFn } from './RouterProvider.cjs';
|
|
10
|
-
import type { NotFoundError } from './not-found.cjs';
|
|
11
|
-
import type { LazyRoute } from './fileRoute.cjs';
|
|
12
13
|
export declare const rootRouteId: "__root__";
|
|
13
14
|
export type RootRouteId = typeof rootRouteId;
|
|
14
15
|
export type AnyPathParams = {};
|
|
@@ -30,9 +31,9 @@ export type RoutePathOptions<TCustomId, TPath> = {
|
|
|
30
31
|
export interface StaticDataRouteOption {
|
|
31
32
|
}
|
|
32
33
|
export type RoutePathOptionsIntersection<TCustomId, TPath> = UnionToIntersection<RoutePathOptions<TCustomId, TPath>>;
|
|
33
|
-
export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchemaInput
|
|
34
|
+
export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchemaInput = {}, TSearchSchema = {}, TSearchSchemaUsed = {}, TFullSearchSchemaInput = TSearchSchemaUsed, TFullSearchSchema = TSearchSchema, TParams = AnyPathParams, TAllParams = TParams, TRouteContextReturn = RouteContext, TRouteContext = RouteContext, TRouterContext = AnyContext, TAllContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn> = BaseRouteOptions<TParentRoute, TCustomId, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn> & UpdatableRouteOptions<NoInfer<TCustomId>, NoInfer<TAllParams>, NoInfer<TFullSearchSchema>, NoInfer<TLoaderData>, NoInfer<TAllContext>, NoInfer<TRouteContext>, NoInfer<TLoaderDeps>>;
|
|
34
35
|
export type ParamsFallback<TPath extends string, TParams> = unknown extends TParams ? Record<ParsePathParams<TPath>, string> : TParams;
|
|
35
|
-
export type FileBaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TPath extends string = string, TSearchSchemaInput
|
|
36
|
+
export type FileBaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TPath extends string = string, TSearchSchemaInput = {}, TSearchSchema = {}, TFullSearchSchema = TSearchSchema, TParams = {}, TAllParams = ParamsFallback<TPath, TParams>, TRouteContextReturn = RouteContext, TRouteContext = RouteContext, TRouterContext = AnyContext, TAllContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown> = {
|
|
36
37
|
validateSearch?: SearchSchemaValidator<TSearchSchemaInput, TSearchSchema>;
|
|
37
38
|
shouldReload?: boolean | ((match: LoaderFnContext<TAllParams, TFullSearchSchema, TAllContext, TRouteContext>) => any);
|
|
38
39
|
beforeLoad?: BeforeLoadFn<TFullSearchSchema, TParentRoute, TAllParams, TRouteContextReturn, TRouterContext>;
|
|
@@ -47,10 +48,10 @@ export type FileBaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TPath
|
|
|
47
48
|
stringifyParams?: never;
|
|
48
49
|
parseParams?: never;
|
|
49
50
|
});
|
|
50
|
-
export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchemaInput
|
|
51
|
+
export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchemaInput = {}, TSearchSchema = {}, TSearchSchemaUsed = {}, TFullSearchSchemaInput = TSearchSchemaUsed, TFullSearchSchema = TSearchSchema, TParams = {}, TAllParams = ParamsFallback<TPath, TParams>, TRouteContextReturn = RouteContext, TRouteContext = RouteContext, TRouterContext = AnyContext, TAllContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown> = RoutePathOptions<TCustomId, TPath> & FileBaseRouteOptions<TParentRoute, TPath, TSearchSchemaInput, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn> & {
|
|
51
52
|
getParentRoute: () => TParentRoute;
|
|
52
53
|
};
|
|
53
|
-
type BeforeLoadFn<in out TFullSearchSchema, in out TParentRoute extends AnyRoute, in out TAllParams, TRouteContextReturn
|
|
54
|
+
type BeforeLoadFn<in out TFullSearchSchema, in out TParentRoute extends AnyRoute, in out TAllParams, TRouteContextReturn, in out TRouterContext = AnyContext, in out TContext = IsAny<TParentRoute['types']['allContext'], TRouterContext>> = (opts: {
|
|
54
55
|
search: TFullSearchSchema;
|
|
55
56
|
abortController: AbortController;
|
|
56
57
|
preload: boolean;
|
|
@@ -164,11 +165,19 @@ export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
|
|
|
164
165
|
fullSearchSchemaInput: infer TFullSearchSchemaInput;
|
|
165
166
|
};
|
|
166
167
|
} ? TFullSearchSchemaInput : {};
|
|
167
|
-
export type
|
|
168
|
-
export type
|
|
168
|
+
export type ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema> = TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, keyof SearchSchemaInput> : TSearchSchema;
|
|
169
|
+
export type ResolveFullSearchSchema<TParentRoute extends AnyRoute, TSearchSchema> = unknown extends TParentRoute ? Omit<TSearchSchema, keyof RootSearchSchema> : Assign<TParentRoute['id'] extends RootRouteId ? Omit<TParentRoute['types']['searchSchema'], keyof RootSearchSchema> : TParentRoute['types']['fullSearchSchema'], TSearchSchema>;
|
|
170
|
+
export type ResolveFullSearchSchemaInput<TParentRoute extends AnyRoute, TSearchSchemaUsed> = unknown extends TParentRoute ? Omit<TSearchSchemaUsed, keyof RootSearchSchema> : Assign<TParentRoute['id'] extends RootRouteId ? Omit<TParentRoute['types']['searchSchemaInput'], keyof RootSearchSchema> : TParentRoute['types']['fullSearchSchemaInput'], TSearchSchemaUsed>;
|
|
171
|
+
export type ResolveRouteContext<TRouteContextReturn> = [
|
|
172
|
+
TRouteContextReturn
|
|
173
|
+
] extends [never] ? RouteContext : TRouteContextReturn;
|
|
174
|
+
export type ResolveAllContext<TParentRoute extends AnyRoute, TRouteContext> = Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>;
|
|
175
|
+
export type ResolveLoaderData<TLoaderDataReturn> = [TLoaderDataReturn] extends [
|
|
176
|
+
never
|
|
177
|
+
] ? undefined : TLoaderDataReturn;
|
|
169
178
|
export interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
|
|
170
179
|
}
|
|
171
|
-
export type
|
|
180
|
+
export type ResolveAllParamsFromParent<TParentRoute extends AnyRoute, TParams> = unknown extends TParentRoute ? TParams : Assign<TParentRoute['types']['allParams'], TParams>;
|
|
172
181
|
export type ResolveAllParams<TParentRoute extends AnyRoute, TParams> = Record<never, string> extends TParentRoute['types']['allParams'] ? TParams : UnionToIntersection<TParentRoute['types']['allParams'] & TParams> & {};
|
|
173
182
|
export type RouteConstraints = {
|
|
174
183
|
TParentRoute: AnyRoute;
|
|
@@ -197,27 +206,27 @@ export declare class RouteApi<TId extends RouteIds<RegisteredRouter['routeTree']
|
|
|
197
206
|
id: TId;
|
|
198
207
|
});
|
|
199
208
|
useMatch: <TRouteTree extends AnyRoute = any, TRouteMatch = MakeRouteMatch<TRouteTree, TId>, TSelected = TRouteMatch>(opts?: {
|
|
200
|
-
select?: (
|
|
201
|
-
}
|
|
209
|
+
select?: (match: TRouteMatch) => TSelected;
|
|
210
|
+
}) => TSelected;
|
|
202
211
|
useRouteContext: <TSelected = Expand<TAllContext>>(opts?: {
|
|
203
|
-
select?: (
|
|
204
|
-
}
|
|
212
|
+
select?: (s: Expand<TAllContext>) => TSelected;
|
|
213
|
+
}) => TSelected;
|
|
205
214
|
useSearch: <TSelected = Expand<TFullSearchSchema>>(opts?: {
|
|
206
|
-
select?: (
|
|
207
|
-
}
|
|
215
|
+
select?: (s: Expand<TFullSearchSchema>) => TSelected;
|
|
216
|
+
}) => TSelected;
|
|
208
217
|
useParams: <TSelected = Expand<TAllParams>>(opts?: {
|
|
209
|
-
select?: (
|
|
210
|
-
}
|
|
218
|
+
select?: (s: Expand<TAllParams>) => TSelected;
|
|
219
|
+
}) => TSelected;
|
|
211
220
|
useLoaderDeps: <TSelected = TLoaderDeps>(opts?: {
|
|
212
|
-
select?: (
|
|
213
|
-
}
|
|
221
|
+
select?: (s: TLoaderDeps) => TSelected;
|
|
222
|
+
}) => TSelected;
|
|
214
223
|
useLoaderData: <TSelected = TLoaderData>(opts?: {
|
|
215
|
-
select?: (
|
|
216
|
-
}
|
|
224
|
+
select?: (s: TLoaderData) => TSelected;
|
|
225
|
+
}) => TSelected;
|
|
217
226
|
useNavigate: () => UseNavigateResult<string>;
|
|
218
227
|
notFound: (opts?: NotFoundError) => NotFoundError;
|
|
219
228
|
}
|
|
220
|
-
export declare class Route<in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, in out TPath extends RouteConstraints['TPath'] = '/', in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, in out TCustomId extends RouteConstraints['TCustomId'] = string, in out TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, in out TSearchSchemaInput
|
|
229
|
+
export declare class Route<in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, in out TPath extends RouteConstraints['TPath'] = '/', in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, in out TCustomId extends RouteConstraints['TCustomId'] = string, in out TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, in out TSearchSchemaInput = {}, in out TSearchSchema = {}, in out TSearchSchemaUsed = ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema>, in out TFullSearchSchemaInput = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, in out TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, in out TParams = Record<ParsePathParams<TPath>, string>, in out TAllParams = ResolveAllParams<TParentRoute, TParams>, TRouteContextReturn = RouteContext, in out TRouteContext = ResolveRouteContext<TRouteContextReturn>, in out TAllContext = Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>, in out TRouterContext = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>, in out TChildren = unknown> {
|
|
221
230
|
isRoot: TParentRoute extends Route<any> ? true : false;
|
|
222
231
|
options: RouteOptions<TParentRoute, TCustomId, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>;
|
|
223
232
|
parentRoute: TParentRoute;
|
|
@@ -258,35 +267,35 @@ export declare class Route<in out TParentRoute extends RouteConstraints['TParent
|
|
|
258
267
|
init: (opts: {
|
|
259
268
|
originalIndex: number;
|
|
260
269
|
}) => void;
|
|
261
|
-
addChildren: <const TNewChildren extends readonly AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TNewChildren>;
|
|
270
|
+
addChildren: <const TNewChildren extends Record<string, AnyRoute> | readonly AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TNewChildren>;
|
|
262
271
|
updateLoader: <TNewLoaderData = unknown>(options: {
|
|
263
272
|
loader: RouteLoaderFn<TAllParams, TLoaderDeps, TAllContext, TRouteContext, TNewLoaderData>;
|
|
264
273
|
}) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TNewLoaderData, TChildren, unknown>;
|
|
265
274
|
update: (options: UpdatableRouteOptions<TCustomId, TAllParams, TFullSearchSchema, TLoaderData, TAllContext, TRouteContext, TLoaderDeps>) => this;
|
|
266
275
|
lazy: (lazyFn: () => Promise<LazyRoute<any>>) => this;
|
|
267
276
|
useMatch: <TRouteTree extends AnyRoute = any, TRouteMatch = MakeRouteMatch<TRouteTree, TId>, TSelected = TRouteMatch>(opts?: {
|
|
268
|
-
select?: (
|
|
269
|
-
}
|
|
277
|
+
select?: (match: TRouteMatch) => TSelected;
|
|
278
|
+
}) => TSelected;
|
|
270
279
|
useRouteContext: <TSelected = Expand<TAllContext>>(opts?: {
|
|
271
|
-
select?: (
|
|
272
|
-
}
|
|
280
|
+
select?: (search: Expand<TAllContext>) => TSelected;
|
|
281
|
+
}) => TSelected;
|
|
273
282
|
useSearch: <TSelected = Expand<TFullSearchSchema>>(opts?: {
|
|
274
|
-
select?: (
|
|
275
|
-
}
|
|
283
|
+
select?: (search: Expand<TFullSearchSchema>) => TSelected;
|
|
284
|
+
}) => TSelected;
|
|
276
285
|
useParams: <TSelected = Expand<TAllParams>>(opts?: {
|
|
277
|
-
select?: (
|
|
278
|
-
}
|
|
286
|
+
select?: (search: Expand<TAllParams>) => TSelected;
|
|
287
|
+
}) => TSelected;
|
|
279
288
|
useLoaderDeps: <TSelected = TLoaderDeps>(opts?: {
|
|
280
|
-
select?: (
|
|
281
|
-
}
|
|
289
|
+
select?: (s: TLoaderDeps) => TSelected;
|
|
290
|
+
}) => TSelected;
|
|
282
291
|
useLoaderData: <TSelected = TLoaderData>(opts?: {
|
|
283
|
-
select?: (
|
|
284
|
-
}
|
|
292
|
+
select?: (search: TLoaderData) => TSelected;
|
|
293
|
+
}) => TSelected;
|
|
285
294
|
useNavigate: () => UseNavigateResult<string>;
|
|
286
295
|
}
|
|
287
|
-
export declare function createRoute<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>, TSearchSchemaInput
|
|
296
|
+
export declare function createRoute<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>, TSearchSchemaInput = {}, TSearchSchema = {}, TSearchSchemaUsed = ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema>, TFullSearchSchemaInput = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams = Record<ParsePathParams<TPath>, string>, TAllParams = ResolveAllParams<TParentRoute, TParams>, TRouteContextReturn = RouteContext, TRouteContext = ResolveRouteContext<TRouteContextReturn>, TAllContext = Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>, TRouterContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = ResolveLoaderData<TLoaderDataReturn>, TChildren = unknown>(options: RouteOptions<TParentRoute, TCustomId, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren>;
|
|
288
297
|
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>;
|
|
289
|
-
export type RootRouteOptions<TSearchSchemaInput
|
|
298
|
+
export type RootRouteOptions<TSearchSchemaInput = RootSearchSchema, TSearchSchema = RootSearchSchema, TSearchSchemaUsed = RootSearchSchema, TRouteContextReturn = RouteContext, TRouteContext = ResolveRouteContext<TRouteContextReturn>, TRouterContext = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = ResolveLoaderData<TLoaderDataReturn>> = Omit<RouteOptions<any, // TParentRoute
|
|
290
299
|
RootRouteId, // TCustomId
|
|
291
300
|
'', // TPath
|
|
292
301
|
TSearchSchemaInput, // TSearchSchemaInput
|
|
@@ -300,7 +309,7 @@ TRouteContext, // TRouteContext
|
|
|
300
309
|
TRouterContext, Assign<TRouterContext, TRouteContext>, // TAllContext
|
|
301
310
|
TLoaderDeps, TLoaderDataReturn, // TLoaderDataReturn,
|
|
302
311
|
TLoaderData>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams'>;
|
|
303
|
-
export declare function createRootRouteWithContext<TRouterContext extends {}>(): <TSearchSchemaInput extends Record<string, any> = RootSearchSchema, TSearchSchema extends Record<string, any> = RootSearchSchema, TSearchSchemaUsed extends Record<string, any> = RootSearchSchema, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn>(options?: RootRouteOptions<TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TRouteContextReturn, TRouteContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>
|
|
312
|
+
export declare function createRootRouteWithContext<TRouterContext extends {}>(): <TSearchSchemaInput extends Record<string, any> = RootSearchSchema, TSearchSchema extends Record<string, any> = RootSearchSchema, TSearchSchemaUsed extends Record<string, any> = RootSearchSchema, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn>(options?: RootRouteOptions<TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TRouteContextReturn, TRouteContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>) => RootRoute<TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TRouteContextReturn, TRouteContext, TRouterContext, TLoaderDeps, TLoaderData, ResolveLoaderData<TLoaderData>>;
|
|
304
313
|
/**
|
|
305
314
|
* @deprecated Use the `createRootRouteWithContext` function instead.
|
|
306
315
|
*/
|
|
@@ -308,9 +317,7 @@ export declare const rootRouteWithContext: typeof createRootRouteWithContext;
|
|
|
308
317
|
export type RootSearchSchema = {
|
|
309
318
|
__TRootSearchSchema__: '__TRootSearchSchema__';
|
|
310
319
|
};
|
|
311
|
-
export declare class RootRoute<in out TSearchSchemaInput
|
|
312
|
-
never
|
|
313
|
-
] ? RouteContext : TRouteContextReturn, in out TRouterContext extends {} = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, in out TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn> extends Route<any, // TParentRoute
|
|
320
|
+
export declare class RootRoute<in out TSearchSchemaInput = RootSearchSchema, in out TSearchSchema = RootSearchSchema, in out TSearchSchemaUsed = RootSearchSchema, TRouteContextReturn = RouteContext, in out TRouteContext = ResolveRouteContext<TRouteContextReturn>, in out TRouterContext = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>> extends Route<any, // TParentRoute
|
|
314
321
|
'/', // TPath
|
|
315
322
|
'/', // TFullPath
|
|
316
323
|
string, // TCustomId
|
|
@@ -331,7 +338,7 @@ TLoaderDeps, TLoaderDataReturn, TLoaderData, any> {
|
|
|
331
338
|
*/
|
|
332
339
|
constructor(options?: RootRouteOptions<TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TRouteContextReturn, TRouteContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>);
|
|
333
340
|
}
|
|
334
|
-
export declare function createRootRoute<TSearchSchemaInput
|
|
341
|
+
export declare function createRootRoute<TSearchSchemaInput = RootSearchSchema, TSearchSchema = RootSearchSchema, TSearchSchemaUsed = RootSearchSchema, TRouteContextReturn = RouteContext, TRouteContext = ResolveRouteContext<TRouteContextReturn>, TRouterContext = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = ResolveLoaderData<TLoaderDataReturn>>(options?: Omit<RouteOptions<any, // TParentRoute
|
|
335
342
|
RootRouteId, // TCustomId
|
|
336
343
|
'', // TPath
|
|
337
344
|
TSearchSchemaInput, // TSearchSchemaInput
|
|
@@ -387,10 +394,10 @@ export type SyncRouteComponent<TProps> = ((props: TProps) => ReactNode) | React.
|
|
|
387
394
|
export type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {
|
|
388
395
|
preload?: () => Promise<void>;
|
|
389
396
|
};
|
|
390
|
-
export type RouteComponent<TProps = any> =
|
|
397
|
+
export type RouteComponent<TProps = any> = AsyncRouteComponent<TProps>;
|
|
391
398
|
export type ErrorRouteComponent = RouteComponent<ErrorComponentProps>;
|
|
392
399
|
export type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>;
|
|
393
|
-
export declare class NotFoundRoute<TParentRoute extends AnyRootRoute, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema
|
|
400
|
+
export declare class NotFoundRoute<TParentRoute extends AnyRootRoute, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema = {}, TSearchSchemaUsed = {}, TFullSearchSchemaInput = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TRouteContextReturn = AnyContext, TRouteContext = RouteContext, TAllContext = Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>, TRouterContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = ResolveLoaderData<TLoaderDataReturn>, TChildren = unknown> extends Route<TParentRoute, '/404', '/404', '404', '404', TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, {}, {}, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren> {
|
|
394
401
|
constructor(options: Omit<RouteOptions<TParentRoute, string, string, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, {}, {}, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>, 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'path' | 'id'>);
|
|
395
402
|
}
|
|
396
403
|
export {};
|
package/dist/cjs/routeInfo.d.cts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { AnyRoute } from './route.cjs';
|
|
2
|
+
import { AnyRouter, TrailingSlashOption } from './router.cjs';
|
|
3
|
+
import { UnionToIntersection, UnionToTuple } from './utils.cjs';
|
|
4
|
+
|
|
4
5
|
export type ParseRoute<TRouteTree, TAcc = TRouteTree> = TRouteTree extends {
|
|
5
6
|
types: {
|
|
6
7
|
children: infer TChildren;
|
|
7
8
|
};
|
|
8
|
-
} ? TChildren extends ReadonlyArray<any> ? ParseRoute<TChildren[number], TAcc | TChildren[number]> : TAcc : TAcc;
|
|
9
|
-
export type ParseRouteWithoutBranches<TRouteTree> = ParseRoute<TRouteTree> extends infer TRoute extends AnyRoute ? TRoute extends any ? TRoute['types']['children'] extends ReadonlyArray<any> ? '/' extends TRoute['types']['children'][number]['path'] ? never : TRoute : TRoute : never : never;
|
|
9
|
+
} ? unknown extends TChildren ? TAcc : TChildren extends ReadonlyArray<any> ? ParseRoute<TChildren[number], TAcc | TChildren[number]> : ParseRoute<TChildren[keyof TChildren], TAcc | TChildren[keyof TChildren]> : TAcc;
|
|
10
|
+
export type ParseRouteWithoutBranches<TRouteTree> = ParseRoute<TRouteTree> extends infer TRoute extends AnyRoute ? TRoute extends any ? unknown extends TRoute['types']['children'] ? TRoute : TRoute['types']['children'] extends ReadonlyArray<any> ? '/' extends TRoute['types']['children'][number]['path'] ? never : TRoute : '/' extends TRoute['types']['children'][keyof TRoute['types']['children']]['path'] ? never : TRoute : never : never;
|
|
10
11
|
export type RoutesById<TRouteTree extends AnyRoute> = {
|
|
11
12
|
[K in ParseRoute<TRouteTree> as K['id']]: K;
|
|
12
13
|
};
|
|
13
14
|
export type RouteById<TRouteTree extends AnyRoute, TId> = Extract<RoutesById<TRouteTree>[TId], AnyRoute>;
|
|
14
15
|
export type RouteIds<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['id'];
|
|
15
|
-
export type CatchAllPaths
|
|
16
|
+
export type CatchAllPaths = '.' | '..' | '';
|
|
16
17
|
export type RoutesByPath<TRouteTree extends AnyRoute> = {
|
|
17
18
|
[K in ParseRoute<TRouteTree> as K['fullPath']]: K;
|
|
18
|
-
}
|
|
19
|
-
export type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<
|
|
19
|
+
};
|
|
20
|
+
export type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<RoutesByPath<TRouteTree>[TPath], AnyRoute>;
|
|
20
21
|
export type RoutePaths<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['fullPath'] | '/';
|
|
21
22
|
export type RouteToPathAlwaysTrailingSlash<TRoute extends AnyRoute> = TRoute['path'] extends '/' ? TRoute['fullPath'] : TRoute['fullPath'] extends '/' ? TRoute['fullPath'] : `${TRoute['fullPath']}/`;
|
|
22
23
|
export type RouteToPathNeverTrailingSlash<TRoute extends AnyRoute> = TRoute['path'] extends '/' ? TRoute['fullPath'] extends '/' ? TRoute['fullPath'] : TRoute['fullPath'] extends `${infer TRest}/` ? TRest : TRoute['fullPath'] : TRoute['fullPath'];
|
|
@@ -31,9 +32,9 @@ export type RouteToByRouter<TRouter extends AnyRouter, TRoute extends AnyRoute>
|
|
|
31
32
|
export type RouteToPath<TRouter extends AnyRouter, TRouteTree extends AnyRoute> = ParseRouteWithoutBranches<TRouteTree> extends infer TRoute extends AnyRoute ? TRoute extends any ? RouteToByRouter<TRouter, TRoute> : never : never;
|
|
32
33
|
export type RoutesByToPath<TRouter extends AnyRouter> = {
|
|
33
34
|
[TRoute in ParseRouteWithoutBranches<TRouter['routeTree']> as RouteToByRouter<TRouter, TRoute>]: TRoute;
|
|
34
|
-
}
|
|
35
|
-
export type RouteByToPath<TRouter extends AnyRouter, TTo> = Extract<
|
|
36
|
-
export type RoutePathsAutoComplete<
|
|
35
|
+
};
|
|
36
|
+
export type RouteByToPath<TRouter extends AnyRouter, TTo> = Extract<RoutesByToPath<TRouter>[TTo], AnyRoute>;
|
|
37
|
+
export type RoutePathsAutoComplete<TRouter extends AnyRouter, T> = (string extends T ? T & {} : T) | RoutePaths<TRouter['routeTree']>;
|
|
37
38
|
type UnionizeCollisions<T, U> = {
|
|
38
39
|
[P in keyof T & keyof U]: T[P] extends U[P] ? T[P] : T[P] | U[P];
|
|
39
40
|
};
|
package/dist/cjs/router.cjs
CHANGED
|
@@ -724,10 +724,10 @@ class Router {
|
|
|
724
724
|
const isMatched = this.state.matches.find((d) => d.id === id);
|
|
725
725
|
const matchesKey = isPending ? "pendingMatches" : isMatched ? "matches" : "cachedMatches";
|
|
726
726
|
this.__store.setState((s) => {
|
|
727
|
-
var _a2
|
|
727
|
+
var _a2;
|
|
728
728
|
return {
|
|
729
729
|
...s,
|
|
730
|
-
[matchesKey]: (
|
|
730
|
+
[matchesKey]: (_a2 = s[matchesKey]) == null ? void 0 : _a2.map(
|
|
731
731
|
(d) => d.id === id ? updated = updater(d) : d
|
|
732
732
|
)
|
|
733
733
|
};
|