@tanstack/react-router 1.112.11 → 1.112.13

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 (136) hide show
  1. package/dist/cjs/Match.cjs +2 -2
  2. package/dist/cjs/Match.cjs.map +1 -1
  3. package/dist/cjs/Matches.cjs.map +1 -1
  4. package/dist/cjs/Matches.d.cts +1 -8
  5. package/dist/cjs/RouterProvider.cjs.map +1 -1
  6. package/dist/cjs/RouterProvider.d.cts +2 -2
  7. package/dist/cjs/Transitioner.cjs +1 -1
  8. package/dist/cjs/Transitioner.cjs.map +1 -1
  9. package/dist/cjs/fileRoute.cjs.map +1 -1
  10. package/dist/cjs/fileRoute.d.cts +4 -7
  11. package/dist/cjs/index.d.cts +4 -6
  12. package/dist/cjs/link.cjs.map +1 -1
  13. package/dist/cjs/link.d.cts +1 -2
  14. package/dist/cjs/not-found.cjs.map +1 -1
  15. package/dist/cjs/not-found.d.cts +1 -2
  16. package/dist/cjs/redirects.cjs.map +1 -1
  17. package/dist/cjs/redirects.d.cts +1 -2
  18. package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
  19. package/dist/cjs/renderRouteNotFound.d.cts +1 -2
  20. package/dist/cjs/route.cjs +15 -23
  21. package/dist/cjs/route.cjs.map +1 -1
  22. package/dist/cjs/route.d.cts +18 -43
  23. package/dist/cjs/router.cjs +18 -20
  24. package/dist/cjs/router.cjs.map +1 -1
  25. package/dist/cjs/router.d.cts +82 -458
  26. package/dist/cjs/routerContext.cjs.map +1 -1
  27. package/dist/cjs/routerContext.d.cts +2 -2
  28. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  29. package/dist/cjs/scroll-restoration.d.cts +1 -2
  30. package/dist/cjs/structuralSharing.d.cts +1 -2
  31. package/dist/cjs/typePrimitives.d.cts +1 -2
  32. package/dist/cjs/useBlocker.cjs.map +1 -1
  33. package/dist/cjs/useBlocker.d.cts +1 -3
  34. package/dist/cjs/useLoaderData.cjs.map +1 -1
  35. package/dist/cjs/useLoaderData.d.cts +1 -2
  36. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  37. package/dist/cjs/useLoaderDeps.d.cts +1 -2
  38. package/dist/cjs/useLocation.cjs.map +1 -1
  39. package/dist/cjs/useLocation.d.cts +1 -1
  40. package/dist/cjs/useMatch.cjs.map +1 -1
  41. package/dist/cjs/useMatch.d.cts +1 -2
  42. package/dist/cjs/useNavigate.cjs.map +1 -1
  43. package/dist/cjs/useNavigate.d.cts +1 -2
  44. package/dist/cjs/useParams.cjs.map +1 -1
  45. package/dist/cjs/useParams.d.cts +1 -2
  46. package/dist/cjs/useRouteContext.cjs.map +1 -1
  47. package/dist/cjs/useRouteContext.d.cts +1 -2
  48. package/dist/cjs/useRouter.cjs.map +1 -1
  49. package/dist/cjs/useRouter.d.cts +1 -1
  50. package/dist/cjs/useRouterState.cjs.map +1 -1
  51. package/dist/cjs/useRouterState.d.cts +1 -1
  52. package/dist/cjs/useSearch.cjs.map +1 -1
  53. package/dist/cjs/useSearch.d.cts +1 -2
  54. package/dist/cjs/utils.d.cts +1 -1
  55. package/dist/esm/Match.js +2 -2
  56. package/dist/esm/Match.js.map +1 -1
  57. package/dist/esm/Matches.d.ts +1 -8
  58. package/dist/esm/Matches.js.map +1 -1
  59. package/dist/esm/RouterProvider.d.ts +2 -2
  60. package/dist/esm/RouterProvider.js.map +1 -1
  61. package/dist/esm/Transitioner.js +1 -1
  62. package/dist/esm/Transitioner.js.map +1 -1
  63. package/dist/esm/fileRoute.d.ts +4 -7
  64. package/dist/esm/fileRoute.js.map +1 -1
  65. package/dist/esm/index.d.ts +4 -6
  66. package/dist/esm/link.d.ts +1 -2
  67. package/dist/esm/link.js.map +1 -1
  68. package/dist/esm/not-found.d.ts +1 -2
  69. package/dist/esm/not-found.js.map +1 -1
  70. package/dist/esm/redirects.d.ts +1 -2
  71. package/dist/esm/redirects.js.map +1 -1
  72. package/dist/esm/renderRouteNotFound.d.ts +1 -2
  73. package/dist/esm/renderRouteNotFound.js.map +1 -1
  74. package/dist/esm/route.d.ts +18 -43
  75. package/dist/esm/route.js +15 -23
  76. package/dist/esm/route.js.map +1 -1
  77. package/dist/esm/router.d.ts +82 -458
  78. package/dist/esm/router.js +18 -20
  79. package/dist/esm/router.js.map +1 -1
  80. package/dist/esm/routerContext.d.ts +2 -2
  81. package/dist/esm/routerContext.js.map +1 -1
  82. package/dist/esm/scroll-restoration.d.ts +1 -2
  83. package/dist/esm/scroll-restoration.js.map +1 -1
  84. package/dist/esm/structuralSharing.d.ts +1 -2
  85. package/dist/esm/typePrimitives.d.ts +1 -2
  86. package/dist/esm/useBlocker.d.ts +1 -3
  87. package/dist/esm/useBlocker.js.map +1 -1
  88. package/dist/esm/useLoaderData.d.ts +1 -2
  89. package/dist/esm/useLoaderData.js.map +1 -1
  90. package/dist/esm/useLoaderDeps.d.ts +1 -2
  91. package/dist/esm/useLoaderDeps.js.map +1 -1
  92. package/dist/esm/useLocation.d.ts +1 -1
  93. package/dist/esm/useLocation.js.map +1 -1
  94. package/dist/esm/useMatch.d.ts +1 -2
  95. package/dist/esm/useMatch.js.map +1 -1
  96. package/dist/esm/useNavigate.d.ts +1 -2
  97. package/dist/esm/useNavigate.js.map +1 -1
  98. package/dist/esm/useParams.d.ts +1 -2
  99. package/dist/esm/useParams.js.map +1 -1
  100. package/dist/esm/useRouteContext.d.ts +1 -2
  101. package/dist/esm/useRouteContext.js.map +1 -1
  102. package/dist/esm/useRouter.d.ts +1 -1
  103. package/dist/esm/useRouter.js.map +1 -1
  104. package/dist/esm/useRouterState.d.ts +1 -1
  105. package/dist/esm/useRouterState.js.map +1 -1
  106. package/dist/esm/useSearch.d.ts +1 -2
  107. package/dist/esm/useSearch.js.map +1 -1
  108. package/dist/esm/utils.d.ts +1 -1
  109. package/package.json +2 -2
  110. package/src/Match.tsx +7 -4
  111. package/src/Matches.tsx +4 -8
  112. package/src/RouterProvider.tsx +2 -8
  113. package/src/Transitioner.tsx +1 -1
  114. package/src/fileRoute.ts +9 -25
  115. package/src/index.tsx +20 -26
  116. package/src/link.tsx +2 -2
  117. package/src/not-found.tsx +1 -2
  118. package/src/redirects.ts +1 -1
  119. package/src/renderRouteNotFound.tsx +1 -2
  120. package/src/route.ts +91 -211
  121. package/src/router.ts +151 -610
  122. package/src/routerContext.tsx +1 -1
  123. package/src/scroll-restoration.tsx +5 -2
  124. package/src/structuralSharing.ts +1 -1
  125. package/src/typePrimitives.ts +2 -2
  126. package/src/useBlocker.tsx +6 -3
  127. package/src/useLoaderData.tsx +2 -1
  128. package/src/useLoaderDeps.tsx +2 -1
  129. package/src/useLocation.tsx +5 -1
  130. package/src/useMatch.tsx +2 -1
  131. package/src/useNavigate.tsx +2 -1
  132. package/src/useParams.tsx +2 -1
  133. package/src/useRouteContext.ts +2 -1
  134. package/src/useRouter.tsx +1 -1
  135. package/src/useRouterState.tsx +5 -1
  136. package/src/useSearch.tsx +2 -1
