@tanstack/react-router 1.97.20 → 1.97.23

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 +52 -71
  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 +2 -21
  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 +33 -53
  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/router.ts CHANGED
@@ -5,30 +5,28 @@ import {
5
5
  } from '@tanstack/history'
6
6
  import { Store, batch } from '@tanstack/react-store'
7
7
  import invariant from 'tiny-invariant'
8
- import { rootRouteId } from './root'
9
- import { defaultParseSearch, defaultStringifySearch } from './searchParams'
10
8
  import {
9
+ cleanPath,
11
10
  createControlledPromise,
12
11
  deepEqual,
12
+ defaultParseSearch,
13
+ defaultStringifySearch,
13
14
  functionalUpdate,
14
- last,
15
- pick,
16
- replaceEqualDeep,
17
- } from './utils'
18
- import {
19
- cleanPath,
20
15
  interpolatePath,
21
16
  joinPaths,
17
+ last,
22
18
  matchPathname,
23
19
  parsePathname,
20
+ pick,
21
+ replaceEqualDeep,
24
22
  resolvePath,
23
+ rootRouteId,
25
24
  trimPath,
26
25
  trimPathLeft,
27
26
  trimPathRight,
28
- } from './path'
27
+ } from '@tanstack/router-core'
29
28
  import { isRedirect, isResolvedRedirect } from './redirects'
30
29
  import { isNotFound } from './not-found'
31
- import type { StartSerializer } from './serializer'
32
30
  import type * as React from 'react'
