@tanstack/react-router 0.0.1-beta.9 → 1.0.1
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/LICENSE +21 -0
- package/build/cjs/CatchBoundary.js +128 -0
- package/build/cjs/CatchBoundary.js.map +1 -0
- package/build/cjs/Matches.js +233 -0
- package/build/cjs/Matches.js.map +1 -0
- package/build/cjs/RouterProvider.js +172 -0
- package/build/cjs/RouterProvider.js.map +1 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +2 -22
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/awaited.js +43 -0
- package/build/cjs/awaited.js.map +1 -0
- package/build/cjs/defer.js +37 -0
- package/build/cjs/defer.js.map +1 -0
- package/build/cjs/fileRoute.js +27 -0
- package/build/cjs/fileRoute.js.map +1 -0
- package/build/cjs/index.js +130 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/lazyRouteComponent.js +54 -0
- package/build/cjs/lazyRouteComponent.js.map +1 -0
- package/build/cjs/link.js +223 -0
- package/build/cjs/link.js.map +1 -0
- package/build/cjs/path.js +214 -0
- package/build/cjs/path.js.map +1 -0
- package/build/cjs/qss.js +63 -0
- package/build/cjs/qss.js.map +1 -0
- package/build/cjs/redirects.js +28 -0
- package/build/cjs/redirects.js.map +1 -0
- package/build/cjs/route.js +191 -0
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/router.js +1085 -0
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/scroll-restoration.js +202 -0
- package/build/cjs/scroll-restoration.js.map +1 -0
- package/build/cjs/searchParams.js +81 -0
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/useBlocker.js +55 -0
- package/build/cjs/useBlocker.js.map +1 -0
- package/build/cjs/useNavigate.js +86 -0
- package/build/cjs/useNavigate.js.map +1 -0
- package/build/cjs/useParams.js +26 -0
- package/build/cjs/useParams.js.map +1 -0
- package/build/cjs/useSearch.js +25 -0
- package/build/cjs/useSearch.js.map +1 -0
- package/build/cjs/utils.js +241 -0
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +2302 -2534
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +3498 -2694
- package/build/stats-react.json +1204 -44
- package/build/types/CatchBoundary.d.ts +36 -0
- package/build/types/Matches.d.ts +64 -0
- package/build/types/RouterProvider.d.ts +35 -0
- package/build/types/awaited.d.ts +9 -0
- package/build/types/defer.d.ts +19 -0
- package/build/types/fileRoute.d.ts +38 -0
- package/build/types/history.d.ts +7 -0
- package/build/types/index.d.ts +27 -74
- package/build/types/lazyRouteComponent.d.ts +2 -0
- package/build/types/link.d.ts +93 -0
- package/build/types/location.d.ts +12 -0
- package/build/types/path.d.ts +17 -0
- package/build/types/qss.d.ts +2 -0
- package/build/types/redirects.d.ts +11 -0
- package/build/types/route.d.ts +283 -0
- package/build/types/routeInfo.d.ts +31 -0
- package/build/types/router.d.ts +186 -0
- package/build/types/scroll-restoration.d.ts +18 -0
- package/build/types/searchParams.d.ts +7 -0
- package/build/types/useBlocker.d.ts +9 -0
- package/build/types/useNavigate.d.ts +19 -0
- package/build/types/useParams.d.ts +7 -0
- package/build/types/useSearch.d.ts +7 -0
- package/build/types/utils.d.ts +69 -0
- package/build/umd/index.development.js +2899 -2493
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +4 -4
- package/build/umd/index.production.js.map +1 -1
- package/package.json +12 -10
- package/src/CatchBoundary.tsx +101 -0
- package/src/Matches.tsx +423 -0
- package/src/RouterProvider.tsx +254 -0
- package/src/awaited.tsx +40 -0
- package/src/defer.ts +55 -0
- package/src/fileRoute.ts +152 -0
- package/src/history.ts +8 -0
- package/src/index.tsx +28 -619
- package/src/lazyRouteComponent.tsx +33 -0
- package/src/link.tsx +603 -0
- package/src/location.ts +13 -0
- package/src/path.ts +261 -0
- package/src/qss.ts +53 -0
- package/src/redirects.ts +39 -0
- package/src/route.ts +882 -0
- package/src/routeInfo.ts +84 -0
- package/src/router.ts +1671 -0
- package/src/scroll-restoration.tsx +230 -0
- package/src/searchParams.ts +79 -0
- package/src/useBlocker.tsx +27 -0
- package/src/useNavigate.tsx +111 -0
- package/src/useParams.tsx +25 -0
- package/src/useSearch.tsx +25 -0
- package/src/utils.ts +360 -0
- package/build/cjs/react-router/src/index.js +0 -458
- package/build/cjs/react-router/src/index.js.map +0 -1
- package/build/cjs/router-core/build/esm/index.js +0 -2524
- package/build/cjs/router-core/build/esm/index.js.map +0 -1
package/src/route.ts
ADDED
|
@@ -0,0 +1,882 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import invariant from 'tiny-invariant'
|
|
3
|
+
import { useLoaderData, useLoaderDeps, useMatch } from './Matches'
|
|
4
|
+
import { AnyRouteMatch } from './Matches'
|
|
5
|
+
import { NavigateOptions, ParsePathParams, ToSubOptions } from './link'
|
|
6
|
+
import { ParsedLocation } from './location'
|
|
7
|
+
import { joinPaths, trimPath } from './path'
|
|
8
|
+
import { RouteById, RouteIds, RoutePaths } from './routeInfo'
|
|
9
|
+
import { AnyRouter, RegisteredRouter } from './router'
|
|
10
|
+
import { useParams } from './useParams'
|
|
11
|
+
import { useSearch } from './useSearch'
|
|
12
|
+
import {
|
|
13
|
+
Assign,
|
|
14
|
+
Expand,
|
|
15
|
+
IsAny,
|
|
16
|
+
NoInfer,
|
|
17
|
+
PickRequired,
|
|
18
|
+
UnionToIntersection,
|
|
19
|
+
} from './utils'
|
|
20
|
+
import { BuildLocationFn, NavigateFn } from './RouterProvider'
|
|
21
|
+
|
|
22
|
+
export const rootRouteId = '__root__' as const
|
|
23
|
+
export type RootRouteId = typeof rootRouteId
|
|
24
|
+
export type AnyPathParams = {}
|
|
25
|
+
|
|
26
|
+
export type AnySearchSchema = {}
|
|
27
|
+
|
|
28
|
+
export type AnyContext = {}
|
|
29
|
+
|
|
30
|
+
export interface RouteContext {}
|
|
31
|
+
|
|
32
|
+
export interface RouteMeta {}
|
|
33
|
+
|
|
34
|
+
export type PreloadableObj = { preload?: () => Promise<void> }
|
|
35
|
+
|
|
36
|
+
export type RoutePathOptions<TCustomId, TPath> =
|
|
37
|
+
| {
|
|
38
|
+
path: TPath
|
|
39
|
+
}
|
|
40
|
+
| {
|
|
41
|
+
id: TCustomId
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type RoutePathOptionsIntersection<TCustomId, TPath> =
|
|
45
|
+
UnionToIntersection<RoutePathOptions<TCustomId, TPath>>
|
|
46
|
+
|
|
47
|
+
export type MetaOptions = keyof PickRequired<RouteMeta> extends never
|
|
48
|
+
? {
|
|
49
|
+
meta?: RouteMeta
|
|
50
|
+
}
|
|
51
|
+
: {
|
|
52
|
+
meta: RouteMeta
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type RouteOptions<
|
|
56
|
+
TParentRoute extends AnyRoute = AnyRoute,
|
|
57
|
+
TCustomId extends string = string,
|
|
58
|
+
TPath extends string = string,
|
|
59
|
+
TSearchSchema extends Record<string, any> = {},
|
|
60
|
+
TFullSearchSchema extends Record<string, any> = TSearchSchema,
|
|
61
|
+
TParams extends AnyPathParams = AnyPathParams,
|
|
62
|
+
TAllParams extends AnyPathParams = TParams,
|
|
63
|
+
TRouteContext extends RouteContext = RouteContext,
|
|
64
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
65
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
66
|
+
TLoaderData extends any = unknown,
|
|
67
|
+
> = BaseRouteOptions<
|
|
68
|
+
TParentRoute,
|
|
69
|
+
TCustomId,
|
|
70
|
+
TPath,
|
|
71
|
+
TSearchSchema,
|
|
72
|
+
TFullSearchSchema,
|
|
73
|
+
TParams,
|
|
74
|
+
TAllParams,
|
|
75
|
+
TRouteContext,
|
|
76
|
+
TAllContext,
|
|
77
|
+
TLoaderDeps,
|
|
78
|
+
TLoaderData
|
|
79
|
+
> &
|
|
80
|
+
UpdatableRouteOptions<NoInfer<TFullSearchSchema>>
|
|
81
|
+
|
|
82
|
+
export type ParamsFallback<
|
|
83
|
+
TPath extends string,
|
|
84
|
+
TParams,
|
|
85
|
+
> = unknown extends TParams ? Record<ParsePathParams<TPath>, string> : TParams
|
|
86
|
+
|
|
87
|
+
export type BaseRouteOptions<
|
|
88
|
+
TParentRoute extends AnyRoute = AnyRoute,
|
|
89
|
+
TCustomId extends string = string,
|
|
90
|
+
TPath extends string = string,
|
|
91
|
+
TSearchSchema extends Record<string, any> = {},
|
|
92
|
+
TFullSearchSchema extends Record<string, any> = TSearchSchema,
|
|
93
|
+
TParams extends AnyPathParams = {},
|
|
94
|
+
TAllParams = ParamsFallback<TPath, TParams>,
|
|
95
|
+
TRouteContext extends RouteContext = RouteContext,
|
|
96
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
97
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
98
|
+
TLoaderData extends any = unknown,
|
|
99
|
+
> = RoutePathOptions<TCustomId, TPath> & {
|
|
100
|
+
getParentRoute: () => TParentRoute
|
|
101
|
+
validateSearch?: SearchSchemaValidator<TSearchSchema>
|
|
102
|
+
shouldReload?:
|
|
103
|
+
| boolean
|
|
104
|
+
| ((
|
|
105
|
+
match: LoaderFnContext<
|
|
106
|
+
TAllParams,
|
|
107
|
+
TFullSearchSchema,
|
|
108
|
+
TAllContext,
|
|
109
|
+
TRouteContext
|
|
110
|
+
>,
|
|
111
|
+
) => any)
|
|
112
|
+
} & (keyof PickRequired<RouteContext> extends never
|
|
113
|
+
? // This async function is called before a route is loaded.
|
|
114
|
+
// If an error is thrown here, the route's loader will not be called.
|
|
115
|
+
// If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.
|
|
116
|
+
// If thrown during a preload event, the error will be logged to the console.
|
|
117
|
+
{
|
|
118
|
+
beforeLoad?: BeforeLoadFn<
|
|
119
|
+
TFullSearchSchema,
|
|
120
|
+
TParentRoute,
|
|
121
|
+
TAllParams,
|
|
122
|
+
TRouteContext
|
|
123
|
+
>
|
|
124
|
+
}
|
|
125
|
+
: {
|
|
126
|
+
beforeLoad: BeforeLoadFn<
|
|
127
|
+
TFullSearchSchema,
|
|
128
|
+
TParentRoute,
|
|
129
|
+
TAllParams,
|
|
130
|
+
TRouteContext
|
|
131
|
+
>
|
|
132
|
+
}) & {
|
|
133
|
+
loaderDeps?: (opts: { search: TFullSearchSchema }) => TLoaderDeps
|
|
134
|
+
loader?: RouteLoaderFn<
|
|
135
|
+
TAllParams,
|
|
136
|
+
NoInfer<TLoaderDeps>,
|
|
137
|
+
NoInfer<TAllContext>,
|
|
138
|
+
NoInfer<TRouteContext>,
|
|
139
|
+
TLoaderData
|
|
140
|
+
>
|
|
141
|
+
} & (
|
|
142
|
+
| {
|
|
143
|
+
// Both or none
|
|
144
|
+
parseParams?: (
|
|
145
|
+
rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>,
|
|
146
|
+
) => TParams extends Record<ParsePathParams<TPath>, any>
|
|
147
|
+
? TParams
|
|
148
|
+
: 'parseParams must return an object'
|
|
149
|
+
stringifyParams?: (
|
|
150
|
+
params: NoInfer<ParamsFallback<TPath, TParams>>,
|
|
151
|
+
) => Record<ParsePathParams<TPath>, string>
|
|
152
|
+
}
|
|
153
|
+
| {
|
|
154
|
+
stringifyParams?: never
|
|
155
|
+
parseParams?: never
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
type BeforeLoadFn<
|
|
160
|
+
TFullSearchSchema extends Record<string, any>,
|
|
161
|
+
TParentRoute extends AnyRoute,
|
|
162
|
+
TAllParams,
|
|
163
|
+
TRouteContext,
|
|
164
|
+
> = (opts: {
|
|
165
|
+
search: TFullSearchSchema
|
|
166
|
+
abortController: AbortController
|
|
167
|
+
preload: boolean
|
|
168
|
+
params: TAllParams
|
|
169
|
+
context: TParentRoute['types']['allContext']
|
|
170
|
+
location: ParsedLocation
|
|
171
|
+
navigate: NavigateFn<AnyRoute>
|
|
172
|
+
buildLocation: BuildLocationFn<TParentRoute>
|
|
173
|
+
cause: 'preload' | 'enter' | 'stay'
|
|
174
|
+
}) => Promise<TRouteContext> | TRouteContext | void
|
|
175
|
+
|
|
176
|
+
export type UpdatableRouteOptions<
|
|
177
|
+
TFullSearchSchema extends Record<string, any>,
|
|
178
|
+
> = MetaOptions & {
|
|
179
|
+
// test?: (args: TAllContext) => void
|
|
180
|
+
// If true, this route will be matched as case-sensitive
|
|
181
|
+
caseSensitive?: boolean
|
|
182
|
+
// If true, this route will be forcefully wrapped in a suspense boundary
|
|
183
|
+
wrapInSuspense?: boolean
|
|
184
|
+
// The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
|
|
185
|
+
component?: RouteComponent
|
|
186
|
+
errorComponent?: false | null | ErrorRouteComponent
|
|
187
|
+
pendingComponent?: RouteComponent
|
|
188
|
+
pendingMs?: number
|
|
189
|
+
pendingMinMs?: number
|
|
190
|
+
staleTime?: number
|
|
191
|
+
gcTime?: number
|
|
192
|
+
preloadStaleTime?: number
|
|
193
|
+
preloadGcTime?: number
|
|
194
|
+
// Filter functions that can manipulate search params *before* they are passed to links and navigate
|
|
195
|
+
// calls that match this route.
|
|
196
|
+
preSearchFilters?: SearchFilter<TFullSearchSchema>[]
|
|
197
|
+
// Filter functions that can manipulate search params *after* they are passed to links and navigate
|
|
198
|
+
// calls that match this route.
|
|
199
|
+
postSearchFilters?: SearchFilter<TFullSearchSchema>[]
|
|
200
|
+
onError?: (err: any) => void
|
|
201
|
+
// These functions are called as route matches are loaded, stick around and leave the active
|
|
202
|
+
// matches
|
|
203
|
+
onEnter?: (match: AnyRouteMatch) => void
|
|
204
|
+
onStay?: (match: AnyRouteMatch) => void
|
|
205
|
+
onLeave?: (match: AnyRouteMatch) => void
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export type ParseParamsOption<TPath extends string, TParams> = ParseParamsFn<
|
|
209
|
+
TPath,
|
|
210
|
+
TParams
|
|
211
|
+
>
|
|
212
|
+
|
|
213
|
+
export type ParseParamsFn<TPath extends string, TParams> = (
|
|
214
|
+
rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>,
|
|
215
|
+
) => TParams extends Record<ParsePathParams<TPath>, any>
|
|
216
|
+
? TParams
|
|
217
|
+
: 'parseParams must return an object'
|
|
218
|
+
|
|
219
|
+
export type ParseParamsObj<TPath extends string, TParams> = {
|
|
220
|
+
parse?: ParseParamsFn<TPath, TParams>
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// The parse type here allows a zod schema to be passed directly to the validator
|
|
224
|
+
export type SearchSchemaValidator<TReturn> =
|
|
225
|
+
| SearchSchemaValidatorObj<TReturn>
|
|
226
|
+
| SearchSchemaValidatorFn<TReturn>
|
|
227
|
+
|
|
228
|
+
export type SearchSchemaValidatorObj<TReturn> = {
|
|
229
|
+
parse?: SearchSchemaValidatorFn<TReturn>
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export type SearchSchemaValidatorFn<TReturn> = (
|
|
233
|
+
searchObj: Record<string, unknown>,
|
|
234
|
+
) => TReturn
|
|
235
|
+
|
|
236
|
+
export type DefinedPathParamWarning =
|
|
237
|
+
'Path params cannot be redefined by child routes!'
|
|
238
|
+
|
|
239
|
+
export type ParentParams<TParentParams> = AnyPathParams extends TParentParams
|
|
240
|
+
? {}
|
|
241
|
+
: {
|
|
242
|
+
[Key in keyof TParentParams]?: DefinedPathParamWarning
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export type RouteLoaderFn<
|
|
246
|
+
TAllParams = {},
|
|
247
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
248
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
249
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
250
|
+
TLoaderData extends any = unknown,
|
|
251
|
+
> = (
|
|
252
|
+
match: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext, TRouteContext>,
|
|
253
|
+
) => Promise<TLoaderData> | TLoaderData
|
|
254
|
+
|
|
255
|
+
export interface LoaderFnContext<
|
|
256
|
+
TAllParams = {},
|
|
257
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
258
|
+
TAllContext extends Record<string, any> = AnyContext,
|
|
259
|
+
TRouteContext extends Record<string, any> = AnyContext,
|
|
260
|
+
> {
|
|
261
|
+
abortController: AbortController
|
|
262
|
+
preload: boolean
|
|
263
|
+
params: TAllParams
|
|
264
|
+
deps: TLoaderDeps
|
|
265
|
+
context: Expand<Assign<TAllContext, TRouteContext>>
|
|
266
|
+
location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps
|
|
267
|
+
navigate: (opts: NavigateOptions<AnyRoute>) => Promise<void>
|
|
268
|
+
parentMatchPromise?: Promise<void>
|
|
269
|
+
cause: 'preload' | 'enter' | 'stay'
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export type SearchFilter<T, U = T> = (prev: T) => U
|
|
273
|
+
|
|
274
|
+
export type ResolveId<
|
|
275
|
+
TParentRoute,
|
|
276
|
+
TCustomId extends string,
|
|
277
|
+
TPath extends string,
|
|
278
|
+
> = TParentRoute extends { id: infer TParentId extends string }
|
|
279
|
+
? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>
|
|
280
|
+
: RootRouteId
|
|
281
|
+
|
|
282
|
+
export type InferFullSearchSchema<TRoute> = TRoute extends {
|
|
283
|
+
types: {
|
|
284
|
+
fullSearchSchema: infer TFullSearchSchema
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
? TFullSearchSchema
|
|
288
|
+
: {}
|
|
289
|
+
|
|
290
|
+
export type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = Expand<
|
|
291
|
+
Assign<InferFullSearchSchema<TParentRoute>, TSearchSchema>
|
|
292
|
+
>
|
|
293
|
+
|
|
294
|
+
export interface AnyRoute
|
|
295
|
+
extends Route<
|
|
296
|
+
any,
|
|
297
|
+
any,
|
|
298
|
+
any,
|
|
299
|
+
any,
|
|
300
|
+
any,
|
|
301
|
+
any,
|
|
302
|
+
any,
|
|
303
|
+
any,
|
|
304
|
+
any,
|
|
305
|
+
any,
|
|
306
|
+
any,
|
|
307
|
+
any,
|
|
308
|
+
any,
|
|
309
|
+
any,
|
|
310
|
+
any,
|
|
311
|
+
any
|
|
312
|
+
> {}
|
|
313
|
+
|
|
314
|
+
export type MergeFromFromParent<T, U> = IsAny<T, U, T & U>
|
|
315
|
+
|
|
316
|
+
export type ResolveAllParams<
|
|
317
|
+
TParentRoute extends AnyRoute,
|
|
318
|
+
TParams extends AnyPathParams,
|
|
319
|
+
> = Record<never, string> extends TParentRoute['types']['allParams']
|
|
320
|
+
? TParams
|
|
321
|
+
: Expand<
|
|
322
|
+
UnionToIntersection<TParentRoute['types']['allParams'] & TParams> & {}
|
|
323
|
+
>
|
|
324
|
+
|
|
325
|
+
export type RouteConstraints = {
|
|
326
|
+
TParentRoute: AnyRoute
|
|
327
|
+
TPath: string
|
|
328
|
+
TFullPath: string
|
|
329
|
+
TCustomId: string
|
|
330
|
+
TId: string
|
|
331
|
+
TSearchSchema: AnySearchSchema
|
|
332
|
+
TFullSearchSchema: AnySearchSchema
|
|
333
|
+
TParams: Record<string, any>
|
|
334
|
+
TAllParams: Record<string, any>
|
|
335
|
+
TParentContext: AnyContext
|
|
336
|
+
TRouteContext: RouteContext
|
|
337
|
+
TAllContext: AnyContext
|
|
338
|
+
TRouterContext: AnyContext
|
|
339
|
+
TChildren: unknown
|
|
340
|
+
TRouteTree: AnyRoute
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export class RouteApi<
|
|
344
|
+
TId extends RouteIds<RegisteredRouter['routeTree']>,
|
|
345
|
+
TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>,
|
|
346
|
+
TFullSearchSchema extends Record<
|
|
347
|
+
string,
|
|
348
|
+
any
|
|
349
|
+
> = TRoute['types']['fullSearchSchema'],
|
|
350
|
+
TAllParams extends AnyPathParams = TRoute['types']['allParams'],
|
|
351
|
+
TAllContext extends Record<string, any> = TRoute['types']['allContext'],
|
|
352
|
+
TLoaderDeps extends Record<string, any> = TRoute['types']['loaderDeps'],
|
|
353
|
+
TLoaderData extends any = TRoute['types']['loaderData'],
|
|
354
|
+
> {
|
|
355
|
+
id: TId
|
|
356
|
+
|
|
357
|
+
constructor({ id }: { id: TId }) {
|
|
358
|
+
this.id = id as any
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
useMatch = <TSelected = TAllContext>(opts?: {
|
|
362
|
+
select?: (s: TAllContext) => TSelected
|
|
363
|
+
}): TSelected => {
|
|
364
|
+
return useMatch({ ...opts, from: this.id }) as any
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
useRouteContext = <TSelected = TAllContext>(opts?: {
|
|
368
|
+
select?: (s: TAllContext) => TSelected
|
|
369
|
+
}): TSelected => {
|
|
370
|
+
return useMatch({
|
|
371
|
+
...opts,
|
|
372
|
+
from: this.id,
|
|
373
|
+
select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),
|
|
374
|
+
} as any)
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
useSearch = <TSelected = TFullSearchSchema>(opts?: {
|
|
378
|
+
select?: (s: TFullSearchSchema) => TSelected
|
|
379
|
+
}): TSelected => {
|
|
380
|
+
return useSearch({ ...opts, from: this.id } as any)
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
useParams = <TSelected = TAllParams>(opts?: {
|
|
384
|
+
select?: (s: TAllParams) => TSelected
|
|
385
|
+
}): TSelected => {
|
|
386
|
+
return useParams({ ...opts, from: this.id } as any)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {
|
|
390
|
+
select?: (s: TLoaderDeps) => TSelected
|
|
391
|
+
}): TSelected => {
|
|
392
|
+
return useLoaderDeps({ ...opts, from: this.id } as any) as any
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
useLoaderData = <TSelected = TLoaderData>(opts?: {
|
|
396
|
+
select?: (s: TLoaderData) => TSelected
|
|
397
|
+
}): TSelected => {
|
|
398
|
+
return useLoaderData({ ...opts, from: this.id } as any) as any
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export class Route<
|
|
403
|
+
TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,
|
|
404
|
+
TPath extends RouteConstraints['TPath'] = '/',
|
|
405
|
+
TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<
|
|
406
|
+
TParentRoute,
|
|
407
|
+
TPath
|
|
408
|
+
>,
|
|
409
|
+
TCustomId extends RouteConstraints['TCustomId'] = string,
|
|
410
|
+
TId extends RouteConstraints['TId'] = ResolveId<
|
|
411
|
+
TParentRoute,
|
|
412
|
+
TCustomId,
|
|
413
|
+
TPath
|
|
414
|
+
>,
|
|
415
|
+
TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
|
|
416
|
+
TFullSearchSchema extends
|
|
417
|
+
RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
|
|
418
|
+
TParentRoute,
|
|
419
|
+
TSearchSchema
|
|
420
|
+
>,
|
|
421
|
+
TParams extends RouteConstraints['TParams'] = Expand<
|
|
422
|
+
Record<ParsePathParams<TPath>, string>
|
|
423
|
+
>,
|
|
424
|
+
TAllParams extends RouteConstraints['TAllParams'] = ResolveAllParams<
|
|
425
|
+
TParentRoute,
|
|
426
|
+
TParams
|
|
427
|
+
>,
|
|
428
|
+
TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,
|
|
429
|
+
TAllContext extends Expand<
|
|
430
|
+
Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
|
|
431
|
+
> = Expand<
|
|
432
|
+
Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
|
|
433
|
+
>,
|
|
434
|
+
TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
|
|
435
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
436
|
+
TLoaderData extends any = unknown,
|
|
437
|
+
TChildren extends RouteConstraints['TChildren'] = unknown,
|
|
438
|
+
TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,
|
|
439
|
+
> {
|
|
440
|
+
isRoot: TParentRoute extends Route<any> ? true : false
|
|
441
|
+
options: RouteOptions<
|
|
442
|
+
TParentRoute,
|
|
443
|
+
TCustomId,
|
|
444
|
+
TPath,
|
|
445
|
+
TSearchSchema,
|
|
446
|
+
TFullSearchSchema,
|
|
447
|
+
TParams,
|
|
448
|
+
TAllParams,
|
|
449
|
+
TRouteContext,
|
|
450
|
+
TAllContext,
|
|
451
|
+
TLoaderDeps,
|
|
452
|
+
TLoaderData
|
|
453
|
+
>
|
|
454
|
+
|
|
455
|
+
test!: Expand<
|
|
456
|
+
Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
|
|
457
|
+
>
|
|
458
|
+
|
|
459
|
+
// Set up in this.init()
|
|
460
|
+
parentRoute!: TParentRoute
|
|
461
|
+
id!: TId
|
|
462
|
+
// customId!: TCustomId
|
|
463
|
+
path!: TPath
|
|
464
|
+
fullPath!: TFullPath
|
|
465
|
+
to!: TrimPathRight<TFullPath>
|
|
466
|
+
|
|
467
|
+
// Optional
|
|
468
|
+
children?: TChildren
|
|
469
|
+
originalIndex?: number
|
|
470
|
+
router?: AnyRouter
|
|
471
|
+
rank!: number
|
|
472
|
+
|
|
473
|
+
constructor(
|
|
474
|
+
options: RouteOptions<
|
|
475
|
+
TParentRoute,
|
|
476
|
+
TCustomId,
|
|
477
|
+
TPath,
|
|
478
|
+
TSearchSchema,
|
|
479
|
+
TFullSearchSchema,
|
|
480
|
+
TParams,
|
|
481
|
+
TAllParams,
|
|
482
|
+
TRouteContext,
|
|
483
|
+
TAllContext,
|
|
484
|
+
TLoaderDeps,
|
|
485
|
+
TLoaderData
|
|
486
|
+
>,
|
|
487
|
+
) {
|
|
488
|
+
this.options = (options as any) || {}
|
|
489
|
+
this.isRoot = !options?.getParentRoute as any
|
|
490
|
+
invariant(
|
|
491
|
+
!((options as any)?.id && (options as any)?.path),
|
|
492
|
+
`Route cannot have both an 'id' and a 'path' option.`,
|
|
493
|
+
)
|
|
494
|
+
;(this as any).$$typeof = Symbol.for('react.memo')
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
types!: {
|
|
498
|
+
parentRoute: TParentRoute
|
|
499
|
+
path: TPath
|
|
500
|
+
to: TrimPathRight<TFullPath>
|
|
501
|
+
fullPath: TFullPath
|
|
502
|
+
customId: TCustomId
|
|
503
|
+
id: TId
|
|
504
|
+
searchSchema: TSearchSchema
|
|
505
|
+
fullSearchSchema: TFullSearchSchema
|
|
506
|
+
params: TParams
|
|
507
|
+
allParams: TAllParams
|
|
508
|
+
routeContext: TRouteContext
|
|
509
|
+
allContext: TAllContext
|
|
510
|
+
children: TChildren
|
|
511
|
+
routeTree: TRouteTree
|
|
512
|
+
routerContext: TRouterContext
|
|
513
|
+
loaderData: TLoaderData
|
|
514
|
+
loaderDeps: TLoaderDeps
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
init = (opts: { originalIndex: number }) => {
|
|
518
|
+
this.originalIndex = opts.originalIndex
|
|
519
|
+
|
|
520
|
+
const options = this.options as RouteOptions<
|
|
521
|
+
TParentRoute,
|
|
522
|
+
TCustomId,
|
|
523
|
+
TPath,
|
|
524
|
+
TSearchSchema,
|
|
525
|
+
TFullSearchSchema,
|
|
526
|
+
TParams,
|
|
527
|
+
TAllParams,
|
|
528
|
+
TRouteContext,
|
|
529
|
+
TAllContext,
|
|
530
|
+
TLoaderDeps,
|
|
531
|
+
TLoaderData
|
|
532
|
+
> &
|
|
533
|
+
RoutePathOptionsIntersection<TCustomId, TPath>
|
|
534
|
+
|
|
535
|
+
const isRoot = !options?.path && !options?.id
|
|
536
|
+
|
|
537
|
+
this.parentRoute = this.options?.getParentRoute?.()
|
|
538
|
+
|
|
539
|
+
if (isRoot) {
|
|
540
|
+
this.path = rootRouteId as TPath
|
|
541
|
+
} else {
|
|
542
|
+
invariant(
|
|
543
|
+
this.parentRoute,
|
|
544
|
+
`Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,
|
|
545
|
+
)
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
let path: undefined | string = isRoot ? rootRouteId : options.path
|
|
549
|
+
|
|
550
|
+
// If the path is anything other than an index path, trim it up
|
|
551
|
+
if (path && path !== '/') {
|
|
552
|
+
path = trimPath(path)
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
const customId = options?.id || path
|
|
556
|
+
|
|
557
|
+
// Strip the parentId prefix from the first level of children
|
|
558
|
+
let id = isRoot
|
|
559
|
+
? rootRouteId
|
|
560
|
+
: joinPaths([
|
|
561
|
+
(this.parentRoute.id as any) === rootRouteId
|
|
562
|
+
? ''
|
|
563
|
+
: this.parentRoute.id,
|
|
564
|
+
customId,
|
|
565
|
+
])
|
|
566
|
+
|
|
567
|
+
if (path === rootRouteId) {
|
|
568
|
+
path = '/'
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
if (id !== rootRouteId) {
|
|
572
|
+
id = joinPaths(['/', id])
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
const fullPath =
|
|
576
|
+
id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])
|
|
577
|
+
|
|
578
|
+
this.path = path as TPath
|
|
579
|
+
this.id = id as TId
|
|
580
|
+
// this.customId = customId as TCustomId
|
|
581
|
+
this.fullPath = fullPath as TFullPath
|
|
582
|
+
this.to = fullPath as TrimPathRight<TFullPath>
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
addChildren = <TNewChildren extends AnyRoute[]>(
|
|
586
|
+
children: TNewChildren,
|
|
587
|
+
): Route<
|
|
588
|
+
TParentRoute,
|
|
589
|
+
TPath,
|
|
590
|
+
TFullPath,
|
|
591
|
+
TCustomId,
|
|
592
|
+
TId,
|
|
593
|
+
TSearchSchema,
|
|
594
|
+
TFullSearchSchema,
|
|
595
|
+
TParams,
|
|
596
|
+
TAllParams,
|
|
597
|
+
TRouteContext,
|
|
598
|
+
TAllContext,
|
|
599
|
+
TRouterContext,
|
|
600
|
+
TLoaderDeps,
|
|
601
|
+
TLoaderData,
|
|
602
|
+
TNewChildren,
|
|
603
|
+
TRouteTree
|
|
604
|
+
> => {
|
|
605
|
+
this.children = children as any
|
|
606
|
+
return this as any
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
update = (options: UpdatableRouteOptions<TFullSearchSchema>) => {
|
|
610
|
+
Object.assign(this.options, options)
|
|
611
|
+
return this
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
useMatch = <TSelected = TAllContext>(opts?: {
|
|
615
|
+
select?: (search: TAllContext) => TSelected
|
|
616
|
+
}): TSelected => {
|
|
617
|
+
return useMatch({ ...opts, from: this.id }) as any
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
useRouteContext = <TSelected = TAllContext>(opts?: {
|
|
621
|
+
select?: (search: TAllContext) => TSelected
|
|
622
|
+
}): TSelected => {
|
|
623
|
+
return useMatch({
|
|
624
|
+
...opts,
|
|
625
|
+
from: this.id,
|
|
626
|
+
select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),
|
|
627
|
+
} as any)
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
useSearch = <TSelected = TFullSearchSchema>(opts?: {
|
|
631
|
+
select?: (search: TFullSearchSchema) => TSelected
|
|
632
|
+
}): TSelected => {
|
|
633
|
+
return useSearch({ ...opts, from: this.id } as any)
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
useParams = <TSelected = TAllParams>(opts?: {
|
|
637
|
+
select?: (search: TAllParams) => TSelected
|
|
638
|
+
}): TSelected => {
|
|
639
|
+
return useParams({ ...opts, from: this.id } as any)
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {
|
|
643
|
+
select?: (s: TLoaderDeps) => TSelected
|
|
644
|
+
}): TSelected => {
|
|
645
|
+
return useLoaderDeps({ ...opts, from: this.id } as any) as any
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
useLoaderData = <TSelected = TLoaderData>(opts?: {
|
|
649
|
+
select?: (search: TLoaderData) => TSelected
|
|
650
|
+
}): TSelected => {
|
|
651
|
+
return useLoaderData({ ...opts, from: this.id } as any) as any
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
export type AnyRootRoute = RootRoute<any, any, any, any>
|
|
656
|
+
|
|
657
|
+
export function rootRouteWithContext<TRouterContext extends {}>() {
|
|
658
|
+
return <
|
|
659
|
+
TSearchSchema extends Record<string, any> = {},
|
|
660
|
+
TRouteContext extends RouteContext = RouteContext,
|
|
661
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
662
|
+
TLoaderData extends any = unknown,
|
|
663
|
+
>(
|
|
664
|
+
options?: Omit<
|
|
665
|
+
RouteOptions<
|
|
666
|
+
AnyRoute, // TParentRoute
|
|
667
|
+
RootRouteId, // TCustomId
|
|
668
|
+
'', // TPath
|
|
669
|
+
TSearchSchema, // TSearchSchema
|
|
670
|
+
TSearchSchema, // TFullSearchSchema
|
|
671
|
+
{}, // TParams
|
|
672
|
+
{}, // TAllParams
|
|
673
|
+
TRouteContext, // TRouteContext
|
|
674
|
+
Assign<TRouterContext, TRouteContext>, // TAllContext
|
|
675
|
+
TLoaderDeps,
|
|
676
|
+
TLoaderData // TLoaderData,
|
|
677
|
+
>,
|
|
678
|
+
| 'path'
|
|
679
|
+
| 'id'
|
|
680
|
+
| 'getParentRoute'
|
|
681
|
+
| 'caseSensitive'
|
|
682
|
+
| 'parseParams'
|
|
683
|
+
| 'stringifyParams'
|
|
684
|
+
>,
|
|
685
|
+
): RootRoute<TSearchSchema, TRouteContext, TRouterContext> => {
|
|
686
|
+
return new RootRoute(options) as any
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
export class RootRoute<
|
|
691
|
+
TSearchSchema extends Record<string, any> = {},
|
|
692
|
+
TRouteContext extends RouteContext = RouteContext,
|
|
693
|
+
TRouterContext extends {} = {},
|
|
694
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
695
|
+
TLoaderData extends any = unknown,
|
|
696
|
+
> extends Route<
|
|
697
|
+
any, // TParentRoute
|
|
698
|
+
'/', // TPath
|
|
699
|
+
'/', // TFullPath
|
|
700
|
+
string, // TCustomId
|
|
701
|
+
RootRouteId, // TId
|
|
702
|
+
TSearchSchema, // TSearchSchema
|
|
703
|
+
TSearchSchema, // TFullSearchSchema
|
|
704
|
+
{}, // TParams
|
|
705
|
+
{}, // TAllParams
|
|
706
|
+
TRouteContext, // TRouteContext
|
|
707
|
+
Expand<Assign<TRouterContext, TRouteContext>>, // TAllContext
|
|
708
|
+
TRouterContext, // TRouterContext
|
|
709
|
+
TLoaderDeps,
|
|
710
|
+
TLoaderData,
|
|
711
|
+
any, // TChildren
|
|
712
|
+
any // TRouteTree
|
|
713
|
+
> {
|
|
714
|
+
constructor(
|
|
715
|
+
options?: Omit<
|
|
716
|
+
RouteOptions<
|
|
717
|
+
AnyRoute, // TParentRoute
|
|
718
|
+
RootRouteId, // TCustomId
|
|
719
|
+
'', // TPath
|
|
720
|
+
TSearchSchema, // TSearchSchema
|
|
721
|
+
TSearchSchema, // TFullSearchSchema
|
|
722
|
+
{}, // TParams
|
|
723
|
+
{}, // TAllParams
|
|
724
|
+
TRouteContext, // TRouteContext
|
|
725
|
+
Assign<TRouterContext, TRouteContext>, // TAllContext
|
|
726
|
+
TLoaderDeps,
|
|
727
|
+
TLoaderData
|
|
728
|
+
>,
|
|
729
|
+
| 'path'
|
|
730
|
+
| 'id'
|
|
731
|
+
| 'getParentRoute'
|
|
732
|
+
| 'caseSensitive'
|
|
733
|
+
| 'parseParams'
|
|
734
|
+
| 'stringifyParams'
|
|
735
|
+
>,
|
|
736
|
+
) {
|
|
737
|
+
super(options as any)
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
export type ResolveFullPath<
|
|
742
|
+
TParentRoute extends AnyRoute,
|
|
743
|
+
TPath extends string,
|
|
744
|
+
TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,
|
|
745
|
+
> = TPrefixed extends RootRouteId ? '/' : TPrefixed
|
|
746
|
+
|
|
747
|
+
type RoutePrefix<
|
|
748
|
+
TPrefix extends string,
|
|
749
|
+
TPath extends string,
|
|
750
|
+
> = string extends TPath
|
|
751
|
+
? RootRouteId
|
|
752
|
+
: TPath extends string
|
|
753
|
+
? TPrefix extends RootRouteId
|
|
754
|
+
? TPath extends '/'
|
|
755
|
+
? '/'
|
|
756
|
+
: `/${TrimPath<TPath>}`
|
|
757
|
+
: `${TPrefix}/${TPath}` extends '/'
|
|
758
|
+
? '/'
|
|
759
|
+
: `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`
|
|
760
|
+
: never
|
|
761
|
+
|
|
762
|
+
export type TrimPath<T extends string> = '' extends T
|
|
763
|
+
? ''
|
|
764
|
+
: TrimPathRight<TrimPathLeft<T>>
|
|
765
|
+
|
|
766
|
+
export type TrimPathLeft<T extends string> =
|
|
767
|
+
T extends `${RootRouteId}/${infer U}`
|
|
768
|
+
? TrimPathLeft<U>
|
|
769
|
+
: T extends `/${infer U}`
|
|
770
|
+
? TrimPathLeft<U>
|
|
771
|
+
: T
|
|
772
|
+
export type TrimPathRight<T extends string> = T extends '/'
|
|
773
|
+
? '/'
|
|
774
|
+
: T extends `${infer U}/`
|
|
775
|
+
? TrimPathRight<U>
|
|
776
|
+
: T
|
|
777
|
+
|
|
778
|
+
export type RouteMask<TRouteTree extends AnyRoute> = {
|
|
779
|
+
routeTree: TRouteTree
|
|
780
|
+
from: RoutePaths<TRouteTree>
|
|
781
|
+
to?: any
|
|
782
|
+
params?: any
|
|
783
|
+
search?: any
|
|
784
|
+
hash?: any
|
|
785
|
+
state?: any
|
|
786
|
+
unmaskOnReload?: boolean
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
export function createRouteMask<
|
|
790
|
+
TRouteTree extends AnyRoute,
|
|
791
|
+
TFrom extends RoutePaths<TRouteTree>,
|
|
792
|
+
TTo extends string,
|
|
793
|
+
>(
|
|
794
|
+
opts: {
|
|
795
|
+
routeTree: TRouteTree
|
|
796
|
+
} & ToSubOptions<TRouteTree, TFrom, TTo>,
|
|
797
|
+
): RouteMask<TRouteTree> {
|
|
798
|
+
return opts as any
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
export type ErrorRouteProps = {
|
|
802
|
+
error: unknown
|
|
803
|
+
info: { componentStack: string }
|
|
804
|
+
}
|
|
805
|
+
//
|
|
806
|
+
|
|
807
|
+
export type ReactNode = any
|
|
808
|
+
|
|
809
|
+
export type SyncRouteComponent<TProps> =
|
|
810
|
+
| ((props: TProps) => ReactNode)
|
|
811
|
+
| React.LazyExoticComponent<(props: TProps) => ReactNode>
|
|
812
|
+
|
|
813
|
+
export type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {
|
|
814
|
+
preload?: () => Promise<void>
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
export type RouteComponent<TProps = any> = SyncRouteComponent<TProps> &
|
|
818
|
+
AsyncRouteComponent<TProps>
|
|
819
|
+
|
|
820
|
+
export type ErrorRouteComponent = RouteComponent<ErrorRouteProps>
|
|
821
|
+
|
|
822
|
+
export class NotFoundRoute<
|
|
823
|
+
TParentRoute extends AnyRootRoute,
|
|
824
|
+
TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
|
|
825
|
+
TFullSearchSchema extends
|
|
826
|
+
RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
|
|
827
|
+
TParentRoute,
|
|
828
|
+
TSearchSchema
|
|
829
|
+
>,
|
|
830
|
+
TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,
|
|
831
|
+
TAllContext extends Expand<
|
|
832
|
+
Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
|
|
833
|
+
> = Expand<
|
|
834
|
+
Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>
|
|
835
|
+
>,
|
|
836
|
+
TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
|
|
837
|
+
TLoaderDeps extends Record<string, any> = {},
|
|
838
|
+
TLoaderData extends any = unknown,
|
|
839
|
+
TChildren extends RouteConstraints['TChildren'] = unknown,
|
|
840
|
+
TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,
|
|
841
|
+
> extends Route<
|
|
842
|
+
TParentRoute,
|
|
843
|
+
'/404',
|
|
844
|
+
'/404',
|
|
845
|
+
'404',
|
|
846
|
+
'404',
|
|
847
|
+
TSearchSchema,
|
|
848
|
+
TFullSearchSchema,
|
|
849
|
+
{},
|
|
850
|
+
{},
|
|
851
|
+
TRouteContext,
|
|
852
|
+
TAllContext,
|
|
853
|
+
TRouterContext,
|
|
854
|
+
TLoaderDeps,
|
|
855
|
+
TLoaderData,
|
|
856
|
+
TChildren,
|
|
857
|
+
TRouteTree
|
|
858
|
+
> {
|
|
859
|
+
constructor(
|
|
860
|
+
options: Omit<
|
|
861
|
+
RouteOptions<
|
|
862
|
+
TParentRoute,
|
|
863
|
+
string,
|
|
864
|
+
string,
|
|
865
|
+
TSearchSchema,
|
|
866
|
+
TFullSearchSchema,
|
|
867
|
+
{},
|
|
868
|
+
{},
|
|
869
|
+
TRouteContext,
|
|
870
|
+
TAllContext,
|
|
871
|
+
TLoaderDeps,
|
|
872
|
+
TLoaderData
|
|
873
|
+
>,
|
|
874
|
+
'caseSensitive' | 'parseParams' | 'stringifyParams' | 'path' | 'id'
|
|
875
|
+
>,
|
|
876
|
+
) {
|
|
877
|
+
super({
|
|
878
|
+
...(options as any),
|
|
879
|
+
id: '404',
|
|
880
|
+
})
|
|
881
|
+
}
|
|
882
|
+
}
|