@tanstack/react-router 1.97.20 → 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.
Files changed (182) hide show
  1. package/dist/cjs/Match.cjs +4 -5
  2. package/dist/cjs/Match.cjs.map +1 -1
  3. package/dist/cjs/Matches.cjs +0 -10
  4. package/dist/cjs/Matches.cjs.map +1 -1
  5. package/dist/cjs/Matches.d.cts +3 -30
  6. package/dist/cjs/RouterProvider.cjs.map +1 -1
  7. package/dist/cjs/RouterProvider.d.cts +2 -2
  8. package/dist/cjs/Transitioner.cjs +2 -2
  9. package/dist/cjs/Transitioner.cjs.map +1 -1
  10. package/dist/cjs/awaited.cjs +6 -6
  11. package/dist/cjs/awaited.cjs.map +1 -1
  12. package/dist/cjs/awaited.d.cts +1 -1
  13. package/dist/cjs/fileRoute.cjs.map +1 -1
  14. package/dist/cjs/fileRoute.d.cts +2 -3
  15. package/dist/cjs/index.cjs +136 -42
  16. package/dist/cjs/index.cjs.map +1 -1
  17. package/dist/cjs/index.d.cts +12 -26
  18. package/dist/cjs/link.cjs +8 -9
  19. package/dist/cjs/link.cjs.map +1 -1
  20. package/dist/cjs/link.d.cts +2 -49
  21. package/dist/cjs/redirects.cjs.map +1 -1
  22. package/dist/cjs/redirects.d.cts +1 -1
  23. package/dist/cjs/route.cjs +14 -15
  24. package/dist/cjs/route.cjs.map +1 -1
  25. package/dist/cjs/route.d.cts +2 -149
  26. package/dist/cjs/routeInfo.d.cts +2 -3
  27. package/dist/cjs/router.cjs +51 -70
  28. package/dist/cjs/router.cjs.map +1 -1
  29. package/dist/cjs/router.d.cts +4 -19
  30. package/dist/cjs/routerContext.d.cts +1 -1
  31. package/dist/cjs/scroll-restoration.cjs +2 -2
  32. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  33. package/dist/cjs/scroll-restoration.d.cts +1 -1
  34. package/dist/cjs/structuralSharing.d.cts +1 -4
  35. package/dist/cjs/typePrimitives.d.cts +1 -1
  36. package/dist/cjs/useLoaderData.cjs.map +1 -1
  37. package/dist/cjs/useLoaderData.d.cts +2 -1
  38. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  39. package/dist/cjs/useLoaderDeps.d.cts +2 -1
  40. package/dist/cjs/useMatch.cjs.map +1 -1
  41. package/dist/cjs/useMatch.d.cts +2 -1
  42. package/dist/cjs/useParams.cjs.map +1 -1
  43. package/dist/cjs/useParams.d.cts +2 -1
  44. package/dist/cjs/useRouteContext.cjs.map +1 -1
  45. package/dist/cjs/useRouteContext.d.cts +2 -1
  46. package/dist/cjs/useRouterState.cjs +2 -2
  47. package/dist/cjs/useRouterState.cjs.map +1 -1
  48. package/dist/cjs/useSearch.cjs.map +1 -1
  49. package/dist/cjs/useSearch.d.cts +2 -1
  50. package/dist/cjs/utils.cjs +0 -152
  51. package/dist/cjs/utils.cjs.map +1 -1
  52. package/dist/cjs/utils.d.cts +1 -81
  53. package/dist/esm/Match.js +1 -2
  54. package/dist/esm/Match.js.map +1 -1
  55. package/dist/esm/Matches.d.ts +3 -30
  56. package/dist/esm/Matches.js +0 -10
  57. package/dist/esm/Matches.js.map +1 -1
  58. package/dist/esm/RouterProvider.d.ts +2 -2
  59. package/dist/esm/RouterProvider.js.map +1 -1
  60. package/dist/esm/Transitioner.js +1 -1
  61. package/dist/esm/Transitioner.js.map +1 -1
  62. package/dist/esm/awaited.d.ts +1 -1
  63. package/dist/esm/awaited.js +1 -1
  64. package/dist/esm/awaited.js.map +1 -1
  65. package/dist/esm/fileRoute.d.ts +2 -3
  66. package/dist/esm/fileRoute.js.map +1 -1
  67. package/dist/esm/index.d.ts +12 -26
  68. package/dist/esm/index.js +5 -10
  69. package/dist/esm/index.js.map +1 -1
  70. package/dist/esm/link.d.ts +2 -49
  71. package/dist/esm/link.js +2 -3
  72. package/dist/esm/link.js.map +1 -1
  73. package/dist/esm/redirects.d.ts +1 -1
  74. package/dist/esm/redirects.js.map +1 -1
  75. package/dist/esm/route.d.ts +2 -149
  76. package/dist/esm/route.js +1 -2
  77. package/dist/esm/route.js.map +1 -1
  78. package/dist/esm/routeInfo.d.ts +2 -3
  79. package/dist/esm/router.d.ts +4 -19
  80. package/dist/esm/router.js +1 -20
  81. package/dist/esm/router.js.map +1 -1
  82. package/dist/esm/routerContext.d.ts +1 -1
  83. package/dist/esm/scroll-restoration.d.ts +1 -1
  84. package/dist/esm/scroll-restoration.js +1 -1
  85. package/dist/esm/scroll-restoration.js.map +1 -1
  86. package/dist/esm/structuralSharing.d.ts +1 -4
  87. package/dist/esm/typePrimitives.d.ts +1 -1
  88. package/dist/esm/useLoaderData.d.ts +2 -1
  89. package/dist/esm/useLoaderData.js.map +1 -1
  90. package/dist/esm/useLoaderDeps.d.ts +2 -1
  91. package/dist/esm/useLoaderDeps.js.map +1 -1
  92. package/dist/esm/useMatch.d.ts +2 -1
  93. package/dist/esm/useMatch.js.map +1 -1
  94. package/dist/esm/useParams.d.ts +2 -1
  95. package/dist/esm/useParams.js.map +1 -1
  96. package/dist/esm/useRouteContext.d.ts +2 -1
  97. package/dist/esm/useRouteContext.js.map +1 -1
  98. package/dist/esm/useRouterState.js +1 -1
  99. package/dist/esm/useRouterState.js.map +1 -1
  100. package/dist/esm/useSearch.d.ts +2 -1
  101. package/dist/esm/useSearch.js.map +1 -1
  102. package/dist/esm/utils.d.ts +1 -81
  103. package/dist/esm/utils.js +0 -152
  104. package/dist/esm/utils.js.map +1 -1
  105. package/package.json +3 -2
  106. package/src/Match.tsx +5 -2
  107. package/src/Matches.tsx +8 -101
  108. package/src/RouterProvider.tsx +4 -2
  109. package/src/Transitioner.tsx +1 -1
  110. package/src/awaited.tsx +2 -2
  111. package/src/fileRoute.ts +6 -3
  112. package/src/index.tsx +128 -128
  113. package/src/link.tsx +27 -155
  114. package/src/redirects.ts +1 -1
  115. package/src/route.ts +41 -315
  116. package/src/routeInfo.ts +7 -3
  117. package/src/router.ts +32 -52
  118. package/src/scroll-restoration.tsx +2 -3
  119. package/src/structuralSharing.ts +5 -7
  120. package/src/typePrimitives.ts +1 -1
  121. package/src/useLoaderData.tsx +2 -1
  122. package/src/useLoaderDeps.tsx +2 -1
  123. package/src/useMatch.tsx +2 -1
  124. package/src/useParams.tsx +2 -1
  125. package/src/useRouteContext.ts +2 -1
  126. package/src/useRouterState.tsx +1 -1
  127. package/src/useSearch.tsx +2 -1
  128. package/src/utils.ts +1 -405
  129. package/dist/cjs/defer.cjs +0 -25
  130. package/dist/cjs/defer.cjs.map +0 -1
  131. package/dist/cjs/defer.d.cts +0 -20
  132. package/dist/cjs/location.d.cts +0 -12
  133. package/dist/cjs/manifest.d.cts +0 -24
  134. package/dist/cjs/path.cjs +0 -289
  135. package/dist/cjs/path.cjs.map +0 -1
  136. package/dist/cjs/path.d.cts +0 -34
  137. package/dist/cjs/qss.cjs +0 -51
  138. package/dist/cjs/qss.cjs.map +0 -1
  139. package/dist/cjs/qss.d.cts +0 -27
  140. package/dist/cjs/root.cjs +0 -5
  141. package/dist/cjs/root.cjs.map +0 -1
  142. package/dist/cjs/root.d.cts +0 -2
  143. package/dist/cjs/searchMiddleware.cjs +0 -42
  144. package/dist/cjs/searchMiddleware.cjs.map +0 -1
  145. package/dist/cjs/searchMiddleware.d.cts +0 -5
  146. package/dist/cjs/searchParams.cjs +0 -61
  147. package/dist/cjs/searchParams.cjs.map +0 -1
  148. package/dist/cjs/searchParams.d.cts +0 -7
  149. package/dist/cjs/serializer.d.cts +0 -15
  150. package/dist/cjs/validators.d.cts +0 -51
  151. package/dist/esm/defer.d.ts +0 -20
  152. package/dist/esm/defer.js +0 -25
  153. package/dist/esm/defer.js.map +0 -1
  154. package/dist/esm/location.d.ts +0 -12
  155. package/dist/esm/manifest.d.ts +0 -24
  156. package/dist/esm/path.d.ts +0 -34
  157. package/dist/esm/path.js +0 -289
  158. package/dist/esm/path.js.map +0 -1
  159. package/dist/esm/qss.d.ts +0 -27
  160. package/dist/esm/qss.js +0 -51
  161. package/dist/esm/qss.js.map +0 -1
  162. package/dist/esm/root.d.ts +0 -2
  163. package/dist/esm/root.js +0 -5
  164. package/dist/esm/root.js.map +0 -1
  165. package/dist/esm/searchMiddleware.d.ts +0 -5
  166. package/dist/esm/searchMiddleware.js +0 -42
  167. package/dist/esm/searchMiddleware.js.map +0 -1
  168. package/dist/esm/searchParams.d.ts +0 -7
  169. package/dist/esm/searchParams.js +0 -61
  170. package/dist/esm/searchParams.js.map +0 -1
  171. package/dist/esm/serializer.d.ts +0 -15
  172. package/dist/esm/validators.d.ts +0 -51
  173. package/src/defer.ts +0 -52
  174. package/src/location.ts +0 -13
  175. package/src/manifest.ts +0 -32
  176. package/src/path.ts +0 -427
  177. package/src/qss.ts +0 -91
  178. package/src/root.ts +0 -2
  179. package/src/searchMiddleware.ts +0 -54
  180. package/src/searchParams.ts +0 -77
  181. package/src/serializer.ts +0 -24
  182. 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
