@timber-js/app 0.2.0-alpha.232 → 0.2.0-alpha.234

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.
Files changed (964) hide show
  1. package/dist/_chunks/{error-boundary-OHK1mI99.js → error-boundary-Cf1m-Ywk.js} +514 -6
  2. package/dist/_chunks/error-boundary-Cf1m-Ywk.js.map +1 -0
  3. package/dist/_chunks/{navigation-root-CoGHIMiE.js → navigation-root-Cvb7P1ud.js} +76 -4
  4. package/dist/_chunks/navigation-root-Cvb7P1ud.js.map +1 -0
  5. package/dist/_chunks/rsc-error-envelope-D6gNqh52.js +19 -0
  6. package/dist/_chunks/rsc-error-envelope-D6gNqh52.js.map +1 -0
  7. package/dist/adapters/nitro-presets.d.ts.map +1 -1
  8. package/dist/adapters/nitro.js +18 -2
  9. package/dist/adapters/nitro.js.map +1 -1
  10. package/dist/client/error-boundary.js +1 -1
  11. package/dist/client/index.js +1 -2
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/client/internal.js +18 -10
  14. package/dist/client/internal.js.map +1 -1
  15. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  16. package/dist/client/router-types.d.ts +7 -0
  17. package/dist/client/router-types.d.ts.map +1 -1
  18. package/dist/client/router.d.ts.map +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +319 -45
  21. package/dist/index.js.map +1 -1
  22. package/dist/native/rsc/_react/chunks/react-dom.react-server-DBDSYwwu.js +132 -0
  23. package/dist/native/rsc/_react/chunks/react-server-dom-webpack-server.node.development-hQ_odxIB.js +3925 -0
  24. package/dist/native/rsc/_react/chunks/react.react-server-Bcw6dpXf.js +539 -0
  25. package/dist/native/rsc/_react/flight-client.js +2867 -0
  26. package/dist/native/rsc/_react/flight-server.js +30 -0
  27. package/dist/native/rsc/_react/flight-static.js +12 -0
  28. package/dist/native/rsc/_react/jsx-dev-runtime.js +234 -0
  29. package/dist/native/rsc/_react/jsx-runtime.js +234 -0
  30. package/dist/native/rsc/_react/react-dom.js +14 -0
  31. package/dist/native/rsc/_react/react.js +29 -0
  32. package/dist/native/rsc/_virtual/_rolldown/runtime.js +2 -0
  33. package/dist/native/rsc/_virtual/_timber-native-client-ref_client/index.js +9 -0
  34. package/dist/native/rsc/_virtual/_timber-native-client-ref_client/use-query-states.js +7 -0
  35. package/dist/native/rsc/adapters/build-output-helper.js +142 -0
  36. package/dist/native/rsc/adapters/build-output-helper.js.map +1 -0
  37. package/dist/native/rsc/adapters/cloudflare-kv-cache.js +96 -0
  38. package/dist/native/rsc/adapters/cloudflare-kv-cache.js.map +1 -0
  39. package/dist/native/rsc/adapters/cloudflare.js +410 -0
  40. package/dist/native/rsc/adapters/cloudflare.js.map +1 -0
  41. package/dist/native/rsc/adapters/fs-identity.js +54 -0
  42. package/dist/native/rsc/adapters/fs-identity.js.map +1 -0
  43. package/dist/native/rsc/adapters/shared.js +99 -0
  44. package/dist/native/rsc/adapters/shared.js.map +1 -0
  45. package/dist/native/rsc/cache/cache-api.js +43 -0
  46. package/dist/native/rsc/cache/cache-api.js.map +1 -0
  47. package/dist/native/rsc/cache/fast-hash.js +15 -0
  48. package/dist/native/rsc/cache/fast-hash.js.map +1 -0
  49. package/dist/native/rsc/cache/guarded-read.js +18 -0
  50. package/dist/native/rsc/cache/guarded-read.js.map +1 -0
  51. package/dist/native/rsc/cache/handler-store.js +69 -0
  52. package/dist/native/rsc/cache/handler-store.js.map +1 -0
  53. package/dist/native/rsc/cache/index.js +86 -0
  54. package/dist/native/rsc/cache/index.js.map +1 -0
  55. package/dist/native/rsc/cache/invalidation-epoch.js +43 -0
  56. package/dist/native/rsc/cache/invalidation-epoch.js.map +1 -0
  57. package/dist/native/rsc/cache/json-lossy-check.js +58 -0
  58. package/dist/native/rsc/cache/json-lossy-check.js.map +1 -0
  59. package/dist/native/rsc/cache/key-discipline.js +93 -0
  60. package/dist/native/rsc/cache/key-discipline.js.map +1 -0
  61. package/dist/native/rsc/cache/redis-handler.js +109 -0
  62. package/dist/native/rsc/cache/redis-handler.js.map +1 -0
  63. package/dist/native/rsc/cache/singleflight.js +49 -0
  64. package/dist/native/rsc/cache/singleflight.js.map +1 -0
  65. package/dist/native/rsc/cache/sizeof.js +15 -0
  66. package/dist/native/rsc/cache/sizeof.js.map +1 -0
  67. package/dist/native/rsc/cache/stable-stringify.js +53 -0
  68. package/dist/native/rsc/cache/stable-stringify.js.map +1 -0
  69. package/dist/native/rsc/cache/stores/cloudflare-kv.js +24 -0
  70. package/dist/native/rsc/cache/stores/cloudflare-kv.js.map +1 -0
  71. package/dist/native/rsc/cache/stores/memory.js +90 -0
  72. package/dist/native/rsc/cache/stores/memory.js.map +1 -0
  73. package/dist/native/rsc/cache/stores/redis.js +35 -0
  74. package/dist/native/rsc/cache/stores/redis.js.map +1 -0
  75. package/dist/native/rsc/cache/stores/vercel.js +33 -0
  76. package/dist/native/rsc/cache/stores/vercel.js.map +1 -0
  77. package/dist/native/rsc/cache/tag-aware-handler.js +147 -0
  78. package/dist/native/rsc/cache/tag-aware-handler.js.map +1 -0
  79. package/dist/native/rsc/cache/timber-cache.js +108 -0
  80. package/dist/native/rsc/cache/timber-cache.js.map +1 -0
  81. package/dist/native/rsc/cdn/cloudflare-purge.js +30 -0
  82. package/dist/native/rsc/cdn/cloudflare-purge.js.map +1 -0
  83. package/dist/native/rsc/cdn/fastly-purge.js +33 -0
  84. package/dist/native/rsc/cdn/fastly-purge.js.map +1 -0
  85. package/dist/native/rsc/cdn/headers.js +41 -0
  86. package/dist/native/rsc/cdn/headers.js.map +1 -0
  87. package/dist/native/rsc/cdn/index.js +4 -0
  88. package/dist/native/rsc/cdn/purge-store.js +25 -0
  89. package/dist/native/rsc/cdn/purge-store.js.map +1 -0
  90. package/dist/native/rsc/cdn/workers-cache-purge.js +14 -0
  91. package/dist/native/rsc/cdn/workers-cache-purge.js.map +1 -0
  92. package/dist/native/rsc/client/ssr-data.js +7 -0
  93. package/dist/native/rsc/client/ssr-data.js.map +1 -0
  94. package/dist/native/rsc/client/state.js +14 -0
  95. package/dist/native/rsc/client/state.js.map +1 -0
  96. package/dist/native/rsc/client/use-cookie.js +81 -0
  97. package/dist/native/rsc/client/use-cookie.js.map +1 -0
  98. package/dist/native/rsc/codec.js +76 -0
  99. package/dist/native/rsc/codec.js.map +1 -0
  100. package/dist/native/rsc/cookies/define-cookie.js +82 -0
  101. package/dist/native/rsc/cookies/define-cookie.js.map +1 -0
  102. package/dist/native/rsc/cookies/index.js +4 -0
  103. package/dist/native/rsc/cookies/json-cookie.js +26 -0
  104. package/dist/native/rsc/cookies/json-cookie.js.map +1 -0
  105. package/dist/native/rsc/cookies/validation.js +42 -0
  106. package/dist/native/rsc/cookies/validation.js.map +1 -0
  107. package/dist/native/rsc/dev-tools/404-page.js +195 -0
  108. package/dist/native/rsc/dev-tools/404-page.js.map +1 -0
  109. package/dist/native/rsc/dev-tools/await-span.js +28 -0
  110. package/dist/native/rsc/dev-tools/await-span.js.map +1 -0
  111. package/dist/native/rsc/dev-tools/dev-page-shell.js +152 -0
  112. package/dist/native/rsc/dev-tools/dev-page-shell.js.map +1 -0
  113. package/dist/native/rsc/dev-tools/error-page.js +214 -0
  114. package/dist/native/rsc/dev-tools/error-page.js.map +1 -0
  115. package/dist/native/rsc/dev-tools/instrumentation.js +117 -0
  116. package/dist/native/rsc/dev-tools/instrumentation.js.map +1 -0
  117. package/dist/native/rsc/dev-tools/logger.js +201 -0
  118. package/dist/native/rsc/dev-tools/logger.js.map +1 -0
  119. package/dist/native/rsc/dev-tools/overlay.js +36 -0
  120. package/dist/native/rsc/dev-tools/overlay.js.map +1 -0
  121. package/dist/native/rsc/dev-tools/span-sink.js +39 -0
  122. package/dist/native/rsc/dev-tools/span-sink.js.map +1 -0
  123. package/dist/native/rsc/dev-tools/stack-classifier.js +40 -0
  124. package/dist/native/rsc/dev-tools/stack-classifier.js.map +1 -0
  125. package/dist/native/rsc/dev-tools/terminal.js +75 -0
  126. package/dist/native/rsc/dev-tools/terminal.js.map +1 -0
  127. package/dist/native/rsc/manifest.json +256 -0
  128. package/dist/native/rsc/params/codec-registry.js +14 -0
  129. package/dist/native/rsc/params/codec-registry.js.map +1 -0
  130. package/dist/native/rsc/params/define-schema.js +7 -0
  131. package/dist/native/rsc/params/define-schema.js.map +1 -0
  132. package/dist/native/rsc/params/index.js +4 -0
  133. package/dist/native/rsc/params/resolve-schema.js +29 -0
  134. package/dist/native/rsc/params/resolve-schema.js.map +1 -0
  135. package/dist/native/rsc/routes/href.js +8 -0
  136. package/dist/native/rsc/routes/href.js.map +1 -0
  137. package/dist/native/rsc/routes/index.js +2 -0
  138. package/dist/native/rsc/routing/collision-probe.js +127 -0
  139. package/dist/native/rsc/routing/collision-probe.js.map +1 -0
  140. package/dist/native/rsc/routing/interception-overlap.js +51 -0
  141. package/dist/native/rsc/routing/interception-overlap.js.map +1 -0
  142. package/dist/native/rsc/routing/interception.js +51 -0
  143. package/dist/native/rsc/routing/interception.js.map +1 -0
  144. package/dist/native/rsc/routing/segment-classify.js +103 -0
  145. package/dist/native/rsc/routing/segment-classify.js.map +1 -0
  146. package/dist/native/rsc/routing/segment-keys.js +58 -0
  147. package/dist/native/rsc/routing/segment-keys.js.map +1 -0
  148. package/dist/native/rsc/routing/types.js +10 -0
  149. package/dist/native/rsc/routing/types.js.map +1 -0
  150. package/dist/native/rsc/routing/walkers.js +28 -0
  151. package/dist/native/rsc/routing/walkers.js.map +1 -0
  152. package/dist/native/rsc/rsc-runtime/dev-reference-cache.js +49 -0
  153. package/dist/native/rsc/rsc-runtime/dev-reference-cache.js.map +1 -0
  154. package/dist/native/rsc/rsc-runtime/server-reference-load-error.js +12 -0
  155. package/dist/native/rsc/rsc-runtime/server-reference-load-error.js.map +1 -0
  156. package/dist/native/rsc/schema-bridge.js +106 -0
  157. package/dist/native/rsc/schema-bridge.js.map +1 -0
  158. package/dist/native/rsc/search-params/define.js +146 -0
  159. package/dist/native/rsc/search-params/define.js.map +1 -0
  160. package/dist/native/rsc/search-params/index.js +5 -0
  161. package/dist/native/rsc/search-params/parse-total.js +10 -0
  162. package/dist/native/rsc/search-params/parse-total.js.map +1 -0
  163. package/dist/native/rsc/search-params/serialize-equal.js +9 -0
  164. package/dist/native/rsc/search-params/serialize-equal.js.map +1 -0
  165. package/dist/native/rsc/search-params/wrappers.js +29 -0
  166. package/dist/native/rsc/search-params/wrappers.js.map +1 -0
  167. package/dist/native/rsc/server/abort-scope.js +23 -0
  168. package/dist/native/rsc/server/abort-scope.js.map +1 -0
  169. package/dist/native/rsc/server/access-gate.js +55 -0
  170. package/dist/native/rsc/server/access-gate.js.map +1 -0
  171. package/dist/native/rsc/server/action-client.js +153 -0
  172. package/dist/native/rsc/server/action-client.js.map +1 -0
  173. package/dist/native/rsc/server/action-handler.js +301 -0
  174. package/dist/native/rsc/server/action-handler.js.map +1 -0
  175. package/dist/native/rsc/server/action-schema.js +66 -0
  176. package/dist/native/rsc/server/action-schema.js.map +1 -0
  177. package/dist/native/rsc/server/actions.js +98 -0
  178. package/dist/native/rsc/server/actions.js.map +1 -0
  179. package/dist/native/rsc/server/als-registry.js +23 -0
  180. package/dist/native/rsc/server/als-registry.js.map +1 -0
  181. package/dist/native/rsc/server/body-limits.js +55 -0
  182. package/dist/native/rsc/server/body-limits.js.map +1 -0
  183. package/dist/native/rsc/server/build-manifest.js +54 -0
  184. package/dist/native/rsc/server/build-manifest.js.map +1 -0
  185. package/dist/native/rsc/server/canonicalize.js +50 -0
  186. package/dist/native/rsc/server/canonicalize.js.map +1 -0
  187. package/dist/native/rsc/server/chain-url-parts.js +49 -0
  188. package/dist/native/rsc/server/chain-url-parts.js.map +1 -0
  189. package/dist/native/rsc/server/children-interception.js +35 -0
  190. package/dist/native/rsc/server/children-interception.js.map +1 -0
  191. package/dist/native/rsc/server/client-error-message.js +10 -0
  192. package/dist/native/rsc/server/client-error-message.js.map +1 -0
  193. package/dist/native/rsc/server/coalesce-tick.js +33 -0
  194. package/dist/native/rsc/server/coalesce-tick.js.map +1 -0
  195. package/dist/native/rsc/server/cookie-context.js +149 -0
  196. package/dist/native/rsc/server/cookie-context.js.map +1 -0
  197. package/dist/native/rsc/server/cookie-parsing.js +74 -0
  198. package/dist/native/rsc/server/cookie-parsing.js.map +1 -0
  199. package/dist/native/rsc/server/csp-nonce.js +20 -0
  200. package/dist/native/rsc/server/csp-nonce.js.map +1 -0
  201. package/dist/native/rsc/server/csrf.js +108 -0
  202. package/dist/native/rsc/server/csrf.js.map +1 -0
  203. package/dist/native/rsc/server/debug.js +24 -0
  204. package/dist/native/rsc/server/debug.js.map +1 -0
  205. package/dist/native/rsc/server/default-logger.js +52 -0
  206. package/dist/native/rsc/server/default-logger.js.map +1 -0
  207. package/dist/native/rsc/server/default-status-page.js +46 -0
  208. package/dist/native/rsc/server/default-status-page.js.map +1 -0
  209. package/dist/native/rsc/server/deny-boundary.js +159 -0
  210. package/dist/native/rsc/server/deny-boundary.js.map +1 -0
  211. package/dist/native/rsc/server/deny-renderer.js +130 -0
  212. package/dist/native/rsc/server/deny-renderer.js.map +1 -0
  213. package/dist/native/rsc/server/early-hints-sender.js +19 -0
  214. package/dist/native/rsc/server/early-hints-sender.js.map +1 -0
  215. package/dist/native/rsc/server/early-hints.js +43 -0
  216. package/dist/native/rsc/server/early-hints.js.map +1 -0
  217. package/dist/native/rsc/server/error-boundary-wrapper.js +42 -0
  218. package/dist/native/rsc/server/error-boundary-wrapper.js.map +1 -0
  219. package/dist/native/rsc/server/error-formatter.js +75 -0
  220. package/dist/native/rsc/server/error-formatter.js.map +1 -0
  221. package/dist/native/rsc/server/error-response-headers.js +17 -0
  222. package/dist/native/rsc/server/error-response-headers.js.map +1 -0
  223. package/dist/native/rsc/server/fallback-error.js +54 -0
  224. package/dist/native/rsc/server/fallback-error.js.map +1 -0
  225. package/dist/native/rsc/server/flight-injection-state.js +31 -0
  226. package/dist/native/rsc/server/flight-injection-state.js.map +1 -0
  227. package/dist/native/rsc/server/flight-injector-core.js +160 -0
  228. package/dist/native/rsc/server/flight-injector-core.js.map +1 -0
  229. package/dist/native/rsc/server/flight-scripts.js +20 -0
  230. package/dist/native/rsc/server/flight-scripts.js.map +1 -0
  231. package/dist/native/rsc/server/flight-source-node.js +226 -0
  232. package/dist/native/rsc/server/flight-source-node.js.map +1 -0
  233. package/dist/native/rsc/server/flight-source.js +134 -0
  234. package/dist/native/rsc/server/flight-source.js.map +1 -0
  235. package/dist/native/rsc/server/form-data.js +113 -0
  236. package/dist/native/rsc/server/form-data.js.map +1 -0
  237. package/dist/native/rsc/server/form-state-flight.js +26 -0
  238. package/dist/native/rsc/server/form-state-flight.js.map +1 -0
  239. package/dist/native/rsc/server/head-response.js +16 -0
  240. package/dist/native/rsc/server/head-response.js.map +1 -0
  241. package/dist/native/rsc/server/html-injector-core.js +134 -0
  242. package/dist/native/rsc/server/html-injector-core.js.map +1 -0
  243. package/dist/native/rsc/server/html-injectors.js +63 -0
  244. package/dist/native/rsc/server/html-injectors.js.map +1 -0
  245. package/dist/native/rsc/server/index.js +10 -0
  246. package/dist/native/rsc/server/instrumentation.js +47 -0
  247. package/dist/native/rsc/server/instrumentation.js.map +1 -0
  248. package/dist/native/rsc/server/interception-gates.js +35 -0
  249. package/dist/native/rsc/server/interception-gates.js.map +1 -0
  250. package/dist/native/rsc/server/internal.js +27 -0
  251. package/dist/native/rsc/server/json-status-response.js +34 -0
  252. package/dist/native/rsc/server/json-status-response.js.map +1 -0
  253. package/dist/native/rsc/server/logger.js +97 -0
  254. package/dist/native/rsc/server/logger.js.map +1 -0
  255. package/dist/native/rsc/server/metadata-collector.js +59 -0
  256. package/dist/native/rsc/server/metadata-collector.js.map +1 -0
  257. package/dist/native/rsc/server/metadata-platform.js +210 -0
  258. package/dist/native/rsc/server/metadata-platform.js.map +1 -0
  259. package/dist/native/rsc/server/metadata-render.js +135 -0
  260. package/dist/native/rsc/server/metadata-render.js.map +1 -0
  261. package/dist/native/rsc/server/metadata-route-links.js +101 -0
  262. package/dist/native/rsc/server/metadata-route-links.js.map +1 -0
  263. package/dist/native/rsc/server/metadata-routes.js +152 -0
  264. package/dist/native/rsc/server/metadata-routes.js.map +1 -0
  265. package/dist/native/rsc/server/metadata-social.js +192 -0
  266. package/dist/native/rsc/server/metadata-social.js.map +1 -0
  267. package/dist/native/rsc/server/metadata.js +114 -0
  268. package/dist/native/rsc/server/metadata.js.map +1 -0
  269. package/dist/native/rsc/server/middleware-runner.js +14 -0
  270. package/dist/native/rsc/server/middleware-runner.js.map +1 -0
  271. package/dist/native/rsc/server/node-body-response.js +158 -0
  272. package/dist/native/rsc/server/node-body-response.js.map +1 -0
  273. package/dist/native/rsc/server/node-response.js +24 -0
  274. package/dist/native/rsc/server/node-response.js.map +1 -0
  275. package/dist/native/rsc/server/node-streams-platform.js +5 -0
  276. package/dist/native/rsc/server/node-streams-platform.js.map +1 -0
  277. package/dist/native/rsc/server/param-coercion.js +69 -0
  278. package/dist/native/rsc/server/param-coercion.js.map +1 -0
  279. package/dist/native/rsc/server/pipeline-helpers.js +213 -0
  280. package/dist/native/rsc/server/pipeline-helpers.js.map +1 -0
  281. package/dist/native/rsc/server/pipeline-interception.js +102 -0
  282. package/dist/native/rsc/server/pipeline-interception.js.map +1 -0
  283. package/dist/native/rsc/server/pipeline-metadata-route.js +135 -0
  284. package/dist/native/rsc/server/pipeline-metadata-route.js.map +1 -0
  285. package/dist/native/rsc/server/pipeline-metadata.js +46 -0
  286. package/dist/native/rsc/server/pipeline-metadata.js.map +1 -0
  287. package/dist/native/rsc/server/pipeline-outcome.js +142 -0
  288. package/dist/native/rsc/server/pipeline-outcome.js.map +1 -0
  289. package/dist/native/rsc/server/pipeline-phases.js +223 -0
  290. package/dist/native/rsc/server/pipeline-phases.js.map +1 -0
  291. package/dist/native/rsc/server/pipeline.js +143 -0
  292. package/dist/native/rsc/server/pipeline.js.map +1 -0
  293. package/dist/native/rsc/server/prebuilt/cache-key.js +112 -0
  294. package/dist/native/rsc/server/prebuilt/cache-key.js.map +1 -0
  295. package/dist/native/rsc/server/prebuilt/capture-render.js +67 -0
  296. package/dist/native/rsc/server/prebuilt/capture-render.js.map +1 -0
  297. package/dist/native/rsc/server/prebuilt/capture-routes.js +42 -0
  298. package/dist/native/rsc/server/prebuilt/capture-routes.js.map +1 -0
  299. package/dist/native/rsc/server/prebuilt/capture-state.js +64 -0
  300. package/dist/native/rsc/server/prebuilt/capture-state.js.map +1 -0
  301. package/dist/native/rsc/server/prebuilt/dev-store.js +75 -0
  302. package/dist/native/rsc/server/prebuilt/dev-store.js.map +1 -0
  303. package/dist/native/rsc/server/prebuilt/lifetime.js +62 -0
  304. package/dist/native/rsc/server/prebuilt/lifetime.js.map +1 -0
  305. package/dist/native/rsc/server/prebuilt/manifest-tag-index.js +25 -0
  306. package/dist/native/rsc/server/prebuilt/manifest-tag-index.js.map +1 -0
  307. package/dist/native/rsc/server/prebuilt/overlay.js +111 -0
  308. package/dist/native/rsc/server/prebuilt/overlay.js.map +1 -0
  309. package/dist/native/rsc/server/prebuilt/payload-source.js +80 -0
  310. package/dist/native/rsc/server/prebuilt/payload-source.js.map +1 -0
  311. package/dist/native/rsc/server/prebuilt/slots.js +77 -0
  312. package/dist/native/rsc/server/prebuilt/slots.js.map +1 -0
  313. package/dist/native/rsc/server/prebuilt/synthetic-store.js +52 -0
  314. package/dist/native/rsc/server/prebuilt/synthetic-store.js.map +1 -0
  315. package/dist/native/rsc/server/prebuilt-builder.js +265 -0
  316. package/dist/native/rsc/server/prebuilt-builder.js.map +1 -0
  317. package/dist/native/rsc/server/prebuilt-runtime.js +329 -0
  318. package/dist/native/rsc/server/prebuilt-runtime.js.map +1 -0
  319. package/dist/native/rsc/server/primitives.js +130 -0
  320. package/dist/native/rsc/server/primitives.js.map +1 -0
  321. package/dist/native/rsc/server/proxy.js +15 -0
  322. package/dist/native/rsc/server/proxy.js.map +1 -0
  323. package/dist/native/rsc/server/publish-params.js +13 -0
  324. package/dist/native/rsc/server/publish-params.js.map +1 -0
  325. package/dist/native/rsc/server/react-cache-bridge.js +55 -0
  326. package/dist/native/rsc/server/react-cache-bridge.js.map +1 -0
  327. package/dist/native/rsc/server/react-cache-scope.js +38 -0
  328. package/dist/native/rsc/server/react-cache-scope.js.map +1 -0
  329. package/dist/native/rsc/server/render-timeout.js +30 -0
  330. package/dist/native/rsc/server/render-timeout.js.map +1 -0
  331. package/dist/native/rsc/server/render-utils.js +16 -0
  332. package/dist/native/rsc/server/render-utils.js.map +1 -0
  333. package/dist/native/rsc/server/request-context.js +152 -0
  334. package/dist/native/rsc/server/request-context.js.map +1 -0
  335. package/dist/native/rsc/server/request-dep.js +12 -0
  336. package/dist/native/rsc/server/request-dep.js.map +1 -0
  337. package/dist/native/rsc/server/response-cache-policy.js +19 -0
  338. package/dist/native/rsc/server/response-cache-policy.js.map +1 -0
  339. package/dist/native/rsc/server/response-framing.js +20 -0
  340. package/dist/native/rsc/server/response-framing.js.map +1 -0
  341. package/dist/native/rsc/server/route-element-builder.js +215 -0
  342. package/dist/native/rsc/server/route-element-builder.js.map +1 -0
  343. package/dist/native/rsc/server/route-element-helpers.js +20 -0
  344. package/dist/native/rsc/server/route-element-helpers.js.map +1 -0
  345. package/dist/native/rsc/server/route-handler.js +74 -0
  346. package/dist/native/rsc/server/route-handler.js.map +1 -0
  347. package/dist/native/rsc/server/route-matcher.js +119 -0
  348. package/dist/native/rsc/server/route-matcher.js.map +1 -0
  349. package/dist/native/rsc/server/route-methods.js +18 -0
  350. package/dist/native/rsc/server/route-methods.js.map +1 -0
  351. package/dist/native/rsc/server/route-module-loader.js +62 -0
  352. package/dist/native/rsc/server/route-module-loader.js.map +1 -0
  353. package/dist/native/rsc/server/rsc-cache-key-guard.js +29 -0
  354. package/dist/native/rsc/server/rsc-cache-key-guard.js.map +1 -0
  355. package/dist/native/rsc/server/rsc-entry/action-dispatcher.js +39 -0
  356. package/dist/native/rsc/server/rsc-entry/action-dispatcher.js.map +1 -0
  357. package/dist/native/rsc/server/rsc-entry/action-middleware-runner.js +59 -0
  358. package/dist/native/rsc/server/rsc-entry/action-middleware-runner.js.map +1 -0
  359. package/dist/native/rsc/server/rsc-entry/api-handler.js +16 -0
  360. package/dist/native/rsc/server/rsc-entry/api-handler.js.map +1 -0
  361. package/dist/native/rsc/server/rsc-entry/deny-fallback.js +39 -0
  362. package/dist/native/rsc/server/rsc-entry/deny-fallback.js.map +1 -0
  363. package/dist/native/rsc/server/rsc-entry/error-renderer.js +133 -0
  364. package/dist/native/rsc/server/rsc-entry/error-renderer.js.map +1 -0
  365. package/dist/native/rsc/server/rsc-entry/helpers.js +48 -0
  366. package/dist/native/rsc/server/rsc-entry/helpers.js.map +1 -0
  367. package/dist/native/rsc/server/rsc-entry/render-route.js +76 -0
  368. package/dist/native/rsc/server/rsc-entry/render-route.js.map +1 -0
  369. package/dist/native/rsc/server/rsc-entry/render-signals.js +41 -0
  370. package/dist/native/rsc/server/rsc-entry/render-signals.js.map +1 -0
  371. package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js +128 -0
  372. package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js.map +1 -0
  373. package/dist/native/rsc/server/rsc-entry/rsc-payload.js +56 -0
  374. package/dist/native/rsc/server/rsc-entry/rsc-payload.js.map +1 -0
  375. package/dist/native/rsc/server/rsc-entry/rsc-stream.js +73 -0
  376. package/dist/native/rsc/server/rsc-entry/rsc-stream.js.map +1 -0
  377. package/dist/native/rsc/server/rsc-entry/ssr-renderer.js +124 -0
  378. package/dist/native/rsc/server/rsc-entry/ssr-renderer.js.map +1 -0
  379. package/dist/native/rsc/server/rsc-error-envelope.js +18 -0
  380. package/dist/native/rsc/server/rsc-error-envelope.js.map +1 -0
  381. package/dist/native/rsc/server/rsc-prop-warnings.js +83 -0
  382. package/dist/native/rsc/server/rsc-prop-warnings.js.map +1 -0
  383. package/dist/native/rsc/server/safe-load.js +20 -0
  384. package/dist/native/rsc/server/safe-load.js.map +1 -0
  385. package/dist/native/rsc/server/schema-introspection.js +247 -0
  386. package/dist/native/rsc/server/schema-introspection.js.map +1 -0
  387. package/dist/native/rsc/server/sensitive-fields.js +103 -0
  388. package/dist/native/rsc/server/sensitive-fields.js.map +1 -0
  389. package/dist/native/rsc/server/server-only-guard-noop.js +1 -0
  390. package/dist/native/rsc/server/server-timing.js +57 -0
  391. package/dist/native/rsc/server/server-timing.js.map +1 -0
  392. package/dist/native/rsc/server/signal-identity.js +41 -0
  393. package/dist/native/rsc/server/signal-identity.js.map +1 -0
  394. package/dist/native/rsc/server/sitemap-generator.js +117 -0
  395. package/dist/native/rsc/server/sitemap-generator.js.map +1 -0
  396. package/dist/native/rsc/server/sitemap-handler.js +73 -0
  397. package/dist/native/rsc/server/sitemap-handler.js.map +1 -0
  398. package/dist/native/rsc/server/skippable-prefix.js +72 -0
  399. package/dist/native/rsc/server/skippable-prefix.js.map +1 -0
  400. package/dist/native/rsc/server/slot-interception.js +46 -0
  401. package/dist/native/rsc/server/slot-interception.js.map +1 -0
  402. package/dist/native/rsc/server/slot-resolver.js +283 -0
  403. package/dist/native/rsc/server/slot-resolver.js.map +1 -0
  404. package/dist/native/rsc/server/slot-subtree-contain.js +112 -0
  405. package/dist/native/rsc/server/slot-subtree-contain.js.map +1 -0
  406. package/dist/native/rsc/server/state-tree-diff.js +35 -0
  407. package/dist/native/rsc/server/state-tree-diff.js.map +1 -0
  408. package/dist/native/rsc/server/static-generator.js +375 -0
  409. package/dist/native/rsc/server/static-generator.js.map +1 -0
  410. package/dist/native/rsc/server/static-not-found.js +32 -0
  411. package/dist/native/rsc/server/static-not-found.js.map +1 -0
  412. package/dist/native/rsc/server/status-code-resolver.js +86 -0
  413. package/dist/native/rsc/server/status-code-resolver.js.map +1 -0
  414. package/dist/native/rsc/server/stream-utils.js +197 -0
  415. package/dist/native/rsc/server/stream-utils.js.map +1 -0
  416. package/dist/native/rsc/server/traced-access.js +29 -0
  417. package/dist/native/rsc/server/traced-access.js.map +1 -0
  418. package/dist/native/rsc/server/tracing.js +143 -0
  419. package/dist/native/rsc/server/tracing.js.map +1 -0
  420. package/dist/native/rsc/server/tree-match.js +205 -0
  421. package/dist/native/rsc/server/tree-match.js.map +1 -0
  422. package/dist/native/rsc/server/utils/element-type.js +31 -0
  423. package/dist/native/rsc/server/utils/element-type.js.map +1 -0
  424. package/dist/native/rsc/server/utils/escape-html.js +7 -0
  425. package/dist/native/rsc/server/utils/escape-html.js.map +1 -0
  426. package/dist/native/rsc/server/version-skew.js +36 -0
  427. package/dist/native/rsc/server/version-skew.js.map +1 -0
  428. package/dist/native/rsc/server/vite-handoff-rsc.js +42 -0
  429. package/dist/native/rsc/server/vite-handoff-rsc.js.map +1 -0
  430. package/dist/native/rsc/server/waituntil-bridge.js +11 -0
  431. package/dist/native/rsc/server/waituntil-bridge.js.map +1 -0
  432. package/dist/native/rsc/server/workers-cache-bridge.js +11 -0
  433. package/dist/native/rsc/server/workers-cache-bridge.js.map +1 -0
  434. package/dist/native/rsc/shared/als-slots.js +22 -0
  435. package/dist/native/rsc/shared/als-slots.js.map +1 -0
  436. package/dist/native/rsc/shared/base-path.js +15 -0
  437. package/dist/native/rsc/shared/base-path.js.map +1 -0
  438. package/dist/native/rsc/shared/csrf-reject.js +6 -0
  439. package/dist/native/rsc/shared/csrf-reject.js.map +1 -0
  440. package/dist/native/rsc/shared/dev-span.js +109 -0
  441. package/dist/native/rsc/shared/dev-span.js.map +1 -0
  442. package/dist/native/rsc/shared/error-digest.js +25 -0
  443. package/dist/native/rsc/shared/error-digest.js.map +1 -0
  444. package/dist/native/rsc/shared/flight-base64.js +15 -0
  445. package/dist/native/rsc/shared/flight-base64.js.map +1 -0
  446. package/dist/native/rsc/shared/href-validation.js +40 -0
  447. package/dist/native/rsc/shared/href-validation.js.map +1 -0
  448. package/dist/native/rsc/shared/href.js +83 -0
  449. package/dist/native/rsc/shared/href.js.map +1 -0
  450. package/dist/native/rsc/shared/merge-search-params.js +20 -0
  451. package/dist/native/rsc/shared/merge-search-params.js.map +1 -0
  452. package/dist/native/rsc/shared/param-value.js +81 -0
  453. package/dist/native/rsc/shared/param-value.js.map +1 -0
  454. package/dist/native/rsc/shared/redirect-type.js +8 -0
  455. package/dist/native/rsc/shared/redirect-type.js.map +1 -0
  456. package/dist/native/rsc/shared/rsc-cache-key.js +56 -0
  457. package/dist/native/rsc/shared/rsc-cache-key.js.map +1 -0
  458. package/dist/native/rsc/shared/rsc-error-envelope.js +5 -0
  459. package/dist/native/rsc/shared/rsc-error-envelope.js.map +1 -0
  460. package/dist/native/rsc/shared/rsc-media-type.js +12 -0
  461. package/dist/native/rsc/shared/rsc-media-type.js.map +1 -0
  462. package/dist/native/rsc/shared/slot-params.js +29 -0
  463. package/dist/native/rsc/shared/slot-params.js.map +1 -0
  464. package/dist/native/rsc/shared/static-platform-files.js +8 -0
  465. package/dist/native/rsc/shared/static-platform-files.js.map +1 -0
  466. package/dist/native/rsc/shared/status-reason-phrase.js +35 -0
  467. package/dist/native/rsc/shared/status-reason-phrase.js.map +1 -0
  468. package/dist/native/rsc/shims/headers.js +64 -0
  469. package/dist/native/rsc/shims/headers.js.map +1 -0
  470. package/dist/native/rsc/shims/image.js +9 -0
  471. package/dist/native/rsc/shims/image.js.map +1 -0
  472. package/dist/native/rsc/shims/navigation-rsc.js +21 -0
  473. package/dist/native/rsc/shims/navigation-rsc.js.map +1 -0
  474. package/dist/native/rsc/utils/format.js +9 -0
  475. package/dist/native/rsc/utils/format.js.map +1 -0
  476. package/dist/native/rsc/utils/state-machine.js +28 -0
  477. package/dist/native/rsc/utils/state-machine.js.map +1 -0
  478. package/dist/native/ssr/_virtual/_rolldown/runtime.js +2 -0
  479. package/dist/native/ssr/adapters/build-output-helper.js +142 -0
  480. package/dist/native/ssr/adapters/build-output-helper.js.map +1 -0
  481. package/dist/native/ssr/adapters/cloudflare-kv-cache.js +96 -0
  482. package/dist/native/ssr/adapters/cloudflare-kv-cache.js.map +1 -0
  483. package/dist/native/ssr/adapters/cloudflare.js +410 -0
  484. package/dist/native/ssr/adapters/cloudflare.js.map +1 -0
  485. package/dist/native/ssr/adapters/fs-identity.js +54 -0
  486. package/dist/native/ssr/adapters/fs-identity.js.map +1 -0
  487. package/dist/native/ssr/adapters/shared.js +99 -0
  488. package/dist/native/ssr/adapters/shared.js.map +1 -0
  489. package/dist/native/ssr/cache/cache-api.js +43 -0
  490. package/dist/native/ssr/cache/cache-api.js.map +1 -0
  491. package/dist/native/ssr/cache/fast-hash.js +15 -0
  492. package/dist/native/ssr/cache/fast-hash.js.map +1 -0
  493. package/dist/native/ssr/cache/guarded-read.js +18 -0
  494. package/dist/native/ssr/cache/guarded-read.js.map +1 -0
  495. package/dist/native/ssr/cache/handler-store.js +53 -0
  496. package/dist/native/ssr/cache/handler-store.js.map +1 -0
  497. package/dist/native/ssr/cache/index.js +86 -0
  498. package/dist/native/ssr/cache/index.js.map +1 -0
  499. package/dist/native/ssr/cache/invalidation-epoch.js +43 -0
  500. package/dist/native/ssr/cache/invalidation-epoch.js.map +1 -0
  501. package/dist/native/ssr/cache/json-lossy-check.js +58 -0
  502. package/dist/native/ssr/cache/json-lossy-check.js.map +1 -0
  503. package/dist/native/ssr/cache/key-discipline.js +90 -0
  504. package/dist/native/ssr/cache/key-discipline.js.map +1 -0
  505. package/dist/native/ssr/cache/redis-handler.js +109 -0
  506. package/dist/native/ssr/cache/redis-handler.js.map +1 -0
  507. package/dist/native/ssr/cache/singleflight.js +49 -0
  508. package/dist/native/ssr/cache/singleflight.js.map +1 -0
  509. package/dist/native/ssr/cache/sizeof.js +15 -0
  510. package/dist/native/ssr/cache/sizeof.js.map +1 -0
  511. package/dist/native/ssr/cache/stable-stringify.js +53 -0
  512. package/dist/native/ssr/cache/stable-stringify.js.map +1 -0
  513. package/dist/native/ssr/cache/stores/cloudflare-kv.js +24 -0
  514. package/dist/native/ssr/cache/stores/cloudflare-kv.js.map +1 -0
  515. package/dist/native/ssr/cache/stores/memory.js +90 -0
  516. package/dist/native/ssr/cache/stores/memory.js.map +1 -0
  517. package/dist/native/ssr/cache/stores/redis.js +35 -0
  518. package/dist/native/ssr/cache/stores/redis.js.map +1 -0
  519. package/dist/native/ssr/cache/stores/vercel.js +33 -0
  520. package/dist/native/ssr/cache/stores/vercel.js.map +1 -0
  521. package/dist/native/ssr/cache/tag-aware-handler.js +147 -0
  522. package/dist/native/ssr/cache/tag-aware-handler.js.map +1 -0
  523. package/dist/native/ssr/cache/timber-cache.js +107 -0
  524. package/dist/native/ssr/cache/timber-cache.js.map +1 -0
  525. package/dist/native/ssr/cdn/cloudflare-purge.js +30 -0
  526. package/dist/native/ssr/cdn/cloudflare-purge.js.map +1 -0
  527. package/dist/native/ssr/cdn/fastly-purge.js +33 -0
  528. package/dist/native/ssr/cdn/fastly-purge.js.map +1 -0
  529. package/dist/native/ssr/cdn/headers.js +41 -0
  530. package/dist/native/ssr/cdn/headers.js.map +1 -0
  531. package/dist/native/ssr/cdn/index.js +4 -0
  532. package/dist/native/ssr/cdn/purge-store.js +11 -0
  533. package/dist/native/ssr/cdn/purge-store.js.map +1 -0
  534. package/dist/native/ssr/cdn/workers-cache-purge.js +14 -0
  535. package/dist/native/ssr/cdn/workers-cache-purge.js.map +1 -0
  536. package/dist/native/ssr/client/deny-last-resort.js +65 -0
  537. package/dist/native/ssr/client/deny-last-resort.js.map +1 -0
  538. package/dist/native/ssr/client/error-boundary.js +160 -0
  539. package/dist/native/ssr/client/error-boundary.js.map +1 -0
  540. package/dist/native/ssr/client/error-reconstituter.js +22 -0
  541. package/dist/native/ssr/client/error-reconstituter.js.map +1 -0
  542. package/dist/native/ssr/client/form.js +26 -0
  543. package/dist/native/ssr/client/form.js.map +1 -0
  544. package/dist/native/ssr/client/global-context.js +20 -0
  545. package/dist/native/ssr/client/global-context.js.map +1 -0
  546. package/dist/native/ssr/client/index.js +16 -0
  547. package/dist/native/ssr/client/link.js +121 -0
  548. package/dist/native/ssr/client/link.js.map +1 -0
  549. package/dist/native/ssr/client/location-search.js +8 -0
  550. package/dist/native/ssr/client/location-search.js.map +1 -0
  551. package/dist/native/ssr/client/navigation-api.js +19 -0
  552. package/dist/native/ssr/client/navigation-api.js.map +1 -0
  553. package/dist/native/ssr/client/navigation-commit.js +21 -0
  554. package/dist/native/ssr/client/navigation-commit.js.map +1 -0
  555. package/dist/native/ssr/client/navigation-context.js +17 -0
  556. package/dist/native/ssr/client/navigation-context.js.map +1 -0
  557. package/dist/native/ssr/client/navigation-root.js +18 -0
  558. package/dist/native/ssr/client/navigation-root.js.map +1 -0
  559. package/dist/native/ssr/client/navigation-transition.js +7 -0
  560. package/dist/native/ssr/client/navigation-transition.js.map +1 -0
  561. package/dist/native/ssr/client/nuqs-adapter.js +99 -0
  562. package/dist/native/ssr/client/nuqs-adapter.js.map +1 -0
  563. package/dist/native/ssr/client/params-context.js +32 -0
  564. package/dist/native/ssr/client/params-context.js.map +1 -0
  565. package/dist/native/ssr/client/router-effects.js +25 -0
  566. package/dist/native/ssr/client/router-effects.js.map +1 -0
  567. package/dist/native/ssr/client/router-ref.js +11 -0
  568. package/dist/native/ssr/client/router-ref.js.map +1 -0
  569. package/dist/native/ssr/client/router-skew.js +13 -0
  570. package/dist/native/ssr/client/router-skew.js.map +1 -0
  571. package/dist/native/ssr/client/router-url.js +8 -0
  572. package/dist/native/ssr/client/router-url.js.map +1 -0
  573. package/dist/native/ssr/client/rsc-fetch.js +88 -0
  574. package/dist/native/ssr/client/rsc-fetch.js.map +1 -0
  575. package/dist/native/ssr/client/segment-cache.js +119 -0
  576. package/dist/native/ssr/client/segment-cache.js.map +1 -0
  577. package/dist/native/ssr/client/segment-context.js +18 -0
  578. package/dist/native/ssr/client/segment-context.js.map +1 -0
  579. package/dist/native/ssr/client/segment-outlet.js +26 -0
  580. package/dist/native/ssr/client/segment-outlet.js.map +1 -0
  581. package/dist/native/ssr/client/segment-update-context.js +9 -0
  582. package/dist/native/ssr/client/segment-update-context.js.map +1 -0
  583. package/dist/native/ssr/client/shallow-url.js +13 -0
  584. package/dist/native/ssr/client/shallow-url.js.map +1 -0
  585. package/dist/native/ssr/client/slot-content-cache-context.js +8 -0
  586. package/dist/native/ssr/client/slot-content-cache-context.js.map +1 -0
  587. package/dist/native/ssr/client/slot-context.js +8 -0
  588. package/dist/native/ssr/client/slot-context.js.map +1 -0
  589. package/dist/native/ssr/client/slot-error-fallback.js +9 -0
  590. package/dist/native/ssr/client/slot-error-fallback.js.map +1 -0
  591. package/dist/native/ssr/client/slot-outlet.js +12 -0
  592. package/dist/native/ssr/client/slot-outlet.js.map +1 -0
  593. package/dist/native/ssr/client/slot-provider.js +16 -0
  594. package/dist/native/ssr/client/slot-provider.js.map +1 -0
  595. package/dist/native/ssr/client/ssr-data.js +11 -0
  596. package/dist/native/ssr/client/ssr-data.js.map +1 -0
  597. package/dist/native/ssr/client/stale-client.js +37 -0
  598. package/dist/native/ssr/client/stale-client.js.map +1 -0
  599. package/dist/native/ssr/client/state.js +30 -0
  600. package/dist/native/ssr/client/state.js.map +1 -0
  601. package/dist/native/ssr/client/status-page-marker.js +14 -0
  602. package/dist/native/ssr/client/status-page-marker.js.map +1 -0
  603. package/dist/native/ssr/client/top-loader.js +77 -0
  604. package/dist/native/ssr/client/top-loader.js.map +1 -0
  605. package/dist/native/ssr/client/unload-guard.js +27 -0
  606. package/dist/native/ssr/client/unload-guard.js.map +1 -0
  607. package/dist/native/ssr/client/use-cookie.js +81 -0
  608. package/dist/native/ssr/client/use-cookie.js.map +1 -0
  609. package/dist/native/ssr/client/use-field-state.js +59 -0
  610. package/dist/native/ssr/client/use-field-state.js.map +1 -0
  611. package/dist/native/ssr/client/use-link-status.js +11 -0
  612. package/dist/native/ssr/client/use-link-status.js.map +1 -0
  613. package/dist/native/ssr/client/use-pathname.js +10 -0
  614. package/dist/native/ssr/client/use-pathname.js.map +1 -0
  615. package/dist/native/ssr/client/use-pending-navigation.js +52 -0
  616. package/dist/native/ssr/client/use-pending-navigation.js.map +1 -0
  617. package/dist/native/ssr/client/use-query-states.js +123 -0
  618. package/dist/native/ssr/client/use-query-states.js.map +1 -0
  619. package/dist/native/ssr/client/use-router.js +54 -0
  620. package/dist/native/ssr/client/use-router.js.map +1 -0
  621. package/dist/native/ssr/client/use-search-params.js +21 -0
  622. package/dist/native/ssr/client/use-search-params.js.map +1 -0
  623. package/dist/native/ssr/client/use-segment-params.js +11 -0
  624. package/dist/native/ssr/client/use-segment-params.js.map +1 -0
  625. package/dist/native/ssr/client/use-selected-layout-segment.js +32 -0
  626. package/dist/native/ssr/client/use-selected-layout-segment.js.map +1 -0
  627. package/dist/native/ssr/codec.js +76 -0
  628. package/dist/native/ssr/codec.js.map +1 -0
  629. package/dist/native/ssr/cookies/define-cookie.js +82 -0
  630. package/dist/native/ssr/cookies/define-cookie.js.map +1 -0
  631. package/dist/native/ssr/cookies/index.js +4 -0
  632. package/dist/native/ssr/cookies/json-cookie.js +26 -0
  633. package/dist/native/ssr/cookies/json-cookie.js.map +1 -0
  634. package/dist/native/ssr/cookies/validation.js +42 -0
  635. package/dist/native/ssr/cookies/validation.js.map +1 -0
  636. package/dist/native/ssr/dev-tools/await-span.js +28 -0
  637. package/dist/native/ssr/dev-tools/await-span.js.map +1 -0
  638. package/dist/native/ssr/dev-tools/instrumentation.js +117 -0
  639. package/dist/native/ssr/dev-tools/instrumentation.js.map +1 -0
  640. package/dist/native/ssr/dev-tools/logger.js +195 -0
  641. package/dist/native/ssr/dev-tools/logger.js.map +1 -0
  642. package/dist/native/ssr/dev-tools/span-sink.js +39 -0
  643. package/dist/native/ssr/dev-tools/span-sink.js.map +1 -0
  644. package/dist/native/ssr/manifest.json +236 -0
  645. package/dist/native/ssr/params/codec-registry.js +14 -0
  646. package/dist/native/ssr/params/codec-registry.js.map +1 -0
  647. package/dist/native/ssr/params/define-schema.js +7 -0
  648. package/dist/native/ssr/params/define-schema.js.map +1 -0
  649. package/dist/native/ssr/params/index.js +4 -0
  650. package/dist/native/ssr/params/resolve-schema.js +29 -0
  651. package/dist/native/ssr/params/resolve-schema.js.map +1 -0
  652. package/dist/native/ssr/routes/href.js +8 -0
  653. package/dist/native/ssr/routes/href.js.map +1 -0
  654. package/dist/native/ssr/routes/index.js +2 -0
  655. package/dist/native/ssr/routing/segment-classify.js +103 -0
  656. package/dist/native/ssr/routing/segment-classify.js.map +1 -0
  657. package/dist/native/ssr/routing/segment-keys.js +22 -0
  658. package/dist/native/ssr/routing/segment-keys.js.map +1 -0
  659. package/dist/native/ssr/routing/types.js +10 -0
  660. package/dist/native/ssr/routing/types.js.map +1 -0
  661. package/dist/native/ssr/rsc-runtime/dev-reference-cache.js +49 -0
  662. package/dist/native/ssr/rsc-runtime/dev-reference-cache.js.map +1 -0
  663. package/dist/native/ssr/schema-bridge.js +106 -0
  664. package/dist/native/ssr/schema-bridge.js.map +1 -0
  665. package/dist/native/ssr/search-params/define.js +146 -0
  666. package/dist/native/ssr/search-params/define.js.map +1 -0
  667. package/dist/native/ssr/search-params/index.js +5 -0
  668. package/dist/native/ssr/search-params/parse-total.js +10 -0
  669. package/dist/native/ssr/search-params/parse-total.js.map +1 -0
  670. package/dist/native/ssr/search-params/serialize-equal.js +9 -0
  671. package/dist/native/ssr/search-params/serialize-equal.js.map +1 -0
  672. package/dist/native/ssr/search-params/wrappers.js +29 -0
  673. package/dist/native/ssr/search-params/wrappers.js.map +1 -0
  674. package/dist/native/ssr/server/abort-scope.js +23 -0
  675. package/dist/native/ssr/server/abort-scope.js.map +1 -0
  676. package/dist/native/ssr/server/access-gate.js +55 -0
  677. package/dist/native/ssr/server/access-gate.js.map +1 -0
  678. package/dist/native/ssr/server/action-client.js +153 -0
  679. package/dist/native/ssr/server/action-client.js.map +1 -0
  680. package/dist/native/ssr/server/action-schema.js +66 -0
  681. package/dist/native/ssr/server/action-schema.js.map +1 -0
  682. package/dist/native/ssr/server/actions.js +98 -0
  683. package/dist/native/ssr/server/actions.js.map +1 -0
  684. package/dist/native/ssr/server/als-registry.js +23 -0
  685. package/dist/native/ssr/server/als-registry.js.map +1 -0
  686. package/dist/native/ssr/server/body-limits.js +48 -0
  687. package/dist/native/ssr/server/body-limits.js.map +1 -0
  688. package/dist/native/ssr/server/build-manifest.js +45 -0
  689. package/dist/native/ssr/server/build-manifest.js.map +1 -0
  690. package/dist/native/ssr/server/canonicalize.js +50 -0
  691. package/dist/native/ssr/server/canonicalize.js.map +1 -0
  692. package/dist/native/ssr/server/coalesce-tick.js +33 -0
  693. package/dist/native/ssr/server/coalesce-tick.js.map +1 -0
  694. package/dist/native/ssr/server/cookie-context.js +143 -0
  695. package/dist/native/ssr/server/cookie-context.js.map +1 -0
  696. package/dist/native/ssr/server/cookie-parsing.js +74 -0
  697. package/dist/native/ssr/server/cookie-parsing.js.map +1 -0
  698. package/dist/native/ssr/server/csp-nonce.js +17 -0
  699. package/dist/native/ssr/server/csp-nonce.js.map +1 -0
  700. package/dist/native/ssr/server/csrf.js +108 -0
  701. package/dist/native/ssr/server/csrf.js.map +1 -0
  702. package/dist/native/ssr/server/debug.js +19 -0
  703. package/dist/native/ssr/server/debug.js.map +1 -0
  704. package/dist/native/ssr/server/default-logger.js +52 -0
  705. package/dist/native/ssr/server/default-logger.js.map +1 -0
  706. package/dist/native/ssr/server/deny-boundary.js +93 -0
  707. package/dist/native/ssr/server/deny-boundary.js.map +1 -0
  708. package/dist/native/ssr/server/early-hints-sender.js +19 -0
  709. package/dist/native/ssr/server/early-hints-sender.js.map +1 -0
  710. package/dist/native/ssr/server/early-hints.js +43 -0
  711. package/dist/native/ssr/server/early-hints.js.map +1 -0
  712. package/dist/native/ssr/server/error-formatter.js +75 -0
  713. package/dist/native/ssr/server/error-formatter.js.map +1 -0
  714. package/dist/native/ssr/server/error-response-headers.js +17 -0
  715. package/dist/native/ssr/server/error-response-headers.js.map +1 -0
  716. package/dist/native/ssr/server/flight-injection-state.js +31 -0
  717. package/dist/native/ssr/server/flight-injection-state.js.map +1 -0
  718. package/dist/native/ssr/server/flight-injector-core.js +160 -0
  719. package/dist/native/ssr/server/flight-injector-core.js.map +1 -0
  720. package/dist/native/ssr/server/flight-scripts.js +20 -0
  721. package/dist/native/ssr/server/flight-scripts.js.map +1 -0
  722. package/dist/native/ssr/server/flight-source-node.js +226 -0
  723. package/dist/native/ssr/server/flight-source-node.js.map +1 -0
  724. package/dist/native/ssr/server/flight-source.js +55 -0
  725. package/dist/native/ssr/server/flight-source.js.map +1 -0
  726. package/dist/native/ssr/server/form-data.js +113 -0
  727. package/dist/native/ssr/server/form-data.js.map +1 -0
  728. package/dist/native/ssr/server/head-response.js +16 -0
  729. package/dist/native/ssr/server/head-response.js.map +1 -0
  730. package/dist/native/ssr/server/html-injector-core.js +134 -0
  731. package/dist/native/ssr/server/html-injector-core.js.map +1 -0
  732. package/dist/native/ssr/server/html-injectors.js +117 -0
  733. package/dist/native/ssr/server/html-injectors.js.map +1 -0
  734. package/dist/native/ssr/server/index.js +10 -0
  735. package/dist/native/ssr/server/instrumentation.js +47 -0
  736. package/dist/native/ssr/server/instrumentation.js.map +1 -0
  737. package/dist/native/ssr/server/internal.js +27 -0
  738. package/dist/native/ssr/server/logger.js +93 -0
  739. package/dist/native/ssr/server/logger.js.map +1 -0
  740. package/dist/native/ssr/server/metadata-platform.js +210 -0
  741. package/dist/native/ssr/server/metadata-platform.js.map +1 -0
  742. package/dist/native/ssr/server/metadata-render.js +135 -0
  743. package/dist/native/ssr/server/metadata-render.js.map +1 -0
  744. package/dist/native/ssr/server/metadata-routes.js +152 -0
  745. package/dist/native/ssr/server/metadata-routes.js.map +1 -0
  746. package/dist/native/ssr/server/metadata-social.js +192 -0
  747. package/dist/native/ssr/server/metadata-social.js.map +1 -0
  748. package/dist/native/ssr/server/metadata.js +101 -0
  749. package/dist/native/ssr/server/metadata.js.map +1 -0
  750. package/dist/native/ssr/server/middleware-runner.js +14 -0
  751. package/dist/native/ssr/server/middleware-runner.js.map +1 -0
  752. package/dist/native/ssr/server/node-body-response.js +159 -0
  753. package/dist/native/ssr/server/node-body-response.js.map +1 -0
  754. package/dist/native/ssr/server/node-response.js +24 -0
  755. package/dist/native/ssr/server/node-response.js.map +1 -0
  756. package/dist/native/ssr/server/node-stream-transforms.js +166 -0
  757. package/dist/native/ssr/server/node-stream-transforms.js.map +1 -0
  758. package/dist/native/ssr/server/node-streams-platform.js +5 -0
  759. package/dist/native/ssr/server/node-streams-platform.js.map +1 -0
  760. package/dist/native/ssr/server/param-coercion.js +43 -0
  761. package/dist/native/ssr/server/param-coercion.js.map +1 -0
  762. package/dist/native/ssr/server/pipeline-helpers.js +203 -0
  763. package/dist/native/ssr/server/pipeline-helpers.js.map +1 -0
  764. package/dist/native/ssr/server/pipeline-interception.js +102 -0
  765. package/dist/native/ssr/server/pipeline-interception.js.map +1 -0
  766. package/dist/native/ssr/server/pipeline-metadata-route.js +135 -0
  767. package/dist/native/ssr/server/pipeline-metadata-route.js.map +1 -0
  768. package/dist/native/ssr/server/pipeline-metadata.js +43 -0
  769. package/dist/native/ssr/server/pipeline-metadata.js.map +1 -0
  770. package/dist/native/ssr/server/pipeline-outcome.js +142 -0
  771. package/dist/native/ssr/server/pipeline-outcome.js.map +1 -0
  772. package/dist/native/ssr/server/pipeline-phases.js +223 -0
  773. package/dist/native/ssr/server/pipeline-phases.js.map +1 -0
  774. package/dist/native/ssr/server/pipeline.js +143 -0
  775. package/dist/native/ssr/server/pipeline.js.map +1 -0
  776. package/dist/native/ssr/server/prebuilt/cache-key.js +112 -0
  777. package/dist/native/ssr/server/prebuilt/cache-key.js.map +1 -0
  778. package/dist/native/ssr/server/prebuilt/capture-render.js +60 -0
  779. package/dist/native/ssr/server/prebuilt/capture-render.js.map +1 -0
  780. package/dist/native/ssr/server/prebuilt/capture-state.js +64 -0
  781. package/dist/native/ssr/server/prebuilt/capture-state.js.map +1 -0
  782. package/dist/native/ssr/server/prebuilt/dev-store.js +68 -0
  783. package/dist/native/ssr/server/prebuilt/dev-store.js.map +1 -0
  784. package/dist/native/ssr/server/prebuilt/lifetime.js +62 -0
  785. package/dist/native/ssr/server/prebuilt/lifetime.js.map +1 -0
  786. package/dist/native/ssr/server/prebuilt/manifest-tag-index.js +25 -0
  787. package/dist/native/ssr/server/prebuilt/manifest-tag-index.js.map +1 -0
  788. package/dist/native/ssr/server/prebuilt/overlay.js +111 -0
  789. package/dist/native/ssr/server/prebuilt/overlay.js.map +1 -0
  790. package/dist/native/ssr/server/prebuilt/payload-source.js +80 -0
  791. package/dist/native/ssr/server/prebuilt/payload-source.js.map +1 -0
  792. package/dist/native/ssr/server/prebuilt/slots.js +77 -0
  793. package/dist/native/ssr/server/prebuilt/slots.js.map +1 -0
  794. package/dist/native/ssr/server/prebuilt/synthetic-store.js +52 -0
  795. package/dist/native/ssr/server/prebuilt/synthetic-store.js.map +1 -0
  796. package/dist/native/ssr/server/prebuilt-runtime.js +326 -0
  797. package/dist/native/ssr/server/prebuilt-runtime.js.map +1 -0
  798. package/dist/native/ssr/server/primitives.js +130 -0
  799. package/dist/native/ssr/server/primitives.js.map +1 -0
  800. package/dist/native/ssr/server/proxy.js +15 -0
  801. package/dist/native/ssr/server/proxy.js.map +1 -0
  802. package/dist/native/ssr/server/react-cache-scope.js +38 -0
  803. package/dist/native/ssr/server/react-cache-scope.js.map +1 -0
  804. package/dist/native/ssr/server/render-timeout.js +47 -0
  805. package/dist/native/ssr/server/render-timeout.js.map +1 -0
  806. package/dist/native/ssr/server/render-utils.js +19 -0
  807. package/dist/native/ssr/server/render-utils.js.map +1 -0
  808. package/dist/native/ssr/server/request-context.js +127 -0
  809. package/dist/native/ssr/server/request-context.js.map +1 -0
  810. package/dist/native/ssr/server/response-cache-policy.js +19 -0
  811. package/dist/native/ssr/server/response-cache-policy.js.map +1 -0
  812. package/dist/native/ssr/server/response-framing.js +20 -0
  813. package/dist/native/ssr/server/response-framing.js.map +1 -0
  814. package/dist/native/ssr/server/route-handler.js +74 -0
  815. package/dist/native/ssr/server/route-handler.js.map +1 -0
  816. package/dist/native/ssr/server/route-matcher.js +101 -0
  817. package/dist/native/ssr/server/route-matcher.js.map +1 -0
  818. package/dist/native/ssr/server/route-methods.js +18 -0
  819. package/dist/native/ssr/server/route-methods.js.map +1 -0
  820. package/dist/native/ssr/server/rsc-cache-key-guard.js +29 -0
  821. package/dist/native/ssr/server/rsc-cache-key-guard.js.map +1 -0
  822. package/dist/native/ssr/server/rsc-error-envelope.js +18 -0
  823. package/dist/native/ssr/server/rsc-error-envelope.js.map +1 -0
  824. package/dist/native/ssr/server/safe-load.js +20 -0
  825. package/dist/native/ssr/server/safe-load.js.map +1 -0
  826. package/dist/native/ssr/server/schema-introspection.js +247 -0
  827. package/dist/native/ssr/server/schema-introspection.js.map +1 -0
  828. package/dist/native/ssr/server/sensitive-fields.js +96 -0
  829. package/dist/native/ssr/server/sensitive-fields.js.map +1 -0
  830. package/dist/native/ssr/server/server-only-guard-noop.js +1 -0
  831. package/dist/native/ssr/server/server-timing.js +52 -0
  832. package/dist/native/ssr/server/server-timing.js.map +1 -0
  833. package/dist/native/ssr/server/signal-identity.js +50 -0
  834. package/dist/native/ssr/server/signal-identity.js.map +1 -0
  835. package/dist/native/ssr/server/ssr-form-state.js +25 -0
  836. package/dist/native/ssr/server/ssr-form-state.js.map +1 -0
  837. package/dist/native/ssr/server/ssr-render.js +179 -0
  838. package/dist/native/ssr/server/ssr-render.js.map +1 -0
  839. package/dist/native/ssr/server/ssr-wrappers.js +26 -0
  840. package/dist/native/ssr/server/ssr-wrappers.js.map +1 -0
  841. package/dist/native/ssr/server/state-tree-diff.js +23 -0
  842. package/dist/native/ssr/server/state-tree-diff.js.map +1 -0
  843. package/dist/native/ssr/server/status-code-resolver.js +86 -0
  844. package/dist/native/ssr/server/status-code-resolver.js.map +1 -0
  845. package/dist/native/ssr/server/stream-utils.js +190 -0
  846. package/dist/native/ssr/server/stream-utils.js.map +1 -0
  847. package/dist/native/ssr/server/traced-access.js +29 -0
  848. package/dist/native/ssr/server/traced-access.js.map +1 -0
  849. package/dist/native/ssr/server/tracing.js +129 -0
  850. package/dist/native/ssr/server/tracing.js.map +1 -0
  851. package/dist/native/ssr/server/tree-match.js +205 -0
  852. package/dist/native/ssr/server/tree-match.js.map +1 -0
  853. package/dist/native/ssr/server/utils/element-type.js +19 -0
  854. package/dist/native/ssr/server/utils/element-type.js.map +1 -0
  855. package/dist/native/ssr/server/version-skew.js +19 -0
  856. package/dist/native/ssr/server/version-skew.js.map +1 -0
  857. package/dist/native/ssr/server/vite-handoff-rsc.js +23 -0
  858. package/dist/native/ssr/server/vite-handoff-rsc.js.map +1 -0
  859. package/dist/native/ssr/server/waituntil-bridge.js +7 -0
  860. package/dist/native/ssr/server/waituntil-bridge.js.map +1 -0
  861. package/dist/native/ssr/server/workers-cache-bridge.js +7 -0
  862. package/dist/native/ssr/server/workers-cache-bridge.js.map +1 -0
  863. package/dist/native/ssr/shared/als-slots.js +22 -0
  864. package/dist/native/ssr/shared/als-slots.js.map +1 -0
  865. package/dist/native/ssr/shared/base-path.js +27 -0
  866. package/dist/native/ssr/shared/base-path.js.map +1 -0
  867. package/dist/native/ssr/shared/csrf-reject.js +6 -0
  868. package/dist/native/ssr/shared/csrf-reject.js.map +1 -0
  869. package/dist/native/ssr/shared/dev-span.js +109 -0
  870. package/dist/native/ssr/shared/dev-span.js.map +1 -0
  871. package/dist/native/ssr/shared/error-digest.js +17 -0
  872. package/dist/native/ssr/shared/error-digest.js.map +1 -0
  873. package/dist/native/ssr/shared/flight-base64.js +9 -0
  874. package/dist/native/ssr/shared/flight-base64.js.map +1 -0
  875. package/dist/native/ssr/shared/form-state-flight.js +19 -0
  876. package/dist/native/ssr/shared/form-state-flight.js.map +1 -0
  877. package/dist/native/ssr/shared/href-validation.js +47 -0
  878. package/dist/native/ssr/shared/href-validation.js.map +1 -0
  879. package/dist/native/ssr/shared/href.js +83 -0
  880. package/dist/native/ssr/shared/href.js.map +1 -0
  881. package/dist/native/ssr/shared/merge-search-params.js +20 -0
  882. package/dist/native/ssr/shared/merge-search-params.js.map +1 -0
  883. package/dist/native/ssr/shared/param-value.js +81 -0
  884. package/dist/native/ssr/shared/param-value.js.map +1 -0
  885. package/dist/native/ssr/shared/payload-root.js +35 -0
  886. package/dist/native/ssr/shared/payload-root.js.map +1 -0
  887. package/dist/native/ssr/shared/redirect-type.js +8 -0
  888. package/dist/native/ssr/shared/redirect-type.js.map +1 -0
  889. package/dist/native/ssr/shared/rsc-cache-key.js +66 -0
  890. package/dist/native/ssr/shared/rsc-cache-key.js.map +1 -0
  891. package/dist/native/ssr/shared/rsc-error-envelope.js +5 -0
  892. package/dist/native/ssr/shared/rsc-error-envelope.js.map +1 -0
  893. package/dist/native/ssr/shared/rsc-media-type.js +12 -0
  894. package/dist/native/ssr/shared/rsc-media-type.js.map +1 -0
  895. package/dist/native/ssr/shared/rsc-payload-path.js +8 -0
  896. package/dist/native/ssr/shared/rsc-payload-path.js.map +1 -0
  897. package/dist/native/ssr/shared/slot-params.js +29 -0
  898. package/dist/native/ssr/shared/slot-params.js.map +1 -0
  899. package/dist/native/ssr/shared/static-platform-files.js +8 -0
  900. package/dist/native/ssr/shared/static-platform-files.js.map +1 -0
  901. package/dist/native/ssr/shared/status-reason-phrase.js +35 -0
  902. package/dist/native/ssr/shared/status-reason-phrase.js.map +1 -0
  903. package/dist/native/ssr/shims/headers.js +64 -0
  904. package/dist/native/ssr/shims/headers.js.map +1 -0
  905. package/dist/native/ssr/shims/image.js +9 -0
  906. package/dist/native/ssr/shims/image.js.map +1 -0
  907. package/dist/native/ssr/shims/link.js +4 -0
  908. package/dist/native/ssr/shims/navigation.js +11 -0
  909. package/dist/native/ssr/utils/format.js +9 -0
  910. package/dist/native/ssr/utils/format.js.map +1 -0
  911. package/dist/native/ssr/utils/state-machine.js +28 -0
  912. package/dist/native/ssr/utils/state-machine.js.map +1 -0
  913. package/dist/plugins/native-runtime-boundary.d.ts +74 -0
  914. package/dist/plugins/native-runtime-boundary.d.ts.map +1 -0
  915. package/dist/plugins/native-runtime.d.ts +66 -0
  916. package/dist/plugins/native-runtime.d.ts.map +1 -0
  917. package/dist/plugins/shims.d.ts +10 -0
  918. package/dist/plugins/shims.d.ts.map +1 -1
  919. package/dist/server/deny-boundary.d.ts.map +1 -1
  920. package/dist/server/internal.js +33 -124
  921. package/dist/server/internal.js.map +1 -1
  922. package/dist/server/prebuilt/capture-render.d.ts.map +1 -1
  923. package/dist/server/prebuilt/slots.d.ts.map +1 -1
  924. package/dist/server/prebuilt-runtime.d.ts +0 -10
  925. package/dist/server/prebuilt-runtime.d.ts.map +1 -1
  926. package/dist/server/route-element-builder.d.ts.map +1 -1
  927. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  928. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  929. package/dist/server/slot-resolver.d.ts.map +1 -1
  930. package/dist/server/vite-handoff-rsc.d.ts +84 -0
  931. package/dist/server/vite-handoff-rsc.d.ts.map +1 -0
  932. package/docs/learn/06-typed-params.mdx +1 -1
  933. package/package.json +3 -2
  934. package/src/adapters/nitro-presets.ts +14 -0
  935. package/src/client/nuqs-adapter.tsx +108 -29
  936. package/src/client/router-types.ts +7 -0
  937. package/src/client/router.ts +19 -10
  938. package/src/index.ts +2 -0
  939. package/src/plugins/native-runtime-boundary.ts +103 -0
  940. package/src/plugins/native-runtime.ts +332 -0
  941. package/src/plugins/shims.ts +162 -156
  942. package/src/server/action-handler.ts +1 -1
  943. package/src/server/deny-boundary.ts +3 -4
  944. package/src/server/deny-renderer.ts +1 -1
  945. package/src/server/form-state-flight.ts +1 -1
  946. package/src/server/prebuilt/capture-render.ts +5 -2
  947. package/src/server/prebuilt/slots.ts +4 -5
  948. package/src/server/prebuilt-builder.ts +1 -1
  949. package/src/server/prebuilt-runtime.ts +4 -32
  950. package/src/server/route-element-builder.ts +7 -9
  951. package/src/server/route-element-helpers.ts +2 -2
  952. package/src/server/rsc-entry/deny-fallback.ts +1 -1
  953. package/src/server/rsc-entry/error-renderer.ts +3 -4
  954. package/src/server/rsc-entry/index.ts +40 -10
  955. package/src/server/rsc-entry/rsc-stream.ts +1 -1
  956. package/src/server/rsc-entry/ssr-renderer.ts +1 -1
  957. package/src/server/slot-resolver.ts +7 -9
  958. package/src/server/vite-handoff-rsc.ts +134 -0
  959. package/dist/_chunks/error-boundary-OHK1mI99.js.map +0 -1
  960. package/dist/_chunks/global-context-CFSSysdJ.js +0 -77
  961. package/dist/_chunks/global-context-CFSSysdJ.js.map +0 -1
  962. package/dist/_chunks/navigation-root-CoGHIMiE.js.map +0 -1
  963. package/dist/_chunks/status-page-marker-U6B1aFMb.js +0 -530
  964. package/dist/_chunks/status-page-marker-U6B1aFMb.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-boundary-Cf1m-Ywk.js","names":[],"sources":["../../src/shared/payload-root.ts","../../src/client/segment-cache.ts","../../src/client/navigation-commit.ts","../../src/client/rsc-fetch.ts","../../src/client/unload-guard.ts","../../src/client/stale-client.ts","../../src/client/navigation-transition.ts","../../src/client/router-skew.ts","../../src/client/router-effects.ts","../../src/client/status-page-marker.tsx","../../src/shared/error-digest.ts","../../src/client/error-boundary.tsx"],"sourcesContent":["/**\n * The shape of an RSC payload's root row.\n *\n * Every tree the server sends the browser is serialized as\n * `{ tree, params, slotParams }` — the route's element tree, plus the coerced\n * params it rendered with, as *siblings* rather than as a wrapper around the\n * tree. See design/41-global-params.md §\"Transport\".\n *\n * Two reasons it is a sibling field rather than a provider inside the payload\n * (TIM-1297, which is TIM-1294's mechanism corrected):\n *\n * 1. **A provider inside the payload cannot serve a partial navigation.** The\n * client keeps the previous tree and splices the new payload in at the\n * first updated `SegmentOutlet`, so the payload's own provider lands\n * *below* the retained region — and the retained region's root is the\n * *departing* route's provider, which therefore wins for every reader in a\n * skipped layout. Wrapping something above it does not help: context\n * resolves to the nearest provider, and the departing one is nearer.\n * Params belong to the *navigation*, so the provider has to be owned by the\n * client, above the merge point, and there must be exactly one.\n *\n * 2. **Element props are not readable at the instant the root resolves.**\n * Flight outlines a React element's props and fills the record in after the\n * root row resolves, so a reader that unblocks on the root sees `{}` — and\n * since the object is filled *in place*, its identity never changes and any\n * memo keyed on it caches the empty snapshot permanently. A plain model\n * field has no such window: the root chunk stays blocked until everything\n * it references has resolved.\n *\n * This module is the single declaration of that shape. The server builds roots\n * through `server/publish-params.ts` and the client reads them through the\n * helpers here — producer and consumer do not each describe the payload.\n */\n\nimport type { CoercedParams } from './param-value.ts';\nimport type { SlotParamsRecord } from './slot-params.ts';\n\n/** The params published beside a tree. */\nexport interface PublishedParams {\n /** The main route's coerced params. */\n params: CoercedParams;\n /** Per-slot params, or null when the route rendered no slots with params. */\n slotParams: SlotParamsRecord | null;\n}\n\n/**\n * Params ready to publish: settled, or a promise the root provider suspends on.\n *\n * Both forms exist on purpose. The hydration path cannot await — `hydrateRoot`\n * has to be called before the inline Flight stream has necessarily produced\n * the root row — so it hands over the promise and suspends exactly where React\n * was already going to suspend on the tree. Every other path settles it inside\n * the navigation transition first, which is what keeps a decode failure inside\n * the app's own error boundaries instead of above them (TIM-1297).\n */\nexport type ParamsSource = PublishedParams | Promise<PublishedParams>;\n\n/** The root row of an RSC payload. */\nexport interface RscPayloadRoot extends PublishedParams {\n /** The route's element tree. */\n tree: unknown;\n}\n\n/**\n * What a reader gets when the value it was handed is not a payload root.\n *\n * In the browser this is unreachable for a real response: all four producers\n * of a route payload go through `withPublishedParams`, and a client talking to\n * a different build is answered with 204 at Stage 1c\n * (`server/pipeline-phases.ts`) before any payload exists. It is what a page\n * with no payload at all publishes — a document hydrated without an inlined\n * payload, or a prefetch entry that carries no params.\n */\nexport const NO_PUBLISHED_PARAMS: PublishedParams = { params: {}, slotParams: null };\n\n/** True when `value` carries published params — a root, or a read of one. */\nfunction hasPublishedParams(value: unknown): value is PublishedParams {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'params' in value &&\n typeof (value as PublishedParams).params === 'object' &&\n (value as PublishedParams).params !== null\n );\n}\n\n/**\n * Read the params published beside a tree.\n *\n * Accepts a payload root *or* a `PublishedParams` already split off one, so\n * the client can pre-resolve on the navigation path and still hand the same\n * value to the same provider. Never throws.\n */\nexport function readPublishedParams(source: unknown): PublishedParams {\n if (!hasPublishedParams(source)) return NO_PUBLISHED_PARAMS;\n return { params: source.params, slotParams: source.slotParams ?? null };\n}\n\n/**\n * Read the renderable tree out of a payload root.\n *\n * Returns the value unchanged when it is not a root, so a malformed value\n * reaches React (and its error boundaries) rather than vanishing here.\n */\nexport function readPayloadTree(root: unknown): unknown {\n if (typeof root === 'object' && root !== null && 'tree' in root && hasPublishedParams(root)) {\n return (root as RscPayloadRoot).tree;\n }\n return root;\n}\n\n/** A decoded payload, split into the two things the client does with it. */\nexport interface SplitPayload {\n /** The renderable tree — an element, or a thenable React suspends on. */\n tree: unknown;\n /**\n * The params published beside it. Settled when the root already is, so the\n * hydration path can render without an extra await.\n *\n * **Never rejects.** A decode failure has to surface through `tree`: where\n * React renders it on hydration, so the error boundary *around the tree*\n * catches it, and where the router awaits it before handing a navigation\n * over, so the navigation fails and recovers. Rejecting here too would take\n * down the provider above every boundary in the app, turning a contained\n * failure into a blank page (TIM-1297).\n */\n params: ParamsSource;\n}\n\n/**\n * Split a decoded payload root into its tree and its params.\n *\n * Accepts a settled root or a thenable of one, and preserves which it was: a\n * settled root splits synchronously, so no code path gains a suspend point it\n * did not already have.\n */\nexport function splitPayloadRoot(root: unknown): SplitPayload {\n if (\n typeof root !== 'object' ||\n root === null ||\n typeof (root as PromiseLike<unknown>).then !== 'function'\n ) {\n return { tree: readPayloadTree(root), params: readPublishedParams(root) };\n }\n const settled = root as PromiseLike<unknown>;\n const tree = Promise.resolve(settled).then(readPayloadTree);\n // The rejection still reaches React through its own read of `tree`; this\n // only marks it handled for the case where nothing renders it (a partial\n // navigation whose segment update finds no matching outlet).\n tree.catch(() => {});\n const params = Promise.resolve(settled).then(readPublishedParams, () => NO_PUBLISHED_PARAMS);\n return { tree, params };\n}\n","// Segment Cache — stores the mounted segment tree and prefetched payloads\n// See design/19-client-navigation.md for architecture details.\n\nimport type { PublishedParams } from '../shared/payload-root.ts';\nimport type { SegmentInfo, StateTree } from '../shared/segment-info.ts';\nimport { createSingleflight } from '../cache/singleflight.ts';\n\n// ─── Types ───────────────────────────────────────────────────────\n\n/** A prefetched RSC result with optional segment metadata. */\nexport interface PrefetchResult {\n payload: unknown;\n /**\n * Completion of the full Flight stream, when the prefetch is still decoding.\n * Carried through to the navigation that consumes the entry so a decode\n * failure reaches *that* navigation's recovery rather than dying with the\n * prefetch (TIM-1275).\n */\n decodePromise?: Promise<void> | null;\n /** Segment metadata from X-Timber-Segments header for populating the segment cache. */\n segmentInfo?: SegmentInfo[] | null;\n /**\n * The params published beside `payload`, split off the same payload root.\n * Carried so a consumed prefetch publishes the params of the tree it is\n * about to render, and not the ones already on screen.\n */\n params?: PublishedParams | Promise<PublishedParams>;\n /** Segment paths skipped by the server (for client-side merging). */\n skippedSegments?: string[] | null;\n}\n\n/**\n * A node in the client-side segment tree. Each node represents a mounted\n * layout or page segment with its RSC flight payload.\n */\nexport interface SegmentNode {\n /** The segment's URL pattern (e.g., \"/\", \"/dashboard\", \"/projects/[id]\") */\n segment: string;\n /**\n * The segment's `app/` directory path, groups included (e.g. `/(browse)/feed`).\n * Undefined for slot nodes and for servers that predate the field.\n */\n treePath?: string;\n /** The RSC flight payload for this segment (opaque to the cache) */\n payload: unknown;\n /**\n * Whether the segment/slot is request-dependent (calls getHeaders,\n * getSearchParams, cookies, etc.). Request-dependent segments always\n * re-render on navigation. For segments, this is still based on the\n * AsyncFunction heuristic (to be replaced separately). For slots,\n * this is taint-tracked via ALS.\n */\n isRequestDependent: boolean;\n /** Child segments keyed by segment path */\n children: Map<string, SegmentNode>;\n /** Parallel route slots keyed by slot path (e.g., \"/@sidebar\") */\n slots?: Map<string, SegmentNode>;\n /** Whether this slot's access.ts denied on its last render. */\n denied?: boolean;\n /**\n * Content key for slot nodes — opaque string the server computed from\n * owner parts, slot name, entry file, and slot params. Advertised back\n * to the server so it can decide skips by key membership (TIM-1370).\n */\n contentKey?: string;\n}\n\n// ─── Segment Cache ───────────────────────────────────────────────\n\n/**\n * Maintains the client-side segment tree representing currently mounted\n * layouts and pages. Used for navigation reconciliation — the router diffs\n * new routes against this tree to determine which segments to re-fetch.\n */\nexport class SegmentCache {\n private root: SegmentNode | undefined;\n /**\n * Monotonic counter. Bumped by `invalidateReuse()` (TIM-1466).\n * `serializeStateTree` suppresses `segments` and `slots` when\n * `reuseInvalidatedAt > reuseRestoredAt`. Only `restoreReuse()`\n * advances `reuseRestoredAt` — `set()` does not, because a\n * pre-invalidation navigation's commit thunk would lift suppression\n * before a post-invalidation request has been sent (codex on #1167).\n */\n private reuseInvalidatedAt = 0;\n private reuseRestoredAt = 0;\n\n get(segment: string): SegmentNode | undefined {\n if (segment === '/' || segment === this.root?.segment) {\n return this.root;\n }\n return undefined;\n }\n\n set(segment: string, node: SegmentNode): void {\n if (segment === '/' || !this.root) {\n this.root = node;\n }\n }\n\n clear(): void {\n this.root = undefined;\n this.reuseRestoredAt = this.reuseInvalidatedAt;\n }\n\n /**\n * Suppress segment and slot reuse without destroying the tree\n * structure (TIM-1466). `serializeStateTree` sends empty\n * `segments`/`slots` (forcing a full render) while `treePaths`\n * still reflects the mounted tree for interception scoping.\n * Call `restoreReuse()` once post-invalidation data has been\n * fetched and committed.\n */\n invalidateReuse(): void {\n this.reuseInvalidatedAt++;\n }\n\n /**\n * Lift reuse suppression. Called after the segment cache has been\n * rebuilt from a response that was fetched with suppression active\n * (i.e. the server sent a full render). Safe to call idempotently.\n */\n restoreReuse(): void {\n this.reuseRestoredAt = this.reuseInvalidatedAt;\n }\n\n /** Whether segment/slot reuse is currently suppressed (TIM-1466). */\n isReuseSuppressed(): boolean {\n return this.reuseInvalidatedAt > this.reuseRestoredAt;\n }\n\n /**\n * Serialize the mounted segment tree for the X-Timber-State-Tree header.\n * Only includes sync segments — async segments are excluded because the\n * server must always re-render them (they may depend on request context).\n *\n * When mergeableFilter is provided, only segments whose paths are in the\n * set are included. This ensures the server only skips segments that the\n * client can actually merge (i.e., segments whose cached element tree\n * contains an inner SegmentProvider the merger can splice into).\n *\n * `treePaths` is collected UNFILTERED, unlike `segments` and `slots`. Those\n * two answer \"what may the server skip re-rendering?\", so every reason a\n * segment cannot be reused is a reason to leave it out. `treePaths` answers\n * \"what is mounted right now?\" for interception scoping — a request-dependent\n * layout is still on screen, and dropping it would silently narrow the scope\n * the server sees and cancel a modal that should open (TIM-1282).\n *\n * This is a performance optimization only, NOT a security boundary.\n * The server always runs all access.ts files regardless of the state tree.\n */\n serializeStateTree(mergeableFilter?: Set<string>): StateTree {\n const segments: string[] = [];\n const slots: string[] = [];\n const treePaths: string[] = [];\n const suppressed = this.reuseInvalidatedAt > this.reuseRestoredAt;\n if (this.root) {\n if (!suppressed) {\n collectSyncSegments(this.root, segments, mergeableFilter);\n collectSyncSlots(this.root, slots);\n }\n collectTreePaths(this.root, treePaths);\n }\n const tree: StateTree = { segments };\n if (slots.length > 0) {\n tree.slots = slots;\n }\n if (treePaths.length > 0) {\n tree.treePaths = treePaths;\n }\n return tree;\n }\n}\n\n/** Recursively collect sync segment paths from the tree */\nfunction collectSyncSegments(\n node: SegmentNode,\n out: string[],\n mergeableFilter?: Set<string>\n): void {\n if (!node.isRequestDependent && (!mergeableFilter || mergeableFilter.has(node.segment))) {\n out.push(node.segment);\n }\n for (const child of node.children.values()) {\n collectSyncSegments(child, out, mergeableFilter);\n }\n}\n\n/**\n * Recursively collect the `app/` directory path of every mounted segment.\n *\n * Slots are not walked: a slot's own sub-tree can never own an intercepting\n * slot's scope, because scopes are always ordinary segments (`interception.ts`\n * derives one from the slot owner's ancestor chain).\n */\nfunction collectTreePaths(node: SegmentNode, out: string[]): void {\n if (node.treePath) out.push(node.treePath);\n for (const child of node.children.values()) {\n collectTreePaths(child, out);\n }\n}\n\n/**\n * Recursively collect content keys from cacheable slots.\n *\n * The server advertises a content key per slot on every render (TIM-1370),\n * encoding the owner's URL parts, the slot name, the matched entry file,\n * and the slot's params. The client stores this key and sends it back on\n * the next navigation so the server can decide skips by key membership —\n * no departing URL reconstruction needed.\n */\nfunction collectSyncSlots(node: SegmentNode, out: string[]): void {\n if (node.slots) {\n for (const slot of node.slots.values()) {\n if (!slot.isRequestDependent && !slot.denied && slot.contentKey) {\n out.push(slot.contentKey);\n }\n }\n }\n for (const child of node.children.values()) {\n collectSyncSlots(child, out);\n }\n}\n\n// ─── Segment Tree Builder ────────────────────────────────────────\n\n/**\n * Build a SegmentNode tree from flat segment metadata.\n *\n * Takes an ordered list of segment descriptors (root → leaf) from the\n * server's X-Timber-Segments header and constructs the hierarchical\n * tree structure that SegmentCache expects.\n *\n * Each segment is nested as a child of the previous one, forming a\n * linear chain from root to leaf. The leaf segment (page) is excluded\n * from the tree — pages are never cached across navigations.\n */\nexport function buildSegmentTree(segments: SegmentInfo[]): SegmentNode | undefined {\n // Need at least a root segment to build a tree\n if (segments.length === 0) return undefined;\n\n // Separate slot entries from segment entries. Slots are attached to\n // their parent segment node after the main chain is built.\n const segmentEntries: SegmentInfo[] = [];\n const slotEntries: SegmentInfo[] = [];\n for (const info of segments) {\n if (info.slot) {\n slotEntries.push(info);\n } else {\n segmentEntries.push(info);\n }\n }\n\n // Build the main segment chain.\n let root: SegmentNode | undefined;\n let parent: SegmentNode | undefined;\n const nodeById = new Map<string, SegmentNode>();\n\n for (const info of segmentEntries) {\n const id = info.segmentId ?? info.path;\n const node: SegmentNode = {\n segment: id,\n treePath: info.treePath,\n payload: null,\n isRequestDependent: info.isRequestDependent,\n children: new Map(),\n };\n\n nodeById.set(id, node);\n\n if (!root) {\n root = node;\n }\n\n if (parent) {\n parent.children.set(id, node);\n }\n\n parent = node;\n }\n\n // Attach slot entries to their parent segment nodes.\n for (const slotInfo of slotEntries) {\n const parentId = slotInfo.parentSegment;\n const parentNode = parentId ? nodeById.get(parentId) : root;\n if (!parentNode) continue;\n\n const slotId = slotInfo.segmentId ?? slotInfo.path;\n const slotNode: SegmentNode = {\n segment: slotId,\n payload: null,\n isRequestDependent: slotInfo.isRequestDependent,\n children: new Map(),\n denied: slotInfo.denied,\n contentKey: slotInfo.contentKey,\n };\n\n if (!parentNode.slots) {\n parentNode.slots = new Map();\n }\n parentNode.slots.set(slotId, slotNode);\n }\n\n return root;\n}\n\n// ─── Prefetch Cache ──────────────────────────────────────────────\n\ninterface ReadyEntry {\n result: PrefetchResult;\n expiresAt: number;\n}\n\n/** Sentinel value for negative cache entries (URL is not a route). */\nconst NEGATIVE_ENTRY: PrefetchResult = Object.freeze({ payload: null });\n\n/**\n * Timeout for the in-flight singleflight (TIM-1438). Per CLAUDE.md's\n * singleflight rule: \"Never write a coalescing Map without a timeout.\"\n * A hung prefetch cannot block clicks or suppress hovers forever.\n */\nconst PREFETCH_SINGLEFLIGHT_TIMEOUT_MS = 5_000;\n\n/**\n * Identifies a prefetched payload. A payload is addressed by *every* input that\n * changes the server's answer, not by the destination alone.\n *\n * The server's answer for a destination depends on where the request came\n * from — that is the whole mechanism behind intercepting routes, and it also\n * drives slot-skip resolution. A prefetch issued from `/gallery` is a modal\n * payload; the same URL prefetched from `/` is the full page. Keying on the\n * destination alone let the first click after a hover be answered with\n * whichever variant happened to be fetched (TIM-1265).\n *\n * `from` alone stopped being enough in TIM-1282. It is a pathname, and once\n * interception scope comes from the rendered tree rather than the address, one\n * pathname no longer names one source tree: `/photo/1` is the address both for\n * a modal open over `(browse)` and for `(landing)`'s canonical page. A key\n * without the scope hands the modal payload to the canonical page's click,\n * which renders it without the server's scope check ever running.\n *\n * The two reads happen at different instants — `scope` is sampled at hover and\n * again at click — which is why a tree that changed in between produces a\n * *miss* and a refetch rather than a wrong hit.\n */\nexport interface PrefetchKey {\n /** Destination URL — hash-less `pathname + search`, as navigate() fetches it. */\n url: string;\n /** Departing pathname — the `X-Timber-URL` the prefetch was issued with. */\n from: string;\n /**\n * The rendered scope the prefetch was issued with — the `treePaths` half of\n * `X-Timber-State-Tree`, joined. Empty when none crossed.\n */\n scope: string;\n}\n\n/**\n * Compose the map key. Length-prefixed rather than delimiter-joined for the\n * same reason `shared/rsc-cache-key.ts` is: any delimiter is forgeable by a\n * value containing it, and a URL may contain any character a delimiter could.\n */\nfunction prefetchMapKey(key: PrefetchKey): string {\n return `${key.from.length}:${key.from}:${key.scope.length}:${key.scope}:${key.url}`;\n}\n\n/**\n * The `scope` half of a `PrefetchKey`, derived from the state tree that will\n * actually be sent. Taking it from the header value rather than re-walking the\n * cache is the point: the key varies by exactly what the request varies by.\n */\nexport function prefetchScopeOf(stateTree: StateTree | undefined): string {\n return stateTree?.treePaths?.join('\\u0000') ?? '';\n}\n\n/** Outcome of a prefetch flight — discriminated so NonRscResponse is a\n * success (stores a negative entry) rather than a rejection.\n * `startGen` is the eviction generation at flight start — joiners that\n * started after a gen bump must reject pre-invalidation results (TIM-1464). */\nexport type FlightOutcome =\n | { kind: 'ready'; result: PrefetchResult; startGen: number }\n | { kind: 'non-route'; startGen: number };\n\n/**\n * Short-lived cache for hover-triggered prefetches. Entries expire after\n * 30 seconds. When a link is clicked, the prefetched payload is consumed\n * (moved to the history stack) and removed from this cache.\n *\n * In-flight dedup (TIM-1438): concurrent fetches for the same key are\n * coalesced by a `createSingleflight` instance. A hover starts a flight;\n * a click for the same key joins it instead of issuing a duplicate. The\n * singleflight enforces a 5-second timeout and cleans up automatically\n * on settlement.\n *\n * timber.js does NOT prefetch on viewport intersection — only explicit\n * hover on <Link prefetch> triggers a prefetch.\n */\nexport class PrefetchCache {\n private static readonly TTL_MS = 30_000;\n private entries = new Map<string, ReadyEntry>();\n private flights = createSingleflight({ timeoutMs: PREFETCH_SINGLEFLIGHT_TIMEOUT_MS });\n private evictionGen = 0;\n\n set(key: PrefetchKey, result: PrefetchResult): void {\n this.entries.set(prefetchMapKey(key), {\n result,\n expiresAt: Date.now() + PrefetchCache.TTL_MS,\n });\n }\n\n get(key: PrefetchKey): PrefetchResult | undefined {\n const mapKey = prefetchMapKey(key);\n const entry = this.entries.get(mapKey);\n if (!entry) return undefined;\n if (Date.now() >= entry.expiresAt) {\n this.entries.delete(mapKey);\n return undefined;\n }\n return entry.result;\n }\n\n /** True if a ready or negative entry exists for this key. */\n has(key: PrefetchKey): boolean {\n return this.get(key) !== undefined;\n }\n\n /** Get and remove the entry (used when navigation consumes a prefetch) */\n consume(key: PrefetchKey): PrefetchResult | undefined {\n const result = this.get(key);\n if (result !== undefined) {\n this.entries.delete(prefetchMapKey(key));\n }\n return result;\n }\n\n /**\n * Fetch or coalesce with an in-flight fetch for this key (TIM-1438).\n *\n * Concurrent callers (hover + click, repeated hovers) get the same\n * promise. On success the result is stored as a ready entry. On\n * NonRscResponse a negative entry is stored and the outcome is\n * `{ kind: 'non-route' }`. Other errors (network, version skew)\n * reject — the singleflight cleans up the key and subsequent callers\n * retry.\n *\n * The singleflight signal is passed to `doFetch` so a timed-out flight\n * aborts the underlying fetch rather than leaving it running.\n */\n fetchOrCoalesce(\n key: PrefetchKey,\n doFetch: (signal: AbortSignal) => Promise<PrefetchResult>,\n isNonRoute: (error: unknown) => boolean\n ): Promise<FlightOutcome> {\n // Capture the eviction generation before the flight starts. If an\n // action evicts caches while this flight is in progress, the gen\n // will have bumped and the stale result is discarded (TIM-1476).\n // The starting gen is also included in the outcome so joiners\n // that started after a gen bump can detect pre-invalidation\n // results (TIM-1464).\n const genAtStart = this.evictionGen;\n return this.flights.do(prefetchMapKey(key), async (signal) => {\n try {\n const result = await doFetch(signal);\n if (!signal.aborted && this.evictionGen === genAtStart) this.set(key, result);\n return { kind: 'ready' as const, result, startGen: genAtStart };\n } catch (err) {\n if (isNonRoute(err)) {\n if (!signal.aborted && this.evictionGen === genAtStart) this.setNegative(key);\n return { kind: 'non-route' as const, startGen: genAtStart };\n }\n throw err;\n }\n });\n }\n\n /**\n * Join an in-flight singleflight fetch if one exists for this key.\n * Returns the in-flight promise or undefined. Used by the click path to\n * coalesce with a hover prefetch without starting a new flight — when no\n * flight exists, the click issues its own fetch with the navigation's\n * abort signal so superseded navigations abort immediately (TIM-1438).\n */\n joinInflight(key: PrefetchKey): Promise<FlightOutcome> | undefined {\n return this.flights.get(prefetchMapKey(key)) as Promise<FlightOutcome> | undefined;\n }\n\n /**\n * Store a negative entry — the URL is not a route (non-RSC Content-Type).\n *\n * Keyed like every other entry even though \"not a route\" does not actually\n * vary by departing URL: a source-independent negative would be a second\n * keying rule to keep correct, and the only cost of the uniform one is a\n * repeated fetch for a link hovered from a second page.\n */\n setNegative(key: PrefetchKey): void {\n this.set(key, NEGATIVE_ENTRY);\n }\n\n /** Check if the entry is a negative cache entry (URL is not a route). */\n isNegative(key: PrefetchKey): boolean {\n return this.get(key) === NEGATIVE_ENTRY;\n }\n\n /**\n * Evict all ready entries and fence in-flight singleflights (TIM-1476).\n * Called after a server action that revalidated data — the mutation may\n * affect any route, not just the paths the server named. In-flight\n * singleflights are not aborted (they may carry post-mutation data),\n * but their results are discarded if they complete after eviction:\n * `fetchOrCoalesce` captures the generation before the flight and\n * skips the store when it has been bumped.\n *\n * Consumers that join an in-flight flight via `joinInflight` must\n * check `getEvictionGen()` before and after the await: if the gen\n * changed, the result predates the eviction and must be discarded\n * (codex on #1131 round 2).\n */\n clearReady(): void {\n this.entries.clear();\n this.evictionGen++;\n }\n\n getEvictionGen(): number {\n return this.evictionGen;\n }\n}\n","/**\n * What it means for a page to be \"current\" on the client.\n *\n * One module owns every write that makes a navigation's destination the\n * current page, and the read that describes the current page back to the\n * server. Keeping them together is the point: `X-Timber-State-Tree` is\n * derived from the segment cache, so the thing that publishes and the thing\n * that reports have to agree about when a page becomes current.\n *\n * See design/19-client-navigation.md §\"State Update Invariants\".\n */\n\nimport { buildSegmentTree, type SegmentCache } from './segment-cache.ts';\nimport type { HistoryStack } from './history.ts';\nimport type { SegmentInfo, StateTree } from '../shared/segment-info.ts';\nimport type { ParamsSource } from '../shared/payload-root.ts';\nimport type { NavigationState } from './navigation-context.ts';\nimport { parseRouterUrl } from './router-url.ts';\nimport {\n statusPageRendered,\n _setStatusPageRendered,\n onStatusPageRendered,\n _setOnStatusPageRendered,\n} from './state.ts';\n\n// ─── What a status page teaches the cache ─────────────────────────────────\n//\n// A status page replaces a subtree: a deny page lands at the segment owning\n// the matched file and nothing below it mounts; an `error.tsx` fallback\n// discards everything under the boundary that rendered it. `X-Timber-Segments`\n// nonetheless describes the whole chain the payload was built against — it\n// must, because a partial navigation picks its merge point out of it — so the\n// cache has to be told not to learn from such a tree.\n//\n// The HTTP status used to say so, and could not be trusted to: an RSC payload\n// response commits one macrotask after its first chunk, and a nested\n// component that denies after I/O puts its row in the stream after the\n// status line has gone out (TIM-1489). The only thing that reliably knows a\n// status page rendered is the status page itself, and the only moment that\n// matters is the commit that puts it on screen — so every status page the\n// framework produces is wrapped in `StatusPageMarker`, whose layout effect\n// reports on each commit that renders it. Layout effects run child-before-\n// parent, so the report lands before `NavigationRoot`'s publish of that\n// same commit, and never for a render React discards. Without Suspense\n// around the row, the transition cannot commit until the row has arrived, so\n// this covers the delayed nested case too, which no status ever could.\n//\n// The report also clears the cache on the spot, because not every commit\n// has a navigation to consume it: a deny row arriving inside a Suspense\n// boundary after its navigation published, or a status document being\n// hydrated, would otherwise leave a tree in the cache that is no longer on\n// screen. Consuming the flag at commit is what keeps the same navigation from\n// re-seeding it a moment later. Both are over-approximations — a page-level\n// deny leaves every layout standing — at the cost of one full render on the\n// next navigation.\n//\n// Slot boundaries do not report: a slot degrading is the page staying, and\n// the chain it mounted is the chain the header describes. See TIM-1356,\n// TIM-1495, design/04-authorization.md §\"Where a Deny Page Renders\".\n\n/**\n * Record that a status page for the main route is on screen. Called from\n * `StatusPageMarker`'s layout effect; consumed by the commit of the\n * navigation whose tree it belongs to, and acted on immediately for the\n * commits that have none.\n */\nexport function reportStatusPageRendered(): void {\n _setStatusPageRendered(true);\n onStatusPageRendered?.();\n}\n\n/** Everything a commit needs to describe the page it makes current. */\nexport interface NavigationCommitInput {\n payload: unknown;\n /** The params that payload published — replayed with it on popstate. */\n params: ParamsSource;\n /**\n * The rendered chain's metadata, or null/undefined when this commit\n * carries none at all — a revalidation payload, or a history entry\n * stored before the channel existed.\n *\n * An empty *array* is a different statement from an absent one: the\n * server rendered a route with no layout-bearing segments (a layoutless\n * app — the missing-root-layout check is a warning, not an error), so\n * the correct tree is the empty one. Collapsing the two left the\n * departing route's tree in place, which `treePaths` then reported as\n * mounted — enough to select an intercepting rewrite whose slot is not\n * on screen (TIM-1282).\n */\n segmentInfo?: SegmentInfo[] | null;\n /** When true, clear the segment cache if segmentInfo is absent\n * (popstate replay for entries without layout metadata). */\n clearSegmentCacheOnEmpty?: boolean;\n /**\n * Layouts the server skipped on this response (`X-Timber-Skipped-Segments`),\n * when it came from a fetch. Omitted by replays and revalidation.\n *\n * Together with `skipped` slot entries in `segmentInfo`, this decides\n * whether the payload can be *replayed*. A partial payload only renders\n * merged over the tree on screen, and a `skip=true` outlet resolves against\n * the slot content cache at render time — so a stored copy of either,\n * replayed later, shows whatever the client holds *then*, not what was on\n * screen when the entry committed. Such entries store a null payload and\n * traversals to them fetch instead. Decided here, not at the fetch call\n * sites, because there are three of those (`performNavigationFetch`,\n * `refresh()`, and uncached traversal) and a rule applied at one of them\n * holds by accident: `performNavigationFetch` had the check and\n * `fetchCommitAndRender` did not, so a back/forward fetch that was\n * answered with skips stored the holes (TIM-1432).\n */\n skippedSegments?: string[] | null;\n}\n\n/** Whether a response skipped layouts — its payload merges over the tree on screen. */\nexport function isPartialNavigation(skippedSegments: string[] | null | undefined): boolean {\n return skippedSegments != null && skippedSegments.length > 0;\n}\n\n/**\n * Whether a payload can stand on its own when replayed from the history\n * stack. See `NavigationCommitInput.skippedSegments`.\n */\nfunction isReplayable(opts: NavigationCommitInput): boolean {\n return !isPartialNavigation(opts.skippedSegments) && !hasSkippedSlot(opts.segmentInfo);\n}\n\nfunction hasSkippedSlot(segmentInfo: SegmentInfo[] | null | undefined): boolean {\n return segmentInfo?.some((s) => s.slot && s.skipped) ?? false;\n}\n\n/**\n * The metadata a committed page keeps — on its history entry, and as the\n * current page's `committedSegmentInfo()`. `skipped` describes the\n * *response* — \"this slot's content was omitted\" — and neither stores such\n * a payload (the entry stores null). Kept, the flag outlives the response:\n * `applyActionResult()` reuses the current page's metadata beside a full\n * re-render and would have that judged non-replayable too.\n */\nfunction storedSegmentInfo(segmentInfo: SegmentInfo[] | null | undefined) {\n if (!hasSkippedSlot(segmentInfo)) return segmentInfo;\n return segmentInfo!.map(({ skipped: _skipped, ...rest }) => rest);\n}\n\n/**\n * A navigation's destination, split into what a render needs and what a\n * commit publishes.\n */\nexport interface PreparedNavigation {\n /** The state the incoming tree renders with. Pure — safe before winning. */\n navState: NavigationState;\n /** Publishes the destination. Call only once the render has won. */\n commit: () => void;\n}\n\nexport interface NavigationCommitter {\n prepareNavigation(url: string, opts: NavigationCommitInput): PreparedNavigation;\n currentStateTree(): StateTree | undefined;\n /**\n * The segment metadata of the page the last commit made current, as that\n * commit recorded it — null when it carried none.\n *\n * Server-action responses carry no segment metadata, so a revalidation\n * re-renders the current page with this. It is the committer's own record\n * rather than a history-stack lookup: the stack is keyed by the URL string\n * a navigation was asked for, and the current page is known by\n * `window.location`'s spelling of it, and the two need not agree\n * (`/a?` against `/a`, a percent-encoded path against a decoded one).\n */\n committedSegmentInfo(): SegmentInfo[] | null;\n /** Whether segment reuse is currently suppressed (TIM-1466). */\n isSegmentReuseSuppressed(): boolean;\n /** Lift segment reuse suppression after fresh data has been fetched (TIM-1466). */\n restoreSegmentReuse(): void;\n}\n\n/**\n * Derive the navigation state (pathname + search) a URL renders with.\n *\n * Pure. The value travels with the tree it describes — callers pass it to\n * `wrapPayload`, and the router's record of the displayed tree keeps it\n * beside that tree — so there is no store to publish it to (TIM-1541).\n */\nexport function deriveNavigationState(url: string): NavigationState {\n // Params are not part of it. They travel with the payload and are published\n // by the one client-owned `ParamsProvider` as the new tree renders, which is\n // also what clears the previous route's — a route with no params of its own\n // still publishes an empty record (TIM-1294/TIM-1297, and the clearing\n // requirement from TIM-1285).\n const parsed = parseRouterUrl(url);\n return { pathname: parsed.pathname || '/', search: parsed.search };\n}\n\nexport function createNavigationCommitter(deps: {\n segmentCache: SegmentCache;\n historyStack: HistoryStack;\n /** Read at call time — the router's `clientSegmentCache` opt-in. */\n clientSegmentCache: () => boolean | undefined;\n}): NavigationCommitter {\n const { segmentCache, historyStack } = deps;\n\n // See `committedSegmentInfo`. Written only by a commit.\n let committedSegmentInfo: SegmentInfo[] | null = null;\n\n // See `reportStatusPageRendered`: a status page that commits with no\n // navigation to consume the report still empties the cache.\n _setOnStatusPageRendered(() => segmentCache.clear());\n\n /**\n * Update the segment cache from server-provided segment metadata.\n *\n * Runs whether or not `clientSegmentCache` is enabled: the tree is also\n * where the mounted tree paths come from, and those cross on every\n * navigation. What the flag gates is which parts get serialized — see\n * `currentStateTree`.\n */\n function updateSegmentCache(segmentInfo: SegmentInfo[]): void {\n const tree = buildSegmentTree(segmentInfo);\n if (tree) {\n segmentCache.set('/', tree);\n }\n }\n\n return {\n committedSegmentInfo: () => committedSegmentInfo,\n isSegmentReuseSuppressed: () => segmentCache.isReuseSuppressed(),\n restoreSegmentReuse: () => segmentCache.restoreReuse(),\n\n /**\n * The X-Timber-State-Tree to send with the next RSC request.\n *\n * Two different things travel on one header. `segments`/`slots` are the\n * caching opt-in and are omitted unless `clientSegmentCache` is on.\n * `treePaths` is how the server learns which route is actually mounted,\n * which stops being derivable from the address bar as soon as a modal is\n * open — so it crosses regardless (TIM-1282). Undefined when there is\n * nothing to say, so a no-op header never enters the `_rsc` cache key.\n *\n * Reads what the last *committed* navigation published, so a superseded\n * navigation's destination can never end up describing the mounted tree\n * (TIM-1301).\n */\n currentStateTree(): StateTree | undefined {\n const tree = segmentCache.serializeStateTree();\n if (deps.clientSegmentCache()) return tree;\n return tree.treePaths ? { segments: [], treePaths: tree.treePaths } : undefined;\n },\n\n /**\n * Prepare all navigation-owned state for a new page — without publishing\n * any of it. Every code path that changes the \"current page\" must go\n * through this function, which is what makes \"forgot a field\" impossible\n * by construction.\n *\n * Returns the destination's `NavigationState`, which is a pure function of\n * the URL and is what the incoming tree is *rendered* with, plus a\n * `commit` thunk that performs the writes that make a page current:\n * 1. Segment cache — update from server-provided segment metadata\n * 2. The current page's segment metadata (`committedSegmentInfo`)\n * 3. History stack — store the payload for instant back/forward replay\n *\n * Pathname and search are not written here: they are the returned\n * `navState`, which the tree renders with and the router's record of the\n * displayed tree keeps (browser-entry/router-init.ts `publishTree`).\n *\n * Nothing is written until `commit()` runs, and on a transitioned\n * navigation it runs only once the transition is known to have won — see\n * `renderViaTransition` and `NavigationRoot`. A navigation superseded\n * while its payload was in flight never calls it, so the cache, the\n * pathname the client reports and the history stack all keep describing\n * the route still on screen (TIM-1301).\n *\n * Callers with state of their own to publish — the address bar, the\n * client's record of the mounted tree — wrap this thunk rather than\n * commit beside it, so there stays exactly one moment at which a page\n * becomes current.\n */\n prepareNavigation(url: string, opts: NavigationCommitInput): PreparedNavigation {\n const navState = deriveNavigationState(url);\n const payload = isReplayable(opts) ? opts.payload : null;\n\n // The tree this navigation renders has not rendered yet. Whatever a\n // boundary reported before now belongs to a commit that had no\n // navigation to consume it — a hydration, a row that arrived inside a\n // Suspense boundary after its navigation had published — and must not\n // be charged to this one.\n _setStatusPageRendered(false);\n\n return {\n navState,\n commit() {\n // A tree in which a boundary rendered a status page is not one to\n // cache — see the module note. Read at commit rather than at\n // prepare because that is when the boundary has spoken: the row it\n // renders may not have existed when the response headers were read.\n // The history entry records the same thing, or a traversal back to\n // this URL would replay the metadata this drops.\n const cacheable = !statusPageRendered;\n _setStatusPageRendered(false);\n const segmentInfo = cacheable ? opts.segmentInfo : [];\n\n if (segmentInfo && segmentInfo.length > 0) {\n updateSegmentCache(segmentInfo);\n } else if (segmentInfo?.length === 0 || opts.clearSegmentCacheOnEmpty) {\n segmentCache.clear();\n }\n\n committedSegmentInfo = storedSegmentInfo(segmentInfo) ?? null;\n\n historyStack.push(url, {\n payload,\n params: opts.params,\n segmentInfo: committedSegmentInfo,\n });\n },\n };\n },\n };\n}\n","/**\n * RSC Fetch — handles fetching and parsing RSC Flight payloads.\n *\n * Extracted from router.ts to keep both files under the 500-line limit.\n * This module handles:\n * - Cache-busting URL generation for RSC requests\n * - Building RSC request headers (Accept, X-Timber-State-Tree)\n * - Extracting metadata from RSC response headers\n * - Fetching and decoding RSC payloads\n *\n * See design/19-client-navigation.md §\"RSC Payload Handling\"\n */\n\nimport {\n rscCacheKey,\n recordLookup,\n randomRscCacheKey,\n RSC_KEY_PARAM,\n} from '../shared/rsc-cache-key.ts';\nimport type { RscManifest, RscManifestEntry } from '../shared/rsc-manifest.ts';\nimport { splitPayloadRoot, type PublishedParams } from '../shared/payload-root.ts';\nimport { normalizeBasePath, stripBasePath, withBasePath } from '../shared/base-path.ts';\nimport { rscPayloadPath } from '../shared/rsc-payload-path.ts';\nimport type { SegmentInfo, StateTree } from '../shared/segment-info.ts';\nimport { TIMBER_ERROR_HEADER } from '../shared/rsc-error-envelope.ts';\nimport { RSC_CONTENT_TYPE, isRscContentType } from '../shared/rsc-media-type.ts';\nimport type { RouterDeps } from './router-types.ts';\n\n// ─── Types ───────────────────────────────────────────────────────\n\n/** Result of fetching an RSC payload — includes segment metadata. */\nexport interface FetchResult {\n /** The renderable tree, split off the payload root. */\n payload: unknown;\n /**\n * The params the same payload published beside that tree.\n *\n * Not a separate channel: both fields come out of one `splitPayloadRoot`\n * call on one decoded root, so a response cannot deliver a tree and another\n * route's params. They used to arrive on their own header, which is how a\n * navigation could render one route and publish another's (TIM-1285,\n * TIM-1294).\n */\n params: PublishedParams | Promise<PublishedParams>;\n /**\n * Promise that settles when the RSC decode completes or fails.\n * The payload thenable is NOT awaited before returning (for streaming),\n * so callers must monitor this to catch async decode errors\n * (truncated streams, Flight parse failures) that would otherwise\n * become unhandled rejections.\n */\n decodePromise: Promise<void> | null;\n /** Segment metadata from X-Timber-Segments header for populating the segment cache. */\n segmentInfo: SegmentInfo[] | null;\n /** Segment paths that were skipped by the server (for client-side merging). */\n skippedSegments: string[] | null;\n}\n\n// ─── URL Helpers ─────────────────────────────────────────────────\n\n/**\n * Append a `_rsc=<key>` query parameter to the URL (TIM-1268).\n *\n * The key is a deterministic hash of the RSC request headers, so identical\n * requests share a URL and the payload becomes cacheable. It also keeps the\n * document and the payload on different URLs, so a shared cache cannot\n * return HTML for an RSC request (or vice versa) even where `Vary` is\n * opt-in configuration rather than default behaviour — Cloudflare and\n * CloudFront both. See GHSA-wfc6-r584-vfw7, design/13-security.md.\n *\n * The origin recomputes this key from the received headers and refuses to\n * let a mismatched response be shared-cached, so a caller cannot claim\n * another client's key while sending its own headers.\n *\n * Falls back to a random value when no key can be derived — `crypto.subtle`\n * is absent in non-secure browsing contexts (plain `http://` on a LAN\n * address). Dropping the parameter instead would put the payload back on\n * the document URL, where a query-keyed cache that ignores `Vary` could\n * store a Flight response under `/about` and serve it to an HTML\n * navigation. The random parameter this feature replaced did separate those\n * representations, and the fallback must not be worse than what it\n * replaced. The origin cannot verify a random key, so it refuses to\n * share-cache the response — which is exactly the old behaviour, where a\n * unique URL was never a cache hit anyway.\n *\n * Strips any #fragment before appending — fragments are client-only and\n * fetch() discards them, so _rsc would land inside the hash and be lost.\n */\nasync function appendRscParam(url: string, headers: Record<string, string>): Promise<string> {\n const hashIndex = url.indexOf('#');\n const urlWithoutHash = hashIndex === -1 ? url : url.slice(0, hashIndex);\n const key = (await rscCacheKey(recordLookup(headers))) ?? randomRscCacheKey();\n const separator = urlWithoutHash.includes('?') ? '&' : '?';\n return `${urlWithoutHash}${separator}${RSC_KEY_PARAM}=${key}`;\n}\n\n// ─── Deployment ID ───────────────────────────────────────────────\n\n/**\n * The client's deployment ID, set at bootstrap from the runtime config.\n * Sent with every RSC/action request for version skew detection.\n * Null in dev mode. See TIM-446.\n */\nlet clientDeploymentId: string | null = null;\n\n/** Set the client deployment ID. Called once at bootstrap. */\nexport function setClientDeploymentId(id: string | null): void {\n clientDeploymentId = id;\n}\n\n/** Get the client deployment ID. */\nexport function getClientDeploymentId(): string | null {\n return clientDeploymentId;\n}\n\n// ─── Base Path ───────────────────────────────────────────────────\n\n/**\n * The deployment base path (Vite's resolved `base`), normalized.\n * Set at bootstrap from `virtual:timber-config`; `'/'` unless the app is\n * deployed under a sub-path. See design/11-platform.md, TIM-1261.\n *\n * **The base is applied in exactly one place: at fetch time**\n * (`toStaticRscUrl`). The static build writes the RSC manifest with\n * root-relative keys *and* root-relative URLs, so the generated site stays\n * relocatable and there is no second copy of the base to drift from this one.\n */\nlet basePath = '/';\n\n/** Set the deployment base path. Called once at bootstrap. */\nexport function setBasePath(base: string | undefined): void {\n basePath = normalizeBasePath(base);\n}\n\n/** Get the normalized deployment base path. @internal Exported for testing. */\nexport function getBasePath(): string {\n return basePath;\n}\n\n// ─── Static Mode ────────────────────────────────────────────────\n\n/**\n * When true, RSC fetches use _rsc/*.rsc file URLs instead of\n * the route URL with Accept headers. Static hosts ignore Accept\n * headers, so the client must fetch the pre-generated .rsc files\n * directly. Set at bootstrap from virtual:timber-config output mode.\n */\nlet staticMode = false;\n\nexport function setStaticMode(enabled: boolean): void {\n staticMode = enabled;\n}\n\nexport function isStaticMode(): boolean {\n return staticMode;\n}\n\n/**\n * RSC manifest mapping unhashed → content-hashed `.rsc` URLs. Populated from\n * `window.__TIMBER_RSC_MANIFEST__` (injected into HTML during static\n * generation). Shape shared with the static build that writes it — see\n * `shared/rsc-manifest.ts`. See TIM-1254.\n */\nlet rscManifest: RscManifest | null = null;\n\nfunction getRscManifest(): RscManifest | null {\n if (rscManifest) return rscManifest;\n if (typeof window !== 'undefined' && (window as any).__TIMBER_RSC_MANIFEST__) {\n rscManifest = (window as any).__TIMBER_RSC_MANIFEST__;\n }\n return rscManifest;\n}\n\n/** @internal Exported for testing. */\nexport function setRscManifest(manifest: RscManifest | null): void {\n rscManifest = manifest;\n}\n\n/** A resolved static payload target: the URL to fetch, and how it was resolved. */\ninterface StaticRscTarget {\n /** Fetchable URL — base-prefixed. */\n url: string;\n /**\n * True when the RSC manifest supplied a content-hashed filename. The hash\n * guarantees freshness, so no `_rsc` cache key is appended (TIM-1254).\n */\n hashed: boolean;\n}\n\n/**\n * Resolve a route URL to the `_rsc/*.rsc` file to fetch. The naming rule is\n * `shared/rsc-payload-path.ts`, shared with the build that writes the files.\n *\n * When an RSC manifest is available (hashed filenames from TIM-1254),\n * the manifest is consulted to resolve to the hashed path.\n *\n * / → /_rsc/index.rsc (or /_rsc/index-B7YxEKdN.rsc with manifest)\n * /about → /_rsc/about/index.rsc (or /_rsc/about/index-C8ZzFLfO.rsc)\n * /blog/hello → /_rsc/blog/hello/index.rsc\n *\n * The manifest is written and read in route space (no base prefix), so the\n * base is applied here — once, on the way out. See client/base-path.ts.\n */\nfunction toStaticRscUrl(url: string): StaticRscTarget {\n const unhashed = toUnhashedRscUrl(url);\n const hashedUrl = manifestLookup(unhashed);\n return { url: withBasePath(basePath, hashedUrl ?? unhashed), hashed: hashedUrl !== null };\n}\n\n/**\n * Compute the unhashed `_rsc/*.rsc` path for a route URL.\n *\n * Returns a **route-space** path: the deployment base is stripped from the\n * incoming URL and is NOT re-applied, because this value doubles as the RSC\n * manifest key, and the manifest is base-less. `toStaticRscUrl` applies the\n * base to whatever is actually fetched.\n *\n * @internal Exported for testing.\n */\nexport function toUnhashedRscUrl(url: string): string {\n const hashIndex = url.indexOf('#');\n const queryIndex = url.indexOf('?');\n const hashEnd = hashIndex === -1 ? url.length : hashIndex;\n const queryEnd = queryIndex === -1 ? url.length : queryIndex;\n const end = Math.min(hashEnd, queryEnd);\n let pathname = stripBasePath(basePath, url.slice(0, end));\n // Strip trailing slash (unless root) to match static build output naming\n if (pathname.length > 1 && pathname.endsWith('/')) {\n pathname = pathname.slice(0, -1);\n }\n return rscPayloadPath(pathname);\n}\n\n/**\n * Look up a key in the RSC manifest, falling back to percent-decoded\n * lookup for encoded browser URLs. Returns the entry or null.\n */\nfunction manifestEntry(key: string): RscManifestEntry | null {\n const manifest = getRscManifest();\n if (!manifest) return null;\n if (manifest[key]) return manifest[key];\n try {\n const decoded = decodeURIComponent(key);\n if (decoded !== key && manifest[decoded]) return manifest[decoded];\n } catch {\n // Malformed percent sequence (e.g. /100%.rsc) — skip decoded lookup\n }\n return null;\n}\n\n/**\n * Look up the hashed URL for an unhashed RSC path.\n */\nfunction manifestLookup(key: string): string | null {\n return manifestEntry(key)?.url ?? null;\n}\n\n// The manifest used to inline each route's params, because a generated\n// `.rsc` file carries no response headers and the header channel therefore\n// did not exist on the static path (TIM-1255, TIM-1285). The `.rsc` file now\n// carries them itself — they are props inside the payload — so the static\n// path needs no special case at all.\n\n// ─── Reload Signal ───────────────────────────────────────────────\n\n/** Header name used by the server to signal a version skew reload. */\nexport const RELOAD_HEADER = 'X-Timber-Reload';\n\n/** Header name for the client's deployment ID. */\nexport const DEPLOYMENT_ID_HEADER = 'X-Timber-Deployment-Id';\n\n/**\n * Check if a response signals a version skew reload.\n * Triggers a full page reload if the server indicates the client is stale.\n */\nexport function checkReloadSignal(response: Response): boolean {\n return response.headers.get(RELOAD_HEADER) === '1';\n}\n\n// ─── Header Builder ──────────────────────────────────────────────\n\n/**\n * Build the headers for an RSC payload request.\n *\n * **Every header added here is hashed into the payload URL** as the `_rsc`\n * cache key (see `rscCacheKey`), and URLs are logged by proxies, CDNs, and\n * origin access logs. So: no credentials, no session identifiers, no\n * user-supplied content. `fnv1aHash` is a cache-key hash, not a KDF — a\n * low-entropy secret would be recoverable from the URL by brute force.\n * Authentication already travels on cookies, which are not part of this\n * object and never enter the key.\n */\nexport function buildRscHeaders(\n stateTree: StateTree | undefined,\n currentUrl?: string\n): Record<string, string> {\n const headers: Record<string, string> = {\n Accept: RSC_CONTENT_TYPE,\n };\n if (stateTree) {\n headers['X-Timber-State-Tree'] = JSON.stringify(stateTree);\n }\n // Send current URL for intercepting route resolution.\n // The server uses this to determine if an intercepting route should\n // render instead of the actual target route (modal pattern).\n // See design/07-routing.md §\"Intercepting Routes\"\n if (currentUrl) {\n headers['X-Timber-URL'] = currentUrl;\n }\n // Send deployment ID for version skew detection (TIM-446).\n // The server compares this against the current build's ID.\n // On mismatch, the server signals a reload instead of returning\n // an RSC payload with mismatched module references.\n if (clientDeploymentId) {\n headers[DEPLOYMENT_ID_HEADER] = clientDeploymentId;\n }\n return headers;\n}\n\n// ─── Response Header Extraction ──────────────────────────────────\n\n/** Dev-only warning for malformed framework headers. Tree-shaken in production. */\nfunction warnMalformedHeader(headerName: string, raw: string): void {\n if (process.env.NODE_ENV !== 'production') {\n const preview = raw.length > 200 ? raw.slice(0, 200) + '…' : raw;\n console.warn(\n `[timber] Malformed ${headerName} header \\u2014 JSON.parse failed. ` +\n `This indicates a framework bug or header corruption. Raw (first 200 chars): ${preview}`\n );\n }\n}\n\n/**\n * Extract segment metadata from the X-Timber-Segments response header.\n * Returns null if the header is missing or malformed.\n *\n * Format: JSON array of {path, isRequestDependent} objects describing the rendered\n * segment chain from root to leaf. Used to populate the client-side\n * segment cache for state tree diffing on subsequent navigations.\n */\nexport function extractSegmentInfo(response: Response): SegmentInfo[] | null {\n const header = response.headers.get('X-Timber-Segments');\n if (!header) return null;\n try {\n return JSON.parse(header);\n } catch {\n warnMalformedHeader('X-Timber-Segments', header);\n return null;\n }\n}\n\n/**\n * Extract skipped segment paths from the X-Timber-Skipped-Segments header.\n * Returns null if the header is missing or malformed.\n *\n * When the server skips sync layouts the client already has cached,\n * it sends this header listing the skipped segment paths (outermost first).\n * The client uses this to merge the partial payload with cached segments.\n */\nexport function extractSkippedSegments(response: Response): string[] | null {\n const header = response.headers.get('X-Timber-Skipped-Segments');\n if (!header) return null;\n try {\n const parsed = JSON.parse(header);\n return Array.isArray(parsed) ? parsed : null;\n } catch {\n warnMalformedHeader('X-Timber-Skipped-Segments', header);\n return null;\n }\n}\n\n// ─── Redirect Error ──────────────────────────────────────────────\n\n/**\n * Thrown when an RSC payload response contains X-Timber-Redirect header.\n * Caught in navigate() to trigger a soft router navigation to the redirect target.\n */\nexport class RedirectError extends Error {\n readonly redirectUrl: string;\n constructor(url: string) {\n super(`Server redirect to ${url}`);\n this.redirectUrl = url;\n }\n}\n\n/**\n * Thrown when the server signals a version skew (X-Timber-Reload header).\n * Caught in navigate() to trigger a full page reload.\n * See TIM-446.\n */\nexport class VersionSkewError extends Error {\n constructor() {\n super('Version skew detected — server has been redeployed');\n }\n}\n\n/**\n * Thrown when the server returns an error for an RSC payload request.\n * The server sends X-Timber-Error header and a JSON body instead of a\n * RSC stream it cannot answer in-SPA (a deny that needs a fallback page, a\n * broken first read). Caught in\n * navigate() to trigger a hard navigation so the server can render\n * the error page as HTML.\n *\n * See design/10-error-handling.md §\"Error Page Rendering for Client Navigation\"\n */\nexport class ServerErrorResponse extends Error {\n readonly status: number;\n readonly url: string;\n constructor(status: number, url: string) {\n super(`Server error ${status} during navigation to ${url}`);\n this.status = status;\n this.url = url;\n }\n}\n\n/**\n * Thrown when the RSC fetch response has a Content-Type that is not\n * text/x-component — e.g., a static asset (image, CSS, JS) served\n * for a same-origin URL that isn't a route. The response body is\n * cancelled immediately (headers-only cost). Caught in navigate()\n * to trigger a hard navigation; caught in prefetch() to store a\n * negative cache entry so click hard-navigates without a second fetch.\n *\n * See TIM-1231.\n */\nexport class NonRscResponse extends Error {\n readonly url: string;\n constructor(url: string) {\n super(`Non-RSC response for ${url}`);\n this.url = url;\n }\n}\n\n// ─── Stream Completion Tracking ───────────────────────────────────\n\n/**\n * Wrap a response body stream to track when it's fully consumed.\n * Returns a new body that passes all chunks through unchanged, plus\n * a `done` promise that resolves when the last chunk is read (or\n * rejects if the stream errors).\n *\n * createFromFetch's thenable resolves on shell arrival, but callers need to\n * know when the stream is fully decoded: that is what `navigateTransition`'s\n * returned promise means, and what the router's pending store, the Navigation\n * API deferred and `<Link>`'s `isPending` are all timed against.\n */\nfunction trackStreamCompletion(body: ReadableStream<Uint8Array>): {\n body: ReadableStream<Uint8Array>;\n done: Promise<void>;\n} {\n let resolveDone!: () => void;\n let rejectDone!: (e: unknown) => void;\n const done = new Promise<void>((res, rej) => {\n resolveDone = res;\n rejectDone = rej;\n });\n\n const reader = body.getReader();\n const tracked = new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const result = await reader.read();\n if (result.done) {\n controller.close();\n resolveDone();\n } else {\n controller.enqueue(result.value);\n }\n } catch (error) {\n controller.error(error);\n rejectDone(error);\n }\n },\n cancel(reason) {\n reader.cancel(reason);\n resolveDone();\n },\n });\n\n return { body: tracked, done };\n}\n\n// ─── Fetch ───────────────────────────────────────────────────────\n\n/**\n * Fetch an RSC payload from the server and start decoding it.\n *\n * Every response is classified here, once: a version-skew reload, a 204 or\n * 3xx redirect, a server error envelope and a non-RSC body are each turned\n * into their error before `decodeRsc` sees the body. There is no second\n * path — tests decode real Flight bytes through the same code (TIM-1541).\n */\nexport async function fetchRscPayload(\n url: string,\n deps: RouterDeps,\n stateTree?: { segments: string[] },\n currentUrl?: string,\n signal?: AbortSignal\n): Promise<FetchResult> {\n // In static mode, fetch the pre-generated _rsc/*.rsc file directly\n // instead of the route URL with Accept headers. Static hosts ignore\n // Accept headers, so the route URL would return HTML.\n const staticTarget = staticMode ? toStaticRscUrl(url) : null;\n const fetchTarget = staticTarget ? staticTarget.url : url;\n // Static hosts resolve neither partial payloads nor intercepting routes,\n // so neither the state tree nor the source URL is sent — and neither may\n // fragment the cache key of a file that does not vary on them.\n const headers = staticMode\n ? buildRscHeaders(undefined, undefined)\n : buildRscHeaders(stateTree, currentUrl);\n // Skip the cache key when the manifest supplies a content-hashed\n // URL — the hash itself guarantees freshness, and the param would defeat\n // the immutable cache headers on /_rsc/* (TIM-1254).\n const rscUrl = staticTarget?.hashed ? fetchTarget : await appendRscParam(fetchTarget, headers);\n // Deriving the cache key is async (SubtleCrypto), so the fetch is no\n // longer issued in the same tick as the call. A navigation superseded\n // during that window would otherwise still hit the network with an\n // already-aborted signal.\n signal?.throwIfAborted();\n // createFromFetch takes a Promise<Response> and progressively parses\n // the RSC Flight stream as chunks arrive.\n //\n // Intercept the response to read segment metadata before createFromFetch\n // consumes the body. Reading headers does NOT consume the body stream.\n const fetchPromise = deps.fetch(rscUrl, { headers, redirect: 'manual', signal });\n let segmentInfo: SegmentInfo[] | null = null;\n let skippedSegments: string[] | null = null;\n // Track when the full RSC body stream is consumed (not just shell).\n // Initialized to resolved for bodyless responses; overwritten when\n // the response has a body.\n let streamDone: Promise<void> = Promise.resolve();\n\n const wrappedPromise = fetchPromise.then((response) => {\n // Version skew detection (TIM-446): if the server signals a reload,\n // throw VersionSkewError so the caller (router navigate) can trigger\n // a full page reload.\n if (checkReloadSignal(response)) {\n throw new VersionSkewError();\n }\n // Detect server-side redirects. The server returns 204 + X-Timber-Redirect\n // for RSC payload requests instead of a raw 302, because fetch with\n // redirect: \"manual\" turns 302s into opaque redirects (status 0, null body)\n // which crashes createFromFetch when it tries to read the body stream.\n const redirectLocation =\n response.headers.get('X-Timber-Redirect') ||\n (response.status >= 300 && response.status < 400 ? response.headers.get('Location') : null);\n if (redirectLocation) {\n throw new RedirectError(redirectLocation);\n }\n // Detect server error responses. The server returns X-Timber-Error header\n // with a JSON body instead of an RSC stream it cannot answer in-SPA.\n // Hard-navigate so the server renders the error page as HTML.\n // See design/10-error-handling.md §\"Error Page Rendering for Client Navigation\"\n if (response.headers.get(TIMBER_ERROR_HEADER) === '1') {\n throw new ServerErrorResponse(response.status, url);\n }\n // Content-Type guard: reject non-RSC responses before createFromFetch\n // tries to parse the body as Flight data.\n // In static mode, accept octet-stream/text/plain/absent content-type\n // (static hosts serve .rsc files with these), but still reject 404s\n // and text/html (missing .rsc file → host returns 404 page or SPA\n // HTML fallback). See TIM-1231, TIM-1243, TIM-1247.\n if (staticMode) {\n const contentType = response.headers.get('content-type');\n if (\n !response.ok ||\n (contentType && contentType.split(';')[0].trim().toLowerCase() === 'text/html')\n ) {\n response.body?.cancel();\n throw new NonRscResponse(url);\n }\n } else {\n if (!isRscContentType(response.headers.get('content-type'))) {\n response.body?.cancel();\n throw new NonRscResponse(url);\n }\n }\n // Metadata (<title>/<meta>/<link>) now rides the RSC Flight payload\n // as React elements — React 19 Float handles them. See TIM-1151.\n segmentInfo = extractSegmentInfo(response);\n skippedSegments = extractSkippedSegments(response);\n\n // Wrap the body to track full stream consumption. createFromFetch's\n // thenable resolves when the root model (shell) arrives, but we need\n // to know when ALL chunks are read — that is what the navigation\n // promise resolving means, and what keeps the pending store set.\n if (response.body) {\n const tracked = trackStreamCompletion(response.body);\n streamDone = tracked.done;\n streamDone.catch(() => {}); // prevent unhandled rejection\n return new Response(tracked.body, {\n headers: response.headers,\n status: response.status,\n });\n }\n return response;\n });\n // Await headers so segmentInfo is populated.\n await wrappedPromise;\n // Start decoding but do NOT await — return the in-progress thenable.\n // React can render a Flight thenable directly: it suspends on unresolved\n // parts and progressively renders as chunks arrive, spreading work across\n // frames instead of blocking the main thread in one burst.\n const root = deps.decodeRsc(wrappedPromise);\n // One split, one root: the tree and the params it was rendered with come\n // apart here and nowhere else, so nothing downstream has to keep them\n // paired by hand.\n const { tree: payload, params } = splitPayloadRoot(root);\n // Settles once the stream has ended AND the root has decoded, and rejects\n // as soon as either fails. streamDone marks the end of the RSC stream,\n // which is what the navigation promise resolves on; the root's rejection\n // carries decode failures (stale client references, Flight parse errors)\n // so the router's catch block can trigger recovery (stale reload).\n //\n // Not a race between the two: a payload that arrives whole — a small\n // static `.rsc` file — ends its stream before Flight rejects the root it\n // could not decode, and a race resolved on the stream, so the failure\n // never reached recovery and the skew was never recorded (TIM-1541).\n const rootDecoded = Promise.resolve(root).then(() => {});\n rootDecoded.catch(() => {});\n const decodePromise = Promise.all([streamDone, rootDecoded]).then(() => {});\n // Mark handled, like rootDecoded above. The same rejection reaches the\n // router through `payload`, and a navigation that recovers by hard\n // navigating (version skew, non-RSC response) hangs deliberately and never\n // awaits this one — leaving it to surface as an unhandled rejection.\n decodePromise.catch(() => {});\n return {\n payload,\n params,\n decodePromise,\n segmentInfo,\n skippedSegments,\n };\n}\n","/**\n * Page unload detection — suppresses spurious errors during page refresh/navigation.\n *\n * When the user refreshes the page or navigates away while React is still\n * streaming Suspense content, the aborted connection causes streaming errors.\n * These are not application errors — they're a side effect of the browser\n * tearing down the connection. This module tracks whether the page is being\n * unloaded so error boundaries and error handlers can suppress abort-related\n * errors during the unload window.\n *\n * This is the single owner of \"is this document going away\". Anything that\n * needs the answer imports `isPageUnloading()` — an unload flag maintained a\n * second time somewhere else is a flag that will drift out of agreement with\n * this one (TIM-1260).\n *\n * Mutable state is delegated to client/state.ts for singleton guarantees.\n * See design/18-build-system.md §\"Singleton State Registry\"\n *\n * See design/10-error-handling.md §\"Known limitation: deny() inside Suspense and hydration\"\n */\n\nimport { unloading, _setUnloading } from './state.ts';\n\n/**\n * Departure is *committed*: `pagehide` has fired, or this document has called\n * reload() on itself. `beforeunload` alone doesn't qualify — it is\n * speculative, and the user can still cancel out of it.\n */\nlet committed = false;\n\nif (typeof window !== 'undefined') {\n window.addEventListener('beforeunload', () => {\n _setUnloading(true);\n\n // An app with an unsaved-changes prompt can have this cancelled. Nothing\n // fires to say so, so the only signal is that the page is still running\n // afterwards — and timers are blocked while the modal is up, so this task\n // cannot run until the user has chosen. If they left, `pagehide` has\n // already committed and this is a no-op.\n setTimeout(() => {\n if (!committed) _setUnloading(false);\n }, 0);\n });\n\n // pagehide is the committed-departure event, and fires for both navigations\n // and bfcache entry. Safari in particular may skip beforeunload entirely.\n window.addEventListener('pagehide', () => {\n committed = true;\n _setUnloading(true);\n });\n\n window.addEventListener('pageshow', (event) => {\n // A bfcache restore un-does the teardown `pagehide` announced: the same\n // document is alive again, with this module's state intact. Without the\n // reset, every consumer would go on suppressing errors on a live page.\n if (event.persisted) {\n committed = false;\n _setUnloading(false);\n }\n });\n}\n\n/**\n * Returns true if the page is currently being unloaded (user refreshed\n * or navigated away). Error boundaries should suppress errors in this state.\n */\nexport function isPageUnloading(): boolean {\n return unloading;\n}\n","/**\n * Stale Client — knowing when this bundle has been superseded.\n *\n * Layer 1 of version skew handling (see design/33-version-skew.md) is\n * proactive: the server compares `X-Timber-Deployment-Id` against the current\n * build and answers a stale client with `X-Timber-Reload: 1`. That covers\n * every RSC navigation and every server action — as long as there is a server\n * in the request path.\n *\n * This module is the reactive half, plus the state both halves feed. It\n * recognizes the two error shapes a stale client produces on its own:\n *\n * 1. **Stale client references** — React's Flight client throws\n * \"Could not find the module …\" when an RSC payload names a client module\n * ID that isn't in this bundle's manifest.\n * 2. **Chunk load failures** — a content-hashed chunk that no longer exists on\n * the CDN fails to `import()`. Every engine words this differently.\n *\n * It matters most for `output: 'static'`, where there is no server to send the\n * reload header and this is the *only* skew detection that can run.\n *\n * **Nothing here reloads the page.** A stale client is recorded, not acted on;\n * the router turns the next user-initiated navigation into a full document\n * load. See design/33-version-skew.md §\"Recovery on the next navigation\" for\n * why — a self-issued `location.reload()` cannot tell a recovery from a bounce\n * between two live deployments, and mid-rollout it produces exactly that loop.\n *\n * See TIM-1260, TIM-1275.\n */\n\n// The only import: the shared unload state. Kept minimal because this module\n// is reached from the error boundary, a `'use client'` component evaluated in\n// the SSR graph too — a dependency on the client fetch layer would drag that\n// graph along with it.\nimport { isPageUnloading } from './unload-guard.ts';\n\n// ─── Error Shapes ────────────────────────────────────────────────\n\n/**\n * Substrings that identify a failed dynamic import, lowercased for\n * case-insensitive matching. Engines and bundlers each word this\n * differently and none of them expose a stable error code.\n */\nconst CHUNK_LOAD_PATTERNS = [\n // Chromium\n 'failed to fetch dynamically imported module',\n // Firefox\n 'error loading dynamically imported module',\n // Safari\n 'importing a module script failed',\n // Vite's preload helper, for the stylesheet of a lazily-imported chunk\n 'unable to preload css for',\n];\n\n/** Substring React's Flight client uses when a client module ID is unknown. */\nconst STALE_REFERENCE_PATTERN = 'could not find the module';\n\n/**\n * Pull a comparable message out of an unknown thrown value. Rejections cross\n * enough boundaries (event handlers, `unhandledrejection`, Vite's preload\n * event) that the value is not reliably an `Error`.\n */\nfunction messageOf(error: unknown): string {\n if (typeof error === 'string') return error.toLowerCase();\n if (error instanceof Error) return error.message.toLowerCase();\n if (error && typeof error === 'object' && 'message' in error) {\n const message = (error as { message: unknown }).message;\n if (typeof message === 'string') return message.toLowerCase();\n }\n return '';\n}\n\n/**\n * True when the error is React's \"client reference not in this manifest\"\n * failure — the payload was produced by a build this bundle doesn't match.\n */\nexport function isStaleClientReference(error: unknown): boolean {\n return messageOf(error).includes(STALE_REFERENCE_PATTERN);\n}\n\n/**\n * True when the error is a failed dynamic import or CSS preload — the\n * content-hashed chunk this bundle asks for is gone from the CDN.\n */\nexport function isChunkLoadError(error: unknown): boolean {\n if (error instanceof Error && error.name === 'ChunkLoadError') return true;\n const message = messageOf(error);\n return CHUNK_LOAD_PATTERNS.some((pattern) => message.includes(pattern));\n}\n\n// ─── Staleness ───────────────────────────────────────────────────\n\n/**\n * True once this client is known to be running against a superseded\n * deployment. One-way: a document that has gone stale cannot come back, since\n * the only way to get fresh code is to load a new document.\n *\n * In-memory on purpose. Persisting it would be wrong — the next document gets\n * whatever build the server hands it, and if that one is stale too it will\n * find out the same way.\n */\nlet stale = false;\n\n/**\n * True once {@link initStaleClient} has seen a deployment ID — i.e. this is a\n * production build. False in dev, where nothing is ever stale: HMR owns code\n * updates, and a failed dynamic import is a real error the developer needs to\n * see rather than something a page load fixes.\n */\nlet deployed = false;\n\n/** Whether this client has been superseded by a newer deployment. */\nexport function isClientStale(): boolean {\n return stale;\n}\n\n/**\n * Record that the origin has told us this client is stale — the `X-Timber-Reload`\n * header on an RSC or action response. Authoritative, so it is not gated on\n * anything: a dev server never sends the header in the first place.\n */\nexport function markClientStale(): void {\n stale = true;\n}\n\n/**\n * Record staleness if `error` is one of the shapes a superseded bundle\n * produces. Returns whether it did, so a caller mid-navigation can decide to\n * hard-navigate instead of surfacing the error.\n *\n * Inference, unlike {@link markClientStale}, so it is gated on being a\n * production build. This is the single place that gate lives — call sites\n * cannot see each other, and \"remember to gate the next one too\" is not a\n * guarantee.\n */\nexport function markStaleFromError(error: unknown): boolean {\n if (!deployed) return false;\n\n // A document being torn down aborts its in-flight dynamic imports, and an\n // aborted import reads exactly like a chunk the CDN has dropped. That is not\n // evidence of staleness, and the bit outlives the teardown that produced it:\n // a document entering the back-forward cache is frozen, not destroyed, so a\n // false positive recorded on the way out would cost the *restored* page its\n // client-side navigation for good. `unload-guard.ts` clears its own flag on\n // a persisted `pageshow`; this one is one-way by design, so it has to not be\n // set in the first place.\n if (isPageUnloading()) return false;\n\n if (!isStaleClientReference(error) && !isChunkLoadError(error)) return false;\n stale = true;\n return true;\n}\n\n// ─── Initialization ──────────────────────────────────────────────\n\n/**\n * The underlying error Vite attaches to a `vite:preloadError` event.\n *\n * Narrowed at runtime rather than cast: the property is Vite's, not ours, and\n * a shape change should fall back to matching the event itself rather than\n * silently reading `undefined` forever.\n */\nfunction preloadErrorPayload(event: Event): unknown {\n return 'payload' in event ? (event as Event & { payload: unknown }).payload : event;\n}\n\n/**\n * Arm the module, and register the listeners that catch stale-client errors\n * never passing through the router: a lazily imported client component, a\n * preloaded stylesheet, anything that rejects outside a navigation.\n *\n * No-op when `deploymentId` is null — that is dev. Called from the browser\n * entry before hydration, so it precedes any render or navigation that could\n * throw.\n */\nexport function initStaleClient(deploymentId: string | null): void {\n if (!deploymentId) return;\n deployed = true;\n\n // Vite dispatches this for failed chunk/CSS preloads. Note what is *not*\n // here: `preventDefault()`. Recording staleness is not recovering from this\n // error — the page is still broken until the user navigates — so Vite must\n // go on rethrowing it rather than have it silently swallowed.\n window.addEventListener('vite:preloadError', (event) => {\n markStaleFromError(preloadErrorPayload(event));\n });\n\n window.addEventListener('unhandledrejection', (event: PromiseRejectionEvent) => {\n markStaleFromError(event.reason);\n });\n}\n","/**\n * Navigation transition — the router-level hand-off of a navigation's tree to\n * React, and the supersession that governs it.\n *\n * `navigateTransition` runs a navigation's fetch OUTSIDE any transition scope\n * and hands the resulting tree to React through a `NavigationRender`, which\n * is a synchronous `startTransition` around `root.render` (client/react-root.ts).\n * Two React behaviours force that shape; both were measured on React 19.2.7\n * (tests/navigation-transition-suspense.test.ts pins the observable half).\n *\n * 1. A transition scope does not survive an `await`. `startTransition`\n * restores the previous scope in its `finally`, which for an async\n * callback runs when that callback RETURNS — i.e. at its first `await`.\n * So an update scheduled past an await inside `startTransition(async …)`\n * is an ordinary urgent update:\n *\n * startTransition(() => render(x)) -> 'HOME' held\n * startTransition(async () => { await p; render(x) }) -> fallback shown\n *\n * Left uncorrected, every navigation whose new tree suspends replaces the\n * visible page with a Suspense fallback — the exact thing NavigationRoot\n * exists to prevent (TIM-1306). React documents the caveat under\n * `startTransition`: updates after an await need their own transition.\n *\n * 2. Re-wrapping *inside* the async callback is not enough. Returning a\n * thenable from `startTransition` hands it to `ReactSharedInternals.S`,\n * which calls react-dom's `entangleAsyncAction`. That opens an action\n * scope: `currentEntangledLane` collects EVERY transition update\n * scheduled while the scope is open — including one from a nested,\n * fully synchronous `startTransition` — and rendering that lane throws\n * `currentEntangledActionThenable`, suspending until the action settles.\n * Which is after the promise `navigateTransition` hands back, so a caller\n * that awaits a navigation and then reads the DOM sees the departing\n * page, and the TIM-1301 publish (a layout effect on the commit) is just\n * as late. (Not `ReactSharedInternals.asyncTransitions` — that counter is\n * write-only in 19.2.7.)\n *\n * No async action is created here, so every navigation commits as soon as\n * React can render its destination — where TIM-1301 put it. That holds for\n * ALL of them. It used not to hold for `<Link>`, which wrapped\n * `router.navigate()` in its own `useTransition`: that action scope entangled\n * the root's updates just the same, so a Link navigation committed only once\n * the payload had finished decoding, and with it `pushState`, the segment\n * cache and `timber:navigation-end`. Link now calls `router.navigate()`\n * outside any transition and tracks its own `isPending` with a plain\n * `useState` (TIM-1307).\n *\n * Nothing here may reopen an action scope: no `startTransition` callback in\n * this path may return a thenable, and no caller may invoke this from inside\n * a React action scope — except one that settles that action at `handedOff`,\n * which commits the action and the tree together on purpose (a server action\n * redirect, TIM-1573). That is a rule about `startTransition`, not about\n * `perform` — `perform` is async by contract and is awaited OUTSIDE any\n * transition scope, which is exactly why it is safe.\n *\n * Standalone `startTransition` rather than `useTransition`'s is deliberate:\n * the hook's is tied to a single fiber and tracks one async callback at a\n * time, and two overlapping navigations through it corrupted React's hook\n * tracking (\"Rendered more hooks than during the previous render\"). Each\n * navigation needs an independent lane. This matches the Next.js pattern\n * (TIM-625): \"No useTransition in the router at all — only standalone\n * startTransition.\"\n *\n * See design/19-client-navigation.md §\"How Pending State Works\"\n */\n\nimport type { ReactNode } from 'react';\nimport type { NavigationRender } from './navigation-root.tsx';\n\n// ─── Transition Result ──────────────────────────────────────────\n\n/**\n * What a navigation's `perform()` hands back to the transition.\n *\n * Declared once and shared by every layer that passes it along — the router's\n * `RouterDeps.navigateTransition` imports it too — so a field cannot be added\n * to the producer and dropped by the adapter in between. `E` is the element\n * type: `ReactNode` here, `unknown` in the router, which never touches it.\n */\nexport interface TransitionResult<E = ReactNode> {\n /** The wrapped tree to render. */\n element: E;\n /** Resolves when the Flight stream finishes decoding, or null. */\n decodePromise: Promise<void> | null;\n /**\n * Publishes the navigation's state — segment cache, pathname, address bar,\n * history stack, and the client's record of the mounted tree — and\n * announces it to listeners outside React.\n *\n * Run when React commits this tree, not when the tree is handed over: a\n * tree React is still waiting on, or one a later navigation replaces first,\n * has been given to React without being on screen. A superseded navigation\n * never runs it and leaves every one of those consumers describing the\n * route still on screen (TIM-1301).\n */\n commit: () => void;\n}\n\n/** What happened to this navigation's tree. */\nexport type CommitOutcome = 'committed' | 'superseded' | 'failed';\n\n/**\n * A navigation as its caller sees it: three endings, which arrive in either\n * order.\n *\n * The handle itself is the promise that settles when the payload has\n * **decoded** — or the navigation was superseded or failed. Scroll\n * restoration, the Navigation API deferred and the router's pending store\n * are timed against it. It does not mean the destination is on screen: a\n * destination that streams commits before its decode finishes, and one\n * waiting on a Suspense boundary commits after.\n *\n * Built by attaching the other two endings to that promise, so awaiting a\n * navigation keeps meaning what it always has, and a caller that wants more\n * than one ending awaits them side by side instead of combining callbacks\n * by hand (TIM-1462).\n */\nexport interface NavigationHandle extends Promise<void> {\n /**\n * Resolves once the navigation's final tree — after any redirect the\n * router follows — has been handed to React: its transition is scheduled,\n * and React has not yet committed it. Never rejects.\n *\n * A navigation that ends without handing a tree over (superseded or\n * failed first) resolves it as it settles, so `router.navigate()` and\n * `refresh()` never leave it pending past the handle itself.\n * `navigateTransition`'s own handle does not — a redirect the router\n * follows hands its tree over later — so there it may never settle.\n *\n * A server action that redirects settles its `useActionState` here, so\n * React commits the action's result and the destination together\n * (TIM-1573).\n */\n readonly handedOff: Promise<void>;\n /**\n * Resolves exactly once, never rejects: `'committed'` when React commits\n * this navigation's tree, or — so nothing waits on a commit that will\n * never come — `'superseded'` or `'failed'` when it is abandoned:\n * superseded by a newer navigation (before or after its tree was handed\n * to React) or failed. A followed redirect is one logical navigation, so\n * this is the redirect hop's outcome. `<Link>` holds `isPending` until\n * both this and the decode have settled (TIM-1418).\n *\n * The one exception is a stale client, which leaves the SPA before it\n * navigates at all: the document is being replaced, and nothing on the\n * handle settles. A navigation that fails into a document load\n * (a server error, a non-RSC response, a version skew) settles this\n * `'failed'` before it leaves.\n */\n readonly committed: Promise<CommitOutcome>;\n}\n\n/** The outcome of a render that ended without committing. */\nexport function abandonedOutcome(owner: RenderOwner): CommitOutcome {\n return owner.outcome === 'superseded' ? 'superseded' : 'failed';\n}\n\n// ─── RenderOwner ────────────────────────────────────────────────\n\n/**\n * A per-render identity that replaces the transition counter, the\n * `handedOffNavAborts` set, and the `AbortController`-as-owner pattern.\n *\n * The navigation lifecycle holds one slot (`current: RenderOwner | null`).\n * All supersession is \"take the slot\":\n *\n * - Navigation takes unconditionally (previous owner gets settled + aborted\n * if !handedOff).\n * - Revalidation takes only if empty (epoch check).\n * - Handover gate before root.render checks `current === owner`.\n * - `settle()` is called from NavigationRoot publish (committed), slot\n * takeover (superseded), or rejection (failed).\n *\n * `settle()` records the outcome and resolves `displaced` for non-committed\n * outcomes. The `outcome` field is first-wins with one exception:\n * `settle('superseded')` overrides a prior `'committed'`, because a\n * committed-but-still-decoding navigation can be displaced by a successor\n * and the post-decode check must throw rather than letting the old\n * navigation continue.\n *\n * TIM-1481: replaces counter + waiters + bumpTransitionCounter +\n * supersedeNavigationTransitions + handedOffNavAborts + globalThis singleton.\n */\nexport interface RenderOwner {\n readonly kind: 'navigation' | 'revalidation';\n readonly fetchAbort: AbortController;\n handedOff: boolean;\n /** Sync read for the post-perform() check. null until settled. */\n outcome: CommitOutcome | null;\n /**\n * Resolves when this owner is displaced — a successor supersedes it or it\n * fails. Does NOT resolve on commit: a committed navigation still waits\n * for its decode to finish. Used to stop waiting on a decode that is no\n * longer this navigation's business.\n */\n readonly displaced: Promise<void>;\n /**\n * Record this owner's outcome and, for non-committed outcomes, resolve\n * `displaced`. First-wins with one exception: `settle('superseded')`\n * overrides a prior `'committed'`.\n */\n settle: (outcome: CommitOutcome) => void;\n}\n\n/**\n * Create a fresh RenderOwner. Exported so tests that call\n * `navigateTransition` directly can construct one without a router.\n */\nexport function createRenderOwner(kind: 'navigation' | 'revalidation'): RenderOwner {\n let resolveDisplaced!: () => void;\n const displaced = new Promise<void>((r) => {\n resolveDisplaced = r;\n });\n\n const owner: RenderOwner = {\n kind,\n fetchAbort: new AbortController(),\n handedOff: false,\n outcome: null,\n displaced,\n settle(outcome: CommitOutcome): void {\n if (owner.outcome === null) {\n owner.outcome = outcome;\n } else if (outcome === 'superseded' && owner.outcome === 'committed') {\n // A committed-but-still-decoding navigation can be displaced by a\n // successor. Override so the post-decode check throws AbortError\n // rather than letting the old navigation continue with scroll\n // restoration while a newer navigation is active.\n owner.outcome = 'superseded';\n }\n // Resolve `displaced` for any non-committed outcome, even if the\n // outcome field was already set. A committed-but-still-decoding\n // navigation must be woken when a successor supersedes it — the old\n // counter-based waiter did this because the counter bumped regardless\n // of commit state. A commit does NOT resolve displaced: that would\n // end the decode wait early, clearing pending state before the Flight\n // stream finishes.\n if (outcome !== 'committed') {\n resolveDisplaced();\n }\n },\n };\n return owner;\n}\n\n// ─── navigateTransition ─────────────────────────────────────────\n\n/**\n * Run a full navigation, handing its tree to React in a transition.\n *\n * The `perform` callback fetches the RSC payload, updates router state, and\n * returns the wrapped React element. `perform` is async by contract and runs\n * OUTSIDE any transition scope — only the `render` that hands its result over\n * is wrapped, in a synchronous `startTransition` (see the module comment).\n *\n * Do not call this from inside a React action scope, and never let a\n * `startTransition` callback in this path return a thenable: either opens an\n * action scope that entangles the update and defers the commit until the\n * action settles (TIM-1306, TIM-1307).\n *\n * Returns a `NavigationHandle` whose promise resolves when the async work\n * completes — the payload is fetched, decoded, and handed to React. It does\n * **not** wait for React to\n * commit the tree, so the state that publishes on that commit (address bar,\n * segment cache, history entry, pathname) may still be a beat behind when it\n * resolves. Anything that needs the destination to be current should listen\n * for `timber:navigation-end`, which is dispatched by the publish itself.\n *\n * Awaiting the publish here was tried and rejected: it makes the promise\n * depend on a React commit, which never arrives if the root unmounts\n * mid-navigation, and deadlocks any caller that awaits a navigation inside\n * `act()`.\n *\n * Rejects with an `AbortError` when a newer transition started while this\n * one's `perform()` was in flight — the stale tree is never handed to React\n * and its `commit` never runs (TIM-629, TIM-1301).\n *\n * The commit is the handle's `committed`, a separate promise that nothing is\n * forced to await — so it can depend on React where the decode promise must\n * not. It settles exactly once: when React commits this navigation's tree,\n * or when the navigation is abandoned instead — superseded by a newer\n * transition (before or after its tree was handed to React) or failed. It is\n * how `<Link>` keeps `isPending` up until the destination is on screen\n * without scheduling anything against React's lanes (TIM-1418).\n *\n * `types` are the view transition types `render` adds beside the tree\n * (design/37-navigation-api.md §\"Transition types\"). They are fixed before\n * `perform` runs — what a render animates as is decided by the operation that\n * started it, not by what the fetch returns.\n *\n * `owner` is the `RenderOwner` for this render (TIM-1481). Supersession is\n * detected via `owner.outcome` (sync) and `owner.displaced` (async).\n * No module-level state; no globalThis singleton.\n *\n * `handedOff` resolves right after `render` has scheduled the tree — in a\n * microtask, so before the Scheduler task that renders and commits it — and not\n * at all when the navigation ends first. A caller inside a React action scope\n * may settle that action there (and only there): the render is already\n * entangled with the scope, so settling commits the action and this tree\n * together, where settling earlier commits the action alone and settling on\n * the commit deadlocks. The server action redirect is that caller (TIM-1573).\n *\n * Used for: navigate(), refresh(), popstate with fetch.\n */\nexport function navigateTransition(\n owner: RenderOwner,\n perform: () => Promise<TransitionResult>,\n render: NavigationRender,\n types: readonly string[]\n): NavigationHandle {\n const superseded = () => new DOMException('Navigation superseded', 'AbortError');\n\n let handOff!: () => void;\n const handedOff = new Promise<void>((resolve) => (handOff = resolve));\n // Exactly once, on whichever comes first — a promise settles only once:\n // the commit, a supersession, or a failure.\n let settleCommit!: (outcome: CommitOutcome) => void;\n const committed = new Promise<CommitOutcome>((resolve) => (settleCommit = resolve));\n\n // Watch for displacement from outside (a successor taking the slot).\n void owner.displaced.then(() => {\n if (owner.outcome === 'superseded') settleCommit('superseded');\n });\n\n const decoded = (async () => {\n try {\n const { element, decodePromise, commit } = await perform();\n if (owner.outcome !== null) {\n decodePromise?.catch(() => {});\n throw superseded();\n }\n // Hand the tree over with its commit attached. NavigationRoot runs it if\n // and when React commits this tree, so a navigation that is superseded\n // while its payload streams publishes nothing (TIM-1301).\n //\n // This is THE update that must not hide the departing page (TIM-1306);\n // `render` is the synchronous transition around `root.render`.\n render(\n element,\n () => {\n try {\n commit();\n } finally {\n settleCommit('committed');\n }\n },\n types\n );\n handOff();\n // React may commit the tree before this settles — that is the point:\n // the destination reveals as React is able to render it\n // rather than waiting for the whole Flight stream. The await is here so\n // the promise this function hands back still means \"the payload is\n // decoded\", which is what the router's scroll restoration and\n // `<Link>`'s `isPending` are timed against.\n //\n // ...unless this navigation loses first, in which case it stops waiting\n // on a stream that is no longer its business.\n if (decodePromise) {\n await settleOnDecodeOrDisplacement(decodePromise, owner);\n }\n if (owner.outcome !== null && owner.outcome !== 'committed') {\n throw superseded();\n }\n } catch (error) {\n settleCommit(abandonedOutcome(owner));\n throw error;\n }\n })();\n return Object.assign(decoded, { handedOff, committed });\n}\n\n/**\n * Wait for the payload to finish decoding, OR for this owner to be\n * displaced — whichever happens first.\n *\n * A superseded navigation must stop waiting on its own stream. The stream is\n * deliberately NOT aborted once its tree has been handed to React (the tree\n * may be on screen with boundaries still feeding from it — see\n * `RenderOwner.handedOff`), so there is nothing left to make `decodePromise`\n * settle promptly. Awaiting it bare would keep the loser's\n * `router.navigate()` promise pending for the rest of the stream — and\n * forever if it stalls — which is what `<Link>`'s `isPending` is timed\n * against, so the losing link would sit spinning while the winner loaded\n * (codex on #1004).\n *\n * A decode *failure* still propagates: it is a real error for this\n * navigation, and the caller's recovery is timed against it.\n */\nfunction settleOnDecodeOrDisplacement(\n decodePromise: Promise<void>,\n owner: RenderOwner\n): Promise<void> {\n // Only bail early for displacement (superseded/failed), not for commit.\n // A committed tree still needs to wait for its decode to finish — pending\n // state and the Link indicator are timed against it.\n if (owner.outcome !== null && owner.outcome !== 'committed') {\n return Promise.resolve();\n }\n return Promise.race([decodePromise, owner.displaced]);\n}\n","/**\n * Router Skew Recording — turning a rejection into \"this bundle is superseded\".\n *\n * Detection lives in `stale-client.ts`; this is the one place the router (and\n * anything else holding an RSC rejection) turns an error into that verdict.\n * Recovery is not here: every path that gives up on client-side navigation —\n * skew or not — leaves through `createSpaExits()` in `router-effects.ts`.\n *\n * See design/33-version-skew.md §\"Recovery on the next navigation\"\n */\n\nimport { VersionSkewError } from './rsc-fetch.ts';\nimport { markClientStale, markStaleFromError } from './stale-client.ts';\n\n/**\n * Record a version skew if `error` is one, and report whether it was.\n *\n * `VersionSkewError` is the origin saying so outright; the reactive shapes are\n * inferred from the error text and are a no-op in dev.\n *\n * Closes over nothing — anywhere an RSC payload can fail needs it, including\n * places that have no router instance to hand.\n */\nexport function recordSkew(error: unknown): boolean {\n if (error instanceof VersionSkewError) {\n markClientStale();\n return true;\n }\n return markStaleFromError(error);\n}\n","/**\n * Router Effects — full-page navigation and post-paint scroll.\n *\n * The two things the router does *to the document* rather than to its own\n * state: leaving the SPA entirely, and moving the scroll position once React\n * has committed. Extracted from `router.ts` to keep that file focused on\n * navigation state (see design/18-build-system.md §\"No file >500 lines\").\n *\n * See design/19-client-navigation.md §\"Scroll Restoration\"\n */\n\nimport { setHardNavigating } from './navigation-root.tsx';\nimport {\n abandonedOutcome,\n type CommitOutcome,\n type NavigationHandle,\n type RenderOwner,\n} from './navigation-transition.ts';\nimport { RedirectError, ServerErrorResponse, NonRscResponse } from './rsc-fetch.ts';\nimport { recordSkew } from './router-skew.ts';\n\n/** The subset of `RouterDeps` the post-paint scroll effects need. */\nexport interface ScrollEffectDeps {\n scrollTo: (x: number, y: number) => void;\n afterPaint?: (callback: () => void) => void;\n scrollToHash?: (hash: string) => boolean;\n}\n\nexport interface ScrollEffects {\n /**\n * Schedule scroll restoration after the next paint and fire the\n * scroll-restored event. Used by navigate, popstate, and refresh.\n */\n restoreScrollAfterPaint: (scrollY: number) => void;\n /**\n * Scroll to the element matching the URL #fragment after paint, falling\n * back to scroll-to-top when no element matches (matching full-page-load\n * behavior for an unknown fragment). Used by forward navigation to a\n * hash-bearing URL (TIM-1035).\n */\n scrollToHashAfterPaint: (hash: string) => void;\n}\n\nexport function createScrollEffects(deps: ScrollEffectDeps): ScrollEffects {\n /** Run a callback after the next paint (after React commit). */\n function afterPaint(callback: () => void): void {\n if (deps.afterPaint) {\n deps.afterPaint(callback);\n } else {\n callback();\n }\n }\n\n function restoreScrollAfterPaint(scrollY: number): void {\n afterPaint(() => {\n deps.scrollTo(0, scrollY);\n window.dispatchEvent(new Event('timber:scroll-restored'));\n });\n }\n\n function scrollToHashAfterPaint(hash: string): void {\n afterPaint(() => {\n if (deps.scrollToHash?.(hash) !== true) {\n deps.scrollTo(0, 0);\n }\n window.dispatchEvent(new Event('timber:scroll-restored'));\n });\n }\n\n return { restoreScrollAfterPaint, scrollToHashAfterPaint };\n}\n\n/**\n * Leave the SPA and never come back.\n *\n * Every router path that gives up on client-side navigation does the same\n * three things: flag the hard navigation so the Navigation API and React stop\n * acting on a dying document, perform the document load, then block forever so\n * the caller cannot carry on rendering into it. The returned promise is\n * deliberately unresolvable — `location` assignment does not stop this turn of\n * the event loop.\n *\n * Callers: server error, non-RSC response, and every version skew path\n * ([33-version-skew.md](../../../../design/33-version-skew.md)).\n */\nexport function leaveSpa(url: string, fromUrl: string): Promise<never> {\n setHardNavigating(true);\n hardNavigate(url, fromUrl);\n return new Promise<never>(() => {});\n}\n\nexport interface SpaExitDeps {\n /** The owner that holds the router right now, or null when idle. */\n currentOwner: () => RenderOwner | null;\n /** Supersede whatever is in flight and take ownership. */\n supersede: () => void;\n}\n\nexport interface SpaExits {\n /**\n * Leave the SPA — but only if `owner` still owns the router. Every\n * failure a navigation can end on (a server error, a non-RSC response, a\n * version skew) can surface long after the user has clicked something else:\n * a fetch that was never cancellable, a Flight thenable that rejects late.\n * Hard navigating to the abandoned URL would undo that click, so a\n * navigation that no longer owns the router does nothing and lets the one\n * that does drive. Never resolves when it does navigate.\n *\n * Must be called from inside the `runNavigation()` callback. That function's\n * `finally` clears the current controller, so an ownership check downstream\n * of it compares against `null` and never leaves at all.\n */\n leaveSpaIfOwned: (owner: RenderOwner, url: string, fromUrl: string) => Promise<void>;\n\n /**\n * Leave the SPA from a path that never entered `runNavigation()` — the\n * stale-client short circuits, which decide before any fetch is attempted.\n *\n * Supersedes first. Nothing else on those paths takes ownership, so without\n * it an in-flight navigation keeps the router: when its fetch or decode\n * fails a moment later it still passes its own ownership check and hard\n * navigates to *its* URL, overwriting the document load started here.\n */\n leaveSpaSuperseding: (url: string, fromUrl: string) => Promise<never>;\n}\n\n/**\n * The two ownership-aware ways out of the SPA.\n *\n * Both wrap {@link leaveSpa} with the question \"is this navigation still the\n * one the user is waiting for?\" — asked before leaving on a failure, answered\n * by force on a path that decided before any navigation began. They live\n * together because every caller of `leaveSpa()` needs one or the other, and\n * an unguarded call is the bug (TIM-1275, TIM-1276).\n */\nexport function createSpaExits({ currentOwner, supersede }: SpaExitDeps): SpaExits {\n async function leaveSpaIfOwned(owner: RenderOwner, url: string, fromUrl: string): Promise<void> {\n if (currentOwner() !== owner) return;\n await leaveSpa(url, fromUrl);\n }\n\n function leaveSpaSuperseding(url: string, fromUrl: string): Promise<never> {\n supersede();\n return leaveSpa(url, fromUrl);\n }\n\n return { leaveSpaIfOwned, leaveSpaSuperseding };\n}\n\nexport interface NavigationRecoveryDeps {\n /** The owner that holds the router right now, or null when idle. */\n currentOwner: () => RenderOwner | null;\n leaveSpaIfOwned: SpaExits['leaveSpaIfOwned'];\n /**\n * Follow a redirect to `url` — the router's own `navigate()`, carrying\n * the interrupted navigation's {@link RedirectHop}.\n */\n navigate: (url: string, hop: RedirectHop) => NavigationHandle;\n}\n\n/**\n * What a redirect hop inherits from the navigation the redirect interrupted.\n */\nexport interface RedirectHop {\n /**\n * The view transition types of the interrupted render, so a redirected Back\n * still animates as Back and a link's own `transitionTypes` survive the\n * hop (TIM-1471).\n */\n types: readonly string[];\n /**\n * The interrupted navigation's history mode. A push stays a push: the\n * address bar moves only when a destination commits, so the interrupted\n * navigation wrote no entry, and replacing would overwrite the page being\n * left — Back would skip it (TIM-1571). A refresh or a traversal replaces:\n * the browser is already on the entry being redirected.\n */\n replace: boolean;\n /**\n * The interrupted navigation's scroll mode. `<Link scroll={false}>` to a\n * URL that redirects — a non-canonical `/x/` among them — still keeps the\n * scroll position; the hop would otherwise default to scrolling to the top.\n */\n scroll: boolean;\n}\n\n/**\n * The endings a navigation reports beside its decode — the `handedOff` and\n * `committed` of its {@link NavigationHandle} — fed by the renders it runs.\n *\n * A followed redirect is one logical navigation, so its endings are the\n * redirect hop's: the hop's commit is the one the caller is waiting for.\n * `<Link>` holds `isPending` until it, and a `'failed'` from the\n * interrupted render would release it on the hop's decode, ahead of a\n * commit React is still holding (TIM-1571). A server action redirect waits\n * for the tree that is finally handed to React, which is the redirected one\n * (TIM-1573). So a render's `'failed'` is not this navigation's:\n * `navigateTransition` settles it as soon as `perform` throws, before the\n * router knows the failure is a redirect it will follow. Recovery decides,\n * and either adopts the hop or settles the outcome itself.\n */\nexport interface NavigationEndings {\n /** Report a render's endings — every outcome but `'failed'` at once. */\n track(render: NavigationHandle): void;\n /** Make a redirect hop's endings this navigation's. */\n adopt(hop: NavigationHandle): void;\n /** Settle `committed`. The first outcome wins. */\n settle(outcome: CommitOutcome): void;\n}\n\n/**\n * Run a navigation as a {@link NavigationHandle}. `run` is the navigation:\n * its promise is the handle's decode, and it reports its renders' other\n * endings into the {@link NavigationEndings} it is given.\n *\n * A navigation that ends without reporting — superseded, or failed, before\n * any render — settles them as it ends: `committed` as `'failed'` if it\n * rejected (an outcome already reported wins), and `handedOff` either way,\n * so neither waits on a render that will not come.\n */\nexport function runAsHandle(run: (endings: NavigationEndings) => Promise<void>): NavigationHandle {\n let handOff!: () => void;\n const handedOff = new Promise<void>((resolve) => (handOff = resolve));\n let settle!: (outcome: CommitOutcome) => void;\n const committed = new Promise<CommitOutcome>((resolve) => (settle = resolve));\n const endings: NavigationEndings = {\n track(render) {\n void render.handedOff.then(handOff);\n void render.committed.then((outcome) => {\n if (outcome !== 'failed') settle(outcome);\n });\n },\n adopt(hop) {\n void hop.handedOff.then(handOff);\n void hop.committed.then(settle);\n },\n settle,\n };\n // Handled here and rethrown, so a caller that ignores the handle still\n // sees the rejection as unhandled — the regime `useRouter().push()` relies\n // on.\n const decoded = run(endings).then(handOff, (error: unknown) => {\n settle('failed');\n handOff();\n throw error;\n });\n return Object.assign(decoded, { handedOff, committed });\n}\n\n/**\n * The URL a redirect hop navigates to. A redirect target without a fragment\n * keeps the one the navigation asked for, as a browser does for a 3xx\n * (RFC 9110 §10.2.2): the server never sees the fragment, so a soft redirect\n * — `<Link href=\"/docs/#install\">` answered with `/docs` — cannot carry it.\n */\nexport function redirectHopUrl(redirectUrl: string, requestedUrl: string): string {\n if (redirectUrl.includes('#')) return redirectUrl;\n const hashIndex = requestedUrl.indexOf('#');\n return hashIndex === -1 ? redirectUrl : redirectUrl + requestedUrl.slice(hashIndex);\n}\n\n/**\n * Answer the failures an RSC fetch can end on, or report that this one is not\n * ours to answer.\n *\n * Returns `true` when the error was handled; the caller rethrows on `false`.\n * Handling a failure by leaving the SPA never resolves at all — the document\n * is going away and the caller must not carry on rendering into it.\n *\n * There is exactly one family of these and one response to it, so it lives in\n * one function rather than once per fetch path. `navigate()`, `refresh()` and\n * an uncached traversal all reach it: the latter two used to rethrow instead,\n * and since nobody awaits a traversal that meant pressing Back on a 500 left\n * the user on the old document with an unhandled rejection (TIM-1277).\n *\n * Order matters in exactly one way: `recordSkew()` ends in error-*text*\n * matching, so it goes last and can never pre-empt a framework control-flow\n * signal whose message happens to read like a stale bundle. The class checks\n * above it are mutually exclusive, so their order is free.\n *\n * Must be called from inside the `runNavigation()` callback — see\n * {@link SpaExits.leaveSpaIfOwned}.\n */\nexport function createNavigationRecovery({\n currentOwner,\n leaveSpaIfOwned,\n navigate,\n}: NavigationRecoveryDeps) {\n return async function recoverFromNavigationError(\n error: unknown,\n owner: RenderOwner,\n url: string,\n fromUrl: string,\n /** What a redirect hop inherits from the navigation that failed. */\n hop: RedirectHop,\n /** The failed navigation's endings; a followed redirect's become them. */\n endings: NavigationEndings\n ): Promise<boolean> {\n if (error instanceof RedirectError) {\n // Same ownership rule as leaving the SPA: a superseded navigation must\n // not steer the document to the destination it was abandoned for.\n if (currentOwner() !== owner) {\n endings.settle('superseded');\n return true;\n }\n const redirected = navigate(redirectHopUrl(error.redirectUrl, url), hop);\n endings.adopt(redirected);\n await redirected;\n return true;\n }\n // Anything else ends this navigation here — superseded if a successor\n // took the router, failed otherwise.\n endings.settle(abandonedOutcome(owner));\n // A server error, a non-RSC response and a version skew all end the same\n // way: hand `url` back to the server as a document load, so it can render\n // the outcome as HTML (design/10-error-handling.md §\"Error Page Rendering\n // for Client Navigation\").\n if (\n error instanceof ServerErrorResponse ||\n error instanceof NonRscResponse ||\n recordSkew(error)\n ) {\n await leaveSpaIfOwned(owner, url, fromUrl);\n return true;\n }\n return false;\n };\n}\n\n/**\n * Perform the full document load.\n *\n * `fromUrl` is the URL the navigation departed from, passed explicitly\n * because the address bar may have already been updated.\n *\n * When the target differs from the departure point only by #fragment,\n * assigning `href` is a hash change, not a load — so assign first (to update\n * the address bar) and then reload (TIM-1235).\n */\nexport function hardNavigate(url: string, fromUrl: string): void {\n const current = new URL(fromUrl, window.location.origin);\n const target = new URL(url, window.location.origin);\n if (target.pathname === current.pathname && target.search === current.search) {\n window.location.href = url;\n window.location.reload();\n } else {\n window.location.href = url;\n }\n}\n","'use client';\n\n/**\n * The one way a status page tells the router it is on screen.\n *\n * A status page replaces a subtree, and the segment cache must not learn a\n * chain that never mounted (see `navigation-commit.ts` §\"What a status page\n * teaches the cache\"). Status pages are produced in three places — an\n * in-tree catch site rendering the page it owns, the server's fallback\n * renderers, and a client boundary rendering its fallback for a Flight row —\n * and every one of them wraps the page in this marker, so the report does\n * not depend on which producer it was. In particular the in-tree case, the\n * common `access.ts` deny, never involves a client boundary at all.\n *\n * A layout effect, on every commit that renders the marker rather than on\n * mount only: React reuses the fiber when one status page is replaced by\n * another at the same position, and the second one must report too. Layout\n * effects run child-before-parent, so the report lands before the ancestor\n * `NavigationRoot` publishes the same commit, and never for a render React\n * discards. Idempotent, so StrictMode's double invocation and a status page\n * re-rendering on its own state are harmless. See TIM-1495.\n */\n\nimport { useLayoutEffect, type ReactNode } from 'react';\nimport { reportStatusPageRendered } from './navigation-commit.ts';\n\nexport function StatusPageMarker({ children }: { children: ReactNode }): ReactNode {\n useLayoutEffect(() => {\n reportStatusPageRendered();\n });\n return children;\n}\n","/**\n * The digest an unhandled render error carries across Flight, and the\n * correlation ID error pages read back out of it.\n *\n * Flight's `onError` (server/rsc-entry/rsc-stream.ts) returns this string for\n * any error that is not a deny or redirect, and React sets it as `digest` on\n * the Error it revives for that row, in SSR and on the client alike. The\n * `errorId` is the one the server logged the error with, so an error page\n * that shows it gives the reader something to quote that an operator can\n * find. It is the `digest` prop every TSX error page receives.\n *\n * `message` is the real message only in dev; production sends a fixed string\n * (design/13-security.md §\"Errors don't leak\").\n */\n\ninterface ErrorRowDigest {\n type: 'error';\n message: string;\n errorId: string;\n}\n\nexport function encodeErrorDigest(digest: Omit<ErrorRowDigest, 'type'>): string {\n const row: ErrorRowDigest = { type: 'error', ...digest };\n return JSON.stringify(row);\n}\n\n/**\n * The correlation ID in an error's Flight digest, or `null` when the error\n * carries none — a deny or redirect row, an error that never crossed Flight,\n * or anything that is not an object.\n */\nexport function errorDigestId(error: unknown): string | null {\n if (typeof error !== 'object' || error === null) return null;\n const digest: unknown = Reflect.get(error, 'digest');\n if (typeof digest !== 'string') return null;\n let parsed: unknown;\n try {\n parsed = JSON.parse(digest);\n } catch {\n // A digest someone else set (a library's own error): not ours to read.\n return null;\n }\n if (typeof parsed !== 'object' || parsed === null) return null;\n const errorId: unknown = Reflect.get(parsed, 'errorId');\n return Reflect.get(parsed, 'type') === 'error' && typeof errorId === 'string' ? errorId : null;\n}\n","'use client';\n\n/**\n * Framework-injected React error boundary.\n *\n * Catches errors thrown by children and renders a fallback component\n * with the appropriate props based on error type:\n * - DenySignal (4xx) → { status, data }\n * - Unhandled error (500) → { error, digest, reset }, where `digest` is the\n * ID the server logged the error with (shared/error-digest.ts)\n *\n * The `status` prop controls which errors this boundary catches:\n * - Specific code (e.g. 403) → only that status\n * - Category (400) → any 4xx\n * - Category (500) → any 5xx\n * - Omitted → catches everything (error.tsx behavior)\n *\n * See design/10-error-handling.md §\"Status-Code Files\"\n */\n\nimport { Component, createContext, createElement, useContext, type ReactNode } from 'react';\nimport { getRouterOrNull } from './router-ref.ts';\nimport { markStaleFromError } from './stale-client.ts';\nimport { StatusPageMarker } from './status-page-marker.tsx';\nimport { errorDigestId } from '../shared/error-digest.ts';\nimport { leaveSpa } from './router-effects.ts';\n// Page unload detection: when the page is being torn down, error boundaries\n// suppress activation — the error is from the aborted connection, not the\n// application. unload-guard.ts is the single owner of that state; this module\n// used to keep its own copy, which drifted (TIM-1260).\nimport { isPageUnloading } from './unload-guard.ts';\n\n// ─── Ancestry Context ────────────────────────────────────────────────────────\n\n/**\n * Tracks the chain of segment keys from root to the current boundary.\n * Each keyed `TimberErrorBoundary` appends its `segmentKey`; unkeyed\n * slot boundaries pass the parent value through. The claim rule uses\n * this to find the first *reachable* owner from the `owners` list,\n * eliminating the owner-below-throw-site escape. See TIM-1450.\n */\nconst DenyAncestryContext = createContext<readonly string[]>([]);\n\nexport { DenyAncestryContext };\n\n// ─── Digest Types ────────────────────────────────────────────────────────────\n\n/** Structured digest returned by RSC onError for DenySignal. */\ninterface DenyDigest {\n type: 'deny';\n status: number;\n data: unknown;\n /**\n * Ordered candidate owners — segment keys of segments with matching deny\n * pages, best match first. Present = addressed (a boundary should render\n * it). In-tree hoists produce a single-element list; late addressing\n * (TIM-1450) produces the full candidate list so the boundary can find the\n * first *reachable* owner via its ancestry context.\n */\n owners?: string[];\n /**\n * A deny no boundary in this tree may place: a gate for a segment of the\n * URL's own route that an intercepted navigation did not render (TIM-1607).\n * Every boundary declines it but the terminal, which leaves the SPA.\n */\n leaveSpa?: boolean;\n}\n\n/** Structured digest returned by RSC onError for RedirectSignal. */\ninterface RedirectDigest {\n type: 'redirect';\n location: string;\n status: number;\n}\n\ntype ParsedDigest = DenyDigest | RedirectDigest;\n\n// ─── Props & State ───────────────────────────────────────────────────────────\n\nexport interface TimberErrorBoundaryProps {\n /** The component to render when an error is caught. */\n fallbackComponent?: (...args: unknown[]) => ReactNode;\n /**\n * Status code filter. If set, only catches errors matching this status.\n * 400 = any 4xx, 500 = any 5xx, specific number = exact match.\n */\n status?: number;\n /**\n * When true, this boundary wraps a parallel slot. Slot denials are\n * graceful degradation: the boundary claims any addressed deny that\n * reaches it and leaves the page's segment chain unmarked.\n */\n isSlotBoundary?: boolean;\n /**\n * Segment key of the segment that declared this boundary. Only meaningful\n * against a deny digest carrying `owners`. See the decline rule in\n * `render()` and TIM-1356.\n */\n segmentKey?: string;\n /**\n * Catch denies only; re-throw everything else. Set on the copy of a\n * segment's boundaries placed outside its layout, which gives a deny thrown\n * from that layout's own chrome a catcher keyed to the segment — without\n * changing where a 5xx from the same chrome goes. See TIM-1450.\n */\n denyOnly?: boolean;\n /**\n * The deny chain's terminal: the outermost framework boundary, which claims\n * any deny that streamed past every segment boundary and renders the\n * framework default page. Implies `denyOnly`. Only a deny thrown from a\n * layout's chrome with no status file at or above that layout gets here —\n * the segment copies (`denyOnly`) claim every other shape. See TIM-1450.\n */\n lastResort?: boolean;\n children: ReactNode;\n}\n\ninterface TimberErrorBoundaryState {\n hasError: boolean;\n error: Error | null;\n}\n\n// Module-level guard: the first boundary to catch a given redirect digest\n// schedules the navigation and marks it handled here. Subsequent renders\n// (React retries the error-boundary render path multiple times in dev, and\n// outer boundaries that also see the error) become no-ops, preventing\n// duplicate router.navigate() calls.\nconst _handledRedirects = new WeakSet<object>();\n\n// The same guard for the terminal's exit: React may render the fallback\n// path more than once for one error, and the document load must start once.\nconst _handledExits = new WeakSet<object>();\n\n// Companion guard keyed by location: client-render redirect() (the\n// next/navigation shim) throws a FRESH error instance on every render\n// attempt, and React replays the errored render — so the WeakSet alone\n// would schedule the navigation twice. While a navigation to a location\n// is pending, further redirect errors for the same location are no-ops.\nlet _pendingRedirectLocation: string | null = null;\n\n// ─── Component ───────────────────────────────────────────────────────────────\n\nexport class TimberErrorBoundary extends Component<\n TimberErrorBoundaryProps,\n TimberErrorBoundaryState\n> {\n constructor(props: TimberErrorBoundaryProps) {\n super(props);\n this.state = { hasError: false, error: null };\n }\n\n static getDerivedStateFromError(error: Error): TimberErrorBoundaryState {\n // Suppress error boundaries during page unload (refresh/navigate away).\n // The aborted connection causes React's streaming hydration to error,\n // but the page is about to be replaced — showing an error boundary\n // would be a jarring flash for the user.\n if (isPageUnloading()) {\n return { hasError: false, error: null };\n }\n\n return { hasError: true, error };\n }\n\n componentDidCatch(error: Error): void {\n // A stale bundle most often surfaces here rather than as a rejected\n // navigation: a client reference missing from this build's manifest, or\n // a lazily-imported chunk the CDN no longer has, thrown during render.\n //\n // Recording it is all that happens — this boundary still renders its\n // fallback, and the recovery is the user's next navigation, which the\n // router turns into a full document load. Reloading from here would be a\n // page load the user did not ask for, on a page that may be mid-rollout\n // and would come back just as stale (TIM-1275).\n markStaleFromError(error);\n }\n\n componentDidUpdate(prevProps: TimberErrorBoundaryProps): void {\n // Reset error state when children change (e.g. client-side navigation).\n // Without this, navigating from one error page to another keeps the\n // stale error — getDerivedStateFromError doesn't re-fire for new children.\n if (this.state.hasError && prevProps.children !== this.props.children) {\n this.setState({ hasError: false, error: null });\n }\n }\n\n /** Reset the error state so children re-render. */\n private reset = () => {\n this.setState({ hasError: false, error: null });\n };\n\n static override contextType = DenyAncestryContext;\n declare context: readonly string[];\n\n private get childAncestry(): readonly string[] {\n const parent = this.context ?? [];\n const key = this.props.segmentKey;\n // A segment has two keyed boundary sets (outside and inside its layout);\n // the inner one sees its own key already present and adds nothing.\n return key && !parent.includes(key) ? [...parent, key] : parent;\n }\n\n render(): ReactNode {\n if (!this.state.hasError || !this.state.error) {\n return createElement(\n DenyAncestryContext.Provider,\n { value: this.childAncestry },\n this.props.children\n );\n }\n\n const error = this.state.error;\n const parsed = parseDigest(error);\n\n // RedirectSignal handling splits by environment:\n //\n // - SSR (no window): re-throw so the Fizz shell fails and the server\n // pipeline catch block can produce a proper HTTP 3xx response. See\n // design/04-authorization.md.\n //\n // - Client (window exists): a RedirectSignal that leaked into the RSC\n // Flight payload during client navigation would otherwise bubble past\n // every error boundary to `window.onerror`, which in dev triggers the\n // Vite error overlay (false positive — navigation itself works).\n // Instead, ask the router to perform an SPA navigation to the target\n // and render nothing while it takes over. The router's own catch path\n // handles cross-origin / hard navigations. See TIM-838.\n if (parsed?.type === 'redirect') {\n if (typeof window === 'undefined') {\n throw error;\n }\n // Dedupe: React may render the error-boundary fallback path more\n // than once for a single caught error (dev-mode double render, and\n // additional boundaries above us in the tree). Only schedule the\n // navigation on the first render that sees this error instance.\n const alreadyHandled =\n _handledRedirects.has(error) || _pendingRedirectLocation === parsed.location;\n if (!alreadyHandled) {\n _handledRedirects.add(error);\n const router = getRouterOrNull();\n if (router) {\n _pendingRedirectLocation = parsed.location;\n // Schedule the navigation outside the render phase to avoid\n // setState-during-render warnings from router state updates.\n queueMicrotask(() => {\n router\n .navigate(parsed.location, { replace: true })\n .catch(() => {\n // Fall back to a hard navigation if the soft navigation fails.\n window.location.href = parsed.location;\n })\n .finally(() => {\n _pendingRedirectLocation = null;\n });\n });\n } else {\n // No router available (shouldn't happen post-bootstrap) — fall\n // back to a hard navigation so the user still ends up at the\n // target.\n window.location.href = parsed.location;\n }\n }\n // Nothing to show, but still a subtree replaced: a layout that\n // redirected after I/O never mounted its children, and the commit that\n // renders this empty spot must not teach the cache otherwise — or the\n // redirect's own navigation would advertise those layouts as mounted\n // and the server would skip into an outlet the client does not have.\n return this.markStatusPage(null);\n }\n\n // A deny the tree cannot hold: its deny pages, and the layouts they\n // render in, belong to a route this tree is not. Nothing here may claim\n // it — not a keyed owner, not a slot, not a status filter — so it passes\n // every boundary to the terminal, which leaves the SPA below and lets the\n // document request render the URL's own answer (TIM-1607).\n const leavesSpa = parsed?.type !== 'deny' || parsed.leaveSpa === true;\n if (parsed?.type === 'deny' && parsed.leaveSpa && !this.props.lastResort) {\n throw error;\n }\n\n // Owner-addressed denies: the digest carries an ordered `owners` list\n // of segment keys with matching deny pages. This boundary claims the\n // deny only when it is the first *reachable* owner — i.e. its\n // segmentKey appears in `owners` AND in its ancestry (the chain from\n // root to here). Unreachable owners (below the throw site) are skipped,\n // and the first ancestor that IS reachable claims. This eliminates the\n // owner-below-throw-site escape (TIM-1450).\n //\n // Unkeyed boundaries (slots, or boundaries without deny chains) never\n // claim an addressed deny. See TIM-1356.\n if (parsed?.type === 'deny' && Array.isArray(parsed.owners) && parsed.owners.length > 0) {\n // Slot boundaries always claim addressed denies — graceful degradation\n // within the slot is correct regardless of which segment the owner\n // chain resolved to. Without this, the deny escapes the slot and\n // becomes a page-level 4xx. See TIM-1450.\n if (!this.props.lastResort && !this.props.isSlotBoundary) {\n const reachable = parsed.owners.find((k: string) => this.childAncestry.includes(k));\n if (!this.props.segmentKey || reachable !== this.props.segmentKey) {\n throw error;\n }\n }\n }\n // Deny-only boundaries (the outer segment copies) re-throw everything\n // else so a crash in a layout's chrome still reaches the documented 5xx\n // flow instead of a status page for an unrelated error.\n if (this.props.denyOnly && !this.props.lastResort && parsed?.type !== 'deny') {\n throw error;\n }\n // The terminal is where that flow ends on the client. A non-deny row\n // nothing claimed — a crash on a route with no\n // matching `error.tsx` — has no page to render in-SPA; React would\n // unmount the root. So the terminal does what the router does for an\n // error envelope (design/10 §\"Error Page Rendering for Client\n // Navigation\"): leave the SPA, and let the document request render the\n // real error page with the real status. On the server it re-throws so\n // the Fizz shell fails and the pipeline serves that page directly. The\n // envelope still covers errors that land inside Flight's opening window;\n // this covers the ones that land after it, which used to be held for\n // (TIM-1495, TIM-1497). A deny the tree cannot hold (above) leaves the\n // same way, for the same reason: no page for it exists in this SPA.\n if (this.props.lastResort && leavesSpa) {\n if (typeof window === 'undefined') {\n throw error;\n }\n if (!_handledExits.has(error)) {\n _handledExits.add(error);\n const router = getRouterOrNull();\n const current = window.location.pathname + window.location.search;\n // The row arrived for the navigation in flight, whose URL is not on\n // the address bar yet; fall back to the current document.\n const target = router?.getPendingUrl() ?? current;\n queueMicrotask(() => {\n void leaveSpa(target, current);\n });\n }\n return null;\n }\n\n // If this boundary has a status filter, check whether the error matches.\n // Non-matching errors re-throw so an outer boundary can catch them.\n if (this.props.status != null) {\n const errorStatus = getErrorStatus(parsed, error);\n if (errorStatus == null || !statusMatches(this.props.status, errorStatus)) {\n // Re-throw: this boundary doesn't handle this error.\n throw error;\n }\n }\n\n return this.markStatusPage(this.renderFallback(parsed, error));\n }\n\n /**\n * The status page this boundary shows for a row it claimed. Its shape is\n * the file's documented contract: TSX status files get `{ status,\n * data }`, `error.tsx` gets `{ error, digest, reset }` (plus\n * the deny extras for dual-shape implementations — without the error prop,\n * an error.tsx reading error.message crashes on deny fall-through, TIM-1081).\n */\n private renderFallback(parsed: ParsedDigest | null, error: Error): ReactNode {\n if (parsed?.type === 'deny') {\n if (this.props.status != null) {\n return createElement(this.props.fallbackComponent as never, {\n status: parsed.status,\n data: parsed.data,\n });\n }\n return createElement(this.props.fallbackComponent as never, {\n error: denyError(parsed.status, error),\n digest: null,\n reset: this.reset,\n status: parsed.status,\n data: parsed.data,\n });\n }\n\n // Unhandled error (500)\n return createElement(this.props.fallbackComponent as never, {\n error,\n digest: errorDigestId(error),\n reset: this.reset,\n });\n }\n\n /**\n * A status page (or, for a redirect row, nothing at all) replaced part of\n * the main route, and the segment cache must not learn a chain that never\n * mounted; the marker tells the navigation that commits this tree. A boundary that declined in `render()` re-threw\n * before getting here, so only the boundary that put a page on screen\n * speaks. A slot degrading leaves the page and its chain intact, so slot\n * boundaries stay silent. See `status-page-marker.tsx` (TIM-1495).\n */\n private markStatusPage(page: ReactNode): ReactNode {\n if (this.props.isSlotBoundary) return page;\n return createElement(StatusPageMarker, null, page);\n }\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\n/**\n * Parse the structured digest from the error.\n * React sets `error.digest` from the string returned by RSC's onError.\n */\nfunction parseDigest(error: Error): ParsedDigest | null {\n const raw = (error as { digest?: string }).digest;\n if (typeof raw !== 'string') return null;\n try {\n const parsed = JSON.parse(raw);\n if (parsed && typeof parsed === 'object' && typeof parsed.type === 'string') {\n return parsed as ParsedDigest;\n }\n } catch (e) {\n console.debug('[timber] error digest is not valid JSON:', e instanceof Error ? e.message : e);\n }\n return null;\n}\n\n/**\n * The Error an `error.tsx` serving a deny should receive.\n *\n * The error that actually arrives here is React's, not the framework's: a\n * server-thrown error crossing Flight has its message and name replaced with\n * a generic redacted string in production, by design. An `error.tsx` written\n * per the docs branches on `error.message` — so handing it the redacted error\n * gives it nothing to branch on, while the in-tree path hands the same file a\n * `DenySignal` named error reading `Access denied with status <N>` (see\n * `renderDenyEntry`). This reconstructs that shape from the digest, which is\n * where the status already is.\n *\n * Derived from the status alone — no stack, no server data — so it is safe on\n * the client for the same reason the digest is. See design/13-security.md\n * §\"Errors don't leak\", TIM-1081.\n */\nfunction denyError(status: number, original: Error): Error {\n // A dev build may have preserved something more useful than the redaction.\n if (original.name === 'DenySignal') return original;\n const error = new Error(`Access denied with status ${status}`);\n error.name = 'DenySignal';\n return error;\n}\n\n/**\n * Extract the HTTP status code from a parsed digest or error message.\n * Falls back to message pattern matching for errors without a digest.\n */\nfunction getErrorStatus(parsed: ParsedDigest | null, error: Error): number | null {\n if (parsed?.type === 'deny') return parsed.status;\n if (parsed?.type === 'redirect') return parsed.status;\n\n // Fallback: parse DenySignal message pattern for errors that lost their digest\n const match = error.message.match(/^Access denied with status (\\d+)$/);\n if (match) return parseInt(match[1], 10);\n\n // Unhandled errors are implicitly 500\n return 500;\n}\n\n/**\n * Check whether an error's status matches the boundary's status filter.\n * Category markers (400, 500) match any status in that range.\n */\nfunction statusMatches(boundaryStatus: number, errorStatus: number): boolean {\n // Category catch-all: 400 matches any 4xx, 500 matches any 5xx\n if (boundaryStatus === 400) return errorStatus >= 400 && errorStatus <= 499;\n if (boundaryStatus === 500) return errorStatus >= 500 && errorStatus <= 599;\n // Exact match\n return boundaryStatus === errorStatus;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyEA,IAAa,sBAAuC;CAAE,QAAQ,CAAC;CAAG,YAAY;AAAK;;AAGnF,SAAS,mBAAmB,OAA0C;CACpE,OACE,OAAO,UAAU,YACjB,UAAU,QACV,YAAY,SACZ,OAAQ,MAA0B,WAAW,YAC5C,MAA0B,WAAW;AAE1C;;;;;;;;AASA,SAAgB,oBAAoB,QAAkC;CACpE,IAAI,CAAC,mBAAmB,MAAM,GAAG,OAAO;CACxC,OAAO;EAAE,QAAQ,OAAO;EAAQ,YAAY,OAAO,cAAc;CAAK;AACxE;;;;;;;AAQA,SAAgB,gBAAgB,MAAwB;CACtD,IAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU,QAAQ,mBAAmB,IAAI,GACxF,OAAQ,KAAwB;CAElC,OAAO;AACT;;;;;;;;AA2BA,SAAgB,iBAAiB,MAA6B;CAC5D,IACE,OAAO,SAAS,YAChB,SAAS,QACT,OAAQ,KAA8B,SAAS,YAE/C,OAAO;EAAE,M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
@@ -1,6 +1,5 @@
1
- import { n as parseRouterUrl, t as createGlobalContext } from "./global-context-CFSSysdJ.js";
2
1
  import { l as globalRouter, n as _setGlobalRouter } from "./state-B-EBjeER.js";
3
- import { createElement, use, useContext, useMemo, useRef, useSyncExternalStore } from "react";
2
+ import React, { createElement, use, useContext, useMemo, useRef, useSyncExternalStore } from "react";
4
3
  // src/client/router-ref.ts
5
4
  /**
6
5
  * Set the global router instance. Called once during bootstrap.
@@ -24,6 +23,49 @@ function getRouter() {
24
23
  function getRouterOrNull() {
25
24
  return globalRouter;
26
25
  }
26
+ // src/client/global-context.ts
27
+ /**
28
+ * createGlobalContext — a React context with a process-wide singleton identity.
29
+ *
30
+ * SINGLETON GUARANTEE: Uses globalThis + Symbol.for — same pattern as
31
+ * NavigationContext. The RSC client bundler can duplicate a module across
32
+ * chunks (browser-entry graph + client-reference graph). With ESM output,
33
+ * each chunk gets its own module scope — a bare createContext at module
34
+ * level would create separate instances per chunk. globalThis guarantees a
35
+ * single instance regardless of duplication.
36
+ *
37
+ * One context per React instance, not per process. Duplicated chunks share
38
+ * one React, so they share the context. A dev SSR program reload evaluates
39
+ * React and react-dom/server again, in the same process: the new renderer
40
+ * must get a context of its own. Handed the previous one, React logs
41
+ * "Detected multiple renderers concurrently rendering the same context
42
+ * provider" on every client-component edit, and the stale context keeps a
43
+ * piece of the discarded copy alive (TIM-1590).
44
+ *
45
+ * See design/19-client-navigation.md §"Singleton Guarantee via globalThis"
46
+ */
47
+ /**
48
+ * The context `key` names for this React instance, created on first use.
49
+ * Pass the key as a `Symbol.for('…')` literal at the call site, so each key
50
+ * stays greppable in the build output (tests/bundle-singleton-audit.test.ts
51
+ * checks `__timber_nav_ctx`).
52
+ */
53
+ function createGlobalContext(key, defaultValue) {
54
+ return createGlobalContextFor(React, key, defaultValue);
55
+ }
56
+ /** createGlobalContext for a given React instance. Exported for tests. */
57
+ function createGlobalContextFor(react, key, defaultValue) {
58
+ if (typeof react.createContext !== "function") return;
59
+ const slot = Reflect.get(globalThis, key);
60
+ const byReact = slot instanceof WeakMap ? slot : /* @__PURE__ */ new WeakMap();
61
+ if (byReact !== slot) Reflect.set(globalThis, key, byReact);
62
+ let ctx = byReact.get(react);
63
+ if (!ctx) {
64
+ ctx = react.createContext(defaultValue);
65
+ byReact.set(react, ctx);
66
+ }
67
+ return ctx;
68
+ }
27
69
  // src/client/navigation-context.ts
28
70
  /**
29
71
  * NavigationContext — React context for navigation state.
@@ -125,6 +167,36 @@ function NavigationProvider({ value, children }) {
125
167
  * One representation, and it is the router's. See
126
168
  * design/19-client-navigation.md §"How Pending State Works".
127
169
  */
170
+ // src/client/router-url.ts
171
+ /**
172
+ * How the client router reads the URLs it is handed.
173
+ *
174
+ * One parser, so the places that key or compare by URL — the history stack,
175
+ * the navigation state a page renders with, the departing page sent as
176
+ * `X-Timber-URL` — cannot disagree about what a URL says. They did: a
177
+ * history entry stored under `navigate('/café')`'s spelling was looked up
178
+ * under the address bar's `/caf%C3%A9`, and missed (TIM-1541).
179
+ */
180
+ var BASE = "http://localhost";
181
+ /**
182
+ * Parse a router URL. A URL that starts with "/" is a path — including one
183
+ * that starts with "//": that is the pathname a document at
184
+ * `https://host//a/b` reports, and resolved against a base it would parse as
185
+ * a scheme-relative reference to host `a`. Anything else resolves against a
186
+ * placeholder origin, so an absolute URL keeps its own.
187
+ */
188
+ function parseRouterUrl(url) {
189
+ return url.startsWith("/") ? new URL(BASE + url) : new URL(url, BASE);
190
+ }
191
+ /**
192
+ * The spelling a URL is stored and looked up under: the browser's own
193
+ * pathname + search, so `/a?` and `/a`, `/café` and `/caf%C3%A9`, are one
194
+ * key. The fragment is dropped — it is client-only.
195
+ */
196
+ function routerUrlKey(url) {
197
+ const parsed = parseRouterUrl(url);
198
+ return parsed.pathname + parsed.search;
199
+ }
128
200
  // src/client/use-pending-navigation.ts
129
201
  function subscribe(onStoreChange) {
130
202
  const router = getRouterOrNull();
@@ -234,6 +306,6 @@ function getHardNavStore() {
234
306
  function setHardNavigating(value) {
235
307
  getHardNavStore().value = value;
236
308
  }
237
- export { getRouter as a, useNavigationContext as i, usePendingNavigation as n, getRouterOrNull as o, NavigationProvider as r, setGlobalRouter as s, setHardNavigating as t };
309
+ export { NavigationProvider as a, getRouter as c, routerUrlKey as i, getRouterOrNull as l, usePendingNavigation as n, useNavigationContext as o, parseRouterUrl as r, createGlobalContext as s, setHardNavigating as t, setGlobalRouter as u };
238
310
 
239
- //# sourceMappingURL=navigation-root-CoGHIMiE.js.map
311
+ //# sourceMappingURL=navigation-root-Cvb7P1ud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-root-Cvb7P1ud.js","names":[],"sources":["../../src/client/router-ref.ts","../../src/client/global-context.ts","../../src/client/navigation-context.ts","../../src/client/router-url.ts","../../src/client/use-pending-navigation.ts","../../src/client/top-loader.tsx","../../src/client/navigation-root.tsx"],"sourcesContent":["// Global router reference — shared between browser-entry and client hooks.\n//\n// Delegates to client/state.ts for the actual module-level variable.\n// This ensures singleton semantics regardless of import path — all\n// callers converge on the same state.ts instance via the barrel.\n//\n// See design/18-build-system.md §\"Module Singleton Strategy\"\n\nimport type { RouterInstance } from './router-types.ts';\nimport { globalRouter, _setGlobalRouter } from './state.ts';\n\n/**\n * Set the global router instance. Called once during bootstrap.\n */\nexport function setGlobalRouter(router: RouterInstance): void {\n _setGlobalRouter(router);\n}\n\n/**\n * Get the global router instance. Throws if called before bootstrap.\n * Used by client-side hooks (usePendingNavigation, etc.)\n */\nexport function getRouter(): RouterInstance {\n if (!globalRouter) {\n throw new Error('[timber] Router not initialized. getRouter() was called before bootstrap().');\n }\n return globalRouter;\n}\n\n/**\n * Get the global router instance or null if not yet initialized.\n * Used by useRouter() methods to avoid silent failures — callers\n * can log a meaningful warning instead of silently no-oping.\n */\nexport function getRouterOrNull(): RouterInstance | null {\n return globalRouter;\n}\n\n/**\n * Reset the global router to null. Used only in tests to isolate\n * module-level state between test cases.\n * @internal\n */\nexport function resetGlobalRouter(): void {\n _setGlobalRouter(null);\n}\n","/**\n * createGlobalContext — a React context with a process-wide singleton identity.\n *\n * SINGLETON GUARANTEE: Uses globalThis + Symbol.for — same pattern as\n * NavigationContext. The RSC client bundler can duplicate a module across\n * chunks (browser-entry graph + client-reference graph). With ESM output,\n * each chunk gets its own module scope — a bare createContext at module\n * level would create separate instances per chunk. globalThis guarantees a\n * single instance regardless of duplication.\n *\n * One context per React instance, not per process. Duplicated chunks share\n * one React, so they share the context. A dev SSR program reload evaluates\n * React and react-dom/server again, in the same process: the new renderer\n * must get a context of its own. Handed the previous one, React logs\n * \"Detected multiple renderers concurrently rendering the same context\n * provider\" on every client-component edit, and the stale context keeps a\n * piece of the discarded copy alive (TIM-1590).\n *\n * See design/19-client-navigation.md §\"Singleton Guarantee via globalThis\"\n */\n\nimport React from 'react';\n\n/** The part of a React instance a context comes from. */\nexport interface ContextFactory {\n createContext?: typeof React.createContext;\n}\n\n/**\n * The context `key` names for this React instance, created on first use.\n * Pass the key as a `Symbol.for('…')` literal at the call site, so each key\n * stays greppable in the build output (tests/bundle-singleton-audit.test.ts\n * checks `__timber_nav_ctx`).\n */\nexport function createGlobalContext<T>(key: symbol, defaultValue: T): React.Context<T> {\n return createGlobalContextFor(React, key, defaultValue);\n}\n\n/** createGlobalContext for a given React instance. Exported for tests. */\nexport function createGlobalContextFor<T>(\n react: ContextFactory,\n key: symbol,\n defaultValue: T\n): React.Context<T> {\n if (typeof react.createContext !== 'function') {\n // RSC environment — createContext not available. Return a dummy that\n // won't be used (the consumers only render on the client / during SSR).\n return undefined as unknown as React.Context<T>;\n }\n const slot: unknown = Reflect.get(globalThis, key);\n const byReact = slot instanceof WeakMap ? slot : new WeakMap<object, React.Context<T>>();\n if (byReact !== slot) Reflect.set(globalThis, key, byReact);\n let ctx: React.Context<T> | undefined = byReact.get(react);\n if (!ctx) {\n ctx = react.createContext<T>(defaultValue);\n byReact.set(react, ctx);\n }\n return ctx;\n}\n","'use client';\n\n/**\n * NavigationContext — React context for navigation state.\n *\n * Holds the current pathname and search, updated atomically with the RSC\n * tree on each navigation. This replaces the previous useSyncExternalStore\n * approach for usePathname() and useSearchParams(), which suffered from a\n * timing gap: the new tree could commit before the external store\n * re-renders fired, causing a frame where both old and new active states\n * were visible simultaneously.\n *\n * Segment params are NOT here — see the note on NavigationState below.\n *\n * By wrapping the RSC payload element in NavigationProvider inside the\n * router's `renderTree` (browser-entry/router-init.ts), the context value and the element tree are passed to\n * reactRoot.render() in the same call — atomic by construction.\n * All consumers (usePathname, useSearchParams) see the new values in the\n * same render pass as the new tree.\n *\n * During SSR, the wrapper chain mounts this same provider with the\n * request's pathname and raw search string (TIM-1424), so the hooks\n * resolve through the identical code path on both sides. Per-request\n * isolation is by construction — the value is part of the request's\n * element tree.\n *\n * This module is `'use client'` and is never evaluated in the RSC\n * environment. The shims plugin resolves next/navigation to\n * navigation-rsc.ts in RSC, which has throwing stubs (TIM-1420).\n *\n * SINGLETON GUARANTEE: All shared mutable state uses globalThis via\n * Symbol.for keys. The RSC client bundler can duplicate this module\n * across chunks (browser-entry graph + client-reference graph). With\n * ESM output, each chunk gets its own module scope — module-level\n * variables would create separate singleton instances per chunk.\n * globalThis guarantees a single instance regardless of duplication.\n *\n * This workaround will be removed when Rolldown ships `format: 'app'`\n * (module registry format that deduplicates like webpack/Turbopack).\n * See design/27-chunking-strategy.md.\n *\n * See design/19-client-navigation.md §\"NavigationContext\"\n */\n\nimport { useContext, createElement, type ReactNode } from 'react';\nimport { createGlobalContext } from './global-context.ts';\n\n// ---------------------------------------------------------------------------\n// Context type\n// ---------------------------------------------------------------------------\n\n/**\n * What the browser knows about the current location.\n *\n * Params are deliberately absent: they are a property of the tree the server\n * rendered, not of the address bar, and they now travel inside the payload as\n * the payload root. Keeping a copy here meant the router had to thread\n * the record from a response header into context on every path — navigation,\n * traversal, prefetch, revalidation — and each of those was a place to drop it\n * (TIM-1294).\n */\nexport interface NavigationState {\n pathname: string;\n search: string;\n}\n\n// ---------------------------------------------------------------------------\n// Lazy context initialization\n// ---------------------------------------------------------------------------\n\n/**\n * Context instances are stored on globalThis (NOT in module-level\n * variables) because the ESM bundler can duplicate this module across\n * chunks. Module-level variables would create separate instances per\n * chunk — the provider in NavigationRoot (index chunk) would use\n * context A while the consumer in usePendingNavigation (shared chunk)\n * reads from context B. globalThis guarantees a single instance.\n *\n * This module is `'use client'` so it is never evaluated in the RSC\n * environment — `createContext` and `useContext` are always available.\n * The shims plugin resolves next/navigation to navigation-rsc.ts in RSC,\n * which has throwing stubs for the hooks (TIM-1420).\n *\n * See design/19-client-navigation.md §\"Singleton Guarantee via globalThis\"\n *\n * Exported for `usePendingNavigation(select)`, which reads it with React\n * `use()` — only in its selector form, so the plain form does not re-render\n * on every commit.\n */\nexport function getOrCreateContext(): import('react').Context<NavigationState | null> {\n return createGlobalContext<NavigationState | null>(Symbol.for('__timber_nav_ctx'), null);\n}\n\n/**\n * Read the navigation context. Returns null only when no provider is above\n * the caller — a component rendered outside the timber app.\n *\n * Internal — used by usePathname() and useSearchParams().\n */\nexport function useNavigationContext(): NavigationState | null {\n return useContext(getOrCreateContext());\n}\n\n// ---------------------------------------------------------------------------\n// Provider component\n// ---------------------------------------------------------------------------\n\nexport interface NavigationProviderProps {\n value: NavigationState;\n children?: ReactNode;\n}\n\n/**\n * Wraps children with NavigationContext.Provider.\n *\n * Used in browser-entry/router-init.ts `renderTree` to wrap the RSC payload element\n * so that navigation state updates atomically with the tree render.\n */\nexport function NavigationProvider({\n value,\n children,\n}: NavigationProviderProps): import('react').ReactElement {\n return createElement(getOrCreateContext().Provider, { value }, children);\n}\n\n// ---------------------------------------------------------------------------\n// Pending navigation state lives in the router, not here\n// ---------------------------------------------------------------------------\n\n/**\n * There was a second React context here — `PendingNavigationContext`, holding\n * the in-flight navigation URL, provided by `NavigationRoot` out of a\n * `useState` — plus a `usePendingNavigationUrl()` reader for it. Both are gone\n * (TIM-1307).\n *\n * Nothing read them. `usePendingNavigation()` (use-pending-navigation.ts) and\n * `TopLoader` both subscribe to the router's external pending store via\n * `useSyncExternalStore`: sync priority, immune to transition entanglement,\n * and cleared by `runNavigation`'s supersession-guarded `finally` (TIM-1034).\n * The context was a parallel representation of the same fact that no consumer\n * ever migrated to, and one that could not even agree with the store — a\n * navigation superseded by a cached popstate replay left its URL set until the\n * next full navigation, because the staleness guard skipped the clear and no\n * other path touched it.\n *\n * One representation, and it is the router's. See\n * design/19-client-navigation.md §\"How Pending State Works\".\n */\n","/**\n * How the client router reads the URLs it is handed.\n *\n * One parser, so the places that key or compare by URL — the history stack,\n * the navigation state a page renders with, the departing page sent as\n * `X-Timber-URL` — cannot disagree about what a URL says. They did: a\n * history entry stored under `navigate('/café')`'s spelling was looked up\n * under the address bar's `/caf%C3%A9`, and missed (TIM-1541).\n */\n\nconst BASE = 'http://localhost';\n\n/**\n * Parse a router URL. A URL that starts with \"/\" is a path — including one\n * that starts with \"//\": that is the pathname a document at\n * `https://host//a/b` reports, and resolved against a base it would parse as\n * a scheme-relative reference to host `a`. Anything else resolves against a\n * placeholder origin, so an absolute URL keeps its own.\n */\nexport function parseRouterUrl(url: string): URL {\n return url.startsWith('/') ? new URL(BASE + url) : new URL(url, BASE);\n}\n\n/**\n * The spelling a URL is stored and looked up under: the browser's own\n * pathname + search, so `/a?` and `/a`, `/café` and `/caf%C3%A9`, are one\n * key. The fragment is dropped — it is client-only.\n */\nexport function routerUrlKey(url: string): string {\n const parsed = parseRouterUrl(url);\n return parsed.pathname + parsed.search;\n}\n","import { use, useMemo, useRef, useSyncExternalStore } from 'react';\nimport { getOrCreateContext } from './navigation-context.ts';\nimport { getRouterOrNull } from './router-ref.ts';\nimport { parseRouterUrl } from './router-url.ts';\n\nfunction subscribe(onStoreChange: () => void): () => void {\n const router = getRouterOrNull();\n if (!router) return () => {};\n return router.onPendingChange(onStoreChange);\n}\n\nfunction isPending(): boolean {\n const router = getRouterOrNull();\n return router ? router.isPending() : false;\n}\n\nconst HAS_SCHEME = /^[a-z][a-z\\d+.-]*:/i;\n\n/**\n * A router URL as a `URL`, read the way the router reads it (`parseRouterUrl`)\n * so `to` names the page the router will commit. Anything without a scheme is\n * a path on this document's origin; an absolute URL keeps its own.\n */\nfunction pageUrl(url: string): URL {\n const parsed = parseRouterUrl(url);\n if (HAS_SCHEME.test(url)) return parsed;\n return new URL(window.location.origin + parsed.pathname + parsed.search + parsed.hash);\n}\n\n/**\n * Decides what a component wants to know about the navigation in flight.\n *\n * `to` is where the router is going, with the `#fragment` of a link or\n * `router.push()` that has one (traversals and refreshes carry none). `from`\n * is the page the navigation departs from, as the calling component rendered\n * it — not the address bar, which on Back/Forward has already moved. Both are\n * fresh `URL`s; don't mutate them.\n */\nexport type PendingNavigationSelector<T> = (to: URL, from: URL) => T;\n\n/**\n * Whether an RSC navigation is in flight — until its payload has decoded and\n * React has committed the destination, so it never turns false while the\n * departing page is still on screen.\n *\n * Reads the router's external pending store via `useSyncExternalStore`, so\n * only components that call this hook re-render when a navigation starts or\n * ends.\n *\n * ```tsx\n * 'use client'\n * import { usePendingNavigation } from '@timber-js/app/client'\n *\n * export function NavBar() {\n * const isPending = usePendingNavigation()\n * return <nav className={isPending ? 'opacity-50' : ''}>…</nav>\n * }\n * ```\n */\nexport function usePendingNavigation(): boolean;\n/**\n * The selector form: `select(to, from)` while a navigation is in flight,\n * `false` when none is. A navigation starting, being superseded or ending\n * re-renders the component only when the result changes (`Object.is`), so\n * return a primitive. The selector form also re-renders on commits, as\n * `usePathname()` does. A superseded navigation reports the newest target; a\n * followed redirect reports the redirect's destination.\n *\n * ```tsx\n * // Dim a list only while its own sort/filter/page navigation is in flight.\n * const replacing = usePendingNavigation((to, from) => to.pathname === from.pathname)\n * ```\n *\n * See design/19-client-navigation.md §\"Where the navigation is going\".\n */\nexport function usePendingNavigation<T>(select: PendingNavigationSelector<T>): T | false;\nexport function usePendingNavigation<T>(select?: PendingNavigationSelector<T>): T | boolean {\n // Read only by the selector form, so the plain form — TopLoader, a global\n // spinner — does not re-render on every commit.\n const nav = select ? use(getOrCreateContext()) : null;\n if (select && nav === null) {\n throw new Error(\n '[timber] usePendingNavigation(select) was called outside the timber app tree ' +\n '(no NavigationProvider found). In tests, render the component ' +\n 'inside the timber providers.'\n );\n }\n const rendered = nav ? nav.pathname + nav.search : null;\n\n // The page each navigation departs from: what this component was rendering\n // when it first saw the target. Held for the navigation's lifetime because\n // the location context moves to the destination at its commit, while the\n // router is still pending — read live, a link away would report \"same page\"\n // for that commit and for any streaming tail after it.\n const departure = useRef<{ target: string; from: string } | null>(null);\n\n const getSnapshot = useMemo((): (() => T | boolean) => {\n if (!select || rendered === null) return isPending;\n // `getSnapshot` must return the same value for the same store state, and\n // a selector returning `to` would otherwise hand React a new URL per call.\n let last: { target: string; from: string; value: T } | null = null;\n return () => {\n const target = getRouterOrNull()?.getPendingUrl() ?? null;\n if (target === null) {\n departure.current = null;\n return false;\n }\n if (departure.current?.target !== target) departure.current = { target, from: rendered };\n const from = departure.current.from;\n if (last?.target !== target || last.from !== from) {\n last = { target, from, value: select(pageUrl(target), pageUrl(from)) };\n }\n return last.value;\n };\n }, [select, rendered]);\n\n // The same read on the server: no router there, so it reports idle.\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","/**\n * TopLoader — Built-in progress bar for client navigations.\n *\n * Shows an animated progress bar at the top of the viewport while an RSC\n * navigation is in flight. Injected automatically by the framework into\n * NavigationRoot — users never render this component directly.\n *\n * Configuration is via timber.config.ts `topLoader` key. Enabled by default.\n * Users who want a fully custom progress indicator disable the built-in one\n * (`topLoader: { enabled: false }`) and use `usePendingNavigation()` directly.\n *\n * Animation approach: pure CSS @keyframes. The bar crawls from 0% to ~90%\n * width over ~30s using ease-out timing. When navigation completes, the bar\n * snaps to 100% and fades out over 200ms. No JS animation loops (RAF, setInterval).\n *\n * Phase transitions are derived synchronously during render (React's\n * getDerivedStateFromProps pattern) — no useEffect needed for state tracking.\n * The finishing → hidden cleanup uses onTransitionEnd from the CSS transition.\n *\n * When delay > 0, CSS animation-delay + a visibility keyframe ensure the bar\n * stays invisible during the delay period. If navigation finishes before the\n * delay, the bar was never visible so the finish transition is also invisible.\n *\n * See design/19-client-navigation.md §\"usePendingNavigation()\"\n * See LOCAL-336 for design decisions.\n */\n\n'use client';\n\nimport { useState, createElement } from 'react';\nimport { usePendingNavigation } from './use-pending-navigation.ts';\n\n// ─── Types ───────────────────────────────────────────────────────\n\nexport interface TopLoaderConfig {\n /** Whether the top-loader is enabled. Default: true. */\n enabled?: boolean;\n /** Bar color. Default: '#2299DD'. */\n color?: string;\n /** Bar height in pixels. Default: 3. */\n height?: number;\n /** Show subtle glow/shadow effect. Default: false. */\n shadow?: boolean;\n /** Delay in ms before showing the bar. Default: 0. */\n delay?: number;\n /** CSS z-index. Default: 1600. */\n zIndex?: number;\n}\n\n// ─── Defaults ────────────────────────────────────────────────────\n\nconst DEFAULT_COLOR = '#2299DD';\nconst DEFAULT_HEIGHT = 3;\nconst DEFAULT_SHADOW = false;\nconst DEFAULT_DELAY = 0;\nconst DEFAULT_Z_INDEX = 1600;\n\n// ─── Keyframes ───────────────────────────────────────────────────\n\n// Unique keyframes name to avoid collisions with user styles.\nconst CRAWL_KEYFRAMES = '__timber_top_loader_crawl';\nconst APPEAR_KEYFRAMES = '__timber_top_loader_appear';\nconst FINISH_KEYFRAMES = '__timber_top_loader_finish';\n\n// Track whether the @keyframes rules have been injected into the document.\nlet keyframesInjected = false;\n\n/**\n * Inject the @keyframes rules into the document head once.\n * Called during render (idempotent). Uses a <style> tag so the\n * animations are available for inline-styled elements.\n */\nfunction ensureKeyframes(): void {\n if (keyframesInjected) return;\n if (typeof document === 'undefined') return;\n\n const style = document.createElement('style');\n style.textContent = `\n@keyframes ${CRAWL_KEYFRAMES} {\n 0% { width: 0%; }\n 100% { width: 90%; }\n}\n@keyframes ${APPEAR_KEYFRAMES} {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n@keyframes ${FINISH_KEYFRAMES} {\n 0% { width: 90%; opacity: 1; }\n 50% { width: 100%; opacity: 1; }\n 100% { width: 100%; opacity: 0; }\n}\n`;\n document.head.appendChild(style);\n keyframesInjected = true;\n}\n\n// ─── Component ───────────────────────────────────────────────────\n\n/**\n * Internal top-loader component. Injected by NavigationRoot.\n *\n * Reads pending navigation state from the router's external store, via\n * usePendingNavigation() — the one pending representation (TIM-1307).\n * Phase transitions are derived synchronously during render:\n *\n * hidden → crawling: when isPending becomes true\n * crawling → finishing: when isPending becomes false\n * finishing → hidden: when CSS transition ends (onTransitionEnd)\n * finishing → crawling: when isPending becomes true again\n *\n * No useEffect — all state changes are either derived during render\n * (getDerivedStateFromProps pattern) or triggered by DOM events.\n */\nexport function TopLoader({ config }: { config?: TopLoaderConfig }): React.ReactElement | null {\n // Read pending state from the router's external store via\n // useSyncExternalStore (inside usePendingNavigation). Only this\n // component re-renders when pending changes — no full-tree re-render.\n const isPending = usePendingNavigation();\n\n const color = config?.color ?? DEFAULT_COLOR;\n const height = config?.height ?? DEFAULT_HEIGHT;\n const shadow = config?.shadow ?? DEFAULT_SHADOW;\n const delay = config?.delay ?? DEFAULT_DELAY;\n const zIndex = config?.zIndex ?? DEFAULT_Z_INDEX;\n\n const [phase, setPhase] = useState<'hidden' | 'crawling' | 'finishing'>('hidden');\n\n // ─── Synchronous phase derivation (getDerivedStateFromProps) ──\n // React allows setState during render if the value changes — it\n // immediately re-renders with the updated state before committing.\n\n if (isPending && (phase === 'hidden' || phase === 'finishing')) {\n setPhase('crawling');\n }\n if (!isPending && phase === 'crawling') {\n setPhase('finishing');\n }\n\n // Inject keyframes on first visible render (idempotent)\n if (phase !== 'hidden') {\n ensureKeyframes();\n }\n\n if (phase === 'hidden') return null;\n\n // ─── Styles ──────────────────────────────────────────────────\n\n const containerStyle: React.CSSProperties = {\n position: 'fixed',\n top: 0,\n left: 0,\n width: '100%',\n height: `${height}px`,\n zIndex,\n pointerEvents: 'none',\n };\n\n const barStyle: React.CSSProperties = {\n height: '100%',\n backgroundColor: color,\n ...(phase === 'crawling'\n ? {\n // Crawl from 0% to 90% over 30s. When delay > 0, both the crawl\n // and a visibility animation are delayed — the bar stays at width 0%\n // and opacity 0 during the delay, then appears and starts crawling.\n // With delay 0, the appear animation is instant (0s duration, no delay).\n animation: [\n `${CRAWL_KEYFRAMES} 30s ease-out ${delay}ms forwards`,\n `${APPEAR_KEYFRAMES} 0s ${delay}ms both`,\n ].join(', '),\n }\n : {\n // Finishing: fill to 100% then fade out via a keyframe animation.\n // We use a keyframe instead of a CSS transition because the\n // animation-to-transition handoff is unreliable — the browser\n // may not capture the animated width as the transition's \"from\"\n // value when both the animation removal and transition are\n // applied in the same render frame.\n animation: `${FINISH_KEYFRAMES} 400ms ease forwards`,\n }),\n ...(shadow\n ? {\n boxShadow: `0 0 10px ${color}, 0 0 5px ${color}`,\n }\n : {}),\n };\n\n // Clean up the finishing phase when the finish animation completes.\n const handleAnimationEnd =\n phase === 'finishing'\n ? (e: React.AnimationEvent) => {\n if (e.animationName === FINISH_KEYFRAMES) {\n setPhase('hidden');\n }\n }\n : undefined;\n\n return createElement(\n 'div',\n {\n 'style': containerStyle,\n 'aria-hidden': 'true',\n 'data-timber-top-loader': '',\n },\n createElement('div', { style: barStyle, onAnimationEnd: handleAnimationEnd })\n );\n}\n","/**\n * NavigationRoot — the component the router renders the page through.\n *\n * It is stateless. The router owns the displayed tree and drives React with\n * `root.render(<NavigationRoot rendered={{ element, publish }} />)` inside a\n * synchronous `startTransition` (see `client/react-root.ts`). A transition\n * update keeps the committed tree on screen while the incoming one resolves,\n * instead of replacing it with a Suspense fallback — the reason this\n * component exists (TIM-1306).\n *\n * It used to hold the tree in `useState` and register `setState` closures\n * into module globals during render so the router could reach into it, with a\n * second set of stand-in closures for the window before a root existed\n * (TIM-600). Inverting that — router calls React, not the reverse — deleted\n * all of it (TIM-1431). Next.js's `use-action-queue.ts` says it wants this\n * shape and cannot have it because it must decode Flight during render;\n * timber decodes in `router-pipeline.ts`, so nothing stands in the way.\n *\n * What this component does own is **the commit-time publish**: a navigation's\n * state (segment cache, address bar, history stack, pathname) is published\n * from a layout effect keyed on the tree object, so the event that puts a\n * route on screen is the event that makes it current (TIM-1301). Props work\n * for that exactly as state did.\n *\n * This component holds no pending state. The `TopLoader` it renders and the\n * public `usePendingNavigation()` both subscribe to the router's external\n * pending store; NavigationRoot's own `pendingUrl` was a second, unread\n * representation of the same fact and is gone (TIM-1307).\n *\n * Hard navigation guard: When a hard navigation is triggered (500 error,\n * version skew), the component throws an unresolved thenable AFTER all\n * hooks to suspend forever — preventing React from rendering children\n * during page teardown. The throw must come after hooks to satisfy\n * React's rules (same hook count every render) while still preventing\n * child renders that could hit hook count mismatches in components\n * whose positions shift during teardown. This pattern is borrowed from\n * Next.js (app-router.tsx pushRef.mpaNavigation — also after hooks).\n *\n * See design/05-streaming.md §\"deferSuspenseFor\"\n * See design/19-client-navigation.md §\"NavigationContext\"\n */\n\nimport { createElement, Fragment, useLayoutEffect, useRef, type ReactNode } from 'react';\nimport { TopLoader, type TopLoaderConfig } from './top-loader.tsx';\n\n// ─── Rendered Tree ──────────────────────────────────────────────\n\n/**\n * The tree the router has handed to React, and the state publish that belongs\n * to it. They travel as one object so React's commit of the tree is the event\n * that publishes — see the effect in NavigationRoot. Every `render` builds a\n * fresh one, which is what keys that effect: a tree is published once, however\n * many times React re-runs the effect for it.\n */\nexport interface RenderedTree {\n element: ReactNode;\n /**\n * Publishes the navigation's state — segment cache, pathname, address bar,\n * history stack, and the client's record of the mounted tree — and\n * announces it to listeners outside React. Runs when React commits\n * `element`, never before (TIM-1301). Null for a render that has nothing to\n * publish on commit (hydration, the shallow search re-wrap).\n */\n publish: (() => void) | null;\n}\n\n/**\n * Hand a tree to React in a transition. `publish` runs when React commits it.\n *\n * Every path that puts a page on screen goes through one of these — a\n * navigation, a revalidation, a popstate replay, a shallow search re-wrap —\n * and it is always a synchronous `startTransition` around `root.render`.\n * The production one is `createReactRoot().render`.\n *\n * `types` are the view transition types this render animates as\n * (design/37-navigation-api.md §\"Transition types\"). They are added with\n * `addTransitionType` inside that same `startTransition`, and nowhere else:\n * React queues types per root and hands them to the next transition-only\n * commit, so a type added in any other scope describes whichever tree commits\n * next rather than this one (TIM-1463, TIM-1471). Empty for the shallow search\n * re-wrap, which re-renders the displayed page rather than changing it.\n */\nexport type NavigationRender = (\n element: ReactNode,\n publish: (() => void) | null,\n types: readonly string[]\n) => void;\n\n// ─── Hard Navigation Guard ──────────────────────────────────────\n\n/**\n * Module-level flag indicating a hard (MPA) navigation is in progress.\n *\n * When true:\n * - NavigationRoot throws an unresolved thenable to suspend forever,\n * preventing React from rendering children during page teardown\n * (avoids \"Rendered more hooks\" crashes).\n * - The Navigation API handler skips interception, letting the browser\n * perform a full page load (prevents infinite loops where\n * window.location.href → navigate event → router.navigate → 500 →\n * window.location.href → ...).\n *\n * Uses globalThis for singleton guarantee across chunks (same pattern\n * as NavigationContext). See design/19-client-navigation.md §\"Singleton\n * Guarantee via globalThis\".\n */\nconst HARD_NAV_KEY = Symbol.for('__timber_hard_navigating');\n\nfunction getHardNavStore(): { value: boolean } {\n const g = globalThis as Record<symbol, unknown>;\n if (!g[HARD_NAV_KEY]) {\n g[HARD_NAV_KEY] = { value: false };\n }\n return g[HARD_NAV_KEY] as { value: boolean };\n}\n\n/**\n * Set the hard-navigating flag. Call this BEFORE setting\n * window.location.href or window.location.reload() to prevent:\n * 1. React from rendering children during page teardown\n * 2. Navigation API from intercepting the hard navigation\n */\nexport function setHardNavigating(value: boolean): void {\n getHardNavStore().value = value;\n}\n\n/**\n * Check if a hard navigation is in progress.\n * Used by NavigationRoot (throw unresolvedThenable) and by the\n * Navigation API handler (skip interception).\n */\nexport function isHardNavigating(): boolean {\n return getHardNavStore().value;\n}\n\n/**\n * A thenable that never resolves. When thrown during React render,\n * it causes the component to suspend forever — React keeps the\n * old committed tree visible and never attempts to render children.\n *\n * This is the same pattern Next.js uses in app-router.tsx for MPA\n * navigations (pushRef.mpaNavigation → throw unresolvedThenable).\n */\n// for React's Suspense mechanism. Same pattern as Next.js's unresolvedThenable.\n// eslint-disable-next-line unicorn/no-thenable -- Intentionally a never-resolving thenable\nconst unresolvedThenable = { then() {} } as PromiseLike<never>;\n\n// ─── Component ───────────────────────────────────────────────────\n\n/**\n * Root component the router renders the page through.\n *\n * Renders the TopLoader alongside the tree it is given. Neither adds a DOM\n * element on the hydration path, so the tree matches the server HTML.\n *\n * Rendered only by `createReactRoot` (client/react-root.ts): hydration passes\n * `{ element, publish: null }`, and every later render is a synchronous\n * `startTransition(() => root.render(...))` with a fresh `rendered` object.\n */\nexport function NavigationRoot({\n rendered,\n topLoaderConfig,\n}: {\n rendered: RenderedTree;\n topLoaderConfig?: TopLoaderConfig;\n}): ReactNode {\n // Publish the navigation's state when React commits its tree — not when the\n // tree is handed over. A tree React is still waiting on, or one a later\n // navigation replaces before React renders it, has been *given* to React\n // without being on screen; publishing then describes a route the user never\n // saw, which is the defect this ordering exists to prevent (TIM-1301).\n //\n // A **layout** effect, so the publish lands before the browser paints and,\n // more importantly, before every descendant's passive effect. A destination\n // component that navigates from a mount effect — a redirect guard, a\n // `refresh()` on mount — would otherwise start its navigation while the\n // segment cache, address bar and pathname still described the departing\n // route, and send an X-Timber-State-Tree for a tree that is no longer\n // mounted (codex on #998).\n //\n // Descendant *layout* effects still run first: React runs layout effects\n // child-before-parent, and the only way to precede them would be a fiber\n // rendered as an earlier sibling of the payload. That is not free here —\n // `server/ssr-wrappers.tsx` mirrors this component's fiber shape so `useId`\n // agrees across hydration, and an extra sibling shifts every id in the\n // payload subtree. A layout effect that navigates on mount is the price.\n //\n // Keyed on the tree object rather than on the effect run. A publish moves\n // the address bar, which is not idempotent, so any second invocation for the\n // same tree — an effect re-run React is entitled to perform, StrictMode's\n // double-invoke — must be a no-op rather than a second history entry.\n const publishedRef = useRef<RenderedTree | null>(null);\n useLayoutEffect(() => {\n if (publishedRef.current === rendered) return;\n publishedRef.current = rendered;\n rendered.publish?.();\n }, [rendered]);\n\n // ─── Hard navigation guard ─────────────────────────────────\n // When a hard navigation is in progress (500 error, version skew),\n // suspend forever to prevent React from rendering children during\n // page teardown. This avoids \"Rendered more hooks\" crashes in\n // CHILD components whose hook counts may shift during teardown.\n //\n // CRITICAL: This throw MUST come AFTER all hooks (the useRef and\n // useLayoutEffect above). React requires the same hooks to run on every\n // render. If we threw before hooks, React would see 0 hooks on the\n // re-render vs 2 on the initial render — triggering the exact \"Rendered\n // more hooks\" error we're trying to prevent.\n //\n // By placing it after hooks but before the return, all hooks\n // satisfy React's rules, but the thrown thenable prevents any\n // children from rendering. Same pattern as Next.js app-router.tsx\n // (pushRef.mpaNavigation — also placed after all hooks).\n if (isHardNavigating()) {\n throw unresolvedThenable;\n }\n\n // Inject TopLoader alongside the element tree. It subscribes to the router's\n // pending store itself, so it takes no props from here beyond its config,\n // and only it re-renders when a navigation starts or ends. Its slot holds\n // `null` when the loader is disabled via config.\n //\n // This Fragment is a FORK — two children — so it advances React's tree\n // context and shifts every `useId` below it. `server/ssr-wrappers.tsx`\n // mirrors it for exactly that reason, and renders the document's default\n // <meta> tags in the first slot. The fork is unconditional so the server\n // never needs to know whether the loader is enabled: a `null` child still\n // counts toward the fork on both sides. See tests/ssr-wrapper-parity.test.ts.\n const showTopLoader = topLoaderConfig?.enabled !== false;\n return createElement(\n Fragment,\n null,\n showTopLoader ? createElement(TopLoader, { config: topLoaderConfig }) : null,\n rendered.element\n );\n}\n"],"mappings":";;;;;;AAcA,SAAgB,gBAAgB,QAA8B;CAC5D,iBAAiB,MAAM;AACzB;;;;;AAMA,SAAgB,YAA4B;CAC1C,IAAI,CAAC,cACH,MAAM,IAAI,MAAM,6EAA6E;CAE/F,OAAO;AACT;;;;;;AAOA,SAAgB,kBAAyC;CACvD,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACFA,SAAgB,oBAAuB,KAAa,cAAmC;CACrF,OAAO,uBAAuB,OAAO,KAAK,YAAY;AACxD;;AAGA,SAAgB,uBACd,OACA,KACA,cACkB;CAClB,IAAI,OAAO,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