void 1.11.0 → 1.12.1

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 (361) hide show
  1. package/dist/{account-cmd-Bbr5cHjm.mjs → account-cmd-BU1Fy_Bf.mjs} +6 -6
  2. package/dist/{agents-DRo8gzni.mjs → agents-64FnLwxP.mjs} +6 -5
  3. package/dist/{application-analysis-XyUuNqYA.mjs → application-analysis-DVeN8yoi.mjs} +48 -22
  4. package/dist/{application-routing-DATqynKH.mjs → application-routing-KKw4Y84h.mjs} +1 -1
  5. package/dist/{assets-DZBd7yqh.mjs → assets-Br6_BeFJ.mjs} +34 -27
  6. package/dist/{ast-Cv0JwXqb.mjs → ast-BkPQu7A0.mjs} +5 -1
  7. package/dist/{auth-BN0NU9dz.mjs → auth-A7cZ8aXA.mjs} +1 -1
  8. package/dist/{auth-CCk9Seol.mjs → auth-CqwJwItO.mjs} +24 -12
  9. package/dist/{auth-link-CVxoyU81.mjs → auth-link-Duu2NvN5.mjs} +6 -6
  10. package/dist/{auth-router-ChXKduRM.mjs → auth-router-vgtOdb9j.mjs} +5 -5
  11. package/dist/{better-auth-shared-B8W8tZxP.d.mts → better-auth-shared-BS3pDQbT.d.mts} +6 -6
  12. package/dist/{better-auth-shared-DRHo5FoG.mjs → better-auth-shared-BcqDt-37.mjs} +7 -2
  13. package/dist/{build-cmd-C3b13rRf.mjs → build-cmd-B7OJ0U5R.mjs} +13 -12
  14. package/dist/build-id-4IV4hC1-.mjs +13 -0
  15. package/dist/{cache-B1WzZV60.mjs → cache-wSpi3aeM.mjs} +6 -6
  16. package/dist/{cancel-deploy-BggXixU_.mjs → cancel-deploy-DMWzkAlb.mjs} +5 -5
  17. package/dist/{cf-access-Dnyw8KFY.mjs → cf-access-DHklo7Rg.mjs} +41 -23
  18. package/dist/{cf-access-pejlJmuy.mjs → cf-access-DmkKPcAI.mjs} +0 -8
  19. package/dist/{cf-build-output-bBx1gDll.mjs → cf-build-output-Cso7Vh-t.mjs} +31 -27
  20. package/dist/cf-build-output-Wpk_e5CI.mjs +1 -0
  21. package/dist/{cf-command-values-Ccl-zRhl.mjs → cf-command-values-5BPBRc9Z.mjs} +1 -1
  22. package/dist/cf-config-migrate-D271BTiw.mjs +1664 -0
  23. package/dist/{cf-worker-settings-CARs4Wy9.mjs → cf-worker-settings-BBdlhm9U.mjs} +1 -1
  24. package/dist/cli/cli.mjs +1 -1
  25. package/dist/cli/cloudflare-operation-process.mjs +17 -14
  26. package/dist/cli/db-execute-process.d.mts +2 -0
  27. package/dist/cli/db-execute-process.mjs +57 -0
  28. package/dist/cli/env-schema-probe.d.mts +3 -1
  29. package/dist/cli/env-schema-probe.mjs +7 -8
  30. package/dist/{cli-main-DW09sVsT.mjs → cli-main-BrChcpE3.mjs} +152 -405
  31. package/dist/{client-DF6U7KLP.mjs → client-DE2m2ldh.mjs} +186 -17
  32. package/dist/{client-DGfZTE4V.mjs → client-eLZwqkPH.mjs} +1 -1
  33. package/dist/{cloudflare-auth-pNvmT6kL.mjs → cloudflare-auth-eWfhdZCk.mjs} +1 -1
  34. package/dist/{cloudflare-cmd-BOhToob3.mjs → cloudflare-cmd-SsFlJe2B.mjs} +7 -8
  35. package/dist/{cloudflare-config-D1dMHbvz.mjs → cloudflare-config-D9UFH_A5.mjs} +2 -2
  36. package/dist/{cloudflare-connect-DTrsIBAa.mjs → cloudflare-connect-BgpHcSg3.mjs} +3 -3
  37. package/dist/{cloudflare-operations-DmqtzoX4.mjs → cloudflare-operations-BIRQkYwL.mjs} +26 -28
  38. package/dist/cloudflare-operations-ByjFGats.mjs +1 -0
  39. package/dist/cloudflare-process-60r4Z2Zf.mjs +671 -0
  40. package/dist/cloudflare-user-output-CCR99eQY.mjs +19 -0
  41. package/dist/collect-B6nlSnsb.mjs +1 -0
  42. package/dist/{collect-C6Blu9yw.mjs → collect-rNLybAnF.mjs} +3 -3
  43. package/dist/{config-Do7gJI3T.mjs → config-BFX5ZB1J.mjs} +5 -4
  44. package/dist/{config-CeZd67L0.mjs → config-BSoW3QCB.mjs} +5 -5
  45. package/dist/{config-DYW2TBgz.d.mts → config-DA6ZbLXO.d.mts} +1 -1
  46. package/dist/{config-dMSpL-ml.mjs → config-DtjrUtPo.mjs} +1 -1
  47. package/dist/{config-BmvqLnbi.mjs → config-Dv5jri1-.mjs} +4 -4
  48. package/dist/config-entry.d.mts +1 -1
  49. package/dist/{connect-B3bKxRzX.mjs → connect-D0V0o40j.mjs} +9 -9
  50. package/dist/{create-project-DLUlxmf5.mjs → create-project-8FdN6D2i.mjs} +7 -6
  51. package/dist/{create-project-By7ymK7F.mjs → create-project-CbuDH5Hv.mjs} +1 -1
  52. package/dist/{db-3qsP21pH.mjs → db-BNPIjLkK.mjs} +1450 -154
  53. package/dist/db-args-BvMwAber.mjs +1 -0
  54. package/dist/db-args-CiQVg8SJ.mjs +321 -0
  55. package/dist/db-seed-loader-Bcz_SutQ.mjs +253 -0
  56. package/dist/{db-types-DC7KJLx2.mjs → db-types-B4Cf9dzR.mjs} +1 -1
  57. package/dist/{delete-HbFqgEFC.mjs → delete-WtLEfap2.mjs} +6 -6
  58. package/dist/{deploy-2QjsBEGw.mjs → deploy-BgSbagIP.mjs} +218 -553
  59. package/dist/deploy-Do6FWqon.mjs +2 -0
  60. package/dist/{deploy-managed-static-JoNP3cec.mjs → deploy-managed-static-BWBsxOww.mjs} +115 -194
  61. package/dist/deploy-security-notice-IRGy6Edf.mjs +192 -0
  62. package/dist/{deploy-transport-QAkhJYRI.mjs → deploy-transport-BKP_oV9q.mjs} +4 -4
  63. package/dist/deploy.mjs +9 -9
  64. package/dist/{dev-inbox-BiamQEAa.mjs → dev-inbox-ClVjKEHy.mjs} +1 -1
  65. package/dist/direct-r2-upload-DFXLWfXV.mjs +204 -0
  66. package/dist/discover-D2KGP3cR.mjs +1 -0
  67. package/dist/{discover-Vd18lHsj.mjs → discover-IcspacCg.mjs} +1 -1
  68. package/dist/{dispatch-BlOYh1Vc.mjs → dispatch-DIhDA3NI.mjs} +11 -10
  69. package/dist/{dist-Cp4b1_T9.mjs → dist-C47zy_kJ.mjs} +1 -1
  70. package/dist/{dist-STQXl8ck.mjs → dist-Cr_xGE_K.mjs} +73 -38
  71. package/dist/{domain-COkVSfII.mjs → domain-mweyYXSw.mjs} +8 -10
  72. package/dist/{dotenv-CEI8hapP.mjs → dotenv-BG6RQavH.mjs} +2 -2
  73. package/dist/{drizzle-BXVOa6Jg.mjs → drizzle-BJDMPrj7.mjs} +3 -4
  74. package/dist/{drizzle-CvSGrvdl.mjs → drizzle-CQ5jWuDL.mjs} +1 -1
  75. package/dist/{email-Dj02fLgQ.mjs → email-DcQNP40O.mjs} +33 -30
  76. package/dist/{email-cloudflare-DDknDAgp.mjs → email-cloudflare-DeYH3Ke7.mjs} +29 -38
  77. package/dist/{email-pattern-BYr-EFq5.mjs → email-pattern-bRna9MOJ.mjs} +2 -2
  78. package/dist/{entry-DMgR7XOf.mjs → entry-Bwb9ev8K.mjs} +13 -10
  79. package/dist/{env-BA7e5yzp.mjs → env-DaAoYR2-.mjs} +8 -8
  80. package/dist/{env-UqS-21xi.mjs → env-EjHqc7m9.mjs} +1 -1
  81. package/dist/{env-types-WEZw5D-r.mjs → env-types-D2hBodXP.mjs} +2 -19
  82. package/dist/{env-validation-DfJ9Fzfa.mjs → env-validation-D-v5_CWL.mjs} +13 -13
  83. package/dist/{env-validation-ly_Q9Kgd.mjs → env-validation-j9pjCDfA.mjs} +1 -1
  84. package/dist/{error-pages-QNeBXiRR.mjs → error-pages-GORL6F_e.mjs} +1 -1
  85. package/dist/{fetch-CbI6lNnk.d.mts → fetch-CczQyIed.d.mts} +1 -1
  86. package/dist/{fetch-DdK9eGin.mjs → fetch-CiEsvjpP.mjs} +1 -1
  87. package/dist/{fetch-stream-DQAavFdm.mjs → fetch-stream-BIG5lHW6.mjs} +3 -4
  88. package/dist/{fetch-stream-DoED9atq.d.mts → fetch-stream-DRX8-83b.d.mts} +2 -2
  89. package/dist/{gen-EMpnzNGz.mjs → gen-aOtHhZLD.mjs} +21 -18
  90. package/dist/gen-vhBDHs3q.mjs +1 -0
  91. package/dist/{generate-BOp1g1H_.mjs → generate-C3ZAqCy-.mjs} +1 -1
  92. package/dist/{generate-CWb8aOsm.mjs → generate-Dq2Bgw75.mjs} +6 -6
  93. package/dist/{git-metadata-Cukp5kV5.mjs → git-metadata-BEokJ6US.mjs} +1 -1
  94. package/dist/{github-cmd-8bXgJNAQ.mjs → github-cmd-BR19Ffdz.mjs} +14 -9
  95. package/dist/{handler-w_FAiIRu.mjs → handler-DCrDLzw2.mjs} +3 -3
  96. package/dist/has-own-key-D9QEnAkF.mjs +5 -0
  97. package/dist/{head-0o0QoREY.mjs → head-BwQ5kgqt.mjs} +5 -4
  98. package/dist/{head-CVO92KEx.d.mts → head-fUp8n_QJ.d.mts} +9 -4
  99. package/dist/{headers-BjgvlY29.mjs → headers-DqBsjDxg.mjs} +7 -7
  100. package/dist/{help-DCQKp3Kp.mjs → help-DvClCzqL.mjs} +138 -60
  101. package/dist/help-fKPzcTJv.mjs +1 -0
  102. package/dist/{inbound-BHt4dIlL.d.mts → inbound-CwgZSqFI.d.mts} +9 -3
  103. package/dist/{inbound--OF7zkwX.mjs → inbound-feMn1Rxx.mjs} +7 -7
  104. package/dist/{index-CmqHYj2R.d.mts → index-8cAgNdb6.d.mts} +1 -1
  105. package/dist/{index-BTmhCDbw.d.mts → index-BQ5qYiAw.d.mts} +2 -2
  106. package/dist/{index-BESZTC1z.d.mts → index-BYcWajVp.d.mts} +2 -1
  107. package/dist/{index-BXdP39qx.d.mts → index-Dn2mkPr2.d.mts} +24 -23
  108. package/dist/index.d.mts +2 -2
  109. package/dist/index.mjs +344 -637
  110. package/dist/{info--jdAIsJN.mjs → info-P6MBiVJi.mjs} +4 -4
  111. package/dist/{init-BLZvktk_.mjs → init-C8YpkGIP.mjs} +124 -345
  112. package/dist/installed-packages-tfmYd-cC.mjs +198 -0
  113. package/dist/{isr-config-Czzb4mIq.mjs → isr-config-DiTnL9Tb.mjs} +5 -5
  114. package/dist/{link-DPJ4jN7y.mjs → link-Dyz9IGcM.mjs} +7 -7
  115. package/dist/{list-B-au6xJt.mjs → list-VGYBMjmx.mjs} +11 -7
  116. package/dist/{live-DvtxTUhW.mjs → live-dvGThbwy.mjs} +14 -17
  117. package/dist/{load-user-env-BltIJLtl.mjs → load-user-env-B8qC0Q2Y.mjs} +1 -1
  118. package/dist/{local-d1-C6xn26Nl.mjs → local-d1-CYOYkVwO.mjs} +3 -3
  119. package/dist/{login-p1_BMgXg.mjs → login-CWFr-G2I.mjs} +8 -6
  120. package/dist/login-DECm3e9b.mjs +1 -0
  121. package/dist/{logs-UNH3vQeX.mjs → logs-kS1wuR4b.mjs} +9 -9
  122. package/dist/{migrate-9dlt6Mxu.mjs → migrate-BNZL1hee.mjs} +9 -10
  123. package/dist/migrate-C9aoWLvY.mjs +1 -0
  124. package/dist/{migrations-Cbns2RAm.mjs → migrations-CUHhX65Y.mjs} +5 -5
  125. package/dist/{mime-BGoZ8ZLL.mjs → mime-Btw9R3CC.mjs} +26 -12
  126. package/dist/module-references-DWQmO6TW.mjs +27 -0
  127. package/dist/mysql-lock-D8xtnI-D.mjs +145 -0
  128. package/dist/mysql-sql-BIE7bc4Z.mjs +124 -0
  129. package/dist/nitro.d.mts +3 -0
  130. package/dist/nitro.mjs +14 -5
  131. package/dist/{node-DqkiQujF.mjs → node-DVJWfV6s.mjs} +6 -6
  132. package/dist/{operator-ai-logging-BQ6mOgQs.mjs → operator-ai-logging-DD0n6zc2.mjs} +11 -10
  133. package/dist/operator-args-nvetCWuz.mjs +1499 -0
  134. package/dist/{operator-auth-CD3pap65.mjs → operator-auth-DMvn-y9X.mjs} +2 -2
  135. package/dist/{operator-client-XvXTkea6.mjs → operator-client-dFNnXfyB.mjs} +6 -5
  136. package/dist/operator-cmd-CVfK5U0B.mjs +1 -0
  137. package/dist/{operator-cmd-CKbZbNKn.mjs → operator-cmd-a7yOf2tH.mjs} +33 -13
  138. package/dist/operator-security-D5MToU0p.mjs +263 -0
  139. package/dist/{output-Bc8ixgPF.mjs → output-BZLnu0z8.mjs} +13 -3
  140. package/dist/output-D7K9TWIA.mjs +1 -0
  141. package/dist/{package-json-DvS6IFRv.mjs → package-json-4xUI3xLz.mjs} +1 -1
  142. package/dist/pages/client.d.mts +53 -30
  143. package/dist/pages/client.mjs +168 -38
  144. package/dist/pages/head.d.mts +1 -1
  145. package/dist/pages/head.mjs +1 -1
  146. package/dist/pages/index.d.mts +8 -2
  147. package/dist/pages/index.mjs +283 -13
  148. package/dist/pages/islands-plugin.d.mts +26 -8
  149. package/dist/pages/islands-plugin.mjs +61 -22
  150. package/dist/pages/protocol.d.mts +2 -2
  151. package/dist/pages/protocol.mjs +1 -1
  152. package/dist/pages/serialize.mjs +1 -1
  153. package/dist/{pgpass-CEtnBOZO.mjs → pgpass-BLPoYN9_.mjs} +3 -2
  154. package/dist/platform-args-CMwMoiLp.mjs +1 -0
  155. package/dist/{platform-args-DQSMW4EP.mjs → platform-args-CvZSuhYS.mjs} +37 -9
  156. package/dist/{platform-auth-config-D80AKe72.mjs → platform-auth-config-CpszX-Ne.mjs} +26 -23
  157. package/dist/{platform-auth-protection-k1Ox-u9T.mjs → platform-auth-protection-DA6Tw8Og.mjs} +10 -10
  158. package/dist/{platform-auth-recovery-D-hKehPy.mjs → platform-auth-recovery-Cztrb1JC.mjs} +11 -9
  159. package/dist/{platform-cmd-DQ0Wi61H.mjs → platform-cmd-m6Asj6nO.mjs} +11 -11
  160. package/dist/{platform-cmd-Dtz5lw7R.mjs → platform-cmd-u1j88ggF.mjs} +1 -1
  161. package/dist/{platform-discovery-B0eZjZ3B.mjs → platform-discovery-CLxtixHJ.mjs} +1 -1
  162. package/dist/{platform-domain-BMGS4l74.mjs → platform-domain-DJSznNTA.mjs} +14 -10
  163. package/dist/{platform-lifecycle-y4AfmC7M.mjs → platform-lifecycle-BC-9p58d.mjs} +1 -1
  164. package/dist/{platform-lifecycle-BCkNQNsQ.mjs → platform-lifecycle-GFeXv3NC.mjs} +802 -207
  165. package/dist/platform-management-BwHkz46V.mjs +1 -0
  166. package/dist/{platform-management-Cj2aXFqD.mjs → platform-management-DX1zINou.mjs} +227 -58
  167. package/dist/{platform-plans-config-CrUUzEl9.mjs → platform-plans-config-DiydtNKY.mjs} +112 -35
  168. package/dist/{platform-recovery-DKZnALHI.mjs → platform-recovery-CnzBbudV.mjs} +5 -5
  169. package/dist/{platform-registry-DZ_2Xuqd.mjs → platform-registry-DHH6fivm.mjs} +6 -5
  170. package/dist/{platform-setup-CKmSEb1J.mjs → platform-setup-Lph9i-rh.mjs} +26 -12
  171. package/dist/{plugin-inference-B_urWd5Z.mjs → plugin-inference-COlq96WJ.mjs} +28 -53
  172. package/dist/prepare-DcwigRUS.mjs +1 -0
  173. package/dist/{prepare-CU7SZieQ.mjs → prepare-WvijE289.mjs} +3 -3
  174. package/dist/{prepare-vCdm5moJ.mjs → prepare-co1o1FFd.mjs} +12 -12
  175. package/dist/{project-cmd-B4cgPSi4.mjs → project-cmd-BWJTplpc.mjs} +30 -24
  176. package/dist/{project-CLwxcEdq.mjs → project-dh9431bN.mjs} +2 -2
  177. package/dist/{project-paths-CUhCPMpK.mjs → project-paths-2ENfCCih.mjs} +4 -3
  178. package/dist/project-security-BV1xfj1K.mjs +1 -0
  179. package/dist/project-security-CY_aahvW.mjs +1340 -0
  180. package/dist/{project-team-BdX6anO3.mjs → project-team-BlIFXlmT.mjs} +8 -8
  181. package/dist/{project-token-C1rcq8Xb.mjs → project-token-CMsB7I1-.mjs} +6 -6
  182. package/dist/{project-tsconfig-MyRJgufB.mjs → project-tsconfig-BOA4ym99.mjs} +25 -5
  183. package/dist/{project-DVsTAWFh.mjs → project-uXKua1it.mjs} +1 -1
  184. package/dist/project-zero-trust-BI6pdpx4.mjs +210 -0
  185. package/dist/{protocol-W5EQcIzN.mjs → protocol-4rEnumif.mjs} +15 -8
  186. package/dist/{protocol-BlAiF-hc.d.mts → protocol-ERy-n3jf.d.mts} +7 -4
  187. package/dist/{provision-DWnnKdT-.mjs → provision-Bh44omGA.mjs} +30 -22
  188. package/dist/{provision-CGI-T0mq.mjs → provision-DFv7SJDn.mjs} +1 -1
  189. package/dist/{public-B80SwOFp.d.mts → public-DB9C2Cy_.d.mts} +5 -2
  190. package/dist/{raw-7pQirZpQ.mjs → raw-5rak34QN.mjs} +2 -1
  191. package/dist/{redirect-Dqb4fEc5.mjs → redirect-Dyvuil0Q.mjs} +6 -3
  192. package/dist/{requests-D6MaLS_Y.mjs → requests-CfmJxNYg.mjs} +6 -6
  193. package/dist/{resolve-project-Da3OgCU1.mjs → resolve-project-8WZ3iVmr.mjs} +3 -3
  194. package/dist/resolve-project-YsTH-U9I.mjs +1 -0
  195. package/dist/{rollback-Bs8I8PF8.mjs → rollback-DL5HuAsM.mjs} +16 -7
  196. package/dist/route-types-CSed9-Dp.mjs +435 -0
  197. package/dist/{route-url-BBdkU7rb.mjs → route-url-B41eQ8QI.mjs} +1 -1
  198. package/dist/{route-url-Di1kB8D_.d.mts → route-url-Bd6IX-JZ.d.mts} +2 -1
  199. package/dist/routes-stub.d.mts +1 -1
  200. package/dist/routes-stub.mjs +1 -1
  201. package/dist/{runner-CTk21HrO.mjs → runner-Bf94YVJK.mjs} +1 -1
  202. package/dist/{runner-CMZb7jNU.mjs → runner-CeguHWJx.mjs} +3 -2
  203. package/dist/{runner-mysql-CJ-HyqxV.mjs → runner-mysql-D549vGGm.mjs} +14 -9
  204. package/dist/{runner-mysql-C_PrAUTm.mjs → runner-mysql-DOjbj-N1.mjs} +1 -1
  205. package/dist/{runner-pg-mYc75KfH.mjs → runner-pg-Buzw17hl.mjs} +1 -1
  206. package/dist/{runner-pg-2pjltt0t.mjs → runner-pg-DMJquR3d.mjs} +1 -1
  207. package/dist/runtime/ai/index.mjs +2 -2
  208. package/dist/runtime/auth/better-auth-d1.d.mts +1 -1
  209. package/dist/runtime/auth/better-auth-d1.mjs +2 -2
  210. package/dist/runtime/auth/better-auth-mysql.d.mts +1 -1
  211. package/dist/runtime/auth/better-auth-mysql.mjs +2 -2
  212. package/dist/runtime/auth/better-auth-postgres.d.mts +1 -1
  213. package/dist/runtime/auth/better-auth-postgres.mjs +3 -3
  214. package/dist/runtime/client/fetch-server.d.mts +1 -1
  215. package/dist/runtime/client/fetch-server.mjs +2 -2
  216. package/dist/runtime/client/fetch-stream.d.mts +2 -2
  217. package/dist/runtime/client/fetch-stream.mjs +1 -1
  218. package/dist/runtime/client/fetch.d.mts +1 -1
  219. package/dist/runtime/client/fetch.mjs +1 -1
  220. package/dist/runtime/client/index.d.mts +2 -2
  221. package/dist/runtime/client/index.mjs +2 -2
  222. package/dist/runtime/client/react.d.mts +2 -2
  223. package/dist/runtime/client/react.mjs +2 -2
  224. package/dist/runtime/client/solid.d.mts +2 -2
  225. package/dist/runtime/client/solid.mjs +2 -2
  226. package/dist/runtime/client/svelte.d.mts +2 -2
  227. package/dist/runtime/client/svelte.mjs +2 -2
  228. package/dist/runtime/client/vue.d.mts +2 -2
  229. package/dist/runtime/client/vue.mjs +2 -2
  230. package/dist/runtime/db/index.d.mts +1 -1
  231. package/dist/runtime/db/index.mjs +3 -3
  232. package/dist/runtime/db/migrations/mysql-handler.mjs +2 -1
  233. package/dist/runtime/db/migrations/postgres-handler.mjs +1 -1
  234. package/dist/runtime/db/session.d.mts +1 -1
  235. package/dist/runtime/db/session.mjs +1 -1
  236. package/dist/runtime/durable/index.mjs +7 -5
  237. package/dist/runtime/email/index.d.mts +1 -1
  238. package/dist/runtime/email/index.mjs +14 -11
  239. package/dist/runtime/email/testing.d.mts +1 -1
  240. package/dist/runtime/email/testing.mjs +4 -4
  241. package/dist/runtime/env/public-client.d.mts +4 -1
  242. package/dist/runtime/env/public.d.mts +1 -1
  243. package/dist/runtime/env/public.mjs +2 -2
  244. package/dist/runtime/env/runtime.mjs +1 -1
  245. package/dist/runtime/handler/index.d.mts +1 -1
  246. package/dist/runtime/handler/index.mjs +1 -1
  247. package/dist/runtime/handler/validator.d.mts +1 -1
  248. package/dist/runtime/handler/validator.mjs +1 -1
  249. package/dist/runtime/isr/index.mjs +1 -1
  250. package/dist/runtime/kv/index.mjs +1 -1
  251. package/dist/runtime/live/client.d.mts +2 -2
  252. package/dist/runtime/live/client.mjs +7 -7
  253. package/dist/runtime/live/index.d.mts +1 -1
  254. package/dist/runtime/live/index.mjs +1 -1
  255. package/dist/runtime/live/server.mjs +3 -3
  256. package/dist/runtime/queues/index.mjs +2 -2
  257. package/dist/runtime/remote/index.d.mts +5 -1
  258. package/dist/runtime/remote/index.mjs +10 -9
  259. package/dist/runtime/routing/index.d.mts +11 -12
  260. package/dist/runtime/routing/index.mjs +69 -65
  261. package/dist/runtime/routing/route-url.d.mts +1 -1
  262. package/dist/runtime/routing/route-url.mjs +1 -1
  263. package/dist/runtime/sandbox/index.d.mts +1 -1
  264. package/dist/runtime/sandbox/index.mjs +2 -2
  265. package/dist/runtime/sse/client.d.mts +1 -1
  266. package/dist/runtime/sse/index.mjs +1 -1
  267. package/dist/runtime/storage/index.mjs +1 -1
  268. package/dist/runtime/ws/index.d.mts +1 -1
  269. package/dist/runtime/ws/index.mjs +3 -2
  270. package/dist/runtime/ws/room.d.mts +1 -1
  271. package/dist/runtime/ws/room.mjs +2 -2
  272. package/dist/runtime/ws/server.d.mts +2 -2
  273. package/dist/runtime/ws/server.mjs +1 -1
  274. package/dist/{runtime-zDDinDI5.mjs → runtime-C_VPIJBF.mjs} +1 -1
  275. package/dist/{scan-LjuG3vfA.mjs → scan-Ct_SEzH4.mjs} +36 -29
  276. package/dist/{secret-DdUs8AuR.mjs → secret-C-WBaUSS.mjs} +11 -10
  277. package/dist/security-api-types-CU7zQtr_.mjs +9 -0
  278. package/dist/security-sarif-ClyYwtAW.mjs +123 -0
  279. package/dist/{serialize-Pf-CIQK_.mjs → serialize-BmB4BfKu.mjs} +1 -1
  280. package/dist/{server-CfUbeOjx.mjs → server-T-4mn8zy.mjs} +5 -4
  281. package/dist/{session-Cw8-b8Um.mjs → session-BT8XDkvL.mjs} +1 -1
  282. package/dist/{session-DgNrdNh_.d.mts → session-ouZYD7zb.d.mts} +1 -1
  283. package/dist/{skills-B40svMBE.mjs → skills-C-csz78e.mjs} +3 -3
  284. package/dist/{sse-BXnTfcf3.mjs → sse-D3ab0YQT.mjs} +16 -13
  285. package/dist/{static-exports-DFkzL-NX.mjs → static-exports-s7P86Ngp.mjs} +3 -3
  286. package/dist/{subcommand-prompt-D-m3Umap.mjs → subcommand-prompt-B4LOLosl.mjs} +31 -21
  287. package/dist/sveltekit.mjs +1 -1
  288. package/dist/{terminal-log-text-DNsWJREL.mjs → terminal-log-text-CfS2JKM6.mjs} +1 -1
  289. package/dist/{url-DaehRGKR.mjs → url-DBQluotE.mjs} +4 -1
  290. package/dist/validate-CZYUIfR-.mjs +1 -0
  291. package/dist/{validate-Ddzl-IwT.mjs → validate-CtBWCzez.mjs} +7 -4
  292. package/dist/{validator-Duafcnh7.mjs → validator-Dfh9kCDm.mjs} +5 -5
  293. package/dist/{version-metadata-k6KFiyWt.mjs → version-metadata-DqgLa6gc.mjs} +1 -1
  294. package/dist/{wrangler-v2BmVchV.mjs → wrangler-DVe5KV5G.mjs} +49 -46
  295. package/dist/wrangler-Dq269bjx.mjs +1 -0
  296. package/dist/{wrapper-eh6MpBZA.mjs → wrapper-CcMYpOS8.mjs} +45 -171
  297. package/docs/guide/app-types.md +1 -1
  298. package/docs/guide/auth.md +2 -16
  299. package/docs/guide/database.md +2 -0
  300. package/docs/guide/email/domains.md +1 -1
  301. package/docs/guide/email/sending.md +18 -1
  302. package/docs/guide/jobs.md +1 -1
  303. package/docs/guide/pages-routing/actions-and-forms.md +40 -19
  304. package/docs/guide/pages-routing/errors.md +3 -1
  305. package/docs/guide/pages-routing/head.md +20 -2
  306. package/docs/guide/pages-routing/overview.md +20 -0
  307. package/docs/guide/platform/administration/plans.md +13 -0
  308. package/docs/guide/platform/administration/security-audits.md +213 -0
  309. package/docs/guide/platform/administration/zero-trust.md +7 -1
  310. package/docs/guide/platform/installation/ci.md +1 -1
  311. package/docs/guide/platform/installation/credentials.md +23 -20
  312. package/docs/guide/platform/installation/maintenance.md +11 -5
  313. package/docs/guide/platform/installation/prerequisites.md +1 -1
  314. package/docs/guide/platform/installation/uninstall.md +2 -0
  315. package/docs/guide/platform-administration.md +1 -0
  316. package/docs/guide/queues.md +1 -1
  317. package/docs/guide/self-hosted-platform.md +14 -13
  318. package/docs/guide/type-safety.md +1 -1
  319. package/docs/integrations/cloudflare.md +3 -1
  320. package/docs/integrations/frameworks/sveltekit.md +1 -1
  321. package/docs/reference/api/handlers.md +3 -3
  322. package/docs/reference/api/pages.md +4 -0
  323. package/docs/reference/api/types.md +11 -1
  324. package/docs/reference/cli/database.md +42 -6
  325. package/docs/reference/cli/deploy.md +5 -1
  326. package/docs/reference/cli/domains.md +1 -1
  327. package/docs/reference/cli/platform-config.md +5 -3
  328. package/docs/reference/cli/platform-installation.md +29 -28
  329. package/docs/reference/cli/platform-security.md +98 -0
  330. package/docs/reference/cli/platform-zero-trust.md +6 -3
  331. package/docs/reference/cli/platform.md +1 -0
  332. package/docs/reference/cli/project.md +57 -0
  333. package/docs/reference/cli/setup.md +4 -0
  334. package/docs/reference/cli.md +3 -1
  335. package/docs/reference/config.md +2 -2
  336. package/package.json +30 -27
  337. package/skills/void/SKILL.md +7 -0
  338. package/dist/cf-build-output-D3_x71H6.mjs +0 -1
  339. package/dist/cf-config-migrate-CHtnM3_C.mjs +0 -348
  340. package/dist/cloudflare-operations-BditDbcd.mjs +0 -1
  341. package/dist/cloudflare-process-wcnaQ5JG.mjs +0 -392
  342. package/dist/cloudflare-user-output-zEwuGrEJ.mjs +0 -19
  343. package/dist/collect-8i0wU63d.mjs +0 -1
  344. package/dist/deploy-DiFfBu8g.mjs +0 -2
  345. package/dist/discover-Diq0l6TZ.mjs +0 -1
  346. package/dist/gen-CuANrEzy.mjs +0 -1
  347. package/dist/help-7EzLA1qP.mjs +0 -1
  348. package/dist/login-apwve7WD.mjs +0 -1
  349. package/dist/migrate-BzRplq7m.mjs +0 -1
  350. package/dist/mysql-sql-SlpS6OMg.mjs +0 -239
  351. package/dist/operator-args-BCCohcz3.mjs +0 -722
  352. package/dist/operator-cmd-D42knxMz.mjs +0 -1
  353. package/dist/output-D4UOUifX.mjs +0 -1
  354. package/dist/platform-args-Rgp86xa7.mjs +0 -1
  355. package/dist/platform-management-CRzeC70H.mjs +0 -1
  356. package/dist/prepare-C2MTqfFv.mjs +0 -1
  357. package/dist/project-zero-trust-CS02LrlK.mjs +0 -64
  358. package/dist/resolve-project-C5wC-Hoi.mjs +0 -1
  359. package/dist/route-types-CrODgORq.mjs +0 -655
  360. package/dist/validate-DY1U9rET.mjs +0 -1
  361. package/dist/wrangler-BPIAJdxA.mjs +0 -1