33
31
  import type {
34
32
  HistoryLocation,
@@ -37,9 +35,27 @@ import type {
37
35
  RouterHistory,
38
36
  } from '@tanstack/history'
39
37
  import type { NoInfer } from '@tanstack/react-store'
40
- import type { Manifest } from './manifest'
38
+
41
39
  import type {
42
40
  AnyContext,
41
+ AnySchema,
42
+ AnyValidator,
43
+ CommitLocationOptions,
44
+ ControlledPromise,
45
+ Manifest,
46
+ NonNullableUpdater,
47
+ ParsedLocation,
48
+ PickAsRequired,
49
+ ResolveRelativePath,
50
+ SearchMiddleware,
51
+ SearchParser,
52
+ SearchSerializer,
53
+ StartSerializer,
54
+ TrailingSlashOption,
55
+ Updater,
56
+ ViewTransitionOptions,
57
+ } from '@tanstack/router-core'
58
+ import type {
43
59
  AnyRoute,
44
60
  AnyRouteWithContext,
45
61
  BeforeLoadContextOptions,
@@ -50,8 +66,8 @@ import type {
50
66
  RouteComponent,
51
67
  RouteContextOptions,
52
68
  RouteMask,
53
- SearchMiddleware,
54
69
  } from './route'
70
+
55
71
  import type {
56
72
  FullSearchSchema,
57
73
  RouteById,
@@ -59,29 +75,18 @@ import type {
59
75
  RoutesById,
60
76
  RoutesByPath,
61
77
  } from './routeInfo'
62
- import type {
63
- ControlledPromise,
64
- NonNullableUpdater,
65
- PickAsRequired,
66
- Updater,
67
- } from './utils'
68
78
  import type {
69
79
  AnyRouteMatch,
70
80
  MakeRouteMatch,
71
81
  MakeRouteMatchUnion,
72
82
  MatchRouteOptions,
73
83
  } from './Matches'
74
- import type { ParsedLocation } from './location'
75
- import type { SearchParser, SearchSerializer } from './searchParams'
76
- import type {
77
- BuildLocationFn,
78
- CommitLocationOptions,
79
- NavigateFn,
80
- } from './RouterProvider'
84
+
85
+ import type { BuildLocationFn, NavigateFn } from './RouterProvider'
86
+
81
87
  import type { AnyRedirect, ResolvedRedirect } from './redirects'
82
88
  import type { NotFoundError } from './not-found'
83
- import type { NavigateOptions, ResolveRelativePath, ToOptions } from './link'
84
- import type { AnySchema, AnyValidator } from './validators'
89
+ import type { NavigateOptions, ToOptions } from './link'
85
90
 
86
91
  declare global {
87
92
  interface Window {
@@ -137,8 +142,6 @@ export type RouterContextOptions<TRouteTree extends AnyRoute> =
137
142
  context: InferRouterContext<TRouteTree>
138
143
  }
139
144
 
140
- export type TrailingSlashOption = 'always' | 'never' | 'preserve'
141
-
142
145
  export type InjectedHtmlEntry = Promise<string>
143
146
 
144
147
  export interface RouterOptions<
@@ -498,10 +501,6 @@ export interface MatchedRoutesResult {
498
501
  routeParams: Record<string, string>
499
502
  }
500
503
 
501
- export interface ViewTransitionOptions {
502
- types: Array<string>
503
- }
504
-
505
504
  export type RouterConstructorOptions<
506
505
  TRouteTree extends AnyRoute,
507
506
  TTrailingSlashOption extends TrailingSlashOption,
@@ -733,7 +732,7 @@ export class Router<
733
732
  ) => {
734
733
  if (newOptions.notFoundRoute) {
735
734
  console.warn(
736
- 'The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.',
735
+ 'The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info.',
737
736
  )
738
737
  }
739
738
 
@@ -3029,22 +3028,3 @@ export function getInitialRouterState(
3029
3028
  statusCode: 200,
3030
3029
  }
3031
3030
  }
3032
-
3033
- export function defaultSerializeError(err: unknown) {
3034
- if (err instanceof Error) {
3035
- const obj = {
3036
- name: err.name,
3037
- message: err.message,
3038
- }
3039
-
3040
- if (process.env.NODE_ENV === 'development') {
3041
- ;(obj as any).stack = err.stack
3042
- }
3043
-
3044
- return obj
3045
- }
3046
-
3047
- return {
3048
- data: err,
3049
- }
3050
- }
@@ -1,8 +1,7 @@
1
1
  import * as React from 'react'
2
+ import { functionalUpdate } from '@tanstack/router-core'
2
3
  import { useRouter } from './useRouter'
3
- import { functionalUpdate } from './utils'
4
- import type { ParsedLocation } from './location'
5
- import type { NonNullableUpdater } from './utils'
4
+ import type { NonNullableUpdater, ParsedLocation } from '@tanstack/router-core'
6
5
 
7
6
  const useLayoutEffect =
8
7
  typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect
@@ -1,4 +1,8 @@
1
- import type { Constrain, ValidateJSON } from './utils'
1
+ import type {
2
+ Constrain,
3
+ OptionalStructuralSharing,
4
+ ValidateJSON,
5
+ } from '@tanstack/router-core'
2
6
  import type { AnyRouter } from './router'
3
7
 
4
8
  export type DefaultStructuralSharingEnabled<TRouter extends AnyRouter> =
@@ -8,12 +12,6 @@ export type DefaultStructuralSharingEnabled<TRouter extends AnyRouter> =
8
12
  false
9
13
  : NonNullable<TRouter['options']['defaultStructuralSharing']>
10
14
 
11
- export interface OptionalStructuralSharing<TStructuralSharing, TConstraint> {
12
- readonly structuralSharing?:
13
- | Constrain<TStructuralSharing, TConstraint>
14
- | undefined
15
- }
16
-
17
15
  export interface RequiredStructuralSharing<TStructuralSharing, TConstraint> {
18
16
  readonly structuralSharing: Constrain<TStructuralSharing, TConstraint>
19
17
  }
@@ -10,7 +10,7 @@ import type { RouteIds } from './routeInfo'
10
10
  import type { AnyRouter, RegisteredRouter } from './router'
11
11
  import type { UseParamsOptions, UseParamsResult } from './useParams'
12
12
  import type { UseSearchOptions, UseSearchResult } from './useSearch'
13
- import type { Constrain, ConstrainLiteral } from './utils'
13
+ import type { Constrain, ConstrainLiteral } from '@tanstack/router-core'
14
14
 
15
15
  export type ValidateFromPath<
16
16
  TFrom,
@@ -5,7 +5,8 @@ import type {
5
5
  } from './structuralSharing'
6
6
  import type { AnyRouter, RegisteredRouter } from './router'
7
7
  import type { AllLoaderData, RouteById } from './routeInfo'
8
- import type { Expand, StrictOrFrom } from './utils'
8
+ import type { StrictOrFrom } from './utils'
9
+ import type { Expand } from '@tanstack/router-core'
9
10
 
10
11
  export interface UseLoaderDataBaseOptions<
11
12
  TRouter extends AnyRouter,
@@ -5,7 +5,8 @@ import type {
5
5
  } from './structuralSharing'
6
6
  import type { AnyRouter, RegisteredRouter } from './router'
7
7
  import type { RouteById } from './routeInfo'
8
- import type { Expand, StrictOrFrom } from './utils'
8
+ import type { StrictOrFrom } from './utils'
9
+ import type { Expand } from '@tanstack/router-core'
9
10
 
10
11
  export interface UseLoaderDepsBaseOptions<
11
12
  TRouter extends AnyRouter,
package/src/useMatch.tsx CHANGED
@@ -8,7 +8,8 @@ import type {
8
8
  } from './structuralSharing'
9
9
  import type { AnyRouter, RegisteredRouter } from './router'
10
10
  import type { MakeRouteMatch, MakeRouteMatchUnion } from './Matches'
11
- import type { StrictOrFrom, ThrowOrOptional } from './utils'
11
+ import type { StrictOrFrom } from './utils'
12
+ import type { ThrowOrOptional } from '@tanstack/router-core'
12
13
 
13
14
  export interface UseMatchBaseOptions<
14
15
  TRouter extends AnyRouter,
package/src/useParams.tsx CHANGED
@@ -5,7 +5,8 @@ import type {
5
5
  } from './structuralSharing'
6
6
  import type { AllParams, RouteById } from './routeInfo'
7
7
  import type { AnyRouter, RegisteredRouter } from './router'
8
- import type { Expand, StrictOrFrom } from './utils'
8
+ import type { StrictOrFrom } from './utils'
9
+ import type { Expand } from '@tanstack/router-core'
9
10
 
10
11
  export interface UseParamsBaseOptions<
11
12
  TRouter extends AnyRouter,
@@ -1,7 +1,8 @@
1
1
  import { useMatch } from './useMatch'
2
2
  import type { AllContext, RouteById } from './routeInfo'
3
3
  import type { AnyRouter, RegisteredRouter } from './router'
4
- import type { Expand, StrictOrFrom } from './utils'
4
+ import type { StrictOrFrom } from './utils'
5
+ import type { Expand } from '@tanstack/router-core'
5
6
 
6
7
  export interface UseRouteContextBaseOptions<
7
8
  TRouter extends AnyRouter,
@@ -1,7 +1,7 @@
1
1
  import { useStore } from '@tanstack/react-store'
2
2
  import { useRef } from 'react'
3
+ import { replaceEqualDeep } from '@tanstack/router-core'
3
4
  import { useRouter } from './useRouter'
4
- import { replaceEqualDeep } from './utils'
5
5
  import type {
6
6
  StructuralSharingOption,
7
7
  ValidateSelected,
package/src/useSearch.tsx CHANGED
@@ -5,7 +5,8 @@ import type {
5
5
  } from './structuralSharing'
6
6
  import type { FullSearchSchema, RouteById } from './routeInfo'
7
7
  import type { AnyRouter, RegisteredRouter } from './router'
8
- import type { Expand, StrictOrFrom } from './utils'
8
+ import type { StrictOrFrom } from './utils'
9
+ import type { Expand } from '@tanstack/router-core'
9
10
 
10
11
  export interface UseSearchBaseOptions<
11
12
  TRouter extends AnyRouter,