@timber-js/app 0.2.0-alpha.221 → 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 (380) hide show
  1. package/agent-skill.md +21 -5
  2. package/dist/_chunks/{actions-BDqn4Oxj.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-GE4AOe2H.js → cache-api-TDZ4hlDc.js} +237 -37
  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-e_Buf9vg.js → chains-Dgm3PrMe.js} +3 -4
  20. package/dist/_chunks/{chains-e_Buf9vg.js.map → chains-Dgm3PrMe.js.map} +1 -1
  21. package/dist/_chunks/{classify-2Yp3xJY1.js → classify--_kINHQV.js} +4 -5
  22. package/dist/_chunks/{classify-2Yp3xJY1.js.map → classify--_kINHQV.js.map} +1 -1
  23. package/dist/_chunks/{cli-check-DDwCkeDY.js → cli-check-Dv3f8d2j.js} +5 -6
  24. package/dist/_chunks/{cli-check-DDwCkeDY.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-BdIebmk3.js → cli-schema-sync-DIPurq7X.js} +4 -5
  33. package/dist/_chunks/{cli-schema-sync-BdIebmk3.js.map → cli-schema-sync-DIPurq7X.js.map} +1 -1
  34. package/dist/_chunks/{cli-schema-sync-CLNfXQDK.js → cli-schema-sync-uq72EZmD.js} +1 -1
  35. package/dist/_chunks/{client-dep-entries-BOkpKjj1.js → client-dep-entries-CP7AkMCM.js} +4 -5
  36. package/dist/_chunks/{client-dep-entries-BOkpKjj1.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-ByKJ6aqD.js → convention-lint-hZwz5wd4.js} +8 -11
  44. package/dist/_chunks/{convention-lint-ByKJ6aqD.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-DIy-SY-J.js → dev-server-C61GWpGg.js} +409 -51
  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-HptmGMT8.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-DbxNWeBP.js +47 -0
  65. package/dist/_chunks/global-context-DbxNWeBP.js.map +1 -0
  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-C8zBY2uZ.js → json-lossy-check-DVkLUlfC.js} +3 -4
  71. package/dist/_chunks/{json-lossy-check-C8zBY2uZ.js.map → json-lossy-check-DVkLUlfC.js.map} +1 -1
  72. package/dist/_chunks/{live-graph-tSWrv8eH.js → live-graph-BcVjQ1Te.js} +6 -7
  73. package/dist/_chunks/{live-graph-tSWrv8eH.js.map → live-graph-BcVjQ1Te.js.map} +1 -1
  74. package/dist/_chunks/{logger-CbLdcy-W.js → logger-CWk44DLp.js} +97 -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-rkQqcFGq.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-C4FgMxFl.js → poison-scan-DJYxZc_7.js} +4 -5
  90. package/dist/_chunks/{poison-scan-C4FgMxFl.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-joFhz4KH.js → render-timeout-MrrqD1wd.js} +20 -4
  94. package/dist/_chunks/{render-timeout-joFhz4KH.js.map → render-timeout-MrrqD1wd.js.map} +1 -1
  95. package/dist/_chunks/{resolve-schema-CBR6Lm4i.js → resolve-schema-B-aCuTu3.js} +3 -4
  96. package/dist/_chunks/{resolve-schema-CBR6Lm4i.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-Cb3fSjAC.js → scanner-CJC-ScJU.js} +15 -23
  106. package/dist/_chunks/{scanner-Cb3fSjAC.js.map → scanner-CJC-ScJU.js.map} +1 -1
  107. package/dist/_chunks/{schema-bridge-C83xa9lT.js → schema-bridge-DyRs3cqy.js} +61 -25
  108. package/dist/_chunks/schema-bridge-DyRs3cqy.js.map +1 -0
  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-xtPUGfdq.js → segment-context-CYiGTi3K.js} +6 -12
  112. package/dist/_chunks/segment-context-CYiGTi3K.js.map +1 -0
  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-QPE5nd3u.js → sizeof-DG4W40lv.js} +3 -4
  118. package/dist/_chunks/{sizeof-QPE5nd3u.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-qu8TpiLh.js → walkers-DIE203ir.js} +6 -8
  130. package/dist/_chunks/{walkers-qu8TpiLh.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/guarded-read.d.ts +29 -0
  151. package/dist/cache/guarded-read.d.ts.map +1 -0
  152. package/dist/cache/index.js +3 -3
  153. package/dist/cache/key-discipline.d.ts +61 -0
  154. package/dist/cache/key-discipline.d.ts.map +1 -0
  155. package/dist/cache/stores/cloudflare-kv.js +1 -2
  156. package/dist/cache/stores/memory.js +2 -3
  157. package/dist/cache/stores/redis.js +1 -2
  158. package/dist/cache/stores/vercel.js +1 -2
  159. package/dist/cache/timber-cache.d.ts +5 -1
  160. package/dist/cache/timber-cache.d.ts.map +1 -1
  161. package/dist/cdn/cloudflare-purge.js +1 -2
  162. package/dist/cdn/fastly-purge.js +1 -2
  163. package/dist/cdn/index.js +2 -3
  164. package/dist/cdn/workers-cache-purge.js +3 -5
  165. package/dist/cdn/workers-cache-purge.js.map +1 -1
  166. package/dist/cli-dev-status.d.ts +75 -0
  167. package/dist/cli-dev-status.d.ts.map +1 -0
  168. package/dist/cli-init.d.ts +72 -0
  169. package/dist/cli-init.d.ts.map +1 -0
  170. package/dist/cli.d.ts +4 -12
  171. package/dist/cli.d.ts.map +1 -1
  172. package/dist/cli.js +27 -54
  173. package/dist/cli.js.map +1 -1
  174. package/dist/client/error-boundary.d.ts.map +1 -1
  175. package/dist/client/error-boundary.js +1 -1
  176. package/dist/client/global-context.d.ts +21 -1
  177. package/dist/client/global-context.d.ts.map +1 -1
  178. package/dist/client/index.js +23 -44
  179. package/dist/client/index.js.map +1 -1
  180. package/dist/client/internal.js +13 -18
  181. package/dist/client/internal.js.map +1 -1
  182. package/dist/client/navigation-context.d.ts.map +1 -1
  183. package/dist/client/params-context.d.ts.map +1 -1
  184. package/dist/client/slot-context.d.ts +2 -2
  185. package/dist/client/slot-context.d.ts.map +1 -1
  186. package/dist/client/use-cookie.d.ts +18 -5
  187. package/dist/client/use-cookie.d.ts.map +1 -1
  188. package/dist/codec.js +2 -3
  189. package/dist/config-types.d.ts +22 -5
  190. package/dist/config-types.d.ts.map +1 -1
  191. package/dist/config-validation.d.ts.map +1 -1
  192. package/dist/cookies/define-cookie.d.ts.map +1 -1
  193. package/dist/cookies/index.js +40 -67
  194. package/dist/cookies/index.js.map +1 -1
  195. package/dist/cookies/json-cookie.d.ts +4 -4
  196. package/dist/index.js +266 -229
  197. package/dist/index.js.map +1 -1
  198. package/dist/params/index.js +3 -4
  199. package/dist/plugin-context.d.ts +7 -0
  200. package/dist/plugin-context.d.ts.map +1 -1
  201. package/dist/plugins/dev-discovery.d.ts +69 -5
  202. package/dist/plugins/dev-discovery.d.ts.map +1 -1
  203. package/dist/plugins/dev-hostname.d.ts +152 -0
  204. package/dist/plugins/dev-hostname.d.ts.map +1 -0
  205. package/dist/plugins/dev-server.d.ts +6 -2
  206. package/dist/plugins/dev-server.d.ts.map +1 -1
  207. package/dist/plugins/dev-store-clear.d.ts +83 -0
  208. package/dist/plugins/dev-store-clear.d.ts.map +1 -0
  209. package/dist/plugins/graph-endpoint.d.ts +4 -2
  210. package/dist/plugins/graph-endpoint.d.ts.map +1 -1
  211. package/dist/plugins/prebuilt.d.ts.map +1 -1
  212. package/dist/routing/index.js +4 -4
  213. package/dist/rsc-runtime/rsc.d.ts +2 -1
  214. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  215. package/dist/rsc-runtime/server-references.d.ts +8 -0
  216. package/dist/rsc-runtime/server-references.d.ts.map +1 -0
  217. package/dist/schema-bridge.d.ts +28 -19
  218. package/dist/schema-bridge.d.ts.map +1 -1
  219. package/dist/search-params/define.d.ts +1 -1
  220. package/dist/search-params/define.d.ts.map +1 -1
  221. package/dist/search-params/index.js +11 -14
  222. package/dist/search-params/index.js.map +1 -1
  223. package/dist/search-params/wrappers.d.ts +3 -3
  224. package/dist/server/access-gate.d.ts +12 -0
  225. package/dist/server/access-gate.d.ts.map +1 -1
  226. package/dist/server/canonicalize.d.ts +21 -0
  227. package/dist/server/canonicalize.d.ts.map +1 -1
  228. package/dist/server/cookie-context.d.ts +8 -1
  229. package/dist/server/cookie-context.d.ts.map +1 -1
  230. package/dist/server/flight-source-node.d.ts.map +1 -1
  231. package/dist/server/flight-source.d.ts.map +1 -1
  232. package/dist/server/index.d.ts +1 -1
  233. package/dist/server/index.d.ts.map +1 -1
  234. package/dist/server/index.js +8 -13
  235. package/dist/server/index.js.map +1 -1
  236. package/dist/server/interception-gates.d.ts +49 -0
  237. package/dist/server/interception-gates.d.ts.map +1 -0
  238. package/dist/server/internal.js +1080 -959
  239. package/dist/server/internal.js.map +1 -1
  240. package/dist/server/logger.d.ts +26 -0
  241. package/dist/server/logger.d.ts.map +1 -1
  242. package/dist/server/param-coercion.d.ts +8 -0
  243. package/dist/server/param-coercion.d.ts.map +1 -1
  244. package/dist/server/pipeline-interception.d.ts +34 -4
  245. package/dist/server/pipeline-interception.d.ts.map +1 -1
  246. package/dist/server/pipeline-metadata-route.d.ts +24 -0
  247. package/dist/server/pipeline-metadata-route.d.ts.map +1 -0
  248. package/dist/server/pipeline-metadata.d.ts +3 -2
  249. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  250. package/dist/server/pipeline-phases.d.ts +9 -3
  251. package/dist/server/pipeline-phases.d.ts.map +1 -1
  252. package/dist/server/pipeline.d.ts +18 -0
  253. package/dist/server/pipeline.d.ts.map +1 -1
  254. package/dist/server/prebuilt/dev-store.d.ts +68 -22
  255. package/dist/server/prebuilt/dev-store.d.ts.map +1 -1
  256. package/dist/server/prebuilt/overlay.d.ts +17 -3
  257. package/dist/server/prebuilt/overlay.d.ts.map +1 -1
  258. package/dist/server/prebuilt-runtime.d.ts.map +1 -1
  259. package/dist/server/primitives.d.ts +13 -0
  260. package/dist/server/primitives.d.ts.map +1 -1
  261. package/dist/server/render-utils.d.ts +21 -0
  262. package/dist/server/render-utils.d.ts.map +1 -1
  263. package/dist/server/request-context.d.ts +14 -0
  264. package/dist/server/request-context.d.ts.map +1 -1
  265. package/dist/server/route-element-builder.d.ts.map +1 -1
  266. package/dist/server/route-handler.d.ts +7 -0
  267. package/dist/server/route-handler.d.ts.map +1 -1
  268. package/dist/server/route-matcher.d.ts +14 -3
  269. package/dist/server/route-matcher.d.ts.map +1 -1
  270. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  271. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  272. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  273. package/dist/server/signal-identity.d.ts +6 -0
  274. package/dist/server/signal-identity.d.ts.map +1 -1
  275. package/dist/server/traced-access.d.ts +18 -0
  276. package/dist/server/traced-access.d.ts.map +1 -0
  277. package/dist/server/tracing.d.ts.map +1 -1
  278. package/dist/server/types.d.ts +5 -4
  279. package/dist/server/types.d.ts.map +1 -1
  280. package/dist/shims/font-google.js +1 -2
  281. package/dist/shims/font-local.js +1 -2
  282. package/dist/shims/headers.d.ts +11 -4
  283. package/dist/shims/headers.d.ts.map +1 -1
  284. package/docs/api/30-api-server.mdx +3 -1
  285. package/docs/api/32-api-cache.mdx +1 -1
  286. package/docs/api/33-api-search-params.mdx +3 -1
  287. package/docs/api/34-api-config.mdx +22 -0
  288. package/docs/api/36-cli.mdx +72 -6
  289. package/docs/learn/01-quick-start.mdx +1 -1
  290. package/docs/learn/06-typed-params.mdx +4 -4
  291. package/docs/learn/10-caching.mdx +26 -5
  292. package/llms.txt +1 -1
  293. package/package.json +12 -12
  294. package/src/adapters/build-output-helper.ts +26 -4
  295. package/src/adapters/cloudflare.ts +1 -0
  296. package/src/adapters/nitro-presets.ts +15 -0
  297. package/src/adapters/nitro-preview.ts +66 -34
  298. package/src/adapters/nitro.ts +14 -6
  299. package/src/analyze/graph-command.ts +25 -133
  300. package/src/cache/guarded-read.ts +44 -0
  301. package/src/cache/key-discipline.ts +218 -0
  302. package/src/cache/timber-cache.ts +46 -7
  303. package/src/cli-dev-status.ts +196 -0
  304. package/src/cli-init.ts +278 -0
  305. package/src/cli.ts +33 -79
  306. package/src/client/error-boundary.tsx +19 -2
  307. package/src/client/global-context.ts +42 -14
  308. package/src/client/navigation-context.ts +4 -11
  309. package/src/client/params-context.ts +5 -17
  310. package/src/client/segment-update-context.ts +1 -1
  311. package/src/client/slot-content-cache-context.ts +1 -1
  312. package/src/client/slot-context.ts +6 -17
  313. package/src/client/use-cookie.ts +33 -21
  314. package/src/config-types.ts +22 -5
  315. package/src/config-validation.ts +17 -0
  316. package/src/cookies/define-cookie.ts +10 -46
  317. package/src/cookies/json-cookie.ts +4 -4
  318. package/src/plugin-context.ts +7 -0
  319. package/src/plugins/dev-discovery.ts +216 -6
  320. package/src/plugins/dev-hostname.ts +322 -0
  321. package/src/plugins/dev-server.ts +130 -37
  322. package/src/plugins/dev-store-clear.ts +145 -0
  323. package/src/plugins/graph-endpoint.ts +15 -3
  324. package/src/plugins/prebuilt.ts +9 -0
  325. package/src/rsc-runtime/rsc.ts +7 -3
  326. package/src/rsc-runtime/server-references.ts +73 -0
  327. package/src/rsc-runtime/vendor-types.d.ts +17 -0
  328. package/src/schema-bridge.ts +93 -38
  329. package/src/search-params/define.ts +5 -6
  330. package/src/search-params/wrappers.ts +3 -3
  331. package/src/server/access-gate.tsx +32 -20
  332. package/src/server/action-handler.ts +58 -36
  333. package/src/server/canonicalize.ts +27 -0
  334. package/src/server/cookie-context.ts +11 -3
  335. package/src/server/flight-source-node.ts +5 -2
  336. package/src/server/flight-source.ts +4 -3
  337. package/src/server/index.ts +6 -1
  338. package/src/server/interception-gates.ts +94 -0
  339. package/src/server/logger.ts +32 -0
  340. package/src/server/param-coercion.ts +22 -0
  341. package/src/server/pipeline-interception.ts +64 -4
  342. package/src/server/pipeline-metadata-route.ts +242 -0
  343. package/src/server/pipeline-metadata.ts +7 -5
  344. package/src/server/pipeline-phases.ts +71 -131
  345. package/src/server/pipeline.ts +20 -2
  346. package/src/server/prebuilt/dev-store.ts +113 -34
  347. package/src/server/prebuilt/overlay.ts +32 -4
  348. package/src/server/prebuilt-runtime.ts +63 -45
  349. package/src/server/primitives.ts +14 -0
  350. package/src/server/render-utils.ts +25 -0
  351. package/src/server/request-context.ts +27 -3
  352. package/src/server/route-element-builder.ts +15 -2
  353. package/src/server/route-handler.ts +3 -2
  354. package/src/server/route-matcher.ts +48 -33
  355. package/src/server/rsc-entry/api-handler.ts +2 -33
  356. package/src/server/rsc-entry/index.ts +8 -3
  357. package/src/server/rsc-entry/rsc-stream.ts +7 -1
  358. package/src/server/signal-identity.ts +30 -12
  359. package/src/server/traced-access.ts +50 -0
  360. package/src/server/tracing.ts +18 -1
  361. package/src/server/types.ts +5 -4
  362. package/src/shims/headers.ts +12 -4
  363. package/dist/_chunks/actions-BDqn4Oxj.js.map +0 -1
  364. package/dist/_chunks/build-output-helper-RV_BRcF1.js.map +0 -1
  365. package/dist/_chunks/cache-api-GE4AOe2H.js.map +0 -1
  366. package/dist/_chunks/chains-CDK1AWZQ.js +0 -1
  367. package/dist/_chunks/cli-context-BJQB6rtF.js +0 -1
  368. package/dist/_chunks/dev-server-BiWNMBVU.js +0 -1
  369. package/dist/_chunks/dev-server-DIy-SY-J.js.map +0 -1
  370. package/dist/_chunks/dev-store-BOa304m_.js.map +0 -1
  371. package/dist/_chunks/flight-source-node-HptmGMT8.js.map +0 -1
  372. package/dist/_chunks/graph-cache-CYiUS2aS.js.map +0 -1
  373. package/dist/_chunks/logger-CbLdcy-W.js.map +0 -1
  374. package/dist/_chunks/node-response-rkQqcFGq.js.map +0 -1
  375. package/dist/_chunks/plugin-context-DxMMvjUt.js.map +0 -1
  376. package/dist/_chunks/schema-bridge-C83xa9lT.js.map +0 -1
  377. package/dist/_chunks/segment-context-xtPUGfdq.js.map +0 -1
  378. package/dist/server/prebuilt/key-discipline.d.ts +0 -52
  379. package/dist/server/prebuilt/key-discipline.d.ts.map +0 -1
  380. package/src/server/prebuilt/key-discipline.ts +0 -122
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // Steps 1–5 of every adapter's buildOutput are platform-agnostic:
4
4
  // 1. Copy client assets to the public/static directory
5
- // 2. Write _headers file for static asset cache control
5
+ // 2. Write _headers file for static asset cache control, where the platform reads it
6
6
  // 3. Copy RSC + SSR server bundles
7
7
  // 4. Write manifest-init module (if present)
8
8
  //
@@ -19,6 +19,7 @@ import { adapterBase, generateHeadersFile } from './shared.ts';
19
19
  // `adapters/shared.ts` importing `../shared/base-path.js`.
20
20
  import {
21
21
  HEADERS_FILE,
22
+ REDIRECTS_FILE,
22
23
  USER_MERGED_PLATFORM_FILES,
23
24
  USER_PLATFORM_DIR,
24
25
  } from '../shared/static-platform-files.ts';
@@ -43,6 +44,15 @@ export interface BuildOutputBaseOptions {
43
44
  * Nitro uses 'public', Cloudflare uses 'static'.
44
45
  */
45
46
  publicDirName: string;
47
+ /**
48
+ * Whether the platform reads `_headers` and `_redirects` from the public
49
+ * directory (Cloudflare, Netlify). When false, the output has neither — no
50
+ * generated `_headers`, and not the user's `public/_headers` or
51
+ * `public/_redirects`, which Vite copies into the client output: on a host
52
+ * that does not read them they are plain files, served to anyone who asks
53
+ * for `/_headers` (TIM-1605).
54
+ */
55
+ platformFiles: boolean;
46
56
  }
47
57
 
48
58
  /**
@@ -50,14 +60,14 @@ export interface BuildOutputBaseOptions {
50
60
  *
51
61
  * 1. Create the output directory
52
62
  * 2. Copy client assets to the public/static directory
53
- * 3. Write the `_headers` file for static asset cache control
63
+ * 3. Write the `_headers` file for static asset cache control, if `platformFiles`
54
64
  * 4. Copy RSC and SSR server bundles into the output directory
55
65
  * 5. Write the manifest-init module if present
56
66
  *
57
67
  * Returns the resolved public directory path for further adapter-specific use.
58
68
  */
59
69
  export async function runSharedBuildSteps(opts: BuildOutputBaseOptions): Promise<string> {
60
- const { config, artifacts, outDir, publicDirName } = opts;
70
+ const { config, artifacts, outDir, publicDirName, platformFiles } = opts;
61
71
 
62
72
  // 1. Create the output directory.
63
73
  await mkdir(outDir, { recursive: true });
@@ -65,9 +75,17 @@ export async function runSharedBuildSteps(opts: BuildOutputBaseOptions): Promise
65
75
  // 2. Copy client assets to public/static directory.
66
76
  // When client JavaScript is disabled, skip .js files — only CSS,
67
77
  // fonts, images, and other static assets are needed.
78
+ // Cleaned first: the adapter output directory outlives a build, and a file
79
+ // an earlier build left here (a static build's pre-rendered `index.html`,
80
+ // a `_headers` the preset no longer reads) would otherwise ship and be
81
+ // served ahead of the app.
68
82
  const publicDir = join(outDir, publicDirName);
83
+ await rm(publicDir, { recursive: true, force: true });
69
84
  await mkdir(publicDir, { recursive: true });
70
85
  const clientDir = artifacts.client.path;
86
+ const userPlatformFiles = new Set(
87
+ platformFiles ? [] : [HEADERS_FILE, REDIRECTS_FILE].map((name) => join(clientDir, name))
88
+ );
71
89
  // Find WASM files that are referenced by client JS (legitimate client WASM)
72
90
  // vs orphaned server-only WASM (e.g. @takumi-rs for OG image generation).
73
91
  // Only strip orphaned WASM to avoid breaking client-side WASM usage.
@@ -80,6 +98,7 @@ export async function runSharedBuildSteps(opts: BuildOutputBaseOptions): Promise
80
98
  return false;
81
99
  }
82
100
  if (config.clientJavascriptDisabled && src.endsWith('.js')) return false;
101
+ if (userPlatformFiles.has(src)) return false;
83
102
  return true;
84
103
  },
