@timber-js/app 0.2.0-alpha.241 → 0.2.0-alpha.243

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 (331) hide show
  1. package/dist/_chunks/{actions-BCYVyoFl.js → actions-DoTj0Jd3.js} +78 -32
  2. package/dist/_chunks/actions-DoTj0Jd3.js.map +1 -0
  3. package/dist/_chunks/{als-registry-fabsRnPY.js → als-registry-C-iwbtvI.js} +1 -2
  4. package/dist/_chunks/{als-registry-fabsRnPY.js.map → als-registry-C-iwbtvI.js.map} +1 -1
  5. package/dist/_chunks/{cache-api-n5FL4wFs.js → cache-api-D3HmgsFh.js} +5 -5
  6. package/dist/_chunks/{cache-api-n5FL4wFs.js.map → cache-api-D3HmgsFh.js.map} +1 -1
  7. package/dist/_chunks/{chains-IswOWMnq.js → chains-BpvDwp08.js} +2 -2
  8. package/dist/_chunks/{chains-IswOWMnq.js.map → chains-BpvDwp08.js.map} +1 -1
  9. package/dist/_chunks/chains-CjlZZ5ad.js +1 -0
  10. package/dist/_chunks/{classify-B08RCF6s.js → classify-Bbb_lKjH.js} +2 -2
  11. package/dist/_chunks/{classify-B08RCF6s.js.map → classify-Bbb_lKjH.js.map} +1 -1
  12. package/dist/_chunks/{cli-check-tpFb6pBU.js → cli-check-DlQBSKIN.js} +3 -3
  13. package/dist/_chunks/{cli-check-tpFb6pBU.js.map → cli-check-DlQBSKIN.js.map} +1 -1
  14. package/dist/_chunks/{cli-schema-sync-DRNJutey.js → cli-schema-sync-CWkGFlYu.js} +2 -2
  15. package/dist/_chunks/{cli-schema-sync-DRNJutey.js.map → cli-schema-sync-CWkGFlYu.js.map} +1 -1
  16. package/dist/_chunks/{cli-schema-sync-C0pXBtzG.js → cli-schema-sync-Dyvdkv_I.js} +1 -1
  17. package/dist/_chunks/{client-dep-entries-Dw5Dvatr.js → client-dep-entries-Dka67elj.js} +2 -2
  18. package/dist/_chunks/{client-dep-entries-Dw5Dvatr.js.map → client-dep-entries-Dka67elj.js.map} +1 -1
  19. package/dist/_chunks/{convention-lint-BfC_dAhZ.js → convention-lint-CGGcseNn.js} +19 -5
  20. package/dist/_chunks/convention-lint-CGGcseNn.js.map +1 -0
  21. package/dist/_chunks/dev-server-DrjLscqT.js +1 -0
  22. package/dist/_chunks/{dev-server-3R6Bl9_R.js → dev-server-LO4McfQi.js} +3 -4
  23. package/dist/_chunks/dev-server-LO4McfQi.js.map +1 -0
  24. package/dist/_chunks/{error-boundary-Dfhxigko.js → error-boundary-wuNvAJ4n.js} +8 -15
  25. package/dist/_chunks/error-boundary-wuNvAJ4n.js.map +1 -0
  26. package/dist/_chunks/{flight-source-node-QOpWZATb.js → flight-source-node-BeF00Wo_.js} +4 -7
  27. package/dist/_chunks/flight-source-node-BeF00Wo_.js.map +1 -0
  28. package/dist/_chunks/{interception-CtNt9jPt.js → interception-D1dCGNmQ.js} +6 -6
  29. package/dist/_chunks/{interception-CtNt9jPt.js.map → interception-D1dCGNmQ.js.map} +1 -1
  30. package/dist/_chunks/{json-lossy-check-5KFcC1yt.js → json-lossy-check-DpXneTBm.js} +2 -2
  31. package/dist/_chunks/{json-lossy-check-5KFcC1yt.js.map → json-lossy-check-DpXneTBm.js.map} +1 -1
  32. package/dist/_chunks/key-headers-uIig1_mU.js +40 -0
  33. package/dist/_chunks/key-headers-uIig1_mU.js.map +1 -0
  34. package/dist/_chunks/{live-graph-D1dfVqoT.js → live-graph-DXhz6A_X.js} +4 -4
  35. package/dist/_chunks/{live-graph-D1dfVqoT.js.map → live-graph-DXhz6A_X.js.map} +1 -1
  36. package/dist/_chunks/{logger-BvGxPd1e.js → logger-D1sWX2I0.js} +18 -3
  37. package/dist/_chunks/logger-D1sWX2I0.js.map +1 -0
  38. package/dist/_chunks/metadata-routes-MXNjWOt5.js.map +1 -1
  39. package/dist/_chunks/{node-response-D5cfiyWP.js → node-response-Cp62CtH1.js} +2 -2
  40. package/dist/_chunks/{node-response-D5cfiyWP.js.map → node-response-Cp62CtH1.js.map} +1 -1
  41. package/dist/_chunks/{poison-scan-CX02ilxN.js → poison-scan-DdkJoHvP.js} +2 -2
  42. package/dist/_chunks/{poison-scan-CX02ilxN.js.map → poison-scan-DdkJoHvP.js.map} +1 -1
  43. package/dist/_chunks/{scanner-DneYxQoY.js → scanner-B6V2RqqF.js} +20 -3
  44. package/dist/_chunks/scanner-B6V2RqqF.js.map +1 -0
  45. package/dist/_chunks/{sizeof-BtQ3ErLf.js → sizeof-BKA6qOZq.js} +2 -2
  46. package/dist/_chunks/{sizeof-BtQ3ErLf.js.map → sizeof-BKA6qOZq.js.map} +1 -1
  47. package/dist/_chunks/{walkers-C9R2A4jN.js → walkers-BAZoAlfI.js} +3 -3
  48. package/dist/_chunks/{walkers-C9R2A4jN.js.map → walkers-BAZoAlfI.js.map} +1 -1
  49. package/dist/adapters/cloudflare-kv-cache.js +1 -1
  50. package/dist/analyze/crawl-entry.js +3 -3
  51. package/dist/analyze/graph-command.js +2 -2
  52. package/dist/cache/index.js +2 -2
  53. package/dist/cache/stores/memory.js +1 -1
  54. package/dist/cdn/workers-cache-purge.js +1 -1
  55. package/dist/cli.js +3 -3
  56. package/dist/client/browser-entry/router-init.d.ts +0 -1
  57. package/dist/client/browser-entry/router-init.d.ts.map +1 -1
  58. package/dist/client/document-withdrawal.d.ts +2 -0
  59. package/dist/client/document-withdrawal.d.ts.map +1 -0
  60. package/dist/client/error-boundary.js +1 -1
  61. package/dist/client/index.js +1 -1
  62. package/dist/client/index.js.map +1 -1
  63. package/dist/client/internal.js +3 -5
  64. package/dist/client/internal.js.map +1 -1
  65. package/dist/client/navigation-commit.d.ts +0 -7
  66. package/dist/client/navigation-commit.d.ts.map +1 -1
  67. package/dist/client/outlet-content-cache.d.ts +28 -42
  68. package/dist/client/outlet-content-cache.d.ts.map +1 -1
  69. package/dist/client/outlet-scope-context.d.ts +9 -4
  70. package/dist/client/outlet-scope-context.d.ts.map +1 -1
  71. package/dist/client/params-context.d.ts +1 -1
  72. package/dist/client/router-types.d.ts +3 -13
  73. package/dist/client/router-types.d.ts.map +1 -1
  74. package/dist/client/router.d.ts.map +1 -1
  75. package/dist/client/segment-cache.d.ts +2 -2
  76. package/dist/client/segment-outlet.d.ts +12 -15
  77. package/dist/client/segment-outlet.d.ts.map +1 -1
  78. package/dist/client/stale-segment.d.ts +2 -2
  79. package/dist/config-types.d.ts +2 -18
  80. package/dist/config-types.d.ts.map +1 -1
  81. package/dist/config-validation.d.ts.map +1 -1
  82. package/dist/index.js +7 -8
  83. package/dist/index.js.map +1 -1
  84. package/dist/native/rsc/manifest.json +3 -4
  85. package/dist/native/rsc/routing/segment-keys.js.map +1 -1
  86. package/dist/native/rsc/server/als-registry.js +1 -2
  87. package/dist/native/rsc/server/als-registry.js.map +1 -1
  88. package/dist/native/rsc/server/client-state-tree.js +1 -5
  89. package/dist/native/rsc/server/client-state-tree.js.map +1 -1
  90. package/dist/native/rsc/server/cookie-context.js +7 -7
  91. package/dist/native/rsc/server/cookie-context.js.map +1 -1
  92. package/dist/native/rsc/server/deny-boundary.js +2 -1
  93. package/dist/native/rsc/server/deny-boundary.js.map +1 -1
  94. package/dist/native/rsc/server/dev-overlay-report.js +13 -0
  95. package/dist/native/rsc/server/dev-overlay-report.js.map +1 -0
  96. package/dist/native/rsc/server/flight-source-node.js +2 -5
  97. package/dist/native/rsc/server/flight-source-node.js.map +1 -1
  98. package/dist/native/rsc/server/flight-source.js +6 -41
  99. package/dist/native/rsc/server/flight-source.js.map +1 -1
  100. package/dist/native/rsc/server/framework-stack-frames.js.map +1 -1
  101. package/dist/native/rsc/server/logger.js +6 -1
  102. package/dist/native/rsc/server/logger.js.map +1 -1
  103. package/dist/native/rsc/server/pipeline-interception.js +4 -1
  104. package/dist/native/rsc/server/pipeline-interception.js.map +1 -1
  105. package/dist/native/rsc/server/pipeline.js.map +1 -1
  106. package/dist/native/rsc/server/request-context.js +6 -6
  107. package/dist/native/rsc/server/request-context.js.map +1 -1
  108. package/dist/native/rsc/server/route-element-builder.js +5 -5
  109. package/dist/native/rsc/server/route-element-builder.js.map +1 -1
  110. package/dist/native/rsc/server/rsc-entry/render-route.js +4 -30
  111. package/dist/native/rsc/server/rsc-entry/render-route.js.map +1 -1
  112. package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js +0 -2
  113. package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js.map +1 -1
  114. package/dist/native/rsc/server/rsc-entry/rsc-stream.js +2 -5
  115. package/dist/native/rsc/server/rsc-entry/rsc-stream.js.map +1 -1
  116. package/dist/native/rsc/server/segment-lifetime/outlet-gate.js +44 -0
  117. package/dist/native/rsc/server/segment-lifetime/outlet-gate.js.map +1 -0
  118. package/dist/native/rsc/server/segment-lifetime/read-rule.js +45 -12
  119. package/dist/native/rsc/server/segment-lifetime/read-rule.js.map +1 -1
  120. package/dist/native/rsc/server/segment-lifetime/read-scope.js +50 -8
  121. package/dist/native/rsc/server/segment-lifetime/read-scope.js.map +1 -1
  122. package/dist/native/rsc/server/segment-lifetime/segment-key.js +17 -3
  123. package/dist/native/rsc/server/segment-lifetime/segment-key.js.map +1 -1
  124. package/dist/native/rsc/server/segment-lifetime/slot-outlets.js +4 -4
  125. package/dist/native/rsc/server/segment-lifetime/slot-outlets.js.map +1 -1
  126. package/dist/native/rsc/server/slot-resolver.js +8 -7
  127. package/dist/native/rsc/server/slot-resolver.js.map +1 -1
  128. package/dist/native/rsc/server/slot-subtree-contain.js +2 -1
  129. package/dist/native/rsc/server/slot-subtree-contain.js.map +1 -1
  130. package/dist/native/rsc/server/subtree-walk.js +14 -5
  131. package/dist/native/rsc/server/subtree-walk.js.map +1 -1
  132. package/dist/native/rsc/server/vite-handoff-rsc.js.map +1 -1
  133. package/dist/native/rsc/shared/key-headers.js +20 -0
  134. package/dist/native/rsc/shared/key-headers.js.map +1 -0
  135. package/dist/native/rsc/shared/outlet-decision.js.map +1 -1
  136. package/dist/native/ssr/client/document-withdrawal.js +17 -0
  137. package/dist/native/ssr/client/document-withdrawal.js.map +1 -0
  138. package/dist/native/ssr/client/outlet-content-cache.js +10 -25
  139. package/dist/native/ssr/client/outlet-content-cache.js.map +1 -1
  140. package/dist/native/ssr/client/outlet-scope-context.js.map +1 -1
  141. package/dist/native/ssr/client/segment-outlet.js +17 -21
  142. package/dist/native/ssr/client/segment-outlet.js.map +1 -1
  143. package/dist/native/ssr/manifest.json +6 -1
  144. package/dist/native/ssr/server/als-registry.js +0 -1
  145. package/dist/native/ssr/server/als-registry.js.map +1 -1
  146. package/dist/native/ssr/server/client-state-tree.js +1 -5
  147. package/dist/native/ssr/server/client-state-tree.js.map +1 -1
  148. package/dist/native/ssr/server/cookie-context.js +7 -7
  149. package/dist/native/ssr/server/cookie-context.js.map +1 -1
  150. package/dist/native/ssr/server/deny-boundary.js +2 -1
  151. package/dist/native/ssr/server/deny-boundary.js.map +1 -1
  152. package/dist/native/ssr/server/dev-overlay-report.js +6 -0
  153. package/dist/native/ssr/server/dev-overlay-report.js.map +1 -0
  154. package/dist/native/ssr/server/flight-source-node.js +2 -5
  155. package/dist/native/ssr/server/flight-source-node.js.map +1 -1
  156. package/dist/native/ssr/server/flight-source.js +0 -1
  157. package/dist/native/ssr/server/flight-source.js.map +1 -1
  158. package/dist/native/ssr/server/framework-stack-frames.js.map +1 -1
  159. package/dist/native/ssr/server/logger.js +6 -1
  160. package/dist/native/ssr/server/logger.js.map +1 -1
  161. package/dist/native/ssr/server/pipeline-interception.js +4 -1
  162. package/dist/native/ssr/server/pipeline-interception.js.map +1 -1
  163. package/dist/native/ssr/server/pipeline.js.map +1 -1
  164. package/dist/native/ssr/server/request-context.js +6 -6
  165. package/dist/native/ssr/server/request-context.js.map +1 -1
  166. package/dist/native/ssr/server/segment-lifetime/outlet-gate.js +11 -0
  167. package/dist/native/ssr/server/segment-lifetime/outlet-gate.js.map +1 -0
  168. package/dist/native/ssr/server/segment-lifetime/read-rule.js +45 -12
  169. package/dist/native/ssr/server/segment-lifetime/read-rule.js.map +1 -1
  170. package/dist/native/ssr/server/segment-lifetime/read-scope.js +16 -0
  171. package/dist/native/ssr/server/segment-lifetime/read-scope.js.map +1 -0
  172. package/dist/native/ssr/server/subtree-walk.js +149 -0
  173. package/dist/native/ssr/server/subtree-walk.js.map +1 -0
  174. package/dist/native/ssr/server/utils/element-type.js +21 -9
  175. package/dist/native/ssr/server/utils/element-type.js.map +1 -1
  176. package/dist/native/ssr/server/vite-handoff-rsc.js.map +1 -1
  177. package/dist/native/ssr/shared/key-headers.js +13 -0
  178. package/dist/native/ssr/shared/key-headers.js.map +1 -0
  179. package/dist/plugins/entries.d.ts.map +1 -1
  180. package/dist/routing/index.js +3 -3
  181. package/dist/routing/route-options.d.ts.map +1 -1
  182. package/dist/routing/segment-keys.d.ts +3 -4
  183. package/dist/routing/segment-keys.d.ts.map +1 -1
  184. package/dist/routing/slot-placement.d.ts +23 -4
  185. package/dist/routing/slot-placement.d.ts.map +1 -1
  186. package/dist/server/als-registry.d.ts +20 -16
  187. package/dist/server/als-registry.d.ts.map +1 -1
  188. package/dist/server/client-state-tree.d.ts +5 -11
  189. package/dist/server/client-state-tree.d.ts.map +1 -1
  190. package/dist/server/deny-boundary.d.ts.map +1 -1
  191. package/dist/server/dev-overlay-report.d.ts +13 -0
  192. package/dist/server/dev-overlay-report.d.ts.map +1 -0
  193. package/dist/server/flight-source-node.d.ts +1 -6
  194. package/dist/server/flight-source-node.d.ts.map +1 -1
  195. package/dist/server/flight-source.d.ts +0 -27
  196. package/dist/server/flight-source.d.ts.map +1 -1
  197. package/dist/server/framework-stack-frames.d.ts +1 -4
  198. package/dist/server/framework-stack-frames.d.ts.map +1 -1
  199. package/dist/server/index.js +2 -2
  200. package/dist/server/internal.js +105 -26
  201. package/dist/server/internal.js.map +1 -1
  202. package/dist/server/logger.d.ts +10 -0
  203. package/dist/server/logger.d.ts.map +1 -1
  204. package/dist/server/pipeline-interception.d.ts.map +1 -1
  205. package/dist/server/pipeline.d.ts +13 -1
  206. package/dist/server/pipeline.d.ts.map +1 -1
  207. package/dist/server/request-context.d.ts.map +1 -1
  208. package/dist/server/route-element-builder.d.ts +2 -2
  209. package/dist/server/route-element-builder.d.ts.map +1 -1
  210. package/dist/server/rsc-entry/helpers.d.ts +1 -1
  211. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  212. package/dist/server/rsc-entry/render-route.d.ts +0 -1
  213. package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
  214. package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -1
  215. package/dist/server/rsc-entry/rsc-stream.d.ts +2 -11
  216. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  217. package/dist/server/segment-lifetime/outlet-gate.d.ts +58 -0
  218. package/dist/server/segment-lifetime/outlet-gate.d.ts.map +1 -0
  219. package/dist/server/segment-lifetime/read-rule.d.ts +19 -13
  220. package/dist/server/segment-lifetime/read-rule.d.ts.map +1 -1
  221. package/dist/server/segment-lifetime/read-scope.d.ts +48 -6
  222. package/dist/server/segment-lifetime/read-scope.d.ts.map +1 -1
  223. package/dist/server/segment-lifetime/segment-key.d.ts +3 -0
  224. package/dist/server/segment-lifetime/segment-key.d.ts.map +1 -1
  225. package/dist/server/segment-lifetime/slot-outlets.d.ts +3 -3
  226. package/dist/server/segment-lifetime/slot-outlets.d.ts.map +1 -1
  227. package/dist/server/slot-resolver.d.ts +5 -5
  228. package/dist/server/slot-resolver.d.ts.map +1 -1
  229. package/dist/server/slot-subtree-contain.d.ts.map +1 -1
  230. package/dist/server/subtree-walk.d.ts +17 -3
  231. package/dist/server/subtree-walk.d.ts.map +1 -1
  232. package/dist/server/types.d.ts +8 -2
  233. package/dist/server/types.d.ts.map +1 -1
  234. package/dist/server/vite-handoff-rsc.d.ts +3 -10
  235. package/dist/server/vite-handoff-rsc.d.ts.map +1 -1
  236. package/dist/shared/key-headers.d.ts +13 -0
  237. package/dist/shared/key-headers.d.ts.map +1 -0
  238. package/dist/shared/outlet-decision.d.ts +13 -44
  239. package/dist/shared/outlet-decision.d.ts.map +1 -1
  240. package/dist/shared/payload-root.d.ts +1 -1
  241. package/dist/shared/segment-info.d.ts +3 -7
  242. package/dist/shared/segment-info.d.ts.map +1 -1
  243. package/docs/api/30-api-server.mdx +1 -1
  244. package/docs/api/34-api-config.mdx +1 -1
  245. package/package.json +1 -1
  246. package/src/client/browser-entry/index.ts +0 -2
  247. package/src/client/browser-entry/router-init.ts +2 -4
  248. package/src/client/document-withdrawal.tsx +41 -0
  249. package/src/client/error-boundary.tsx +1 -1
  250. package/src/client/navigation-commit.ts +4 -18
  251. package/src/client/outlet-content-cache.ts +38 -60
  252. package/src/client/outlet-scope-context.ts +10 -5
  253. package/src/client/params-context.ts +1 -1
  254. package/src/client/router-types.ts +3 -14
  255. package/src/client/router.ts +0 -2
  256. package/src/client/rsc-fetch.ts +1 -1
  257. package/src/client/segment-cache.ts +2 -2
  258. package/src/client/segment-outlet.tsx +28 -54
  259. package/src/client/stale-segment.ts +2 -2
  260. package/src/config-types.ts +2 -18
  261. package/src/config-validation.ts +0 -1
  262. package/src/plugins/entries.ts +0 -1
  263. package/src/routing/interception.ts +5 -5
  264. package/src/routing/route-options.ts +20 -4
  265. package/src/routing/scanner.ts +1 -1
  266. package/src/routing/segment-keys.ts +3 -4
  267. package/src/routing/slot-placement.ts +41 -4
  268. package/src/rsc-runtime/vendor-types.d.ts +1 -1
  269. package/src/server/als-registry.ts +16 -23
  270. package/src/server/client-state-tree.ts +7 -18
  271. package/src/server/cookie-context.ts +7 -7
  272. package/src/server/deny-boundary.ts +4 -1
  273. package/src/server/dev-overlay-report.ts +22 -0
  274. package/src/server/flight-source-node.ts +1 -5
  275. package/src/server/flight-source.ts +1 -81
  276. package/src/server/framework-stack-frames.ts +1 -4
  277. package/src/server/logger.ts +13 -0
  278. package/src/server/pipeline-interception.ts +11 -2
  279. package/src/server/pipeline.ts +13 -1
  280. package/src/server/request-context.ts +12 -11
  281. package/src/server/route-element-builder.ts +15 -16
  282. package/src/server/rsc-entry/helpers.ts +1 -1
  283. package/src/server/rsc-entry/index.ts +7 -3
  284. package/src/server/rsc-entry/render-route.ts +7 -54
  285. package/src/server/rsc-entry/revalidate-renderer.ts +0 -2
  286. package/src/server/rsc-entry/rsc-stream.ts +3 -23
  287. package/src/server/segment-lifetime/outlet-gate.ts +102 -0
  288. package/src/server/segment-lifetime/read-rule.ts +110 -22
  289. package/src/server/segment-lifetime/read-scope.ts +131 -15
  290. package/src/server/segment-lifetime/segment-key.ts +31 -3
  291. package/src/server/segment-lifetime/slot-outlets.ts +6 -6
  292. package/src/server/slot-resolver.ts +30 -18
  293. package/src/server/slot-subtree-contain.ts +2 -1
  294. package/src/server/subtree-walk.ts +34 -9
  295. package/src/server/types.ts +8 -2
  296. package/src/server/vite-handoff-rsc.ts +3 -12
  297. package/src/shared/key-headers.ts +42 -0
  298. package/src/shared/outlet-decision.ts +13 -48
  299. package/src/shared/payload-root.ts +1 -1
  300. package/src/shared/segment-info.ts +3 -7
  301. package/dist/_chunks/actions-BCYVyoFl.js.map +0 -1
  302. package/dist/_chunks/chains-DPZAMMav.js +0 -1
  303. package/dist/_chunks/convention-lint-BfC_dAhZ.js.map +0 -1
  304. package/dist/_chunks/dev-server-3DNTXQV-.js +0 -1
  305. package/dist/_chunks/dev-server-3R6Bl9_R.js.map +0 -1
  306. package/dist/_chunks/error-boundary-Dfhxigko.js.map +0 -1
  307. package/dist/_chunks/flight-source-node-QOpWZATb.js.map +0 -1
  308. package/dist/_chunks/logger-BvGxPd1e.js.map +0 -1
  309. package/dist/_chunks/scanner-DneYxQoY.js.map +0 -1
  310. package/dist/native/rsc/server/segment-hash/capture.js +0 -107
  311. package/dist/native/rsc/server/segment-hash/capture.js.map +0 -1
  312. package/dist/native/rsc/server/segment-hash/outlet.js +0 -101
  313. package/dist/native/rsc/server/segment-hash/outlet.js.map +0 -1
  314. package/dist/native/rsc/server/segment-hash/stream-tap.js +0 -139
  315. package/dist/native/rsc/server/segment-hash/stream-tap.js.map +0 -1
  316. package/dist/native/rsc/server/segment-hash/value-hash.js +0 -171
  317. package/dist/native/rsc/server/segment-hash/value-hash.js.map +0 -1
  318. package/dist/native/ssr/server/segment-hash/value-hash.js +0 -162
  319. package/dist/native/ssr/server/segment-hash/value-hash.js.map +0 -1
  320. package/dist/server/segment-hash/capture.d.ts +0 -77
  321. package/dist/server/segment-hash/capture.d.ts.map +0 -1
  322. package/dist/server/segment-hash/outlet.d.ts +0 -93
  323. package/dist/server/segment-hash/outlet.d.ts.map +0 -1
  324. package/dist/server/segment-hash/stream-tap.d.ts +0 -49
  325. package/dist/server/segment-hash/stream-tap.d.ts.map +0 -1
  326. package/dist/server/segment-hash/value-hash.d.ts +0 -70
  327. package/dist/server/segment-hash/value-hash.d.ts.map +0 -1
  328. package/src/server/segment-hash/capture.ts +0 -232
  329. package/src/server/segment-hash/outlet.ts +0 -229
  330. package/src/server/segment-hash/stream-tap.ts +0 -244
  331. package/src/server/segment-hash/value-hash.ts +0 -338
