@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.192",
4
+ "version": "0.0.1-beta.194",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
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'] = MergeFromFromParent<
105
- TParentRoute['types']['context'],
106
- TRouteContext
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 { AllParams, RouteByPath, RouteIds, RoutePaths } from './routeInfo'
4
- import { LocationState, ParsedLocation } from './router'
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 = 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 = 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 = 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 = 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
- TFromSearchEnsured = Expand<
175
- UnionToIntersection<
176
- PickRequired<RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']>
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 = Expand<RouteByPath<TRouteTree, TTo>['types']['fullSearchSchema']>,
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 = 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,