package/src/router.ts CHANGED
@@ -31,510 +31,132 @@ import { isNotFound } from './not-found'
31
31
 
32
32
  import { setupScrollRestoration } from './scroll-restoration'
33
33
  import type * as React from 'react'
34
- import type {
35
- HistoryLocation,
36
- HistoryState,
37
- ParsedHistoryState,
38
- RouterHistory,
39
- } from '@tanstack/history'
40
- import type { NoInfer } from '@tanstack/react-store'
34
+ import type { HistoryLocation, RouterHistory } from '@tanstack/history'
41
35
 
42
36
  import type {
43
- AnyContext,
44
37
  AnyRedirect,
38
+ AnyRoute,
45
39
  AnyRouteMatch,
40
+ AnyRouter,
46
41
  AnySchema,
47
42
  AnyValidator,
48
43
  BeforeLoadContextOptions,
49
44
  BuildLocationFn,
45
+ BuildNextOptions,
46
+ ClearCacheFn,
47
+ CommitLocationFn,
50
48
  CommitLocationOptions,
51
49
  ControlledPromise,
50
+ Router as CoreRouter,
51
+ EmitFn,
52
52
  FullSearchSchema,
53
+ GetMatchFn,
54
+ GetMatchRoutesFn,
55
+ InjectedHtmlEntry,
56
+ InvalidateFn,
57
+ LoadFn,
53
58
  LoaderFnContext,
54
- MakeRemountDepsOptionsUnion,
55
59
  MakeRouteMatch,
56
60
  MakeRouteMatchUnion,
57
61
  Manifest,
62
+ MatchRouteFn,
63
+ MatchRoutesFn,
64
+ MatchRoutesOpts,
65
+ MatchedRoutesResult,
58
66
  NavigateFn,
59
- NavigateOptions,
60
- NonNullableUpdater,
67
+ ParseLocationFn,
61
68
  ParsedLocation,
62
69
  PickAsRequired,
63
- Register,
64
- ResolveRelativePath,
70
+ PreloadRouteFn,
65
71
  ResolvedRedirect,
66
- RouteById,
67
72
  RouteContextOptions,
68
- RoutePaths,
73
+ RouterConstructorOptions,
74
+ RouterEvent,
75
+ RouterListener,
76
+ RouterOptions,
77
+ RouterState,
69
78
  RoutesById,
70
79
  RoutesByPath,
71
80
  SearchMiddleware,
72
- SearchParser,
73
- SearchSerializer,
74
81
  StartSerializer,
75
- ToOptions,
82
+ StartTransitionFn,
83
+ SubscribeFn,
76
84
  TrailingSlashOption,
77
- Updater,
85
+ UpdateFn,
86
+ UpdateMatchFn,
78
87
  ViewTransitionOptions,
79
88
  } from '@tanstack/router-core'
