@tanstack/react-router 1.49.2 → 1.49.8
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/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +4 -4
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +65 -69
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -1
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +1 -1
- package/dist/esm/fileRoute.d.ts +4 -4
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/route.d.ts +65 -69
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +1 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/fileRoute.ts +20 -37
- package/src/route.ts +172 -185
- package/src/router.ts +0 -1
- package/src/utils.ts +2 -2
package/src/route.ts
CHANGED
|
@@ -54,12 +54,10 @@ export type RouteOptions<
|
|
|
54
54
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
55
55
|
TCustomId extends string = string,
|
|
56
56
|
TPath extends string = string,
|
|
57
|
-
TSearchValidator
|
|
57
|
+
TSearchValidator = undefined,
|
|
58
58
|
TParams = AnyPathParams,
|
|
59
|
-
TAllParams = TParams,
|
|
60
59
|
TLoaderDeps extends Record<string, any> = {},
|
|
61
|
-
|
|
62
|
-
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
60
|
+
TLoaderFn = undefined,
|
|
63
61
|
TRouterContext = {},
|
|
64
62
|
TRouteContextFn = AnyContext,
|
|
65
63
|
TBeforeLoadFn = AnyContext,
|
|
@@ -70,7 +68,7 @@ export type RouteOptions<
|
|
|
70
68
|
TSearchValidator,
|
|
71
69
|
TParams,
|
|
72
70
|
TLoaderDeps,
|
|
73
|
-
|
|
71
|
+
TLoaderFn,
|
|
74
72
|
TRouterContext,
|
|
75
73
|
TRouteContextFn,
|
|
76
74
|
TBeforeLoadFn
|
|
@@ -78,9 +76,9 @@ export type RouteOptions<
|
|
|
78
76
|
UpdatableRouteOptions<
|
|
79
77
|
NoInfer<TParentRoute>,
|
|
80
78
|
NoInfer<TCustomId>,
|
|
81
|
-
NoInfer<
|
|
79
|
+
NoInfer<TParams>,
|
|
82
80
|
NoInfer<TSearchValidator>,
|
|
83
|
-
NoInfer<
|
|
81
|
+
NoInfer<TLoaderFn>,
|
|
84
82
|
NoInfer<TLoaderDeps>,
|
|
85
83
|
NoInfer<TRouterContext>,
|
|
86
84
|
NoInfer<TRouteContextFn>,
|
|
@@ -131,14 +129,14 @@ export type ParamsOptions<TPath extends string, TParams> = {
|
|
|
131
129
|
|
|
132
130
|
export interface FullSearchSchemaOption<
|
|
133
131
|
in out TParentRoute extends AnyRoute,
|
|
134
|
-
in out TSearchValidator
|
|
132
|
+
in out TSearchValidator,
|
|
135
133
|
> {
|
|
136
134
|
search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
|
|
137
135
|
}
|
|
138
136
|
|
|
139
137
|
export type RouteContextFn<
|
|
140
138
|
in out TParentRoute extends AnyRoute,
|
|
141
|
-
in out TSearchValidator
|
|
139
|
+
in out TSearchValidator,
|
|
142
140
|
in out TParams,
|
|
143
141
|
in out TRouterContext,
|
|
144
142
|
> = (
|
|
@@ -152,7 +150,7 @@ export type RouteContextFn<
|
|
|
152
150
|
|
|
153
151
|
export type BeforeLoadFn<
|
|
154
152
|
in out TParentRoute extends AnyRoute,
|
|
155
|
-
in out TSearchValidator
|
|
153
|
+
in out TSearchValidator,
|
|
156
154
|
in out TParams,
|
|
157
155
|
in out TRouterContext,
|
|
158
156
|
in out TRouteContextFn,
|
|
@@ -169,15 +167,20 @@ export type BeforeLoadFn<
|
|
|
169
167
|
export type FileBaseRouteOptions<
|
|
170
168
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
171
169
|
TPath extends string = string,
|
|
172
|
-
TSearchValidator
|
|
170
|
+
TSearchValidator = undefined,
|
|
173
171
|
TParams = {},
|
|
174
172
|
TLoaderDeps extends Record<string, any> = {},
|
|
175
|
-
|
|
173
|
+
TLoaderFn = undefined,
|
|
176
174
|
TRouterContext = {},
|
|
177
175
|
TRouteContextFn = AnyContext,
|
|
178
176
|
TBeforeLoadFn = AnyContext,
|
|
179
177
|
> = ParamsOptions<TPath, TParams> & {
|
|
180
|
-
validateSearch?:
|
|
178
|
+
validateSearch?: Constrain<
|
|
179
|
+
TSearchValidator,
|
|
180
|
+
AnySearchValidator,
|
|
181
|
+
DefaultSearchValidator
|
|
182
|
+
>
|
|
183
|
+
|
|
181
184
|
shouldReload?:
|
|
182
185
|
| boolean
|
|
183
186
|
| ((
|
|
@@ -193,7 +196,14 @@ export type FileBaseRouteOptions<
|
|
|
193
196
|
|
|
194
197
|
context?: Constrain<
|
|
195
198
|
TRouteContextFn,
|
|
196
|
-
|
|
199
|
+
(
|
|
200
|
+
ctx: RouteContextOptions<
|
|
201
|
+
TParentRoute,
|
|
202
|
+
TSearchValidator,
|
|
203
|
+
TParams,
|
|
204
|
+
TRouterContext
|
|
205
|
+
>,
|
|
206
|
+
) => any
|
|
197
207
|
>
|
|
198
208
|
|
|
199
209
|
// This async function is called before a route is loaded.
|
|
@@ -202,39 +212,44 @@ export type FileBaseRouteOptions<
|
|
|
202
212
|
// If thrown during a preload event, the error will be logged to the console.
|
|
203
213
|
beforeLoad?: Constrain<
|
|
204
214
|
TBeforeLoadFn,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
215
|
+
(
|
|
216
|
+
ctx: BeforeLoadContextOptions<
|
|
217
|
+
TParentRoute,
|
|
218
|
+
TSearchValidator,
|
|
219
|
+
TParams,
|
|
220
|
+
TRouterContext,
|
|
221
|
+
TRouteContextFn
|
|
222
|
+
>,
|
|
223
|
+
) => any
|
|
212
224
|
>
|
|
213
225
|
|
|
214
226
|
loaderDeps?: (
|
|
215
227
|
opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>,
|
|
216
228
|
) => TLoaderDeps
|
|
217
229
|
|
|
218
|
-
loader?:
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
230
|
+
loader?: Constrain<
|
|
231
|
+
TLoaderFn,
|
|
232
|
+
(
|
|
233
|
+
ctx: LoaderFnContext<
|
|
234
|
+
TParentRoute,
|
|
235
|
+
TParams,
|
|
236
|
+
TLoaderDeps,
|
|
237
|
+
TRouterContext,
|
|
238
|
+
TRouteContextFn,
|
|
239
|
+
TBeforeLoadFn
|
|
240
|
+
>,
|
|
241
|
+
) => any
|
|
242
|
+
>
|
|
228
243
|
}
|
|
229
244
|
|
|
230
245
|
export type BaseRouteOptions<
|
|
231
246
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
232
247
|
TCustomId extends string = string,
|
|
233
248
|
TPath extends string = string,
|
|
234
|
-
TSearchValidator
|
|
249
|
+
TSearchValidator = undefined,
|
|
235
250
|
TParams = {},
|
|
236
251
|
TLoaderDeps extends Record<string, any> = {},
|
|
237
|
-
|
|
252
|
+
TLoaderFn = undefined,
|
|
238
253
|
TRouterContext = {},
|
|
239
254
|
TRouteContextFn = AnyContext,
|
|
240
255
|
TBeforeLoadFn = AnyContext,
|
|
@@ -245,7 +260,7 @@ export type BaseRouteOptions<
|
|
|
245
260
|
TSearchValidator,
|
|
246
261
|
TParams,
|
|
247
262
|
TLoaderDeps,
|
|
248
|
-
|
|
263
|
+
TLoaderFn,
|
|
249
264
|
TRouterContext,
|
|
250
265
|
TRouteContextFn,
|
|
251
266
|
TBeforeLoadFn
|
|
@@ -255,7 +270,7 @@ export type BaseRouteOptions<
|
|
|
255
270
|
|
|
256
271
|
export interface ContextOptions<
|
|
257
272
|
in out TParentRoute extends AnyRoute,
|
|
258
|
-
in out TSearchValidator
|
|
273
|
+
in out TSearchValidator,
|
|
259
274
|
in out TParams,
|
|
260
275
|
> extends FullSearchSchemaOption<TParentRoute, TSearchValidator> {
|
|
261
276
|
abortController: AbortController
|
|
@@ -272,7 +287,7 @@ export interface ContextOptions<
|
|
|
272
287
|
|
|
273
288
|
export interface RouteContextOptions<
|
|
274
289
|
in out TParentRoute extends AnyRoute,
|
|
275
|
-
in out TSearchValidator
|
|
290
|
+
in out TSearchValidator,
|
|
276
291
|
in out TParams,
|
|
277
292
|
in out TRouterContext,
|
|
278
293
|
> extends ContextOptions<TParentRoute, TSearchValidator, TParams> {
|
|
@@ -281,7 +296,7 @@ export interface RouteContextOptions<
|
|
|
281
296
|
|
|
282
297
|
export interface BeforeLoadContextOptions<
|
|
283
298
|
in out TParentRoute extends AnyRoute,
|
|
284
|
-
in out TSearchValidator
|
|
299
|
+
in out TSearchValidator,
|
|
285
300
|
in out TParams,
|
|
286
301
|
in out TRouterContext,
|
|
287
302
|
in out TRouteContextFn,
|
|
@@ -291,17 +306,17 @@ export interface BeforeLoadContextOptions<
|
|
|
291
306
|
>
|
|
292
307
|
}
|
|
293
308
|
|
|
294
|
-
export
|
|
295
|
-
TParentRoute extends AnyRoute,
|
|
296
|
-
TRouteId,
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
TLoaderDeps,
|
|
301
|
-
TRouterContext,
|
|
302
|
-
TRouteContextFn,
|
|
303
|
-
TBeforeLoadFn,
|
|
304
|
-
>
|
|
309
|
+
export interface UpdatableRouteOptions<
|
|
310
|
+
in out TParentRoute extends AnyRoute,
|
|
311
|
+
in out TRouteId,
|
|
312
|
+
in out TParams,
|
|
313
|
+
in out TSearchValidator,
|
|
314
|
+
in out TLoaderFn,
|
|
315
|
+
in out TLoaderDeps,
|
|
316
|
+
in out TRouterContext,
|
|
317
|
+
in out TRouteContextFn,
|
|
318
|
+
in out TBeforeLoadFn,
|
|
319
|
+
> extends UpdatableStaticRouteOption {
|
|
305
320
|
// test?: (args: TAllContext) => void
|
|
306
321
|
// If true, this route will be matched as case-sensitive
|
|
307
322
|
caseSensitive?: boolean
|
|
@@ -336,9 +351,9 @@ export type UpdatableRouteOptions<
|
|
|
336
351
|
onEnter?: (
|
|
337
352
|
match: RouteMatch<
|
|
338
353
|
TRouteId,
|
|
339
|
-
|
|
354
|
+
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
340
355
|
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
341
|
-
|
|
356
|
+
ResolveLoaderData<TLoaderFn>,
|
|
342
357
|
ResolveAllContext<
|
|
343
358
|
TParentRoute,
|
|
344
359
|
TRouterContext,
|
|
@@ -351,9 +366,9 @@ export type UpdatableRouteOptions<
|
|
|
351
366
|
onStay?: (
|
|
352
367
|
match: RouteMatch<
|
|
353
368
|
TRouteId,
|
|
354
|
-
|
|
369
|
+
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
355
370
|
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
356
|
-
|
|
371
|
+
ResolveLoaderData<TLoaderFn>,
|
|
357
372
|
ResolveAllContext<
|
|
358
373
|
TParentRoute,
|
|
359
374
|
TRouterContext,
|
|
@@ -366,9 +381,9 @@ export type UpdatableRouteOptions<
|
|
|
366
381
|
onLeave?: (
|
|
367
382
|
match: RouteMatch<
|
|
368
383
|
TRouteId,
|
|
369
|
-
|
|
384
|
+
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
370
385
|
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
371
|
-
|
|
386
|
+
ResolveLoaderData<TLoaderFn>,
|
|
372
387
|
ResolveAllContext<
|
|
373
388
|
TParentRoute,
|
|
374
389
|
TRouterContext,
|
|
@@ -382,9 +397,9 @@ export type UpdatableRouteOptions<
|
|
|
382
397
|
matches: Array<
|
|
383
398
|
RouteMatch<
|
|
384
399
|
TRouteId,
|
|
385
|
-
|
|
400
|
+
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
386
401
|
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
387
|
-
|
|
402
|
+
ResolveLoaderData<TLoaderFn>,
|
|
388
403
|
ResolveAllContext<
|
|
389
404
|
TParentRoute,
|
|
390
405
|
TRouterContext,
|
|
@@ -396,9 +411,9 @@ export type UpdatableRouteOptions<
|
|
|
396
411
|
>
|
|
397
412
|
match: RouteMatch<
|
|
398
413
|
TRouteId,
|
|
399
|
-
|
|
414
|
+
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
400
415
|
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
401
|
-
|
|
416
|
+
ResolveLoaderData<TLoaderFn>,
|
|
402
417
|
ResolveAllContext<
|
|
403
418
|
TParentRoute,
|
|
404
419
|
TRouterContext,
|
|
@@ -407,22 +422,27 @@ export type UpdatableRouteOptions<
|
|
|
407
422
|
>,
|
|
408
423
|
TLoaderDeps
|
|
409
424
|
>
|
|
410
|
-
params:
|
|
411
|
-
loaderData:
|
|
425
|
+
params: ResolveAllParamsFromParent<TParentRoute, TParams>
|
|
426
|
+
loaderData: ResolveLoaderData<TLoaderFn>
|
|
412
427
|
}) => Array<React.JSX.IntrinsicElements['meta']>
|
|
413
428
|
links?: () => Array<React.JSX.IntrinsicElements['link']>
|
|
414
429
|
scripts?: () => Array<React.JSX.IntrinsicElements['script']>
|
|
415
|
-
headers?: (ctx: {
|
|
416
|
-
|
|
430
|
+
headers?: (ctx: {
|
|
431
|
+
loaderData: ResolveLoaderData<TLoaderFn>
|
|
432
|
+
}) => Record<string, string>
|
|
433
|
+
}
|
|
417
434
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
435
|
+
interface RequiredStaticDataRouteOption {
|
|
436
|
+
staticData: StaticDataRouteOption
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
interface OptionalStaticDataRouteOption {
|
|
440
|
+
staticData?: StaticDataRouteOption
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export type UpdatableStaticRouteOption = {} extends StaticDataRouteOption
|
|
444
|
+
? OptionalStaticDataRouteOption
|
|
445
|
+
: RequiredStaticDataRouteOption
|
|
426
446
|
|
|
427
447
|
export type MetaDescriptor =
|
|
428
448
|
| { charSet: 'utf-8' }
|
|
@@ -483,7 +503,6 @@ export type RouteLoaderFn<
|
|
|
483
503
|
in out TRouterContext = {},
|
|
484
504
|
in out TRouteContextFn = AnyContext,
|
|
485
505
|
in out TBeforeLoadFn = AnyContext,
|
|
486
|
-
TLoaderData = undefined,
|
|
487
506
|
> = (
|
|
488
507
|
match: LoaderFnContext<
|
|
489
508
|
TParentRoute,
|
|
@@ -493,7 +512,7 @@ export type RouteLoaderFn<
|
|
|
493
512
|
TRouteContextFn,
|
|
494
513
|
TBeforeLoadFn
|
|
495
514
|
>,
|
|
496
|
-
) =>
|
|
515
|
+
) => any
|
|
497
516
|
|
|
498
517
|
export interface LoaderFnContext<
|
|
499
518
|
in out TParentRoute extends AnyRoute = AnyRoute,
|
|
@@ -569,28 +588,27 @@ export type InferAllContext<TRoute> = unknown extends TRoute
|
|
|
569
588
|
? TAllContext
|
|
570
589
|
: {}
|
|
571
590
|
|
|
572
|
-
export type ResolveSearchSchemaFnInput<
|
|
573
|
-
TSearchValidator extends
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
: ResolveSearchSchemaFn<TSearchValidator>
|
|
578
|
-
: AnySearchSchema
|
|
579
|
-
|
|
580
|
-
export type ResolveSearchSchemaInput<
|
|
581
|
-
TSearchValidator extends AnySearchValidator,
|
|
582
|
-
> = TSearchValidator extends AnySearchValidatorAdapter
|
|
583
|
-
? TSearchValidator['types']['input']
|
|
584
|
-
: TSearchValidator extends AnySearchValidatorObj
|
|
585
|
-
? ResolveSearchSchemaFnInput<TSearchValidator['parse']>
|
|
586
|
-
: ResolveSearchSchemaFnInput<TSearchValidator>
|
|
587
|
-
|
|
588
|
-
export type ResolveSearchSchemaFn<TSearchValidator extends AnySearchValidator> =
|
|
589
|
-
TSearchValidator extends (...args: any) => infer TSearchSchema
|
|
590
|
-
? TSearchSchema
|
|
591
|
+
export type ResolveSearchSchemaFnInput<TSearchValidator> =
|
|
592
|
+
TSearchValidator extends (input: infer TSearchSchemaInput) => any
|
|
593
|
+
? TSearchSchemaInput extends SearchSchemaInput
|
|
594
|
+
? Omit<TSearchSchemaInput, keyof SearchSchemaInput>
|
|
595
|
+
: ResolveSearchSchemaFn<TSearchValidator>
|
|
591
596
|
: AnySearchSchema
|
|
592
597
|
|
|
593
|
-
export type
|
|
598
|
+
export type ResolveSearchSchemaInput<TSearchValidator> =
|
|
599
|
+
TSearchValidator extends AnySearchValidatorAdapter
|
|
600
|
+
? TSearchValidator['types']['input']
|
|
601
|
+
: TSearchValidator extends AnySearchValidatorObj
|
|
602
|
+
? ResolveSearchSchemaFnInput<TSearchValidator['parse']>
|
|
603
|
+
: ResolveSearchSchemaFnInput<TSearchValidator>
|
|
604
|
+
|
|
605
|
+
export type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (
|
|
606
|
+
...args: any
|
|
607
|
+
) => infer TSearchSchema
|
|
608
|
+
? TSearchSchema
|
|
609
|
+
: AnySearchSchema
|
|
610
|
+
|
|
611
|
+
export type ResolveSearchSchema<TSearchValidator> =
|
|
594
612
|
unknown extends TSearchValidator
|
|
595
613
|
? TSearchValidator
|
|
596
614
|
: TSearchValidator extends AnySearchValidatorAdapter
|
|
@@ -601,7 +619,7 @@ export type ResolveSearchSchema<TSearchValidator extends AnySearchValidator> =
|
|
|
601
619
|
|
|
602
620
|
export type ResolveFullSearchSchema<
|
|
603
621
|
TParentRoute extends AnyRoute,
|
|
604
|
-
TSearchValidator
|
|
622
|
+
TSearchValidator,
|
|
605
623
|
> = unknown extends TParentRoute
|
|
606
624
|
? ResolveSearchSchema<TSearchValidator>
|
|
607
625
|
: Assign<
|
|
@@ -611,7 +629,7 @@ export type ResolveFullSearchSchema<
|
|
|
611
629
|
|
|
612
630
|
export type ResolveFullSearchSchemaInput<
|
|
613
631
|
TParentRoute extends AnyRoute,
|
|
614
|
-
TSearchValidator
|
|
632
|
+
TSearchValidator,
|
|
615
633
|
> = Assign<
|
|
616
634
|
InferFullSearchSchemaInput<TParentRoute>,
|
|
617
635
|
ResolveSearchSchemaInput<TSearchValidator>
|
|
@@ -673,11 +691,11 @@ export type ResolveAllContext<
|
|
|
673
691
|
ContextAsyncReturnType<TBeforeLoadFn>
|
|
674
692
|
>
|
|
675
693
|
|
|
676
|
-
export type ResolveLoaderData<
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
694
|
+
export type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn
|
|
695
|
+
? TLoaderFn
|
|
696
|
+
: LooseAsyncReturnType<TLoaderFn> extends never
|
|
697
|
+
? {}
|
|
698
|
+
: LooseAsyncReturnType<TLoaderFn>
|
|
681
699
|
|
|
682
700
|
export interface AnyRoute
|
|
683
701
|
extends Route<
|
|
@@ -693,8 +711,6 @@ export interface AnyRoute
|
|
|
693
711
|
any,
|
|
694
712
|
any,
|
|
695
713
|
any,
|
|
696
|
-
any,
|
|
697
|
-
any,
|
|
698
714
|
any
|
|
699
715
|
> {}
|
|
700
716
|
|
|
@@ -831,15 +847,13 @@ export class Route<
|
|
|
831
847
|
TCustomId,
|
|
832
848
|
TPath
|
|
833
849
|
>,
|
|
834
|
-
in out TSearchValidator
|
|
850
|
+
in out TSearchValidator = undefined,
|
|
835
851
|
in out TParams = ResolveParams<TPath>,
|
|
836
|
-
in out TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
837
852
|
in out TRouterContext = AnyContext,
|
|
838
853
|
in out TRouteContextFn = AnyContext,
|
|
839
854
|
in out TBeforeLoadFn = AnyContext,
|
|
840
855
|
in out TLoaderDeps extends Record<string, any> = {},
|
|
841
|
-
|
|
842
|
-
in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
856
|
+
in out TLoaderFn = undefined,
|
|
843
857
|
in out TChildren = unknown,
|
|
844
858
|
> {
|
|
845
859
|
isRoot: TParentRoute extends Route<any> ? true : false
|
|
@@ -849,10 +863,8 @@ export class Route<
|
|
|
849
863
|
TPath,
|
|
850
864
|
TSearchValidator,
|
|
851
865
|
TParams,
|
|
852
|
-
TAllParams,
|
|
853
866
|
TLoaderDeps,
|
|
854
|
-
|
|
855
|
-
TLoaderData,
|
|
867
|
+
TLoaderFn,
|
|
856
868
|
TRouterContext,
|
|
857
869
|
TRouteContextFn,
|
|
858
870
|
TBeforeLoadFn
|
|
@@ -884,10 +896,8 @@ export class Route<
|
|
|
884
896
|
TPath,
|
|
885
897
|
TSearchValidator,
|
|
886
898
|
TParams,
|
|
887
|
-
TAllParams,
|
|
888
899
|
TLoaderDeps,
|
|
889
|
-
|
|
890
|
-
TLoaderData,
|
|
900
|
+
TLoaderFn,
|
|
891
901
|
TRouterContext,
|
|
892
902
|
TRouteContextFn,
|
|
893
903
|
TBeforeLoadFn
|
|
@@ -919,7 +929,7 @@ export class Route<
|
|
|
919
929
|
TSearchValidator
|
|
920
930
|
>
|
|
921
931
|
params: TParams
|
|
922
|
-
allParams:
|
|
932
|
+
allParams: ResolveAllParamsFromParent<TParentRoute, TParams>
|
|
923
933
|
routerContext: TRouterContext
|
|
924
934
|
routeContext: ResolveRouteContext<TRouteContextFn, TBeforeLoadFn>
|
|
925
935
|
routeContextFn: TRouteContextFn
|
|
@@ -931,7 +941,7 @@ export class Route<
|
|
|
931
941
|
TBeforeLoadFn
|
|
932
942
|
>
|
|
933
943
|
children: TChildren
|
|
934
|
-
loaderData:
|
|
944
|
+
loaderData: ResolveLoaderData<TLoaderFn>
|
|
935
945
|
loaderDeps: TLoaderDeps
|
|
936
946
|
}
|
|
937
947
|
|
|
@@ -945,10 +955,8 @@ export class Route<
|
|
|
945
955
|
TPath,
|
|
946
956
|
TSearchValidator,
|
|
947
957
|
TParams,
|
|
948
|
-
TAllParams,
|
|
949
958
|
TLoaderDeps,
|
|
950
|
-
|
|
951
|
-
TLoaderData,
|
|
959
|
+
TLoaderFn,
|
|
952
960
|
TRouterContext,
|
|
953
961
|
TRouteContextFn,
|
|
954
962
|
TBeforeLoadFn
|
|
@@ -1019,13 +1027,11 @@ export class Route<
|
|
|
1019
1027
|
TId,
|
|
1020
1028
|
TSearchValidator,
|
|
1021
1029
|
TParams,
|
|
1022
|
-
TAllParams,
|
|
1023
1030
|
TRouterContext,
|
|
1024
1031
|
TRouteContextFn,
|
|
1025
1032
|
TBeforeLoadFn,
|
|
1026
1033
|
TLoaderDeps,
|
|
1027
|
-
|
|
1028
|
-
TLoaderData,
|
|
1034
|
+
TLoaderFn,
|
|
1029
1035
|
TNewChildren
|
|
1030
1036
|
> {
|
|
1031
1037
|
this.children = (
|
|
@@ -1034,15 +1040,17 @@ export class Route<
|
|
|
1034
1040
|
return this as any
|
|
1035
1041
|
}
|
|
1036
1042
|
|
|
1037
|
-
updateLoader = <
|
|
1038
|
-
loader:
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1043
|
+
updateLoader = <TNewLoaderFn>(options: {
|
|
1044
|
+
loader: Constrain<
|
|
1045
|
+
TNewLoaderFn,
|
|
1046
|
+
RouteLoaderFn<
|
|
1047
|
+
TParentRoute,
|
|
1048
|
+
TParams,
|
|
1049
|
+
TLoaderDeps,
|
|
1050
|
+
TRouterContext,
|
|
1051
|
+
TRouteContextFn,
|
|
1052
|
+
TBeforeLoadFn
|
|
1053
|
+
>
|
|
1046
1054
|
>
|
|
1047
1055
|
}) => {
|
|
1048
1056
|
Object.assign(this.options, options)
|
|
@@ -1054,12 +1062,11 @@ export class Route<
|
|
|
1054
1062
|
TId,
|
|
1055
1063
|
TSearchValidator,
|
|
1056
1064
|
TParams,
|
|
1057
|
-
TAllParams,
|
|
1058
1065
|
TRouterContext,
|
|
1059
1066
|
TRouteContextFn,
|
|
1060
1067
|
TBeforeLoadFn,
|
|
1061
1068
|
TLoaderDeps,
|
|
1062
|
-
|
|
1069
|
+
TNewLoaderFn,
|
|
1063
1070
|
TChildren
|
|
1064
1071
|
>
|
|
1065
1072
|
}
|
|
@@ -1068,9 +1075,9 @@ export class Route<
|
|
|
1068
1075
|
options: UpdatableRouteOptions<
|
|
1069
1076
|
TParentRoute,
|
|
1070
1077
|
TCustomId,
|
|
1071
|
-
|
|
1078
|
+
TParams,
|
|
1072
1079
|
TSearchValidator,
|
|
1073
|
-
|
|
1080
|
+
TLoaderFn,
|
|
1074
1081
|
TLoaderDeps,
|
|
1075
1082
|
TRouterContext,
|
|
1076
1083
|
TRouteContextFn,
|
|
@@ -1135,8 +1142,12 @@ export class Route<
|
|
|
1135
1142
|
return useSearch({ ...opts, from: this.id })
|
|
1136
1143
|
}
|
|
1137
1144
|
|
|
1138
|
-
useParams = <
|
|
1139
|
-
|
|
1145
|
+
useParams = <
|
|
1146
|
+
TSelected = Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,
|
|
1147
|
+
>(opts?: {
|
|
1148
|
+
select?: (
|
|
1149
|
+
search: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,
|
|
1150
|
+
) => TSelected
|
|
1140
1151
|
}): TSelected => {
|
|
1141
1152
|
return useParams({ ...opts, from: this.id })
|
|
1142
1153
|
}
|
|
@@ -1147,8 +1158,8 @@ export class Route<
|
|
|
1147
1158
|
return useLoaderDeps({ ...opts, from: this.id } as any)
|
|
1148
1159
|
}
|
|
1149
1160
|
|
|
1150
|
-
useLoaderData = <TSelected =
|
|
1151
|
-
select?: (search:
|
|
1161
|
+
useLoaderData = <TSelected = ResolveLoaderData<TLoaderFn>>(opts?: {
|
|
1162
|
+
select?: (search: ResolveLoaderData<TLoaderFn>) => TSelected
|
|
1152
1163
|
}): TSelected => {
|
|
1153
1164
|
return useLoaderData({ ...opts, from: this.id } as any)
|
|
1154
1165
|
}
|
|
@@ -1171,14 +1182,12 @@ export function createRoute<
|
|
|
1171
1182
|
TCustomId,
|
|
1172
1183
|
TPath
|
|
1173
1184
|
>,
|
|
1174
|
-
TSearchValidator
|
|
1185
|
+
TSearchValidator = undefined,
|
|
1175
1186
|
TParams = ResolveParams<TPath>,
|
|
1176
|
-
TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
1177
1187
|
TRouteContextFn = AnyContext,
|
|
1178
1188
|
TBeforeLoadFn = AnyContext,
|
|
1179
1189
|
TLoaderDeps extends Record<string, any> = {},
|
|
1180
|
-
|
|
1181
|
-
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
1190
|
+
TLoaderFn = undefined,
|
|
1182
1191
|
TChildren = unknown,
|
|
1183
1192
|
>(
|
|
1184
1193
|
options: RouteOptions<
|
|
@@ -1187,10 +1196,8 @@ export function createRoute<
|
|
|
1187
1196
|
TPath,
|
|
1188
1197
|
TSearchValidator,
|
|
1189
1198
|
TParams,
|
|
1190
|
-
TAllParams,
|
|
1191
1199
|
TLoaderDeps,
|
|
1192
|
-
|
|
1193
|
-
TLoaderData,
|
|
1200
|
+
TLoaderFn,
|
|
1194
1201
|
AnyContext,
|
|
1195
1202
|
TRouteContextFn,
|
|
1196
1203
|
TBeforeLoadFn
|
|
@@ -1204,27 +1211,24 @@ export function createRoute<
|
|
|
1204
1211
|
TId,
|
|
1205
1212
|
TSearchValidator,
|
|
1206
1213
|
TParams,
|
|
1207
|
-
TAllParams,
|
|
1208
1214
|
AnyContext,
|
|
1209
1215
|
TRouteContextFn,
|
|
1210
1216
|
TBeforeLoadFn,
|
|
1211
1217
|
TLoaderDeps,
|
|
1212
|
-
|
|
1213
|
-
TLoaderData,
|
|
1218
|
+
TLoaderFn,
|
|
1214
1219
|
TChildren
|
|
1215
1220
|
>(options)
|
|
1216
1221
|
}
|
|
1217
1222
|
|
|
1218
|
-
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any
|
|
1223
|
+
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any>
|
|
1219
1224
|
|
|
1220
1225
|
export type RootRouteOptions<
|
|
1221
|
-
TSearchValidator
|
|
1226
|
+
TSearchValidator = undefined,
|
|
1222
1227
|
TRouterContext = {},
|
|
1223
1228
|
TRouteContextFn = AnyContext,
|
|
1224
1229
|
TBeforeLoadFn = AnyContext,
|
|
1225
1230
|
TLoaderDeps extends Record<string, any> = {},
|
|
1226
|
-
|
|
1227
|
-
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
1231
|
+
TLoaderFn = undefined,
|
|
1228
1232
|
> = Omit<
|
|
1229
1233
|
RouteOptions<
|
|
1230
1234
|
any, // TParentRoute
|
|
@@ -1232,10 +1236,8 @@ export type RootRouteOptions<
|
|
|
1232
1236
|
'', // TPath
|
|
1233
1237
|
TSearchValidator,
|
|
1234
1238
|
{}, // TParams
|
|
1235
|
-
{}, // TAllParams
|
|
1236
1239
|
TLoaderDeps,
|
|
1237
|
-
|
|
1238
|
-
TLoaderData, // TLoaderData,
|
|
1240
|
+
TLoaderFn,
|
|
1239
1241
|
TRouterContext,
|
|
1240
1242
|
TRouteContextFn,
|
|
1241
1243
|
TBeforeLoadFn
|
|
@@ -1253,10 +1255,9 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
|
1253
1255
|
return <
|
|
1254
1256
|
TRouteContextFn = AnyContext,
|
|
1255
1257
|
TBeforeLoadFn = AnyContext,
|
|
1256
|
-
TSearchValidator
|
|
1258
|
+
TSearchValidator = undefined,
|
|
1257
1259
|
TLoaderDeps extends Record<string, any> = {},
|
|
1258
|
-
|
|
1259
|
-
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
1260
|
+
TLoaderFn = undefined,
|
|
1260
1261
|
>(
|
|
1261
1262
|
options?: RootRouteOptions<
|
|
1262
1263
|
TSearchValidator,
|
|
@@ -1264,8 +1265,7 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
|
1264
1265
|
TRouteContextFn,
|
|
1265
1266
|
TBeforeLoadFn,
|
|
1266
1267
|
TLoaderDeps,
|
|
1267
|
-
|
|
1268
|
-
TLoaderData
|
|
1268
|
+
TLoaderFn
|
|
1269
1269
|
>,
|
|
1270
1270
|
) => {
|
|
1271
1271
|
return createRootRoute<
|
|
@@ -1274,7 +1274,7 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
|
1274
1274
|
TRouteContextFn,
|
|
1275
1275
|
TBeforeLoadFn,
|
|
1276
1276
|
TLoaderDeps,
|
|
1277
|
-
|
|
1277
|
+
TLoaderFn
|
|
1278
1278
|
>(options as any)
|
|
1279
1279
|
}
|
|
1280
1280
|
}
|
|
@@ -1285,13 +1285,12 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
|
1285
1285
|
export const rootRouteWithContext = createRootRouteWithContext
|
|
1286
1286
|
|
|
1287
1287
|
export class RootRoute<
|
|
1288
|
-
in out TSearchValidator
|
|
1288
|
+
in out TSearchValidator = undefined,
|
|
1289
1289
|
in out TRouterContext = {},
|
|
1290
1290
|
in out TRouteContextFn = AnyContext,
|
|
1291
1291
|
in out TBeforeLoadFn = AnyContext,
|
|
1292
1292
|
TLoaderDeps extends Record<string, any> = {},
|
|
1293
|
-
|
|
1294
|
-
in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
1293
|
+
in out TLoaderFn = undefined,
|
|
1295
1294
|
TChildren = unknown,
|
|
1296
1295
|
> extends Route<
|
|
1297
1296
|
any, // TParentRoute
|
|
@@ -1301,13 +1300,11 @@ export class RootRoute<
|
|
|
1301
1300
|
RootRouteId, // TId
|
|
1302
1301
|
TSearchValidator, // TSearchValidator
|
|
1303
1302
|
{}, // TParams
|
|
1304
|
-
{}, // TAllParams
|
|
1305
1303
|
TRouterContext,
|
|
1306
1304
|
TRouteContextFn,
|
|
1307
1305
|
TBeforeLoadFn,
|
|
1308
1306
|
TLoaderDeps,
|
|
1309
|
-
|
|
1310
|
-
TLoaderData,
|
|
1307
|
+
TLoaderFn,
|
|
1311
1308
|
TChildren // TChildren
|
|
1312
1309
|
> {
|
|
1313
1310
|
/**
|
|
@@ -1320,8 +1317,7 @@ export class RootRoute<
|
|
|
1320
1317
|
TRouteContextFn,
|
|
1321
1318
|
TBeforeLoadFn,
|
|
1322
1319
|
TLoaderDeps,
|
|
1323
|
-
|
|
1324
|
-
TLoaderData
|
|
1320
|
+
TLoaderFn
|
|
1325
1321
|
>,
|
|
1326
1322
|
) {
|
|
1327
1323
|
super(options as any)
|
|
@@ -1339,8 +1335,7 @@ export class RootRoute<
|
|
|
1339
1335
|
TRouteContextFn,
|
|
1340
1336
|
TBeforeLoadFn,
|
|
1341
1337
|
TLoaderDeps,
|
|
1342
|
-
|
|
1343
|
-
TLoaderData,
|
|
1338
|
+
TLoaderFn,
|
|
1344
1339
|
TNewChildren
|
|
1345
1340
|
> {
|
|
1346
1341
|
return super.addChildren(children)
|
|
@@ -1348,13 +1343,12 @@ export class RootRoute<
|
|
|
1348
1343
|
}
|
|
1349
1344
|
|
|
1350
1345
|
export function createRootRoute<
|
|
1351
|
-
TSearchValidator
|
|
1346
|
+
TSearchValidator = undefined,
|
|
1352
1347
|
TRouterContext = {},
|
|
1353
1348
|
TRouteContextFn = AnyContext,
|
|
1354
1349
|
TBeforeLoadFn = AnyContext,
|
|
1355
1350
|
TLoaderDeps extends Record<string, any> = {},
|
|
1356
|
-
|
|
1357
|
-
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
1351
|
+
TLoaderFn = undefined,
|
|
1358
1352
|
>(
|
|
1359
1353
|
options?: RootRouteOptions<
|
|
1360
1354
|
TSearchValidator,
|
|
@@ -1362,8 +1356,7 @@ export function createRootRoute<
|
|
|
1362
1356
|
TRouteContextFn,
|
|
1363
1357
|
TBeforeLoadFn,
|
|
1364
1358
|
TLoaderDeps,
|
|
1365
|
-
|
|
1366
|
-
TLoaderData
|
|
1359
|
+
TLoaderFn
|
|
1367
1360
|
>,
|
|
1368
1361
|
) {
|
|
1369
1362
|
return new RootRoute<
|
|
@@ -1372,8 +1365,7 @@ export function createRootRoute<
|
|
|
1372
1365
|
TRouteContextFn,
|
|
1373
1366
|
TBeforeLoadFn,
|
|
1374
1367
|
TLoaderDeps,
|
|
1375
|
-
|
|
1376
|
-
TLoaderData
|
|
1368
|
+
TLoaderFn
|
|
1377
1369
|
>(options)
|
|
1378
1370
|
}
|
|
1379
1371
|
|
|
@@ -1478,10 +1470,9 @@ export class NotFoundRoute<
|
|
|
1478
1470
|
TRouterContext = AnyContext,
|
|
1479
1471
|
TRouteContextFn = AnyContext,
|
|
1480
1472
|
TBeforeLoadFn = AnyContext,
|
|
1481
|
-
TSearchValidator
|
|
1473
|
+
TSearchValidator = undefined,
|
|
1482
1474
|
TLoaderDeps extends Record<string, any> = {},
|
|
1483
|
-
|
|
1484
|
-
TLoaderData = ResolveLoaderData<TLoaderDataReturn>,
|
|
1475
|
+
TLoaderFn = undefined,
|
|
1485
1476
|
TChildren = unknown,
|
|
1486
1477
|
> extends Route<
|
|
1487
1478
|
TParentRoute,
|
|
@@ -1491,13 +1482,11 @@ export class NotFoundRoute<
|
|
|
1491
1482
|
'404',
|
|
1492
1483
|
TSearchValidator,
|
|
1493
1484
|
{},
|
|
1494
|
-
{},
|
|
1495
1485
|
TRouterContext,
|
|
1496
1486
|
TRouteContextFn,
|
|
1497
1487
|
TBeforeLoadFn,
|
|
1498
1488
|
TLoaderDeps,
|
|
1499
|
-
|
|
1500
|
-
TLoaderData,
|
|
1489
|
+
TLoaderFn,
|
|
1501
1490
|
TChildren
|
|
1502
1491
|
> {
|
|
1503
1492
|
constructor(
|
|
@@ -1508,10 +1497,8 @@ export class NotFoundRoute<
|
|
|
1508
1497
|
string,
|
|
1509
1498
|
TSearchValidator,
|
|
1510
1499
|
{},
|
|
1511
|
-
{},
|
|
1512
1500
|
TLoaderDeps,
|
|
1513
|
-
|
|
1514
|
-
TLoaderData,
|
|
1501
|
+
TLoaderFn,
|
|
1515
1502
|
TRouterContext,
|
|
1516
1503
|
TRouteContextFn,
|
|
1517
1504
|
TBeforeLoadFn
|