@tanstack/router-core 1.115.0 → 1.117.0

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/router-core",
3
- "version": "1.115.0",
3
+ "version": "1.117.0",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/redirect.ts CHANGED
@@ -51,8 +51,8 @@ export type ResolvedRedirect<
51
51
  }
52
52
 
53
53
  export function redirect<
54
- TRouter extends RegisteredRouter,
55
- const TTo extends string | undefined,
54
+ TRouter extends AnyRouter = RegisteredRouter,
55
+ const TTo extends string | undefined = '.',
56
56
  const TFrom extends string = string,
57
57
  const TMaskFrom extends string = TFrom,
58
58
  const TMaskTo extends string = '',
package/src/router.ts CHANGED
@@ -670,7 +670,15 @@ export type AnyRouterWithContext<TContext> = RouterCore<
670
670
  export type AnyRouter = RouterCore<any, any, any, any, any>
671
671
 
672
672
  export interface ViewTransitionOptions {
673
- types: Array<string>
673
+ types:
674
+ | Array<string>
675
+ | ((locationChangeInfo: {
676
+ fromLocation?: ParsedLocation
677
+ toLocation: ParsedLocation
678
+ pathChanged: boolean
679
+ hrefChanged: boolean
680
+ hashChanged: boolean
681
+ }) => Array<string>)
674
682
  }
675
683
 
676
684
  export function defaultSerializeError(err: unknown) {
@@ -2172,9 +2180,22 @@ export class RouterCore<
2172
2180
  typeof shouldViewTransition === 'object' &&
2173
2181
  this.isViewTransitionTypesSupported
2174
2182
  ) {
2183
+ const next = this.latestLocation
2184
+ const prevLocation = this.state.resolvedLocation
2185
+
2186
+ const resolvedViewTransitionTypes =
2187
+ typeof shouldViewTransition.types === 'function'
2188
+ ? shouldViewTransition.types(
2189
+ getLocationChangeInfo({
2190
+ resolvedLocation: prevLocation,
2191
+ location: next,
2192
+ }),
2193
+ )
2194
+ : shouldViewTransition.types
2195
+
2175
2196
  startViewTransitionParams = {
2176
2197
  update: fn,
2177
- types: shouldViewTransition.types,
2198
+ types: resolvedViewTransitionTypes,
2178
2199
  }
2179
2200
  } else {
2180
2201
  startViewTransitionParams = fn