85
104
  });
@@ -88,7 +107,10 @@ export async function runSharedBuildSteps(opts: BuildOutputBaseOptions): Promise
88
107
  // Scan for unhashed files so they get per-file Cache-Control rules in the
89
108
  // _headers file. On platforms like Cloudflare Workers Static Assets, the
90
109
  // worker never sees static file requests — _headers is the only mechanism.
91
- await writeHeadersFile(publicDir, config, artifacts);
110
+ // Elsewhere nothing reads it, so its rules never applied and the file was
111
+ // only a public asset; the immutable header there comes from the server
112
+ // instead (nitro-immutable-assets.ts).
113
+ if (platformFiles) await writeHeadersFile(publicDir, config, artifacts);
92
114
 
93
115
  // 4. Copy RSC + SSR server bundles into the output directory. The RSC
94
116
  // bundle imports the SSR one by a path the RSC plugin computed between the
@@ -277,6 +277,7 @@ export function cloudflare(options: CloudflareAdapterOptions = {}): TimberPlatfo
277
277
  artifacts: { ...artifacts, prebuilt: undefined },
278
278
  outDir,
279
279
  publicDirName: 'static',
280
+ platformFiles: true,
280
281
  });
281
282
 
282
283
  // Compile optional worker handlers (queue, scheduled, etc.)
