@tanstack/router-core 0.0.1-beta.2 → 0.0.1-beta.201

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