@tanstack/router-core 0.0.1-beta.19 → 0.0.1-beta.190
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/defer.js +39 -0
- package/build/cjs/defer.js.map +1 -0
- package/build/cjs/fileRoute.js +29 -0
- package/build/cjs/fileRoute.js.map +1 -0
- package/build/cjs/history.js +228 -0
- package/build/cjs/history.js.map +1 -0
- package/build/cjs/index.js +86 -0
- package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
- package/build/cjs/{packages/router-core/src/path.js → path.js} +45 -56
- package/build/cjs/path.js.map +1 -0
- package/build/cjs/{packages/router-core/src/qss.js → qss.js} +10 -16
- package/build/cjs/qss.js.map +1 -0
- package/build/cjs/route.js +114 -0
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/router.js +1267 -0
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/scroll-restoration.js +139 -0
- package/build/cjs/scroll-restoration.js.map +1 -0
- package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +32 -19
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/{packages/router-core/src/utils.js → utils.js} +69 -64
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +1746 -2121
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +197 -211
- package/build/types/defer.d.ts +19 -0
- package/build/types/fileRoute.d.ts +35 -0
- package/build/types/history.d.ts +36 -0
- package/build/types/index.d.ts +13 -609
- package/build/types/link.d.ts +96 -0
- package/build/types/path.d.ts +16 -0
- package/build/types/qss.d.ts +2 -0
- package/build/types/route.d.ts +251 -0
- package/build/types/routeInfo.d.ts +22 -0
- package/build/types/router.d.ts +260 -0
- package/build/types/scroll-restoration.d.ts +6 -0
- package/build/types/searchParams.d.ts +5 -0
- package/build/types/utils.d.ts +44 -0
- package/build/umd/index.development.js +1978 -2243
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +13 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +11 -7
- package/src/defer.ts +55 -0
- package/src/fileRoute.ts +161 -0
- package/src/history.ts +300 -0
- package/src/index.ts +5 -10
- package/src/link.ts +136 -125
- package/src/path.ts +37 -17
- package/src/qss.ts +1 -2
- package/src/route.ts +948 -218
- package/src/routeInfo.ts +45 -211
- package/src/router.ts +1778 -1075
- package/src/scroll-restoration.ts +179 -0
- package/src/searchParams.ts +31 -9
- package/src/utils.ts +84 -49
- 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/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 -147
- 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 -220
- package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
- package/build/cjs/packages/router-core/src/router.js +0 -870
- 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.map +0 -1
- package/src/frameworks.ts +0 -11
- package/src/routeConfig.ts +0 -511
- package/src/routeMatch.ts +0 -312
package/src/routeInfo.ts
CHANGED
|
@@ -1,142 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
AnyLoaderData,
|
|
5
|
-
AnyPathParams,
|
|
6
|
-
AnyRouteConfig,
|
|
7
|
-
AnyRouteConfigWithChildren,
|
|
8
|
-
AnySearchSchema,
|
|
9
|
-
RootRouteId,
|
|
10
|
-
RouteConfig,
|
|
11
|
-
RouteOptions,
|
|
12
|
-
} from './routeConfig'
|
|
13
|
-
import { IsAny, Values } from './utils'
|
|
1
|
+
import { AnyRoute, Route } from './route'
|
|
2
|
+
import { UnionToIntersection } from './utils'
|
|
14
3
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
routeInfoById: Record<string, AnyRouteInfo>
|
|
19
|
-
routeInfoByFullPath: Record<string, AnyRouteInfo>
|
|
20
|
-
routeIds: any
|
|
21
|
-
routePaths: any
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface DefaultAllRouteInfo {
|
|
25
|
-
routeConfig: RouteConfig
|
|
26
|
-
routeInfo: RouteInfo
|
|
27
|
-
routeInfoById: Record<string, RouteInfo>
|
|
28
|
-
routeInfoByFullPath: Record<string, RouteInfo>
|
|
29
|
-
routeIds: string
|
|
30
|
-
routePaths: string
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface AllRouteInfo<TRouteConfig extends AnyRouteConfig = RouteConfig>
|
|
34
|
-
extends RoutesInfoInner<TRouteConfig, ParseRouteConfig<TRouteConfig>> {}
|
|
35
|
-
|
|
36
|
-
export type ParseRouteConfig<TRouteConfig = AnyRouteConfig> =
|
|
37
|
-
TRouteConfig extends AnyRouteConfig
|
|
38
|
-
? RouteConfigRoute<TRouteConfig> | ParseRouteChildren<TRouteConfig>
|
|
39
|
-
: never
|
|
40
|
-
|
|
41
|
-
type ParseRouteChildren<TRouteConfig> =
|
|
42
|
-
TRouteConfig extends AnyRouteConfigWithChildren<infer TChildren>
|
|
43
|
-
? unknown extends TChildren
|
|
44
|
-
? never
|
|
45
|
-
: TChildren extends AnyRouteConfig[]
|
|
46
|
-
? Values<{
|
|
47
|
-
[TId in TChildren[number]['id']]: ParseRouteChild<
|
|
48
|
-
TChildren[number],
|
|
49
|
-
TId
|
|
50
|
-
>
|
|
51
|
-
}>
|
|
52
|
-
: never // Children are not routes
|
|
53
|
-
: never // No children
|
|
54
|
-
|
|
55
|
-
type ParseRouteChild<TRouteConfig, TId> = TRouteConfig & {
|
|
56
|
-
id: TId
|
|
57
|
-
} extends AnyRouteConfig
|
|
58
|
-
? ParseRouteConfig<TRouteConfig>
|
|
59
|
-
: never
|
|
4
|
+
export type ParseRoute<TRouteTree extends AnyRoute> =
|
|
5
|
+
| TRouteTree
|
|
6
|
+
| ParseRouteChildren<TRouteTree>
|
|
60
7
|
|
|
61
|
-
export type
|
|
62
|
-
|
|
63
|
-
infer TRouteId,
|
|
64
|
-
infer TPath,
|
|
65
|
-
infer TFullPath,
|
|
66
|
-
infer TParentLoaderData,
|
|
67
|
-
infer TRouteLoaderData,
|
|
68
|
-
infer TLoaderData,
|
|
69
|
-
infer TActionPayload,
|
|
70
|
-
infer TActionResponse,
|
|
71
|
-
infer TParentSearchSchema,
|
|
72
|
-
infer TSearchSchema,
|
|
73
|
-
infer TFullSearchSchema,
|
|
74
|
-
infer TParentParams,
|
|
75
|
-
infer TParams,
|
|
76
|
-
infer TAllParams,
|
|
77
|
-
any
|
|
78
|
-
>
|
|
79
|
-
? string extends TRouteId
|
|
80
|
-
? never
|
|
81
|
-
: RouteInfo<
|
|
82
|
-
TId,
|
|
83
|
-
TRouteId,
|
|
84
|
-
TPath,
|
|
85
|
-
TFullPath,
|
|
86
|
-
TParentLoaderData,
|
|
87
|
-
TRouteLoaderData,
|
|
88
|
-
TLoaderData,
|
|
89
|
-
TActionPayload,
|
|
90
|
-
TActionResponse,
|
|
91
|
-
TParentSearchSchema,
|
|
92
|
-
TSearchSchema,
|
|
93
|
-
TFullSearchSchema,
|
|
94
|
-
TParentParams,
|
|
95
|
-
TParams,
|
|
96
|
-
TAllParams
|
|
97
|
-
>
|
|
98
|
-
: never
|
|
99
|
-
|
|
100
|
-
export interface RoutesInfoInner<
|
|
101
|
-
TRouteConfig extends AnyRouteConfig,
|
|
102
|
-
TRouteInfo extends RouteInfo<
|
|
103
|
-
string,
|
|
104
|
-
string,
|
|
105
|
-
any,
|
|
106
|
-
any,
|
|
107
|
-
any,
|
|
108
|
-
any,
|
|
8
|
+
export type ParseRouteChildren<TRouteTree extends AnyRoute> =
|
|
9
|
+
TRouteTree extends Route<
|
|
109
10
|
any,
|
|
110
|
-
any,
|
|
111
|
-
any,
|
|
112
|
-
any,
|
|
113
|
-
any,
|
|
114
|
-
any,
|
|
115
|
-
any,
|
|
116
|
-
any,
|
|
117
|
-
any
|
|
118
|
-
> = RouteInfo,
|
|
119
|
-
TRouteInfoById = { '/': TRouteInfo } & {
|
|
120
|
-
[TInfo in TRouteInfo as TInfo['id']]: TInfo
|
|
121
|
-
},
|
|
122
|
-
TRouteInfoByFullPath = { '/': TRouteInfo } & {
|
|
123
|
-
[TInfo in TRouteInfo as TInfo['fullPath'] extends RootRouteId
|
|
124
|
-
? never
|
|
125
|
-
: string extends TInfo['fullPath']
|
|
126
|
-
? never
|
|
127
|
-
: TInfo['fullPath']]: TInfo
|
|
128
|
-
},
|
|
129
|
-
> {
|
|
130
|
-
routeConfig: TRouteConfig
|
|
131
|
-
routeInfo: TRouteInfo
|
|
132
|
-
routeInfoById: TRouteInfoById
|
|
133
|
-
routeInfoByFullPath: TRouteInfoByFullPath
|
|
134
|
-
routeIds: keyof TRouteInfoById
|
|
135
|
-
routePaths: keyof TRouteInfoByFullPath
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export interface AnyRouteInfo
|
|
139
|
-
extends RouteInfo<
|
|
140
11
|
any,
|
|
141
12
|
any,
|
|
142
13
|
any,
|
|
@@ -151,85 +22,48 @@ export interface AnyRouteInfo
|
|
|
151
22
|
any,
|
|
152
23
|
any,
|
|
153
24
|
any,
|
|
25
|
+
infer TChildren,
|
|
154
26
|
any
|
|
155
|
-
> {}
|
|
156
|
-
|
|
157
|
-
export interface RouteInfo<
|
|
158
|
-
TId extends string = string,
|
|
159
|
-
TRouteId extends string = string,
|
|
160
|
-
TPath extends string = string,
|
|
161
|
-
TFullPath extends string = string,
|
|
162
|
-
TParentRouteLoaderData extends AnyLoaderData = {},
|
|
163
|
-
TRouteLoaderData extends AnyLoaderData = {},
|
|
164
|
-
TLoaderData extends AnyLoaderData = {},
|
|
165
|
-
TActionPayload = unknown,
|
|
166
|
-
TActionResponse = unknown,
|
|
167
|
-
TParentSearchSchema extends {} = {},
|
|
168
|
-
TSearchSchema extends AnySearchSchema = {},
|
|
169
|
-
TFullSearchSchema extends AnySearchSchema = {},
|
|
170
|
-
TParentParams extends AnyPathParams = {},
|
|
171
|
-
TParams extends Record<ParsePathParams<TPath>, unknown> = Record<
|
|
172
|
-
ParsePathParams<TPath>,
|
|
173
|
-
string
|
|
174
|
-
>,
|
|
175
|
-
TAllParams extends AnyPathParams = {},
|
|
176
|
-
> {
|
|
177
|
-
id: TId
|
|
178
|
-
routeId: TRouteId
|
|
179
|
-
path: TPath
|
|
180
|
-
fullPath: TFullPath
|
|
181
|
-
parentRouteLoaderData: TParentRouteLoaderData
|
|
182
|
-
routeLoaderData: TRouteLoaderData
|
|
183
|
-
loaderData: TLoaderData
|
|
184
|
-
actionPayload: TActionPayload
|
|
185
|
-
actionResponse: TActionResponse
|
|
186
|
-
searchSchema: TSearchSchema
|
|
187
|
-
fullSearchSchema: TFullSearchSchema
|
|
188
|
-
parentParams: TParentParams
|
|
189
|
-
params: TParams
|
|
190
|
-
allParams: TAllParams
|
|
191
|
-
options: RouteOptions<
|
|
192
|
-
TRouteId,
|
|
193
|
-
TPath,
|
|
194
|
-
TParentRouteLoaderData,
|
|
195
|
-
TRouteLoaderData,
|
|
196
|
-
TLoaderData,
|
|
197
|
-
TActionPayload,
|
|
198
|
-
TActionResponse,
|
|
199
|
-
TParentSearchSchema,
|
|
200
|
-
TSearchSchema,
|
|
201
|
-
TFullSearchSchema,
|
|
202
|
-
TParentParams,
|
|
203
|
-
TParams,
|
|
204
|
-
TAllParams
|
|
205
27
|
>
|
|
28
|
+
? unknown extends TChildren
|
|
29
|
+
? never
|
|
30
|
+
: TChildren extends AnyRoute[]
|
|
31
|
+
? {
|
|
32
|
+
[TId in TChildren[number]['id'] as string]: ParseRoute<
|
|
33
|
+
TChildren[number]
|
|
34
|
+
>
|
|
35
|
+
}[string]
|
|
36
|
+
: never
|
|
37
|
+
: never
|
|
38
|
+
|
|
39
|
+
export type RoutesById<TRouteTree extends AnyRoute> = {
|
|
40
|
+
[K in ParseRoute<TRouteTree> as K['id']]: K
|
|
206
41
|
}
|
|
207
42
|
|
|
208
|
-
export type
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
43
|
+
export type RouteById<TRouteTree extends AnyRoute, TId> = Extract<
|
|
44
|
+
ParseRoute<TRouteTree>,
|
|
45
|
+
{ id: TId }
|
|
46
|
+
>
|
|
47
|
+
|
|
48
|
+
export type RouteIds<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['id']
|
|
49
|
+
|
|
50
|
+
export type RoutesByPath<TRouteTree extends AnyRoute> = {
|
|
51
|
+
[K in ParseRoute<TRouteTree> as K['fullPath']]: K
|
|
213
52
|
}
|
|
214
53
|
|
|
215
|
-
export type
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
>
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
>
|
|
224
|
-
: never
|
|
54
|
+
export type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<
|
|
55
|
+
ParseRoute<TRouteTree>,
|
|
56
|
+
{ fullPath: TPath }
|
|
57
|
+
>
|
|
58
|
+
|
|
59
|
+
export type RoutePaths<TRouteTree extends AnyRoute> =
|
|
60
|
+
| ParseRoute<TRouteTree>['fullPath']
|
|
61
|
+
| '/'
|
|
225
62
|
|
|
226
|
-
export type
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
TAllRouteInfo['routeInfoByFullPath'][TPath]
|
|
234
|
-
>
|
|
235
|
-
: never
|
|
63
|
+
export type FullSearchSchema<TRouteTree extends AnyRoute> = UnionToIntersection<
|
|
64
|
+
ParseRoute<TRouteTree>['types']['fullSearchSchema']
|
|
65
|
+
> & {}
|
|
66
|
+
|
|
67
|
+
export type AllParams<TRouteTree extends AnyRoute> = UnionToIntersection<
|
|
68
|
+
ParseRoute<TRouteTree>['types']['allParams']
|
|
69
|
+
>
|