@@ -1,244 +0,0 @@
1
- /**
2
- * The advertised hash: each live segment's hash, computed from what the main
3
- * Flight stream actually sent.
4
- *
5
- * A live `SegmentOutlet` carries `decision.hash` as a promise. The tap feeds
6
- * the outgoing stream to React's own Flight client in the RSC environment,
7
- * finds each live outlet in the decoded tree, and once everything the
8
- * decision's `children` reach has settled, resolves that promise with the
9
- * hash of those decoded values (value-hash.ts). Flight then writes the hash
10
- * as one more row. The client stores it beside the content it committed, so
11
- * the hash it later advertises describes exactly what it received
12
- * (design/52 §"Two hashes, two jobs").
13
- *
14
- * Nothing about this can stall the response: a hash the tap cannot compute
15
- * resolves to null once the decoded payload has been explored without
16
- * finding its outlet, or when the stream ends, and every pending hash
17
- * resolves to null once `timeoutMs` passes — a pending promise would otherwise hold the
18
- * Flight stream open.
19
- *
20
- * See design/52-segment-hash-dedupe.md §"Wire format".
21
- */
22
-
23
- import { hashSettledValue } from './value-hash.ts';
24
-
25
- export interface SegmentHashTap {
26
- /**
27
- * The hash of live segment `segmentPath`'s content in this stream, once it
28
- * has all arrived. Null when it cannot be computed.
29
- */
30
- advertise(segmentPath: string): Promise<string | null>;
31
- /** Feed one chunk of the outgoing stream. */
32
- observe(chunk: Uint8Array): void;
33
- /** The stream ended or was cancelled: give up on everything pending. */
34
- end(): void;
35
- /**
36
- * Run `cancel` once the stream ends, however it ends; returns the
37
- * unsubscribe. Captures started for this render stop with it (capture.ts) —
38
- * nothing waits on them any more. A callback list rather than an
39
- * AbortSignal: aborting a signal from the stream's teardown kept every
40
- * finished request reachable in dev (tests/e2e/dev-request-retention.test.ts).
41
- */
42
- onEnd(cancel: () => void): () => void;
43
- }
44
-
45
- export interface SegmentHashTapOptions {
46
- timeoutMs: number;
47
- /** Whether a decoded element type is timber's `SegmentOutlet`. */
48
- isOutlet: (type: unknown) => boolean;
49
- /** React's Flight client in the RSC environment. */
50
- decode: (stream: ReadableStream<Uint8Array>) => PromiseLike<unknown>;
51
- }
52
-
53
- const LAZY = Symbol.for('react.lazy');
54
- const ELEMENT = new Set([Symbol.for('react.transitional.element'), Symbol.for('react.element')]);
55
-
56
- function isThenable(value: unknown): value is PromiseLike<unknown> {
57
- return (
58
- typeof value === 'object' &&
59
- value !== null &&
60
- typeof (value as { then?: unknown }).then === 'function'
61
- );
62
- }
63
-
64
- /** Await a decoded promise; a rejection settles to undefined. */
65
- async function settled(value: PromiseLike<unknown>): Promise<unknown> {
66
- try {
67
- return await value;
68
- } catch {
69
- return undefined;
70
- }
71
- }
72
-
73
- export function createSegmentHashTap(options: SegmentHashTapOptions): SegmentHashTap {
74
- const pending = new Map<string, (hash: string | null) => void>();
75
- const computed = new Map<string, Promise<string | null>>();
76
- const ambiguous = new Set<string>();
77
- const onEnd = new Set<() => void>();
78
- const state = { aborted: false };
79
- let explored = false;
80
- let timer: ReturnType<typeof setTimeout> | undefined;
81
- let controller: ReadableStreamDefaultController<Uint8Array> | null = null;
82
-
83
- const stream = new ReadableStream<Uint8Array>({
84
- start(c) {
85
- controller = c;
86
- },
87
- });
88
-
89
- function settle(path: string, hash: string | null): void {
90
- const resolve = pending.get(path);
91
- if (!resolve) return;
92
- pending.delete(path);
93
- resolve(hash);
94
- if (pending.size === 0 && timer !== undefined) {
95
- clearTimeout(timer);
96
- timer = undefined;
97
- }
98
- }
99
-
100
- function deliver(path: string): void {
101
- const hash = computed.get(path);
102
- if (!hash || !pending.has(path)) return;
103
- // A hash that cannot be computed is no hash — never a rejection left to
104
- // crash the process.
105
- void hash.then(
106
- (h) => settle(path, ambiguous.has(path) ? null : h),
107
- () => settle(path, null)
108
- );
109
- }
110
-
111
- // ─── Finding the outlets in the decoded tree ─────────────────────────────
112
-
113
- const visited = new WeakSet<object>();
114
-
115
- /** Walk a decoded value for outlet elements, waiting on what is pending. */
116
- async function explore(value: unknown): Promise<void> {
117
- if (state.aborted || value === null || typeof value !== 'object') return;
118
- if (visited.has(value)) return;
119
- visited.add(value);
120
- const tagged = value as { $$typeof?: unknown; _payload?: unknown };
121
- if (tagged.$$typeof === LAZY) {
122
- if (isThenable(tagged._payload)) await explore(await settled(tagged._payload));
123
- return;
124
- }
125
- if (tagged.$$typeof !== undefined && ELEMENT.has(tagged.$$typeof as symbol)) {
126
- const { props } = value as { props: Record<string, unknown> | null };
127
- // A client component's type arrives as a lazy reference to its module.
128
- let type = (value as { type: unknown }).type;
129
- const lazyType = type as { $$typeof?: unknown; _payload?: unknown } | null;
130
- if (lazyType && typeof lazyType === 'object' && lazyType.$$typeof === LAZY) {
131
- type = isThenable(lazyType._payload) ? await settled(lazyType._payload) : undefined;
132
- }
133
- if (options.isOutlet(type) && props) {
134
- await outlet(props.segmentPath, props.decision);
135
- return;
136
- }
137
- await explore(props);
138
- return;
139
- }
140
- if (isThenable(value)) {
141
- await explore(await settled(value));
142
- return;
143
- }
144
- const children: unknown[] = Array.isArray(value)
145
- ? value
146
- : value instanceof Map
147
- ? [...value.keys(), ...value.values()]
148
- : value instanceof Set
149
- ? [...value]
150
- : Object.getPrototypeOf(value) === Object.prototype ||
151
- Object.getPrototypeOf(value) === null
152
- ? Object.values(value)
153
- : [];
154
- await Promise.all(children.map(explore));
155
- }
156
-
157
- /** One outlet: hash it if live, and find the outlets inside it. */
158
- async function outlet(segmentPath: unknown, decisionValue: unknown): Promise<void> {
159
- if (typeof segmentPath !== 'string') return;
160
- const decision = isThenable(decisionValue) ? await settled(decisionValue) : decisionValue;
161
- if (!decision || typeof decision !== 'object') return;
162
- const d = decision as { skip?: unknown; children?: unknown; outlets?: unknown };
163
- if (d.skip === true) {
164
- // A skip carries its nested segments' decisions.
165
- const outlets = d.outlets && typeof d.outlets === 'object' ? d.outlets : {};
166
- await Promise.all(Object.entries(outlets).map(([path, nested]) => outlet(path, nested)));
167
- return;
168
- }
169
- if (computed.has(segmentPath)) ambiguous.add(segmentPath);
170
- computed.set(segmentPath, hashSettledValue(d.children, { isOutlet: options.isOutlet }, state));
171
- deliver(segmentPath);
172
- await explore(d.children);
173
- }
174
-
175
- /**
176
- * Everything the payload reaches has been explored: an outlet whose hash is
177
- * still pending is one the walk did not find (a value kind it does not
178
- * descend into). Its hash is none — it must not hold the stream open until
179
- * the deadline.
180
- */
181
- function exploredAll(): void {
182
- explored = true;
183
- for (const path of [...pending.keys()]) if (!computed.has(path)) settle(path, null);
184
- }
185
-
186
- // Decoding starts at once and reads whatever `observe` feeds it. A decoder
187
- // that throws — even synchronously — ends hashing, never the response.
188
- void new Promise<unknown>((resolve) => resolve(options.decode(stream)))
189
- .then((root) => explore(root))
190
- .then(exploredAll)
191
- .catch(() => end());
192
-
193
- function end(): void {
194
- if (state.aborted) return;
195
- state.aborted = true;
196
- for (const cancel of [...onEnd]) cancel();
197
- onEnd.clear();
198
- if (timer !== undefined) clearTimeout(timer);
199
- timer = undefined;
200
- try {
201
- controller?.close();
202
- } catch {
203
- // Already closed or errored.
204
- }
205
- controller = null;
206
- for (const path of [...pending.keys()]) settle(path, null);
207
- computed.clear();
208
- }
209
-
210
- return {
211
- advertise(segmentPath) {
212
- if (state.aborted) return Promise.resolve(null);
213
- if (pending.has(segmentPath)) {
214
- // Two live outlets claimed one path: neither hash is trustworthy.
215
- ambiguous.add(segmentPath);
216
- settle(segmentPath, null);
217
- return Promise.resolve(null);
218
- }
219
- if (explored && !computed.has(segmentPath)) return Promise.resolve(null);
220
- const promise = new Promise<string | null>((resolve) => pending.set(segmentPath, resolve));
221
- timer ??= setTimeout(end, options.timeoutMs);
222
- deliver(segmentPath);
223
- return promise;
224
- },
225
- observe(chunk) {
226
- // The tap runs inside the response's stream: nothing it does may break
227
- // that stream. A chunk it cannot hand on ends hashing for this response.
228
- try {
229
- controller?.enqueue(chunk);
230
- } catch {
231
- end();
232
- }
233
- },
234
- end,
235
- onEnd(cancel) {
236
- if (state.aborted) {
237
- cancel();
238
- return () => {};
239
- }
240
- onEnd.add(cancel);
241
- return () => onEnd.delete(cancel);
242
- },
243
- };
244
- }
@@ -1,338 +0,0 @@
1
- /**
2
- * The hash of a segment: a canonical walk over the values React's own Flight
3
- * client decoded — never over the wire format.
4
- *
5
- * Both sides of the comparison are decoded by React (`createFromReadableStream`
6
- * in the RSC environment): the capture of a segment, and the segment's rows in
7
- * the response the client received. So everything about how Flight encodes a
8
- * value — which markers mean references, how objects are outlined or deduped,
9
- * which rows carry debug info — is interpreted by the code that defines it,
10
- * and a React upgrade that changes the encoding changes nothing here.
11
- *
12
- * What is hashed is what a client can observe:
13
- *
14
- * - **Identity.** Every object is a node, numbered on first visit; a later
15
- * visit writes `alias(n)`. Objects are the decoded objects themselves, so
16
- * sharing, cycles and promise identity are exactly what the client gets —
17
- * and a shared subgraph is written once.
18
- * - **An allowlist of value kinds**: primitives, plain objects (own keys, in
19
- * order), arrays, React elements, client and server references, promises,
20
- * lazy elements, Dates, Maps, Sets, binary data and errors. Anything else —
21
- * a stream, an async iterator, a class instance — makes the segment
22
- * unhashable, which means it is always sent: a value kind this code does
23
- * not know costs bytes, never correctness.
24
- * - **Holes.** A nested `SegmentOutlet` element is `hole(segmentPath, key)`;
25
- * its decision — and the nested segment's content — is not visited.
26
- *
27
- * The hash is SHA-256, truncated to 132 bits (22 base64url characters).
28
- *
29
- * See design/52-segment-hash-dedupe.md §"The hash is over a canonical form".
30
- */
31
-
32
- import { createHash } from 'node:crypto';
33
-
34
- export const SEGMENT_HASH_LENGTH = 22;
35
-
36
- export type ValueHashOutcome =
37
- /** Every value the subgraph reaches is settled. */
38
- | { status: 'complete'; hash: string; streaming: boolean }
39
- /** Some promises or lazy elements are still pending; wait for them. */
40
- | { status: 'pending'; streaming: boolean; waitFor: PromiseLike<unknown>[] }
41
- /** A value of a kind not on the allowlist, or over budget: always sent. */
42
- | { status: 'unhashable' };
43
-
44
- export interface ValueHashOptions {
45
- /** Whether an element type is timber's `SegmentOutlet` client reference. */
46
- isOutlet(type: unknown): boolean;
47
- }
48
-
49
- const ELEMENT = new Set([Symbol.for('react.transitional.element'), Symbol.for('react.element')]);
50
- const LAZY = Symbol.for('react.lazy');
51
- const CLIENT_REFERENCE = Symbol.for('react.client.reference');
52
- const SERVER_REFERENCE = Symbol.for('react.server.reference');
53
- const SUSPENSE = Symbol.for('react.suspense');
54
-
55
- /** Thrown inside the walk for a value kind not on the allowlist. */
56
- const UNHASHABLE = Symbol('unhashable');
57
-
58
- /**
59
- * Upper bound on a canonical form, in characters. Far above any segment a
60
- * page sends; it exists so that no value graph can make the synchronous walk
61
- * do unbounded work.
62
- */
63
- const BUDGET = 32 * 1024 * 1024;
64
-
65
- /**
66
- * Upper bound on how deeply objects nest, so the recursive walk never
67
- * reaches the engine's stack limit: an element costs about three levels
68
- * (element, props, children), so this is some 330 levels of markup. A
69
- * deeper graph is unhashable — sent, never skipped.
70
- */
71
- const MAX_DEPTH = 1000;
72
-
73
- export function hashCanonical(canonical: string): string {
74
- return createHash('sha256').update(canonical).digest('base64url').slice(0, SEGMENT_HASH_LENGTH);
75
- }
76
-
77
- /**
78
- * In dev, @vitejs/plugin-rsc appends `$$cache=<random>` to every reference
79
- * id, freshly per render, so the browser re-imports a module after HMR. Two
80
- * renders of the same tree name the same module with different ids; the tag
81
- * is not part of what the module is.
82
- */
83
- export function stripReferenceCacheTag(id: string): string {
84
- return id.replace(/\$\$cache=[^#]*/, '');
85
- }
86
-
87
- /** A React Flight chunk or any thenable a decoded value may hold. */
88
- interface Thenable {
89
- then: (onFulfilled: (value: unknown) => void, onRejected: (reason: unknown) => void) => unknown;
90
- status?: string;
91
- value?: unknown;
92
- reason?: unknown;
93
- }
94
-
95
- function isThenable(value: object): value is Thenable {
96
- return typeof (value as { then?: unknown }).then === 'function';
97
- }
98
-
99
- /** Hash the value graph rooted at `root`. */
100
- export function hashValue(root: unknown, options: ValueHashOptions): ValueHashOutcome {
101
- const nodes = new Map<object, number>();
102
- const waitFor: PromiseLike<unknown>[] = [];
103
- let size = 0;
104
- let depth = 0;
105
- let streaming = false;
106
-
107
- const emit = (text: string): string => {
108
- size += text.length;
109
- if (size > BUDGET) throw UNHASHABLE;
110
- return text;
111
- };
112
-
113
- const node = (object: object, write: () => string): string => {
114
- const seen = nodes.get(object);
115
- if (seen !== undefined) return emit('alias(' + seen + ')');
116
- nodes.set(object, nodes.size);
117
- if (++depth > MAX_DEPTH) throw UNHASHABLE;
118
- const out = write();
119
- depth--;
120
- return out;
121
- };
122
-
123
- /** A settled promise's value, or `pending` with the walk going on past it. */
124
- const settled = (thenable: Thenable): { value: unknown } | { error: unknown } | null => {
125
- if (thenable.status === 'fulfilled') return { value: thenable.value };
126
- if (thenable.status === 'rejected') return { error: thenable.reason };
127
- waitFor.push(thenable as PromiseLike<unknown>);
128
- return null;
129
- };
130
-
131
- const value = (v: unknown): string => {
132
- switch (typeof v) {
133
- case 'undefined':
134
- return emit('u');
135
- case 'boolean':
136
- return emit(v ? 't' : 'f');
137
- case 'number':
138
- return emit(Object.is(v, -0) ? 'n(-0)' : 'n(' + String(v) + ')');
139
- case 'bigint':
140
- return emit('big(' + v.toString() + ')');
141
- case 'string':
142
- return emit(JSON.stringify(v));
143
- case 'symbol': {
144
- const key = Symbol.keyFor(v);
145
- if (key === undefined) throw UNHASHABLE;
146
- if (v === SUSPENSE) streaming = true;
147
- return emit('sym(' + JSON.stringify(key) + ')');
148
- }
149
- case 'function':
150
- return reference(v);
151
- case 'object':
152
- return v === null ? emit('null') : object(v);
153
- }
154
- throw UNHASHABLE;
155
- };
156
-
157
- const reference = (fn: object): string => {
158
- const ref = fn as { $$typeof?: unknown; $$id?: unknown; $$bound?: unknown };
159
- const id = ref.$$id;
160
- if (typeof id !== 'string') throw UNHASHABLE;
161
- if (ref.$$typeof === CLIENT_REFERENCE) {
162
- return emit('client(' + JSON.stringify(stripReferenceCacheTag(id)) + ')');
163
- }
164
- if (ref.$$typeof === SERVER_REFERENCE) {
165
- return node(
166
- fn,
167
- () =>
168
- emit('server(' + JSON.stringify(stripReferenceCacheTag(id)) + ',') +
169
- value(ref.$$bound ?? null) +
170
- emit(')')
171
- );
172
- }
173
- throw UNHASHABLE;
174
- };
175
-
176
- const object = (o: object): string => {
177
- const tagged = o as { $$typeof?: unknown };
178
- if (tagged.$$typeof !== undefined && ELEMENT.has(tagged.$$typeof as symbol)) return element(o);
179
- if (tagged.$$typeof === LAZY) {
180
- const payload = (o as { _payload?: unknown })._payload;
181
- if (!payload || typeof payload !== 'object' || !isThenable(payload)) throw UNHASHABLE;
182
- // A lazy element is its chunk's value, rendered in place.
183
- return node(o, () => {
184
- const result = settled(payload);
185
- if (result === null) return emit('pending');
186
- return 'error' in result ? error(result.error) : value(result.value);
187
- });
188
- }
189
- if (tagged.$$typeof === CLIENT_REFERENCE || tagged.$$typeof === SERVER_REFERENCE) {
190
- return reference(o);
191
- }
192
- if (isThenable(o)) {
193
- // A promise prop — the client receives it as a thenable. Waiting on it
194
- // is streaming, the same as a Suspense boundary.
195
- streaming = true;
196
- return node(o, () => {
197
- const result = settled(o);
198
- if (result === null) return emit('promise(pending)');
199
- return 'error' in result
200
- ? emit('promise(') + error(result.error) + emit(')')
201
- : emit('promise(') + value(result.value) + emit(')');
202
- });
203
- }
204
- if (Array.isArray(o)) {
205
- return node(o, () => emit('[') + o.map((item) => value(item)).join(',') + emit(']'));
206
- }
207
- if (o instanceof Date) return node(o, () => emit('date(' + String(o.getTime()) + ')'));
208
- if (o instanceof Map) {
209
- return node(
210
- o,
211
- () =>
212
- emit('map(') +
213
- [...o].map(([k, item]) => value(k) + emit(':') + value(item)).join(',') +
214
- emit(')')
215
- );
216
- }
217
- if (o instanceof Set) {
218
- return node(o, () => emit('set(') + [...o].map((item) => value(item)).join(',') + emit(')'));
219
- }
220
- if (o instanceof ArrayBuffer) {
221
- return node(o, () => emit('buffer(' + bytes(new Uint8Array(o)) + ')'));
222
- }
223
- if (ArrayBuffer.isView(o)) {
224
- const view = new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
225
- return node(o, () => emit('view(' + o.constructor.name + ',' + bytes(view) + ')'));
226
- }
227
- if (o instanceof Error) return node(o, () => error(o));
228
- const proto = Object.getPrototypeOf(o);
229
- if (proto !== Object.prototype && proto !== null) throw UNHASHABLE;
230
- // Own key order, not sorted: a client component that iterates its props
231
- // (`Object.entries`, a `style` object's shorthand/longhand order) renders
232
- // differently when it changes.
233
- return node(
234
- o,
235
- () =>
236
- emit('{') +
237
- Object.keys(o)
238
- .map((k) => emit(JSON.stringify(k) + ':') + value((o as Record<string, unknown>)[k]))
239
- .join(',') +
240
- emit('}')
241
- );
242
- };
243
-
244
- const element = (el: object): string => {
245
- const { key, props } = el as { key: unknown; props: unknown };
246
- // A client component's type arrives as a lazy reference to its module
247
- // until the module resolves.
248
- let type = (el as { type: unknown }).type;
249
- const lazyType = type as { $$typeof?: unknown; _payload?: unknown } | null;
250
- if (lazyType && typeof lazyType === 'object' && lazyType.$$typeof === LAZY) {
251
- const payload = lazyType._payload;
252
- if (!payload || typeof payload !== 'object' || !isThenable(payload)) throw UNHASHABLE;
253
- const result = settled(payload);
254
- if (result === null) return emit('pending');
255
- if ('error' in result) return error(result.error);
256
- type = result.value;
257
- }
258
- if (options.isOutlet(type)) {
259
- const segmentPath =
260
- props && typeof props === 'object'
261
- ? (props as { segmentPath?: unknown }).segmentPath
262
- : undefined;
263
- // The key stays: a layout that re-keys its children (cloneElement) asks
264
- // React to remount them, which is a change to the layout's output.
265
- return emit(
266
- 'hole(' + JSON.stringify(segmentPath ?? null) + ',' + JSON.stringify(key ?? null) + ')'
267
- );
268
- }
269
- return node(
270
- el,
271
- () =>
272
- emit('el(') +
273
- value(type) +
274
- emit(',' + JSON.stringify(key ?? null) + ',') +
275
- value(props) +
276
- emit(')')
277
- );
278
- };
279
-
280
- /**
281
- * An error, as Flight sends it. Production sends a bare marker the client
282
- * revives as a generic Error (or a digest on an error row). Development
283
- * sends name, message, stack and environment, and the `cause` and an
284
- * AggregateError's `errors` — all of which the client's revived error
285
- * carries, so all of which are hashed.
286
- */
287
- const error = (e: unknown): string => {
288
- if (!(e instanceof Error)) return emit('error(') + value(e) + emit(')');
289
- const fields = e as Error & { digest?: unknown; environmentName?: unknown; errors?: unknown };
290
- let out = emit(
291
- 'error(' +
292
- JSON.stringify([
293
- e.name,
294
- e.message,
295
- typeof fields.digest === 'string' ? fields.digest : null,
296
- typeof e.stack === 'string' ? e.stack : null,
297
- typeof fields.environmentName === 'string' ? fields.environmentName : null,
298
- ])
299
- );
300
- if ('cause' in e) out += emit(',cause:') + value(e.cause);
301
- if (Array.isArray(fields.errors)) out += emit(',errors:') + value(fields.errors);
302
- return out + emit(')');
303
- };
304
-
305
- try {
306
- const canonical = value(root);
307
- if (waitFor.length > 0) return { status: 'pending', streaming, waitFor };
308
- return { status: 'complete', hash: hashCanonical(canonical), streaming };
309
- } catch (thrown) {
310
- if (thrown === UNHASHABLE) return { status: 'unhashable' };
311
- throw thrown;
312
- }
313
- }
314
-
315
- function bytes(view: Uint8Array): string {
316
- let binary = '';
317
- for (let i = 0; i < view.length; i++) binary += String.fromCharCode(view[i]);
318
- return btoa(binary);
319
- }
320
-
321
- /**
322
- * Hash `root` once everything it reaches has settled, waiting as needed.
323
- * Settles to null if it is unhashable or `signal` aborts first.
324
- */
325
- export async function hashSettledValue(
326
- root: unknown,
327
- options: ValueHashOptions,
328
- signal: { aborted: boolean }
329
- ): Promise<string | null> {
330
- for (;;) {
331
- if (signal.aborted) return null;
332
- const outcome = hashValue(root, options);
333
- if (outcome.status === 'complete') return outcome.hash;
334
- if (outcome.status === 'unhashable') return null;
335
- // Rejections are part of the value (`error(...)`), not a reason to stop.
336
- await Promise.allSettled(outcome.waitFor.map((t) => Promise.resolve(t)));
337
- }
338
- }