@tanstack/solid-router 1.112.11 → 1.112.12

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 (184) hide show
  1. package/dist/cjs/Match.cjs.map +1 -1
  2. package/dist/cjs/Matches.cjs.map +1 -1
  3. package/dist/cjs/Matches.d.cts +1 -8
  4. package/dist/cjs/RouterProvider.cjs.map +1 -1
  5. package/dist/cjs/RouterProvider.d.cts +4 -4
  6. package/dist/cjs/Transitioner.cjs +1 -1
  7. package/dist/cjs/Transitioner.cjs.map +1 -1
  8. package/dist/cjs/fileRoute.cjs.map +1 -1
  9. package/dist/cjs/fileRoute.d.cts +4 -7
  10. package/dist/cjs/index.d.cts +3 -5
  11. package/dist/cjs/link.cjs.map +1 -1
  12. package/dist/cjs/link.d.cts +1 -2
  13. package/dist/cjs/not-found.cjs.map +1 -1
  14. package/dist/cjs/not-found.d.cts +1 -2
  15. package/dist/cjs/redirects.cjs.map +1 -1
  16. package/dist/cjs/redirects.d.cts +1 -2
  17. package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
  18. package/dist/cjs/renderRouteNotFound.d.cts +1 -2
  19. package/dist/cjs/route.cjs +15 -23
  20. package/dist/cjs/route.cjs.map +1 -1
  21. package/dist/cjs/route.d.cts +19 -50
  22. package/dist/cjs/router.cjs +18 -20
  23. package/dist/cjs/router.cjs.map +1 -1
  24. package/dist/cjs/router.d.cts +84 -454
  25. package/dist/cjs/routerContext.cjs.map +1 -1
  26. package/dist/cjs/routerContext.d.cts +2 -2
  27. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  28. package/dist/cjs/scroll-restoration.d.cts +1 -2
  29. package/dist/cjs/typePrimitives.d.cts +1 -2
  30. package/dist/cjs/useBlocker.cjs.map +1 -1
  31. package/dist/cjs/useBlocker.d.cts +2 -3
  32. package/dist/cjs/useLoaderData.cjs.map +1 -1
  33. package/dist/cjs/useLoaderData.d.cts +1 -3
  34. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  35. package/dist/cjs/useLoaderDeps.d.cts +1 -3
  36. package/dist/cjs/useLocation.cjs.map +1 -1
  37. package/dist/cjs/useLocation.d.cts +1 -1
  38. package/dist/cjs/useMatch.cjs.map +1 -1
  39. package/dist/cjs/useMatch.d.cts +1 -3
  40. package/dist/cjs/useNavigate.cjs.map +1 -1
  41. package/dist/cjs/useNavigate.d.cts +1 -2
  42. package/dist/cjs/useParams.cjs.map +1 -1
  43. package/dist/cjs/useParams.d.cts +1 -3
  44. package/dist/cjs/useRouteContext.cjs.map +1 -1
  45. package/dist/cjs/useRouteContext.d.cts +1 -2
  46. package/dist/cjs/useRouter.cjs.map +1 -1
  47. package/dist/cjs/useRouter.d.cts +1 -1
  48. package/dist/cjs/useRouterState.cjs.map +1 -1
  49. package/dist/cjs/useRouterState.d.cts +1 -1
  50. package/dist/cjs/useSearch.cjs.map +1 -1
  51. package/dist/cjs/useSearch.d.cts +1 -3
  52. package/dist/cjs/utils.cjs.map +1 -1
  53. package/dist/cjs/utils.d.cts +0 -9
  54. package/dist/esm/Match.js.map +1 -1
  55. package/dist/esm/Matches.d.ts +1 -8
  56. package/dist/esm/Matches.js.map +1 -1
  57. package/dist/esm/RouterProvider.d.ts +4 -4
  58. package/dist/esm/RouterProvider.js.map +1 -1
  59. package/dist/esm/Transitioner.js +1 -1
  60. package/dist/esm/Transitioner.js.map +1 -1
  61. package/dist/esm/fileRoute.d.ts +4 -7
  62. package/dist/esm/fileRoute.js.map +1 -1
  63. package/dist/esm/index.d.ts +3 -5
  64. package/dist/esm/link.d.ts +1 -2
  65. package/dist/esm/link.js.map +1 -1
  66. package/dist/esm/not-found.d.ts +1 -2
  67. package/dist/esm/not-found.js.map +1 -1
  68. package/dist/esm/redirects.d.ts +1 -2
  69. package/dist/esm/redirects.js.map +1 -1
  70. package/dist/esm/renderRouteNotFound.d.ts +1 -2
  71. package/dist/esm/renderRouteNotFound.js.map +1 -1
  72. package/dist/esm/route.d.ts +19 -50
  73. package/dist/esm/route.js +15 -23
  74. package/dist/esm/route.js.map +1 -1
  75. package/dist/esm/router.d.ts +84 -454
  76. package/dist/esm/router.js +18 -20
  77. package/dist/esm/router.js.map +1 -1
  78. package/dist/esm/routerContext.d.ts +2 -2
  79. package/dist/esm/routerContext.js.map +1 -1
  80. package/dist/esm/scroll-restoration.d.ts +1 -2
  81. package/dist/esm/scroll-restoration.js.map +1 -1
  82. package/dist/esm/typePrimitives.d.ts +1 -2
  83. package/dist/esm/useBlocker.d.ts +2 -3
  84. package/dist/esm/useBlocker.js.map +1 -1
  85. package/dist/esm/useLoaderData.d.ts +1 -3
  86. package/dist/esm/useLoaderData.js.map +1 -1
  87. package/dist/esm/useLoaderDeps.d.ts +1 -3
  88. package/dist/esm/useLoaderDeps.js.map +1 -1
  89. package/dist/esm/useLocation.d.ts +1 -1
  90. package/dist/esm/useLocation.js.map +1 -1
  91. package/dist/esm/useMatch.d.ts +1 -3
  92. package/dist/esm/useMatch.js.map +1 -1
  93. package/dist/esm/useNavigate.d.ts +1 -2
  94. package/dist/esm/useNavigate.js.map +1 -1
  95. package/dist/esm/useParams.d.ts +1 -3
  96. package/dist/esm/useParams.js.map +1 -1
  97. package/dist/esm/useRouteContext.d.ts +1 -2
  98. package/dist/esm/useRouteContext.js.map +1 -1
  99. package/dist/esm/useRouter.d.ts +1 -1
  100. package/dist/esm/useRouter.js.map +1 -1
  101. package/dist/esm/useRouterState.d.ts +1 -1
  102. package/dist/esm/useRouterState.js.map +1 -1
  103. package/dist/esm/useSearch.d.ts +1 -3
  104. package/dist/esm/useSearch.js.map +1 -1
  105. package/dist/esm/utils.d.ts +0 -9
  106. package/dist/esm/utils.js.map +1 -1
  107. package/dist/source/Matches.d.ts +1 -8
  108. package/dist/source/Matches.jsx.map +1 -1
  109. package/dist/source/RouterProvider.d.ts +4 -4
  110. package/dist/source/RouterProvider.jsx.map +1 -1
  111. package/dist/source/Transitioner.jsx +1 -1
  112. package/dist/source/Transitioner.jsx.map +1 -1
  113. package/dist/source/fileRoute.d.ts +4 -7
  114. package/dist/source/fileRoute.js.map +1 -1
  115. package/dist/source/index.d.ts +3 -5
  116. package/dist/source/index.jsx.map +1 -1
  117. package/dist/source/link.d.ts +1 -2
  118. package/dist/source/link.jsx.map +1 -1
  119. package/dist/source/not-found.d.ts +1 -2
  120. package/dist/source/not-found.jsx.map +1 -1
  121. package/dist/source/redirects.d.ts +1 -2
  122. package/dist/source/renderRouteNotFound.d.ts +1 -2
  123. package/dist/source/renderRouteNotFound.jsx.map +1 -1
  124. package/dist/source/route.d.ts +19 -50
  125. package/dist/source/route.js +15 -23
  126. package/dist/source/route.js.map +1 -1
  127. package/dist/source/router.d.ts +83 -454
  128. package/dist/source/router.js +23 -14
  129. package/dist/source/router.js.map +1 -1
  130. package/dist/source/routerContext.d.ts +2 -2
  131. package/dist/source/routerContext.jsx.map +1 -1
  132. package/dist/source/scroll-restoration.d.ts +1 -2
  133. package/dist/source/scroll-restoration.jsx.map +1 -1
  134. package/dist/source/typePrimitives.d.ts +1 -2
  135. package/dist/source/useBlocker.d.ts +2 -3
  136. package/dist/source/useBlocker.jsx.map +1 -1
  137. package/dist/source/useLoaderData.d.ts +1 -3
  138. package/dist/source/useLoaderData.jsx.map +1 -1
  139. package/dist/source/useLoaderDeps.d.ts +1 -3
  140. package/dist/source/useLoaderDeps.jsx.map +1 -1
  141. package/dist/source/useLocation.d.ts +1 -1
  142. package/dist/source/useLocation.jsx.map +1 -1
  143. package/dist/source/useMatch.d.ts +1 -3
  144. package/dist/source/useMatch.jsx.map +1 -1
  145. package/dist/source/useNavigate.d.ts +1 -2
  146. package/dist/source/useNavigate.jsx.map +1 -1
  147. package/dist/source/useParams.d.ts +1 -3
  148. package/dist/source/useParams.jsx.map +1 -1
  149. package/dist/source/useRouteContext.d.ts +1 -2
  150. package/dist/source/useRouter.d.ts +1 -1
  151. package/dist/source/useRouterState.d.ts +1 -1
  152. package/dist/source/useRouterState.jsx.map +1 -1
  153. package/dist/source/useSearch.d.ts +1 -3
  154. package/dist/source/useSearch.jsx.map +1 -1
  155. package/dist/source/utils.d.ts +1 -10
  156. package/dist/source/utils.js.map +1 -1
  157. package/package.json +3 -3
  158. package/src/Match.tsx +1 -1
  159. package/src/Matches.tsx +4 -8
  160. package/src/RouterProvider.tsx +4 -7
  161. package/src/Transitioner.tsx +1 -1
  162. package/src/fileRoute.ts +9 -25
  163. package/src/index.tsx +22 -28
  164. package/src/link.tsx +2 -1
  165. package/src/not-found.tsx +1 -2
  166. package/src/redirects.ts +1 -1
  167. package/src/renderRouteNotFound.tsx +1 -2
  168. package/src/route.ts +93 -222
  169. package/src/router.ts +146 -591
  170. package/src/routerContext.tsx +3 -3
  171. package/src/scroll-restoration.tsx +6 -2
  172. package/src/typePrimitives.ts +2 -1
  173. package/src/useBlocker.tsx +7 -3
  174. package/src/useLoaderData.tsx +3 -2
  175. package/src/useLoaderDeps.tsx +3 -2
  176. package/src/useLocation.tsx +5 -1
  177. package/src/useMatch.tsx +3 -2
  178. package/src/useNavigate.tsx +2 -1
  179. package/src/useParams.tsx +3 -2
  180. package/src/useRouteContext.ts +2 -2
  181. package/src/useRouter.tsx +1 -1
  182. package/src/useRouterState.tsx +5 -1
  183. package/src/useSearch.tsx +3 -2
  184. package/src/utils.ts +0 -16
