@tanstack/router-core 0.0.1-beta.5 → 0.0.1-beta.50
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/actions.js +94 -0
- package/build/cjs/actions.js.map +1 -0
- package/build/cjs/history.js +163 -0
- package/build/cjs/history.js.map +1 -0
- package/build/cjs/{packages/router-core/src/index.js → index.js} +26 -11
- package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
- package/build/cjs/interop.js +175 -0
- package/build/cjs/interop.js.map +1 -0
- package/build/cjs/{packages/router-core/src/path.js → path.js} +23 -48
- package/build/cjs/path.js.map +1 -0
- package/build/cjs/{packages/router-core/src/qss.js → qss.js} +8 -13
- package/build/cjs/qss.js.map +1 -0
- package/build/cjs/route.js +33 -0
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/{packages/router-core/src/routeConfig.js → routeConfig.js} +13 -18
- package/build/cjs/routeConfig.js.map +1 -0
- package/build/cjs/routeMatch.js +237 -0
- package/build/cjs/routeMatch.js.map +1 -0
- package/build/cjs/router.js +821 -0
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +10 -12
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/store.js +54 -0
- package/build/cjs/store.js.map +1 -0
- package/build/cjs/utils.js +47 -0
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +1384 -2059
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +248 -193
- package/build/types/index.d.ts +385 -317
- package/build/umd/index.development.js +1486 -2142
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +6 -4
- package/src/actions.ts +157 -0
- package/src/frameworks.ts +2 -2
- package/src/history.ts +199 -0
- package/src/index.ts +4 -7
- package/src/interop.ts +169 -0
- package/src/link.ts +87 -44
- package/src/path.ts +12 -8
- package/src/route.ts +36 -229
- package/src/routeConfig.ts +99 -102
- package/src/routeInfo.ts +28 -25
- package/src/routeMatch.ts +294 -322
- package/src/router.ts +1047 -884
- package/src/store.ts +52 -0
- package/src/utils.ts +14 -72
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
- package/build/cjs/node_modules/history/index.js +0 -815
- package/build/cjs/node_modules/history/index.js.map +0 -1
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
- package/build/cjs/packages/router-core/src/path.js.map +0 -1
- package/build/cjs/packages/router-core/src/qss.js.map +0 -1
- package/build/cjs/packages/router-core/src/route.js +0 -161
- package/build/cjs/packages/router-core/src/route.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeMatch.js +0 -266
- package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
- package/build/cjs/packages/router-core/src/router.js +0 -797
- package/build/cjs/packages/router-core/src/router.js.map +0 -1
- package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
- package/build/cjs/packages/router-core/src/utils.js +0 -118
- package/build/cjs/packages/router-core/src/utils.js.map +0 -1
package/src/routeConfig.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
+
import invariant from 'tiny-invariant'
|
|
1
2
|
import { GetFrameworkGeneric } from './frameworks'
|
|
2
3
|
import { ParsePathParams } from './link'
|
|
3
4
|
import { joinPaths, trimPath, trimPathRight } from './path'
|
|
4
5
|
import { RouteInfo } from './routeInfo'
|
|
5
6
|
import { RouteMatch } from './routeMatch'
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
Expand,
|
|
9
|
-
IsAny,
|
|
10
|
-
NoInfer,
|
|
11
|
-
PickUnsafe,
|
|
12
|
-
Values,
|
|
13
|
-
} from './utils'
|
|
7
|
+
import { AnyRouter, RegisteredRouter, Router } from './router'
|
|
8
|
+
import { Expand, IsAny, NoInfer, PickUnsafe } from './utils'
|
|
14
9
|
|
|
15
10
|
export const rootRouteId = '__root__' as const
|
|
16
11
|
export type RootRouteId = typeof rootRouteId
|
|
@@ -50,12 +45,12 @@ export type ParentParams<TParentParams> = AnyPathParams extends TParentParams
|
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
export type LoaderFn<
|
|
53
|
-
TRouteLoaderData extends AnyLoaderData,
|
|
48
|
+
TRouteLoaderData extends AnyLoaderData = {},
|
|
54
49
|
TFullSearchSchema extends AnySearchSchema = {},
|
|
55
50
|
TAllParams extends AnyPathParams = {},
|
|
56
51
|
> = (
|
|
57
52
|
loaderContext: LoaderContext<TFullSearchSchema, TAllParams>,
|
|
58
|
-
) => Promise<TRouteLoaderData>
|
|
53
|
+
) => TRouteLoaderData | Promise<TRouteLoaderData>
|
|
59
54
|
|
|
60
55
|
export interface LoaderContext<
|
|
61
56
|
TFullSearchSchema extends AnySearchSchema = {},
|
|
@@ -64,12 +59,9 @@ export interface LoaderContext<
|
|
|
64
59
|
params: TAllParams
|
|
65
60
|
search: TFullSearchSchema
|
|
66
61
|
signal?: AbortSignal
|
|
62
|
+
// parentLoaderPromise?: Promise<TParentRouteLoaderData>
|
|
67
63
|
}
|
|
68
64
|
|
|
69
|
-
export type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (
|
|
70
|
-
submission: TActionPayload,
|
|
71
|
-
) => TActionResponse | Promise<TActionResponse>
|
|
72
|
-
|
|
73
65
|
export type UnloaderFn<TPath extends string> = (
|
|
74
66
|
routeMatch: RouteMatch<any, RouteInfo<string, TPath>>,
|
|
75
67
|
) => void
|
|
@@ -77,10 +69,10 @@ export type UnloaderFn<TPath extends string> = (
|
|
|
77
69
|
export type RouteOptions<
|
|
78
70
|
TRouteId extends string = string,
|
|
79
71
|
TPath extends string = string,
|
|
72
|
+
TParentRouteLoaderData extends AnyLoaderData = {},
|
|
80
73
|
TRouteLoaderData extends AnyLoaderData = {},
|
|
74
|
+
TParentLoaderData extends AnyLoaderData = {},
|
|
81
75
|
TLoaderData extends AnyLoaderData = {},
|
|
82
|
-
TActionPayload = unknown,
|
|
83
|
-
TActionResponse = unknown,
|
|
84
76
|
TParentSearchSchema extends {} = {},
|
|
85
77
|
TSearchSchema extends AnySearchSchema = {},
|
|
86
78
|
TFullSearchSchema extends AnySearchSchema = TSearchSchema,
|
|
@@ -108,18 +100,12 @@ export type RouteOptions<
|
|
|
108
100
|
// Filter functions that can manipulate search params *after* they are passed to links and navigate
|
|
109
101
|
// calls that match this route.
|
|
110
102
|
postSearchFilters?: SearchFilter<TFullSearchSchema>[]
|
|
111
|
-
// The
|
|
112
|
-
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
// The content to be rendered when `loader` encounters an error
|
|
118
|
-
errorElement?: GetFrameworkGeneric<'SyncOrAsyncElement'> // , NoInfer<TLoaderData>>
|
|
119
|
-
// The content to be rendered when rendering encounters an error
|
|
120
|
-
catchElement?: GetFrameworkGeneric<'SyncOrAsyncElement'> // , NoInfer<TLoaderData>>
|
|
121
|
-
// The content to be rendered when the duration of `loader` execution surpasses the `pendingMs` duration
|
|
122
|
-
pendingElement?: GetFrameworkGeneric<'SyncOrAsyncElement'> //, NoInfer<TLoaderData>>
|
|
103
|
+
// The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
|
|
104
|
+
component?: GetFrameworkGeneric<'Component'> // , NoInfer<TParentLoaderData>>
|
|
105
|
+
// The content to be rendered when the route encounters an error
|
|
106
|
+
errorComponent?: GetFrameworkGeneric<'ErrorComponent'> // , NoInfer<TParentLoaderData>>
|
|
107
|
+
// If supported by your framework, the content to be rendered as the fallback content until the route is ready to render
|
|
108
|
+
pendingComponent?: GetFrameworkGeneric<'Component'> //, NoInfer<TParentLoaderData>>
|
|
123
109
|
// An asynchronous function responsible for preparing or fetching data for the route before it is rendered
|
|
124
110
|
loader?: LoaderFn<TRouteLoaderData, TFullSearchSchema, TAllParams>
|
|
125
111
|
// The max age to consider loader data fresh (not-stale) for this route in milliseconds from the time of fetch
|
|
@@ -128,16 +114,21 @@ export type RouteOptions<
|
|
|
128
114
|
// The max age to cache the loader data for this route in milliseconds from the time of route inactivity
|
|
129
115
|
// before it is garbage collected.
|
|
130
116
|
loaderGcMaxAge?: number
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
|
|
117
|
+
// This async function is called before a route is loaded.
|
|
118
|
+
// If an error is thrown here, the route's loader will not be called.
|
|
119
|
+
// If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onLoadError` function.
|
|
120
|
+
// If thrown during a preload event, the error will be logged to the console.
|
|
121
|
+
beforeLoad?: (opts: {
|
|
122
|
+
router: AnyRouter
|
|
123
|
+
match: RouteMatch
|
|
124
|
+
}) => Promise<void> | void
|
|
125
|
+
// This function will be called if the route's loader throws an error **during an attempted navigation**.
|
|
126
|
+
// If you want to redirect due to an error, call `router.navigate()` from within this function.
|
|
127
|
+
onLoadError?: (err: any) => void
|
|
137
128
|
// This function is called
|
|
138
129
|
// when moving from an inactive state to an active one. Likewise, when moving from
|
|
139
130
|
// an active to an inactive state, the return function (if provided) is called.
|
|
140
|
-
|
|
131
|
+
onLoaded?: (matchContext: {
|
|
141
132
|
params: TAllParams
|
|
142
133
|
search: TFullSearchSchema
|
|
143
134
|
}) =>
|
|
@@ -177,18 +168,15 @@ export interface RouteConfig<
|
|
|
177
168
|
TRouteId extends string = string,
|
|
178
169
|
TPath extends string = string,
|
|
179
170
|
TFullPath extends string = string,
|
|
171
|
+
TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData,
|
|
180
172
|
TRouteLoaderData extends AnyLoaderData = AnyLoaderData,
|
|
173
|
+
TParentLoaderData extends AnyLoaderData = {},
|
|
181
174
|
TLoaderData extends AnyLoaderData = AnyLoaderData,
|
|
182
|
-
TActionPayload = unknown,
|
|
183
|
-
TActionResponse = unknown,
|
|
184
175
|
TParentSearchSchema extends {} = {},
|
|
185
176
|
TSearchSchema extends AnySearchSchema = {},
|
|
186
177
|
TFullSearchSchema extends AnySearchSchema = {},
|
|
187
178
|
TParentParams extends AnyPathParams = {},
|
|
188
|
-
TParams extends
|
|
189
|
-
ParsePathParams<TPath>,
|
|
190
|
-
string
|
|
191
|
-
>,
|
|
179
|
+
TParams extends AnyPathParams = {},
|
|
192
180
|
TAllParams extends AnyPathParams = {},
|
|
193
181
|
TKnownChildren = unknown,
|
|
194
182
|
> {
|
|
@@ -199,10 +187,10 @@ export interface RouteConfig<
|
|
|
199
187
|
options: RouteOptions<
|
|
200
188
|
TRouteId,
|
|
201
189
|
TPath,
|
|
190
|
+
TParentRouteLoaderData,
|
|
202
191
|
TRouteLoaderData,
|
|
192
|
+
TParentLoaderData,
|
|
203
193
|
TLoaderData,
|
|
204
|
-
TActionPayload,
|
|
205
|
-
TActionResponse,
|
|
206
194
|
TParentSearchSchema,
|
|
207
195
|
TSearchSchema,
|
|
208
196
|
TFullSearchSchema,
|
|
@@ -223,44 +211,10 @@ export interface RouteConfig<
|
|
|
223
211
|
TRouteId,
|
|
224
212
|
TPath,
|
|
225
213
|
TFullPath,
|
|
214
|
+
TParentRouteLoaderData,
|
|
226
215
|
TRouteLoaderData,
|
|
216
|
+
TParentLoaderData,
|
|
227
217
|
TLoaderData,
|
|
228
|
-
TActionPayload,
|
|
229
|
-
TActionResponse,
|
|
230
|
-
TParentSearchSchema,
|
|
231
|
-
TSearchSchema,
|
|
232
|
-
TFullSearchSchema,
|
|
233
|
-
TParentParams,
|
|
234
|
-
TParams,
|
|
235
|
-
TAllParams,
|
|
236
|
-
TNewChildren
|
|
237
|
-
>
|
|
238
|
-
>
|
|
239
|
-
createChildren: IsAny<
|
|
240
|
-
TId,
|
|
241
|
-
any,
|
|
242
|
-
<TNewChildren extends any>(
|
|
243
|
-
cb: (
|
|
244
|
-
createChildRoute: CreateRouteConfigFn<
|
|
245
|
-
false,
|
|
246
|
-
TId,
|
|
247
|
-
TFullPath,
|
|
248
|
-
TLoaderData,
|
|
249
|
-
TFullSearchSchema,
|
|
250
|
-
TAllParams
|
|
251
|
-
>,
|
|
252
|
-
) => TNewChildren extends AnyRouteConfig[]
|
|
253
|
-
? TNewChildren
|
|
254
|
-
: { error: 'Invalid route detected'; route: TNewChildren },
|
|
255
|
-
) => RouteConfig<
|
|
256
|
-
TId,
|
|
257
|
-
TRouteId,
|
|
258
|
-
TPath,
|
|
259
|
-
TFullPath,
|
|
260
|
-
TRouteLoaderData,
|
|
261
|
-
TLoaderData,
|
|
262
|
-
TActionPayload,
|
|
263
|
-
TActionResponse,
|
|
264
218
|
TParentSearchSchema,
|
|
265
219
|
TSearchSchema,
|
|
266
220
|
TFullSearchSchema,
|
|
@@ -274,25 +228,72 @@ export interface RouteConfig<
|
|
|
274
228
|
false,
|
|
275
229
|
TId,
|
|
276
230
|
TFullPath,
|
|
231
|
+
TRouteLoaderData,
|
|
277
232
|
TLoaderData,
|
|
278
233
|
TFullSearchSchema,
|
|
279
234
|
TAllParams
|
|
280
235
|
>
|
|
236
|
+
generate: GenerateFn<
|
|
237
|
+
TRouteId,
|
|
238
|
+
TPath,
|
|
239
|
+
TParentRouteLoaderData,
|
|
240
|
+
TParentLoaderData,
|
|
241
|
+
TParentSearchSchema,
|
|
242
|
+
TParentParams
|
|
243
|
+
>
|
|
281
244
|
}
|
|
282
245
|
|
|
246
|
+
type GenerateFn<
|
|
247
|
+
TRouteId extends string = string,
|
|
248
|
+
TPath extends string = string,
|
|
249
|
+
TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData,
|
|
250
|
+
TParentLoaderData extends AnyLoaderData = {},
|
|
251
|
+
TParentSearchSchema extends {} = {},
|
|
252
|
+
TParentParams extends AnyPathParams = {},
|
|
253
|
+
> = <
|
|
254
|
+
TRouteLoaderData extends AnyLoaderData = AnyLoaderData,
|
|
255
|
+
TSearchSchema extends AnySearchSchema = {},
|
|
256
|
+
TParams extends Record<ParsePathParams<TPath>, unknown> = Record<
|
|
257
|
+
ParsePathParams<TPath>,
|
|
258
|
+
string
|
|
259
|
+
>,
|
|
260
|
+
TAllParams extends AnyPathParams extends TParams
|
|
261
|
+
? Record<ParsePathParams<TPath>, string>
|
|
262
|
+
: NoInfer<TParams> = AnyPathParams extends TParams
|
|
263
|
+
? Record<ParsePathParams<TPath>, string>
|
|
264
|
+
: NoInfer<TParams>,
|
|
265
|
+
>(
|
|
266
|
+
options: Omit<
|
|
267
|
+
RouteOptions<
|
|
268
|
+
TRouteId,
|
|
269
|
+
TPath,
|
|
270
|
+
TParentRouteLoaderData,
|
|
271
|
+
TRouteLoaderData,
|
|
272
|
+
TParentLoaderData,
|
|
273
|
+
Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>,
|
|
274
|
+
TParentSearchSchema,
|
|
275
|
+
TSearchSchema,
|
|
276
|
+
Expand<TParentSearchSchema & TSearchSchema>,
|
|
277
|
+
TParentParams,
|
|
278
|
+
TParams,
|
|
279
|
+
Expand<TParentParams & TAllParams>
|
|
280
|
+
>,
|
|
281
|
+
'path'
|
|
282
|
+
>,
|
|
283
|
+
) => void
|
|
284
|
+
|
|
283
285
|
type CreateRouteConfigFn<
|
|
284
286
|
TIsRoot extends boolean = false,
|
|
285
287
|
TParentId extends string = string,
|
|
286
288
|
TParentPath extends string = string,
|
|
287
|
-
|
|
289
|
+
TParentRouteLoaderData extends AnyLoaderData = {},
|
|
290
|
+
TParentLoaderData extends AnyLoaderData = {},
|
|
288
291
|
TParentSearchSchema extends AnySearchSchema = {},
|
|
289
292
|
TParentParams extends AnyPathParams = {},
|
|
290
293
|
> = <
|
|
291
294
|
TRouteId extends string,
|
|
292
295
|
TPath extends string,
|
|
293
296
|
TRouteLoaderData extends AnyLoaderData,
|
|
294
|
-
TActionPayload,
|
|
295
|
-
TActionResponse,
|
|
296
297
|
TSearchSchema extends AnySearchSchema = AnySearchSchema,
|
|
297
298
|
TParams extends Record<ParsePathParams<TPath>, unknown> = Record<
|
|
298
299
|
ParsePathParams<TPath>,
|
|
@@ -315,10 +316,10 @@ type CreateRouteConfigFn<
|
|
|
315
316
|
RouteOptions<
|
|
316
317
|
TRouteId,
|
|
317
318
|
TPath,
|
|
319
|
+
TParentRouteLoaderData,
|
|
318
320
|
TRouteLoaderData,
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
TActionResponse,
|
|
321
|
+
TParentLoaderData,
|
|
322
|
+
Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>,
|
|
322
323
|
TParentSearchSchema,
|
|
323
324
|
TSearchSchema,
|
|
324
325
|
Expand<TParentSearchSchema & TSearchSchema>,
|
|
@@ -331,10 +332,10 @@ type CreateRouteConfigFn<
|
|
|
331
332
|
: RouteOptions<
|
|
332
333
|
TRouteId,
|
|
333
334
|
TPath,
|
|
335
|
+
TParentRouteLoaderData,
|
|
334
336
|
TRouteLoaderData,
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
TActionResponse,
|
|
337
|
+
TParentLoaderData,
|
|
338
|
+
Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>,
|
|
338
339
|
TParentSearchSchema,
|
|
339
340
|
TSearchSchema,
|
|
340
341
|
Expand<TParentSearchSchema & TSearchSchema>,
|
|
@@ -351,10 +352,10 @@ type CreateRouteConfigFn<
|
|
|
351
352
|
TResolvedId,
|
|
352
353
|
TPath,
|
|
353
354
|
string extends TPath ? '' : RoutePath<RoutePrefix<TParentPath, TPath>>,
|
|
355
|
+
TParentRouteLoaderData,
|
|
354
356
|
TRouteLoaderData,
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
TActionResponse,
|
|
357
|
+
TParentLoaderData,
|
|
358
|
+
Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>,
|
|
358
359
|
TParentSearchSchema,
|
|
359
360
|
TSearchSchema,
|
|
360
361
|
Expand<TParentSearchSchema & TSearchSchema>,
|
|
@@ -434,7 +435,7 @@ type TrimPathRight<T extends string> = T extends '/'
|
|
|
434
435
|
|
|
435
436
|
export const createRouteConfig: CreateRouteConfigFn<true> = (
|
|
436
437
|
options = {} as any,
|
|
437
|
-
children,
|
|
438
|
+
children = [] as any,
|
|
438
439
|
isRoot = true,
|
|
439
440
|
parentId,
|
|
440
441
|
parentPath,
|
|
@@ -477,19 +478,15 @@ export const createRouteConfig: CreateRouteConfigFn<true> = (
|
|
|
477
478
|
fullPath: fullPath as any,
|
|
478
479
|
options: options as any,
|
|
479
480
|
children,
|
|
480
|
-
createChildren: (cb: any) =>
|
|
481
|
-
createRouteConfig(
|
|
482
|
-
options,
|
|
483
|
-
cb((childOptions: any) =>
|
|
484
|
-
createRouteConfig(childOptions, undefined, false, id, fullPath),
|
|
485
|
-
),
|
|
486
|
-
false,
|
|
487
|
-
parentId,
|
|
488
|
-
parentPath,
|
|
489
|
-
),
|
|
490
481
|
addChildren: (children: any) =>
|
|
491
482
|
createRouteConfig(options, children, false, parentId, parentPath),
|
|
492
483
|
createRoute: (childOptions: any) =>
|
|
493
484
|
createRouteConfig(childOptions, undefined, false, id, fullPath) as any,
|
|
485
|
+
generate: () => {
|
|
486
|
+
invariant(
|
|
487
|
+
false,
|
|
488
|
+
`routeConfig.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. `,
|
|
489
|
+
)
|
|
490
|
+
},
|
|
494
491
|
}
|
|
495
492
|
}
|
package/src/routeInfo.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ParsePathParams } from './link'
|
|
2
1
|
import { Route } from './route'
|
|
3
2
|
import {
|
|
4
3
|
AnyLoaderData,
|
|
@@ -10,7 +9,7 @@ import {
|
|
|
10
9
|
RouteConfig,
|
|
11
10
|
RouteOptions,
|
|
12
11
|
} from './routeConfig'
|
|
13
|
-
import { IsAny, Values } from './utils'
|
|
12
|
+
import { IsAny, UnionToIntersection, Values } from './utils'
|
|
14
13
|
|
|
15
14
|
export interface AnyAllRouteInfo {
|
|
16
15
|
routeConfig: AnyRouteConfig
|
|
@@ -19,6 +18,8 @@ export interface AnyAllRouteInfo {
|
|
|
19
18
|
routeInfoByFullPath: Record<string, AnyRouteInfo>
|
|
20
19
|
routeIds: any
|
|
21
20
|
routePaths: any
|
|
21
|
+
fullSearchSchema: Record<string, any>
|
|
22
|
+
allParams: Record<string, any>
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export interface DefaultAllRouteInfo {
|
|
@@ -28,6 +29,8 @@ export interface DefaultAllRouteInfo {
|
|
|
28
29
|
routeInfoByFullPath: Record<string, RouteInfo>
|
|
29
30
|
routeIds: string
|
|
30
31
|
routePaths: string
|
|
32
|
+
fullSearchSchema: AnySearchSchema
|
|
33
|
+
allParams: AnyPathParams
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export interface AllRouteInfo<TRouteConfig extends AnyRouteConfig = RouteConfig>
|
|
@@ -58,15 +61,16 @@ type ParseRouteChild<TRouteConfig, TId> = TRouteConfig & {
|
|
|
58
61
|
? ParseRouteConfig<TRouteConfig>
|
|
59
62
|
: never
|
|
60
63
|
|
|
64
|
+
// Generics!
|
|
61
65
|
export type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<
|
|
62
66
|
infer TId,
|
|
63
|
-
infer
|
|
67
|
+
infer TCustomId,
|
|
64
68
|
infer TPath,
|
|
65
69
|
infer TFullPath,
|
|
70
|
+
infer TParentRouteLoaderData,
|
|
66
71
|
infer TRouteLoaderData,
|
|
72
|
+
infer TParentLoaderData,
|
|
67
73
|
infer TLoaderData,
|
|
68
|
-
infer TActionPayload,
|
|
69
|
-
infer TActionResponse,
|
|
70
74
|
infer TParentSearchSchema,
|
|
71
75
|
infer TSearchSchema,
|
|
72
76
|
infer TFullSearchSchema,
|
|
@@ -75,17 +79,17 @@ export type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<
|
|
|
75
79
|
infer TAllParams,
|
|
76
80
|
any
|
|
77
81
|
>
|
|
78
|
-
? string extends
|
|
82
|
+
? string extends TCustomId
|
|
79
83
|
? never
|
|
80
84
|
: RouteInfo<
|
|
81
85
|
TId,
|
|
82
|
-
|
|
86
|
+
TCustomId,
|
|
83
87
|
TPath,
|
|
84
88
|
TFullPath,
|
|
89
|
+
TParentRouteLoaderData,
|
|
85
90
|
TRouteLoaderData,
|
|
91
|
+
TParentLoaderData,
|
|
86
92
|
TLoaderData,
|
|
87
|
-
TActionPayload,
|
|
88
|
-
TActionResponse,
|
|
89
93
|
TParentSearchSchema,
|
|
90
94
|
TSearchSchema,
|
|
91
95
|
TFullSearchSchema,
|
|
@@ -113,10 +117,10 @@ export interface RoutesInfoInner<
|
|
|
113
117
|
any,
|
|
114
118
|
any
|
|
115
119
|
> = RouteInfo,
|
|
116
|
-
TRouteInfoById = {
|
|
120
|
+
TRouteInfoById = { '/': TRouteInfo } & {
|
|
117
121
|
[TInfo in TRouteInfo as TInfo['id']]: TInfo
|
|
118
122
|
},
|
|
119
|
-
TRouteInfoByFullPath = {
|
|
123
|
+
TRouteInfoByFullPath = { '/': TRouteInfo } & {
|
|
120
124
|
[TInfo in TRouteInfo as TInfo['fullPath'] extends RootRouteId
|
|
121
125
|
? never
|
|
122
126
|
: string extends TInfo['fullPath']
|
|
@@ -130,6 +134,8 @@ export interface RoutesInfoInner<
|
|
|
130
134
|
routeInfoByFullPath: TRouteInfoByFullPath
|
|
131
135
|
routeIds: keyof TRouteInfoById
|
|
132
136
|
routePaths: keyof TRouteInfoByFullPath
|
|
137
|
+
fullSearchSchema: Partial<UnionToIntersection<TRouteInfo['fullSearchSchema']>>
|
|
138
|
+
allParams: Partial<UnionToIntersection<TRouteInfo['allParams']>>
|
|
133
139
|
}
|
|
134
140
|
|
|
135
141
|
export interface AnyRouteInfo
|
|
@@ -152,43 +158,40 @@ export interface AnyRouteInfo
|
|
|
152
158
|
|
|
153
159
|
export interface RouteInfo<
|
|
154
160
|
TId extends string = string,
|
|
155
|
-
|
|
161
|
+
TCustomId extends string = string,
|
|
156
162
|
TPath extends string = string,
|
|
157
|
-
TFullPath extends string =
|
|
163
|
+
TFullPath extends string = '/',
|
|
164
|
+
TParentRouteLoaderData extends AnyLoaderData = {},
|
|
158
165
|
TRouteLoaderData extends AnyLoaderData = {},
|
|
166
|
+
TParentLoaderData extends AnyLoaderData = {},
|
|
159
167
|
TLoaderData extends AnyLoaderData = {},
|
|
160
|
-
TActionPayload = unknown,
|
|
161
|
-
TActionResponse = unknown,
|
|
162
168
|
TParentSearchSchema extends {} = {},
|
|
163
169
|
TSearchSchema extends AnySearchSchema = {},
|
|
164
170
|
TFullSearchSchema extends AnySearchSchema = {},
|
|
165
171
|
TParentParams extends AnyPathParams = {},
|
|
166
|
-
TParams extends
|
|
167
|
-
ParsePathParams<TPath>,
|
|
168
|
-
string
|
|
169
|
-
>,
|
|
172
|
+
TParams extends AnyPathParams = {},
|
|
170
173
|
TAllParams extends AnyPathParams = {},
|
|
171
174
|
> {
|
|
172
175
|
id: TId
|
|
173
|
-
|
|
176
|
+
customId: TCustomId
|
|
174
177
|
path: TPath
|
|
175
178
|
fullPath: TFullPath
|
|
179
|
+
parentRouteLoaderData: TParentRouteLoaderData
|
|
176
180
|
routeLoaderData: TRouteLoaderData
|
|
181
|
+
parentLoaderData: TParentLoaderData
|
|
177
182
|
loaderData: TLoaderData
|
|
178
|
-
actionPayload: TActionPayload
|
|
179
|
-
actionResponse: TActionResponse
|
|
180
183
|
searchSchema: TSearchSchema
|
|
181
184
|
fullSearchSchema: TFullSearchSchema
|
|
182
185
|
parentParams: TParentParams
|
|
183
186
|
params: TParams
|
|
184
187
|
allParams: TAllParams
|
|
185
188
|
options: RouteOptions<
|
|
186
|
-
|
|
189
|
+
TCustomId,
|
|
187
190
|
TPath,
|
|
191
|
+
TParentRouteLoaderData,
|
|
188
192
|
TRouteLoaderData,
|
|
193
|
+
TParentLoaderData,
|
|
189
194
|
TLoaderData,
|
|
190
|
-
TActionPayload,
|
|
191
|
-
TActionResponse,
|
|
192
195
|
TParentSearchSchema,
|
|
193
196
|
TSearchSchema,
|
|
194
197
|
TFullSearchSchema,
|