@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
@@ -1 +1 @@
1
- {"version":3,"file":"als-slots-BEEIPKYm.js","names":[],"sources":["../../src/shared/als-slots.ts"],"sourcesContent":["/**\n * ALS getter slots for the isomorphic `define*` modules.\n *\n * `searchParams.get()` and `segmentParams.get()` read per-request state out of\n * `server/als-registry.ts`, but the modules that expose them are *isomorphic*:\n * `search-params/define.ts` and `segment-params/define.ts` are imported by\n * `'use client'` components for their hooks, so neither may import\n * `node:async_hooks` — not even transitively, because the dep optimizer\n * pre-bundles them before per-environment resolution runs. So the server\n * registers its getter into a slot at module-init time and the define modules\n * read the slot.\n *\n * The slots live here, in a module with **no imports at all**, rather than in\n * the define modules themselves. That is the whole point: `request-context.ts`\n * has to reach the setter, and when the setter lived in\n * `search-params/define.ts` every server entry that touched\n * `@timber-js/app/server` pulled that module — and therefore its `'use client'`\n * import of `client/use-query-states.ts`, and therefore `nuqs` — into the\n * server graph. `nuqs` named-imports `createContext`/`useContext` from React,\n * which React's `react-server` export withholds, so `@timber-js/app`,\n * `@timber-js/app/server`, `@timber-js/app/cookies` and `@timber-js/app/cache`\n * all failed to instantiate under the `react-server` condition (TIM-1298).\n * A leaf module breaks the edge without a registration ceremony on either side.\n *\n * Registration must be eager, not a call-time `await import()`: the async\n * microtask a dynamic import introduces loses AsyncLocalStorage context inside\n * React's RSC Flight renderer, which broke `getSearchParams()` in parallel slot\n * pages (TIM-523).\n *\n * See design/23-search-params.md §\"defineSearchParams — The Factory\" and\n * design/41-global-params.md.\n */\n\nimport type { CoercedParams } from './param-value.ts';\n\ninterface AlsSlot<T> {\n /** Register the server-side getter. Called once at module-init time. */\n set(fn: () => T): void;\n /** Read through to the registered getter, or throw the client-side message. */\n get(): T;\n}\n\nfunction createAlsSlot<T>(message: string): AlsSlot<T> {\n let fn: (() => T) | undefined;\n return {\n set(next) {\n fn = next;\n },\n get() {\n if (!fn) throw new Error(message);\n return fn();\n },\n };\n}\n\nconst searchParamsSlot = createAlsSlot<URLSearchParams>(\n '[timber] searchParams.get() is only available on the server. ' +\n 'Use searchParams.useQueryStates() on the client.'\n);\n\nconst segmentParamsSlot = createAlsSlot<CoercedParams>(\n '[timber] segmentParams.get() is only available on the server. ' +\n 'Use segmentParams.useSegmentParams() on the client.'\n);\n\n/** @internal Called from `server/request-context.ts` at module init. */\nexport const _setGetSearchParamsFn = searchParamsSlot.set;\n/** @internal Read by `search-params/define.ts` inside `.get()`. */\nexport const getSearchParamsFromAls = searchParamsSlot.get;\n\n/** @internal Called from `server/request-context.ts` at module init. */\nexport const _setGetSegmentParamsFn = segmentParamsSlot.set;\n/** @internal Read by `segment-params/define.ts` inside `.get()`. */\nexport const getSegmentParamsFromAls = segmentParamsSlot.get;\n"],"mappings":";AA0CA,SAAS,cAAiB,SAA6B;CACrD,IAAI;CACJ,OAAO;EACL,IAAI,MAAM;GACR,KAAK;EACP;EACA,MAAM;GACJ,IAAI,CAAC,IAAI,MAAM,IAAI,MAAM,OAAO;GAChC,OAAO,GAAG;EACZ;CACF;AACF;AAEA,IAAM,mBAAmB,cACvB,+GAEF;AAEA,IAAM,oBAAoB,cACxB,mHAEF;;AAGA,IAAa,wBAAwB,iBAAiB;;AAEtD,IAAa,yBAAyB,iBAAiB;;AAGvD,IAAa,yBAAyB,kBAAkB;AAEjB,kBAAkB"}
1
+ {"version":3,"file":"als-slots-kbQrHTzm.js","names":[],"sources":["../../src/shared/als-slots.ts"],"sourcesContent":["/**\n * ALS getter slots for the isomorphic `define*` modules.\n *\n * `searchParams.get()` and `segmentParams.get()` read per-request state out of\n * `server/als-registry.ts`, but the modules that expose them are *isomorphic*:\n * `search-params/define.ts` and `segment-params/define.ts` are imported by\n * `'use client'` components for their hooks, so neither may import\n * `node:async_hooks` — not even transitively, because the dep optimizer\n * pre-bundles them before per-environment resolution runs. So the server\n * registers its getter into a slot at module-init time and the define modules\n * read the slot.\n *\n * The slots live here, in a module with **no imports at all**, rather than in\n * the define modules themselves. That is the whole point: `request-context.ts`\n * has to reach the setter, and when the setter lived in\n * `search-params/define.ts` every server entry that touched\n * `@timber-js/app/server` pulled that module — and therefore its `'use client'`\n * import of `client/use-query-states.ts`, and therefore `nuqs` — into the\n * server graph. `nuqs` named-imports `createContext`/`useContext` from React,\n * which React's `react-server` export withholds, so `@timber-js/app`,\n * `@timber-js/app/server`, `@timber-js/app/cookies` and `@timber-js/app/cache`\n * all failed to instantiate under the `react-server` condition (TIM-1298).\n * A leaf module breaks the edge without a registration ceremony on either side.\n *\n * Registration must be eager, not a call-time `await import()`: the async\n * microtask a dynamic import introduces loses AsyncLocalStorage context inside\n * React's RSC Flight renderer, which broke `getSearchParams()` in parallel slot\n * pages (TIM-523).\n *\n * See design/23-search-params.md §\"defineSearchParams — The Factory\" and\n * design/41-global-params.md.\n */\n\nimport type { CoercedParams } from './param-value.ts';\n\ninterface AlsSlot<T> {\n /** Register the server-side getter. Called once at module-init time. */\n set(fn: () => T): void;\n /** Read through to the registered getter, or throw the client-side message. */\n get(): T;\n}\n\nfunction createAlsSlot<T>(message: string): AlsSlot<T> {\n let fn: (() => T) | undefined;\n return {\n set(next) {\n fn = next;\n },\n get() {\n if (!fn) throw new Error(message);\n return fn();\n },\n };\n}\n\nconst searchParamsSlot = createAlsSlot<URLSearchParams>(\n '[timber] searchParams.get() is only available on the server. ' +\n 'Use searchParams.useQueryStates() on the client.'\n);\n\nconst segmentParamsSlot = createAlsSlot<CoercedParams>(\n '[timber] segmentParams.get() is only available on the server. ' +\n 'Use segmentParams.useSegmentParams() on the client.'\n);\n\n/** @internal Called from `server/request-context.ts` at module init. */\nexport const _setGetSearchParamsFn = searchParamsSlot.set;\n/** @internal Read by `search-params/define.ts` inside `.get()`. */\nexport const getSearchParamsFromAls = searchParamsSlot.get;\n\n/** @internal Called from `server/request-context.ts` at module init. */\nexport const _setGetSegmentParamsFn = segmentParamsSlot.set;\n/** @internal Read by `segment-params/define.ts` inside `.get()`. */\nexport const getSegmentParamsFromAls = segmentParamsSlot.get;\n"],"mappings":";AA0CA,SAAS,cAAiB,SAA6B;CACrD,IAAI;CACJ,OAAO;EACL,IAAI,MAAM;GACR,KAAK;EACP;EACA,MAAM;GACJ,IAAI,CAAC,IAAI,MAAM,IAAI,MAAM,OAAO;GAChC,OAAO,GAAG;EACZ;CACF;AACF;AAEA,IAAM,mBAAmB,cACvB,+GAEF;AAEA,IAAM,oBAAoB,cACxB,mHAEF;;AAGA,IAAa,wBAAwB,iBAAiB;;AAEtD,IAAa,yBAAyB,iBAAiB;;AAGvD,IAAa,yBAAyB,kBAAkB;AAEjB,kBAAkB"}
@@ -1,4 +1,4 @@
1
- //#region src/shared/base-path.ts
1
+ // src/shared/base-path.ts
2
2
  /**
3
3
  * Deployment base path — Vite's resolved `base`, as it applies to the URLs
4
4
  * timber addresses at runtime.
@@ -74,7 +74,6 @@ function withBasePath(base, path) {
74
74
  if (base === "/") return path;
75
75
  return path.startsWith("/") ? base.slice(0, -1) + path : `${base}${path}`;
76
76
  }
77
- //#endregion
78
77
  export { withBasePath as i, normalizeBasePath as n, stripBasePath as r, isRelativeBase as t };
79
78
 
80
- //# sourceMappingURL=base-path-DaQrzbez.js.map
79
+ //# sourceMappingURL=base-path-DDIx0FXe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-path-DaQrzbez.js","names":[],"sources":["../../src/shared/base-path.ts"],"sourcesContent":["/**\n * Deployment base path — Vite's resolved `base`, as it applies to the URLs\n * timber addresses at runtime.\n *\n * A static build deployed under a sub-path (`base: '/repo/'`, the GitHub\n * Pages project-site layout) serves every generated file below that prefix:\n * the document for `/about` lives at `/repo/about/index.html`, its flight\n * payload at `/repo/_rsc/about/index.rsc`. The client works in *route space* — the\n * paths the app declares — so both a strip (browser URL → route path) and a\n * prefix (route-space path → URL) are needed, and this module owns both.\n *\n * Pure functions, no state: the caller supplies the base. `client/rsc-fetch.ts`\n * holds the client's copy, set at bootstrap from `virtual:timber-config`.\n *\n * See design/11-platform.md §\"Deploying under a non-root base\" (TIM-1261).\n */\n\n/** `https://cdn.example.com/`, `//cdn.example.com/` — a base pointing off-origin. */\nfunction isAbsoluteUrlBase(base: string): boolean {\n return base.startsWith('//') || /^[a-z][a-z0-9+.-]*:\\/\\//i.test(base);\n}\n\n/**\n * True when `base` is document-relative (`'./'`, `'foo/'`) — it makes asset\n * URLs resolve against whatever document loaded them, which says nothing\n * about where the deployment sits, so no prefix can be computed from it.\n */\nexport function isRelativeBase(base: string | undefined): boolean {\n if (!base) return false;\n return !base.startsWith('/') && !isAbsoluteUrlBase(base);\n}\n\n/**\n * Normalize Vite's `base` into a path prefix. Always returns a value with a\n * leading and trailing slash.\n *\n * Two forms carry no usable deployment prefix and normalize to `/`:\n *\n * - **An absolute-URL base** points *assets* at a CDN. The HTML documents and\n * `.rsc` payloads are still served from the deployment origin, so their\n * URLs stay root-relative. This is correct, not a degradation.\n * - **A relative base** — see `isRelativeBase`. The static build warns,\n * because SPA navigation then only works at the domain root.\n */\nexport function normalizeBasePath(base: string | undefined): string {\n if (!base) return '/';\n if (isAbsoluteUrlBase(base) || isRelativeBase(base)) return '/';\n return base.endsWith('/') ? base : `${base}/`;\n}\n\n/**\n * Strip the base prefix from a browser pathname, returning the route-space\n * path. With base `/repo/`: `/repo/about` → `/about`, `/repo/` and `/repo`\n * → `/`.\n *\n * A pathname outside the base is returned unchanged. It cannot be served by\n * this deployment at all, so there is no better answer than letting the\n * resulting fetch 404 and the router hard-navigate — visibly wrong beats\n * silently rewritten.\n *\n * @param base A normalized base (see `normalizeBasePath`).\n */\nexport function stripBasePath(base: string, pathname: string): string {\n if (base === '/') return pathname;\n const withoutTrailingSlash = base.slice(0, -1);\n if (pathname === withoutTrailingSlash) return '/';\n if (!pathname.startsWith(base)) return pathname;\n return pathname.slice(withoutTrailingSlash.length);\n}\n\n/**\n * Prefix a route-space, root-relative path with the base.\n * `/_rsc/about/index.rsc` → `/repo/_rsc/about/index.rsc`.\n *\n * @param base A normalized base (see `normalizeBasePath`).\n */\nexport function withBasePath(base: string, path: string): string {\n if (base === '/') return path;\n return path.startsWith('/') ? base.slice(0, -1) + path : `${base}${path}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,SAAS,kBAAkB,MAAuB;CAChD,OAAO,KAAK,WAAW,IAAI,KAAK,2BAA2B,KAAK,IAAI;AACtE;;;;;;AAOA,SAAgB,eAAe,MAAmC;CAChE,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,CAAC,KAAK,WAAW,GAAG,KAAK,CAAC,kBAAkB,IAAI;AACzD;;;;;;;;;;;;;AAcA,SAAgB,kBAAkB,MAAkC;CAClE,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,kBAAkB,IAAI,KAAK,eAAe,IAAI,GAAG,OAAO;CAC5D,OAAO,KAAK,SAAS,GAAG,IAAI,OAAO,GAAG,KAAK;AAC7C;;;;;;;;;;;;;AAcA,SAAgB,cAAc,MAAc,UAA0B;CACpE,IAAI,SAAS,KAAK,OAAO;CACzB,MAAM,uBAAuB,KAAK,MAAM,GAAG,EAAE;CAC7C,IAAI,aAAa,sBAAsB,OAAO;CAC9C,IAAI,CAAC,SAAS,WAAW,IAAI,GAAG,OAAO;CACvC,OAAO,SAAS,MAAM,qBAAqB,MAAM;AACnD;;;;;;;AAQA,SAAgB,aAAa,MAAc,MAAsB;CAC/D,IAAI,SAAS,KAAK,OAAO;CACzB,OAAO,KAAK,WAAW,GAAG,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI,OAAO,GAAG,OAAO;AACrE"}
1
+ {"version":3,"file":"base-path-DDIx0FXe.js","names":[],"sources":["../../src/shared/base-path.ts"],"sourcesContent":["/**\n * Deployment base path — Vite's resolved `base`, as it applies to the URLs\n * timber addresses at runtime.\n *\n * A static build deployed under a sub-path (`base: '/repo/'`, the GitHub\n * Pages project-site layout) serves every generated file below that prefix:\n * the document for `/about` lives at `/repo/about/index.html`, its flight\n * payload at `/repo/_rsc/about/index.rsc`. The client works in *route space* — the\n * paths the app declares — so both a strip (browser URL → route path) and a\n * prefix (route-space path → URL) are needed, and this module owns both.\n *\n * Pure functions, no state: the caller supplies the base. `client/rsc-fetch.ts`\n * holds the client's copy, set at bootstrap from `virtual:timber-config`.\n *\n * See design/11-platform.md §\"Deploying under a non-root base\" (TIM-1261).\n */\n\n/** `https://cdn.example.com/`, `//cdn.example.com/` — a base pointing off-origin. */\nfunction isAbsoluteUrlBase(base: string): boolean {\n return base.startsWith('//') || /^[a-z][a-z0-9+.-]*:\\/\\//i.test(base);\n}\n\n/**\n * True when `base` is document-relative (`'./'`, `'foo/'`) — it makes asset\n * URLs resolve against whatever document loaded them, which says nothing\n * about where the deployment sits, so no prefix can be computed from it.\n */\nexport function isRelativeBase(base: string | undefined): boolean {\n if (!base) return false;\n return !base.startsWith('/') && !isAbsoluteUrlBase(base);\n}\n\n/**\n * Normalize Vite's `base` into a path prefix. Always returns a value with a\n * leading and trailing slash.\n *\n * Two forms carry no usable deployment prefix and normalize to `/`:\n *\n * - **An absolute-URL base** points *assets* at a CDN. The HTML documents and\n * `.rsc` payloads are still served from the deployment origin, so their\n * URLs stay root-relative. This is correct, not a degradation.\n * - **A relative base** — see `isRelativeBase`. The static build warns,\n * because SPA navigation then only works at the domain root.\n */\nexport function normalizeBasePath(base: string | undefined): string {\n if (!base) return '/';\n if (isAbsoluteUrlBase(base) || isRelativeBase(base)) return '/';\n return base.endsWith('/') ? base : `${base}/`;\n}\n\n/**\n * Strip the base prefix from a browser pathname, returning the route-space\n * path. With base `/repo/`: `/repo/about` → `/about`, `/repo/` and `/repo`\n * → `/`.\n *\n * A pathname outside the base is returned unchanged. It cannot be served by\n * this deployment at all, so there is no better answer than letting the\n * resulting fetch 404 and the router hard-navigate — visibly wrong beats\n * silently rewritten.\n *\n * @param base A normalized base (see `normalizeBasePath`).\n */\nexport function stripBasePath(base: string, pathname: string): string {\n if (base === '/') return pathname;\n const withoutTrailingSlash = base.slice(0, -1);\n if (pathname === withoutTrailingSlash) return '/';\n if (!pathname.startsWith(base)) return pathname;\n return pathname.slice(withoutTrailingSlash.length);\n}\n\n/**\n * Prefix a route-space, root-relative path with the base.\n * `/_rsc/about/index.rsc` → `/repo/_rsc/about/index.rsc`.\n *\n * @param base A normalized base (see `normalizeBasePath`).\n */\nexport function withBasePath(base: string, path: string): string {\n if (base === '/') return path;\n return path.startsWith('/') ? base.slice(0, -1) + path : `${base}${path}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,SAAS,kBAAkB,MAAuB;CAChD,OAAO,KAAK,WAAW,IAAI,KAAK,2BAA2B,KAAK,IAAI;AACtE;;;;;;AAOA,SAAgB,eAAe,MAAmC;CAChE,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,CAAC,KAAK,WAAW,GAAG,KAAK,CAAC,kBAAkB,IAAI;AACzD;;;;;;;;;;;;;AAcA,SAAgB,kBAAkB,MAAkC;CAClE,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,kBAAkB,IAAI,KAAK,eAAe,IAAI,GAAG,OAAO;CAC5D,OAAO,KAAK,SAAS,GAAG,IAAI,OAAO,GAAG,KAAK;AAC7C;;;;;;;;;;;;;AAcA,SAAgB,cAAc,MAAc,UAA0B;CACpE,IAAI,SAAS,KAAK,OAAO;CACzB,MAAM,uBAAuB,KAAK,MAAM,GAAG,EAAE;CAC7C,IAAI,aAAa,sBAAsB,OAAO;CAC9C,IAAI,CAAC,SAAS,WAAW,IAAI,GAAG,OAAO;CACvC,OAAO,SAAS,MAAM,qBAAqB,MAAM;AACnD;;;;;;;AAQA,SAAgB,aAAa,MAAc,MAAsB;CAC/D,IAAI,SAAS,KAAK,OAAO;CACzB,OAAO,KAAK,WAAW,GAAG,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI,OAAO,GAAG,OAAO;AACrE"}
@@ -1,4 +1,4 @@
1
- //#region src/server/build-manifest.ts
1
+ // src/server/build-manifest.ts
2
2
  /**
3
3
  * Empty build manifest used in dev mode, and the single source of truth for
4
4
  * what an empty manifest contains.
@@ -80,7 +80,6 @@ function collectRouteModulepreloads(segments, manifest) {
80
80
  }
81
81
  return result;
82
82
  }
83
- //#endregion
84
83
  export { collectRouteModulepreloads as i, collectRouteCss as n, collectRouteFonts as r, EMPTY_BUILD_MANIFEST as t };
85
84
 
86
- //# sourceMappingURL=build-manifest-DWppEdLB.js.map
85
+ //# sourceMappingURL=build-manifest-Y4jl7nwU.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-manifest-DWppEdLB.js","names":[],"sources":["../../src/server/build-manifest.ts"],"sourcesContent":["/**\n * Build manifest types and utilities for CSS and JS asset tracking.\n *\n * The build manifest maps route segment file paths to their output\n * chunks from Vite's client build. This enables:\n * - <link rel=\"stylesheet\"> injection in HTML <head>\n * - <script type=\"module\"> with hashed URLs in production\n * - <link rel=\"modulepreload\"> for client chunk dependencies\n * - Link preload headers for Early Hints (103)\n *\n * In dev mode, Vite's HMR client handles CSS/JS injection, so the build\n * manifest is empty. In production, it's populated from Vite's\n * .vite/manifest.json after the client build.\n *\n * Design docs: 18-build-system.md §\"Build Manifest\", 02-rendering-pipeline.md §\"Early Hints\"\n */\n\n/** A font asset entry in the build manifest. */\nexport interface ManifestFontEntry {\n /** URL path to the font file (e.g. `/_timber/fonts/inter-latin-400-abc123.woff2`). */\n href: string;\n /** Font format (e.g. `woff2`). */\n format: string;\n /** Crossorigin attribute — always `anonymous` for fonts. */\n crossOrigin: string;\n}\n\n/** Build manifest mapping input file paths to output asset URLs. */\nexport interface BuildManifest {\n /** Map from input file path (relative to project root) to output CSS URLs. */\n css: Record<string, string[]>;\n /** Map from input file path to output JS chunk URL (hashed filename). */\n js: Record<string, string>;\n /** Map from input file path to transitive JS dependency URLs for modulepreload. */\n modulepreload: Record<string, string[]>;\n /** Map from input file path to font assets used by that module. */\n fonts: Record<string, ManifestFontEntry[]>;\n /**\n * Cache-busting hashes for metadata route files (opengraph-image, etc.).\n * Map from file path (relative to project root) to short content hash.\n * In dev mode this is empty — a startup nonce is used instead.\n */\n metadataRouteHashes?: Record<string, string>;\n /**\n * Static request-dependency map from the Vite plugin's module-graph analysis.\n * Map from segment entry file path to whether it's request-dependent.\n * Used by buildSegmentInfo() for X-Timber-Segments in production.\n */\n requestDep?: Record<string, boolean>;\n}\n\n/**\n * Empty build manifest used in dev mode, and the single source of truth for\n * what an empty manifest contains.\n *\n * `virtual:timber-build-manifest` serializes this constant into its generated\n * source rather than restating it — one literal for the dev module, one for the\n * production module's `globalThis.__TIMBER_BUILD_MANIFEST__ ?? …` fallback.\n * They were three hand-written objects that had already drifted: this one and\n * the dev literal were missing `requestDep` while the production fallback had\n * it, so a reader who grepped the built bundle for `requestDep` found the one\n * copy that mentioned it and read the fallback as the shipped map (TIM-1300).\n * A field added here now reaches every copy.\n */\nexport const EMPTY_BUILD_MANIFEST: BuildManifest = {\n css: {},\n js: {},\n modulepreload: {},\n fonts: {},\n metadataRouteHashes: {},\n requestDep: {},\n};\n\n/** Segment shape expected by collectRouteCss (matches ManifestSegmentNode). */\ninterface SegmentWithFiles {\n layout?: { filePath: string };\n page?: { filePath: string };\n}\n\n/**\n * Collect all CSS files needed for a matched route's segment chain.\n *\n * Walks segments root → leaf, collecting CSS for each layout and page.\n * Deduplicates while preserving order (root layout CSS first).\n */\nexport function collectRouteCss(segments: SegmentWithFiles[], manifest: BuildManifest): string[] {\n const seen = new Set<string>();\n const result: string[] = [];\n\n for (const segment of segments) {\n for (const file of [segment.layout, segment.page]) {\n if (!file) continue;\n const cssFiles = manifest.css[file.filePath];\n if (!cssFiles) continue;\n for (const url of cssFiles) {\n if (!seen.has(url)) {\n seen.add(url);\n result.push(url);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Generate <link rel=\"stylesheet\"> tags for CSS URLs.\n *\n * Returns an HTML string to prepend to headHtml for injection\n * via injectHead() before </head>.\n */\nexport function buildCssLinkTags(cssUrls: string[]): string {\n // Emit only <link rel=\"stylesheet\"> — no preload tags. CSS preloading\n // is handled by 103 Early Hints (Link header) which fires before the\n // HTML stream. Float also emits `<link rel=\"stylesheet\" data-precedence>`\n // at the top of <head> during Fizz rendering — the browser discovers\n // CSS from that tag. A <link rel=\"preload\"> here would arrive *after*\n // Float's stylesheet tag and trigger \"Preload was ignored\" warnings.\n return cssUrls.map((url) => `<link rel=\"stylesheet\" href=\"${url}\">`).join('');\n}\n\n// ─── Font utilities ──────────────────────────────────────────────────────\n\n/**\n * Collect all font entries needed for a matched route's segment chain.\n *\n * Walks segments root → leaf, collecting fonts for each layout and page.\n * Deduplicates by href while preserving order.\n */\nexport function collectRouteFonts(\n segments: SegmentWithFiles[],\n manifest: BuildManifest\n): ManifestFontEntry[] {\n const seen = new Set<string>();\n const result: ManifestFontEntry[] = [];\n\n for (const segment of segments) {\n for (const file of [segment.layout, segment.page]) {\n if (!file) continue;\n const fonts = manifest.fonts[file.filePath];\n if (!fonts) continue;\n for (const entry of fonts) {\n if (!seen.has(entry.href)) {\n seen.add(entry.href);\n result.push(entry);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Generate <link rel=\"preload\"> tags for font assets.\n *\n * Font preloads use `as=font` and always include `crossorigin` (required\n * for font preloads even for same-origin resources per the spec).\n */\nexport function buildFontPreloadTags(fonts: ManifestFontEntry[]): string {\n return fonts\n .map(\n (f) =>\n `<link rel=\"preload\" href=\"${f.href}\" as=\"font\" type=\"font/${f.format}\" crossorigin=\"${f.crossOrigin}\">`\n )\n .join('');\n}\n\n// ─── JS chunk utilities ──────────────────────────────────────────────────\n\n/**\n * Collect modulepreload URLs for a matched route's segment chain.\n *\n * Walks segments root → leaf, collecting transitive JS dependencies\n * for each layout and page. Deduplicates across segments.\n */\nexport function collectRouteModulepreloads(\n segments: SegmentWithFiles[],\n manifest: BuildManifest\n): string[] {\n const seen = new Set<string>();\n const result: string[] = [];\n\n for (const segment of segments) {\n for (const file of [segment.layout, segment.page]) {\n if (!file) continue;\n const preloads = manifest.modulepreload[file.filePath];\n if (!preloads) continue;\n for (const url of preloads) {\n if (!seen.has(url)) {\n seen.add(url);\n result.push(url);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Generate <link rel=\"modulepreload\"> tags for JS dependency URLs.\n *\n * Modulepreload hints tell the browser to fetch and parse JS modules\n * before they're needed, reducing waterfall latency for dynamic imports.\n */\nexport function buildModulepreloadTags(urls: string[]): string {\n return urls.map((url) => `<link rel=\"modulepreload\" href=\"${url}\">`).join('');\n}\n"],"mappings":";;;;;;;;;;;;;;AAgEA,IAAa,uBAAsC;CACjD,KAAK,CAAC;CACN,IAAI,CAAC;CACL,eAAe,CAAC;CAChB,OAAO,CAAC;CACR,qBAAqB,CAAC;CACtB,YAAY,CAAC;AACf;;;;;;;AAcA,SAAgB,gBAAgB,UAA8B,UAAmC;CAC/F,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,SAAmB,CAAC;CAE1B,KAAK,MAAM,WAAW,UACpB,KAAK,MAAM,QAAQ,CAAC,QAAQ,QAAQ,QAAQ,IAAI,GAAG;EACjD,IAAI,CAAC,MAAM;EACX,MAAM,WAAW,SAAS,IAAI,KAAK;EACnC,IAAI,CAAC,UAAU;EACf,KAAK,MAAM,OAAO,UAChB,IAAI,CAAC,KAAK,IAAI,GAAG,GAAG;GAClB,KAAK,IAAI,GAAG;GACZ,OAAO,KAAK,GAAG;EACjB;CAEJ;CAGF,OAAO;AACT;;;;;;;AA0BA,SAAgB,kBACd,UACA,UACqB;CACrB,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,SAA8B,CAAC;CAErC,KAAK,MAAM,WAAW,UACpB,KAAK,MAAM,QAAQ,CAAC,QAAQ,QAAQ,QAAQ,IAAI,GAAG;EACjD,IAAI,CAAC,MAAM;EACX,MAAM,QAAQ,SAAS,MAAM,KAAK;EAClC,IAAI,CAAC,OAAO;EACZ,KAAK,MAAM,SAAS,OAClB,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,GAAG;GACzB,KAAK,IAAI,MAAM,IAAI;GACnB,OAAO,KAAK,KAAK;EACnB;CAEJ;CAGF,OAAO;AACT;;;;;;;AAyBA,SAAgB,2BACd,UACA,UACU;CACV,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,SAAmB,CAAC;CAE1B,KAAK,MAAM,WAAW,UACpB,KAAK,MAAM,QAAQ,CAAC,QAAQ,QAAQ,QAAQ,IAAI,GAAG;EACjD,IAAI,CAAC,MAAM;EACX,MAAM,WAAW,SAAS,cAAc,KAAK;EAC7C,IAAI,CAAC,UAAU;EACf,KAAK,MAAM,OAAO,UAChB,IAAI,CAAC,KAAK,IAAI,GAAG,GAAG;GAClB,KAAK,IAAI,GAAG;GACZ,OAAO,KAAK,GAAG;EACjB;CAEJ;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"build-manifest-Y4jl7nwU.js","names":[],"sources":["../../src/server/build-manifest.ts"],"sourcesContent":["/**\n * Build manifest types and utilities for CSS and JS asset tracking.\n *\n * The build manifest maps route segment file paths to their output\n * chunks from Vite's client build. This enables:\n * - <link rel=\"stylesheet\"> injection in HTML <head>\n * - <script type=\"module\"> with hashed URLs in production\n * - <link rel=\"modulepreload\"> for client chunk dependencies\n * - Link preload headers for Early Hints (103)\n *\n * In dev mode, Vite's HMR client handles CSS/JS injection, so the build\n * manifest is empty. In production, it's populated from Vite's\n * .vite/manifest.json after the client build.\n *\n * Design docs: 18-build-system.md §\"Build Manifest\", 02-rendering-pipeline.md §\"Early Hints\"\n */\n\n/** A font asset entry in the build manifest. */\nexport interface ManifestFontEntry {\n /** URL path to the font file (e.g. `/_timber/fonts/inter-latin-400-abc123.woff2`). */\n href: string;\n /** Font format (e.g. `woff2`). */\n format: string;\n /** Crossorigin attribute — always `anonymous` for fonts. */\n crossOrigin: string;\n}\n\n/** Build manifest mapping input file paths to output asset URLs. */\nexport interface BuildManifest {\n /** Map from input file path (relative to project root) to output CSS URLs. */\n css: Record<string, string[]>;\n /** Map from input file path to output JS chunk URL (hashed filename). */\n js: Record<string, string>;\n /** Map from input file path to transitive JS dependency URLs for modulepreload. */\n modulepreload: Record<string, string[]>;\n /** Map from input file path to font assets used by that module. */\n fonts: Record<string, ManifestFontEntry[]>;\n /**\n * Cache-busting hashes for metadata route files (opengraph-image, etc.).\n * Map from file path (relative to project root) to short content hash.\n * In dev mode this is empty — a startup nonce is used instead.\n */\n metadataRouteHashes?: Record<string, string>;\n /**\n * Static request-dependency map from the Vite plugin's module-graph analysis.\n * Map from segment entry file path to whether it's request-dependent.\n * Used by buildSegmentInfo() for X-Timber-Segments in production.\n */\n requestDep?: Record<string, boolean>;\n}\n\n/**\n * Empty build manifest used in dev mode, and the single source of truth for\n * what an empty manifest contains.\n *\n * `virtual:timber-build-manifest` serializes this constant into its generated\n * source rather than restating it — one literal for the dev module, one for the\n * production module's `globalThis.__TIMBER_BUILD_MANIFEST__ ?? …` fallback.\n * They were three hand-written objects that had already drifted: this one and\n * the dev literal were missing `requestDep` while the production fallback had\n * it, so a reader who grepped the built bundle for `requestDep` found the one\n * copy that mentioned it and read the fallback as the shipped map (TIM-1300).\n * A field added here now reaches every copy.\n */\nexport const EMPTY_BUILD_MANIFEST: BuildManifest = {\n css: {},\n js: {},\n modulepreload: {},\n fonts: {},\n metadataRouteHashes: {},\n requestDep: {},\n};\n\n/** Segment shape expected by collectRouteCss (matches ManifestSegmentNode). */\ninterface SegmentWithFiles {\n layout?: { filePath: string };\n page?: { filePath: string };\n}\n\n/**\n * Collect all CSS files needed for a matched route's segment chain.\n *\n * Walks segments root → leaf, collecting CSS for each layout and page.\n * Deduplicates while preserving order (root layout CSS first).\n */\nexport function collectRouteCss(segments: SegmentWithFiles[], manifest: BuildManifest): string[] {\n const seen = new Set<string>();\n const result: string[] = [];\n\n for (const segment of segments) {\n for (const file of [segment.layout, segment.page]) {\n if (!file) continue;\n const cssFiles = manifest.css[file.filePath];\n if (!cssFiles) continue;\n for (const url of cssFiles) {\n if (!seen.has(url)) {\n seen.add(url);\n result.push(url);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Generate <link rel=\"stylesheet\"> tags for CSS URLs.\n *\n * Returns an HTML string to prepend to headHtml for injection\n * via injectHead() before </head>.\n */\nexport function buildCssLinkTags(cssUrls: string[]): string {\n // Emit only <link rel=\"stylesheet\"> — no preload tags. CSS preloading\n // is handled by 103 Early Hints (Link header) which fires before the\n // HTML stream. Float also emits `<link rel=\"stylesheet\" data-precedence>`\n // at the top of <head> during Fizz rendering — the browser discovers\n // CSS from that tag. A <link rel=\"preload\"> here would arrive *after*\n // Float's stylesheet tag and trigger \"Preload was ignored\" warnings.\n return cssUrls.map((url) => `<link rel=\"stylesheet\" href=\"${url}\">`).join('');\n}\n\n// ─── Font utilities ──────────────────────────────────────────────────────\n\n/**\n * Collect all font entries needed for a matched route's segment chain.\n *\n * Walks segments root → leaf, collecting fonts for each layout and page.\n * Deduplicates by href while preserving order.\n */\nexport function collectRouteFonts(\n segments: SegmentWithFiles[],\n manifest: BuildManifest\n): ManifestFontEntry[] {\n const seen = new Set<string>();\n const result: ManifestFontEntry[] = [];\n\n for (const segment of segments) {\n for (const file of [segment.layout, segment.page]) {\n if (!file) continue;\n const fonts = manifest.fonts[file.filePath];\n if (!fonts) continue;\n for (const entry of fonts) {\n if (!seen.has(entry.href)) {\n seen.add(entry.href);\n result.push(entry);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Generate <link rel=\"preload\"> tags for font assets.\n *\n * Font preloads use `as=font` and always include `crossorigin` (required\n * for font preloads even for same-origin resources per the spec).\n */\nexport function buildFontPreloadTags(fonts: ManifestFontEntry[]): string {\n return fonts\n .map(\n (f) =>\n `<link rel=\"preload\" href=\"${f.href}\" as=\"font\" type=\"font/${f.format}\" crossorigin=\"${f.crossOrigin}\">`\n )\n .join('');\n}\n\n// ─── JS chunk utilities ──────────────────────────────────────────────────\n\n/**\n * Collect modulepreload URLs for a matched route's segment chain.\n *\n * Walks segments root → leaf, collecting transitive JS dependencies\n * for each layout and page. Deduplicates across segments.\n */\nexport function collectRouteModulepreloads(\n segments: SegmentWithFiles[],\n manifest: BuildManifest\n): string[] {\n const seen = new Set<string>();\n const result: string[] = [];\n\n for (const segment of segments) {\n for (const file of [segment.layout, segment.page]) {\n if (!file) continue;\n const preloads = manifest.modulepreload[file.filePath];\n if (!preloads) continue;\n for (const url of preloads) {\n if (!seen.has(url)) {\n seen.add(url);\n result.push(url);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Generate <link rel=\"modulepreload\"> tags for JS dependency URLs.\n *\n * Modulepreload hints tell the browser to fetch and parse JS modules\n * before they're needed, reducing waterfall latency for dynamic imports.\n */\nexport function buildModulepreloadTags(urls: string[]): string {\n return urls.map((url) => `<link rel=\"modulepreload\" href=\"${url}\">`).join('');\n}\n"],"mappings":";;;;;;;;;;;;;;AAgEA,IAAa,uBAAsC;CACjD,KAAK,CAAC;CACN,IAAI,CAAC;CACL,eAAe,CAAC;CAChB,OAAO,CAAC;CACR,qBAAqB,CAAC;CACtB,YAAY,CAAC;AACf;;;;;;;AAcA,SAAgB,gBAAgB,UAA8B,UAAmC;CAC/F,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,SAAmB,CAAC;CAE1B,KAAK,MAAM,WAAW,UACpB,KAAK,MAAM,QAAQ,CAAC,QAAQ,QAAQ,QAAQ,IAAI,GAAG;EACjD,IAAI,CAAC,MAAM;EACX,MAAM,WAAW,SAAS,IAAI,KAAK;EACnC,IAAI,CAAC,UAAU;EACf,KAAK,MAAM,OAAO,UAChB,IAAI,CAAC,KAAK,IAAI,GAAG,GAAG;GAClB,KAAK,IAAI,GAAG;GACZ,OAAO,KAAK,GAAG;EACjB;CAEJ;CAGF,OAAO;AACT;;;;;;;AA0BA,SAAgB,kBACd,UACA,UACqB;CACrB,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,SAA8B,CAAC;CAErC,KAAK,MAAM,WAAW,UACpB,KAAK,MAAM,QAAQ,CAAC,QAAQ,QAAQ,QAAQ,IAAI,GAAG;EACjD,IAAI,CAAC,MAAM;EACX,MAAM,QAAQ,SAAS,MAAM,KAAK;EAClC,IAAI,CAAC,OAAO;EACZ,KAAK,MAAM,SAAS,OAClB,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,GAAG;GACzB,KAAK,IAAI,MAAM,IAAI;GACnB,OAAO,KAAK,KAAK;EACnB;CAEJ;CAGF,OAAO;AACT;;;;;;;AAyBA,SAAgB,2BACd,UACA,UACU;CACV,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,SAAmB,CAAC;CAE1B,KAAK,MAAM,WAAW,UACpB,KAAK,MAAM,QAAQ,CAAC,QAAQ,QAAQ,QAAQ,IAAI,GAAG;EACjD,IAAI,CAAC,MAAM;EACX,MAAM,WAAW,SAAS,cAAc,KAAK;EAC7C,IAAI,CAAC,UAAU;EACf,KAAK,MAAM,OAAO,UAChB,IAAI,CAAC,KAAK,IAAI,GAAG,GAAG;GAClB,KAAK,IAAI,GAAG;GACZ,OAAO,KAAK,GAAG;EACjB;CAEJ;CAGF,OAAO;AACT"}
@@ -1,8 +1,8 @@
1
- import { i as withBasePath } from "./base-path-DaQrzbez.js";
2
- import { c as USER_PLATFORM_DIR, i as HEADERS_FILE, n as detectFsIdentity, r as fsKey, s as USER_MERGED_PLATFORM_FILES } from "./fs-identity-BRKuL215.js";
1
+ import { i as withBasePath } from "./base-path-DDIx0FXe.js";
2
+ import { a as REDIRECTS_FILE, c as USER_PLATFORM_DIR, i as HEADERS_FILE, n as detectFsIdentity, r as fsKey, s as USER_MERGED_PLATFORM_FILES } from "./fs-identity-BmQ_Agg-.js";
3
3
  import { basename, join, relative } from "node:path";
4
4
  import { cp, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
5
- //#region src/adapters/shared.ts
5
+ // src/adapters/shared.ts
6
6
  /**
7
7
  * The deployment base an adapter should write platform rules against.
8
8
  *
@@ -153,35 +153,40 @@ function generateHeadersFile({ base, immutableDirs, unhashedPaths, contentTypes,
153
153
  }
154
154
  return content;
155
155
  }
156
- //#endregion
157
- //#region src/adapters/build-output-helper.ts
156
+ // src/adapters/build-output-helper.ts
158
157
  /**
159
158
  * Run the platform-agnostic build output steps shared by all adapters:
160
159
  *
161
160
  * 1. Create the output directory
162
161
  * 2. Copy client assets to the public/static directory
163
- * 3. Write the `_headers` file for static asset cache control
162
+ * 3. Write the `_headers` file for static asset cache control, if `platformFiles`
164
163
  * 4. Copy RSC and SSR server bundles into the output directory
165
164
  * 5. Write the manifest-init module if present
166
165
  *
167
166
  * Returns the resolved public directory path for further adapter-specific use.
168
167
  */
169
168
  async function runSharedBuildSteps(opts) {
170
- const { config, artifacts, outDir, publicDirName } = opts;
169
+ const { config, artifacts, outDir, publicDirName, platformFiles } = opts;
171
170
  await mkdir(outDir, { recursive: true });
172
171
  const publicDir = join(outDir, publicDirName);
172
+ await rm(publicDir, {
173
+ recursive: true,
174
+ force: true
175
+ });
173
176
  await mkdir(publicDir, { recursive: true });
174
177
  const clientDir = artifacts.client.path;
178
+ const userPlatformFiles = new Set(platformFiles ? [] : [HEADERS_FILE, REDIRECTS_FILE].map((name) => join(clientDir, name)));
175
179
  const referencedWasm = await findReferencedWasm(clientDir);
176
180
  await cp(clientDir, publicDir, {
177
181
  recursive: true,
178
182
  filter: (src) => {
179
183
  if (src.endsWith(".wasm") && !referencedWasm.has(basename(src))) return false;
180
184
  if (config.clientJavascriptDisabled && src.endsWith(".js")) return false;
185
+ if (userPlatformFiles.has(src)) return false;
181
186
  return true;
182
187
  }
183
188
  });
184
- await writeHeadersFile(publicDir, config, artifacts);
189
+ if (platformFiles) await writeHeadersFile(publicDir, config, artifacts);
185
190
  await cp(artifacts.rsc.path, join(outDir, "rsc"), { recursive: true });
186
191
  await cp(artifacts.ssr.path, join(outDir, "ssr"), { recursive: true });
187
192
  if (artifacts.prebuilt) await cp(artifacts.prebuilt.path, join(outDir, "prebuilt"), { recursive: true });
@@ -361,7 +366,6 @@ async function collectFiles(dir) {
361
366
  }
362
367
  return result;
363
368
  }
364
- //#endregion
365
369
  export { STATIC_CACHE as a, IMMUTABLE_CACHE as i, runSharedBuildSteps as n, adapterBase as o, writeHeadersFile as r, buildStaticDirectoryOutput as t };
366
370
 
367
- //# sourceMappingURL=build-output-helper-RV_BRcF1.js.map
371
+ //# sourceMappingURL=build-output-helper-B7wWGTfR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-output-helper-B7wWGTfR.js","names":[],"sources":["../../src/adapters/shared.ts","../../src/adapters/build-output-helper.ts"],"sourcesContent":["// Shared adapter utilities — leaf module with zero deps on server/, client/,\n// or any Vite-dependent code.\n//\n// Adapters are loaded by Node at Vite startup time, before Vite's module\n// resolver is available. This module uses only Node built-ins and can be\n// imported by both adapters via a relative path.\n//\n// IMPORTANT: Do NOT add imports from ../server/, ../client/, ../plugins/,\n// or any module that transitively depends on Vite. A test in\n// tests/adapters/shared-no-forbidden-imports.test.ts enforces this.\n// ../shared/ is exempt: it is dependency-free by the same rule.\n\nimport { withBasePath } from '../shared/base-path.ts';\n\n/**\n * The deployment base an adapter should write platform rules against.\n *\n * `config.base` is optional on `TimberConfig` because adapters can be invoked\n * by callers that predate it (a hand-written adapter, a test harness). Falling\n * back to `'/'` reproduces the pre-TIM-1274 output exactly, which is correct\n * for the only deployments those callers can have: a build under a non-root\n * base always goes through `plugins/post-build.ts`, which populates it.\n *\n * Typed structurally rather than as `TimberConfig` so this module keeps no\n * import of `./types.js` at runtime.\n */\nexport function adapterBase(config: { base?: string }): string {\n return config.base ?? '/';\n}\n\n// ─── Static asset cache headers ──────────────────────────────────────────\n\n/** Cache-Control value for hashed (immutable) assets. */\nexport const IMMUTABLE_CACHE = 'public, max-age=31536000, immutable';\n\n/** Cache-Control value for unhashed static assets. */\nexport const STATIC_CACHE = 'public, max-age=3600, must-revalidate';\n\n/**\n * Generate a `_headers` file for static asset cache control.\n *\n * The `_headers` file is a platform convention supported by Cloudflare Workers\n * Static Assets, Cloudflare Pages, and Netlify. It maps URL patterns to\n * HTTP response headers.\n *\n * The build's content-hashed directories (`immutableDirs`, recorded on\n * `BuildArtifacts` by the phases that hashed them) get one wildcard rule\n * each. When\n * `unhashedPaths` is provided, per-file rules are appended for unhashed\n * static assets (favicon.ico, robots.txt, etc.) so they get Cache-Control\n * on platforms like Cloudflare Workers Static Assets where the server\n * handler never sees static file requests.\n *\n * A `/*` catch-all is NOT used — it would be additive on Cloudflare,\n * producing duplicate Cache-Control directives on hashed assets\n * (invalid per RFC 9111).\n *\n * **Every rule path is written in deployed-URL space** (TIM-1274). The\n * platform matches these patterns against the request path, which under a\n * non-root `base` sits below the prefix: with `base: '/repo/'` the assets are\n * at `/repo/assets/*`, so a rule saying `/assets/*` matches nothing. Silent\n * for the cache rules (slower, still correct) and not silent for the\n * Content-Type rules — an extensionless API route output is unreadable on\n * Cloudflare Workers Static Assets without one.\n *\n * The prefix is applied at exactly one point, `rulePath()`, which every rule\n * in this function goes through. Prefixing the wildcards and\n * hand-checking that the per-file rules agree is how the next rule gets\n * missed.\n */\n// Cloudflare Workers Static Assets caps _headers at 100 rules. The wildcard\n// rules for the immutable directories come out of the same budget.\nconst MAX_RULES = 100;\n\nexport interface HeadersFileOptions {\n /**\n * The deployment base, already normalized by `normalizeBasePath()` —\n * leading and trailing slash, `'/'` at the domain root.\n *\n * Required rather than defaulted: a caller that forgets it would emit\n * root-relative rules that match nothing, which is the bug this closes.\n */\n base: string;\n /**\n * Content-hashed directories, from `BuildArtifacts.immutableDirs`. Each\n * gets an immutable `Cache-Control` wildcard rule.\n */\n immutableDirs: readonly string[];\n /** Unhashed static files (route-space paths) needing per-file cache rules. */\n unhashedPaths?: string[];\n /** Route-space path → Content-Type, for extensionless API route outputs. */\n contentTypes?: Record<string, string>;\n /**\n * Verbatim contents of the user's `public/_headers`, appended after the\n * generated rules. See `mergeUserHeaders` for why it goes last.\n */\n userRules?: string;\n}\n\n/**\n * Count the rules in a `_headers` file — a rule is a path line, which is any\n * line that is neither blank, a comment, nor an indented header.\n *\n * @internal Exported for testing.\n */\nexport function countHeaderRules(content: string): number {\n return content\n .split('\\n')\n .filter((line) => line.trim() !== '' && !line.startsWith('#') && !/^\\s/.test(line)).length;\n}\n\n/** One `_headers` block: a path pattern and the headers it sets. */\nexport interface HeaderRule {\n pattern: string;\n headers: Array<{ name: string; value: string }>;\n}\n\n/**\n * Parse a `_headers` file. A non-indented, non-comment line opens a rule; the\n * indented `Name: value` lines beneath it belong to that rule.\n *\n * @internal Exported for testing.\n */\nexport function parseHeaderRules(content: string): HeaderRule[] {\n const rules: HeaderRule[] = [];\n for (const raw of content.split('\\n')) {\n const line = raw.replace(/\\r$/, '');\n if (line.trim() === '' || line.trimStart().startsWith('#')) continue;\n if (/^\\s/.test(line)) {\n const current = rules[rules.length - 1];\n if (!current) continue; // header with no rule above it — not ours to fix\n const colon = line.indexOf(':');\n if (colon === -1) continue;\n current.headers.push({\n name: line.slice(0, colon).trim(),\n value: line.slice(colon + 1).trim(),\n });\n } else {\n rules.push({ pattern: line.trim(), headers: [] });\n }\n }\n return rules;\n}\n\n/**\n * Whether a user pattern can match paths a generated pattern also matches.\n *\n * Deliberately narrow: equality, or a prefix-glob (`/x/*`, `/*`) whose literal\n * prefix contains the other's. Anything cleverer risks claiming an overlap\n * that is not there, and the only thing this drives is a warning — a false\n * positive is noise a developer cannot act on.\n */\nfunction patternsOverlap(a: string, b: string): boolean {\n if (a === b) return true;\n const prefixOf = (p: string) => (p.endsWith('*') ? p.slice(0, -1) : null);\n const [pa, pb] = [prefixOf(a), prefixOf(b)];\n if (pa !== null && (b.startsWith(pa) || pa === '')) return true;\n if (pb !== null && (a.startsWith(pb) || pb === '')) return true;\n return false;\n}\n\nexport function generateHeadersFile({\n base,\n immutableDirs,\n unhashedPaths,\n contentTypes,\n userRules,\n}: HeadersFileOptions): string {\n /** Route-space rule path → deployed-URL rule path. */\n const rulePath = (path: string) => withBasePath(base, path);\n\n // Cloudflare and Netlify apply *every* matching rule, so emitting a header\n // the user also sets on the same path yields two definitions of it — a\n // comma-joined `Cache-Control` that is invalid per RFC 9111, and neither\n // side's intent. This module already refuses to emit a `/*` catch-all for\n // that reason; appending the user's file verbatim reintroduced it through\n // the back door (TIM-1326).\n //\n // An explicit app rule beats a framework default, so where the user names\n // the same pattern and the same header, ours is dropped. Only exact pattern\n // matches are resolved this way: silently dropping asset immutability\n // because a `/*` rule *might* subsume it would be a worse surprise than the\n // duplicate, so overlapping-but-different patterns warn instead.\n const userRuleList = userRules ? parseHeaderRules(userRules) : [];\n const overriddenExactly = new Set(\n userRuleList.flatMap((rule) =>\n rule.headers.map((h) => `${rule.pattern}\\0${h.name.toLowerCase()}`)\n )\n );\n const overridden = (pattern: string, header: string) =>\n overriddenExactly.has(`${pattern}\\0${header.toLowerCase()}`);\n\n const warnedOverlaps = new Set<string>();\n const emit = (pattern: string, header: string, value: string): string => {\n if (overridden(pattern, header)) return '';\n for (const rule of userRuleList) {\n if (rule.pattern === pattern) continue;\n if (!patternsOverlap(rule.pattern, pattern)) continue;\n for (const h of rule.headers) {\n if (h.name.toLowerCase() !== header.toLowerCase()) continue;\n const key = `${rule.pattern}\\0${pattern}\\0${header.toLowerCase()}`;\n if (warnedOverlaps.has(key)) continue;\n warnedOverlaps.add(key);\n console.warn(\n `[timber] _headers: your rule \"${rule.pattern}\" sets ${header}, which ` +\n `timber also sets on \"${pattern}\". Cloudflare and Netlify apply both, ` +\n `so the response gets two ${header} values. Use the exact pattern ` +\n `\"${pattern}\" to replace timber's rule, or narrow yours so they do ` +\n `not overlap.`\n );\n }\n }\n return `\\n${pattern}\\n ${header}: ${value}\\n`;\n };\n\n let content = `# Auto-generated by @timber-js/app — static asset cache headers.\n# See design/25-production-deployments.md §\"CDN / Edge Cache\"\n`;\n for (const dir of immutableDirs) {\n content += emit(rulePath(`/${dir}/*`), 'Cache-Control', IMMUTABLE_CACHE);\n }\n const maxPerFileRules = MAX_RULES - immutableDirs.length;\n\n // Content-Type rules are higher priority than cache headers for\n // extensionless files — without them the file is unreadable.\n const allCtEntries = contentTypes\n ? Object.entries(contentTypes).sort(([a], [b]) => a.localeCompare(b))\n : [];\n const ctEntries = allCtEntries.slice(0, maxPerFileRules);\n if (allCtEntries.length > maxPerFileRules) {\n console.warn(\n `[timber] _headers: ${allCtEntries.length} content-type rules exceed ` +\n `Cloudflare's 100-rule limit. Only the first ${maxPerFileRules} ` +\n `extensionless API routes will get Content-Type headers.`\n );\n }\n const remainingBudget = maxPerFileRules - ctEntries.length;\n\n if (unhashedPaths && unhashedPaths.length > 0) {\n const capped = unhashedPaths.slice(0, Math.max(0, remainingBudget));\n if (unhashedPaths.length > remainingBudget) {\n console.warn(\n `[timber] _headers: ${unhashedPaths.length} unhashed static files + ` +\n `${ctEntries.length} content-type rules found, but Cloudflare limits ` +\n `_headers to 100 rules. Only the first ${capped.length} unhashed ` +\n `files will get Cache-Control headers.`\n );\n }\n // Section bodies are built before their comment header so a section the\n // user has overridden entirely does not leave a heading over nothing.\n const body = capped.map((p) => emit(rulePath(p), 'Cache-Control', STATIC_CACHE)).join('');\n if (body !== '') {\n content += `\\n# Unhashed static assets — short-lived cache with revalidation\\n${body}`;\n }\n }\n\n const ctBody = ctEntries\n .map(([urlPath, ct]) => emit(rulePath(urlPath), 'Content-Type', ct))\n .join('');\n if (ctBody !== '') {\n content += `\\n# Content-Type for extensionless API routes\\n${ctBody}`;\n }\n\n // User rules last, matching the `_redirects` merge. Their paths are left\n // verbatim: `_redirects` prefixes the rules it generates because it wrote\n // them in route space, but these are the user's own text, already authored\n // against the URLs the site is deployed at.\n if (userRules && userRules.trim() !== '') {\n content += `\\n# User-authored rules from public/_headers\\n\\n${userRules.trim()}\\n`;\n\n const total = countHeaderRules(content);\n if (total > MAX_RULES) {\n console.warn(\n `[timber] _headers: ${total} rules after merging public/_headers, over ` +\n `Cloudflare's ${MAX_RULES}-rule limit. Rules past the ` +\n `limit are dropped by the platform — remove some, or move static ` +\n `assets under a directory the wildcard rules already cover.`\n );\n }\n }\n\n return content;\n}\n","// Shared build-output helper for adapter buildOutput() methods.\n//\n// Steps 1–5 of every adapter's buildOutput are platform-agnostic:\n// 1. Copy client assets to the public/static directory\n// 2. Write _headers file for static asset cache control, where the platform reads it\n// 3. Copy RSC + SSR server bundles\n// 4. Write manifest-init module (if present)\n//\n// Only the final steps (entry codegen, platform config) vary per adapter.\n//\n// IMPORTANT: This module must remain a leaf — no imports from ../server/,\n// ../client/, or Vite-dependent code. See adapters/shared.ts header.\n\nimport { writeFile, mkdir, cp, rm, readdir, readFile } from 'node:fs/promises';\nimport { join, basename, relative } from 'node:path';\nimport { adapterBase, generateHeadersFile } from './shared.ts';\n// Isomorphic, zero-import module — safe to load from an adapter, which Node's\n// native ESM loader evaluates before Vite's resolver exists. Same precedent as\n// `adapters/shared.ts` importing `../shared/base-path.js`.\nimport {\n HEADERS_FILE,\n REDIRECTS_FILE,\n USER_MERGED_PLATFORM_FILES,\n USER_PLATFORM_DIR,\n} from '../shared/static-platform-files.ts';\nimport { detectFsIdentity, fsKey } from './fs-identity.ts';\nimport type {\n BuildArtifacts,\n ServerBuildArtifacts,\n StaticBuildArtifacts,\n TimberConfig,\n} from './types.ts';\n\n/** Options for the shared build output steps. */\nexport interface BuildOutputBaseOptions {\n /** Resolved timber config. */\n config: TimberConfig;\n /** What the build produced. */\n artifacts: ServerBuildArtifacts;\n /** Adapter-specific output directory (e.g. `.timber/dist/nitro`). */\n outDir: string;\n /**\n * Name of the public/static directory within outDir.\n * Nitro uses 'public', Cloudflare uses 'static'.\n */\n publicDirName: string;\n /**\n * Whether the platform reads `_headers` and `_redirects` from the public\n * directory (Cloudflare, Netlify). When false, the output has neither — no\n * generated `_headers`, and not the user's `public/_headers` or\n * `public/_redirects`, which Vite copies into the client output: on a host\n * that does not read them they are plain files, served to anyone who asks\n * for `/_headers` (TIM-1605).\n */\n platformFiles: boolean;\n}\n\n/**\n * Run the platform-agnostic build output steps shared by all adapters:\n *\n * 1. Create the output directory\n * 2. Copy client assets to the public/static directory\n * 3. Write the `_headers` file for static asset cache control, if `platformFiles`\n * 4. Copy RSC and SSR server bundles into the output directory\n * 5. Write the manifest-init module if present\n *\n * Returns the resolved public directory path for further adapter-specific use.\n */\nexport async function runSharedBuildSteps(opts: BuildOutputBaseOptions): Promise<string> {\n const { config, artifacts, outDir, publicDirName, platformFiles } = opts;\n\n // 1. Create the output directory.\n await mkdir(outDir, { recursive: true });\n\n // 2. Copy client assets to public/static directory.\n // When client JavaScript is disabled, skip .js files — only CSS,\n // fonts, images, and other static assets are needed.\n // Cleaned first: the adapter output directory outlives a build, and a file\n // an earlier build left here (a static build's pre-rendered `index.html`,\n // a `_headers` the preset no longer reads) would otherwise ship and be\n // served ahead of the app.\n const publicDir = join(outDir, publicDirName);\n await rm(publicDir, { recursive: true, force: true });\n await mkdir(publicDir, { recursive: true });\n const clientDir = artifacts.client.path;\n const userPlatformFiles = new Set(\n platformFiles ? [] : [HEADERS_FILE, REDIRECTS_FILE].map((name) => join(clientDir, name))\n );\n // Find WASM files that are referenced by client JS (legitimate client WASM)\n // vs orphaned server-only WASM (e.g. @takumi-rs for OG image generation).\n // Only strip orphaned WASM to avoid breaking client-side WASM usage.\n const referencedWasm = await findReferencedWasm(clientDir);\n\n await cp(clientDir, publicDir, {\n recursive: true,\n filter: (src: string) => {\n if (src.endsWith('.wasm') && !referencedWasm.has(basename(src))) {\n return false;\n }\n if (config.clientJavascriptDisabled && src.endsWith('.js')) return false;\n if (userPlatformFiles.has(src)) return false;\n return true;\n },\n });\n\n // 3. Write _headers file for static asset cache control.\n // Scan for unhashed files so they get per-file Cache-Control rules in the\n // _headers file. On platforms like Cloudflare Workers Static Assets, the\n // worker never sees static file requests — _headers is the only mechanism.\n // Elsewhere nothing reads it, so its rules never applied and the file was\n // only a public asset; the immutable header there comes from the server\n // instead (nitro-immutable-assets.ts).\n if (platformFiles) await writeHeadersFile(publicDir, config, artifacts);\n\n // 4. Copy RSC + SSR server bundles into the output directory. The RSC\n // bundle imports the SSR one by a path the RSC plugin computed between the\n // two *build* directories, which the build names `rsc/` and `ssr/` as\n // siblings (index.ts); deploying them under the same names keeps it valid.\n await cp(artifacts.rsc.path, join(outDir, 'rsc'), { recursive: true });\n await cp(artifacts.ssr.path, join(outDir, 'ssr'), { recursive: true });\n\n // 4b. Copy prebuilt/ flight payloads (cache.component artifacts). These\n // are produced by the post-build capture pass (design/44) and read at\n // request time via the adapter's PrebuiltPayloadSource.\n if (artifacts.prebuilt) {\n await cp(artifacts.prebuilt.path, join(outDir, 'prebuilt'), { recursive: true });\n }\n\n // 5. Write manifest-init module if present.\n if (artifacts.manifestInit) {\n await writeFile(join(outDir, '_timber-manifest-init.js'), artifacts.manifestInit);\n }\n\n return publicDir;\n}\n\n/**\n * Find unhashed static files in the public directory that need per-file\n * Cache-Control rules in the `_headers` file.\n *\n * Excludes:\n * - Files under the build's `immutableDirs` (covered by wildcard rules)\n * - Files under `rsc/` and `ssr/` (server bundles, never served)\n * - Underscore-prefixed files (`_headers`, `_worker.js`, etc.)\n *\n * Ordered for the rule cap: well-known metadata files, then everything\n * else, then files under an underscore-prefixed directory — the\n * framework's own output (unhashed RSC payloads in a static build with\n * client JavaScript disabled, which nothing fetches). Those can number one\n * per route, and must not take the budget from the app's real files.\n *\n * @internal Exported for testing.\n */\n// Well-known metadata files that should be prioritized when capping\n// _headers rules, so they're never dropped in favor of less important files.\nconst PRIORITY_FILES = new Set([\n '/favicon.ico',\n '/robots.txt',\n '/sitemap.xml',\n '/manifest.json',\n '/manifest.webmanifest',\n '/apple-touch-icon.png',\n]);\n\nexport async function findUnhashedStaticFiles(\n publicDir: string,\n immutableDirs: readonly string[]\n): Promise<string[]> {\n let files: string[];\n try {\n files = await collectFiles(publicDir);\n } catch {\n return [];\n }\n\n const priority: string[] = [];\n const rest: string[] = [];\n const framework: string[] = [];\n for (const file of files) {\n const rel = relative(publicDir, file).replace(/\\\\/g, '/');\n if (immutableDirs.some((dir) => rel.startsWith(`${dir}/`))) continue;\n if (rel.startsWith('rsc/') || rel.startsWith('ssr/')) continue;\n if (basename(rel).startsWith('_')) continue;\n const urlPath = '/' + rel;\n if (PRIORITY_FILES.has(urlPath)) {\n priority.push(urlPath);\n } else if (rel.startsWith('_')) {\n framework.push(urlPath);\n } else {\n rest.push(urlPath);\n }\n }\n\n return [...priority.sort(), ...rest.sort(), ...framework.sort()];\n}\n\n/**\n * Scan client JS files for references to .wasm filenames.\n * Returns the set of WASM basenames that are actually imported/referenced\n * by client code and must be preserved in the static output.\n */\nasync function findReferencedWasm(clientDir: string): Promise<Set<string>> {\n const referenced = new Set<string>();\n const files = await collectFiles(clientDir);\n\n const jsFiles = files.filter((f) => f.endsWith('.js'));\n const wasmFiles = files.filter((f) => f.endsWith('.wasm')).map((f) => basename(f));\n if (wasmFiles.length === 0) return referenced;\n\n for (const jsFile of jsFiles) {\n const content = await readFile(jsFile, 'utf-8');\n for (const wasmName of wasmFiles) {\n if (content.includes(wasmName)) {\n referenced.add(wasmName);\n }\n }\n }\n\n return referenced;\n}\n\n/**\n * Build a static-only output directory (no server entry). Copies client\n * assets and pre-rendered HTML/RSC/API files into `outDir/publicDirName`.\n * Used by both Cloudflare and Nitro adapters in `output: 'static'` mode.\n */\nexport async function buildStaticDirectoryOutput(\n config: TimberConfig,\n artifacts: StaticBuildArtifacts,\n outDir: string,\n publicDirName: string\n): Promise<void> {\n // Clean stale artifacts from prior builds (e.g. server-mode builds that\n // left rsc/, ssr/, _worker.js in the outDir). Without this, a static\n // build after a server build inherits 140+ unused server chunks.\n await rm(outDir, { recursive: true, force: true }).catch(() => {});\n await mkdir(outDir, { recursive: true });\n\n const publicDir = join(outDir, publicDirName);\n await mkdir(publicDir, { recursive: true });\n\n // Copy client assets (JS, CSS, fonts, images).\n await cp(artifacts.client.path, publicDir, {\n recursive: true,\n filter: (src: string) => {\n if (config.clientJavascriptDisabled && src.endsWith('.js')) return false;\n return true;\n },\n });\n\n // Copy pre-rendered static pages (HTML + RSC flight + API routes).\n //\n // This is the one place the build merges two independently-produced trees\n // into a single directory, and `cp` resolves an overlap by overwriting with\n // no diagnostic — the deployment then contains one of the two artifacts and\n // nothing recorded which. Refuse instead (TIM-1266).\n await assertNoTreeCollision(artifacts.pages.path, publicDir);\n await cp(artifacts.pages.path, publicDir, { recursive: true });\n}\n\n/**\n * Write the `_headers` file, folding in the user's `public/_headers`.\n *\n * Every adapter used to `writeFile` a generated `_headers` over whatever\n * Vite had copied out of `public/`, so an app shipping its own CSP, CORS, or\n * cache rules deployed without them and without a word (TIM-1326). The\n * generated rules and the user's are not competitors — they address different\n * paths — so this merges rather than refusing, the way `_redirects` has since\n * TIM-1249.\n *\n * **Read from the project, not the output.** The generated file lands under\n * the same name in the output directory, and `runSharedBuildSteps` does not\n * clean `outDir`; a reader aimed there would fold the previous build's\n * generated rules back in and compound them on every rebuild — the defect\n * this pass fixed for `_redirects`.\n *\n * User rules go last. On Cloudflare and Netlify a `_headers` file applies\n * every matching rule, so appending means the user's rules take effect; where\n * a platform resolves a conflict in favour of the earlier rule instead, the\n * framework keeps the paths it owns and the user keeps the rest. Under either\n * reading this is no worse than the previous behaviour, which was to drop the\n * user's rules entirely.\n *\n * @internal Exported for testing.\n */\nexport async function writeHeadersFile(\n dir: string,\n config: TimberConfig,\n artifacts: BuildArtifacts\n): Promise<void> {\n const userRules = await readUserPlatformFile(config.root, HEADERS_FILE);\n await writeFile(\n join(dir, HEADERS_FILE),\n generateHeadersFile({\n base: adapterBase(config),\n immutableDirs: artifacts.immutableDirs,\n // Scanned from the directory being deployed, which holds everything\n // the platform will serve from it.\n unhashedPaths: await findUnhashedStaticFiles(dir, artifacts.immutableDirs),\n contentTypes: artifacts.output === 'static' ? artifacts.contentTypes : undefined,\n userRules: userRules ?? undefined,\n })\n );\n}\n\n/**\n * Read a user-authored platform file from the project's `public/` directory.\n * Returns null when the project has none, or when no root is configured —\n * a caller without a root cannot locate the project at all, and inventing\n * one from `process.cwd()` would read a different project's file.\n */\nasync function readUserPlatformFile(\n root: string | undefined,\n name: string\n): Promise<string | null> {\n if (!root) return null;\n try {\n return await readFile(join(root, USER_PLATFORM_DIR, name), 'utf-8');\n } catch {\n return null;\n }\n}\n\n/**\n * Throw if copying `srcDir` over `destDir` would overwrite an existing file.\n *\n * Compared against the destination **as it stands**, not against the other\n * source tree: the first copy is filtered (client JS is dropped when client\n * JavaScript is disabled), so the files that are actually there are the only\n * ones a second copy can clobber.\n *\n * @internal Exported for testing.\n */\nexport async function assertNoTreeCollision(srcDir: string, destDir: string): Promise<void> {\n const [srcFiles, destFiles, identity] = await Promise.all([\n collectFiles(srcDir).catch(() => [] as string[]),\n collectFiles(destDir).catch(() => [] as string[]),\n // `cp` will resolve these paths the way the destination filesystem does,\n // so the comparison predicting it has to as well: on macOS a hand-written\n // `public/About/index.html` and a generated `about/index.html` are one\n // file, and an exact-string set waves the overwrite through (TIM-1266).\n detectFsIdentity(destDir),\n ]);\n\n const key = (p: string) => fsKey(p, identity);\n const existing = new Set(destFiles.map((f) => key(relative(destDir, f).replace(/\\\\/g, '/'))));\n const exempt = new Set(USER_MERGED_PLATFORM_FILES.map(key));\n const collisions = srcFiles\n .map((f) => relative(srcDir, f).replace(/\\\\/g, '/'))\n .filter((rel) => existing.has(key(rel)) && !exempt.has(key(rel)))\n .sort();\n\n if (collisions.length === 0) return;\n\n throw new Error(\n `[timber] Build output: ${collisions.length} file(s) in the pre-rendered site ` +\n `collide with files already in the output directory. Copying would silently ` +\n `overwrite them — a generated page and a file in public/ cannot share a path:\\n` +\n collisions.map((c) => ` - ${c}`).join('\\n')\n );\n}\n\nasync function collectFiles(dir: string): Promise<string[]> {\n const result: string[] = [];\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n if (entry.isDirectory()) {\n result.push(...(await collectFiles(fullPath)));\n } else {\n result.push(fullPath);\n }\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,SAAgB,YAAY,QAAmC;CAC7D,OAAO,OAAO,QAAQ;AACxB;;AAKA,IAAa,kBAAkB;;AAG/B,IAAa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoC5B,IAAM,YAAY;;;;;;;AAiClB,SAAgB,iBAAiB,SAAyB;CACxD,OAAO,QACJ,MAAM,IAAI,CAAC,CACX,QAAQ,SAAS,KAAK,KAAK,MAAM,MAAM,CAAC,KAAK,WAAW,GAAG,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC;AACxF;;;;;;;AAcA,SAAgB,iBAAiB,SAA+B;CAC9D,MAAM,QAAsB,CAAC;CAC7B,KAAK,MAAM,OAAO,QAAQ,MAAM,IAAI,GAAG;EACrC,MAAM,OAAO,IAAI,QAAQ,OAAO,EAAE;EAClC,IAAI,KAAK,KAAK,MAAM,MAAM,KAAK,UAAU,CAAC,CAAC,WAAW,GAAG,GAAG;EAC5D,IAAI,MAAM,KAAK,IAAI,GAAG;GACpB,MAAM,UAAU,MAAM,MAAM,SAAS;GACrC,IAAI,CAAC,SAAS;GACd,MAAM,QAAQ,KAAK,QAAQ,GAAG;GAC9B,IAAI,UAAU,IAAI;GAClB,QAAQ,QAAQ,KAAK;IACnB,MAAM,KAAK,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK;IAChC,OAAO,KAAK,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK;GACpC,CAAC;EAC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$1 } from "./render-timeout-Ln_u7fX-.js";
2
- import { _ as isCacheHandlerConfigured, f as currentInvalidationEpoch, g as getCacheHandler, h as wasInvalidatedSince, i as devOverlayNamespace, m as recordInvalidation, p as lastInvalidationEpochFor, r as devDataCacheKey, s as invalidateDevSeedsByTag } from "./dev-store-BOa304m_.js";
3
- import { c as waitUntilAls } from "./als-registry-BZqHCtq-.js";
4
- import { O as addSpanEventSync, h as logSwrRefetchFailed, n as logCacheMiss, r as logCacheReadFailed, y as swallow } from "./logger-CI_hThfy.js";
5
- import { t as fnv1aHash } from "./fast-hash-C-tVYrLb.js";
6
- import { n as createSingleflight } from "./singleflight-BeVMMKi0.js";
7
- import { t as estimateByteSize } from "./sizeof-CO3dk0V1.js";
8
- import { t as warnLossyJsonValue } from "./json-lossy-check-C3Sht92C.js";
9
- import { t as getCdnPurgeHandler } from "./purge-store-WZaxu-3m.js";
10
- //#region src/server/waituntil-bridge.ts
1
+ import { a as withTimeout$1 } from "./render-timeout-MrrqD1wd.js";
2
+ import { _ as wasInvalidatedSince, g as recordInvalidation, h as lastInvalidationEpochFor, i as devDataCacheKey, l as invalidateDevSeedsByTag, m as currentInvalidationEpoch, o as devOverlayNamespace, v as getCacheHandler, y as isCacheHandlerConfigured } from "./dev-store-BvdqtHvK.js";
3
+ import { c as waitUntilAls, i as requestContextAls } from "./als-registry-DpygwCp0.js";
4
+ import { a as logKeyDisciplineViolation, b as swallow, g as logSwrRefetchFailed, n as logCacheMiss, r as logCacheReadFailed, w as addSpanEventSync } from "./logger-CWk44DLp.js";
5
+ import { t as fnv1aHash } from "./fast-hash-DddxkU5Y.js";
6
+ import { n as createSingleflight } from "./singleflight-BChPMjwH.js";
7
+ import { t as estimateByteSize } from "./sizeof-DG4W40lv.js";
8
+ import { t as warnLossyJsonValue } from "./json-lossy-check-DVkLUlfC.js";
9
+ import { t as getCdnPurgeHandler } from "./purge-store-8BqLAYZ1.js";
10
+ // src/server/waituntil-bridge.ts
11
11
  /**
12
12
  * Per-request waitUntil bridge — ALS bridge for platform adapters.
13
13
  *
@@ -29,8 +29,7 @@ import { t as getCdnPurgeHandler } from "./purge-store-WZaxu-3m.js";
29
29
  function getWaitUntil() {
30
30
  return waitUntilAls.getStore();
31
31
  }
32
- //#endregion
33
- //#region src/cache/stable-stringify.ts
32
+ // src/cache/stable-stringify.ts
34
33
  /**
35
34
  * Deterministic JSON serialization with sorted object keys.
36
35
  * Used for cache key generation — ensures { a: 1, b: 2 } and { b: 2, a: 1 }
@@ -75,8 +74,7 @@ function stableStringify(value) {
75
74
  }
76
75
  return "{" + pairs.join(",") + "}";
77
76
  }
78
- //#endregion
79
- //#region src/cache/guarded-read.ts
77
+ // src/cache/guarded-read.ts
80
78
  /**
81
79
  * Cache reads never fail a request.
82
80
  *
@@ -115,8 +113,145 @@ async function guardedRead(cacheKey, read, onFailure) {
115
113
  return onFailure;
116
114
  }
117
115
  }
118
- //#endregion
119
- //#region src/cache/timber-cache.ts
116
+ // src/cache/key-discipline.ts
117
+ /**
118
+ * Key-discipline diagnostic for both cache tiers (design/45 §Enforcement).
119
+ *
120
+ * A cached value is stored under a key computed from declared inputs only —
121
+ * props and segment params for `cache.component`, the function's arguments
122
+ * for `cache.data`. A request-context read while the value is being computed
123
+ * is the data-leak danger zone (design/06 security note): the result varies
124
+ * by user but the key does not. While the cached work runs, the ALS store is
125
+ * wrapped in a transparent observing proxy; any request-context read
126
+ * produces a structured, rate-limited production diagnostic.
127
+ *
128
+ * The diagnostic fires per offending callsite, rate-limited to once per
129
+ * interval (default 60 s) — not once per process. This ensures the
130
+ * signal stays visible in log aggregators across restarts and deploys.
131
+ *
132
+ * When `strictKeyDiscipline` is enabled (via timber.config.ts
133
+ * `cache.strictKeyDiscipline: true`), the diagnostic is promoted to a
134
+ * thrown error that prevents the tainted value from being cached.
135
+ */
136
+ /** Store fields every tier's key leaves out, by the API that reads them. */
137
+ var REQUEST_FIELDS = /* @__PURE__ */ new Map([
138
+ ["headers", "headers()"],
139
+ ["parsedCookies", "cookies()"],
140
+ ["searchParams", "searchParams"]
141
+ ]);
142
+ /**
143
+ * The data tier also leaves out segment params: a cache.component key
144
+ * includes them, a cache.data key holds only the function's arguments.
145
+ */
146
+ var DATA_TIER_FIELDS = new Map([
147
+ ...REQUEST_FIELDS,
148
+ ["segmentParams", "segment params"],
149
+ ["slotParams", "segment params"]
150
+ ]);
151
+ var TIERS = {
152
+ "cache.component": {
153
+ observed: REQUEST_FIELDS,
154
+ keyedBy: "props and segment params",
155
+ passAs: "as props",
156
+ work: "a cache capture render"
157
+ },
158
+ "cache.data": {
159
+ observed: DATA_TIER_FIELDS,
160
+ keyedBy: "the function's arguments",
161
+ passAs: "as an argument",
162
+ work: "a cached call"
163
+ }
164
+ };
165
+ /** Rate-limit interval: one diagnostic per callsite per 60 seconds. */
166
+ var RATE_LIMIT_MS = 6e4;
167
+ /**
168
+ * Last emission timestamp per `${tier}:${id}`. Past this many entries,
169
+ * ones whose window has elapsed are pruned — an untransformed callsite
170
+ * re-created per request gets a fresh fallback id each time.
171
+ */
172
+ var lastEmitted = /* @__PURE__ */ new Map();
173
+ var PRUNE_AT = 1e3;
174
+ /**
175
+ * Thrown in strict mode. A distinct class so a caller holding an earlier
176
+ * result computed by the same fn (a stale SWR entry) can drop it.
177
+ */
178
+ var KeyDisciplineViolation = class extends Error {
179
+ name = "KeyDisciplineViolation";
180
+ };
181
+ var strict = false;
182
+ /**
183
+ * Run a cached callsite's work under the observing proxy, then report any
184
+ * request-context read it made. The proxy is transparent — it forwards all
185
+ * reads and writes; it only observes.
186
+ *
187
+ * Outside a request context `run` executes as-is: there is nothing to read,
188
+ * and cache.data must keep working there. In default mode a callsite that
189
+ * reported within the rate-limit window is not observed at all. In strict
190
+ * mode a violation rejects after `run` resolves, so the caller never stores
191
+ * the value.
192
+ */
193
+ async function observeKeyDiscipline(site, run) {
194
+ const store = requestContextAls.getStore();
195
+ if (!store || !shouldCheck(site)) return run();
196
+ const { proxy, accessedApis } = createObservingProxy(store, TIERS[site.tier].observed);
197
+ const result = await requestContextAls.run(proxy, run);
198
+ if (accessedApis.size > 0) reportViolation(site, accessedApis);
199
+ return result;
200
+ }
201
+ function rateLimitKey(site) {
202
+ return `${site.tier}:${site.id}`;
203
+ }
204
+ /**
205
+ * Whether to observe this callsite on this call. Always in strict mode;
206
+ * otherwise only once the rate-limit window since its last report elapsed.
207
+ */
208
+ function shouldCheck(site) {
209
+ if (strict) return true;
210
+ const last = lastEmitted.get(rateLimitKey(site));
211
+ if (last === void 0) return true;
212
+ return Date.now() - last >= RATE_LIMIT_MS;
213
+ }
214
+ function createObservingProxy(store, observed) {
215
+ const accessedApis = /* @__PURE__ */ new Set();
216
+ return {
217
+ proxy: new Proxy(store, { get(target, prop, receiver) {
218
+ const api = observed.get(prop);
219
+ if (api) accessedApis.add(api);
220
+ return Reflect.get(target, prop, receiver);
221
+ } }),
222
+ accessedApis
223
+ };
224
+ }
225
+ /**
226
+ * Throw in strict mode; otherwise emit a structured error-level diagnostic
227
+ * through the logger (same path as render errors), rate-limited per callsite.
228
+ */
229
+ function reportViolation(site, apis) {
230
+ const { tier, id } = site;
231
+ const name = site.label ?? id;
232
+ const apiList = Array.from(apis).join(", ");
233
+ const wording = TIERS[tier];
234
+ const remedy = `Either pass request-derived values ${wording.passAs} (included in the cache key) or remove the ${apiList} call.`;
235
+ if (strict) throw new KeyDisciplineViolation(`[timber] ${tier} key-discipline violation: "${name}" reads ${apiList} during ${wording.work}. The cache key is computed from ${wording.keyedBy} only — caching this result would serve one user's data to another. ${remedy} To downgrade this to a warning, set cache.strictKeyDiscipline: false in timber.config.ts.`);
236
+ const now = Date.now();
237
+ const key = rateLimitKey(site);
238
+ const last = lastEmitted.get(key);
239
+ if (last !== void 0 && now - last < RATE_LIMIT_MS) return;
240
+ if (lastEmitted.size >= PRUNE_AT) {
241
+ for (const [k, t] of lastEmitted) if (now - t >= RATE_LIMIT_MS) lastEmitted.delete(k);
242
+ }
243
+ lastEmitted.set(key, now);
244
+ logKeyDisciplineViolation(`${tier} cross-user data leak risk`, {
245
+ ...tier === "cache.component" ? { component: name } : {
246
+ fn: name,
247
+ id,
248
+ cacheKey: site.cacheKey
249
+ },
250
+ accessedApis: Array.from(apis),
251
+ message: `${tier} "${name}" reads ${apiList} but the cache key is computed from ${wording.keyedBy} only. If the result varies by ${apiList}, different users may see each other's cached data. ${remedy}`
252
+ });
253
+ }
254
+ // src/cache/timber-cache.ts
120
255
  var defaultSingleflight = createSingleflight();
121
256
  /**
122
257
  * Per-key monotonic generation counter for CAS writes (TIM-1158).
@@ -205,13 +340,18 @@ function deriveFallbackFnId(fn) {
205
340
  * configured handler once it arrives (TIM-1029)
206
341
  * - No ALS dependency for correctness — cache() works outside a request
207
342
  * context. The waitUntil ALS bridge is read optionally so the SWR
208
- * background refetch survives handler return on Workers/Lambda.
343
+ * background refetch survives handler return on Workers/Lambda, and
344
+ * inside one, fn runs under the key-discipline observer (design/45
345
+ * §Enforcement): the key comes from the arguments only, so a
346
+ * request-context read in fn is reported, or rejected in strict mode
347
+ * before the result is stored.
209
348
  *
210
349
  * Cache hits/misses are recorded as OTEL span events on the enclosing
211
350
  * span (not child spans). The DevSpanProcessor reads these for dev log output.
212
351
  */
213
352
  function createCache(fn, opts, getHandler, stableId) {
214
353
  const fnId = stableId ?? (opts.key ? void 0 : deriveFallbackFnId(fn));
354
+ const disciplineId = fnId ?? `key-fn:${fnv1aHash(fn.toString())}`;
215
355
  const perCallSf = opts.timeoutMs !== void 0 ? createSingleflight({ timeoutMs: opts.timeoutMs }) : void 0;
216
356
  return (async (...args) => {
217
357
  const sf = perCallSf ?? defaultSingleflight;
@@ -227,7 +367,7 @@ function createCache(fn, opts, getHandler, stableId) {
227
367
  return cached.value;
228
368
  }
229
369
  const tags = resolveTags(opts, args);
230
- const flightKey = `${key}\u0000${lastInvalidationEpochFor(key, tags)}`;
370
+ const flightKey = `${storeKey}\u0000${lastInvalidationEpochFor(key, tags)}`;
231
371
  /**
232
372
  * Run fn and store the result — exactly once per coalesced execution,
233
373
  * inside the singleflight callback. The write is skipped when:
@@ -241,7 +381,18 @@ function createCache(fn, opts, getHandler, stableId) {
241
381
  const executeAndStore = async (signal) => {
242
382
  const startEpoch = currentInvalidationEpoch();
243
383
  const generation = nextGeneration(key);
244
- const result = await fn(...args);
384
+ let result;
385
+ try {
386
+ result = await observeKeyDiscipline({
387
+ tier: "cache.data",
388
+ id: disciplineId,
389
+ label: fn.name || void 0,
390
+ cacheKey: key
391
+ }, () => fn(...args));
392
+ } catch (err) {
393
+ if (err instanceof KeyDisciplineViolation && !signal.aborted && writeGenerations.get(key) === generation) await getHandler().invalidate({ key: storeKey }).catch((e) => swallow(e, `cache invalidate failed for key "${key}"`));
394
+ throw err;
395
+ }
245
396
  if (!signal.aborted && !wasInvalidatedSince(startEpoch, key, tags)) try {
246
397
  await getHandler().set(storeKey, result, {
247
398
  ttl: opts.ttl,
@@ -281,8 +432,7 @@ function createCache(fn, opts, getHandler, stableId) {
281
432
  return result;
282
433
  });
283
434
  }
284
- //#endregion
285
- //#region src/cache/redis-handler.ts
435
+ // src/cache/redis-handler.ts
286
436
  var KEY_PREFIX = "timber:cache:";
287
437
  var TAG_PREFIX = "timber:tag:";
288
438
  /**
@@ -398,8 +548,7 @@ var RedisCacheHandler = class {
398
548
  }
399
549
  }
400
550
  };
401
- //#endregion
402
- //#region src/cache/tag-aware-handler.ts
551
+ // src/cache/tag-aware-handler.ts
403
552
  var DATA_PREFIX = "d:";
404
553
  var TAG_SET_PREFIX = "ts:";
405
554
  var TAG_VERSION_PREFIX = "tv:";
@@ -544,8 +693,7 @@ var TagAwareCacheHandler = class {
544
693
  await this.store.set(key, String(version), 31536e3);
545
694
  }
546
695
  };
547
- //#endregion
548
- //#region src/cache/index.ts
696
+ // src/cache/index.ts
549
697
  var MemoryCacheHandler = class {
550
698
  store = /* @__PURE__ */ new Map();
551
699
  generations = /* @__PURE__ */ new Map();
@@ -633,8 +781,7 @@ var MemoryCacheHandler = class {
633
781
  }
634
782
  }
635
783
  };
636
- //#endregion
637
- //#region src/server/version-skew.ts
784
+ // src/server/version-skew.ts
638
785
  /**
639
786
  * Version Skew Detection — graceful recovery when stale clients hit new deployments.
640
787
  *
@@ -709,8 +856,7 @@ function checkVersionSkew(req) {
709
856
  function applyReloadHeaders(headers) {
710
857
  headers.set(RELOAD_HEADER, "1");
711
858
  }
712
- //#endregion
713
- //#region src/server/prebuilt/manifest-tag-index.ts
859
+ // src/server/prebuilt/manifest-tag-index.ts
714
860
  /**
715
861
  * Build the inverted tag → seed key index from the manifest.
716
862
  *
@@ -739,8 +885,7 @@ function buildTagIndex(manifest) {
739
885
  }
740
886
  return index;
741
887
  }
742
- //#endregion
743
- //#region src/server/prebuilt/payload-source.ts
888
+ // src/server/prebuilt/payload-source.ts
744
889
  /**
745
890
  * Prebuilt payload source — the adapter seam through which the runtime
746
891
  * reads build-time flight artifacts (`.timber/dist/prebuilt/`).
@@ -879,8 +1024,7 @@ async function lookupArtifactSeed(id, cacheKey, needsTimestamp) {
879
1024
  capturedAt: (needsTimestamp ? await getManifestEntry(id, cacheKey) : null)?.buildTimestamp ?? 0
880
1025
  };
881
1026
  }
882
- //#endregion
883
- //#region src/server/prebuilt/overlay.ts
1027
+ // src/server/prebuilt/overlay.ts
884
1028
  /**
885
1029
  * Component cache overlay — runtime CacheHandler layer for ISR.
886
1030
  *
@@ -913,6 +1057,16 @@ function isTombstone(v) {
913
1057
  function overlayKey(componentId, cacheKey) {
914
1058
  return `timber:c:${getDeploymentId() ?? devOverlayNamespace() ?? "dev"}:${componentId}:${cacheKey}`;
915
1059
  }
1060
+ /**
1061
+ * Whether a re-render that started at `startEpoch` may store its capture
1062
+ * under `oKey`: nothing invalidated the key or its tags meanwhile
1063
+ * (TIM-1028), and the overlay key has not moved on. In dev a save moves it
1064
+ * to a new namespace, and the bytes may come from the pre-save code: stored,
1065
+ * they would answer every request after the save.
1066
+ */
1067
+ function mayStoreRerender(startEpoch, componentId, cacheKey, oKey, tags) {
1068
+ return !wasInvalidatedSince(startEpoch, oKey, tags) && overlayKey(componentId, cacheKey) === oKey;
1069
+ }
916
1070
  var READ_FAILED = Symbol("overlay read failed");
917
1071
  /**
918
1072
  * Look up an overlay entry in the cache handler.
@@ -1031,8 +1185,7 @@ function bytesToBase64(bytes) {
1031
1185
  function base64ToBytes(b64) {
1032
1186
  return new Uint8Array(Buffer.from(b64, "base64"));
1033
1187
  }
1034
- //#endregion
1035
- //#region src/cache/cache-api.ts
1188
+ // src/cache/cache-api.ts
1036
1189
  var componentFallbackWarned = /* @__PURE__ */ new WeakSet();
1037
1190
  /**
1038
1191
  * Cache namespace — `cache.data`, `cache.component`, `cache.invalidate`.
@@ -1103,7 +1256,6 @@ var cache = {
1103
1256
  return componentFn;
1104
1257
  }
1105
1258
  };
1106
- //#endregion
1107
- export { hasPrebuiltPayloadSource as a, setPrebuiltPayloadSource as c, MemoryCacheHandler as d, TagAwareCacheHandler as f, getWaitUntil as h, storeOverlayEntry as i, applyReloadHeaders as l, setDefaultSingleflightTimeout as m, lookupOverlay as n, isParamIndependent as o, RedisCacheHandler as p, overlayKey as r, lookupArtifactSeed as s, cache as t, checkVersionSkew as u };
1259
+ export { getWaitUntil as _, storeOverlayEntry as a, lookupArtifactSeed as c, checkVersionSkew as d, MemoryCacheHandler as f, observeKeyDiscipline as g, setDefaultSingleflightTimeout as h, overlayKey as i, setPrebuiltPayloadSource as l, RedisCacheHandler as m, lookupOverlay as n, hasPrebuiltPayloadSource as o, TagAwareCacheHandler as p, mayStoreRerender as r, isParamIndependent as s, cache as t, applyReloadHeaders as u };
1108
1260
 
1109
- //# sourceMappingURL=cache-api-DdcDLpBj.js.map
1261
+ //# sourceMappingURL=cache-api-TDZ4hlDc.js.map