@tanstack/react-router 1.121.0-alpha.5 → 1.121.2

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.121.0-alpha.5",
3
+ "version": "1.121.2",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -38,7 +38,13 @@
38
38
  "default": "./dist/cjs/index.cjs"
39
39
  }
40
40
  },
41
- "./package.json": "./package.json"
41
+ "./package.json": "./package.json",
42
+ "./llms": {
43
+ "import": {
44
+ "types": "./dist/llms/index.d.ts",
45
+ "default": "./dist/llms/index.js"
46
+ }
47
+ }
42
48
  },
43
49
  "sideEffects": false,
44
50
  "files": [
@@ -53,8 +59,8 @@
53
59
  "jsesc": "^3.1.0",
54
60
  "tiny-invariant": "^1.3.3",
55
61
  "tiny-warning": "^1.0.3",
56
- "@tanstack/history": "1.121.0-alpha.1",
57
- "@tanstack/router-core": "1.121.0-alpha.5"
62
+ "@tanstack/history": "1.120.17",
63
+ "@tanstack/router-core": "1.121.2"
58
64
  },
59
65
  "devDependencies": {
60
66
  "@testing-library/jest-dom": "^6.6.3",
@@ -64,6 +70,7 @@
64
70
  "combinate": "^1.1.11",
65
71
  "react": "^19.0.0",
66
72
  "react-dom": "^19.0.0",
73
+ "vibe-rules": "^0.2.57",
67
74
  "zod": "^3.24.2"
68
75
  },