- import { exactPathTest, removeTrailingSlash } from './path'
20
+
15
21
  import { useMatch } from './useMatch'
16
- import type { ParsedLocation } from './location'
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 './utils'
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 './path'
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,63 +58,14 @@ import type {
22
58
  MakeRouteMatchUnion,
23
59
  RouteMatch,
24
60
  } from './Matches'
25
- import type { NavigateOptions, ParsePathParams, ToMaskOptions } from './link'
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
- IntersectAssign,
35
- NoInfer,
36
- } from './utils'
37
64
  import type { BuildLocationFn, NavigateFn } from './RouterProvider'
38
65
  import type { NotFoundError } from './not-found'
39
66
  import type { LazyRoute } from './fileRoute'
40
- import type {
41
- AnySchema,
42
- AnyStandardSchemaValidator,
43
- AnyValidator,
44
- AnyValidatorAdapter,
45
- AnyValidatorObj,
46
- DefaultValidator,
47
- ResolveSearchValidatorInput,
48
- ResolveValidatorOutput,
49
- StandardSchemaValidator,
50
- ValidatorAdapter,
51
- ValidatorFn,
52
- ValidatorObj,
53
- } from './validators'
54
- import type { UseRouteContextRoute } from './useRouteContext'
55
-
56
- export type AnyPathParams = {}
57
-
58
- export type SearchSchemaInput = {
59
- __TSearchSchemaInput__: 'TSearchSchemaInput'
60
- }
61
-
62
- export type AnyContext = {}
63
-
64
- export interface RouteContext {}
65
-
66
- export type PreloadableObj = { preload?: () => Promise<void> }
67
-
68
- export type RoutePathOptions<TCustomId, TPath> =
69
- | {
70
- path: TPath
71
- }
72
- | {
73
- id: TCustomId
74
- }
75
67
 
