@tanstack/router-core 1.115.3 → 1.117.1

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.3",
3
+ "version": "1.117.1",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
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
@@ -2253,10 +2274,6 @@ export class RouterCore<
2253
2274
  return !!(allPreload && !this.state.matches.find((d) => d.id === matchId))
2254
2275
  }
2255
2276
 
2256
- if (!this.isServer && !this.state.matches.length) {
2257
- triggerOnReady()
2258
- }
2259
-
2260
2277
  const handleRedirectAndNotFound = (match: AnyRouteMatch, err: any) => {
2261
2278
  if (isResolvedRedirect(err)) {
2262
2279
  if (!err.reloadDocument) {
@@ -2362,7 +2379,9 @@ export class RouterCore<
2362
2379
  onReady &&
2363
2380
  !this.isServer &&
2364
2381
  !resolvePreload(matchId) &&
2365
- (route.options.loader || route.options.beforeLoad) &&
2382
+ (route.options.loader ||
2383
+ route.options.beforeLoad ||
2384
+ routeNeedsPreload(route)) &&
2366
2385
  typeof pendingMs === 'number' &&
2367
2386
  pendingMs !== Infinity &&
2368
2387
  (route.options.pendingComponent ??
@@ -2647,6 +2666,10 @@ export class RouterCore<
2647
2666
  loaderData,
2648
2667
  })
2649
2668
 
2669
+ // Last but not least, wait for the the components
2670
+ // to be preloaded before we resolve the match
2671
+ await route._componentsPromise
2672
+
2650
2673
  updateMatch(matchId, (prev) => ({
2651
2674
  ...prev,
2652
2675
  error: undefined,
@@ -2689,10 +2712,6 @@ export class RouterCore<
2689
2712
  router: this,
2690
2713
  match: this.getMatch(matchId)!,
2691
2714
  })
2692
-
2693
- // Last but not least, wait for the the components
2694
- // to be preloaded before we resolve the match
2695
- await route._componentsPromise
2696
2715
  } catch (err) {
2697
2716
  updateMatch(matchId, (prev) => ({
2698
2717
  ...prev,