80
89
  import type {
81
- AnyRoute,
82
90
  ErrorRouteComponent,
83
91
  NotFoundRouteComponent,
84
- RootRoute,
85
92
  RouteComponent,
86
- RouteMask,
87
93
  } from './route'
88
94
 
89
- import type { MatchRouteOptions } from './Matches'
90
-
91
95
  import type { NotFoundError } from './not-found'
92
96
 
93
- declare global {
94
- interface Window {
95
- __TSR_ROUTER__?: AnyRouter
96
- }
97
- }
98
-
99
- export type AnyRouter = Router<any, any, any, any, any, any>
100
-
101
- export type RegisteredRouter = Register extends {
102
- router: infer TRouter extends AnyRouter
103
- }
104
- ? TRouter
105
- : AnyRouter
106
-
107
- export type InferRouterContext<TRouteTree extends AnyRoute> =
108
- TRouteTree extends RootRoute<
109
- any,
110
- infer TRouterContext extends AnyContext,
111
- any,
112
- any,
113
- any,
114
- any,
115
- any,
116
- any
117
- >
118
- ? TRouterContext
119
- : AnyContext
120
-
121
- export type ControllablePromise<T = any> = Promise<T> & {
122
- resolve: (value: T) => void
123
- reject: (value?: any) => void
124
- }
125
-
126
- export type RouterContextOptions<TRouteTree extends AnyRoute> =
127
- AnyContext extends InferRouterContext<TRouteTree>
128
- ? {
129
- context?: InferRouterContext<TRouteTree>
130
- }
131
- : {
132
- context: InferRouterContext<TRouteTree>
133
- }
134
-
135
- export type InjectedHtmlEntry = Promise<string>
136
-
137
- export interface RouterOptions<
138
- TRouteTree extends AnyRoute,
139
- TTrailingSlashOption extends TrailingSlashOption,
140
- TDefaultStructuralSharingOption extends boolean = false,
141
- TRouterHistory extends RouterHistory = RouterHistory,
142
- TDehydrated extends Record<string, any> = Record<string, any>,
143
- > {
144
- /**
145
- * The history object that will be used to manage the browser history.
146
- *
147
- * If not provided, a new createBrowserHistory instance will be created and used.
148
- *
149
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)
150
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)
151
- */
152
- history?: TRouterHistory
153
- /**
154
- * A function that will be used to stringify search params when generating links.
155
- *
156
- * @default defaultStringifySearch
157
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#stringifysearch-method)
158
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
159
- */
160
- stringifySearch?: SearchSerializer
161
- /**
162
- * A function that will be used to parse search params when parsing the current location.
163
- *
164
- * @default defaultParseSearch
165
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#parsesearch-method)
166
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
167
- */
168
- parseSearch?: SearchParser
169
- /**
170
- * If `false`, routes will not be preloaded by default in any way.
171
- *
172
- * If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a `<Link>`.
173
- *
174
- * If `'viewport'`, routes will be preloaded by default when they are within the viewport.
175
- *
176
- * @default false
177
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreload-property)
178
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
179
- */
180
- defaultPreload?: false | 'intent' | 'viewport' | 'render'
181
- /**
182
- * The delay in milliseconds that a route must be hovered over or touched before it is preloaded.
183
- *
184
- * @default 50
185
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloaddelay-property)
186
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay)
187
- */
188
- defaultPreloadDelay?: number
189
- /**
190
- * The default `component` a route should use if no component is provided.
191
- *
192
- * @default Outlet
193
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
194
- */
195
- defaultComponent?: RouteComponent
196
- /**
197
- * The default `errorComponent` a route should use if no error component is provided.
198
- *
199
- * @default ErrorComponent
200
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
201
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
202
- */
203
- defaultErrorComponent?: ErrorRouteComponent
204
- /**
205
- * The default `pendingComponent` a route should use if no pending component is provided.
206
- *
207
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)
208
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
209
- */
210
- defaultPendingComponent?: RouteComponent
211
- /**
212
- * The default `pendingMs` a route should use if no pendingMs is provided.
213
- *
214
- * @default 1000
215
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingms-property)
216
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
217
- */
218
- defaultPendingMs?: number
219
- /**
220
- * The default `pendingMinMs` a route should use if no pendingMinMs is provided.
221
- *
222
- * @default 500
223
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingminms-property)
224
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
225
- */
226
- defaultPendingMinMs?: number
227
- /**
228
- * 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.
229
- *
230
- * @default 0
231
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstaletime-property)
232
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
233
- */
234
- defaultStaleTime?: number
235
- /**
236
- * The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.
237
- *
238
- * @default 30_000 `(30 seconds)`
239
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadstaletime-property)
240
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
241
- */
242
- defaultPreloadStaleTime?: number
243
- /**
244
- * The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.
245
- *
246
- * @default 1_800_000 `(30 minutes)`
247
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadgctime-property)
248
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
249
- */
250
- defaultPreloadGcTime?: number
251
- /**
252
- * The default `onCatch` handler for errors caught by the Router ErrorBoundary
253
- *
254
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
255
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
256
- */
257
- defaultOnCatch?: (error: Error, errorInfo: React.ErrorInfo) => void
258
- /**
259
- * If `true`, route navigations will called using `document.startViewTransition()`.
260
- *
261
- * If the browser does not support this api, this option will be ignored.
262
- *
263
- * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for more information on how this function works.
264
- *
265
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultviewtransition-property)
266
- */
267
- defaultViewTransition?: boolean | ViewTransitionOptions
268
- /**
269
- * The default `hashScrollIntoView` a route should use if no hashScrollIntoView is provided while navigating
270
- *
271
- * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) for more information on `ScrollIntoViewOptions`.
272
- *
273
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulthashscrollintoview-property)
274
- */
275
- defaultHashScrollIntoView?: boolean | ScrollIntoViewOptions
276
- /**
277
- * @default 'fuzzy'
278
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundmode-property)
279
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#the-notfoundmode-option)
280
- */
281
- notFoundMode?: 'root' | 'fuzzy'
282
- /**
283
- * The default `gcTime` a route should use if no gcTime is provided.
284
- *
285
- * @default 1_800_000 `(30 minutes)`
286
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultgctime-property)
287
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
288
- */
289
- defaultGcTime?: number
290
- /**
291
- * If `true`, all routes will be matched as case-sensitive.
292
- *
293
- * @default false
294
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)
295
- */
296
- caseSensitive?: boolean
297
- /**
298
- *
299
- * The route tree that will be used to configure the router instance.
300
- *
301
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)
302
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/routing/route-trees)
303
- */
304
- routeTree?: TRouteTree
305
- /**
306
- * The basepath for then entire router. This is useful for mounting a router instance at a subpath.
307
- *
308
- * @default '/'
309
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)
310
- */
311
- basepath?: string
312
- /**
313
- * The root context that will be provided to all routes in the route tree.
314
- *
315
- * This can be used to provide a context to all routes in the tree without having to provide it to each route individually.
316
- *
317
- * Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).
318
- *
319
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#context-property)
320
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)
321
- */
322
- context?: InferRouterContext<TRouteTree>
323
- /**
324
- * A function that will be called when the router is dehydrated.
325
- *
326
- * The return value of this function will be serialized and stored in the router's dehydrated state.
327
- *
328
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)
329
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
330
- */
331
- dehydrate?: () => TDehydrated
332
- /**
333
- * A function that will be called when the router is hydrated.
334
- *
335
- * The return value of this function will be serialized and stored in the router's dehydrated state.
336
- *
337
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#hydrate-method)
338
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
339
- */
340
- hydrate?: (dehydrated: TDehydrated) => void
341
- /**
342
- * An array of route masks that will be used to mask routes in the route tree.
343
- *
344
- * 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.
345
- *
346
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routemasks-property)
347
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking)
348
- */
349
- routeMasks?: Array<RouteMask<TRouteTree>>
350
- /**
351
- * If `true`, route masks will, by default, be removed when the page is reloaded.
352
- *
353
- * 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.
354
- *
355
- * @default false
356
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#unmaskonreload-property)
357
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking#unmasking-on-page-reload)
358
- */
359
- unmaskOnReload?: boolean
360
- /**
361
- * A component that will be used to wrap the entire router.
362
- *
363
- * This is useful for providing a context to the entire router.
364
- *
365
- * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
366
- *
367
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
368
- */
369
- Wrap?: (props: { children: any }) => React.JSX.Element
370
- /**
371
- * A component that will be used to wrap the inner contents of the router.
372
- *
373
- * 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.
374
- *
375
- * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
376
- *
377
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
378
- */
379
- InnerWrap?: (props: { children: any }) => React.JSX.Element
380
- /**
381
- * Use `notFoundComponent` instead.
382
- *
383
- * @deprecated
384
- * See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.
385
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundroute-property)
386
- */
387
- notFoundRoute?: AnyRoute
388
- /**
389
- * The default `notFoundComponent` a route should use if no notFound component is provided.
390
- *
391
- * @default NotFound
392
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
393
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
394
- */
395
- defaultNotFoundComponent?: NotFoundRouteComponent
396
- /**
397
- * Configures how trailing slashes are treated.
398
- *
399
- * - `'always'` will add a trailing slash if not present
400
- * - `'never'` will remove the trailing slash if present
401
- * - `'preserve'` will not modify the trailing slash.
402
- *
403
- * @default 'never'
404
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)
405
- */
406
- trailingSlash?: TTrailingSlashOption
407
- /**
408
- * 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.
409
- *
410
- * @default typeof document !== 'undefined'
411
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#isserver-property)
412
- */
413
- isServer?: boolean
414
-
415
- defaultSsr?: boolean
416
-
417
- search?: {
97
+ declare module '@tanstack/router-core' {
98
+ export interface RouterOptionsExtensions {
418
99
  /**
419
- * Configures how unknown search params (= not returned by any `validateSearch`) are treated.
100
+ * The default `component` a route should use if no component is provided.
420
101
  *
421
- * @default false
422
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#search.strict-property)
102
+ * @default Outlet
103
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
423
104
  */
424
- strict?: boolean
425
- }
426
-
427
- /**
428
- * Configures whether structural sharing is enabled by default for fine-grained selectors.
429
- *
430
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstructuralsharing-property)
431
- */
432
- defaultStructuralSharing?: TDefaultStructuralSharingOption
433
-
434
- /**
435
- * Configures which URI characters are allowed in path params that would ordinarily be escaped by encodeURIComponent.
436
- *
437
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#pathparamsallowedcharacters-property)
438
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/path-params#allowed-characters)
439
- */
440
- pathParamsAllowedCharacters?: Array<
441
- ';' | ':' | '@' | '&' | '=' | '+' | '$' | ','
442
- >
443
-
444
- defaultRemountDeps?: (opts: MakeRemountDepsOptionsUnion<TRouteTree>) => any
445
-
446
- /**
447
- * If `true`, scroll restoration will be enabled
448
- *
449
- * @default false
450
- */
451
- scrollRestoration?: boolean
452
- /**
453
- * A function that will be called to get the key for the scroll restoration cache.
454
- *
455
- * @default (location) => location.href
456
- */
457
- getScrollRestorationKey?: (location: ParsedLocation) => string
458
- /**
459
- * The default behavior for scroll restoration.
460
- *
461
- * @default 'auto'
462
- */
463
- scrollRestorationBehavior?: ScrollBehavior
464
- /**
465
- * An array of selectors that will be used to scroll to the top of the page in addition to `window`
466
- *
467
- * @default ['window']
468
- */
469
- scrollToTopSelectors?: Array<string>
470
- }
471
-
472
- export interface RouterErrorSerializer<TSerializedError> {
473
- serialize: (err: unknown) => TSerializedError
474
- deserialize: (err: TSerializedError) => unknown
475
- }
476
-
477
- export interface RouterState<
478
- TRouteTree extends AnyRoute = AnyRoute,
479
- TRouteMatch = MakeRouteMatchUnion,
480
- > {
481
- status: 'pending' | 'idle'
482
- loadedAt: number
483
- isLoading: boolean
484
- isTransitioning: boolean
485
- matches: Array<TRouteMatch>
486
- pendingMatches?: Array<TRouteMatch>
487
- cachedMatches: Array<TRouteMatch>
488
- location: ParsedLocation<FullSearchSchema<TRouteTree>>
489
- resolvedLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>
490
- statusCode: number
491
- redirect?: ResolvedRedirect
492
- }
105
+ defaultComponent?: RouteComponent
106
+ /**
107
+ * The default `errorComponent` a route should use if no error component is provided.
108
+ *
109
+ * @default ErrorComponent
110
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
111
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
112
+ */
113
+ defaultErrorComponent?: ErrorRouteComponent
114
+ /**
115
+ * The default `pendingComponent` a route should use if no pending component is provided.
116
+ *
117
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)
118
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
119
+ */
120
+ defaultPendingComponent?: RouteComponent
121
+ /**
122
+ * The default `notFoundComponent` a route should use if no notFound component is provided.
123
+ *
124
+ * @default NotFound
125
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
126
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
127
+ */
128
+ defaultNotFoundComponent?: NotFoundRouteComponent
129
+ /**
130
+ * A component that will be used to wrap the entire router.
131
+ *
132
+ * This is useful for providing a context to the entire router.
133
+ *
134
+ * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
135
+ *
136
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
137
+ */
138
+ Wrap?: (props: { children: any }) => React.JSX.Element
139
+ /**
140
+ * A component that will be used to wrap the inner contents of the router.
141
+ *
142
+ * 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.
143
+ *
144
+ * Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
145
+ *
146
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
147
+ */
148
+ InnerWrap?: (props: { children: any }) => React.JSX.Element
493
149
 
494
- export type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void
495
-
496
- export interface BuildNextOptions {
497
- to?: string | number | null
498
- params?: true | Updater<unknown>
499
- search?: true | Updater<unknown>
500
- hash?: true | Updater<string>
501
- state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>
502
- mask?: {
503
- to?: string | number | null
504
- params?: true | Updater<unknown>
505
- search?: true | Updater<unknown>
506
- hash?: true | Updater<string>
507
- state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>
508
- unmaskOnReload?: boolean
150
+ /**
151
+ * The default `onCatch` handler for errors caught by the Router ErrorBoundary
152
+ *
153
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
154
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
155
+ */
156
+ defaultOnCatch?: (error: Error, errorInfo: React.ErrorInfo) => void
509
157
  }
510
- from?: string
511
- _fromLocation?: ParsedLocation
512
- href?: string
513
- }
514
-
515
- export interface MatchedRoutesResult {
516
- matchedRoutes: Array<AnyRoute>
517
- routeParams: Record<string, string>
518
158
  }
519
159
 
520
- export type RouterConstructorOptions<
521
- TRouteTree extends AnyRoute,
522
- TTrailingSlashOption extends TrailingSlashOption,
523
- TDefaultStructuralSharingOption extends boolean,
524
- TRouterHistory extends RouterHistory,
525
- TDehydrated extends Record<string, any>,
526
- > = Omit<
527
- RouterOptions<
528
- TRouteTree,
529
- TTrailingSlashOption,
530
- TDefaultStructuralSharingOption,
531
- TRouterHistory,
532
- TDehydrated
533
- >,
534
- 'context'
535
- > &
536
- RouterContextOptions<TRouteTree>
537
-
538
160
  export const componentTypes = [
539
161
  'component',
540
162
  'errorComponent',
@@ -579,53 +201,12 @@ function validateSearch(validateSearch: AnyValidator, input: unknown): unknown {
579
201
  return {}
580
202
  }
581
203
 
582
- type NavigationEventInfo = {
583
- fromLocation?: ParsedLocation
584
- toLocation: ParsedLocation
585
- pathChanged: boolean
586
- hrefChanged: boolean
587
- hashChanged: boolean
588
- }
589
-
590
- export type RouterEvents = {
591
- onBeforeNavigate: {
592
- type: 'onBeforeNavigate'
593
- } & NavigationEventInfo
594
- onBeforeLoad: {
595
- type: 'onBeforeLoad'
596
- } & NavigationEventInfo
597
- onLoad: {
598
- type: 'onLoad'
599
- } & NavigationEventInfo
600
- onResolved: {
601
- type: 'onResolved'
602
- } & NavigationEventInfo
603
- onBeforeRouteMount: {
604
- type: 'onBeforeRouteMount'
605
- } & NavigationEventInfo
606
- onInjectedHtml: {
607
- type: 'onInjectedHtml'
608
- promise: Promise<string>
609
- }
610
- onRendered: {
611
- type: 'onRendered'
612
- } & NavigationEventInfo
613
- }
614
-
615
- export type RouterEvent = RouterEvents[keyof RouterEvents]
616
-
617
- export type RouterListener<TRouterEvent extends RouterEvent> = {
618
- eventType: TRouterEvent['type']
619
- fn: ListenerFn<TRouterEvent>
620
- }
621
-
622
204
  export function createRouter<
623
205
  TRouteTree extends AnyRoute,
624
206
  TTrailingSlashOption extends TrailingSlashOption,
625
207
  TDefaultStructuralSharingOption extends boolean,
626
208
  TRouterHistory extends RouterHistory = RouterHistory,
627
209
  TDehydrated extends Record<string, any> = Record<string, any>,
628
- TSerializedError extends Record<string, any> = Record<string, any>,
629
210
  >(
630
211
  options: undefined extends number
631
212
  ? 'strictNullChecks must be enabled in tsconfig.json'
@@ -636,32 +217,37 @@ export function createRouter<
636
217
  TRouterHistory,
637
218
  TDehydrated
638
219
  >,
639
- ) {
220
+ ): CoreRouter<
221
+ TRouteTree,
222
+ TTrailingSlashOption,
223
+ TDefaultStructuralSharingOption,
224
+ TRouterHistory,
225
+ TDehydrated
226
+ > {
640
227
  return new Router<
641
228
  TRouteTree,
642
229
  TTrailingSlashOption,
643
230
  TDefaultStructuralSharingOption,
644
231
  TRouterHistory,
645
- TDehydrated,
646
- TSerializedError
232
+ TDehydrated
647
233
  >(options)
648
234
  }
649
235
 
650
- type MatchRoutesOpts = {
651
- preload?: boolean
652
- throwOnError?: boolean
653
- _buildLocation?: boolean
654
- dest?: BuildNextOptions
655
- }
656
-
657
236
  export class Router<
658
237
  in out TRouteTree extends AnyRoute,
659
238
  in out TTrailingSlashOption extends TrailingSlashOption,
660
239
  in out TDefaultStructuralSharingOption extends boolean,
661
240
  in out TRouterHistory extends RouterHistory = RouterHistory,
662
241
  in out TDehydrated extends Record<string, any> = Record<string, any>,
663
- in out TSerializedError extends Record<string, any> = Record<string, any>,
664
- > {
242
+ > implements
243
+ CoreRouter<
244
+ TRouteTree,
245
+ TTrailingSlashOption,
246
+ TDefaultStructuralSharingOption,
247
+ TRouterHistory,
248
+ TDehydrated
249
+ >
250
+ {
665
251
  // Option-independent properties
666
252
  tempLocationKey: string | undefined = `${Math.round(
667
253
  Math.random() * 10000000,
@@ -728,17 +314,15 @@ export class Router<
728
314
  // These are default implementations that can optionally be overridden
729
315
  // by the router provider once rendered. We provide these so that the
730
316
  // router can be used in a non-react environment if necessary
731
- startReactTransition: (fn: () => void) => void = (fn) => fn()
317
+ startTransition: StartTransitionFn = (fn) => fn()
732
318
 
733
- update = (
734
- newOptions: RouterConstructorOptions<
735
- TRouteTree,
736
- TTrailingSlashOption,
737
- TDefaultStructuralSharingOption,
738
- TRouterHistory,
739
- TDehydrated
740
- >,
741
- ) => {
319
+ update: UpdateFn<
320
+ TRouteTree,
321
+ TTrailingSlashOption,
322
+ TDefaultStructuralSharingOption,
323
+ TRouterHistory,
324
+ TDehydrated
325
+ > = (newOptions) => {
742
326
  if (newOptions.notFoundRoute) {
743
327
  console.warn(
744
328
  '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.',
@@ -950,10 +534,7 @@ export class Router<
950
534
  })
951
535
  }
952
536
 
953
- subscribe = <TType extends keyof RouterEvents>(
954
- eventType: TType,
955
- fn: ListenerFn<RouterEvents[TType]>,
956
- ) => {
537
+ subscribe: SubscribeFn = (eventType, fn) => {
957
538
  const listener: RouterListener<any> = {
958
539
  eventType,
959
540
  fn,
@@ -966,7 +547,7 @@ export class Router<
966
547
  }
967
548
  }
968
549
 
969
- emit = (routerEvent: RouterEvent) => {
550
+ emit: EmitFn = (routerEvent) => {
970
551
  this.subscribers.forEach((listener) => {
971
552
  if (listener.eventType === routerEvent.type) {
972
553
  listener.fn(routerEvent)
@@ -974,10 +555,10 @@ export class Router<
974
555
  })
975
556
  }
976
557
 
977
- parseLocation = (
978
- previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>,
979
- locationToParse?: HistoryLocation,
980
- ): ParsedLocation<FullSearchSchema<TRouteTree>> => {
558
+ parseLocation: ParseLocationFn<TRouteTree> = (
559
+ previousLocation,
560
+ locationToParse,
561
+ ) => {
981
562
  const parse = ({
982
563
  pathname,
983
564
  search,
@@ -1041,21 +622,11 @@ export class Router<
1041
622
  ): Array<AnyRouteMatch>;
1042
623
  ```
1043
624
  */
1044
- public matchRoutes(
1045
- pathname: string,
1046
- locationSearch: AnySchema,
1047
- opts?: MatchRoutesOpts,
1048
- ): Array<AnyRouteMatch>
1049
- public matchRoutes(
1050
- next: ParsedLocation,
1051
- opts?: MatchRoutesOpts,
1052
- ): Array<AnyRouteMatch>
1053
-
1054
- public matchRoutes(
625
+ matchRoutes: MatchRoutesFn = (
1055
626
  pathnameOrNext: string | ParsedLocation,
1056
627
  locationSearchOrOpts?: AnySchema | MatchRoutesOpts,
1057
628
  opts?: MatchRoutesOpts,
1058
- ) {
629
+ ) => {
1059
630
  if (typeof pathnameOrNext === 'string') {
1060
631
  return this.matchRoutesInternal(
1061
632
  {
@@ -1381,7 +952,7 @@ export class Router<
1381
952
  return matches
1382
953
  }
1383
954
 
1384
- getMatchedRoutes = (next: ParsedLocation, dest?: BuildNextOptions) => {
955
+ getMatchedRoutes: GetMatchRoutesFn = (next, dest) => {
1385
956
  let routeParams: Record<string, string> = {}
1386
957
  const trimmedPath = trimPathRight(next.pathname)
1387
958
  const getMatchedParams = (route: AnyRoute) => {
@@ -1745,11 +1316,11 @@ export class Router<
1745
1316
 
1746
1317
  commitLocationPromise: undefined | ControlledPromise<void>
1747
1318
 
1748
- commitLocation = ({
1319
+ commitLocation: CommitLocationFn = ({
1749
1320
  viewTransition,
1750
1321
  ignoreBlocker,
1751
1322
  ...next
1752
- }: ParsedLocation & CommitLocationOptions): Promise<void> => {
1323
+ }) => {
1753
1324
  const isSameState = () => {
1754
1325
  // the following props are ignored but may still be provided when navigating,
1755
1326
  // temporarily add the previous values to the next state so they don't affect
@@ -1889,7 +1460,7 @@ export class Router<
1889
1460
 
1890
1461
  latestLoadPromise: undefined | Promise<void>
1891
1462
 
1892
- load = async (opts?: { sync?: boolean }): Promise<void> => {
1463
+ load: LoadFn = async (opts?: { sync?: boolean }): Promise<void> => {
1893
1464
  this.latestLocation = this.parseLocation(this.latestLocation)
1894
1465
 
1895
1466
  let redirect: ResolvedRedirect | undefined
@@ -1899,7 +1470,7 @@ export class Router<
1899
1470
 
1900
1471
  // eslint-disable-next-line prefer-const
1901
1472
  loadPromise = new Promise<void>((resolve) => {
1902
- this.startReactTransition(async () => {
1473
+ this.startTransition(async () => {
1903
1474
  try {
1904
1475
  const next = this.latestLocation
1905
1476
  const prevLocation = this.state.resolvedLocation
@@ -2103,10 +1674,7 @@ export class Router<
2103
1674
  }
2104
1675
  }
2105
1676
 
2106
- updateMatch = (
2107
- id: string,
2108
- updater: (match: AnyRouteMatch) => AnyRouteMatch,
2109
- ) => {
1677
+ updateMatch: UpdateMatchFn = (id, updater) => {
2110
1678
  let updated!: AnyRouteMatch
2111
1679
  const isPending = this.state.pendingMatches?.find((d) => d.id === id)
2112
1680
  const isMatched = this.state.matches.find((d) => d.id === id)
@@ -2132,7 +1700,7 @@ export class Router<
2132
1700
  return updated
2133
1701
  }
2134
1702
 
2135
- getMatch = (matchId: string) => {
1703
+ getMatch: GetMatchFn = (matchId: string) => {
2136
1704
  return [
2137
1705
  ...this.state.cachedMatches,
2138
1706
  ...(this.state.pendingMatches ?? []),
@@ -2318,11 +1886,9 @@ export class Router<
2318
1886
  const prevLoadPromise = prev.loadPromise
2319
1887
  return {
2320
1888
  ...prev,
2321
- loadPromise: createControlledPromise<void>(
2322
- function demo() {
2323
- prevLoadPromise?.resolve()
2324
- },
2325
- ),
1889
+ loadPromise: createControlledPromise<void>(() => {
1890
+ prevLoadPromise?.resolve()
1891
+ }),
2326
1892
  beforeLoadPromise: createControlledPromise<void>(),
2327
1893
  }
2328
1894
  })
@@ -2699,12 +2265,17 @@ export class Router<
2699
2265
  return matches
2700
2266
  }
2701
2267
 
2702
- invalidate = <TRouter extends AnyRouter = typeof this>(opts?: {
2703
- filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean
2704
- sync?: boolean
2705
- }) => {
2268
+ invalidate: InvalidateFn<
2269
+ Router<
2270
+ TRouteTree,
2271
+ TTrailingSlashOption,
2272
+ TDefaultStructuralSharingOption,
2273
+ TRouterHistory,
2274
+ TDehydrated
2275
+ >
2276
+ > = (opts) => {
2706
2277
  const invalidate = (d: MakeRouteMatch<TRouteTree>) => {
2707
- if (opts?.filter?.(d as MakeRouteMatchUnion<TRouter>) ?? true) {
2278
+ if (opts?.filter?.(d as MakeRouteMatchUnion<this>) ?? true) {
2708
2279
  return {
2709
2280
  ...d,
2710
2281
  invalid: true,
@@ -2736,16 +2307,14 @@ export class Router<
2736
2307
  return redirect
2737
2308
  }
2738
2309
 
2739
- clearCache = <TRouter extends AnyRouter = typeof this>(opts?: {
2740
- filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean
2741
- }) => {
2310
+ clearCache: ClearCacheFn<this> = (opts) => {
2742
2311
  const filter = opts?.filter
2743
2312
  if (filter !== undefined) {
2744
2313
  this.__store.setState((s) => {
2745
2314
  return {
2746
2315
  ...s,
2747
2316
  cachedMatches: s.cachedMatches.filter(
2748
- (m) => !filter(m as MakeRouteMatchUnion<TRouter>),
2317
+ (m) => !filter(m as MakeRouteMatchUnion<this>),
2749
2318
  ),
2750
2319
  }
2751
2320
  })
@@ -2812,27 +2381,12 @@ export class Router<
2812
2381
  return route._componentsPromise
2813
2382
  }
2814
2383
 
2815
- preloadRoute = async <
2816
- TFrom extends RoutePaths<TRouteTree> | string = string,
2817
- TTo extends string | undefined = undefined,
2818
- TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,
2819
- TMaskTo extends string = '',
2820
- >(
2821
- opts: NavigateOptions<
2822
- Router<
2823
- TRouteTree,
2824
- TTrailingSlashOption,
2825
- TDefaultStructuralSharingOption,
2826
- TRouterHistory,
2827
- TDehydrated,
2828
- TSerializedError
2829
- >,
2830
- TFrom,
2831
- TTo,
2832
- TMaskFrom,
2833
- TMaskTo
2834
- >,
2835
- ): Promise<Array<AnyRouteMatch> | undefined> => {
2384
+ preloadRoute: PreloadRouteFn<
2385
+ TRouteTree,
2386
+ TTrailingSlashOption,
2387
+ TDefaultStructuralSharingOption,
2388
+ TRouterHistory
2389
+ > = async (opts) => {
2836
2390
  const next = this.buildLocation(opts as any)
2837
2391
 
2838
2392
  let matches = this.matchRoutes(next, {
@@ -2898,25 +2452,12 @@ export class Router<
2898
2452
  }
2899
2453
  }
2900
2454
 
2901
- matchRoute = <
2902
- TFrom extends RoutePaths<TRouteTree> = '/',
2903
- TTo extends string | undefined = undefined,
2904
- TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,
2905
- >(
2906
- location: ToOptions<
2907
- Router<
2908
- TRouteTree,
2909
- TTrailingSlashOption,
2910
- TDefaultStructuralSharingOption,
2911
- TRouterHistory,
2912
- TDehydrated,
2913
- TSerializedError
2914
- >,
2915
- TFrom,
2916
- TTo
2917
- >,
2918
- opts?: MatchRouteOptions,
2919
- ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {
2455
+ matchRoute: MatchRouteFn<
2456
+ TRouteTree,
2457
+ TTrailingSlashOption,
2458
+ TDefaultStructuralSharingOption,
2459
+ TRouterHistory
2460
+ > = (location, opts) => {
2920
2461
  const matchLocation = {
2921
2462
  ...location,
2922
2463
  to: location.to