package/dist/index.mjs CHANGED
@@ -1,51 +1,54 @@
1
1
  import { n as __toESM } from "./rolldown-runtime-uD8oG6U2.mjs";
2
- import { a as join, c as resolve, i as isAbsolute, n as dirname, o as normalize, s as relative, t as basename } from "./dist-DMYe8CZJ.mjs";
2
+ import { a as join, c as resolve, i as isAbsolute, l as toSlash, n as dirname, s as relative, t as basename } from "./dist-DMYe8CZJ.mjs";
3
3
  import { t as require_picocolors } from "./picocolors-D1NxSLw-.mjs";
4
- import { a as hasSandboxSqliteMigration, c as sandboxContainerConfig, f as scanQueuesSync, h as scanJobsSync, i as assertSandboxNamespaceConfig, n as DEFAULT_SANDBOX_CLASS_NAME, r as SANDBOX_MIGRATION_TAG, s as resolveSandboxConfig, t as analyzeApplicationSync, u as hasEmailHandlers } from "./application-analysis-XyUuNqYA.mjs";
5
- import { l as inferBindingsFromSource, m as applyBindingOverrides, n as FRAMEWORK_SCAN_DIRS, t as DEFAULT_SCAN_DIRS, u as staticModuleReferences } from "./plugin-inference-B_urWd5Z.mjs";
6
- import { a as isAssetBypassRule, d as hasDocumentRoutes, l as edgeRulesNeedWorker, n as mergeRoutingRules, o as isGeneratedAssetHeaders, p as resolveAssetRoutingPolicy, s as resolveAssetWorkerBypass, t as lintRoutingPhases, u as hasApiRoutes } from "./headers-BjgvlY29.mjs";
7
- import { n as readDeploymentPlatform, r as readProjectConfig } from "./project-CLwxcEdq.mjs";
8
- import { A as syncWranglerWebSockets, E as resolveLiveBindingConfig, O as syncWranglerBindings, T as readWranglerWebSocketTombstones, a as LIVE_MIGRATION_TAG, b as readRootWranglerConfig, d as ensureWranglerCompatibilityDate, f as ensureWranglerNodejsAlsFlag, g as normalizeWranglerCompatibilityFlags, h as nextDurableObjectMigrationTag, k as syncWranglerDurableObjects, m as hasDurableObjectSqliteMigration, p as findBindingNameOwner, u as ensureWranglerCompat, v as readExistingLiveBindingConfig, x as readWranglerCompat } from "./wrangler-v2BmVchV.mjs";
9
- import { c as stashCloudflareDeployPointer, i as materializeCloudflareConfig, l as ensureGitignoreLines, o as restoreCloudflarePreviewPointer } from "./cloudflare-config-D1dMHbvz.mjs";
10
- import { a as syncAuthTypesFile, i as removeAuthTypesIfPresent, n as generateQueueTypes, s as syncBindingTypes, t as generateRouteTypes } from "./route-types-CrODgORq.mjs";
11
- import { c as getDatabaseCasing, l as getDatabaseDialect, p as readConfig, u as isNodeTarget } from "./config-BmvqLnbi.mjs";
12
- import { n as writeLocalD1PersistState, t as resolveLocalD1Target } from "./local-d1-C6xn26Nl.mjs";
4
+ import { a as assertSandboxNamespaceConfig, c as resolveSandboxConfig, d as hasEmailHandlers, g as scanJobsSync, i as SANDBOX_MIGRATION_TAG, l as sandboxContainerConfig, n as getNativeWorkerSourceFiles, o as hasSandboxSqliteMigration, p as scanQueuesSync, r as DEFAULT_SANDBOX_CLASS_NAME, t as analyzeApplicationSync } from "./application-analysis-DVeN8yoi.mjs";
5
+ import { l as inferBindingsFromSource, n as FRAMEWORK_SCAN_DIRS, p as applyBindingOverrides, t as DEFAULT_SCAN_DIRS } from "./plugin-inference-COlq96WJ.mjs";
6
+ import { a as isAssetBypassRule, d as hasDocumentRoutes, l as edgeRulesNeedWorker, n as mergeRoutingRules, o as isGeneratedAssetHeaders, p as resolveAssetRoutingPolicy, s as resolveAssetWorkerBypass, t as lintRoutingPhases, u as hasApiRoutes } from "./headers-DqBsjDxg.mjs";
7
+ import { n as readDeploymentPlatform, r as readProjectConfig } from "./project-dh9431bN.mjs";
8
+ import { A as syncWranglerWebSockets, E as resolveLiveBindingConfig, O as syncWranglerBindings, T as readWranglerWebSocketTombstones, a as LIVE_MIGRATION_TAG, b as readRootWranglerConfig, d as ensureWranglerCompatibilityDate, f as ensureWranglerNodejsAlsFlag, g as normalizeWranglerCompatibilityFlags, h as nextDurableObjectMigrationTag, k as syncWranglerDurableObjects, m as hasDurableObjectSqliteMigration, p as findBindingNameOwner, u as ensureWranglerCompat, v as readExistingLiveBindingConfig, x as readWranglerCompat } from "./wrangler-DVe5KV5G.mjs";
9
+ import { c as stashCloudflareDeployPointer, i as materializeCloudflareConfig, l as ensureGitignoreLines, o as restoreCloudflarePreviewPointer } from "./cloudflare-config-D9UFH_A5.mjs";
10
+ import { a as syncAuthTypesFile, i as removeAuthTypesIfPresent, n as generateQueueTypes, s as syncBindingTypes, t as generateRouteTypes } from "./route-types-CSed9-Dp.mjs";
11
+ import { c as getDatabaseCasing, l as getDatabaseDialect, p as readConfig, u as isNodeTarget } from "./config-Dv5jri1-.mjs";
12
+ import { n as writeLocalD1PersistState, t as resolveLocalD1Target } from "./local-d1-CYOYkVwO.mjs";
13
13
  import { i as voidWarn, n as voidError, r as voidLog, t as setShowTimestamp } from "./log-D9hwSySP.mjs";
14
- import { a as getApiUrl, c as getToken, o as getProxyUrl } from "./auth-CCk9Seol.mjs";
15
- import { n as ensurePlatformProxyAccess } from "./cf-access-Dnyw8KFY.mjs";
16
- import { n as scopedAccessCredentials } from "./cf-access-pejlJmuy.mjs";
14
+ import { t as Buffer } from "./node-buffer-D7kgjaDs.mjs";
15
+ import { t as staticModuleReferences } from "./module-references-DWQmO6TW.mjs";
16
+ import { a as getApiUrl, c as getToken, o as getProxyUrl } from "./auth-CqwJwItO.mjs";
17
+ import { n as ensurePlatformProxyAccess } from "./cf-access-DHklo7Rg.mjs";
18
+ import { n as scopedAccessCredentials } from "./cf-access-DmkKPcAI.mjs";
17
19
  import { n as readGeneratedWranglerConfigFile } from "./generated-wrangler-config-CoDaaFsA.mjs";
18
- import { t as migrateBuiltWranglerConfig } from "./cf-config-migrate-CHtnM3_C.mjs";
20
+ import { t as migrateBuiltWranglerConfig } from "./cf-config-migrate-D271BTiw.mjs";
19
21
  import { t as writeFileAtomic } from "./atomic-write-DA6eD1Kp.mjs";
20
- import { a as findReservedEnvKeys, c as loadLocalEnv, i as findLegacyEnvFiles, l as reservedEnvKeysMessage, o as isClientEnvKey, r as LOCAL_ENV_FILE, s as legacyEnvExampleHint, u as resolveRemoteMode } from "./env-UqS-21xi.mjs";
21
- import { n as readProjectPaths, t as assertNoRootSourceConventionConflicts } from "./project-paths-CUhCPMpK.mjs";
22
- import { a as readDeployBuildQueueNames, r as cloudflareQueueName, s as drizzlePlugin, t as generateQueueResolverSource } from "./dispatch-BlOYh1Vc.mjs";
23
- import { _ as parseCapturedMessage, a as DEV_INBOX_ENV_VAR, c as DEV_INBOX_TOKEN_ENV_VAR, f as clearDevBuffer, g as listDevMessages, l as DEV_INBOX_TOKEN_HEADER, m as findDevMessage, n as DEV_INBOX_ACK_VALUE, o as DEV_INBOX_MAX_CAPTURE_BYTES, s as DEV_INBOX_PREFIX, t as DEV_INBOX_ACK_HEADER, u as DEV_INBOX_TOKEN_QUERY, v as pushToDevBuffer } from "./dev-inbox-BiamQEAa.mjs";
22
+ import { a as findReservedEnvKeys, c as loadLocalEnv, i as findLegacyEnvFiles, l as reservedEnvKeysMessage, o as isClientEnvKey, r as LOCAL_ENV_FILE, s as legacyEnvExampleHint, u as resolveRemoteMode } from "./env-EjHqc7m9.mjs";
23
+ import { n as readProjectPaths, t as assertNoRootSourceConventionConflicts } from "./project-paths-2ENfCCih.mjs";
24
+ import { a as readDeployBuildQueueNames, r as cloudflareQueueName, s as drizzlePlugin, t as generateQueueResolverSource } from "./dispatch-DIhDA3NI.mjs";
25
+ import { _ as parseCapturedMessage, a as DEV_INBOX_ENV_VAR, c as DEV_INBOX_TOKEN_ENV_VAR, f as clearDevBuffer, g as listDevMessages, l as DEV_INBOX_TOKEN_HEADER, m as findDevMessage, n as DEV_INBOX_ACK_VALUE, o as DEV_INBOX_MAX_CAPTURE_BYTES, s as DEV_INBOX_PREFIX, t as DEV_INBOX_ACK_HEADER, u as DEV_INBOX_TOKEN_QUERY, v as pushToDevBuffer } from "./dev-inbox-ClVjKEHy.mjs";
24
26
  import { t as MagicString } from "./dist-B6eN80gc.mjs";
