@tanstack/react-router 1.1.10 → 1.1.11
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/fileRoute.js.map +1 -1
- package/build/cjs/route.js.map +1 -1
- 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/fileRoute.d.ts +2 -2
- package/build/types/route.d.ts +22 -20
- package/build/types/routeInfo.d.ts +1 -1
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/fileRoute.ts +9 -1
- package/src/route.ts +48 -34
- package/src/routeInfo.ts +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.11",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@tanstack/store": "^0.1.3",
|
|
45
45
|
"tiny-invariant": "^1.3.1",
|
|
46
46
|
"tiny-warning": "^1.0.3",
|
|
47
|
-
"@tanstack/history": "1.1.
|
|
47
|
+
"@tanstack/history": "1.1.11"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rollup --config rollup.config.js"
|
package/src/fileRoute.ts
CHANGED
|
@@ -125,7 +125,13 @@ export class FileRoute<
|
|
|
125
125
|
TParentRoute['types']['allParams'],
|
|
126
126
|
TParams
|
|
127
127
|
>,
|
|
128
|
-
|
|
128
|
+
TRouteContextReturn extends
|
|
129
|
+
RouteConstraints['TRouteContext'] = RouteContext,
|
|
130
|
+
TRouteContext extends RouteConstraints['TRouteContext'] = [
|
|
131
|
+
TRouteContextReturn,
|
|
132
|
+
] extends [never]
|
|
133
|
+
? RouteContext
|
|
134
|
+
: TRouteContextReturn,
|
|
129
135
|
TContext extends Expand<
|
|
130
136
|
Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
|
|
131
137
|
> = Expand<
|
|
@@ -149,6 +155,7 @@ export class FileRoute<
|
|
|
149
155
|
TFullSearchSchema,
|
|
150
156
|
TParams,
|
|
151
157
|
TAllParams,
|
|
158
|
+
TRouteContextReturn,
|
|
152
159
|
TRouteContext,
|
|
153
160
|
TContext,
|
|
154
161
|
TLoaderDeps,
|
|
@@ -170,6 +177,7 @@ export class FileRoute<
|
|
|
170
177
|
TFullSearchSchema,
|
|
171
178
|
TParams,
|
|
172
179
|
TAllParams,
|
|
180
|
+
TRouteContextReturn,
|
|
173
181
|
TRouteContext,
|
|
174
182
|
TContext,
|
|
175
183
|
TRouterContext,
|
package/src/route.ts
CHANGED
|
@@ -67,6 +67,7 @@ export type RouteOptions<
|
|
|
67
67
|
TFullSearchSchema extends Record<string, any> = TSearchSchema,
|
|
68
68
|
TParams extends AnyPathParams = AnyPathParams,
|
|
69
69
|
TAllParams extends AnyPathParams = TParams,
|
|
70
|
+
TRouteContextReturn extends RouteContext = RouteContext,
|
|
70
71
|
TRouteContext extends RouteContext = RouteContext,
|
|
71
72
|
TAllContext extends Record<string, any> = AnyContext,
|
|
72
73
|
TLoaderDeps extends Record<string, any> = {},
|
|
@@ -82,6 +83,7 @@ export type RouteOptions<
|
|
|
82
83
|
TFullSearchSchema,
|
|
83
84
|
TParams,
|
|
84
85
|
TAllParams,
|
|
86
|
+
TRouteContextReturn,
|
|
85
87
|
TRouteContext,
|
|
86
88
|
TAllContext,
|
|
87
89
|
TLoaderDeps,
|
|
@@ -105,6 +107,7 @@ export type BaseRouteOptions<
|
|
|
105
107
|
TFullSearchSchema extends Record<string, any> = TSearchSchema,
|
|
106
108
|
TParams extends AnyPathParams = {},
|
|
107
109
|
TAllParams = ParamsFallback<TPath, TParams>,
|
|
110
|
+
TRouteContextReturn extends RouteContext = RouteContext,
|
|
108
111
|
TRouteContext extends RouteContext = RouteContext,
|
|
109
112
|
TAllContext extends Record<string, any> = AnyContext,
|
|
110
113
|
TLoaderDeps extends Record<string, any> = {},
|
|
@@ -122,36 +125,27 @@ export type BaseRouteOptions<
|
|
|
122
125
|
TRouteContext
|
|
123
126
|
>,
|
|
124
127
|
) => any)
|
|
125
|
-
} &
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
loaderDeps?: (opts: { search: TFullSearchSchema }) => TLoaderDeps
|
|
147
|
-
loader?: RouteLoaderFn<
|
|
148
|
-
TAllParams,
|
|
149
|
-
NoInfer<TLoaderDeps>,
|
|
150
|
-
NoInfer<TAllContext>,
|
|
151
|
-
NoInfer<TRouteContext>,
|
|
152
|
-
TLoaderData
|
|
153
|
-
>
|
|
154
|
-
} & (
|
|
128
|
+
} & {
|
|
129
|
+
// This async function is called before a route is loaded.
|
|
130
|
+
// If an error is thrown here, the route's loader will not be called.
|
|
131
|
+
// If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.
|
|
132
|
+
// If thrown during a preload event, the error will be logged to the console.
|
|
133
|
+
beforeLoad?: BeforeLoadFn<
|
|
134
|
+
TFullSearchSchema,
|
|
135
|
+
TParentRoute,
|
|
136
|
+
TAllParams,
|
|
137
|
+
TRouteContextReturn
|
|
138
|
+
>
|
|
139
|
+
} & {
|
|
140
|
+
loaderDeps?: (opts: { search: TFullSearchSchema }) => TLoaderDeps
|
|
141
|
+
loader?: RouteLoaderFn<
|
|
142
|
+
TAllParams,
|
|
143
|
+
NoInfer<TLoaderDeps>,
|
|
144
|
+
NoInfer<TAllContext>,
|
|
145
|
+
NoInfer<TRouteContext>,
|
|
146
|
+
TLoaderData
|
|
147
|
+
>
|
|
148
|
+
} & (
|
|
155
149
|
| {
|
|
156
150
|
// Both or none
|
|
157
151
|
parseParams?: (
|
|
@@ -173,7 +167,7 @@ type BeforeLoadFn<
|
|
|
173
167
|
TFullSearchSchema extends Record<string, any>,
|
|
174
168
|
TParentRoute extends AnyRoute,
|
|
175
169
|
TAllParams,
|
|
176
|
-
|
|
170
|
+
TRouteContextReturn extends RouteContext,
|
|
177
171
|
> = (opts: {
|
|
178
172
|
search: TFullSearchSchema
|
|
179
173
|
abortController: AbortController
|
|
@@ -184,7 +178,7 @@ type BeforeLoadFn<
|
|
|
184
178
|
navigate: NavigateFn<AnyRoute>
|
|
185
179
|
buildLocation: BuildLocationFn<TParentRoute>
|
|
186
180
|
cause: 'preload' | 'enter' | 'stay'
|
|
187
|
-
}) => Promise<
|
|
181
|
+
}) => Promise<TRouteContextReturn> | TRouteContextReturn | void
|
|
188
182
|
|
|
189
183
|
export type UpdatableRouteOptions<
|
|
190
184
|
TFullSearchSchema extends Record<string, any>,
|
|
@@ -343,6 +337,7 @@ export interface AnyRoute
|
|
|
343
337
|
any,
|
|
344
338
|
any,
|
|
345
339
|
any,
|
|
340
|
+
any,
|
|
346
341
|
any
|
|
347
342
|
> {}
|
|
348
343
|
|
|
@@ -471,7 +466,12 @@ export class Route<
|
|
|
471
466
|
TParentRoute,
|
|
472
467
|
TParams
|
|
473
468
|
>,
|
|
474
|
-
|
|
469
|
+
TRouteContextReturn extends RouteConstraints['TRouteContext'] = RouteContext,
|
|
470
|
+
TRouteContext extends RouteConstraints['TRouteContext'] = [
|
|
471
|
+
TRouteContextReturn,
|
|
472
|
+
] extends [never]
|
|
473
|
+
? RouteContext
|
|
474
|
+
: TRouteContextReturn,
|
|
475
475
|
TAllContext extends Expand<
|
|
476
476
|
Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
|
|
477
477
|
> = Expand<
|
|
@@ -495,6 +495,7 @@ export class Route<
|
|
|
495
495
|
TFullSearchSchema,
|
|
496
496
|
TParams,
|
|
497
497
|
TAllParams,
|
|
498
|
+
TRouteContextReturn,
|
|
498
499
|
TRouteContext,
|
|
499
500
|
TAllContext,
|
|
500
501
|
TLoaderDeps,
|
|
@@ -531,6 +532,7 @@ export class Route<
|
|
|
531
532
|
TFullSearchSchema,
|
|
532
533
|
TParams,
|
|
533
534
|
TAllParams,
|
|
535
|
+
TRouteContextReturn,
|
|
534
536
|
TRouteContext,
|
|
535
537
|
TAllContext,
|
|
536
538
|
TLoaderDeps,
|
|
@@ -583,6 +585,7 @@ export class Route<
|
|
|
583
585
|
TFullSearchSchema,
|
|
584
586
|
TParams,
|
|
585
587
|
TAllParams,
|
|
588
|
+
TRouteContextReturn,
|
|
586
589
|
TRouteContext,
|
|
587
590
|
TAllContext,
|
|
588
591
|
TLoaderDeps,
|
|
@@ -655,6 +658,7 @@ export class Route<
|
|
|
655
658
|
TFullSearchSchema,
|
|
656
659
|
TParams,
|
|
657
660
|
TAllParams,
|
|
661
|
+
TRouteContextReturn,
|
|
658
662
|
TRouteContext,
|
|
659
663
|
TAllContext,
|
|
660
664
|
TRouterContext,
|
|
@@ -690,6 +694,7 @@ export class Route<
|
|
|
690
694
|
TFullSearchSchema,
|
|
691
695
|
TParams,
|
|
692
696
|
TAllParams,
|
|
697
|
+
TRouteContextReturn,
|
|
693
698
|
TRouteContext,
|
|
694
699
|
TAllContext,
|
|
695
700
|
TRouterContext,
|
|
@@ -746,13 +751,14 @@ export class Route<
|
|
|
746
751
|
}
|
|
747
752
|
}
|
|
748
753
|
|
|
749
|
-
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any>
|
|
754
|
+
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>
|
|
750
755
|
|
|
751
756
|
export function rootRouteWithContext<TRouterContext extends {}>() {
|
|
752
757
|
return <
|
|
753
758
|
TSearchSchemaInput extends Record<string, any> = RootSearchSchema,
|
|
754
759
|
TSearchSchema extends Record<string, any> = RootSearchSchema,
|
|
755
760
|
TSearchSchemaUsed extends Record<string, any> = RootSearchSchema,
|
|
761
|
+
TRouteContextReturn extends RouteContext = RouteContext,
|
|
756
762
|
TRouteContext extends RouteContext = RouteContext,
|
|
757
763
|
TLoaderDeps extends Record<string, any> = {},
|
|
758
764
|
TLoaderData extends any = unknown,
|
|
@@ -769,6 +775,7 @@ export function rootRouteWithContext<TRouterContext extends {}>() {
|
|
|
769
775
|
TSearchSchema, // TFullSearchSchema
|
|
770
776
|
{}, // TParams
|
|
771
777
|
{}, // TAllParams
|
|
778
|
+
TRouteContextReturn, // TRouteContextReturn
|
|
772
779
|
TRouteContext, // TRouteContext
|
|
773
780
|
Assign<TRouterContext, TRouteContext>, // TAllContext
|
|
774
781
|
TLoaderDeps,
|
|
@@ -785,6 +792,7 @@ export function rootRouteWithContext<TRouterContext extends {}>() {
|
|
|
785
792
|
TSearchSchemaInput,
|
|
786
793
|
TSearchSchema,
|
|
787
794
|
TSearchSchemaUsed,
|
|
795
|
+
TRouteContextReturn,
|
|
788
796
|
TRouteContext,
|
|
789
797
|
TRouterContext
|
|
790
798
|
> => {
|
|
@@ -800,6 +808,7 @@ export class RootRoute<
|
|
|
800
808
|
TSearchSchemaInput extends Record<string, any> = RootSearchSchema,
|
|
801
809
|
TSearchSchema extends Record<string, any> = RootSearchSchema,
|
|
802
810
|
TSearchSchemaUsed extends Record<string, any> = RootSearchSchema,
|
|
811
|
+
TRouteContextReturn extends RouteContext = RouteContext,
|
|
803
812
|
TRouteContext extends RouteContext = RouteContext,
|
|
804
813
|
TRouterContext extends {} = {},
|
|
805
814
|
TLoaderDeps extends Record<string, any> = {},
|
|
@@ -817,6 +826,7 @@ export class RootRoute<
|
|
|
817
826
|
TSearchSchema, // TFullSearchSchema
|
|
818
827
|
{}, // TParams
|
|
819
828
|
{}, // TAllParams
|
|
829
|
+
TRouteContextReturn, // TRouteContextReturn
|
|
820
830
|
TRouteContext, // TRouteContext
|
|
821
831
|
Expand<Assign<TRouterContext, TRouteContext>>, // TAllContext
|
|
822
832
|
TRouterContext, // TRouterContext
|
|
@@ -838,6 +848,7 @@ export class RootRoute<
|
|
|
838
848
|
TSearchSchema, // TFullSearchSchema
|
|
839
849
|
{}, // TParams
|
|
840
850
|
{}, // TAllParams
|
|
851
|
+
TRouteContextReturn, // TRouteContextReturn
|
|
841
852
|
TRouteContext, // TRouteContext
|
|
842
853
|
Assign<TRouterContext, TRouteContext>, // TAllContext
|
|
843
854
|
TLoaderDeps,
|
|
@@ -957,6 +968,7 @@ export class NotFoundRoute<
|
|
|
957
968
|
> = Expand<
|
|
958
969
|
Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
|
|
959
970
|
>,
|
|
971
|
+
TRouteContextReturn extends RouteConstraints['TRouterContext'] = AnyContext,
|
|
960
972
|
TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
|
|
961
973
|
TLoaderDeps extends Record<string, any> = {},
|
|
962
974
|
TLoaderData extends any = unknown,
|
|
@@ -975,6 +987,7 @@ export class NotFoundRoute<
|
|
|
975
987
|
TFullSearchSchema,
|
|
976
988
|
{},
|
|
977
989
|
{},
|
|
990
|
+
TRouteContextReturn,
|
|
978
991
|
TRouteContext,
|
|
979
992
|
TAllContext,
|
|
980
993
|
TRouterContext,
|
|
@@ -996,6 +1009,7 @@ export class NotFoundRoute<
|
|
|
996
1009
|
TFullSearchSchema,
|
|
997
1010
|
{},
|
|
998
1011
|
{},
|
|
1012
|
+
TRouteContextReturn,
|
|
999
1013
|
TRouteContext,
|
|
1000
1014
|
TAllContext,
|
|
1001
1015
|
TLoaderDeps,
|