@@ -30,6 +30,12 @@ export interface PresetConfig {
30
30
  supportsWaitUntil: boolean;
31
31
  /** Whether the runtime supports application-level 103 Early Hints. */
32
32
  supportsEarlyHints: boolean;
33
+ /**
34
+ * Whether the platform reads `_headers` and `_redirects` from the public
35
+ * directory. Everywhere else they are just public files anyone can fetch,
36
+ * so the build leaves them out (TIM-1605).
37
+ */
38
+ readsPlatformFiles: boolean;
33
39
  /** Value for TIMBER_RUNTIME env var. See design/25-production-deployments.md. */
34
40
  runtimeName: string;
35
41
  /** Additional nitro.config fields for this preset. */
@@ -42,6 +48,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
42
48
  outputDir: '.vercel/output',
43
49
  supportsWaitUntil: true,
44
50
  supportsEarlyHints: false,
51
+ readsPlatformFiles: false,
45
52
  runtimeName: 'vercel',
46
53
  extraConfig: { vercel: { functions: { maxDuration: 30 } } },
47
54
  },
@@ -50,6 +57,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
50
57
  outputDir: '.vercel/output',
51
58
  supportsWaitUntil: true,
52
59
  supportsEarlyHints: false,
60
+ readsPlatformFiles: false,
53
61
  runtimeName: 'vercel-edge',
