@tanstack/react-router 1.109.2 → 1.111.6

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 (97) hide show
  1. package/dist/cjs/Matches.cjs.map +1 -1
  2. package/dist/cjs/Matches.d.cts +1 -3
  3. package/dist/cjs/RouterProvider.cjs.map +1 -1
  4. package/dist/cjs/RouterProvider.d.cts +0 -25
  5. package/dist/cjs/fileRoute.cjs +4 -1
  6. package/dist/cjs/fileRoute.cjs.map +1 -1
  7. package/dist/cjs/fileRoute.d.cts +5 -17
  8. package/dist/cjs/index.d.cts +7 -9
  9. package/dist/cjs/link.cjs.map +1 -1
  10. package/dist/cjs/link.d.cts +1 -73
  11. package/dist/cjs/not-found.cjs.map +1 -1
  12. package/dist/cjs/not-found.d.cts +1 -1
  13. package/dist/cjs/redirects.cjs.map +1 -1
  14. package/dist/cjs/redirects.d.cts +2 -18
  15. package/dist/cjs/route.cjs.map +1 -1
  16. package/dist/cjs/route.d.cts +10 -57
  17. package/dist/cjs/router.cjs.map +1 -1
  18. package/dist/cjs/router.d.cts +2 -9
  19. package/dist/cjs/typePrimitives.d.cts +4 -6
  20. package/dist/cjs/useBlocker.cjs.map +1 -1
  21. package/dist/cjs/useBlocker.d.cts +1 -1
  22. package/dist/cjs/useLoaderData.cjs.map +1 -1
  23. package/dist/cjs/useLoaderData.d.cts +2 -6
  24. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  25. package/dist/cjs/useLoaderDeps.d.cts +2 -6
  26. package/dist/cjs/useMatch.cjs.map +1 -1
  27. package/dist/cjs/useMatch.d.cts +1 -2
  28. package/dist/cjs/useNavigate.cjs.map +1 -1
  29. package/dist/cjs/useNavigate.d.cts +1 -2
  30. package/dist/cjs/useParams.cjs.map +1 -1
  31. package/dist/cjs/useParams.d.cts +2 -6
  32. package/dist/cjs/useRouteContext.cjs.map +1 -1
  33. package/dist/cjs/useRouteContext.d.cts +1 -9
  34. package/dist/cjs/useSearch.cjs.map +1 -1
  35. package/dist/cjs/useSearch.d.cts +2 -6
  36. package/dist/cjs/utils.cjs.map +1 -1
  37. package/dist/cjs/utils.d.cts +1 -11
  38. package/dist/esm/Matches.d.ts +1 -3
  39. package/dist/esm/Matches.js.map +1 -1
  40. package/dist/esm/RouterProvider.d.ts +0 -25
  41. package/dist/esm/RouterProvider.js.map +1 -1
  42. package/dist/esm/fileRoute.d.ts +5 -17
  43. package/dist/esm/fileRoute.js +4 -1
  44. package/dist/esm/fileRoute.js.map +1 -1
  45. package/dist/esm/index.d.ts +7 -9
  46. package/dist/esm/link.d.ts +1 -73
  47. package/dist/esm/link.js.map +1 -1
  48. package/dist/esm/not-found.d.ts +1 -1
  49. package/dist/esm/not-found.js.map +1 -1
  50. package/dist/esm/redirects.d.ts +2 -18
  51. package/dist/esm/redirects.js.map +1 -1
  52. package/dist/esm/route.d.ts +10 -57
  53. package/dist/esm/route.js.map +1 -1
  54. package/dist/esm/router.d.ts +2 -9
  55. package/dist/esm/router.js.map +1 -1
  56. package/dist/esm/typePrimitives.d.ts +4 -6
  57. package/dist/esm/useBlocker.d.ts +1 -1
  58. package/dist/esm/useBlocker.js.map +1 -1
  59. package/dist/esm/useLoaderData.d.ts +2 -6
  60. package/dist/esm/useLoaderData.js.map +1 -1
  61. package/dist/esm/useLoaderDeps.d.ts +2 -6
  62. package/dist/esm/useLoaderDeps.js.map +1 -1
  63. package/dist/esm/useMatch.d.ts +1 -2
  64. package/dist/esm/useMatch.js.map +1 -1
  65. package/dist/esm/useNavigate.d.ts +1 -2
  66. package/dist/esm/useNavigate.js.map +1 -1
  67. package/dist/esm/useParams.d.ts +2 -6
  68. package/dist/esm/useParams.js.map +1 -1
  69. package/dist/esm/useRouteContext.d.ts +1 -9
  70. package/dist/esm/useRouteContext.js.map +1 -1
  71. package/dist/esm/useSearch.d.ts +2 -6
  72. package/dist/esm/useSearch.js.map +1 -1
  73. package/dist/esm/utils.d.ts +1 -11
  74. package/dist/esm/utils.js.map +1 -1
  75. package/package.json +2 -2
  76. package/src/Matches.tsx +11 -15
  77. package/src/RouterProvider.tsx +0 -48
  78. package/src/fileRoute.ts +22 -43
  79. package/src/index.tsx +30 -43
  80. package/src/link.tsx +4 -427
  81. package/src/not-found.tsx +1 -1
  82. package/src/redirects.ts +6 -36
  83. package/src/route.ts +103 -167
  84. package/src/router.ts +13 -25
  85. package/src/typePrimitives.ts +11 -7
  86. package/src/useBlocker.tsx +1 -1
  87. package/src/useLoaderData.tsx +6 -21
  88. package/src/useLoaderDeps.tsx +6 -14
  89. package/src/useMatch.tsx +1 -2
  90. package/src/useNavigate.tsx +5 -12
  91. package/src/useParams.tsx +7 -21
  92. package/src/useRouteContext.ts +5 -37
  93. package/src/useSearch.tsx +7 -21
  94. package/src/utils.ts +0 -17
  95. package/dist/cjs/routeInfo.d.cts +0 -53
  96. package/dist/esm/routeInfo.d.ts +0 -53
  97. package/src/routeInfo.ts +0 -239