25
- import { s as bindingResolver } from "./static-exports-DFkzL-NX.mjs";
26
- import { i as isMemberExpression, n as isIdentifier, r as isLiteral } from "./ast-Cv0JwXqb.mjs";
27
- import { n as findEnvFileForPaths, r as generateEnvTypes, t as findEnvFile } from "./env-types-WEZw5D-r.mjs";
28
- import { i as writeFileIfChanged, r as syncAuthTypesInProjectTsconfig } from "./project-tsconfig-MyRJgufB.mjs";
29
- import { t as loadUserEnvFile } from "./load-user-env-BltIJLtl.mjs";
30
- import { n as scanWranglerDotenvKeys } from "./dotenv-CEI8hapP.mjs";
31
- import { _ as isRouteEnabledForEnvironment, a as createBoundaryManifest, c as resolveLayoutIds, h as invalidateSourceAnalysis, i as patternToRegex } from "./scan-LjuG3vfA.mjs";
32
- import { n as INTERNAL_BINDING_PREFIXES, t as INTERNAL_BINDING_EXACT_NAMES } from "./raw-7pQirZpQ.mjs";
33
- import { t as ASSET_EXTENSIONS } from "./assets-DZBd7yqh.mjs";
34
- import { i as loadVoidAuthConfig, n as devAuthConfigImporter, o as viteAuthConfigImporter, t as AUTH_CONFIG_ENVIRONMENT } from "./config-Do7gJI3T.mjs";
35
- import { a as resolveDistDir, n as collectRevalidate, o as resolveWorkerDirName, r as hasRevalidate, t as collectPages } from "./isr-config-Czzb4mIq.mjs";
27
+ import { s as bindingResolver } from "./static-exports-s7P86Ngp.mjs";
28
+ import { a as isMemberExpression, i as isLiteral, r as isIdentifier, t as asAstProgram } from "./ast-BkPQu7A0.mjs";
29
+ import { n as findEnvFileForPaths, r as generateEnvTypes, t as findEnvFile } from "./env-types-D2hBodXP.mjs";
30
+ import { a as syncAuthTypesInProjectTsconfig, o as writeFileIfChanged } from "./project-tsconfig-BOA4ym99.mjs";
31
+ import { t as loadUserEnvFile } from "./load-user-env-B8qC0Q2Y.mjs";
32
+ import { n as scanWranglerDotenvKeys } from "./dotenv-BG6RQavH.mjs";
33
+ import { _ as isRouteEnabledForEnvironment, a as createBoundaryManifest, c as resolveLayoutIds, h as invalidateSourceAnalysis, i as patternToRegex, x as convertPathToPattern } from "./scan-Ct_SEzH4.mjs";
34
+ import { n as INTERNAL_BINDING_PREFIXES, t as INTERNAL_BINDING_EXACT_NAMES } from "./raw-5rak34QN.mjs";
35
+ import { i as isClientManifest, t as ASSET_EXTENSIONS } from "./assets-Br6_BeFJ.mjs";
36
+ import { r as findVoidDependentPackages, t as findDependencyClosure } from "./installed-packages-tfmYd-cC.mjs";
37
+ import { i as loadVoidAuthConfig, n as devAuthConfigImporter, o as viteAuthConfigImporter, t as AUTH_CONFIG_ENVIRONMENT } from "./config-BFX5ZB1J.mjs";
38
+ import { a as resolveDistDir, n as collectRevalidate, o as resolveWorkerDirName, r as hasRevalidate, t as collectPages } from "./isr-config-DiTnL9Tb.mjs";
36
39
  import { t as assertNoPrerenderFailures } from "./prerender-render-BAdYhivW.mjs";
37
- import { h as prerenderPagesNode, m as prerenderPages, n as SEND_EMAIL_BINDING } from "./email-cloudflare-DDknDAgp.mjs";
38
- import { a as safeJsonStringify } from "./protocol-W5EQcIzN.mjs";
39
- import { n as completeApplicationAnalysis } from "./application-routing-DATqynKH.mjs";
40
- import { a as validateSsrEntries, n as SSR_SERVER_ENTRY_RELATIVE_PATHS, o as validateSsrEntry, t as SSR_CLIENT_ENTRY_RELATIVE_PATHS } from "./entry-DMgR7XOf.mjs";
41
- import { r as selectNativeVersionMetadataBinding, t as CLOUDFLARE_PRESERVE_BINDINGS_BUILD_ENV } from "./version-metadata-k6KFiyWt.mjs";
42
- import { a as defineMiddleware, c as defineScheduled, i as defineHead, n as basicAuth, o as defineQueue, r as defineHandler, s as defineRender, t as VoidAssetRewriteError } from "./handler-w_FAiIRu.mjs";
40
+ import { h as prerenderPagesNode, m as prerenderPages, n as SEND_EMAIL_BINDING } from "./email-cloudflare-DeYH3Ke7.mjs";
41
+ import { a as safeJsonStringify } from "./protocol-4rEnumif.mjs";
42
+ import { n as completeApplicationAnalysis } from "./application-routing-KKw4Y84h.mjs";
43
+ import { a as validateSsrEntries, n as SSR_SERVER_ENTRY_RELATIVE_PATHS, o as validateSsrEntry, r as getSsrServerEntryPath, t as SSR_CLIENT_ENTRY_RELATIVE_PATHS } from "./entry-Bwb9ev8K.mjs";
44
+ import { r as selectNativeVersionMetadataBinding, t as CLOUDFLARE_PRESERVE_BINDINGS_BUILD_ENV } from "./version-metadata-DqgLa6gc.mjs";
45
+ import { a as defineMiddleware, c as defineScheduled, i as defineHead, n as basicAuth, o as defineQueue, r as defineHandler, s as defineRender, t as VoidAssetRewriteError } from "./handler-DCrDLzw2.mjs";
43
46
  import { r as defer } from "./validation-error-CtcAvyI7.mjs";
44
- import module, { builtinModules, createRequire } from "node:module";
47
+ import { builtinModules, createRequire } from "node:module";
45
48
  import { chmodSync, closeSync, cpSync, existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
46
49
  import { createRunnableDevEnvironment, defaultServerConditions, isFileServingAllowed, isRunnableDevEnvironment, loadEnv, normalizePath, parseSync, resolveEnvPrefix } from "vite";
47
50
  import { fileURLToPath, pathToFileURL } from "node:url";
48
- import { appendSqliteClassMigration } from "@void/deploy-core";
51
+ import { appendSqliteClassMigration, isRecord } from "@void/deploy-core";
49
52
  import { randomBytes, timingSafeEqual } from "node:crypto";
50
53
  import { homedir } from "node:os";
51
54
  import { isDeepStrictEqual, parseEnv } from "node:util";
@@ -265,11 +268,15 @@ var DevCssProvider = class {
265
268
  return assets;
266
269
  }
267
270
  };
