@tanstack/router-core 1.117.0 → 1.119.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.117.0",
3
+ "version": "1.119.0",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/path.ts CHANGED
@@ -216,6 +216,7 @@ interface InterpolatePathOptions {
216
216
  type InterPolatePathResult = {
217
217
  interpolatedPath: string
218
218
  usedParams: Record<string, unknown>
219
+ isMissingParams: boolean // true if any params were not available when being looked up in the params object
219
220
  }
220
221
  export function interpolatePath({
221
222
  path,
@@ -238,6 +239,10 @@ export function interpolatePath({
238
239
  }
239
240
  }
240
241
 
242
+ // Tracking if any params are missing in the `params` object
243
+ // when interpolating the path
244
+ let isMissingParams = false
245
+
241
246
  const usedParams: Record<string, unknown> = {}
242
247
  const interpolatedPath = joinPaths(
243
248
  interpolatedPathSegments.map((segment) => {
@@ -250,6 +255,9 @@ export function interpolatePath({
250
255
 
251
256
  if (segment.type === 'param') {
252
257
  const key = segment.value.substring(1)
258
+ if (!isMissingParams && !(key in params)) {
259
+ isMissingParams = true
260
+ }
253
261
  usedParams[key] = params[key]
254
262
  if (leaveParams) {
255
263
  const value = encodeParam(segment.value)
@@ -261,7 +269,7 @@ export function interpolatePath({
261
269
  return segment.value
262
270
  }),
263
271
  )
264
- return { usedParams, interpolatedPath }
272
+ return { usedParams, interpolatedPath, isMissingParams }
265
273
  }
266
274
 
267
275
  function encodePathParam(value: string, decodeCharMap?: Map<string, string>) {
package/src/router.ts CHANGED
@@ -2274,10 +2274,6 @@ export class RouterCore<
2274
2274
  return !!(allPreload && !this.state.matches.find((d) => d.id === matchId))
2275
2275
  }
2276
2276
 
2277
- if (!this.isServer && !this.state.matches.length) {
2278
- triggerOnReady()
2279
- }
2280
-
2281
2277
  const handleRedirectAndNotFound = (match: AnyRouteMatch, err: any) => {
2282
2278
  if (isResolvedRedirect(err)) {
2283
2279
  if (!err.reloadDocument) {
@@ -2383,7 +2379,9 @@ export class RouterCore<
2383
2379
  onReady &&
2384
2380
  !this.isServer &&
2385
2381
  !resolvePreload(matchId) &&
2386
- (route.options.loader || route.options.beforeLoad) &&
2382
+ (route.options.loader ||
2383
+ route.options.beforeLoad ||
2384
+ routeNeedsPreload(route)) &&
2387
2385
  typeof pendingMs === 'number' &&
2388
2386
  pendingMs !== Infinity &&
2389
2387
  (route.options.pendingComponent ??
@@ -2668,6 +2666,10 @@ export class RouterCore<
2668
2666
  loaderData,
2669
2667
  })
2670
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
+
2671
2673
  updateMatch(matchId, (prev) => ({
2672
2674
  ...prev,
2673
2675
  error: undefined,
@@ -2710,10 +2712,6 @@ export class RouterCore<
2710
2712
  router: this,
2711
2713
  match: this.getMatch(matchId)!,
2712
2714
  })
2713
-
2714
- // Last but not least, wait for the the components
2715
- // to be preloaded before we resolve the match
2716
- await route._componentsPromise
2717
2715
  } catch (err) {
2718
2716
  updateMatch(matchId, (prev) => ({
2719
2717
  ...prev,