54
62
  },
55
63
  'netlify': {
@@ -57,6 +65,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
57
65
  outputDir: '.netlify/functions-internal',
58
66
  supportsWaitUntil: false,
59
67
  supportsEarlyHints: false,
68
+ readsPlatformFiles: true,
60
69
  runtimeName: 'netlify',
61
70
  },
62
71
  'netlify-edge': {
@@ -64,6 +73,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
64
73
  outputDir: '.netlify/edge-functions',
65
74
  supportsWaitUntil: true,
66
75
  supportsEarlyHints: false,
76
+ readsPlatformFiles: true,
67
77
  runtimeName: 'netlify-edge',
68
78
  },
69
79
  'aws-lambda': {
@@ -71,6 +81,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
71
81
  outputDir: '.output',
72
82
  supportsWaitUntil: false,
73
83
  supportsEarlyHints: false,
84
+ readsPlatformFiles: false,
74
85
  runtimeName: 'aws-lambda',
75
86
  },
76
87
  'deno-deploy': {
@@ -78,6 +89,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
78
89
  outputDir: '.output',
79
90
  supportsWaitUntil: true,
80
91
  supportsEarlyHints: false,
92
+ readsPlatformFiles: false,
81
93
  runtimeName: 'deno-deploy',
82
94
  },