76
- export interface StaticDataRouteOption {}
77
-
78
- export type RoutePathOptionsIntersection<TCustomId, TPath> = {
79
- path: TPath
80
- id: TCustomId
81
- }
68
+ import type { UseRouteContextRoute } from './useRouteContext'
82
69
 
83
70
  export type RouteOptions<
84
71
  TParentRoute extends AnyRoute = AnyRoute,
@@ -119,49 +106,6 @@ export type RouteOptions<
119
106
  NoInfer<TBeforeLoadFn>
120
107
  >
121
108
 
122
- export type ParseSplatParams<TPath extends string> = TPath &
123
- `${string}$` extends never
124
- ? TPath & `${string}$/${string}` extends never
125
- ? never
126
- : '_splat'
127
- : '_splat'
128
-
129
- export interface SplatParams {
130
- _splat?: string
131
- }
132
-
133
- export type ResolveParams<TPath extends string> =
134
- ParseSplatParams<TPath> extends never
135
- ? Record<ParsePathParams<TPath>, string>
136
- : Record<ParsePathParams<TPath>, string> & SplatParams
137
-
138
- export type ParseParamsFn<in out TPath extends string, in out TParams> = (
139
- rawParams: ResolveParams<TPath>,
140
- ) => TParams extends Record<ParsePathParams<TPath>, any>
141
- ? TParams
142
- : Record<ParsePathParams<TPath>, any>
143
-
144
- export type StringifyParamsFn<in out TPath extends string, in out TParams> = (
145
- params: TParams,
146
- ) => ResolveParams<TPath>
147
-
148
- export type ParamsOptions<in out TPath extends string, in out TParams> = {
149
- params?: {
150
- parse?: ParseParamsFn<TPath, TParams>
151
- stringify?: StringifyParamsFn<TPath, TParams>
152
- }
153
-
154
- /**
155
- @deprecated Use params.parse instead
156
- */
157
- parseParams?: ParseParamsFn<TPath, TParams>
158
-
159
- /**
160
- @deprecated Use params.stringify instead
161
- */
162
- stringifyParams?: StringifyParamsFn<TPath, TParams>
163
- }
164
-
165
109
  export interface FullSearchSchemaOption<
