@tanstack/router-core 0.0.1-beta.15 → 0.0.1-beta.151
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/fileRoute.js +29 -0
- package/build/cjs/fileRoute.js.map +1 -0
- package/build/cjs/history.js +226 -0
- package/build/cjs/history.js.map +1 -0
- package/build/cjs/index.js +78 -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 +103 -0
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/router.js +1113 -0
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +11 -13
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/{packages/router-core/src/utils.js → utils.js} +54 -64
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +1417 -2105
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +203 -234
- package/build/types/index.d.ts +604 -426
- package/build/umd/index.development.js +1640 -2224
- 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/fileRoute.ts +120 -0
- package/src/history.ts +292 -0
- package/src/index.ts +3 -10
- package/src/link.ts +118 -113
- package/src/path.ts +37 -17
- package/src/qss.ts +1 -2
- package/src/route.ts +891 -218
- package/src/routeInfo.ts +121 -204
- package/src/router.ts +1494 -1017
- package/src/searchParams.ts +1 -1
- package/src/utils.ts +80 -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 -231
- package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
- package/build/cjs/packages/router-core/src/router.js +0 -833
- 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 -514
- package/src/routeMatch.ts +0 -319
package/src/routeInfo.ts
CHANGED
|
@@ -1,235 +1,152 @@
|
|
|
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 { AnyPathParams, AnySearchSchema, RootRouteId } from './route'
|
|
3
|
+
import { IsAny, MergeUnion, Values } from './utils'
|
|
14
4
|
|
|
15
|
-
export interface
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
export interface AnyRoutesInfo {
|
|
6
|
+
routeTree: AnyRoute
|
|
7
|
+
routeUnion: AnyRoute
|
|
8
|
+
routesById: Record<string, AnyRoute>
|
|
9
|
+
routesByFullPath: Record<string, AnyRoute>
|
|
20
10
|
routeIds: any
|
|
21
11
|
routePaths: any
|
|
12
|
+
routeIntersection: AnyRoute
|
|
13
|
+
fullSearchSchema: Record<string, any>
|
|
14
|
+
allParams: Record<string, any>
|
|
22
15
|
}
|
|
23
16
|
|
|
24
|
-
export interface
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
export interface DefaultRoutesInfo {
|
|
18
|
+
routeTree: AnyRoute
|
|
19
|
+
routeUnion: AnyRoute
|
|
20
|
+
routesById: Record<string, Route>
|
|
21
|
+
routesByFullPath: Record<string, Route>
|
|
29
22
|
routeIds: string
|
|
30
23
|
routePaths: string
|
|
24
|
+
routeIntersection: AnyRoute
|
|
25
|
+
fullSearchSchema: AnySearchSchema
|
|
26
|
+
allParams: AnyPathParams
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
export interface
|
|
34
|
-
extends RoutesInfoInner<
|
|
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
|
|
60
|
-
|
|
61
|
-
export type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<
|
|
62
|
-
infer TId,
|
|
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
|
|
29
|
+
export interface RoutesInfo<TRouteTree extends AnyRoute = Route>
|
|
30
|
+
extends RoutesInfoInner<TRouteTree, ParseRoute<TRouteTree>> {}
|
|
99
31
|
|
|
100
32
|
export interface RoutesInfoInner<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
any,
|
|
106
|
-
any,
|
|
107
|
-
any,
|
|
108
|
-
any,
|
|
109
|
-
any,
|
|
110
|
-
any,
|
|
111
|
-
any,
|
|
112
|
-
any,
|
|
113
|
-
any,
|
|
114
|
-
any,
|
|
115
|
-
any,
|
|
116
|
-
any,
|
|
117
|
-
any
|
|
118
|
-
> = RouteInfo,
|
|
119
|
-
TRouteInfoById = {
|
|
120
|
-
[TInfo in TRouteInfo as TInfo['id']]: TInfo
|
|
33
|
+
TRouteTree extends AnyRoute,
|
|
34
|
+
TRouteUnion extends AnyRoute = Route,
|
|
35
|
+
TRoutesById = { '/': TRouteUnion } & {
|
|
36
|
+
[TRoute in TRouteUnion as TRoute['id']]: TRoute
|
|
121
37
|
},
|
|
122
|
-
|
|
123
|
-
|
|
38
|
+
// RoutePaths should always use index routes if possible, but not
|
|
39
|
+
// force trailing slashes. To do this, we check if each route
|
|
40
|
+
// has an index route registered and if it does, we omit the layout
|
|
41
|
+
// route. Then for any index routes, we remove the trailing slash
|
|
42
|
+
TRoutesByFullPath = { '/': TRouteUnion } & {
|
|
43
|
+
[TRoute in TRouteUnion as TRoute['fullPath'] extends RootRouteId
|
|
124
44
|
? never
|
|
125
|
-
: string extends
|
|
45
|
+
: string extends TRoute['fullPath']
|
|
126
46
|
? never
|
|
127
|
-
:
|
|
47
|
+
: `${TRoute['fullPath']}/` extends keyof TRoutesById
|
|
48
|
+
? never
|
|
49
|
+
: TRoute['fullPath'] extends `${infer Trimmed}/`
|
|
50
|
+
? Trimmed
|
|
51
|
+
: TRoute['fullPath']]: TRoute
|
|
128
52
|
},
|
|
129
53
|
> {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
routeIds: keyof
|
|
135
|
-
routePaths: keyof
|
|
54
|
+
routeTree: TRouteTree
|
|
55
|
+
routeUnion: TRouteUnion
|
|
56
|
+
routesById: TRoutesById
|
|
57
|
+
routesByFullPath: TRoutesByFullPath
|
|
58
|
+
routeIds: keyof TRoutesById
|
|
59
|
+
routePaths: keyof TRoutesByFullPath
|
|
60
|
+
routeIntersection: Route<
|
|
61
|
+
TRouteUnion['__types']['parentRoute'], // TParentRoute,
|
|
62
|
+
TRouteUnion['__types']['path'], // TPath,
|
|
63
|
+
TRouteUnion['__types']['fullPath'], // TFullPath,
|
|
64
|
+
TRouteUnion['__types']['customId'], // TCustomId,
|
|
65
|
+
TRouteUnion['__types']['id'], // TId,
|
|
66
|
+
TRouteUnion['__types']['loader'], // TId,
|
|
67
|
+
MergeUnion<TRouteUnion['__types']['searchSchema']> & {}, // TSearchSchema,
|
|
68
|
+
MergeUnion<TRouteUnion['__types']['fullSearchSchema']> & {}, // TFullSearchSchema,
|
|
69
|
+
MergeUnion<TRouteUnion['__types']['params']>, // TParams,
|
|
70
|
+
MergeUnion<TRouteUnion['__types']['allParams']>, // TAllParams,
|
|
71
|
+
MergeUnion<TRouteUnion['__types']['parentContext']>, // TParentContext,
|
|
72
|
+
MergeUnion<TRouteUnion['__types']['allParentContext']>, // TAllParentContext,
|
|
73
|
+
MergeUnion<TRouteUnion['__types']['routeContext']> & {}, // TRouteContext,
|
|
74
|
+
MergeUnion<TRouteUnion['__types']['context']> & {}, // TContext,
|
|
75
|
+
MergeUnion<TRouteUnion['__types']['routerContext']> & {}, // TRouterContext,
|
|
76
|
+
TRouteUnion['__types']['children'], // TChildren,
|
|
77
|
+
TRouteUnion['__types']['routesInfo'] // TRoutesInfo,
|
|
78
|
+
>
|
|
79
|
+
fullSearchSchema: Partial<
|
|
80
|
+
MergeUnion<TRouteUnion['__types']['fullSearchSchema']>
|
|
81
|
+
>
|
|
82
|
+
allParams: Partial<MergeUnion<TRouteUnion['__types']['allParams']>>
|
|
136
83
|
}
|
|
137
84
|
|
|
138
|
-
export
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
any,
|
|
142
|
-
any,
|
|
143
|
-
any,
|
|
144
|
-
any,
|
|
145
|
-
any,
|
|
146
|
-
any,
|
|
147
|
-
any,
|
|
148
|
-
any,
|
|
149
|
-
any,
|
|
150
|
-
any,
|
|
151
|
-
any,
|
|
152
|
-
any,
|
|
153
|
-
any,
|
|
154
|
-
any
|
|
155
|
-
> {}
|
|
85
|
+
export type ParseRoute<TRouteTree> = TRouteTree extends AnyRoute
|
|
86
|
+
? TRouteTree | ParseRouteChildren<TRouteTree>
|
|
87
|
+
: never
|
|
156
88
|
|
|
157
|
-
export
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
>
|
|
206
|
-
}
|
|
89
|
+
export type ParseRouteChildren<TRouteTree> = TRouteTree extends Route<
|
|
90
|
+
any,
|
|
91
|
+
any,
|
|
92
|
+
any,
|
|
93
|
+
any,
|
|
94
|
+
any,
|
|
95
|
+
any,
|
|
96
|
+
any,
|
|
97
|
+
any,
|
|
98
|
+
any,
|
|
99
|
+
any,
|
|
100
|
+
any,
|
|
101
|
+
any,
|
|
102
|
+
any,
|
|
103
|
+
any,
|
|
104
|
+
any,
|
|
105
|
+
infer TChildren,
|
|
106
|
+
any
|
|
107
|
+
>
|
|
108
|
+
? unknown extends TChildren
|
|
109
|
+
? never
|
|
110
|
+
: TChildren extends AnyRoute[]
|
|
111
|
+
? Values<{
|
|
112
|
+
[TId in TChildren[number]['id']]: ParseRouteChild<
|
|
113
|
+
TChildren[number],
|
|
114
|
+
TId
|
|
115
|
+
>
|
|
116
|
+
}>
|
|
117
|
+
: never
|
|
118
|
+
: never
|
|
207
119
|
|
|
208
|
-
export type
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
120
|
+
export type ParseRouteChild<TRoute, TId> = TRoute extends AnyRoute
|
|
121
|
+
? ParseRoute<TRoute>
|
|
122
|
+
: never
|
|
123
|
+
|
|
124
|
+
export type RoutesById<TRoutesInfo extends AnyRoutesInfo> = {
|
|
125
|
+
[K in keyof TRoutesInfo['routesById']]: TRoutesInfo['routesById'][K]
|
|
213
126
|
}
|
|
214
127
|
|
|
215
|
-
export type
|
|
216
|
-
|
|
128
|
+
export type RouteById<
|
|
129
|
+
TRoutesInfo extends AnyRoutesInfo,
|
|
217
130
|
TId,
|
|
218
|
-
> = TId extends keyof
|
|
131
|
+
> = TId extends keyof TRoutesInfo['routesById']
|
|
219
132
|
? IsAny<
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
133
|
+
TRoutesInfo['routesById'][TId]['id'],
|
|
134
|
+
Route,
|
|
135
|
+
TRoutesInfo['routesById'][TId]
|
|
223
136
|
>
|
|
224
137
|
: never
|
|
225
138
|
|
|
226
|
-
export type
|
|
227
|
-
|
|
139
|
+
export type RoutesByPath<TRoutesInfo extends AnyRoutesInfo> = {
|
|
140
|
+
[K in keyof TRoutesInfo['routesByFullPath']]: TRoutesInfo['routesByFullPath'][K]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export type RouteByPath<
|
|
144
|
+
TRoutesInfo extends AnyRoutesInfo,
|
|
228
145
|
TPath,
|
|
229
|
-
> = TPath extends keyof
|
|
146
|
+
> = TPath extends keyof TRoutesInfo['routesByFullPath']
|
|
230
147
|
? IsAny<
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
148
|
+
TRoutesInfo['routesByFullPath'][TPath]['id'],
|
|
149
|
+
Route,
|
|
150
|
+
TRoutesInfo['routesByFullPath'][TPath]
|
|
234
151
|
>
|
|
235
152
|
: never
|