@tanstack/react-router 1.97.19 → 1.97.21
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/Match.cjs +4 -5
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs +0 -10
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +3 -30
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +2 -2
- package/dist/cjs/Transitioner.cjs +2 -2
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/awaited.cjs +6 -6
- package/dist/cjs/awaited.cjs.map +1 -1
- package/dist/cjs/awaited.d.cts +1 -1
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +2 -3
- package/dist/cjs/index.cjs +136 -42
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +12 -26
- package/dist/cjs/link.cjs +8 -9
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +2 -49
- package/dist/cjs/redirects.cjs.map +1 -1
- package/dist/cjs/redirects.d.cts +1 -1
- package/dist/cjs/route.cjs +14 -15
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +4 -151
- package/dist/cjs/routeInfo.d.cts +2 -3
- package/dist/cjs/router.cjs +51 -70
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +4 -19
- package/dist/cjs/routerContext.d.cts +1 -1
- package/dist/cjs/scroll-restoration.cjs +2 -2
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.d.cts +1 -1
- package/dist/cjs/structuralSharing.d.cts +1 -4
- package/dist/cjs/typePrimitives.d.cts +1 -1
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderData.d.cts +2 -1
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.d.cts +2 -1
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useMatch.d.cts +2 -1
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +2 -1
- package/dist/cjs/useRouteContext.cjs.map +1 -1
- package/dist/cjs/useRouteContext.d.cts +2 -1
- package/dist/cjs/useRouterState.cjs +2 -2
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +2 -1
- package/dist/cjs/utils.cjs +0 -152
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +1 -79
- package/dist/esm/Match.js +1 -2
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.d.ts +3 -30
- package/dist/esm/Matches.js +0 -10
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +2 -2
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/Transitioner.js +1 -1
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/awaited.d.ts +1 -1
- package/dist/esm/awaited.js +1 -1
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +2 -3
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +12 -26
- package/dist/esm/index.js +5 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/link.d.ts +2 -49
- package/dist/esm/link.js +2 -3
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/redirects.d.ts +1 -1
- package/dist/esm/redirects.js.map +1 -1
- package/dist/esm/route.d.ts +4 -151
- package/dist/esm/route.js +1 -2
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/routeInfo.d.ts +2 -3
- package/dist/esm/router.d.ts +4 -19
- package/dist/esm/router.js +1 -20
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.d.ts +1 -1
- package/dist/esm/scroll-restoration.d.ts +1 -1
- package/dist/esm/scroll-restoration.js +1 -1
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/structuralSharing.d.ts +1 -4
- package/dist/esm/typePrimitives.d.ts +1 -1
- package/dist/esm/useLoaderData.d.ts +2 -1
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.d.ts +2 -1
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useMatch.d.ts +2 -1
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useParams.d.ts +2 -1
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.d.ts +2 -1
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouterState.js +1 -1
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.d.ts +2 -1
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -79
- package/dist/esm/utils.js +0 -152
- package/dist/esm/utils.js.map +1 -1
- package/package.json +3 -2
- package/src/Match.tsx +5 -2
- package/src/Matches.tsx +8 -101
- package/src/RouterProvider.tsx +4 -2
- package/src/Transitioner.tsx +1 -1
- package/src/awaited.tsx +2 -2
- package/src/fileRoute.ts +6 -3
- package/src/index.tsx +128 -127
- package/src/link.tsx +27 -155
- package/src/redirects.ts +1 -1
- package/src/route.ts +43 -316
- package/src/routeInfo.ts +7 -3
- package/src/router.ts +32 -52
- package/src/scroll-restoration.tsx +2 -3
- package/src/structuralSharing.ts +5 -7
- package/src/typePrimitives.ts +1 -1
- package/src/useLoaderData.tsx +2 -1
- package/src/useLoaderDeps.tsx +2 -1
- package/src/useMatch.tsx +2 -1
- package/src/useParams.tsx +2 -1
- package/src/useRouteContext.ts +2 -1
- package/src/useRouterState.tsx +1 -1
- package/src/useSearch.tsx +2 -1
- package/src/utils.ts +1 -389
- package/dist/cjs/defer.cjs +0 -25
- package/dist/cjs/defer.cjs.map +0 -1
- package/dist/cjs/defer.d.cts +0 -20
- package/dist/cjs/location.d.cts +0 -12
- package/dist/cjs/manifest.d.cts +0 -24
- package/dist/cjs/path.cjs +0 -289
- package/dist/cjs/path.cjs.map +0 -1
- package/dist/cjs/path.d.cts +0 -34
- package/dist/cjs/qss.cjs +0 -51
- package/dist/cjs/qss.cjs.map +0 -1
- package/dist/cjs/qss.d.cts +0 -27
- package/dist/cjs/root.cjs +0 -5
- package/dist/cjs/root.cjs.map +0 -1
- package/dist/cjs/root.d.cts +0 -2
- package/dist/cjs/searchMiddleware.cjs +0 -42
- package/dist/cjs/searchMiddleware.cjs.map +0 -1
- package/dist/cjs/searchMiddleware.d.cts +0 -5
- package/dist/cjs/searchParams.cjs +0 -61
- package/dist/cjs/searchParams.cjs.map +0 -1
- package/dist/cjs/searchParams.d.cts +0 -7
- package/dist/cjs/serializer.d.cts +0 -15
- package/dist/cjs/validators.d.cts +0 -51
- package/dist/esm/defer.d.ts +0 -20
- package/dist/esm/defer.js +0 -25
- package/dist/esm/defer.js.map +0 -1
- package/dist/esm/location.d.ts +0 -12
- package/dist/esm/manifest.d.ts +0 -24
- package/dist/esm/path.d.ts +0 -34
- package/dist/esm/path.js +0 -289
- package/dist/esm/path.js.map +0 -1
- package/dist/esm/qss.d.ts +0 -27
- package/dist/esm/qss.js +0 -51
- package/dist/esm/qss.js.map +0 -1
- package/dist/esm/root.d.ts +0 -2
- package/dist/esm/root.js +0 -5
- package/dist/esm/root.js.map +0 -1
- package/dist/esm/searchMiddleware.d.ts +0 -5
- package/dist/esm/searchMiddleware.js +0 -42
- package/dist/esm/searchMiddleware.js.map +0 -1
- package/dist/esm/searchParams.d.ts +0 -7
- package/dist/esm/searchParams.js +0 -61
- package/dist/esm/searchParams.js.map +0 -1
- package/dist/esm/serializer.d.ts +0 -15
- package/dist/esm/validators.d.ts +0 -51
- package/src/defer.ts +0 -52
- package/src/location.ts +0 -13
- package/src/manifest.ts +0 -32
- package/src/path.ts +0 -427
- package/src/qss.ts +0 -91
- package/src/root.ts +0 -2
- package/src/searchMiddleware.ts +0 -54
- package/src/searchParams.ts +0 -77
- package/src/serializer.ts +0 -24
- package/src/validators.ts +0 -121
package/src/link.tsx
CHANGED
|
@@ -2,18 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { flushSync } from 'react-dom'
|
|
5
|
-
import { useRouterState } from './useRouterState'
|
|
6
|
-
import { useRouter } from './useRouter'
|
|
7
5
|
import {
|
|
8
6
|
deepEqual,
|
|
7
|
+
exactPathTest,
|
|
9
8
|
functionalUpdate,
|
|
9
|
+
preloadWarning,
|
|
10
|
+
removeTrailingSlash,
|
|
11
|
+
} from '@tanstack/router-core'
|
|
12
|
+
import { useRouterState } from './useRouterState'
|
|
13
|
+
import { useRouter } from './useRouter'
|
|
14
|
+
|
|
15
|
+
import {
|
|
10
16
|
useForwardedRef,
|
|
11
17
|
useIntersectionObserver,
|
|
12
18
|
useLayoutEffect,
|
|
13
19
|
} from './utils'
|
|
14
|
-
|
|
20
|
+
|
|
15
21
|
import { useMatch } from './useMatch'
|
|
16
|
-
import type {
|
|
22
|
+
import type {
|
|
23
|
+
Constrain,
|
|
24
|
+
ConstrainLiteral,
|
|
25
|
+
Expand,
|
|
26
|
+
IsRequiredParams,
|
|
27
|
+
LinkOptionsProps,
|
|
28
|
+
MakeDifferenceOptional,
|
|
29
|
+
NoInfer,
|
|
30
|
+
NonNullableUpdater,
|
|
31
|
+
ParsedLocation,
|
|
32
|
+
PickRequired,
|
|
33
|
+
RemoveTrailingSlashes,
|
|
34
|
+
ResolveRelativePath,
|
|
35
|
+
Updater,
|
|
36
|
+
ViewTransitionOptions,
|
|
37
|
+
WithoutEmpty,
|
|
38
|
+
} from '@tanstack/router-core'
|
|
17
39
|
import type { HistoryState, ParsedHistoryState } from '@tanstack/history'
|
|
18
40
|
import type {
|
|
19
41
|
AllParams,
|
|
@@ -28,57 +50,13 @@ import type {
|
|
|
28
50
|
RouteToPath,
|
|
29
51
|
ToPath,
|
|
30
52
|
} from './routeInfo'
|
|
31
|
-
import type {
|
|
32
|
-
AnyRouter,
|
|
33
|
-
RegisteredRouter,
|
|
34
|
-
ViewTransitionOptions,
|
|
35
|
-
} from './router'
|
|
36
|
-
import type {
|
|
37
|
-
Constrain,
|
|
38
|
-
ConstrainLiteral,
|
|
39
|
-
Expand,
|
|
40
|
-
MakeDifferenceOptional,
|
|
41
|
-
NoInfer,
|
|
42
|
-
NonNullableUpdater,
|
|
43
|
-
PickRequired,
|
|
44
|
-
Updater,
|
|
45
|
-
WithoutEmpty,
|
|
46
|
-
} from './utils'
|
|
53
|
+
import type { AnyRouter, RegisteredRouter } from './router'
|
|
47
54
|
import type { ReactNode } from 'react'
|
|
48
55
|
import type {
|
|
49
56
|
ValidateLinkOptions,
|
|
50
57
|
ValidateLinkOptionsArray,
|
|
51
58
|
} from './typePrimitives'
|
|
52
59
|
|
|
53
|
-
export type ParsePathParams<T extends string, TAcc = never> = T &
|
|
54
|
-
`${string}$${string}` extends never
|
|
55
|
-
? TAcc
|
|
56
|
-
: T extends `${string}$${infer TPossiblyParam}`
|
|
57
|
-
? TPossiblyParam extends ''
|
|
58
|
-
? TAcc
|
|
59
|
-
: TPossiblyParam & `${string}/${string}` extends never
|
|
60
|
-
? TPossiblyParam | TAcc
|
|
61
|
-
: TPossiblyParam extends `${infer TParam}/${infer TRest}`
|
|
62
|
-
? ParsePathParams<TRest, TParam extends '' ? TAcc : TParam | TAcc>
|
|
63
|
-
: never
|
|
64
|
-
: TAcc
|
|
65
|
-
|
|
66
|
-
export type AddTrailingSlash<T> = T extends `${string}/` ? T : `${T & string}/`
|
|
67
|
-
|
|
68
|
-
export type RemoveTrailingSlashes<T> = T extends `${string}/`
|
|
69
|
-
? T extends `${infer R}/`
|
|
70
|
-
? R
|
|
71
|
-
: T
|
|
72
|
-
: T
|
|
73
|
-
|
|
74
|
-
export type AddLeadingSlash<T> = T extends `/${string}` ? T : `/${T & string}`
|
|
75
|
-
|
|
76
|
-
export type RemoveLeadingSlashes<T> = T extends `/${string}`
|
|
77
|
-
? T extends `/${infer R}`
|
|
78
|
-
? R
|
|
79
|
-
: T
|
|
80
|
-
: T
|
|
81
|
-
|
|
82
60
|
export type FindDescendantToPaths<
|
|
83
61
|
TRouter extends AnyRouter,
|
|
84
62
|
TPrefix extends string,
|
|
@@ -404,9 +382,6 @@ export interface MakeRequiredSearchParams<
|
|
|
404
382
|
search: MakeRequiredParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {}
|
|
405
383
|
}
|
|
406
384
|
|
|
407
|
-
export type IsRequiredParams<TParams> =
|
|
408
|
-
Record<never, never> extends TParams ? never : true
|
|
409
|
-
|
|
410
385
|
export type IsRequired<
|
|
411
386
|
TRouter extends AnyRouter,
|
|
412
387
|
TParamVariant extends ParamVariant,
|
|
@@ -451,13 +426,6 @@ export type FromPathOption<TRouter extends AnyRouter, TFrom> = ConstrainLiteral<
|
|
|
451
426
|
RoutePaths<TRouter['routeTree']>
|
|
452
427
|
>
|
|
453
428
|
|
|
454
|
-
export interface ActiveOptions {
|
|
455
|
-
exact?: boolean
|
|
456
|
-
includeHash?: boolean
|
|
457
|
-
includeSearch?: boolean
|
|
458
|
-
explicitUndefined?: boolean
|
|
459
|
-
}
|
|
460
|
-
|
|
461
429
|
export type LinkOptions<
|
|
462
430
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
463
431
|
TFrom extends string = string,
|
|
@@ -466,99 +434,6 @@ export type LinkOptions<
|
|
|
466
434
|
TMaskTo extends string = '.',
|
|
467
435
|
> = NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkOptionsProps
|
|
468
436
|
|
|
469
|
-
export interface LinkOptionsProps {
|
|
470
|
-
/**
|
|
471
|
-
* The standard anchor tag target attribute
|
|
472
|
-
*/
|
|
473
|
-
target?: HTMLAnchorElement['target']
|
|
474
|
-
/**
|
|
475
|
-
* Configurable options to determine if the link should be considered active or not
|
|
476
|
-
* @default {exact:true,includeHash:true}
|
|
477
|
-
*/
|
|
478
|
-
activeOptions?: ActiveOptions
|
|
479
|
-
/**
|
|
480
|
-
* The preloading strategy for this link
|
|
481
|
-
* - `false` - No preloading
|
|
482
|
-
* - `'intent'` - Preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.
|
|
483
|
-
* - `'viewport'` - Preload the linked route when it enters the viewport
|
|
484
|
-
*/
|
|
485
|
-
preload?: false | 'intent' | 'viewport' | 'render'
|
|
486
|
-
/**
|
|
487
|
-
* When a preload strategy is set, this delays the preload by this many milliseconds.
|
|
488
|
-
* If the user exits the link before this delay, the preload will be cancelled.
|
|
489
|
-
*/
|
|
490
|
-
preloadDelay?: number
|
|
491
|
-
/**
|
|
492
|
-
* Control whether the link should be disabled or not
|
|
493
|
-
* If set to `true`, the link will be rendered without an `href` attribute
|
|
494
|
-
* @default false
|
|
495
|
-
*/
|
|
496
|
-
disabled?: boolean
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
type JoinPath<TLeft extends string, TRight extends string> = TRight extends ''
|
|
500
|
-
? TLeft
|
|
501
|
-
: TLeft extends ''
|
|
502
|
-
? TRight
|
|
503
|
-
: `${RemoveTrailingSlashes<TLeft>}/${RemoveLeadingSlashes<TRight>}`
|
|
504
|
-
|
|
505
|
-
type RemoveLastSegment<
|
|
506
|
-
T extends string,
|
|
507
|
-
TAcc extends string = '',
|
|
508
|
-
> = T extends `${infer TSegment}/${infer TRest}`
|
|
509
|
-
? TRest & `${string}/${string}` extends never
|
|
510
|
-
? TRest extends ''
|
|
511
|
-
? TAcc
|
|
512
|
-
: `${TAcc}${TSegment}`
|
|
513
|
-
: RemoveLastSegment<TRest, `${TAcc}${TSegment}/`>
|
|
514
|
-
: TAcc
|
|
515
|
-
|
|
516
|
-
export type ResolveCurrentPath<
|
|
517
|
-
TFrom extends string,
|
|
518
|
-
TTo extends string,
|
|
519
|
-
> = TTo extends '.'
|
|
520
|
-
? TFrom
|
|
521
|
-
: TTo extends './'
|
|
522
|
-
? AddTrailingSlash<TFrom>
|
|
523
|
-
: TTo & `./${string}` extends never
|
|
524
|
-
? never
|
|
525
|
-
: TTo extends `./${infer TRest}`
|
|
526
|
-
? AddLeadingSlash<JoinPath<TFrom, TRest>>
|
|
527
|
-
: never
|
|
528
|
-
|
|
529
|
-
export type ResolveParentPath<
|
|
530
|
-
TFrom extends string,
|
|
531
|
-
TTo extends string,
|
|
532
|
-
> = TTo extends '../' | '..'
|
|
533
|
-
? TFrom extends '' | '/'
|
|
534
|
-
? never
|
|
535
|
-
: AddLeadingSlash<RemoveLastSegment<TFrom>>
|
|
536
|
-
: TTo & `../${string}` extends never
|
|
537
|
-
? AddLeadingSlash<JoinPath<TFrom, TTo>>
|
|
538
|
-
: TFrom extends '' | '/'
|
|
539
|
-
? never
|
|
540
|
-
: TTo extends `../${infer ToRest}`
|
|
541
|
-
? ResolveParentPath<RemoveLastSegment<TFrom>, ToRest>
|
|
542
|
-
: AddLeadingSlash<JoinPath<TFrom, TTo>>
|
|
543
|
-
|
|
544
|
-
export type ResolveRelativePath<TFrom, TTo = '.'> = string extends TFrom
|
|
545
|
-
? TTo
|
|
546
|
-
: string extends TTo
|
|
547
|
-
? TFrom
|
|
548
|
-
: undefined extends TTo
|
|
549
|
-
? TFrom
|
|
550
|
-
: TTo extends string
|
|
551
|
-
? TFrom extends string
|
|
552
|
-
? TTo extends `/${string}`
|
|
553
|
-
? TTo
|
|
554
|
-
: TTo extends `..${string}`
|
|
555
|
-
? ResolveParentPath<TFrom, TTo>
|
|
556
|
-
: TTo extends `.${string}`
|
|
557
|
-
? ResolveCurrentPath<TFrom, TTo>
|
|
558
|
-
: AddLeadingSlash<JoinPath<TFrom, TTo>>
|
|
559
|
-
: never
|
|
560
|
-
: never
|
|
561
|
-
|
|
562
437
|
// type Test1 = ResolveRelativePath<'/', '/posts'>
|
|
563
438
|
// // ^?
|
|
564
439
|
// type Test4 = ResolveRelativePath<'/posts/1/comments', '../..'>
|
|
@@ -577,13 +452,10 @@ export type ResolveRelativePath<TFrom, TTo = '.'> = string extends TFrom
|
|
|
577
452
|
// // ^?
|
|
578
453
|
// type Test11 = ResolveRelativePath<'/posts/1/comments', './1/2'>
|
|
579
454
|
// // ^?
|
|
580
|
-
|
|
581
455
|
type LinkCurrentTargetElement = {
|
|
582
456
|
preloadTimeout?: null | ReturnType<typeof setTimeout>
|
|
583
457
|
}
|
|
584
458
|
|
|
585
|
-
const preloadWarning = 'Error preloading route! ☝️'
|
|
586
|
-
|
|
587
459
|
export function useLinkProps<
|
|
588
460
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
589
461
|
const TFrom extends string = string,
|
package/src/redirects.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NavigateOptions } from './link'
|
|
2
2
|
import type { RoutePaths } from './routeInfo'
|
|
3
3
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
4
|
-
import type { PickAsRequired } from '
|
|
4
|
+
import type { PickAsRequired } from '@tanstack/router-core'
|
|
5
5
|
|
|
6
6
|
export type AnyRedirect = Redirect<any, any, any, any, any>
|
|
7
7
|
|
package/src/route.ts
CHANGED
|
@@ -1,20 +1,56 @@
|
|
|
1
1
|
import invariant from 'tiny-invariant'
|
|
2
|
-
import { joinPaths, trimPathLeft } from '
|
|
2
|
+
import { joinPaths, rootRouteId, trimPathLeft } from '@tanstack/router-core'
|
|
3
3
|
import { useLoaderData } from './useLoaderData'
|
|
4
4
|
import { useLoaderDeps } from './useLoaderDeps'
|
|
5
5
|
import { useParams } from './useParams'
|
|
6
6
|
import { useSearch } from './useSearch'
|
|
7
7
|
import { notFound } from './not-found'
|
|
8
8
|
import { useNavigate } from './useNavigate'
|
|
9
|
-
import { rootRouteId } from './root'
|
|
10
9
|
import { useMatch } from './useMatch'
|
|
10
|
+
import type {
|
|
11
|
+
AnyContext,
|
|
12
|
+
AnyPathParams,
|
|
13
|
+
AnySchema,
|
|
14
|
+
AnyValidator,
|
|
15
|
+
Assign,
|
|
16
|
+
Constrain,
|
|
17
|
+
ConstrainLiteral,
|
|
18
|
+
ContextAsyncReturnType,
|
|
19
|
+
ContextReturnType,
|
|
20
|
+
DefaultValidator,
|
|
21
|
+
ErrorComponentProps,
|
|
22
|
+
Expand,
|
|
23
|
+
InferAllContext,
|
|
24
|
+
InferAllParams,
|
|
25
|
+
InferFullSearchSchema,
|
|
26
|
+
InferFullSearchSchemaInput,
|
|
27
|
+
IntersectAssign,
|
|
28
|
+
NoInfer,
|
|
29
|
+
NotFoundRouteProps,
|
|
30
|
+
ParamsOptions,
|
|
31
|
+
ParsedLocation,
|
|
32
|
+
ResolveId,
|
|
33
|
+
ResolveLoaderData,
|
|
34
|
+
ResolveParams,
|
|
35
|
+
ResolveRouteContext,
|
|
36
|
+
ResolveSearchValidatorInput,
|
|
37
|
+
ResolveValidatorOutput,
|
|
38
|
+
RootRouteId,
|
|
39
|
+
RouteContext,
|
|
40
|
+
RoutePathOptions,
|
|
41
|
+
RoutePathOptionsIntersection,
|
|
42
|
+
RoutePrefix,
|
|
43
|
+
SearchFilter,
|
|
44
|
+
SearchMiddleware,
|
|
45
|
+
TrimPathRight,
|
|
46
|
+
UpdatableStaticRouteOption,
|
|
47
|
+
} from '@tanstack/router-core'
|
|
11
48
|
import type { UseLoaderDataRoute } from './useLoaderData'
|
|
12
49
|
import type { UseMatchRoute } from './useMatch'
|
|
13
50
|
import type { UseLoaderDepsRoute } from './useLoaderDeps'
|
|
14
51
|
import type { UseParamsRoute } from './useParams'
|
|
15
52
|
import type { UseSearchRoute } from './useSearch'
|
|
16
53
|
import type * as React from 'react'
|
|
17
|
-
import type { RootRouteId } from './root'
|
|
18
54
|
import type { UseNavigateResult } from './useNavigate'
|
|
19
55
|
import type {
|
|
20
56
|
AnyRouteMatch,
|
|
@@ -22,62 +58,14 @@ import type {
|
|
|
22
58
|
MakeRouteMatchUnion,
|
|
23
59
|
RouteMatch,
|
|
24
60
|
} from './Matches'
|
|
25
|
-
import type { NavigateOptions,
|
|
26
|
-
import type { ParsedLocation } from './location'
|
|
61
|
+
import type { NavigateOptions, ToMaskOptions } from './link'
|
|
27
62
|
import type { RouteById, RouteIds, RoutePaths } from './routeInfo'
|
|
28
63
|
import type { AnyRouter, RegisteredRouter, Router } from './router'
|
|
29
|
-
import type {
|
|
30
|
-
Assign,
|
|
31
|
-
Constrain,
|
|
32
|
-
ConstrainLiteral,
|
|
33
|
-
Expand,
|
|
34
|
-
NoInfer,
|
|
35
|
-
} from './utils'
|
|
36
64
|
import type { BuildLocationFn, NavigateFn } from './RouterProvider'
|
|
37
65
|
import type { NotFoundError } from './not-found'
|
|
38
66
|
import type { LazyRoute } from './fileRoute'
|
|
39
|
-
import type {
|
|
40
|
-
AnySchema,
|
|
41
|
-
AnyStandardSchemaValidator,
|
|
42
|
-
AnyValidator,
|
|
43
|
-
AnyValidatorAdapter,
|
|
44
|
-
AnyValidatorObj,
|
|
45
|
-
DefaultValidator,
|
|
46
|
-
ResolveSearchValidatorInput,
|
|
47
|
-
ResolveValidatorOutput,
|
|
48
|
-
StandardSchemaValidator,
|
|
49
|
-
ValidatorAdapter,
|
|
50
|
-
ValidatorFn,
|
|
51
|
-
ValidatorObj,
|
|
52
|
-
} from './validators'
|
|
53
|
-
import type { UseRouteContextRoute } from './useRouteContext'
|
|
54
|
-
|
|
55
|
-
export type AnyPathParams = {}
|
|
56
|
-
|
|
57
|
-
export type SearchSchemaInput = {
|
|
58
|
-
__TSearchSchemaInput__: 'TSearchSchemaInput'
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export type AnyContext = {}
|
|
62
|
-
|
|
63
|
-
export interface RouteContext {}
|
|
64
|
-
|
|
65
|
-
export type PreloadableObj = { preload?: () => Promise<void> }
|
|
66
|
-
|
|
67
|
-
export type RoutePathOptions<TCustomId, TPath> =
|
|
68
|
-
| {
|
|
69
|
-
path: TPath
|
|
70
|
-
}
|
|
71
|
-
| {
|
|
72
|
-
id: TCustomId
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface StaticDataRouteOption {}
|
|
76
67
|
|
|
77
|
-
|
|
78
|
-
path: TPath
|
|
79
|
-
id: TCustomId
|
|
80
|
-
}
|
|
68
|
+
import type { UseRouteContextRoute } from './useRouteContext'
|
|
81
69
|
|
|
82
70
|
export type RouteOptions<
|
|
83
71
|
TParentRoute extends AnyRoute = AnyRoute,
|
|
@@ -118,49 +106,6 @@ export type RouteOptions<
|
|
|
118
106
|
NoInfer<TBeforeLoadFn>
|
|
119
107
|
>
|
|
120
108
|
|
|
121
|
-
export type ParseSplatParams<TPath extends string> = TPath &
|
|
122
|
-
`${string}$` extends never
|
|
123
|
-
? TPath & `${string}$/${string}` extends never
|
|
124
|
-
? never
|
|
125
|
-
: '_splat'
|
|
126
|
-
: '_splat'
|
|
127
|
-
|
|
128
|
-
export interface SplatParams {
|
|
129
|
-
_splat?: string
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export type ResolveParams<TPath extends string> =
|
|
133
|
-
ParseSplatParams<TPath> extends never
|
|
134
|
-
? Record<ParsePathParams<TPath>, string>
|
|
135
|
-
: Record<ParsePathParams<TPath>, string> & SplatParams
|
|
136
|
-
|
|
137
|
-
export type ParseParamsFn<in out TPath extends string, in out TParams> = (
|
|
138
|
-
rawParams: ResolveParams<TPath>,
|
|
139
|
-
) => TParams extends Record<ParsePathParams<TPath>, any>
|
|
140
|
-
? TParams
|
|
141
|
-
: Record<ParsePathParams<TPath>, any>
|
|
142
|
-
|
|
143
|
-
export type StringifyParamsFn<in out TPath extends string, in out TParams> = (
|
|
144
|
-
params: TParams,
|
|
145
|
-
) => ResolveParams<TPath>
|
|
146
|
-
|
|
147
|
-
export type ParamsOptions<in out TPath extends string, in out TParams> = {
|
|
148
|
-
params?: {
|
|
149
|
-
parse?: ParseParamsFn<TPath, TParams>
|
|
150
|
-
stringify?: StringifyParamsFn<TPath, TParams>
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
@deprecated Use params.parse instead
|
|
155
|
-
*/
|
|
156
|
-
parseParams?: ParseParamsFn<TPath, TParams>
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
@deprecated Use params.stringify instead
|
|
160
|
-
*/
|
|
161
|
-
stringifyParams?: StringifyParamsFn<TPath, TParams>
|
|
162
|
-
}
|
|
163
|
-
|
|
164
109
|
export interface FullSearchSchemaOption<
|
|
165
110
|
in out TParentRoute extends AnyRoute,
|
|
166
111
|
in out TSearchValidator,
|
|
@@ -486,51 +431,6 @@ export interface UpdatableRouteOptions<
|
|
|
486
431
|
ssr?: boolean
|
|
487
432
|
}
|
|
488
433
|
|
|
489
|
-
interface RequiredStaticDataRouteOption {
|
|
490
|
-
staticData: StaticDataRouteOption
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
interface OptionalStaticDataRouteOption {
|
|
494
|
-
staticData?: StaticDataRouteOption
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
export type UpdatableStaticRouteOption = {} extends StaticDataRouteOption
|
|
498
|
-
? OptionalStaticDataRouteOption
|
|
499
|
-
: RequiredStaticDataRouteOption
|
|
500
|
-
|
|
501
|
-
export type MetaDescriptor =
|
|
502
|
-
| { charSet: 'utf-8' }
|
|
503
|
-
| { title: string }
|
|
504
|
-
| { name: string; content: string }
|
|
505
|
-
| { property: string; content: string }
|
|
506
|
-
| { httpEquiv: string; content: string }
|
|
507
|
-
| { 'script:ld+json': LdJsonObject }
|
|
508
|
-
| { tagName: 'meta' | 'link'; [name: string]: string }
|
|
509
|
-
| Record<string, unknown>
|
|
510
|
-
|
|
511
|
-
type LdJsonObject = { [Key in string]: LdJsonValue } & {
|
|
512
|
-
[Key in string]?: LdJsonValue | undefined
|
|
513
|
-
}
|
|
514
|
-
type LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>
|
|
515
|
-
type LdJsonPrimitive = string | number | boolean | null
|
|
516
|
-
type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray
|
|
517
|
-
|
|
518
|
-
export type RouteLinkEntry = {}
|
|
519
|
-
|
|
520
|
-
export type SearchValidator<TInput, TOutput> =
|
|
521
|
-
| ValidatorObj<TInput, TOutput>
|
|
522
|
-
| ValidatorFn<TInput, TOutput>
|
|
523
|
-
| ValidatorAdapter<TInput, TOutput>
|
|
524
|
-
| StandardSchemaValidator<TInput, TOutput>
|
|
525
|
-
| undefined
|
|
526
|
-
|
|
527
|
-
export type AnySearchValidator = SearchValidator<any, any>
|
|
528
|
-
|
|
529
|
-
export type DefaultSearchValidator = SearchValidator<
|
|
530
|
-
Record<string, unknown>,
|
|
531
|
-
AnySchema
|
|
532
|
-
>
|
|
533
|
-
|
|
534
434
|
export type RouteLoaderFn<
|
|
535
435
|
in out TParentRoute extends AnyRoute = AnyRoute,
|
|
536
436
|
in out TId extends string = string,
|
|
@@ -585,98 +485,12 @@ export interface LoaderFnContext<
|
|
|
585
485
|
route: Route
|
|
586
486
|
}
|
|
587
487
|
|
|
588
|
-
export type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult
|
|
589
|
-
|
|
590
|
-
export type SearchMiddlewareContext<TSearchSchema> = {
|
|
591
|
-
search: TSearchSchema
|
|
592
|
-
next: (newSearch: TSearchSchema) => TSearchSchema
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
export type SearchMiddleware<TSearchSchema> = (
|
|
596
|
-
ctx: SearchMiddlewareContext<TSearchSchema>,
|
|
597
|
-
) => TSearchSchema
|
|
598
|
-
|
|
599
|
-
export type ResolveId<
|
|
600
|
-
TParentRoute,
|
|
601
|
-
TCustomId extends string,
|
|
602
|
-
TPath extends string,
|
|
603
|
-
> = TParentRoute extends { id: infer TParentId extends string }
|
|
604
|
-
? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>
|
|
605
|
-
: RootRouteId
|
|
606
|
-
|
|
607
|
-
export type InferFullSearchSchema<TRoute> = TRoute extends {
|
|
608
|
-
types: {
|
|
609
|
-
fullSearchSchema: infer TFullSearchSchema
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
? TFullSearchSchema
|
|
613
|
-
: {}
|
|
614
|
-
|
|
615
|
-
export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
|
|
616
|
-
types: {
|
|
617
|
-
fullSearchSchemaInput: infer TFullSearchSchemaInput
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
? TFullSearchSchemaInput
|
|
621
|
-
: {}
|
|
622
|
-
|
|
623
|
-
export type InferAllParams<TRoute> = TRoute extends {
|
|
624
|
-
types: {
|
|
625
|
-
allParams: infer TAllParams
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
? TAllParams
|
|
629
|
-
: {}
|
|
630
|
-
|
|
631
|
-
export type InferAllContext<TRoute> = unknown extends TRoute
|
|
632
|
-
? TRoute
|
|
633
|
-
: TRoute extends {
|
|
634
|
-
types: {
|
|
635
|
-
allContext: infer TAllContext
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
? TAllContext
|
|
639
|
-
: {}
|
|
640
|
-
|
|
641
|
-
export type ResolveSearchSchemaFnInput<TSearchValidator> =
|
|
642
|
-
TSearchValidator extends (input: infer TSearchSchemaInput) => any
|
|
643
|
-
? TSearchSchemaInput extends SearchSchemaInput
|
|
644
|
-
? Omit<TSearchSchemaInput, keyof SearchSchemaInput>
|
|
645
|
-
: ResolveSearchSchemaFn<TSearchValidator>
|
|
646
|
-
: AnySchema
|
|
647
|
-
|
|
648
|
-
export type ResolveSearchSchemaInput<TSearchValidator> =
|
|
649
|
-
TSearchValidator extends AnyStandardSchemaValidator
|
|
650
|
-
? NonNullable<TSearchValidator['~standard']['types']>['input']
|
|
651
|
-
: TSearchValidator extends AnyValidatorAdapter
|
|
652
|
-
? TSearchValidator['types']['input']
|
|
653
|
-
: TSearchValidator extends AnyValidatorObj
|
|
654
|
-
? ResolveSearchSchemaFnInput<TSearchValidator['parse']>
|
|
655
|
-
: ResolveSearchSchemaFnInput<TSearchValidator>
|
|
656
|
-
|
|
657
|
-
export type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (
|
|
658
|
-
...args: any
|
|
659
|
-
) => infer TSearchSchema
|
|
660
|
-
? TSearchSchema
|
|
661
|
-
: AnySchema
|
|
662
|
-
|
|
663
|
-
export type ResolveSearchSchema<TSearchValidator> =
|
|
664
|
-
unknown extends TSearchValidator
|
|
665
|
-
? TSearchValidator
|
|
666
|
-
: TSearchValidator extends AnyStandardSchemaValidator
|
|
667
|
-
? NonNullable<TSearchValidator['~standard']['types']>['output']
|
|
668
|
-
: TSearchValidator extends AnyValidatorAdapter
|
|
669
|
-
? TSearchValidator['types']['output']
|
|
670
|
-
: TSearchValidator extends AnyValidatorObj
|
|
671
|
-
? ResolveSearchSchemaFn<TSearchValidator['parse']>
|
|
672
|
-
: ResolveSearchSchemaFn<TSearchValidator>
|
|
673
|
-
|
|
674
488
|
export type ResolveFullSearchSchema<
|
|
675
489
|
TParentRoute extends AnyRoute,
|
|
676
490
|
TSearchValidator,
|
|
677
491
|
> = unknown extends TParentRoute
|
|
678
492
|
? ResolveValidatorOutput<TSearchValidator>
|
|
679
|
-
:
|
|
493
|
+
: IntersectAssign<
|
|
680
494
|
InferFullSearchSchema<TParentRoute>,
|
|
681
495
|
ResolveValidatorOutput<TSearchValidator>
|
|
682
496
|
>
|
|
@@ -684,37 +498,11 @@ export type ResolveFullSearchSchema<
|
|
|
684
498
|
export type ResolveFullSearchSchemaInput<
|
|
685
499
|
TParentRoute extends AnyRoute,
|
|
686
500
|
TSearchValidator,
|
|
687
|
-
> =
|
|
501
|
+
> = IntersectAssign<
|
|
688
502
|
InferFullSearchSchemaInput<TParentRoute>,
|
|
689
503
|
ResolveSearchValidatorInput<TSearchValidator>
|
|
690
504
|
>
|
|
691
505
|
|
|
692
|
-
export type LooseReturnType<T> = T extends (
|
|
693
|
-
...args: Array<any>
|
|
694
|
-
) => infer TReturn
|
|
695
|
-
? TReturn
|
|
696
|
-
: never
|
|
697
|
-
|
|
698
|
-
export type LooseAsyncReturnType<T> = T extends (
|
|
699
|
-
...args: Array<any>
|
|
700
|
-
) => infer TReturn
|
|
701
|
-
? TReturn extends Promise<infer TReturn>
|
|
702
|
-
? TReturn
|
|
703
|
-
: TReturn
|
|
704
|
-
: never
|
|
705
|
-
|
|
706
|
-
export type ContextReturnType<TContextFn> = unknown extends TContextFn
|
|
707
|
-
? TContextFn
|
|
708
|
-
: LooseReturnType<TContextFn> extends never
|
|
709
|
-
? AnyContext
|
|
710
|
-
: LooseReturnType<TContextFn>
|
|
711
|
-
|
|
712
|
-
export type ContextAsyncReturnType<TContextFn> = unknown extends TContextFn
|
|
713
|
-
? TContextFn
|
|
714
|
-
: LooseAsyncReturnType<TContextFn> extends never
|
|
715
|
-
? AnyContext
|
|
716
|
-
: LooseAsyncReturnType<TContextFn>
|
|
717
|
-
|
|
718
506
|
export type RouteContextParameter<
|
|
719
507
|
TParentRoute extends AnyRoute,
|
|
720
508
|
TRouterContext,
|
|
@@ -722,10 +510,6 @@ export type RouteContextParameter<
|
|
|
722
510
|
? TRouterContext
|
|
723
511
|
: Assign<TRouterContext, InferAllContext<TParentRoute>>
|
|
724
512
|
|
|
725
|
-
export type ResolveRouteContext<TRouteContextFn, TBeforeLoadFn> = Assign<
|
|
726
|
-
ContextReturnType<TRouteContextFn>,
|
|
727
|
-
ContextAsyncReturnType<TBeforeLoadFn>
|
|
728
|
-
>
|
|
729
513
|
export type BeforeLoadContextParameter<
|
|
730
514
|
TParentRoute extends AnyRoute,
|
|
731
515
|
TRouterContext,
|
|
@@ -745,12 +529,6 @@ export type ResolveAllContext<
|
|
|
745
529
|
ContextAsyncReturnType<TBeforeLoadFn>
|
|
746
530
|
>
|
|
747
531
|
|
|
748
|
-
export type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn
|
|
749
|
-
? TLoaderFn
|
|
750
|
-
: LooseAsyncReturnType<TLoaderFn> extends never
|
|
751
|
-
? {}
|
|
752
|
-
: LooseAsyncReturnType<TLoaderFn>
|
|
753
|
-
|
|
754
532
|
export interface AnyRoute
|
|
755
533
|
extends Route<
|
|
756
534
|
any,
|
|
@@ -1529,37 +1307,6 @@ export type ResolveFullPath<
|
|
|
1529
1307
|
TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,
|
|
1530
1308
|
> = TPrefixed extends RootRouteId ? '/' : TPrefixed
|
|
1531
1309
|
|
|
1532
|
-
type RoutePrefix<
|
|
1533
|
-
TPrefix extends string,
|
|
1534
|
-
TPath extends string,
|
|
1535
|
-
> = string extends TPath
|
|
1536
|
-
? RootRouteId
|
|
1537
|
-
: TPath extends string
|
|
1538
|
-
? TPrefix extends RootRouteId
|
|
1539
|
-
? TPath extends '/'
|
|
1540
|
-
? '/'
|
|
1541
|
-
: `/${TrimPath<TPath>}`
|
|
1542
|
-
: `${TPrefix}/${TPath}` extends '/'
|
|
1543
|
-
? '/'
|
|
1544
|
-
: `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`
|
|
1545
|
-
: never
|
|
1546
|
-
|
|
1547
|
-
export type TrimPath<T extends string> = '' extends T
|
|
1548
|
-
? ''
|
|
1549
|
-
: TrimPathRight<TrimPathLeft<T>>
|
|
1550
|
-
|
|
1551
|
-
export type TrimPathLeft<T extends string> =
|
|
1552
|
-
T extends `${RootRouteId}/${infer U}`
|
|
1553
|
-
? TrimPathLeft<U>
|
|
1554
|
-
: T extends `/${infer U}`
|
|
1555
|
-
? TrimPathLeft<U>
|
|
1556
|
-
: T
|
|
1557
|
-
export type TrimPathRight<T extends string> = T extends '/'
|
|
1558
|
-
? '/'
|
|
1559
|
-
: T extends `${infer U}/`
|
|
1560
|
-
? TrimPathRight<U>
|
|
1561
|
-
: T
|
|
1562
|
-
|
|
1563
1310
|
export type RouteMask<TRouteTree extends AnyRoute> = {
|
|
1564
1311
|
routeTree: TRouteTree
|
|
1565
1312
|
from: RoutePaths<TRouteTree>
|
|
@@ -1583,26 +1330,6 @@ export function createRouteMask<
|
|
|
1583
1330
|
return opts as any
|
|
1584
1331
|
}
|
|
1585
1332
|
|
|
1586
|
-
/**
|
|
1587
|
-
* @deprecated Use `ErrorComponentProps` instead.
|
|
1588
|
-
*/
|
|
1589
|
-
export type ErrorRouteProps = {
|
|
1590
|
-
error: unknown
|
|
1591
|
-
info?: { componentStack: string }
|
|
1592
|
-
reset: () => void
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
export type ErrorComponentProps = {
|
|
1596
|
-
error: Error
|
|
1597
|
-
info?: { componentStack: string }
|
|
1598
|
-
reset: () => void
|
|
1599
|
-
}
|
|
1600
|
-
export type NotFoundRouteProps = {
|
|
1601
|
-
// TODO: Make sure this is `| null | undefined` (this is for global not-founds)
|
|
1602
|
-
data: unknown
|
|
1603
|
-
}
|
|
1604
|
-
//
|
|
1605
|
-
|
|
1606
1333
|
export type ReactNode = any
|
|
1607
1334
|
|
|
1608
1335
|
export type SyncRouteComponent<TProps> =
|