@timber-js/app 0.2.0-alpha.21 → 0.2.0-alpha.210

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 (1386) hide show
  1. package/LICENSE +8 -0
  2. package/agent-skill.md +346 -0
  3. package/bin/timber.mjs +15 -1
  4. package/dist/_chunks/actions-Rjk4htmA.js +1199 -0
  5. package/dist/_chunks/actions-Rjk4htmA.js.map +1 -0
  6. package/dist/_chunks/als-registry-DaxkVjt5.js +45 -0
  7. package/dist/_chunks/als-registry-DaxkVjt5.js.map +1 -0
  8. package/dist/_chunks/als-slots-BEEIPKYm.js +26 -0
  9. package/dist/_chunks/als-slots-BEEIPKYm.js.map +1 -0
  10. package/dist/_chunks/base-path-DaQrzbez.js +80 -0
  11. package/dist/_chunks/base-path-DaQrzbez.js.map +1 -0
  12. package/dist/_chunks/build-manifest-DWppEdLB.js +86 -0
  13. package/dist/_chunks/build-manifest-DWppEdLB.js.map +1 -0
  14. package/dist/_chunks/build-output-helper-RV_BRcF1.js +367 -0
  15. package/dist/_chunks/build-output-helper-RV_BRcF1.js.map +1 -0
  16. package/dist/_chunks/cache-api-DGdYfNJn.js +1182 -0
  17. package/dist/_chunks/cache-api-DGdYfNJn.js.map +1 -0
  18. package/dist/_chunks/canonicalize-CgHoscYO.js +66 -0
  19. package/dist/_chunks/canonicalize-CgHoscYO.js.map +1 -0
  20. package/dist/_chunks/chains-BoO51joc.js +413 -0
  21. package/dist/_chunks/chains-BoO51joc.js.map +1 -0
  22. package/dist/_chunks/cli-check-ajNY3B2e.js +252 -0
  23. package/dist/_chunks/cli-check-ajNY3B2e.js.map +1 -0
  24. package/dist/_chunks/cli-context-By7k2xVo.js +70 -0
  25. package/dist/_chunks/cli-context-By7k2xVo.js.map +1 -0
  26. package/dist/_chunks/cli-schema-sync-D2eI8jEg.js +299 -0
  27. package/dist/_chunks/cli-schema-sync-D2eI8jEg.js.map +1 -0
  28. package/dist/_chunks/cloudflare-Byxl8FWP.js +1333 -0
  29. package/dist/_chunks/cloudflare-Byxl8FWP.js.map +1 -0
  30. package/dist/_chunks/codec-registry-oOUxugz3.js +21 -0
  31. package/dist/_chunks/codec-registry-oOUxugz3.js.map +1 -0
  32. package/dist/_chunks/codegen-Bps1sLKJ.js +432 -0
  33. package/dist/_chunks/codegen-Bps1sLKJ.js.map +1 -0
  34. package/dist/_chunks/convention-lint-DLmhGsRS.js +590 -0
  35. package/dist/_chunks/convention-lint-DLmhGsRS.js.map +1 -0
  36. package/dist/_chunks/dev-server-v97rQH4b.js +2039 -0
  37. package/dist/_chunks/dev-server-v97rQH4b.js.map +1 -0
  38. package/dist/_chunks/dist-DtrJyBbw.js +386 -0
  39. package/dist/_chunks/dist-DtrJyBbw.js.map +1 -0
  40. package/dist/_chunks/error-boundary-DsNScGRM.js +1024 -0
  41. package/dist/_chunks/error-boundary-DsNScGRM.js.map +1 -0
  42. package/dist/_chunks/fast-hash-C-tVYrLb.js +41 -0
  43. package/dist/_chunks/fast-hash-C-tVYrLb.js.map +1 -0
  44. package/dist/_chunks/format-BKclgVbk.js +14 -0
  45. package/dist/_chunks/format-BKclgVbk.js.map +1 -0
  46. package/dist/_chunks/fs-identity-BRKuL215.js +207 -0
  47. package/dist/_chunks/fs-identity-BRKuL215.js.map +1 -0
  48. package/dist/_chunks/graph-cache-CYiUS2aS.js +303 -0
  49. package/dist/_chunks/graph-cache-CYiUS2aS.js.map +1 -0
  50. package/dist/_chunks/href-validation-BIrxavIy.js +213 -0
  51. package/dist/_chunks/href-validation-BIrxavIy.js.map +1 -0
  52. package/dist/_chunks/json-lossy-check-CVuRs2hG.js +66 -0
  53. package/dist/_chunks/json-lossy-check-CVuRs2hG.js.map +1 -0
  54. package/dist/_chunks/live-graph-9cSnn_h9.js +150 -0
  55. package/dist/_chunks/live-graph-9cSnn_h9.js.map +1 -0
  56. package/dist/_chunks/logger-BP0LN6vP.js +662 -0
  57. package/dist/_chunks/logger-BP0LN6vP.js.map +1 -0
  58. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-DSDjM_hJ.js} +71 -27
  59. package/dist/_chunks/metadata-routes-DSDjM_hJ.js.map +1 -0
  60. package/dist/_chunks/navigation-root-BQfo1-kG.js +126 -0
  61. package/dist/_chunks/navigation-root-BQfo1-kG.js.map +1 -0
  62. package/dist/_chunks/param-value-C8TNYchQ.js +66 -0
  63. package/dist/_chunks/param-value-C8TNYchQ.js.map +1 -0
  64. package/dist/_chunks/plugin-context-BPBPc3lL.js +345 -0
  65. package/dist/_chunks/plugin-context-BPBPc3lL.js.map +1 -0
  66. package/dist/_chunks/poison-rules-DoEhbqaY.js +110 -0
  67. package/dist/_chunks/poison-rules-DoEhbqaY.js.map +1 -0
  68. package/dist/_chunks/poison-scan-vGV7Re0B.js +101 -0
  69. package/dist/_chunks/poison-scan-vGV7Re0B.js.map +1 -0
  70. package/dist/_chunks/purge-store-Byr8XOjU.js +14 -0
  71. package/dist/_chunks/purge-store-Byr8XOjU.js.map +1 -0
  72. package/dist/_chunks/render-timeout-DOf_BBcO.js +46 -0
  73. package/dist/_chunks/render-timeout-DOf_BBcO.js.map +1 -0
  74. package/dist/_chunks/resolve-schema-CBR6Lm4i.js +50 -0
  75. package/dist/_chunks/resolve-schema-CBR6Lm4i.js.map +1 -0
  76. package/dist/_chunks/rolldown-runtime-D7D4PA-g.js +13 -0
  77. package/dist/_chunks/rsc-cache-key-ClUiXQnK.js +243 -0
  78. package/dist/_chunks/rsc-cache-key-ClUiXQnK.js.map +1 -0
  79. package/dist/_chunks/rsc-media-type-DDc7duTD.js +61 -0
  80. package/dist/_chunks/rsc-media-type-DDc7duTD.js.map +1 -0
  81. package/dist/_chunks/rsc-payload-path-dffcs4jp.js +54 -0
  82. package/dist/_chunks/rsc-payload-path-dffcs4jp.js.map +1 -0
  83. package/dist/_chunks/scan-BoP17W3w.js +140 -0
  84. package/dist/_chunks/scan-BoP17W3w.js.map +1 -0
  85. package/dist/_chunks/scanner-DmqdxzbW.js +2056 -0
  86. package/dist/_chunks/scanner-DmqdxzbW.js.map +1 -0
  87. package/dist/_chunks/schema-bridge-C83xa9lT.js +199 -0
  88. package/dist/_chunks/schema-bridge-C83xa9lT.js.map +1 -0
  89. package/dist/_chunks/segment-classify-C539Pa2O.js +197 -0
  90. package/dist/_chunks/segment-classify-C539Pa2O.js.map +1 -0
  91. package/dist/_chunks/segment-context-xtPUGfdq.js +137 -0
  92. package/dist/_chunks/segment-context-xtPUGfdq.js.map +1 -0
  93. package/dist/_chunks/segment-keys-D5hu1hz4.js +62 -0
  94. package/dist/_chunks/segment-keys-D5hu1hz4.js.map +1 -0
  95. package/dist/_chunks/singleflight-BeVMMKi0.js +55 -0
  96. package/dist/_chunks/singleflight-BeVMMKi0.js.map +1 -0
  97. package/dist/_chunks/sizeof-BM1409x2.js +36 -0
  98. package/dist/_chunks/sizeof-BM1409x2.js.map +1 -0
  99. package/dist/_chunks/ssr-data-nA3I70_n.js +49 -0
  100. package/dist/_chunks/ssr-data-nA3I70_n.js.map +1 -0
  101. package/dist/_chunks/state-BhNGPsdi.js +50 -0
  102. package/dist/_chunks/state-BhNGPsdi.js.map +1 -0
  103. package/dist/_chunks/status-page-marker-BRX9Ib-d.js +564 -0
  104. package/dist/_chunks/status-page-marker-BRX9Ib-d.js.map +1 -0
  105. package/dist/_chunks/tree-match-6yihorhk.js +169 -0
  106. package/dist/_chunks/tree-match-6yihorhk.js.map +1 -0
  107. package/dist/_chunks/use-query-states-I3JMng6J.js +226 -0
  108. package/dist/_chunks/use-query-states-I3JMng6J.js.map +1 -0
  109. package/dist/_chunks/walkers-Czu2jXFq.js +144 -0
  110. package/dist/_chunks/walkers-Czu2jXFq.js.map +1 -0
  111. package/dist/_chunks/write-file-atomic-D1qWqHb4.js +32 -0
  112. package/dist/_chunks/write-file-atomic-D1qWqHb4.js.map +1 -0
  113. package/dist/adapters/build-output-helper.d.ts +72 -0
  114. package/dist/adapters/build-output-helper.d.ts.map +1 -0
  115. package/dist/adapters/canonicalize-module.d.ts +8 -0
  116. package/dist/adapters/canonicalize-module.d.ts.map +1 -0
  117. package/dist/adapters/cloudflare-dev.d.ts +109 -0
  118. package/dist/adapters/cloudflare-dev.d.ts.map +1 -0
  119. package/dist/adapters/cloudflare-dev.js +74 -0
  120. package/dist/adapters/cloudflare-dev.js.map +1 -0
  121. package/dist/adapters/cloudflare-kv-cache.d.ts +65 -0
  122. package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
  123. package/dist/adapters/cloudflare-kv-cache.js +123 -0
  124. package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
  125. package/dist/adapters/cloudflare.d.ts +224 -24
  126. package/dist/adapters/cloudflare.d.ts.map +1 -1
  127. package/dist/adapters/cloudflare.js +2 -188
  128. package/dist/adapters/compress-module.d.ts +25 -4
  129. package/dist/adapters/compress-module.d.ts.map +1 -1
  130. package/dist/adapters/fs-identity.d.ts +63 -0
  131. package/dist/adapters/fs-identity.d.ts.map +1 -0
  132. package/dist/adapters/nitro-presets.d.ts +31 -0
  133. package/dist/adapters/nitro-presets.d.ts.map +1 -0
  134. package/dist/adapters/nitro-preview.d.ts +64 -0
  135. package/dist/adapters/nitro-preview.d.ts.map +1 -0
  136. package/dist/adapters/nitro.d.ts +54 -37
  137. package/dist/adapters/nitro.d.ts.map +1 -1
  138. package/dist/adapters/nitro.js +631 -359
  139. package/dist/adapters/nitro.js.map +1 -1
  140. package/dist/adapters/shared.d.ts +67 -0
  141. package/dist/adapters/shared.d.ts.map +1 -0
  142. package/dist/adapters/types.d.ts +122 -16
  143. package/dist/adapters/types.d.ts.map +1 -1
  144. package/dist/adapters/types.js +0 -0
  145. package/dist/analyze/chains.d.ts +124 -0
  146. package/dist/analyze/chains.d.ts.map +1 -0
  147. package/dist/analyze/classify.d.ts +151 -0
  148. package/dist/analyze/classify.d.ts.map +1 -0
  149. package/dist/analyze/crawl-entry.d.ts +17 -0
  150. package/dist/analyze/crawl-entry.d.ts.map +1 -0
  151. package/dist/analyze/crawl-entry.js +313 -0
  152. package/dist/analyze/crawl-entry.js.map +1 -0
  153. package/dist/analyze/crawl.d.ts +134 -0
  154. package/dist/analyze/crawl.d.ts.map +1 -0
  155. package/dist/analyze/graph-cache.d.ts +104 -0
  156. package/dist/analyze/graph-cache.d.ts.map +1 -0
  157. package/dist/analyze/graph-command.d.ts +43 -0
  158. package/dist/analyze/graph-command.d.ts.map +1 -0
  159. package/dist/analyze/graph-command.js +472 -0
  160. package/dist/analyze/graph-command.js.map +1 -0
  161. package/dist/analyze/live-graph.d.ts +81 -0
  162. package/dist/analyze/live-graph.d.ts.map +1 -0
  163. package/dist/analyze/poison-rules.d.ts +72 -0
  164. package/dist/analyze/poison-rules.d.ts.map +1 -0
  165. package/dist/analyze/poison-scan.d.ts +48 -0
  166. package/dist/analyze/poison-scan.d.ts.map +1 -0
  167. package/dist/analyze/scan.d.ts +73 -0
  168. package/dist/analyze/scan.d.ts.map +1 -0
  169. package/dist/cache/cache-api.d.ts +48 -0
  170. package/dist/cache/cache-api.d.ts.map +1 -0
  171. package/dist/cache/fast-hash.d.ts +5 -0
  172. package/dist/cache/fast-hash.d.ts.map +1 -1
  173. package/dist/cache/handler-store.d.ts +33 -0
  174. package/dist/cache/handler-store.d.ts.map +1 -0
  175. package/dist/cache/index.d.ts +32 -9
  176. package/dist/cache/index.d.ts.map +1 -1
  177. package/dist/cache/index.js +3 -326
  178. package/dist/cache/invalidation-epoch.d.ts +43 -0
  179. package/dist/cache/invalidation-epoch.d.ts.map +1 -0
  180. package/dist/cache/json-lossy-check.d.ts +11 -0
  181. package/dist/cache/json-lossy-check.d.ts.map +1 -0
  182. package/dist/cache/redis-handler.d.ts +141 -9
  183. package/dist/cache/redis-handler.d.ts.map +1 -1
  184. package/dist/cache/singleflight.d.ts +21 -2
  185. package/dist/cache/singleflight.d.ts.map +1 -1
  186. package/dist/cache/sizeof.d.ts +22 -0
  187. package/dist/cache/sizeof.d.ts.map +1 -0
  188. package/dist/cache/stable-stringify.d.ts +9 -0
  189. package/dist/cache/stable-stringify.d.ts.map +1 -1
  190. package/dist/cache/store.d.ts +53 -0
  191. package/dist/cache/store.d.ts.map +1 -0
  192. package/dist/cache/stores/cloudflare-kv.d.ts +38 -0
  193. package/dist/cache/stores/cloudflare-kv.d.ts.map +1 -0
  194. package/dist/cache/stores/cloudflare-kv.js +29 -0
  195. package/dist/cache/stores/cloudflare-kv.js.map +1 -0
  196. package/dist/cache/stores/memory.d.ts +42 -0
  197. package/dist/cache/stores/memory.d.ts.map +1 -0
  198. package/dist/cache/stores/memory.js +90 -0
  199. package/dist/cache/stores/memory.js.map +1 -0
  200. package/dist/cache/stores/redis.d.ts +69 -0
  201. package/dist/cache/stores/redis.d.ts.map +1 -0
  202. package/dist/cache/stores/redis.js +35 -0
  203. package/dist/cache/stores/redis.js.map +1 -0
  204. package/dist/cache/stores/vercel.d.ts +36 -0
  205. package/dist/cache/stores/vercel.d.ts.map +1 -0
  206. package/dist/cache/stores/vercel.js +33 -0
  207. package/dist/cache/stores/vercel.js.map +1 -0
  208. package/dist/cache/tag-aware-handler.d.ts +52 -0
  209. package/dist/cache/tag-aware-handler.d.ts.map +1 -0
  210. package/dist/cache/timber-cache.d.ts +21 -11
  211. package/dist/cache/timber-cache.d.ts.map +1 -1
  212. package/dist/cdn/cloudflare-purge.d.ts +23 -0
  213. package/dist/cdn/cloudflare-purge.d.ts.map +1 -0
  214. package/dist/cdn/cloudflare-purge.js +30 -0
  215. package/dist/cdn/cloudflare-purge.js.map +1 -0
  216. package/dist/cdn/fastly-purge.d.ts +25 -0
  217. package/dist/cdn/fastly-purge.d.ts.map +1 -0
  218. package/dist/cdn/fastly-purge.js +33 -0
  219. package/dist/cdn/fastly-purge.js.map +1 -0
  220. package/dist/cdn/headers.d.ts +97 -0
  221. package/dist/cdn/headers.d.ts.map +1 -0
  222. package/dist/cdn/index.d.ts +5 -0
  223. package/dist/cdn/index.d.ts.map +1 -0
  224. package/dist/cdn/index.js +94 -0
  225. package/dist/cdn/index.js.map +1 -0
  226. package/dist/cdn/purge-store.d.ts +23 -0
  227. package/dist/cdn/purge-store.d.ts.map +1 -0
  228. package/dist/cdn/workers-cache-purge.d.ts +20 -0
  229. package/dist/cdn/workers-cache-purge.d.ts.map +1 -0
  230. package/dist/cdn/workers-cache-purge.js +35 -0
  231. package/dist/cdn/workers-cache-purge.js.map +1 -0
  232. package/dist/cli-check.d.ts +133 -0
  233. package/dist/cli-check.d.ts.map +1 -0
  234. package/dist/cli-context.d.ts +54 -0
  235. package/dist/cli-context.d.ts.map +1 -0
  236. package/dist/cli-schema-sync.d.ts +59 -0
  237. package/dist/cli-schema-sync.d.ts.map +1 -0
  238. package/dist/cli.d.ts +85 -13
  239. package/dist/cli.d.ts.map +1 -1
  240. package/dist/cli.js +224 -63
  241. package/dist/cli.js.map +1 -1
  242. package/dist/client/browser-dev.d.ts +42 -2
  243. package/dist/client/browser-dev.d.ts.map +1 -1
  244. package/dist/client/browser-entry/action-dispatch.d.ts +19 -0
  245. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -0
  246. package/dist/client/browser-entry/action-queue.d.ts +63 -0
  247. package/dist/client/browser-entry/action-queue.d.ts.map +1 -0
  248. package/dist/client/browser-entry/hmr.d.ts +21 -0
  249. package/dist/client/browser-entry/hmr.d.ts.map +1 -0
  250. package/dist/client/browser-entry/hydrate.d.ts +53 -0
  251. package/dist/client/browser-entry/hydrate.d.ts.map +1 -0
  252. package/dist/client/browser-entry/index.d.ts +30 -0
  253. package/dist/client/browser-entry/index.d.ts.map +1 -0
  254. package/dist/client/browser-entry/post-hydration.d.ts +26 -0
  255. package/dist/client/browser-entry/post-hydration.d.ts.map +1 -0
  256. package/dist/client/browser-entry/router-init.d.ts +41 -0
  257. package/dist/client/browser-entry/router-init.d.ts.map +1 -0
  258. package/dist/client/browser-entry/rsc-stream.d.ts +32 -0
  259. package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
  260. package/dist/client/browser-entry/scroll.d.ts +28 -0
  261. package/dist/client/browser-entry/scroll.d.ts.map +1 -0
  262. package/dist/client/deny-last-resort.d.ts +29 -0
  263. package/dist/client/deny-last-resort.d.ts.map +1 -0
  264. package/dist/client/error-boundary.d.ts +58 -9
  265. package/dist/client/error-boundary.d.ts.map +1 -1
  266. package/dist/client/error-boundary.js +2 -126
  267. package/dist/client/error-reconstituter.d.ts +55 -0
  268. package/dist/client/error-reconstituter.d.ts.map +1 -0
  269. package/dist/client/form.d.ts +16 -27
  270. package/dist/client/form.d.ts.map +1 -1
  271. package/dist/client/global-context.d.ts +15 -0
  272. package/dist/client/global-context.d.ts.map +1 -0
  273. package/dist/client/history.d.ts +50 -9
  274. package/dist/client/history.d.ts.map +1 -1
  275. package/dist/client/index.d.ts +20 -33
  276. package/dist/client/index.d.ts.map +1 -1
  277. package/dist/client/index.js +330 -1150
  278. package/dist/client/index.js.map +1 -1
  279. package/dist/client/internal.d.ts +20 -0
  280. package/dist/client/internal.d.ts.map +1 -0
  281. package/dist/client/internal.js +792 -0
  282. package/dist/client/internal.js.map +1 -0
  283. package/dist/client/link.d.ts +85 -60
  284. package/dist/client/link.d.ts.map +1 -1
  285. package/dist/client/location-search.d.ts +12 -0
  286. package/dist/client/location-search.d.ts.map +1 -0
  287. package/dist/client/navigation-api.d.ts +133 -0
  288. package/dist/client/navigation-api.d.ts.map +1 -0
  289. package/dist/client/navigation-commit.d.ts +111 -0
  290. package/dist/client/navigation-commit.d.ts.map +1 -0
  291. package/dist/client/navigation-context.d.ts +54 -36
  292. package/dist/client/navigation-context.d.ts.map +1 -1
  293. package/dist/client/navigation-root.d.ts +106 -0
  294. package/dist/client/navigation-root.d.ts.map +1 -0
  295. package/dist/client/navigation-transition.d.ts +192 -0
  296. package/dist/client/navigation-transition.d.ts.map +1 -0
  297. package/dist/client/nuqs-adapter.d.ts +1 -1
  298. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  299. package/dist/client/params-context.d.ts +81 -0
  300. package/dist/client/params-context.d.ts.map +1 -0
  301. package/dist/client/react-root.d.ts +45 -0
  302. package/dist/client/react-root.d.ts.map +1 -0
  303. package/dist/client/router-effects.d.ts +137 -0
  304. package/dist/client/router-effects.d.ts.map +1 -0
  305. package/dist/client/router-lifecycle.d.ts +98 -0
  306. package/dist/client/router-lifecycle.d.ts.map +1 -0
  307. package/dist/client/router-pipeline.d.ts +84 -0
  308. package/dist/client/router-pipeline.d.ts.map +1 -0
  309. package/dist/client/router-ref.d.ts +2 -2
  310. package/dist/client/router-ref.d.ts.map +1 -1
  311. package/dist/client/router-skew.d.ts +21 -0
  312. package/dist/client/router-skew.d.ts.map +1 -0
  313. package/dist/client/router-types.d.ts +334 -0
  314. package/dist/client/router-types.d.ts.map +1 -0
  315. package/dist/client/router-url.d.ts +24 -0
  316. package/dist/client/router-url.d.ts.map +1 -0
  317. package/dist/client/router.d.ts +1 -97
  318. package/dist/client/router.d.ts.map +1 -1
  319. package/dist/client/rsc-fetch.d.ts +110 -28
  320. package/dist/client/rsc-fetch.d.ts.map +1 -1
  321. package/dist/client/segment-cache.d.ts +186 -25
  322. package/dist/client/segment-cache.d.ts.map +1 -1
  323. package/dist/client/segment-context.d.ts.map +1 -1
  324. package/dist/client/segment-outlet.d.ts +68 -0
  325. package/dist/client/segment-outlet.d.ts.map +1 -0
  326. package/dist/client/segment-update-context.d.ts +15 -0
  327. package/dist/client/segment-update-context.d.ts.map +1 -0
  328. package/dist/client/shallow-url.d.ts +10 -0
  329. package/dist/client/shallow-url.d.ts.map +1 -0
  330. package/dist/client/slot-content-cache-context.d.ts +35 -0
  331. package/dist/client/slot-content-cache-context.d.ts.map +1 -0
  332. package/dist/client/slot-context.d.ts +31 -0
  333. package/dist/client/slot-context.d.ts.map +1 -0
  334. package/dist/client/slot-outlet.d.ts +16 -0
  335. package/dist/client/slot-outlet.d.ts.map +1 -0
  336. package/dist/client/slot-provider.d.ts +25 -0
  337. package/dist/client/slot-provider.d.ts.map +1 -0
  338. package/dist/client/ssr-data.d.ts +26 -50
  339. package/dist/client/ssr-data.d.ts.map +1 -1
  340. package/dist/client/stale-client.d.ts +69 -0
  341. package/dist/client/stale-client.d.ts.map +1 -0
  342. package/dist/client/state.d.ts +21 -13
  343. package/dist/client/state.d.ts.map +1 -1
  344. package/dist/client/status-page-marker.d.ts +25 -0
  345. package/dist/client/status-page-marker.d.ts.map +1 -0
  346. package/dist/client/top-loader.d.ts +7 -6
  347. package/dist/client/top-loader.d.ts.map +1 -1
  348. package/dist/client/unload-guard.d.ts +5 -0
  349. package/dist/client/unload-guard.d.ts.map +1 -1
  350. package/dist/client/use-cookie.d.ts +12 -0
  351. package/dist/client/use-cookie.d.ts.map +1 -1
  352. package/dist/client/use-link-status.d.ts +5 -5
  353. package/dist/client/use-link-status.d.ts.map +1 -1
  354. package/dist/client/use-pathname.d.ts +13 -11
  355. package/dist/client/use-pathname.d.ts.map +1 -1
  356. package/dist/client/use-pending-navigation.d.ts +23 -0
  357. package/dist/client/use-pending-navigation.d.ts.map +1 -0
  358. package/dist/client/use-query-states.d.ts +10 -4
  359. package/dist/client/use-query-states.d.ts.map +1 -1
  360. package/dist/client/use-router.d.ts +15 -8
  361. package/dist/client/use-router.d.ts.map +1 -1
  362. package/dist/client/use-search-params.d.ts +15 -8
  363. package/dist/client/use-search-params.d.ts.map +1 -1
  364. package/dist/client/use-segment-params.d.ts +55 -0
  365. package/dist/client/use-segment-params.d.ts.map +1 -0
  366. package/dist/codec.d.ts +69 -0
  367. package/dist/codec.d.ts.map +1 -0
  368. package/dist/codec.js +76 -0
  369. package/dist/codec.js.map +1 -0
  370. package/dist/config-types.d.ts +323 -0
  371. package/dist/config-types.d.ts.map +1 -0
  372. package/dist/config-validation.d.ts +68 -0
  373. package/dist/config-validation.d.ts.map +1 -0
  374. package/dist/cookies/define-cookie.d.ts +58 -25
  375. package/dist/cookies/define-cookie.d.ts.map +1 -1
  376. package/dist/cookies/index.d.ts +3 -2
  377. package/dist/cookies/index.d.ts.map +1 -1
  378. package/dist/cookies/index.js +256 -36
  379. package/dist/cookies/index.js.map +1 -1
  380. package/dist/cookies/json-cookie.d.ts +64 -0
  381. package/dist/cookies/json-cookie.d.ts.map +1 -0
  382. package/dist/cookies/validation.d.ts +34 -0
  383. package/dist/cookies/validation.d.ts.map +1 -0
  384. package/dist/dev-tools/404-page.d.ts +50 -0
  385. package/dist/dev-tools/404-page.d.ts.map +1 -0
  386. package/dist/dev-tools/browser-logs.d.ts +40 -0
  387. package/dist/dev-tools/browser-logs.d.ts.map +1 -0
  388. package/dist/dev-tools/dev-page-shell.d.ts +95 -0
  389. package/dist/dev-tools/dev-page-shell.d.ts.map +1 -0
  390. package/dist/dev-tools/error-page.d.ts +32 -0
  391. package/dist/dev-tools/error-page.d.ts.map +1 -0
  392. package/dist/dev-tools/holding-server.d.ts +46 -0
  393. package/dist/dev-tools/holding-server.d.ts.map +1 -0
  394. package/dist/dev-tools/hydration-overlay.d.ts +11 -0
  395. package/dist/dev-tools/hydration-overlay.d.ts.map +1 -0
  396. package/dist/dev-tools/index.d.ts +31 -0
  397. package/dist/dev-tools/index.d.ts.map +1 -0
  398. package/dist/dev-tools/instrumentation.d.ts +74 -0
  399. package/dist/dev-tools/instrumentation.d.ts.map +1 -0
  400. package/dist/{server/dev-logger.d.ts → dev-tools/logger.d.ts} +1 -1
  401. package/dist/dev-tools/logger.d.ts.map +1 -0
  402. package/dist/{plugins/dev-logs.d.ts → dev-tools/logs.d.ts} +17 -3
  403. package/dist/dev-tools/logs.d.ts.map +1 -0
  404. package/dist/{plugins/dev-error-overlay.d.ts → dev-tools/overlay.d.ts} +15 -25
  405. package/dist/dev-tools/overlay.d.ts.map +1 -0
  406. package/dist/dev-tools/stack-classifier.d.ts +34 -0
  407. package/dist/dev-tools/stack-classifier.d.ts.map +1 -0
  408. package/dist/dev-tools/terminal.d.ts +28 -0
  409. package/dist/dev-tools/terminal.d.ts.map +1 -0
  410. package/dist/fonts/ast-walk.d.ts +68 -0
  411. package/dist/fonts/ast-walk.d.ts.map +1 -0
  412. package/dist/fonts/ast.d.ts +112 -8
  413. package/dist/fonts/ast.d.ts.map +1 -1
  414. package/dist/fonts/bundle.d.ts +50 -0
  415. package/dist/fonts/bundle.d.ts.map +1 -0
  416. package/dist/fonts/css.d.ts +1 -1
  417. package/dist/fonts/dev-middleware.d.ts +22 -0
  418. package/dist/fonts/dev-middleware.d.ts.map +1 -0
  419. package/dist/fonts/fallbacks.d.ts +0 -7
  420. package/dist/fonts/fallbacks.d.ts.map +1 -1
  421. package/dist/fonts/google.d.ts +5 -3
  422. package/dist/fonts/google.d.ts.map +1 -1
  423. package/dist/fonts/local.d.ts +5 -5
  424. package/dist/fonts/local.d.ts.map +1 -1
  425. package/dist/fonts/paths.d.ts +43 -0
  426. package/dist/fonts/paths.d.ts.map +1 -0
  427. package/dist/fonts/pipeline.d.ts +177 -0
  428. package/dist/fonts/pipeline.d.ts.map +1 -0
  429. package/dist/fonts/transform.d.ts +82 -0
  430. package/dist/fonts/transform.d.ts.map +1 -0
  431. package/dist/fonts/types.d.ts +47 -1
  432. package/dist/fonts/types.d.ts.map +1 -1
  433. package/dist/fonts/virtual-modules.d.ts +77 -0
  434. package/dist/fonts/virtual-modules.d.ts.map +1 -0
  435. package/dist/index.d.ts +35 -181
  436. package/dist/index.d.ts.map +1 -1
  437. package/dist/index.js +8844 -14244
  438. package/dist/index.js.map +1 -1
  439. package/dist/params/codec-registry.d.ts +26 -0
  440. package/dist/params/codec-registry.d.ts.map +1 -0
  441. package/dist/params/define-schema.d.ts +81 -0
  442. package/dist/params/define-schema.d.ts.map +1 -0
  443. package/dist/params/index.d.ts +5 -0
  444. package/dist/params/index.d.ts.map +1 -0
  445. package/dist/params/index.js +34 -0
  446. package/dist/params/index.js.map +1 -0
  447. package/dist/params/resolve-schema.d.ts +34 -0
  448. package/dist/params/resolve-schema.d.ts.map +1 -0
  449. package/dist/plugin-context.d.ts +262 -0
  450. package/dist/plugin-context.d.ts.map +1 -0
  451. package/dist/plugins/build-manifest.d.ts +7 -3
  452. package/dist/plugins/build-manifest.d.ts.map +1 -1
  453. package/dist/plugins/build-report.d.ts +61 -11
  454. package/dist/plugins/build-report.d.ts.map +1 -1
  455. package/dist/plugins/cache.d.ts +64 -0
  456. package/dist/plugins/cache.d.ts.map +1 -0
  457. package/dist/plugins/callsite-ast.d.ts +117 -0
  458. package/dist/plugins/callsite-ast.d.ts.map +1 -0
  459. package/dist/plugins/callsite-jsx.d.ts +35 -0
  460. package/dist/plugins/callsite-jsx.d.ts.map +1 -0
  461. package/dist/plugins/chunks.d.ts +11 -4
  462. package/dist/plugins/chunks.d.ts.map +1 -1
  463. package/dist/plugins/client-chunks.d.ts +40 -0
  464. package/dist/plugins/client-chunks.d.ts.map +1 -0
  465. package/dist/plugins/cloudflare-wasm.d.ts +21 -0
  466. package/dist/plugins/cloudflare-wasm.d.ts.map +1 -0
  467. package/dist/plugins/content.d.ts +1 -1
  468. package/dist/plugins/content.d.ts.map +1 -1
  469. package/dist/plugins/dev-discovery.d.ts +123 -0
  470. package/dist/plugins/dev-discovery.d.ts.map +1 -0
  471. package/dist/plugins/dev-server.d.ts +24 -1
  472. package/dist/plugins/dev-server.d.ts.map +1 -1
  473. package/dist/plugins/entries.d.ts +28 -4
  474. package/dist/plugins/entries.d.ts.map +1 -1
  475. package/dist/plugins/fonts.d.ts +35 -74
  476. package/dist/plugins/fonts.d.ts.map +1 -1
  477. package/dist/plugins/graph-endpoint.d.ts +112 -0
  478. package/dist/plugins/graph-endpoint.d.ts.map +1 -0
  479. package/dist/plugins/mdx.d.ts +18 -5
  480. package/dist/plugins/mdx.d.ts.map +1 -1
  481. package/dist/plugins/post-build.d.ts +110 -0
  482. package/dist/plugins/post-build.d.ts.map +1 -0
  483. package/dist/plugins/prebuilt-capture.d.ts +67 -0
  484. package/dist/plugins/prebuilt-capture.d.ts.map +1 -0
  485. package/dist/plugins/prebuilt-options-analysis.d.ts +40 -0
  486. package/dist/plugins/prebuilt-options-analysis.d.ts.map +1 -0
  487. package/dist/plugins/prebuilt.d.ts +98 -0
  488. package/dist/plugins/prebuilt.d.ts.map +1 -0
  489. package/dist/plugins/prerender-sugar.d.ts +39 -0
  490. package/dist/plugins/prerender-sugar.d.ts.map +1 -0
  491. package/dist/plugins/react-resolve.d.ts +49 -0
  492. package/dist/plugins/react-resolve.d.ts.map +1 -0
  493. package/dist/plugins/request-dep/analysis.d.ts +106 -0
  494. package/dist/plugins/request-dep/analysis.d.ts.map +1 -0
  495. package/dist/plugins/request-dep/index.d.ts +75 -0
  496. package/dist/plugins/request-dep/index.d.ts.map +1 -0
  497. package/dist/plugins/request-dep/origin.d.ts +61 -0
  498. package/dist/plugins/request-dep/origin.d.ts.map +1 -0
  499. package/dist/plugins/routing.d.ts +1 -1
  500. package/dist/plugins/routing.d.ts.map +1 -1
  501. package/dist/plugins/rsc-assets-manifest.d.ts +33 -0
  502. package/dist/plugins/rsc-assets-manifest.d.ts.map +1 -0
  503. package/dist/plugins/server-bundle.d.ts.map +1 -1
  504. package/dist/plugins/shims.d.ts +29 -5
  505. package/dist/plugins/shims.d.ts.map +1 -1
  506. package/dist/plugins/static-build.d.ts +246 -26
  507. package/dist/plugins/static-build.d.ts.map +1 -1
  508. package/dist/routing/codegen-shared.d.ts +26 -0
  509. package/dist/routing/codegen-shared.d.ts.map +1 -0
  510. package/dist/routing/codegen-types.d.ts +61 -0
  511. package/dist/routing/codegen-types.d.ts.map +1 -0
  512. package/dist/routing/codegen-write.d.ts +42 -0
  513. package/dist/routing/codegen-write.d.ts.map +1 -0
  514. package/dist/routing/codegen.d.ts +8 -3
  515. package/dist/routing/codegen.d.ts.map +1 -1
  516. package/dist/routing/collision-probe.d.ts +104 -0
  517. package/dist/routing/collision-probe.d.ts.map +1 -0
  518. package/dist/routing/collision-spaces.d.ts +26 -0
  519. package/dist/routing/collision-spaces.d.ts.map +1 -0
  520. package/dist/routing/convention-lint.d.ts +55 -0
  521. package/dist/routing/convention-lint.d.ts.map +1 -0
  522. package/dist/routing/export-detect.d.ts +91 -0
  523. package/dist/routing/export-detect.d.ts.map +1 -0
  524. package/dist/routing/file-cache.d.ts +8 -0
  525. package/dist/routing/file-cache.d.ts.map +1 -0
  526. package/dist/routing/index.d.ts +13 -7
  527. package/dist/routing/index.d.ts.map +1 -1
  528. package/dist/routing/index.js +5 -2
  529. package/dist/routing/interception-overlap.d.ts +35 -0
  530. package/dist/routing/interception-overlap.d.ts.map +1 -0
  531. package/dist/routing/interception.d.ts +234 -10
  532. package/dist/routing/interception.d.ts.map +1 -1
  533. package/dist/routing/link-codegen.d.ts +105 -0
  534. package/dist/routing/link-codegen.d.ts.map +1 -0
  535. package/dist/routing/manifest-codegen.d.ts +26 -0
  536. package/dist/routing/manifest-codegen.d.ts.map +1 -0
  537. package/dist/routing/scanner.d.ts +14 -10
  538. package/dist/routing/scanner.d.ts.map +1 -1
  539. package/dist/routing/schema-validation.d.ts +35 -0
  540. package/dist/routing/schema-validation.d.ts.map +1 -0
  541. package/dist/routing/segment-classify.d.ts +114 -0
  542. package/dist/routing/segment-classify.d.ts.map +1 -0
  543. package/dist/routing/segment-codegen.d.ts +38 -0
  544. package/dist/routing/segment-codegen.d.ts.map +1 -0
  545. package/dist/routing/segment-keys.d.ts +118 -0
  546. package/dist/routing/segment-keys.d.ts.map +1 -0
  547. package/dist/routing/slot-placement.d.ts +48 -0
  548. package/dist/routing/slot-placement.d.ts.map +1 -0
  549. package/dist/routing/types.d.ts +81 -26
  550. package/dist/routing/types.d.ts.map +1 -1
  551. package/dist/routing/walkers.d.ts +57 -0
  552. package/dist/routing/walkers.d.ts.map +1 -0
  553. package/dist/rsc-runtime/rsc.d.ts +1 -1
  554. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  555. package/dist/rsc-runtime/ssr.d.ts +14 -0
  556. package/dist/rsc-runtime/ssr.d.ts.map +1 -1
  557. package/dist/rsc-runtime/transforms.d.ts +13 -0
  558. package/dist/rsc-runtime/transforms.d.ts.map +1 -0
  559. package/dist/schema-bridge.d.ts +145 -0
  560. package/dist/schema-bridge.d.ts.map +1 -0
  561. package/dist/search-params/define.d.ts +262 -0
  562. package/dist/search-params/define.d.ts.map +1 -0
  563. package/dist/search-params/index.d.ts +3 -7
  564. package/dist/search-params/index.d.ts.map +1 -1
  565. package/dist/search-params/index.js +179 -360
  566. package/dist/search-params/index.js.map +1 -1
  567. package/dist/search-params/parse-total.d.ts +81 -0
  568. package/dist/search-params/parse-total.d.ts.map +1 -0
  569. package/dist/search-params/serialize-equal.d.ts +9 -0
  570. package/dist/search-params/serialize-equal.d.ts.map +1 -0
  571. package/dist/search-params/wrappers.d.ts +76 -0
  572. package/dist/search-params/wrappers.d.ts.map +1 -0
  573. package/dist/server/access-gate.d.ts +98 -10
  574. package/dist/server/access-gate.d.ts.map +1 -1
  575. package/dist/server/action-client.d.ts +44 -9
  576. package/dist/server/action-client.d.ts.map +1 -1
  577. package/dist/server/action-encryption.d.ts +76 -0
  578. package/dist/server/action-encryption.d.ts.map +1 -0
  579. package/dist/server/action-handler.d.ts +40 -5
  580. package/dist/server/action-handler.d.ts.map +1 -1
  581. package/dist/server/actions.d.ts +78 -40
  582. package/dist/server/actions.d.ts.map +1 -1
  583. package/dist/server/als-registry.d.ts +166 -16
  584. package/dist/server/als-registry.d.ts.map +1 -1
  585. package/dist/server/body-limits.d.ts.map +1 -1
  586. package/dist/server/build-manifest.d.ts +25 -30
  587. package/dist/server/build-manifest.d.ts.map +1 -1
  588. package/dist/server/canonicalize.d.ts +10 -0
  589. package/dist/server/canonicalize.d.ts.map +1 -1
  590. package/dist/server/chain-url-parts.d.ts +82 -0
  591. package/dist/server/chain-url-parts.d.ts.map +1 -0
  592. package/dist/server/children-interception.d.ts +49 -0
  593. package/dist/server/children-interception.d.ts.map +1 -0
  594. package/dist/server/coalesce-tick.d.ts +40 -0
  595. package/dist/server/coalesce-tick.d.ts.map +1 -0
  596. package/dist/server/compress.d.ts.map +1 -1
  597. package/dist/server/cookie-context.d.ts +149 -0
  598. package/dist/server/cookie-context.d.ts.map +1 -0
  599. package/dist/server/cookie-parsing.d.ts +65 -0
  600. package/dist/server/cookie-parsing.d.ts.map +1 -0
  601. package/dist/server/csp-nonce.d.ts +36 -0
  602. package/dist/server/csp-nonce.d.ts.map +1 -0
  603. package/dist/server/csrf.d.ts +58 -15
  604. package/dist/server/csrf.d.ts.map +1 -1
  605. package/dist/server/debug.d.ts +0 -1
  606. package/dist/server/debug.d.ts.map +1 -1
  607. package/dist/server/default-logger.d.ts +23 -0
  608. package/dist/server/default-logger.d.ts.map +1 -0
  609. package/dist/server/default-status-page.d.ts +45 -0
  610. package/dist/server/default-status-page.d.ts.map +1 -0
  611. package/dist/server/deny-boundary.d.ts +257 -0
  612. package/dist/server/deny-boundary.d.ts.map +1 -0
  613. package/dist/server/deny-renderer.d.ts +21 -15
  614. package/dist/server/deny-renderer.d.ts.map +1 -1
  615. package/dist/server/early-hints-sender.d.ts.map +1 -1
  616. package/dist/server/early-hints.d.ts +14 -12
  617. package/dist/server/early-hints.d.ts.map +1 -1
  618. package/dist/server/error-boundary-wrapper.d.ts +102 -10
  619. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  620. package/dist/server/error-response-headers.d.ts +3 -0
  621. package/dist/server/error-response-headers.d.ts.map +1 -0
  622. package/dist/server/fallback-error.d.ts +19 -7
  623. package/dist/server/fallback-error.d.ts.map +1 -1
  624. package/dist/server/flight-injection-state.d.ts +66 -0
  625. package/dist/server/flight-injection-state.d.ts.map +1 -0
  626. package/dist/server/flight-scripts.d.ts +45 -0
  627. package/dist/server/flight-scripts.d.ts.map +1 -0
  628. package/dist/server/form-data.d.ts +41 -0
  629. package/dist/server/form-data.d.ts.map +1 -1
  630. package/dist/server/form-flash.d.ts +2 -2
  631. package/dist/server/head-response.d.ts +35 -0
  632. package/dist/server/head-response.d.ts.map +1 -0
  633. package/dist/server/html-injector-core.d.ts +257 -0
  634. package/dist/server/html-injector-core.d.ts.map +1 -0
  635. package/dist/server/html-injectors.d.ts +84 -42
  636. package/dist/server/html-injectors.d.ts.map +1 -1
  637. package/dist/server/index.d.ts +17 -54
  638. package/dist/server/index.d.ts.map +1 -1
  639. package/dist/server/index.js +195 -2922
  640. package/dist/server/index.js.map +1 -1
  641. package/dist/server/instrumentation.d.ts +11 -4
  642. package/dist/server/instrumentation.d.ts.map +1 -1
  643. package/dist/server/internal.d.ts +47 -0
  644. package/dist/server/internal.d.ts.map +1 -0
  645. package/dist/server/internal.js +4645 -0
  646. package/dist/server/internal.js.map +1 -0
  647. package/dist/server/json-status-response.d.ts +34 -0
  648. package/dist/server/json-status-response.d.ts.map +1 -0
  649. package/dist/server/logger.d.ts +78 -7
  650. package/dist/server/logger.d.ts.map +1 -1
  651. package/dist/server/metadata-collector.d.ts +73 -0
  652. package/dist/server/metadata-collector.d.ts.map +1 -0
  653. package/dist/server/metadata-platform.d.ts +2 -2
  654. package/dist/server/metadata-render.d.ts +2 -2
  655. package/dist/server/metadata-render.d.ts.map +1 -1
  656. package/dist/server/metadata-routes.d.ts +71 -11
  657. package/dist/server/metadata-routes.d.ts.map +1 -1
  658. package/dist/server/metadata-social.d.ts +2 -2
  659. package/dist/server/metadata.d.ts +10 -2
  660. package/dist/server/metadata.d.ts.map +1 -1
  661. package/dist/server/middleware-runner.d.ts +20 -5
  662. package/dist/server/middleware-runner.d.ts.map +1 -1
  663. package/dist/server/node-stream-transforms.d.ts +105 -0
  664. package/dist/server/node-stream-transforms.d.ts.map +1 -0
  665. package/dist/server/nuqs-ssr-provider.d.ts +7 -3
  666. package/dist/server/nuqs-ssr-provider.d.ts.map +1 -1
  667. package/dist/server/param-coercion.d.ts +83 -0
  668. package/dist/server/param-coercion.d.ts.map +1 -0
  669. package/dist/server/pipeline-helpers.d.ts +193 -0
  670. package/dist/server/pipeline-helpers.d.ts.map +1 -0
  671. package/dist/server/pipeline-interception.d.ts +70 -9
  672. package/dist/server/pipeline-interception.d.ts.map +1 -1
  673. package/dist/server/pipeline-metadata.d.ts +7 -1
  674. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  675. package/dist/server/pipeline-outcome.d.ts +59 -0
  676. package/dist/server/pipeline-outcome.d.ts.map +1 -0
  677. package/dist/server/pipeline-phases.d.ts +70 -0
  678. package/dist/server/pipeline-phases.d.ts.map +1 -0
  679. package/dist/server/pipeline.d.ts +147 -23
  680. package/dist/server/pipeline.d.ts.map +1 -1
  681. package/dist/server/port-resolution.d.ts +31 -0
  682. package/dist/server/port-resolution.d.ts.map +1 -0
  683. package/dist/server/prebuilt/cache-key.d.ts +63 -0
  684. package/dist/server/prebuilt/cache-key.d.ts.map +1 -0
  685. package/dist/server/prebuilt/capture-render.d.ts +25 -0
  686. package/dist/server/prebuilt/capture-render.d.ts.map +1 -0
  687. package/dist/server/prebuilt/capture-routes.d.ts +37 -0
  688. package/dist/server/prebuilt/capture-routes.d.ts.map +1 -0
  689. package/dist/server/prebuilt/capture-state.d.ts +101 -0
  690. package/dist/server/prebuilt/capture-state.d.ts.map +1 -0
  691. package/dist/server/prebuilt/key-discipline.d.ts +52 -0
  692. package/dist/server/prebuilt/key-discipline.d.ts.map +1 -0
  693. package/dist/server/prebuilt/lifetime.d.ts +38 -0
  694. package/dist/server/prebuilt/lifetime.d.ts.map +1 -0
  695. package/dist/server/prebuilt/manifest-tag-index.d.ts +27 -0
  696. package/dist/server/prebuilt/manifest-tag-index.d.ts.map +1 -0
  697. package/dist/server/prebuilt/overlay.d.ts +100 -0
  698. package/dist/server/prebuilt/overlay.d.ts.map +1 -0
  699. package/dist/server/prebuilt/payload-source.d.ts +79 -0
  700. package/dist/server/prebuilt/payload-source.d.ts.map +1 -0
  701. package/dist/server/prebuilt/slots.d.ts +106 -0
  702. package/dist/server/prebuilt/slots.d.ts.map +1 -0
  703. package/dist/server/prebuilt/synthetic-store.d.ts +67 -0
  704. package/dist/server/prebuilt/synthetic-store.d.ts.map +1 -0
  705. package/dist/server/prebuilt-builder.d.ts +121 -0
  706. package/dist/server/prebuilt-builder.d.ts.map +1 -0
  707. package/dist/server/prebuilt-runtime.d.ts +111 -0
  708. package/dist/server/prebuilt-runtime.d.ts.map +1 -0
  709. package/dist/server/primitives.d.ts +101 -90
  710. package/dist/server/primitives.d.ts.map +1 -1
  711. package/dist/server/publish-params.d.ts +33 -0
  712. package/dist/server/publish-params.d.ts.map +1 -0
  713. package/dist/server/react-cache-bridge.d.ts +59 -0
  714. package/dist/server/react-cache-bridge.d.ts.map +1 -0
  715. package/dist/server/react-cache-scope.d.ts +49 -0
  716. package/dist/server/react-cache-scope.d.ts.map +1 -0
  717. package/dist/server/render-timeout.d.ts +66 -0
  718. package/dist/server/render-timeout.d.ts.map +1 -0
  719. package/dist/server/render-utils.d.ts +35 -0
  720. package/dist/server/render-utils.d.ts.map +1 -0
  721. package/dist/server/request-context.d.ts +128 -103
  722. package/dist/server/request-context.d.ts.map +1 -1
  723. package/dist/server/request-dep.d.ts +15 -0
  724. package/dist/server/request-dep.d.ts.map +1 -0
  725. package/dist/server/response-cache-policy.d.ts +3 -0
  726. package/dist/server/response-cache-policy.d.ts.map +1 -0
  727. package/dist/server/route-element-builder.d.ts +57 -30
  728. package/dist/server/route-element-builder.d.ts.map +1 -1
  729. package/dist/server/route-element-helpers.d.ts +12 -0
  730. package/dist/server/route-element-helpers.d.ts.map +1 -0
  731. package/dist/server/route-handler.d.ts +1 -1
  732. package/dist/server/route-handler.d.ts.map +1 -1
  733. package/dist/server/route-matcher.d.ts +55 -38
  734. package/dist/server/route-matcher.d.ts.map +1 -1
  735. package/dist/server/route-module-loader.d.ts +37 -0
  736. package/dist/server/route-module-loader.d.ts.map +1 -0
  737. package/dist/server/rsc-cache-key-guard.d.ts +78 -0
  738. package/dist/server/rsc-cache-key-guard.d.ts.map +1 -0
  739. package/dist/server/rsc-entry/action-dispatcher.d.ts +67 -0
  740. package/dist/server/rsc-entry/action-dispatcher.d.ts.map +1 -0
  741. package/dist/server/rsc-entry/action-middleware-runner.d.ts +66 -0
  742. package/dist/server/rsc-entry/action-middleware-runner.d.ts.map +1 -0
  743. package/dist/server/rsc-entry/api-handler.d.ts +19 -3
  744. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  745. package/dist/server/rsc-entry/deny-fallback.d.ts +55 -0
  746. package/dist/server/rsc-entry/deny-fallback.d.ts.map +1 -0
  747. package/dist/server/rsc-entry/error-renderer.d.ts +35 -21
  748. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  749. package/dist/server/rsc-entry/helpers.d.ts +14 -59
  750. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  751. package/dist/server/rsc-entry/index.d.ts +30 -6
  752. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  753. package/dist/server/rsc-entry/render-route.d.ts +50 -0
  754. package/dist/server/rsc-entry/render-route.d.ts.map +1 -0
  755. package/dist/server/rsc-entry/render-signals.d.ts +65 -0
  756. package/dist/server/rsc-entry/render-signals.d.ts.map +1 -0
  757. package/dist/server/rsc-entry/revalidate-renderer.d.ts +98 -0
  758. package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -0
  759. package/dist/server/rsc-entry/rsc-payload.d.ts +30 -6
  760. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  761. package/dist/server/rsc-entry/rsc-stream.d.ts +12 -30
  762. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  763. package/dist/server/rsc-entry/ssr-bridge.d.ts +6 -2
  764. package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
  765. package/dist/server/rsc-entry/ssr-renderer.d.ts +44 -7
  766. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  767. package/dist/server/rsc-error-envelope.d.ts +11 -0
  768. package/dist/server/rsc-error-envelope.d.ts.map +1 -0
  769. package/dist/server/safe-load.d.ts +39 -0
  770. package/dist/server/safe-load.d.ts.map +1 -0
  771. package/dist/server/sensitive-fields.d.ts +74 -0
  772. package/dist/server/sensitive-fields.d.ts.map +1 -0
  773. package/dist/server/signal-identity.d.ts +43 -0
  774. package/dist/server/signal-identity.d.ts.map +1 -0
  775. package/dist/server/sitemap-generator.d.ts +130 -0
  776. package/dist/server/sitemap-generator.d.ts.map +1 -0
  777. package/dist/server/sitemap-handler.d.ts +22 -0
  778. package/dist/server/sitemap-handler.d.ts.map +1 -0
  779. package/dist/server/skippable-prefix.d.ts +29 -0
  780. package/dist/server/skippable-prefix.d.ts.map +1 -0
  781. package/dist/server/slot-interception.d.ts +80 -0
  782. package/dist/server/slot-interception.d.ts.map +1 -0
  783. package/dist/server/slot-resolver.d.ts +138 -7
  784. package/dist/server/slot-resolver.d.ts.map +1 -1
  785. package/dist/server/slot-subtree-contain.d.ts +54 -0
  786. package/dist/server/slot-subtree-contain.d.ts.map +1 -0
  787. package/dist/server/ssr-bridge-types.d.ts +198 -0
  788. package/dist/server/ssr-bridge-types.d.ts.map +1 -0
  789. package/dist/server/ssr-entry.d.ts +8 -47
  790. package/dist/server/ssr-entry.d.ts.map +1 -1
  791. package/dist/server/ssr-render.d.ts +60 -27
  792. package/dist/server/ssr-render.d.ts.map +1 -1
  793. package/dist/server/ssr-wrappers.d.ts +93 -0
  794. package/dist/server/ssr-wrappers.d.ts.map +1 -0
  795. package/dist/server/state-tree-diff.d.ts +44 -9
  796. package/dist/server/state-tree-diff.d.ts.map +1 -1
  797. package/dist/server/static-generator.d.ts +112 -0
  798. package/dist/server/static-generator.d.ts.map +1 -0
  799. package/dist/server/static-not-found.d.ts +52 -0
  800. package/dist/server/static-not-found.d.ts.map +1 -0
  801. package/dist/server/status-code-resolver.d.ts +26 -15
  802. package/dist/server/status-code-resolver.d.ts.map +1 -1
  803. package/dist/server/stream-utils.d.ts +59 -0
  804. package/dist/server/stream-utils.d.ts.map +1 -0
  805. package/dist/server/tracing.d.ts +57 -26
  806. package/dist/server/tracing.d.ts.map +1 -1
  807. package/dist/server/tree-match.d.ts +59 -0
  808. package/dist/server/tree-match.d.ts.map +1 -0
  809. package/dist/server/types.d.ts +89 -8
  810. package/dist/server/types.d.ts.map +1 -1
  811. package/dist/server/utils/element-type.d.ts +50 -0
  812. package/dist/server/utils/element-type.d.ts.map +1 -0
  813. package/dist/server/utils/escape-html.d.ts +14 -0
  814. package/dist/server/utils/escape-html.d.ts.map +1 -0
  815. package/dist/server/version-skew.d.ts +61 -0
  816. package/dist/server/version-skew.d.ts.map +1 -0
  817. package/dist/server/workers-cache-bridge.d.ts +26 -0
  818. package/dist/server/workers-cache-bridge.d.ts.map +1 -0
  819. package/dist/shared/als-slots.d.ts +42 -0
  820. package/dist/shared/als-slots.d.ts.map +1 -0
  821. package/dist/shared/base-path.d.ts +56 -0
  822. package/dist/shared/base-path.d.ts.map +1 -0
  823. package/dist/shared/csrf-reject.d.ts +16 -0
  824. package/dist/shared/csrf-reject.d.ts.map +1 -0
  825. package/dist/shared/error-digest.d.ts +28 -0
  826. package/dist/shared/error-digest.d.ts.map +1 -0
  827. package/dist/shared/href-validation.d.ts +49 -0
  828. package/dist/shared/href-validation.d.ts.map +1 -0
  829. package/dist/shared/merge-search-params.d.ts +22 -0
  830. package/dist/shared/merge-search-params.d.ts.map +1 -0
  831. package/dist/shared/param-value.d.ts +104 -0
  832. package/dist/shared/param-value.d.ts.map +1 -0
  833. package/dist/shared/payload-root.d.ts +110 -0
  834. package/dist/shared/payload-root.d.ts.map +1 -0
  835. package/dist/shared/redirect-type.d.ts +17 -0
  836. package/dist/shared/redirect-type.d.ts.map +1 -0
  837. package/dist/shared/rsc-cache-key.d.ts +163 -0
  838. package/dist/shared/rsc-cache-key.d.ts.map +1 -0
  839. package/dist/shared/rsc-error-envelope.d.ts +16 -0
  840. package/dist/shared/rsc-error-envelope.d.ts.map +1 -0
  841. package/dist/shared/rsc-manifest.d.ts +28 -0
  842. package/dist/shared/rsc-manifest.d.ts.map +1 -0
  843. package/dist/shared/rsc-media-type.d.ts +52 -0
  844. package/dist/shared/rsc-media-type.d.ts.map +1 -0
  845. package/dist/shared/rsc-payload-path.d.ts +48 -0
  846. package/dist/shared/rsc-payload-path.d.ts.map +1 -0
  847. package/dist/shared/segment-info.d.ts +66 -0
  848. package/dist/shared/segment-info.d.ts.map +1 -0
  849. package/dist/shared/slot-params.d.ts +52 -0
  850. package/dist/shared/slot-params.d.ts.map +1 -0
  851. package/dist/shared/static-platform-files.d.ts +71 -0
  852. package/dist/shared/static-platform-files.d.ts.map +1 -0
  853. package/dist/shared/status-reason-phrase.d.ts +26 -0
  854. package/dist/shared/status-reason-phrase.d.ts.map +1 -0
  855. package/dist/shims/font-google.d.ts +1 -1
  856. package/dist/shims/font-google.d.ts.map +1 -1
  857. package/dist/shims/font-google.js +42 -0
  858. package/dist/shims/font-google.js.map +1 -0
  859. package/dist/shims/font-local.d.ts +26 -0
  860. package/dist/shims/font-local.d.ts.map +1 -0
  861. package/dist/shims/font-local.js +20 -0
  862. package/dist/shims/font-local.js.map +1 -0
  863. package/dist/shims/headers.d.ts +53 -1
  864. package/dist/shims/headers.d.ts.map +1 -1
  865. package/dist/shims/image.d.ts +120 -120
  866. package/dist/shims/image.d.ts.map +1 -1
  867. package/dist/shims/navigation-client.d.ts +25 -12
  868. package/dist/shims/navigation-client.d.ts.map +1 -1
  869. package/dist/shims/navigation-rsc.d.ts +21 -0
  870. package/dist/shims/navigation-rsc.d.ts.map +1 -0
  871. package/dist/shims/navigation.d.ts +10 -5
  872. package/dist/shims/navigation.d.ts.map +1 -1
  873. package/dist/utils/state-machine.d.ts +80 -0
  874. package/dist/utils/state-machine.d.ts.map +1 -0
  875. package/dist/utils/write-file-atomic.d.ts +17 -0
  876. package/dist/utils/write-file-atomic.d.ts.map +1 -0
  877. package/docs/api/30-api-server.mdx +239 -0
  878. package/docs/api/31-api-client.mdx +170 -0
  879. package/docs/api/32-api-cache.mdx +339 -0
  880. package/docs/api/33-api-search-params.mdx +176 -0
  881. package/docs/api/34-api-config.mdx +359 -0
  882. package/docs/api/35-api-typescript.mdx +91 -0
  883. package/docs/api/36-cli.mdx +202 -0
  884. package/docs/learn/00-introduction.mdx +109 -0
  885. package/docs/learn/01-quick-start.mdx +94 -0
  886. package/docs/learn/02-pages-and-layouts.mdx +147 -0
  887. package/docs/learn/03-fetching-data.mdx +227 -0
  888. package/docs/learn/04-access-control.mdx +115 -0
  889. package/docs/learn/05-the-flush-point.mdx +175 -0
  890. package/docs/learn/06-typed-params.mdx +275 -0
  891. package/docs/learn/07-typed-routes.mdx +108 -0
  892. package/docs/learn/08-forms-and-actions.mdx +146 -0
  893. package/docs/learn/09-streaming.mdx +140 -0
  894. package/docs/learn/10-caching.mdx +270 -0
  895. package/docs/learn/11-middleware.mdx +164 -0
  896. package/docs/learn/12-error-handling.mdx +192 -0
  897. package/docs/learn/13-deploying.mdx +287 -0
  898. package/llms.txt +55 -0
  899. package/package.json +120 -29
  900. package/src/adapters/build-output-helper.ts +353 -0
  901. package/src/adapters/canonicalize-module.ts +29 -0
  902. package/src/adapters/cloudflare-dev.ts +183 -0
  903. package/src/adapters/cloudflare-kv-cache.ts +207 -0
  904. package/src/adapters/cloudflare.ts +809 -150
  905. package/src/adapters/compress-module.ts +110 -86
  906. package/src/adapters/fs-identity.ts +155 -0
  907. package/src/adapters/nitro-presets.ts +124 -0
  908. package/src/adapters/nitro-preview.ts +476 -0
  909. package/src/adapters/nitro.ts +317 -457
  910. package/src/adapters/raw-imports.d.ts +5 -0
  911. package/src/adapters/shared.ts +283 -0
  912. package/src/adapters/types.ts +127 -17
  913. package/src/adapters/wrangler.d.ts +7 -0
  914. package/src/analyze/chains.ts +411 -0
  915. package/src/analyze/classify.ts +259 -0
  916. package/src/analyze/crawl-entry.ts +68 -0
  917. package/src/analyze/crawl.ts +500 -0
  918. package/src/analyze/graph-cache.ts +331 -0
  919. package/src/analyze/graph-command.ts +762 -0
  920. package/src/analyze/live-graph.ts +232 -0
  921. package/src/analyze/poison-rules.ts +165 -0
  922. package/src/analyze/poison-scan.ts +162 -0
  923. package/src/analyze/scan.ts +149 -0
  924. package/src/cache/cache-api.ts +107 -0
  925. package/src/cache/fast-hash.ts +5 -0
  926. package/src/cache/handler-store.ts +76 -0
  927. package/src/cache/index.ts +115 -22
  928. package/src/cache/invalidation-epoch.ts +93 -0
  929. package/src/cache/json-lossy-check.ts +69 -0
  930. package/src/cache/redis-handler.ts +198 -20
  931. package/src/cache/singleflight.ts +72 -6
  932. package/src/cache/sizeof.ts +35 -0
  933. package/src/cache/stable-stringify.ts +65 -2
  934. package/src/cache/store.ts +71 -0
  935. package/src/cache/stores/cloudflare-kv.ts +52 -0
  936. package/src/cache/stores/memory.ts +125 -0
  937. package/src/cache/stores/redis.ts +97 -0
  938. package/src/cache/stores/vercel.ts +59 -0
  939. package/src/cache/tag-aware-handler.ts +254 -0
  940. package/src/cache/timber-cache.ts +165 -40
  941. package/src/cdn/cloudflare-purge.ts +50 -0
  942. package/src/cdn/fastly-purge.ts +63 -0
  943. package/src/cdn/headers.ts +153 -0
  944. package/src/cdn/index.ts +23 -0
  945. package/src/cdn/purge-store.ts +34 -0
  946. package/src/cdn/workers-cache-purge.ts +34 -0
  947. package/src/cli-check.ts +417 -0
  948. package/src/cli-context.ts +119 -0
  949. package/src/cli-schema-sync.ts +401 -0
  950. package/src/cli.ts +330 -78
  951. package/src/client/browser-dev.ts +192 -5
  952. package/src/client/browser-entry/action-dispatch.ts +237 -0
  953. package/src/client/browser-entry/action-queue.ts +152 -0
  954. package/src/client/browser-entry/hmr.ts +70 -0
  955. package/src/client/browser-entry/hydrate.ts +143 -0
  956. package/src/client/browser-entry/index.ts +120 -0
  957. package/src/client/browser-entry/post-hydration.ts +99 -0
  958. package/src/client/browser-entry/router-init.ts +406 -0
  959. package/src/client/browser-entry/rsc-stream.ts +145 -0
  960. package/src/client/browser-entry/scroll.ts +50 -0
  961. package/src/client/deny-last-resort.tsx +54 -0
  962. package/src/client/error-boundary.tsx +279 -61
  963. package/src/client/error-reconstituter.tsx +84 -0
  964. package/src/client/form.tsx +36 -32
  965. package/src/client/global-context.ts +31 -0
  966. package/src/client/history.ts +74 -11
  967. package/src/client/index.ts +89 -53
  968. package/src/client/internal.ts +54 -0
  969. package/src/client/link.tsx +468 -151
  970. package/src/client/location-search.ts +15 -0
  971. package/src/client/navigation-api.ts +380 -0
  972. package/src/client/navigation-commit.ts +318 -0
  973. package/src/client/navigation-context.ts +67 -134
  974. package/src/client/navigation-root.tsx +236 -0
  975. package/src/client/navigation-transition.ts +337 -0
  976. package/src/client/nuqs-adapter.tsx +21 -9
  977. package/src/client/params-context.ts +187 -0
  978. package/src/client/react-root.ts +82 -0
  979. package/src/client/router-effects.ts +235 -0
  980. package/src/client/router-lifecycle.ts +354 -0
  981. package/src/client/router-pipeline.ts +458 -0
  982. package/src/client/router-ref.ts +3 -3
  983. package/src/client/router-skew.ts +30 -0
  984. package/src/client/router-types.ts +370 -0
  985. package/src/client/router-url.ts +32 -0
  986. package/src/client/router.ts +491 -424
  987. package/src/client/rsc-fetch.ts +510 -109
  988. package/src/client/segment-cache.ts +362 -41
  989. package/src/client/segment-context.ts +7 -4
  990. package/src/client/segment-outlet.tsx +96 -0
  991. package/src/client/segment-update-context.ts +23 -0
  992. package/src/client/shallow-url.ts +22 -0
  993. package/src/client/slot-content-cache-context.ts +43 -0
  994. package/src/client/slot-context.ts +50 -0
  995. package/src/client/slot-outlet.tsx +22 -0
  996. package/src/client/slot-provider.tsx +32 -0
  997. package/src/client/ssr-data.ts +27 -67
  998. package/src/client/stale-client.ts +191 -0
  999. package/src/client/state.ts +31 -24
  1000. package/src/client/status-page-marker.tsx +32 -0
  1001. package/src/client/top-loader.tsx +13 -10
  1002. package/src/client/unload-guard.ts +35 -3
  1003. package/src/client/use-cookie.ts +70 -18
  1004. package/src/client/use-link-status.ts +7 -7
  1005. package/src/client/use-pathname.ts +22 -31
  1006. package/src/client/use-pending-navigation.ts +40 -0
  1007. package/src/client/use-query-states.ts +206 -36
  1008. package/src/client/use-router.ts +31 -9
  1009. package/src/client/use-search-params.ts +38 -49
  1010. package/src/client/use-segment-params.ts +69 -0
  1011. package/src/client/use-selected-layout-segment.ts +2 -2
  1012. package/src/codec.ts +149 -0
  1013. package/src/config-types.ts +323 -0
  1014. package/src/config-validation.ts +464 -0
  1015. package/src/cookies/define-cookie.ts +222 -53
  1016. package/src/cookies/index.ts +13 -2
  1017. package/src/cookies/json-cookie.ts +105 -0
  1018. package/src/cookies/validation.ts +192 -0
  1019. package/src/dev-tools/404-page.ts +286 -0
  1020. package/src/dev-tools/browser-logs.ts +55 -0
  1021. package/src/dev-tools/dev-page-shell.ts +278 -0
  1022. package/src/dev-tools/error-page.ts +331 -0
  1023. package/src/dev-tools/holding-server.ts +185 -0
  1024. package/src/dev-tools/hydration-overlay.ts +158 -0
  1025. package/src/dev-tools/index.ts +79 -0
  1026. package/src/dev-tools/instrumentation.ts +261 -0
  1027. package/src/{server/dev-logger.ts → dev-tools/logger.ts} +33 -51
  1028. package/src/{plugins/dev-logs.ts → dev-tools/logs.ts} +122 -26
  1029. package/src/{plugins/dev-error-overlay.ts → dev-tools/overlay.ts} +25 -80
  1030. package/src/dev-tools/stack-classifier.ts +75 -0
  1031. package/src/dev-tools/terminal.ts +182 -0
  1032. package/src/fonts/ast-walk.ts +235 -0
  1033. package/src/fonts/ast.ts +479 -128
  1034. package/src/fonts/bundle.ts +138 -0
  1035. package/src/fonts/css.ts +1 -1
  1036. package/src/fonts/dev-middleware.ts +85 -0
  1037. package/src/fonts/fallbacks.ts +0 -23
  1038. package/src/fonts/google.ts +101 -19
  1039. package/src/fonts/local.ts +12 -11
  1040. package/src/fonts/paths.ts +58 -0
  1041. package/src/fonts/pipeline.ts +348 -0
  1042. package/src/fonts/transform.ts +311 -0
  1043. package/src/fonts/types.ts +52 -1
  1044. package/src/fonts/virtual-modules.ts +179 -0
  1045. package/src/index.ts +494 -380
  1046. package/src/params/codec-registry.ts +34 -0
  1047. package/src/params/define-schema.ts +115 -0
  1048. package/src/params/index.ts +17 -0
  1049. package/src/params/resolve-schema.ts +84 -0
  1050. package/src/plugin-context.ts +502 -0
  1051. package/src/plugins/build-manifest.ts +204 -36
  1052. package/src/plugins/build-report.ts +299 -87
  1053. package/src/plugins/cache.ts +243 -0
  1054. package/src/plugins/callsite-ast.ts +472 -0
  1055. package/src/plugins/callsite-jsx.ts +243 -0
  1056. package/src/plugins/chunks.ts +74 -5
  1057. package/src/plugins/client-chunks.ts +185 -0
  1058. package/src/plugins/cloudflare-wasm.ts +141 -0
  1059. package/src/plugins/content.ts +5 -1
  1060. package/src/plugins/dev-discovery.ts +218 -0
  1061. package/src/plugins/dev-server.ts +360 -97
  1062. package/src/plugins/entries.ts +142 -16
  1063. package/src/plugins/fonts.ts +260 -657
  1064. package/src/plugins/graph-endpoint.ts +532 -0
  1065. package/src/plugins/mdx.ts +108 -35
  1066. package/src/plugins/post-build.ts +327 -0
  1067. package/src/plugins/prebuilt-capture.ts +213 -0
  1068. package/src/plugins/prebuilt-options-analysis.ts +175 -0
  1069. package/src/plugins/prebuilt.ts +670 -0
  1070. package/src/plugins/prerender-sugar.ts +316 -0
  1071. package/src/plugins/react-resolve.ts +149 -0
  1072. package/src/plugins/request-dep/analysis.ts +447 -0
  1073. package/src/plugins/request-dep/index.ts +376 -0
  1074. package/src/plugins/request-dep/origin.ts +310 -0
  1075. package/src/plugins/routing.ts +273 -277
  1076. package/src/plugins/rsc-assets-manifest.ts +251 -0
  1077. package/src/plugins/server-bundle.ts +99 -14
  1078. package/src/plugins/shims.ts +260 -97
  1079. package/src/plugins/static-build.ts +681 -71
  1080. package/src/react-canary.d.ts +2 -0
  1081. package/src/routing/codegen-shared.ts +39 -0
  1082. package/src/routing/codegen-types.ts +62 -0
  1083. package/src/routing/codegen-write.ts +163 -0
  1084. package/src/routing/codegen.ts +349 -232
  1085. package/src/routing/collision-probe.ts +438 -0
  1086. package/src/routing/collision-spaces.ts +281 -0
  1087. package/src/routing/convention-lint.ts +651 -0
  1088. package/src/routing/export-detect.ts +536 -0
  1089. package/src/routing/file-cache.ts +23 -0
  1090. package/src/routing/index.ts +16 -7
  1091. package/src/routing/interception-overlap.ts +141 -0
  1092. package/src/routing/interception.ts +1044 -67
  1093. package/src/routing/link-codegen.ts +280 -0
  1094. package/src/routing/manifest-codegen.ts +232 -0
  1095. package/src/routing/scanner.ts +417 -223
  1096. package/src/routing/schema-validation.ts +155 -0
  1097. package/src/routing/segment-classify.ts +280 -0
  1098. package/src/routing/segment-codegen.ts +99 -0
  1099. package/src/routing/segment-keys.ts +186 -0
  1100. package/src/routing/slot-placement.ts +97 -0
  1101. package/src/routing/types.ts +82 -26
  1102. package/src/routing/walkers.ts +98 -0
  1103. package/src/rsc-runtime/rsc.ts +9 -0
  1104. package/src/rsc-runtime/ssr.ts +51 -0
  1105. package/src/rsc-runtime/transforms.ts +13 -0
  1106. package/src/rsc-runtime/vendor-types.d.ts +27 -0
  1107. package/src/schema-bridge.ts +382 -0
  1108. package/src/search-params/define.ts +677 -0
  1109. package/src/search-params/index.ts +14 -20
  1110. package/src/search-params/parse-total.ts +91 -0
  1111. package/src/search-params/serialize-equal.ts +14 -0
  1112. package/src/search-params/wrappers.ts +150 -0
  1113. package/src/server/access-gate.tsx +195 -56
  1114. package/src/server/action-client.ts +126 -33
  1115. package/src/server/action-encryption.ts +144 -0
  1116. package/src/server/action-handler.ts +457 -111
  1117. package/src/server/actions.ts +172 -85
  1118. package/src/server/als-registry.ts +224 -25
  1119. package/src/server/body-limits.ts +10 -2
  1120. package/src/server/build-manifest.ts +33 -57
  1121. package/src/server/canonicalize.ts +6 -3
  1122. package/src/server/chain-url-parts.ts +163 -0
  1123. package/src/server/children-interception.ts +116 -0
  1124. package/src/server/coalesce-tick.ts +75 -0
  1125. package/src/server/compress.ts +43 -8
  1126. package/src/server/cookie-context.ts +454 -0
  1127. package/src/server/cookie-parsing.ts +163 -0
  1128. package/src/server/csp-nonce.ts +58 -0
  1129. package/src/server/csrf.ts +228 -35
  1130. package/src/server/debug.ts +0 -1
  1131. package/src/server/default-logger.ts +100 -0
  1132. package/src/server/default-status-page.ts +88 -0
  1133. package/src/server/deny-boundary.ts +527 -0
  1134. package/src/server/deny-renderer.ts +201 -179
  1135. package/src/server/early-hints-sender.ts +4 -3
  1136. package/src/server/early-hints.ts +39 -29
  1137. package/src/server/error-boundary-wrapper.ts +160 -44
  1138. package/src/server/error-response-headers.ts +18 -0
  1139. package/src/server/fallback-error.ts +88 -104
  1140. package/src/server/flight-injection-state.ts +113 -0
  1141. package/src/server/flight-scripts.ts +67 -0
  1142. package/src/server/form-data.ts +124 -12
  1143. package/src/server/form-flash.ts +3 -3
  1144. package/src/server/head-response.ts +54 -0
  1145. package/src/server/html-injector-core.ts +512 -0
  1146. package/src/server/html-injectors.ts +270 -255
  1147. package/src/server/index.ts +36 -192
  1148. package/src/server/instrumentation.ts +11 -4
  1149. package/src/server/internal.ts +168 -0
  1150. package/src/server/json-status-response.ts +105 -0
  1151. package/src/server/logger.ts +126 -38
  1152. package/src/server/metadata-collector.ts +177 -0
  1153. package/src/server/metadata-platform.ts +2 -2
  1154. package/src/server/metadata-render.ts +30 -8
  1155. package/src/server/metadata-routes.ts +220 -24
  1156. package/src/server/metadata-social.ts +2 -2
  1157. package/src/server/metadata.ts +23 -2
  1158. package/src/server/middleware-runner.ts +32 -5
  1159. package/src/server/node-stream-transforms.ts +323 -0
  1160. package/src/server/nuqs-ssr-provider.tsx +8 -7
  1161. package/src/server/param-coercion.ts +201 -0
  1162. package/src/server/pipeline-helpers.ts +485 -0
  1163. package/src/server/pipeline-interception.ts +241 -32
  1164. package/src/server/pipeline-metadata.ts +15 -1
  1165. package/src/server/pipeline-outcome.ts +290 -0
  1166. package/src/server/pipeline-phases.ts +496 -0
  1167. package/src/server/pipeline.ts +385 -427
  1168. package/src/server/port-resolution.ts +53 -0
  1169. package/src/server/prebuilt/cache-key.ts +299 -0
  1170. package/src/server/prebuilt/capture-render.ts +118 -0
  1171. package/src/server/prebuilt/capture-routes.ts +104 -0
  1172. package/src/server/prebuilt/capture-state.ts +196 -0
  1173. package/src/server/prebuilt/key-discipline.ts +122 -0
  1174. package/src/server/prebuilt/lifetime.ts +151 -0
  1175. package/src/server/prebuilt/manifest-tag-index.ts +46 -0
  1176. package/src/server/prebuilt/overlay.ts +256 -0
  1177. package/src/server/prebuilt/payload-source.ts +202 -0
  1178. package/src/server/prebuilt/slots.ts +202 -0
  1179. package/src/server/prebuilt/synthetic-store.ts +125 -0
  1180. package/src/server/prebuilt-builder.ts +514 -0
  1181. package/src/server/prebuilt-runtime.ts +813 -0
  1182. package/src/server/primitives.ts +153 -171
  1183. package/src/server/publish-params.ts +42 -0
  1184. package/src/server/react-cache-bridge.ts +124 -0
  1185. package/src/server/react-cache-scope.ts +104 -0
  1186. package/src/server/render-timeout.ts +128 -0
  1187. package/src/server/render-utils.ts +45 -0
  1188. package/src/server/request-context.ts +269 -332
  1189. package/src/server/request-dep.ts +37 -0
  1190. package/src/server/response-cache-policy.ts +45 -0
  1191. package/src/server/route-element-builder.ts +514 -355
  1192. package/src/server/route-element-helpers.ts +37 -0
  1193. package/src/server/route-handler.ts +67 -27
  1194. package/src/server/route-matcher.ts +238 -267
  1195. package/src/server/route-module-loader.ts +161 -0
  1196. package/src/server/rsc-cache-key-guard.ts +122 -0
  1197. package/src/server/rsc-entry/action-dispatcher.ts +142 -0
  1198. package/src/server/rsc-entry/action-middleware-runner.ts +130 -0
  1199. package/src/server/rsc-entry/api-handler.ts +49 -81
  1200. package/src/server/rsc-entry/deny-fallback.ts +151 -0
  1201. package/src/server/rsc-entry/error-renderer.ts +301 -113
  1202. package/src/server/rsc-entry/helpers.ts +90 -115
  1203. package/src/server/rsc-entry/index.ts +370 -350
  1204. package/src/server/rsc-entry/render-route.ts +229 -0
  1205. package/src/server/rsc-entry/render-signals.ts +108 -0
  1206. package/src/server/rsc-entry/revalidate-renderer.ts +349 -0
  1207. package/src/server/rsc-entry/rsc-payload.ts +192 -72
  1208. package/src/server/rsc-entry/rsc-stream.ts +128 -131
  1209. package/src/server/rsc-entry/ssr-bridge.ts +19 -6
  1210. package/src/server/rsc-entry/ssr-renderer.ts +300 -137
  1211. package/src/server/rsc-error-envelope.ts +18 -0
  1212. package/src/server/rsc-prop-warnings.ts +1 -1
  1213. package/src/server/safe-load.ts +53 -0
  1214. package/src/server/sensitive-fields.ts +230 -0
  1215. package/src/server/server-only-guard-noop.js +3 -0
  1216. package/src/server/server-timing.ts +1 -1
  1217. package/src/server/signal-identity.ts +112 -0
  1218. package/src/server/sitemap-generator.ts +337 -0
  1219. package/src/server/sitemap-handler.ts +157 -0
  1220. package/src/server/skippable-prefix.ts +172 -0
  1221. package/src/server/slot-interception.ts +168 -0
  1222. package/src/server/slot-resolver.ts +707 -300
  1223. package/src/server/slot-subtree-contain.ts +273 -0
  1224. package/src/server/ssr-bridge-types.ts +201 -0
  1225. package/src/server/ssr-entry.ts +225 -104
  1226. package/src/server/ssr-render.ts +354 -91
  1227. package/src/server/ssr-wrappers.tsx +162 -0
  1228. package/src/server/state-tree-diff.ts +85 -30
  1229. package/src/server/static-generator.ts +680 -0
  1230. package/src/server/static-not-found.ts +134 -0
  1231. package/src/server/status-code-resolver.ts +107 -148
  1232. package/src/server/stream-utils.ts +343 -0
  1233. package/src/server/tracing.ts +163 -68
  1234. package/src/server/tree-match.ts +494 -0
  1235. package/src/server/types.ts +96 -11
  1236. package/src/server/utils/element-type.ts +88 -0
  1237. package/src/server/utils/escape-html.ts +20 -0
  1238. package/src/server/version-skew.ts +104 -0
  1239. package/src/server/waituntil-bridge.ts +1 -1
  1240. package/src/server/workers-cache-bridge.ts +33 -0
  1241. package/src/shared/als-slots.ts +74 -0
  1242. package/src/shared/base-path.ts +80 -0
  1243. package/src/shared/csrf-reject.ts +15 -0
  1244. package/src/shared/error-digest.ts +46 -0
  1245. package/src/shared/href-validation.ts +159 -0
  1246. package/src/shared/merge-search-params.ts +55 -0
  1247. package/src/shared/param-value.ts +281 -0
  1248. package/src/shared/payload-root.ts +153 -0
  1249. package/src/shared/redirect-type.ts +17 -0
  1250. package/src/shared/rsc-cache-key.ts +269 -0
  1251. package/src/shared/rsc-error-envelope.ts +16 -0
  1252. package/src/shared/rsc-manifest.ts +29 -0
  1253. package/src/shared/rsc-media-type.ts +59 -0
  1254. package/src/shared/rsc-payload-path.ts +52 -0
  1255. package/src/shared/segment-info.ts +67 -0
  1256. package/src/shared/slot-params.ts +109 -0
  1257. package/src/shared/static-platform-files.ts +75 -0
  1258. package/src/shared/status-reason-phrase.ts +61 -0
  1259. package/src/shims/font-google.ts +1 -1
  1260. package/src/shims/font-local.ts +34 -0
  1261. package/src/shims/headers.ts +122 -1
  1262. package/src/shims/navigation-client.ts +36 -32
  1263. package/src/shims/navigation-rsc.ts +47 -0
  1264. package/src/shims/navigation.ts +10 -7
  1265. package/src/utils/state-machine.ts +111 -0
  1266. package/src/utils/write-file-atomic.ts +32 -0
  1267. package/dist/_chunks/als-registry-B7DbZ2hS.js +0 -41
  1268. package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
  1269. package/dist/_chunks/debug-B3Gypr3D.js +0 -108
  1270. package/dist/_chunks/debug-B3Gypr3D.js.map +0 -1
  1271. package/dist/_chunks/format-RyoGQL74.js +0 -164
  1272. package/dist/_chunks/format-RyoGQL74.js.map +0 -1
  1273. package/dist/_chunks/interception-BOoWmLUA.js +0 -676
  1274. package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
  1275. package/dist/_chunks/metadata-routes-Cjmvi3rQ.js.map +0 -1
  1276. package/dist/_chunks/request-context-BQUC8PHn.js +0 -330
  1277. package/dist/_chunks/request-context-BQUC8PHn.js.map +0 -1
  1278. package/dist/_chunks/ssr-data-MjmprTmO.js +0 -88
  1279. package/dist/_chunks/ssr-data-MjmprTmO.js.map +0 -1
  1280. package/dist/_chunks/tracing-CemImE6h.js +0 -187
  1281. package/dist/_chunks/tracing-CemImE6h.js.map +0 -1
  1282. package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
  1283. package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
  1284. package/dist/_chunks/use-query-states-D5KaffOK.js +0 -109
  1285. package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
  1286. package/dist/adapters/cloudflare.js.map +0 -1
  1287. package/dist/cache/index.js.map +0 -1
  1288. package/dist/cache/register-cached-function.d.ts +0 -17
  1289. package/dist/cache/register-cached-function.d.ts.map +0 -1
  1290. package/dist/client/browser-entry.d.ts +0 -21
  1291. package/dist/client/browser-entry.d.ts.map +0 -1
  1292. package/dist/client/error-boundary.js.map +0 -1
  1293. package/dist/client/head.d.ts +0 -16
  1294. package/dist/client/head.d.ts.map +0 -1
  1295. package/dist/client/link-status-provider.d.ts +0 -11
  1296. package/dist/client/link-status-provider.d.ts.map +0 -1
  1297. package/dist/client/segment-merger.d.ts +0 -119
  1298. package/dist/client/segment-merger.d.ts.map +0 -1
  1299. package/dist/client/stale-reload.d.ts +0 -44
  1300. package/dist/client/stale-reload.d.ts.map +0 -1
  1301. package/dist/client/transition-root.d.ts +0 -74
  1302. package/dist/client/transition-root.d.ts.map +0 -1
  1303. package/dist/client/types.d.ts +0 -14
  1304. package/dist/client/types.d.ts.map +0 -1
  1305. package/dist/client/use-navigation-pending.d.ts +0 -26
  1306. package/dist/client/use-navigation-pending.d.ts.map +0 -1
  1307. package/dist/client/use-params.d.ts +0 -92
  1308. package/dist/client/use-params.d.ts.map +0 -1
  1309. package/dist/content/index.d.ts +0 -11
  1310. package/dist/content/index.d.ts.map +0 -1
  1311. package/dist/content/index.js +0 -2
  1312. package/dist/plugins/adapter-build.d.ts +0 -18
  1313. package/dist/plugins/adapter-build.d.ts.map +0 -1
  1314. package/dist/plugins/cache-transform.d.ts +0 -36
  1315. package/dist/plugins/cache-transform.d.ts.map +0 -1
  1316. package/dist/plugins/dev-error-overlay.d.ts.map +0 -1
  1317. package/dist/plugins/dev-logs.d.ts.map +0 -1
  1318. package/dist/plugins/dynamic-transform.d.ts +0 -72
  1319. package/dist/plugins/dynamic-transform.d.ts.map +0 -1
  1320. package/dist/plugins/server-action-exports.d.ts +0 -26
  1321. package/dist/plugins/server-action-exports.d.ts.map +0 -1
  1322. package/dist/routing/status-file-lint.d.ts +0 -33
  1323. package/dist/routing/status-file-lint.d.ts.map +0 -1
  1324. package/dist/search-params/analyze.d.ts +0 -54
  1325. package/dist/search-params/analyze.d.ts.map +0 -1
  1326. package/dist/search-params/builtin-codecs.d.ts +0 -105
  1327. package/dist/search-params/builtin-codecs.d.ts.map +0 -1
  1328. package/dist/search-params/codecs.d.ts +0 -53
  1329. package/dist/search-params/codecs.d.ts.map +0 -1
  1330. package/dist/search-params/create.d.ts +0 -106
  1331. package/dist/search-params/create.d.ts.map +0 -1
  1332. package/dist/search-params/registry.d.ts +0 -20
  1333. package/dist/search-params/registry.d.ts.map +0 -1
  1334. package/dist/server/asset-headers.d.ts +0 -42
  1335. package/dist/server/asset-headers.d.ts.map +0 -1
  1336. package/dist/server/client-module-map.d.ts +0 -47
  1337. package/dist/server/client-module-map.d.ts.map +0 -1
  1338. package/dist/server/dev-fetch-instrumentation.d.ts +0 -22
  1339. package/dist/server/dev-fetch-instrumentation.d.ts.map +0 -1
  1340. package/dist/server/dev-logger.d.ts.map +0 -1
  1341. package/dist/server/dev-span-processor.d.ts +0 -29
  1342. package/dist/server/dev-span-processor.d.ts.map +0 -1
  1343. package/dist/server/dev-warnings.d.ts +0 -129
  1344. package/dist/server/dev-warnings.d.ts.map +0 -1
  1345. package/dist/server/flush.d.ts +0 -74
  1346. package/dist/server/flush.d.ts.map +0 -1
  1347. package/dist/server/manifest-status-resolver.d.ts +0 -58
  1348. package/dist/server/manifest-status-resolver.d.ts.map +0 -1
  1349. package/dist/server/prerender.d.ts +0 -77
  1350. package/dist/server/prerender.d.ts.map +0 -1
  1351. package/dist/server/tree-builder.d.ts +0 -126
  1352. package/dist/server/tree-builder.d.ts.map +0 -1
  1353. package/dist/utils/directive-parser.d.ts +0 -70
  1354. package/dist/utils/directive-parser.d.ts.map +0 -1
  1355. package/src/cache/register-cached-function.ts +0 -103
  1356. package/src/client/browser-entry.ts +0 -678
  1357. package/src/client/head.ts +0 -61
  1358. package/src/client/link-status-provider.tsx +0 -30
  1359. package/src/client/segment-merger.ts +0 -339
  1360. package/src/client/stale-reload.ts +0 -87
  1361. package/src/client/transition-root.tsx +0 -166
  1362. package/src/client/types.ts +0 -21
  1363. package/src/client/use-navigation-pending.ts +0 -38
  1364. package/src/client/use-params.ts +0 -141
  1365. package/src/content/index.ts +0 -13
  1366. package/src/plugins/adapter-build.ts +0 -118
  1367. package/src/plugins/cache-transform.ts +0 -199
  1368. package/src/plugins/dynamic-transform.ts +0 -161
  1369. package/src/plugins/server-action-exports.ts +0 -220
  1370. package/src/routing/status-file-lint.ts +0 -112
  1371. package/src/search-params/analyze.ts +0 -192
  1372. package/src/search-params/builtin-codecs.ts +0 -228
  1373. package/src/search-params/codecs.ts +0 -153
  1374. package/src/search-params/create.ts +0 -321
  1375. package/src/search-params/registry.ts +0 -31
  1376. package/src/server/asset-headers.ts +0 -81
  1377. package/src/server/client-module-map.ts +0 -58
  1378. package/src/server/dev-fetch-instrumentation.ts +0 -96
  1379. package/src/server/dev-span-processor.ts +0 -78
  1380. package/src/server/dev-warnings.ts +0 -283
  1381. package/src/server/flush.ts +0 -182
  1382. package/src/server/manifest-status-resolver.ts +0 -215
  1383. package/src/server/prerender.ts +0 -139
  1384. package/src/server/tree-builder.ts +0 -382
  1385. package/src/shims/server-only-noop.js +0 -6
  1386. package/src/utils/directive-parser.ts +0 -529
