@tanstack/router-core 1.111.3 → 1.111.7
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 +51 -1
- package/dist/cjs/index.d.cts +11 -4
- package/dist/cjs/path.cjs +1 -1
- package/dist/cjs/path.cjs.map +1 -1
- package/dist/cjs/redirect.d.cts +18 -0
- package/dist/cjs/route.d.cts +117 -4
- package/dist/cjs/typePrimitives.d.cts +0 -0
- package/dist/cjs/useLoaderData.d.cts +5 -0
- package/dist/cjs/useLoaderDeps.d.cts +5 -0
- package/dist/cjs/useNavigate.d.cts +3 -0
- package/dist/cjs/useParams.d.cts +5 -0
- package/dist/cjs/useRouteContext.d.cts +9 -0
- package/dist/cjs/useSearch.d.cts +5 -0
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +9 -0
- package/dist/esm/Matches.d.ts +51 -1
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/index.d.ts +11 -4
- package/dist/esm/path.js +1 -1
- package/dist/esm/path.js.map +1 -1
- package/dist/esm/redirect.d.ts +18 -0
- package/dist/esm/route.d.ts +117 -4
- package/dist/esm/typePrimitives.d.ts +0 -0
- package/dist/esm/useLoaderData.d.ts +5 -0
- package/dist/esm/useLoaderDeps.d.ts +5 -0
- package/dist/esm/useNavigate.d.ts +3 -0
- package/dist/esm/useParams.d.ts +5 -0
- package/dist/esm/useRouteContext.d.ts +9 -0
- package/dist/esm/useSearch.d.ts +5 -0
- package/dist/esm/utils.d.ts +9 -0
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/Matches.ts +114 -1
- package/src/index.ts +39 -0
- package/src/path.ts +6 -1
- package/src/redirect.ts +36 -0
- package/src/route.ts +530 -3
- package/src/typePrimitives.ts +0 -0
- package/src/useLoaderData.ts +20 -0
- package/src/useLoaderDeps.ts +13 -0
- package/src/useNavigate.ts +13 -0
- package/src/useParams.ts +20 -0
- package/src/useRouteContext.ts +39 -0
- package/src/useSearch.ts +20 -0
- package/src/utils.ts +17 -0
package/src/index.ts
CHANGED
|
@@ -85,6 +85,12 @@ export type {
|
|
|
85
85
|
IsMatchResult,
|
|
86
86
|
IsMatchParse,
|
|
87
87
|
IsMatch,
|
|
88
|
+
RouteMatch,
|
|
89
|
+
RouteMatchExtensions,
|
|
90
|
+
MakeRouteMatchUnion,
|
|
91
|
+
MakeRouteMatch,
|
|
92
|
+
AnyRouteMatch,
|
|
93
|
+
MakeRouteMatchFromRoute,
|
|
88
94
|
} from './Matches'
|
|
89
95
|
export {
|
|
90
96
|
joinPaths,
|
|
@@ -167,6 +173,19 @@ export type {
|
|
|
167
173
|
MakeRemountDepsOptionsUnion,
|
|
168
174
|
ResolveFullPath,
|
|
169
175
|
AnyRouteWithContext,
|
|
176
|
+
RouteOptions,
|
|
177
|
+
FileBaseRouteOptions,
|
|
178
|
+
BaseRouteOptions,
|
|
179
|
+
UpdatableRouteOptions,
|
|
180
|
+
RouteLoaderFn,
|
|
181
|
+
LoaderFnContext,
|
|
182
|
+
RouteContextFn,
|
|
183
|
+
RouteContextOptions,
|
|
184
|
+
BeforeLoadFn,
|
|
185
|
+
BeforeLoadContextOptions,
|
|
186
|
+
ContextOptions,
|
|
187
|
+
RootRouteOptions,
|
|
188
|
+
UpdatableRouteOptionsExtensions,
|
|
170
189
|
} from './route'
|
|
171
190
|
|
|
172
191
|
export { defaultSerializeError, getLocationChangeInfo } from './router'
|
|
@@ -181,6 +200,7 @@ export type {
|
|
|
181
200
|
Register,
|
|
182
201
|
AnyRouter,
|
|
183
202
|
AnyRouterWithContext,
|
|
203
|
+
RegisteredRouter,
|
|
184
204
|
} from './router'
|
|
185
205
|
|
|
186
206
|
export type {
|
|
@@ -245,6 +265,7 @@ export type {
|
|
|
245
265
|
MergeAllObjects,
|
|
246
266
|
MergeAll,
|
|
247
267
|
ValidateJSON,
|
|
268
|
+
StrictOrFrom,
|
|
248
269
|
} from './utils'
|
|
249
270
|
|
|
250
271
|
export type {
|
|
@@ -274,3 +295,21 @@ export type {
|
|
|
274
295
|
ResolveValidatorOutputFn,
|
|
275
296
|
ResolveValidatorOutput,
|
|
276
297
|
} from './validators'
|
|
298
|
+
|
|
299
|
+
export type {
|
|
300
|
+
UseRouteContextBaseOptions,
|
|
301
|
+
UseRouteContextOptions,
|
|
302
|
+
UseRouteContextResult,
|
|
303
|
+
} from './useRouteContext'
|
|
304
|
+
|
|
305
|
+
export type { UseSearchResult, ResolveUseSearch } from './useSearch'
|
|
306
|
+
|
|
307
|
+
export type { UseParamsResult, ResolveUseParams } from './useParams'
|
|
308
|
+
|
|
309
|
+
export type { UseNavigateResult } from './useNavigate'
|
|
310
|
+
|
|
311
|
+
export type { UseLoaderDepsResult, ResolveUseLoaderDeps } from './useLoaderDeps'
|
|
312
|
+
|
|
313
|
+
export type { UseLoaderDataResult, ResolveUseLoaderData } from './useLoaderData'
|
|
314
|
+
|
|
315
|
+
export type { Redirect, ResolvedRedirect, AnyRedirect } from './redirect'
|
package/src/path.ts
CHANGED
|
@@ -183,7 +183,12 @@ export function parsePathname(pathname?: string): Array<Segment> {
|
|
|
183
183
|
|
|
184
184
|
return {
|
|
185
185
|
type: 'pathname',
|
|
186
|
-
value:
|
|
186
|
+
value: part.includes('%25')
|
|
187
|
+
? part
|
|
188
|
+
.split('%25')
|
|
189
|
+
.map((segment) => decodeURI(segment))
|
|
190
|
+
.join('%25')
|
|
191
|
+
: decodeURI(part),
|
|
187
192
|
}
|
|
188
193
|
}),
|
|
189
194
|
)
|
package/src/redirect.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { NavigateOptions } from './link'
|
|
2
|
+
import type { RoutePaths } from './routeInfo'
|
|
3
|
+
import type { AnyRouter, RegisteredRouter } from './router'
|
|
4
|
+
import type { PickAsRequired } from './utils'
|
|
5
|
+
|
|
6
|
+
export type AnyRedirect = Redirect<any, any, any, any, any>
|
|
7
|
+
|
|
8
|
+
export type Redirect<
|
|
9
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
10
|
+
TFrom extends RoutePaths<TRouter['routeTree']> | string = '/',
|
|
11
|
+
TTo extends string | undefined = '.',
|
|
12
|
+
TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,
|
|
13
|
+
TMaskTo extends string = '.',
|
|
14
|
+
> = {
|
|
15
|
+
href?: string
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `statusCode` instead
|
|
18
|
+
**/
|
|
19
|
+
code?: number
|
|
20
|
+
statusCode?: number
|
|
21
|
+
throw?: any
|
|
22
|
+
headers?: HeadersInit
|
|
23
|
+
} & NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>
|
|
24
|
+
|
|
25
|
+
export type ResolvedRedirect<
|
|
26
|
+
TRouter extends AnyRouter = RegisteredRouter,
|
|
27
|
+
TFrom extends RoutePaths<TRouter['routeTree']> = '/',
|
|
28
|
+
TTo extends string = '',
|
|
29
|
+
TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,
|
|
30
|
+
TMaskTo extends string = '',
|
|
31
|
+
> = PickAsRequired<
|
|
32
|
+
Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,
|
|
33
|
+
'code' | 'statusCode' | 'headers'
|
|
34
|
+
> & {
|
|
35
|
+
href: string
|
|
36
|
+
}
|
package/src/route.ts
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
|
-
import type { ParsePathParams } from './link'
|
|
1
|
+
import type { NavigateOptions, ParsePathParams } from './link'
|
|
2
|
+
import type { ParsedLocation } from './location'
|
|
3
|
+
import type {
|
|
4
|
+
AnyRouteMatch,
|
|
5
|
+
MakeRouteMatchFromRoute,
|
|
6
|
+
MakeRouteMatchUnion,
|
|
7
|
+
RouteMatch,
|
|
8
|
+
} from './Matches'
|
|
2
9
|
import type { RootRouteId } from './root'
|
|
3
10
|
import type { ParseRoute } from './routeInfo'
|
|
4
|
-
import type { RegisteredRouter } from './router'
|
|
5
|
-
import type {
|
|
11
|
+
import type { AnyRouter, RegisteredRouter } from './router'
|
|
12
|
+
import type { BuildLocationFn, NavigateFn } from './RouterProvider'
|
|
13
|
+
import type {
|
|
14
|
+
Assign,
|
|
15
|
+
Constrain,
|
|
16
|
+
Expand,
|
|
17
|
+
IntersectAssign,
|
|
18
|
+
NoInfer,
|
|
19
|
+
} from './utils'
|
|
6
20
|
import type {
|
|
7
21
|
AnySchema,
|
|
8
22
|
AnyStandardSchemaValidator,
|
|
23
|
+
AnyValidator,
|
|
9
24
|
AnyValidatorAdapter,
|
|
10
25
|
AnyValidatorObj,
|
|
26
|
+
DefaultValidator,
|
|
11
27
|
ResolveSearchValidatorInput,
|
|
12
28
|
ResolveValidatorOutput,
|
|
13
29
|
StandardSchemaValidator,
|
|
@@ -503,6 +519,517 @@ export type AnyRouteWithContext<TContext> = AnyRoute & {
|
|
|
503
519
|
types: { allContext: TContext }
|
|
504
520
|
}
|
|
505
521
|
|
|
522
|
+
export type RouteOptions<
|
|
523
|
+
TParentRoute extends AnyRoute = AnyRoute,
|
|
524
|
+
TId extends string = string,
|
|
525
|
+
TCustomId extends string = string,
|
|
526
|
+
TFullPath extends string = string,
|
|
527
|
+
TPath extends string = string,
|
|
528
|
+
TSearchValidator = undefined,
|
|
529
|
+
TParams = AnyPathParams,
|
|
530
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
531
|
+
TLoaderFn = undefined,
|
|
532
|
+
TRouterContext = {},
|
|
533
|
+
TRouteContextFn = AnyContext,
|
|
534
|
+
TBeforeLoadFn = AnyContext,
|
|
535
|
+
> = BaseRouteOptions<
|
|
536
|
+
TParentRoute,
|
|
537
|
+
TId,
|
|
538
|
+
TCustomId,
|
|
539
|
+
TPath,
|
|
540
|
+
TSearchValidator,
|
|
541
|
+
TParams,
|
|
542
|
+
TLoaderDeps,
|
|
543
|
+
TLoaderFn,
|
|
544
|
+
TRouterContext,
|
|
545
|
+
TRouteContextFn,
|
|
546
|
+
TBeforeLoadFn
|
|
547
|
+
> &
|
|
548
|
+
UpdatableRouteOptions<
|
|
549
|
+
NoInfer<TParentRoute>,
|
|
550
|
+
NoInfer<TCustomId>,
|
|
551
|
+
NoInfer<TFullPath>,
|
|
552
|
+
NoInfer<TParams>,
|
|
553
|
+
NoInfer<TSearchValidator>,
|
|
554
|
+
NoInfer<TLoaderFn>,
|
|
555
|
+
NoInfer<TLoaderDeps>,
|
|
556
|
+
NoInfer<TRouterContext>,
|
|
557
|
+
NoInfer<TRouteContextFn>,
|
|
558
|
+
NoInfer<TBeforeLoadFn>
|
|
559
|
+
>
|
|
560
|
+
|
|
561
|
+
export type RouteContextFn<
|
|
562
|
+
in out TParentRoute extends AnyRoute,
|
|
563
|
+
in out TSearchValidator,
|
|
564
|
+
in out TParams,
|
|
565
|
+
in out TRouterContext,
|
|
566
|
+
> = (
|
|
567
|
+
ctx: RouteContextOptions<
|
|
568
|
+
TParentRoute,
|
|
569
|
+
TSearchValidator,
|
|
570
|
+
TParams,
|
|
571
|
+
TRouterContext
|
|
572
|
+
>,
|
|
573
|
+
) => any
|
|
574
|
+
|
|
575
|
+
export type BeforeLoadFn<
|
|
576
|
+
in out TParentRoute extends AnyRoute,
|
|
577
|
+
in out TSearchValidator,
|
|
578
|
+
in out TParams,
|
|
579
|
+
in out TRouterContext,
|
|
580
|
+
in out TRouteContextFn,
|
|
581
|
+
> = (
|
|
582
|
+
ctx: BeforeLoadContextOptions<
|
|
583
|
+
TParentRoute,
|
|
584
|
+
TSearchValidator,
|
|
585
|
+
TParams,
|
|
586
|
+
TRouterContext,
|
|
587
|
+
TRouteContextFn
|
|
588
|
+
>,
|
|
589
|
+
) => any
|
|
590
|
+
|
|
591
|
+
export type FileBaseRouteOptions<
|
|
592
|
+
TParentRoute extends AnyRoute = AnyRoute,
|
|
593
|
+
TId extends string = string,
|
|
594
|
+
TPath extends string = string,
|
|
595
|
+
TSearchValidator = undefined,
|
|
596
|
+
TParams = {},
|
|
597
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
598
|
+
TLoaderFn = undefined,
|
|
599
|
+
TRouterContext = {},
|
|
600
|
+
TRouteContextFn = AnyContext,
|
|
601
|
+
TBeforeLoadFn = AnyContext,
|
|
602
|
+
TRemountDepsFn = AnyContext,
|
|
603
|
+
> = ParamsOptions<TPath, TParams> & {
|
|
604
|
+
validateSearch?: Constrain<TSearchValidator, AnyValidator, DefaultValidator>
|
|
605
|
+
|
|
606
|
+
shouldReload?:
|
|
607
|
+
| boolean
|
|
608
|
+
| ((
|
|
609
|
+
match: LoaderFnContext<
|
|
610
|
+
TParentRoute,
|
|
611
|
+
TId,
|
|
612
|
+
TParams,
|
|
613
|
+
TLoaderDeps,
|
|
614
|
+
TRouterContext,
|
|
615
|
+
TRouteContextFn,
|
|
616
|
+
TBeforeLoadFn
|
|
617
|
+
>,
|
|
618
|
+
) => any)
|
|
619
|
+
|
|
620
|
+
context?: Constrain<
|
|
621
|
+
TRouteContextFn,
|
|
622
|
+
(
|
|
623
|
+
ctx: RouteContextOptions<
|
|
624
|
+
TParentRoute,
|
|
625
|
+
TParams,
|
|
626
|
+
TRouterContext,
|
|
627
|
+
TLoaderDeps
|
|
628
|
+
>,
|
|
629
|
+
) => any
|
|
630
|
+
>
|
|
631
|
+
|
|
632
|
+
// This async function is called before a route is loaded.
|
|
633
|
+
// If an error is thrown here, the route's loader will not be called.
|
|
634
|
+
// If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.
|
|
635
|
+
// If thrown during a preload event, the error will be logged to the console.
|
|
636
|
+
beforeLoad?: Constrain<
|
|
637
|
+
TBeforeLoadFn,
|
|
638
|
+
(
|
|
639
|
+
ctx: BeforeLoadContextOptions<
|
|
640
|
+
TParentRoute,
|
|
641
|
+
TSearchValidator,
|
|
642
|
+
TParams,
|
|
643
|
+
TRouterContext,
|
|
644
|
+
TRouteContextFn
|
|
645
|
+
>,
|
|
646
|
+
) => any
|
|
647
|
+
>
|
|
648
|
+
|
|
649
|
+
loaderDeps?: (
|
|
650
|
+
opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>,
|
|
651
|
+
) => TLoaderDeps
|
|
652
|
+
|
|
653
|
+
remountDeps?: Constrain<
|
|
654
|
+
TRemountDepsFn,
|
|
655
|
+
(
|
|
656
|
+
opt: RemountDepsOptions<
|
|
657
|
+
TId,
|
|
658
|
+
FullSearchSchemaOption<TParentRoute, TSearchValidator>,
|
|
659
|
+
Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,
|
|
660
|
+
TLoaderDeps
|
|
661
|
+
>,
|
|
662
|
+
) => any
|
|
663
|
+
>
|
|
664
|
+
|
|
665
|
+
loader?: Constrain<
|
|
666
|
+
TLoaderFn,
|
|
667
|
+
(
|
|
668
|
+
ctx: LoaderFnContext<
|
|
669
|
+
TParentRoute,
|
|
670
|
+
TId,
|
|
671
|
+
TParams,
|
|
672
|
+
TLoaderDeps,
|
|
673
|
+
TRouterContext,
|
|
674
|
+
TRouteContextFn,
|
|
675
|
+
TBeforeLoadFn
|
|
676
|
+
>,
|
|
677
|
+
) => any
|
|
678
|
+
>
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
export type BaseRouteOptions<
|
|
682
|
+
TParentRoute extends AnyRoute = AnyRoute,
|
|
683
|
+
TId extends string = string,
|
|
684
|
+
TCustomId extends string = string,
|
|
685
|
+
TPath extends string = string,
|
|
686
|
+
TSearchValidator = undefined,
|
|
687
|
+
TParams = {},
|
|
688
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
689
|
+
TLoaderFn = undefined,
|
|
690
|
+
TRouterContext = {},
|
|
691
|
+
TRouteContextFn = AnyContext,
|
|
692
|
+
TBeforeLoadFn = AnyContext,
|
|
693
|
+
> = RoutePathOptions<TCustomId, TPath> &
|
|
694
|
+
FileBaseRouteOptions<
|
|
695
|
+
TParentRoute,
|
|
696
|
+
TId,
|
|
697
|
+
TPath,
|
|
698
|
+
TSearchValidator,
|
|
699
|
+
TParams,
|
|
700
|
+
TLoaderDeps,
|
|
701
|
+
TLoaderFn,
|
|
702
|
+
TRouterContext,
|
|
703
|
+
TRouteContextFn,
|
|
704
|
+
TBeforeLoadFn
|
|
705
|
+
> & {
|
|
706
|
+
getParentRoute: () => TParentRoute
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
export interface ContextOptions<
|
|
710
|
+
in out TParentRoute extends AnyRoute,
|
|
711
|
+
in out TParams,
|
|
712
|
+
> {
|
|
713
|
+
abortController: AbortController
|
|
714
|
+
preload: boolean
|
|
715
|
+
params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>
|
|
716
|
+
location: ParsedLocation
|
|
717
|
+
/**
|
|
718
|
+
* @deprecated Use `throw redirect({ to: '/somewhere' })` instead
|
|
719
|
+
**/
|
|
720
|
+
navigate: NavigateFn
|
|
721
|
+
buildLocation: BuildLocationFn
|
|
722
|
+
cause: 'preload' | 'enter' | 'stay'
|
|
723
|
+
matches: Array<MakeRouteMatchUnion>
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
export interface RouteContextOptions<
|
|
727
|
+
in out TParentRoute extends AnyRoute,
|
|
728
|
+
in out TParams,
|
|
729
|
+
in out TRouterContext,
|
|
730
|
+
in out TLoaderDeps,
|
|
731
|
+
> extends ContextOptions<TParentRoute, TParams> {
|
|
732
|
+
deps: TLoaderDeps
|
|
733
|
+
context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
export interface BeforeLoadContextOptions<
|
|
737
|
+
in out TParentRoute extends AnyRoute,
|
|
738
|
+
in out TSearchValidator,
|
|
739
|
+
in out TParams,
|
|
740
|
+
in out TRouterContext,
|
|
741
|
+
in out TRouteContextFn,
|
|
742
|
+
> extends ContextOptions<TParentRoute, TParams>,
|
|
743
|
+
FullSearchSchemaOption<TParentRoute, TSearchValidator> {
|
|
744
|
+
context: Expand<
|
|
745
|
+
BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>
|
|
746
|
+
>
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
type AssetFnContextOptions<
|
|
750
|
+
in out TRouteId,
|
|
751
|
+
in out TFullPath,
|
|
752
|
+
in out TParentRoute extends AnyRoute,
|
|
753
|
+
in out TParams,
|
|
754
|
+
in out TSearchValidator,
|
|
755
|
+
in out TLoaderFn,
|
|
756
|
+
in out TRouterContext,
|
|
757
|
+
in out TRouteContextFn,
|
|
758
|
+
in out TBeforeLoadFn,
|
|
759
|
+
in out TLoaderDeps,
|
|
760
|
+
> = {
|
|
761
|
+
matches: Array<
|
|
762
|
+
RouteMatch<
|
|
763
|
+
TRouteId,
|
|
764
|
+
TFullPath,
|
|
765
|
+
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
766
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
767
|
+
ResolveLoaderData<TLoaderFn>,
|
|
768
|
+
ResolveAllContext<
|
|
769
|
+
TParentRoute,
|
|
770
|
+
TRouterContext,
|
|
771
|
+
TRouteContextFn,
|
|
772
|
+
TBeforeLoadFn
|
|
773
|
+
>,
|
|
774
|
+
TLoaderDeps
|
|
775
|
+
>
|
|
776
|
+
>
|
|
777
|
+
match: RouteMatch<
|
|
778
|
+
TRouteId,
|
|
779
|
+
TFullPath,
|
|
780
|
+
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
781
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
782
|
+
ResolveLoaderData<TLoaderFn>,
|
|
783
|
+
ResolveAllContext<
|
|
784
|
+
TParentRoute,
|
|
785
|
+
TRouterContext,
|
|
786
|
+
TRouteContextFn,
|
|
787
|
+
TBeforeLoadFn
|
|
788
|
+
>,
|
|
789
|
+
TLoaderDeps
|
|
790
|
+
>
|
|
791
|
+
params: ResolveAllParamsFromParent<TParentRoute, TParams>
|
|
792
|
+
loaderData: ResolveLoaderData<TLoaderFn>
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
export interface DefaultUpdatableRouteOptionsExtensions {
|
|
796
|
+
component?: unknown
|
|
797
|
+
errorComponent?: unknown
|
|
798
|
+
notFoundComponent?: unknown
|
|
799
|
+
pendingComponent?: unknown
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
export interface UpdatableRouteOptionsExtensions {}
|
|
803
|
+
|
|
804
|
+
export interface UpdatableRouteOptions<
|
|
805
|
+
in out TParentRoute extends AnyRoute,
|
|
806
|
+
in out TRouteId,
|
|
807
|
+
in out TFullPath,
|
|
808
|
+
in out TParams,
|
|
809
|
+
in out TSearchValidator,
|
|
810
|
+
in out TLoaderFn,
|
|
811
|
+
in out TLoaderDeps,
|
|
812
|
+
in out TRouterContext,
|
|
813
|
+
in out TRouteContextFn,
|
|
814
|
+
in out TBeforeLoadFn,
|
|
815
|
+
> extends UpdatableStaticRouteOption,
|
|
816
|
+
UpdatableRouteOptionsExtensions {
|
|
817
|
+
// If true, this route will be matched as case-sensitive
|
|
818
|
+
caseSensitive?: boolean
|
|
819
|
+
// If true, this route will be forcefully wrapped in a suspense boundary
|
|
820
|
+
wrapInSuspense?: boolean
|
|
821
|
+
// The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
|
|
822
|
+
|
|
823
|
+
pendingMs?: number
|
|
824
|
+
pendingMinMs?: number
|
|
825
|
+
staleTime?: number
|
|
826
|
+
gcTime?: number
|
|
827
|
+
preload?: boolean
|
|
828
|
+
preloadStaleTime?: number
|
|
829
|
+
preloadGcTime?: number
|
|
830
|
+
search?: {
|
|
831
|
+
middlewares?: Array<
|
|
832
|
+
SearchMiddleware<
|
|
833
|
+
ResolveFullSearchSchemaInput<TParentRoute, TSearchValidator>
|
|
834
|
+
>
|
|
835
|
+
>
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
@deprecated Use search.middlewares instead
|
|
839
|
+
*/
|
|
840
|
+
preSearchFilters?: Array<
|
|
841
|
+
SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
|
|
842
|
+
>
|
|
843
|
+
/**
|
|
844
|
+
@deprecated Use search.middlewares instead
|
|
845
|
+
*/
|
|
846
|
+
postSearchFilters?: Array<
|
|
847
|
+
SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
|
|
848
|
+
>
|
|
849
|
+
onCatch?: (error: Error) => void
|
|
850
|
+
onError?: (err: any) => void
|
|
851
|
+
// These functions are called as route matches are loaded, stick around and leave the active
|
|
852
|
+
// matches
|
|
853
|
+
onEnter?: (
|
|
854
|
+
match: RouteMatch<
|
|
855
|
+
TRouteId,
|
|
856
|
+
TFullPath,
|
|
857
|
+
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
858
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
859
|
+
ResolveLoaderData<TLoaderFn>,
|
|
860
|
+
ResolveAllContext<
|
|
861
|
+
TParentRoute,
|
|
862
|
+
TRouterContext,
|
|
863
|
+
TRouteContextFn,
|
|
864
|
+
TBeforeLoadFn
|
|
865
|
+
>,
|
|
866
|
+
TLoaderDeps
|
|
867
|
+
>,
|
|
868
|
+
) => void
|
|
869
|
+
onStay?: (
|
|
870
|
+
match: RouteMatch<
|
|
871
|
+
TRouteId,
|
|
872
|
+
TFullPath,
|
|
873
|
+
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
874
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
875
|
+
ResolveLoaderData<TLoaderFn>,
|
|
876
|
+
ResolveAllContext<
|
|
877
|
+
TParentRoute,
|
|
878
|
+
TRouterContext,
|
|
879
|
+
TRouteContextFn,
|
|
880
|
+
TBeforeLoadFn
|
|
881
|
+
>,
|
|
882
|
+
TLoaderDeps
|
|
883
|
+
>,
|
|
884
|
+
) => void
|
|
885
|
+
onLeave?: (
|
|
886
|
+
match: RouteMatch<
|
|
887
|
+
TRouteId,
|
|
888
|
+
TFullPath,
|
|
889
|
+
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
890
|
+
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
891
|
+
ResolveLoaderData<TLoaderFn>,
|
|
892
|
+
ResolveAllContext<
|
|
893
|
+
TParentRoute,
|
|
894
|
+
TRouterContext,
|
|
895
|
+
TRouteContextFn,
|
|
896
|
+
TBeforeLoadFn
|
|
897
|
+
>,
|
|
898
|
+
TLoaderDeps
|
|
899
|
+
>,
|
|
900
|
+
) => void
|
|
901
|
+
headers?: (ctx: {
|
|
902
|
+
loaderData: ResolveLoaderData<TLoaderFn>
|
|
903
|
+
}) => Record<string, string>
|
|
904
|
+
head?: (
|
|
905
|
+
ctx: AssetFnContextOptions<
|
|
906
|
+
TRouteId,
|
|
907
|
+
TFullPath,
|
|
908
|
+
TParentRoute,
|
|
909
|
+
TParams,
|
|
910
|
+
TSearchValidator,
|
|
911
|
+
TLoaderFn,
|
|
912
|
+
TRouterContext,
|
|
913
|
+
TRouteContextFn,
|
|
914
|
+
TBeforeLoadFn,
|
|
915
|
+
TLoaderDeps
|
|
916
|
+
>,
|
|
917
|
+
) => {
|
|
918
|
+
links?: AnyRouteMatch['links']
|
|
919
|
+
scripts?: AnyRouteMatch['headScripts']
|
|
920
|
+
meta?: AnyRouteMatch['meta']
|
|
921
|
+
}
|
|
922
|
+
scripts?: (
|
|
923
|
+
ctx: AssetFnContextOptions<
|
|
924
|
+
TRouteId,
|
|
925
|
+
TFullPath,
|
|
926
|
+
TParentRoute,
|
|
927
|
+
TParams,
|
|
928
|
+
TSearchValidator,
|
|
929
|
+
TLoaderFn,
|
|
930
|
+
TRouterContext,
|
|
931
|
+
TRouteContextFn,
|
|
932
|
+
TBeforeLoadFn,
|
|
933
|
+
TLoaderDeps
|
|
934
|
+
>,
|
|
935
|
+
) => AnyRouteMatch['scripts']
|
|
936
|
+
ssr?: boolean
|
|
937
|
+
codeSplitGroupings?: Array<
|
|
938
|
+
Array<
|
|
939
|
+
| 'loader'
|
|
940
|
+
| 'component'
|
|
941
|
+
| 'pendingComponent'
|
|
942
|
+
| 'notFoundComponent'
|
|
943
|
+
| 'errorComponent'
|
|
944
|
+
>
|
|
945
|
+
>
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
export type RouteLoaderFn<
|
|
949
|
+
in out TParentRoute extends AnyRoute = AnyRoute,
|
|
950
|
+
in out TId extends string = string,
|
|
951
|
+
in out TParams = {},
|
|
952
|
+
in out TLoaderDeps = {},
|
|
953
|
+
in out TRouterContext = {},
|
|
954
|
+
in out TRouteContextFn = AnyContext,
|
|
955
|
+
in out TBeforeLoadFn = AnyContext,
|
|
956
|
+
> = (
|
|
957
|
+
match: LoaderFnContext<
|
|
958
|
+
TParentRoute,
|
|
959
|
+
TId,
|
|
960
|
+
TParams,
|
|
961
|
+
TLoaderDeps,
|
|
962
|
+
TRouterContext,
|
|
963
|
+
TRouteContextFn,
|
|
964
|
+
TBeforeLoadFn
|
|
965
|
+
>,
|
|
966
|
+
) => any
|
|
967
|
+
|
|
968
|
+
export interface LoaderFnContext<
|
|
969
|
+
in out TParentRoute extends AnyRoute = AnyRoute,
|
|
970
|
+
in out TId extends string = string,
|
|
971
|
+
in out TParams = {},
|
|
972
|
+
in out TLoaderDeps = {},
|
|
973
|
+
in out TRouterContext = {},
|
|
974
|
+
in out TRouteContextFn = AnyContext,
|
|
975
|
+
in out TBeforeLoadFn = AnyContext,
|
|
976
|
+
> {
|
|
977
|
+
abortController: AbortController
|
|
978
|
+
preload: boolean
|
|
979
|
+
params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>
|
|
980
|
+
deps: TLoaderDeps
|
|
981
|
+
context: Expand<
|
|
982
|
+
ResolveAllContext<
|
|
983
|
+
TParentRoute,
|
|
984
|
+
TRouterContext,
|
|
985
|
+
TRouteContextFn,
|
|
986
|
+
TBeforeLoadFn
|
|
987
|
+
>
|
|
988
|
+
>
|
|
989
|
+
location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps
|
|
990
|
+
/**
|
|
991
|
+
* @deprecated Use `throw redirect({ to: '/somewhere' })` instead
|
|
992
|
+
**/
|
|
993
|
+
navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void> | void
|
|
994
|
+
// root route does not have a parent match
|
|
995
|
+
parentMatchPromise: TId extends RootRouteId
|
|
996
|
+
? never
|
|
997
|
+
: Promise<MakeRouteMatchFromRoute<TParentRoute>>
|
|
998
|
+
cause: 'preload' | 'enter' | 'stay'
|
|
999
|
+
route: AnyRoute
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
export type RootRouteOptions<
|
|
1003
|
+
TSearchValidator = undefined,
|
|
1004
|
+
TRouterContext = {},
|
|
1005
|
+
TRouteContextFn = AnyContext,
|
|
1006
|
+
TBeforeLoadFn = AnyContext,
|
|
1007
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
1008
|
+
TLoaderFn = undefined,
|
|
1009
|
+
> = Omit<
|
|
1010
|
+
RouteOptions<
|
|
1011
|
+
any, // TParentRoute
|
|
1012
|
+
RootRouteId, // TId
|
|
1013
|
+
RootRouteId, // TCustomId
|
|
1014
|
+
'', // TFullPath
|
|
1015
|
+
'', // TPath
|
|
1016
|
+
TSearchValidator,
|
|
1017
|
+
{}, // TParams
|
|
1018
|
+
TLoaderDeps,
|
|
1019
|
+
TLoaderFn,
|
|
1020
|
+
TRouterContext,
|
|
1021
|
+
TRouteContextFn,
|
|
1022
|
+
TBeforeLoadFn
|
|
1023
|
+
>,
|
|
1024
|
+
| 'path'
|
|
1025
|
+
| 'id'
|
|
1026
|
+
| 'getParentRoute'
|
|
1027
|
+
| 'caseSensitive'
|
|
1028
|
+
| 'parseParams'
|
|
1029
|
+
| 'stringifyParams'
|
|
1030
|
+
| 'params'
|
|
1031
|
+
>
|
|
1032
|
+
|
|
506
1033
|
/**
|
|
507
1034
|
* @deprecated Use `ErrorComponentProps` instead.
|
|
508
1035
|
*/
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AllLoaderData, RouteById } from './routeInfo'
|
|
2
|
+
import type { AnyRouter } from './router'
|
|
3
|
+
import type { Expand } from './utils'
|
|
4
|
+
|
|
5
|
+
export type ResolveUseLoaderData<
|
|
6
|
+
TRouter extends AnyRouter,
|
|
7
|
+
TFrom,
|
|
8
|
+
TStrict extends boolean,
|
|
9
|
+
> = TStrict extends false
|
|
10
|
+
? AllLoaderData<TRouter['routeTree']>
|
|
11
|
+
: Expand<RouteById<TRouter['routeTree'], TFrom>['types']['loaderData']>
|
|
12
|
+
|
|
13
|
+
export type UseLoaderDataResult<
|
|
14
|
+
TRouter extends AnyRouter,
|
|
15
|
+
TFrom,
|
|
16
|
+
TStrict extends boolean,
|
|
17
|
+
TSelected,
|
|
18
|
+
> = unknown extends TSelected
|
|
19
|
+
? ResolveUseLoaderData<TRouter, TFrom, TStrict>
|
|
20
|
+
: TSelected
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RouteById } from './routeInfo'
|
|
2
|
+
import type { AnyRouter } from './router'
|
|
3
|
+
import type { Expand } from './utils'
|
|
4
|
+
|
|
5
|
+
export type ResolveUseLoaderDeps<TRouter extends AnyRouter, TFrom> = Expand<
|
|
6
|
+
RouteById<TRouter['routeTree'], TFrom>['types']['loaderDeps']
|
|
7
|
+
>
|
|
8
|
+
|
|
9
|
+
export type UseLoaderDepsResult<
|
|
10
|
+
TRouter extends AnyRouter,
|
|
11
|
+
TFrom,
|
|
12
|
+
TSelected,
|
|
13
|
+
> = unknown extends TSelected ? ResolveUseLoaderDeps<TRouter, TFrom> : TSelected
|