@tanstack/router-core 0.0.1-beta.9 → 1.97.21
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/README.md +5 -0
- package/dist/cjs/Matches.cjs +13 -0
- package/dist/cjs/Matches.cjs.map +1 -0
- package/dist/cjs/Matches.d.cts +28 -0
- package/dist/cjs/RouterProvider.d.cts +18 -0
- package/dist/cjs/defer.cjs +25 -0
- package/dist/cjs/defer.cjs.map +1 -0
- package/dist/cjs/defer.d.cts +20 -0
- package/dist/cjs/index.cjs +50 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +25 -0
- package/dist/cjs/link.cjs +5 -0
- package/dist/cjs/link.cjs.map +1 -0
- package/dist/cjs/link.d.cts +51 -0
- package/dist/cjs/location.d.cts +12 -0
- package/dist/cjs/manifest.d.cts +24 -0
- package/dist/cjs/path.cjs +289 -0
- package/dist/cjs/path.cjs.map +1 -0
- package/dist/cjs/path.d.cts +34 -0
- package/dist/cjs/qss.cjs +51 -0
- package/dist/cjs/qss.cjs.map +1 -0
- package/dist/cjs/qss.d.cts +27 -0
- package/dist/cjs/root.cjs +5 -0
- package/dist/cjs/root.cjs.map +1 -0
- package/dist/cjs/root.d.cts +2 -0
- package/dist/cjs/route.d.cts +148 -0
- package/dist/cjs/router.cjs +19 -0
- package/dist/cjs/router.cjs.map +1 -0
- package/dist/cjs/router.d.cts +31 -0
- package/dist/cjs/searchMiddleware.cjs +42 -0
- package/dist/cjs/searchMiddleware.cjs.map +1 -0
- package/dist/cjs/searchMiddleware.d.cts +5 -0
- package/dist/cjs/searchParams.cjs +61 -0
- package/dist/cjs/searchParams.cjs.map +1 -0
- package/dist/cjs/searchParams.d.cts +7 -0
- package/dist/cjs/serializer.d.cts +15 -0
- package/dist/cjs/structuralSharing.d.cts +4 -0
- package/dist/cjs/utils.cjs +155 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +81 -0
- package/dist/cjs/validators.d.cts +51 -0
- package/dist/esm/Matches.d.ts +28 -0
- package/dist/esm/Matches.js +13 -0
- package/dist/esm/Matches.js.map +1 -0
- package/dist/esm/RouterProvider.d.ts +18 -0
- package/dist/esm/defer.d.ts +20 -0
- package/dist/esm/defer.js +25 -0
- package/dist/esm/defer.js.map +1 -0
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.js +50 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/link.d.ts +51 -0
- package/dist/esm/link.js +5 -0
- package/dist/esm/link.js.map +1 -0
- package/dist/esm/location.d.ts +12 -0
- package/dist/esm/manifest.d.ts +24 -0
- package/dist/esm/path.d.ts +34 -0
- package/dist/esm/path.js +289 -0
- package/dist/esm/path.js.map +1 -0
- package/dist/esm/qss.d.ts +27 -0
- package/dist/esm/qss.js +51 -0
- package/dist/esm/qss.js.map +1 -0
- package/dist/esm/root.d.ts +2 -0
- package/dist/esm/root.js +5 -0
- package/dist/esm/root.js.map +1 -0
- package/dist/esm/route.d.ts +148 -0
- package/dist/esm/router.d.ts +31 -0
- package/dist/esm/router.js +19 -0
- package/dist/esm/router.js.map +1 -0
- package/dist/esm/searchMiddleware.d.ts +5 -0
- package/dist/esm/searchMiddleware.js +42 -0
- package/dist/esm/searchMiddleware.js.map +1 -0
- package/dist/esm/searchParams.d.ts +7 -0
- package/dist/esm/searchParams.js +61 -0
- package/dist/esm/searchParams.js.map +1 -0
- package/dist/esm/serializer.d.ts +15 -0
- package/dist/esm/structuralSharing.d.ts +4 -0
- package/dist/esm/utils.d.ts +81 -0
- package/dist/esm/utils.js +155 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/validators.d.ts +51 -0
- package/package.json +35 -32
- package/src/Matches.ts +94 -0
- package/src/RouterProvider.ts +20 -0
- package/src/defer.ts +52 -0
- package/src/index.ts +206 -19
- package/src/link.ts +122 -300
- package/src/location.ts +13 -0
- package/src/manifest.ts +32 -0
- package/src/path.ts +238 -47
- package/src/qss.ts +56 -19
- package/src/root.ts +2 -0
- package/src/route.ts +296 -223
- package/src/router.ts +34 -1281
- package/src/searchMiddleware.ts +54 -0
- package/src/searchParams.ts +43 -20
- package/src/serializer.ts +24 -0
- package/src/structuralSharing.ts +7 -0
- package/src/utils.ts +314 -75
- package/src/validators.ts +121 -0
- 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/index.js +0 -58
- package/build/cjs/packages/router-core/src/index.js.map +0 -1
- package/build/cjs/packages/router-core/src/path.js +0 -222
- package/build/cjs/packages/router-core/src/path.js.map +0 -1
- package/build/cjs/packages/router-core/src/qss.js +0 -71
- package/build/cjs/packages/router-core/src/qss.js.map +0 -1
- package/build/cjs/packages/router-core/src/route.js +0 -150
- package/build/cjs/packages/router-core/src/route.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
- 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 -822
- package/build/cjs/packages/router-core/src/router.js.map +0 -1
- package/build/cjs/packages/router-core/src/searchParams.js +0 -70
- package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
- package/build/cjs/packages/router-core/src/utils.js +0 -125
- package/build/cjs/packages/router-core/src/utils.js.map +0 -1
- package/build/esm/index.js +0 -2481
- package/build/esm/index.js.map +0 -1
- package/build/stats-html.html +0 -4034
- package/build/stats-react.json +0 -493
- package/build/types/index.d.ts +0 -618
- package/build/umd/index.development.js +0 -2514
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -12
- package/build/umd/index.production.js.map +0 -1
- package/src/frameworks.ts +0 -12
- package/src/routeConfig.ts +0 -495
- package/src/routeInfo.ts +0 -228
- package/src/routeMatch.ts +0 -374
package/src/route.ts
CHANGED
|
@@ -1,230 +1,303 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
ActionState,
|
|
20
|
-
Loader,
|
|
21
|
-
LoaderState,
|
|
22
|
-
MatchRouteOptions,
|
|
23
|
-
Router,
|
|
24
|
-
} from './router'
|
|
25
|
-
import { NoInfer, replaceEqualDeep } from './utils'
|
|
26
|
-
|
|
27
|
-
export interface AnyRoute extends Route<any, any> {}
|
|
28
|
-
|
|
29
|
-
export interface Route<
|
|
30
|
-
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
|
|
31
|
-
TRouteInfo extends AnyRouteInfo = RouteInfo,
|
|
32
|
-
> {
|
|
33
|
-
routeId: TRouteInfo['id']
|
|
34
|
-
routeRouteId: TRouteInfo['routeId']
|
|
35
|
-
routePath: TRouteInfo['path']
|
|
36
|
-
fullPath: TRouteInfo['fullPath']
|
|
37
|
-
parentRoute?: AnyRoute
|
|
38
|
-
childRoutes?: AnyRoute[]
|
|
39
|
-
options: RouteOptions
|
|
40
|
-
router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>
|
|
41
|
-
buildLink: <TTo extends string = '.'>(
|
|
42
|
-
options: Omit<
|
|
43
|
-
LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>,
|
|
44
|
-
'from'
|
|
45
|
-
>,
|
|
46
|
-
) => LinkInfo
|
|
47
|
-
matchRoute: <
|
|
48
|
-
TTo extends string = '.',
|
|
49
|
-
TResolved extends string = ResolveRelativePath<TRouteInfo['id'], TTo>,
|
|
50
|
-
>(
|
|
51
|
-
matchLocation: CheckRelativePath<
|
|
52
|
-
TAllRouteInfo,
|
|
53
|
-
TRouteInfo['fullPath'],
|
|
54
|
-
NoInfer<TTo>
|
|
55
|
-
> &
|
|
56
|
-
Omit<ToOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>,
|
|
57
|
-
opts?: MatchRouteOptions,
|
|
58
|
-
) => RouteInfoByPath<TAllRouteInfo, TResolved>['allParams']
|
|
59
|
-
navigate: <TTo extends string = '.'>(
|
|
60
|
-
options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['id'], TTo>, 'from'>,
|
|
61
|
-
) => Promise<void>
|
|
62
|
-
action: unknown extends TRouteInfo['actionResponse']
|
|
63
|
-
?
|
|
64
|
-
| Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>
|
|
65
|
-
| undefined
|
|
66
|
-
: Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>
|
|
67
|
-
loader: unknown extends TRouteInfo['routeLoaderData']
|
|
68
|
-
?
|
|
69
|
-
| Action<
|
|
70
|
-
LoaderContext<
|
|
71
|
-
TRouteInfo['fullSearchSchema'],
|
|
72
|
-
TRouteInfo['allParams']
|
|
73
|
-
>,
|
|
74
|
-
TRouteInfo['routeLoaderData']
|
|
75
|
-
>
|
|
76
|
-
| undefined
|
|
77
|
-
: Loader<
|
|
78
|
-
TRouteInfo['fullSearchSchema'],
|
|
79
|
-
TRouteInfo['allParams'],
|
|
80
|
-
TRouteInfo['routeLoaderData']
|
|
81
|
-
>
|
|
1
|
+
import type { ParsePathParams } from './link'
|
|
2
|
+
import type { RootRouteId } from './root'
|
|
3
|
+
import type { Assign } from './utils'
|
|
4
|
+
import type {
|
|
5
|
+
AnySchema,
|
|
6
|
+
AnyStandardSchemaValidator,
|
|
7
|
+
AnyValidatorAdapter,
|
|
8
|
+
AnyValidatorObj,
|
|
9
|
+
StandardSchemaValidator,
|
|
10
|
+
ValidatorAdapter,
|
|
11
|
+
ValidatorFn,
|
|
12
|
+
ValidatorObj,
|
|
13
|
+
} from './validators'
|
|
14
|
+
|
|
15
|
+
export type AnyPathParams = {}
|
|
16
|
+
|
|
17
|
+
export type SearchSchemaInput = {
|
|
18
|
+
__TSearchSchemaInput__: 'TSearchSchemaInput'
|
|
82
19
|
}
|
|
83
20
|
|
|
84
|
-
export
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
router.state.loaders[id] = {
|
|
155
|
-
pending: [],
|
|
156
|
-
fetch: (async (loaderContext: LoaderContext<any, any>) => {
|
|
157
|
-
if (!route) {
|
|
158
|
-
return
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const loaderState: LoaderState<any, any> = {
|
|
162
|
-
loadedAt: Date.now(),
|
|
163
|
-
loaderContext,
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
loader.current = loaderState
|
|
167
|
-
loader.latest = loaderState
|
|
168
|
-
loader.pending.push(loaderState)
|
|
169
|
-
|
|
170
|
-
// router.state = {
|
|
171
|
-
// ...router.state,
|
|
172
|
-
// currentAction: loaderState,
|
|
173
|
-
// latestAction: loaderState,
|
|
174
|
-
// }
|
|
175
|
-
|
|
176
|
-
router.notify()
|
|
177
|
-
|
|
178
|
-
try {
|
|
179
|
-
return await route.options.loader?.(loaderContext)
|
|
180
|
-
} finally {
|
|
181
|
-
loader.pending = loader.pending.filter((d) => d !== loaderState)
|
|
182
|
-
// router.removeActionQueue.push({ loader, loaderState })
|
|
183
|
-
router.notify()
|
|
184
|
-
}
|
|
185
|
-
}) as any,
|
|
21
|
+
export type AnyContext = {}
|
|
22
|
+
|
|
23
|
+
export interface RouteContext {}
|
|
24
|
+
|
|
25
|
+
export type PreloadableObj = { preload?: () => Promise<void> }
|
|
26
|
+
|
|
27
|
+
export type RoutePathOptions<TCustomId, TPath> =
|
|
28
|
+
| {
|
|
29
|
+
path: TPath
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
id: TCustomId
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface StaticDataRouteOption {}
|
|
36
|
+
|
|
37
|
+
export type RoutePathOptionsIntersection<TCustomId, TPath> = {
|
|
38
|
+
path: TPath
|
|
39
|
+
id: TCustomId
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult
|
|
43
|
+
|
|
44
|
+
export type SearchMiddlewareContext<TSearchSchema> = {
|
|
45
|
+
search: TSearchSchema
|
|
46
|
+
next: (newSearch: TSearchSchema) => TSearchSchema
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type SearchMiddleware<TSearchSchema> = (
|
|
50
|
+
ctx: SearchMiddlewareContext<TSearchSchema>,
|
|
51
|
+
) => TSearchSchema
|
|
52
|
+
|
|
53
|
+
export type ResolveId<
|
|
54
|
+
TParentRoute,
|
|
55
|
+
TCustomId extends string,
|
|
56
|
+
TPath extends string,
|
|
57
|
+
> = TParentRoute extends { id: infer TParentId extends string }
|
|
58
|
+
? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>
|
|
59
|
+
: RootRouteId
|
|
60
|
+
|
|
61
|
+
export type InferFullSearchSchema<TRoute> = TRoute extends {
|
|
62
|
+
types: {
|
|
63
|
+
fullSearchSchema: infer TFullSearchSchema
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
? TFullSearchSchema
|
|
67
|
+
: {}
|
|
68
|
+
|
|
69
|
+
export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
|
|
70
|
+
types: {
|
|
71
|
+
fullSearchSchemaInput: infer TFullSearchSchemaInput
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
? TFullSearchSchemaInput
|
|
75
|
+
: {}
|
|
76
|
+
|
|
77
|
+
export type InferAllParams<TRoute> = TRoute extends {
|
|
78
|
+
types: {
|
|
79
|
+
allParams: infer TAllParams
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
? TAllParams
|
|
83
|
+
: {}
|
|
84
|
+
|
|
85
|
+
export type InferAllContext<TRoute> = unknown extends TRoute
|
|
86
|
+
? TRoute
|
|
87
|
+
: TRoute extends {
|
|
88
|
+
types: {
|
|
89
|
+
allContext: infer TAllContext
|
|
90
|
+
}
|
|
186
91
|
}
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
92
|
+
? TAllContext
|
|
93
|
+
: {}
|
|
94
|
+
|
|
95
|
+
export type ResolveSearchSchemaFnInput<TSearchValidator> =
|
|
96
|
+
TSearchValidator extends (input: infer TSearchSchemaInput) => any
|
|
97
|
+
? TSearchSchemaInput extends SearchSchemaInput
|
|
98
|
+
? Omit<TSearchSchemaInput, keyof SearchSchemaInput>
|
|
99
|
+
: ResolveSearchSchemaFn<TSearchValidator>
|
|
100
|
+
: AnySchema
|
|
101
|
+
|
|
102
|
+
export type ResolveSearchSchemaInput<TSearchValidator> =
|
|
103
|
+
TSearchValidator extends AnyStandardSchemaValidator
|
|
104
|
+
? NonNullable<TSearchValidator['~standard']['types']>['input']
|
|
105
|
+
: TSearchValidator extends AnyValidatorAdapter
|
|
106
|
+
? TSearchValidator['types']['input']
|
|
107
|
+
: TSearchValidator extends AnyValidatorObj
|
|
108
|
+
? ResolveSearchSchemaFnInput<TSearchValidator['parse']>
|
|
109
|
+
: ResolveSearchSchemaFnInput<TSearchValidator>
|
|
110
|
+
|
|
111
|
+
export type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (
|
|
112
|
+
...args: any
|
|
113
|
+
) => infer TSearchSchema
|
|
114
|
+
? TSearchSchema
|
|
115
|
+
: AnySchema
|
|
116
|
+
|
|
117
|
+
export type ResolveSearchSchema<TSearchValidator> =
|
|
118
|
+
unknown extends TSearchValidator
|
|
119
|
+
? TSearchValidator
|
|
120
|
+
: TSearchValidator extends AnyStandardSchemaValidator
|
|
121
|
+
? NonNullable<TSearchValidator['~standard']['types']>['output']
|
|
122
|
+
: TSearchValidator extends AnyValidatorAdapter
|
|
123
|
+
? TSearchValidator['types']['output']
|
|
124
|
+
: TSearchValidator extends AnyValidatorObj
|
|
125
|
+
? ResolveSearchSchemaFn<TSearchValidator['parse']>
|
|
126
|
+
: ResolveSearchSchemaFn<TSearchValidator>
|
|
127
|
+
|
|
128
|
+
export type ParseSplatParams<TPath extends string> = TPath &
|
|
129
|
+
`${string}$` extends never
|
|
130
|
+
? TPath & `${string}$/${string}` extends never
|
|
131
|
+
? never
|
|
132
|
+
: '_splat'
|
|
133
|
+
: '_splat'
|
|
134
|
+
|
|
135
|
+
export interface SplatParams {
|
|
136
|
+
_splat?: string
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type ResolveParams<TPath extends string> =
|
|
140
|
+
ParseSplatParams<TPath> extends never
|
|
141
|
+
? Record<ParsePathParams<TPath>, string>
|
|
142
|
+
: Record<ParsePathParams<TPath>, string> & SplatParams
|
|
143
|
+
|
|
144
|
+
export type ParseParamsFn<in out TPath extends string, in out TParams> = (
|
|
145
|
+
rawParams: ResolveParams<TPath>,
|
|
146
|
+
) => TParams extends Record<ParsePathParams<TPath>, any>
|
|
147
|
+
? TParams
|
|
148
|
+
: Record<ParsePathParams<TPath>, any>
|
|
149
|
+
|
|
150
|
+
export type StringifyParamsFn<in out TPath extends string, in out TParams> = (
|
|
151
|
+
params: TParams,
|
|
152
|
+
) => ResolveParams<TPath>
|
|
153
|
+
|
|
154
|
+
export type ParamsOptions<in out TPath extends string, in out TParams> = {
|
|
155
|
+
params?: {
|
|
156
|
+
parse?: ParseParamsFn<TPath, TParams>
|
|
157
|
+
stringify?: StringifyParamsFn<TPath, TParams>
|
|
225
158
|
}
|
|
226
159
|
|
|
227
|
-
|
|
160
|
+
/**
|
|
161
|
+
@deprecated Use params.parse instead
|
|
162
|
+
*/
|
|
163
|
+
parseParams?: ParseParamsFn<TPath, TParams>
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
@deprecated Use params.stringify instead
|
|
167
|
+
*/
|
|
168
|
+
stringifyParams?: StringifyParamsFn<TPath, TParams>
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
interface RequiredStaticDataRouteOption {
|
|
172
|
+
staticData: StaticDataRouteOption
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface OptionalStaticDataRouteOption {
|
|
176
|
+
staticData?: StaticDataRouteOption
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export type UpdatableStaticRouteOption = {} extends StaticDataRouteOption
|
|
180
|
+
? OptionalStaticDataRouteOption
|
|
181
|
+
: RequiredStaticDataRouteOption
|
|
182
|
+
|
|
183
|
+
export type MetaDescriptor =
|
|
184
|
+
| { charSet: 'utf-8' }
|
|
185
|
+
| { title: string }
|
|
186
|
+
| { name: string; content: string }
|
|
187
|
+
| { property: string; content: string }
|
|
188
|
+
| { httpEquiv: string; content: string }
|
|
189
|
+
| { 'script:ld+json': LdJsonObject }
|
|
190
|
+
| { tagName: 'meta' | 'link'; [name: string]: string }
|
|
191
|
+
| Record<string, unknown>
|
|
228
192
|
|
|
229
|
-
|
|
193
|
+
type LdJsonObject = { [Key in string]: LdJsonValue } & {
|
|
194
|
+
[Key in string]?: LdJsonValue | undefined
|
|
230
195
|
}
|
|
196
|
+
type LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>
|
|
197
|
+
type LdJsonPrimitive = string | number | boolean | null
|
|
198
|
+
type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray
|
|
199
|
+
|
|
200
|
+
export type RouteLinkEntry = {}
|
|
201
|
+
|
|
202
|
+
export type SearchValidator<TInput, TOutput> =
|
|
203
|
+
| ValidatorObj<TInput, TOutput>
|
|
204
|
+
| ValidatorFn<TInput, TOutput>
|
|
205
|
+
| ValidatorAdapter<TInput, TOutput>
|
|
206
|
+
| StandardSchemaValidator<TInput, TOutput>
|
|
207
|
+
| undefined
|
|
208
|
+
|
|
209
|
+
export type AnySearchValidator = SearchValidator<any, any>
|
|
210
|
+
|
|
211
|
+
export type DefaultSearchValidator = SearchValidator<
|
|
212
|
+
Record<string, unknown>,
|
|
213
|
+
AnySchema
|
|
214
|
+
>
|
|
215
|
+
|
|
216
|
+
export type LooseReturnType<T> = T extends (
|
|
217
|
+
...args: Array<any>
|
|
218
|
+
) => infer TReturn
|
|
219
|
+
? TReturn
|
|
220
|
+
: never
|
|
221
|
+
|
|
222
|
+
export type LooseAsyncReturnType<T> = T extends (
|
|
223
|
+
...args: Array<any>
|
|
224
|
+
) => infer TReturn
|
|
225
|
+
? TReturn extends Promise<infer TReturn>
|
|
226
|
+
? TReturn
|
|
227
|
+
: TReturn
|
|
228
|
+
: never
|
|
229
|
+
|
|
230
|
+
export type ContextReturnType<TContextFn> = unknown extends TContextFn
|
|
231
|
+
? TContextFn
|
|
232
|
+
: LooseReturnType<TContextFn> extends never
|
|
233
|
+
? AnyContext
|
|
234
|
+
: LooseReturnType<TContextFn>
|
|
235
|
+
|
|
236
|
+
export type ContextAsyncReturnType<TContextFn> = unknown extends TContextFn
|
|
237
|
+
? TContextFn
|
|
238
|
+
: LooseAsyncReturnType<TContextFn> extends never
|
|
239
|
+
? AnyContext
|
|
240
|
+
: LooseAsyncReturnType<TContextFn>
|
|
241
|
+
|
|
242
|
+
export type ResolveRouteContext<TRouteContextFn, TBeforeLoadFn> = Assign<
|
|
243
|
+
ContextReturnType<TRouteContextFn>,
|
|
244
|
+
ContextAsyncReturnType<TBeforeLoadFn>
|
|
245
|
+
>
|
|
246
|
+
|
|
247
|
+
export type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn
|
|
248
|
+
? TLoaderFn
|
|
249
|
+
: LooseAsyncReturnType<TLoaderFn> extends never
|
|
250
|
+
? {}
|
|
251
|
+
: LooseAsyncReturnType<TLoaderFn>
|
|
252
|
+
|
|
253
|
+
export type RoutePrefix<
|
|
254
|
+
TPrefix extends string,
|
|
255
|
+
TPath extends string,
|
|
256
|
+
> = string extends TPath
|
|
257
|
+
? RootRouteId
|
|
258
|
+
: TPath extends string
|
|
259
|
+
? TPrefix extends RootRouteId
|
|
260
|
+
? TPath extends '/'
|
|
261
|
+
? '/'
|
|
262
|
+
: `/${TrimPath<TPath>}`
|
|
263
|
+
: `${TPrefix}/${TPath}` extends '/'
|
|
264
|
+
? '/'
|
|
265
|
+
: `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`
|
|
266
|
+
: never
|
|
267
|
+
|
|
268
|
+
export type TrimPath<T extends string> = '' extends T
|
|
269
|
+
? ''
|
|
270
|
+
: TrimPathRight<TrimPathLeft<T>>
|
|
271
|
+
|
|
272
|
+
export type TrimPathLeft<T extends string> =
|
|
273
|
+
T extends `${RootRouteId}/${infer U}`
|
|
274
|
+
? TrimPathLeft<U>
|
|
275
|
+
: T extends `/${infer U}`
|
|
276
|
+
? TrimPathLeft<U>
|
|
277
|
+
: T
|
|
278
|
+
export type TrimPathRight<T extends string> = T extends '/'
|
|
279
|
+
? '/'
|
|
280
|
+
: T extends `${infer U}/`
|
|
281
|
+
? TrimPathRight<U>
|
|
282
|
+
: T
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @deprecated Use `ErrorComponentProps` instead.
|
|
286
|
+
*/
|
|
287
|
+
export type ErrorRouteProps = {
|
|
288
|
+
error: unknown
|
|
289
|
+
info?: { componentStack: string }
|
|
290
|
+
reset: () => void
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export type ErrorComponentProps = {
|
|
294
|
+
error: Error
|
|
295
|
+
info?: { componentStack: string }
|
|
296
|
+
reset: () => void
|
|
297
|
+
}
|
|
298
|
+
export type NotFoundRouteProps = {
|
|
299
|
+
// TODO: Make sure this is `| null | undefined` (this is for global not-founds)
|
|
300
|
+
data: unknown
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
//
|