package/src/router.ts CHANGED
@@ -30,495 +30,132 @@ import { isRedirect, isResolvedRedirect } from './redirects'
30
30
  import { isNotFound } from './not-found'
31
31
  import { setupScrollRestoration } from './scroll-restoration'
32
32
  import type * as Solid from 'solid-js'
33
- import type {
34
- HistoryLocation,
35
- HistoryState,
36
- ParsedHistoryState,
37
- RouterHistory,
38
- } from '@tanstack/history'
39
- import type { NoInfer } from '@tanstack/solid-store'
33
+ import type { HistoryLocation, RouterHistory } from '@tanstack/history'
40
34
 
41
35
  import type {
42
- AnyContext,
43
36
  AnyRedirect,
37
+ AnyRoute,
44
38
  AnyRouteMatch,
39
+ AnyRouter,
45
40
  AnySchema,
46
41
  AnyValidator,
47
42
  BeforeLoadContextOptions,
48
43
  BuildLocationFn,
44
+ BuildNextOptions,
45
+ ClearCacheFn,
46
+ CommitLocationFn,
49
47
  CommitLocationOptions,
50
48
  ControlledPromise,
49
+ Router as CoreRouter,
50
+ EmitFn,
51
51
  FullSearchSchema,
52
+ GetMatchFn,
53
+ GetMatchRoutesFn,
54
+ InjectedHtmlEntry,
55
+ InvalidateFn,
56
+ LoadFn,
52
57
  LoaderFnContext,
53
- MakeRemountDepsOptionsUnion,
54
58
  MakeRouteMatch,
55
59
  MakeRouteMatchUnion,
56
60
  Manifest,
61
+ MatchRouteFn,
62
+ MatchRoutesFn,
63
+ MatchRoutesOpts,
64
+ MatchedRoutesResult,
57
65
  NavigateFn,
58
- NavigateOptions,
59
- NonNullableUpdater,
66
+ ParseLocationFn,
60
67
  ParsedLocation,
61
68
  PickAsRequired,
62
- Register,
63
- ResolveRelativePath,
69
+ PreloadRouteFn,
64
70
  ResolvedRedirect,
65
- RouteById,
66
71
  RouteContextOptions,
67
- RoutePaths,
72
+ RouterConstructorOptions,
73
+ RouterEvent,
74
+ RouterListener,
75
+ RouterOptions,
76
+ RouterState,
68
77
  RoutesById,
69
78
  RoutesByPath,
70
79
  SearchMiddleware,
71
- SearchParser,
72
- SearchSerializer,
73
80
  StartSerializer,
74
- ToOptions,
81
+ StartTransitionFn,
82
+ SubscribeFn,
75
83
  TrailingSlashOption,
76
- Updater,
84
+ UpdateFn,
85
+ UpdateMatchFn,
77
86
  ViewTransitionOptions,
78
87
  } from '@tanstack/router-core'