69
76
  "peerDependencies": {
@@ -2,7 +2,7 @@ import React from 'react'
2
2
 
3
3
  export interface ClientOnlyProps {
4
4
  /**
5
- * The children to render if the JS is loaded.
5
+ * The children to render when the JS is loaded.
6
6
  */
7
7
  children: React.ReactNode
8
8
  /**
package/src/link.tsx CHANGED
@@ -17,7 +17,6 @@ import {
17
17
  } from './utils'
18
18
 
19
19
  import { useMatch } from './useMatch'
20
- import { useMatches } from './Matches'
21
20
  import type {
22
21
  AnyRouter,
23
22
  Constrain,
@@ -106,23 +105,12 @@ export function useLinkProps<
106
105
  structuralSharing: true as any,
107
106
  })
108
107
 
109
- const isRelativeFromPath = options.unsafeRelative === 'path'
110
-
111
- // when `from` is not supplied, use the nearest parent match's full path as the `from` location
112
- // so relative routing works as expected. Try to stay out of rerenders as much as possible.
113
108
  const nearestFrom = useMatch({
114
109
  strict: false,
115
- select: (match) => (isRelativeFromPath ? undefined : match.fullPath),
116
- })
117
-
118
- // When no from and relative is path, use the leaf match as the from location
119
- // Avoid rerenders as much as possible.
120
- const leafFrom = useMatches({
121
- select: (matches) =>
122
- isRelativeFromPath ? matches[matches.length - 1]!.fullPath : undefined,
110
+ select: (match) => match.fullPath,
123
111
  })
124
112
 
125
- const from = options.from ?? (isRelativeFromPath ? leafFrom : nearestFrom)
113
+ const from = options.from ?? nearestFrom
126
114
 
127
115
  // Use it as the default `from` location
128
116
  options = { ...options, from }
@@ -382,8 +370,8 @@ type UseLinkReactProps<TComp> = TComp extends keyof React.JSX.IntrinsicElements
382
370
  > &
383
371
  React.RefAttributes<
384
372
  TComp extends
385
- | React.FC<{ ref: infer TRef }>
386
- | React.Component<{ ref: infer TRef }>
373
+ | React.FC<{ ref: React.Ref<infer TRef> }>
374
+ | React.Component<{ ref: React.Ref<infer TRef> }>
387
375
  ? TRef
388
376
  : never
389
377
  >
package/src/route.tsx CHANGED
@@ -25,9 +25,11 @@ import type {
25
25
  ResolveFullPath,
26
26
  ResolveId,
27
27
  ResolveParams,
28
+ RootRoute as RootRouteCore,
28
29
  RootRouteId,
29
30
  RootRouteOptions,
30
31
  RouteConstraints,
32
+ Route as RouteCore,
31
33
  RouteIds,
32
34
  RouteMask,
33
35
  RouteOptions,
@@ -148,43 +150,62 @@ export class RouteApi<
148
150
  }
149
151
 
150
152
  export class Route<
151
- in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,
152
- in out TPath extends RouteConstraints['TPath'] = '/',
153
- in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<
154
- TParentRoute,
155
- TPath
156
- >,
157
- in out TCustomId extends RouteConstraints['TCustomId'] = string,
158
- in out TId extends RouteConstraints['TId'] = ResolveId<
153
+ in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,
154
+ in out TPath extends RouteConstraints['TPath'] = '/',
155
+ in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<
156
+ TParentRoute,
157
+ TPath
158
+ >,
159
+ in out TCustomId extends RouteConstraints['TCustomId'] = string,
160
+ in out TId extends RouteConstraints['TId'] = ResolveId<
161
+ TParentRoute,
162
+ TCustomId,
163
+ TPath
164
+ >,
165
+ in out TSearchValidator = undefined,
166
+ in out TParams = ResolveParams<TPath>,
167
+ in out TRouterContext = AnyContext,
168
+ in out TRouteContextFn = AnyContext,
169
+ in out TBeforeLoadFn = AnyContext,
170
+ in out TLoaderDeps extends Record<string, any> = {},
171
+ in out TLoaderFn = undefined,
172
+ in out TChildren = unknown,
173
+ in out TFileRouteTypes = unknown,
174
+ >
175
+ extends BaseRoute<
159
176
  TParentRoute,
177
+ TPath,
178
+ TFullPath,
160
179
  TCustomId,
161
- TPath
162
- >,
163
- in out TSearchValidator = undefined,
164
- in out TParams = ResolveParams<TPath>,
165
- in out TRouterContext = AnyContext,
166
- in out TRouteContextFn = AnyContext,
167
- in out TBeforeLoadFn = AnyContext,
168
- in out TLoaderDeps extends Record<string, any> = {},
169
- in out TLoaderFn = undefined,
170
- in out TChildren = unknown,
171
- in out TFileRouteTypes = unknown,
172
- > extends BaseRoute<
173
- TParentRoute,
174
- TPath,
175
- TFullPath,
176
- TCustomId,
177
- TId,
178
- TSearchValidator,
179
- TParams,
180
- TRouterContext,
181
- TRouteContextFn,
182
- TBeforeLoadFn,
183
- TLoaderDeps,
184
- TLoaderFn,
185
- TChildren,
186
- TFileRouteTypes
187
- > {
180
+ TId,
181
+ TSearchValidator,
182
+ TParams,
183
+ TRouterContext,
184
+ TRouteContextFn,
185
+ TBeforeLoadFn,
186
+ TLoaderDeps,
187
+ TLoaderFn,
188
+ TChildren,
189
+ TFileRouteTypes
190
+ >
191
+ implements
192
+ RouteCore<
193
+ TParentRoute,
194
+ TPath,
195
+ TFullPath,
196
+ TCustomId,
197
+ TId,
198
+ TSearchValidator,
199
+ TParams,
200
+ TRouterContext,
201
+ TRouteContextFn,
202
+ TBeforeLoadFn,
203
+ TLoaderDeps,
204
+ TLoaderFn,
205
+ TChildren,
206
+ TFileRouteTypes
207
+ >
208
+ {
188
209
  /**
189
210
  * @deprecated Use the `createRoute` function instead.
190
211
  */
@@ -364,24 +385,37 @@ export function createRootRouteWithContext<TRouterContext extends {}>() {
364
385
  export const rootRouteWithContext = createRootRouteWithContext
365
386
 
366
387
  export class RootRoute<
367
- in out TSearchValidator = undefined,
368
- in out TRouterContext = {},
369
- in out TRouteContextFn = AnyContext,
370
- in out TBeforeLoadFn = AnyContext,
371
- in out TLoaderDeps extends Record<string, any> = {},
372
- in out TLoaderFn = undefined,
373
- in out TChildren = unknown,
374
- in out TFileRouteTypes = unknown,
375
- > extends BaseRootRoute<
376
- TSearchValidator,
377
- TRouterContext,
378
- TRouteContextFn,
379
- TBeforeLoadFn,
380
- TLoaderDeps,
381
- TLoaderFn,
382
- TChildren,
383
- TFileRouteTypes
384
- > {
388
+ in out TSearchValidator = undefined,
389
+ in out TRouterContext = {},
390
+ in out TRouteContextFn = AnyContext,
391
+ in out TBeforeLoadFn = AnyContext,
392
+ in out TLoaderDeps extends Record<string, any> = {},
393
+ in out TLoaderFn = undefined,
394
+ in out TChildren = unknown,
395
+ in out TFileRouteTypes = unknown,
396
+ >
397
+ extends BaseRootRoute<
398
+ TSearchValidator,
399
+ TRouterContext,
400
+ TRouteContextFn,
401
+ TBeforeLoadFn,
402
+ TLoaderDeps,
403
+ TLoaderFn,
404
+ TChildren,
405
+ TFileRouteTypes
406
+ >
407
+ implements
408
+ RootRouteCore<
409
+ TSearchValidator,
410
+ TRouterContext,
411
+ TRouteContextFn,
412
+ TBeforeLoadFn,
413
+ TLoaderDeps,
414
+ TLoaderFn,
415
+ TChildren,
416
+ TFileRouteTypes
417
+ >
418
+ {
385
419
  /**
386
420
  * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
387
421
  */
@@ -26,14 +26,10 @@ export function useNavigate<
26
26
 
27
27
  return React.useCallback(
28
28
  (options: NavigateOptions) => {
29
- const isRelativeFromPath = options.unsafeRelative === 'path'
30
-
31
29
  const from =
32
30
  options.from ??
33
31
  _defaultOpts?.from ??
34
- (isRelativeFromPath
35
- ? state.matches[state.matches.length - 1]!.fullPath
36
- : state.matches[matchIndex]!.fullPath)
32
+ state.matches[matchIndex]!.fullPath
37
33
 
38
34
  return navigate({
39
35
  ...options,