@tanstack/router-core 1.121.16 → 1.121.17

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 (125) hide show
  1. package/package.json +1 -1
  2. package/src/redirect.ts +3 -0
  3. package/src/router.ts +15 -1
  4. package/dist/cjs/Matches.cjs +0 -13
  5. package/dist/cjs/Matches.cjs.map +0 -1
  6. package/dist/cjs/Matches.d.cts +0 -109
  7. package/dist/cjs/RouterProvider.d.cts +0 -26
  8. package/dist/cjs/defer.cjs +0 -25
  9. package/dist/cjs/defer.cjs.map +0 -1
  10. package/dist/cjs/defer.d.cts +0 -20
  11. package/dist/cjs/fileRoute.d.cts +0 -23
  12. package/dist/cjs/history.d.cts +0 -8
  13. package/dist/cjs/index.cjs +0 -79
  14. package/dist/cjs/index.cjs.map +0 -1
  15. package/dist/cjs/index.d.cts +0 -41
  16. package/dist/cjs/link.cjs +0 -5
  17. package/dist/cjs/link.cjs.map +0 -1
  18. package/dist/cjs/link.d.cts +0 -212
  19. package/dist/cjs/location.d.cts +0 -12
  20. package/dist/cjs/manifest.d.cts +0 -24
  21. package/dist/cjs/not-found.cjs +0 -13
  22. package/dist/cjs/not-found.cjs.map +0 -1
  23. package/dist/cjs/not-found.d.cts +0 -20
  24. package/dist/cjs/path.cjs +0 -412
  25. package/dist/cjs/path.cjs.map +0 -1
  26. package/dist/cjs/path.d.cts +0 -56
  27. package/dist/cjs/qss.cjs +0 -36
  28. package/dist/cjs/qss.cjs.map +0 -1
  29. package/dist/cjs/qss.d.cts +0 -31
  30. package/dist/cjs/redirect.cjs +0 -39
  31. package/dist/cjs/redirect.cjs.map +0 -1
  32. package/dist/cjs/redirect.d.cts +0 -41
  33. package/dist/cjs/root.cjs +0 -5
  34. package/dist/cjs/root.cjs.map +0 -1
  35. package/dist/cjs/root.d.cts +0 -2
  36. package/dist/cjs/route.cjs +0 -119
  37. package/dist/cjs/route.cjs.map +0 -1
  38. package/dist/cjs/route.d.cts +0 -432
  39. package/dist/cjs/routeInfo.d.cts +0 -54
  40. package/dist/cjs/router.cjs +0 -1792
  41. package/dist/cjs/router.cjs.map +0 -1
  42. package/dist/cjs/router.d.cts +0 -627
  43. package/dist/cjs/scroll-restoration.cjs +0 -207
  44. package/dist/cjs/scroll-restoration.cjs.map +0 -1
  45. package/dist/cjs/scroll-restoration.d.cts +0 -38
  46. package/dist/cjs/searchMiddleware.cjs +0 -42
  47. package/dist/cjs/searchMiddleware.cjs.map +0 -1
  48. package/dist/cjs/searchMiddleware.d.cts +0 -5
  49. package/dist/cjs/searchParams.cjs +0 -61
  50. package/dist/cjs/searchParams.cjs.map +0 -1
  51. package/dist/cjs/searchParams.d.cts +0 -7
  52. package/dist/cjs/serializer.d.cts +0 -22
  53. package/dist/cjs/structuralSharing.d.cts +0 -4
  54. package/dist/cjs/typePrimitives.d.cts +0 -65
  55. package/dist/cjs/useLoaderData.d.cts +0 -5
  56. package/dist/cjs/useLoaderDeps.d.cts +0 -5
  57. package/dist/cjs/useNavigate.d.cts +0 -3
  58. package/dist/cjs/useParams.d.cts +0 -5
  59. package/dist/cjs/useRouteContext.d.cts +0 -9
  60. package/dist/cjs/useSearch.d.cts +0 -5
  61. package/dist/cjs/utils.cjs +0 -165
  62. package/dist/cjs/utils.cjs.map +0 -1
  63. package/dist/cjs/utils.d.cts +0 -94
  64. package/dist/cjs/validators.d.cts +0 -51
  65. package/dist/esm/Matches.d.ts +0 -109
  66. package/dist/esm/Matches.js +0 -13
  67. package/dist/esm/Matches.js.map +0 -1
  68. package/dist/esm/RouterProvider.d.ts +0 -26
  69. package/dist/esm/defer.d.ts +0 -20
  70. package/dist/esm/defer.js +0 -25
  71. package/dist/esm/defer.js.map +0 -1
  72. package/dist/esm/fileRoute.d.ts +0 -23
  73. package/dist/esm/history.d.ts +0 -8
  74. package/dist/esm/index.d.ts +0 -41
  75. package/dist/esm/index.js +0 -79
  76. package/dist/esm/index.js.map +0 -1
  77. package/dist/esm/link.d.ts +0 -212
  78. package/dist/esm/link.js +0 -5
  79. package/dist/esm/link.js.map +0 -1
  80. package/dist/esm/location.d.ts +0 -12
  81. package/dist/esm/manifest.d.ts +0 -24
  82. package/dist/esm/not-found.d.ts +0 -20
  83. package/dist/esm/not-found.js +0 -13
  84. package/dist/esm/not-found.js.map +0 -1
  85. package/dist/esm/path.d.ts +0 -56
  86. package/dist/esm/path.js +0 -412
  87. package/dist/esm/path.js.map +0 -1
  88. package/dist/esm/qss.d.ts +0 -31
  89. package/dist/esm/qss.js +0 -36
  90. package/dist/esm/qss.js.map +0 -1
  91. package/dist/esm/redirect.d.ts +0 -41
  92. package/dist/esm/redirect.js +0 -39
  93. package/dist/esm/redirect.js.map +0 -1
  94. package/dist/esm/root.d.ts +0 -2
  95. package/dist/esm/root.js +0 -5
  96. package/dist/esm/root.js.map +0 -1
  97. package/dist/esm/route.d.ts +0 -432
  98. package/dist/esm/route.js +0 -119
  99. package/dist/esm/route.js.map +0 -1
  100. package/dist/esm/routeInfo.d.ts +0 -54
  101. package/dist/esm/router.d.ts +0 -627
  102. package/dist/esm/router.js +0 -1792
  103. package/dist/esm/router.js.map +0 -1
  104. package/dist/esm/scroll-restoration.d.ts +0 -38
  105. package/dist/esm/scroll-restoration.js +0 -207
  106. package/dist/esm/scroll-restoration.js.map +0 -1
  107. package/dist/esm/searchMiddleware.d.ts +0 -5
  108. package/dist/esm/searchMiddleware.js +0 -42
  109. package/dist/esm/searchMiddleware.js.map +0 -1
  110. package/dist/esm/searchParams.d.ts +0 -7
  111. package/dist/esm/searchParams.js +0 -61
  112. package/dist/esm/searchParams.js.map +0 -1
  113. package/dist/esm/serializer.d.ts +0 -22
  114. package/dist/esm/structuralSharing.d.ts +0 -4
  115. package/dist/esm/typePrimitives.d.ts +0 -65
  116. package/dist/esm/useLoaderData.d.ts +0 -5
  117. package/dist/esm/useLoaderDeps.d.ts +0 -5
  118. package/dist/esm/useNavigate.d.ts +0 -3
  119. package/dist/esm/useParams.d.ts +0 -5
  120. package/dist/esm/useRouteContext.d.ts +0 -9
  121. package/dist/esm/useSearch.d.ts +0 -5
  122. package/dist/esm/utils.d.ts +0 -94
  123. package/dist/esm/utils.js +0 -165
  124. package/dist/esm/utils.js.map +0 -1
  125. package/dist/esm/validators.d.ts +0 -51