166
110
  in out TParentRoute extends AnyRoute,
167
111
  in out TSearchValidator,
@@ -487,51 +431,6 @@ export interface UpdatableRouteOptions<
487
431
  ssr?: boolean
488
432
  }
489
433
 
490
- interface RequiredStaticDataRouteOption {
491
- staticData: StaticDataRouteOption
492
- }
493
-
494
- interface OptionalStaticDataRouteOption {
495
- staticData?: StaticDataRouteOption
496
- }
497
-
498
- export type UpdatableStaticRouteOption = {} extends StaticDataRouteOption
499
- ? OptionalStaticDataRouteOption
500
- : RequiredStaticDataRouteOption
501
-
502
- export type MetaDescriptor =
503
- | { charSet: 'utf-8' }
504
- | { title: string }
505
- | { name: string; content: string }
506
- | { property: string; content: string }
507
- | { httpEquiv: string; content: string }
508
- | { 'script:ld+json': LdJsonObject }
509
- | { tagName: 'meta' | 'link'; [name: string]: string }
510
- | Record<string, unknown>
511
-
512
- type LdJsonObject = { [Key in string]: LdJsonValue } & {
513
- [Key in string]?: LdJsonValue | undefined
514
- }
515
- type LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>
516
- type LdJsonPrimitive = string | number | boolean | null
517
- type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray
518
-
519
- export type RouteLinkEntry = {}
520
-
521
- export type SearchValidator<TInput, TOutput> =
522
- | ValidatorObj<TInput, TOutput>
523
- | ValidatorFn<TInput, TOutput>
524
- | ValidatorAdapter<TInput, TOutput>
525
- | StandardSchemaValidator<TInput, TOutput>
526
- | undefined
527
-
528
- export type AnySearchValidator = SearchValidator<any, any>
529
-
530
- export type DefaultSearchValidator = SearchValidator<
531
- Record<string, unknown>,
532
- AnySchema
533
- >
534
-
535
434
  export type RouteLoaderFn<
536
435
  in out TParentRoute extends AnyRoute = AnyRoute,
537
436
  in out TId extends string = string,
@@ -586,92 +485,6 @@ export interface LoaderFnContext<
586
485
  route: Route
587
486
  }
588
487
 