@@ -0,0 +1,2039 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { n as RENDER_TIMEOUT_CEILING_MS, t as DEFAULT_RENDER_TIMEOUT_MS } from "./render-timeout-DOf_BBcO.js";
3
+ import { l as registerDevDiscovery } from "./graph-cache-CYiUS2aS.js";
4
+ import { n as isScannableSourceFile, t as buildSourceExtensions } from "./scan-BoP17W3w.js";
5
+ import { t as RSC_CONTENT_TYPE } from "./rsc-media-type-DDc7duTD.js";
6
+ import { t as matchUrlParts } from "./tree-match-6yihorhk.js";
7
+ import { o as isMetadataRouteServePath } from "./metadata-routes-DSDjM_hJ.js";
8
+ import { r as canonicalize } from "./canonicalize-CgHoscYO.js";
9
+ import { normalizePath } from "vite";
10
+ import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
11
+ import { createRequire } from "node:module";
12
+ import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
13
+ import "node:http";
14
+ import { Readable, pipeline } from "node:stream";
15
+ import { pipeline as pipeline$1 } from "node:stream/promises";
16
+ import "node:https";
17
+ import "node:http2";
18
+ import { pathToFileURL } from "node:url";
19
+ import { styleText } from "node:util";
20
+ import { realpath, stat } from "node:fs/promises";
21
+ import { isIP } from "node:net";
22
+ import { constants, createGzip } from "node:zlib";
23
+ //#region ../../node_modules/.pnpm/srvx@1.0.5/node_modules/srvx/dist/adapters/node.mjs
24
+ function sendNodeResponse(nodeRes, webRes) {
25
+ try {
26
+ return _sendNodeResponse(nodeRes, webRes, false) || Promise.resolve();
27
+ } catch (error) {
28
+ return Promise.reject(error);
29
+ }
30
+ }
31
+ function _sendNodeResponse(nodeRes, webRes, detached) {
32
+ if (!webRes) {
33
+ nodeRes.statusCode = 500;
34
+ return endNodeResponse(nodeRes, detached);
35
+ }
36
+ if (webRes._toNodeResponse) {
37
+ const res = webRes._toNodeResponse();
38
+ if (res.body) {
39
+ if (res.body instanceof ReadableStream) {
40
+ writeHead(nodeRes, res.status, res.statusText, res.headers);
41
+ return streamBody(res.body, nodeRes);
42
+ } else if (typeof res.body?.pipe === "function") return pipeBody(res.body, nodeRes, res.status, res.statusText, res.headers);
43
+ writeHead(nodeRes, res.status, res.statusText, res.headers);
44
+ nodeRes.write(res.body);
45
+ } else writeHead(nodeRes, res.status, res.statusText, res.headers);
46
+ return endNodeResponse(nodeRes, detached);
47
+ }
48
+ const rawHeaders = [];
49
+ for (const [key, value] of webRes.headers) rawHeaders.push(key, value);
50
+ writeHead(nodeRes, webRes.status, webRes.statusText, rawHeaders);
51
+ return webRes.body ? streamBody(webRes.body, nodeRes) : endNodeResponse(nodeRes, detached);
52
+ }
53
+ function writeHead(nodeRes, status, statusText, rawHeaders) {
54
+ if (!nodeRes.headersSent) {
55
+ if (nodeRes.req?.httpVersion === "2.0") nodeRes.writeHead(status, rawHeaders);
56
+ else nodeRes.writeHead(status, safeStatusText(statusText), rawHeaders);
57
+ }
58
+ }
59
+ var INVALID_REASON_PHRASE_RE = /[^\t\u0020-\u007E\u0080-\u00FF]/g;
60
+ function safeStatusText(statusText) {
61
+ return typeof statusText === "string" && statusText ? statusText.replace(INVALID_REASON_PHRASE_RE, "") : statusText;
62
+ }
63
+ function endNodeResponse(nodeRes, detached) {
64
+ if (detached) {
65
+ nodeRes.end();
66
+ return;
67
+ }
68
+ return new Promise((resolve) => nodeRes.end(resolve));
69
+ }
70
+ function pipeBody(stream, nodeRes, status, statusText, headers) {
71
+ if (nodeRes.destroyed) {
72
+ stream.destroy?.();
73
+ return;
74
+ }
75
+ if (nodeRes.req?.method === "HEAD") {
76
+ if (typeof stream.destroy === "function") stream.destroy();
77
+ else stream.abort?.();
78
+ writeHead(nodeRes, status, statusText, headers);
79
+ return endNodeResponse(nodeRes);
80
+ }
81
+ if (typeof stream.on !== "function" || typeof stream.destroy !== "function") {
82
+ writeHead(nodeRes, status, statusText, headers);
83
+ stream.pipe(nodeRes);
84
+ return new Promise((resolve) => nodeRes.on("close", resolve));
85
+ }
86
+ if (stream.destroyed) {
87
+ writeHead(nodeRes, 500, "Internal Server Error", []);
88
+ return endNodeResponse(nodeRes);
89
+ }
90
+ return new Promise((resolve) => {
91
+ function cleanup() {
92
+ stream.off("error", onEarlyError);
93
+ stream.off("readable", onReadable);
94
+ nodeRes.off("close", onResClose);
95
+ }
96
+ function onEarlyError() {
97
+ cleanup();
98
+ stream.destroy();
99
+ writeHead(nodeRes, 500, "Internal Server Error", []);
100
+ endNodeResponse(nodeRes).then(resolve);
101
+ }
102
+ function onReadable() {
103
+ cleanup();
104
+ if (nodeRes.destroyed) {
105
+ stream.destroy();
106
+ return resolve();
107
+ }
108
+ writeHead(nodeRes, status, statusText, headers);
109
+ pipeline$1(stream, nodeRes).catch(() => {}).then(() => resolve());
110
+ }
111
+ function onResClose() {
112
+ cleanup();
113
+ stream.destroy();
114
+ resolve();
115
+ }
116
+ stream.once("error", onEarlyError);
117
+ stream.once("readable", onReadable);
118
+ nodeRes.once("close", onResClose);
119
+ });
120
+ }
121
+ function streamBody(stream, nodeRes) {
122
+ if (nodeRes.destroyed) {
123
+ stream.cancel().catch(() => {});
124
+ return;
125
+ }
126
+ if (nodeRes.req?.method === "HEAD") {
127
+ stream.cancel().catch(() => {});
128
+ return endNodeResponse(nodeRes);
129
+ }
130
+ const reader = stream.getReader();
131
+ function streamCancel(error) {
132
+ reader.cancel(error).catch(() => {});
133
+ if (error) nodeRes.destroy(error);
134
+ }
135
+ function streamHandle({ done, value }) {
136
+ try {
137
+ if (done) nodeRes.end();
138
+ else if (nodeRes.write(value)) reader.read().then(streamHandle, streamCancel);
139
+ else nodeRes.once("drain", () => reader.read().then(streamHandle, streamCancel));
140
+ } catch (error) {
141
+ streamCancel(error instanceof Error ? error : void 0);
142
+ }
143
+ }
144
+ nodeRes.on("close", streamCancel);
145
+ nodeRes.on("error", streamCancel);
146
+ reader.read().then(streamHandle, streamCancel);
147
+ return reader.closed.catch(streamCancel).finally(() => {
148
+ nodeRes.off("close", streamCancel);
149
+ nodeRes.off("error", streamCancel);
150
+ });
151
+ }
152
+ //#endregion
153
+ //#region src/dev-tools/stack-classifier.ts
154
+ /** Parse file/line/col from a stack frame line. */
155
+ function parseFrame(frameLine) {
156
+ const parenMatch = /\(([^)]+):(\d+):(\d+)\)/.exec(frameLine);
157
+ if (parenMatch) return {
158
+ file: parenMatch[1],
159
+ line: Number(parenMatch[2]),
160
+ col: Number(parenMatch[3])
161
+ };
162
+ const bareMatch = /at (\/[^:]+):(\d+):(\d+)/.exec(frameLine);
163
+ if (bareMatch) return {
164
+ file: bareMatch[1],
165
+ line: Number(bareMatch[2]),
166
+ col: Number(bareMatch[3])
167
+ };
168
+ return {};
169
+ }
170
+ /**
171
+ * Classify a single stack frame line by origin.
172
+ *
173
+ * - 'app': user application code (in project root, not node_modules)
174
+ * - 'framework': timber-app internal code
175
+ * - 'internal': node_modules, Node.js internals
176
+ */
177
+ function classifyFrame(frameLine, projectRoot) {
178
+ const trimmed = frameLine.trim();
179
+ if (trimmed.includes("packages/timber-app/")) return "framework";
180
+ if (trimmed.includes("node_modules/")) return "internal";
181
+ if (trimmed.startsWith("at node:") || trimmed.includes("(node:")) return "internal";
182
+ if (trimmed.includes(projectRoot)) return "app";
183
+ return "internal";
184
+ }
185
+ /**
186
+ * Classify all frames in a full stack trace string.
187
+ *
188
+ * Parses the stack, skips the first line (error message), filters to
189
+ * lines starting with "at ", and returns classified frames with optional
190
+ * file/line/col metadata.
191
+ */
192
+ function classifyStack(stack, projectRoot) {
193
+ return stack.split("\n").slice(1).filter((line) => line.trim().startsWith("at ")).map((raw) => {
194
+ const type = classifyFrame(raw, projectRoot);
195
+ const { file, line, col } = parseFrame(raw);
196
+ return {
197
+ raw,
198
+ type,
199
+ file,
200
+ line,
201
+ col
202
+ };
203
+ });
204
+ }
205
+ //#endregion
206
+ //#region src/dev-tools/terminal.ts
207
+ /**
208
+ * Terminal error formatting — boxed, color-coded error output for dev mode.
209
+ *
210
+ * Produces a visually scannable error block with:
211
+ * - Unicode box-drawing border around the error
212
+ * - Phase badge and error message
213
+ * - First app frame highlighted as the primary action item
214
+ * - OSC 8 clickable file:line links (VSCode terminal, iTerm2, etc.)
215
+ * - Internal/framework frames collapsed with a count
216
+ * - Component stack (for React render errors)
217
+ *
218
+ * Dev-only: this module is only imported by dev-error-overlay.ts.
219
+ *
220
+ * Design doc: 21-dev-server.md §"Error Overlay"
221
+ */
222
+ var noValidate = { validateStream: false };
223
+ var style = (fmt, text) => styleText(fmt, text, noValidate);
224
+ /**
225
+ * Wrap text in an OSC 8 hyperlink escape sequence.
226
+ *
227
+ * Terminals that support OSC 8 (VSCode, iTerm2, Windows Terminal, etc.)
228
+ * render this as a clickable link. Others ignore the escape sequences
229
+ * and show the text normally.
230
+ *
231
+ * Format: \x1b]8;;URL\x07TEXT\x1b]8;;\x07
232
+ */
233
+ function hyperlink(text, url) {
234
+ return `\x1b]8;;${url}\x07${text}\x1b]8;;\x07`;
235
+ }
236
+ /**
237
+ * Format a file:line:col reference as a clickable terminal link.
238
+ *
239
+ * Uses file:// URLs so terminals open the file in the configured editor.
240
+ * The link text is styled with cyan + underline for visibility.
241
+ */
242
+ function fileLink(filePath, line, col) {
243
+ const display = line ? `${filePath}:${line}${col ? `:${col}` : ""}` : filePath;
244
+ const base = pathToFileURL(filePath).href;
245
+ return style(["cyan", "underline"], hyperlink(display, line ? `${base}:${line}${col ? `:${col}` : ""}` : base));
246
+ }
247
+ var BOX = {
248
+ topLeft: "╭",
249
+ topRight: "╮",
250
+ bottomLeft: "╰",
251
+ bottomRight: "╯",
252
+ horizontal: "─",
253
+ vertical: "│"
254
+ };
255
+ /**
256
+ * Wrap lines of text in a Unicode box with a colored left border.
257
+ *
258
+ * @param lines - Content lines (no ANSI length calculation — keeps it simple)
259
+ * @param width - Box width (characters). Lines longer than this are not truncated.
260
+ */
261
+ function box(lines, borderFormat, width = 80) {
262
+ const bar = BOX.horizontal.repeat(width - 2);
263
+ const output = [];
264
+ output.push(style(borderFormat, `${BOX.topLeft}${bar}${BOX.topRight}`));
265
+ for (const line of lines) output.push(`${style(borderFormat, BOX.vertical)} ${line}`);
266
+ output.push(style(borderFormat, `${BOX.bottomLeft}${bar}${BOX.bottomRight}`));
267
+ return output.join("\n");
268
+ }
269
+ /**
270
+ * Format an error for terminal output with a boxed layout.
271
+ *
272
+ * The output is designed to be scannable at a glance:
273
+ * 1. Red box with phase badge and error message
274
+ * 2. First app frame as a clickable link (the primary action item)
275
+ * 3. App frames listed normally
276
+ * 4. Internal/framework frames collapsed with count
277
+ * 5. Component stack (if present)
278
+ */
279
+ function formatTerminalError$1(error, phase, projectRoot) {
280
+ const sections = [];
281
+ const componentStack = extractComponentStack(error);
282
+ const loc = parseFirstAppFrame(error.stack ?? "", projectRoot);
283
+ const frames = error.stack ? classifyStack(error.stack, projectRoot) : [];
284
+ const appFrames = frames.filter((f) => f.type === "app");
285
+ const internalCount = frames.filter((f) => f.type !== "app").length;
286
+ const boxLines = [];
287
+ boxLines.push(style(["red", "bold"], `${PHASE_LABELS$1[phase]} Error`));
288
+ boxLines.push("");
289
+ for (const msgLine of error.message.split("\n")) boxLines.push(style("red", msgLine));
290
+ if (loc) {
291
+ boxLines.push("");
292
+ const relPath = loc.file.startsWith(projectRoot) ? loc.file.slice(projectRoot.length + 1) : loc.file;
293
+ boxLines.push(`${style("bold", "→")} ${fileLink(loc.file, loc.line, loc.column)} ${style("dim", `(${relPath})`)}`);
294
+ }
295
+ sections.push(box(boxLines, "red"));
296
+ if (componentStack) {
297
+ sections.push("");
298
+ sections.push(` ${style("bold", "Component Stack:")}`);
299
+ for (const csLine of componentStack.trim().split("\n")) sections.push(` ${style("dim", csLine.trim())}`);
300
+ }
301
+ if (appFrames.length > 0) {
302
+ sections.push("");
303
+ sections.push(` ${style("bold", "Application Frames:")}`);
304
+ for (let i = 0; i < appFrames.length; i++) {
305
+ const f = appFrames[i];
306
+ if (f.file && f.line) {
307
+ const prefix = i === 0 ? style("bold", "▸") : " ";
308
+ sections.push(` ${prefix} ${fileLink(f.file, f.line, f.col)} ${style("dim", extractFnName(f.raw))}`);
309
+ } else sections.push(` ${f.raw}`);
310
+ }
311
+ }
312
+ if (internalCount > 0) sections.push(` ${style("dim", `… ${internalCount} internal frame${internalCount !== 1 ? "s" : ""} hidden`)}`);
313
+ sections.push("");
314
+ return sections.join("\n");
315
+ }
316
+ /** Extract the function name from a stack frame line like " at fnName (/path:1:2)". */
317
+ function extractFnName(frameLine) {
318
+ const match = /at\s+(\S+)\s+\(/.exec(frameLine.trim());
319
+ return match ? match[1] : "";
320
+ }
321
+ //#endregion
322
+ //#region src/dev-tools/overlay.ts
323
+ /** Labels for terminal output. */
324
+ var PHASE_LABELS$1 = {
325
+ "module-transform": "Module Transform",
326
+ "proxy": "Proxy",
327
+ "middleware": "Middleware",
328
+ "access": "Access Check",
329
+ "render": "RSC Render",
330
+ "handler": "Route Handler"
331
+ };
332
+ /**
333
+ * Extract the React component stack from an error, if present.
334
+ * React attaches this as `componentStack` during renderToReadableStream errors.
335
+ */
336
+ function extractComponentStack(error) {
337
+ if (error && typeof error === "object" && "componentStack" in error && typeof error.componentStack === "string") return error.componentStack;
338
+ return null;
339
+ }
340
+ /**
341
+ * Parse the first application frame from a stack trace.
342
+ * Returns file/line/column for the overlay's `loc` field.
343
+ */
344
+ function parseFirstAppFrame(stack, projectRoot) {
345
+ const lines = stack.split("\n");
346
+ const parenRegex = /\(([^)]+):(\d+):(\d+)\)/;
347
+ const bareRegex = /at (\/[^:]+):(\d+):(\d+)/;
348
+ for (const line of lines) {
349
+ if (classifyFrame(line, projectRoot) !== "app") continue;
350
+ const match = parenRegex.exec(line) ?? bareRegex.exec(line);
351
+ if (!match) continue;
352
+ const [, file, lineNum, col] = match;
353
+ if (file && lineNum && col) return {
354
+ file,
355
+ line: parseInt(lineNum, 10),
356
+ column: parseInt(col, 10)
357
+ };
358
+ }
359
+ return null;
360
+ }
361
+ /**
362
+ * Classify the error phase by inspecting the error's stack trace.
363
+ * Falls back to 'render' if no specific phase can be determined.
364
+ */
365
+ function classifyErrorPhase(error, projectRoot) {
366
+ const stack = error.stack ?? "";
367
+ if (extractComponentStack(error)) return "render";
368
+ const appRoot = projectRoot.replace(/\/$/, "");
369
+ if (stack.includes(`${appRoot}/app/`) || stack.includes("/app/")) {
370
+ if (stack.includes("/middleware.ts") || stack.includes("/middleware.js")) return "middleware";
371
+ if (stack.includes("/access.ts") || stack.includes("/access.js")) return "access";
372
+ if (stack.includes("/route.ts") || stack.includes("/route.js")) return "handler";
373
+ }
374
+ return "render";
375
+ }
376
+ var formatTerminalError = formatTerminalError$1;
377
+ /**
378
+ * Send an error to Vite's browser overlay and log it to stderr.
379
+ *
380
+ * Reads `error` and never writes it: the pipeline may render the same object
381
+ * on the fallback error page after reporting it here.
382
+ *
383
+ * The dev server remains running — errors are handled, not fatal.
384
+ */
385
+ function sendErrorToOverlay(server, error, phase, projectRoot) {
386
+ const formatted = formatTerminalError(error, phase, projectRoot);
387
+ process.stderr.write(`${formatted}\n`);
388
+ const loc = parseFirstAppFrame(error.stack ?? "", projectRoot);
389
+ const componentStack = extractComponentStack(error);
390
+ let message = error.message;
391
+ if (componentStack) message = `${error.message}\n\nComponent Stack:\n${componentStack.trim()}`;
392
+ try {
393
+ server.hot.send({
394
+ type: "error",
395
+ err: {
396
+ message,
397
+ stack: error.stack ?? "",
398
+ id: loc?.file,
399
+ plugin: `timber (${PHASE_LABELS$1[phase]})`,
400
+ loc: loc ? {
401
+ file: loc.file,
402
+ line: loc.line,
403
+ column: loc.column
404
+ } : void 0
405
+ }
406
+ });
407
+ } catch (e) {
408
+ console.debug("[timber] overlay error send failed:", e instanceof Error ? e.message : e);
409
+ }
410
+ }
411
+ //#endregion
412
+ //#region src/server/utils/escape-html.ts
413
+ /**
414
+ * Shared HTML escaping utility.
415
+ *
416
+ * Used by both dev-only paths (error pages, 404 page) and production
417
+ * paths (deny-renderer, RSC helpers). Lives in server/utils/ because
418
+ * it's not dev-only.
419
+ */
420
+ /**
421
+ * Escape a string for safe embedding in HTML content or attributes.
422
+ *
423
+ * Replaces `&`, `<`, `>`, and `"` with their HTML entity equivalents.
424
+ */
425
+ function escapeHtml(str) {
426
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
427
+ }
428
+ //#endregion
429
+ //#region src/dev-tools/dev-page-shell.ts
430
+ /**
431
+ * Shared scaffold for dev-mode HTML pages (dev error page, dev 404 page).
432
+ *
433
+ * Both pages are self-contained HTML documents served when the normal
434
+ * render pipeline can't produce a page. They share:
435
+ * - The document scaffold (head, container, footer)
436
+ * - Base CSS (layout, light/dark variables, common components)
437
+ * - The HMR auto-reload script that watches Vite's WebSocket and reloads
438
+ * when the developer fixes the error / adds the missing route
439
+ *
440
+ * Dev-only: this module is only imported by dev-mode code paths. It is
441
+ * never included in production builds.
442
+ *
443
+ * Design doc: 21-dev-server.md §"Error Overlay", §"Dev 404 Page"
444
+ */
445
+ /**
446
+ * Extract HMR connection options from a Vite resolved config.
447
+ * Used by the dev server to pass HMR config to the dev page generators
448
+ * so the auto-reload WebSocket connects to the correct endpoint.
449
+ */
450
+ function extractHmrOptions(config) {
451
+ const hmr = config.server?.hmr;
452
+ if (hmr === false) return void 0;
453
+ const hmrOpts = typeof hmr === "object" ? hmr : {};
454
+ const opts = {
455
+ protocol: hmrOpts.protocol,
456
+ host: hmrOpts.host,
457
+ port: hmrOpts.clientPort || hmrOpts.port,
458
+ path: hmrOpts.path,
459
+ token: config.webSocketToken
460
+ };
461
+ if (!opts.protocol && !opts.host && !opts.port && !opts.path && !opts.token) return;
462
+ return opts;
463
+ }
464
+ /**
465
+ * Build the inline auto-reload script for dev pages.
466
+ *
467
+ * The page is static HTML, not a Vite-managed module, so the normal HMR
468
+ * update flow can't reach it. Instead we connect to Vite's HMR WebSocket
469
+ * directly and reload on any update event.
470
+ *
471
+ * URL construction mirrors Vite's own client.mjs: explicitly configured
472
+ * values win, and the browser's location fills any gaps at runtime. This
473
+ * matters because Vite 8 requires a `?token=` on browser WS upgrades in
474
+ * every config — a config with only a token still needs the host and port
475
+ * from `location` (TIM-1067).
476
+ */
477
+ function buildReloadScript(hmrOptions) {
478
+ return ` (function() {
479
+ try {
480
+ var o = ${JSON.stringify(hmrOptions ?? {}).replace(/</g, "\\u003c")};
481
+ var protocol = o.protocol || (location.protocol === 'https:' ? 'wss' : 'ws');
482
+ var host = o.host || location.hostname;
483
+ var port = o.port || location.port;
484
+ var url = protocol + '://' + host + (port ? ':' + port : '') + (o.path || '')
485
+ + (o.token ? '?token=' + encodeURIComponent(o.token) : '');
486
+ var ws = new WebSocket(url, 'vite-hmr');
487
+ ws.addEventListener('message', function(e) {
488
+ try {
489
+ var data = JSON.parse(e.data);
490
+ if (data.type === 'full-reload' || data.type === 'update') {
491
+ location.reload();
492
+ }
493
+ } catch (ex) {}
494
+ });
495
+ } catch (ex) {}
496
+ })();`;
497
+ }
498
+ /**
499
+ * Render a self-contained dev page: scaffold + shared CSS + footer +
500
+ * HMR auto-reload script.
501
+ */
502
+ function renderDevPageShell(opts) {
503
+ return `<!DOCTYPE html>
504
+ <html lang="en">
505
+ <head>
506
+ <meta charset="utf-8">
507
+ <meta name="viewport" content="width=device-width, initial-scale=1">
508
+ <title>${escapeHtml(opts.title)}</title>
509
+ <style>${SHARED_CSS}${opts.extraCss ?? ""}</style>
510
+ </head>
511
+ <body>
512
+ <div class="container">
513
+ ${opts.bodyHtml}
514
+
515
+ <footer class="footer">
516
+ <span class="timber-logo">🪵 timber.js</span>
517
+ <span class="footer-hint">${opts.footerHint}</span>
518
+ </footer>
519
+ </div>
520
+
521
+ <script>
522
+ ${opts.extraScript ?? ""}
523
+ // Auto-reload when Vite HMR signals an update (file fixed, route added).
524
+ ${buildReloadScript(opts.hmrOptions)}
525
+ <\/script>
526
+ </body>
527
+ </html>`;
528
+ }
529
+ /**
530
+ * Base CSS shared by all dev pages. Pages override the --badge-* variables
531
+ * (and add their own component styles) via `extraCss`.
532
+ */
533
+ var SHARED_CSS = `
534
+ :root {
535
+ --bg: #fff;
536
+ --fg: #1a1a1a;
537
+ --fg-dim: #6b7280;
538
+ --border: #e5e7eb;
539
+ --source-bg: #fafafa;
540
+ --link: #2563eb;
541
+ --code-bg: #f3f4f6;
542
+ --btn-bg: #f3f4f6;
543
+ --btn-fg: #374151;
544
+ --btn-border: #d1d5db;
545
+ --code-font: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
546
+ }
547
+
548
+ @media (prefers-color-scheme: dark) {
549
+ :root {
550
+ --bg: #0a0a0a;
551
+ --fg: #f5f5f5;
552
+ --fg-dim: #9ca3af;
553
+ --border: #27272a;
554
+ --source-bg: #18181b;
555
+ --link: #60a5fa;
556
+ --code-bg: #27272a;
557
+ --btn-bg: #27272a;
558
+ --btn-fg: #e5e7eb;
559
+ --btn-border: #3f3f46;
560
+ }
561
+ }
562
+
563
+ * { margin: 0; padding: 0; box-sizing: border-box; }
564
+
565
+ body {
566
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
567
+ background: var(--bg);
568
+ color: var(--fg);
569
+ line-height: 1.6;
570
+ padding: 2rem;
571
+ }
572
+
573
+ .container { max-width: 56rem; margin: 0 auto; }
574
+ .header { margin-bottom: 1.5rem; }
575
+
576
+ .badge {
577
+ display: inline-block;
578
+ font-size: 0.75rem;
579
+ font-weight: 600;
580
+ text-transform: uppercase;
581
+ letter-spacing: 0.05em;
582
+ padding: 0.25rem 0.625rem;
583
+ border-radius: 0.375rem;
584
+ background: var(--badge-bg);
585
+ color: var(--badge-fg);
586
+ border: 1px solid var(--badge-border);
587
+ margin-bottom: 0.75rem;
588
+ }
589
+
590
+ .message {
591
+ font-size: 1.375rem;
592
+ font-weight: 600;
593
+ line-height: 1.3;
594
+ word-break: break-word;
595
+ }
596
+
597
+ .hint {
598
+ margin-top: 0.5rem;
599
+ color: var(--fg-dim);
600
+ font-size: 0.875rem;
601
+ }
602
+
603
+ .section {
604
+ margin-bottom: 1rem;
605
+ border: 1px solid var(--border);
606
+ border-radius: 0.5rem;
607
+ overflow: hidden;
608
+ }
609
+
610
+ .section-header {
611
+ font-size: 0.75rem;
612
+ font-weight: 600;
613
+ text-transform: uppercase;
614
+ letter-spacing: 0.05em;
615
+ padding: 0.5rem 0.75rem;
616
+ background: var(--source-bg);
617
+ border-bottom: 1px solid var(--border);
618
+ color: var(--fg-dim);
619
+ }
620
+
621
+ .footer {
622
+ display: flex;
623
+ align-items: center;
624
+ gap: 0.75rem;
625
+ padding-top: 1rem;
626
+ border-top: 1px solid var(--border);
627
+ font-size: 0.75rem;
628
+ color: var(--fg-dim);
629
+ }
630
+
631
+ .timber-logo { font-weight: 600; white-space: nowrap; }
632
+ `;
633
+ //#endregion
634
+ //#region src/dev-tools/error-page.ts
635
+ /**
636
+ * Dev error page — self-contained HTML error page for dev server 500s.
637
+ *
638
+ * Generates a styled, self-contained HTML page when the RSC pipeline fails
639
+ * and the Vite error overlay can't fire (e.g., first page load before HMR
640
+ * WebSocket connects, RSC entry module crash, early pipeline errors).
641
+ *
642
+ * This is NOT a replacement for Vite's error overlay — it's the fallback
643
+ * for when the overlay's transport (WebSocket) isn't available yet.
644
+ *
645
+ * Dev-only: this module is only imported by dev-server.ts (apply: 'serve')
646
+ * and via dynamic import from fallback-error.ts in dev mode. It is never
647
+ * included in production builds.
648
+ *
649
+ * Design doc: 21-dev-server.md §"Error Overlay"
650
+ */
651
+ var PHASE_LABELS = {
652
+ "module-transform": "Module Transform",
653
+ "proxy": "Proxy",
654
+ "middleware": "Middleware",
655
+ "access": "Access Check",
656
+ "render": "RSC Render",
657
+ "handler": "Route Handler"
658
+ };
659
+ var PHASE_HINTS = {
660
+ "module-transform": "This error occurred while Vite was transforming a module. Check for syntax errors or missing imports.",
661
+ "proxy": "This error occurred in proxy.ts. Check your proxy configuration.",
662
+ "middleware": "This error occurred in a middleware.ts file. Check the middleware function for unhandled exceptions.",
663
+ "access": "This error occurred in an access.ts file. Check your access control logic.",
664
+ "render": "This error occurred while rendering a server component. Check the component for runtime errors.",
665
+ "handler": "This error occurred in a route handler (route.ts). Check the handler function."
666
+ };
667
+ /**
668
+ * Try to read a few lines of source code around the error location.
669
+ * Returns null if the file can't be read (e.g., virtual modules).
670
+ *
671
+ * Uses a top-level `node:fs` import — this module is dev-server-only and
672
+ * Node-only. A bare `require()` here would throw in the ESM build and the
673
+ * code frame would silently never render (TIM-1067, B48).
674
+ */
675
+ function readSourceContext(filePath, line, contextLines = 3) {
676
+ try {
677
+ const allLines = readFileSync(filePath, "utf-8").split("\n");
678
+ const start = Math.max(0, line - 1 - contextLines);
679
+ const end = Math.min(allLines.length, line + contextLines);
680
+ return {
681
+ startLine: start + 1,
682
+ lines: allLines.slice(start, end).map((text, i) => ({
683
+ num: start + 1 + i,
684
+ text,
685
+ highlight: start + 1 + i === line
686
+ }))
687
+ };
688
+ } catch (e) {
689
+ console.debug("[timber] source context extraction failed:", e instanceof Error ? e.message : e);
690
+ return null;
691
+ }
692
+ }
693
+ var esc = escapeHtml;
694
+ /**
695
+ * Escape a JSON string for safe embedding in an HTML `<script>` block.
696
+ *
697
+ * `JSON.stringify` does not escape `<\/script>`, so error text containing
698
+ * that sequence breaks out of the script block — an XSS vector.
699
+ * We replace all `<` with the equivalent unicode escape, which is valid in
700
+ * JSON strings and prevents the HTML parser from seeing a closing
701
+ * `<\/script>` tag.
702
+ *
703
+ * Security: TIM-788
704
+ */
705
+ function escJsonForScript(json) {
706
+ return json.replace(/</g, "\\u003c");
707
+ }
708
+ /**
709
+ * Generate a self-contained HTML error page for dev server 500 responses.
710
+ *
711
+ * The page includes:
712
+ * - Error message and phase label
713
+ * - Source code context around the first app frame (if readable)
714
+ * - Component stack (for React render errors)
715
+ * - Classified stack trace (app frames highlighted, internals collapsed)
716
+ * - Copy button for the full error
717
+ * - Dark/light mode via prefers-color-scheme
718
+ * - Auto-reconnect script that watches for Vite HMR and reloads
719
+ */
720
+ function generateDevErrorPage(error, phase, projectRoot, hmrOptions) {
721
+ const message = error.message || "Unknown error";
722
+ const phaseLabel = PHASE_LABELS[phase];
723
+ const phaseHint = PHASE_HINTS[phase];
724
+ const componentStack = extractComponentStack(error);
725
+ const loc = parseFirstAppFrame(error.stack ?? "", projectRoot);
726
+ const frames = error.stack ? classifyStack(error.stack, projectRoot) : [];
727
+ const appFrames = frames.filter((f) => f.type === "app");
728
+ const internalFrameCount = frames.filter((f) => f.type !== "app").length;
729
+ let sourceContext = null;
730
+ if (loc) sourceContext = readSourceContext(loc.file, loc.line);
731
+ const relPath = loc?.file.startsWith(projectRoot) ? loc.file.slice(projectRoot.length + 1) : loc?.file;
732
+ const bodyHtml = `<header class="header">
733
+ <div class="badge">${esc(phaseLabel)} Error</div>
734
+ <h1 class="message">${esc(message)}</h1>
735
+ ${phaseHint ? `<p class="hint">${esc(phaseHint)}</p>` : ""}
736
+ </header>
737
+
738
+ ${relPath ? `<div class="location">${esc(relPath)}${loc ? `:${loc.line}:${loc.column}` : ""}</div>` : ""}
739
+
740
+ ${sourceContext ? `<div class="source-context">
741
+ <div class="section-header">Source</div>
742
+ <pre class="source-code"><code>${sourceContext.lines.map((l) => `<span class="source-line${l.highlight ? " source-line-highlight" : ""}"><span class="line-num">${l.num}</span>${esc(l.text)}</span>`).join("\n")}</code></pre>
743
+ </div>` : ""}
744
+
745
+ ${componentStack ? `<div class="section">
746
+ <div class="section-header">Component Stack</div>
747
+ <pre class="component-stack">${esc(componentStack.trim())}</pre>
748
+ </div>` : ""}
749
+
750
+ ${appFrames.length > 0 ? `<div class="section">
751
+ <div class="section-header">Application Frames</div>
752
+ <pre class="stack">${appFrames.map((f) => esc(f.raw)).join("\n")}</pre>
753
+ </div>` : ""}
754
+
755
+ ${internalFrameCount > 0 ? `<details class="section internal-frames">
756
+ <summary class="section-header clickable">${internalFrameCount} internal frame${internalFrameCount !== 1 ? "s" : ""}</summary>
757
+ <pre class="stack dimmed">${frames.filter((f) => f.type !== "app").map((f) => esc(f.raw)).join("\n")}</pre>
758
+ </details>` : ""}
759
+
760
+ <div class="actions">
761
+ <button class="btn" onclick="copyError()">Copy Error</button>
762
+ </div>`;
763
+ const copyScript = ` function copyError() {
764
+ var text = ${escJsonForScript(JSON.stringify(`${phaseLabel} Error: ${message}\n\n` + (relPath ? `File: ${relPath}${loc ? `:${loc.line}:${loc.column}` : ""}\n\n` : "") + (componentStack ? `Component Stack:\n${componentStack.trim()}\n\n` : "") + `Stack Trace:\n${error.stack ?? ""}`))};
765
+ navigator.clipboard.writeText(text).then(function() {
766
+ var btn = document.querySelector('.btn');
767
+ if (btn) { btn.textContent = 'Copied!'; setTimeout(function() { btn.textContent = 'Copy Error'; }, 1500); }
768
+ });
769
+ }
770
+ `;
771
+ return renderDevPageShell({
772
+ title: `Error — ${phaseLabel} | timber.js`,
773
+ extraCss: ERROR_CSS,
774
+ bodyHtml,
775
+ footerHint: "Fix the error and save — the page will reload automatically via HMR.",
776
+ extraScript: copyScript,
777
+ hmrOptions
778
+ });
779
+ }
780
+ var ERROR_CSS = `
781
+ :root {
782
+ --badge-bg: #fef2f2;
783
+ --badge-fg: #991b1b;
784
+ --badge-border: #fecaca;
785
+ --highlight-bg: #fef2f2;
786
+ --highlight-border: #ef4444;
787
+ --line-num: #9ca3af;
788
+ }
789
+
790
+ @media (prefers-color-scheme: dark) {
791
+ :root {
792
+ --badge-bg: #450a0a;
793
+ --badge-fg: #fca5a5;
794
+ --badge-border: #7f1d1d;
795
+ --highlight-bg: #450a0a;
796
+ --highlight-border: #dc2626;
797
+ --line-num: #6b7280;
798
+ }
799
+ }
800
+
801
+ .location {
802
+ font-family: var(--code-font);
803
+ font-size: 0.8125rem;
804
+ color: var(--link);
805
+ margin-bottom: 1rem;
806
+ padding: 0.5rem 0.75rem;
807
+ background: var(--source-bg);
808
+ border-radius: 0.375rem;
809
+ border: 1px solid var(--border);
810
+ }
811
+
812
+ .source-context {
813
+ margin-bottom: 1rem;
814
+ border: 1px solid var(--border);
815
+ border-radius: 0.5rem;
816
+ overflow: hidden;
817
+ }
818
+
819
+ .source-code {
820
+ overflow-x: auto;
821
+ font-family: var(--code-font);
822
+ font-size: 0.8125rem;
823
+ line-height: 1.7;
824
+ padding: 0;
825
+ margin: 0;
826
+ }
827
+
828
+ .source-code code {
829
+ display: block;
830
+ }
831
+
832
+ .source-line {
833
+ display: block;
834
+ padding: 0 0.75rem;
835
+ border-left: 3px solid transparent;
836
+ }
837
+
838
+ .source-line-highlight {
839
+ background: var(--highlight-bg);
840
+ border-left-color: var(--highlight-border);
841
+ }
842
+
843
+ .line-num {
844
+ display: inline-block;
845
+ width: 3rem;
846
+ text-align: right;
847
+ margin-right: 1rem;
848
+ color: var(--line-num);
849
+ user-select: none;
850
+ }
851
+
852
+ .clickable { cursor: pointer; }
853
+ .clickable:hover { background: var(--btn-bg); }
854
+
855
+ .component-stack, .stack {
856
+ font-family: var(--code-font);
857
+ font-size: 0.8125rem;
858
+ line-height: 1.7;
859
+ padding: 0.75rem;
860
+ overflow-x: auto;
861
+ white-space: pre;
862
+ margin: 0;
863
+ }
864
+
865
+ .dimmed { color: var(--fg-dim); }
866
+
867
+ .actions {
868
+ margin: 1.5rem 0;
869
+ }
870
+
871
+ .btn {
872
+ font-family: inherit;
873
+ font-size: 0.8125rem;
874
+ font-weight: 500;
875
+ padding: 0.5rem 1rem;
876
+ border-radius: 0.375rem;
877
+ border: 1px solid var(--btn-border);
878
+ background: var(--btn-bg);
879
+ color: var(--btn-fg);
880
+ cursor: pointer;
881
+ transition: background 0.15s;
882
+ }
883
+
884
+ .btn:hover { opacity: 0.85; }
885
+ `;
886
+ //#endregion
887
+ //#region src/config-validation.ts
888
+ /**
889
+ * Config validation — validates timber.config.ts at startup.
890
+ *
891
+ * Runs in the plugin's configResolved hook (once, at startup/build).
892
+ * Each check produces a clear error message with the invalid value,
893
+ * what's expected, and how to fix it.
894
+ *
895
+ * Design doc: 18-build-system.md
896
+ */
897
+ var knownKeys = new Set(Object.keys({
898
+ output: true,
899
+ debug: true,
900
+ clientJavascript: true,
901
+ adapter: true,
902
+ allowedOrigins: true,
903
+ csrf: true,
904
+ limits: true,
905
+ forms: true,
906
+ pageExtensions: true,
907
+ slowRequestMs: true,
908
+ renderTimeoutMs: true,
909
+ devBrowserLogs: true,
910
+ dev: true,
911
+ serverTiming: true,
912
+ appDir: true,
913
+ mdx: true,
914
+ actionEncryption: true,
915
+ reactCompiler: true,
916
+ sitemap: true,
917
+ buildDir: true,
918
+ cache: true,
919
+ clientSegmentCache: true,
920
+ topLoader: true,
921
+ budget: true
922
+ }));
923
+ /**
924
+ * Validate a TimberUserConfig object.
925
+ *
926
+ * Returns an array of errors. Empty array means the config is valid.
927
+ * Does not throw — the caller decides how to surface errors.
928
+ */
929
+ function validateConfig(config) {
930
+ const errors = [];
931
+ if (config.output !== void 0 && config.output !== "server" && config.output !== "static") errors.push({
932
+ field: "output",
933
+ message: `Invalid output mode: "${String(config.output)}". Must be "server" or "static".`,
934
+ value: config.output,
935
+ suggestion: "Use output: \"server\" (default) or output: \"static\" for static site generation."
936
+ });
937
+ if (config.pageExtensions !== void 0) {
938
+ if (!Array.isArray(config.pageExtensions)) errors.push({
939
+ field: "pageExtensions",
940
+ message: "pageExtensions must be an array of strings.",
941
+ value: config.pageExtensions,
942
+ suggestion: "Example: pageExtensions: [\"tsx\", \"ts\", \"jsx\", \"js\", \"mdx\"]"
943
+ });
944
+ else for (const ext of config.pageExtensions) {
945
+ if (typeof ext !== "string") {
946
+ errors.push({
947
+ field: "pageExtensions",
948
+ message: `pageExtensions contains a non-string value: ${JSON.stringify(ext)}`,
949
+ value: ext
950
+ });
951
+ break;
952
+ }
953
+ if (ext.startsWith(".")) {
954
+ errors.push({
955
+ field: "pageExtensions",
956
+ message: `pageExtensions should not include the leading dot: "${ext}"`,
957
+ value: ext,
958
+ suggestion: `Use "${ext.slice(1)}" instead of "${ext}".`
959
+ });
960
+ break;
961
+ }
962
+ }
963
+ }
964
+ if (config.allowedOrigins !== void 0) {
965
+ if (!Array.isArray(config.allowedOrigins)) errors.push({
966
+ field: "allowedOrigins",
967
+ message: "allowedOrigins must be an array of origin strings.",
968
+ value: config.allowedOrigins,
969
+ fatal: true,
970
+ suggestion: "Example: allowedOrigins: [\"https://app.example.com\"]"
971
+ });
972
+ else for (const entry of config.allowedOrigins) {
973
+ const error = allowedOriginError(entry);
974
+ if (error) errors.push(error);
975
+ }
976
+ }
977
+ if (config.slowRequestMs !== void 0) {
978
+ if (typeof config.slowRequestMs !== "number" || config.slowRequestMs < 0) errors.push({
979
+ field: "slowRequestMs",
980
+ message: `slowRequestMs must be a non-negative number (got ${JSON.stringify(config.slowRequestMs)}).`,
981
+ value: config.slowRequestMs,
982
+ suggestion: "Use slowRequestMs: 3000 (default) or slowRequestMs: 0 to disable."
983
+ });
984
+ }
985
+ if (config.renderTimeoutMs !== void 0) {
986
+ if (typeof config.renderTimeoutMs !== "number" || config.renderTimeoutMs < 0) errors.push({
987
+ field: "renderTimeoutMs",
988
+ message: `renderTimeoutMs must be a non-negative number (got ${JSON.stringify(config.renderTimeoutMs)}).`,
989
+ value: config.renderTimeoutMs,
990
+ suggestion: `Use renderTimeoutMs: ${DEFAULT_RENDER_TIMEOUT_MS} (default). Setting 0 uses a ${RENDER_TIMEOUT_CEILING_MS / 1e3}s safety ceiling.`
991
+ });
992
+ }
993
+ if (config.serverTiming !== void 0) {
994
+ if (config.serverTiming !== "detailed" && config.serverTiming !== "total" && config.serverTiming !== false) errors.push({
995
+ field: "serverTiming",
996
+ message: `Invalid serverTiming value: ${JSON.stringify(config.serverTiming)}.`,
997
+ value: config.serverTiming,
998
+ suggestion: "Use \"detailed\", \"total\", or false."
999
+ });
1000
+ }
1001
+ if (config.devBrowserLogs !== void 0) {
1002
+ const valid = [
1003
+ "error",
1004
+ "warn",
1005
+ "info",
1006
+ "none"
1007
+ ];
1008
+ if (!valid.includes(config.devBrowserLogs)) errors.push({
1009
+ field: "devBrowserLogs",
1010
+ message: `Invalid devBrowserLogs value: ${JSON.stringify(config.devBrowserLogs)}.`,
1011
+ value: config.devBrowserLogs,
1012
+ suggestion: `Use one of: ${valid.map((v) => `"${v}"`).join(", ")}.`
1013
+ });
1014
+ }
1015
+ if (config.sitemap != null && typeof config.sitemap === "object") {
1016
+ if (config.sitemap.enabled && !config.sitemap.baseUrl) errors.push({
1017
+ field: "sitemap.baseUrl",
1018
+ message: "sitemap.baseUrl is required when sitemap is enabled.",
1019
+ suggestion: "Add sitemap: { enabled: true, baseUrl: \"https://example.com\" }."
1020
+ });
1021
+ if (config.sitemap.defaultPriority !== void 0 && (config.sitemap.defaultPriority < 0 || config.sitemap.defaultPriority > 1)) errors.push({
1022
+ field: "sitemap.defaultPriority",
1023
+ message: `sitemap.defaultPriority must be between 0.0 and 1.0 (got ${config.sitemap.defaultPriority}).`,
1024
+ value: config.sitemap.defaultPriority
1025
+ });
1026
+ }
1027
+ if (config.budget != null && typeof config.budget === "object") {
1028
+ if (config.budget.firstLoadJs !== void 0 && (typeof config.budget.firstLoadJs !== "number" || config.budget.firstLoadJs <= 0)) errors.push({
1029
+ field: "budget.firstLoadJs",
1030
+ message: `budget.firstLoadJs must be a positive number in bytes (got ${JSON.stringify(config.budget.firstLoadJs)}).`,
1031
+ value: config.budget.firstLoadJs,
1032
+ suggestion: "Example: budget: { firstLoadJs: 150_000 } for a ~150 kB limit."
1033
+ });
1034
+ }
1035
+ if (config.cache != null && typeof config.cache === "object") {
1036
+ if (config.cache.strictKeyDiscipline !== void 0 && typeof config.cache.strictKeyDiscipline !== "boolean") errors.push({
1037
+ field: "cache.strictKeyDiscipline",
1038
+ message: `cache.strictKeyDiscipline must be a boolean (got ${JSON.stringify(config.cache.strictKeyDiscipline)}).`,
1039
+ value: config.cache.strictKeyDiscipline,
1040
+ suggestion: "Use cache: { strictKeyDiscipline: true } to promote key-discipline warnings to errors."
1041
+ });
1042
+ }
1043
+ const MOVED_TO_CACHE_FILE = /* @__PURE__ */ new Set(["cacheHandler", "cdnPurge"]);
1044
+ for (const key of Object.keys(config)) if (!knownKeys.has(key)) errors.push({
1045
+ field: key,
1046
+ message: `Unknown config option: "${key}".`,
1047
+ suggestion: MOVED_TO_CACHE_FILE.has(key) ? `"${key}" has moved to timber.cache.ts. Export cacheHandler as default, cdnPurge as a named export.` : `Check for typos. Known options: ${[...knownKeys].sort().join(", ")}.`
1048
+ });
1049
+ return errors;
1050
+ }
1051
+ /**
1052
+ * Why one `allowedOrigins` entry can never match, or null when it can.
1053
+ *
1054
+ * The CSRF check compares entries to the request's `Origin` header by
1055
+ * exact string, and browsers send only the canonical form — scheme, host,
1056
+ * and non-default port, lowercased, no path. So an entry that is not its
1057
+ * own `new URL(x).origin` (`https://example.com/`, `https://Example.com`,
1058
+ * `example.com`) silently matches nothing. `"null"` is refused outright:
1059
+ * it is the `Origin` of every opaque context at once.
1060
+ */
1061
+ function allowedOriginError(entry) {
1062
+ const field = "allowedOrigins";
1063
+ const fatal = true;
1064
+ if (typeof entry !== "string") return {
1065
+ field,
1066
+ message: `allowedOrigins contains a non-string value: ${JSON.stringify(entry)}.`,
1067
+ value: entry,
1068
+ fatal
1069
+ };
1070
+ if (entry === "null") return {
1071
+ field,
1072
+ message: "allowedOrigins cannot contain \"null\". Browsers send Origin: null from every opaque context — sandboxed iframes (an attacker's <iframe sandbox> included), POSTs redirected across origins, and file: pages — so allowing it allows all of them.",
1073
+ value: entry,
1074
+ suggestion: "To accept a cross-site POST on one endpoint, handle it in a route.ts that exports `const csrf = false` instead.",
1075
+ fatal
1076
+ };
1077
+ if (entry.includes("*")) return {
1078
+ field,
1079
+ message: `allowedOrigins entry ${JSON.stringify(entry)} uses a wildcard. Matching is exact; wildcards are not supported.`,
1080
+ value: entry,
1081
+ suggestion: "List each origin, e.g. [\"https://app.example.com\", \"https://admin.example.com\"].",
1082
+ fatal
1083
+ };
1084
+ const canonical = canonicalOrigin(entry) ?? canonicalOrigin(`https://${entry}`);
1085
+ if (canonical === entry) return null;
1086
+ return {
1087
+ field,
1088
+ message: `allowedOrigins entry ${JSON.stringify(entry)} is not a canonical origin, so it can never match a request's Origin header.`,
1089
+ value: entry,
1090
+ suggestion: canonical ? `Did you mean "${canonical}"? An origin is scheme://host[:port] — lowercase, no path or trailing slash.` : "An origin is scheme://host[:port], e.g. \"https://app.example.com\".",
1091
+ fatal
1092
+ };
1093
+ }
1094
+ /** `new URL(x).origin` for an http(s) URL, or null. Opaque origins are not origins here. */
1095
+ function canonicalOrigin(value) {
1096
+ try {
1097
+ const url = new URL(value);
1098
+ return url.protocol === "http:" || url.protocol === "https:" ? url.origin : null;
1099
+ } catch {
1100
+ return null;
1101
+ }
1102
+ }
1103
+ var RED = "\x1B[31m";
1104
+ var BOLD = "\x1B[1m";
1105
+ var DIM = "\x1B[2m";
1106
+ var RESET = "\x1B[0m";
1107
+ /**
1108
+ * Format config errors for terminal output. Pass `color: false` for text
1109
+ * that goes into a thrown `Error` — escapes there reach CI logs and the
1110
+ * Vite overlay as raw bytes.
1111
+ */
1112
+ function formatConfigErrors(errors, { color = true } = {}) {
1113
+ if (errors.length === 0) return "";
1114
+ const [red, bold, dim, reset] = color ? [
1115
+ RED,
1116
+ BOLD,
1117
+ DIM,
1118
+ RESET
1119
+ ] : [
1120
+ "",
1121
+ "",
1122
+ "",
1123
+ ""
1124
+ ];
1125
+ const lines = [];
1126
+ lines.push(`${red}${bold}[timber]${reset} ${red}${errors.length} config error${errors.length !== 1 ? "s" : ""} in timber.config.ts:${reset}`);
1127
+ for (const err of errors) {
1128
+ lines.push("");
1129
+ lines.push(` ${red}✗${reset} ${bold}${err.field}${reset}: ${err.message}`);
1130
+ if (err.suggestion) lines.push(` ${dim}${err.suggestion}${reset}`);
1131
+ }
1132
+ return lines.join("\n");
1133
+ }
1134
+ /**
1135
+ * Surface config errors at startup: non-fatal ones are written to stderr
1136
+ * (Vite may still work partially, and the message guides the fix); fatal
1137
+ * ones then stop startup with a thrown error. Non-fatal errors are written
1138
+ * first so a fatal one does not hide them.
1139
+ */
1140
+ function reportConfigErrors(errors, write = (text) => process.stderr.write(text)) {
1141
+ const warnings = errors.filter((e) => !e.fatal);
1142
+ if (warnings.length > 0) write(`${formatConfigErrors(warnings)}\n\n`);
1143
+ const fatal = errors.filter((e) => e.fatal);
1144
+ if (fatal.length > 0) throw new Error(formatConfigErrors(fatal, { color: false }));
1145
+ }
1146
+ var VIRTUAL_MODULE_NAMES = {
1147
+ "virtual:timber-rsc-entry": "RSC entry (server component handler)",
1148
+ "virtual:timber-ssr-entry": "SSR entry (HTML renderer)",
1149
+ "virtual:timber-browser-entry": "Browser entry (client hydration)",
1150
+ "virtual:timber-config": "Runtime config (timber.config.ts)",
1151
+ "virtual:timber-route-manifest": "Route manifest (app/ file tree)",
1152
+ "virtual:timber-instrumentation": "Instrumentation (instrumentation.ts)",
1153
+ "virtual:timber-cache-handler": "Cache handler (timber.cache.ts)",
1154
+ "virtual:timber-build-manifest": "Build manifest (asset mapping)"
1155
+ };
1156
+ /**
1157
+ * Add timber-specific context to an error message that references virtual modules.
1158
+ *
1159
+ * If the error message contains a `virtual:timber-*` ID, appends a
1160
+ * human-readable explanation. Does not replace the original message.
1161
+ */
1162
+ function addVirtualModuleContext(errorMessage) {
1163
+ for (const [id, name] of Object.entries(VIRTUAL_MODULE_NAMES)) if (errorMessage.includes(id)) return `${errorMessage}\n\n [timber] This error references "${id}" — timber's ${name}.\n This is an internal module. The issue is likely in your app code or timber configuration.`;
1164
+ return errorMessage;
1165
+ }
1166
+ /**
1167
+ * Required (non-optional) peer dependencies that must be installed.
1168
+ */
1169
+ var REQUIRED_PEERS = [
1170
+ "react",
1171
+ "react-dom",
1172
+ "@vitejs/plugin-react",
1173
+ "@vitejs/plugin-rsc"
1174
+ ];
1175
+ /**
1176
+ * Check that required peer dependencies are installed.
1177
+ *
1178
+ * Uses require.resolve with a try/catch — no fs scanning.
1179
+ * Returns only the missing packages.
1180
+ */
1181
+ function checkPeerDependencies(projectRoot) {
1182
+ const results = [];
1183
+ const userRequire = createRequire(`${projectRoot}/package.json`);
1184
+ for (const name of REQUIRED_PEERS) try {
1185
+ userRequire.resolve(name);
1186
+ results.push({
1187
+ name,
1188
+ status: "ok"
1189
+ });
1190
+ } catch {
1191
+ results.push({
1192
+ name,
1193
+ status: "missing"
1194
+ });
1195
+ }
1196
+ return results;
1197
+ }
1198
+ /**
1199
+ * Format missing peer dependencies as an actionable warning.
1200
+ */
1201
+ function formatMissingPeers(results) {
1202
+ const missing = results.filter((r) => r.status === "missing");
1203
+ if (missing.length === 0) return "";
1204
+ const names = missing.map((r) => r.name);
1205
+ const lines = [];
1206
+ lines.push(`${RED}${BOLD}[timber]${RESET} ${RED}Missing required dependencies:${RESET}`);
1207
+ lines.push("");
1208
+ for (const name of names) lines.push(` ${RED}✗${RESET} ${name}`);
1209
+ lines.push("");
1210
+ lines.push(` ${DIM}Install with:${RESET}`);
1211
+ lines.push(` ${BOLD}pnpm add ${names.join(" ")}${RESET}`);
1212
+ return lines.join("\n");
1213
+ }
1214
+ /** HMR custom event name for graph-affecting file changes. */
1215
+ var GRAPH_UPDATE_EVENT = "timber:graph-update";
1216
+ /**
1217
+ * Host-header allowlist check, ported branch-for-branch from Vite's
1218
+ * host-validation middleware (`isHostAllowedWithoutCache`) so this
1219
+ * endpoint's reachability matches the rest of the dev server:
1220
+ *
1221
+ * - `allowedHosts: true` allows everything
1222
+ * - a MISSING Host header is allowed (Vite parity — HTTP/1.0 probes)
1223
+ * - any IP-literal host is allowed (`vite --host` LAN access sends
1224
+ * `Host: 192.168.x.x:port`; rejecting it would 403 this endpoint
1225
+ * while every other dev route works)
1226
+ * - `localhost` and `*.localhost` are always allowed
1227
+ * - allowedHosts entries: exact match, or `.suffix` subdomain entries
1228
+ */
1229
+ function isAllowedGraphHost(hostHeader, allowedHosts) {
1230
+ if (allowedHosts === true) return true;
1231
+ if (hostHeader === void 0) return true;
1232
+ let host = hostHeader;
1233
+ const bracket = host.match(/^\[([^\]]+)\](?::\d+)?$/);
1234
+ if (bracket) return isIP(bracket[1]) === 6;
1235
+ const colon = host.lastIndexOf(":");
1236
+ if (colon !== -1) host = host.slice(0, colon);
1237
+ host = host.toLowerCase();
1238
+ if (isIP(host) !== 0) return true;
1239
+ if (host === "localhost" || host.endsWith(".localhost")) return true;
1240
+ for (const entry of allowedHosts ?? []) {
1241
+ const allowed = entry.toLowerCase();
1242
+ if (allowed.startsWith(".")) {
1243
+ if (host === allowed.slice(1) || host.endsWith(allowed)) return true;
1244
+ } else if (host === allowed) return true;
1245
+ }
1246
+ return false;
1247
+ }
1248
+ /**
1249
+ * Non-http(s) origins admitted without a host check: Vite's own
1250
+ * `file:` / `*-extension:` set (its host-validation regex), plus
1251
+ * `vscode-webview:` — VS Code webviews fetch with that Origin, and the
1252
+ * extension is this endpoint's primary consumer. Vite itself never
1253
+ * origin-checks plain HTTP GETs (only WebSocket upgrades), so this
1254
+ * layer is strictly additional; the additions keep it from rejecting
1255
+ * consumers Vite would serve.
1256
+ *
1257
+ * NOT admitted: `Origin: null`. Browsers serialize file:// pages'
1258
+ * opaque origin as the literal string `null` — but so do sandboxed
1259
+ * iframes and data: documents, exactly the untrusted embedders the
1260
+ * check exists to stop, and the header offers nothing to tell them
1261
+ * apart. file:// pages therefore cannot use this endpoint from a
1262
+ * browser; the `file:` scheme entry covers non-browser clients that
1263
+ * send a real scheme-form Origin (Vite admits the same set).
1264
+ */
1265
+ var TRUSTED_ORIGIN_SCHEMES = /^(?:file|vscode-webview|.+-extension):/i;
1266
+ /** Origin check: absent is fine (CLI probe); present must pass the host allowlist. */
1267
+ function isAllowedGraphOrigin(originHeader, allowedHosts) {
1268
+ if (originHeader === void 0) return true;
1269
+ if (TRUSTED_ORIGIN_SCHEMES.test(originHeader)) return true;
1270
+ let originUrl;
1271
+ try {
1272
+ originUrl = new URL(originHeader);
1273
+ } catch {
1274
+ return false;
1275
+ }
1276
+ if (originUrl.host === "") return false;
1277
+ const bareHost = originUrl.hostname.replace(/^\[|\]$/g, "");
1278
+ if (isIP(bareHost) !== 0) {
1279
+ if (bareHost === "127.0.0.1" || bareHost === "::1") return true;
1280
+ if (allowedHosts === true) return true;
1281
+ return (allowedHosts ?? []).some((entry) => entry.toLowerCase() === bareHost);
1282
+ }
1283
+ return isAllowedGraphHost(originUrl.host, allowedHosts);
1284
+ }
1285
+ function sendJson(res, status, body) {
1286
+ res.statusCode = status;
1287
+ res.setHeader("content-type", "application/json; charset=utf-8");
1288
+ res.end(JSON.stringify(body));
1289
+ }
1290
+ /**
1291
+ * Echo an ADMITTED origin back as CORS headers. A webview fetch from
1292
+ * `vscode-webview://…` passes the origin check but the browser rejects
1293
+ * the response body without `Access-Control-Allow-Origin` — the exact
1294
+ * transport design/47 specifies for the extension. Only the validated
1295
+ * origin is echoed (never `*`), with `Vary: Origin` for any cache in
1296
+ * between; unadmitted origins were already 403'd and get nothing.
1297
+ */
1298
+ function reflectCors(res, origin) {
1299
+ if (!origin) return;
1300
+ res.setHeader("Access-Control-Allow-Origin", origin);
1301
+ res.setHeader("Vary", "Origin");
1302
+ }
1303
+ /**
1304
+ * Create the Connect middleware handling GET /__timber/graph.
1305
+ *
1306
+ * Query surface: `?file=<path>` (absolute or project-root-relative) or
1307
+ * `?all=1`. Anything else is a 400 — fail loudly, like the CLI.
1308
+ */
1309
+ function createGraphEndpointMiddleware(server, ctx) {
1310
+ const sourceExtensions = buildSourceExtensions(ctx.config.pageExtensions);
1311
+ return async (req, res, next) => {
1312
+ const rawUrl = req.url;
1313
+ if (!rawUrl || !rawUrl.startsWith("/__timber/")) {
1314
+ next();
1315
+ return;
1316
+ }
1317
+ const url = new URL(rawUrl, "http://placeholder.invalid");
1318
+ if (url.pathname !== "/__timber/graph") {
1319
+ sendJson(res, 404, { error: `unknown /__timber/ endpoint: ${url.pathname}` });
1320
+ return;
1321
+ }
1322
+ if (req.method !== "GET") {
1323
+ res.setHeader("Allow", "GET");
1324
+ sendJson(res, 405, { error: "GET only" });
1325
+ return;
1326
+ }
1327
+ const origin = req.headers.origin;
1328
+ const allowedHosts = server.config.server.allowedHosts;
1329
+ if (!server.config.server.https && !isAllowedGraphHost(req.headers.host, allowedHosts)) {
1330
+ sendJson(res, 403, { error: "host not allowed" });
1331
+ return;
1332
+ }
1333
+ if (!isAllowedGraphOrigin(origin, allowedHosts)) {
1334
+ sendJson(res, 403, { error: "origin not allowed" });
1335
+ return;
1336
+ }
1337
+ reflectCors(res, origin);
1338
+ try {
1339
+ const { classifyLiveFile, classifyLiveProject } = await import("./live-graph-9cSnn_h9.js");
1340
+ const preserveSymlinks = server.config.resolve.preserveSymlinks;
1341
+ const root = normalizePath(preserveSymlinks ? ctx.root : await realpath(ctx.root));
1342
+ const appDir = normalizePath(preserveSymlinks ? ctx.appDir : await realpath(ctx.appDir).catch(() => join(root, relative(ctx.root, ctx.appDir))));
1343
+ const liveCtx = {
1344
+ rsc: server.environments.rsc.moduleGraph,
1345
+ ssr: server.environments.ssr.moduleGraph,
1346
+ client: server.environments.client.moduleGraph,
1347
+ root,
1348
+ appDir,
1349
+ pageExtensions: ctx.config.pageExtensions
1350
+ };
1351
+ const allParam = url.searchParams.get("all");
1352
+ if (allParam !== null && allParam !== "1") {
1353
+ sendJson(res, 400, { error: `unsupported all value: ${allParam} (use ?all=1)` });
1354
+ return;
1355
+ }
1356
+ if (allParam === "1") {
1357
+ sendJson(res, 200, {
1358
+ version: 1,
1359
+ source: "dev-server",
1360
+ cached: false,
1361
+ ...await classifyLiveProject(liveCtx)
1362
+ });
1363
+ return;
1364
+ }
1365
+ const fileParam = url.searchParams.get("file");
1366
+ if (!fileParam) {
1367
+ sendJson(res, 400, { error: "missing ?file=<path> (or ?all=1)" });
1368
+ return;
1369
+ }
1370
+ const absolute = normalizePath(isAbsolute(fileParam) ? resolve(fileParam) : resolve(root, fileParam));
1371
+ let target;
1372
+ try {
1373
+ const physical = normalizePath(await realpath(absolute));
1374
+ const rootPhysical = preserveSymlinks ? normalizePath(await realpath(root)) : root;
1375
+ if (physical !== rootPhysical && !physical.startsWith(rootPhysical + "/") && !physical.startsWith(rootPhysical + "\\")) {
1376
+ sendJson(res, 404, { error: `not a project file under ${root}` });
1377
+ return;
1378
+ }
1379
+ if (preserveSymlinks) {
1380
+ if (physical !== rootPhysical + absolute.slice(root.length)) {
1381
+ sendJson(res, 404, { error: `not a project source file: ${absolute}` });
1382
+ return;
1383
+ }
1384
+ }
1385
+ target = normalizePath(preserveSymlinks ? absolute : physical);
1386
+ } catch {
1387
+ sendJson(res, 404, { error: `file not found: ${absolute}` });
1388
+ return;
1389
+ }
1390
+ if (target !== root && !target.startsWith(root + "/") && !target.startsWith(root + "\\")) {
1391
+ sendJson(res, 404, { error: `not a project file under ${root}` });
1392
+ return;
1393
+ }
1394
+ if (!(await stat(target).catch(() => null))?.isFile() || !isScannableSourceFile(normalizePath(target), normalizePath(root), sourceExtensions)) {
1395
+ sendJson(res, 404, { error: `not a project source file: ${target}` });
1396
+ return;
1397
+ }
1398
+ const errors = [];
1399
+ const module = await classifyLiveFile(target, liveCtx, void 0, errors);
1400
+ sendJson(res, 200, {
1401
+ version: 1,
1402
+ source: "dev-server",
1403
+ cached: false,
1404
+ target: {
1405
+ input: fileParam,
1406
+ resolved: target
1407
+ },
1408
+ kind: module.kind,
1409
+ pending: module.pending,
1410
+ subtreeUnknown: module.subtreeUnknown,
1411
+ envs: module.envs,
1412
+ boundary: module.boundary,
1413
+ chains: module.chains,
1414
+ poisonings: module.poisonings,
1415
+ errors
1416
+ });
1417
+ } catch (error) {
1418
+ sendJson(res, 500, { error: error instanceof Error ? error.message : String(error) });
1419
+ }
1420
+ };
1421
+ }
1422
+ /**
1423
+ * Build the push channel: `timber:graph-update` custom HMR events per
1424
+ * project-source change. Consumers (the VS Code extension) re-query
1425
+ * and debounce on their side; the channel just emits. Non-source noise
1426
+ * (build output, dotdirs) is filtered by the same extension set the
1427
+ * scanners use.
1428
+ *
1429
+ * Two phases per edit, because one is not enough (codex review, PR
1430
+ * #1057): the `invalidated` event fires from the plugin's `hotUpdate`
1431
+ * hook — after Vite clears the module's transform result, but its
1432
+ * importer EDGES are only rebuilt when the module is next transformed.
1433
+ * The `transformed` event fires for exactly the files with a pending
1434
+ * invalidation, and only once the node's `transformResult` is set
1435
+ * again — the plugin transform hook itself runs BEFORE Vite's trailing
1436
+ * `vite:import-analysis` (which rebuilds the edges), so the hook only
1437
+ * marks the file "settling" and a short bounded timer confirms
1438
+ * completion via `isTransformed` before emitting. (A module nothing
1439
+ * re-requests never re-transforms — its `transformed` event waits for
1440
+ * the next render, which is also when the graph has new information.)
1441
+ */
1442
+ function makeGraphUpdateChannel(ctx, send, isTransformed, canonicalize = (file) => file) {
1443
+ /** Files invalidated but not yet re-transformed, per environment. */
1444
+ const pending = /* @__PURE__ */ new Set();
1445
+ const key = (file, environment) => `${environment}\0${file}`;
1446
+ const root = normalizePath(canonicalize(ctx.root));
1447
+ const extensions = buildSourceExtensions(ctx.config.pageExtensions);
1448
+ const emitTransformed = (file, environment, structural) => {
1449
+ send({
1450
+ type: "custom",
1451
+ event: GRAPH_UPDATE_EVENT,
1452
+ data: structural ? {
1453
+ file,
1454
+ event: "update",
1455
+ environment,
1456
+ phase: "transformed",
1457
+ structural: true
1458
+ } : {
1459
+ file,
1460
+ event: "update",
1461
+ environment,
1462
+ phase: "transformed"
1463
+ }
1464
+ });
1465
+ };
1466
+ /**
1467
+ * Confirm the transform request finished (transformResult set again)
1468
+ * before emitting phase `transformed`. If confirmation never arrives
1469
+ * within the bounded schedule below, the pending key is RE-ARMED
1470
+ * rather than emitted — a `transformed` event over a still-stale
1471
+ * graph would be a false all-clear with no corrective event.
1472
+ */
1473
+ /**
1474
+ * Delays between confirmation re-checks: dense while a normal
1475
+ * transform request finishes, then exponential backoff for slow
1476
+ * import-analysis passes (large graphs, cold dep optimizer) — a
1477
+ * completed slow transform is CACHED, so no later transform hook may
1478
+ * ever fire for it and the tail checks are the only chance to emit.
1479
+ * Total window ≈ 16 s, then give up (bounded — the async-safety
1480
+ * rules ban open-ended polling) and re-arm the pending key.
1481
+ */
1482
+ const CONFIRM_DELAYS_MS = [
1483
+ ...Array.from({ length: 25 }, () => 20),
1484
+ 500,
1485
+ 1e3,
1486
+ 2e3,
1487
+ 4e3,
1488
+ 8e3
1489
+ ];
1490
+ const confirmAndEmit = (file, environment, attempt = 0, structural = false) => {
1491
+ if (!isTransformed || isTransformed(file, environment)) {
1492
+ emitTransformed(file, environment, structural);
1493
+ return;
1494
+ }
1495
+ if (attempt >= CONFIRM_DELAYS_MS.length) {
1496
+ if (!structural) pending.add(key(file, environment));
1497
+ return;
1498
+ }
1499
+ setTimeout(() => confirmAndEmit(file, environment, attempt + 1, structural), CONFIRM_DELAYS_MS[attempt]);
1500
+ };
1501
+ return {
1502
+ onHotUpdate(update) {
1503
+ const file = normalizePath(canonicalize(update.file));
1504
+ if (!isScannableSourceFile(file, root, extensions)) return;
1505
+ if (update.type === "delete") pending.delete(key(file, update.environment));
1506
+ else pending.add(key(file, update.environment));
1507
+ send({
1508
+ type: "custom",
1509
+ event: GRAPH_UPDATE_EVENT,
1510
+ data: {
1511
+ file,
1512
+ event: update.type,
1513
+ environment: update.environment,
1514
+ phase: "invalidated"
1515
+ }
1516
+ });
1517
+ },
1518
+ onTransform(id, environment) {
1519
+ const file = normalizePath(id.split("?")[0]);
1520
+ if (file.includes("virtual:timber-route-manifest")) {
1521
+ confirmAndEmit(file, environment, 25, true);
1522
+ return;
1523
+ }
1524
+ const pendingKey = key(file, environment);
1525
+ if (!pending.has(pendingKey)) return;
1526
+ pending.delete(pendingKey);
1527
+ confirmAndEmit(file, environment);
1528
+ }
1529
+ };
1530
+ }
1531
+ //#endregion
1532
+ //#region src/server/compress.ts
1533
+ /**
1534
+ * MIME types that benefit from compression.
1535
+ * text/* is handled via prefix matching; these are the specific
1536
+ * application/* and image/* types that are compressible.
1537
+ */
1538
+ var COMPRESSIBLE_TYPES = /* @__PURE__ */ new Set([
1539
+ "text/html",
1540
+ "text/css",
1541
+ "text/plain",
1542
+ "text/xml",
1543
+ "text/javascript",
1544
+ RSC_CONTENT_TYPE,
1545
+ "application/json",
1546
+ "application/javascript",
1547
+ "application/xml",
1548
+ "application/xhtml+xml",
1549
+ "application/rss+xml",
1550
+ "application/atom+xml",
1551
+ "image/svg+xml"
1552
+ ]);
1553
+ /**
1554
+ * Status codes that should never be compressed (no body or special semantics).
1555
+ */
1556
+ var NO_COMPRESS_STATUSES = /* @__PURE__ */ new Set([204, 304]);
1557
+ /**
1558
+ * Parse Accept-Encoding and return the best supported encoding.
1559
+ * Returns 'gzip' if the client accepts it, null otherwise.
1560
+ *
1561
+ * Brotli (br) is intentionally not handled at the application level.
1562
+ * At the streaming-friendly quality levels (0–4), brotli's compression
1563
+ * ratio advantage over gzip is marginal, and node:zlib's brotli transform
1564
+ * buffers output internally — turning smooth streaming responses into
1565
+ * large infrequent bursts. Brotli's real wins come from offline/static
1566
+ * compression at higher quality levels (5–11), which CDNs and reverse
1567
+ * proxies (Cloudflare, nginx, Caddy) apply on cached responses.
1568
+ *
1569
+ * See design/25-production-deployments.md.
1570
+ */
1571
+ function negotiateEncoding(acceptEncoding) {
1572
+ if (!acceptEncoding) return null;
1573
+ const parts = acceptEncoding.split(",");
1574
+ for (const part of parts) {
1575
+ const [token, ...params] = part.split(";");
1576
+ if (token.trim().toLowerCase() !== "gzip") continue;
1577
+ let qValue = 1;
1578
+ for (const param of params) {
1579
+ const trimmed = param.trim().toLowerCase();
1580
+ if (trimmed.startsWith("q=")) {
1581
+ qValue = parseFloat(trimmed.slice(2));
1582
+ if (Number.isNaN(qValue)) qValue = 1;
1583
+ break;
1584
+ }
1585
+ }
1586
+ if (qValue > 0) return "gzip";
1587
+ }
1588
+ return null;
1589
+ }
1590
+ /**
1591
+ * Determine if a response should be compressed.
1592
+ *
1593
+ * Returns false for:
1594
+ * - Responses without a body (204, 304, null body)
1595
+ * - Already-encoded responses (Content-Encoding set)
1596
+ * - Non-compressible content types (images, binary)
1597
+ * - SSE streams (text/event-stream — must not be buffered)
1598
+ */
1599
+ function shouldCompress(response) {
1600
+ if (!response.body) return false;
1601
+ if (NO_COMPRESS_STATUSES.has(response.status)) return false;
1602
+ if (response.headers.has("Content-Encoding")) return false;
1603
+ const contentType = response.headers.get("Content-Type");
1604
+ if (!contentType) return false;
1605
+ const mimeType = contentType.split(";")[0].trim().toLowerCase();
1606
+ if (mimeType === "text/event-stream") return false;
1607
+ return COMPRESSIBLE_TYPES.has(mimeType);
1608
+ }
1609
+ /**
1610
+ * Compress a Web Response if the client supports it and the content is compressible.
1611
+ *
1612
+ * Returns the original response unchanged if compression is not applicable.
1613
+ * Returns a new Response with the compressed body, Content-Encoding, and Vary headers.
1614
+ *
1615
+ * The body is piped through a compression stream — no buffering of the full response.
1616
+ * This preserves streaming behavior for HTML shell + deferred Suspense chunks.
1617
+ */
1618
+ function compressResponse(request, response) {
1619
+ if (!shouldCompress(response)) return response;
1620
+ const encoding = negotiateEncoding(request.headers.get("Accept-Encoding") ?? "");
1621
+ if (!encoding) return response;
1622
+ const compressedBody = compressWithGzip(response.body);
1623
+ const headers = new Headers(response.headers);
1624
+ headers.set("Content-Encoding", encoding);
1625
+ headers.delete("Content-Length");
1626
+ const existingVary = headers.get("Vary");
1627
+ if (existingVary) {
1628
+ if (!existingVary.toLowerCase().includes("accept-encoding")) headers.set("Vary", `${existingVary}, Accept-Encoding`);
1629
+ } else headers.set("Vary", "Accept-Encoding");
1630
+ return new Response(compressedBody, {
1631
+ status: response.status,
1632
+ statusText: response.statusText,
1633
+ headers
1634
+ });
1635
+ }
1636
+ /**
1637
+ * Compress a ReadableStream with gzip, flushing each chunk immediately.
1638
+ *
1639
+ * Uses node:zlib's createGzip with Z_SYNC_FLUSH to ensure each HTML chunk
1640
+ * (shell, Suspense resolution, RSC payload) is delivered to the browser
1641
+ * as soon as it's available — preserving streaming semantics.
1642
+ */
1643
+ function compressWithGzip(body) {
1644
+ const gzip = createGzip({ flush: constants.Z_SYNC_FLUSH });
1645
+ const nodeInput = Readable.fromWeb(body);
1646
+ pipeline(nodeInput, gzip, () => {});
1647
+ return Readable.toWeb(gzip);
1648
+ }
1649
+ //#endregion
1650
+ //#region src/plugins/dev-server.ts
1651
+ var dev_server_exports = /* @__PURE__ */ __exportAll({
1652
+ RESTART_EXIT_CODE: () => 75,
1653
+ timberDevServer: () => timberDevServer,
1654
+ toWebRequest: () => toWebRequest
1655
+ });
1656
+ var RSC_ENTRY_ID = "virtual:timber-rsc-entry";
1657
+ /**
1658
+ * Config file names that trigger a full dev server restart when changed.
1659
+ * See 21-dev-server.md §HMR Wiring — config is loaded once at startup.
1660
+ */
1661
+ var CONFIG_FILE_NAMES = [
1662
+ "timber.config.ts",
1663
+ "timber.config.js",
1664
+ "timber.config.mjs"
1665
+ ];
1666
+ /**
1667
+ * URL prefixes that are Vite-internal and should never be intercepted.
1668
+ * These are passed through to Vite's built-in middleware.
1669
+ */
1670
+ var VITE_INTERNAL_PREFIXES = [
1671
+ "/@",
1672
+ "/__vite",
1673
+ "/node_modules/"
1674
+ ];
1675
+ /**
1676
+ * File extensions that indicate static asset requests.
1677
+ * These are passed through to Vite's static file serving.
1678
+ */
1679
+ var ASSET_EXTENSIONS = /\.(?:js|ts|tsx|jsx|css|map|json|svg|png|jpg|jpeg|gif|webp|avif|ico|woff|woff2|ttf|eot|mp4|webm|ogg|mp3|wav)(?:\?.*)?$/;
1680
+ /**
1681
+ * Create the timber-dev-server Vite plugin.
1682
+ *
1683
+ * Hook: configureServer (returns post-hook to register after Vite's middleware)
1684
+ */
1685
+ function timberDevServer(ctx) {
1686
+ let graphChannel = null;
1687
+ return {
1688
+ name: "timber-dev-server",
1689
+ apply: "serve",
1690
+ /**
1691
+ * Push channel for the graph endpoint, phase 1: `invalidated`, one
1692
+ * per (file, environment). Emitted from hotUpdate — which runs
1693
+ * AFTER Vite invalidates the environment module graphs — never
1694
+ * from a raw watcher listener, which would race consumers into
1695
+ * querying pre-invalidation memberships (design/47 §"Dev-server
1696
+ * endpoint").
1697
+ */
1698
+ hotUpdate({ file, type }) {
1699
+ graphChannel?.onHotUpdate({
1700
+ file,
1701
+ type,
1702
+ environment: this.environment.name
1703
+ });
1704
+ },
1705
+ /**
1706
+ * Push channel phase 2: `transformed`, when a pending-invalidated
1707
+ * module's import edges are actually rebuilt. A Set lookup for
1708
+ * everything without a pending invalidation — free on the hot
1709
+ * path. Returning nothing leaves the code untouched.
1710
+ */
1711
+ transform(_code, id) {
1712
+ graphChannel?.onTransform(id, this.environment.name);
1713
+ },
1714
+ /**
1715
+ * Register the dev server middleware and config file watcher.
1716
+ *
1717
+ * Registers as a pre-hook (no return value) so our middleware runs
1718
+ * before Vite's built-in SPA fallback / historyApiFallback. This
1719
+ * ensures we see the original URL (e.g. /blog) rather than a
1720
+ * rewritten /index.html. Vite-internal and asset requests are
1721
+ * filtered out explicitly and passed through to Vite.
1722
+ */
1723
+ async configureServer(server) {
1724
+ const configPaths = CONFIG_FILE_NAMES.map((name) => join(ctx.root, name));
1725
+ server.watcher.add(configPaths);
1726
+ const configPathSet = new Set(configPaths);
1727
+ const hasSupervisor = Boolean(process.env.__TIMBER_DEV_WORKER);
1728
+ const onConfigChange = (filePath) => {
1729
+ if (!configPathSet.has(filePath)) return;
1730
+ if (hasSupervisor) {
1731
+ console.log(`\n[timber] ${basename(filePath)} changed — restarting dev server...\n`);
1732
+ process.exit(75);
1733
+ } else {
1734
+ console.log(`\n[timber] ${basename(filePath)} changed — restarting dev server...\n[timber] Run \`timber dev\` instead of \`vite dev\` for guaranteed fresh config on restart.\n`);
1735
+ server.restart();
1736
+ }
1737
+ };
1738
+ server.watcher.on("change", onConfigChange);
1739
+ server.watcher.on("add", onConfigChange);
1740
+ server.watcher.on("unlink", onConfigChange);
1741
+ listenForClientErrors(server, ctx.root);
1742
+ server.middlewares.use(createGraphEndpointMiddleware(server, ctx));
1743
+ graphChannel = makeGraphUpdateChannel(ctx, (payload) => server.hot.send(payload), (file, environment) => {
1744
+ const graph = server.environments[environment]?.moduleGraph;
1745
+ if (!graph) return false;
1746
+ const nodes = graph.getModulesByFile(file);
1747
+ if (nodes) {
1748
+ for (const node of nodes) if (node.transformResult != null) return true;
1749
+ return false;
1750
+ }
1751
+ return graph.getModuleById(file)?.transformResult != null;
1752
+ }, (file) => {
1753
+ if (server.config?.resolve?.preserveSymlinks || file.includes("virtual:")) return file;
1754
+ try {
1755
+ return realpathSync(file);
1756
+ } catch {
1757
+ try {
1758
+ return join(realpathSync(dirname(file)), basename(file));
1759
+ } catch {
1760
+ return file;
1761
+ }
1762
+ }
1763
+ });
1764
+ server.middlewares.use(createTimberMiddleware(server, ctx));
1765
+ registerDevDiscovery(server.httpServer, ctx.root, server.config);
1766
+ if (ctx.holdingServer) {
1767
+ await ctx.holdingServer.close().catch(() => {});
1768
+ ctx.holdingServer = null;
1769
+ }
1770
+ ctx.timer.end("dev-server-setup");
1771
+ const summary = ctx.timer.formatSummary();
1772
+ if (summary) console.log(summary);
1773
+ }
1774
+ };
1775
+ }
1776
+ /**
1777
+ * Create the Connect middleware that routes requests through the timber pipeline.
1778
+ *
1779
+ * For route requests (HTML pages, API endpoints), the middleware:
1780
+ * 1. Loads the RSC entry via ssrLoadModule
1781
+ * 2. Converts the Node request to a Web Request
1782
+ * 3. Passes it through the RSC handler (which runs the full pipeline)
1783
+ * 4. Converts the Web Response back to a Node response
1784
+ *
1785
+ * For non-route requests (assets, Vite internals, HMR), the middleware
1786
+ * calls next() to let Vite handle them.
1787
+ */
1788
+ function createTimberMiddleware(server, ctx) {
1789
+ const projectRoot = ctx.root;
1790
+ const hmrOptions = extractHmrOptions(server.config);
1791
+ return async (req, res, next) => {
1792
+ const url = req.url;
1793
+ if (!url) {
1794
+ next();
1795
+ return;
1796
+ }
1797
+ if (isViteInternal(url)) {
1798
+ next();
1799
+ return;
1800
+ }
1801
+ if (isPublicFile(server, url)) {
1802
+ next();
1803
+ return;
1804
+ }
1805
+ if (isAssetRequest(url) && !isMetadataRouteServePath(url) && !isRouteOwnedAsset(ctx.routeTree, server, url)) {
1806
+ next();
1807
+ return;
1808
+ }
1809
+ let handler;
1810
+ try {
1811
+ const rscEnv = server.environments.rsc;
1812
+ if (!rscEnv?.runner?.import) throw new Error("[timber] RSC environment is not runnable");
1813
+ const rscModule = await rscEnv.runner.import(RSC_ENTRY_ID);
1814
+ handler = rscModule.default;
1815
+ const setDevHooks = rscModule.setDevHooks;
1816
+ setDevHooks?.({
1817
+ onPipelineError: (error) => {
1818
+ sendErrorToOverlay(server, error, classifyErrorPhase(error, projectRoot), projectRoot);
1819
+ },
1820
+ hmrOptions
1821
+ });
1822
+ } catch (error) {
1823
+ if (error instanceof Error) {
1824
+ addTimberContext(error);
1825
+ sendErrorToOverlay(server, error, "module-transform", projectRoot);
1826
+ }
1827
+ respond500(res, error, "module-transform", projectRoot, hmrOptions);
1828
+ return;
1829
+ }
1830
+ if (typeof handler !== "function") {
1831
+ console.error("[timber] RSC entry module does not export a default function");
1832
+ next();
1833
+ return;
1834
+ }
1835
+ try {
1836
+ const webRequest = toWebRequest(req);
1837
+ const wrapper = server[Symbol.for("timber:dev-request-wrapper")];
1838
+ const finalResponse = compressResponse(webRequest, wrapper ? await wrapper(() => handler(webRequest)) : await handler(webRequest));
1839
+ res.writeHead(finalResponse.status, [...finalResponse.headers].flat());
1840
+ res.flushHeaders();
1841
+ await sendNodeResponse(res, finalResponse);
1842
+ } catch (error) {
1843
+ if (error instanceof Error) {
1844
+ const phase = classifyErrorPhase(error, projectRoot);
1845
+ sendErrorToOverlay(server, error, phase, projectRoot);
1846
+ respond500(res, error, phase, projectRoot, hmrOptions);
1847
+ } else {
1848
+ process.stderr.write(`\x1b[31m[timber] Dev server error:\x1b[0m ${String(error)}\n`);
1849
+ respond500(res, error, "render", projectRoot, hmrOptions);
1850
+ }
1851
+ }
1852
+ };
1853
+ }
1854
+ /**
1855
+ * Send a 500 response without crashing the dev server.
1856
+ *
1857
+ * In dev mode, renders a styled HTML error page with source context,
1858
+ * classified stack trace, and auto-reload on HMR. Falls back to
1859
+ * text/plain if the HTML generator fails (must never crash).
1860
+ */
1861
+ function respond500(res, error, phase, projectRoot, hmrOptions) {
1862
+ if (res.headersSent) return;
1863
+ if (error instanceof Error) try {
1864
+ const html = generateDevErrorPage(error, phase, projectRoot, hmrOptions);
1865
+ res.statusCode = 500;
1866
+ res.setHeader("content-type", "text/html; charset=utf-8");
1867
+ res.end(html);
1868
+ return;
1869
+ } catch (e) {
1870
+ console.debug("[timber] dev error page generation failed, falling back to text/plain:", e instanceof Error ? e.message : e);
1871
+ }
1872
+ res.statusCode = 500;
1873
+ res.setHeader("content-type", "text/plain");
1874
+ res.end(`[timber] Internal server error\n\n${error instanceof Error ? error.stack ?? error.message : String(error)}`);
1875
+ }
1876
+ /**
1877
+ * Add timber-specific context to an error's message if it references
1878
+ * internal virtual modules (virtual:timber-*). Mutates the error in place.
1879
+ */
1880
+ function addTimberContext(error) {
1881
+ const enriched = addVirtualModuleContext(error.message);
1882
+ if (enriched !== error.message) error.message = enriched;
1883
+ }
1884
+ /**
1885
+ * Convert a Node IncomingMessage to a Web Request.
1886
+ *
1887
+ * Constructs the full URL from the Host header and request URL,
1888
+ * and forwards the method, headers, and body.
1889
+ *
1890
+ * The scheme comes from the socket's TLS state — with `server.https` the
1891
+ * browser sends `Origin: https://host`, and a hardcoded `http://` would
1892
+ * fail CSRF origin comparison on every POST. X-Forwarded-Proto is NOT
1893
+ * consulted: dev connections are direct, so the header would be
1894
+ * attacker-controlled. (TIM-1067, B32)
1895
+ *
1896
+ * Exported for tests.
1897
+ */
1898
+ function toWebRequest(nodeReq) {
1899
+ const protocol = nodeReq.socket?.encrypted ? "https" : "http";
1900
+ const host = nodeReq.headers.host ?? nodeReq.headers[":authority"] ?? "localhost";
1901
+ const url = `${protocol}://${host}${nodeReq.url}`;
1902
+ const headers = new Headers();
1903
+ for (const [key, value] of Object.entries(nodeReq.headers)) {
1904
+ if (value === void 0) continue;
1905
+ if (key.startsWith(":")) continue;
1906
+ if (Array.isArray(value)) for (const v of value) headers.append(key, v);
1907
+ else headers.set(key, value);
1908
+ }
1909
+ if (!headers.has("host")) headers.set("host", host);
1910
+ const method = nodeReq.method ?? "GET";
1911
+ const hasBody = method !== "GET" && method !== "HEAD";
1912
+ return new Request(url, {
1913
+ method,
1914
+ headers,
1915
+ body: hasBody ? nodeReadableToWebStream(nodeReq) : void 0,
1916
+ duplex: hasBody ? "half" : void 0
1917
+ });
1918
+ }
1919
+ /**
1920
+ * Convert a Node Readable stream to a Web ReadableStream.
1921
+ */
1922
+ function nodeReadableToWebStream(nodeStream) {
1923
+ return new ReadableStream({ start(controller) {
1924
+ nodeStream.on("data", (chunk) => {
1925
+ controller.enqueue(new Uint8Array(chunk));
1926
+ });
1927
+ nodeStream.on("end", () => {
1928
+ controller.close();
1929
+ });
1930
+ nodeStream.on("error", (err) => {
1931
+ controller.error(err);
1932
+ });
1933
+ } });
1934
+ }
1935
+ /**
1936
+ * Check if a URL is a Vite-internal request that should be passed through.
1937
+ */
1938
+ function isViteInternal(url) {
1939
+ return VITE_INTERNAL_PREFIXES.some((prefix) => url.startsWith(prefix));
1940
+ }
1941
+ /**
1942
+ * Check if a URL looks like a static asset request.
1943
+ */
1944
+ function isAssetRequest(url) {
1945
+ return ASSET_EXTENSIONS.test(url);
1946
+ }
1947
+ /**
1948
+ * Check if a URL maps to a real file in the project's public/ directory.
1949
+ * Vite serves public/ files as static assets — if a file exists there it
1950
+ * must be passed through to Vite regardless of extension.
1951
+ */
1952
+ function isPublicFile(server, url) {
1953
+ const { publicDir } = server.config;
1954
+ if (!publicDir) return false;
1955
+ const pathname = url.split("?")[0];
1956
+ const relativePath = pathname.startsWith("/") ? pathname.slice(1) : pathname;
1957
+ if (!relativePath) return false;
1958
+ const fullPath = join(publicDir, relativePath);
1959
+ try {
1960
+ return statSync(fullPath).isFile();
1961
+ } catch {
1962
+ return false;
1963
+ }
1964
+ }
1965
+ /**
1966
+ * Check whether an asset-extension URL belongs to a scanned route rather
1967
+ * than a static file.
1968
+ *
1969
+ * Route handlers may live at paths ending in asset-like extensions
1970
+ * (app/feed.json/route.ts → /feed.json), which the asset bypass would
1971
+ * otherwise hand to Vite — 404ing in dev while working in production.
1972
+ * Uses the same canonicalization and tree walker as the runtime matcher
1973
+ * so dev classification agrees with what the pipeline would match.
1974
+ *
1975
+ * A file that actually exists on disk wins over the route match: the
1976
+ * production server serves public/ statics before the RSC handler (see
1977
+ * adapters/nitro.ts), and Vite serves root-relative source files (e.g.
1978
+ * /app/global.css) in dev. Without this, a broad catch-all route like
1979
+ * app/[...slug] would shadow every static asset. Joining the canonical
1980
+ * pathname is traversal-safe — canonicalize() resolves `..` segments and
1981
+ * rejects root escapes and encoded separators.
1982
+ *
1983
+ * Reads ctx.routeTree per request — the routing plugin rescans it on
1984
+ * file add/unlink/change, so newly created routes are picked up live.
1985
+ */
1986
+ function isRouteOwnedAsset(routeTree, server, url) {
1987
+ if (!routeTree) return false;
1988
+ const rawPathname = url.split("?")[0];
1989
+ const result = canonicalize(rawPathname);
1990
+ if (!result.ok) return false;
1991
+ const parts = result.pathname === "/" ? [] : result.pathname.slice(1).split("/");
1992
+ if (matchUrlParts(routeTree.root, parts) === null) return false;
1993
+ const relativePath = result.pathname.slice(1);
1994
+ const { publicDir, root } = server.config;
1995
+ if (publicDir && existsSync(join(publicDir, relativePath))) return false;
1996
+ if (existsSync(join(root, relativePath))) return false;
1997
+ return true;
1998
+ }
1999
+ /**
2000
+ * Listen for client-side errors forwarded from the browser via HMR.
2001
+ *
2002
+ * The browser entry catches uncaught errors and unhandled rejections,
2003
+ * then sends them as 'timber:client-error' custom events. We parse
2004
+ * the first app frame for the overlay's loc field and forward the
2005
+ * error to Vite's overlay protocol.
2006
+ */
2007
+ function listenForClientErrors(server, projectRoot) {
2008
+ server.hot.on("timber:client-error", (data) => {
2009
+ const loc = parseFirstAppFrame(data.stack, projectRoot);
2010
+ let message = data.message;
2011
+ if (data.componentStack) message = `${data.message}\n\nComponent Stack:\n${data.componentStack.trim()}`;
2012
+ const RED = "\x1B[31m";
2013
+ const BOLD = "\x1B[1m";
2014
+ const RESET = "\x1B[0m";
2015
+ process.stderr.write(`${RED}${BOLD}[timber] Client Error${RESET}\n${RED}${data.message}${RESET}\n\n`);
2016
+ try {
2017
+ server.hot.send({
2018
+ type: "error",
2019
+ err: {
2020
+ message,
2021
+ stack: data.stack,
2022
+ id: loc?.file,
2023
+ plugin: "timber (Client)",
2024
+ loc: loc ? {
2025
+ file: loc.file,
2026
+ line: loc.line,
2027
+ column: loc.column
2028
+ } : void 0
2029
+ }
2030
+ });
2031
+ } catch (e) {
2032
+ console.debug("[timber] overlay send failed:", e instanceof Error ? e.message : e);
2033
+ }
2034
+ });
2035
+ }
2036
+ //#endregion
2037
+ export { reportConfigErrors as a, formatMissingPeers as i, timberDevServer as n, validateConfig as o, checkPeerDependencies as r, dev_server_exports as t };
2038
+
2039
+ //# sourceMappingURL=dev-server-v97rQH4b.js.map