268
- async function readJsonBody(req) {
271
+ async function readDevCssRootPhases(req) {
269
272
  const chunks = [];
270
273
  for await (const chunk of req) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
271
- if (chunks.length === 0) return {};
272
- return JSON.parse(Buffer.concat(chunks).toString("utf-8"));
274
+ if (chunks.length === 0) return [];
275
+ const body = JSON.parse(Buffer.concat(chunks).toString("utf8"));
276
+ const rootPhases = isRecord(body) ? body.rootPhases : void 0;
277
+ if (!Array.isArray(rootPhases)) return [];
278
+ if (!rootPhases.every((phase) => Array.isArray(phase) && phase.every((url) => typeof url === "string"))) throw new Error("Invalid dev CSS root phases");
279
+ return rootPhases;
273
280
  }
274
281
  function getInternalDevOrigin(server) {
275
282
  const address = server.httpServer?.address();
@@ -284,7 +291,6 @@ function getInternalDevOrigin(server) {
284
291
  }
285
292
  function pagesDevCssAssetsPlugin(root, token) {
286
293
  const edgeStore = createOrderedEdgeStore(root);
287
- let provider = null;
288
294
  let viteServer = null;
289
295
  return [{
290
296
  name: "void:pages-dev-css-assets",
@@ -323,7 +329,17 @@ async function readDevCssResponse(response) {
323
329
  throw new Error("HTTP " + response.status);
324
330
  }
325
331
  const body = await response.json();
326
- return Array.isArray(body.assets) ? body.assets : [];
332
+ const assets = body?.assets;
333
+ if (
334
+ !Array.isArray(assets) ||
335
+ !assets.every((asset) =>
336
+ asset && typeof asset.url === "string" && typeof asset.css === "string" &&
337
+ (asset.id === undefined || typeof asset.id === "string")
338
+ )
339
+ ) {
340
+ throw new Error("Invalid dev CSS assets");
341
+ }
342
+ return assets;
327
343
  }
328
344
 
329
345
  export async function getVoidPagesDevCss(request, env, payload) {
@@ -372,8 +388,8 @@ export async function getVoidPagesDevCss(request, env, payload) {
372
388
  },
373
389
  configureServer(server) {
374
390
  viteServer = server;
375
- provider = new DevCssProvider(server, root, edgeStore);
376
- const invalidate = () => provider?.invalidate();
391
+ const provider = new DevCssProvider(server, root, edgeStore);
392
+ const invalidate = () => provider.invalidate();
377
393
  server.watcher.on("add", invalidate);
378
394
  server.watcher.on("change", invalidate);
379
395
  server.watcher.on("unlink", invalidate);
@@ -402,8 +418,7 @@ export async function getVoidPagesDevCss(request, env, payload) {
402
418
  return;
403
419
  }
404
420
  try {
405
- const body = await readJsonBody(req);
406
- const rootPhases = Array.isArray(body.rootPhases) ? body.rootPhases : [];
421
+ const rootPhases = await readDevCssRootPhases(req);
407
422
  const assets = await provider.collect(rootPhases);
408
423
  res.statusCode = 200;
409
424
  res.setHeader("Content-Type", "application/json");
@@ -494,11 +509,11 @@ function readVoidDevCredentials(root) {
494
509
  * block the server. On completion, writes project.json and restarts the server.
495
510
  */
496
511
  async function runAiSetupPrompt(root, token, apiUrl, server) {
497
- const { select, text, isCancel, log } = await import("./dist-Cp4b1_T9.mjs");
498
- const { PlatformClient } = await import("./client-DGfZTE4V.mjs");
499
- const { attachSelectedPlatform, writeProjectConfig } = await import("./project-DVsTAWFh.mjs");
500
- const { inferDefaultSlug } = await import("./resolve-project-C5wC-Hoi.mjs");
501
- const { printSuccess } = await import("./output-D4UOUifX.mjs");
512
+ const { select, text, isCancel, log } = await import("./dist-C47zy_kJ.mjs");
513
+ const { PlatformClient } = await import("./client-eLZwqkPH.mjs");
514
+ const { attachSelectedPlatform, writeProjectConfig } = await import("./project-uXKua1it.mjs");
515
+ const { inferDefaultSlug } = await import("./resolve-project-YsTH-U9I.mjs");
516
+ const { printSuccess } = await import("./output-D7K9TWIA.mjs");
502
517
  const client = new PlatformClient(token, { apiUrl });
503
518
  let projects;
504
519
  try {
@@ -525,7 +540,7 @@ async function runAiSetupPrompt(root, token, apiUrl, server) {
525
540
  let slug;
526
541
  if (result === "__create__") {
527
542
  const { validateProjectSlug } = await import("./project-slug-BUy0lmyR.mjs");
528
- const { createProjectWithSlugRetry } = await import("./create-project-By7ymK7F.mjs");
543
+ const { createProjectWithSlugRetry } = await import("./create-project-CbuDH5Hv.mjs");
529
544
  let created;
530
545
  try {
531
546
  created = await createProjectWithSlugRetry(client, inferDefaultSlug(root), async (defaultSlug) => {
@@ -547,6 +562,10 @@ async function runAiSetupPrompt(root, token, apiUrl, server) {
547
562
  slug = created.slug;
548
563
  } else {
549
564
  const project = projects.find((p) => p.id === result);
565
+ if (!project) {
566
+ voidError("project: Selected project is unavailable.");
567
+ return;
568
+ }
550
569
  projectId = project.id;
551
570
  slug = project.slug;
552
571
  }
@@ -612,7 +631,7 @@ export const storage = new Proxy({}, {
612
631
  // src/plugin-client-stubs.ts
613
632
  function createClientStubsPlugin() {
614
633
  const STUB_PREFIX = "\0void-client-stub:";
615
- const SERVER_ONLY_STUBS = {
634
+ const stubSources = new Map(Object.entries({
616
635
  "void/db": "export const db = {}; export const createDb = () => ({});",
617
636
  "void/kv": "export const kv = {}; export const createKV = () => ({});",
618
637
  "void/ai": "export const ai = {};",
@@ -658,8 +677,8 @@ function createClientStubsPlugin() {
658
677
  `,
659
678
  "void/live": "",
660
679
  "void/durable": ""
661
- };
662
- const STUB_RESOLVE_FILTER = new RegExp(`^(${Object.keys(SERVER_ONLY_STUBS).join("|").replaceAll("/", "\\/")})$`);
680
+ }));
681
+ const STUB_RESOLVE_FILTER = new RegExp(`^(${Array.from(stubSources.keys()).join("|").replaceAll("/", String.raw`\/`)})$`);
663
682
  const STUB_LOAD_FILTER = new RegExp(`^\\0void-client-stub:`);
664
683
  return {
665
684
  name: "void:client-stubs",
@@ -676,7 +695,7 @@ function createClientStubsPlugin() {
676
695
  load: {
677
696
  filter: { id: STUB_LOAD_FILTER },
678
697
  handler(id) {
679
- return SERVER_ONLY_STUBS[id.slice(18)] ?? "export default {};";
698
+ return stubSources.get(id.slice(18)) ?? "export default {};";
680
699
  }
681
700
  }
682
701
  };
@@ -692,11 +711,11 @@ function mergeCloudflareConfig(patch, fallback) {
692
711
  }
693
712
  return result;
694
713
  }
695
- /** Use Cloudflare's public migration API rather than maintaining a second binding translator. */
714
+ /** Translate Void's Wrangler-shaped settings to the configuration that the Cloudflare plugin takes. */
696
715
  function toNativeCloudflareConfig(raw, root) {
697
716
  const packagePath = join(root, "package.json");
698
717
  const packageName = existsSync(packagePath) ? JSON.parse(readFileSync(packagePath, "utf8")).name : void 0;
699
- const name = String(packageName ?? basename(root)).replaceAll("_", "-").replace(/[^a-z0-9- ]/g, "-").replace(/^(-+)|(-+)$/g, "").slice(0, 63) || "my-worker";
718
+ const name = String(packageName ?? basename(root)).replaceAll("_", "-").replaceAll(/[^a-z0-9- ]/g, "-").replaceAll(/^(-+)|(-+)$/g, "").slice(0, 63) || "my-worker";
700
719
  const { env, vars, ...base } = raw;
701
720
  const selected = process.env.CLOUDFLARE_ENV ? env?.[process.env.CLOUDFLARE_ENV] : void 0;
702
721
  const values = selected ? selected.vars : vars;
@@ -733,11 +752,13 @@ function toNativeCloudflareConfig(raw, root) {
733
752
  * even one with a class of the same name, so it stays as written.
734
753
  */
735
754
  function restoreLocalContainerBindings(worker) {
736
- for (const [name, binding] of Object.entries(worker.env ?? {})) {
755
+ const env = worker.env;
756
+ if (!env) return;
757
+ for (const [name, binding] of Object.entries(env)) {
737
758
  if (binding.type !== "unsafe:durable_object_namespace" || Object.keys(binding).some((key) => !["type", "class_name"].includes(key))) continue;
738
759
  const className = binding.class_name;
739
760
  const declaration = worker.exports?.[className];
740
- if (declaration && "container" in declaration) worker.env[name] = {
761
+ if (declaration && "container" in declaration) env[name] = {
741
762
  type: "durable-object",
742
763
  worker: worker.name,
743
764
  exportName: className
@@ -787,13 +808,14 @@ function withLocalPreviewBindings(plugins, root) {
787
808
  const path = getWorkerConfigPath(directory);
788
809
  const worker = JSON.parse(readFileSync(path, "utf8"));
789
810
  worker.env ??= {};
811
+ const inlineBindingTypes = /* @__PURE__ */ new Set([
812
+ "text",
813
+ "json",
814
+ "secret"
815
+ ]);
790
816
  for (const name of Object.keys(loadLocalEnv(root))) {
791
817
  const binding = worker.env[name];
792
- if (!binding || [
793
- "text",
794
- "json",
795
- "secret"
796
- ].includes(binding.type)) worker.env[name] = { type: "secret" };
818
+ if (!binding || inlineBindingTypes.has(binding.type)) worker.env[name] = { type: "secret" };
797
819
  }
798
820
  writeFileAtomic(path, JSON.stringify(worker));
799
821
  return await hook.call(this, {
@@ -886,7 +908,7 @@ function getOrCreateDevTriggerToken(root) {
886
908
  const tokenPath = join(root, ".void", "dev-trigger-token");
887
909
  const readExisting = () => {
888
910
  try {
889
- const existing = readFileSync(tokenPath, "utf-8").trim();
911
+ const existing = readFileSync(tokenPath, "utf8").trim();
890
912
  return existing.length > 0 ? existing : void 0;
891
913
  } catch {
892
914
  return;
@@ -979,7 +1001,7 @@ function warnIfPackageJsonIsNotEsm(root) {
979
1001
  if (!existsSync(pkgPath)) return;
980
1002
  let pkg;
981
1003
  try {
982
- pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
1004
+ pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
983
1005
  } catch {
984
1006
  return;
985
1007
  }
@@ -1068,6 +1090,7 @@ function cloudflare$1(options) {
1068
1090
  const environment = options.viteEnvironment.name ?? "ssr";
1069
1091
  const destination = outputDirectories.get(environment);
1070
1092
  const client = outputDirectories.get("client");
1093
+ if (!destination || !client) throw new Error("Void requires configured Worker and client output directories.");
1071
1094
  if (!worker.bundleDir || !worker.config.manifest) throw new Error("Void requires a built Cloudflare Worker.");
1072
1095
  for (const directory of [destination, client]) if (directory !== root && isInside(root, directory) && !isInside(directory, worker.bundleDir)) rmSync(directory, {
1073
1096
  recursive: true,
@@ -1156,7 +1179,7 @@ function devTriggersHintPlugin(root, devTriggerToken) {
1156
1179
  afterServerReady(server, () => {
1157
1180
  const address = server.httpServer?.address();
1158
1181
  const port = typeof address === "object" && address ? address.port : null;
1159
- if (port == null) return;
1182
+ if (port === null || port === void 0) return;
1160
1183
  const baseUrl = `http://localhost:${port}`;
1161
1184
  const summary = [];
1162
1185
  if (jobs.length > 0) summary.push(`${jobs.length} cron${jobs.length === 1 ? "" : "s"}`);
@@ -1166,11 +1189,11 @@ function devTriggersHintPlugin(root, devTriggerToken) {
1166
1189
  const authHeader = `x-void-dev-trigger: ${devTriggerToken}`;
1167
1190
  if (jobs.length > 0) {
1168
1191
  const sample = jobs[0].crons[0];
1169
- console.log(` \x1b[2mcurl -X POST ${baseUrl}/__void/scheduled \\\n -H "${authHeader}" \\\n -d '{"cron":"${sample}","scheduledTime":'"$(date +%s000)"'}'\x1b[22m`);
1192
+ console.log(` \u001b[2mcurl -X POST ${baseUrl}/__void/scheduled \\\n -H "${authHeader}" \\\n -d '{"cron":"${sample}","scheduledTime":'"$(date +%s000)"'}'\u001b[22m`);
1170
1193
  }
1171
1194
  if (queues.length > 0) {
1172
1195
  const sample = queues[0].name;
1173
- console.log(` \x1b[2mcurl -X POST ${baseUrl}/__void/queue \\\n -H "${authHeader}" \\\n -d '{"queue":"${sample}","messages":[{"id":"1","timestamp":'"$(date +%s000)"',"body":{},"attempts":1}]}'\x1b[22m`);
1196
+ console.log(` \u001b[2mcurl -X POST ${baseUrl}/__void/queue \\\n -H "${authHeader}" \\\n -d '{"queue":"${sample}","messages":[{"id":"1","timestamp":'"$(date +%s000)"',"body":{},"attempts":1}]}'\u001b[22m`);
1174
1197
  }
1175
1198
  });
1176
1199
  }
@@ -1195,7 +1218,7 @@ function emailDevInboxPlugin(options) {
1195
1218
  const printInboxUrl = () => {
1196
1219
  const address = server.httpServer?.address();
1197
1220
  const port = typeof address === "object" && address ? address.port : null;
1198
- if (port == null) return;
1221
+ if (port === null || port === void 0) return;
1199
1222
  voidLog(`Email inbox: http://localhost:${port}${inboxHref("")}`);
1200
1223
  };
1201
1224
  afterServerReady(server, printInboxUrl);
@@ -1251,7 +1274,7 @@ function emailDevInboxPlugin(options) {
1251
1274
  return;
1252
1275
  }
1253
1276
  if (wantsRaw) {
1254
- const safeId = id.replace(/["\r\n]/g, "");
1277
+ const safeId = id.replaceAll(/["\r\n]/g, "");
1255
1278
  res.writeHead(200, {
1256
1279
  ...SECURITY_HEADERS,
1257
1280
  "Content-Type": "message/rfc822",
@@ -1337,7 +1360,7 @@ async function handleCapture(req, res) {
1337
1360
  }
1338
1361
  }
1339
1362
  function escapeHtml(s) {
1340
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1363
+ return s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&#39;");
1341
1364
  }
1342
1365
  function formatAddress(a) {
1343
1366
  return a.name ? `${a.name} <${a.email}>` : a.email;
@@ -1512,8 +1535,8 @@ function walkEnvReads(program, bindings, visit) {
1512
1535
  for (const { node, name, bindingType } of references) if (resolve(node, name)?.type === bindingType) visit(node);
1513
1536
  }
1514
1537
  /**
1515
- * Collect every `void/env` read. Computed access produces a warning hit
1516
- * with `property === null`; everything else carries the property name.
1538
+ * Collect every `void/env` read. Computed access produces a warning hit;
1539
+ * statically known reads carry the property name.
1517
1540
  */
1518
1541
  function findHits(program, bindings) {
1519
1542
  const hits = [];
@@ -1521,10 +1544,10 @@ function findHits(program, bindings) {
1521
1544
  return hits;
1522
1545
  }
1523
1546
  function recordHit(node, hits) {
1547
+ if (node.start === void 0) throw new Error("Expected an offset for a parsed environment read.");
1524
1548
  if (node.computed) {
1525
1549
  hits.push({
1526
1550
  kind: "warn",
1527
- property: null,
1528
1551
  start: node.start
1529
1552
  });
1530
1553
  return;
@@ -1565,7 +1588,7 @@ function envClientGuardPlugin(root) {
1565
1588
  } catch {
1566
1589
  return;
1567
1590
  }
1568
- const program = parsed.program;
1591
+ const program = asAstProgram(parsed.program);
1569
1592
  const bindings = extractEnvBindings(program);
1570
1593
  if (!bindings) return;
1571
1594
  const hits = findHits(program, bindings);
@@ -1613,6 +1636,7 @@ function findFoldHits(program, bindings) {
1613
1636
  return hits;
1614
1637
  }
1615
1638
  function pushHit(node, hits) {
1639
+ if (node.start === void 0 || node.end === void 0) throw new Error("Expected offsets for a parsed environment read.");
1616
1640
  if (!node.computed && isIdentifier(node.property)) {
1617
1641
  hits.push({
1618
1642
  start: node.start,
@@ -1674,7 +1698,7 @@ function envClientFoldPlugin() {
1674
1698
  } catch {
1675
1699
  return;
1676
1700
  }
1677
- const program = parsed.program;
1701
+ const program = asAstProgram(parsed.program);
1678
1702
  const bindings = extractEnvBindings(program);
1679
1703
  if (!bindings) return;
1680
1704
  const hits = findFoldHits(program, bindings);
@@ -1725,7 +1749,7 @@ function readProcessEnvCopies() {
1725
1749
  * once per environment) see only the shell.
1726
1750
  */
1727
1751
  function stripLocalClientEnv(root, config, before) {
1728
- if (config.envDir === false || realPath(config.envDir) !== realPath(root)) return;
1752
+ if (config.envDir === false || realPath$1(config.envDir) !== realPath$1(root)) return;
1729
1753
  const file = join(root, LOCAL_ENV_FILE);
1730
1754
  if (!existsSync(file)) return;
1731
1755
  const parsed = parseEnv(readFileSync(file, "utf8"));
@@ -1746,7 +1770,7 @@ function stripLocalClientEnv(root, config, before) {
1746
1770
  }
1747
1771
  }
1748
1772
  /** Match Vite's canonical paths, including Windows short names and filesystem casing. */
1749
- function realPath(path) {
1773
+ function realPath$1(path) {
1750
1774
  try {
1751
1775
  return realpathSync.native(path);
1752
1776
  } catch {
@@ -1755,14 +1779,40 @@ function realPath(path) {
1755
1779
  }
1756
1780
  /** Module ids that name an env file: its path as found, and as Vite resolves it. */
1757
1781
  function envFileIdsFor(envFile) {
1758
- return new Set(envFile ? [normalizePath(envFile), normalizePath(realPath(envFile))] : []);
1782
+ return new Set(envFile ? [normalizePath(envFile), normalizePath(realPath$1(envFile))] : []);
1759
1783
  }
1760
1784
  /** A hook filter pattern that matches exactly `id`. */
1761
1785
  function exactId(id) {
1762
- return new RegExp(`^${id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`);
1786
+ return new RegExp(`^${id.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)}$`);
1763
1787
  }
1764
1788
  /** Patterns Vite's `define` typically uses for env-shaped constants. */
1765
1789
  const DEFINE_ENV_PATTERN = /^(?:globalThis\.)?(?:process\.env|import\.meta\.env)\.([A-Z_][A-Z0-9_]*)$/;
1790
+ async function warnOnDefineOverlap(define) {
1791
+ const { _hasRegisteredSchema, _getRegisteredSchema } = await loadEnvPublic();
1792
+ if (!_hasRegisteredSchema()) return;
1793
+ const schema = _getRegisteredSchema();
1794
+ if (!schema) return;
1795
+ const overlaps = [];
1796
+ for (const defineKey of Object.keys(define)) {
1797
+ const match = DEFINE_ENV_PATTERN.exec(defineKey);
1798
+ if (!match) continue;
1799
+ const name = match[1];
1800
+ if (name in schema) overlaps.push({
1801
+ defineKey,
1802
+ schemaKey: name
1803
+ });
1804
+ }
1805
+ if (overlaps.length === 0) return;
1806
+ const lines = ["Vite `define` is shadowing schema env keys:"];
1807
+ for (const { defineKey, schemaKey } of overlaps) lines.push(` • "${defineKey}" → schema key "${schemaKey}". The compiled client code receives the define value, but the typed env.X proxy and validation still source from the schema. Prefer one or the other for any given key.`);
1808
+ voidWarn(lines.join("\n"));
1809
+ }
1810
+ async function assertNoReservedSchemaKeys() {
1811
+ const { _hasRegisteredSchema, _getRegisteredSchema } = await loadEnvPublic();
1812
+ if (!_hasRegisteredSchema()) return;
1813
+ const reserved = findReservedEnvKeys(Object.keys(_getRegisteredSchema() ?? {}));
1814
+ if (reserved.length > 0) throw new Error(reservedEnvKeysMessage("env.ts", reserved));
1815
+ }
1766
1816
  /**
1767
1817
  * Vite plugin that auto-discovers `env.ts` at the project root and:
1768
1818
  * - imports it (registering the user's schema via `defineEnv`)
@@ -1813,12 +1863,6 @@ function envSchemaPlugin(root, options = {}) {
1813
1863
  requiredServerKeys
1814
1864
  });
1815
1865
  }
1816
- async function assertNoReservedSchemaKeys() {
1817
- const { _hasRegisteredSchema, _getRegisteredSchema } = await loadEnvPublic();
1818
- if (!_hasRegisteredSchema()) return;
1819
- const reserved = findReservedEnvKeys(Object.keys(_getRegisteredSchema() ?? {}));
1820
- if (reserved.length > 0) throw new Error(reservedEnvKeysMessage("env.ts", reserved));
1821
- }
1822
1866
  function regenerateTypes() {
1823
1867
  if (!envFile) return;
1824
1868
  mkdirSync(outDir, { recursive: true });
@@ -1834,26 +1878,6 @@ function envSchemaPlugin(root, options = {}) {
1834
1878
  voidWarn(err.message);
1835
1879
  }
1836
1880
  }
1837
- async function warnOnDefineOverlap(define) {
1838
- const { _hasRegisteredSchema, _getRegisteredSchema } = await loadEnvPublic();
1839
- if (!_hasRegisteredSchema()) return;
1840
- const schema = _getRegisteredSchema();
1841
- if (!schema) return;
1842
- const overlaps = [];
1843
- for (const defineKey of Object.keys(define)) {
1844
- const match = DEFINE_ENV_PATTERN.exec(defineKey);
1845
- if (!match) continue;
1846
- const name = match[1];
1847
- if (name in schema) overlaps.push({
1848
- defineKey,
1849
- schemaKey: name
1850
- });
1851
- }
1852
- if (overlaps.length === 0) return;
1853
- const lines = ["Vite `define` is shadowing schema env keys:"];
1854
- for (const { defineKey, schemaKey } of overlaps) lines.push(` • "${defineKey}" → schema key "${schemaKey}". The compiled client code receives the define value, but the typed env.X proxy and validation still source from the schema. Prefer one or the other for any given key.`);
1855
- voidWarn(lines.join("\n"));
1856
- }
1857
1881
  async function validateAndWarn() {
1858
1882
  if (!envFile) return;
1859
1883
  const { _hasRegisteredSchema, validateAllEnv } = await loadEnvPublic();
@@ -2147,7 +2171,7 @@ export async function handleDevTrigger(request, env, ctx) {
2147
2171
  function removeGitignoreLines(root, lines) {
2148
2172
  const gitignorePath = join(root, ".gitignore");
2149
2173
  if (lines.length === 0 || !existsSync(gitignorePath)) return;
2150
- const contents = readFileSync(gitignorePath, "utf-8");
2174
+ const contents = readFileSync(gitignorePath, "utf8");
2151
2175
  const remove = new Set(lines);
2152
2176
  const next = contents.split("\n").filter((line) => !remove.has(line.trim())).join("\n");
2153
2177
  if (next !== contents) writeFileSync(gitignorePath, next);
@@ -2455,8 +2479,7 @@ function pushDefaultErrorPageHelpers(lines, options) {
2455
2479
  dev: options.dev === true,
2456
2480
  projectRoot: options.projectRoot,
2457
2481
  homeDir: options.homeDir
2458
- })});`);
2459
- lines.push("app.onError(__createPageErrorHandler(__matchedRoutes, __errorRenderer.onError));");
2482
+ })});`, "app.onError(__createPageErrorHandler(__matchedRoutes, __errorRenderer.onError));");
2460
2483
  }
2461
2484
  /**
2462
2485
  * Returns a lookup that gives each key its own identifier suffix. The suffix
@@ -2490,9 +2513,7 @@ function compileRouteTable(scan, routesDir, middlewareDir, jobsDir, queuesDir, s
2490
2513
  const auth = options.auth;
2491
2514
  const webSockets = scan.websockets ?? [];
2492
2515
  const managedDispatch = options.nodeTarget !== true && options.dev !== true && options.managedDispatch === true;
2493
- lines.push(`import { AsyncLocalStorage } from "node:async_hooks";`);
2494
- lines.push(`import { Hono } from ${JSON.stringify(options.honoPath)};`);
2495
- lines.push(`import { createRoutingRuntime as __createRoutingRuntime, createHttpRouteHandler as __createHttpRouteHandler, createErrorRenderer as __createErrorRenderer, createPageGetHandler as __createPageGetHandler, createStaticNotFound as __createStaticNotFound, createPageMutationHandler as __createPageMutationHandler, createNamedActionMarker as __createNamedActionMarker, markRouteHandler as __markRouteHandler, createPagesFallback as __createPagesFallback, createModuleLoader as __createModuleLoader, createClientAssetTags as __createClientAssetTags, createManifestLoader as __createManifestLoader, createSsrFallback as __createSsrFallback, createAssetNotFound as __createAssetNotFound, buildPrerenderPath as __buildPrerenderPath } from ${JSON.stringify(ROUTING_RUNTIME_PATH)};`);
2516
+ lines.push(`import { AsyncLocalStorage } from "node:async_hooks";`, `import { Hono, createRoutingRuntime as __createRoutingRuntime, createHttpRouteHandler as __createHttpRouteHandler, createErrorRenderer as __createErrorRenderer, createPageGetHandler as __createPageGetHandler, createStaticNotFound as __createStaticNotFound, createPageMutationHandler as __createPageMutationHandler, createNamedActionMarker as __createNamedActionMarker, markRouteHandler as __markRouteHandler, createPagesFallback as __createPagesFallback, createModuleLoader as __createModuleLoader, createClientAssetTags as __createClientAssetTags, createManifestLoader as __createManifestLoader, createSsrFallback as __createSsrFallback, createAssetNotFound as __createAssetNotFound, buildPrerenderPath as __buildPrerenderPath } from ${JSON.stringify(ROUTING_RUNTIME_PATH)};`);
2496
2517
  if (pages) lines.push(`import { createPageErrorHandler as __createPageErrorHandler } from ${JSON.stringify(ROUTING_RUNTIME_PATH)};`);
2497
2518
  if (options.nodeTarget) lines.push(`const withRuntimeEnv = (_env, fn) => fn();`);
2498
2519
  else lines.push(`import { withRuntimeEnv } from ${JSON.stringify(options.runtimeEnvPath)};`);
@@ -2503,9 +2524,7 @@ function compileRouteTable(scan, routesDir, middlewareDir, jobsDir, queuesDir, s
2503
2524
  "runVoidAuthMigrations"
2504
2525
  ];
2505
2526
  if (webSockets.length > 0) authImports.push("resolveVoidAuthState as __resolveVoidAuthStateRuntime");
2506
- lines.push(`import { ${authImports.join(", ")} } from ${JSON.stringify(auth.authRuntimePath)};`);
2507
- lines.push(`import { __voidAuthDatabase } from ${JSON.stringify(auth.authDatabasePath)};`);
2508
- lines.push(`import { migrationSchema as __voidAuthMigrationSchema } from ${JSON.stringify(auth.authSchemaPath)};`);
2527
+ lines.push(`import { ${authImports.join(", ")} } from ${JSON.stringify(auth.authRuntimePath)};`, `import { __voidAuthDatabase } from ${JSON.stringify(auth.authDatabasePath)};`, `import { migrationSchema as __voidAuthMigrationSchema } from ${JSON.stringify(auth.authSchemaPath)};`);
2509
2528
  if (auth.authConfigPath) lines.push(`import __voidAuthConfig from ${JSON.stringify(auth.authConfigPath)};`);
2510
2529
  }
2511
2530
  if ((webSockets.length > 0 || options.webSocketTombstones?.length) && options.webSocketRuntimePath) lines.push(`import { createWebSocketDurableObject as __createWebSocketDurableObject, createWebSocketTombstoneDurableObject as __createWebSocketTombstoneDurableObject, forwardWebSocketRequest as __forwardWebSocketRequest, __registerWebSocketRoutes } from ${JSON.stringify(options.webSocketRuntimePath)};`);
@@ -2540,48 +2559,29 @@ function compileRouteTable(scan, routesDir, middlewareDir, jobsDir, queuesDir, s
2540
2559
  nodeTarget: options.nodeTarget === true,
2541
2560
  managedDispatch,
2542
2561
  blockedAssetExtensions: blockedExts
2543
- })});`);
2544
- lines.push("export const requestContext = __routingRuntime.requestContext;");
2545
- lines.push("app.use(__routingRuntime.contextMiddleware);");
2546
- lines.push("app.use(__routingRuntime.requestMiddleware);");
2547
- lines.push("");
2562
+ })});`, "export const requestContext = __routingRuntime.requestContext;", "app.use(__routingRuntime.contextMiddleware);", "app.use(__routingRuntime.requestMiddleware);", "");
2548
2563
  const emitEdgeRules = !managedDispatch;
2549
2564
  const fallbackRulesJson = JSON.stringify(emitEdgeRules && options.fallbackRules?.length ? options.dev ? options.fallbackRules : stripOriginForProd(options.fallbackRules) : void 0);
2550
2565
  if (emitEdgeRules && options.redirectRules?.length) compileRoutingRulesMiddleware(lines, options.redirectRules, options.dev === true);
2551
2566
  if (pages) {
2552
- lines.push(`import { matchedRoutes as __matchedRoutes } from ${JSON.stringify(options.honoRoutePath)};`);
2567
+ lines.push(`import { matchedRoutes as __matchedRoutes } from ${JSON.stringify(ROUTING_RUNTIME_PATH)};`);
2553
2568
  if (scan.pages.pages.some((page) => page.methods.includes("actions"))) lines.push("app.use(__createNamedActionMarker(__matchedRoutes));");
2554
2569
  }
2555
2570
  const headerRules = emitEdgeRules ? options.headerRules : void 0;
2556
2571
  if (headerRules?.length) lines.push(`const __headerRules = ${JSON.stringify(headerRules)};`);
2557
2572
  if (auth) {
2558
2573
  if (headerRules?.length) lines.push("app.use(\"*\", __routingRuntime.headerMiddleware(__headerRules, \"auth-error\"));");
2559
- lines.push("app.use(async (c, next) => {");
2560
- lines.push(" return runVoidAuthMiddleware(c, next, __voidAuthOptions, __voidAuthDatabase);");
2561
- lines.push("});");
2562
- lines.push("");
2574
+ lines.push("app.use(async (c, next) => {", " return runVoidAuthMiddleware(c, next, __voidAuthOptions, __voidAuthDatabase);", "});", "");
2563
2575
  }
2564
2576
  if (headerRules?.length) lines.push("app.use(\"*\", __routingRuntime.headerMiddleware(__headerRules));");
2565
2577
  for (let i = 0; i < scan.middleware.length; i++) lines.push(`app.use(middleware${i});`);
2566
2578
  if (scan.middleware.length > 0) lines.push("");
2567
2579
  for (let i = 0; i < webSockets.length; i++) {
2568
2580
  const route = webSockets[i];
2569
- lines.push(`app.all(${JSON.stringify(route.pattern)}, async (c, next) => {`);
2570
- lines.push(` if (c.req.raw.headers.get("upgrade")?.toLowerCase() !== "websocket") return next();`);
2571
- lines.push(` return __forwardWebSocketRequest(c.req.raw, c.env, __voidWebSocketRoutes[${i}]);`);
2572
- lines.push("});");
2581
+ lines.push(`app.all(${JSON.stringify(route.pattern)}, async (c, next) => {`, ` if (c.req.raw.headers.get("upgrade")?.toLowerCase() !== "websocket") return next();`, ` return __forwardWebSocketRequest(c.req.raw, c.env, __voidWebSocketRoutes[${i}]);`, "});");
2573
2582
  }
2574
2583
  if (webSockets.length > 0) lines.push("");
2575
- if (auth) {
2576
- lines.push("app.all(\"/api/auth\", __markRouteHandler(async (c) => {");
2577
- lines.push(" return handleVoidAuthRequest(c, __voidAuthOptions, __voidAuthDatabase);");
2578
- lines.push("}));");
2579
- lines.push("");
2580
- lines.push("app.all(\"/api/auth/*\", __markRouteHandler(async (c) => {");
2581
- lines.push(" return handleVoidAuthRequest(c, __voidAuthOptions, __voidAuthDatabase);");
2582
- lines.push("}));");
2583
- lines.push("");
2584
- }
2584
+ if (auth) lines.push("app.all(\"/api/auth\", __markRouteHandler(async (c) => {", " return handleVoidAuthRequest(c, __voidAuthOptions, __voidAuthDatabase);", "}));", "", "app.all(\"/api/auth/*\", __markRouteHandler(async (c) => {", " return handleVoidAuthRequest(c, __voidAuthOptions, __voidAuthDatabase);", "}));", "");
2585
2585
  const seenFiles = /* @__PURE__ */ new Set();
2586
2586
  const routeNames = createIdentifierNames();
2587
2587
  for (const route of scan.routes) {
@@ -2610,25 +2610,20 @@ function compileRouteTable(scan, routesDir, middlewareDir, jobsDir, queuesDir, s
2610
2610
  ...route.name !== void 0 && { name: route.name }
2611
2611
  })}, ${auth ? "__voidAuthOptions" : "undefined"}, ${auth ? "__resolveVoidAuthState" : "undefined"});`);
2612
2612
  }
2613
- lines.push("");
2614
- lines.push(`const __voidWebSocketRoutes = ${JSON.stringify(webSockets.map((route) => ({
2613
+ lines.push("", `const __voidWebSocketRoutes = ${JSON.stringify(webSockets.map((route) => ({
2615
2614
  pattern: route.pattern,
2616
2615
  params: route.params,
2617
2616
  className: route.className,
2618
2617
  bindingName: route.bindingName,
2619
2618
  mode: route.mode,
2620
2619
  ...route.name !== void 0 && { name: route.name }
2621
- })))};`);
2622
- lines.push("");
2620
+ })))};`, "");
2623
2621
  }
2624
2622
  for (let i = 0; i < webSockets.length; i++) lines.push(`__voidWebSocketRoutes[${i}].key = websocket${i}.key;`);
2625
2623
  if (webSockets.length > 0 && options.webSocketRuntimePath) lines.push("__registerWebSocketRoutes(__voidWebSocketRoutes);");
2626
2624
  for (const className of options.webSocketTombstones ?? []) lines.push(`export const ${className} = __createWebSocketTombstoneDurableObject(${JSON.stringify(className)});`);
2627
2625
  if (options.webSocketTombstones?.length) lines.push("");
2628
- if (options.hasLive) {
2629
- lines.push("export const VoidLiveStreamDurableObject = __createLiveDurableObject();");
2630
- lines.push("");
2631
- }
2626
+ if (options.hasLive) lines.push("export const VoidLiveStreamDurableObject = __createLiveDurableObject();", "");
2632
2627
  const pageNames = createIdentifierNames();
2633
2628
  if (pages && (scan.pages.pages.length > 0 || scan.pages.boundaries?.some((boundary) => boundary.kind === "not-found" && !boundary.directory))) compilePageRoutes(lines, scan, pages, options, pageNames);
2634
2629
  if (!pages || !createBoundaryManifest(scan.pages).root) lines.push("export async function __voidRenderStaticNotFound() { return new Response(null, { status: 204 }); }");
@@ -2660,112 +2655,28 @@ function compileRouteTable(scan, routesDir, middlewareDir, jobsDir, queuesDir, s
2660
2655
  const job = scan.jobs[i];
2661
2656
  lines.push(`const job${i}Crons = ${JSON.stringify(job.crons)};`);
2662
2657
  }
2663
- lines.push("");
2664
- lines.push("export async function scheduled(controller, env, ctx) {");
2665
- lines.push(" const run = async (job, loadJob) => {");
2666
- lines.push(" try {");
2667
- lines.push(" const mod = await loadJob();");
2668
- lines.push(" if (typeof mod.default === 'function') await mod.default(controller, env, ctx);");
2669
- lines.push(" } catch (error) {");
2670
- lines.push(" console.error(`[void] Scheduled job ${job} failed for cron \"${controller.cron}\":`, error);");
2671
- lines.push(" return { job, error };");
2672
- lines.push(" }");
2673
- lines.push(" };");
2674
- lines.push(" const tasks = [];");
2658
+ lines.push("", "export async function scheduled(controller, env, ctx) {", " const run = async (job, loadJob) => {", " try {", " const mod = await loadJob();", " if (typeof mod.default === 'function') await mod.default(controller, env, ctx);", " } catch (error) {", " console.error(`[void] Scheduled job ${job} failed for cron \"${controller.cron}\":`, error);", " return { job, error };", " }", " };", " const tasks = [];");
2675
2659
  for (let i = 0; i < scan.jobs.length; i++) {
2676
2660
  const job = scan.jobs[i];
2677
2661
  const filePath = JSON.stringify(`${jobsDir}/${job.filePath}`);
2678
2662
  const label = JSON.stringify(relative(options.projectRoot, `${jobsDir}/${job.filePath}`));
2679
2663
  lines.push(` if (job${i}Crons.includes(controller.cron)) tasks.push(run(${label}, () => import(${filePath})));`);
2680
2664
  }
2681
- lines.push(" const failures = (await Promise.all(tasks)).filter(Boolean);");
2682
- lines.push(" if (failures.length) {");
2683
- lines.push(" throw new AggregateError(failures.map((failure) => failure.error), `Scheduled jobs failed: ${failures.map((failure) => failure.job).join(\", \")}`);");
2684
- lines.push(" }");
2685
- lines.push("}");
2686
- lines.push("");
2687
- } else {
2688
- lines.push("export async function scheduled() {}");
2689
- lines.push("");
2690
- }
2691
- if (scan.jobs.length > 0 || scan.queues.length > 0) {
2692
- lines.push("function __voidTriggerUnauthorized(c) {");
2693
- lines.push(" const __token = c.req.header(\"x-void-internal\");");
2694
- lines.push(" const __expected = __getRawEnv()?.__VOID_PROXY_TOKEN;");
2695
- lines.push(" const __devToken = c.req.header(\"x-void-dev-trigger\");");
2696
- lines.push(" return __VOID_SERVE ? __devToken !== __VOID_DEV_TRIGGER_TOKEN : __expected ? __token !== __expected : __token !== __VOID_BUILD_KEY;");
2697
- lines.push("}");
2698
- lines.push("");
2699
- }
2700
- if (scan.jobs.length > 0) {
2701
- lines.push("const __scheduledHandler = async (c) => {");
2702
- lines.push(" if (__voidTriggerUnauthorized(c)) return c.json({ error: \"unauthorized\" }, 401);");
2703
- lines.push(" const { cron, scheduledTime } = await c.req.json();");
2704
- lines.push(" const controller = { cron, scheduledTime, noRetry() {} };");
2705
- lines.push(" await scheduled(controller, c.env, c.executionCtx);");
2706
- lines.push(" return c.json({ ok: true });");
2707
- lines.push("};");
2708
- lines.push("app.post(\"/__void/scheduled\", __markRouteHandler(__scheduledHandler));");
2709
- lines.push("");
2710
- }
2665
+ lines.push(" const failures = (await Promise.all(tasks)).filter(Boolean);", " if (failures.length) {", " throw new AggregateError(failures.map((failure) => failure.error), `Scheduled jobs failed: ${failures.map((failure) => failure.job).join(\", \")}`);", " }", "}", "");
2666
+ } else lines.push("export async function scheduled() {}", "");
2667
+ if (scan.jobs.length > 0 || scan.queues.length > 0) lines.push("function __voidTriggerUnauthorized(c) {", " const __token = c.req.header(\"x-void-internal\");", " const __expected = __getRawEnv()?.__VOID_PROXY_TOKEN;", " const __devToken = c.req.header(\"x-void-dev-trigger\");", " return __VOID_SERVE ? __devToken !== __VOID_DEV_TRIGGER_TOKEN : __expected ? __token !== __expected : __token !== __VOID_BUILD_KEY;", "}", "");
2668
+ if (scan.jobs.length > 0) lines.push("const __scheduledHandler = async (c) => {", " if (__voidTriggerUnauthorized(c)) return c.json({ error: \"unauthorized\" }, 401);", " const { cron, scheduledTime } = await c.req.json();", " const controller = { cron, scheduledTime, noRetry() {} };", " await scheduled(controller, c.env, c.executionCtx);", " return c.json({ ok: true });", "};", "app.post(\"/__void/scheduled\", __markRouteHandler(__scheduledHandler));", "");
2711
2669
  if (scan.queues.length > 0) {
2712
2670
  const queueNames = scan.queues.map((queue) => queue.name);
2713
2671
  const cloudflareNames = options.cloudflareQueueNames;
2714
- lines.push(generateQueueResolverSource(queueNames, cloudflareNames && queueNames.map((name) => cloudflareQueueName(name, cloudflareNames))));
2715
- lines.push("");
2672
+ lines.push(generateQueueResolverSource(queueNames, cloudflareNames && queueNames.map((name) => cloudflareQueueName(name, cloudflareNames))), "");
2716
2673
  const queueLabels = scan.queues.map((queue) => relative(options.projectRoot, `${queuesDir}/${queue.filePath}`));
2717
- lines.push(`const __queueLabels = ${JSON.stringify(queueLabels)};`);
2718
- lines.push("export async function __processQueue(payload, env) {");
2719
- lines.push(" const queueSuffix = payload.queue;");
2720
- lines.push(" const __queueIndex = __resolveQueueIndex(queueSuffix);");
2721
- lines.push(" if (__queueIndex === -1) {");
2722
- lines.push(" const __error = `No unambiguous queue handler matches \"${String(queueSuffix)}\"`;");
2723
- lines.push(" console.error(`[void] ${__error}`);");
2724
- lines.push(" return { ok: false, error: __error };");
2725
- lines.push(" }");
2726
- lines.push(" const __decisions = new Map();");
2727
- lines.push(" function __wrapMsg(m) {");
2728
- lines.push(" let decided = false;");
2729
- lines.push(" return {");
2730
- lines.push(" id: m.id, timestamp: new Date(m.timestamp), body: m.body, attempts: m.attempts,");
2731
- lines.push(" ack() { if (!decided) { decided = true; __decisions.set(m.id, { action: \"ack\" }); } },");
2732
- lines.push(" retry(opts) { if (!decided) { decided = true; __decisions.set(m.id, { action: \"retry\", ...(opts?.delaySeconds != null ? { delaySeconds: opts.delaySeconds } : {}) }); } },");
2733
- lines.push(" };");
2734
- lines.push(" }");
2735
- lines.push(" const __msgs = payload.messages.map(__wrapMsg);");
2736
- lines.push(" const batch = {");
2737
- lines.push(" queue: queueSuffix,");
2738
- lines.push(" messages: __msgs,");
2739
- lines.push(" ackAll() { for (const m of __msgs) m.ack(); },");
2740
- lines.push(" retryAll(opts) { for (const m of __msgs) m.retry(opts); },");
2741
- lines.push(" };");
2742
- lines.push(" let __ok = true;");
2743
- lines.push(" try {");
2744
- lines.push(" switch (__queueIndex) {");
2674
+ lines.push(`const __queueLabels = ${JSON.stringify(queueLabels)};`, "export async function __processQueue(payload, env) {", " const queueSuffix = payload.queue;", " const __queueIndex = __resolveQueueIndex(queueSuffix);", " if (__queueIndex === -1) {", " const __error = `No unambiguous queue handler matches \"${String(queueSuffix)}\"`;", " console.error(`[void] ${__error}`);", " return { ok: false, error: __error };", " }", " const __decisions = new Map();", " function __wrapMsg(m) {", " let decided = false;", " return {", " id: m.id, timestamp: new Date(m.timestamp), body: m.body, attempts: m.attempts,", " ack() { if (!decided) { decided = true; __decisions.set(m.id, { action: \"ack\" }); } },", " retry(opts) { if (!decided) { decided = true; __decisions.set(m.id, { action: \"retry\", ...(opts?.delaySeconds != null ? { delaySeconds: opts.delaySeconds } : {}) }); } },", " };", " }", " const __msgs = payload.messages.map(__wrapMsg);", " const batch = {", " queue: queueSuffix,", " messages: __msgs,", " ackAll() { for (const m of __msgs) m.ack(); },", " retryAll(opts) { for (const m of __msgs) m.retry(opts); },", " };", " let __ok = true;", " try {", " switch (__queueIndex) {");
2745
2675
  for (let i = 0; i < scan.queues.length; i++) {
2746
2676
  const q = scan.queues[i];
2747
- lines.push(` case ${i}: {`);
2748
- lines.push(` const mod = await import(${JSON.stringify(`${queuesDir}/${q.filePath}`)});`);
2749
- lines.push(" if (typeof mod.default === 'function') await mod.default(batch, env);");
2750
- lines.push(" break;");
2751
- lines.push(" }");
2677
+ lines.push(` case ${i}: {`, ` const mod = await import(${JSON.stringify(`${queuesDir}/${q.filePath}`)});`, " if (typeof mod.default === 'function') await mod.default(batch, env);", " break;", " }");
2752
2678
  }
2753
- lines.push(" }");
2754
- lines.push(" } catch (error) {");
2755
- lines.push(" console.error(`[void] Queue handler ${__queueLabels[__queueIndex]} failed for queue \"${String(queueSuffix)}\":`, error);");
2756
- lines.push(" __ok = false;");
2757
- lines.push(" }");
2758
- lines.push(" return { ok: __ok, ...(__decisions.size > 0 ? { decisions: Object.fromEntries(__decisions) } : {}) };");
2759
- lines.push("}");
2760
- lines.push("");
2761
- lines.push("const __queueHandler = async (c) => {");
2762
- lines.push(" if (__voidTriggerUnauthorized(c)) return c.json({ error: \"unauthorized\" }, 401);");
2763
- lines.push(" const payload = await c.req.json();");
2764
- lines.push(" const result = await __processQueue(payload, c.env);");
2765
- lines.push(" return c.json(result);");
2766
- lines.push("};");
2767
- lines.push("app.post(\"/__void/queue\", __markRouteHandler(__queueHandler));");
2768
- lines.push("");
2679
+ lines.push(" }", " } catch (error) {", " console.error(`[void] Queue handler ${__queueLabels[__queueIndex]} failed for queue \"${String(queueSuffix)}\":`, error);", " __ok = false;", " }", " return { ok: __ok, ...(__decisions.size > 0 ? { decisions: Object.fromEntries(__decisions) } : {}) };", "}", "", "const __queueHandler = async (c) => {", " if (__voidTriggerUnauthorized(c)) return c.json({ error: \"unauthorized\" }, 401);", " const payload = await c.req.json();", " const result = await __processQueue(payload, c.env);", " return c.json(result);", "};", "app.post(\"/__void/queue\", __markRouteHandler(__queueHandler));", "");
2769
2680
  }
2770
2681
  const email = scan.email;
2771
2682
  const emailDir = options.emailDir;
@@ -2784,175 +2695,62 @@ function compileRouteTable(scan, routesDir, middlewareDir, jobsDir, queuesDir, s
2784
2695
  }
2785
2696
  lines.push("];");
2786
2697
  }
2787
- lines.push("");
2788
- lines.push("export async function __emailHandler(message, env, ctx, __opts) {");
2789
- lines.push(" const __platformTo = message ? message.__voidPlatformTo : undefined;");
2790
- lines.push(" const __to = String((__platformTo ?? (message && message.to)) || \"\");");
2791
- lines.push(" const __localFull = __to.split(\"@\")[0] || \"\";");
2792
- lines.push(" let __local = __localFull;");
2793
- lines.push(" if (__opts && __opts.slug) {");
2794
- lines.push(" const __plus = __localFull.indexOf(\"+\");");
2795
- lines.push(" __local = __plus === -1 ? \"\" : __localFull.slice(__plus + 1);");
2796
- lines.push(" }");
2797
- if (email.addresses.length > 0) {
2798
- lines.push(" for (const __p of __emailPatterns) {");
2799
- lines.push(" const __m = __p.re.exec(__local);");
2800
- lines.push(" if (!__m) continue;");
2801
- lines.push(" const __params = {};");
2802
- lines.push(" for (let __i = 0; __i < __p.params.length; __i++) {");
2803
- lines.push(" __params[__p.params[__i]] = __m[__i + 1];");
2804
- lines.push(" }");
2805
- lines.push(" const __mod = await __p.load();");
2806
- lines.push(" if (typeof __mod.default !== \"function\") {");
2807
- lines.push(" throw new Error(\"email handler at \" + __p.path + \" has no default export\");");
2808
- lines.push(" }");
2809
- lines.push(" return await __mod.default(message, env, ctx, { params: __params });");
2810
- lines.push(" }");
2811
- }
2698
+ lines.push("", "export async function __emailHandler(message, env, ctx, __opts) {", " const __platformTo = message ? message.__voidPlatformTo : undefined;", " const __to = String((__platformTo ?? (message && message.to)) || \"\");", " const __localFull = __to.split(\"@\")[0] || \"\";", " let __local = __localFull;", " if (__opts && __opts.slug) {", " const __plus = __localFull.indexOf(\"+\");", " __local = __plus === -1 ? \"\" : __localFull.slice(__plus + 1);", " }");
2699
+ if (email.addresses.length > 0) lines.push(" for (const __p of __emailPatterns) {", " const __m = __p.re.exec(__local);", " if (!__m) continue;", " const __params = {};", " for (let __i = 0; __i < __p.params.length; __i++) {", " __params[__p.params[__i]] = __m[__i + 1];", " }", " const __mod = await __p.load();", " if (typeof __mod.default !== \"function\") {", " throw new Error(\"email handler at \" + __p.path + \" has no default export\");", " }", " return await __mod.default(message, env, ctx, { params: __params });", " }");
2812
2700
  if (email.defaultHandler) {
2813
2701
  const defaultPath = `${emailDir}/${email.defaultHandler}`;
2814
- lines.push(" const __dmod = await __emailDefault();");
2815
- lines.push(" if (typeof __dmod.default !== \"function\") {");
2816
- lines.push(` throw new Error("email handler at " + ${JSON.stringify(defaultPath)} + " has no default export");`);
2817
- lines.push(" }");
2818
- lines.push(" return await __dmod.default(message, env, ctx, { params: {} });");
2819
- } else {
2820
- lines.push(" if (typeof message.setReject === \"function\") {");
2821
- lines.push(" message.setReject(\"no handler matched recipient \\\"\" + __to + \"\\\" — add email/_default.ts to handle unmatched mail\");");
2822
- lines.push(" }");
2823
- }
2824
- lines.push("}");
2825
- lines.push("");
2702
+ lines.push(" const __dmod = await __emailDefault();", " if (typeof __dmod.default !== \"function\") {", ` throw new Error("email handler at " + ${JSON.stringify(defaultPath)} + " has no default export");`, " }", " return await __dmod.default(message, env, ctx, { params: {} });");
2703
+ } else lines.push(" if (typeof message.setReject === \"function\") {", String.raw` message.setReject("no handler matched recipient \"" + __to + "\" — add email/_default.ts to handle unmatched mail");`, " }");
2704
+ lines.push("}", "");
2826
2705
  }
2827
2706
  if (options.migrationHandlerPath && (options.migrations?.length || auth)) {
2828
2707
  const d1BindingName = options.bindingNames?.d1;
2829
- lines.push(`import { createMigrationHandler as __createMigrationHandler } from ${JSON.stringify(options.migrationHandlerPath)};`);
2830
- lines.push(`const __migrations = ${JSON.stringify(options.migrations)};`);
2831
- lines.push(`const __migrationPlanBundle = ${JSON.stringify(options.migrationPlanBundle)};`);
2708
+ lines.push(`import { createMigrationHandler as __createMigrationHandler } from ${JSON.stringify(options.migrationHandlerPath)};`, `const __migrations = ${JSON.stringify(options.migrations)};`, `const __migrationPlanBundle = ${JSON.stringify(options.migrationPlanBundle)};`);
2832
2709
  if (d1BindingName) lines.push(`function __voidGetMigrationEnv() {
2833
2710
  const env = __getRawEnv();
2834
2711
  if (!env || env[${JSON.stringify(d1BindingName)}] == null) return env;
2835
2712
  return { ...env, DB: env[${JSON.stringify(d1BindingName)}] };
2836
2713
  }`);
2837
2714
  else lines.push("function __voidGetMigrationEnv() { return __getRawEnv(); }");
2838
- lines.push("function __voidCreateMigrationRequestHandler(includeAuthMigrations, includePlanBundle) {");
2839
- lines.push(" return __createMigrationHandler(");
2840
- lines.push(" __voidGetMigrationEnv(),");
2841
- lines.push(" __migrations,");
2715
+ lines.push("function __voidCreateMigrationRequestHandler(includeAuthMigrations, includePlanBundle) {", " return __createMigrationHandler(", " __voidGetMigrationEnv(),", " __migrations,");
2842
2716
  if (auth) lines.push(" includeAuthMigrations ? () => runVoidAuthMigrations(__voidGetMigrationEnv(), __voidAuthOptions, __voidAuthMigrationSchema) : undefined,");
2843
2717
  else lines.push(" undefined,");
2844
- lines.push(" includePlanBundle ? __migrationPlanBundle : undefined,");
2845
- lines.push(" );");
2846
- lines.push("}");
2847
- lines.push("export async function __voidHandleInternalRoute(request) {");
2848
- lines.push(" const url = new URL(request.url);");
2849
- lines.push(" if (request.method === \"POST\" && url.pathname === \"/__void/migrate\") {");
2850
- lines.push(` return __voidCreateMigrationRequestHandler(${auth ? "true" : "false"}, false)(request);`);
2851
- lines.push(" }");
2852
- lines.push(" if (request.method === \"GET\" && url.pathname === \"/__void/migrate/capabilities\") {");
2853
- lines.push(` return __voidCreateMigrationRequestHandler(${auth ? "true" : "false"}, true)(request);`);
2854
- lines.push(" }");
2855
- lines.push(" if (request.method === \"POST\" && url.pathname === \"/__void/migrate/app\") {");
2856
- lines.push(" return __voidCreateMigrationRequestHandler(false, true)(request);");
2857
- lines.push(" }");
2858
- lines.push(" if (request.method === \"GET\" && url.pathname.startsWith(\"/__void/migrate/app/attempt/\")) {");
2859
- lines.push(" return __voidCreateMigrationRequestHandler(false, true)(request);");
2860
- lines.push(" }");
2861
- if (auth) {
2862
- lines.push(" if (request.method === \"POST\" && url.pathname === \"/__void/migrate/auth\") {");
2863
- lines.push(" return __voidCreateMigrationRequestHandler(true, true)(request);");
2864
- lines.push(" }");
2865
- }
2866
- lines.push(" return null;");
2867
- lines.push("}");
2868
- lines.push(`app.post("/__void/migrate", __markRouteHandler((c) => __voidCreateMigrationRequestHandler(${auth ? "true" : "false"}, false)(c.req.raw)));`);
2869
- lines.push(`app.get("/__void/migrate/capabilities", __markRouteHandler((c) => __voidCreateMigrationRequestHandler(${auth ? "true" : "false"}, true)(c.req.raw)));`);
2870
- lines.push("app.post(\"/__void/migrate/app\", __markRouteHandler((c) => __voidCreateMigrationRequestHandler(false, true)(c.req.raw)));");
2871
- lines.push("app.get(\"/__void/migrate/app/attempt/:attemptId\", __markRouteHandler((c) => __voidCreateMigrationRequestHandler(false, true)(c.req.raw)));");
2718
+ lines.push(" includePlanBundle ? __migrationPlanBundle : undefined,", " );", "}", "export async function __voidHandleInternalRoute(request) {", " const url = new URL(request.url);", " if (request.method === \"POST\" && url.pathname === \"/__void/migrate\") {", ` return __voidCreateMigrationRequestHandler(${auth ? "true" : "false"}, false)(request);`, " }", " if (request.method === \"GET\" && url.pathname === \"/__void/migrate/capabilities\") {", ` return __voidCreateMigrationRequestHandler(${auth ? "true" : "false"}, true)(request);`, " }", " if (request.method === \"POST\" && url.pathname === \"/__void/migrate/app\") {", " return __voidCreateMigrationRequestHandler(false, true)(request);", " }", " if (request.method === \"GET\" && url.pathname.startsWith(\"/__void/migrate/app/attempt/\")) {", " return __voidCreateMigrationRequestHandler(false, true)(request);", " }");
2719
+ if (auth) lines.push(" if (request.method === \"POST\" && url.pathname === \"/__void/migrate/auth\") {", " return __voidCreateMigrationRequestHandler(true, true)(request);", " }");
2720
+ lines.push(" return null;", "}", `app.post("/__void/migrate", __markRouteHandler((c) => __voidCreateMigrationRequestHandler(${auth ? "true" : "false"}, false)(c.req.raw)));`, `app.get("/__void/migrate/capabilities", __markRouteHandler((c) => __voidCreateMigrationRequestHandler(${auth ? "true" : "false"}, true)(c.req.raw)));`, "app.post(\"/__void/migrate/app\", __markRouteHandler((c) => __voidCreateMigrationRequestHandler(false, true)(c.req.raw)));", "app.get(\"/__void/migrate/app/attempt/:attemptId\", __markRouteHandler((c) => __voidCreateMigrationRequestHandler(false, true)(c.req.raw)));");
2872
2721
  if (auth) lines.push("app.post(\"/__void/migrate/auth\", __markRouteHandler((c) => __voidCreateMigrationRequestHandler(true, true)(c.req.raw)));");
2873
2722
  lines.push("");
2874
- } else {
2875
- lines.push("export async function __voidHandleInternalRoute() { return null; }");
2876
- lines.push("");
2877
- }
2878
- if (options.bindingHandlerPath) {
2879
- lines.push(`import { createBindingHandler as __createBindingHandler } from ${JSON.stringify(options.bindingHandlerPath)};`);
2880
- lines.push("let __voidBindingApp;");
2881
- lines.push("app.all(\"/__void/*\", __markRouteHandler(async (c) => {");
2882
- lines.push(" if (!__voidBindingApp) __voidBindingApp = __createBindingHandler(__getRawEnv());");
2883
- lines.push(" const url = new URL(c.req.url);");
2884
- lines.push(" url.pathname = url.pathname.slice(7);");
2885
- lines.push(" return __voidBindingApp.fetch(new Request(url.toString(), c.req.raw));");
2886
- lines.push("}));");
2887
- lines.push("");
2888
- }
2889
- lines.push("const __rawEnvStore = new AsyncLocalStorage();");
2890
- lines.push("export function __withRawEnv(env, fn) { return __rawEnvStore.run(env, fn); }");
2891
- lines.push("function __getRawEnv() { return __rawEnvStore.getStore(); }");
2892
- lines.push(`export const __VOID_BUILD_KEY = ${JSON.stringify(crypto.randomUUID())};`);
2893
- lines.push(`export const __VOID_DEV_TRIGGER_TOKEN = ${JSON.stringify(options.devTriggerToken ?? crypto.randomUUID())};`);
2894
- lines.push(`const __VOID_SERVE = ${JSON.stringify(options.dev === true)};`);
2895
- lines.push(`export const __VOID_ISR_REVALIDATE = ${JSON.stringify(mergedRevalidate)};`);
2896
- lines.push(`export const __VOID_ISR_PAGES = ${JSON.stringify(isrPages)};`);
2897
- lines.push(`export const __VOID_ISR_PATH_REVALIDATE = ${JSON.stringify(isrPathRevalidate)};`);
2898
- lines.push(`export const __VOID_ISR_DEPLOYMENT_ID = ${JSON.stringify(crypto.randomUUID())};`);
2899
- lines.push("");
2900
- lines.push(`export default app;`);
2723
+ } else lines.push("export async function __voidHandleInternalRoute() { return null; }", "");
2724
+ if (options.bindingHandlerPath) lines.push(`import { createBindingHandler as __createBindingHandler } from ${JSON.stringify(options.bindingHandlerPath)};`, "let __voidBindingApp;", "app.all(\"/__void/*\", __markRouteHandler(async (c) => {", " if (!__voidBindingApp) __voidBindingApp = __createBindingHandler(__getRawEnv());", " const url = new URL(c.req.url);", " url.pathname = url.pathname.slice(7);", " return __voidBindingApp.fetch(new Request(url.toString(), c.req.raw));", "}));", "");
2725
+ lines.push("const __rawEnvStore = new AsyncLocalStorage();", "export function __withRawEnv(env, fn) { return __rawEnvStore.run(env, fn); }", "function __getRawEnv() { return __rawEnvStore.getStore(); }", `export const __VOID_BUILD_KEY = ${JSON.stringify(crypto.randomUUID())};`, `export const __VOID_DEV_TRIGGER_TOKEN = ${JSON.stringify(options.devTriggerToken ?? crypto.randomUUID())};`, `const __VOID_SERVE = ${JSON.stringify(options.dev === true)};`, `export const __VOID_ISR_REVALIDATE = ${JSON.stringify(mergedRevalidate)};`, `export const __VOID_ISR_PAGES = ${JSON.stringify(isrPages)};`, `export const __VOID_ISR_PATH_REVALIDATE = ${JSON.stringify(isrPathRevalidate)};`, `export const __VOID_ISR_DEPLOYMENT_ID = ${JSON.stringify(crypto.randomUUID())};`, "", `export default app;`);
2901
2726
  return lines.join("\n");
2902
2727
  }
2903
2728
  function compilePrerenderCollector(lines, scan, ssr, options, pageNames, pagesDirRelative) {
2904
2729
  const staticPaths = scan.pages.pages.filter((page) => page.shouldPrerender && page.params.length === 0 && !page.catchAll).map((page) => page.pattern);
2905
2730
  const dynamicPages = scan.pages.pages.filter((page) => page.shouldPrerender && page.hasGetPrerenderPaths && (page.params.length > 0 || page.catchAll));
2906
2731
  const explicitPaths = options.explicitPrerenderPaths ?? [];
2907
- lines.push(`export async function __voidCollectPrerenderPaths(request, env, ctx) {`);
2908
- lines.push(` return withRuntimeEnv(env, async () => {`);
2732
+ lines.push(`export async function __voidCollectPrerenderPaths(request, env, ctx) {`, ` return withRuntimeEnv(env, async () => {`);
2909
2733
  if (options.nodeTarget) lines.push(` return requestContext.run({ request }, async () => {`);
2910
2734
  else lines.push(` return requestContext.run({ request, executionCtx: ctx }, async () => {`);
2911
2735
  lines.push(` const paths = [];`);
2912
2736
  for (const path of staticPaths) lines.push(` paths.push(${JSON.stringify(path)});`);
2913
2737
  for (const page of dynamicPages) {
2914
2738
  const loaderName = `_pload_${pageNames(page.componentId)}`;
2915
- lines.push(` {`);
2916
- lines.push(` const mod = await ${loaderName}();`);
2917
- lines.push(` if (typeof mod.getPrerenderPaths === "function") {`);
2918
- lines.push(` const paramSets = await mod.getPrerenderPaths();`);
2919
- lines.push(` if (Array.isArray(paramSets)) {`);
2739
+ lines.push(` {`, ` const mod = await ${loaderName}();`, ` if (typeof mod.getPrerenderPaths === "function") {`, ` const paramSets = await mod.getPrerenderPaths();`, ` if (Array.isArray(paramSets)) {`);
2920
2740
  const file = [pagesDirRelative, page.serverPath ?? page.componentPath].filter(Boolean).join("/");
2921
- lines.push(` for (let index = 0; index < paramSets.length; index++) {`);
2922
- lines.push(` paths.push(__buildPrerenderPath(${JSON.stringify(page.pattern)}, paramSets[index], ${JSON.stringify(file)}, index));`);
2923
- lines.push(` }`);
2924
- lines.push(` }`);
2925
- lines.push(` }`);
2926
- lines.push(` }`);
2927
- }
2928
- if (ssr) {
2929
- lines.push(` {`);
2930
- lines.push(` const mod = await import(${JSON.stringify(ssr.serverEntryPath)});`);
2931
- lines.push(` if (typeof mod.getPrerenderPaths === "function") {`);
2932
- lines.push(` const ssrPaths = await mod.getPrerenderPaths();`);
2933
- lines.push(` if (Array.isArray(ssrPaths)) {`);
2934
- lines.push(` for (const path of ssrPaths) {`);
2935
- lines.push(` if (typeof path === "string") paths.push(path);`);
2936
- lines.push(` }`);
2937
- lines.push(` }`);
2938
- lines.push(` }`);
2939
- lines.push(` }`);
2741
+ lines.push(` for (let index = 0; index < paramSets.length; index++) {`, ` paths.push(__buildPrerenderPath(${JSON.stringify(page.pattern)}, paramSets[index], ${JSON.stringify(file)}, index));`, ` }`, ` }`, ` }`, ` }`);
2940
2742
  }
2743
+ if (ssr) lines.push(` {`, ` const mod = await import(${JSON.stringify(ssr.serverEntryPath)});`, ` if (typeof mod.getPrerenderPaths === "function") {`, ` const ssrPaths = await mod.getPrerenderPaths();`, ` if (Array.isArray(ssrPaths)) {`, ` for (const path of ssrPaths) {`, ` if (typeof path === "string") paths.push(path);`, ` }`, ` }`, ` }`, ` }`);
2941
2744
  for (const path of explicitPaths) lines.push(` paths.push(${JSON.stringify(path)});`);
2942
- lines.push(options.trailingSlash ? ` return [...new Set(paths.map((path) => path.endsWith("/") ? path : path + "/"))];` : ` return [...new Set(paths)];`);
2943
- lines.push(` });`);
2944
- lines.push(` });`);
2945
- lines.push(`}`);
2946
- lines.push("");
2745
+ lines.push(options.trailingSlash ? ` return [...new Set(paths.map((path) => path.endsWith("/") ? path : path + "/"))];` : ` return [...new Set(paths)];`, ` });`, ` });`, `}`, "");
2947
2746
  }
2747
+ const virtualDevUrl = (id) => "/@id/__x00__" + id;
2948
2748
  function compilePageRoutes(lines, scan, pages, options, pageNames) {
2949
2749
  lines.push(`import { renderPage } from "virtual:void-pages-renderer";`);
2950
2750
  if (options.dev) lines.push(`import { getVoidPagesDevCss } from "virtual:void-pages-dev-assets";`);
2951
2751
  const hasIslandPages = scan.pages.pages.some((p) => p.renderMode === "island");
2952
2752
  if (hasIslandPages) lines.push(`import { renderIslandPage } from "virtual:void-islands-renderer";`);
2953
- lines.push("");
2954
- lines.push(`const __voidHeadConfig = ${JSON.stringify(pages.headConfig ?? null)};`);
2955
- lines.push("");
2753
+ lines.push("", `const __voidHeadConfig = ${JSON.stringify(pages.headConfig ?? null)};`, "");
2956
2754
  pushDefaultErrorPageHelpers(lines, options);
2957
2755
  const relPagesDir = pages.pagesDirRelative;
2958
2756
  const pageCssKeys = {};
@@ -2960,7 +2758,6 @@ function compilePageRoutes(lines, scan, pages, options, pageNames) {
2960
2758
  const boundaryManifest = createBoundaryManifest(scan.pages);
2961
2759
  const projectRoot = options.projectRoot;
2962
2760
  const toDevRootUrl = (absolutePath) => "/" + absolutePath.replaceAll("\\", "/").slice(projectRoot.replaceAll("\\", "/").length + 1);
2963
- const virtualDevUrl = (id) => "/@id/__x00__" + id;
2964
2761
  for (const page of scan.pages.pages) {
2965
2762
  const keys = [];
2966
2763
  const routeRootPhases = [[virtualDevUrl(page.island ? pages.islandClientEntryId ?? pages.clientEntryId : pages.clientEntryId)]];
@@ -2983,17 +2780,16 @@ function compilePageRoutes(lines, scan, pages, options, pageNames) {
2983
2780
  }
2984
2781
  }
2985
2782
  keys.push(`${relPagesDir}/${page.componentPath}`);
2986
- routeRootPhases.push(layoutRoots);
2987
- routeRootPhases.push([toDevRootUrl(`${pages.pagesDir}/${page.componentPath}`)]);
2783
+ routeRootPhases.push(layoutRoots, [toDevRootUrl(`${pages.pagesDir}/${page.componentPath}`)]);
2988
2784
  pageCssKeys[page.componentId] = keys;
2989
2785
  pageDevRootPhases[page.componentId] = routeRootPhases.filter((phase) => phase.length > 0);
2990
2786
  }
2991
2787
  for (const plan of Object.values(boundaryManifest.plans)) {
2992
- const files = [...scan.pages.layouts, ...scan.pages.namedLayouts].filter((layout) => {
2788
+ const files = [...scan.pages.layouts, ...scan.pages.namedLayouts].flatMap((layout) => {
2993
2789
  const id = "name" in layout ? layout.directory ? layout.directory + "/_layouts/" + layout.name : "_layouts/" + layout.name : layout.directory ? layout.directory + "/layout" : "layout";
2994
2790
  const key = scan.pages.pages.some((page) => page.componentId === id) ? id.replace(/(^|\/)([^/]+)$/, "$1_$2") : id;
2995
- return plan.layouts.includes(key);
2996
- }).map((layout) => layout.filePath);
2791
+ return plan.layouts.includes(key) ? [layout.filePath] : [];
2792
+ });
2997
2793
  files.push(plan.filePath);
2998
2794
  pageCssKeys[plan.id] = files.map((file) => `${relPagesDir}/${file}`);
2999
2795
  pageDevRootPhases[plan.id] = [[virtualDevUrl(pages.clientEntryId)], files.map((file) => toDevRootUrl(`${pages.pagesDir}/${file}`))];
@@ -3225,15 +3021,14 @@ ${entryClass}`;
3225
3021
  * Generate the app module — exports the Hono app with static asset serving.
3226
3022
  * This is the entry imported by `vite preview` and can be used programmatically.
3227
3023
  */
3228
- function compileNodeApp(target, honoPath, envSchemaModule) {
3024
+ function compileNodeApp(target, envSchemaModule) {
3229
3025
  const staticImport = target === "bun" ? `import { serveStatic } from "hono/bun";` : target === "deno" ? `import { serveStatic } from "hono/deno";` : `import { serveStatic } from "@hono/node-server/serve-static";`;
3230
3026
  const envSchemaImport = envSchemaModule ? `import ${JSON.stringify(envSchemaModule.importPath)};\nimport { _validateEnvOnce } from ${JSON.stringify(envSchemaModule.helperPath)};\n` : "";
3231
3027
  const envMiddleware = envSchemaModule ? `app.use("*", async (c, next) => { if (!(((c.req.method === "POST" && c.req.path === "/__void/prerender-paths") || (c.req.method === "GET" && c.req.path === "/__void/static-not-found")) && c.env?.__VOID_PRERENDER === "1")) await _validateEnvOnce(${target === "deno" ? "Deno.env.toObject()" : "process.env"}); return next(); });\n` : "";
3232
3028
  return `${staticImport}
3233
3029
  import { fileURLToPath } from "node:url";
3234
- import { Hono } from ${JSON.stringify(honoPath)};
3235
3030
  import innerApp, { __voidCollectPrerenderPaths, __voidRenderStaticNotFound } from "virtual:void-routes";
3236
- import { prerenderPathsResponse as __prerenderPathsResponse } from ${JSON.stringify(ROUTING_RUNTIME_PATH)};
3031
+ import { Hono, prerenderPathsResponse as __prerenderPathsResponse } from ${JSON.stringify(ROUTING_RUNTIME_PATH)};
3237
3032
  ${envSchemaImport}
3238
3033
  // dist/client, created on first use so a server that supplies its own ASSETS
3239
3034
  // (a single executable, for one) never looks for a directory it doesn't have.
@@ -3297,9 +3092,7 @@ function stripOriginForProd(rules) {
3297
3092
  return rules.map(({ origin: _origin, ...rest }) => rest);
3298
3093
  }
3299
3094
  function compileRoutingRulesMiddleware(lines, rules, dev) {
3300
- lines.push("// Routing rules: redirects + rewrites (applied before route handlers)");
3301
- lines.push(`const __routingRules = ${JSON.stringify(dev ? rules : stripOriginForProd(rules))};`);
3302
- lines.push("app.use(\"*\", __routingRuntime.routingMiddleware(__routingRules));");
3095
+ lines.push("// Routing rules: redirects + rewrites (applied before route handlers)", `const __routingRules = ${JSON.stringify(dev ? rules : stripOriginForProd(rules))};`, "app.use(\"*\", __routingRuntime.routingMiddleware(__routingRules));");
3303
3096
  }
3304
3097
  /** Generate the server-side fetch client, which calls `app.fetch()` with the current request's credentials. */
3305
3098
  function compileWorkerClient(authClientPath, nodeTarget = false) {
@@ -3407,7 +3200,7 @@ function generateClassATriggerWrapper(root, framework, original, isBuild, dialec
3407
3200
  const scoped = dialect !== "sqlite";
3408
3201
  const fetchMethod = scoped ? ` fetch(request, env, ctx) {
3409
3202
  return withRuntimeEnv(env, async () => {
3410
- ${fetchBody.replace(/^/gm, " ")}
3203
+ ${fetchBody.replaceAll(/^/gm, " ")}
3411
3204
  });
3412
3205
  },` : ` async fetch(request, env, ctx) {
3413
3206
  ${fetchBody}
@@ -3446,198 +3239,6 @@ export default {
3446
3239
  `);
3447
3240
  return entryPath;
3448
3241
  }
3449
- // src/installed-packages.ts
3450
- function readManifest(dir) {
3451
- try {
3452
- return JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
3453
- } catch {
3454
- return;
3455
- }
3456
- }
3457
- /** The directory Node loads `name` from for code in `fromDir`. Ignores `exports`. */
3458
- function findInstalledPackage(name, fromDir) {
3459
- const pnp = module.findPnpApi?.(fromDir);
3460
- if (pnp) try {
3461
- const manifest = pnp.resolveToUnqualified(`${name}/package.json`, `${fromDir}/`);
3462
- return manifest ? dirname(manifest) : void 0;
3463
- } catch {
3464
- return;
3465
- }
3466
- for (let dir = fromDir;; dir = dirname(dir)) {
3467
- const candidate = join(dir, "node_modules", name);
3468
- if (existsSync(join(candidate, "package.json"))) return realpathSync(candidate);
3469
- if (dirname(dir) === dir) return;
3470
- }
3471
- }
3472
- function isVoidPackage(name) {
3473
- return name === "void" || name.startsWith("@void/");
3474
- }
3475
- /** The `exports` conditions that an import matches in Vite's SSR graph. */
3476
- const IMPORT_CONDITIONS = /* @__PURE__ */ new Set([
3477
- "node",
3478
- "import",
3479
- "module",
3480
- "default"
3481
- ]);
3482
- /**
3483
- * Vite's SSR graph also matches `production` or `development`, as NODE_ENV says. Vite sets
3484
- * NODE_ENV before it runs the plugin hooks that call this.
3485
- */
3486
- function matchesImport(condition) {
3487
- const mode = process.env.NODE_ENV === "production" ? "production" : "development";
3488
- return IMPORT_CONDITIONS.has(condition) || condition === mode;
3489
- }
3490
- /** The target an import picks from an `exports` value: its first matching key, as in Node. */
3491
- function importTarget(value) {
3492
- if (typeof value === "string") return value;
3493
- if (Array.isArray(value)) {
3494
- for (const item of value) {
3495
- const target = importTarget(item);
3496
- if (target) return target;
3497
- }
3498
- return;
3499
- }
3500
- if (!value || typeof value !== "object") return;
3501
- for (const [key, item] of Object.entries(value)) {
3502
- const target = matchesImport(key) ? importTarget(item) : void 0;
3503
- if (target) return target;
3504
- }
3505
- }
3506
- function isFile(path) {
3507
- try {
3508
- return statSync(path).isFile();
3509
- } catch {
3510
- return false;
3511
- }
3512
- }
3513
- /** The file an import of the package loads: `exports` ".", then `module`, then `main`. */
3514
- function findImportEntry(dir, manifest) {
3515
- const exports = manifest.exports;
3516
- const entry = importTarget(exports && typeof exports === "object" && Object.keys(exports).some((key) => key.startsWith(".")) ? exports["."] : exports) ?? (typeof manifest.module === "string" ? manifest.module : void 0) ?? (typeof manifest.main === "string" ? manifest.main : "index.js");
3517
- for (const candidate of [
3518
- entry,
3519
- `${entry}.js`,
3520
- `${entry}/index.js`
3521
- ]) {
3522
- const file = join(dir, candidate);
3523
- if (isFile(file)) return file;
3524
- }
3525
- }
3526
- /** Whether Node loads a `.mjs` or `.js` file in the package as an ES module. */
3527
- function isEsmFile(file, dir, manifest) {
3528
- if (file.endsWith(".mjs")) return true;
3529
- if (!file.endsWith(".js")) return false;
3530
- for (let scope = dirname(file); scope.startsWith(`${dir}/`); scope = dirname(scope)) {
3531
- const nested = readManifest(scope);
3532
- if (nested) return nested.type === "module";
3533
- }
3534
- return manifest.type === "module";
3535
- }
3536
- /** A dynamic `import()` argument that is a single string literal naming a relative file. */
3537
- const RELATIVE_LITERAL = /^(["'])(\.{1,2}\/[^"']*)\1$/;
3538
- /** The relative files that a module's imports, re-exports and `import()` calls name. */
3539
- function relativeImports(code, parsed) {
3540
- const specifiers = staticModuleReferences(parsed, code).map((reference) => reference.source);
3541
- for (const { moduleRequest } of parsed.module.dynamicImports) {
3542
- const literal = RELATIVE_LITERAL.exec(code.slice(moduleRequest.start, moduleRequest.end));
3543
- if (literal) specifiers.push(literal[2]);
3544
- }
3545
- return specifiers.filter((specifier) => /^\.{1,2}\//.test(specifier));
3546
- }
3547
- /** The most files of one package that the check reads. A package with more stays with Node. */
3548
- const MAX_PACKAGE_MODULES = 2e3;
3549
- /**
3550
- * Vite's SSR module runner evaluates an inlined package as ES modules. The package's import
3551
- * entry and every file it reaches through relative imports must be one. So the ES module
3552
- * wrapper in Node's dual-package guide, or any ES module of the package that imports a
3553
- * CommonJS file, keeps the package with Node.
3554
- */
3555
- function shipsEsm(packageDir, manifest) {
3556
- const dir = normalize(packageDir);
3557
- const entry = findImportEntry(dir, manifest);
3558
- if (!entry) return false;
3559
- const files = [entry];
3560
- const seen = new Set(files);
3561
- for (const file of files) {
3562
- if (!isEsmFile(file, dir, manifest)) return false;
3563
- let code;
3564
- try {
3565
- code = readFileSync(file, "utf8");
3566
- } catch {
3567
- return false;
3568
- }
3569
- const parsed = parseSync(file, code, {
3570
- lang: "js",
3571
- sourceType: "module"
3572
- });
3573
- if (parsed.errors.length > 0) return false;
3574
- for (const specifier of relativeImports(code, parsed)) {
3575
- const next = join(dirname(file), specifier);
3576
- if (/\.[cm]?js$/.test(next) && !seen.has(next)) {
3577
- if (seen.size >= MAX_PACKAGE_MODULES) return false;
3578
- seen.add(next);
3579
- files.push(next);
3580
- }
3581
- }
3582
- }
3583
- return true;
3584
- }
3585
- /**
3586
- * Installed ES module packages that list `void` or an `@void/` package as a dependency, among
3587
- * the app's own dependencies and, through them, the packages they depend on (the rule
3588
- * vite-plugin-svelte applies to Svelte libraries). Vite leaves a package in node_modules to Node,
3589
- * whose `void/*` imports then skip Void's plugins: the generated `void/db` and the Node target's
3590
- * guard. Listing these packages in `ssr.noExternal` keeps them in Vite's graph.
3591
- */
3592
- function findVoidDependentPackages(root) {
3593
- const app = readManifest(root);
3594
- if (!app) return [];
3595
- const found = /* @__PURE__ */ new Set();
3596
- const seen = /* @__PURE__ */ new Set();
3597
- const visit = (names, fromDir) => {
3598
- for (const name of names) {
3599
- if (isVoidPackage(name)) continue;
3600
- const dir = findInstalledPackage(name, fromDir);
3601
- if (!dir || seen.has(dir)) continue;
3602
- seen.add(dir);
3603
- const manifest = readManifest(dir);
3604
- const dependencies = {
3605
- ...manifest?.dependencies,
3606
- ...manifest?.optionalDependencies
3607
- };
3608
- if (!manifest || !Object.keys({
3609
- ...dependencies,
3610
- ...manifest.peerDependencies
3611
- }).some(isVoidPackage) || !shipsEsm(dir, manifest)) continue;
3612
- found.add(name);
3613
- visit(Object.keys(dependencies), dir);
3614
- }
3615
- };
3616
- visit(Object.keys({
3617
- ...app.dependencies,
3618
- ...app.devDependencies,
3619
- ...app.optionalDependencies
3620
- }), root);
3621
- return [...found].sort();
3622
- }
3623
- /** `name` and every package it depends on, as installed for code in `fromDir`. */
3624
- function findDependencyClosure(name, fromDir) {
3625
- const found = /* @__PURE__ */ new Set();
3626
- const seen = /* @__PURE__ */ new Set();
3627
- const visit = (dependency, from) => {
3628
- const dir = findInstalledPackage(dependency, from);
3629
- if (!dir || seen.has(dir)) return;
3630
- seen.add(dir);
3631
- found.add(dependency);
3632
- const manifest = readManifest(dir);
3633
- for (const next of Object.keys({
3634
- ...manifest?.dependencies,
3635
- ...manifest?.optionalDependencies
3636
- })) visit(next, dir);
3637
- };
3638
- visit(name, fromDir);
3639
- return [...found].sort();
3640
- }
3641
3242
  // src/plugin-migration.ts
3642
3243
  function readDatabaseUrl(root) {
3643
3244
  return loadLocalEnv(root).DATABASE_URL;
@@ -3649,6 +3250,9 @@ function readDatabaseUrl(root) {
3649
3250
  function readAuthDatabaseUrl(root) {
3650
3251
  return process.env.DATABASE_URL || readDatabaseUrl(root) || void 0;
3651
3252
  }
3253
+ const logApplied = (applied) => {
3254
+ if (applied.length > 0) voidLog(`Applied ${applied.length} migration(s): ${applied.join(", ")}`);
3255
+ };
3652
3256
  /**
3653
3257
  * Vite plugin that runs local migrations on dev server startup.
3654
3258
  * For SQLite/D1: applies migrations to the local miniflare database.
@@ -3664,13 +3268,10 @@ function migrationPlugin(root, dialect, databaseId = "local", persistRoot = join
3664
3268
  const hasSqlMigrations = existsSync(migrationsDir);
3665
3269
  if (!hasSqlMigrations && !auth?.enabled) return;
3666
3270
  const migrateAuth = async (databaseUrl) => {
3667
- const { runLocalVoidAuthMigrations } = await import("./node-DqkiQujF.mjs");
3271
+ const { runLocalVoidAuthMigrations } = await import("./node-DVJWfV6s.mjs");
3668
3272
  await runLocalVoidAuthMigrations(root, dialect, persistRoot, databaseId, auth?.configPath, databaseUrl, devAuthConfigImporter(server));
3669
3273
  };
3670
3274
  const mysqlAuth = dialect === "mysql" && auth?.enabled === true;
3671
- const logApplied = (applied) => {
3672
- if (applied.length > 0) voidLog(`Applied ${applied.length} migration(s): ${applied.join(", ")}`);
3673
- };
3674
3275
  const refuse = (err) => {
3675
3276
  afterServerReady(server, () => {
3676
3277
  console.log();
@@ -3679,7 +3280,7 @@ function migrationPlugin(root, dialect, databaseId = "local", persistRoot = join
3679
3280
  };
3680
3281
  try {
3681
3282
  if (dialect !== "sqlite") {
3682
- const { collectMigrations } = await import("./collect-8i0wU63d.mjs");
3283
+ const { collectMigrations } = await import("./collect-B6nlSnsb.mjs");
3683
3284
  const allMigrations = collectMigrations(migrationsDir);
3684
3285
  const runFiles = dialect === "mysql" ? allMigrations.length > 0 : hasSqlMigrations;
3685
3286
  const url = runFiles ? readDatabaseUrl(root) : void 0;
@@ -3693,8 +3294,8 @@ function migrationPlugin(root, dialect, databaseId = "local", persistRoot = join
3693
3294
  }
3694
3295
  const authWithFiles = authUrl !== void 0 && authUrl === url;
3695
3296
  if (url) {
3696
- const { validateMigrations } = await import("./validate-DY1U9rET.mjs");
3697
- const appliedNames = dialect === "mysql" ? await import("./runner-mysql-C_PrAUTm.mjs").then((runner) => runner.getMySqlAppliedMigrations(url)) : await import("./runner-pg-2pjltt0t.mjs").then((runner) => runner.getPgAppliedMigrations(url));
3297
+ const { validateMigrations } = await import("./validate-CZYUIfR-.mjs");
3298
+ const appliedNames = dialect === "mysql" ? await import("./runner-mysql-DOjbj-N1.mjs").then((runner) => runner.getMySqlAppliedMigrations(url)) : await import("./runner-pg-DMJquR3d.mjs").then((runner) => runner.getPgAppliedMigrations(url));
3698
3299
  const appliedSet = new Set(appliedNames);
3699
3300
  const pending = allMigrations.filter((migration) => !appliedSet.has(migration.name));
3700
3301
  if (pending.length > 0) try {
@@ -3703,20 +3304,20 @@ function migrationPlugin(root, dialect, databaseId = "local", persistRoot = join
3703
3304
  refuse(err);
3704
3305
  return;
3705
3306
  }
3706
- const applied = dialect === "mysql" ? await import("./runner-mysql-C_PrAUTm.mjs").then((runner) => runner.runMySqlMigrations(migrationsDir, url, authWithFiles ? async (names) => {
3307
+ const applied = dialect === "mysql" ? await import("./runner-mysql-DOjbj-N1.mjs").then((runner) => runner.runMySqlMigrations(migrationsDir, url, authWithFiles ? async (names) => {
3707
3308
  logApplied(names);
3708
3309
  await migrateAuth(url);
3709
- } : void 0)) : await import("./runner-pg-2pjltt0t.mjs").then((runner) => runner.runPgMigrations(migrationsDir, url));
3310
+ } : void 0)) : await import("./runner-pg-DMJquR3d.mjs").then((runner) => runner.runPgMigrations(migrationsDir, url));
3710
3311
  if (!authWithFiles) logApplied(applied);
3711
3312
  }
3712
3313
  if (authUrl && !authWithFiles) {
3713
- const { withMySqlMigrationLockAt } = await import("./runner-mysql-C_PrAUTm.mjs");
3314
+ const { withMySqlMigrationLockAt } = await import("./runner-mysql-DOjbj-N1.mjs");
3714
3315
  await withMySqlMigrationLockAt(authUrl, () => migrateAuth(authUrl));
3715
3316
  }
3716
3317
  } else if (hasSqlMigrations) {
3717
- const { runMigrations, getMiniflareDatabasePath, getAppliedMigrations } = await import("./runner-CTk21HrO.mjs");
3718
- const { collectMigrations } = await import("./collect-8i0wU63d.mjs");
3719
- const { validateMigrations } = await import("./validate-DY1U9rET.mjs");
3318
+ const { runMigrations, getMiniflareDatabasePath, getAppliedMigrations } = await import("./runner-Bf94YVJK.mjs");
3319
+ const { collectMigrations } = await import("./collect-B6nlSnsb.mjs");
3320
+ const { validateMigrations } = await import("./validate-CZYUIfR-.mjs");
3720
3321
  const dbPath = getMiniflareDatabasePath(persistRoot, databaseId);
3721
3322
  const allMigrations = collectMigrations(migrationsDir);
3722
3323
  const appliedRows = await getAppliedMigrations(dbPath);
@@ -3872,16 +3473,43 @@ async function readWorkerdNodeBuiltins(compat) {
3872
3473
  });
3873
3474
  return /* @__PURE__ */ new Set([...external.map((name) => name.replace(/^node:/, "")), "process"]);
3874
3475
  }
3875
- function createServerRuntimeOptimizerPlugin(dialect, readCompat) {
3476
+ function createServerRuntimeOptimizerPlugin(dialect, readCompat, ssrEntry = null, nativeWorker) {
3876
3477
  let workerdNodeBuiltins;
3478
+ let scanNativeWorker = false;
3479
+ let hasExplicitWorkerEntries = false;
3877
3480
  return {
3878
3481
  name: "void:server-runtime-optimizer",
3879
- configEnvironment(name, environment) {
3482
+ config: {
3483
+ order: "pre",
3484
+ handler(config, { command, isPreview }) {
3485
+ scanNativeWorker = nativeWorker !== void 0 && command === "serve" && !isPreview;
3486
+ if (!scanNativeWorker) return;
3487
+ const optimizer = config.environments?.[DEFAULT_WORKER_ENVIRONMENT_NAME]?.optimizeDeps;
3488
+ hasExplicitWorkerEntries = optimizer?.entries !== void 0;
3489
+ if (typeof optimizer?.entries === "string") optimizer.entries = [optimizer.entries];
3490
+ }
3491
+ },
3492
+ async configEnvironment(name, environment) {
3880
3493
  if (name === "client") return;
3881
3494
  if (!environment.resolve?.conditions?.includes("workerd")) return { optimizeDeps: { exclude: ["void"] } };
3495
+ const entries = ssrEntry ? [ssrEntry] : [];
3496
+ if (name === "void_worker" && scanNativeWorker && nativeWorker) {
3497
+ const optimizer = environment.optimizeDeps ??= {};
3498
+ const generatedEntry = join(nativeWorker.root, ".void/entry.ts");
3499
+ const configured = optimizer.entries ?? generatedEntry;
3500
+ optimizer.entries = (Array.isArray(configured) ? configured : [configured]).map((entry) => entry === generatedEntry ? convertPathToPattern(entry) : entry);
3501
+ if (!hasExplicitWorkerEntries) entries.push(...await nativeWorker.scan());
3502
+ }
3882
3503
  return { optimizeDeps: {
3883
3504
  exclude: ["void", "better-auth"],
3884
- include: ["void > email-validator", ...DATABASE_DRIVER_DEPS[dialect]]
3505
+ ...entries.length > 0 ? { entries: entries.map(convertPathToPattern) } : {},
3506
+ include: [
3507
+ "void > devalue",
3508
+ "void > email-validator",
3509
+ "void > hono",
3510
+ "void > hono/route",
3511
+ ...DATABASE_DRIVER_DEPS[dialect]
3512
+ ]
3885
3513
  } };
3886
3514
  },
3887
3515
  resolveId: {
@@ -3918,7 +3546,7 @@ function injectSvelteKitBuildHooks(code, id, envModule) {
3918
3546
  }
3919
3547
  function editGetHooks(code, id, prologue, handleWrapper) {
3920
3548
  if (!code.includes("get_hooks")) return;
3921
- const hooks = (parseSync(id, code).program.body ?? []).filter((node) => node.type === "ExportNamedDeclaration").map((node) => node.declaration).filter((node) => {
3549
+ const hooks = (asAstProgram(parseSync(id, code).program).body ?? []).filter((node) => node.type === "ExportNamedDeclaration").map((node) => node.declaration).filter((node) => {
3922
3550
  const name = node?.id;
3923
3551
  return node?.type === "FunctionDeclaration" && isIdentifier(name) && name.name === "get_hooks";
3924
3552
  });
@@ -3937,9 +3565,75 @@ function editGetHooks(code, id, prologue, handleWrapper) {
3937
3565
  // src/plugin-framework.ts
3938
3566
  const handlerFile = fileURLToPath(import.meta.resolve("#self/handler"));
3939
3567
  const envModuleFile = fileURLToPath(import.meta.resolve("#self/_env"));
3940
- const voidDir = dirname(fileURLToPath(import.meta.url));
3568
+ const envPublicFile = fileURLToPath(import.meta.resolve("#self/env"));
3569
+ const voidDir = toSlash(import.meta.dirname);
3941
3570
  const ASTRO_SERVER_ENTRY = "@astrojs/cloudflare/entrypoints/server";
3942
3571
  const ASTRO_SCOPED_SERVER_ENTRY = "\0void:astro-server-entry";
3572
+ /**
3573
+ * A define value as Vite writes it into code (its handleDefineValue): a string is code, anything
3574
+ * else is JSON.
3575
+ */
3576
+ function defineValue(value) {
3577
+ if (value === void 0) return "undefined";
3578
+ return typeof value === "string" ? value : JSON.stringify(value);
3579
+ }
3580
+ /** The real path, so a symlinked id (`preserveSymlinks`) or a Windows short name still matches. */
3581
+ function realPath(file) {
3582
+ try {
3583
+ return normalizePath(realpathSync.native(file));
3584
+ } catch {
3585
+ return normalizePath(file);
3586
+ }
3587
+ }
3588
+ const IMPORT_META_ENV = "import.meta.env";
3589
+ function isNameChar(char) {
3590
+ return char !== void 0 && (char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char >= "0" && char <= "9" || char === "_" || char === "$");
3591
+ }
3592
+ /**
3593
+ * Where `import.meta.env` stands on its own: not inside a longer name, and not a property like
3594
+ * `a.import.meta.env`.
3595
+ */
3596
+ function findImportMetaEnv(code) {
3597
+ const starts = [];
3598
+ let index = code.indexOf(IMPORT_META_ENV);
3599
+ while (index !== -1) {
3600
+ const before = code[index - 1];
3601
+ if (!isNameChar(before) && before !== "." && !isNameChar(code[index + 15])) starts.push(index);
3602
+ index = code.indexOf(IMPORT_META_ENV, index + 15);
3603
+ }
3604
+ return starts;
3605
+ }
3606
+ function createAstroPublicEnvPlugin(file = envPublicFile) {
3607
+ const envPublicPath = realPath(file);
3608
+ let astroBuildEnv = {};
3609
+ return {
3610
+ name: "void:astro-public-env",
3611
+ apply: "build",
3612
+ enforce: "pre",
3613
+ configResolved(resolvedConfig) {
3614
+ astroBuildEnv = resolvedConfig.env;
3615
+ },
3616
+ transform: {
3617
+ filter: { id: /[\\/]env[\\/]public\.mjs$/ },
3618
+ handler(code, id) {
3619
+ if (this.environment?.name === "client" || realPath(id) !== envPublicPath) return;
3620
+ const values = {};
3621
+ for (const [key, value] of Object.entries(astroBuildEnv)) if (isClientEnvKey(key)) values[key] = JSON.stringify(value);
3622
+ for (const [key, value] of Object.entries(this.environment.config.define ?? {})) {
3623
+ const name = key.slice(16);
3624
+ if (key.startsWith("import.meta.env.") && isClientEnvKey(name)) values[name] = value;
3625
+ }
3626
+ const object = `{${Object.keys(values).sort().map((key) => `${JSON.stringify(key)}: ${defineValue(values[key])}`).join(", ")}}`;
3627
+ const ms = new MagicString(code);
3628
+ for (const start of findImportMetaEnv(code)) ms.overwrite(start, start + 15, `(${object})`);
3629
+ return ms.hasChanged() ? {
3630
+ code: ms.toString(),
3631
+ map: ms.generateMap({ hires: true })
3632
+ } : void 0;
3633
+ }
3634
+ }
3635
+ };
3636
+ }
3943
3637
  function createFrameworkPlugins(input) {
3944
3638
  const { localD1, root, directCloudflareDestination, bindings, config, dialect, application, bindingNames, websocketRoutes, liveConfig, detected, clientStubsPlugin, serverRuntimeOptimizerPlugin, devTriggerToken, implicitDeployGuard } = input;
3945
3639
  const frameworkPersistRoot = localD1.persistRoot;
@@ -4059,6 +3753,7 @@ export default {
4059
3753
  }
4060
3754
  }
4061
3755
  } : void 0;
3756
+ const astroPublicEnvPlugin = detected.name === "astro" ? createAstroPublicEnvPlugin() : void 0;
4062
3757
  const svelteKitWorkerBuildPlugin = detected.class === "b" && dialect !== "sqlite" ? {
4063
3758
  name: "void:sveltekit-worker-build",
4064
3759
  apply: "build",
@@ -4104,6 +3799,7 @@ export default {
4104
3799
  wranglerSyncPlugin,
4105
3800
  ...nuxtVite8WebSocketCompatPlugin ? [nuxtVite8WebSocketCompatPlugin] : [],
4106
3801
  ...astroServerEntryPlugin ? [astroServerEntryPlugin] : [],
3802
+ ...astroPublicEnvPlugin ? [astroPublicEnvPlugin] : [],
4107
3803
  svelteKitHooksInjectPlugin,
4108
3804
  ...svelteKitWorkerBuildPlugin ? [svelteKitWorkerBuildPlugin] : [],
4109
3805
  ...svelteKitD1CasingBuildPlugin ? [svelteKitD1CasingBuildPlugin] : [],
@@ -4138,7 +3834,7 @@ const CF_ONLY_REGEX = new RegExp(`^(${[
4138
3834
  "void/ai",
4139
3835
  "void/sandbox",
4140
3836
  "void/env"
4141
- ].map((s) => s.replace("/", "\\/")).join("|")})$`);
3837
+ ].map((s) => s.replace("/", String.raw`\/`)).join("|")})$`);
4142
3838
  /**
4143
3839
  * Bridge Node.js HTTP to Web API and serve via a Hono app.
4144
3840
  * Used by both dev server and preview server middleware.
@@ -4159,12 +3855,13 @@ function honoMiddleware(getApp, isViteFile) {
4159
3855
  const headers = new Headers();
4160
3856
  for (const [key, value] of Object.entries(req.headers)) if (value) headers.set(key, Array.isArray(value) ? value.join(", ") : value);
4161
3857
  const hasBody = req.method !== "GET" && req.method !== "HEAD";
4162
- const request = new Request(url.toString(), {
3858
+ const init = {
4163
3859
  method: req.method,
4164
3860
  headers,
4165
3861
  body: hasBody ? req : void 0,
4166
3862
  duplex: hasBody ? "half" : void 0
4167
- });
3863
+ };
3864
+ const request = new Request(url.toString(), init);
4168
3865
  const response = await app.fetch(request);
4169
3866
  if (response.status === 404 && (await isViteFile?.(request) || !response.headers.get("content-type")?.includes("text/html") && !response.headers.has("X-VoidPages"))) {
4170
3867
  next();
@@ -4576,13 +4273,15 @@ function restartPlugin() {
4576
4273
  function stampClientAssetCachePolicy(bundle, manifestPath, headerRules = []) {
4577
4274
  const asset = bundle[manifestPath];
4578
4275
  if (asset?.type !== "asset") return [];
4276
+ const source = typeof asset.source === "string" ? asset.source : new TextDecoder().decode(asset.source);
4277
+ const manifest = JSON.parse(source);
4278
+ if (!isClientManifest(manifest)) throw new Error(`Invalid Vite client manifest in ${manifestPath}`);
4579
4279
  const fingerprinted = /* @__PURE__ */ new Set();
4580
- const authoredCachePatterns = headerRules.filter((rule) => rule.headers.some(([name]) => name.toLowerCase() === "cache-control")).map((rule) => rule.pattern);
4280
+ const authoredCachePatterns = headerRules.flatMap((rule) => rule.headers.some(([name]) => name.toLowerCase() === "cache-control") ? [rule.pattern] : []);
4581
4281
  for (const pattern of authoredCachePatterns) compilePattern(pattern);
4582
4282
  for (const item of Object.values(bundle)) if (item.type === "chunk" && typeof item.preliminaryFileName === "string" && item.preliminaryFileName !== item.fileName) {
4583
4283
  if (!authoredCachePatterns.some((pattern) => matchPattern(pattern, "/" + item.fileName))) fingerprinted.add(item.fileName);
4584
4284
  }
4585
- const manifest = JSON.parse(String(asset.source));
4586
4285
  const stamped = /* @__PURE__ */ new Set();
4587
4286
  for (const entry of Object.values(manifest)) if (entry.file && fingerprinted.has(entry.file)) {
4588
4287
  entry.immutableFiles = [entry.file];
@@ -4605,6 +4304,18 @@ const PAGE_VIRTUAL_MODULE_IDS = [
4605
4304
  ];
4606
4305
  const RESOLVE_ID_FILTER = /^(virtual:void-(routes|client-worker(?::(react|vue|svelte|solid))?|client-browser(?::(react|vue|svelte|solid))?)|void(\/client(\/(react|vue|svelte|solid))?|\/queues)?)$/;
4607
4306
  const LOAD_ID_FILTER = /^virtual:void-(routes|client-worker(?::(react|vue|svelte|solid))?|client-browser(?::(react|vue|svelte|solid))?)$/;
4307
+ function resolveAuthClientFramework(config) {
4308
+ return [
4309
+ "react",
4310
+ "vue",
4311
+ "svelte",
4312
+ "solid"
4313
+ ].find((framework) => config.plugins.some((plugin) => plugin.name === `void-${framework}:pages`));
4314
+ }
4315
+ const resolveFile = (specifier) => fileURLToPath(import.meta.resolve(specifier));
4316
+ function isInDirectory(path, directory) {
4317
+ return path === directory || path.startsWith(directory + "/");
4318
+ }
4608
4319
  /**
4609
4320
  * Vite plugin that provides file-based routing.
4610
4321
  * - Scans routes/ and middleware/ directories
@@ -4650,14 +4361,11 @@ function routingPlugin(root, options) {
4650
4361
  const normalizedQueuesDir = normalizePath(queuesDir);
4651
4362
  const normalizedEmailDir = normalizePath(emailDir);
4652
4363
  const normalizedPagesDir = normalizePath(pagesDir);
4653
- const ssrEntryAbsPaths = new Set([...SSR_SERVER_ENTRY_RELATIVE_PATHS, ...SSR_CLIENT_ENTRY_RELATIVE_PATHS].map((path) => normalizePath(join(ssrDir, path.split("/").pop()))));
4364
+ const ssrEntryAbsPaths = new Set([...SSR_SERVER_ENTRY_RELATIVE_PATHS, ...SSR_CLIENT_ENTRY_RELATIVE_PATHS].map((path) => normalizePath(join(ssrDir, path.slice(path.lastIndexOf("/") + 1)))));
4654
4365
  function hasEmailHandlers() {
4655
4366
  const email = scan?.email;
4656
4367
  return Boolean(email && (email.addresses.length > 0 || email.defaultHandler));
4657
4368
  }
4658
- function isInDirectory(path, directory) {
4659
- return path === directory || path.startsWith(directory + "/");
4660
- }
4661
4369
  function writeRouteTypes() {
4662
4370
  if (!scan) return;
4663
4371
  const { dts } = generateRouteTypes(scan, routesDir, outDir, pagesDir, { typedRoutes: options.routing?.typedRoutes });
@@ -4680,7 +4388,6 @@ function routingPlugin(root, options) {
4680
4388
  clientEntryRelativePath: entries.client.relativePath
4681
4389
  } : null;
4682
4390
  }
4683
- const resolveFile = (specifier) => fileURLToPath(import.meta.resolve(specifier));
4684
4391
  const handlerFile = resolveFile("#self/handler");
4685
4392
  const authRuntimeDir = dirname(resolveFile("void/auth"));
4686
4393
  const fetchPath = resolveFile("#self/runtime/fetch");
@@ -4709,8 +4416,6 @@ function routingPlugin(root, options) {
4709
4416
  const runtimeEmailPath = resolveFile("#self/email");
4710
4417
  const compileOptions = {
4711
4418
  trailingSlash: options.routing?.trailingSlash,
4712
- honoPath: resolveFile("hono"),
4713
- honoRoutePath: resolveFile("hono/route"),
4714
4419
  runtimeEnvPath: resolveFile("#self/_env"),
4715
4420
  emailDir,
4716
4421
  projectRoot: root,
@@ -4797,7 +4502,7 @@ function routingPlugin(root, options) {
4797
4502
  if (removeAuthTypesIfPresent(outDir)) syncAuthTypesInProjectTsconfig(root);
4798
4503
  return;
4799
4504
  }
4800
- const { generateVoidAuthDatabaseModule, generateVoidAuthDrizzleSchema } = await import("./drizzle-CvSGrvdl.mjs");
4505
+ const { generateVoidAuthDatabaseModule, generateVoidAuthDrizzleSchema } = await import("./drizzle-CQ5jWuDL.mjs");
4801
4506
  const authRuntime = {
4802
4507
  dialect: compileOptions.auth.dialect,
4803
4508
  providers: compileOptions.auth.providers,
@@ -4822,14 +4527,6 @@ function routingPlugin(root, options) {
4822
4527
  let isrRevalidate;
4823
4528
  let isrPages;
4824
4529
  let isrPathRevalidate;
4825
- function resolveAuthClientFramework(config) {
4826
- return [
4827
- "react",
4828
- "vue",
4829
- "svelte",
4830
- "solid"
4831
- ].find((framework) => config.plugins.some((plugin) => plugin.name === `void-${framework}:pages`));
4832
- }
4833
4530
  function getClientAuthPath(id) {
4834
4531
  const framework = VIRTUAL_CLIENT_RE.exec(id)?.[2];
4835
4532
  return framework ? explicitAuthClientPaths[framework] : authClientPath;
@@ -4849,7 +4546,7 @@ function routingPlugin(root, options) {
4849
4546
  function getPagesCompileOptions() {
4850
4547
  if (!scan || scan.pages.pages.length === 0 && !scan.pages.boundaries?.some((boundary) => boundary.kind === "not-found" && !boundary.directory)) return null;
4851
4548
  const hasIslandPages = scan.pages.pages.some((p) => p.island);
4852
- const mdPlugin = resolvedConfig?.plugins?.find((p) => p.name === "void-md");
4549
+ const mdPlugin = resolvedConfig?.plugins?.find((plugin) => plugin.name === "void-md");
4853
4550
  const mdClientEntryId = hasIslandPages && mdPlugin?.api?.clientEntryId ? mdPlugin.api.clientEntryId : void 0;
4854
4551
  return {
4855
4552
  pagesDir,
@@ -4860,8 +4557,12 @@ function routingPlugin(root, options) {
4860
4557
  headConfig: options.headConfig
4861
4558
  };
4862
4559
  }
4560
+ function completedScan() {
4561
+ if (!scan) throw new Error("Expected route analysis to complete before generating routes.");
4562
+ return scan;
4563
+ }
4863
4564
  function resolveCurrentAssetRoutingPolicy() {
4864
- const { pages, routes, websockets = [], middleware } = scan;
4565
+ const { pages, routes, websockets = [], middleware } = completedScan();
4865
4566
  return resolveAssetRoutingPolicy({
4866
4567
  isSsr: Boolean(ssr),
4867
4568
  hasPages: pages.pages.length > 0 || !!pages.boundaries?.some((boundary) => boundary.kind === "not-found" && !boundary.directory),
@@ -4960,19 +4661,20 @@ function routingPlugin(root, options) {
4960
4661
  runtimePath: sandboxRuntimePath
4961
4662
  } : false;
4962
4663
  function writeNodeEntries(target) {
4963
- writeFileIfChanged(join(outDir, "app.ts"), compileNodeApp(target, compileOptions.honoPath, getEnvSchemaModule()));
4664
+ writeFileIfChanged(join(outDir, "app.ts"), compileNodeApp(target, getEnvSchemaModule()));
4964
4665
  writeFileIfChanged(join(outDir, "index.ts"), compileNodeServer(target));
4965
4666
  }
4966
4667
  /** Write the Cloudflare worker entry from the completed scan. */
4967
4668
  function writeWorkerEntry(isr) {
4669
+ const { queues, websockets = [] } = completedScan();
4968
4670
  const policy = resolveCurrentAssetRoutingPolicy();
4969
4671
  writeFileIfChanged(join(outDir, "entry.ts"), compileWorkerEntry({
4970
4672
  versionMetadataBinding: options.getVersionMetadataBinding?.(),
4971
4673
  alwaysUseHttps: options.routing?.alwaysUseHttps === true && resolvedConfig?.command === "build" && !compileOptions.managedDispatch,
4972
- hasQueues: scan.queues.length > 0,
4674
+ hasQueues: queues.length > 0,
4973
4675
  remote,
4974
4676
  assetsDir: resolvedConfig?.build.assetsDir,
4975
- webSocketClasses: [...(scan.websockets ?? []).map((route) => route.className), ...options.websocketTombstones ?? []],
4677
+ webSocketClasses: [...websockets.map((route) => route.className), ...options.websocketTombstones ?? []],
4976
4678
  runtimeEnvPath: compileOptions.runtimeEnvPath,
4977
4679
  runtimeEmailPath,
4978
4680
  envSchemaModule: getEnvSchemaModule(),
@@ -5087,7 +4789,7 @@ function routingPlugin(root, options) {
5087
4789
  if (!options.target) {
5088
4790
  const migrationsDir = paths.migrationsDir;
5089
4791
  if (existsSync(migrationsDir) || compileOptions.auth) {
5090
- const { collectMigrations } = await import("./collect-8i0wU63d.mjs");
4792
+ const { collectMigrations } = await import("./collect-B6nlSnsb.mjs");
5091
4793
  const { buildMigrationPlanBundle } = await import("./plan-CQ-N4gws.mjs");
5092
4794
  const migrations = existsSync(migrationsDir) ? collectMigrations(migrationsDir) : [];
5093
4795
  const dialect = getDatabaseDialect(readConfig(root));
@@ -5099,11 +4801,12 @@ function routingPlugin(root, options) {
5099
4801
  if (options.target) writeNodeEntries(options.target);
5100
4802
  else {
5101
4803
  const buildConfig = readConfig(root);
5102
- const merged = collectRevalidate(buildConfig, scan.pages);
4804
+ const { pages } = completedScan();
4805
+ const merged = collectRevalidate(buildConfig, pages);
5103
4806
  const configuredRevalidate = buildConfig.routing?.revalidate;
5104
4807
  const emitIsr = resolvedConfig?.command === "build" && !process.env.VOID_DEPLOY_PROJECT_ID && hasRevalidate(merged);
5105
4808
  isrRevalidate = emitIsr ? merged : void 0;
5106
- isrPages = emitIsr ? collectPages(scan.pages, configuredRevalidate) : void 0;
4809
+ isrPages = emitIsr ? collectPages(pages, configuredRevalidate) : void 0;
5107
4810
  isrPathRevalidate = emitIsr && configuredRevalidate && typeof configuredRevalidate === "object" ? configuredRevalidate : void 0;
5108
4811
  writeWorkerEntry(emitIsr ? {
5109
4812
  runtimePath: resolveFile("@void/isr/runtime"),
@@ -5137,7 +4840,7 @@ function routingPlugin(root, options) {
5137
4840
  if (id !== VIRTUAL_ROUTES_ID) return;
5138
4841
  if (this?.environment?.name === "client") throw new Error(`${VIRTUAL_ROUTES_ID} is server-only and cannot be loaded by client code.`);
5139
4842
  if (!scan) await regenerateInOrder(() => rescan());
5140
- return compileRouteTable(scan, routesDir, middlewareDir, jobsDir, queuesDir, ssr, compileOptions, getPagesCompileOptions(), isrRevalidate, isrPages, isrPathRevalidate);
4843
+ return compileRouteTable(completedScan(), routesDir, middlewareDir, jobsDir, queuesDir, ssr, compileOptions, getPagesCompileOptions(), isrRevalidate, isrPages, isrPathRevalidate);
5141
4844
  }
5142
4845
  },
5143
4846
  hotUpdate() {
@@ -5418,11 +5121,11 @@ function mergeWorkerBindings(resolved, input) {
5418
5121
  })),
5419
5122
  consumers: queues.map((q) => ({
5420
5123
  queue: cloudflareQueueName(q.name, cloudflareNames),
5421
- ...q.maxBatchSize != null && { max_batch_size: q.maxBatchSize },
5422
- ...q.maxBatchTimeout != null && { max_batch_timeout: q.maxBatchTimeout },
5423
- ...q.maxConcurrency != null && { max_concurrency: q.maxConcurrency },
5424
- ...q.maxRetries != null && { max_retries: q.maxRetries },
5425
- ...q.retryDelay != null && { retry_delay: q.retryDelay }
5124
+ ...q.maxBatchSize !== null && q.maxBatchSize !== void 0 && { max_batch_size: q.maxBatchSize },
5125
+ ...q.maxBatchTimeout !== null && q.maxBatchTimeout !== void 0 && { max_batch_timeout: q.maxBatchTimeout },
5126
+ ...q.maxConcurrency !== null && q.maxConcurrency !== void 0 && { max_concurrency: q.maxConcurrency },
5127
+ ...q.maxRetries !== null && q.maxRetries !== void 0 && { max_retries: q.maxRetries },
5128
+ ...q.retryDelay !== null && q.retryDelay !== void 0 && { retry_delay: q.retryDelay }
5426
5129
  }))
5427
5130
  };
5428
5131
  }
@@ -5625,7 +5328,10 @@ function voidPlugin(options) {
5625
5328
  const hasInboundEmail = hasEmailHandlers(application.email);
5626
5329
  if (detected && hasInboundEmail) throw new Error("email: inbound email handlers are only supported in Void apps. Remove the email/ directory — `sendEmail` from void/email keeps working.");
5627
5330
  const clientStubsPlugin = createClientStubsPlugin();
5628
- const serverRuntimeOptimizerPlugin = createServerRuntimeOptimizerPlugin(dialect, () => readWranglerCompat(root, config));
5331
+ const serverRuntimeOptimizerPlugin = createServerRuntimeOptimizerPlugin(dialect, () => readWranglerCompat(root, config), framework ? null : getSsrServerEntryPath(root), detected || isNodeTarget(config.target) ? void 0 : {
5332
+ root,
5333
+ scan: () => getNativeWorkerSourceFiles(application)
5334
+ });
5629
5335
  const queues = framework ? [] : application.queues;
5630
5336
  const websocketRoutes = framework ? [] : application.allWebsockets;
5631
5337
  const durableObjects = application.durableObjects;
@@ -5808,8 +5514,8 @@ function voidPlugin(options) {
5808
5514
  if (hintShown) return;
5809
5515
  if (!watchDirs.some((d) => path.startsWith(d))) return;
5810
5516
  try {
5811
- const code = readFileSync(path, "utf-8");
5812
- const fileBindings = applyBindingOverrides(inferBindingsFromSource(code, path.split("/").pop()), config.inference?.bindings);
5517
+ const code = readFileSync(path, "utf8");
5518
+ const fileBindings = applyBindingOverrides(inferBindingsFromSource(code, path.slice(path.lastIndexOf("/") + 1)), config.inference?.bindings);
5813
5519
  const newBindings = [];
5814
5520
  if (fileBindings.needsD1 && !bindings.needsD1) newBindings.push("D1 (void/db)");
5815
5521
  if (fileBindings.needsKV && !bindings.needsKV) newBindings.push("KV (void/kv)");
@@ -6078,7 +5784,8 @@ function voidPlugin(options) {
6078
5784
  viteEnvironment: { name: DEFAULT_WORKER_ENVIRONMENT_NAME },
6079
5785
  config: mergeBindings,
6080
5786
  finalizeAssets(clientDir, environment) {
6081
- (environment?.config.plugins.find((plugin) => plugin.name === routes.name))?.api.finalizeCloudflareAssets(clientDir, environment.config.build.assetsDir);
5787
+ if (!environment) return;
5788
+ environment.config.plugins.find((plugin) => plugin.name === routes.name)?.api.finalizeCloudflareAssets(clientDir, environment.config.build.assetsDir);
6082
5789
  }
6083
5790
  }),
6084
5791
  prerenderPlugin(root, config),