@tanstack/router-core 1.112.0 → 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.
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +6 -0
- package/dist/cjs/fileRoute.d.cts +9 -2
- package/dist/cjs/index.d.cts +4 -4
- package/dist/cjs/route.d.cts +57 -14
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +469 -7
- package/dist/esm/Matches.d.ts +6 -0
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +9 -2
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/route.d.ts +57 -14
- package/dist/esm/router.d.ts +469 -7
- package/dist/esm/router.js.map +1 -1
- package/package.json +2 -2
- package/src/Matches.ts +7 -0
- package/src/fileRoute.ts +34 -15
- package/src/index.ts +45 -1
- package/src/route.ts +240 -39
- package/src/router.ts +694 -6
package/dist/cjs/router.d.cts
CHANGED
|
@@ -1,21 +1,482 @@
|
|
|
1
1
|
import { ParsedLocation } from './location.cjs';
|
|
2
2
|
import { DeferredPromiseState } from './defer.cjs';
|
|
3
|
-
import { ControlledPromise } from './utils.cjs';
|
|
4
|
-
import { AnyRoute, AnyRouteWithContext } from './route.cjs';
|
|
3
|
+
import { ControlledPromise, NoInfer, NonNullableUpdater, Updater } from './utils.cjs';
|
|
4
|
+
import { AnyContext, AnyRoute, AnyRouteWithContext, MakeRemountDepsOptionsUnion, RouteMask } from './route.cjs';
|
|
5
|
+
import { Store } from '@tanstack/store';
|
|
6
|
+
import { FullSearchSchema, RouteById, RoutePaths, RoutesById, RoutesByPath } from './routeInfo.cjs';
|
|
7
|
+
import { AnyRouteMatch, MakeRouteMatchUnion, MatchRouteOptions } from './Matches.cjs';
|
|
8
|
+
import { AnyRedirect, ResolvedRedirect } from './redirect.cjs';
|
|
9
|
+
import { BuildLocationFn, CommitLocationOptions, NavigateFn } from './RouterProvider.cjs';
|
|
10
|
+
import { HistoryLocation, HistoryState, ParsedHistoryState, RouterHistory } from '@tanstack/history';
|
|
11
|
+
import { Manifest } from './manifest.cjs';
|
|
12
|
+
import { StartSerializer } from './serializer.cjs';
|
|
13
|
+
import { AnySchema } from './validators.cjs';
|
|
14
|
+
import { NavigateOptions, ResolveRelativePath, ToOptions } from './link.cjs';
|
|
15
|
+
import { SearchParser, SearchSerializer } from './searchParams.cjs';
|
|
16
|
+
declare global {
|
|
17
|
+
interface Window {
|
|
18
|
+
__TSR_ROUTER__?: AnyRouter;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export type ControllablePromise<T = any> = Promise<T> & {
|
|
22
|
+
resolve: (value: T) => void;
|
|
23
|
+
reject: (value?: any) => void;
|
|
24
|
+
};
|
|
25
|
+
export type InjectedHtmlEntry = Promise<string>;
|
|
5
26
|
export interface Register {
|
|
6
27
|
}
|
|
7
28
|
export type RegisteredRouter = Register extends {
|
|
8
29
|
router: infer TRouter extends AnyRouter;
|
|
9
30
|
} ? TRouter : AnyRouter;
|
|
10
|
-
export
|
|
31
|
+
export type DefaultRemountDepsFn<TRouteTree extends AnyRoute> = (opts: MakeRemountDepsOptionsUnion<TRouteTree>) => any;
|
|
32
|
+
export interface DefaultRouterOptionsExtensions {
|
|
33
|
+
}
|
|
34
|
+
export interface RouterOptionsExtensions extends DefaultRouterOptionsExtensions {
|
|
35
|
+
}
|
|
36
|
+
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 {
|
|
37
|
+
/**
|
|
38
|
+
* The history object that will be used to manage the browser history.
|
|
39
|
+
*
|
|
40
|
+
* If not provided, a new createBrowserHistory instance will be created and used.
|
|
41
|
+
*
|
|
42
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)
|
|
43
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)
|
|
44
|
+
*/
|
|
45
|
+
history?: TRouterHistory;
|
|
46
|
+
/**
|
|
47
|
+
* A function that will be used to stringify search params when generating links.
|
|
48
|
+
*
|
|
49
|
+
* @default defaultStringifySearch
|
|
50
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#stringifysearch-method)
|
|
51
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
|
|
52
|
+
*/
|
|
53
|
+
stringifySearch?: SearchSerializer;
|
|
54
|
+
/**
|
|
55
|
+
* A function that will be used to parse search params when parsing the current location.
|
|
56
|
+
*
|
|
57
|
+
* @default defaultParseSearch
|
|
58
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#parsesearch-method)
|
|
59
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)
|
|
60
|
+
*/
|
|
61
|
+
parseSearch?: SearchParser;
|
|
62
|
+
/**
|
|
63
|
+
* If `false`, routes will not be preloaded by default in any way.
|
|
64
|
+
*
|
|
65
|
+
* If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a `<Link>`.
|
|
66
|
+
*
|
|
67
|
+
* If `'viewport'`, routes will be preloaded by default when they are within the viewport.
|
|
68
|
+
*
|
|
69
|
+
* @default false
|
|
70
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreload-property)
|
|
71
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
|
|
72
|
+
*/
|
|
73
|
+
defaultPreload?: false | 'intent' | 'viewport' | 'render';
|
|
74
|
+
/**
|
|
75
|
+
* The delay in milliseconds that a route must be hovered over or touched before it is preloaded.
|
|
76
|
+
*
|
|
77
|
+
* @default 50
|
|
78
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloaddelay-property)
|
|
79
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay)
|
|
80
|
+
*/
|
|
81
|
+
defaultPreloadDelay?: number;
|
|
82
|
+
/**
|
|
83
|
+
* The default `pendingMs` a route should use if no pendingMs is provided.
|
|
84
|
+
*
|
|
85
|
+
* @default 1000
|
|
86
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingms-property)
|
|
87
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
|
|
88
|
+
*/
|
|
89
|
+
defaultPendingMs?: number;
|
|
90
|
+
/**
|
|
91
|
+
* The default `pendingMinMs` a route should use if no pendingMinMs is provided.
|
|
92
|
+
*
|
|
93
|
+
* @default 500
|
|
94
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingminms-property)
|
|
95
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)
|
|
96
|
+
*/
|
|
97
|
+
defaultPendingMinMs?: number;
|
|
98
|
+
/**
|
|
99
|
+
* 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.
|
|
100
|
+
*
|
|
101
|
+
* @default 0
|
|
102
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstaletime-property)
|
|
103
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
|
|
104
|
+
*/
|
|
105
|
+
defaultStaleTime?: number;
|
|
106
|
+
/**
|
|
107
|
+
* The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.
|
|
108
|
+
*
|
|
109
|
+
* @default 30_000 `(30 seconds)`
|
|
110
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadstaletime-property)
|
|
111
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
|
|
112
|
+
*/
|
|
113
|
+
defaultPreloadStaleTime?: number;
|
|
114
|
+
/**
|
|
115
|
+
* The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.
|
|
116
|
+
*
|
|
117
|
+
* @default 1_800_000 `(30 minutes)`
|
|
118
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadgctime-property)
|
|
119
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)
|
|
120
|
+
*/
|
|
121
|
+
defaultPreloadGcTime?: number;
|
|
122
|
+
/**
|
|
123
|
+
* If `true`, route navigations will called using `document.startViewTransition()`.
|
|
124
|
+
*
|
|
125
|
+
* If the browser does not support this api, this option will be ignored.
|
|
126
|
+
*
|
|
127
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for more information on how this function works.
|
|
128
|
+
*
|
|
129
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultviewtransition-property)
|
|
130
|
+
*/
|
|
131
|
+
defaultViewTransition?: boolean | ViewTransitionOptions;
|
|
132
|
+
/**
|
|
133
|
+
* The default `hashScrollIntoView` a route should use if no hashScrollIntoView is provided while navigating
|
|
134
|
+
*
|
|
135
|
+
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) for more information on `ScrollIntoViewOptions`.
|
|
136
|
+
*
|
|
137
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulthashscrollintoview-property)
|
|
138
|
+
*/
|
|
139
|
+
defaultHashScrollIntoView?: boolean | ScrollIntoViewOptions;
|
|
140
|
+
/**
|
|
141
|
+
* @default 'fuzzy'
|
|
142
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundmode-property)
|
|
143
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#the-notfoundmode-option)
|
|
144
|
+
*/
|
|
145
|
+
notFoundMode?: 'root' | 'fuzzy';
|
|
146
|
+
/**
|
|
147
|
+
* The default `gcTime` a route should use if no gcTime is provided.
|
|
148
|
+
*
|
|
149
|
+
* @default 1_800_000 `(30 minutes)`
|
|
150
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultgctime-property)
|
|
151
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)
|
|
152
|
+
*/
|
|
153
|
+
defaultGcTime?: number;
|
|
154
|
+
/**
|
|
155
|
+
* If `true`, all routes will be matched as case-sensitive.
|
|
156
|
+
*
|
|
157
|
+
* @default false
|
|
158
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)
|
|
159
|
+
*/
|
|
160
|
+
caseSensitive?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
*
|
|
163
|
+
* The route tree that will be used to configure the router instance.
|
|
164
|
+
*
|
|
165
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)
|
|
166
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/routing/route-trees)
|
|
167
|
+
*/
|
|
168
|
+
routeTree?: TRouteTree;
|
|
169
|
+
/**
|
|
170
|
+
* The basepath for then entire router. This is useful for mounting a router instance at a subpath.
|
|
171
|
+
*
|
|
172
|
+
* @default '/'
|
|
173
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)
|
|
174
|
+
*/
|
|
175
|
+
basepath?: string;
|
|
176
|
+
/**
|
|
177
|
+
* The root context that will be provided to all routes in the route tree.
|
|
178
|
+
*
|
|
179
|
+
* This can be used to provide a context to all routes in the tree without having to provide it to each route individually.
|
|
180
|
+
*
|
|
181
|
+
* Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).
|
|
182
|
+
*
|
|
183
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#context-property)
|
|
184
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)
|
|
185
|
+
*/
|
|
186
|
+
context?: InferRouterContext<TRouteTree>;
|
|
187
|
+
/**
|
|
188
|
+
* A function that will be called when the router is dehydrated.
|
|
189
|
+
*
|
|
190
|
+
* The return value of this function will be serialized and stored in the router's dehydrated state.
|
|
191
|
+
*
|
|
192
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)
|
|
193
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
|
|
194
|
+
*/
|
|
195
|
+
dehydrate?: () => TDehydrated;
|
|
196
|
+
/**
|
|
197
|
+
* A function that will be called when the router is hydrated.
|
|
198
|
+
*
|
|
199
|
+
* The return value of this function will be serialized and stored in the router's dehydrated state.
|
|
200
|
+
*
|
|
201
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#hydrate-method)
|
|
202
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
|
|
203
|
+
*/
|
|
204
|
+
hydrate?: (dehydrated: TDehydrated) => void;
|
|
205
|
+
/**
|
|
206
|
+
* An array of route masks that will be used to mask routes in the route tree.
|
|
207
|
+
*
|
|
208
|
+
* 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.
|
|
209
|
+
*
|
|
210
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routemasks-property)
|
|
211
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking)
|
|
212
|
+
*/
|
|
213
|
+
routeMasks?: Array<RouteMask<TRouteTree>>;
|
|
214
|
+
/**
|
|
215
|
+
* If `true`, route masks will, by default, be removed when the page is reloaded.
|
|
216
|
+
*
|
|
217
|
+
* 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.
|
|
218
|
+
*
|
|
219
|
+
* @default false
|
|
220
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#unmaskonreload-property)
|
|
221
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking#unmasking-on-page-reload)
|
|
222
|
+
*/
|
|
223
|
+
unmaskOnReload?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Use `notFoundComponent` instead.
|
|
226
|
+
*
|
|
227
|
+
* @deprecated
|
|
228
|
+
* See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.
|
|
229
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundroute-property)
|
|
230
|
+
*/
|
|
231
|
+
notFoundRoute?: AnyRoute;
|
|
232
|
+
/**
|
|
233
|
+
* Configures how trailing slashes are treated.
|
|
234
|
+
*
|
|
235
|
+
* - `'always'` will add a trailing slash if not present
|
|
236
|
+
* - `'never'` will remove the trailing slash if present
|
|
237
|
+
* - `'preserve'` will not modify the trailing slash.
|
|
238
|
+
*
|
|
239
|
+
* @default 'never'
|
|
240
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)
|
|
241
|
+
*/
|
|
11
242
|
trailingSlash?: TTrailingSlashOption;
|
|
243
|
+
/**
|
|
244
|
+
* 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.
|
|
245
|
+
*
|
|
246
|
+
* @default typeof document !== 'undefined'
|
|
247
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#isserver-property)
|
|
248
|
+
*/
|
|
249
|
+
isServer?: boolean;
|
|
250
|
+
defaultSsr?: boolean;
|
|
251
|
+
search?: {
|
|
252
|
+
/**
|
|
253
|
+
* Configures how unknown search params (= not returned by any `validateSearch`) are treated.
|
|
254
|
+
*
|
|
255
|
+
* @default false
|
|
256
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#search.strict-property)
|
|
257
|
+
*/
|
|
258
|
+
strict?: boolean;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Configures whether structural sharing is enabled by default for fine-grained selectors.
|
|
262
|
+
*
|
|
263
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstructuralsharing-property)
|
|
264
|
+
*/
|
|
265
|
+
defaultStructuralSharing?: TDefaultStructuralSharingOption;
|
|
266
|
+
/**
|
|
267
|
+
* Configures which URI characters are allowed in path params that would ordinarily be escaped by encodeURIComponent.
|
|
268
|
+
*
|
|
269
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#pathparamsallowedcharacters-property)
|
|
270
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/path-params#allowed-characters)
|
|
271
|
+
*/
|
|
272
|
+
pathParamsAllowedCharacters?: Array<';' | ':' | '@' | '&' | '=' | '+' | '$' | ','>;
|
|
273
|
+
defaultRemountDeps?: DefaultRemountDepsFn<TRouteTree>;
|
|
274
|
+
/**
|
|
275
|
+
* If `true`, scroll restoration will be enabled
|
|
276
|
+
*
|
|
277
|
+
* @default false
|
|
278
|
+
*/
|
|
279
|
+
scrollRestoration?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* A function that will be called to get the key for the scroll restoration cache.
|
|
282
|
+
*
|
|
283
|
+
* @default (location) => location.href
|
|
284
|
+
*/
|
|
285
|
+
getScrollRestorationKey?: (location: ParsedLocation) => string;
|
|
286
|
+
/**
|
|
287
|
+
* The default behavior for scroll restoration.
|
|
288
|
+
*
|
|
289
|
+
* @default 'auto'
|
|
290
|
+
*/
|
|
291
|
+
scrollRestorationBehavior?: ScrollBehavior;
|
|
292
|
+
/**
|
|
293
|
+
* An array of selectors that will be used to scroll to the top of the page in addition to `window`
|
|
294
|
+
*
|
|
295
|
+
* @default ['window']
|
|
296
|
+
*/
|
|
297
|
+
scrollToTopSelectors?: Array<string>;
|
|
298
|
+
}
|
|
299
|
+
export interface RouterState<in out TRouteTree extends AnyRoute = AnyRoute, in out TRouteMatch = MakeRouteMatchUnion> {
|
|
300
|
+
status: 'pending' | 'idle';
|
|
301
|
+
loadedAt: number;
|
|
302
|
+
isLoading: boolean;
|
|
303
|
+
isTransitioning: boolean;
|
|
304
|
+
matches: Array<TRouteMatch>;
|
|
305
|
+
pendingMatches?: Array<TRouteMatch>;
|
|
306
|
+
cachedMatches: Array<TRouteMatch>;
|
|
307
|
+
location: ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
308
|
+
resolvedLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
309
|
+
statusCode: number;
|
|
310
|
+
redirect?: ResolvedRedirect;
|
|
311
|
+
}
|
|
312
|
+
export interface BuildNextOptions {
|
|
313
|
+
to?: string | number | null;
|
|
314
|
+
params?: true | Updater<unknown>;
|
|
315
|
+
search?: true | Updater<unknown>;
|
|
316
|
+
hash?: true | Updater<string>;
|
|
317
|
+
state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>;
|
|
318
|
+
mask?: {
|
|
319
|
+
to?: string | number | null;
|
|
320
|
+
params?: true | Updater<unknown>;
|
|
321
|
+
search?: true | Updater<unknown>;
|
|
322
|
+
hash?: true | Updater<string>;
|
|
323
|
+
state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>;
|
|
324
|
+
unmaskOnReload?: boolean;
|
|
325
|
+
};
|
|
326
|
+
from?: string;
|
|
327
|
+
_fromLocation?: ParsedLocation;
|
|
328
|
+
href?: string;
|
|
329
|
+
}
|
|
330
|
+
type NavigationEventInfo = {
|
|
331
|
+
fromLocation?: ParsedLocation;
|
|
332
|
+
toLocation: ParsedLocation;
|
|
333
|
+
pathChanged: boolean;
|
|
334
|
+
hrefChanged: boolean;
|
|
335
|
+
hashChanged: boolean;
|
|
336
|
+
};
|
|
337
|
+
export type RouterEvents = {
|
|
338
|
+
onBeforeNavigate: {
|
|
339
|
+
type: 'onBeforeNavigate';
|
|
340
|
+
} & NavigationEventInfo;
|
|
341
|
+
onBeforeLoad: {
|
|
342
|
+
type: 'onBeforeLoad';
|
|
343
|
+
} & NavigationEventInfo;
|
|
344
|
+
onLoad: {
|
|
345
|
+
type: 'onLoad';
|
|
346
|
+
} & NavigationEventInfo;
|
|
347
|
+
onResolved: {
|
|
348
|
+
type: 'onResolved';
|
|
349
|
+
} & NavigationEventInfo;
|
|
350
|
+
onBeforeRouteMount: {
|
|
351
|
+
type: 'onBeforeRouteMount';
|
|
352
|
+
} & NavigationEventInfo;
|
|
353
|
+
onInjectedHtml: {
|
|
354
|
+
type: 'onInjectedHtml';
|
|
355
|
+
promise: Promise<string>;
|
|
356
|
+
};
|
|
357
|
+
onRendered: {
|
|
358
|
+
type: 'onRendered';
|
|
359
|
+
} & NavigationEventInfo;
|
|
360
|
+
};
|
|
361
|
+
export type RouterEvent = RouterEvents[keyof RouterEvents];
|
|
362
|
+
export type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void;
|
|
363
|
+
export type RouterListener<TRouterEvent extends RouterEvent> = {
|
|
364
|
+
eventType: TRouterEvent['type'];
|
|
365
|
+
fn: ListenerFn<TRouterEvent>;
|
|
366
|
+
};
|
|
367
|
+
export interface MatchRoutesOpts {
|
|
368
|
+
preload?: boolean;
|
|
369
|
+
throwOnError?: boolean;
|
|
370
|
+
_buildLocation?: boolean;
|
|
371
|
+
dest?: BuildNextOptions;
|
|
372
|
+
}
|
|
373
|
+
export type InferRouterContext<TRouteTree extends AnyRoute> = TRouteTree['types']['routerContext'];
|
|
374
|
+
export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends InferRouterContext<TRouteTree> ? {
|
|
375
|
+
context?: InferRouterContext<TRouteTree>;
|
|
376
|
+
} : {
|
|
377
|
+
context: InferRouterContext<TRouteTree>;
|
|
378
|
+
};
|
|
379
|
+
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>;
|
|
380
|
+
export interface RouterErrorSerializer<TSerializedError> {
|
|
381
|
+
serialize: (err: unknown) => TSerializedError;
|
|
382
|
+
deserialize: (err: TSerializedError) => unknown;
|
|
383
|
+
}
|
|
384
|
+
export interface MatchedRoutesResult {
|
|
385
|
+
matchedRoutes: Array<AnyRoute>;
|
|
386
|
+
routeParams: Record<string, string>;
|
|
387
|
+
}
|
|
388
|
+
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<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<Array<AnyRouteMatch> | undefined>;
|
|
389
|
+
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<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>, TFrom, TTo>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>['types']['allParams'];
|
|
390
|
+
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;
|
|
391
|
+
export type InvalidateFn<TRouter extends AnyRouter> = (opts?: {
|
|
392
|
+
filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
|
|
393
|
+
sync?: boolean;
|
|
394
|
+
}) => Promise<void>;
|
|
395
|
+
export type ParseLocationFn<TRouteTree extends AnyRoute> = (previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>, locationToParse?: HistoryLocation) => ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
396
|
+
export type GetMatchRoutesFn = (next: ParsedLocation, dest?: BuildNextOptions) => {
|
|
397
|
+
matchedRoutes: Array<AnyRoute>;
|
|
398
|
+
routeParams: Record<string, string>;
|
|
399
|
+
foundRoute: AnyRoute | undefined;
|
|
400
|
+
};
|
|
401
|
+
export type EmitFn = (routerEvent: RouterEvent) => void;
|
|
402
|
+
export type LoadFn = (opts?: {
|
|
403
|
+
sync?: boolean;
|
|
404
|
+
}) => Promise<void>;
|
|
405
|
+
export type CommitLocationFn = ({ viewTransition, ignoreBlocker, ...next }: ParsedLocation & CommitLocationOptions) => Promise<void>;
|
|
406
|
+
export type StartTransitionFn = (fn: () => void) => void;
|
|
407
|
+
export type SubscribeFn = <TType extends keyof RouterEvents>(eventType: TType, fn: ListenerFn<RouterEvents[TType]>) => () => void;
|
|
408
|
+
export interface MatchRoutesFn {
|
|
409
|
+
(pathname: string, locationSearch: AnySchema, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
|
|
410
|
+
(next: ParsedLocation, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
|
|
411
|
+
(pathnameOrNext: string | ParsedLocation, locationSearchOrOpts?: AnySchema | MatchRoutesOpts, opts?: MatchRoutesOpts): Array<AnyRouteMatch>;
|
|
412
|
+
}
|
|
413
|
+
export type GetMatchFn = (matchId: string) => AnyRouteMatch | undefined;
|
|
414
|
+
export type UpdateMatchFn = (id: string, updater: (match: AnyRouteMatch) => AnyRouteMatch) => AnyRouteMatch;
|
|
415
|
+
export type LoadRouteChunkFn = (route: AnyRoute) => Promise<Array<void>>;
|
|
416
|
+
export type ResolveRedirect = (err: AnyRedirect) => ResolvedRedirect;
|
|
417
|
+
export type ClearCacheFn<TRouter extends AnyRouter> = (opts?: {
|
|
418
|
+
filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean;
|
|
419
|
+
}) => void;
|
|
420
|
+
export interface ServerSrr {
|
|
421
|
+
injectedHtml: Array<InjectedHtmlEntry>;
|
|
422
|
+
injectHtml: (getHtml: () => string | Promise<string>) => Promise<void>;
|
|
423
|
+
injectScript: (getScript: () => string | Promise<string>, opts?: {
|
|
424
|
+
logScript?: boolean;
|
|
425
|
+
}) => Promise<void>;
|
|
426
|
+
streamValue: (key: string, value: any) => void;
|
|
427
|
+
streamedKeys: Set<string>;
|
|
428
|
+
onMatchSettled: (opts: {
|
|
429
|
+
router: AnyRouter;
|
|
430
|
+
match: AnyRouteMatch;
|
|
431
|
+
}) => any;
|
|
12
432
|
}
|
|
13
|
-
export interface Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption> {
|
|
433
|
+
export interface Router<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>> {
|
|
14
434
|
routeTree: TRouteTree;
|
|
15
|
-
options: RouterOptions<TTrailingSlashOption>;
|
|
435
|
+
options: RouterOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>;
|
|
436
|
+
__store: Store<RouterState<TRouteTree>>;
|
|
437
|
+
navigate: NavigateFn;
|
|
438
|
+
history: TRouterHistory;
|
|
439
|
+
state: RouterState<TRouteTree>;
|
|
440
|
+
isServer: boolean;
|
|
441
|
+
clientSsr?: {
|
|
442
|
+
getStreamedValue: <T>(key: string) => T | undefined;
|
|
443
|
+
};
|
|
444
|
+
looseRoutesById: Record<string, AnyRoute>;
|
|
445
|
+
latestLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
446
|
+
isScrollRestoring: boolean;
|
|
447
|
+
resetNextScroll: boolean;
|
|
448
|
+
isScrollRestorationSetup: boolean;
|
|
449
|
+
ssr?: {
|
|
450
|
+
manifest: Manifest | undefined;
|
|
451
|
+
serializer: StartSerializer;
|
|
452
|
+
};
|
|
453
|
+
serverSsr?: ServerSrr;
|
|
454
|
+
basepath: string;
|
|
455
|
+
routesById: RoutesById<TRouteTree>;
|
|
456
|
+
routesByPath: RoutesByPath<TRouteTree>;
|
|
457
|
+
flatRoutes: Array<AnyRoute>;
|
|
458
|
+
parseLocation: ParseLocationFn<TRouteTree>;
|
|
459
|
+
getMatchedRoutes: GetMatchRoutesFn;
|
|
460
|
+
emit: EmitFn;
|
|
461
|
+
load: LoadFn;
|
|
462
|
+
commitLocation: CommitLocationFn;
|
|
463
|
+
buildLocation: BuildLocationFn;
|
|
464
|
+
startTransition: StartTransitionFn;
|
|
465
|
+
subscribe: SubscribeFn;
|
|
466
|
+
matchRoutes: MatchRoutesFn;
|
|
467
|
+
preloadRoute: PreloadRouteFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>;
|
|
468
|
+
getMatch: GetMatchFn;
|
|
469
|
+
updateMatch: UpdateMatchFn;
|
|
470
|
+
matchRoute: MatchRouteFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory>;
|
|
471
|
+
update: UpdateFn<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>;
|
|
472
|
+
invalidate: InvalidateFn<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>>;
|
|
473
|
+
loadRouteChunk: LoadRouteChunkFn;
|
|
474
|
+
resolveRedirect: ResolveRedirect;
|
|
475
|
+
buildRouteTree: () => void;
|
|
476
|
+
clearCache: ClearCacheFn<Router<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>>;
|
|
16
477
|
}
|
|
17
|
-
export type AnyRouterWithContext<TContext> = Router<AnyRouteWithContext<TContext>, any>;
|
|
18
|
-
export type AnyRouter = Router<any, any>;
|
|
478
|
+
export type AnyRouterWithContext<TContext> = Router<AnyRouteWithContext<TContext>, any, any, any, any>;
|
|
479
|
+
export type AnyRouter = Router<any, any, any, any, any>;
|
|
19
480
|
export interface ViewTransitionOptions {
|
|
20
481
|
types: Array<string>;
|
|
21
482
|
}
|
|
@@ -55,3 +516,4 @@ export declare function getLocationChangeInfo(routerState: {
|
|
|
55
516
|
hrefChanged: boolean;
|
|
56
517
|
hashChanged: boolean;
|
|
57
518
|
};
|
|
519
|
+
export {};
|
package/dist/esm/Matches.d.ts
CHANGED
|
@@ -76,3 +76,9 @@ export type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<TRoute
|
|
|
76
76
|
export type MakeRouteMatch<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TRouteId = RouteIds<TRouteTree>, TStrict extends boolean = true> = RouteMatch<TRouteId, RouteById<TRouteTree, TRouteId>['types']['fullPath'], TStrict extends false ? AllParams<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['allParams'], TStrict extends false ? FullSearchSchema<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'], TStrict extends false ? AllLoaderData<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['loaderData'], TStrict extends false ? AllContext<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['allContext'], RouteById<TRouteTree, TRouteId>['types']['loaderDeps']>;
|
|
77
77
|
export type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>;
|
|
78
78
|
export type MakeRouteMatchUnion<TRouter extends AnyRouter = RegisteredRouter, TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>> = TRoute extends any ? RouteMatch<TRoute['id'], TRoute['fullPath'], TRoute['types']['allParams'], TRoute['types']['fullSearchSchema'], TRoute['types']['loaderData'], TRoute['types']['allContext'], TRoute['types']['loaderDeps']> : never;
|
|
79
|
+
export interface MatchRouteOptions {
|
|
80
|
+
pending?: boolean;
|
|
81
|
+
caseSensitive?: boolean;
|
|
82
|
+
includeSearch?: boolean;
|
|
83
|
+
fuzzy?: boolean;
|
|
84
|
+
}
|
package/dist/esm/Matches.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matches.js","sources":["../../src/Matches.ts"],"sourcesContent":["import type { AnyRoute, StaticDataRouteOption } from './route'\nimport type {\n AllContext,\n AllLoaderData,\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteIds,\n} from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { Constrain, ControlledPromise } from './utils'\n\nexport type AnyMatchAndValue = { match: any; value: any }\n\nexport type FindValueByIndex<\n TKey,\n TValue extends ReadonlyArray<any>,\n> = TKey extends `${infer TIndex extends number}` ? TValue[TIndex] : never\n\nexport type FindValueByKey<TKey, TValue> =\n TValue extends ReadonlyArray<any>\n ? FindValueByIndex<TKey, TValue>\n : TValue[TKey & keyof TValue]\n\nexport type CreateMatchAndValue<TMatch, TValue> = TValue extends any\n ? {\n match: TMatch\n value: TValue\n }\n : never\n\nexport type NextMatchAndValue<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? CreateMatchAndValue<\n TMatchAndValue['match'],\n FindValueByKey<TKey, TMatchAndValue['value']>\n >\n : never\n\nexport type IsMatchKeyOf<TValue> =\n TValue extends ReadonlyArray<any>\n ? number extends TValue['length']\n ? `${number}`\n : keyof TValue & `${number}`\n : TValue extends object\n ? keyof TValue & string\n : never\n\nexport type IsMatchPath<\n TParentPath extends string,\n TMatchAndValue extends AnyMatchAndValue,\n> = `${TParentPath}${IsMatchKeyOf<TMatchAndValue['value']>}`\n\nexport type IsMatchResult<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? TKey extends keyof TMatchAndValue['value']\n ? TMatchAndValue['match']\n : never\n : never\n\nexport type IsMatchParse<\n TPath,\n TMatchAndValue extends AnyMatchAndValue,\n TParentPath extends string = '',\n> = TPath extends `${string}.${string}`\n ? TPath extends `${infer TFirst}.${infer TRest}`\n ? IsMatchParse<\n TRest,\n NextMatchAndValue<TFirst, TMatchAndValue>,\n `${TParentPath}${TFirst}.`\n >\n : never\n : {\n path: IsMatchPath<TParentPath, TMatchAndValue>\n result: IsMatchResult<TPath, TMatchAndValue>\n }\n\nexport type IsMatch<TMatch, TPath> = IsMatchParse<\n TPath,\n TMatch extends any ? { match: TMatch; value: TMatch } : never\n>\n\n/**\n * Narrows matches based on a path\n * @experimental\n */\nexport const isMatch = <TMatch, TPath extends string>(\n match: TMatch,\n path: Constrain<TPath, IsMatch<TMatch, TPath>['path']>,\n): match is IsMatch<TMatch, TPath>['result'] => {\n const parts = (path as string).split('.')\n let part\n let value: any = match\n\n while ((part = parts.shift()) != null && value != null) {\n value = value[part]\n }\n\n return value != null\n}\n\nexport interface DefaultRouteMatchExtensions {\n scripts?: unknown\n links?: unknown\n headScripts?: unknown\n meta?: unknown\n}\n\nexport interface RouteMatchExtensions extends DefaultRouteMatchExtensions {}\n\nexport interface RouteMatch<\n out TRouteId,\n out TFullPath,\n out TAllParams,\n out TFullSearchSchema,\n out TLoaderData,\n out TAllContext,\n out TLoaderDeps,\n> extends RouteMatchExtensions {\n id: string\n routeId: TRouteId\n fullPath: TFullPath\n index: number\n pathname: string\n params: TAllParams\n _strictParams: TAllParams\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: false | 'beforeLoad' | 'loader'\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: ControlledPromise<void>\n beforeLoadPromise?: ControlledPromise<void>\n loaderPromise?: ControlledPromise<void>\n loaderData?: TLoaderData\n __routeContext: Record<string, unknown>\n __beforeLoadContext: Record<string, unknown>\n context: TAllContext\n search: TFullSearchSchema\n _strictSearch: TFullSearchSchema\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: TLoaderDeps\n preload: boolean\n invalid: boolean\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n minPendingPromise?: ControlledPromise<void>\n pendingTimeout?: ReturnType<typeof setTimeout>\n}\n\nexport type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<\n TRoute['types']['id'],\n TRoute['types']['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n>\n\nexport type MakeRouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\n> = RouteMatch<\n TRouteId,\n RouteById<TRouteTree, TRouteId>['types']['fullPath'],\n TStrict extends false\n ? AllParams<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allParams'],\n TStrict extends false\n ? FullSearchSchema<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n TStrict extends false\n ? AllLoaderData<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['loaderData'],\n TStrict extends false\n ? AllContext<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allContext'],\n RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n>\n\nexport type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>\n\nexport type MakeRouteMatchUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? RouteMatch<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n >\n : never\n"],"names":[],"mappings":"AA2Fa,MAAA,UAAU,CACrB,OACA,SAC8C;AACxC,QAAA,QAAS,KAAgB,MAAM,GAAG;AACpC,MAAA;AACJ,MAAI,QAAa;AAEjB,UAAQ,OAAO,MAAM,MAAY,MAAA,QAAQ,SAAS,MAAM;AACtD,YAAQ,MAAM,IAAI;AAAA,EAAA;AAGpB,SAAO,SAAS;AAClB;"}
|
|
1
|
+
{"version":3,"file":"Matches.js","sources":["../../src/Matches.ts"],"sourcesContent":["import type { AnyRoute, StaticDataRouteOption } from './route'\nimport type {\n AllContext,\n AllLoaderData,\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteIds,\n} from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { Constrain, ControlledPromise } from './utils'\n\nexport type AnyMatchAndValue = { match: any; value: any }\n\nexport type FindValueByIndex<\n TKey,\n TValue extends ReadonlyArray<any>,\n> = TKey extends `${infer TIndex extends number}` ? TValue[TIndex] : never\n\nexport type FindValueByKey<TKey, TValue> =\n TValue extends ReadonlyArray<any>\n ? FindValueByIndex<TKey, TValue>\n : TValue[TKey & keyof TValue]\n\nexport type CreateMatchAndValue<TMatch, TValue> = TValue extends any\n ? {\n match: TMatch\n value: TValue\n }\n : never\n\nexport type NextMatchAndValue<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? CreateMatchAndValue<\n TMatchAndValue['match'],\n FindValueByKey<TKey, TMatchAndValue['value']>\n >\n : never\n\nexport type IsMatchKeyOf<TValue> =\n TValue extends ReadonlyArray<any>\n ? number extends TValue['length']\n ? `${number}`\n : keyof TValue & `${number}`\n : TValue extends object\n ? keyof TValue & string\n : never\n\nexport type IsMatchPath<\n TParentPath extends string,\n TMatchAndValue extends AnyMatchAndValue,\n> = `${TParentPath}${IsMatchKeyOf<TMatchAndValue['value']>}`\n\nexport type IsMatchResult<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? TKey extends keyof TMatchAndValue['value']\n ? TMatchAndValue['match']\n : never\n : never\n\nexport type IsMatchParse<\n TPath,\n TMatchAndValue extends AnyMatchAndValue,\n TParentPath extends string = '',\n> = TPath extends `${string}.${string}`\n ? TPath extends `${infer TFirst}.${infer TRest}`\n ? IsMatchParse<\n TRest,\n NextMatchAndValue<TFirst, TMatchAndValue>,\n `${TParentPath}${TFirst}.`\n >\n : never\n : {\n path: IsMatchPath<TParentPath, TMatchAndValue>\n result: IsMatchResult<TPath, TMatchAndValue>\n }\n\nexport type IsMatch<TMatch, TPath> = IsMatchParse<\n TPath,\n TMatch extends any ? { match: TMatch; value: TMatch } : never\n>\n\n/**\n * Narrows matches based on a path\n * @experimental\n */\nexport const isMatch = <TMatch, TPath extends string>(\n match: TMatch,\n path: Constrain<TPath, IsMatch<TMatch, TPath>['path']>,\n): match is IsMatch<TMatch, TPath>['result'] => {\n const parts = (path as string).split('.')\n let part\n let value: any = match\n\n while ((part = parts.shift()) != null && value != null) {\n value = value[part]\n }\n\n return value != null\n}\n\nexport interface DefaultRouteMatchExtensions {\n scripts?: unknown\n links?: unknown\n headScripts?: unknown\n meta?: unknown\n}\n\nexport interface RouteMatchExtensions extends DefaultRouteMatchExtensions {}\n\nexport interface RouteMatch<\n out TRouteId,\n out TFullPath,\n out TAllParams,\n out TFullSearchSchema,\n out TLoaderData,\n out TAllContext,\n out TLoaderDeps,\n> extends RouteMatchExtensions {\n id: string\n routeId: TRouteId\n fullPath: TFullPath\n index: number\n pathname: string\n params: TAllParams\n _strictParams: TAllParams\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: false | 'beforeLoad' | 'loader'\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: ControlledPromise<void>\n beforeLoadPromise?: ControlledPromise<void>\n loaderPromise?: ControlledPromise<void>\n loaderData?: TLoaderData\n __routeContext: Record<string, unknown>\n __beforeLoadContext: Record<string, unknown>\n context: TAllContext\n search: TFullSearchSchema\n _strictSearch: TFullSearchSchema\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: TLoaderDeps\n preload: boolean\n invalid: boolean\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n minPendingPromise?: ControlledPromise<void>\n pendingTimeout?: ReturnType<typeof setTimeout>\n}\n\nexport type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<\n TRoute['types']['id'],\n TRoute['types']['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n>\n\nexport type MakeRouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\n> = RouteMatch<\n TRouteId,\n RouteById<TRouteTree, TRouteId>['types']['fullPath'],\n TStrict extends false\n ? AllParams<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allParams'],\n TStrict extends false\n ? FullSearchSchema<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n TStrict extends false\n ? AllLoaderData<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['loaderData'],\n TStrict extends false\n ? AllContext<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allContext'],\n RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n>\n\nexport type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>\n\nexport type MakeRouteMatchUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? RouteMatch<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n >\n : never\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n"],"names":[],"mappings":"AA2Fa,MAAA,UAAU,CACrB,OACA,SAC8C;AACxC,QAAA,QAAS,KAAgB,MAAM,GAAG;AACpC,MAAA;AACJ,MAAI,QAAa;AAEjB,UAAQ,OAAO,MAAM,MAAY,MAAA,QAAQ,SAAS,MAAM;AACtD,YAAQ,MAAM,IAAI;AAAA,EAAA;AAGpB,SAAO,SAAS;AAClB;"}
|
package/dist/esm/fileRoute.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AnyRoute,
|
|
1
|
+
import { AnyContext, AnyPathParams, AnyRoute, UpdatableRouteOptions } from './route.js';
|
|
2
|
+
import { AnyValidator } from './validators.js';
|
|
2
3
|
export interface FileRouteTypes {
|
|
3
4
|
fileRoutesByFullPath: any;
|
|
4
5
|
fullPaths: any;
|
|
@@ -7,6 +8,12 @@ export interface FileRouteTypes {
|
|
|
7
8
|
id: any;
|
|
8
9
|
fileRoutesById: any;
|
|
9
10
|
}
|
|
10
|
-
export type InferFileRouteTypes<TRouteTree extends AnyRoute> =
|
|
11
|
+
export type InferFileRouteTypes<TRouteTree extends AnyRoute> = unknown extends TRouteTree['types']['fileRouteTypes'] ? never : TRouteTree['types']['fileRouteTypes'] extends FileRouteTypes ? TRouteTree['types']['fileRouteTypes'] : never;
|
|
11
12
|
export interface FileRoutesByPath {
|
|
12
13
|
}
|
|
14
|
+
export type LazyRouteOptions = Pick<UpdatableRouteOptions<AnyRoute, string, string, AnyPathParams, AnyValidator, {}, AnyContext, AnyContext, AnyContext, AnyContext>, 'component' | 'errorComponent' | 'pendingComponent' | 'notFoundComponent'>;
|
|
15
|
+
export interface LazyRoute {
|
|
16
|
+
options: {
|
|
17
|
+
id: string;
|
|
18
|
+
} & LazyRouteOptions;
|
|
19
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,20 +3,20 @@ export type { DeferredPromiseState, DeferredPromise } from './defer.js';
|
|
|
3
3
|
export { preloadWarning } from './link.js';
|
|
4
4
|
export type { IsRequiredParams, ParsePathParams, AddTrailingSlash, RemoveTrailingSlashes, AddLeadingSlash, RemoveLeadingSlashes, ActiveOptions, LinkOptionsProps, ResolveCurrentPath, ResolveParentPath, ResolveRelativePath, LinkCurrentTargetElement, FindDescendantToPaths, InferDescendantToPaths, RelativeToPath, RelativeToParentPath, RelativeToCurrentPath, AbsoluteToPath, RelativeToPathAutoComplete, NavigateOptions, ToOptions, ToMaskOptions, ToSubOptions, ResolveRoute, SearchParamOptions, PathParamOptions, ToPathOption, LinkOptions, MakeOptionalPathParams, FromPathOption, MakeOptionalSearchParams, MaskOptions, ToSubOptionsProps, RequiredToOptions, } from './link.js';
|
|
5
5
|
export type { RouteToPath, TrailingSlashOptionByRouter, ParseRoute, CodeRouteToPath, RouteIds, FullSearchSchema, FullSearchSchemaInput, AllParams, RouteById, AllContext, RoutePaths, RoutesById, RoutesByPath, AllLoaderData, RouteByPath, } from './routeInfo.js';
|
|
6
|
-
export type { InferFileRouteTypes, FileRouteTypes, FileRoutesByPath, } from './fileRoute.js';
|
|
6
|
+
export type { InferFileRouteTypes, FileRouteTypes, FileRoutesByPath, LazyRoute, LazyRouteOptions, } from './fileRoute.js';
|
|
7
7
|
export type { StartSerializer, Serializable, SerializerParse, SerializerParseBy, SerializerStringify, SerializerStringifyBy, } from './serializer.js';
|
|
8
8
|
export type { ParsedLocation } from './location.js';
|
|
9
9
|
export type { Manifest, RouterManagedTag } from './manifest.js';
|
|
10
10
|
export { isMatch } from './Matches.js';
|
|
11
|
-
export type { AnyMatchAndValue, FindValueByIndex, FindValueByKey, CreateMatchAndValue, NextMatchAndValue, IsMatchKeyOf, IsMatchPath, IsMatchResult, IsMatchParse, IsMatch, RouteMatch, RouteMatchExtensions, MakeRouteMatchUnion, MakeRouteMatch, AnyRouteMatch, MakeRouteMatchFromRoute, } from './Matches.js';
|
|
11
|
+
export type { AnyMatchAndValue, FindValueByIndex, FindValueByKey, CreateMatchAndValue, NextMatchAndValue, IsMatchKeyOf, IsMatchPath, IsMatchResult, IsMatchParse, IsMatch, RouteMatch, RouteMatchExtensions, MakeRouteMatchUnion, MakeRouteMatch, AnyRouteMatch, MakeRouteMatchFromRoute, MatchRouteOptions, } from './Matches.js';
|
|
12
12
|
export { joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, removeTrailingSlash, exactPathTest, resolvePath, parsePathname, interpolatePath, matchPathname, removeBasepath, matchByPath, } from './path.js';
|
|
13
13
|
export type { Segment } from './path.js';
|
|
14
14
|
export { encode, decode } from './qss.js';
|
|
15
15
|
export { rootRouteId } from './root.js';
|
|
16
16
|
export type { RootRouteId } from './root.js';
|
|
17
|
-
export type { AnyPathParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, SearchFilter, SearchMiddlewareContext, SearchMiddleware, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, InferAllParams, InferAllContext, MetaDescriptor, RouteLinkEntry, SearchValidator, AnySearchValidator, DefaultSearchValidator, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, ParseSplatParams, SplatParams, ResolveParams, ParseParamsFn, StringifyParamsFn, ParamsOptions, UpdatableStaticRouteOption, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveRouteContext, ResolveLoaderData, RoutePrefix, TrimPath, TrimPathLeft, TrimPathRight, ResolveSearchSchemaFnInput, ResolveSearchSchemaInput, ResolveSearchSchemaFn, ResolveSearchSchema, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, ResolveAllContext, BeforeLoadContextParameter, RouteContextParameter, ResolveAllParamsFromParent, AnyRoute, Route,
|
|
17
|
+
export type { AnyPathParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, SearchFilter, SearchMiddlewareContext, SearchMiddleware, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, InferAllParams, InferAllContext, MetaDescriptor, RouteLinkEntry, SearchValidator, AnySearchValidator, DefaultSearchValidator, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, ParseSplatParams, SplatParams, ResolveParams, ParseParamsFn, StringifyParamsFn, ParamsOptions, UpdatableStaticRouteOption, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveRouteContext, ResolveLoaderData, RoutePrefix, TrimPath, TrimPathLeft, TrimPathRight, ResolveSearchSchemaFnInput, ResolveSearchSchemaInput, ResolveSearchSchemaFn, ResolveSearchSchema, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, ResolveAllContext, BeforeLoadContextParameter, RouteContextParameter, ResolveAllParamsFromParent, AnyRoute, Route, RouteTypes, FullSearchSchemaOption, RemountDepsOptions, MakeRemountDepsOptionsUnion, ResolveFullPath, AnyRouteWithContext, RouteOptions, FileBaseRouteOptions, BaseRouteOptions, UpdatableRouteOptions, RouteLoaderFn, LoaderFnContext, RouteContextFn, RouteContextOptions, BeforeLoadFn, BeforeLoadContextOptions, ContextOptions, RootRouteOptions, UpdatableRouteOptionsExtensions, RouteConstraints, RouteTypesById, RouteMask, RouteExtensions, RouteLazyFn, RouteAddChildrenFn, RouteAddFileChildrenFn, RouteAddFileTypesFn, } from './route.js';
|
|
18
18
|
export { defaultSerializeError, getLocationChangeInfo } from './router.js';
|
|
19
|
-
export type { ViewTransitionOptions, ExtractedBaseEntry, ExtractedStream, ExtractedPromise, ExtractedEntry, StreamState, TrailingSlashOption, Register, AnyRouter, AnyRouterWithContext, RegisteredRouter, } from './router.js';
|
|
19
|
+
export type { ViewTransitionOptions, ExtractedBaseEntry, ExtractedStream, ExtractedPromise, ExtractedEntry, StreamState, TrailingSlashOption, Register, AnyRouter, AnyRouterWithContext, RegisteredRouter, RouterState, BuildNextOptions, RouterListener, RouterEvent, ListenerFn, RouterEvents, MatchRoutesOpts, RouterOptionsExtensions, Router, DefaultRemountDepsFn, PreloadRouteFn, MatchRouteFn, RouterContextOptions, RouterOptions, RouterConstructorOptions, UpdateFn, ParseLocationFn, InvalidateFn, ControllablePromise, InjectedHtmlEntry, RouterErrorSerializer, MatchedRoutesResult, EmitFn, LoadFn, GetMatchFn, SubscribeFn, UpdateMatchFn, CommitLocationFn, GetMatchRoutesFn, MatchRoutesFn, StartTransitionFn, LoadRouteChunkFn, ServerSrr, ClearCacheFn, } from './router.js';
|
|
20
20
|
export type { MatchLocation, CommitLocationOptions, NavigateFn, BuildLocationFn, } from './RouterProvider.js';
|
|
21
21
|
export { retainSearchParams, stripSearchParams } from './searchMiddleware.js';
|
|
22
22
|
export { defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, } from './searchParams.js';
|