@tanstack/router-core 0.0.1-beta.192 → 0.0.1-beta.194
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/build/cjs/fileRoute.js.map +1 -1
- package/build/cjs/route.js.map +1 -1
- package/build/cjs/router.js +29 -18
- package/build/cjs/router.js.map +1 -1
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +29 -18
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +124 -124
- package/build/types/fileRoute.d.ts +4 -4
- package/build/types/link.d.ts +9 -9
- package/build/types/route.d.ts +72 -62
- package/build/types/routeInfo.d.ts +4 -4
- package/build/types/router.d.ts +1 -2
- package/build/types/utils.d.ts +8 -1
- package/build/umd/index.development.js +29 -18
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/fileRoute.ts +12 -10
- package/src/link.ts +27 -14
- package/src/route.ts +155 -197
- package/src/routeInfo.ts +10 -7
- package/src/router.ts +51 -25
- package/src/utils.ts +21 -1
package/package.json
CHANGED
package/src/fileRoute.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
TrimPathLeft,
|
|
16
16
|
RouteConstraints,
|
|
17
17
|
} from './route'
|
|
18
|
+
import { DeepMergeAll, Expand, IsAny } from './utils'
|
|
18
19
|
|
|
19
20
|
export interface FileRoutesByPath {
|
|
20
21
|
// '/': {
|
|
@@ -85,6 +86,7 @@ export class FileRoute<
|
|
|
85
86
|
constructor(public path: TFilePath) {}
|
|
86
87
|
|
|
87
88
|
createRoute = <
|
|
89
|
+
TLoaderContext extends RouteConstraints['TLoaderContext'] = {},
|
|
88
90
|
TLoader = unknown,
|
|
89
91
|
TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
|
|
90
92
|
TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<
|
|
@@ -98,12 +100,15 @@ export class FileRoute<
|
|
|
98
100
|
TParentRoute['types']['allParams'],
|
|
99
101
|
TParams
|
|
100
102
|
>,
|
|
101
|
-
TParentContext extends RouteConstraints['TParentContext'] = TParentRoute['types']['routeContext'],
|
|
102
|
-
TAllParentContext extends RouteConstraints['TId'] = TParentRoute['types']['context'],
|
|
103
103
|
TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,
|
|
104
|
-
TContext extends RouteConstraints['TAllContext'] =
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
TContext extends RouteConstraints['TAllContext'] = Expand<
|
|
105
|
+
DeepMergeAll<
|
|
106
|
+
[
|
|
107
|
+
IsAny<TParentRoute['types']['context'], {}>,
|
|
108
|
+
TLoaderContext,
|
|
109
|
+
TRouteContext,
|
|
110
|
+
]
|
|
111
|
+
>
|
|
107
112
|
>,
|
|
108
113
|
TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,
|
|
109
114
|
TChildren extends RouteConstraints['TChildren'] = unknown,
|
|
@@ -114,14 +119,12 @@ export class FileRoute<
|
|
|
114
119
|
TParentRoute,
|
|
115
120
|
string,
|
|
116
121
|
string,
|
|
122
|
+
TLoaderContext,
|
|
117
123
|
TLoader,
|
|
118
|
-
InferFullSearchSchema<TParentRoute>,
|
|
119
124
|
TSearchSchema,
|
|
120
125
|
TFullSearchSchema,
|
|
121
126
|
TParams,
|
|
122
127
|
TAllParams,
|
|
123
|
-
TParentContext,
|
|
124
|
-
TAllParentContext,
|
|
125
128
|
TRouteContext,
|
|
126
129
|
TContext
|
|
127
130
|
>,
|
|
@@ -141,13 +144,12 @@ export class FileRoute<
|
|
|
141
144
|
TFullPath,
|
|
142
145
|
TFilePath,
|
|
143
146
|
TId,
|
|
147
|
+
TLoaderContext,
|
|
144
148
|
TLoader,
|
|
145
149
|
TSearchSchema,
|
|
146
150
|
TFullSearchSchema,
|
|
147
151
|
TParams,
|
|
148
152
|
TAllParams,
|
|
149
|
-
TParentContext,
|
|
150
|
-
TAllParentContext,
|
|
151
153
|
TRouteContext,
|
|
152
154
|
TContext,
|
|
153
155
|
TRouterContext,
|
package/src/link.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Trim } from './fileRoute'
|
|
2
2
|
import { AnyRoute } from './route'
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
AllParams,
|
|
5
|
+
FullSearchSchema,
|
|
6
|
+
RouteByPath,
|
|
7
|
+
RouteIds,
|
|
8
|
+
RoutePaths,
|
|
9
|
+
} from './routeInfo'
|
|
10
|
+
import { LocationState, ParsedLocation, RegisteredRouter } from './router'
|
|
5
11
|
import {
|
|
6
12
|
Expand,
|
|
7
13
|
NoInfer,
|
|
@@ -119,7 +125,7 @@ export type RelativeToPathAutoComplete<
|
|
|
119
125
|
| AllPaths
|
|
120
126
|
|
|
121
127
|
export type NavigateOptions<
|
|
122
|
-
TRouteTree extends AnyRoute =
|
|
128
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
123
129
|
TFrom extends RoutePaths<TRouteTree> = '/',
|
|
124
130
|
TTo extends string = '',
|
|
125
131
|
TMaskFrom extends RoutePaths<TRouteTree> = TFrom,
|
|
@@ -131,7 +137,7 @@ export type NavigateOptions<
|
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
export type ToOptions<
|
|
134
|
-
TRouteTree extends AnyRoute =
|
|
140
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
135
141
|
TFrom extends RoutePaths<TRouteTree> = '/',
|
|
136
142
|
TTo extends string = '',
|
|
137
143
|
TMaskFrom extends RoutePaths<TRouteTree> = '/',
|
|
@@ -141,7 +147,7 @@ export type ToOptions<
|
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
export type ToMaskOptions<
|
|
144
|
-
TRouteTree extends AnyRoute =
|
|
150
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
145
151
|
TMaskFrom extends RoutePaths<TRouteTree> = '/',
|
|
146
152
|
TMaskTo extends string = '',
|
|
147
153
|
> = ToSubOptions<TRouteTree, TMaskFrom, TMaskTo> & {
|
|
@@ -149,7 +155,7 @@ export type ToMaskOptions<
|
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
export type ToSubOptions<
|
|
152
|
-
TRouteTree extends AnyRoute =
|
|
158
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
153
159
|
TFrom extends RoutePaths<TRouteTree> = '/',
|
|
154
160
|
TTo extends string = '',
|
|
155
161
|
TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,
|
|
@@ -164,21 +170,28 @@ export type ToSubOptions<
|
|
|
164
170
|
// // When using relative route paths, this option forces resolution from the current path, instead of the route API's path or `from` path
|
|
165
171
|
// fromCurrent?: boolean
|
|
166
172
|
} & CheckPath<TRouteTree, NoInfer<TResolved>, {}> &
|
|
167
|
-
SearchParamOptions<TRouteTree, TFrom, TResolved> &
|
|
173
|
+
SearchParamOptions<TRouteTree, TFrom, TTo, TResolved> &
|
|
168
174
|
PathParamOptions<TRouteTree, TFrom, TResolved>
|
|
169
175
|
|
|
170
176
|
export type SearchParamOptions<
|
|
171
177
|
TRouteTree extends AnyRoute,
|
|
172
178
|
TFrom,
|
|
173
179
|
TTo,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
180
|
+
TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,
|
|
181
|
+
TFromSearchEnsured = '/' extends TFrom
|
|
182
|
+
? FullSearchSchema<TRouteTree>
|
|
183
|
+
: Expand<
|
|
184
|
+
UnionToIntersection<
|
|
185
|
+
PickRequired<
|
|
186
|
+
RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']
|
|
187
|
+
>
|
|
188
|
+
>
|
|
189
|
+
>,
|
|
179
190
|
TFromSearchOptional = Omit<AllParams<TRouteTree>, keyof TFromSearchEnsured>,
|
|
180
191
|
TFromSearch = Expand<TFromSearchEnsured & TFromSearchOptional>,
|
|
181
|
-
TToSearch =
|
|
192
|
+
TToSearch = '' extends TTo
|
|
193
|
+
? FullSearchSchema<TRouteTree>
|
|
194
|
+
: Expand<RouteByPath<TRouteTree, TResolved>['types']['fullSearchSchema']>,
|
|
182
195
|
> = keyof PickRequired<TToSearch> extends never
|
|
183
196
|
? {
|
|
184
197
|
search?: true | SearchReducer<TFromSearch, TToSearch>
|
|
@@ -246,7 +259,7 @@ export interface ActiveOptions {
|
|
|
246
259
|
}
|
|
247
260
|
|
|
248
261
|
export type LinkOptions<
|
|
249
|
-
TRouteTree extends AnyRoute =
|
|
262
|
+
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
250
263
|
TFrom extends RoutePaths<TRouteTree> = '/',
|
|
251
264
|
TTo extends string = '',
|
|
252
265
|
TMaskFrom extends RoutePaths<TRouteTree> = TFrom,
|