@@ -1,627 +0,0 @@
1
- import { Store } from '@tanstack/store';
2
- import { SearchParser, SearchSerializer } from './searchParams.js';
3
- import { AnyRedirect, ResolvedRedirect } from './redirect.js';
4
- import { HistoryLocation, HistoryState, ParsedHistoryState, RouterHistory } from '@tanstack/history';
5
- import { Awaitable, ControlledPromise, NoInfer, NonNullableUpdater, PickAsRequired, Updater } from './utils.js';
6
- import { ParsedLocation } from './location.js';
7
- import { DeferredPromiseState } from './defer.js';
8
- import { AnyContext, AnyRoute, AnyRouteWithContext, MakeRemountDepsOptionsUnion, RouteMask } from './route.js';
9
- import { FullSearchSchema, RouteById, RoutePaths, RoutesById, RoutesByPath } from './routeInfo.js';
10
- import { AnyRouteMatch, MakeRouteMatch, MakeRouteMatchUnion, MatchRouteOptions } from './Matches.js';
11
- import { BuildLocationFn, CommitLocationOptions, NavigateFn } from './RouterProvider.js';
12
- import { Manifest } from './manifest.js';
13
- import { StartSerializer } from './serializer.js';
14
- import { AnySchema } from './validators.js';
15
- import { NavigateOptions, ResolveRelativePath, ToOptions } from './link.js';
16
- import { NotFoundError } from './not-found.js';
17
- declare global {
18
- interface Window {
19
- __TSR_ROUTER__?: AnyRouter;
20
- }
21
- }
22
- export type ControllablePromise<T = any> = Promise<T> & {
23
- resolve: (value: T) => void;
24
- reject: (value?: any) => void;
25
- };
26
- export type InjectedHtmlEntry = Promise<string>;
27
- export interface DefaultRegister {
28
- router: AnyRouter;
29
- }
30
- export interface Register extends DefaultRegister {
31
- }
32
- export type RegisteredRouter = Register['router'];
33
- export type DefaultRemountDepsFn<TRouteTree extends AnyRoute> = (opts: MakeRemountDepsOptionsUnion<TRouteTree>) => any;
34
- export interface DefaultRouterOptionsExtensions {
35
- }
36
- export interface RouterOptionsExtensions extends DefaultRouterOptionsExtensions {
37
- }
38
- export interface RouterOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean = false, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>> extends RouterOptionsExtensions {
39
- /**
40
- * The history object that will be used to manage the browser history.
41
- *
42
- * If not provided, a new createBrowserHistory instance will be created and used.
43
- *
44
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)
45
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)
46
- */
47
- history?: TRouterHistory;
48
- /**
49
- * A function that will be used to stringify search params when generating links.
50
- *
51
- * @default defaultStringifySearch
52
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#stringifysearch-method)
53
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
54
- */
55
- stringifySearch?: SearchSerializer;
56
- /**
57
- * A function that will be used to parse search params when parsing the current location.
58
- *
59
- * @default defaultParseSearch
60
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#parsesearch-method)
61
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
62
- */
63
- parseSearch?: SearchParser;
64
- /**
65
- * If `false`, routes will not be preloaded by default in any way.
66
- *
67
- * If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a `<Link>`.
68
- *
69
- * If `'viewport'`, routes will be preloaded by default when they are within the viewport.
70
- *
71
- * @default false
72
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreload-property)
73
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
74
- */
75
- defaultPreload?: false | 'intent' | 'viewport' | 'render';
76
- /**
77
- * The delay in milliseconds that a route must be hovered over or touched before it is preloaded.
78
- *
79
- * @default 50
80
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloaddelay-property)
81
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay)
82
- */
83
- defaultPreloadDelay?: number;
84
- /**
85
- * The default `preloadIntentProximity` a route should use if no preloadIntentProximity is provided.
86
- *
87
- * @default 0
88
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadintentproximity-property)
89
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-intent-proximity)
90
- */
91
- defaultPreloadIntentProximity?: number;
92
- /**
93
- * The default `pendingMs` a route should use if no pendingMs is provided.
94
- *
95
- * @default 1000
96
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingms-property)
97
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
98
- */
99
- defaultPendingMs?: number;
100
- /**
101
- * The default `pendingMinMs` a route should use if no pendingMinMs is provided.
102
- *
103
- * @default 500
104
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingminms-property)
105
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
106
- */
107
- defaultPendingMinMs?: number;
108
- /**
109
- * 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.
110
- *
111
- * @default 0
112
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstaletime-property)
113
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
114
- */
115
- defaultStaleTime?: number;
116
- /**
117
- * The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.
118
- *
119
- * @default 30_000 `(30 seconds)`
120
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadstaletime-property)
121
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
122
- */
123
- defaultPreloadStaleTime?: number;
124
- /**
125
- * The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.
126
- *
127
- * @default 1_800_000 `(30 minutes)`
128
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadgctime-property)
129
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
130
- */
131
- defaultPreloadGcTime?: number;
132
- /**
133
- * If `true`, route navigations will called using `document.startViewTransition()`.
134
- *
135
- * If the browser does not support this api, this option will be ignored.
136
- *
137
- * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for more information on how this function works.
138
- *
139
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultviewtransition-property)
140
- */
141
- defaultViewTransition?: boolean | ViewTransitionOptions;
142
- /**
143
- * The default `hashScrollIntoView` a route should use if no hashScrollIntoView is provided while navigating
144
- *
145
- * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) for more information on `ScrollIntoViewOptions`.
146
- *
147
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulthashscrollintoview-property)
148
- */
149
- defaultHashScrollIntoView?: boolean | ScrollIntoViewOptions;
150
- /**
151
- * @default 'fuzzy'
152
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundmode-property)
153
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#the-notfoundmode-option)
154
- */
155
- notFoundMode?: 'root' | 'fuzzy';
156
- /**
157
- * The default `gcTime` a route should use if no gcTime is provided.
158
- *
159
- * @default 1_800_000 `(30 minutes)`
160
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultgctime-property)
161
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
162
- */
163
- defaultGcTime?: number;
164
- /**
165
- * If `true`, all routes will be matched as case-sensitive.
166
- *
167
- * @default false
168
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)
169
- */
170
- caseSensitive?: boolean;
171
- /**
172
- *
173
- * The route tree that will be used to configure the router instance.
174
- *
175
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)
176
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/routing/route-trees)
177
- */
178
- routeTree?: TRouteTree;
179
- /**
180
- * The basepath for then entire router. This is useful for mounting a router instance at a subpath.
181
- *
182
- * @default '/'
183
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)
184
- */
185
- basepath?: string;
186
- /**
187
- * The root context that will be provided to all routes in the route tree.
188
- *
189
- * This can be used to provide a context to all routes in the tree without having to provide it to each route individually.
190
- *
191
- * Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).
192
- *
193
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#context-property)
194
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)
195
- */
196
- context?: InferRouterContext<TRouteTree>;
197
- /**
198
- * A function that will be called when the router is dehydrated.
199
- *
200
- * The return value of this function will be serialized and stored in the router's dehydrated state.
201
- *
202
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)
203
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
204
- */
205
- dehydrate?: () => TDehydrated;
206
- /**
207
- * A function that will be called when the router is hydrated.
208
- *
209
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#hydrate-method)
210
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
211
- */
212
- hydrate?: (dehydrated: TDehydrated) => Awaitable<void>;
213
- /**
214
- * An array of route masks that will be used to mask routes in the route tree.
215
- *
216
- * 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.
217
- *
218
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routemasks-property)
219
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking)
220
- */
221
- routeMasks?: Array<RouteMask<TRouteTree>>;
222
- /**
223
- * If `true`, route masks will, by default, be removed when the page is reloaded.
224
- *
225
- * 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.
226
- *
227
- * @default false
228
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#unmaskonreload-property)
229
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking#unmasking-on-page-reload)
230
- */
231
- unmaskOnReload?: boolean;
232
- /**
233
- * Use `notFoundComponent` instead.
234
- *
235
- * @deprecated
236
- * See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.
237
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundroute-property)
238
- */
239
- notFoundRoute?: AnyRoute;
240
- /**
241
- * Configures how trailing slashes are treated.
242
- *
243
- * - `'always'` will add a trailing slash if not present
244
- * - `'never'` will remove the trailing slash if present
245
- * - `'preserve'` will not modify the trailing slash.
246
- *
247
- * @default 'never'
248
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)
249
- */
250
- trailingSlash?: TTrailingSlashOption;
251
- /**
252
- * 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.
253
- *
254
- * @default typeof document !== 'undefined'
255
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#isserver-property)
256
- */
257
- isServer?: boolean;
258
- defaultSsr?: boolean;
259
- search?: {
260
- /**
261
- * Configures how unknown search params (= not returned by any `validateSearch`) are treated.
262
- *
263
- * @default false
264
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#search.strict-property)
265
- */
266
- strict?: boolean;
267
- };
268
- /**
269
- * Configures whether structural sharing is enabled by default for fine-grained selectors.
270
- *
271
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstructuralsharing-property)
272
- */
273
- defaultStructuralSharing?: TDefaultStructuralSharingOption;
274
- /**
275
- * Configures which URI characters are allowed in path params that would ordinarily be escaped by encodeURIComponent.
276
- *
277
- * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#pathparamsallowedcharacters-property)
278
- * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/path-params#allowed-characters)
279
- */
280
- pathParamsAllowedCharacters?: Array<';' | ':' | '@' | '&' | '=' | '+' | '$' | ','>;
281
- defaultRemountDeps?: DefaultRemountDepsFn<TRouteTree>;
282
- /**
283
- * If `true`, scroll restoration will be enabled
284
- *
285
- * @default false
286
- */
287
- scrollRestoration?: boolean;
288
- /**
289
- * A function that will be called to get the key for the scroll restoration cache.
290
- *
291
- * @default (location) => location.href
292
- */
293
- getScrollRestorationKey?: (location: ParsedLocation) => string;
294
- /**
295
- * The default behavior for scroll restoration.
296
- *
297
- * @default 'auto'
298
- */
299
- scrollRestorationBehavior?: ScrollBehavior;
300
- /**
301
- * An array of selectors that will be used to scroll to the top of the page in addition to `window`
302
- *
303
- * @default ['window']
304
- */
305
- scrollToTopSelectors?: Array<string | (() => Element | null | undefined)>;
306
- }
307
- export interface RouterState<in out TRouteTree extends AnyRoute = AnyRoute, in out TRouteMatch = MakeRouteMatchUnion> {
308
- status: 'pending' | 'idle';
309
- loadedAt: number;
310
- isLoading: boolean;
311
- isTransitioning: boolean;
312
- matches: Array<TRouteMatch>;
313
- pendingMatches?: Array<TRouteMatch>;
314
- cachedMatches: Array<TRouteMatch>;
315
- location: ParsedLocation<FullSearchSchema<TRouteTree>>;
316
- resolvedLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>;
317
- statusCode: number;
318
- redirect?: AnyRedirect;
319
- }
320
- export interface BuildNextOptions {
321
- to?: string | number | null;
322
- params?: true | Updater<unknown>;
323
- search?: true | Updater<unknown>;
324
- hash?: true | Updater<string>;
325
- state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>;
326
- mask?: {
327
- to?: string | number | null;
328
- params?: true | Updater<unknown>;
329
- search?: true | Updater<unknown>;
330
- hash?: true | Updater<string>;
331
- state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>;
332
- unmaskOnReload?: boolean;
333
- };
334
- from?: string;
335
- href?: string;
336
- _fromLocation?: ParsedLocation;
337
- unsafeRelative?: 'path';
338
- }
339
- type NavigationEventInfo = {
340
- fromLocation?: ParsedLocation;
341
- toLocation: ParsedLocation;
342
- pathChanged: boolean;
343
- hrefChanged: boolean;
344
- hashChanged: boolean;
345
- };
346
- export type RouterEvents = {
347
- onBeforeNavigate: {
348
- type: 'onBeforeNavigate';
349
- } & NavigationEventInfo;
350
- onBeforeLoad: {
351
- type: 'onBeforeLoad';
352
- } & NavigationEventInfo;
353
- onLoad: {
354
- type: 'onLoad';
355
- } & NavigationEventInfo;
356
- onResolved: {
357
- type: 'onResolved';
358
- } & NavigationEventInfo;
359
- onBeforeRouteMount: {
360
- type: 'onBeforeRouteMount';
361
- } & NavigationEventInfo;
362
- onInjectedHtml: {
363
- type: 'onInjectedHtml';
364
- promise: Promise<string>;
365
- };
366
- onRendered: {
367
- type: 'onRendered';
368
- } & NavigationEventInfo;
369
- };
370
- export type RouterEvent = RouterEvents[keyof RouterEvents];
371
- export type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void;
372
- export type RouterListener<TRouterEvent extends RouterEvent> = {
373
- eventType: TRouterEvent['type'];
374
- fn: ListenerFn<TRouterEvent>;
375
- };
376
- export interface MatchRoutesOpts {
377
- preload?: boolean;
378
- throwOnError?: boolean;
379
- _buildLocation?: boolean;
380
- dest?: BuildNextOptions;
381
- }
382
- export type InferRouterContext<TRouteTree extends AnyRoute> = TRouteTree['types']['routerContext'];
383
- export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends InferRouterContext<TRouteTree> ? {
384
- context?: InferRouterContext<TRouteTree>;
385
- } : {
386
- context: InferRouterContext<TRouteTree>;
387
- };
388
- export type RouterConstructorOptions<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory, TDehydrated extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>, 'context'> & RouterContextOptions<TRouteTree>;
389
- export interface RouterErrorSerializer<TSerializedError> {
390
- serialize: (err: unknown) => TSerializedError;
391
- deserialize: (err: TSerializedError) => unknown;
392
- }
393
- export type PreloadRouteFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory> = <TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string | undefined = undefined, TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''>(opts: NavigateOptions<RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<Array<AnyRouteMatch> | undefined>;
394
- export type MatchRouteFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory> = <TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string | undefined = undefined, TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>, TFrom, TTo>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>['types']['allParams'];
395
- export type UpdateFn<TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption, TDefaultStructuralSharingOption extends boolean, TRouterHistory extends RouterHistory, TDehydrated extends Record<string, any>> = (newOptions: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>) => void;
396
- export type InvalidateFn<TRouter extends AnyRouter> = (opts?: {
397
- filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
398
- sync?: boolean;
399
- }) => Promise<void>;
400
- export type ParseLocationFn<TRouteTree extends AnyRoute> = (previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>, locationToParse?: HistoryLocation) => ParsedLocation<FullSearchSchema<TRouteTree>>;
401
- export type GetMatchRoutesFn = (pathname: string, routePathname: string | undefined) => {
402
- matchedRoutes: Array<AnyRoute>;
403
- routeParams: Record<string, string>;
404
- foundRoute: AnyRoute | undefined;
405
- };
406
- export type EmitFn = (routerEvent: RouterEvent) => void;
407
- export type LoadFn = (opts?: {
408
- sync?: boolean;
409
- }) => Promise<void>;
410
- export type CommitLocationFn = ({ viewTransition, ignoreBlocker, ...next }: ParsedLocation & CommitLocationOptions) => Promise<void>;
411
- export type StartTransitionFn = (fn: () => void) => void;
412
- export type SubscribeFn = <TType extends keyof RouterEvents>(eventType: TType, fn: ListenerFn<RouterEvents[TType]>) => () => void;
413
- export interface MatchRoutesFn {
414
- (pathname: string, locationSearch: AnySchema, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
415
- (next: ParsedLocation, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
416
- (pathnameOrNext: string | ParsedLocation, locationSearchOrOpts?: AnySchema | MatchRoutesOpts, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
417
- }
418
- export type GetMatchFn = (matchId: string) => AnyRouteMatch | undefined;
419
- export type UpdateMatchFn = (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => AnyRouteMatch;
420
- export type LoadRouteChunkFn = (route: AnyRoute) => Promise<Array<void>>;
421
- export type ResolveRedirect = (err: AnyRedirect) => ResolvedRedirect;
422
- export type ClearCacheFn<TRouter extends AnyRouter> = (opts?: {
423
- filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
424
- }) => void;
425
- export interface ServerSrr {
426
- injectedHtml: Array<InjectedHtmlEntry>;
427
- injectHtml: (getHtml: () => string | Promise<string>) => Promise<void>;
428
- injectScript: (getScript: () => string | Promise<string>, opts?: {
429
- logScript?: boolean;
430
- }) => Promise<void>;
431
- streamValue: (key: string, value: any) => void;
432
- streamedKeys: Set<string>;
433
- onMatchSettled: (opts: {
434
- router: AnyRouter;
435
- match: AnyRouteMatch;
436
- }) => any;
437
- }
438
- export type AnyRouterWithContext<TContext> = RouterCore<AnyRouteWithContext<TContext>, any, any, any, any>;
439
- export type AnyRouter = RouterCore<any, any, any, any, any>;
440
- export interface ViewTransitionOptions {
441
- types: Array<string> | ((locationChangeInfo: {
442
- fromLocation?: ParsedLocation;
443
- toLocation: ParsedLocation;
444
- pathChanged: boolean;
445
- hrefChanged: boolean;
446
- hashChanged: boolean;
447
- }) => Array<string>);
448
- }
449
- export declare function defaultSerializeError(err: unknown): {
450
- name: string;
451
- message: string;
452
- } | {
453
- data: unknown;
454
- };
455
- export interface ExtractedBaseEntry {
456
- dataType: '__beforeLoadContext' | 'loaderData';
457
- type: string;
458
- path: Array<string>;
459
- id: number;
460
- matchIndex: number;
461
- }
462
- export interface ExtractedStream extends ExtractedBaseEntry {
463
- type: 'stream';
464
- streamState: StreamState;
465
- }
466
- export interface ExtractedPromise extends ExtractedBaseEntry {
467
- type: 'promise';
468
- promiseState: DeferredPromiseState<any>;
469
- }
470
- export type ExtractedEntry = ExtractedStream | ExtractedPromise;
471
- export type StreamState = {
472
- promises: Array<ControlledPromise<string | null>>;
473
- };
474
- export type TrailingSlashOption = 'always' | 'never' | 'preserve';
475
- export declare function getLocationChangeInfo(routerState: {
476
- resolvedLocation?: ParsedLocation;
477
- location: ParsedLocation;
478
- }): {
479
- fromLocation: ParsedLocation<{}> | undefined;
480
- toLocation: ParsedLocation<{}>;
481
- pathChanged: boolean;
482
- hrefChanged: boolean;
483
- hashChanged: boolean;
484
- };
485
- export type CreateRouterFn = <TRouteTree extends AnyRoute, TTrailingSlashOption extends TrailingSlashOption = 'never', TDefaultStructuralSharingOption extends boolean = false, TRouterHistory extends RouterHistory = RouterHistory, TDehydrated extends Record<string, any> = Record<string, any>>(options: undefined extends number ? 'strictNullChecks must be enabled in tsconfig.json' : RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>) => RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>;
486
- export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption, in out TDefaultStructuralSharingOption extends boolean, in out TRouterHistory extends RouterHistory = RouterHistory, in out TDehydrated extends Record<string, any> = Record<string, any>> {
487
- tempLocationKey: string | undefined;
488
- resetNextScroll: boolean;
489
- shouldViewTransition?: boolean | ViewTransitionOptions;
490
- isViewTransitionTypesSupported?: boolean;
491
- subscribers: Set<RouterListener<RouterEvent>>;
492
- viewTransitionPromise?: ControlledPromise<true>;
493
- isScrollRestoring: boolean;
494
- isScrollRestorationSetup: boolean;
495
- __store: Store<RouterState<TRouteTree>>;
496
- options: PickAsRequired<RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>, 'stringifySearch' | 'parseSearch' | 'context'>;
497
- history: TRouterHistory;
498
- latestLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
499
- basepath: string;
500
- routeTree: TRouteTree;
501
- routesById: RoutesById<TRouteTree>;
502
- routesByPath: RoutesByPath<TRouteTree>;
503
- flatRoutes: Array<AnyRoute>;
504
- isServer: boolean;
505
- pathParamsDecodeCharMap?: Map<string, string>;
506
- /**
507
- * @deprecated Use the `createRouter` function instead
508
- */
509
- constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>);
510
- startTransition: StartTransitionFn;
511
- isShell: boolean;
512
- update: UpdateFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>;
513
- get state(): RouterState<TRouteTree, import('./Matches.js').RouteMatch<any, any, any, any, any, any, any>>;
514
- buildRouteTree: () => void;
515
- subscribe: SubscribeFn;
516
- emit: EmitFn;
517
- parseLocation: ParseLocationFn<TRouteTree>;
518
- resolvePathWithBase: (from: string, path: string) => string;
519
- get looseRoutesById(): Record<string, AnyRoute>;
520
- /**
521
- @deprecated use the following signature instead
522
- ```ts
523
- matchRoutes (
524
- next: ParsedLocation,
525
- opts?: { preload?: boolean; throwOnError?: boolean },
526
- ): Array<AnyRouteMatch>;
527
- ```
528
- */
529
- matchRoutes: MatchRoutesFn;
530
- private matchRoutesInternal;
531
- getMatchedRoutes: GetMatchRoutesFn;
532
- cancelMatch: (id: string) => void;
533
- cancelMatches: () => void;
534
- buildLocation: BuildLocationFn;
535
- commitLocationPromise: undefined | ControlledPromise<void>;
536
- commitLocation: CommitLocationFn;
537
- buildAndCommitLocation: ({ replace, resetScroll, hashScrollIntoView, viewTransition, ignoreBlocker, href, ...rest }?: BuildNextOptions & CommitLocationOptions) => Promise<void>;
538
- navigate: NavigateFn;
539
- latestLoadPromise: undefined | Promise<void>;
540
- beforeLoad: () => void;
541
- load: LoadFn;
542
- startViewTransition: (fn: () => Promise<void>) => void;
543
- updateMatch: UpdateMatchFn;
544
- getMatch: GetMatchFn;
545
- loadMatches: ({ location, matches, preload: allPreload, onReady, updateMatch, sync, }: {
546
- location: ParsedLocation;
547
- matches: Array<AnyRouteMatch>;
548
- preload?: boolean;
549
- onReady?: () => Promise<void>;
550
- updateMatch?: (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => void;
551
- getMatch?: (matchId: string) => AnyRouteMatch | undefined;
552
- sync?: boolean;
553
- }) => Promise<Array<MakeRouteMatch>>;
554
- invalidate: InvalidateFn<RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>>;
555
- resolveRedirect: (redirect: AnyRedirect) => AnyRedirect;
556
- clearCache: ClearCacheFn<this>;
557
- clearExpiredCache: () => void;
558
- loadRouteChunk: (route: AnyRoute) => Promise<void[]>;
559
- preloadRoute: PreloadRouteFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>;
560
- matchRoute: MatchRouteFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>;
561
- ssr?: {
562
- manifest: Manifest | undefined;
563
- serializer: StartSerializer;
564
- };
565
- serverSsr?: {
566
- injectedHtml: Array<InjectedHtmlEntry>;
567
- injectHtml: (getHtml: () => string | Promise<string>) => Promise<void>;
568
- injectScript: (getScript: () => string | Promise<string>, opts?: {
569
- logScript?: boolean;
570
- }) => Promise<void>;
571
- streamValue: (key: string, value: any) => void;
572
- streamedKeys: Set<string>;
573
- onMatchSettled: (opts: {
574
- router: AnyRouter;
575
- match: AnyRouteMatch;
576
- }) => any;
577
- };
578
- clientSsr?: {
579
- getStreamedValue: <T>(key: string) => T | undefined;
580
- };
581
- _handleNotFound: (matches: Array<AnyRouteMatch>, err: NotFoundError, { updateMatch, }?: {
582
- updateMatch?: (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => void;
583
- }) => void;
584
- hasNotFoundMatch: () => boolean;
585
- }
586
- export declare class SearchParamError extends Error {
587
- }
588
- export declare class PathParamError extends Error {
589
- }
590
- export declare function lazyFn<T extends Record<string, (...args: Array<any>) => any>, TKey extends keyof T = 'default'>(fn: () => Promise<T>, key?: TKey): (...args: Parameters<T[TKey]>) => Promise<Awaited<ReturnType<T[TKey]>>>;
591
- export declare function getInitialRouterState(location: ParsedLocation): RouterState<any>;
592
- export declare const componentTypes: readonly ["component", "errorComponent", "pendingComponent", "notFoundComponent"];
593
- interface RouteLike {
594
- id: string;
595
- isRoot?: boolean;
596
- path?: string;
597
- fullPath: string;
598
- rank?: number;
599
- parentRoute?: RouteLike;
600
- children?: Array<RouteLike>;
601
- options?: {
602
- caseSensitive?: boolean;
603
- };
604
- }
605
- export type ProcessRouteTreeResult<TRouteLike extends RouteLike> = {
606
- routesById: Record<string, TRouteLike>;
607
- routesByPath: Record<string, TRouteLike>;
608
- flatRoutes: Array<TRouteLike>;
609
- };
610
- export declare function processRouteTree<TRouteLike extends RouteLike>({ routeTree, initRoute, }: {
611
- routeTree: TRouteLike;
612
- initRoute?: (route: TRouteLike, index: number) => void;
613
- }): ProcessRouteTreeResult<TRouteLike>;
614
- export declare function getMatchedRoutes<TRouteLike extends RouteLike>({ pathname, routePathname, basepath, caseSensitive, routesByPath, routesById, flatRoutes, }: {
615
- pathname: string;
616
- routePathname?: string;
617
- basepath: string;
618
- caseSensitive?: boolean;
619
- routesByPath: Record<string, TRouteLike>;
620
- routesById: Record<string, TRouteLike>;
621
- flatRoutes: Array<TRouteLike>;
622
- }): {
623
- matchedRoutes: TRouteLike[];
624
- routeParams: Record<string, string>;
625
- foundRoute: TRouteLike | undefined;
626
- };
627
- export {};