package/src/index.tsx CHANGED
@@ -106,6 +106,7 @@ export type {
106
106
  IntersectAssign,
107
107
  ResolveValidatorInput,
108
108
  ResolveValidatorOutput,
109
+ Register,
109
110
  AnyValidator,
110
111
  DefaultValidator,
111
112
  ValidatorFn,
@@ -120,6 +121,8 @@ export type {
120
121
  Validator,
121
122
  ValidatorAdapter,
122
123
  ValidatorObj,
124
+ FileRoutesByPath,
125
+ RouteById,
123
126
  } from '@tanstack/router-core'
124
127
 
125
128
  export {
@@ -150,11 +153,7 @@ export {
150
153
  createLazyRoute,
151
154
  createLazyFileRoute,
152
155
  } from './fileRoute'
153
- export type {
154
- FileRoutesByPath,
155
- FileRouteTypes,
156
- LazyRouteOptions,
157
- } from './fileRoute'
156
+ export type { LazyRouteOptions } from './fileRoute'
158
157
 
159
158
  export * from './history'
160
159
 
@@ -177,13 +176,37 @@ export type {
177
176
  PathParamOptions,
178
177
  ToPathOption,
179
178
  LinkOptions,
179
+ MakeOptionalPathParams,
180
+ FileRouteTypes,
181
+ RouteContextParameter,
182
+ BeforeLoadContextParameter,
183
+ ResolveAllContext,
184
+ ResolveAllParamsFromParent,
185
+ ResolveFullSearchSchema,
186
+ ResolveFullSearchSchemaInput,
187
+ RouteIds,
188
+ NavigateFn,
189
+ BuildLocationFn,
190
+ FullSearchSchemaOption,
191
+ MakeRemountDepsOptionsUnion,
192
+ RemountDepsOptions,
193
+ ResolveFullPath,
194
+ AnyRouteWithContext,
195
+ AnyRouterWithContext,
196
+ CommitLocationOptions,
197
+ MatchLocation,
198
+ UseNavigateResult,
199
+ AnyRedirect,
200
+ Redirect,
201
+ ResolvedRedirect,
202
+ } from '@tanstack/router-core'
203
+ export type {
180
204
  UseLinkPropsOptions,
181
205
  ActiveLinkOptions,
182
206
  LinkProps,
183
207
  LinkComponent,
184
208
  LinkComponentProps,
185
209
  CreateLinkProps,
186
- MakeOptionalPathParams,
187
210
  } from './link'
188
211
 
189
212
  export {
@@ -213,7 +236,6 @@ export { useLoaderDeps } from './useLoaderDeps'
213
236
  export { useLoaderData } from './useLoaderData'
214
237
 
215
238
  export { redirect, isRedirect } from './redirects'
216
- export type { AnyRedirect, Redirect, ResolvedRedirect } from './redirects'
217
239
 
218
240
  export {
219
241
  RouteApi,
@@ -234,12 +256,9 @@ export type {
234
256
  UpdatableRouteOptions,
235
257
  RouteLoaderFn,
236
258
  LoaderFnContext,
237
- ResolveFullSearchSchema,
238
- ResolveFullSearchSchemaInput,
239
259
  AnyRoute,
240
260
  RouteConstraints,
241
261
  AnyRootRoute,
242
- ResolveFullPath,
243
262
  RouteMask,
244
263
  ReactNode,
245
264
  SyncRouteComponent,
@@ -248,36 +267,13 @@ export type {
248
267
  ErrorRouteComponent,
249
268
  NotFoundRouteComponent,
250
269
  RootRouteOptions,
251
- AnyRouteWithContext,
252
- FullSearchSchemaOption,
253
270
  RouteContextFn,
254
271
  RouteContextOptions,
255
272
  BeforeLoadFn,
256
273
  BeforeLoadContextOptions,
257
274
  ContextOptions,
258
- RouteContextParameter,
259
- BeforeLoadContextParameter,
260
- ResolveAllContext,
261
- ResolveAllParamsFromParent,
262
- MakeRemountDepsOptionsUnion,
263
- RemountDepsOptions,
264
275
  } from './route'
265
276
 
266
- export type {
267
- ParseRoute,
268
- RoutesById,
269
- RouteById,
270
- RouteIds,
271
- RoutesByPath,
272
- RouteByPath,
273
- RoutePaths,
274
- FullSearchSchema,
275
- AllParams,
276
- AllLoaderData,
277
- FullSearchSchemaInput,
278
- AllContext,
279
- } from './routeInfo'
280
-
281
277
  export {
282
278
  componentTypes,
283
279
  createRouter,
@@ -289,7 +285,6 @@ export {
289
285
  } from './router'
290
286
 
291
287
  export type {
292
- Register,
293
288
  AnyRouter,
294
289
  RegisteredRouter,
295
290
  RouterContextOptions,
@@ -302,19 +297,12 @@ export type {
302
297
  RouterEvents,
303
298
  RouterEvent,
304
299
  RouterListener,
305
- AnyRouterWithContext,
306
300
  ControllablePromise,
307
301
  InjectedHtmlEntry,
308
302
  } from './router'
309
303
 
310
304
  export { RouterProvider, RouterContextProvider } from './RouterProvider'
311
- export type {
312
- RouterProps,
313
- CommitLocationOptions,
314
- MatchLocation,
315
- NavigateFn,
316
- BuildLocationFn,
317
- } from './RouterProvider'
305
+ export type { RouterProps } from './RouterProvider'
318
306
 
319
307
  export {
320
308
  useElementScrollRestoration,
@@ -325,7 +313,6 @@ export type { UseBlockerOpts, ShouldBlockFn } from './useBlocker'
325
313
  export { useBlocker, Block } from './useBlocker'
326
314
 
327
315
  export { useNavigate, Navigate } from './useNavigate'
328
- export type { UseNavigateResult } from './useNavigate'
329
316
 
330
317
  export { useParams } from './useParams'
331
318
  export { useSearch } from './useSearch'
package/src/link.tsx CHANGED
@@ -19,35 +19,11 @@ import {
19
19
  import { useMatch } from './useMatch'
20
20
  import type {
21
21
  Constrain,
22
- ConstrainLiteral,
23
- Expand,
24
- IsRequiredParams,
25
- LinkOptionsProps,
26
- MakeDifferenceOptional,
27
- NoInfer,
28
- NonNullableUpdater,
29
- ParsedLocation,
30
- PickRequired,
31
- RemoveTrailingSlashes,
32
- ResolveRelativePath,
33
- Updater,
34
- ViewTransitionOptions,
35
- WithoutEmpty,
36
- } from '@tanstack/router-core'
37
- import type { HistoryState, ParsedHistoryState } from '@tanstack/history'
38
- import type {
39
- AllParams,
40
- CatchAllPaths,
41
- CurrentPath,
42
- FullSearchSchema,
43
- FullSearchSchemaInput,
44
- ParentPath,
45
- RouteByPath,
46
- RouteByToPath,
22
+ LinkCurrentTargetElement,
23
+ LinkOptions,
47
24
  RoutePaths,
48
- RouteToPath,
49
- ToPath,
50
- } from './routeInfo'
25
+ } from '@tanstack/router-core'
26
+
51
27
  import type { AnyRouter, RegisteredRouter } from './router'
52
28
  import type { ReactNode } from 'react'
53
29
  import type {
@@ -55,405 +31,6 @@ import type {
55
31
  ValidateLinkOptionsArray,
56
32
  } from './typePrimitives'
57
33
 
58
- export type FindDescendantToPaths<
59
- TRouter extends AnyRouter,
60
- TPrefix extends string,
61
- > = `${TPrefix}/${string}` & RouteToPath<TRouter>
62
-
63
- export type InferDescendantToPaths<
64
- TRouter extends AnyRouter,
65
- TPrefix extends string,
66
- TPaths = FindDescendantToPaths<TRouter, TPrefix>,
67
- > = TPaths extends `${TPrefix}/`
68
- ? never
69
- : TPaths extends `${TPrefix}/${infer TRest}`
70
- ? TRest
71
- : never
72
-
73
- export type RelativeToPath<
74
- TRouter extends AnyRouter,
75
- TTo extends string,
76
- TResolvedPath extends string,
77
- > =
78
- | (TResolvedPath & RouteToPath<TRouter> extends never
79
- ? never
80
- : ToPath<TRouter, TTo>)
81
- | `${RemoveTrailingSlashes<TTo>}/${InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TResolvedPath>>}`
82
-
83
- export type RelativeToParentPath<
84
- TRouter extends AnyRouter,
85
- TFrom extends string,
86
- TTo extends string,
87
- TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,
88
- > =
89
- | RelativeToPath<TRouter, TTo, TResolvedPath>
90
- | (TTo extends `${string}..` | `${string}../`
91
- ? TResolvedPath extends '/' | ''
92
- ? never
93
- : FindDescendantToPaths<
94
- TRouter,
95
- RemoveTrailingSlashes<TResolvedPath>
96
- > extends never
97
- ? never
98
- : `${RemoveTrailingSlashes<TTo>}/${ParentPath<TRouter>}`
99
- : never)
100
-
101
- export type RelativeToCurrentPath<
102
- TRouter extends AnyRouter,
103
- TFrom extends string,
104
- TTo extends string,
105
- TResolvedPath extends string = ResolveRelativePath<TFrom, TTo>,
106
- > = RelativeToPath<TRouter, TTo, TResolvedPath> | CurrentPath<TRouter>
107
-
108
- export type AbsoluteToPath<TRouter extends AnyRouter, TFrom extends string> =
109
- | (string extends TFrom
110
- ? CurrentPath<TRouter>
111
- : TFrom extends `/`
112
- ? never
113
- : CurrentPath<TRouter>)
114
- | (string extends TFrom
115
- ? ParentPath<TRouter>
116
- : TFrom extends `/`
117
- ? never
118
- : ParentPath<TRouter>)
119
- | RouteToPath<TRouter>
120
- | (TFrom extends '/'
121
- ? never
122
- : string extends TFrom
123
- ? never
124
- : InferDescendantToPaths<TRouter, RemoveTrailingSlashes<TFrom>>)
125
-
126
- export type RelativeToPathAutoComplete<
127
- TRouter extends AnyRouter,
128
- TFrom extends string,
129
- TTo extends string,
130
- > = string extends TTo
131
- ? string
132
- : string extends TFrom
133
- ? AbsoluteToPath<TRouter, TFrom>
134
- : TTo & `..${string}` extends never
135
- ? TTo & `.${string}` extends never
136
- ? AbsoluteToPath<TRouter, TFrom>
137
- : RelativeToCurrentPath<TRouter, TFrom, TTo>
138
- : RelativeToParentPath<TRouter, TFrom, TTo>
139
-
140
- export type NavigateOptions<
141
- TRouter extends AnyRouter = RegisteredRouter,
142
- TFrom extends string = string,
143
- TTo extends string | undefined = '.',
144
- TMaskFrom extends string = TFrom,
145
- TMaskTo extends string = '.',
146
- > = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & NavigateOptionProps
147
-
148
- export interface NavigateOptionProps {
149
- // if set to `true`, the router will scroll the element with an id matching the hash into view with default ScrollIntoViewOptions.
150
- // if set to `false`, the router will not scroll the element with an id matching the hash into view.
151
- // if set to `ScrollIntoViewOptions`, the router will scroll the element with an id matching the hash into view with the provided options.
152
- hashScrollIntoView?: boolean | ScrollIntoViewOptions
153
- // `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.
154
- replace?: boolean
155
- resetScroll?: boolean
156
- /** @deprecated All navigations now use startTransition under the hood */
157
- startTransition?: boolean
158
- // if set to `true`, the router will wrap the resulting navigation in a document.startViewTransition() call.
159
- // if set to `ViewTransitionOptions`, the router will pass the `types` field to document.startViewTransition({update: fn, types: viewTransition.types}) call
160
- viewTransition?: boolean | ViewTransitionOptions
161
- ignoreBlocker?: boolean
162
- reloadDocument?: boolean
163
- href?: string
164
- }
165
-
166
- export type ToOptions<
167
- TRouter extends AnyRouter = RegisteredRouter,
168
- TFrom extends string = string,
169
- TTo extends string | undefined = '.',
170
- TMaskFrom extends string = TFrom,
171
- TMaskTo extends string = '.',
172
- > = ToSubOptions<TRouter, TFrom, TTo> & MaskOptions<TRouter, TMaskFrom, TMaskTo>
173
-
174
- export interface MaskOptions<
175
- in out TRouter extends AnyRouter,
176
- in out TMaskFrom extends string,
177
- in out TMaskTo extends string,
178
- > {
179
- _fromLocation?: ParsedLocation
180
- mask?: ToMaskOptions<TRouter, TMaskFrom, TMaskTo>
181
- }
182
-
183
- export type ToMaskOptions<
184
- TRouter extends AnyRouter = RegisteredRouter,
185
- TMaskFrom extends string = string,
186
- TMaskTo extends string = '.',
187
- > = ToSubOptions<TRouter, TMaskFrom, TMaskTo> & {
188
- unmaskOnReload?: boolean
189
- }
190
-
191
- export type ToSubOptions<
192
- TRouter extends AnyRouter = RegisteredRouter,
193
- TFrom extends string = string,
194
- TTo extends string | undefined = '.',
195
- > = ToSubOptionsProps<TRouter, TFrom, TTo> &
196
- SearchParamOptions<TRouter, TFrom, TTo> &
197
- PathParamOptions<TRouter, TFrom, TTo>
198
-
199
- export interface RequiredToOptions<
200
- in out TRouter extends AnyRouter,
201
- in out TFrom extends string,
202
- in out TTo extends string | undefined,
203
- > {
204
- to: ToPathOption<TRouter, TFrom, TTo> & {}
205
- }
206
-
207
- export interface OptionalToOptions<
208
- in out TRouter extends AnyRouter,
209
- in out TFrom extends string,
210
- in out TTo extends string | undefined,
211
- > {
212
- to?: ToPathOption<TRouter, TFrom, TTo> & {}
213
- }
214
-
215
- export type MakeToRequired<
216
- TRouter extends AnyRouter,
217
- TFrom extends string,
218
- TTo extends string | undefined,
219
- > = string extends TFrom
220
- ? string extends TTo
221
- ? OptionalToOptions<TRouter, TFrom, TTo>
222
- : TTo & CatchAllPaths<TRouter> extends never
223
- ? RequiredToOptions<TRouter, TFrom, TTo>
224
- : OptionalToOptions<TRouter, TFrom, TTo>
225
- : OptionalToOptions<TRouter, TFrom, TTo>
226
-
227
- export type ToSubOptionsProps<
228
- TRouter extends AnyRouter = RegisteredRouter,
229
- TFrom extends RoutePaths<TRouter['routeTree']> | string = string,
230
- TTo extends string | undefined = '.',
231
- > = MakeToRequired<TRouter, TFrom, TTo> & {
232
- hash?: true | Updater<string>
233
- state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>
234
- from?: FromPathOption<TRouter, TFrom> & {}
235
- }
236
-
237
- export type ParamsReducerFn<
238
- in out TRouter extends AnyRouter,
239
- in out TParamVariant extends ParamVariant,
240
- in out TFrom,
241
- in out TTo,
242
- > = (
243
- current: Expand<ResolveFromParams<TRouter, TParamVariant, TFrom>>,
244
- ) => Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>
245
-
246
- type ParamsReducer<
247
- TRouter extends AnyRouter,
248
- TParamVariant extends ParamVariant,
249
- TFrom,
250
- TTo,
251
- > =
252
- | Expand<ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>>
253
- | (ParamsReducerFn<TRouter, TParamVariant, TFrom, TTo> & {})
254
-
255
- type ParamVariant = 'PATH' | 'SEARCH'
256
-
257
- export type ResolveRoute<
258
- TRouter extends AnyRouter,
259
- TFrom,
260
- TTo,
261
- TPath = ResolveRelativePath<TFrom, TTo>,
262
- > = TPath extends string
263
- ? TFrom extends TPath
264
- ? RouteByPath<TRouter['routeTree'], TPath>
265
- : RouteByToPath<TRouter, TPath>
266
- : never
267
-
268
- type ResolveFromParamType<TParamVariant extends ParamVariant> =
269
- TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema'
270
-
271
- type ResolveFromAllParams<
272
- TRouter extends AnyRouter,
273
- TParamVariant extends ParamVariant,
274
- > = TParamVariant extends 'PATH'
275
- ? AllParams<TRouter['routeTree']>
276
- : FullSearchSchema<TRouter['routeTree']>
277
-
278
- type ResolveFromParams<
279
- TRouter extends AnyRouter,
280
- TParamVariant extends ParamVariant,
281
- TFrom,
282
- > = string extends TFrom
283
- ? ResolveFromAllParams<TRouter, TParamVariant>
284
- : RouteByPath<
285
- TRouter['routeTree'],
286
- TFrom
287
- >['types'][ResolveFromParamType<TParamVariant>]
288
-
289
- type ResolveToParamType<TParamVariant extends ParamVariant> =
290
- TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput'
291
-
292
- type ResolveAllToParams<
293
- TRouter extends AnyRouter,
294
- TParamVariant extends ParamVariant,
295
- > = TParamVariant extends 'PATH'
296
- ? AllParams<TRouter['routeTree']>
297
- : FullSearchSchemaInput<TRouter['routeTree']>
298
-
299
- export type ResolveToParams<
300
- TRouter extends AnyRouter,
301
- TParamVariant extends ParamVariant,
302
- TFrom,
303
- TTo,
304
- > =
305
- ResolveRelativePath<TFrom, TTo> extends infer TPath
306
- ? undefined extends TPath
307
- ? never
308
- : string extends TPath
309
- ? ResolveAllToParams<TRouter, TParamVariant>
310
- : TPath extends CatchAllPaths<TRouter>
311
- ? ResolveAllToParams<TRouter, TParamVariant>
312
- : ResolveRoute<
313
- TRouter,
314
- TFrom,
315
- TTo
316
- >['types'][ResolveToParamType<TParamVariant>]
317
- : never
318
-
319
- type ResolveRelativeToParams<
320
- TRouter extends AnyRouter,
321
- TParamVariant extends ParamVariant,
322
- TFrom,
323
- TTo,
324
- TToParams = ResolveToParams<TRouter, TParamVariant, TFrom, TTo>,
325
- > = TParamVariant extends 'SEARCH'
326
- ? TToParams
327
- : string extends TFrom
328
- ? TToParams
329
- : MakeDifferenceOptional<
330
- ResolveFromParams<TRouter, TParamVariant, TFrom>,
331
- TToParams
332
- >
333
-
334
- export interface MakeOptionalSearchParams<
335
- in out TRouter extends AnyRouter,
336
- in out TFrom,
337
- in out TTo,
338
- > {
339
- search?: true | (ParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {})
340
- }
341
-
342
- export interface MakeOptionalPathParams<
343
- in out TRouter extends AnyRouter,
344
- in out TFrom,
345
- in out TTo,
346
- > {
347
- params?: true | (ParamsReducer<TRouter, 'PATH', TFrom, TTo> & {})
348
- }
349
-
350
- type MakeRequiredParamsReducer<
351
- TRouter extends AnyRouter,
352
- TParamVariant extends ParamVariant,
353
- TFrom,
354
- TTo,
355
- > =
356
- | (string extends TFrom
357
- ? never
358
- : ResolveFromParams<TRouter, TParamVariant, TFrom> extends WithoutEmpty<
359
- PickRequired<
360
- ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>
361
- >
362
- >
363
- ? true
364
- : never)
365
- | (ParamsReducer<TRouter, TParamVariant, TFrom, TTo> & {})
366
-
367
- export interface MakeRequiredPathParams<
368
- in out TRouter extends AnyRouter,
369
- in out TFrom,
370
- in out TTo,
371
- > {
372
- params: MakeRequiredParamsReducer<TRouter, 'PATH', TFrom, TTo> & {}
373
- }
374
-
375
- export interface MakeRequiredSearchParams<
376
- in out TRouter extends AnyRouter,
377
- in out TFrom,
378
- in out TTo,
379
- > {
380
- search: MakeRequiredParamsReducer<TRouter, 'SEARCH', TFrom, TTo> & {}
381
- }
382
-
383
- export type IsRequired<
384
- TRouter extends AnyRouter,
385
- TParamVariant extends ParamVariant,
386
- TFrom,
387
- TTo,
388
- > =
389
- ResolveRelativePath<TFrom, TTo> extends infer TPath
390
- ? undefined extends TPath
391
- ? never
392
- : TPath extends CatchAllPaths<TRouter>
393
- ? never
394
- : IsRequiredParams<
395
- ResolveRelativeToParams<TRouter, TParamVariant, TFrom, TTo>
396
- >
397
- : never
398
-
399
- export type SearchParamOptions<TRouter extends AnyRouter, TFrom, TTo> =
400
- IsRequired<TRouter, 'SEARCH', TFrom, TTo> extends never
401
- ? MakeOptionalSearchParams<TRouter, TFrom, TTo>
402
- : MakeRequiredSearchParams<TRouter, TFrom, TTo>
403
-
404
- export type PathParamOptions<TRouter extends AnyRouter, TFrom, TTo> =
405
- IsRequired<TRouter, 'PATH', TFrom, TTo> extends never
406
- ? MakeOptionalPathParams<TRouter, TFrom, TTo>
407
- : MakeRequiredPathParams<TRouter, TFrom, TTo>
408
-
409
- export type ToPathOption<
410
- TRouter extends AnyRouter = AnyRouter,
411
- TFrom extends string = string,
412
- TTo extends string | undefined = string,
413
- > = ConstrainLiteral<
414
- TTo,
415
- RelativeToPathAutoComplete<
416
- TRouter,
417
- NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',
418
- NoInfer<TTo> & string
419
- >
420
- >
421
-
422
- export type FromPathOption<TRouter extends AnyRouter, TFrom> = ConstrainLiteral<
423
- TFrom,
424
- RoutePaths<TRouter['routeTree']>
425
- >
426
-
427
- export type LinkOptions<
428
- TRouter extends AnyRouter = RegisteredRouter,
429
- TFrom extends string = string,
430
- TTo extends string | undefined = '.',
431
- TMaskFrom extends string = TFrom,
432
- TMaskTo extends string = '.',
433
- > = NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkOptionsProps
434
-
435
- // type Test1 = ResolveRelativePath<'/', '/posts'>
436
- // // ^?
437
- // type Test4 = ResolveRelativePath<'/posts/1/comments', '../..'>
438
- // // ^?
439
- // type Test5 = ResolveRelativePath<'/posts/1/comments', '../../..'>
440
- // // ^?
441
- // type Test6 = ResolveRelativePath<'/posts/1/comments', './1'>
442
- // // ^?
443
- // type Test7 = ResolveRelativePath<'/posts/1/comments', './1/2'>
444
- // // ^?
445
- // type Test8 = ResolveRelativePath<'/posts/1/comments', '../edit'>
446
- // // ^?
447
- // type Test9 = ResolveRelativePath<'/posts/1/comments', '1'>
448
- // // ^?
449
- // type Test10 = ResolveRelativePath<'/posts/1/comments', './1'>
450
- // // ^?
451
- // type Test11 = ResolveRelativePath<'/posts/1/comments', './1/2'>
452
- // // ^?
453
- type LinkCurrentTargetElement = {
454
- preloadTimeout?: null | ReturnType<typeof setTimeout>
455
- }
456
-
457
34
  export function useLinkProps<
458
35
  TRouter extends AnyRouter = RegisteredRouter,
459
36
  const TFrom extends string = string,
package/src/not-found.tsx CHANGED
@@ -3,7 +3,7 @@ import { CatchBoundary } from './CatchBoundary'
3
3
  import { useRouterState } from './useRouterState'
4
4
  import type { ErrorInfo } from 'react'
5
5
  import type { RegisteredRouter } from './router'
6
- import type { RouteIds } from './routeInfo'
6
+ import type { RouteIds } from '@tanstack/router-core'
7
7
 
8
8
  export type NotFoundError = {
9
9
  /**
package/src/redirects.ts CHANGED
@@ -1,39 +1,9 @@
1
- import type { NavigateOptions } from './link'
2
- import type { RoutePaths } from './routeInfo'
3
- import type { AnyRouter, RegisteredRouter } from './router'
4
- import type { PickAsRequired } from '@tanstack/router-core'
5
-
6
- export type AnyRedirect = Redirect<any, any, any, any, any>
7
-
8
- export type Redirect<
9
- TRouter extends AnyRouter = RegisteredRouter,
10
- TFrom extends RoutePaths<TRouter['routeTree']> | string = '/',
11
- TTo extends string | undefined = '.',
12
- TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,
13
- TMaskTo extends string = '.',
14
- > = {
15
- href?: string
16
- /**
17
- * @deprecated Use `statusCode` instead
18
- **/
19
- code?: number
20
- statusCode?: number
21
- throw?: any
22
- headers?: HeadersInit
23
- } & NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>
24
-
25
- export type ResolvedRedirect<
26
- TRouter extends AnyRouter = RegisteredRouter,
27
- TFrom extends RoutePaths<TRouter['routeTree']> = '/',
28
- TTo extends string = '',
29
- TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,
30
- TMaskTo extends string = '',
31
- > = PickAsRequired<
32
- Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,
33
- 'code' | 'statusCode' | 'headers'
34
- > & {
35
- href: string
36
- }
1
+ import type {
2
+ AnyRedirect,
3
+ Redirect,
4
+ ResolvedRedirect,
5
+ } from '@tanstack/router-core'
6
+ import type { RegisteredRouter } from './router'
37
7
 
38
8
  export function redirect<
39
9
  TRouter extends RegisteredRouter,