83
95
  'azure-functions': {
@@ -85,6 +97,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
85
97
  outputDir: '.output',
86
98
  supportsWaitUntil: false,
87
99
  supportsEarlyHints: false,
100
+ readsPlatformFiles: false,
88
101
  runtimeName: 'azure-functions',
89
102
  },
90
103
  'node-server': {
@@ -99,6 +112,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
99
112
  // are the safe fallback — Cloudflare and other CDNs convert them to
100
113
  // 103 automatically at the edge (over HTTP/2+ to the browser).
101
114
  supportsEarlyHints: false,
115
+ readsPlatformFiles: false,
102
116
  runtimeName: 'node-server',
103
117
  },
104
118
  'bun': {
@@ -108,6 +122,7 @@ export const PRESET_CONFIGS: Record<NitroPreset, PresetConfig> = {
108
122
  // Disabled for same reason as node-server — reverse proxies choke on 103.
109
123
  // Link headers on the 200 response are converted to 103 by CDNs.
110
124
  supportsEarlyHints: false,
125
+ readsPlatformFiles: false,
111
126
  runtimeName: 'bun',
112
127
  },
113
128
  };
@@ -250,7 +250,7 @@ import { createServer } from 'node:http';
250
250
  import { readFile, stat } from 'node:fs/promises';
251
251
  import { join, extname, sep } from 'node:path';
252
252
  import { fileURLToPath } from 'node:url';
253
- import { canonicalize } from './_canonicalize.mjs';
253
+ import { canonicalize, requestTargetUrl } from './_canonicalize.mjs';
254
254
 
255
255
  const __dirname = fileURLToPath(new URL('.', import.meta.url));
256
256
 
@@ -321,6 +321,9 @@ const envPort = process.env.PORT ? parseInt(process.env.PORT, 10) : null;
321
321
  const portIsExplicit = envPort != null && Number.isFinite(envPort) && envPort > 0;
322
322
  const startPort = portIsExplicit ? envPort : 3000;
323
323
  const host = process.env.HOST || 'localhost';