79
88
  import type {
80
- AnyRoute,
81
89
  ErrorRouteComponent,
82
90
  NotFoundRouteComponent,
83
- RootRoute,
84
91
  RouteComponent,
85
- RouteMask,
86
92
  } from './route'
87
- import type { MatchRouteOptions } from './Matches'
88
-
89
93
  import type { NotFoundError } from './not-found'
90
94
 
91
- declare global {
92
- interface Window {
93
- __TSR_ROUTER__?: AnyRouter
94
- }
95
- }
96
-
97
- export type AnyRouter = Router<any, any, any, any, any>
98
-
99
- export type RegisteredRouter = Register extends {
100
- router: infer TRouter extends AnyRouter
101
- }
102
- ? TRouter
103
- : AnyRouter
104
-
105
- export type InferRouterContext<TRouteTree extends AnyRoute> =
106
- TRouteTree extends RootRoute<
107
- any,
108
- infer TRouterContext extends AnyContext,
109
- any,
110
- any,
111
- any,
112
- any,
113
- any,
114
- any
115
- >
116
- ? TRouterContext
117
- : AnyContext
118
-
119
- export type ControllablePromise<T = any> = Promise<T> & {
120
- resolve: (value: T) => void
121
- reject: (value?: any) => void
122
- }
123
-
124
- export type RouterContextOptions<TRouteTree extends AnyRoute> =
125
- AnyContext extends InferRouterContext<TRouteTree>
126
- ? {
127
- context?: InferRouterContext<TRouteTree>
128
- }
129
- : {
130
- context: InferRouterContext<TRouteTree>
131
- }
132
-
133
- export type InjectedHtmlEntry = Promise<string>
134
-
135
- export interface RouterOptions<
136
- TRouteTree extends AnyRoute,
137
- TTrailingSlashOption extends TrailingSlashOption,
138
- TRouterHistory extends RouterHistory = RouterHistory,
139
- TDehydrated extends Record<string, any> = Record<string, any>,
140
- > {
141
- /**
142
- * The history object that will be used to manage the browser history.
143
- *
144
- * If not provided, a new createBrowserHistory instance will be created and used.
145
- *
146
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)
147
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)
148
- */
149
- history?: TRouterHistory
150
- /**
151
- * A function that will be used to stringify search params when generating links.
152
- *
153
- * @default defaultStringifySearch
154
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#stringifysearch-method)
155
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
156
- */
157
- stringifySearch?: SearchSerializer
158
- /**
159
- * A function that will be used to parse search params when parsing the current location.
160
- *
161
- * @default defaultParseSearch
162
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#parsesearch-method)
163
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
164
- */
165
- parseSearch?: SearchParser
166
- /**
167
- * If `false`, routes will not be preloaded by default in any way.
168
- *
169
- * If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a `<Link>`.
170
- *
171
- * If `'viewport'`, routes will be preloaded by default when they are within the viewport.
172
- *
173
- * @default false
174
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreload-property)
175
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
176
- */
177
- defaultPreload?: false | 'intent' | 'viewport' | 'render'
178
- /**
179
- * The delay in milliseconds that a route must be hovered over or touched before it is preloaded.
180
- *
181
- * @default 50
182
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloaddelay-property)
183
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay)
184
- */
185
- defaultPreloadDelay?: number
186
- /**
187
- * The default `component` a route should use if no component is provided.
188
- *
189
- * @default Outlet
190
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
191
- */
192
- defaultComponent?: RouteComponent
193
- /**
194
- * The default `errorComponent` a route should use if no error component is provided.
195
- *
196
- * @default ErrorComponent
197
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
198
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
199
- */
200
- defaultErrorComponent?: ErrorRouteComponent
201
- /**
202
- * The default `pendingComponent` a route should use if no pending component is provided.
203
- *
204
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)
205
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
206
- */
207
- defaultPendingComponent?: RouteComponent
208
- /**
209
- * The default `pendingMs` a route should use if no pendingMs is provided.
210
- *
211
- * @default 1000
212
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingms-property)
213
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
214
- */
215
- defaultPendingMs?: number
216
- /**
217
- * The default `pendingMinMs` a route should use if no pendingMinMs is provided.
218
- *
219
- * @default 500
220
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingminms-property)
221
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
222
- */
223
- defaultPendingMinMs?: number
224
- /**
225
- * The default `staleTime` a route should use if no staleTime is provided. This is the time in milliseconds that a route will be considered fresh.
226
- *
227
- * @default 0
228
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstaletime-property)
229
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
230
- */
231
- defaultStaleTime?: number
232
- /**
233
- * The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.
234
- *
235
- * @default 30_000 `(30 seconds)`
236
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadstaletime-property)
237
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
238
- */
239
- defaultPreloadStaleTime?: number
240
- /**
241
- * The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.
242
- *
243
- * @default 1_800_000 `(30 minutes)`
244
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadgctime-property)
245
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
246
- */
247
- defaultPreloadGcTime?: number
248
- /**
249
- * The default `onCatch` handler for errors caught by the Router ErrorBoundary
250
- *
251
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
252
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
253
- */
254
- defaultOnCatch?: (error: Error) => void
255
- /**
256
- * If `true`, route navigations will called using `document.startViewTransition()`.
257
- *
258
- * If the browser does not support this api, this option will be ignored.
259
- *
260
- * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for more information on how this function works.
261
- *
262
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultviewtransition-property)
263
- */
264
- defaultViewTransition?: boolean | ViewTransitionOptions
265
- /**
266
- * The default `hashScrollIntoView` a route should use if no hashScrollIntoView is provided while navigating
267
- *
268
- * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) for more information on `ScrollIntoViewOptions`.
269
- *
270
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulthashscrollintoview-property)
271
- */
272
- defaultHashScrollIntoView?: boolean | ScrollIntoViewOptions
273
- /**
274
- * @default 'fuzzy'
275
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundmode-property)
276
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#the-notfoundmode-option)
277
- */
278
- notFoundMode?: 'root' | 'fuzzy'
279
- /**
280
- * The default `gcTime` a route should use if no gcTime is provided.
281
- *
282
- * @default 1_800_000 `(30 minutes)`
283
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultgctime-property)
284
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
285
- */
286
- defaultGcTime?: number
287
- /**
288
- * If `true`, all routes will be matched as case-sensitive.
289
- *
290
- * @default false
291
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)
292
- */
293
- caseSensitive?: boolean
294
- /**
295
- *
296
- * The route tree that will be used to configure the router instance.
297
- *
298
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)
299
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/routing/route-trees)
300
- */
301
- routeTree?: TRouteTree
302
- /**
303
- * The basepath for then entire router. This is useful for mounting a router instance at a subpath.
304
- *
305
- * @default '/'
306
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)
307
- */
308
- basepath?: string
309
- /**
310
- * The root context that will be provided to all routes in the route tree.
311
- *
312
- * This can be used to provide a context to all routes in the tree without having to provide it to each route individually.
313
- *
314
- * Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).
315
- *
316
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#context-property)
317
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)
318
- */
319
- context?: InferRouterContext<TRouteTree>
320
- /**
321
- * A function that will be called when the router is dehydrated.
322
- *
323
- * The return value of this function will be serialized and stored in the router's dehydrated state.
324
- *
325
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)
326
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
327
- */
328
- dehydrate?: () => TDehydrated
329
- /**
330
- * A function that will be called when the router is hydrated.
331
- *
332
- * The return value of this function will be serialized and stored in the router's dehydrated state.
333
- *
334
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#hydrate-method)
335
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
336
- */
337
- hydrate?: (dehydrated: TDehydrated) => void
338
- /**
339
- * An array of route masks that will be used to mask routes in the route tree.
340
- *
341
- * Route masking is when you display a route at a different path than the one it is configured to match, like a modal popup that when shared will unmask to the modal's content instead of the modal's context.
342
- *
343
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routemasks-property)
344
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking)
345
- */
346
- routeMasks?: Array<RouteMask<TRouteTree>>
347
- /**
348
- * If `true`, route masks will, by default, be removed when the page is reloaded.
349
- *
350
- * This can be overridden on a per-mask basis by setting the `unmaskOnReload` option on the mask, or on a per-navigation basis by setting the `unmaskOnReload` option in the `Navigate` options.
351
- *
352
- * @default false
353
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#unmaskonreload-property)
354
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking#unmasking-on-page-reload)
355
- */
356
- unmaskOnReload?: boolean
357
- /**
358
- * A component that will be used to wrap the entire router.
359
- *
360
- * This is useful for providing a context to the entire router.
361
- *
362
- * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
363
- *
364
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
365
- */
366
- Wrap?: (props: { children: any }) => Solid.JSX.Element
367
- /**
368
- * A component that will be used to wrap the inner contents of the router.
369
- *
370
- * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.
371
- *
372
- * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
373
- *
374
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
375
- */
376
- InnerWrap?: (props: { children: any }) => Solid.JSX.Element
377
- /**
378
- * Use `notFoundComponent` instead.
379
- *
380
- * @deprecated
381
- * See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.
382
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundroute-property)
383
- */
384
- notFoundRoute?: AnyRoute
385
- /**
386
- * The default `notFoundComponent` a route should use if no notFound component is provided.
387
- *
388
- * @default NotFound
389
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
390
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
391
- */
392
- defaultNotFoundComponent?: NotFoundRouteComponent
393
- /**
394
- * Configures how trailing slashes are treated.
395
- *
396
- * - `'always'` will add a trailing slash if not present
397
- * - `'never'` will remove the trailing slash if present
398
- * - `'preserve'` will not modify the trailing slash.
399
- *
400
- * @default 'never'
401
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)
402
- */
403
- trailingSlash?: TTrailingSlashOption
404
- /**
405
- * While usually automatic, sometimes it can be useful to force the router into a server-side state, e.g. when using the router in a non-browser environment that has access to a global.document object.
406
- *
407
- * @default typeof document !== 'undefined'
408
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#isserver-property)
409
- */
410
- isServer?: boolean
411
-
412
- defaultSsr?: boolean
413
-
414
- search?: {
95
+ declare module '@tanstack/router-core' {
96
+ export interface RouterOptionsExtensions {
415
97
  /**
416
- * Configures how unknown search params (= not returned by any `validateSearch`) are treated.
98
+ * A component that will be used to wrap the entire router.
417
99
  *
418
- * @default false
419
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#search.strict-property)
100
+ * This is useful for providing a context to the entire router.
101
+ *
102
+ * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
103
+ *
104
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
420
105
  */
421
- strict?: boolean
422
- }
423
-
424
- /**
425
- * Configures which URI characters are allowed in path params that would ordinarily be escaped by encodeURIComponent.
426
- *
427
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#pathparamsallowedcharacters-property)
428
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/path-params#allowed-characters)
429
- */
430
- pathParamsAllowedCharacters?: Array<
431
- ';' | ':' | '@' | '&' | '=' | '+' | '$' | ','
432
- >
433
-
434
- defaultRemountDeps?: (opts: MakeRemountDepsOptionsUnion<TRouteTree>) => any
435
-
436
- /**
437
- * If `true`, scroll restoration will be enabled
438
- *
439
- * @default false
440
- */
441
- scrollRestoration?: boolean
442
-
443
- /**
444
- * A function that will be called to get the key for the scroll restoration cache.
445
- *
446
- * @default (location) => location.href
447
- */
448
- getScrollRestorationKey?: (location: ParsedLocation) => string
449
- /**
450
- * The default behavior for scroll restoration.
451
- *
452
- * @default 'auto'
453
- */
454
- scrollRestorationBehavior?: ScrollBehavior
455
- /**
456
- * An array of selectors that will be used to scroll to the top of the page in addition to `window`
457
- *
458
- * @default ['window']
459
- */
460
- scrollToTopSelectors?: Array<string>
461
- }
462
-
463
- export interface RouterErrorSerializer<TSerializedError> {
464
- serialize: (err: unknown) => TSerializedError
465
- deserialize: (err: TSerializedError) => unknown
466
- }
106
+ Wrap?: (props: { children: any }) => Solid.JSX.Element
107
+ /**
108
+ * A component that will be used to wrap the inner contents of the router.
109
+ *
110
+ * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.
111
+ *
112
+ * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
113
+ *
114
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
115
+ */
116
+ InnerWrap?: (props: { children: any }) => Solid.JSX.Element
467
117
 
468
- export interface RouterState<
469
- TRouteTree extends AnyRoute = AnyRoute,
470
- TRouteMatch = MakeRouteMatchUnion,
471
- > {
472
- status: 'pending' | 'idle'
473
- loadedAt: number
474
- isLoading: boolean
475
- isTransitioning: boolean
476
- matches: Array<TRouteMatch>
477
- pendingMatches?: Array<TRouteMatch>
478
- cachedMatches: Array<TRouteMatch>
479
- location: ParsedLocation<FullSearchSchema<TRouteTree>>
480
- resolvedLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>
481
- statusCode: number
482
- redirect?: ResolvedRedirect
483
- }
118
+ /**
119
+ * The default `component` a route should use if no component is provided.
120
+ *
121
+ * @default Outlet
122
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
123
+ */
124
+ defaultComponent?: RouteComponent
125
+ /**
126
+ * The default `errorComponent` a route should use if no error component is provided.
127
+ *
128
+ * @default ErrorComponent
129
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
130
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
131
+ */
132
+ defaultErrorComponent?: ErrorRouteComponent
133
+ /**
134
+ * The default `pendingComponent` a route should use if no pending component is provided.
135
+ *
136
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)
137
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
138
+ */
139
+ defaultPendingComponent?: RouteComponent
140
+ /**
141
+ * The default `notFoundComponent` a route should use if no notFound component is provided.
142
+ *
143
+ * @default NotFound
144
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
145
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
146
+ */
147
+ defaultNotFoundComponent?: NotFoundRouteComponent
484
148
 
485
- export type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void
486
-
487
- export interface BuildNextOptions {
488
- to?: string | number | null
489
- params?: true | Updater<unknown>
490
- search?: true | Updater<unknown>
491
- hash?: true | Updater<string>
492
- state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>
493
- mask?: {
494
- to?: string | number | null
495
- params?: true | Updater<unknown>
496
- search?: true | Updater<unknown>
497
- hash?: true | Updater<string>
498
- state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>
499
- unmaskOnReload?: boolean
149
+ /**
150
+ * The default `onCatch` handler for errors caught by the Router ErrorBoundary
151
+ *
152
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
153
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
154
+ */
155
+ defaultOnCatch?: (error: Error) => void
500
156
  }
501
- from?: string
502
- _fromLocation?: ParsedLocation
503
- href?: string
504
- }
505
-
506
- export interface MatchedRoutesResult {
507
- matchedRoutes: Array<AnyRoute>
508
- routeParams: Record<string, string>
509
157
  }
510
158
 
511
- export type RouterConstructorOptions<
512
- TRouteTree extends AnyRoute,
513
- TTrailingSlashOption extends TrailingSlashOption,
514
- TRouterHistory extends RouterHistory,
515
- TDehydrated extends Record<string, any>,
516
- > = Omit<
517
- RouterOptions<TRouteTree, TTrailingSlashOption, TRouterHistory, TDehydrated>,
518
- 'context'
519
- > &
520
- RouterContextOptions<TRouteTree>
521
-
522
159
  export const componentTypes = [
523
160
  'component',
524
161
  'errorComponent',
@@ -563,85 +200,50 @@ function validateSearch(validateSearch: AnyValidator, input: unknown): unknown {
563
200
  return {}
564
201
  }
565
202
 
566
- type NavigationEventInfo = {
567
- fromLocation?: ParsedLocation
568
- toLocation: ParsedLocation
569
- pathChanged: boolean
570
- hrefChanged: boolean
571
- hashChanged: boolean
572
- }
573
-
574
- export type RouterEvents = {
575
- onBeforeNavigate: {
576
- type: 'onBeforeNavigate'
577
- } & NavigationEventInfo
578
- onBeforeLoad: {
579
- type: 'onBeforeLoad'
580
- } & NavigationEventInfo
581
- onLoad: {
582
- type: 'onLoad'
583
- } & NavigationEventInfo
584
- onResolved: {
585
- type: 'onResolved'
586
- } & NavigationEventInfo
587
- onBeforeRouteMount: {
588
- type: 'onBeforeRouteMount'
589
- } & NavigationEventInfo
590
- onInjectedHtml: {
591
- type: 'onInjectedHtml'
592
- promise: Promise<string>
593
- }
594
- onRendered: {
595
- type: 'onRendered'
596
- } & NavigationEventInfo
597
- }
598
-
599
- export type RouterEvent = RouterEvents[keyof RouterEvents]
600
-
601
- export type RouterListener<TRouterEvent extends RouterEvent> = {
602
- eventType: TRouterEvent['type']
603
- fn: ListenerFn<TRouterEvent>
604
- }
605
-
606
203
  export function createRouter<
607
204
  TRouteTree extends AnyRoute,
608
205
  TTrailingSlashOption extends TrailingSlashOption,
609
206
  TRouterHistory extends RouterHistory = RouterHistory,
610
207
  TDehydrated extends Record<string, any> = Record<string, any>,
611
- TSerializedError extends Record<string, any> = Record<string, any>,
612
208
  >(
613
209
  options: undefined extends number
614
210
  ? 'strictNullChecks must be enabled in tsconfig.json'
615
211
  : RouterConstructorOptions<
616
212
  TRouteTree,
617
213
  TTrailingSlashOption,
214
+ false,
618
215
  TRouterHistory,
619
216
  TDehydrated
620
217
  >,
621
- ) {
218
+ ): CoreRouter<
219
+ TRouteTree,
220
+ TTrailingSlashOption,
221
+ false,
222
+ TRouterHistory,
223
+ TDehydrated
224
+ > {
622
225
  return new Router<
623
226
  TRouteTree,
624
227
  TTrailingSlashOption,
625
228
  TRouterHistory,
626
- TDehydrated,
627
- TSerializedError
229
+ TDehydrated
628
230
  >(options)
629
231
  }
630
232
 
631
- type MatchRoutesOpts = {
632
- preload?: boolean
633
- throwOnError?: boolean
634
- _buildLocation?: boolean
635
- dest?: BuildNextOptions
636
- }
637
-
638
233
  export class Router<
639
234
  in out TRouteTree extends AnyRoute,
640
235
  in out TTrailingSlashOption extends TrailingSlashOption,
641
236
  in out TRouterHistory extends RouterHistory = RouterHistory,
642
237
  in out TDehydrated extends Record<string, any> = Record<string, any>,
643
- in out TSerializedError extends Record<string, any> = Record<string, any>,
644
- > {
238
+ > implements
239
+ CoreRouter<
240
+ TRouteTree,
241
+ TTrailingSlashOption,
242
+ false,
243
+ TRouterHistory,
244
+ TDehydrated
245
+ >
246
+ {
645
247
  // Option-independent properties
646
248
  tempLocationKey: string | undefined = `${Math.round(
647
249
  Math.random() * 10000000,
@@ -660,6 +262,7 @@ export class Router<
660
262
  RouterOptions<
661
263
  TRouteTree,
662
264
  TTrailingSlashOption,
265
+ false,
663
266
  TRouterHistory,
664
267
  TDehydrated
665
268
  >,
@@ -682,6 +285,7 @@ export class Router<
682
285
  options: RouterConstructorOptions<
683
286
  TRouteTree,
684
287
  TTrailingSlashOption,
288
+ false,
685
289
  TRouterHistory,
686
290
  TDehydrated
687
291
  >,
@@ -706,16 +310,15 @@ export class Router<
706
310
  // These are default implementations that can optionally be overridden
707
311
  // by the router provider once rendered. We provide these so that the
708
312
  // router can be used in a non-react environment if necessary
709
- startSolidTransition: (fn: () => void) => void = (fn) => fn()
313
+ startTransition: StartTransitionFn = (fn) => fn()
710
314
 
711
- update = (
712
- newOptions: RouterConstructorOptions<
713
- TRouteTree,
714
- TTrailingSlashOption,
715
- TRouterHistory,
716
- TDehydrated
717
- >,
718
- ) => {
315
+ update: UpdateFn<
316
+ TRouteTree,
317
+ TTrailingSlashOption,
318
+ false,
319
+ TRouterHistory,
320
+ TDehydrated
321
+ > = (newOptions) => {
719
322
  if (newOptions.notFoundRoute) {
720
323
  console.warn(
721
324
  '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.',
@@ -924,10 +527,7 @@ export class Router<
924
527
  })
925
528
  }
926
529
 
927
- subscribe = <TType extends keyof RouterEvents>(
928
- eventType: TType,
929
- fn: ListenerFn<RouterEvents[TType]>,
930
- ) => {
530
+ subscribe: SubscribeFn = (eventType, fn) => {
931
531
  const listener: RouterListener<any> = {
932
532
  eventType,
933
533
  fn,
@@ -940,7 +540,7 @@ export class Router<
940
540
  }
941
541
  }
942
542
 
943
- emit = (routerEvent: RouterEvent) => {
543
+ emit: EmitFn = (routerEvent) => {
944
544
  this.subscribers.forEach((listener) => {
945
545
  if (listener.eventType === routerEvent.type) {
946
546
  listener.fn(routerEvent)
@@ -948,10 +548,10 @@ export class Router<
948
548
  })
949
549
  }
950
550
 
951
- parseLocation = (
952
- previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>,
953
- locationToParse?: HistoryLocation,
954
- ): ParsedLocation<FullSearchSchema<TRouteTree>> => {
551
+ parseLocation: ParseLocationFn<TRouteTree> = (
552
+ previousLocation,
553
+ locationToParse,
554
+ ) => {
955
555
  const parse = ({
956
556
  pathname,
957
557
  search,
@@ -1015,21 +615,12 @@ export class Router<
1015
615
  ): Array<AnyRouteMatch>;
1016
616
  ```
1017
617
  */
1018
- public matchRoutes(
1019
- pathname: string,
1020
- locationSearch: AnySchema,
1021
- opts?: MatchRoutesOpts,
1022
- ): Array<AnyRouteMatch>
1023
- public matchRoutes(
1024
- next: ParsedLocation,
1025
- opts?: MatchRoutesOpts,
1026
- ): Array<AnyRouteMatch>
1027
618
 
1028
- public matchRoutes(
619
+ public matchRoutes: MatchRoutesFn = (
1029
620
  pathnameOrNext: string | ParsedLocation,
1030
621
  locationSearchOrOpts?: AnySchema | MatchRoutesOpts,
1031
622
  opts?: MatchRoutesOpts,
1032
- ) {
623
+ ) => {
1033
624
  if (typeof pathnameOrNext === 'string') {
1034
625
  return this.matchRoutesInternal(
1035
626
  {
@@ -1355,7 +946,7 @@ export class Router<
1355
946
  return matches
1356
947
  }
1357
948
 
1358
- getMatchedRoutes = (next: ParsedLocation, dest?: BuildNextOptions) => {
949
+ getMatchedRoutes: GetMatchRoutesFn = (next, dest) => {
1359
950
  let routeParams: Record<string, string> = {}
1360
951
  const trimmedPath = trimPathRight(next.pathname)
1361
952
  const getMatchedParams = (route: AnyRoute) => {
@@ -1719,11 +1310,11 @@ export class Router<
1719
1310
 
1720
1311
  commitLocationPromise: undefined | ControlledPromise<void>
1721
1312
 
1722
- commitLocation = ({
1313
+ commitLocation: CommitLocationFn = ({
1723
1314
  viewTransition,
1724
1315
  ignoreBlocker,
1725
1316
  ...next
1726
- }: ParsedLocation & CommitLocationOptions): Promise<void> => {
1317
+ }) => {
1727
1318
  const isSameState = () => {
1728
1319
  // the following props are ignored but may still be provided when navigating,
1729
1320
  // temporarily add the previous values to the next state so they don't affect
@@ -1863,7 +1454,7 @@ export class Router<
1863
1454
 
1864
1455
  latestLoadPromise: undefined | Promise<void>
1865
1456
 
1866
- load = async (opts?: { sync?: boolean }): Promise<void> => {
1457
+ load: LoadFn = async (opts) => {
1867
1458
  this.latestLocation = this.parseLocation(this.latestLocation)
1868
1459
 
1869
1460
  let redirect: ResolvedRedirect | undefined
@@ -1873,7 +1464,7 @@ export class Router<
1873
1464
 
1874
1465
  // eslint-disable-next-line prefer-const
1875
1466
  loadPromise = new Promise<void>((resolve) => {
1876
- this.startSolidTransition(async () => {
1467
+ this.startTransition(async () => {
1877
1468
  try {
1878
1469
  const next = this.latestLocation
1879
1470
  const prevLocation = this.state.resolvedLocation
@@ -2077,10 +1668,7 @@ export class Router<
2077
1668
  }
2078
1669
  }
2079
1670
 
2080
- updateMatch = (
2081
- id: string,
2082
- updater: (match: AnyRouteMatch) => AnyRouteMatch,
2083
- ) => {
1671
+ updateMatch: UpdateMatchFn = (id, updater) => {
2084
1672
  let updated!: AnyRouteMatch
2085
1673
  const isPending = this.state.pendingMatches?.find((d) => d.id === id)
2086
1674
  const isMatched = this.state.matches.find((d) => d.id === id)
@@ -2106,7 +1694,7 @@ export class Router<
2106
1694
  return updated
2107
1695
  }
2108
1696
 
2109
- getMatch = (matchId: string) => {
1697
+ getMatch: GetMatchFn = (matchId) => {
2110
1698
  return [
2111
1699
  ...this.state.cachedMatches,
2112
1700
  ...(this.state.pendingMatches ?? []),
@@ -2292,11 +1880,9 @@ export class Router<
2292
1880
  const prevLoadPromise = prev.loadPromise
2293
1881
  return {
2294
1882
  ...prev,
2295
- loadPromise: createControlledPromise<void>(
2296
- function demo() {
2297
- prevLoadPromise?.resolve()
2298
- },
2299
- ),
1883
+ loadPromise: createControlledPromise<void>(() => {
1884
+ prevLoadPromise?.resolve()
1885
+ }),
2300
1886
  beforeLoadPromise: createControlledPromise<void>(),
2301
1887
  }
2302
1888
  })
@@ -2672,12 +2258,9 @@ export class Router<
2672
2258
  return matches
2673
2259
  }
2674
2260
 
2675
- invalidate = <TRouter extends AnyRouter = typeof this>(opts?: {
2676
- filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean
2677
- sync?: boolean
2678
- }) => {
2261
+ invalidate: InvalidateFn<this> = (opts) => {
2679
2262
  const invalidate = (d: MakeRouteMatch<TRouteTree>) => {
2680
- if (opts?.filter?.(d as MakeRouteMatchUnion<TRouter>) ?? true) {
2263
+ if (opts?.filter?.(d as MakeRouteMatchUnion<this>) ?? true) {
2681
2264
  return {
2682
2265
  ...d,
2683
2266
  invalid: true,
@@ -2709,16 +2292,14 @@ export class Router<
2709
2292
  return redirect
2710
2293
  }
2711
2294
 
2712
- clearCache = <TRouter extends AnyRouter = typeof this>(opts?: {
2713
- filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean
2714
- }) => {
2295
+ clearCache: ClearCacheFn<this> = (opts) => {
2715
2296
  const filter = opts?.filter
2716
2297
  if (filter !== undefined) {
2717
2298
  this.__store.setState((s) => {
2718
2299
  return {
2719
2300
  ...s,
2720
2301
  cachedMatches: s.cachedMatches.filter(
2721
- (m) => !filter(m as MakeRouteMatchUnion<TRouter>),
2302
+ (m) => !filter(m as MakeRouteMatchUnion<this>),
2722
2303
  ),
2723
2304
  }
2724
2305
  })
@@ -2785,26 +2366,12 @@ export class Router<
2785
2366
  return route._componentsPromise
2786
2367
  }
2787
2368
 
2788
- preloadRoute = async <
2789
- TFrom extends RoutePaths<TRouteTree> | string = string,
2790
- TTo extends string | undefined = undefined,
2791
- TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
2792
- TMaskTo extends string = '',
2793
- >(
2794
- opts: NavigateOptions<
2795
- Router<
2796
- TRouteTree,
2797
- TTrailingSlashOption,
2798
- TRouterHistory,
2799
- TDehydrated,
2800
- TSerializedError
2801
- >,
2802
- TFrom,
2803
- TTo,
2804
- TMaskFrom,
2805
- TMaskTo
2806
- >,
2807
- ): Promise<Array<AnyRouteMatch> | undefined> => {
2369
+ preloadRoute: PreloadRouteFn<
2370
+ TRouteTree,
2371
+ TTrailingSlashOption,
2372
+ false,
2373
+ TRouterHistory
2374
+ > = async (opts) => {
2808
2375
  const next = this.buildLocation(opts as any)
2809
2376
 
2810
2377
  let matches = this.matchRoutes(next, {
@@ -2870,24 +2437,12 @@ export class Router<
2870
2437
  }
2871
2438
  }
2872
2439
 
2873
- matchRoute = <
2874
- TFrom extends RoutePaths<TRouteTree> = '/',
2875
- TTo extends string | undefined = undefined,
2876
- TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,
2877
- >(
2878
- location: ToOptions<
2879
- Router<
2880
- TRouteTree,
2881
- TTrailingSlashOption,
2882
- TRouterHistory,
2883
- TDehydrated,
2884
- TSerializedError
2885
- >,
2886
- TFrom,
2887
- TTo
2888
- >,
2889
- opts?: MatchRouteOptions,
2890
- ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {
2440
+ matchRoute: MatchRouteFn<
2441
+ TRouteTree,
2442
+ TTrailingSlashOption,
2443
+ false,
2444
+ TRouterHistory
2445
+ > = (location, opts) => {
2891
2446
  const matchLocation = {
2892
2447
  ...location,
2893
2448
  to: location.to