@tanstack/react-router 1.111.6 → 1.111.11
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 +9 -44
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +2 -2
- package/dist/cjs/index.d.cts +4 -4
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +8 -108
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +5 -6
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useMatch.d.cts +1 -2
- package/dist/esm/Matches.d.ts +9 -44
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +2 -2
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/route.d.ts +8 -108
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +5 -6
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useMatch.d.ts +1 -2
- package/dist/esm/useMatch.js.map +1 -1
- package/package.json +2 -2
- package/src/Matches.tsx +9 -105
- package/src/fileRoute.ts +4 -8
- package/src/index.tsx +16 -16
- package/src/route.ts +11 -529
- package/src/router.ts +8 -11
- package/src/useMatch.tsx +6 -2
package/src/route.ts
CHANGED
|
@@ -9,48 +9,29 @@ import { useNavigate } from './useNavigate'
|
|
|
9
9
|
import { useMatch } from './useMatch'
|
|
10
10
|
import type {
|
|
11
11
|
AnyContext,
|
|
12
|
-
AnyPathParams,
|
|
13
12
|
AnySchema,
|
|
14
|
-
AnyValidator,
|
|
15
|
-
BeforeLoadContextParameter,
|
|
16
|
-
BuildLocationFn,
|
|
17
13
|
Constrain,
|
|
18
14
|
ConstrainLiteral,
|
|
19
15
|
RootRoute as CoreRootRoute,
|
|
20
16
|
Route as CoreRoute,
|
|
21
|
-
DefaultValidator,
|
|
22
17
|
ErrorComponentProps,
|
|
23
|
-
Expand,
|
|
24
|
-
FullSearchSchemaOption,
|
|
25
|
-
NavigateFn,
|
|
26
|
-
NavigateOptions,
|
|
27
|
-
NoInfer,
|
|
28
18
|
NotFoundRouteProps,
|
|
29
|
-
ParamsOptions,
|
|
30
|
-
ParsedLocation,
|
|
31
|
-
RemountDepsOptions,
|
|
32
|
-
ResolveAllContext,
|
|
33
|
-
ResolveAllParamsFromParent,
|
|
34
19
|
ResolveFullPath,
|
|
35
|
-
ResolveFullSearchSchema,
|
|
36
|
-
ResolveFullSearchSchemaInput,
|
|
37
20
|
ResolveId,
|
|
38
|
-
ResolveLoaderData,
|
|
39
21
|
ResolveParams,
|
|
40
22
|
RootRouteId,
|
|
23
|
+
RootRouteOptions,
|
|
41
24
|
RouteById,
|
|
42
25
|
RouteContext,
|
|
43
|
-
RouteContextParameter,
|
|
44
26
|
RouteIds,
|
|
45
|
-
|
|
27
|
+
RouteLoaderFn,
|
|
28
|
+
RouteOptions,
|
|
46
29
|
RoutePathOptionsIntersection,
|
|
47
30
|
RoutePaths,
|
|
48
31
|
RouteTypes,
|
|
49
|
-
SearchFilter,
|
|
50
|
-
SearchMiddleware,
|
|
51
32
|
ToMaskOptions,
|
|
52
33
|
TrimPathRight,
|
|
53
|
-
|
|
34
|
+
UpdatableRouteOptions,
|
|
54
35
|
UseNavigateResult,
|
|
55
36
|
} from '@tanstack/router-core'
|
|
56
37
|
import type { UseLoaderDataRoute } from './useLoaderData'
|
|
@@ -59,487 +40,19 @@ import type { UseLoaderDepsRoute } from './useLoaderDeps'
|
|
|
59
40
|
import type { UseParamsRoute } from './useParams'
|
|
60
41
|
import type { UseSearchRoute } from './useSearch'
|
|
61
42
|
import type * as React from 'react'
|
|
62
|
-
import type {
|
|
63
|
-
AnyRouteMatch,
|
|
64
|
-
MakeRouteMatchFromRoute,
|
|
65
|
-
MakeRouteMatchUnion,
|
|
66
|
-
RouteMatch,
|
|
67
|
-
} from './Matches'
|
|
43
|
+
import type {} from './Matches'
|
|
68
44
|
import type { AnyRouter, RegisteredRouter, Router } from './router'
|
|
69
45
|
import type { NotFoundError } from './not-found'
|
|
70
46
|
import type { LazyRoute } from './fileRoute'
|
|
71
47
|
import type { UseRouteContextRoute } from './useRouteContext'
|
|
72
48
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
TSearchValidator = undefined,
|
|
80
|
-
TParams = AnyPathParams,
|
|
81
|
-
TLoaderDeps extends Record<string, any> = {},
|
|
82
|
-
TLoaderFn = undefined,
|
|
83
|
-
TRouterContext = {},
|
|
84
|
-
TRouteContextFn = AnyContext,
|
|
85
|
-
TBeforeLoadFn = AnyContext,
|
|
86
|
-
> = BaseRouteOptions<
|
|
87
|
-
TParentRoute,
|
|
88
|
-
TId,
|
|
89
|
-
TCustomId,
|
|
90
|
-
TPath,
|
|
91
|
-
TSearchValidator,
|
|
92
|
-
TParams,
|
|
93
|
-
TLoaderDeps,
|
|
94
|
-
TLoaderFn,
|
|
95
|
-
TRouterContext,
|
|
96
|
-
TRouteContextFn,
|
|
97
|
-
TBeforeLoadFn
|
|
98
|
-
> &
|
|
99
|
-
UpdatableRouteOptions<
|
|
100
|
-
NoInfer<TParentRoute>,
|
|
101
|
-
NoInfer<TCustomId>,
|
|
102
|
-
NoInfer<TFullPath>,
|
|
103
|
-
NoInfer<TParams>,
|
|
104
|
-
NoInfer<TSearchValidator>,
|
|
105
|
-
NoInfer<TLoaderFn>,
|
|
106
|
-
NoInfer<TLoaderDeps>,
|
|
107
|
-
NoInfer<TRouterContext>,
|
|
108
|
-
NoInfer<TRouteContextFn>,
|
|
109
|
-
NoInfer<TBeforeLoadFn>
|
|
110
|
-
>
|
|
111
|
-
|
|
112
|
-
export type RouteContextFn<
|
|
113
|
-
in out TParentRoute extends AnyRoute,
|
|
114
|
-
in out TSearchValidator,
|
|
115
|
-
in out TParams,
|
|
116
|
-
in out TRouterContext,
|
|
117
|
-
> = (
|
|
118
|
-
ctx: RouteContextOptions<
|
|
119
|
-
TParentRoute,
|
|
120
|
-
TSearchValidator,
|
|
121
|
-
TParams,
|
|
122
|
-
TRouterContext
|
|
123
|
-
>,
|
|
124
|
-
) => any
|
|
125
|
-
|
|
126
|
-
export type BeforeLoadFn<
|
|
127
|
-
in out TParentRoute extends AnyRoute,
|
|
128
|
-
in out TSearchValidator,
|
|
129
|
-
in out TParams,
|
|
130
|
-
in out TRouterContext,
|
|
131
|
-
in out TRouteContextFn,
|
|
132
|
-
> = (
|
|
133
|
-
ctx: BeforeLoadContextOptions<
|
|
134
|
-
TParentRoute,
|
|
135
|
-
TSearchValidator,
|
|
136
|
-
TParams,
|
|
137
|
-
TRouterContext,
|
|
138
|
-
TRouteContextFn
|
|
139
|
-
>,
|
|
140
|
-
) => any
|
|
141
|
-
|
|
142
|
-
export type FileBaseRouteOptions<
|
|
143
|
-
TParentRoute extends AnyRoute = AnyRoute,
|
|
144
|
-
TId extends string = string,
|
|
145
|
-
TPath extends string = string,
|
|
146
|
-
TSearchValidator = undefined,
|
|
147
|
-
TParams = {},
|
|
148
|
-
TLoaderDeps extends Record<string, any> = {},
|
|
149
|
-
TLoaderFn = undefined,
|
|
150
|
-
TRouterContext = {},
|
|
151
|
-
TRouteContextFn = AnyContext,
|
|
152
|
-
TBeforeLoadFn = AnyContext,
|
|
153
|
-
TRemountDepsFn = AnyContext,
|
|
154
|
-
> = ParamsOptions<TPath, TParams> & {
|
|
155
|
-
validateSearch?: Constrain<TSearchValidator, AnyValidator, DefaultValidator>
|
|
156
|
-
|
|
157
|
-
shouldReload?:
|
|
158
|
-
| boolean
|
|
159
|
-
| ((
|
|
160
|
-
match: LoaderFnContext<
|
|
161
|
-
TParentRoute,
|
|
162
|
-
TId,
|
|
163
|
-
TParams,
|
|
164
|
-
TLoaderDeps,
|
|
165
|
-
TRouterContext,
|
|
166
|
-
TRouteContextFn,
|
|
167
|
-
TBeforeLoadFn
|
|
168
|
-
>,
|
|
169
|
-
) => any)
|
|
170
|
-
|
|
171
|
-
context?: Constrain<
|
|
172
|
-
TRouteContextFn,
|
|
173
|
-
(
|
|
174
|
-
ctx: RouteContextOptions<
|
|
175
|
-
TParentRoute,
|
|
176
|
-
TParams,
|
|
177
|
-
TRouterContext,
|
|
178
|
-
TLoaderDeps
|
|
179
|
-
>,
|
|
180
|
-
) => any
|
|
181
|
-
>
|
|
182
|
-
|
|
183
|
-
// This async function is called before a route is loaded.
|
|
184
|
-
// If an error is thrown here, the route's loader will not be called.
|
|
185
|
-
// If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.
|
|
186
|
-
// If thrown during a preload event, the error will be logged to the console.
|
|
187
|
-
beforeLoad?: Constrain<
|
|
188
|
-
TBeforeLoadFn,
|
|
189
|
-
(
|
|
190
|
-
ctx: BeforeLoadContextOptions<
|
|
191
|
-
TParentRoute,
|
|
192
|
-
TSearchValidator,
|
|
193
|
-
TParams,
|
|
194
|
-
TRouterContext,
|
|
195
|
-
TRouteContextFn
|
|
196
|
-
>,
|
|
197
|
-
) => any
|
|
198
|
-
>
|
|
199
|
-
|
|
200
|
-
loaderDeps?: (
|
|
201
|
-
opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>,
|
|
202
|
-
) => TLoaderDeps
|
|
203
|
-
|
|
204
|
-
remountDeps?: Constrain<
|
|
205
|
-
TRemountDepsFn,
|
|
206
|
-
(
|
|
207
|
-
opt: RemountDepsOptions<
|
|
208
|
-
TId,
|
|
209
|
-
FullSearchSchemaOption<TParentRoute, TSearchValidator>,
|
|
210
|
-
Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,
|
|
211
|
-
TLoaderDeps
|
|
212
|
-
>,
|
|
213
|
-
) => any
|
|
214
|
-
>
|
|
215
|
-
|
|
216
|
-
loader?: Constrain<
|
|
217
|
-
TLoaderFn,
|
|
218
|
-
(
|
|
219
|
-
ctx: LoaderFnContext<
|
|
220
|
-
TParentRoute,
|
|
221
|
-
TId,
|
|
222
|
-
TParams,
|
|
223
|
-
TLoaderDeps,
|
|
224
|
-
TRouterContext,
|
|
225
|
-
TRouteContextFn,
|
|
226
|
-
TBeforeLoadFn
|
|
227
|
-
>,
|
|
228
|
-
) => any
|
|
229
|
-
>
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export type BaseRouteOptions<
|
|
233
|
-
TParentRoute extends AnyRoute = AnyRoute,
|
|
234
|
-
TId extends string = string,
|
|
235
|
-
TCustomId extends string = string,
|
|
236
|
-
TPath extends string = string,
|
|
237
|
-
TSearchValidator = undefined,
|
|
238
|
-
TParams = {},
|
|
239
|
-
TLoaderDeps extends Record<string, any> = {},
|
|
240
|
-
TLoaderFn = undefined,
|
|
241
|
-
TRouterContext = {},
|
|
242
|
-
TRouteContextFn = AnyContext,
|
|
243
|
-
TBeforeLoadFn = AnyContext,
|
|
244
|
-
> = RoutePathOptions<TCustomId, TPath> &
|
|
245
|
-
FileBaseRouteOptions<
|
|
246
|
-
TParentRoute,
|
|
247
|
-
TId,
|
|
248
|
-
TPath,
|
|
249
|
-
TSearchValidator,
|
|
250
|
-
TParams,
|
|
251
|
-
TLoaderDeps,
|
|
252
|
-
TLoaderFn,
|
|
253
|
-
TRouterContext,
|
|
254
|
-
TRouteContextFn,
|
|
255
|
-
TBeforeLoadFn
|
|
256
|
-
> & {
|
|
257
|
-
getParentRoute: () => TParentRoute
|
|
49
|
+
declare module '@tanstack/router-core' {
|
|
50
|
+
export interface UpdatableRouteOptionsExtensions {
|
|
51
|
+
component?: RouteComponent
|
|
52
|
+
errorComponent?: false | null | ErrorRouteComponent
|
|
53
|
+
notFoundComponent?: NotFoundRouteComponent
|
|
54
|
+
pendingComponent?: RouteComponent
|
|
258
55
|
}
|
|
259
|
-
|
|
260
|
-
export interface ContextOptions<
|
|
261
|
-
in out TParentRoute extends AnyRoute,
|
|
262
|
-
in out TParams,
|
|
263
|
-
> {
|
|
264
|
-
abortController: AbortController
|
|
265
|
-
preload: boolean
|
|
266
|
-
params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>
|
|
267
|
-
location: ParsedLocation
|
|
268
|
-
/**
|
|
269
|
-
* @deprecated Use `throw redirect({ to: '/somewhere' })` instead
|
|
270
|
-
**/
|
|
271
|
-
navigate: NavigateFn
|
|
272
|
-
buildLocation: BuildLocationFn
|
|
273
|
-
cause: 'preload' | 'enter' | 'stay'
|
|
274
|
-
matches: Array<MakeRouteMatchUnion>
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
export interface RouteContextOptions<
|
|
278
|
-
in out TParentRoute extends AnyRoute,
|
|
279
|
-
in out TParams,
|
|
280
|
-
in out TRouterContext,
|
|
281
|
-
in out TLoaderDeps,
|
|
282
|
-
> extends ContextOptions<TParentRoute, TParams> {
|
|
283
|
-
deps: TLoaderDeps
|
|
284
|
-
context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export interface BeforeLoadContextOptions<
|
|
288
|
-
in out TParentRoute extends AnyRoute,
|
|
289
|
-
in out TSearchValidator,
|
|
290
|
-
in out TParams,
|
|
291
|
-
in out TRouterContext,
|
|
292
|
-
in out TRouteContextFn,
|
|
293
|
-
> extends ContextOptions<TParentRoute, TParams>,
|
|
294
|
-
FullSearchSchemaOption<TParentRoute, TSearchValidator> {
|
|
295
|
-
context: Expand<
|
|
296
|
-
BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>
|
|
297
|
-
>
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
type AssetFnContextOptions<
|
|
301
|
-
in out TRouteId,
|
|
302
|
-
in out TFullPath,
|
|
303
|
-
in out TParentRoute extends AnyRoute,
|
|
304
|
-
in out TParams,
|
|
305
|
-
in out TSearchValidator,
|
|
306
|
-
in out TLoaderFn,
|
|
307
|
-
in out TRouterContext,
|
|
308
|
-
in out TRouteContextFn,
|
|
309
|
-
in out TBeforeLoadFn,
|
|
310
|
-
in out TLoaderDeps,
|
|
311
|
-
> = {
|
|
312
|
-
matches: Array<
|
|
313
|
-
RouteMatch<
|
|
314
|
-
TRouteId,
|
|
315
|
-
TFullPath,
|
|
316
|
-
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
317
|
-
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
318
|
-
ResolveLoaderData<TLoaderFn>,
|
|
319
|
-
ResolveAllContext<
|
|
320
|
-
TParentRoute,
|
|
321
|
-
TRouterContext,
|
|
322
|
-
TRouteContextFn,
|
|
323
|
-
TBeforeLoadFn
|
|
324
|
-
>,
|
|
325
|
-
TLoaderDeps
|
|
326
|
-
>
|
|
327
|
-
>
|
|
328
|
-
match: RouteMatch<
|
|
329
|
-
TRouteId,
|
|
330
|
-
TFullPath,
|
|
331
|
-
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
332
|
-
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
333
|
-
ResolveLoaderData<TLoaderFn>,
|
|
334
|
-
ResolveAllContext<
|
|
335
|
-
TParentRoute,
|
|
336
|
-
TRouterContext,
|
|
337
|
-
TRouteContextFn,
|
|
338
|
-
TBeforeLoadFn
|
|
339
|
-
>,
|
|
340
|
-
TLoaderDeps
|
|
341
|
-
>
|
|
342
|
-
params: ResolveAllParamsFromParent<TParentRoute, TParams>
|
|
343
|
-
loaderData: ResolveLoaderData<TLoaderFn>
|
|
344
|
-
}
|
|
345
|
-
export interface UpdatableRouteOptions<
|
|
346
|
-
in out TParentRoute extends AnyRoute,
|
|
347
|
-
in out TRouteId,
|
|
348
|
-
in out TFullPath,
|
|
349
|
-
in out TParams,
|
|
350
|
-
in out TSearchValidator,
|
|
351
|
-
in out TLoaderFn,
|
|
352
|
-
in out TLoaderDeps,
|
|
353
|
-
in out TRouterContext,
|
|
354
|
-
in out TRouteContextFn,
|
|
355
|
-
in out TBeforeLoadFn,
|
|
356
|
-
> extends UpdatableStaticRouteOption {
|
|
357
|
-
// If true, this route will be matched as case-sensitive
|
|
358
|
-
caseSensitive?: boolean
|
|
359
|
-
// If true, this route will be forcefully wrapped in a suspense boundary
|
|
360
|
-
wrapInSuspense?: boolean
|
|
361
|
-
// The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
|
|
362
|
-
component?: RouteComponent
|
|
363
|
-
errorComponent?: false | null | ErrorRouteComponent
|
|
364
|
-
notFoundComponent?: NotFoundRouteComponent
|
|
365
|
-
pendingComponent?: RouteComponent
|
|
366
|
-
pendingMs?: number
|
|
367
|
-
pendingMinMs?: number
|
|
368
|
-
staleTime?: number
|
|
369
|
-
gcTime?: number
|
|
370
|
-
preload?: boolean
|
|
371
|
-
preloadStaleTime?: number
|
|
372
|
-
preloadGcTime?: number
|
|
373
|
-
search?: {
|
|
374
|
-
middlewares?: Array<
|
|
375
|
-
SearchMiddleware<
|
|
376
|
-
ResolveFullSearchSchemaInput<TParentRoute, TSearchValidator>
|
|
377
|
-
>
|
|
378
|
-
>
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
@deprecated Use search.middlewares instead
|
|
382
|
-
*/
|
|
383
|
-
preSearchFilters?: Array<
|
|
384
|
-
SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
|
|
385
|
-
>
|
|
386
|
-
/**
|
|
387
|
-
@deprecated Use search.middlewares instead
|
|
388
|
-
*/
|
|
389
|
-
postSearchFilters?: Array<
|
|
390
|
-
SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
|
|
391
|
-
>
|
|
392
|
-
onCatch?: (error: Error, errorInfo: React.ErrorInfo) => void
|
|
393
|
-
onError?: (err: any) => void
|
|
394
|
-
// These functions are called as route matches are loaded, stick around and leave the active
|
|
395
|
-
// matches
|
|
396
|
-
onEnter?: (
|
|
397
|
-
match: RouteMatch<
|
|
398
|
-
TRouteId,
|
|
399
|
-
TFullPath,
|
|
400
|
-
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
401
|
-
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
402
|
-
ResolveLoaderData<TLoaderFn>,
|
|
403
|
-
ResolveAllContext<
|
|
404
|
-
TParentRoute,
|
|
405
|
-
TRouterContext,
|
|
406
|
-
TRouteContextFn,
|
|
407
|
-
TBeforeLoadFn
|
|
408
|
-
>,
|
|
409
|
-
TLoaderDeps
|
|
410
|
-
>,
|
|
411
|
-
) => void
|
|
412
|
-
onStay?: (
|
|
413
|
-
match: RouteMatch<
|
|
414
|
-
TRouteId,
|
|
415
|
-
TFullPath,
|
|
416
|
-
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
417
|
-
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
418
|
-
ResolveLoaderData<TLoaderFn>,
|
|
419
|
-
ResolveAllContext<
|
|
420
|
-
TParentRoute,
|
|
421
|
-
TRouterContext,
|
|
422
|
-
TRouteContextFn,
|
|
423
|
-
TBeforeLoadFn
|
|
424
|
-
>,
|
|
425
|
-
TLoaderDeps
|
|
426
|
-
>,
|
|
427
|
-
) => void
|
|
428
|
-
onLeave?: (
|
|
429
|
-
match: RouteMatch<
|
|
430
|
-
TRouteId,
|
|
431
|
-
TFullPath,
|
|
432
|
-
ResolveAllParamsFromParent<TParentRoute, TParams>,
|
|
433
|
-
ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
|
|
434
|
-
ResolveLoaderData<TLoaderFn>,
|
|
435
|
-
ResolveAllContext<
|
|
436
|
-
TParentRoute,
|
|
437
|
-
TRouterContext,
|
|
438
|
-
TRouteContextFn,
|
|
439
|
-
TBeforeLoadFn
|
|
440
|
-
>,
|
|
441
|
-
TLoaderDeps
|
|
442
|
-
>,
|
|
443
|
-
) => void
|
|
444
|
-
headers?: (ctx: {
|
|
445
|
-
loaderData: ResolveLoaderData<TLoaderFn>
|
|
446
|
-
}) => Record<string, string>
|
|
447
|
-
head?: (
|
|
448
|
-
ctx: AssetFnContextOptions<
|
|
449
|
-
TRouteId,
|
|
450
|
-
TFullPath,
|
|
451
|
-
TParentRoute,
|
|
452
|
-
TParams,
|
|
453
|
-
TSearchValidator,
|
|
454
|
-
TLoaderFn,
|
|
455
|
-
TRouterContext,
|
|
456
|
-
TRouteContextFn,
|
|
457
|
-
TBeforeLoadFn,
|
|
458
|
-
TLoaderDeps
|
|
459
|
-
>,
|
|
460
|
-
) => {
|
|
461
|
-
links?: AnyRouteMatch['links']
|
|
462
|
-
scripts?: AnyRouteMatch['headScripts']
|
|
463
|
-
meta?: AnyRouteMatch['meta']
|
|
464
|
-
}
|
|
465
|
-
scripts?: (
|
|
466
|
-
ctx: AssetFnContextOptions<
|
|
467
|
-
TRouteId,
|
|
468
|
-
TFullPath,
|
|
469
|
-
TParentRoute,
|
|
470
|
-
TParams,
|
|
471
|
-
TSearchValidator,
|
|
472
|
-
TLoaderFn,
|
|
473
|
-
TRouterContext,
|
|
474
|
-
TRouteContextFn,
|
|
475
|
-
TBeforeLoadFn,
|
|
476
|
-
TLoaderDeps
|
|
477
|
-
>,
|
|
478
|
-
) => AnyRouteMatch['scripts']
|
|
479
|
-
ssr?: boolean
|
|
480
|
-
codeSplitGroupings?: Array<
|
|
481
|
-
Array<
|
|
482
|
-
| 'loader'
|
|
483
|
-
| 'component'
|
|
484
|
-
| 'pendingComponent'
|
|
485
|
-
| 'notFoundComponent'
|
|
486
|
-
| 'errorComponent'
|
|
487
|
-
>
|
|
488
|
-
>
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
export type RouteLoaderFn<
|
|
492
|
-
in out TParentRoute extends AnyRoute = AnyRoute,
|
|
493
|
-
in out TId extends string = string,
|
|
494
|
-
in out TParams = {},
|
|
495
|
-
in out TLoaderDeps = {},
|
|
496
|
-
in out TRouterContext = {},
|
|
497
|
-
in out TRouteContextFn = AnyContext,
|
|
498
|
-
in out TBeforeLoadFn = AnyContext,
|
|
499
|
-
> = (
|
|
500
|
-
match: LoaderFnContext<
|
|
501
|
-
TParentRoute,
|
|
502
|
-
TId,
|
|
503
|
-
TParams,
|
|
504
|
-
TLoaderDeps,
|
|
505
|
-
TRouterContext,
|
|
506
|
-
TRouteContextFn,
|
|
507
|
-
TBeforeLoadFn
|
|
508
|
-
>,
|
|
509
|
-
) => any
|
|
510
|
-
|
|
511
|
-
export interface LoaderFnContext<
|
|
512
|
-
in out TParentRoute extends AnyRoute = AnyRoute,
|
|
513
|
-
in out TId extends string = string,
|
|
514
|
-
in out TParams = {},
|
|
515
|
-
in out TLoaderDeps = {},
|
|
516
|
-
in out TRouterContext = {},
|
|
517
|
-
in out TRouteContextFn = AnyContext,
|
|
518
|
-
in out TBeforeLoadFn = AnyContext,
|
|
519
|
-
> {
|
|
520
|
-
abortController: AbortController
|
|
521
|
-
preload: boolean
|
|
522
|
-
params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>
|
|
523
|
-
deps: TLoaderDeps
|
|
524
|
-
context: Expand<
|
|
525
|
-
ResolveAllContext<
|
|
526
|
-
TParentRoute,
|
|
527
|
-
TRouterContext,
|
|
528
|
-
TRouteContextFn,
|
|
529
|
-
TBeforeLoadFn
|
|
530
|
-
>
|
|
531
|
-
>
|
|
532
|
-
location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps
|
|
533
|
-
/**
|
|
534
|
-
* @deprecated Use `throw redirect({ to: '/somewhere' })` instead
|
|
535
|
-
**/
|
|
536
|
-
navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void> | void
|
|
537
|
-
// root route does not have a parent match
|
|
538
|
-
parentMatchPromise: TId extends RootRouteId
|
|
539
|
-
? never
|
|
540
|
-
: Promise<MakeRouteMatchFromRoute<TParentRoute>>
|
|
541
|
-
cause: 'preload' | 'enter' | 'stay'
|
|
542
|
-
route: Route
|
|
543
56
|
}
|
|
544
57
|
|
|
545
58
|
export interface AnyRoute
|
|
@@ -1119,37 +632,6 @@ export function createRoute<
|
|
|
1119
632
|
|
|
1120
633
|
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>
|
|
1121
634
|
|
|
1122
|
-
export type RootRouteOptions<
|
|
1123
|
-
TSearchValidator = undefined,
|
|
1124
|
-
TRouterContext = {},
|
|
1125
|
-
TRouteContextFn = AnyContext,
|
|
1126
|
-
TBeforeLoadFn = AnyContext,
|
|
1127
|
-
TLoaderDeps extends Record<string, any> = {},
|
|
1128
|
-
TLoaderFn = undefined,
|
|
1129
|
-
> = Omit<
|
|
1130
|
-
RouteOptions<
|
|
1131
|
-
any, // TParentRoute
|
|
1132
|
-
RootRouteId, // TId
|
|
1133
|
-
RootRouteId, // TCustomId
|
|
1134
|
-
'', // TFullPath
|
|
1135
|
-
'', // TPath
|
|
1136
|
-
TSearchValidator,
|
|
1137
|
-
{}, // TParams
|
|
1138
|
-
TLoaderDeps,
|
|
1139
|
-
TLoaderFn,
|
|
1140
|
-
TRouterContext,
|
|
1141
|
-
TRouteContextFn,
|
|
1142
|
-
TBeforeLoadFn
|
|
1143
|
-
>,
|
|
1144
|
-
| 'path'
|
|
1145
|
-
| 'id'
|
|
1146
|
-
| 'getParentRoute'
|
|
1147
|
-
| 'caseSensitive'
|
|
1148
|
-
| 'parseParams'
|
|
1149
|
-
| 'stringifyParams'
|
|
1150
|
-
| 'params'
|
|
1151
|
-
>
|
|
1152
|
-
|
|
1153
635
|
export function createRootRouteWithContext<TRouterContext extends {}>() {
|
|
1154
636
|
return <
|
|
1155
637
|
TRouteContextFn = AnyContext,
|
package/src/router.ts
CHANGED
|
@@ -42,13 +42,18 @@ import type { NoInfer } from '@tanstack/react-store'
|
|
|
42
42
|
import type {
|
|
43
43
|
AnyContext,
|
|
44
44
|
AnyRedirect,
|
|
45
|
+
AnyRouteMatch,
|
|
45
46
|
AnySchema,
|
|
46
47
|
AnyValidator,
|
|
48
|
+
BeforeLoadContextOptions,
|
|
47
49
|
BuildLocationFn,
|
|
48
50
|
CommitLocationOptions,
|
|
49
51
|
ControlledPromise,
|
|
50
52
|
FullSearchSchema,
|
|
53
|
+
LoaderFnContext,
|
|
51
54
|
MakeRemountDepsOptionsUnion,
|
|
55
|
+
MakeRouteMatch,
|
|
56
|
+
MakeRouteMatchUnion,
|
|
52
57
|
Manifest,
|
|
53
58
|
NavigateFn,
|
|
54
59
|
NavigateOptions,
|
|
@@ -59,6 +64,7 @@ import type {
|
|
|
59
64
|
ResolveRelativePath,
|
|
60
65
|
ResolvedRedirect,
|
|
61
66
|
RouteById,
|
|
67
|
+
RouteContextOptions,
|
|
62
68
|
RoutePaths,
|
|
63
69
|
RoutesById,
|
|
64
70
|
RoutesByPath,
|
|
@@ -73,22 +79,14 @@ import type {
|
|
|
73
79
|
} from '@tanstack/router-core'
|
|
74
80
|
import type {
|
|
75
81
|
AnyRoute,
|
|
76
|
-
BeforeLoadContextOptions,
|
|
77
82
|
ErrorRouteComponent,
|
|
78
|
-
LoaderFnContext,
|
|
79
83
|
NotFoundRouteComponent,
|
|
80
84
|
RootRoute,
|
|
81
85
|
RouteComponent,
|
|
82
|
-
RouteContextOptions,
|
|
83
86
|
RouteMask,
|
|
84
87
|
} from './route'
|
|
85
88
|
|
|
86
|
-
import type {
|
|
87
|
-
AnyRouteMatch,
|
|
88
|
-
MakeRouteMatch,
|
|
89
|
-
MakeRouteMatchUnion,
|
|
90
|
-
MatchRouteOptions,
|
|
91
|
-
} from './Matches'
|
|
89
|
+
import type { MatchRouteOptions } from './Matches'
|
|
92
90
|
|
|
93
91
|
import type { NotFoundError } from './not-found'
|
|
94
92
|
|
|
@@ -294,7 +292,6 @@ export interface RouterOptions<
|
|
|
294
292
|
*
|
|
295
293
|
* @default false
|
|
296
294
|
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)
|
|
297
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-trees#case-sensitivity)
|
|
298
295
|
*/
|
|
299
296
|
caseSensitive?: boolean
|
|
300
297
|
/**
|
|
@@ -302,7 +299,7 @@ export interface RouterOptions<
|
|
|
302
299
|
* The route tree that will be used to configure the router instance.
|
|
303
300
|
*
|
|
304
301
|
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)
|
|
305
|
-
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/
|
|
302
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/routing/route-trees)
|
|
306
303
|
*/
|
|
307
304
|
routeTree?: TRouteTree
|
|
308
305
|
/**
|
package/src/useMatch.tsx
CHANGED
|
@@ -7,8 +7,12 @@ import type {
|
|
|
7
7
|
ValidateSelected,
|
|
8
8
|
} from './structuralSharing'
|
|
9
9
|
import type { AnyRouter, RegisteredRouter } from './router'
|
|
10
|
-
import type {
|
|
11
|
-
|
|
10
|
+
import type {
|
|
11
|
+
MakeRouteMatch,
|
|
12
|
+
MakeRouteMatchUnion,
|
|
13
|
+
StrictOrFrom,
|
|
14
|
+
ThrowOrOptional,
|
|
15
|
+
} from '@tanstack/router-core'
|
|
12
16
|
|
|
13
17
|
export interface UseMatchBaseOptions<
|
|
14
18
|
TRouter extends AnyRouter,
|