589
- export type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult
590
-
591
- export type SearchMiddlewareContext<TSearchSchema> = {
592
- search: TSearchSchema
593
- next: (newSearch: TSearchSchema) => TSearchSchema
594
- }
595
-
596
- export type SearchMiddleware<TSearchSchema> = (
597
- ctx: SearchMiddlewareContext<TSearchSchema>,
598
- ) => TSearchSchema
599
-
600
- export type ResolveId<
601
- TParentRoute,
602
- TCustomId extends string,
603
- TPath extends string,
604
- > = TParentRoute extends { id: infer TParentId extends string }
605
- ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>
606
- : RootRouteId
607
-
608
- export type InferFullSearchSchema<TRoute> = TRoute extends {
609
- types: {
610
- fullSearchSchema: infer TFullSearchSchema
611
- }
612
- }
613
- ? TFullSearchSchema
614
- : {}
615
-
616
- export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
617
- types: {
618
- fullSearchSchemaInput: infer TFullSearchSchemaInput
619
- }
620
- }
621
- ? TFullSearchSchemaInput
622
- : {}
623
-
624
- export type InferAllParams<TRoute> = TRoute extends {
625
- types: {
626
- allParams: infer TAllParams
627
- }
628
- }
629
- ? TAllParams
630
- : {}
631
-
632
- export type InferAllContext<TRoute> = unknown extends TRoute
633
- ? TRoute
634
- : TRoute extends {
635
- types: {
636
- allContext: infer TAllContext
637
- }
638
- }
639
- ? TAllContext
640
- : {}
641
-
642
- export type ResolveSearchSchemaFnInput<TSearchValidator> =
643
- TSearchValidator extends (input: infer TSearchSchemaInput) => any
644
- ? TSearchSchemaInput extends SearchSchemaInput
645
- ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>
646
- : ResolveSearchSchemaFn<TSearchValidator>
647
- : AnySchema
648
-
649
- export type ResolveSearchSchemaInput<TSearchValidator> =
650
- TSearchValidator extends AnyStandardSchemaValidator
651
- ? NonNullable<TSearchValidator['~standard']['types']>['input']
652
- : TSearchValidator extends AnyValidatorAdapter
653
- ? TSearchValidator['types']['input']
654
- : TSearchValidator extends AnyValidatorObj
655
- ? ResolveSearchSchemaFnInput<TSearchValidator['parse']>
656
- : ResolveSearchSchemaFnInput<TSearchValidator>
657
-
658
- export type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (
659
- ...args: any
660
- ) => infer TSearchSchema
661
- ? TSearchSchema
662
- : AnySchema
663
-
664
- export type ResolveSearchSchema<TSearchValidator> =
665
- unknown extends TSearchValidator
666
- ? TSearchValidator
667
- : TSearchValidator extends AnyStandardSchemaValidator
668
- ? NonNullable<TSearchValidator['~standard']['types']>['output']
669
- : TSearchValidator extends AnyValidatorAdapter
670
- ? TSearchValidator['types']['output']
671
- : TSearchValidator extends AnyValidatorObj
672
- ? ResolveSearchSchemaFn<TSearchValidator['parse']>
673
- : ResolveSearchSchemaFn<TSearchValidator>
674
-
675
488
  export type ResolveFullSearchSchema<
676
489
  TParentRoute extends AnyRoute,
677
490
  TSearchValidator,
@@ -690,32 +503,6 @@ export type ResolveFullSearchSchemaInput<
690
503
  ResolveSearchValidatorInput<TSearchValidator>
691
504
  >
692
505
 
693
- export type LooseReturnType<T> = T extends (
694
- ...args: Array<any>
695
- ) => infer TReturn
696
- ? TReturn
697
- : never
698
-
699
- export type LooseAsyncReturnType<T> = T extends (
700
- ...args: Array<any>
701
- ) => infer TReturn
702
- ? TReturn extends Promise<infer TReturn>
703
- ? TReturn
704
- : TReturn
705
- : never
706
-
707
- export type ContextReturnType<TContextFn> = unknown extends TContextFn
708
- ? TContextFn
709
- : LooseReturnType<TContextFn> extends never
710
- ? AnyContext
711
- : LooseReturnType<TContextFn>
712
-
713
- export type ContextAsyncReturnType<TContextFn> = unknown extends TContextFn
714
- ? TContextFn
715
- : LooseAsyncReturnType<TContextFn> extends never
716
- ? AnyContext
717
- : LooseAsyncReturnType<TContextFn>
718
-
719
506
  export type RouteContextParameter<