324
+ // An IPv6 HOST ('::', '::1') binds as is but needs brackets in a URL;
325
+ // unbracketed, every request URL is unparseable and answered 400.
326
+ const urlHost = host.includes(':') && !host.startsWith('[') ? \`[\${host}]\` : host;
324
327
 
325
328
  // Set after listenWithBump() resolves so request handlers can build
326
329
  // absolute URLs from the actual bound port (which may differ from
@@ -335,16 +338,17 @@ const server = createServer(async (req, res) => {
335
338
  // connection it would be attacker-controlled. The CSRF layer honors it
336
339
  // separately for reverse-proxy deployments.
337
340
  const scheme = req.socket?.encrypted ? 'https' : 'http';
338
- // An origin-form target ('/path') is concatenated, not resolved against
339
- // the base: resolved as a relative reference, '//evil.com/' names another
340
- // host, and the pipeline would see '/' instead of the path it must
341
- // redirect to '/evil.com' (TIM-1571). Any other form — 'OPTIONS *', an
342
- // absolute-form target — is resolved as before: concatenating '*' makes
343
- // an invalid URL, and this callback has no catch around it, so the
344
- // rejection would take the preview process down.
345
- const origin = \`\${scheme}://\${host}:\${boundPort}\`;
346
- const target = req.url || '/';
347
- const url = target.startsWith('/') ? new URL(origin + target) : new URL(target, origin);
341
+ // requestTargetUrl() (server/canonicalize.ts) concatenates an origin-form
342
+ // target and resolves any other form, so '//evil.com/' stays a path the
343
+ // pipeline redirects (TIM-1571) and 'OPTIONS *' is '/*'. A target that
344
+ // names no URL is answered here: thrown in this callback, which has no
345
+ // catch around it, the rejection would take the preview process down.
346
+ const url = requestTargetUrl(\`\${scheme}://\${urlHost}:\${boundPort}\`, req.url || '/');
347
+ if (!url) {
348
+ res.writeHead(400, { 'Content-Type': 'text/plain' });
349
+ res.end('Bad Request');
350
+ return;
351
+ }
348
352
 
349
353
  // The runtime's own request-boundary canonicalizer (_canonicalize.mjs,
350
354
  // compiled from server/canonicalize.ts): one decode, and the same 400s for
@@ -450,44 +454,63 @@ export function sendNodeResponse(nodeRes, webRes) {
450
454
  // pipe it straight to the socket, no Web Streams round trip. pipe() rather
451
455
  // than pipeline(), which allocates an AbortController and an error on every
452
456
  // finish; a client that disconnects early destroys the body (aborting the
453
- // render), and a body that errors destroys the socket.
457
+ // render), and a body that errors mid-stream destroys the socket.
458
+ //
459
+ // As srvx's pipeBody does, the status line waits until the body is
460
+ // readable: a body that errors before its first chunk answers a bare 500
461
+ // instead of closing the socket with nothing written (TIM-1602).
454
462
  if (typeof webRes._toNodeResponse === 'function') {
455
463
  const res = webRes._toNodeResponse();
456
464
  if (res.body && typeof res.body.pipe === 'function') {
457
- if (!nodeRes.headersSent) {
458
- if (nodeRes.req?.httpVersion === '2.0') {
459
- nodeRes.writeHead(res.status, res.headers);
460
- } else {
461
- nodeRes.writeHead(res.status, res.statusText, res.headers);
462
- }
463
- }
464
465
  const body = res.body;
465
466
  // The client already left: 'close' has fired and will not again.
466
467
  if (nodeRes.destroyed) {
467
468
  body.destroy();
468
469
  return;
469
470
  }
471
+ // Already failed: its 'error' has fired and 'readable' never will.
472
+ if (body.destroyed) {
473
+ writeHead(nodeRes, 500, 'Internal Server Error', []);
474
+ return new Promise((resolve) => nodeRes.end(resolve));
475
+ }
470
476
  return new Promise((resolve) => {
471
- nodeRes.once('close', () => {
472
- if (!body.readableEnded) body.destroy();
477
+ function cleanup() {
478
+ body.off('error', onEarlyError);
479
+ body.off('readable', onReadable);
480
+ nodeRes.off('close', onEarlyClose);
481
+ }
482
+ function onEarlyError() {
483
+ cleanup();
484
+ body.destroy();
485
+ writeHead(nodeRes, 500, 'Internal Server Error', []);
486
+ nodeRes.end(resolve);
487
+ }
488
+ function onEarlyClose() {
489
+ cleanup();
490
+ body.destroy();
473
491
  resolve();
474
- });
475
- nodeRes.on('error', () => body.destroy());
476
- body.once('error', (error) => nodeRes.destroy(error));
477
- body.pipe(nodeRes);
492
+ }
493
+ function onReadable() {
494
+ cleanup();
495
+ writeHead(nodeRes, res.status, res.statusText, res.headers);
496
+ nodeRes.once('close', () => {
497
+ if (!body.readableEnded) body.destroy();
498
+ resolve();
499
+ });
500
+ nodeRes.on('error', () => body.destroy());
501
+ body.once('error', (error) => nodeRes.destroy(error));
502
+ body.pipe(nodeRes);
503
+ }
504
+ body.once('error', onEarlyError);
505
+ body.once('readable', onReadable);
506
+ nodeRes.once('close', onEarlyClose);
478
507
  });
479
508
  }
480
509
  webRes = new Response(res.body, { status: res.status, statusText: res.statusText, headers: pairs(res.headers) });
481
510
  }
482
- const rawHeaders = [...webRes.headers];
483
- const writeHeaders = rawHeaders.flat();
484
- if (!nodeRes.headersSent) {
485
- if (nodeRes.req?.httpVersion === '2.0') {
486
- nodeRes.writeHead(webRes.status, writeHeaders);
487
- } else {
488
- nodeRes.writeHead(webRes.status, webRes.statusText, writeHeaders);
489
- }
490
- }
511
+ // A Web body's status line goes out before its first read, as in srvx:
512
+ // one that errors before its first chunk closes the socket unanswered.
513
+ writeHead(nodeRes, webRes.status, webRes.statusText, [...webRes.headers].flat());
491
514
  if (!webRes.body) {
492
515
  return new Promise((resolve) => nodeRes.end(resolve));
493
516
  }
@@ -524,6 +547,15 @@ export function sendNodeResponse(nodeRes, webRes) {
524
547
  });
525
548
  }
526
549
 
550
+ function writeHead(nodeRes, status, statusText, headers) {
551
+ if (nodeRes.headersSent) return;
552
+ if (nodeRes.req?.httpVersion === '2.0') {
553
+ nodeRes.writeHead(status, headers);
554
+ } else {
555
+ nodeRes.writeHead(status, statusText, headers);
556
+ }
557
+ }
558
+
527
559
  function pairs(flat) {
528
560
  const out = [];
529
561
  for (let i = 0; i < flat.length; i += 2) out.push([flat[i], flat[i + 1]]);
@@ -6,7 +6,7 @@
6
6
  // See design/11-platform.md and design/25-production-deployments.md.
7
7
 
8
8
  import { existsSync } from 'node:fs';
9
- import { cp, glob, readFile, writeFile } from 'node:fs/promises';
9
+ import { cp, glob, readFile, rm, writeFile } from 'node:fs/promises';
10
10
  import { basename, dirname, join, relative, sep } from 'node:path';
11
11
  import type { NitroConfig } from 'nitro/types';
12
12
  import {
@@ -24,6 +24,7 @@ import {
24
24
  spawnNitroPreview,
25
25
  } from './nitro-preview.ts';
26
26
  import { adapterBase } from './shared.ts';
27
+ import { HEADERS_FILE, REDIRECTS_FILE } from '../shared/static-platform-files.ts';
27
28
  import type {
28
29
  BuildArtifacts,
29
30
  PreviewTarget,
@@ -117,10 +118,12 @@ export function nitro(options: NitroAdapterOptions = {}): TimberPlatformAdapter
117
118
  if (artifacts.output === 'static') {
118
119
  await buildStaticDirectoryOutput(config, artifacts, outDir, 'public');
119
120
  const publicDir = join(outDir, 'public');
121
+ const target = options.staticTarget ?? 'generic';
120
122
 
121
- // Write _headers for cache control + extensionless Content-Type.
122
- // Netlify supports the _headers convention just like Cloudflare.
123
- await writeHeadersFile(publicDir, config, artifacts);
123
+ // Write _headers for cache control + extensionless Content-Type, for
124
+ // the hosts a generic static build lands on that read it (Netlify,
125
+ // Cloudflare Pages). GitHub Pages reads neither platform file.
126
+ if (target !== 'github-pages') await writeHeadersFile(publicDir, config, artifacts);
124
127
 
125
128
  // Local preview serves the site as the build recorded it.
126
129
  await writeFile(join(outDir, CANONICALIZE_MODULE), await generateCanonicalizeModule());
@@ -135,7 +138,6 @@ export function nitro(options: NitroAdapterOptions = {}): TimberPlatformAdapter
135
138
  );
136
139
 
137
140
  // Platform-specific files for static deploy targets.
138
- const target = options.staticTarget ?? 'generic';
139
141
  if (target === 'github-pages') {
140
142
  // Deploy-from-a-branch runs Jekyll, which drops `_`-prefixed paths —
141
143
  // every `_rsc/` payload. Written unconditionally: GitHub reads only
@@ -154,18 +156,24 @@ export function nitro(options: NitroAdapterOptions = {}): TimberPlatformAdapter
154
156
  } catch {
155
157
  // No _redirects file — nothing to warn about
156
158
  }
159
+ // With `.nojekyll` nothing hides `_`-prefixed files, so these would be
160
+ // published as-is — the user's `public/` copies included (TIM-1605).
161
+ for (const name of [HEADERS_FILE, REDIRECTS_FILE]) {
162
+ await rm(join(publicDir, name), { force: true });
163
+ }
157
164
  }
158
165
 
159
166
  return;
160
167
  }
161
168
 
162
169
  // Steps 1–5: shared across all adapters (mkdir, copy client/rsc/ssr,
163
- // write _headers, write manifest-init).
170
+ // write _headers where the platform reads it, write manifest-init).
164
171
  await runSharedBuildSteps({
165
172
  config,
166
173
  artifacts,
167
174
  outDir,
168
175
  publicDirName: 'public',
176
+ platformFiles: PRESET_CONFIGS[preset].readsPlatformFiles,
169
177
  });
170
178
 
171
179
  // Write runtime helper modules used by the preview server.
@@ -22,15 +22,13 @@
22
22
  */
23
23
 
24
24
  import { execFile } from 'node:child_process';
25
- import { existsSync, readdirSync, readFileSync } from 'node:fs';
25
+ import { existsSync } from 'node:fs';
26
26
  import { mkdir, readFile, realpath, rm } from 'node:fs/promises';
27
- import { request as httpRequest } from 'node:http';
28
- import { request as httpsRequest } from 'node:https';
29
27
  import { createRequire } from 'node:module';
30
28
  import { dirname, join, relative, resolve, sep } from 'node:path';
31
29
  import { fileURLToPath } from 'node:url';
32
30
  import { promisify } from 'node:util';
33
- import { DEV_DISCOVERY_DIR, isPidAlive, type DevRecord } from '../plugins/dev-discovery.ts';
31
+ import { DEV_PROBE_TIMEOUT_MS, probeDevServer, readDevRecords } from '../plugins/dev-discovery.ts';
34
32
  import {
35
33
  collectBaseFingerprintEntries,
36
34
  computeProjectFingerprint,
@@ -53,12 +51,6 @@ export type GraphSource = 'dev-server' | 'static-scan';
53
51
  const CRAWL_TIMEOUT_MS = 120_000;
54
52
  const SPAWN_SLACK_MS = 30_000;
55
53
 
56
- /**
57
- * Short timeout for the dev-server probe: the fast path must not hold
58
- * the fallback hostage if the server is wedged or the connection hangs.
59
- */
60
- const DEV_PROBE_TIMEOUT_MS = 2_000;
61
-
62
54
  /**
63
55
  * Vite's own default config file names, in Vite's precedence order.
64
56
  * Matching the list (rather than globbing) keeps the walk-up aligned
@@ -100,146 +92,46 @@ export function findViteConfigUpward(startDir: string): string | null {
100
92
  }
101
93
  }
102
94
 
103
- /** Max response body size (16 MB — matches the crawl child). */
104
- const PROBE_MAX_BODY_BYTES = 16 * 1024 * 1024;
105
-
106
- /**
107
- * HTTP(S) GET with a wall-clock deadline and response-size limit,
108
- * returning the parsed JSON body or null on any failure. Uses
109
- * node:http/https directly — `fetch` silently strips the Host header,
110
- * which the endpoint's DNS-rebinding defense needs to see as `localhost`.
111
- *
112
- * The wall-clock timer covers both connection and body streaming —
113
- * node's `timeout` option is an INACTIVITY timeout that resets on every
114
- * chunk, so a slow-drip response would never fire it.
115
- */
116
- function probeEndpoint(record: DevRecord, path: string, timeoutMs: number): Promise<unknown> {
117
- return new Promise((resolve) => {
118
- let settled = false;
119
- const done = (value: unknown) => {
120
- if (settled) return;
121
- settled = true;
122
- clearTimeout(wallClock);
123
- resolve(value);
124
- };
125
-
126
- const probeHost =
127
- record.host === '0.0.0.0' || record.host === '::' || record.host === ''
128
- ? '127.0.0.1'
129
- : record.host;
130
- const doRequest = record.protocol === 'https' ? httpsRequest : httpRequest;
131
- const req = doRequest(
132
- {
133
- hostname: probeHost,
134
- port: record.port,
135
- path,
136
- method: 'GET',
137
- // Self-signed certs are normal for dev servers.
138
- rejectUnauthorized: false,
139
- },
140
- (res) => {
141
- if (res.statusCode !== 200) {
142
- req.destroy();
143
- done(null);
144
- return;
145
- }
146
- const chunks: Buffer[] = [];
147
- let totalBytes = 0;
148
- res.on('data', (chunk: Buffer) => {
149
- totalBytes += chunk.length;
150
- if (totalBytes > PROBE_MAX_BODY_BYTES) {
151
- req.destroy();
152
- done(null);
153
- return;
154
- }
155
- chunks.push(chunk);
156
- });
157
- res.on('end', () => {
158
- try {
159
- const parsed = JSON.parse(Buffer.concat(chunks).toString('utf8')) as Record<
160
- string,
161
- unknown
162
- >;
163
- done(
164
- parsed?.version === GRAPH_JSON_VERSION && parsed?.source === 'dev-server'
165
- ? parsed
166
- : null
167
- );
168
- } catch {
169
- done(null);
170
- }
171
- });
172
- res.on('error', () => done(null));
173
- }
174
- );
175
- req.on('error', () => done(null));
176
-
177
- const wallClock = setTimeout(() => {
178
- req.destroy();
179
- done(null);
180
- }, timeoutMs);
181
- req.end();
182
- });
183
- }
184
-
185
95
  /**
186
96
  * Try to delegate a graph query to a running dev server discovered via
187
- * `.timber/dev/` records. Returns the parsed JSON response on success,
188
- * null on any failure (missing dir, no live records, probe failure).
189
- * Every failure mode is silent — the caller falls back to the cold crawl.
97
+ * its discovery record. Returns the parsed JSON response on success, null
98
+ * on any failure (no live records, wrong config, probe failure). Every
99
+ * failure mode is silent — the caller falls back to the cold crawl. The
100
+ * graph request itself is the liveness probe, so no separate status probe
101
+ * is made.
190
102
  */
191
103
  async function tryDevServer(
192
104
  configDir: string,
193
105
  configFile: string,
194
106
  queryString: string
195
107
  ): Promise<unknown> {
196
- const dir = join(configDir, DEV_DISCOVERY_DIR);
197
- let entries: string[];
198
- try {
199
- entries = readdirSync(dir);
200
- } catch {
201
- return null;
202
- }
203
- for (const entry of entries) {
204
- if (!entry.endsWith('.json')) continue;
205
- let record: DevRecord;
206
- try {
207
- record = JSON.parse(readFileSync(join(dir, entry), 'utf8')) as DevRecord;
208
- } catch {
209
- continue;
210
- }
211
- if (
212
- typeof record.port !== 'number' ||
213
- !Number.isInteger(record.port) ||
214
- record.port < 1 ||
215
- record.port > 65535 ||
216
- typeof record.pid !== 'number' ||
217
- !Number.isInteger(record.pid) ||
218
- record.pid < 1 ||
219
- typeof record.host !== 'string' ||
220
- (record.protocol !== 'http' && record.protocol !== 'https')
221
- ) {
222
- continue;
223
- }
108
+ for (const record of readDevRecords(configDir)) {
224
109
  // Skip records from a different Vite config (TIM-1393). Records
225
110
  // without configFile (old servers) are accepted — rejecting them
226
111
  // would break the fast path until every server restarts.
227
112
  if (record.configFile && normalizeSlashes(record.configFile) !== normalizeSlashes(configFile))
228
113
  continue;
229
- if (!isPidAlive(record.pid)) continue;
230
- let result: unknown;
231
- try {
232
- result = await probeEndpoint(record, `/__timber/graph${queryString}`, DEV_PROBE_TIMEOUT_MS);
233
- } catch {
234
- // http.request can throw synchronously on malformed hostnames
235
- // (ERR_INVALID_CHAR) or other invalid options — treat as absent.
236
- continue;
237
- }
238
- if (result) return result;
114
+ const result = await probeDevServer(
115
+ record,
116
+ `/__timber/graph${queryString}`,
117
+ DEV_PROBE_TIMEOUT_MS
118
+ );
119
+ if (isDevServerGraphResponse(result)) return result;
239
120
  }
240
121
  return null;
241
122
  }
242
123
 
124
+ function isDevServerGraphResponse(value: unknown): boolean {
125
+ return (
126
+ typeof value === 'object' &&
127
+ value !== null &&
128
+ 'version' in value &&
129
+ value.version === GRAPH_JSON_VERSION &&
130
+ 'source' in value &&
131
+ value.source === 'dev-server'
132
+ );
133
+ }
134
+
243
135
  /**
244
136
  * Resolve the app root from the config file's own directory, reading
245
137
  * it off the timber root-sync plugin api (the single supported way —
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Cache reads never fail a request.
3
+ *
4
+ * A cache is an optimization: when the store is down, slow, or returns
5
+ * garbage, the request must still succeed by doing the work the cache would
6
+ * have skipped. Writes already follow this rule (timber-cache.ts swallows a
7
+ * failed handler.set, TIM-1046); reads go through here so a throwing or hung
8
+ * handler.get costs a live fetch or render, never a failed or stalled request.
9
+ *
10
+ * The timeout matters as much as the catch. Shared-store clients often queue
11
+ * commands while disconnected (ioredis retries each one up to 20 times by
12
+ * default), so an outage shows up as a read that never settles, not an error.
13
+ *
14
+ * Invalidation is deliberately NOT guarded: a failed invalidate that looked
15
+ * like success would leave stale data in place silently.
16
+ *
17
+ * See design/06-caching.md §"Store failures".
18
+ */
19
+
20
+ import { logCacheReadFailed } from '../server/logger.ts';
21
+ import { withTimeout } from '../server/render-timeout.ts';
22
+
23
+ /** Ceiling for a single cache read. A healthy store answers in milliseconds. */
24
+ export const CACHE_READ_TIMEOUT_MS = 1_000;
25
+
26
+ /**
27
+ * Run a cache read. A throw, a rejection, or no answer within
28
+ * CACHE_READ_TIMEOUT_MS logs a warning and resolves to `onFailure`, which the
29
+ * caller picks: `null` where a failed read means "miss", a distinct value
30
+ * where a miss would fall back to something the failed read might have
31
+ * overridden (an invalidated build seed — server/prebuilt/overlay.ts).
32
+ */
33
+ export async function guardedRead<T, F>(
34
+ cacheKey: string,
35
+ read: () => Promise<T>,
36
+ onFailure: F
37
+ ): Promise<T | F> {
38
+ try {
39
+ return await withTimeout(read(), CACHE_READ_TIMEOUT_MS, `cache read for "${cacheKey}"`);
40
+ } catch (error) {
41
+ logCacheReadFailed({ cacheKey, error });
42
+ return onFailure;
43
+ }
44
+ }