@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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/build/cjs/defer.js +39 -0
  3. package/build/cjs/defer.js.map +1 -0
  4. package/build/cjs/fileRoute.js +29 -0
  5. package/build/cjs/fileRoute.js.map +1 -0
  6. package/build/cjs/history.js +228 -0
  7. package/build/cjs/history.js.map +1 -0
  8. package/build/cjs/index.js +86 -0
  9. package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
  10. package/build/cjs/{packages/router-core/src/path.js → path.js} +45 -56
  11. package/build/cjs/path.js.map +1 -0
  12. package/build/cjs/{packages/router-core/src/qss.js → qss.js} +10 -16
  13. package/build/cjs/qss.js.map +1 -0
  14. package/build/cjs/route.js +114 -0
  15. package/build/cjs/route.js.map +1 -0
  16. package/build/cjs/router.js +1267 -0
  17. package/build/cjs/router.js.map +1 -0
  18. package/build/cjs/scroll-restoration.js +139 -0
  19. package/build/cjs/scroll-restoration.js.map +1 -0
  20. package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +32 -19
  21. package/build/cjs/searchParams.js.map +1 -0
  22. package/build/cjs/{packages/router-core/src/utils.js → utils.js} +69 -64
  23. package/build/cjs/utils.js.map +1 -0
  24. package/build/esm/index.js +1746 -2121
  25. package/build/esm/index.js.map +1 -1
  26. package/build/stats-html.html +59 -49
  27. package/build/stats-react.json +197 -211
  28. package/build/types/defer.d.ts +19 -0
  29. package/build/types/fileRoute.d.ts +35 -0
  30. package/build/types/history.d.ts +36 -0
  31. package/build/types/index.d.ts +13 -609
  32. package/build/types/link.d.ts +96 -0
  33. package/build/types/path.d.ts +16 -0
  34. package/build/types/qss.d.ts +2 -0
  35. package/build/types/route.d.ts +251 -0
  36. package/build/types/routeInfo.d.ts +22 -0
  37. package/build/types/router.d.ts +260 -0
  38. package/build/types/scroll-restoration.d.ts +6 -0
  39. package/build/types/searchParams.d.ts +5 -0
  40. package/build/types/utils.d.ts +44 -0
  41. package/build/umd/index.development.js +1978 -2243
  42. package/build/umd/index.development.js.map +1 -1
  43. package/build/umd/index.production.js +13 -2
  44. package/build/umd/index.production.js.map +1 -1
  45. package/package.json +11 -7
  46. package/src/defer.ts +55 -0
  47. package/src/fileRoute.ts +161 -0
  48. package/src/history.ts +300 -0
  49. package/src/index.ts +5 -10
  50. package/src/link.ts +136 -125
  51. package/src/path.ts +37 -17
  52. package/src/qss.ts +1 -2
  53. package/src/route.ts +948 -218
  54. package/src/routeInfo.ts +45 -211
  55. package/src/router.ts +1778 -1075
  56. package/src/scroll-restoration.ts +179 -0
  57. package/src/searchParams.ts +31 -9
  58. package/src/utils.ts +84 -49
  59. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
  60. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  61. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
  62. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  63. package/build/cjs/node_modules/history/index.js +0 -815
  64. package/build/cjs/node_modules/history/index.js.map +0 -1
  65. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
  66. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
  67. package/build/cjs/packages/router-core/src/index.js +0 -58
  68. package/build/cjs/packages/router-core/src/path.js.map +0 -1
  69. package/build/cjs/packages/router-core/src/qss.js.map +0 -1
  70. package/build/cjs/packages/router-core/src/route.js +0 -147
  71. package/build/cjs/packages/router-core/src/route.js.map +0 -1
  72. package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
  73. package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
  74. package/build/cjs/packages/router-core/src/routeMatch.js +0 -220
  75. package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
  76. package/build/cjs/packages/router-core/src/router.js +0 -870
  77. package/build/cjs/packages/router-core/src/router.js.map +0 -1
  78. package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
  79. package/build/cjs/packages/router-core/src/utils.js.map +0 -1
  80. package/src/frameworks.ts +0 -11
  81. package/src/routeConfig.ts +0 -511
  82. package/src/routeMatch.ts +0 -312
package/src/routeInfo.ts CHANGED
@@ -1,142 +1,13 @@
1
- import { ParsePathParams } from './link'
2
- import { Route } from './route'
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 interface AnyAllRouteInfo {
16
- routeConfig: AnyRouteConfig
17
- routeInfo: AnyRouteInfo
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 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
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 RoutesById<TAllRouteInfo extends AnyAllRouteInfo> = {
209
- [K in keyof TAllRouteInfo['routeInfoById']]: Route<
210
- TAllRouteInfo,
211
- TAllRouteInfo['routeInfoById'][K]
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 RouteInfoById<
216
- TAllRouteInfo extends AnyAllRouteInfo,
217
- TId,
218
- > = TId extends keyof TAllRouteInfo['routeInfoById']
219
- ? IsAny<
220
- TAllRouteInfo['routeInfoById'][TId]['id'],
221
- RouteInfo,
222
- TAllRouteInfo['routeInfoById'][TId]
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 RouteInfoByPath<
227
- TAllRouteInfo extends AnyAllRouteInfo,
228
- TPath,
229
- > = TPath extends keyof TAllRouteInfo['routeInfoByFullPath']
230
- ? IsAny<
231
- TAllRouteInfo['routeInfoByFullPath'][TPath]['id'],
232
- RouteInfo,
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
+ >