@tanstack/router-core 0.0.1-beta.192 → 0.0.1-beta.194
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/cjs/router.js +29 -18
- package/build/cjs/router.js.map +1 -1
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +29 -18
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +124 -124
- package/build/types/fileRoute.d.ts +4 -4
- package/build/types/link.d.ts +9 -9
- package/build/types/route.d.ts +72 -62
- package/build/types/routeInfo.d.ts +4 -4
- package/build/types/router.d.ts +1 -2
- package/build/types/utils.d.ts +8 -1
- package/build/umd/index.development.js +29 -18
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/fileRoute.ts +12 -10
- package/src/link.ts +27 -14
- package/src/route.ts +155 -197
- package/src/routeInfo.ts +10 -7
- package/src/router.ts +51 -25
- package/src/utils.ts +21 -1
package/src/route.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { RoutePaths } from './routeInfo'
|
|
|
3
3
|
import { joinPaths, trimPath } from './path'
|
|
4
4
|
import { AnyRouter, RouteMatch, AnyRouteMatch } from './router'
|
|
5
5
|
import {
|
|
6
|
+
DeepMerge,
|
|
7
|
+
DeepMergeAll,
|
|
6
8
|
Expand,
|
|
7
9
|
IsAny,
|
|
8
10
|
NoInfer,
|
|
@@ -20,63 +22,63 @@ export interface RouteMeta {}
|
|
|
20
22
|
export interface RouteContext {}
|
|
21
23
|
export interface RegisterRouteComponent<
|
|
22
24
|
TLoader = unknown,
|
|
23
|
-
TFullSearchSchema extends
|
|
25
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
24
26
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
25
|
-
TRouteContext extends
|
|
26
|
-
TAllContext extends
|
|
27
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
28
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
27
29
|
> {
|
|
28
30
|
// RouteComponent: unknown // This is registered by the framework
|
|
29
31
|
}
|
|
30
32
|
export interface RegisterErrorRouteComponent<
|
|
31
|
-
TFullSearchSchema extends
|
|
33
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
32
34
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
33
|
-
TRouteContext extends
|
|
34
|
-
TAllContext extends
|
|
35
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
36
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
35
37
|
> {
|
|
36
38
|
// ErrorRouteComponent: unknown // This is registered by the framework
|
|
37
39
|
}
|
|
38
40
|
export interface RegisterPendingRouteComponent<
|
|
39
|
-
TFullSearchSchema extends
|
|
41
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
40
42
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
41
|
-
TRouteContext extends
|
|
42
|
-
TAllContext extends
|
|
43
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
44
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
43
45
|
> {
|
|
44
46
|
// PendingRouteComponent: unknown // This is registered by the framework
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
export interface RegisterRouteProps<
|
|
48
50
|
TLoader = unknown,
|
|
49
|
-
TFullSearchSchema extends
|
|
51
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
50
52
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
51
|
-
TRouteContext extends
|
|
52
|
-
TAllContext extends
|
|
53
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
54
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
53
55
|
> {
|
|
54
56
|
// RouteProps: unknown // This is registered by the framework
|
|
55
57
|
}
|
|
56
58
|
export interface RegisterErrorRouteProps<
|
|
57
|
-
TFullSearchSchema extends
|
|
59
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
58
60
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
59
|
-
TRouteContext extends
|
|
60
|
-
TAllContext extends
|
|
61
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
62
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
61
63
|
> {
|
|
62
64
|
// ErrorRouteProps: unknown // This is registered by the framework
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
export interface RegisterPendingRouteProps<
|
|
66
|
-
TFullSearchSchema extends
|
|
68
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
67
69
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
68
|
-
TRouteContext extends
|
|
69
|
-
TAllContext extends
|
|
70
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
71
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
70
72
|
> {
|
|
71
73
|
// PendingRouteProps: unknown // This is registered by the framework
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
export type RegisteredRouteComponent<
|
|
75
77
|
TLoader = unknown,
|
|
76
|
-
TFullSearchSchema extends
|
|
78
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
77
79
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
78
|
-
TRouteContext extends
|
|
79
|
-
TAllContext extends
|
|
80
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
81
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
80
82
|
> = RegisterRouteComponent<
|
|
81
83
|
TLoader,
|
|
82
84
|
TFullSearchSchema,
|
|
@@ -90,10 +92,10 @@ export type RegisteredRouteComponent<
|
|
|
90
92
|
: () => unknown
|
|
91
93
|
|
|
92
94
|
export type RegisteredErrorRouteComponent<
|
|
93
|
-
TFullSearchSchema extends
|
|
95
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
94
96
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
95
|
-
TRouteContext extends
|
|
96
|
-
TAllContext extends
|
|
97
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
98
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
97
99
|
> = RegisterErrorRouteComponent<
|
|
98
100
|
TFullSearchSchema,
|
|
99
101
|
TAllParams,
|
|
@@ -106,10 +108,10 @@ export type RegisteredErrorRouteComponent<
|
|
|
106
108
|
: () => unknown
|
|
107
109
|
|
|
108
110
|
export type RegisteredPendingRouteComponent<
|
|
109
|
-
TFullSearchSchema extends
|
|
111
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
110
112
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
111
|
-
TRouteContext extends
|
|
112
|
-
TAllContext extends
|
|
113
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
114
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
113
115
|
> = RegisterPendingRouteComponent<
|
|
114
116
|
TFullSearchSchema,
|
|
115
117
|
TAllParams,
|
|
@@ -123,10 +125,10 @@ export type RegisteredPendingRouteComponent<
|
|
|
123
125
|
|
|
124
126
|
export type RegisteredRouteProps<
|
|
125
127
|
TLoader = unknown,
|
|
126
|
-
TFullSearchSchema extends
|
|
128
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
127
129
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
128
|
-
TRouteContext extends
|
|
129
|
-
TAllContext extends
|
|
130
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
131
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
130
132
|
> = RegisterRouteProps<
|
|
131
133
|
TLoader,
|
|
132
134
|
TFullSearchSchema,
|
|
@@ -140,10 +142,10 @@ export type RegisteredRouteProps<
|
|
|
140
142
|
: {}
|
|
141
143
|
|
|
142
144
|
export type RegisteredErrorRouteProps<
|
|
143
|
-
TFullSearchSchema extends
|
|
145
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
144
146
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
145
|
-
TRouteContext extends
|
|
146
|
-
TAllContext extends
|
|
147
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
148
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
147
149
|
> = RegisterRouteProps<
|
|
148
150
|
TFullSearchSchema,
|
|
149
151
|
TAllParams,
|
|
@@ -156,10 +158,10 @@ export type RegisteredErrorRouteProps<
|
|
|
156
158
|
: {}
|
|
157
159
|
|
|
158
160
|
export type RegisteredPendingRouteProps<
|
|
159
|
-
TFullSearchSchema extends
|
|
161
|
+
TFullSearchSchema extends Record<string, any> = AnySearchSchema,
|
|
160
162
|
TAllParams extends AnyPathParams = AnyPathParams,
|
|
161
|
-
TRouteContext extends
|
|
162
|
-
TAllContext extends
|
|
163
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
164
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
163
165
|
> = RegisterRouteProps<
|
|
164
166
|
TFullSearchSchema,
|
|
165
167
|
TAllParams,
|
|
@@ -198,28 +200,24 @@ export type RouteOptions<
|
|
|
198
200
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
199
201
|
TCustomId extends string = string,
|
|
200
202
|
TPath extends string = string,
|
|
203
|
+
TLoaderContext extends Record<string, any> = AnyContext,
|
|
201
204
|
TLoader = unknown,
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
TFullSearchSchema extends AnySearchSchema = TSearchSchema,
|
|
205
|
+
TSearchSchema extends Record<string, any> = {},
|
|
206
|
+
TFullSearchSchema extends Record<string, any> = TSearchSchema,
|
|
205
207
|
TParams extends AnyPathParams = AnyPathParams,
|
|
206
208
|
TAllParams extends AnyPathParams = TParams,
|
|
207
|
-
TParentContext extends AnyContext = AnyContext,
|
|
208
|
-
TAllParentContext extends AnyContext = AnyContext,
|
|
209
209
|
TRouteContext extends RouteContext = RouteContext,
|
|
210
|
-
TAllContext extends
|
|
210
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
211
211
|
> = BaseRouteOptions<
|
|
212
212
|
TParentRoute,
|
|
213
213
|
TCustomId,
|
|
214
214
|
TPath,
|
|
215
|
+
TLoaderContext,
|
|
215
216
|
TLoader,
|
|
216
|
-
TParentSearchSchema,
|
|
217
217
|
TSearchSchema,
|
|
218
218
|
TFullSearchSchema,
|
|
219
219
|
TParams,
|
|
220
220
|
TAllParams,
|
|
221
|
-
TParentContext,
|
|
222
|
-
TAllParentContext,
|
|
223
221
|
TRouteContext,
|
|
224
222
|
TAllContext
|
|
225
223
|
> &
|
|
@@ -245,27 +243,18 @@ export type BaseRouteOptions<
|
|
|
245
243
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
246
244
|
TCustomId extends string = string,
|
|
247
245
|
TPath extends string = string,
|
|
246
|
+
TLoaderContext extends Record<string, any> = AnyContext,
|
|
248
247
|
TLoader = unknown,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
TFullSearchSchema extends AnySearchSchema = TSearchSchema,
|
|
248
|
+
TSearchSchema extends Record<string, any> = {},
|
|
249
|
+
TFullSearchSchema extends Record<string, any> = TSearchSchema,
|
|
252
250
|
TParams extends AnyPathParams = {},
|
|
253
251
|
TAllParams = ParamsFallback<TPath, TParams>,
|
|
254
|
-
TParentContext extends AnyContext = AnyContext,
|
|
255
|
-
TAllParentContext extends AnyContext = AnyContext,
|
|
256
252
|
TRouteContext extends RouteContext = RouteContext,
|
|
257
|
-
TAllContext extends
|
|
253
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
258
254
|
> = RoutePathOptions<TCustomId, TPath> & {
|
|
259
255
|
getParentRoute: () => TParentRoute
|
|
260
256
|
validateSearch?: SearchSchemaValidator<TSearchSchema>
|
|
261
|
-
|
|
262
|
-
TLoader,
|
|
263
|
-
TSearchSchema,
|
|
264
|
-
TFullSearchSchema,
|
|
265
|
-
TAllParams,
|
|
266
|
-
NoInfer<TRouteContext>,
|
|
267
|
-
TAllContext
|
|
268
|
-
>
|
|
257
|
+
loaderContext?: (opts: { search: TFullSearchSchema }) => TLoaderContext
|
|
269
258
|
} & (keyof PickRequired<RouteContext> extends never
|
|
270
259
|
? // This async function is called before a route is loaded.
|
|
271
260
|
// If an error is thrown here, the route's loader will not be called.
|
|
@@ -275,10 +264,7 @@ export type BaseRouteOptions<
|
|
|
275
264
|
beforeLoad?: BeforeLoadFn<
|
|
276
265
|
TParentRoute,
|
|
277
266
|
TAllParams,
|
|
278
|
-
|
|
279
|
-
TFullSearchSchema,
|
|
280
|
-
TParentContext,
|
|
281
|
-
TAllParentContext,
|
|
267
|
+
NoInfer<TLoaderContext>,
|
|
282
268
|
TRouteContext
|
|
283
269
|
>
|
|
284
270
|
}
|
|
@@ -286,14 +272,18 @@ export type BaseRouteOptions<
|
|
|
286
272
|
beforeLoad: BeforeLoadFn<
|
|
287
273
|
TParentRoute,
|
|
288
274
|
TAllParams,
|
|
289
|
-
|
|
290
|
-
TFullSearchSchema,
|
|
291
|
-
TParentContext,
|
|
292
|
-
TAllParentContext,
|
|
275
|
+
NoInfer<TLoaderContext>,
|
|
293
276
|
TRouteContext
|
|
294
277
|
>
|
|
295
|
-
}) &
|
|
296
|
-
|
|
278
|
+
}) & {
|
|
279
|
+
loader?: LoaderFn<
|
|
280
|
+
TLoader,
|
|
281
|
+
TAllParams,
|
|
282
|
+
NoInfer<TLoaderContext>,
|
|
283
|
+
NoInfer<TAllContext>,
|
|
284
|
+
NoInfer<TRouteContext>
|
|
285
|
+
>
|
|
286
|
+
} & ([TLoader] extends [never]
|
|
297
287
|
? {
|
|
298
288
|
loader: 'Loaders must return a type other than never. If you are throwing a redirect() and not returning anything, return a redirect() instead.'
|
|
299
289
|
}
|
|
@@ -317,40 +307,25 @@ export type BaseRouteOptions<
|
|
|
317
307
|
)
|
|
318
308
|
|
|
319
309
|
type BeforeLoadFn<
|
|
320
|
-
TParentRoute,
|
|
310
|
+
TParentRoute extends AnyRoute,
|
|
321
311
|
TAllParams,
|
|
322
|
-
|
|
323
|
-
TFullSearchSchema,
|
|
324
|
-
TParentContext,
|
|
325
|
-
TAllParentContext,
|
|
312
|
+
TLoaderContext,
|
|
326
313
|
TRouteContext,
|
|
327
|
-
> = (
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
preload: boolean
|
|
334
|
-
} & (TParentRoute extends undefined
|
|
335
|
-
? {
|
|
336
|
-
context?: TAllParentContext
|
|
337
|
-
parentContext?: TParentContext
|
|
338
|
-
}
|
|
339
|
-
: {
|
|
340
|
-
context: TAllParentContext
|
|
341
|
-
parentContext: TParentContext
|
|
342
|
-
}),
|
|
343
|
-
) => Promise<TRouteContext> | TRouteContext | void
|
|
314
|
+
> = (opts: {
|
|
315
|
+
abortController: AbortController
|
|
316
|
+
preload: boolean
|
|
317
|
+
params: TAllParams
|
|
318
|
+
context: Expand<TParentRoute['types']['context'] & TLoaderContext>
|
|
319
|
+
}) => Promise<TRouteContext> | TRouteContext | void
|
|
344
320
|
|
|
345
321
|
export type UpdatableRouteOptions<
|
|
346
322
|
TLoader,
|
|
347
|
-
TSearchSchema extends
|
|
348
|
-
TFullSearchSchema extends
|
|
323
|
+
TSearchSchema extends Record<string, any>,
|
|
324
|
+
TFullSearchSchema extends Record<string, any>,
|
|
349
325
|
TAllParams extends AnyPathParams,
|
|
350
|
-
TRouteContext extends
|
|
351
|
-
TAllContext extends
|
|
326
|
+
TRouteContext extends Record<string, any>,
|
|
327
|
+
TAllContext extends Record<string, any>,
|
|
352
328
|
> = MetaOptions & {
|
|
353
|
-
key?: null | false | GetKeyFn<TFullSearchSchema, TAllParams>
|
|
354
329
|
// If true, this route will be matched as case-sensitive
|
|
355
330
|
caseSensitive?: boolean
|
|
356
331
|
// If true, this route will be forcefully wrapped in a suspense boundary
|
|
@@ -439,48 +414,33 @@ export type ParentParams<TParentParams> = AnyPathParams extends TParentParams
|
|
|
439
414
|
|
|
440
415
|
export type LoaderFn<
|
|
441
416
|
TLoader = unknown,
|
|
442
|
-
TSearchSchema extends AnySearchSchema = {},
|
|
443
|
-
TFullSearchSchema extends AnySearchSchema = {},
|
|
444
417
|
TAllParams = {},
|
|
445
|
-
|
|
446
|
-
TAllContext extends
|
|
418
|
+
TLoaderContext extends Record<string, any> = AnyContext,
|
|
419
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
420
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
447
421
|
> = (
|
|
448
422
|
match: LoaderContext<
|
|
449
|
-
TSearchSchema,
|
|
450
|
-
TFullSearchSchema,
|
|
451
423
|
TAllParams,
|
|
452
|
-
|
|
453
|
-
TAllContext
|
|
424
|
+
TLoaderContext,
|
|
425
|
+
TAllContext,
|
|
426
|
+
TRouteContext
|
|
454
427
|
> & {
|
|
455
428
|
parentMatchPromise?: Promise<void>
|
|
456
429
|
},
|
|
457
430
|
) => Promise<TLoader> | TLoader
|
|
458
431
|
|
|
459
|
-
export type GetKeyFn<
|
|
460
|
-
TFullSearchSchema extends AnySearchSchema = {},
|
|
461
|
-
TAllParams = {},
|
|
462
|
-
> = (loaderContext: { params: TAllParams; search: TFullSearchSchema }) => any
|
|
463
|
-
|
|
464
432
|
export interface LoaderContext<
|
|
465
|
-
TSearchSchema extends AnySearchSchema = {},
|
|
466
|
-
TFullSearchSchema extends AnySearchSchema = {},
|
|
467
433
|
TAllParams = {},
|
|
468
|
-
|
|
469
|
-
TAllContext extends
|
|
434
|
+
TLoaderContext = {},
|
|
435
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
436
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
470
437
|
> {
|
|
471
|
-
params: TAllParams
|
|
472
|
-
routeSearch: TSearchSchema
|
|
473
|
-
search: TFullSearchSchema
|
|
474
438
|
abortController: AbortController
|
|
475
439
|
preload: boolean
|
|
476
|
-
|
|
477
|
-
context: TAllContext
|
|
440
|
+
params: TAllParams
|
|
441
|
+
context: DeepMergeAll<[TAllContext, TLoaderContext, TRouteContext]>
|
|
478
442
|
}
|
|
479
443
|
|
|
480
|
-
export type UnloaderFn<TPath extends string> = (
|
|
481
|
-
routeMatch: RouteMatch<any, Route>,
|
|
482
|
-
) => void
|
|
483
|
-
|
|
484
444
|
export type SearchFilter<T, U = T> = (prev: T) => U
|
|
485
445
|
|
|
486
446
|
export type ResolveId<
|
|
@@ -492,22 +452,16 @@ export type ResolveId<
|
|
|
492
452
|
: RootRouteId
|
|
493
453
|
|
|
494
454
|
export type InferFullSearchSchema<TRoute> = TRoute extends {
|
|
495
|
-
isRoot: true
|
|
496
455
|
types: {
|
|
497
|
-
|
|
456
|
+
fullSearchSchema: infer TFullSearchSchema
|
|
498
457
|
}
|
|
499
458
|
}
|
|
500
|
-
? TSearchSchema
|
|
501
|
-
: TRoute extends {
|
|
502
|
-
types: {
|
|
503
|
-
fullSearchSchema: infer TFullSearchSchema
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
459
|
? TFullSearchSchema
|
|
507
460
|
: {}
|
|
508
461
|
|
|
509
|
-
export type ResolveFullSearchSchema<TParentRoute, TSearchSchema> =
|
|
510
|
-
InferFullSearchSchema<TParentRoute
|
|
462
|
+
export type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = Expand<
|
|
463
|
+
DeepMerge<InferFullSearchSchema<TParentRoute>, TSearchSchema>
|
|
464
|
+
>
|
|
511
465
|
|
|
512
466
|
export interface AnyRoute
|
|
513
467
|
extends Route<
|
|
@@ -526,7 +480,6 @@ export interface AnyRoute
|
|
|
526
480
|
any,
|
|
527
481
|
any,
|
|
528
482
|
any,
|
|
529
|
-
any,
|
|
530
483
|
any
|
|
531
484
|
> {}
|
|
532
485
|
|
|
@@ -565,12 +518,12 @@ export type RouteConstraints = {
|
|
|
565
518
|
TFullPath: string
|
|
566
519
|
TCustomId: string
|
|
567
520
|
TId: string
|
|
521
|
+
TLoaderContext: Record<string, any>
|
|
568
522
|
TSearchSchema: AnySearchSchema
|
|
569
523
|
TFullSearchSchema: AnySearchSchema
|
|
570
524
|
TParams: Record<string, any>
|
|
571
525
|
TAllParams: Record<string, any>
|
|
572
526
|
TParentContext: AnyContext
|
|
573
|
-
TAllParentContext: AnyContext
|
|
574
527
|
TRouteContext: RouteContext
|
|
575
528
|
TAllContext: AnyContext
|
|
576
529
|
TRouterContext: AnyContext
|
|
@@ -591,6 +544,7 @@ export class Route<
|
|
|
591
544
|
TCustomId,
|
|
592
545
|
TPath
|
|
593
546
|
>,
|
|
547
|
+
TLoaderContext extends RouteConstraints['TLoaderContext'] = {},
|
|
594
548
|
TLoader = unknown,
|
|
595
549
|
TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
|
|
596
550
|
TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
|
|
@@ -604,12 +558,15 @@ export class Route<
|
|
|
604
558
|
TParentRoute,
|
|
605
559
|
TParams
|
|
606
560
|
>,
|
|
607
|
-
TParentContext extends RouteConstraints['TParentContext'] = TParentRoute['types']['routeContext'],
|
|
608
|
-
TAllParentContext extends RouteConstraints['TAllParentContext'] = TParentRoute['types']['context'],
|
|
609
561
|
TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,
|
|
610
|
-
TAllContext extends RouteConstraints['TAllContext'] =
|
|
611
|
-
|
|
612
|
-
|
|
562
|
+
TAllContext extends RouteConstraints['TAllContext'] = Expand<
|
|
563
|
+
DeepMergeAll<
|
|
564
|
+
[
|
|
565
|
+
IsAny<TParentRoute['types']['context'], {}>,
|
|
566
|
+
TLoaderContext,
|
|
567
|
+
TRouteContext,
|
|
568
|
+
]
|
|
569
|
+
>
|
|
613
570
|
>,
|
|
614
571
|
TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
|
|
615
572
|
TChildren extends RouteConstraints['TChildren'] = unknown,
|
|
@@ -627,8 +584,6 @@ export class Route<
|
|
|
627
584
|
fullSearchSchema: TFullSearchSchema
|
|
628
585
|
params: TParams
|
|
629
586
|
allParams: TAllParams
|
|
630
|
-
parentContext: TParentContext
|
|
631
|
-
allParentContext: TAllParentContext
|
|
632
587
|
routeContext: TRouteContext
|
|
633
588
|
context: TAllContext
|
|
634
589
|
children: TChildren
|
|
@@ -640,14 +595,12 @@ export class Route<
|
|
|
640
595
|
TParentRoute,
|
|
641
596
|
TCustomId,
|
|
642
597
|
TPath,
|
|
598
|
+
TLoaderContext,
|
|
643
599
|
TLoader,
|
|
644
|
-
InferFullSearchSchema<TParentRoute>,
|
|
645
600
|
TSearchSchema,
|
|
646
601
|
TFullSearchSchema,
|
|
647
602
|
TParams,
|
|
648
603
|
TAllParams,
|
|
649
|
-
TParentContext,
|
|
650
|
-
TAllParentContext,
|
|
651
604
|
TRouteContext,
|
|
652
605
|
TAllContext
|
|
653
606
|
>
|
|
@@ -671,14 +624,12 @@ export class Route<
|
|
|
671
624
|
TParentRoute,
|
|
672
625
|
TCustomId,
|
|
673
626
|
TPath,
|
|
627
|
+
TLoaderContext,
|
|
674
628
|
TLoader,
|
|
675
|
-
InferFullSearchSchema<TParentRoute>,
|
|
676
629
|
TSearchSchema,
|
|
677
630
|
TFullSearchSchema,
|
|
678
631
|
TParams,
|
|
679
632
|
TAllParams,
|
|
680
|
-
TParentContext,
|
|
681
|
-
TAllParentContext,
|
|
682
633
|
TRouteContext,
|
|
683
634
|
TAllContext
|
|
684
635
|
> &
|
|
@@ -704,9 +655,14 @@ export class Route<
|
|
|
704
655
|
TParentRoute,
|
|
705
656
|
TCustomId,
|
|
706
657
|
TPath,
|
|
707
|
-
|
|
658
|
+
TLoaderContext,
|
|
659
|
+
TLoader,
|
|
708
660
|
TSearchSchema,
|
|
709
|
-
|
|
661
|
+
TFullSearchSchema,
|
|
662
|
+
TParams,
|
|
663
|
+
TAllParams,
|
|
664
|
+
TRouteContext,
|
|
665
|
+
TAllContext
|
|
710
666
|
> &
|
|
711
667
|
RoutePathOptionsIntersection<TCustomId, TPath>
|
|
712
668
|
|
|
@@ -768,13 +724,12 @@ export class Route<
|
|
|
768
724
|
TFullPath,
|
|
769
725
|
TCustomId,
|
|
770
726
|
TId,
|
|
727
|
+
TLoaderContext,
|
|
771
728
|
TLoader,
|
|
772
729
|
TSearchSchema,
|
|
773
730
|
TFullSearchSchema,
|
|
774
731
|
TParams,
|
|
775
732
|
TAllParams,
|
|
776
|
-
TParentContext,
|
|
777
|
-
TAllParentContext,
|
|
778
733
|
TRouteContext,
|
|
779
734
|
TAllContext,
|
|
780
735
|
TRouterContext,
|
|
@@ -811,25 +766,24 @@ export class RouterContext<TRouterContext extends {}> {
|
|
|
811
766
|
constructor() {}
|
|
812
767
|
|
|
813
768
|
createRootRoute = <
|
|
769
|
+
TLoaderContext extends Record<string, any> = AnyContext,
|
|
814
770
|
TLoader = unknown,
|
|
815
|
-
TSearchSchema extends
|
|
771
|
+
TSearchSchema extends Record<string, any> = {},
|
|
816
772
|
TRouteContext extends RouteContext = RouteContext,
|
|
817
773
|
>(
|
|
818
774
|
options?: Omit<
|
|
819
775
|
RouteOptions<
|
|
820
|
-
AnyRoute,
|
|
821
|
-
RootRouteId,
|
|
822
|
-
'',
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
TSearchSchema,
|
|
826
|
-
TSearchSchema,
|
|
827
|
-
{},
|
|
828
|
-
{},
|
|
829
|
-
|
|
830
|
-
TRouterContext,
|
|
831
|
-
TRouteContext,
|
|
832
|
-
MergeFromFromParent<TRouterContext, TRouteContext>
|
|
776
|
+
AnyRoute, // TParentRoute
|
|
777
|
+
RootRouteId, // TCustomId
|
|
778
|
+
'', // TPath
|
|
779
|
+
TLoaderContext, // TLoaderContext
|
|
780
|
+
TLoader, // TLoader
|
|
781
|
+
TSearchSchema, // TSearchSchema
|
|
782
|
+
TSearchSchema, // TFullSearchSchema
|
|
783
|
+
{}, // TParams
|
|
784
|
+
{}, // TAllParams
|
|
785
|
+
TRouteContext, // TRouteContext
|
|
786
|
+
DeepMergeAll<[TRouterContext, TLoaderContext, TRouteContext]> // TAllContext
|
|
833
787
|
>,
|
|
834
788
|
| 'path'
|
|
835
789
|
| 'id'
|
|
@@ -838,51 +792,55 @@ export class RouterContext<TRouterContext extends {}> {
|
|
|
838
792
|
| 'parseParams'
|
|
839
793
|
| 'stringifyParams'
|
|
840
794
|
>,
|
|
841
|
-
): RootRoute<
|
|
795
|
+
): RootRoute<
|
|
796
|
+
TLoaderContext,
|
|
797
|
+
TLoader,
|
|
798
|
+
TSearchSchema,
|
|
799
|
+
TRouteContext,
|
|
800
|
+
TRouterContext
|
|
801
|
+
> => {
|
|
842
802
|
return new RootRoute(options) as any
|
|
843
803
|
}
|
|
844
804
|
}
|
|
845
805
|
|
|
846
806
|
export class RootRoute<
|
|
807
|
+
TLoaderContext extends Record<string, any> = AnyContext,
|
|
847
808
|
TLoader = unknown,
|
|
848
|
-
TSearchSchema extends
|
|
809
|
+
TSearchSchema extends Record<string, any> = {},
|
|
849
810
|
TRouteContext extends RouteContext = RouteContext,
|
|
850
811
|
TRouterContext extends {} = {},
|
|
851
812
|
> extends Route<
|
|
852
|
-
any,
|
|
853
|
-
'/',
|
|
854
|
-
'/',
|
|
855
|
-
string,
|
|
856
|
-
RootRouteId,
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
TSearchSchema,
|
|
860
|
-
|
|
861
|
-
{},
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
TRouteContext
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
any
|
|
868
|
-
any
|
|
813
|
+
any, // TParentRoute
|
|
814
|
+
'/', // TPath
|
|
815
|
+
'/', // TFullPath
|
|
816
|
+
string, // TCustomId
|
|
817
|
+
RootRouteId, // TId
|
|
818
|
+
TLoaderContext, // TLoaderContext
|
|
819
|
+
TLoader, // TLoader
|
|
820
|
+
TSearchSchema, // TSearchSchema
|
|
821
|
+
TSearchSchema, // TFullSearchSchema
|
|
822
|
+
{}, // TParams
|
|
823
|
+
{}, // TAllParams
|
|
824
|
+
TRouteContext, // TRouteContext
|
|
825
|
+
DeepMergeAll<[TRouterContext, TLoaderContext, TRouteContext]>, // TAllContext
|
|
826
|
+
TRouterContext, // TRouterContext
|
|
827
|
+
any, // TChildren
|
|
828
|
+
any // TRouteTree
|
|
869
829
|
> {
|
|
870
830
|
constructor(
|
|
871
831
|
options?: Omit<
|
|
872
832
|
RouteOptions<
|
|
873
|
-
AnyRoute,
|
|
874
|
-
RootRouteId,
|
|
875
|
-
'',
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
TSearchSchema,
|
|
879
|
-
TSearchSchema,
|
|
880
|
-
{},
|
|
881
|
-
{},
|
|
882
|
-
|
|
883
|
-
TRouterContext,
|
|
884
|
-
TRouteContext,
|
|
885
|
-
MergeFromFromParent<TRouterContext, TRouteContext>
|
|
833
|
+
AnyRoute, // TParentRoute
|
|
834
|
+
RootRouteId, // TCustomId
|
|
835
|
+
'', // TPath
|
|
836
|
+
TLoaderContext, // TLoaderContext
|
|
837
|
+
TLoader, // TLoader
|
|
838
|
+
TSearchSchema, // TSearchSchema
|
|
839
|
+
TSearchSchema, // TFullSearchSchema
|
|
840
|
+
{}, // TParams
|
|
841
|
+
{}, // TAllParams
|
|
842
|
+
TRouteContext, // TRouteContext
|
|
843
|
+
DeepMergeAll<[TRouterContext, TLoaderContext, TRouteContext]> // TAllContext
|
|
886
844
|
>,
|
|
887
845
|
| 'path'
|
|
888
846
|
| 'id'
|
package/src/routeInfo.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyRoute, Route } from './route'
|
|
2
|
-
import { UnionToIntersection } from './utils'
|
|
2
|
+
import { Expand, UnionToIntersection } from './utils'
|
|
3
3
|
|
|
4
4
|
export type ParseRoute<TRouteTree extends AnyRoute> =
|
|
5
5
|
| TRouteTree
|
|
@@ -21,7 +21,6 @@ export type ParseRouteChildren<TRouteTree extends AnyRoute> =
|
|
|
21
21
|
any,
|
|
22
22
|
any,
|
|
23
23
|
any,
|
|
24
|
-
any,
|
|
25
24
|
infer TChildren,
|
|
26
25
|
any
|
|
27
26
|
>
|
|
@@ -60,10 +59,14 @@ export type RoutePaths<TRouteTree extends AnyRoute> =
|
|
|
60
59
|
| ParseRoute<TRouteTree>['fullPath']
|
|
61
60
|
| '/'
|
|
62
61
|
|
|
63
|
-
export type FullSearchSchema<TRouteTree extends AnyRoute> =
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
export type FullSearchSchema<TRouteTree extends AnyRoute> = Partial<
|
|
63
|
+
Expand<
|
|
64
|
+
UnionToIntersection<
|
|
65
|
+
ParseRoute<TRouteTree>['types']['fullSearchSchema']
|
|
66
|
+
> & {}
|
|
67
|
+
>
|
|
68
|
+
>
|
|
66
69
|
|
|
67
|
-
export type AllParams<TRouteTree extends AnyRoute> =
|
|
68
|
-
ParseRoute<TRouteTree>['types']['allParams']
|
|
70
|
+
export type AllParams<TRouteTree extends AnyRoute> = Expand<
|
|
71
|
+
UnionToIntersection<ParseRoute<TRouteTree>['types']['allParams']>
|
|
69
72
|
>
|