@tanstack/react-router 1.109.0 → 1.111.3
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.map +1 -1
- package/dist/cjs/fileRoute.d.cts +2 -14
- package/dist/cjs/index.d.cts +7 -7
- 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 +1 -3
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +10 -56
- package/dist/cjs/router.cjs +2 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +2 -8
- package/dist/cjs/typePrimitives.d.cts +2 -3
- 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 +1 -2
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.d.cts +1 -2
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useNavigate.d.cts +1 -1
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +1 -2
- package/dist/cjs/useRouteContext.cjs.map +1 -1
- package/dist/cjs/useRouteContext.d.cts +1 -2
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +1 -2
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +2 -4
- 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 +2 -14
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +7 -7
- 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 +1 -3
- package/dist/esm/redirects.js.map +1 -1
- package/dist/esm/route.d.ts +10 -56
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +2 -8
- package/dist/esm/router.js +2 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/typePrimitives.d.ts +2 -3
- package/dist/esm/useBlocker.d.ts +1 -1
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useLoaderData.d.ts +1 -2
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.d.ts +1 -2
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useNavigate.d.ts +1 -1
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.d.ts +1 -2
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.d.ts +1 -2
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useSearch.d.ts +1 -2
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.d.ts +2 -4
- 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 +10 -38
- package/src/index.tsx +26 -41
- package/src/link.tsx +4 -427
- package/src/not-found.tsx +1 -1
- package/src/redirects.ts +5 -3
- package/src/route.ts +102 -165
- package/src/router.ts +13 -25
- package/src/typePrimitives.ts +5 -4
- package/src/useBlocker.tsx +1 -1
- package/src/useLoaderData.tsx +1 -2
- package/src/useLoaderDeps.tsx +1 -2
- package/src/useNavigate.tsx +1 -1
- package/src/useParams.tsx +6 -2
- package/src/useRouteContext.ts +1 -2
- package/src/useSearch.tsx +6 -2
- package/src/utils.ts +5 -3
- 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,36 +12,43 @@ 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,
|
|
47
54
|
} from '@tanstack/router-core'
|
|
@@ -58,10 +65,7 @@ import type {
|
|
|
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
71
|
|
|
@@ -106,13 +110,6 @@ export type RouteOptions<
|
|
|
106
110
|
NoInfer<TBeforeLoadFn>
|
|
107
111
|
>
|
|
108
112
|
|
|
109
|
-
export interface FullSearchSchemaOption<
|
|
110
|
-
in out TParentRoute extends AnyRoute,
|
|
111
|
-
in out TSearchValidator,
|
|
112
|
-
> {
|
|
113
|
-
search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
|
|
114
|
-
}
|
|
115
|
-
|
|
116
113
|
export type RouteContextFn<
|
|
117
114
|
in out TParentRoute extends AnyRoute,
|
|
118
115
|
in out TSearchValidator,
|
|
@@ -288,30 +285,6 @@ export interface RouteContextOptions<
|
|
|
288
285
|
context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>
|
|
289
286
|
}
|
|
290
287
|
|
|
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
288
|
export interface BeforeLoadContextOptions<
|
|
316
289
|
in out TParentRoute extends AnyRoute,
|
|
317
290
|
in out TSearchValidator,
|
|
@@ -570,50 +543,6 @@ export interface LoaderFnContext<
|
|
|
570
543
|
route: Route
|
|
571
544
|
}
|
|
572
545
|
|
|
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
546
|
export interface AnyRoute
|
|
618
547
|
extends Route<
|
|
619
548
|
any,
|
|
@@ -628,18 +557,10 @@ export interface AnyRoute
|
|
|
628
557
|
any,
|
|
629
558
|
any,
|
|
630
559
|
any,
|
|
560
|
+
any,
|
|
631
561
|
any
|
|
632
562
|
> {}
|
|
633
563
|
|
|
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
564
|
export type RouteConstraints = {
|
|
644
565
|
TParentRoute: AnyRoute
|
|
645
566
|
TPath: string
|
|
@@ -753,7 +674,25 @@ export class Route<
|
|
|
753
674
|
in out TLoaderDeps extends Record<string, any> = {},
|
|
754
675
|
in out TLoaderFn = undefined,
|
|
755
676
|
in out TChildren = unknown,
|
|
756
|
-
|
|
677
|
+
in out TFileRouteTypes = unknown,
|
|
678
|
+
> implements
|
|
679
|
+
CoreRoute<
|
|
680
|
+
TParentRoute,
|
|
681
|
+
TPath,
|
|
682
|
+
TFullPath,
|
|
683
|
+
TCustomId,
|
|
684
|
+
TId,
|
|
685
|
+
TSearchValidator,
|
|
686
|
+
TParams,
|
|
687
|
+
TRouterContext,
|
|
688
|
+
TRouteContextFn,
|
|
689
|
+
TBeforeLoadFn,
|
|
690
|
+
TLoaderDeps,
|
|
691
|
+
TLoaderFn,
|
|
692
|
+
TChildren,
|
|
693
|
+
TFileRouteTypes
|
|
694
|
+
>
|
|
695
|
+
{
|
|
757
696
|
isRoot: TParentRoute extends Route<any> ? true : false
|
|
758
697
|
options: RouteOptions<
|
|
759
698
|
TParentRoute,
|
|
@@ -852,37 +791,22 @@ export class Route<
|
|
|
852
791
|
;(this as any).$$typeof = Symbol.for('react.memo')
|
|
853
792
|
}
|
|
854
793
|
|
|
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
|
-
}
|
|
794
|
+
types!: RouteTypes<
|
|
795
|
+
TParentRoute,
|
|
796
|
+
TPath,
|
|
797
|
+
TFullPath,
|
|
798
|
+
TCustomId,
|
|
799
|
+
TId,
|
|
800
|
+
TSearchValidator,
|
|
801
|
+
TParams,
|
|
802
|
+
TRouterContext,
|
|
803
|
+
TRouteContextFn,
|
|
804
|
+
TBeforeLoadFn,
|
|
805
|
+
TLoaderDeps,
|
|
806
|
+
TLoaderFn,
|
|
807
|
+
TChildren,
|
|
808
|
+
TFileRouteTypes
|
|
809
|
+
>
|
|
886
810
|
|
|
887
811
|
init = (opts: { originalIndex: number; defaultSsr?: boolean }): void => {
|
|
888
812
|
this.originalIndex = opts.originalIndex
|
|
@@ -973,7 +897,8 @@ export class Route<
|
|
|
973
897
|
TBeforeLoadFn,
|
|
974
898
|
TLoaderDeps,
|
|
975
899
|
TLoaderFn,
|
|
976
|
-
TNewChildren
|
|
900
|
+
TNewChildren,
|
|
901
|
+
TFileRouteTypes
|
|
977
902
|
> {
|
|
978
903
|
return this._addFileChildren(children) as Route<
|
|
979
904
|
TParentRoute,
|
|
@@ -988,7 +913,8 @@ export class Route<
|
|
|
988
913
|
TBeforeLoadFn,
|
|
989
914
|
TLoaderDeps,
|
|
990
915
|
TLoaderFn,
|
|
991
|
-
TNewChildren
|
|
916
|
+
TNewChildren,
|
|
917
|
+
TFileRouteTypes
|
|
992
918
|
>
|
|
993
919
|
}
|
|
994
920
|
|
|
@@ -1007,7 +933,8 @@ export class Route<
|
|
|
1007
933
|
TBeforeLoadFn,
|
|
1008
934
|
TLoaderDeps,
|
|
1009
935
|
TLoaderFn,
|
|
1010
|
-
TNewChildren
|
|
936
|
+
TNewChildren,
|
|
937
|
+
TFileRouteTypes
|
|
1011
938
|
> {
|
|
1012
939
|
if (Array.isArray(children)) {
|
|
1013
940
|
this.children = children as TChildren
|
|
@@ -1030,7 +957,8 @@ export class Route<
|
|
|
1030
957
|
TBeforeLoadFn,
|
|
1031
958
|
TLoaderDeps,
|
|
1032
959
|
TLoaderFn,
|
|
1033
|
-
TNewChildren
|
|
960
|
+
TNewChildren,
|
|
961
|
+
TFileRouteTypes
|
|
1034
962
|
>
|
|
1035
963
|
}
|
|
1036
964
|
|
|
@@ -1062,7 +990,8 @@ export class Route<
|
|
|
1062
990
|
TBeforeLoadFn,
|
|
1063
991
|
TLoaderDeps,
|
|
1064
992
|
TNewLoaderFn,
|
|
1065
|
-
TChildren
|
|
993
|
+
TChildren,
|
|
994
|
+
TFileRouteTypes
|
|
1066
995
|
>
|
|
1067
996
|
}
|
|
1068
997
|
|
|
@@ -1256,29 +1185,43 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
|
1256
1185
|
export const rootRouteWithContext = createRootRouteWithContext
|
|
1257
1186
|
|
|
1258
1187
|
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
|
-
|
|
1188
|
+
in out TSearchValidator = undefined,
|
|
1189
|
+
in out TRouterContext = {},
|
|
1190
|
+
in out TRouteContextFn = AnyContext,
|
|
1191
|
+
in out TBeforeLoadFn = AnyContext,
|
|
1192
|
+
in out TLoaderDeps extends Record<string, any> = {},
|
|
1193
|
+
in out TLoaderFn = undefined,
|
|
1194
|
+
in out TChildren = unknown,
|
|
1195
|
+
in out TFileRouteTypes = unknown,
|
|
1196
|
+
>
|
|
1197
|
+
extends Route<
|
|
1198
|
+
any, // TParentRoute
|
|
1199
|
+
'/', // TPath
|
|
1200
|
+
'/', // TFullPath
|
|
1201
|
+
string, // TCustomId
|
|
1202
|
+
RootRouteId, // TId
|
|
1203
|
+
TSearchValidator, // TSearchValidator
|
|
1204
|
+
{}, // TParams
|
|
1205
|
+
TRouterContext,
|
|
1206
|
+
TRouteContextFn,
|
|
1207
|
+
TBeforeLoadFn,
|
|
1208
|
+
TLoaderDeps,
|
|
1209
|
+
TLoaderFn,
|
|
1210
|
+
TChildren, // TChildren
|
|
1211
|
+
TFileRouteTypes
|
|
1212
|
+
>
|
|
1213
|
+
implements
|
|
1214
|
+
CoreRootRoute<
|
|
1215
|
+
TSearchValidator,
|
|
1216
|
+
TRouterContext,
|
|
1217
|
+
TRouteContextFn,
|
|
1218
|
+
TBeforeLoadFn,
|
|
1219
|
+
TLoaderDeps,
|
|
1220
|
+
TLoaderFn,
|
|
1221
|
+
TChildren,
|
|
1222
|
+
TFileRouteTypes
|
|
1223
|
+
>
|
|
1224
|
+
{
|
|
1282
1225
|
/**
|
|
1283
1226
|
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
|
|
1284
1227
|
*/
|
|
@@ -1389,12 +1332,6 @@ export function createRootRoute<
|
|
|
1389
1332
|
>(options)
|
|
1390
1333
|
}
|
|
1391
1334
|
|
|
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
1335
|
export type RouteMask<TRouteTree extends AnyRoute> = {
|
|
1399
1336
|
routeTree: TRouteTree
|
|
1400
1337
|
from: RoutePaths<TRouteTree>
|
package/src/router.ts
CHANGED
|
@@ -43,28 +43,37 @@ import type {
|
|
|
43
43
|
AnyContext,
|
|
44
44
|
AnySchema,
|
|
45
45
|
AnyValidator,
|
|
46
|
+
BuildLocationFn,
|
|
46
47
|
CommitLocationOptions,
|
|
47
48
|
ControlledPromise,
|
|
49
|
+
FullSearchSchema,
|
|
50
|
+
MakeRemountDepsOptionsUnion,
|
|
48
51
|
Manifest,
|
|
52
|
+
NavigateFn,
|
|
53
|
+
NavigateOptions,
|
|
49
54
|
NonNullableUpdater,
|
|
50
55
|
ParsedLocation,
|
|
51
56
|
PickAsRequired,
|
|
57
|
+
Register,
|
|
52
58
|
ResolveRelativePath,
|
|
59
|
+
RouteById,
|
|
60
|
+
RoutePaths,
|
|
61
|
+
RoutesById,
|
|
62
|
+
RoutesByPath,
|
|
53
63
|
SearchMiddleware,
|
|
54
64
|
SearchParser,
|
|
55
65
|
SearchSerializer,
|
|
56
66
|
StartSerializer,
|
|
67
|
+
ToOptions,
|
|
57
68
|
TrailingSlashOption,
|
|
58
69
|
Updater,
|
|
59
70
|
ViewTransitionOptions,
|
|
60
71
|
} from '@tanstack/router-core'
|
|
61
72
|
import type {
|
|
62
73
|
AnyRoute,
|
|
63
|
-
AnyRouteWithContext,
|
|
64
74
|
BeforeLoadContextOptions,
|
|
65
75
|
ErrorRouteComponent,
|
|
66
76
|
LoaderFnContext,
|
|
67
|
-
MakeRemountDepsOptionsUnion,
|
|
68
77
|
NotFoundRouteComponent,
|
|
69
78
|
RootRoute,
|
|
70
79
|
RouteComponent,
|
|
@@ -72,13 +81,6 @@ import type {
|
|
|
72
81
|
RouteMask,
|
|
73
82
|
} from './route'
|
|
74
83
|
|
|
75
|
-
import type {
|
|
76
|
-
FullSearchSchema,
|
|
77
|
-
RouteById,
|
|
78
|
-
RoutePaths,
|
|
79
|
-
RoutesById,
|
|
80
|
-
RoutesByPath,
|
|
81
|
-
} from './routeInfo'
|
|
82
84
|
import type {
|
|
83
85
|
AnyRouteMatch,
|
|
84
86
|
MakeRouteMatch,
|
|
@@ -86,11 +88,8 @@ import type {
|
|
|
86
88
|
MatchRouteOptions,
|
|
87
89
|
} from './Matches'
|
|
88
90
|
|
|
89
|
-
import type { BuildLocationFn, NavigateFn } from './RouterProvider'
|
|
90
|
-
|
|
91
91
|
import type { AnyRedirect, ResolvedRedirect } from './redirects'
|
|
92
92
|
import type { NotFoundError } from './not-found'
|
|
93
|
-
import type { NavigateOptions, ToOptions } from './link'
|
|
94
93
|
|
|
95
94
|
declare global {
|
|
96
95
|
interface Window {
|
|
@@ -98,20 +97,8 @@ declare global {
|
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
export interface Register {
|
|
102
|
-
// router: Router
|
|
103
|
-
}
|
|
104
|
-
|
|
105
100
|
export type AnyRouter = Router<any, any, any, any, any, any>
|
|
106
101
|
|
|
107
|
-
export type AnyRouterWithContext<TContext> = Router<
|
|
108
|
-
AnyRouteWithContext<TContext>,
|
|
109
|
-
any,
|
|
110
|
-
any,
|
|
111
|
-
any,
|
|
112
|
-
any
|
|
113
|
-
>
|
|
114
|
-
|
|
115
102
|
export type RegisteredRouter = Register extends {
|
|
116
103
|
router: infer TRouter extends AnyRouter
|
|
117
104
|
}
|
|
@@ -1611,8 +1598,8 @@ export class Router<
|
|
|
1611
1598
|
}
|
|
1612
1599
|
if (opts._includeValidateSearch && route.options.validateSearch) {
|
|
1613
1600
|
const validate: SearchMiddleware<any> = ({ search, next }) => {
|
|
1601
|
+
const result = next(search)
|
|
1614
1602
|
try {
|
|
1615
|
-
const result = next(search)
|
|
1616
1603
|
const validatedSearch = {
|
|
1617
1604
|
...result,
|
|
1618
1605
|
...(validateSearch(
|
|
@@ -1623,6 +1610,7 @@ export class Router<
|
|
|
1623
1610
|
return validatedSearch
|
|
1624
1611
|
} catch {
|
|
1625
1612
|
// ignore errors here because they are already handled in matchRoutes
|
|
1613
|
+
return result
|
|
1626
1614
|
}
|
|
1627
1615
|
}
|
|
1628
1616
|
middlewares.push(validate)
|
package/src/typePrimitives.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
Constrain,
|
|
3
|
+
ConstrainLiteral,
|
|
2
4
|
FromPathOption,
|
|
3
|
-
LinkComponentProps,
|
|
4
5
|
NavigateOptions,
|
|
5
6
|
PathParamOptions,
|
|
7
|
+
RouteIds,
|
|
6
8
|
SearchParamOptions,
|
|
7
9
|
ToPathOption,
|
|
8
|
-
} from '
|
|
10
|
+
} from '@tanstack/router-core'
|
|
11
|
+
import type { LinkComponentProps } from './link'
|
|
9
12
|
import type { Redirect } from './redirects'
|
|
10
|
-
import type { RouteIds } from './routeInfo'
|
|
11
13
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
12
14
|
import type { UseParamsOptions, UseParamsResult } from './useParams'
|
|
13
15
|
import type { UseSearchOptions, UseSearchResult } from './useSearch'
|
|
14
|
-
import type { Constrain, ConstrainLiteral } from '@tanstack/router-core'
|
|
15
16
|
|
|
16
17
|
export type ValidateFromPath<
|
|
17
18
|
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,8 @@ import type {
|
|
|
4
4
|
ValidateSelected,
|
|
5
5
|
} from './structuralSharing'
|
|
6
6
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
7
|
-
import type { AllLoaderData, RouteById } from '
|
|
7
|
+
import type { AllLoaderData, Expand, RouteById } from '@tanstack/router-core'
|
|
8
8
|
import type { StrictOrFrom } from './utils'
|
|
9
|
-
import type { Expand } from '@tanstack/router-core'
|
|
10
9
|
|
|
11
10
|
export interface UseLoaderDataBaseOptions<
|
|
12
11
|
TRouter extends AnyRouter,
|
package/src/useLoaderDeps.tsx
CHANGED
|
@@ -4,9 +4,8 @@ import type {
|
|
|
4
4
|
ValidateSelected,
|
|
5
5
|
} from './structuralSharing'
|
|
6
6
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
7
|
-
import type { RouteById } from './routeInfo'
|
|
8
7
|
import type { StrictOrFrom } from './utils'
|
|
9
|
-
import type { Expand } from '@tanstack/router-core'
|
|
8
|
+
import type { Expand, RouteById } from '@tanstack/router-core'
|
|
10
9
|
|
|
11
10
|
export interface UseLoaderDepsBaseOptions<
|
|
12
11
|
TRouter extends AnyRouter,
|
package/src/useNavigate.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { useRouter } from './useRouter'
|
|
3
|
-
import type { FromPathOption, NavigateOptions } from '
|
|
3
|
+
import type { FromPathOption, NavigateOptions } from '@tanstack/router-core'
|
|
4
4
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
5
5
|
|
|
6
6
|
export type UseNavigateResult<TDefaultFrom extends string> = <
|
package/src/useParams.tsx
CHANGED
|
@@ -4,10 +4,14 @@ import type {
|
|
|
4
4
|
StructuralSharingOption,
|
|
5
5
|
ValidateSelected,
|
|
6
6
|
} from './structuralSharing'
|
|
7
|
-
import type { AllParams, RouteById } from './routeInfo'
|
|
8
7
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
9
8
|
import type { StrictOrFrom } from './utils'
|
|
10
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
AllParams,
|
|
11
|
+
Expand,
|
|
12
|
+
RouteById,
|
|
13
|
+
ThrowOrOptional,
|
|
14
|
+
} from '@tanstack/router-core'
|
|
11
15
|
|
|
12
16
|
export interface UseParamsBaseOptions<
|
|
13
17
|
TRouter extends AnyRouter,
|
package/src/useRouteContext.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { useMatch } from './useMatch'
|
|
2
|
-
import type { AllContext, RouteById } from './routeInfo'
|
|
3
2
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
4
3
|
import type { StrictOrFrom } from './utils'
|
|
5
|
-
import type { Expand } from '@tanstack/router-core'
|
|
4
|
+
import type { AllContext, Expand, RouteById } from '@tanstack/router-core'
|
|
6
5
|
|
|
7
6
|
export interface UseRouteContextBaseOptions<
|
|
8
7
|
TRouter extends AnyRouter,
|
package/src/useSearch.tsx
CHANGED
|
@@ -4,10 +4,14 @@ import type {
|
|
|
4
4
|
StructuralSharingOption,
|
|
5
5
|
ValidateSelected,
|
|
6
6
|
} from './structuralSharing'
|
|
7
|
-
import type { FullSearchSchema, RouteById } from './routeInfo'
|
|
8
7
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
9
8
|
import type { StrictOrFrom } from './utils'
|
|
10
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
Expand,
|
|
11
|
+
FullSearchSchema,
|
|
12
|
+
RouteById,
|
|
13
|
+
ThrowOrOptional,
|
|
14
|
+
} from '@tanstack/router-core'
|
|
11
15
|
|
|
12
16
|
export interface UseSearchBaseOptions<
|
|
13
17
|
TRouter extends AnyRouter,
|
package/src/utils.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type {
|
|
3
|
+
AnyRouter,
|
|
4
|
+
ConstrainLiteral,
|
|
5
|
+
RouteIds,
|
|
6
|
+
} from '@tanstack/router-core'
|
|
5
7
|
|
|
6
8
|
export function useStableCallback<T extends (...args: Array<any>) => any>(
|
|
7
9
|
fn: T,
|
package/dist/cjs/routeInfo.d.cts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { InferFileRouteTypes } from './fileRoute.cjs';
|
|
2
|
-
import { AddTrailingSlash, PartialMergeAll, RemoveTrailingSlashes, TrailingSlashOption } from '@tanstack/router-core';
|
|
3
|
-
import { AnyRoute } from './route.cjs';
|
|
4
|
-
import { AnyRouter } from './router.cjs';
|
|
5
|
-
export type ParseRoute<TRouteTree, TAcc = TRouteTree> = TRouteTree extends {
|
|
6
|
-
types: {
|
|
7
|
-
children: infer TChildren;
|
|
8
|
-
};
|
|
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;
|
|
11
|
-
export type CodeRoutesById<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? {
|
|
12
|
-
[K in TRoutes as K['id']]: K;
|
|
13
|
-
} : never;
|
|
14
|
-
export type RoutesById<TRouteTree extends AnyRoute> = InferFileRouteTypes<TRouteTree> extends never ? CodeRoutesById<TRouteTree> : InferFileRouteTypes<TRouteTree>['fileRoutesById'];
|
|
15
|
-
export type RouteById<TRouteTree extends AnyRoute, TId> = Extract<RoutesById<TRouteTree>[TId & keyof RoutesById<TRouteTree>], AnyRoute>;
|
|
16
|
-
export type CodeRouteIds<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? TRoutes['id'] : never;
|
|
17
|
-
export type RouteIds<TRouteTree extends AnyRoute> = InferFileRouteTypes<TRouteTree> extends never ? CodeRouteIds<TRouteTree> : InferFileRouteTypes<TRouteTree>['id'];
|
|
18
|
-
export type ParentPath<TRouter extends AnyRouter> = TrailingSlashOptionByRouter<TRouter> extends 'always' ? '../' : TrailingSlashOptionByRouter<TRouter> extends 'never' ? '..' : '../' | '..';
|
|
19
|
-
export type CurrentPath<TRouter extends AnyRouter> = TrailingSlashOptionByRouter<TRouter> extends 'always' ? './' : TrailingSlashOptionByRouter<TRouter> extends 'never' ? '.' : './' | '.';
|
|
20
|
-
export type ToPath<TRouter extends AnyRouter, TTo extends string> = TrailingSlashOptionByRouter<TRouter> extends 'always' ? AddTrailingSlash<TTo> : TrailingSlashOptionByRouter<TRouter> extends 'never' ? RemoveTrailingSlashes<TTo> : AddTrailingSlash<TTo> | RemoveTrailingSlashes<TTo>;
|
|
21
|
-
export type CatchAllPaths<TRouter extends AnyRouter> = CurrentPath<TRouter> | ParentPath<TRouter>;
|
|
22
|
-
export type CodeRoutesByPath<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? {
|
|
23
|
-
[K in TRoutes as K['fullPath']]: K;
|
|
24
|
-
} : never;
|
|
25
|
-
export type RoutesByPath<TRouteTree extends AnyRoute> = InferFileRouteTypes<TRouteTree> extends never ? CodeRoutesByPath<TRouteTree> : InferFileRouteTypes<TRouteTree>['fileRoutesByFullPath'];
|
|
26
|
-
export type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<RoutesByPath<TRouteTree>[TPath & keyof RoutesByPath<TRouteTree>], AnyRoute>;
|
|
27
|
-
export type CodeRoutePaths<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? TRoutes['fullPath'] : never;
|
|
28
|
-
export type RoutePaths<TRouteTree extends AnyRoute> = unknown extends TRouteTree ? string : (InferFileRouteTypes<TRouteTree> extends never ? CodeRoutePaths<TRouteTree> : InferFileRouteTypes<TRouteTree>['fullPaths']) | '/';
|
|
29
|
-
export type RouteToPathAlwaysTrailingSlash<TRoute extends AnyRoute> = TRoute['path'] extends '/' ? TRoute['fullPath'] : TRoute['fullPath'] extends '/' ? TRoute['fullPath'] : `${TRoute['fullPath']}/`;
|
|
30
|
-
export type RouteToPathNeverTrailingSlash<TRoute extends AnyRoute> = TRoute['path'] extends '/' ? TRoute['fullPath'] extends '/' ? TRoute['fullPath'] : RemoveTrailingSlashes<TRoute['fullPath']> : TRoute['fullPath'];
|
|
31
|
-
export type RouteToPathPreserveTrailingSlash<TRoute extends AnyRoute> = RouteToPathNeverTrailingSlash<TRoute> | RouteToPathAlwaysTrailingSlash<TRoute>;
|
|
32
|
-
export type RouteToPathByTrailingSlashOption<TRoute extends AnyRoute> = {
|
|
33
|
-
always: RouteToPathAlwaysTrailingSlash<TRoute>;
|
|
34
|
-
preserve: RouteToPathPreserveTrailingSlash<TRoute>;
|
|
35
|
-
never: RouteToPathNeverTrailingSlash<TRoute>;
|
|
36
|
-
};
|
|
37
|
-
export type TrailingSlashOptionByRouter<TRouter extends AnyRouter> = TrailingSlashOption extends TRouter['options']['trailingSlash'] ? 'never' : NonNullable<TRouter['options']['trailingSlash']>;
|
|
38
|
-
export type RouteToByRouter<TRouter extends AnyRouter, TRoute extends AnyRoute> = RouteToPathByTrailingSlashOption<TRoute>[TrailingSlashOptionByRouter<TRouter>];
|
|
39
|
-
export type CodeRouteToPath<TRouter extends AnyRouter> = ParseRouteWithoutBranches<TRouter['routeTree']> extends infer TRoute extends AnyRoute ? TRoute extends any ? RouteToByRouter<TRouter, TRoute> : never : never;
|
|
40
|
-
export type FileRouteToPath<TRouter extends AnyRouter, TTo = InferFileRouteTypes<TRouter['routeTree']>['to'], TTrailingSlashOption = TrailingSlashOptionByRouter<TRouter>> = 'never' extends TTrailingSlashOption ? TTo : 'always' extends TTrailingSlashOption ? AddTrailingSlash<TTo> : TTo | AddTrailingSlash<TTo>;
|
|
41
|
-
export type RouteToPath<TRouter extends AnyRouter> = unknown extends TRouter ? string : InferFileRouteTypes<TRouter['routeTree']> extends never ? CodeRouteToPath<TRouter> : FileRouteToPath<TRouter>;
|
|
42
|
-
export type CodeRoutesByToPath<TRouter extends AnyRouter> = ParseRouteWithoutBranches<TRouter['routeTree']> extends infer TRoutes extends AnyRoute ? {
|
|
43
|
-
[TRoute in TRoutes as RouteToByRouter<TRouter, TRoute>]: TRoute;
|
|
44
|
-
} : never;
|
|
45
|
-
export type RoutesByToPath<TRouter extends AnyRouter> = InferFileRouteTypes<TRouter['routeTree']> extends never ? CodeRoutesByToPath<TRouter> : InferFileRouteTypes<TRouter['routeTree']>['fileRoutesByTo'];
|
|
46
|
-
export type CodeRouteByToPath<TRouter extends AnyRouter, TTo> = Extract<RoutesByToPath<TRouter>[TTo & keyof RoutesByToPath<TRouter>], AnyRoute>;
|
|
47
|
-
export type FileRouteByToPath<TRouter extends AnyRouter, TTo> = 'never' extends TrailingSlashOptionByRouter<TRouter> ? CodeRouteByToPath<TRouter, TTo> : 'always' extends TrailingSlashOptionByRouter<TRouter> ? TTo extends '/' ? CodeRouteByToPath<TRouter, TTo> : TTo extends `${infer TPath}/` ? CodeRouteByToPath<TRouter, TPath> : never : CodeRouteByToPath<TRouter, TTo extends '/' ? TTo : RemoveTrailingSlashes<TTo>>;
|
|
48
|
-
export type RouteByToPath<TRouter extends AnyRouter, TTo> = InferFileRouteTypes<TRouter['routeTree']> extends never ? CodeRouteByToPath<TRouter, TTo> : FileRouteByToPath<TRouter, TTo>;
|
|
49
|
-
export type FullSearchSchema<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? PartialMergeAll<TRoutes['types']['fullSearchSchema']> : never;
|
|
50
|
-
export type FullSearchSchemaInput<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? PartialMergeAll<TRoutes['types']['fullSearchSchemaInput']> : never;
|
|
51
|
-
export type AllParams<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? PartialMergeAll<TRoutes['types']['allParams']> : never;
|
|
52
|
-
export type AllContext<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? PartialMergeAll<TRoutes['types']['allContext']> : never;
|
|
53
|
-
export type AllLoaderData<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? PartialMergeAll<TRoutes['types']['loaderData']> : never;
|