720
507
  TParentRoute extends AnyRoute,
721
508
  TRouterContext,
@@ -723,10 +510,6 @@ export type RouteContextParameter<
723
510
  ? TRouterContext
724
511
  : Assign<TRouterContext, InferAllContext<TParentRoute>>
725
512
 
726
- export type ResolveRouteContext<TRouteContextFn, TBeforeLoadFn> = Assign<
727
- ContextReturnType<TRouteContextFn>,
728
- ContextAsyncReturnType<TBeforeLoadFn>
729
- >
730
513
  export type BeforeLoadContextParameter<
731
514
  TParentRoute extends AnyRoute,
732
515
  TRouterContext,
@@ -746,12 +529,6 @@ export type ResolveAllContext<
746
529
  ContextAsyncReturnType<TBeforeLoadFn>
747
530
  >
748
531
 
749
- export type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn
750
- ? TLoaderFn
751
- : LooseAsyncReturnType<TLoaderFn> extends never
752
- ? {}
753
- : LooseAsyncReturnType<TLoaderFn>
754
-
755
532
  export interface AnyRoute
756
533
  extends Route<
757
534
  any,
@@ -1530,37 +1307,6 @@ export type ResolveFullPath<
1530
1307
  TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,
1531
1308
  > = TPrefixed extends RootRouteId ? '/' : TPrefixed
1532
1309
 
1533
- type RoutePrefix<
1534
- TPrefix extends string,
1535
- TPath extends string,
1536
- > = string extends TPath
1537
- ? RootRouteId
1538
- : TPath extends string
1539
- ? TPrefix extends RootRouteId
1540
- ? TPath extends '/'
1541
- ? '/'
1542
- : `/${TrimPath<TPath>}`
1543
- : `${TPrefix}/${TPath}` extends '/'
1544
- ? '/'
1545
- : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`
1546
- : never
1547
-
1548
- export type TrimPath<T extends string> = '' extends T
1549
- ? ''
1550
- : TrimPathRight<TrimPathLeft<T>>
1551
-
1552
- export type TrimPathLeft<T extends string> =
1553
- T extends `${RootRouteId}/${infer U}`
1554
- ? TrimPathLeft<U>
1555
- : T extends `/${infer U}`
1556
- ? TrimPathLeft<U>
1557
- : T
1558
- export type TrimPathRight<T extends string> = T extends '/'
1559
- ? '/'
1560
- : T extends `${infer U}/`
1561
- ? TrimPathRight<U>
1562
- : T
1563
-
1564
1310
  export type RouteMask<TRouteTree extends AnyRoute> = {
1565
1311
  routeTree: TRouteTree
1566
1312
  from: RoutePaths<TRouteTree>
@@ -1584,26 +1330,6 @@ export function createRouteMask<
1584
1330
  return opts as any
1585
1331
  }
1586
1332
 
1587
- /**
1588
- * @deprecated Use `ErrorComponentProps` instead.
1589
- */
1590
- export type ErrorRouteProps = {
1591
- error: unknown
1592
- info?: { componentStack: string }
1593
- reset: () => void
1594
- }
1595
-
1596
- export type ErrorComponentProps = {
1597
- error: Error
1598
- info?: { componentStack: string }
1599
- reset: () => void
1600
- }
1601
- export type NotFoundRouteProps = {
1602
- // TODO: Make sure this is `| null | undefined` (this is for global not-founds)
1603
- data: unknown
1604
- }
1605
- //
1606
-
1607
1333
  export type ReactNode = any
1608
1334
 
1609
1335
  export type SyncRouteComponent<TProps> =
package/src/routeInfo.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  import type { InferFileRouteTypes } from './fileRoute'
2
- import type { AddTrailingSlash, RemoveTrailingSlashes } from './link'
2
+ import type {
3
+ AddTrailingSlash,
4
+ PartialMergeAll,
5
+ RemoveTrailingSlashes,
6
+ TrailingSlashOption,
7
+ } from '@tanstack/router-core'
3
8
  import type { AnyRoute } from './route'
4
- import type { AnyRouter, TrailingSlashOption } from './router'
5
- import type { PartialMergeAll } from './utils'
9
+ import type { AnyRouter } from './router'
6
10
 
7
11
  export type ParseRoute<TRouteTree, TAcc = TRouteTree> = TRouteTree extends {
8
12
  types: { children: infer TChildren }