@timber-js/app 0.2.0-alpha.222 → 0.2.0-alpha.223

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 (354) hide show
  1. package/agent-skill.md +21 -5
  2. package/dist/_chunks/{actions-vBHr2vqd.js → actions-7dTXYJfu.js} +53 -24
  3. package/dist/_chunks/actions-7dTXYJfu.js.map +1 -0
  4. package/dist/_chunks/{als-registry-BZqHCtq-.js → als-registry-DpygwCp0.js} +2 -3
  5. package/dist/_chunks/{als-registry-BZqHCtq-.js.map → als-registry-DpygwCp0.js.map} +1 -1
  6. package/dist/_chunks/{als-slots-BEEIPKYm.js → als-slots-kbQrHTzm.js} +2 -3
  7. package/dist/_chunks/{als-slots-BEEIPKYm.js.map → als-slots-kbQrHTzm.js.map} +1 -1
  8. package/dist/_chunks/{base-path-DaQrzbez.js → base-path-DDIx0FXe.js} +2 -3
  9. package/dist/_chunks/{base-path-DaQrzbez.js.map → base-path-DDIx0FXe.js.map} +1 -1
  10. package/dist/_chunks/{build-manifest-DWppEdLB.js → build-manifest-Y4jl7nwU.js} +2 -3
  11. package/dist/_chunks/{build-manifest-DWppEdLB.js.map → build-manifest-Y4jl7nwU.js.map} +1 -1
  12. package/dist/_chunks/{build-output-helper-RV_BRcF1.js → build-output-helper-B7wWGTfR.js} +14 -10
  13. package/dist/_chunks/build-output-helper-B7wWGTfR.js.map +1 -0
  14. package/dist/_chunks/{cache-api-DdcDLpBj.js → cache-api-TDZ4hlDc.js} +190 -38
  15. package/dist/_chunks/cache-api-TDZ4hlDc.js.map +1 -0
  16. package/dist/_chunks/{canonicalize-BAWkWiKK.js → canonicalize-CqK135BN.js} +29 -4
  17. package/dist/_chunks/{canonicalize-BAWkWiKK.js.map → canonicalize-CqK135BN.js.map} +1 -1
  18. package/dist/_chunks/chains-CwOr3Myj.js +1 -0
  19. package/dist/_chunks/{chains-BchW_AtW.js → chains-Dgm3PrMe.js} +3 -4
  20. package/dist/_chunks/{chains-BchW_AtW.js.map → chains-Dgm3PrMe.js.map} +1 -1
  21. package/dist/_chunks/{classify-IqzMpxMs.js → classify--_kINHQV.js} +4 -5
  22. package/dist/_chunks/{classify-IqzMpxMs.js.map → classify--_kINHQV.js.map} +1 -1
  23. package/dist/_chunks/{cli-check-DQne_YhU.js → cli-check-Dv3f8d2j.js} +5 -6
  24. package/dist/_chunks/{cli-check-DQne_YhU.js.map → cli-check-Dv3f8d2j.js.map} +1 -1
  25. package/dist/_chunks/{cli-context-_mPttGGY.js → cli-context-CbZp32SK.js} +3 -4
  26. package/dist/_chunks/{cli-context-_mPttGGY.js.map → cli-context-CbZp32SK.js.map} +1 -1
  27. package/dist/_chunks/cli-context-n5hmkdla.js +1 -0
  28. package/dist/_chunks/cli-dev-status-prPMLU8G.js +138 -0
  29. package/dist/_chunks/cli-dev-status-prPMLU8G.js.map +1 -0
  30. package/dist/_chunks/cli-init-BoXOYYil.js +196 -0
  31. package/dist/_chunks/cli-init-BoXOYYil.js.map +1 -0
  32. package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js → cli-schema-sync-DIPurq7X.js} +4 -5
  33. package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js.map → cli-schema-sync-DIPurq7X.js.map} +1 -1
  34. package/dist/_chunks/{cli-schema-sync-v872sHms.js → cli-schema-sync-uq72EZmD.js} +1 -1
  35. package/dist/_chunks/{client-dep-entries-BJyP9SIu.js → client-dep-entries-CP7AkMCM.js} +4 -5
  36. package/dist/_chunks/{client-dep-entries-BJyP9SIu.js.map → client-dep-entries-CP7AkMCM.js.map} +1 -1
  37. package/dist/_chunks/{cloudflare-Byxl8FWP.js → cloudflare-B75X6u4O.js} +10 -13
  38. package/dist/_chunks/{cloudflare-Byxl8FWP.js.map → cloudflare-B75X6u4O.js.map} +1 -1
  39. package/dist/_chunks/{codec-registry-oOUxugz3.js → codec-registry-CPc6bjVl.js} +2 -3
  40. package/dist/_chunks/{codec-registry-oOUxugz3.js.map → codec-registry-CPc6bjVl.js.map} +1 -1
  41. package/dist/_chunks/{codegen-Bps1sLKJ.js → codegen-B9oWkWGf.js} +5 -8
  42. package/dist/_chunks/{codegen-Bps1sLKJ.js.map → codegen-B9oWkWGf.js.map} +1 -1
  43. package/dist/_chunks/{convention-lint-VwzrtjIt.js → convention-lint-hZwz5wd4.js} +8 -11
  44. package/dist/_chunks/{convention-lint-VwzrtjIt.js.map → convention-lint-hZwz5wd4.js.map} +1 -1
  45. package/dist/_chunks/dev-discovery-YnabkCKD.js +238 -0
  46. package/dist/_chunks/dev-discovery-YnabkCKD.js.map +1 -0
  47. package/dist/_chunks/{dev-server-BNr5drEO.js → dev-server-C61GWpGg.js} +369 -55
  48. package/dist/_chunks/dev-server-C61GWpGg.js.map +1 -0
  49. package/dist/_chunks/dev-server-CBvvM7Lr.js +1 -0
  50. package/dist/_chunks/{dev-store-BOa304m_.js → dev-store-BvdqtHvK.js} +82 -38
  51. package/dist/_chunks/dev-store-BvdqtHvK.js.map +1 -0
  52. package/dist/_chunks/{dist-DtrJyBbw.js → dist-C1Rjlo6s.js} +3 -5
  53. package/dist/_chunks/{dist-DtrJyBbw.js.map → dist-C1Rjlo6s.js.map} +1 -1
  54. package/dist/_chunks/{error-boundary-Bc8QPZuq.js → error-boundary-DRQXGWCp.js} +20 -27
  55. package/dist/_chunks/{error-boundary-Bc8QPZuq.js.map → error-boundary-DRQXGWCp.js.map} +1 -1
  56. package/dist/_chunks/{fast-hash-C-tVYrLb.js → fast-hash-DddxkU5Y.js} +2 -3
  57. package/dist/_chunks/{fast-hash-C-tVYrLb.js.map → fast-hash-DddxkU5Y.js.map} +1 -1
  58. package/dist/_chunks/{flight-source-node-BdHUOUqg.js → flight-source-node-0Tp6evlz.js} +6 -8
  59. package/dist/_chunks/flight-source-node-0Tp6evlz.js.map +1 -0
  60. package/dist/_chunks/{format-BKclgVbk.js → format-DuPOoXUP.js} +2 -3
  61. package/dist/_chunks/{format-BKclgVbk.js.map → format-DuPOoXUP.js.map} +1 -1
  62. package/dist/_chunks/{fs-identity-BRKuL215.js → fs-identity-BmQ_Agg-.js} +3 -5
  63. package/dist/_chunks/{fs-identity-BRKuL215.js.map → fs-identity-BmQ_Agg-.js.map} +1 -1
  64. package/dist/_chunks/{global-context-B9PFncvb.js → global-context-DbxNWeBP.js} +2 -3
  65. package/dist/_chunks/{global-context-B9PFncvb.js.map → global-context-DbxNWeBP.js.map} +1 -1
  66. package/dist/_chunks/{graph-cache-CYiUS2aS.js → graph-cache-B1LAg4t7.js} +5 -89
  67. package/dist/_chunks/graph-cache-B1LAg4t7.js.map +1 -0
  68. package/dist/_chunks/{href-validation-BIrxavIy.js → href-validation-CEZy1V-k.js} +4 -7
  69. package/dist/_chunks/{href-validation-BIrxavIy.js.map → href-validation-CEZy1V-k.js.map} +1 -1
  70. package/dist/_chunks/{json-lossy-check-C3Sht92C.js → json-lossy-check-DVkLUlfC.js} +3 -4
  71. package/dist/_chunks/{json-lossy-check-C3Sht92C.js.map → json-lossy-check-DVkLUlfC.js.map} +1 -1
  72. package/dist/_chunks/{live-graph-DEu_GWbc.js → live-graph-BcVjQ1Te.js} +6 -7
  73. package/dist/_chunks/{live-graph-DEu_GWbc.js.map → live-graph-BcVjQ1Te.js.map} +1 -1
  74. package/dist/_chunks/{logger-CI_hThfy.js → logger-CWk44DLp.js} +89 -47
  75. package/dist/_chunks/logger-CWk44DLp.js.map +1 -0
  76. package/dist/_chunks/{metadata-routes-B3XJNyIH.js → metadata-routes-BL26HCDd.js} +2 -3
  77. package/dist/_chunks/{metadata-routes-B3XJNyIH.js.map → metadata-routes-BL26HCDd.js.map} +1 -1
  78. package/dist/_chunks/{navigation-root-BQfo1-kG.js → navigation-root-M3B2ZrdO.js} +6 -10
  79. package/dist/_chunks/{navigation-root-BQfo1-kG.js.map → navigation-root-M3B2ZrdO.js.map} +1 -1
  80. package/dist/_chunks/{node-response-bF0bKoig.js → node-response-B9aviPDa.js} +43 -9
  81. package/dist/_chunks/node-response-B9aviPDa.js.map +1 -0
  82. package/dist/_chunks/{param-value-C8TNYchQ.js → param-value-DqlGfF57.js} +2 -3
  83. package/dist/_chunks/{param-value-C8TNYchQ.js.map → param-value-DqlGfF57.js.map} +1 -1
  84. package/dist/_chunks/{plugin-context-uDHFqHHJ.js → plugin-context-BfSRKJfz.js} +1 -1
  85. package/dist/_chunks/{plugin-context-DxMMvjUt.js → plugin-context-FCkaNLUB.js} +4 -6
  86. package/dist/_chunks/plugin-context-FCkaNLUB.js.map +1 -0
  87. package/dist/_chunks/{poison-rules-DoEhbqaY.js → poison-rules-Bmz-lCPi.js} +2 -3
  88. package/dist/_chunks/{poison-rules-DoEhbqaY.js.map → poison-rules-Bmz-lCPi.js.map} +1 -1
  89. package/dist/_chunks/{poison-scan-DTWIfNgD.js → poison-scan-DJYxZc_7.js} +4 -5
  90. package/dist/_chunks/{poison-scan-DTWIfNgD.js.map → poison-scan-DJYxZc_7.js.map} +1 -1
  91. package/dist/_chunks/{purge-store-WZaxu-3m.js → purge-store-8BqLAYZ1.js} +2 -3
  92. package/dist/_chunks/{purge-store-WZaxu-3m.js.map → purge-store-8BqLAYZ1.js.map} +1 -1
  93. package/dist/_chunks/{render-timeout-Ln_u7fX-.js → render-timeout-MrrqD1wd.js} +2 -3
  94. package/dist/_chunks/{render-timeout-Ln_u7fX-.js.map → render-timeout-MrrqD1wd.js.map} +1 -1
  95. package/dist/_chunks/{resolve-schema-CkAInout.js → resolve-schema-B-aCuTu3.js} +3 -4
  96. package/dist/_chunks/{resolve-schema-CkAInout.js.map → resolve-schema-B-aCuTu3.js.map} +1 -1
  97. package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js → rsc-cache-key-D0cb0Gmc.js} +2 -3
  98. package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js.map → rsc-cache-key-D0cb0Gmc.js.map} +1 -1
  99. package/dist/_chunks/{rsc-media-type-DDc7duTD.js → rsc-media-type-m8jz9u6_.js} +2 -3
  100. package/dist/_chunks/{rsc-media-type-DDc7duTD.js.map → rsc-media-type-m8jz9u6_.js.map} +1 -1
  101. package/dist/_chunks/{rsc-payload-path-dffcs4jp.js → rsc-payload-path-EphpDB-J.js} +2 -3
  102. package/dist/_chunks/{rsc-payload-path-dffcs4jp.js.map → rsc-payload-path-EphpDB-J.js.map} +1 -1
  103. package/dist/_chunks/{scan-BoP17W3w.js → scan-CyizcBiX.js} +2 -3
  104. package/dist/_chunks/{scan-BoP17W3w.js.map → scan-CyizcBiX.js.map} +1 -1
  105. package/dist/_chunks/{scanner-C8fdKvKG.js → scanner-CJC-ScJU.js} +15 -23
  106. package/dist/_chunks/{scanner-C8fdKvKG.js.map → scanner-CJC-ScJU.js.map} +1 -1
  107. package/dist/_chunks/{schema-bridge-DpOmvZlI.js → schema-bridge-DyRs3cqy.js} +2 -3
  108. package/dist/_chunks/{schema-bridge-DpOmvZlI.js.map → schema-bridge-DyRs3cqy.js.map} +1 -1
  109. package/dist/_chunks/{segment-classify-C539Pa2O.js → segment-classify-Ho8jXWeC.js} +3 -5
  110. package/dist/_chunks/{segment-classify-C539Pa2O.js.map → segment-classify-Ho8jXWeC.js.map} +1 -1
  111. package/dist/_chunks/{segment-context-D3DNxKFq.js → segment-context-CYiGTi3K.js} +4 -6
  112. package/dist/_chunks/{segment-context-D3DNxKFq.js.map → segment-context-CYiGTi3K.js.map} +1 -1
  113. package/dist/_chunks/{segment-keys-D5hu1hz4.js → segment-keys-Y60KNc8C.js} +2 -3
  114. package/dist/_chunks/{segment-keys-D5hu1hz4.js.map → segment-keys-Y60KNc8C.js.map} +1 -1
  115. package/dist/_chunks/{singleflight-BeVMMKi0.js → singleflight-BChPMjwH.js} +2 -3
  116. package/dist/_chunks/{singleflight-BeVMMKi0.js.map → singleflight-BChPMjwH.js.map} +1 -1
  117. package/dist/_chunks/{sizeof-CO3dk0V1.js → sizeof-DG4W40lv.js} +3 -4
  118. package/dist/_chunks/{sizeof-CO3dk0V1.js.map → sizeof-DG4W40lv.js.map} +1 -1
  119. package/dist/_chunks/{ssr-data-nA3I70_n.js → ssr-data-9hPtcNOr.js} +3 -4
  120. package/dist/_chunks/{ssr-data-nA3I70_n.js.map → ssr-data-9hPtcNOr.js.map} +1 -1
  121. package/dist/_chunks/{state-BhNGPsdi.js → state-B-EBjeER.js} +2 -3
  122. package/dist/_chunks/{state-BhNGPsdi.js.map → state-B-EBjeER.js.map} +1 -1
  123. package/dist/_chunks/{status-page-marker-BRX9Ib-d.js → status-page-marker-XIQXlTOb.js} +8 -13
  124. package/dist/_chunks/{status-page-marker-BRX9Ib-d.js.map → status-page-marker-XIQXlTOb.js.map} +1 -1
  125. package/dist/_chunks/{tree-match-6yihorhk.js → tree-match-Bqdr9szG.js} +2 -3
  126. package/dist/_chunks/{tree-match-6yihorhk.js.map → tree-match-Bqdr9szG.js.map} +1 -1
  127. package/dist/_chunks/{use-query-states-I3JMng6J.js → use-query-states-pkDV-jSg.js} +4 -7
  128. package/dist/_chunks/{use-query-states-I3JMng6J.js.map → use-query-states-pkDV-jSg.js.map} +1 -1
  129. package/dist/_chunks/{walkers-BqzxnwGC.js → walkers-DIE203ir.js} +6 -8
  130. package/dist/_chunks/{walkers-BqzxnwGC.js.map → walkers-DIE203ir.js.map} +1 -1
  131. package/dist/_chunks/{write-file-atomic-D1qWqHb4.js → write-file-atomic-DW8m_Atv.js} +2 -3
  132. package/dist/_chunks/{write-file-atomic-D1qWqHb4.js.map → write-file-atomic-DW8m_Atv.js.map} +1 -1
  133. package/dist/adapters/build-output-helper.d.ts +10 -1
  134. package/dist/adapters/build-output-helper.d.ts.map +1 -1
  135. package/dist/adapters/cloudflare-dev.js +2 -3
  136. package/dist/adapters/cloudflare-kv-cache.js +3 -4
  137. package/dist/adapters/cloudflare.d.ts.map +1 -1
  138. package/dist/adapters/cloudflare.js +1 -1
  139. package/dist/adapters/nitro-presets.d.ts +6 -0
  140. package/dist/adapters/nitro-presets.d.ts.map +1 -1
  141. package/dist/adapters/nitro-preview.d.ts.map +1 -1
  142. package/dist/adapters/nitro.d.ts.map +1 -1
  143. package/dist/adapters/nitro.js +94 -57
  144. package/dist/adapters/nitro.js.map +1 -1
  145. package/dist/analyze/crawl-entry.js +7 -9
  146. package/dist/analyze/crawl-entry.js.map +1 -1
  147. package/dist/analyze/graph-command.d.ts.map +1 -1
  148. package/dist/analyze/graph-command.js +19 -105
  149. package/dist/analyze/graph-command.js.map +1 -1
  150. package/dist/cache/index.js +3 -3
  151. package/dist/cache/key-discipline.d.ts +61 -0
  152. package/dist/cache/key-discipline.d.ts.map +1 -0
  153. package/dist/cache/stores/cloudflare-kv.js +1 -2
  154. package/dist/cache/stores/memory.js +2 -3
  155. package/dist/cache/stores/redis.js +1 -2
  156. package/dist/cache/stores/vercel.js +1 -2
  157. package/dist/cache/timber-cache.d.ts +5 -1
  158. package/dist/cache/timber-cache.d.ts.map +1 -1
  159. package/dist/cdn/cloudflare-purge.js +1 -2
  160. package/dist/cdn/fastly-purge.js +1 -2
  161. package/dist/cdn/index.js +2 -3
  162. package/dist/cdn/workers-cache-purge.js +3 -5
  163. package/dist/cdn/workers-cache-purge.js.map +1 -1
  164. package/dist/cli-dev-status.d.ts +75 -0
  165. package/dist/cli-dev-status.d.ts.map +1 -0
  166. package/dist/cli-init.d.ts +72 -0
  167. package/dist/cli-init.d.ts.map +1 -0
  168. package/dist/cli.d.ts +4 -12
  169. package/dist/cli.d.ts.map +1 -1
  170. package/dist/cli.js +27 -54
  171. package/dist/cli.js.map +1 -1
  172. package/dist/client/error-boundary.d.ts.map +1 -1
  173. package/dist/client/error-boundary.js +1 -1
  174. package/dist/client/index.js +22 -34
  175. package/dist/client/index.js.map +1 -1
  176. package/dist/client/internal.js +13 -18
  177. package/dist/client/internal.js.map +1 -1
  178. package/dist/client/use-cookie.d.ts +18 -5
  179. package/dist/client/use-cookie.d.ts.map +1 -1
  180. package/dist/codec.js +2 -3
  181. package/dist/config-types.d.ts +22 -5
  182. package/dist/config-types.d.ts.map +1 -1
  183. package/dist/config-validation.d.ts.map +1 -1
  184. package/dist/cookies/define-cookie.d.ts.map +1 -1
  185. package/dist/cookies/index.js +40 -67
  186. package/dist/cookies/index.js.map +1 -1
  187. package/dist/cookies/json-cookie.d.ts +4 -4
  188. package/dist/index.js +266 -229
  189. package/dist/index.js.map +1 -1
  190. package/dist/params/index.js +3 -4
  191. package/dist/plugin-context.d.ts +7 -0
  192. package/dist/plugin-context.d.ts.map +1 -1
  193. package/dist/plugins/dev-discovery.d.ts +69 -5
  194. package/dist/plugins/dev-discovery.d.ts.map +1 -1
  195. package/dist/plugins/dev-hostname.d.ts +152 -0
  196. package/dist/plugins/dev-hostname.d.ts.map +1 -0
  197. package/dist/plugins/dev-server.d.ts +5 -1
  198. package/dist/plugins/dev-server.d.ts.map +1 -1
  199. package/dist/plugins/dev-store-clear.d.ts +59 -4
  200. package/dist/plugins/dev-store-clear.d.ts.map +1 -1
  201. package/dist/plugins/graph-endpoint.d.ts +4 -2
  202. package/dist/plugins/graph-endpoint.d.ts.map +1 -1
  203. package/dist/plugins/prebuilt.d.ts.map +1 -1
  204. package/dist/routing/index.js +4 -4
  205. package/dist/rsc-runtime/rsc.d.ts +2 -1
  206. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  207. package/dist/rsc-runtime/server-references.d.ts +8 -0
  208. package/dist/rsc-runtime/server-references.d.ts.map +1 -0
  209. package/dist/search-params/index.js +5 -7
  210. package/dist/search-params/index.js.map +1 -1
  211. package/dist/server/access-gate.d.ts +12 -0
  212. package/dist/server/access-gate.d.ts.map +1 -1
  213. package/dist/server/canonicalize.d.ts +21 -0
  214. package/dist/server/canonicalize.d.ts.map +1 -1
  215. package/dist/server/cookie-context.d.ts +8 -1
  216. package/dist/server/cookie-context.d.ts.map +1 -1
  217. package/dist/server/flight-source-node.d.ts.map +1 -1
  218. package/dist/server/flight-source.d.ts.map +1 -1
  219. package/dist/server/index.d.ts +1 -1
  220. package/dist/server/index.d.ts.map +1 -1
  221. package/dist/server/index.js +8 -13
  222. package/dist/server/index.js.map +1 -1
  223. package/dist/server/interception-gates.d.ts +49 -0
  224. package/dist/server/interception-gates.d.ts.map +1 -0
  225. package/dist/server/internal.js +1061 -943
  226. package/dist/server/internal.js.map +1 -1
  227. package/dist/server/logger.d.ts +17 -0
  228. package/dist/server/logger.d.ts.map +1 -1
  229. package/dist/server/param-coercion.d.ts +8 -0
  230. package/dist/server/param-coercion.d.ts.map +1 -1
  231. package/dist/server/pipeline-interception.d.ts +34 -4
  232. package/dist/server/pipeline-interception.d.ts.map +1 -1
  233. package/dist/server/pipeline-metadata-route.d.ts +24 -0
  234. package/dist/server/pipeline-metadata-route.d.ts.map +1 -0
  235. package/dist/server/pipeline-metadata.d.ts +3 -2
  236. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  237. package/dist/server/pipeline-phases.d.ts +9 -3
  238. package/dist/server/pipeline-phases.d.ts.map +1 -1
  239. package/dist/server/pipeline.d.ts +18 -0
  240. package/dist/server/pipeline.d.ts.map +1 -1
  241. package/dist/server/prebuilt/dev-store.d.ts +68 -22
  242. package/dist/server/prebuilt/dev-store.d.ts.map +1 -1
  243. package/dist/server/prebuilt/overlay.d.ts +8 -0
  244. package/dist/server/prebuilt/overlay.d.ts.map +1 -1
  245. package/dist/server/prebuilt-runtime.d.ts.map +1 -1
  246. package/dist/server/primitives.d.ts +13 -0
  247. package/dist/server/primitives.d.ts.map +1 -1
  248. package/dist/server/render-utils.d.ts +21 -0
  249. package/dist/server/render-utils.d.ts.map +1 -1
  250. package/dist/server/request-context.d.ts +14 -0
  251. package/dist/server/request-context.d.ts.map +1 -1
  252. package/dist/server/route-element-builder.d.ts.map +1 -1
  253. package/dist/server/route-handler.d.ts +7 -0
  254. package/dist/server/route-handler.d.ts.map +1 -1
  255. package/dist/server/route-matcher.d.ts +14 -3
  256. package/dist/server/route-matcher.d.ts.map +1 -1
  257. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  258. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  259. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  260. package/dist/server/signal-identity.d.ts +6 -0
  261. package/dist/server/signal-identity.d.ts.map +1 -1
  262. package/dist/server/traced-access.d.ts +18 -0
  263. package/dist/server/traced-access.d.ts.map +1 -0
  264. package/dist/server/tracing.d.ts.map +1 -1
  265. package/dist/server/types.d.ts +5 -4
  266. package/dist/server/types.d.ts.map +1 -1
  267. package/dist/shims/font-google.js +1 -2
  268. package/dist/shims/font-local.js +1 -2
  269. package/dist/shims/headers.d.ts +11 -4
  270. package/dist/shims/headers.d.ts.map +1 -1
  271. package/docs/api/30-api-server.mdx +3 -1
  272. package/docs/api/32-api-cache.mdx +1 -1
  273. package/docs/api/34-api-config.mdx +22 -0
  274. package/docs/api/36-cli.mdx +72 -6
  275. package/docs/learn/01-quick-start.mdx +1 -1
  276. package/docs/learn/06-typed-params.mdx +2 -2
  277. package/docs/learn/10-caching.mdx +26 -5
  278. package/llms.txt +1 -1
  279. package/package.json +12 -12
  280. package/src/adapters/build-output-helper.ts +26 -4
  281. package/src/adapters/cloudflare.ts +1 -0
  282. package/src/adapters/nitro-presets.ts +15 -0
  283. package/src/adapters/nitro-preview.ts +66 -34
  284. package/src/adapters/nitro.ts +14 -6
  285. package/src/analyze/graph-command.ts +25 -133
  286. package/src/cache/key-discipline.ts +218 -0
  287. package/src/cache/timber-cache.ts +42 -5
  288. package/src/cli-dev-status.ts +196 -0
  289. package/src/cli-init.ts +278 -0
  290. package/src/cli.ts +33 -79
  291. package/src/client/error-boundary.tsx +19 -2
  292. package/src/client/use-cookie.ts +33 -21
  293. package/src/config-types.ts +22 -5
  294. package/src/config-validation.ts +17 -0
  295. package/src/cookies/define-cookie.ts +10 -46
  296. package/src/cookies/json-cookie.ts +4 -4
  297. package/src/plugin-context.ts +7 -0
  298. package/src/plugins/dev-discovery.ts +216 -6
  299. package/src/plugins/dev-hostname.ts +322 -0
  300. package/src/plugins/dev-server.ts +96 -37
  301. package/src/plugins/dev-store-clear.ts +105 -7
  302. package/src/plugins/graph-endpoint.ts +15 -3
  303. package/src/plugins/prebuilt.ts +9 -0
  304. package/src/rsc-runtime/rsc.ts +7 -3
  305. package/src/rsc-runtime/server-references.ts +73 -0
  306. package/src/rsc-runtime/vendor-types.d.ts +9 -0
  307. package/src/server/access-gate.tsx +32 -20
  308. package/src/server/action-handler.ts +40 -34
  309. package/src/server/canonicalize.ts +27 -0
  310. package/src/server/cookie-context.ts +11 -3
  311. package/src/server/flight-source-node.ts +5 -2
  312. package/src/server/flight-source.ts +4 -3
  313. package/src/server/index.ts +6 -1
  314. package/src/server/interception-gates.ts +94 -0
  315. package/src/server/logger.ts +23 -0
  316. package/src/server/param-coercion.ts +22 -0
  317. package/src/server/pipeline-interception.ts +64 -4
  318. package/src/server/pipeline-metadata-route.ts +242 -0
  319. package/src/server/pipeline-metadata.ts +7 -5
  320. package/src/server/pipeline-phases.ts +71 -131
  321. package/src/server/pipeline.ts +20 -2
  322. package/src/server/prebuilt/dev-store.ts +113 -34
  323. package/src/server/prebuilt/overlay.ts +18 -0
  324. package/src/server/prebuilt-runtime.ts +43 -44
  325. package/src/server/primitives.ts +14 -0
  326. package/src/server/render-utils.ts +25 -0
  327. package/src/server/request-context.ts +27 -3
  328. package/src/server/route-element-builder.ts +15 -2
  329. package/src/server/route-handler.ts +3 -2
  330. package/src/server/route-matcher.ts +48 -33
  331. package/src/server/rsc-entry/api-handler.ts +2 -33
  332. package/src/server/rsc-entry/index.ts +8 -3
  333. package/src/server/rsc-entry/rsc-stream.ts +7 -1
  334. package/src/server/signal-identity.ts +30 -12
  335. package/src/server/traced-access.ts +50 -0
  336. package/src/server/tracing.ts +18 -1
  337. package/src/server/types.ts +5 -4
  338. package/src/shims/headers.ts +12 -4
  339. package/dist/_chunks/actions-vBHr2vqd.js.map +0 -1
  340. package/dist/_chunks/build-output-helper-RV_BRcF1.js.map +0 -1
  341. package/dist/_chunks/cache-api-DdcDLpBj.js.map +0 -1
  342. package/dist/_chunks/chains-B8TCLved.js +0 -1
  343. package/dist/_chunks/cli-context-BJQB6rtF.js +0 -1
  344. package/dist/_chunks/dev-server-BNr5drEO.js.map +0 -1
  345. package/dist/_chunks/dev-server-CUg7Mqh_.js +0 -1
  346. package/dist/_chunks/dev-store-BOa304m_.js.map +0 -1
  347. package/dist/_chunks/flight-source-node-BdHUOUqg.js.map +0 -1
  348. package/dist/_chunks/graph-cache-CYiUS2aS.js.map +0 -1
  349. package/dist/_chunks/logger-CI_hThfy.js.map +0 -1
  350. package/dist/_chunks/node-response-bF0bKoig.js.map +0 -1
  351. package/dist/_chunks/plugin-context-DxMMvjUt.js.map +0 -1
  352. package/dist/server/prebuilt/key-discipline.d.ts +0 -52
  353. package/dist/server/prebuilt/key-discipline.d.ts.map +0 -1
  354. package/src/server/prebuilt/key-discipline.ts +0 -122
