@tanstack/router-core 1.163.3 → 1.166.4

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.
@@ -28,6 +28,14 @@ function hydrateMatch(
28
28
  match.ssr = deyhydratedMatch.ssr
29
29
  match.updatedAt = deyhydratedMatch.u
30
30
  match.error = deyhydratedMatch.e
31
+ // Only hydrate global-not-found when a defined value is present in the
32
+ // dehydrated payload. If omitted, preserve the value computed from the
33
+ // current client location (important for SPA fallback HTML served at unknown
34
+ // URLs, where dehydrated matches may come from `/` but client matching marks
35
+ // root as globalNotFound).
36
+ if (deyhydratedMatch.g !== undefined) {
37
+ match.globalNotFound = deyhydratedMatch.g
38
+ }
31
39
  }
32
40
 
33
41
  export async function hydrate(router: AnyRouter): Promise<any> {
@@ -82,10 +90,9 @@ export async function hydrate(router: AnyRouter): Promise<any> {
82
90
 
83
91
  // kick off loading the route chunks
84
92
  const routeChunkPromise = Promise.all(
85
- matches.map((match) => {
86
- const route = router.looseRoutesById[match.routeId]!
87
- return router.loadRouteChunk(route)
88
- }),
93
+ matches.map((match) =>
94
+ router.loadRouteChunk(router.looseRoutesById[match.routeId]!),
95
+ ),
89
96
  )
90
97
 
91
98
  function setMatchForcePending(match: AnyRouteMatch) {
@@ -146,12 +153,10 @@ export async function hydrate(router: AnyRouter): Promise<any> {
146
153
  }
147
154
  })
148
155
 
149
- router.__store.setState((s) => {
150
- return {
151
- ...s,
152
- matches,
153
- }
154
- })
156
+ router.__store.setState((s) => ({
157
+ ...s,
158
+ matches,
159
+ }))
155
160
 
156
161
  // Allow the user to handle custom hydration data
157
162
  await router.options.hydrate?.(dehydratedData)
@@ -277,13 +282,11 @@ export async function hydrate(router: AnyRouter): Promise<any> {
277
282
  }))
278
283
  }
279
284
  // hide the pending component once the load is finished
280
- router.updateMatch(match.id, (prev) => {
281
- return {
282
- ...prev,
283
- _displayPending: undefined,
284
- displayPendingPromise: undefined,
285
- }
286
- })
285
+ router.updateMatch(match.id, (prev) => ({
286
+ ...prev,
287
+ _displayPending: undefined,
288
+ displayPendingPromise: undefined,
289
+ }))
287
290
  })
288
291
  })
289
292
  }
@@ -54,6 +54,9 @@ export function dehydrateMatch(match: AnyRouteMatch): DehydratedMatch {
54
54
  dehydratedMatch[shorthand] = match[key]
55
55
  }
56
56
  }
57
+ if (match.globalNotFound) {
58
+ dehydratedMatch.g = true
59
+ }
57
60
  return dehydratedMatch
58
61
  }
59
62
 
package/src/ssr/types.ts CHANGED
@@ -9,6 +9,7 @@ export interface DehydratedMatch {
9
9
  u: MakeRouteMatch['updatedAt']
10
10
  s: MakeRouteMatch['status']
11
11
  ssr?: MakeRouteMatch['ssr']
12
+ g?: true
12
13
  }
13
14
 
14
15
  export interface DehydratedRouter {