@tanstack/react-router 1.109.2 → 1.111.6
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.map +1 -1
- package/dist/cjs/Matches.d.cts +1 -3
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +0 -25
- package/dist/cjs/fileRoute.cjs +4 -1
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +5 -17
- package/dist/cjs/index.d.cts +7 -9
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +1 -73
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +1 -1
- package/dist/cjs/redirects.cjs.map +1 -1
- package/dist/cjs/redirects.d.cts +2 -18
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +10 -57
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +2 -9
- package/dist/cjs/typePrimitives.d.cts +4 -6
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useBlocker.d.cts +1 -1
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderData.d.cts +2 -6
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.d.cts +2 -6
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useMatch.d.cts +1 -2
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useNavigate.d.cts +1 -2
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +2 -6
- package/dist/cjs/useRouteContext.cjs.map +1 -1
- package/dist/cjs/useRouteContext.d.cts +1 -9
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +2 -6
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +1 -11
- package/dist/esm/Matches.d.ts +1 -3
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +0 -25
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +5 -17
- package/dist/esm/fileRoute.js +4 -1
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +7 -9
- package/dist/esm/link.d.ts +1 -73
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/not-found.d.ts +1 -1
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/redirects.d.ts +2 -18
- package/dist/esm/redirects.js.map +1 -1
- package/dist/esm/route.d.ts +10 -57
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +2 -9
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/typePrimitives.d.ts +4 -6
- package/dist/esm/useBlocker.d.ts +1 -1
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useLoaderData.d.ts +2 -6
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.d.ts +2 -6
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useMatch.d.ts +1 -2
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useNavigate.d.ts +1 -2
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.d.ts +2 -6
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.d.ts +1 -9
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useSearch.d.ts +2 -6
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -11
- package/dist/esm/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/Matches.tsx +11 -15
- package/src/RouterProvider.tsx +0 -48
- package/src/fileRoute.ts +22 -43
- package/src/index.tsx +30 -43
- package/src/link.tsx +4 -427
- package/src/not-found.tsx +1 -1
- package/src/redirects.ts +6 -36
- package/src/route.ts +103 -167
- package/src/router.ts +13 -25
- package/src/typePrimitives.ts +11 -7
- package/src/useBlocker.tsx +1 -1
- package/src/useLoaderData.tsx +6 -21
- package/src/useLoaderDeps.tsx +6 -14
- package/src/useMatch.tsx +1 -2
- package/src/useNavigate.tsx +5 -12
- package/src/useParams.tsx +7 -21
- package/src/useRouteContext.ts +5 -37
- package/src/useSearch.tsx +7 -21
- package/src/utils.ts +0 -17
- package/dist/cjs/routeInfo.d.cts +0 -53
- package/dist/esm/routeInfo.d.ts +0 -53
- package/src/routeInfo.ts +0 -239
package/src/route.ts
CHANGED
|
@@ -12,38 +12,46 @@ import type {
|
|
|
12
12
|
AnyPathParams,
|
|
13
13
|
AnySchema,
|
|
14
14
|
AnyValidator,
|
|
15
|
-
|
|
15
|
+
BeforeLoadContextParameter,
|
|
16
|
+
BuildLocationFn,
|
|
16
17
|
Constrain,
|
|
17
18
|
ConstrainLiteral,
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
RootRoute as CoreRootRoute,
|
|
20
|
+
Route as CoreRoute,
|
|
20
21
|
DefaultValidator,
|
|
21
22
|
ErrorComponentProps,
|
|
22
23
|
Expand,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
InferFullSearchSchemaInput,
|
|
27
|
-
IntersectAssign,
|
|
24
|
+
FullSearchSchemaOption,
|
|
25
|
+
NavigateFn,
|
|
26
|
+
NavigateOptions,
|
|
28
27
|
NoInfer,
|
|
29
28
|
NotFoundRouteProps,
|
|
30
29
|
ParamsOptions,
|
|
31
30
|
ParsedLocation,
|
|
31
|
+
RemountDepsOptions,
|
|
32
|
+
ResolveAllContext,
|
|
33
|
+
ResolveAllParamsFromParent,
|
|
34
|
+
ResolveFullPath,
|
|
35
|
+
ResolveFullSearchSchema,
|
|
36
|
+
ResolveFullSearchSchemaInput,
|
|
32
37
|
ResolveId,
|
|
33
38
|
ResolveLoaderData,
|
|
34
39
|
ResolveParams,
|
|
35
|
-
ResolveRouteContext,
|
|
36
|
-
ResolveSearchValidatorInput,
|
|
37
|
-
ResolveValidatorOutput,
|
|
38
40
|
RootRouteId,
|
|
41
|
+
RouteById,
|
|
39
42
|
RouteContext,
|
|
43
|
+
RouteContextParameter,
|
|
44
|
+
RouteIds,
|
|
40
45
|
RoutePathOptions,
|
|
41
46
|
RoutePathOptionsIntersection,
|
|
42
|
-
|
|
47
|
+
RoutePaths,
|
|
48
|
+
RouteTypes,
|
|
43
49
|
SearchFilter,
|
|
44
50
|
SearchMiddleware,
|
|
51
|
+
ToMaskOptions,
|
|
45
52
|
TrimPathRight,
|
|
46
53
|
UpdatableStaticRouteOption,
|
|
54
|
+
UseNavigateResult,
|
|
47
55
|
} from '@tanstack/router-core'
|
|
48
56
|
import type { UseLoaderDataRoute } from './useLoaderData'
|
|
49
57
|
import type { UseMatchRoute } from './useMatch'
|
|
@@ -51,20 +59,15 @@ import type { UseLoaderDepsRoute } from './useLoaderDeps'
|
|
|
51
59
|
import type { UseParamsRoute } from './useParams'
|
|
52
60
|
import type { UseSearchRoute } from './useSearch'
|
|
53
61
|
import type * as React from 'react'
|
|
54
|
-
import type { UseNavigateResult } from './useNavigate'
|
|
55
62
|
import type {
|
|
56
63
|
AnyRouteMatch,
|
|
57
64
|
MakeRouteMatchFromRoute,
|
|
58
65
|
MakeRouteMatchUnion,
|
|
59
66
|
RouteMatch,
|
|
60
67
|
} from './Matches'
|
|
61
|
-
import type { NavigateOptions, ToMaskOptions } from './link'
|
|
62
|
-
import type { ParseRoute, RouteById, RouteIds, RoutePaths } from './routeInfo'
|
|
63
68
|
import type { AnyRouter, RegisteredRouter, Router } from './router'
|
|
64
|
-
import type { BuildLocationFn, NavigateFn } from './RouterProvider'
|
|
65
69
|
import type { NotFoundError } from './not-found'
|
|
66
70
|
import type { LazyRoute } from './fileRoute'
|
|
67
|
-
|
|
68
71
|
import type { UseRouteContextRoute } from './useRouteContext'
|
|
69
72
|
|
|
70
73
|
export type RouteOptions<
|
|
@@ -106,13 +109,6 @@ export type RouteOptions<
|
|
|
106
109
|
NoInfer<TBeforeLoadFn>
|
|
107
110
|
>
|
|
108
111
|
|
|
109
|
-
export interface FullSearchSchemaOption<
|
|
110
|
-
in out TParentRoute extends AnyRoute,
|
|
111
|
-
in out TSearchValidator,
|
|
112
|
-
> {
|
|
113
|
-
search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
|
|
114
|
-
}
|
|
115
|
-
|
|
116
112
|
export type RouteContextFn<
|
|
117
113
|
in out TParentRoute extends AnyRoute,
|
|
118
114
|
in out TSearchValidator,
|
|
@@ -288,30 +284,6 @@ export interface RouteContextOptions<
|
|
|
288
284
|
context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>
|
|
289
285
|
}
|
|
290
286
|
|
|
291
|
-
export interface RemountDepsOptions<
|
|
292
|
-
in out TRouteId,
|
|
293
|
-
in out TFullSearchSchema,
|
|
294
|
-
in out TAllParams,
|
|
295
|
-
in out TLoaderDeps,
|
|
296
|
-
> {
|
|
297
|
-
routeId: TRouteId
|
|
298
|
-
search: TFullSearchSchema
|
|
299
|
-
params: TAllParams
|
|
300
|
-
loaderDeps: TLoaderDeps
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
export type MakeRemountDepsOptionsUnion<
|
|
304
|
-
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
305
|
-
TRoute extends AnyRoute = ParseRoute<TRouteTree>,
|
|
306
|
-
> = TRoute extends any
|
|
307
|
-
? RemountDepsOptions<
|
|
308
|
-
TRoute['id'],
|
|
309
|
-
TRoute['types']['fullSearchSchema'],
|
|
310
|
-
TRoute['types']['allParams'],
|
|
311
|
-
TRoute['types']['loaderDeps']
|
|
312
|
-
>
|
|
313
|
-
: never
|
|
314
|
-
|
|
315
287
|
export interface BeforeLoadContextOptions<
|
|
316
288
|
in out TParentRoute extends AnyRoute,
|
|
317
289
|
in out TSearchValidator,
|
|
@@ -570,50 +542,6 @@ export interface LoaderFnContext<
|
|
|
570
542
|
route: Route
|
|
571
543
|
}
|
|
572
544
|
|
|
573
|
-
export type ResolveFullSearchSchema<
|
|
574
|
-
TParentRoute extends AnyRoute,
|
|
575
|
-
TSearchValidator,
|
|
576
|
-
> = unknown extends TParentRoute
|
|
577
|
-
? ResolveValidatorOutput<TSearchValidator>
|
|
578
|
-
: IntersectAssign<
|
|
579
|
-
InferFullSearchSchema<TParentRoute>,
|
|
580
|
-
ResolveValidatorOutput<TSearchValidator>
|
|
581
|
-
>
|
|
582
|
-
|
|
583
|
-
export type ResolveFullSearchSchemaInput<
|
|
584
|
-
TParentRoute extends AnyRoute,
|
|
585
|
-
TSearchValidator,
|
|
586
|
-
> = IntersectAssign<
|
|
587
|
-
InferFullSearchSchemaInput<TParentRoute>,
|
|
588
|
-
ResolveSearchValidatorInput<TSearchValidator>
|
|
589
|
-
>
|
|
590
|
-
|
|
591
|
-
export type RouteContextParameter<
|
|
592
|
-
TParentRoute extends AnyRoute,
|
|
593
|
-
TRouterContext,
|
|
594
|
-
> = unknown extends TParentRoute
|
|
595
|
-
? TRouterContext
|
|
596
|
-
: Assign<TRouterContext, InferAllContext<TParentRoute>>
|
|
597
|
-
|
|
598
|
-
export type BeforeLoadContextParameter<
|
|
599
|
-
TParentRoute extends AnyRoute,
|
|
600
|
-
TRouterContext,
|
|
601
|
-
TRouteContextFn,
|
|
602
|
-
> = Assign<
|
|
603
|
-
RouteContextParameter<TParentRoute, TRouterContext>,
|
|
604
|
-
ContextReturnType<TRouteContextFn>
|
|
605
|
-
>
|
|
606
|
-
|
|
607
|
-
export type ResolveAllContext<
|
|
608
|
-
TParentRoute extends AnyRoute,
|
|
609
|
-
TRouterContext,
|
|
610
|
-
TRouteContextFn,
|
|
611
|
-
TBeforeLoadFn,
|
|
612
|
-
> = Assign<
|
|
613
|
-
BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>,
|
|
614
|
-
ContextAsyncReturnType<TBeforeLoadFn>
|
|
615
|
-
>
|
|
616
|
-
|
|
617
545
|
export interface AnyRoute
|
|
618
546
|
extends Route<
|
|
619
547
|
any,
|
|
@@ -628,18 +556,10 @@ export interface AnyRoute
|
|
|
628
556
|
any,
|
|
629
557
|
any,
|
|
630
558
|
any,
|
|
559
|
+
any,
|
|
631
560
|
any
|
|
632
561
|
> {}
|
|
633
562
|
|
|
634
|
-
export type AnyRouteWithContext<TContext> = AnyRoute & {
|
|
635
|
-
types: { allContext: TContext }
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
export type ResolveAllParamsFromParent<
|
|
639
|
-
TParentRoute extends AnyRoute,
|
|
640
|
-
TParams,
|
|
641
|
-
> = Assign<InferAllParams<TParentRoute>, TParams>
|
|
642
|
-
|
|
643
563
|
export type RouteConstraints = {
|
|
644
564
|
TParentRoute: AnyRoute
|
|
645
565
|
TPath: string
|
|
@@ -753,7 +673,25 @@ export class Route<
|
|
|
753
673
|
in out TLoaderDeps extends Record<string, any> = {},
|
|
754
674
|
in out TLoaderFn = undefined,
|
|
755
675
|
in out TChildren = unknown,
|
|
756
|
-
|
|
676
|
+
in out TFileRouteTypes = unknown,
|
|
677
|
+
> implements
|
|
678
|
+
CoreRoute<
|
|
679
|
+
TParentRoute,
|
|
680
|
+
TPath,
|
|
681
|
+
TFullPath,
|
|
682
|
+
TCustomId,
|
|
683
|
+
TId,
|
|
684
|
+
TSearchValidator,
|
|
685
|
+
TParams,
|
|
686
|
+
TRouterContext,
|
|
687
|
+
TRouteContextFn,
|
|
688
|
+
TBeforeLoadFn,
|
|
689
|
+
TLoaderDeps,
|
|
690
|
+
TLoaderFn,
|
|
691
|
+
TChildren,
|
|
692
|
+
TFileRouteTypes
|
|
693
|
+
>
|
|
694
|
+
{
|
|
757
695
|
isRoot: TParentRoute extends Route<any> ? true : false
|
|
758
696
|
options: RouteOptions<
|
|
759
697
|
TParentRoute,
|
|
@@ -852,37 +790,22 @@ export class Route<
|
|
|
852
790
|
;(this as any).$$typeof = Symbol.for('react.memo')
|
|
853
791
|
}
|
|
854
792
|
|
|
855
|
-
types!:
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
allParams: ResolveAllParamsFromParent<TParentRoute, TParams>
|
|
872
|
-
routerContext: TRouterContext
|
|
873
|
-
routeContext: ResolveRouteContext<TRouteContextFn, TBeforeLoadFn>
|
|
874
|
-
routeContextFn: TRouteContextFn
|
|
875
|
-
beforeLoadFn: TBeforeLoadFn
|
|
876
|
-
allContext: ResolveAllContext<
|
|
877
|
-
TParentRoute,
|
|
878
|
-
TRouterContext,
|
|
879
|
-
TRouteContextFn,
|
|
880
|
-
TBeforeLoadFn
|
|
881
|
-
>
|
|
882
|
-
children: TChildren
|
|
883
|
-
loaderData: ResolveLoaderData<TLoaderFn>
|
|
884
|
-
loaderDeps: TLoaderDeps
|
|
885
|
-
}
|
|
793
|
+
types!: RouteTypes<
|
|
794
|
+
TParentRoute,
|
|
795
|
+
TPath,
|
|
796
|
+
TFullPath,
|
|
797
|
+
TCustomId,
|
|
798
|
+
TId,
|
|
799
|
+
TSearchValidator,
|
|
800
|
+
TParams,
|
|
801
|
+
TRouterContext,
|
|
802
|
+
TRouteContextFn,
|
|
803
|
+
TBeforeLoadFn,
|
|
804
|
+
TLoaderDeps,
|
|
805
|
+
TLoaderFn,
|
|
806
|
+
TChildren,
|
|
807
|
+
TFileRouteTypes
|
|
808
|
+
>
|
|
886
809
|
|
|
887
810
|
init = (opts: { originalIndex: number; defaultSsr?: boolean }): void => {
|
|
888
811
|
this.originalIndex = opts.originalIndex
|
|
@@ -973,7 +896,8 @@ export class Route<
|
|
|
973
896
|
TBeforeLoadFn,
|
|
974
897
|
TLoaderDeps,
|
|
975
898
|
TLoaderFn,
|
|
976
|
-
TNewChildren
|
|
899
|
+
TNewChildren,
|
|
900
|
+
TFileRouteTypes
|
|
977
901
|
> {
|
|
978
902
|
return this._addFileChildren(children) as Route<
|
|
979
903
|
TParentRoute,
|
|
@@ -988,7 +912,8 @@ export class Route<
|
|
|
988
912
|
TBeforeLoadFn,
|
|
989
913
|
TLoaderDeps,
|
|
990
914
|
TLoaderFn,
|
|
991
|
-
TNewChildren
|
|
915
|
+
TNewChildren,
|
|
916
|
+
TFileRouteTypes
|
|
992
917
|
>
|
|
993
918
|
}
|
|
994
919
|
|
|
@@ -1007,7 +932,8 @@ export class Route<
|
|
|
1007
932
|
TBeforeLoadFn,
|
|
1008
933
|
TLoaderDeps,
|
|
1009
934
|
TLoaderFn,
|
|
1010
|
-
TNewChildren
|
|
935
|
+
TNewChildren,
|
|
936
|
+
TFileRouteTypes
|
|
1011
937
|
> {
|
|
1012
938
|
if (Array.isArray(children)) {
|
|
1013
939
|
this.children = children as TChildren
|
|
@@ -1030,7 +956,8 @@ export class Route<
|
|
|
1030
956
|
TBeforeLoadFn,
|
|
1031
957
|
TLoaderDeps,
|
|
1032
958
|
TLoaderFn,
|
|
1033
|
-
TNewChildren
|
|
959
|
+
TNewChildren,
|
|
960
|
+
TFileRouteTypes
|
|
1034
961
|
>
|
|
1035
962
|
}
|
|
1036
963
|
|
|
@@ -1062,7 +989,8 @@ export class Route<
|
|
|
1062
989
|
TBeforeLoadFn,
|
|
1063
990
|
TLoaderDeps,
|
|
1064
991
|
TNewLoaderFn,
|
|
1065
|
-
TChildren
|
|
992
|
+
TChildren,
|
|
993
|
+
TFileRouteTypes
|
|
1066
994
|
>
|
|
1067
995
|
}
|
|
1068
996
|
|
|
@@ -1256,29 +1184,43 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
|
1256
1184
|
export const rootRouteWithContext = createRootRouteWithContext
|
|
1257
1185
|
|
|
1258
1186
|
export class RootRoute<
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
>
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1187
|
+
in out TSearchValidator = undefined,
|
|
1188
|
+
in out TRouterContext = {},
|
|
1189
|
+
in out TRouteContextFn = AnyContext,
|
|
1190
|
+
in out TBeforeLoadFn = AnyContext,
|
|
1191
|
+
in out TLoaderDeps extends Record<string, any> = {},
|
|
1192
|
+
in out TLoaderFn = undefined,
|
|
1193
|
+
in out TChildren = unknown,
|
|
1194
|
+
in out TFileRouteTypes = unknown,
|
|
1195
|
+
>
|
|
1196
|
+
extends Route<
|
|
1197
|
+
any, // TParentRoute
|
|
1198
|
+
'/', // TPath
|
|
1199
|
+
'/', // TFullPath
|
|
1200
|
+
string, // TCustomId
|
|
1201
|
+
RootRouteId, // TId
|
|
1202
|
+
TSearchValidator, // TSearchValidator
|
|
1203
|
+
{}, // TParams
|
|
1204
|
+
TRouterContext,
|
|
1205
|
+
TRouteContextFn,
|
|
1206
|
+
TBeforeLoadFn,
|
|
1207
|
+
TLoaderDeps,
|
|
1208
|
+
TLoaderFn,
|
|
1209
|
+
TChildren, // TChildren
|
|
1210
|
+
TFileRouteTypes
|
|
1211
|
+
>
|
|
1212
|
+
implements
|
|
1213
|
+
CoreRootRoute<
|
|
1214
|
+
TSearchValidator,
|
|
1215
|
+
TRouterContext,
|
|
1216
|
+
TRouteContextFn,
|
|
1217
|
+
TBeforeLoadFn,
|
|
1218
|
+
TLoaderDeps,
|
|
1219
|
+
TLoaderFn,
|
|
1220
|
+
TChildren,
|
|
1221
|
+
TFileRouteTypes
|
|
1222
|
+
>
|
|
1223
|
+
{
|
|
1282
1224
|
/**
|
|
1283
1225
|
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
|
|
1284
1226
|
*/
|
|
@@ -1389,12 +1331,6 @@ export function createRootRoute<
|
|
|
1389
1331
|
>(options)
|
|
1390
1332
|
}
|
|
1391
1333
|
|
|
1392
|
-
export type ResolveFullPath<
|
|
1393
|
-
TParentRoute extends AnyRoute,
|
|
1394
|
-
TPath extends string,
|
|
1395
|
-
TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,
|
|
1396
|
-
> = TPrefixed extends RootRouteId ? '/' : TPrefixed
|
|
1397
|
-
|
|
1398
1334
|
export type RouteMask<TRouteTree extends AnyRoute> = {
|
|
1399
1335
|
routeTree: TRouteTree
|
|
1400
1336
|
from: RoutePaths<TRouteTree>
|
package/src/router.ts
CHANGED
|
@@ -41,30 +41,41 @@ import type { NoInfer } from '@tanstack/react-store'
|
|
|
41
41
|
|
|
42
42
|
import type {
|
|
43
43
|
AnyContext,
|
|
44
|
+
AnyRedirect,
|
|
44
45
|
AnySchema,
|
|
45
46
|
AnyValidator,
|
|
47
|
+
BuildLocationFn,
|
|
46
48
|
CommitLocationOptions,
|
|
47
49
|
ControlledPromise,
|
|
50
|
+
FullSearchSchema,
|
|
51
|
+
MakeRemountDepsOptionsUnion,
|
|
48
52
|
Manifest,
|
|
53
|
+
NavigateFn,
|
|
54
|
+
NavigateOptions,
|
|
49
55
|
NonNullableUpdater,
|
|
50
56
|
ParsedLocation,
|
|
51
57
|
PickAsRequired,
|
|
58
|
+
Register,
|
|
52
59
|
ResolveRelativePath,
|
|
60
|
+
ResolvedRedirect,
|
|
61
|
+
RouteById,
|
|
62
|
+
RoutePaths,
|
|
63
|
+
RoutesById,
|
|
64
|
+
RoutesByPath,
|
|
53
65
|
SearchMiddleware,
|
|
54
66
|
SearchParser,
|
|
55
67
|
SearchSerializer,
|
|
56
68
|
StartSerializer,
|
|
69
|
+
ToOptions,
|
|
57
70
|
TrailingSlashOption,
|
|
58
71
|
Updater,
|
|
59
72
|
ViewTransitionOptions,
|
|
60
73
|
} from '@tanstack/router-core'
|
|
61
74
|
import type {
|
|
62
75
|
AnyRoute,
|
|
63
|
-
AnyRouteWithContext,
|
|
64
76
|
BeforeLoadContextOptions,
|
|
65
77
|
ErrorRouteComponent,
|
|
66
78
|
LoaderFnContext,
|
|
67
|
-
MakeRemountDepsOptionsUnion,
|
|
68
79
|
NotFoundRouteComponent,
|
|
69
80
|
RootRoute,
|
|
70
81
|
RouteComponent,
|
|
@@ -72,13 +83,6 @@ import type {
|
|
|
72
83
|
RouteMask,
|
|
73
84
|
} from './route'
|
|
74
85
|
|
|
75
|
-
import type {
|
|
76
|
-
FullSearchSchema,
|
|
77
|
-
RouteById,
|
|
78
|
-
RoutePaths,
|
|
79
|
-
RoutesById,
|
|
80
|
-
RoutesByPath,
|
|
81
|
-
} from './routeInfo'
|
|
82
86
|
import type {
|
|
83
87
|
AnyRouteMatch,
|
|
84
88
|
MakeRouteMatch,
|
|
@@ -86,11 +90,7 @@ import type {
|
|
|
86
90
|
MatchRouteOptions,
|
|
87
91
|
} from './Matches'
|
|
88
92
|
|
|
89
|
-
import type { BuildLocationFn, NavigateFn } from './RouterProvider'
|
|
90
|
-
|
|
91
|
-
import type { AnyRedirect, ResolvedRedirect } from './redirects'
|
|
92
93
|
import type { NotFoundError } from './not-found'
|
|
93
|
-
import type { NavigateOptions, ToOptions } from './link'
|
|
94
94
|
|
|
95
95
|
declare global {
|
|
96
96
|
interface Window {
|
|
@@ -98,20 +98,8 @@ declare global {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
export interface Register {
|
|
102
|
-
// router: Router
|
|
103
|
-
}
|
|
104
|
-
|
|
105
101
|
export type AnyRouter = Router<any, any, any, any, any, any>
|
|
106
102
|
|
|
107
|
-
export type AnyRouterWithContext<TContext> = Router<
|
|
108
|
-
AnyRouteWithContext<TContext>,
|
|
109
|
-
any,
|
|
110
|
-
any,
|
|
111
|
-
any,
|
|
112
|
-
any
|
|
113
|
-
>
|
|
114
|
-
|
|
115
103
|
export type RegisteredRouter = Register extends {
|
|
116
104
|
router: infer TRouter extends AnyRouter
|
|
117
105
|
}
|
package/src/typePrimitives.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
Constrain,
|
|
3
|
+
ConstrainLiteral,
|
|
2
4
|
FromPathOption,
|
|
3
|
-
LinkComponentProps,
|
|
4
5
|
NavigateOptions,
|
|
5
6
|
PathParamOptions,
|
|
7
|
+
Redirect,
|
|
8
|
+
RouteIds,
|
|
6
9
|
SearchParamOptions,
|
|
7
10
|
ToPathOption,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
UseParamsResult,
|
|
12
|
+
UseSearchResult,
|
|
13
|
+
} from '@tanstack/router-core'
|
|
14
|
+
import type { LinkComponentProps } from './link'
|
|
11
15
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
12
|
-
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
16
|
+
|
|
17
|
+
import type { UseParamsOptions } from './useParams'
|
|
18
|
+
import type { UseSearchOptions } from './useSearch'
|
|
15
19
|
|
|
16
20
|
export type ValidateFromPath<
|
|
17
21
|
TRouter extends AnyRouter = RegisteredRouter,
|
package/src/useBlocker.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
HistoryLocation,
|
|
7
7
|
} from '@tanstack/history'
|
|
8
8
|
import type { AnyRoute } from './route'
|
|
9
|
-
import type { ParseRoute } from '
|
|
9
|
+
import type { ParseRoute } from '@tanstack/router-core'
|
|
10
10
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
11
11
|
|
|
12
12
|
interface ShouldBlockFnLocation<
|
package/src/useLoaderData.tsx
CHANGED
|
@@ -4,9 +4,11 @@ import type {
|
|
|
4
4
|
ValidateSelected,
|
|
5
5
|
} from './structuralSharing'
|
|
6
6
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import type {
|
|
8
|
+
ResolveUseLoaderData,
|
|
9
|
+
StrictOrFrom,
|
|
10
|
+
UseLoaderDataResult,
|
|
11
|
+
} from '@tanstack/router-core'
|
|
10
12
|
|
|
11
13
|
export interface UseLoaderDataBaseOptions<
|
|
12
14
|
TRouter extends AnyRouter,
|
|
@@ -16,7 +18,7 @@ export interface UseLoaderDataBaseOptions<
|
|
|
16
18
|
TStructuralSharing,
|
|
17
19
|
> {
|
|
18
20
|
select?: (
|
|
19
|
-
match:
|
|
21
|
+
match: ResolveUseLoaderData<TRouter, TFrom, TStrict>,
|
|
20
22
|
) => ValidateSelected<TRouter, TSelected, TStructuralSharing>
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -36,23 +38,6 @@ export type UseLoaderDataOptions<
|
|
|
36
38
|
> &
|
|
37
39
|
StructuralSharingOption<TRouter, TSelected, TStructuralSharing>
|
|
38
40
|
|
|
39
|
-
export type ResolveLoaderData<
|
|
40
|
-
TRouter extends AnyRouter,
|
|
41
|
-
TFrom,
|
|
42
|
-
TStrict extends boolean,
|
|
43
|
-
> = TStrict extends false
|
|
44
|
-
? AllLoaderData<TRouter['routeTree']>
|
|
45
|
-
: Expand<RouteById<TRouter['routeTree'], TFrom>['types']['loaderData']>
|
|
46
|
-
|
|
47
|
-
export type UseLoaderDataResult<
|
|
48
|
-
TRouter extends AnyRouter,
|
|
49
|
-
TFrom,
|
|
50
|
-
TStrict extends boolean,
|
|
51
|
-
TSelected,
|
|
52
|
-
> = unknown extends TSelected
|
|
53
|
-
? ResolveLoaderData<TRouter, TFrom, TStrict>
|
|
54
|
-
: TSelected
|
|
55
|
-
|
|
56
41
|
export type UseLoaderDataRoute<out TId> = <
|
|
57
42
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
58
43
|
TSelected = unknown,
|
package/src/useLoaderDeps.tsx
CHANGED
|
@@ -4,9 +4,11 @@ import type {
|
|
|
4
4
|
ValidateSelected,
|
|
5
5
|
} from './structuralSharing'
|
|
6
6
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import type {
|
|
8
|
+
ResolveUseLoaderDeps,
|
|
9
|
+
StrictOrFrom,
|
|
10
|
+
UseLoaderDepsResult,
|
|
11
|
+
} from '@tanstack/router-core'
|
|
10
12
|
|
|
11
13
|
export interface UseLoaderDepsBaseOptions<
|
|
12
14
|
TRouter extends AnyRouter,
|
|
@@ -15,7 +17,7 @@ export interface UseLoaderDepsBaseOptions<
|
|
|
15
17
|
TStructuralSharing,
|
|
16
18
|
> {
|
|
17
19
|
select?: (
|
|
18
|
-
deps:
|
|
20
|
+
deps: ResolveUseLoaderDeps<TRouter, TFrom>,
|
|
19
21
|
) => ValidateSelected<TRouter, TSelected, TStructuralSharing>
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -28,16 +30,6 @@ export type UseLoaderDepsOptions<
|
|
|
28
30
|
UseLoaderDepsBaseOptions<TRouter, TFrom, TSelected, TStructuralSharing> &
|
|
29
31
|
StructuralSharingOption<TRouter, TSelected, TStructuralSharing>
|
|
30
32
|
|
|
31
|
-
export type ResolveLoaderDeps<TRouter extends AnyRouter, TFrom> = Expand<
|
|
32
|
-
RouteById<TRouter['routeTree'], TFrom>['types']['loaderDeps']
|
|
33
|
-
>
|
|
34
|
-
|
|
35
|
-
export type UseLoaderDepsResult<
|
|
36
|
-
TRouter extends AnyRouter,
|
|
37
|
-
TFrom,
|
|
38
|
-
TSelected,
|
|
39
|
-
> = unknown extends TSelected ? ResolveLoaderDeps<TRouter, TFrom> : TSelected
|
|
40
|
-
|
|
41
33
|
export type UseLoaderDepsRoute<out TId> = <
|
|
42
34
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
43
35
|
TSelected = unknown,
|
package/src/useMatch.tsx
CHANGED
|
@@ -8,8 +8,7 @@ import type {
|
|
|
8
8
|
} from './structuralSharing'
|
|
9
9
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
10
10
|
import type { MakeRouteMatch, MakeRouteMatchUnion } from './Matches'
|
|
11
|
-
import type { StrictOrFrom } from '
|
|
12
|
-
import type { ThrowOrOptional } from '@tanstack/router-core'
|
|
11
|
+
import type { StrictOrFrom, ThrowOrOptional } from '@tanstack/router-core'
|
|
13
12
|
|
|
14
13
|
export interface UseMatchBaseOptions<
|
|
15
14
|
TRouter extends AnyRouter,
|
package/src/useNavigate.tsx
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { useRouter } from './useRouter'
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
FromPathOption,
|
|
5
|
+
NavigateOptions,
|
|
6
|
+
UseNavigateResult,
|
|
7
|
+
} from '@tanstack/router-core'
|
|
4
8
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
5
9
|
|
|
6
|
-
export type UseNavigateResult<TDefaultFrom extends string> = <
|
|
7
|
-
TRouter extends RegisteredRouter,
|
|
8
|
-
TTo extends string | undefined,
|
|
9
|
-
TFrom extends string = TDefaultFrom,
|
|
10
|
-
TMaskFrom extends string = TFrom,
|
|
11
|
-
TMaskTo extends string = '',
|
|
12
|
-
>({
|
|
13
|
-
from,
|
|
14
|
-
...rest
|
|
15
|
-
}: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void>
|
|
16
|
-
|
|
17
10
|
export function useNavigate<
|
|
18
11
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
19
12
|
TDefaultFrom extends string = string,
|