@@ -178,6 +178,21 @@ export function logActionError(data: {
178
178
  _logger.error('unhandled server action error', withTraceContext(data));
179
179
  }
180
180
 
181
+ /**
182
+ * Log a server action request rejected as the client's mistake before the
183
+ * action ran: a reference that does not exist, a body that will not decode.
184
+ * Level: warn, with the reason but no stack — any client can send these, so
185
+ * they must not read as server faults (TIM-1601).
186
+ */
187
+ export function logActionRejected(data: {
188
+ method: string;
189
+ path: string;
190
+ status: number;
191
+ reason: string;
192
+ }): void {
193
+ _logger.warn('server action request rejected', withTraceContext(data));
194
+ }
195
+
181
196
  /** Log unhandled error in route handler. Level: error. */
182
197
  export function logRouteError(data: { method: string; path: string; error: unknown }): void {
183
198
  if (isControlFlowSignal(data.error)) return;
@@ -199,6 +214,14 @@ export function logWaitUntilRejected(data: { error: unknown }): void {
199
214
  _logger.warn('waitUntil() promise rejected', withTraceContext(data));
200
215
  }
201
216
 
217
+ /**
218
+ * Log a cached value computed from request context its key leaves out
219
+ * (design/45 §Enforcement). Level: error.
220
+ */
221
+ export function logKeyDisciplineViolation(event: string, data: Record<string, unknown>): void {
222
+ _logger.error(event, withTraceContext(data));
223
+ }
224
+
202
225
  /** Log staleWhileRevalidate refetch failure. Level: warn. */
203
226
  export function logSwrRefetchFailed(data: { cacheKey: string; error: unknown }): void {
204
227
  _logger.warn('staleWhileRevalidate refetch failed', withTraceContext(data));
@@ -28,6 +28,28 @@ export class ParamCoercionError extends Error {
28
28
  this.name = 'ParamCoercionError';
29
29
  }
30
30
  }
31
+
32
+ /**
33
+ * The dev diagnostic for a match whose params a codec rejected; the caller
34
+ * answers 404. Shared by page/route.ts matches and metadata routes, so a
35
+ * silent coercion 404 explains itself the same way on either.
36
+ */
37
+ export function warnParamCoercionFailure(
38
+ method: string,
39
+ pathname: string,
40
+ segments: readonly { segmentName: string }[],
41
+ error: ParamCoercionError
42
+ ): void {
43
+ if (!isDebug()) return;
44
+ const segmentChain = segments.map((s) => s.segmentName || '/').join(' → ');
45
+ console.warn(
46
+ `[timber] Param coercion failed for ${method} ${pathname} — responding with 404\n` +
47
+ ` Matched segments: ${segmentChain}\n` +
48
+ ` Error: ${error.message}\n` +
49
+ ` This usually means a codec in app/schema.ts rejected the URL value.\n` +
50
+ ` Check the codec for the bracket key of the segment named above.`
51
+ );
52
+ }
31
53
  import { isDebug } from './debug.ts';
32
54
 
33
55
  // ---------------------------------------------------------------------------
@@ -16,6 +16,9 @@ import { isRscRequest } from '../shared/rsc-media-type.ts';
16
16
  import { canonicalize } from './canonicalize.ts';
17
17
  import { parseClientStateTree } from './state-tree-diff.ts';
18
18
  import type { InterceptionContext, PipelineConfig, RouteMatch } from './pipeline.ts';
19
+ import type { MiddlewareFn } from './middleware-runner.ts';
20
+ import { collectMiddlewareChain, matchedSegmentPath } from './route-matcher.ts';
21
+ import { runWithSegmentParams } from './request-context.ts';
19
22
 
20
23
  /**
21
24
  * Check if an intercepting route applies for this soft navigation.
@@ -158,6 +161,24 @@ export function pathnameMatchesPattern(pathname: string, pattern: string): boole
158
161
 
159
162
  // ─── Pipeline Resolution ──────────────────────────────────────────────────
160
163
 
164
+ /**
165
+ * Which route renders a request, and — when an interception replaced it —
166
+ * which route authorizes it.
167
+ */
168
+ export interface ResolvedRoute {
169
+ /** The route that renders: the canonical match unless a rewrite applied. */
170
+ match: RouteMatch | null;
171
+ /** Set for the modal shape only; see the `'children'` branch below. */
172
+ interception?: InterceptionContext;
173
+ /**
174
+ * The URL's own route, set whenever an interception replaced it — in
175
+ * either shape. Its middleware and access chain authorize the response:
176
+ * the rendered chain is a different route, and nothing on it was written
177
+ * to protect this URL (TIM-1607).
178
+ */
179
+ canonical?: RouteMatch;
180
+ }
181
+
161
182
  /**
162
183
  * Resolve which route renders a soft navigation that an intercepting route
163
184
  * may claim. Returns the canonical match unchanged when no rewrite applies.
@@ -169,12 +190,13 @@ export function resolveInterceptedRoute(
169
190
  req: Request,
170
191
  canonicalPathname: string,
171
192
  canonicalMatch: RouteMatch | null
172
- ): { match: RouteMatch | null; interception?: InterceptionContext } {
193
+ ): ResolvedRoute {
173
194
  const stripTrailingSlash = config.stripTrailingSlash ?? true;
174
195
  let match = canonicalMatch;
175
196
  let interception: InterceptionContext | undefined;
176
197
 
177
198
  // Stage 2a: Intercepting route resolution (modal pattern).
199
+
178
200
  // Only honored on RSC client-navigation requests (Accept: text/x-component)
179
201
  // to prevent spoofing from plain HTML navigations or raw HTTP clients.
180
202
  // The header value must be a valid relative pathname — reject schemes,
@@ -201,8 +223,14 @@ export function resolveInterceptedRoute(
201
223
  //
202
224
  // Neither is trusted: both are client-supplied, and satisfying the scope
203
225
  // only selects which build-time rewrite applies. The rendered pathname is
204
- // always the rewrite's own `interceptingPrefix`, the server re-derives the
205
- // rendered chain from it below, and every access.ts runs regardless.
226
+ // always the rewrite's own `interceptingPrefix`, and the server re-derives
227
+ // the rendered chain from it below. Choosing the rendered chain is not
228
+ // authorization, though: an interception renders a different route than
229
+ // the URL names, so the URL's own middleware and access.ts files still
230
+ // run — the middleware before render, the access files as gates in the
231
+ // intercepted tree, both through `canonical` returned below (TIM-1607).
232
+ // Only that makes a forged header harmless: the rendered chain's
233
+ // access.ts files were written to protect the source page, not the target.
206
234
  //
207
235
  // They are handed over as two sets in that order rather than one union:
208
236
  // each describes a single rendered chain, and only within one chain does
@@ -261,7 +289,28 @@ export function resolveInterceptedRoute(
261
289
  }
262
290
  }
263
291
 
264
- return { match, interception };
292
+ // No canonical route — an interception with no page at its URL — leaves
293
+ // nothing to authorize against; the rendered chain's gates are all there
294
+ // are. See design/07 §"Authorization".
295
+ if (match === canonicalMatch || !canonicalMatch) return { match, interception };
296
+ return { match, interception, canonical: canonicalMatch };
297
+ }
298
+
299
+ /**
300
+ * The middleware an intercepted navigation runs: the URL's chain, then each
301
+ * middleware.ts only the rendered chain has. Shared ancestors are the same
302
+ * manifest nodes on both chains, so each file runs once, and each chain keeps
303
+ * its own root-to-leaf order (TIM-1607).
304
+ */
305
+ export function interceptedMiddlewareChain(
306
+ canonical: RouteMatch,
307
+ rendered: RouteMatch
308
+ ): MiddlewareFn[] {
309
+ const onCanonical = new Set(canonical.segments);
310
+ return collectMiddlewareChain([
311
+ ...canonical.segments,
312
+ ...rendered.segments.filter((segment) => !onCanonical.has(segment)),
313
+ ]);
265
314
  }
266
315
 
267
316
  /**
@@ -283,3 +332,14 @@ function validateInterceptionHeader(raw: string, stripTrailingSlash: boolean): s
283
332
  if (!result.ok) return null;
284
333
  return result.pathname;
285
334
  }
335
+
336
+ /**
337
+ * Run `fn` with a route's own params as what `getSegmentParams()` returns.
338
+ *
339
+ * An intercepted request publishes the rendered route's params. The URL's
340
+ * middleware and access.ts were written for the URL's route, and run under
341
+ * this so they read its params (TIM-1607).
342
+ */
343
+ export function runWithRouteParams<T>(route: RouteMatch, fn: () => T): T {
344
+ return runWithSegmentParams(matchedSegmentPath(route.segments), route.segmentParams, fn);
345
+ }
@@ -0,0 +1,242 @@
1
+ /**
2
+ * Stage 1b of the request pipeline: serving a matched metadata route
3
+ * (sitemap, robots, manifest, favicon, icon, apple-icon, opengraph-image).
4
+ *
5
+ * A metadata route runs the per-segment stages a page at its segment runs,
6
+ * in the same order: param coercion through `app/schema.ts`, then the
7
+ * `middleware.ts` chain, then the `access.ts` chain — then the file or
8
+ * handler. Files owned by the root segment are the one exception: they are
9
+ * the app's public crawler surface (`/robots.txt`, `/sitemap.xml`, the app
10
+ * icons), so no gate runs for them, not even a root `access.ts` that gates
11
+ * every page. A file anywhere below the root, a route group included, sits
12
+ * in its segments' authorization scope like any page there (TIM-1609).
13
+ *
14
+ * Signals answer with a bare status, never a deny page: a metadata route is
15
+ * an image, a sitemap or a text file, not a document.
16
+ *
17
+ * See design/16-metadata.md §"Pipeline Integration",
18
+ * design/13-security.md threat 11b.
19
+ */
20
+
21
+ import {
22
+ applyCookieJar,
23
+ buildRedirectResponse,
24
+ cloneWithMutableHeaders,
25
+ dynamicResponseHeaders,
26
+ fireOnRequestError,
27
+ } from './pipeline-helpers.ts';
28
+ import { errorResponseHeaders } from './error-response-headers.ts';
29
+ import { outcomeToResponse } from './pipeline-outcome.ts';
30
+ import { runMiddlewarePhase } from './pipeline-phases.ts';
31
+ import {
32
+ METADATA_CACHE_CONTROL,
33
+ serveStaticMetadataFile,
34
+ serializeSitemap,
35
+ } from './pipeline-metadata.ts';
36
+ import {
37
+ coerceSegmentParams,
38
+ ParamCoercionError,
39
+ warnParamCoercionFailure,
40
+ } from './param-coercion.ts';
41
+ import { setMatchedSegmentPath, setSegmentParams } from './request-context.ts';
42
+ import {
43
+ collectMiddlewareChain,
44
+ matchedSegmentPath,
45
+ type MetadataRouteMatch,
46
+ } from './route-matcher.ts';
47
+ import { mergeResponseHeaders } from './route-handler.ts';
48
+ import { runAccessChain } from './traced-access.ts';
49
+ import { loadModule } from './safe-load.ts';
50
+ import { isDenySignal, isRedirectSignal } from './signal-identity.ts';
51
+ import { logRenderError, logRouteSetupError } from './logger.ts';
52
+ import { isDebug } from './debug.ts';
53
+ import { resolveRenderTimeoutMs } from './render-timeout.ts';
54
+ import { concatBytes, drainWithDeadline } from './stream-utils.ts';
55
+ import { onAbortUntil } from './abort-scope.ts';
56
+ import type { PipelineConfig, RouteMatch } from './pipeline.ts';
57
+ import type { MetadataHandler, MetadataRoute } from './types.ts';
58
+
59
+ /** Answer a request whose canonical pathname matched a metadata route. */
60
+ export async function serveMetadataRoute(
61
+ config: PipelineConfig,
62
+ req: Request,
63
+ method: string,
64
+ path: string,
65
+ pathname: string,
66
+ metaMatch: MetadataRouteMatch
67
+ ): Promise<Response> {
68
+ const { segments } = metaMatch;
69
+ const middlewareChain = segments.length > 1 ? collectMiddlewareChain(segments) : [];
70
+ // Root-owned files run no gate. A deeper file is gated when its chain —
71
+ // root segment included — has something to run; with nothing there, it
72
+ // answers like a root file.
73
+ const gated =
74
+ segments.length > 1 && (middlewareChain.length > 0 || segments.some((s) => s.access));
75
+ const route: RouteMatch = {
76
+ segments,
77
+ segmentParams: metaMatch.segmentParams,
78
+ rawSegmentParams: metaMatch.segmentParams,
79
+ middlewareChain,
80
+ };
81
+
82
+ // A gated answer depends on who asked, so it starts from the page cache
83
+ // policy, which middleware (or a handler's own Cache-Control) may
84
+ // override. Under the public policy a shared cache would hand it to the
85
+ // next visitor without running the gates.
86
+ const responseHeaders = gated ? dynamicResponseHeaders() : undefined;
87
+ // The jar goes onto the bag once, on the way out — a middleware
88
+ // short-circuit or error goes through `outcomeToResponse`, which applies it.
89
+ const finish = (response: Response): Response => {
90
+ if (!responseHeaders) return cloneWithMutableHeaders(response);
91
+ applyCookieJar(responseHeaders);
92
+ return mergeResponseHeaders(response, responseHeaders);
93
+ };
94
+ const fail = async (error: unknown, phase: 'setup' | 'route'): Promise<Response> => {
95
+ if (phase === 'setup') logRouteSetupError({ method, path, error });
96
+ else logRenderError({ method, path, error });
97
+ await fireOnRequestError(error, req, phase, segments);
98
+ if (config.onPipelineError && error instanceof Error)
99
+ config.onPipelineError(error, 'metadata-route');
100
+ if (responseHeaders) applyCookieJar(responseHeaders);
101
+ // An error answer must not inherit the success policy or validators.
102
+ return new Response(null, { status: 500, headers: errorResponseHeaders(responseHeaders) });
103
+ };
104
+
105
+ // Setup: the same coercion, and the same failure split, as Stage 2c.
106
+ try {
107
+ route.segmentParams = await coerceSegmentParams(route);
108
+ } catch (error) {
109
+ if (!(error instanceof ParamCoercionError)) return fail(error, 'setup');
110
+ warnParamCoercionFailure(method, pathname, segments, error);
111
+ return new Response(null, { status: 404 });
112
+ }
113
+ setSegmentParams(route.segmentParams);
114
+ setMatchedSegmentPath(matchedSegmentPath(segments));
115
+
116
+ try {
117
+ if (responseHeaders && middlewareChain.length > 0) {
118
+ const stopped = await runMiddlewarePhase(config, req, route, responseHeaders);
119
+ if (stopped?.kind === 'redirect' || stopped?.kind === 'deny') throw stopped.signal;
120
+ if (stopped)
121
+ return await outcomeToResponse(config, stopped, { req, method, path, responseHeaders });
122
+ }
123
+ if (gated) await runAccessChain(segments);
124
+
125
+ const cacheControl = gated ? undefined : METADATA_CACHE_CONTROL;
126
+ if (metaMatch.isStatic) return finish(await serveStaticMetadataFile(metaMatch, cacheControl));
127
+ const response = await runMetadataHandler(metaMatch, cacheControl);
128
+ // An image is read to the end before it is answered, so a render that
129
+ // fails is a 500 (bufferResponse). Not for HEAD, whose body the
130
+ // pipeline discards unread: a link-preview probe must not render the
131
+ // image. Not for sitemap, robots or manifest: a handler's Response
132
+ // there can be a large stream and keeps streaming.
133
+ if (method === 'HEAD' || !metaMatch.contentType.startsWith('image/')) return finish(response);
134
+ const timeoutMs = resolveRenderTimeoutMs(config.renderTimeoutMs);
135
+ return finish(await bufferResponse(response, timeoutMs, req.signal));
136
+ } catch (error) {
137
+ // Control-flow signals — from a gate, or from the handler (a sitemap
138
+ // that calls deny(404) for an unknown tenant, a dynamic icon that
139
+ // redirects to a CDN-hosted asset) — answer with a bare status. A
140
+ // metadata route is not a navigation, so a redirect is always a real 3xx.
141
+ if (isRedirectSignal(error)) return finish(buildRedirectResponse(error, new Headers(), false));
142
+ if (isDenySignal(error)) return finish(new Response(null, { status: error.status }));
143
+ return fail(error, 'route');
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Call a dynamic metadata route's default export and turn its result into a
149
+ * Response. `cacheControl` is set on a result the framework serializes; a
150
+ * Response the handler returns gets no framework default (a gated route then
151
+ * merges its middleware headers and page policy under the handler's own).
152
+ */
153
+ async function runMetadataHandler(
154
+ metaMatch: MetadataRouteMatch,
155
+ cacheControl: string | undefined
156
+ ): Promise<Response> {
157
+ const mod = await loadModule<{ default?: MetadataHandler }>(metaMatch.file);
158
+ if (typeof mod.default !== 'function') {
159
+ if (isDebug()) {
160
+ console.warn(
161
+ `[timber] Metadata route ${metaMatch.file} does not export a default function — responding with 500\n` +
162
+ ` Metadata routes must export a default function that returns the metadata content.`
163
+ );
164
+ }
165
+ return new Response('Metadata route must export a default function', { status: 500 });
166
+ }
167
+ const handlerResult = await mod.default();
168
+ // No default Cache-Control on a returned Response: the handler runs in
169
+ // the request context and may vary on cookies or headers, so a public
170
+ // default could serve one user's response to another (#1064).
171
+ if (handlerResult instanceof Response) return handlerResult;
172
+ // Otherwise, serialize based on content type. The type discriminator
173
+ // here is the metadata route's declared content type (from the file
174
+ // convention), not the shape of `handlerResult` — TS can't narrow the
175
+ // `MetadataResult` union on that, so we assert against the expected
176
+ // shape at each branch.
177
+ const contentType = metaMatch.contentType;
178
+ let body: string;
179
+ if (typeof handlerResult === 'string') {
180
+ body = handlerResult;
181
+ } else if (contentType === 'application/xml') {
182
+ body = serializeSitemap(handlerResult as MetadataRoute.Sitemap);
183
+ } else if (contentType === 'application/manifest+json') {
184
+ body = JSON.stringify(handlerResult, null, 2);
185
+ } else {
186
+ body = String(handlerResult);
187
+ }
188
+ const headers = new Headers({ 'Content-Type': `${contentType}; charset=utf-8` });
189
+ if (cacheControl) headers.set('Cache-Control', cacheControl);
190
+ return new Response(body, { status: 200, headers });
191
+ }
192
+
193
+ /**
194
+ * Read an image route's Response body to the end, under `renderTimeoutMs`
195
+ * and until the client leaves, and answer with the bytes and their
196
+ * Content-Length.
197
+ *
198
+ * An `ImageResponse` renders lazily: the handler returns at once and the
199
+ * image fails, if it fails, on the body's first read. Passed through, that
200
+ * read happens after the status is committed, and the Web→Node bridge
201
+ * (srvx's `sendNodeResponse`) destroys the socket before any byte is
202
+ * written — an empty reply with no status line (TIM-1602). Read here, the
203
+ * failure throws inside `serveMetadataRoute`'s catch and answers 500.
204
+ * Icons and social cards are small, bounded assets, so holding one is
205
+ * cheap; a route.ts body is never buffered.
206
+ */
207
+ async function bufferResponse(
208
+ response: Response,
209
+ timeoutMs: number,
210
+ signal: AbortSignal
211
+ ): Promise<Response> {
212
+ if (!response.body) return response;
213
+ const reader = response.body.getReader();
214
+ // A client that leaves ends the read, as the bridge's close handler
215
+ // ended it when the body streamed. The listener lasts as long as the read.
216
+ const readDone = new AbortController();
217
+ const clientLeft = new Promise<never>((_, reject) => {
218
+ onAbortUntil(signal, () => reject(signal.reason), readDone.signal);
219
+ });
220
+ clientLeft.catch(() => {});
221
+ let chunks: Uint8Array[];
222
+ try {
223
+ chunks = await drainWithDeadline(
224
+ {
225
+ read: () => Promise.race([reader.read(), clientLeft]),
226
+ cancel: (reason) => void reader.cancel(reason).catch(() => {}),
227
+ },
228
+ timeoutMs,
229
+ 'Metadata route body'
230
+ );
231
+ } finally {
232
+ readDone.abort();
233
+ }
234
+ const bytes = concatBytes(chunks);
235
+ const headers = new Headers(response.headers);
236
+ headers.set('Content-Length', String(bytes.byteLength));
237
+ return new Response(bytes, {
238
+ status: response.status,
239
+ statusText: response.statusText,
240
+ headers,
241
+ });
242
+ }
@@ -36,23 +36,25 @@ const TEXT_CONTENT_TYPES = new Set([
36
36
  *
37
37
  * Static metadata route files (.xml, .txt, .json, .png, .ico, .svg, etc.)
38
38
  * are served as-is with the appropriate Content-Type header.
39
- * Text files include charset=utf-8; binary files do not.
39
+ * Text files include charset=utf-8; binary files do not. `cacheControl` is
40
+ * omitted for a file behind gates, whose answer depends on who asked.
40
41
  *
41
42
  * See design/16-metadata.md §"Metadata Routes"
42
43
  */
43
44
  export async function serveStaticMetadataFile(
44
- metaMatch: import('./route-matcher.ts').MetadataRouteMatch
45
+ metaMatch: import('./route-matcher.ts').MetadataRouteMatch,
46
+ cacheControl: string | undefined
45
47
  ): Promise<Response> {
46
48
  const { contentType, file } = metaMatch;
47
49
  const isText = TEXT_CONTENT_TYPES.has(contentType);
48
50
 
49
51
  const body = await readFile(file.filePath);
50
52
 
51
- const headers: Record<string, string> = {
53
+ const headers = new Headers({
52
54
  'Content-Type': isText ? `${contentType}; charset=utf-8` : contentType,
53
55
  'Content-Length': String(body.byteLength),
54
- 'Cache-Control': METADATA_CACHE_CONTROL,
55
- };
56
+ });
57
+ if (cacheControl) headers.set('Cache-Control', cacheControl);
56
58
 
57
59
  return new Response(body, { status: 200, headers });
58
60
  }