void 0.28.0 → 1.0.3

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 (212) hide show
  1. package/dist/{account-cmd-Ci00cncT.mjs → account-cmd-BTcUzv9L.mjs} +4 -4
  2. package/dist/{application-analysis-D72ZQfMZ.mjs → application-analysis-AB_YYWgH.mjs} +1 -1
  3. package/dist/{application-routing-Dy589Vgn.mjs → application-routing-L7V-TFhZ.mjs} +1 -1
  4. package/dist/auth-Cbqi1iVX.mjs +1 -0
  5. package/dist/{auth-link-DWr6Afao.mjs → auth-link-DUJuvRx5.mjs} +4 -4
  6. package/dist/{auth-router-DP14wVkZ.mjs → auth-router-CIxiMG7i.mjs} +3 -3
  7. package/dist/{build-cmd-Cr3FJxv0.mjs → build-cmd-BkIv25PA.mjs} +3 -3
  8. package/dist/{cache-D0Tt28cn.mjs → cache-Ctzfig-W.mjs} +3 -3
  9. package/dist/{cancel-deploy-CJKvk7AN.mjs → cancel-deploy-CD9o-SsC.mjs} +2 -2
  10. package/dist/cf-build-output-BU3hqdHu.mjs +1 -0
  11. package/dist/cli/cli.mjs +31 -31
  12. package/dist/cli/cloudflare-operation-process.mjs +2 -2
  13. package/dist/cli/env-schema-probe.d.mts +2 -1
  14. package/dist/cli/env-schema-probe.mjs +2 -2
  15. package/dist/client-B60PwCC4.mjs +1 -0
  16. package/dist/{cloudflare-cmd-CTrn-lXJ.mjs → cloudflare-cmd-BIAF_BIY.mjs} +2 -2
  17. package/dist/{cloudflare-connect-BosmCNlq.mjs → cloudflare-connect-WjwnVOJA.mjs} +1 -1
  18. package/dist/{cloudflare-operations-BKdSfNBN.mjs → cloudflare-operations-B42EZeJy.mjs} +3 -3
  19. package/dist/cloudflare-operations-CrSUFRzJ.mjs +1 -0
  20. package/dist/collect-Cae8A7Zr.mjs +1 -0
  21. package/dist/config-QrJWu0IX.mjs +1 -0
  22. package/dist/{connect-nukQSoEO.mjs → connect-CKtk-EZe.mjs} +5 -5
  23. package/dist/create-project-B-ewF_Af.mjs +1 -0
  24. package/dist/{create-project-D4APeBwX.mjs → create-project-yInGo72M.mjs} +3 -3
  25. package/dist/database-provider.mjs +1 -2
  26. package/dist/{db-27RztQLy.mjs → db-7I_gfdVq.mjs} +37 -38
  27. package/dist/db-types-Bb4WBWIs.mjs +49 -0
  28. package/dist/{delete-BbsZFZIw.mjs → delete-Cy-M1u-r.mjs} +3 -3
  29. package/dist/deploy-9lgfhrXS.mjs +2 -0
  30. package/dist/{deploy-B06EQq4t.mjs → deploy-BYYlnsiy.mjs} +176 -21
  31. package/dist/{deploy-managed-static-CGswbcay.mjs → deploy-managed-static-Ca4TFdmx.mjs} +24 -706
  32. package/dist/{deploy-transport-BiicfoQW.mjs → deploy-transport-DWlWBe6M.mjs} +1 -1
  33. package/dist/deploy.mjs +4 -4
  34. package/dist/discover-ClzFSwns.mjs +1 -0
  35. package/dist/dispatch-DrTTk8Xg.mjs +431 -0
  36. package/dist/{dist-D3m88sjf.mjs → dist-BVdsO7Py.mjs} +5 -6
  37. package/dist/dist-CfgIkieS.mjs +1 -0
  38. package/dist/{domain-Bfq9n03H.mjs → domain-CZGxPv9u.mjs} +4 -4
  39. package/dist/edge.mjs +1 -2
  40. package/dist/{email-DIwaQU4P.mjs → email-DzyNVuoU.mjs} +6 -6
  41. package/dist/{email-cloudflare-CH053RxK.mjs → email-cloudflare-DfG6UEMm.mjs} +1 -1
  42. package/dist/{env-BhdWMrNy.mjs → env-0jrMQJI_.mjs} +5 -2
  43. package/dist/{env-C6ipBLp3.mjs → env-Nx3yf50r.mjs} +4 -4
  44. package/dist/{env-raw-Cklzcde3.mjs → env-raw-D74P4ebM.mjs} +12 -1
  45. package/dist/env-validation-BT7z-qpQ.mjs +1 -0
  46. package/dist/{env-validation-cE0zcmzO.mjs → env-validation-DYxjz_Wo.mjs} +2 -0
  47. package/dist/{gen-CnN1Xidx.mjs → gen-CufHEf42.mjs} +2 -2
  48. package/dist/gen-sXyp5DFO.mjs +1 -0
  49. package/dist/generate-ClI89brV.mjs +1 -0
  50. package/dist/{github-cmd-BdkU4Nhe.mjs → github-cmd-FU8EjFyU.mjs} +3 -3
  51. package/dist/{help-Bug7pyK_.mjs → help-BT2hovNI.mjs} +9 -5
  52. package/dist/help-i2YGGnTH.mjs +1 -0
  53. package/dist/{inbound-DmkTQeWp.mjs → inbound-BuTfm11U.mjs} +1 -1
  54. package/dist/index.mjs +551 -303
  55. package/dist/{info-CujPwtMe.mjs → info-l249eUdH.mjs} +1 -1
  56. package/dist/{init-ZWOJvc-Z.mjs → init-D0A6M64Q.mjs} +60 -14
  57. package/dist/{isr-config-DPjXM8J2.mjs → isr-config-fZaJJ8t7.mjs} +1 -30
  58. package/dist/{link-UEc7bnF4.mjs → link-WMoJFf4i.mjs} +4 -4
  59. package/dist/{list-CuWeOnzk.mjs → list-CQ2EQEHL.mjs} +4 -4
  60. package/dist/{live-BxLX-JqJ.mjs → live-BcHoTDFe.mjs} +1 -1
  61. package/dist/{local-d1-BM3p74mm.mjs → local-d1-BxvQYEFi.mjs} +1 -1
  62. package/dist/{login-CZ2Cqa-D.mjs → login-C2T1oVG-.mjs} +3 -3
  63. package/dist/login-XD844Xs-.mjs +1 -0
  64. package/dist/{logs-TihRcLTk.mjs → logs-DnC1d7xB.mjs} +3 -3
  65. package/dist/{migrate-uFwojusJ.mjs → migrate-BDIprOYd.mjs} +2 -2
  66. package/dist/migrate-BRwU-blY.mjs +1 -0
  67. package/dist/mysql-migration-sql-BIS5vbNk.mjs +241 -0
  68. package/dist/nitro.d.mts +30 -0
  69. package/dist/nitro.mjs +88 -0
  70. package/dist/{node-DoKbo1SZ.mjs → node-cPadMgUO.mjs} +3 -3
  71. package/dist/operator-cmd-D6gnZsnK.mjs +1 -0
  72. package/dist/{operator-cmd-C5lCctnc.mjs → operator-cmd-DHieWtFp.mjs} +5 -5
  73. package/dist/{output-FNHKw5Ac.mjs → output-Ba6ZbrzY.mjs} +1 -1
  74. package/dist/pages/head.mjs +1 -2
  75. package/dist/pages/prefetch.mjs +1 -2
  76. package/dist/pages/serialize.mjs +1 -2
  77. package/dist/plan-CKX_jWnD.mjs +1 -0
  78. package/dist/platform-args-B0HeTh0C.mjs +1 -0
  79. package/dist/{platform-args-C6Mb_I3a.mjs → platform-args-CaCL_1Ch.mjs} +9 -2
  80. package/dist/{platform-auth-config-CJmNkFT2.mjs → platform-auth-config-Z16-I8nT.mjs} +6 -6
  81. package/dist/{platform-auth-protection-D5wvsI-Y.mjs → platform-auth-protection-BXwZiJSF.mjs} +4 -4
  82. package/dist/{platform-auth-recovery-D_0I3n-1.mjs → platform-auth-recovery-CXjfqyOv.mjs} +4 -4
  83. package/dist/{platform-cmd-DxxZO6e5.mjs → platform-cmd-DaAOiWTl.mjs} +7 -7
  84. package/dist/platform-cmd-PT4YwMLM.mjs +1 -0
  85. package/dist/{platform-domain-zLXnW1G_.mjs → platform-domain-CxpvUeo0.mjs} +4 -4
  86. package/dist/{platform-lifecycle-DOW-wLfx.mjs → platform-lifecycle-DBiS0cJd.mjs} +317 -99
  87. package/dist/platform-lifecycle-u9pMOvxC.mjs +1 -0
  88. package/dist/{platform-management-t7HKy4-U.mjs → platform-management-DhEFdQAf.mjs} +67 -9
  89. package/dist/platform-management-DvBS83rC.mjs +1 -0
  90. package/dist/{platform-plans-config-CNH6zbPX.mjs → platform-plans-config-BWn1S2Rv.mjs} +2 -2
  91. package/dist/{platform-recovery-DeucI7A9.mjs → platform-recovery-BUGOB4RC.mjs} +2 -2
  92. package/dist/{platform-setup-CTf6MMT9.mjs → platform-setup-YvN9VQXV.mjs} +3 -3
  93. package/dist/prepare-CYT6tAzD.mjs +1 -0
  94. package/dist/{prepare-CSH9dKTI.mjs → prepare-DEB5SeVJ.mjs} +3 -2
  95. package/dist/{prepare-C4zfwks4.mjs → prepare-PQCgsny0.mjs} +3 -3
  96. package/dist/prerender-render.mjs +1 -2
  97. package/dist/{project-cmd-Dq75AXzy.mjs → project-cmd-DVatD8Ev.mjs} +16 -16
  98. package/dist/project-slug-6cyz8E7k.mjs +1 -0
  99. package/dist/{project-team-B3_QcStG.mjs → project-team-DJrWEAG1.mjs} +3 -3
  100. package/dist/{project-token-CvsRvv2I.mjs → project-token-CBgLBuL6.mjs} +3 -3
  101. package/dist/project-zdB3fs9G.mjs +1 -0
  102. package/dist/{project-zero-trust-D1ICiwN_.mjs → project-zero-trust-92gLtZ25.mjs} +3 -3
  103. package/dist/{provision-DDh7ITVS.mjs → provision-BnSSkiED.mjs} +1 -1
  104. package/dist/{requests-3CL3BuZh.mjs → requests-7W1Pygt2.mjs} +2 -2
  105. package/dist/resolve-project-PnhzMtY6.mjs +1 -0
  106. package/dist/{resolve-project-C_Cu7E8a.mjs → resolve-project-WpwkCB_c.mjs} +1 -1
  107. package/dist/{rollback-Ce1d_0J9.mjs → rollback-BcASVnwP.mjs} +3 -3
  108. package/dist/{route-types-IrBuwJ7u.mjs → route-types-BZi26DVS.mjs} +2 -49
  109. package/dist/{runner-DcVDrzuR.mjs → runner-CabsQ-iM.mjs} +15 -6
  110. package/dist/runner-So9mYfcm.mjs +1 -0
  111. package/dist/runner-mysql-BhRaONkO.mjs +146 -0
  112. package/dist/runner-mysql-DWwE8jKi.mjs +1 -0
  113. package/dist/{runner-pg-CPd-CB_F.mjs → runner-pg-BRemq_GX.mjs} +2 -2
  114. package/dist/runner-pg-_Xncr3H5.mjs +1 -0
  115. package/dist/runtime/ai.mjs +15 -4
  116. package/dist/runtime/auth-client-react.mjs +1 -2
  117. package/dist/runtime/auth-client-solid.mjs +1 -2
  118. package/dist/runtime/auth-client-svelte.mjs +1 -2
  119. package/dist/runtime/auth-client-vue.mjs +1 -2
  120. package/dist/runtime/auth-client.mjs +1 -2
  121. package/dist/runtime/auth.mjs +1 -2
  122. package/dist/runtime/better-auth-mysql.mjs +4 -1
  123. package/dist/runtime/db.mjs +6 -2
  124. package/dist/runtime/durable.d.mts +2 -1
  125. package/dist/runtime/durable.mjs +1 -1
  126. package/dist/runtime/email/testing.mjs +1 -1
  127. package/dist/runtime/email-protocol.mjs +1 -2
  128. package/dist/runtime/email.mjs +1 -1
  129. package/dist/runtime/env-public.mjs +2 -2
  130. package/dist/runtime/env.mjs +1 -2
  131. package/dist/runtime/isr.mjs +1 -1
  132. package/dist/runtime/kv.mjs +1 -1
  133. package/dist/runtime/limits.mjs +1 -2
  134. package/dist/runtime/live-client.d.mts +2 -1
  135. package/dist/runtime/live-server.d.mts +2 -1
  136. package/dist/runtime/live-server.mjs +1 -1
  137. package/dist/runtime/live.mjs +1 -2
  138. package/dist/runtime/log.d.mts +2 -1
  139. package/dist/runtime/migration-handler-mysql.mjs +38 -8
  140. package/dist/runtime/migration-handler.mjs +1 -2
  141. package/dist/runtime/queues.mjs +1 -1
  142. package/dist/runtime/response.mjs +1 -2
  143. package/dist/runtime/route-url.mjs +1 -2
  144. package/dist/runtime/routing.d.mts +2 -1
  145. package/dist/runtime/sandbox-container.mjs +1 -2
  146. package/dist/runtime/sandbox.mjs +3 -3
  147. package/dist/runtime/seed.d.mts +2 -1
  148. package/dist/runtime/sse.mjs +1 -2
  149. package/dist/runtime/storage.mjs +1 -1
  150. package/dist/runtime/validator.mjs +1 -2
  151. package/dist/runtime/ws-server.d.mts +2 -1
  152. package/dist/runtime/ws-server.mjs +1 -1
  153. package/dist/{secret-B5J8bBsI.mjs → secret-bg73f1Ge.mjs} +5 -5
  154. package/dist/{skills-BJsan98C.mjs → skills-C_yRTg0g.mjs} +1 -1
  155. package/dist/{subcommand-prompt-gQ-NDA-u.mjs → subcommand-prompt-Bm3ZlYgA.mjs} +2 -2
  156. package/dist/sveltekit.d.mts +2 -1
  157. package/dist/validate-BQFdf0Pi.mjs +1 -0
  158. package/dist/wrapper-CwhpNWtH.mjs +663 -0
  159. package/docs/guide/ai.md +8 -2
  160. package/docs/guide/database/mysql.md +14 -3
  161. package/docs/guide/database.md +1 -5
  162. package/docs/guide/durable-state.md +9 -5
  163. package/docs/guide/platform/installation/credentials.md +18 -2
  164. package/docs/guide/platform/installation/domains.md +1 -1
  165. package/docs/guide/platform/installation/maintenance.md +38 -1
  166. package/docs/guide/platform/installation/prerequisites.md +6 -2
  167. package/docs/guide/platform/installation/setup.md +23 -1
  168. package/docs/guide/platform/installation/uninstall.md +6 -1
  169. package/docs/guide/sandboxes.md +1 -1
  170. package/docs/guide/self-hosted-platform.md +1 -1
  171. package/docs/integrations/cloudflare.md +2 -2
  172. package/docs/integrations/frameworks/analog.md +3 -11
  173. package/docs/integrations/frameworks/nuxt.md +7 -10
  174. package/docs/integrations/nodejs-bun-deno.md +2 -0
  175. package/docs/reference/api.md +1 -0
  176. package/docs/reference/cli/platform-installation.md +18 -6
  177. package/docs/reference/config.md +2 -0
  178. package/package.json +34 -28
  179. package/sandbox.Dockerfile +1 -1
  180. package/skills/void/SKILL.md +1 -1
  181. package/dist/auth-wn6F8dB8.mjs +0 -2
  182. package/dist/cf-build-output-2u583yJK.mjs +0 -2
  183. package/dist/client-C1BjRn3g.mjs +0 -2
  184. package/dist/cloudflare-operations-Ds-lX3Ts.mjs +0 -2
  185. package/dist/collect-NUlJMpLY.mjs +0 -2
  186. package/dist/config-CNnrSMYm.mjs +0 -2
  187. package/dist/create-project-DL7YXpjj.mjs +0 -2
  188. package/dist/deploy-Db2ALnQP.mjs +0 -3
  189. package/dist/discover-CTUiSsfG.mjs +0 -2
  190. package/dist/dist-Bx1z6Eva.mjs +0 -2
  191. package/dist/env-validation-CTn-HhG1.mjs +0 -2
  192. package/dist/gen-F8pSZnhc.mjs +0 -2
  193. package/dist/generate-Rii9klHB.mjs +0 -2
  194. package/dist/help-s9q7LTcu.mjs +0 -2
  195. package/dist/login-DhK7o1oJ.mjs +0 -2
  196. package/dist/migrate-BgT-hmu8.mjs +0 -2
  197. package/dist/operator-cmd-Cjk5DiRx.mjs +0 -2
  198. package/dist/plan-CH2G51je.mjs +0 -2
  199. package/dist/platform-args-Cm7x-fot.mjs +0 -2
  200. package/dist/platform-cmd-Cuj4oUVo.mjs +0 -2
  201. package/dist/platform-lifecycle-_gfnjUBr.mjs +0 -2
  202. package/dist/platform-management-CYrLvTGH.mjs +0 -2
  203. package/dist/prepare-dr9uxQSV.mjs +0 -2
  204. package/dist/project-DiiOBZPF.mjs +0 -2
  205. package/dist/project-slug-DofjTFd-.mjs +0 -2
  206. package/dist/resolve-project-B9Hr0D3n.mjs +0 -2
  207. package/dist/runner-B5huK2eC.mjs +0 -2
  208. package/dist/runner-mysql-CCtyI0p6.mjs +0 -55
  209. package/dist/runner-mysql-CaJq-hd6.mjs +0 -2
  210. package/dist/runner-pg-BJhFZZG4.mjs +0 -2
  211. package/dist/validate-C9xtFOYR.mjs +0 -2
  212. package/dist/{sandbox-container-DBKIqDEK.mjs → sandbox-container-a9LRUtii.mjs} +1 -1
@@ -2,18 +2,15 @@ import { a as join, c as resolve, n as dirname, r as extname, s as relative } fr
2
2
  import { h as needsApplicationDatabase } from "./plugin-inference-DsARdQKE.mjs";
3
3
  import { n as readProjectPaths } from "./project-paths-DMvEeSau.mjs";
4
4
  import { c as isNodeTarget } from "./config-Bx_1SpnO.mjs";
5
- import { n as isIdentifier, r as isLiteral } from "./ast-CPGPjb0V.mjs";
6
- import { p as scanDurableObjectModules, t as analyzeApplicationSync } from "./application-analysis-D72ZQfMZ.mjs";
7
5
  import { t as collectMigrations } from "./collect-xjffdCdk.mjs";
8
- import { t as MagicString } from "./dist-Cegxq8gs.mjs";
9
- import { i as collectFiles, n as collectRevalidate, s as generateQueueResolverSource, t as collectPages } from "./isr-config-DPjXM8J2.mjs";
6
+ import { i as collectFiles, t as collectPages } from "./isr-config-fZaJJ8t7.mjs";
10
7
  import { n as mergeRoutingRules, t as lintRoutingPhases } from "./headers-Di1FsD3e.mjs";
11
8
  import { s as shouldLinkDeployProject, t as attachSelectedPlatform, u as writeProjectConfig } from "./project-rqDnVsJN.mjs";
12
9
  import { D as syncWranglerBindings, E as resolveLiveBindingConfig, a as LIVE_MIGRATION_TAG, g as normalizeWranglerCompatibilityFlags, u as ensureWranglerCompat, v as readExistingLiveBindingConfig } from "./wrangler-BYs07Rxy.mjs";
13
10
  import { n as buildMigrationPlanBundle } from "./plan-BhLO2p4w.mjs";
14
11
  import { l as getTokenSource } from "./auth-B6iOCjKI.mjs";
15
- import { L as log$1, N as intro, X as text, tt as isCancel } from "./dist-D3m88sjf.mjs";
16
- import { f as import_picocolors, h as sanitizeTerminalText, m as printSuccess, o as formatCount, p as note, r as createSpinner, u as getErrorMessage } from "./output-FNHKw5Ac.mjs";
12
+ import { L as log$1, N as intro, X as text, tt as isCancel } from "./dist-BVdsO7Py.mjs";
13
+ import { f as import_picocolors, h as sanitizeTerminalText, m as printSuccess, o as formatCount, p as note, r as createSpinner, u as getErrorMessage } from "./output-Ba6ZbrzY.mjs";
17
14
  import { t as discoverSchema } from "./discover-D2PGT63u.mjs";
18
15
  import { t as findEnvFile } from "./env-types-DS2_y4X8.mjs";
19
16
  import { a as buildEnv } from "./version-metadata-DIrqEHQo.mjs";
@@ -21,554 +18,19 @@ import { r as writeDrizzleConfig, t as PLACEHOLDER_DB_URL } from "./config-BEm9v
21
18
  import { i as validateMigrations, r as listDrizzleArtifacts, t as assertJournalCoherence } from "./validate-CheZGRE7.mjs";
22
19
  import { t as formatCloudflareUserMessage } from "./cloudflare-user-output-Q-k0QoNQ.mjs";
23
20
  import { c as platformErrorMessage, i as isCliOutdatedError, n as PlatformApiError, o as isHeadersTimeoutError, s as parsePlatformErrorBody } from "./client-DM9Kcf4e.mjs";
24
- import { a as promptProjectSelection, i as reportProjectCreationWarnings, o as promptProjectSetupAction, r as promptAndCreateProject } from "./create-project-D4APeBwX.mjs";
21
+ import { a as promptProjectSelection, i as reportProjectCreationWarnings, o as promptProjectSetupAction, r as promptAndCreateProject } from "./create-project-yInGo72M.mjs";
25
22
  import { o as detectPreset, s as formatProjectCommand, u as resolveProjectCommand } from "./cloudflare-process-CeDWJRhj.mjs";
26
- import { d as formatEnvReport, g as validateProdEnv, u as fetchRemoteSecretNames } from "./env-validation-cE0zcmzO.mjs";
23
+ import { d as formatEnvReport, g as validateProdEnv, u as fetchRemoteSecretNames } from "./env-validation-DYxjz_Wo.mjs";
24
+ import { a as needsWrapper, i as generateWrapper } from "./wrapper-CwhpNWtH.mjs";
27
25
  import { n as drizzleKitBin } from "./yarn-pnp-DLbEFMT0.mjs";
28
- import { t as MANAGED_DEPLOY_BUILD_ENV } from "./deploy-transport-BiicfoQW.mjs";
29
- import { createRequire } from "node:module";
30
- import { copyFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
31
- import { fileURLToPath } from "node:url";
32
- import { build, parseSync } from "vite";
26
+ import { t as MANAGED_DEPLOY_BUILD_ENV } from "./deploy-transport-DWlWBe6M.mjs";
27
+ import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
33
28
  import { createDeployArtifact, createDeployUploadPayload } from "@void/deploy-core";
34
29
  import { createHash } from "node:crypto";
35
30
  import { execSync, spawnSync } from "node:child_process";
36
31
  import { getContentType } from "@void/edge";
37
32
  import { hash } from "blake3-jit";
38
33
  import ignore from "ignore";
39
- //#region src/cli/pg-bundle-transform.ts
40
- function nodes(root) {
41
- const found = [];
42
- const pending = [root];
43
- while (pending.length > 0) {
44
- const node = pending.pop();
45
- found.push(node);
46
- for (const value of Object.values(node)) if (Array.isArray(value)) {
47
- for (const child of value) if (child && typeof child === "object" && typeof child.type === "string") pending.push(child);
48
- } else if (value && typeof value === "object" && typeof value.type === "string") pending.push(value);
49
- }
50
- return found;
51
- }
52
- /** Rewrite the two CommonJS constructs emitted by the PG migration bundle. */
53
- function transformPgWorkerBundle(code, filename, requireShim) {
54
- if (!code.includes("createRequire") && !code.includes("pgpass")) return code;
55
- const program = parseSync(filename, code).program;
56
- const edits = [];
57
- let hasRequireBinding = false;
58
- let pgpassCalls = 0;
59
- for (const statement of program.body ?? []) {
60
- if (statement.type === "ImportDeclaration" && statement.source?.value === "node:module") {
61
- const specifiers = statement.specifiers;
62
- if (specifiers?.length !== 1 || !isIdentifier(specifiers[0]?.imported) || specifiers[0].imported.name !== "createRequire") throw new Error(`deploy: Unsupported node:module import in PostgreSQL bundle ${filename}.`);
63
- edits.push({
64
- start: statement.start,
65
- end: statement.end,
66
- replacement: ""
67
- });
68
- }
69
- if (statement.type === "VariableDeclaration") {
70
- const declarations = statement.declarations;
71
- if (declarations?.some((declaration) => isIdentifier(declaration.id) && declaration.id.name === "__require")) {
72
- if (declarations.length !== 1 || hasRequireBinding) throw new Error(`deploy: Unsupported require binding in PostgreSQL bundle ${filename}.`);
73
- hasRequireBinding = true;
74
- edits.push({
75
- start: statement.start,
76
- end: statement.end,
77
- replacement: requireShim
78
- });
79
- }
80
- }
81
- }
82
- for (const node of nodes(program)) {
83
- if (node.type !== "CallExpression" || !isIdentifier(node.callee) || node.callee.name !== "__require") continue;
84
- const args = node.arguments;
85
- if (args?.length !== 1 || !isLiteral(args[0]) || args[0].value !== "pgpass") continue;
86
- pgpassCalls++;
87
- edits.push({
88
- start: node.start,
89
- end: node.end,
90
- replacement: "__voidPgpassNoop"
91
- });
92
- }
93
- if (code.includes("createRequire") && !hasRequireBinding) throw new Error(`deploy: Could not locate the generated require binding in PostgreSQL bundle ${filename}.`);
94
- if (code.includes("pgpass") && pgpassCalls === 0 && code.includes("__require")) throw new Error(`deploy: Could not locate the pgpass require in PostgreSQL bundle ${filename}.`);
95
- const ms = new MagicString(code);
96
- for (const edit of edits.sort((a, b) => b.start - a.start)) ms.overwrite(edit.start, edit.end, edit.replacement);
97
- const transformed = ms.toString();
98
- if (transformed.includes("createRequire") || transformed.includes("__require(\"pgpass\")")) throw new Error(`deploy: PostgreSQL bundle ${filename} still contains an unsupported require.`);
99
- return pgpassCalls > 0 ? `const __voidPgpassNoop = Object.assign(function pgpass(_connectionInfo, callback) { callback(undefined); }, { warnTo() {} });\n${transformed}` : transformed;
100
- }
101
- //#endregion
102
- //#region src/cli/wrapper.ts
103
- const BUNDLED_ENTRY_RE = /^index\.(?:m?js|cjs)$/;
104
- const WRAPPER_MARKER = "// Generated by Void: deployment wrapper.";
105
- function isGeneratedWrapper(source, originalName) {
106
- return source.startsWith(WRAPPER_MARKER) || source.startsWith(`import original from "./${originalName}";\n`);
107
- }
108
- function selectBundledEntryFilename(outFiles) {
109
- const entryFilename = outFiles.find((file) => BUNDLED_ENTRY_RE.test(file));
110
- if (!entryFilename) throw new Error(`deploy: Bundled worker entry not found. Expected index.js, index.mjs, or index.cjs in bundle output. Found: ${outFiles.join(", ") || "(none)"}`);
111
- return entryFilename;
112
- }
113
- /**
114
- * Determine whether a wrapper is needed based on the features.
115
- */
116
- function needsWrapper(features) {
117
- return features.crons.length > 0 || features.queues.length > 0 || !!features.hasMigrations || !!features.readiness || !!features.isr;
118
- }
119
- /**
120
- * Generate a wrapper entry in-place in the worker directory.
121
- *
122
- * - Preserves the original entry (e.g. `index.js` → `__original.js`)
123
- * - Compiles cron/queue handlers via a small Vite build
124
- * - Writes a wrapper module as the original entry name that imports
125
- * the renamed original + compiled handlers
126
- *
127
- * The original worker code is never re-bundled.
128
- */
129
- async function generateWrapper(workerDir, workerMain, root, features) {
130
- const renamedName = `__original${extname(workerMain) || ".js"}`;
131
- const mainPath = join(workerDir, workerMain);
132
- const originalPath = join(workerDir, renamedName);
133
- const alreadyWrapped = isGeneratedWrapper(readFileSync(mainPath, "utf8"), renamedName);
134
- if (alreadyWrapped && (!existsSync(originalPath) || isGeneratedWrapper(readFileSync(originalPath, "utf8"), renamedName))) throw new Error("deploy: Original framework entry is missing or already wrapped. Rebuild the application before deploying.");
135
- let handlerFilename = "__void_handlers.mjs";
136
- if (features.crons.length > 0 || features.queues.length > 0) {
137
- const tmpDir = join(root, ".void", "handlers");
138
- mkdirSync(tmpDir, { recursive: true });
139
- const handlersSource = generateHandlersSource(root, features);
140
- const handlersEntry = join(tmpDir, "handlers.ts");
141
- writeFileSync(handlersEntry, handlersSource);
142
- const outDir = join(tmpDir, "out");
143
- await build({
144
- root: tmpDir,
145
- logLevel: "silent",
146
- resolve: { alias: [{
147
- find: /^void$/,
148
- replacement: fileURLToPath(import.meta.resolve("void/handler"))
149
- }] },
150
- build: {
151
- outDir,
152
- emptyOutDir: true,
153
- lib: {
154
- entry: handlersEntry,
155
- formats: ["es"],
156
- fileName: "__void_handlers"
157
- },
158
- rollupOptions: { external: [/^cloudflare:/, /^node:/] },
159
- minify: false,
160
- target: "esnext"
161
- }
162
- });
163
- handlerFilename = readdirSync(outDir).filter((f) => f.startsWith("__void_handlers"))[0] ?? "__void_handlers.mjs";
164
- copyFileSync(join(outDir, handlerFilename), join(workerDir, handlerFilename));
165
- }
166
- let migrations;
167
- let migrationPlanBundle;
168
- if (features.hasMigrations) {
169
- const { collectMigrations } = await import("./collect-NUlJMpLY.mjs");
170
- const { buildMigrationPlanBundle } = await import("./plan-CH2G51je.mjs");
171
- const migrationsDir = readProjectPaths(root).migrationsDir;
172
- migrations = collectMigrations(migrationsDir);
173
- migrationPlanBundle = features.migrationDialect === "sqlite" ? buildMigrationPlanBundle(migrations) : void 0;
174
- const handlerName = features.migrationDialect === "postgresql" ? "migration-handler-pg" : features.migrationDialect === "mysql" ? "migration-handler-mysql" : "migration-handler";
175
- const handlerFilename_ = `${handlerName}.mjs`;
176
- let handlerPath = join(import.meta.dirname, "..", "runtime", `${handlerName}.ts`);
177
- if (!existsSync(handlerPath)) handlerPath = join(import.meta.dirname, "runtime", handlerFilename_);
178
- if (!existsSync(handlerPath)) handlerPath = join(import.meta.dirname, "..", "runtime", handlerFilename_);
179
- if (!existsSync(handlerPath)) throw new Error(`Migration handler not found: ${handlerFilename_}. Run "pnpm -C packages/void build" first.`);
180
- await bundleMigrationHandler(root, workerDir, handlerPath, features.migrationDialect ?? "sqlite");
181
- }
182
- if (features.isr) await bundleFrameworkIsr(root, workerDir);
183
- const wrapperSource = generateWrapperSource(renamedName, handlerFilename, features, migrations, migrationPlanBundle);
184
- const stagedPath = `${mainPath}.${crypto.randomUUID()}.tmp`;
185
- try {
186
- writeFileSync(stagedPath, wrapperSource);
187
- if (!alreadyWrapped) copyFileSync(mainPath, originalPath);
188
- renameSync(stagedPath, mainPath);
189
- } finally {
190
- rmSync(stagedPath, { force: true });
191
- }
192
- }
193
- async function bundleFrameworkIsr(root, workerDir) {
194
- const entry = fileURLToPath(import.meta.resolve("@void/isr/runtime"));
195
- const tmpDir = join(root, ".void", "isr");
196
- const outDir = join(tmpDir, "out");
197
- mkdirSync(tmpDir, { recursive: true });
198
- await build({
199
- root: tmpDir,
200
- logLevel: "silent",
201
- ssr: { noExternal: true },
202
- build: {
203
- outDir,
204
- emptyOutDir: true,
205
- minify: false,
206
- ssr: entry,
207
- target: "esnext",
208
- rollupOptions: {
209
- input: entry,
210
- external: [/^cloudflare:/, /^node:/],
211
- output: {
212
- entryFileNames: "__void_isr.mjs",
213
- chunkFileNames: "__void_isr-[hash].mjs"
214
- }
215
- }
216
- }
217
- });
218
- for (const file of readdirSync(outDir)) copyFileSync(join(outDir, file), join(workerDir, file));
219
- }
220
- async function bundleMigrationHandler(root, workerDir, handlerPath, dialect) {
221
- const tmpDir = join(root, ".void", "migration-handler");
222
- mkdirSync(tmpDir, { recursive: true });
223
- const outDir = join(tmpDir, "out");
224
- const isPostgresql = dialect === "postgresql";
225
- const isMysql = dialect === "mysql";
226
- await build({
227
- root: tmpDir,
228
- logLevel: "silent",
229
- resolve: isPostgresql ? {
230
- alias: {
231
- "pg-cloudflare": resolvePgCloudflareWorkerdEntry(handlerPath),
232
- "pg-pool": resolvePgCjsDependency(handlerPath, "pg-pool")
233
- },
234
- conditions: [
235
- "workerd",
236
- "worker",
237
- "browser",
238
- "module",
239
- "import",
240
- "default"
241
- ]
242
- } : void 0,
243
- ssr: isPostgresql ? {
244
- noExternal: ["pg", "pg-cloudflare"],
245
- resolve: { conditions: [
246
- "workerd",
247
- "worker",
248
- "browser",
249
- "module",
250
- "import",
251
- "default"
252
- ] }
253
- } : isMysql ? { noExternal: ["mysql2"] } : void 0,
254
- build: {
255
- outDir,
256
- emptyOutDir: true,
257
- minify: false,
258
- ssr: handlerPath,
259
- target: "esnext",
260
- rollupOptions: {
261
- input: handlerPath,
262
- external: [
263
- /^cloudflare:/,
264
- /^node:/,
265
- /^pgpass$/
266
- ],
267
- output: {
268
- entryFileNames: "__void_migration_handler.mjs",
269
- chunkFileNames: "__void_migration_handler-[hash].mjs"
270
- }
271
- }
272
- }
273
- });
274
- if (isPostgresql) patchPgWorkerBundle(outDir);
275
- for (const file of readdirSync(outDir)) copyFileSync(join(outDir, file), join(workerDir, file));
276
- }
277
- function patchPgWorkerBundle(outDir) {
278
- for (const file of readdirSync(outDir)) {
279
- if (!file.endsWith(".mjs") && !file.endsWith(".js")) continue;
280
- const path = join(outDir, file);
281
- const code = readFileSync(path, "utf-8");
282
- const transformed = transformPgWorkerBundle(code, file, pgWorkerRequireShim());
283
- if (transformed !== code) writeFileSync(path, transformed);
284
- }
285
- }
286
- function createPgPackageRequire(fromPath) {
287
- const fromRequire = createRequire(fromPath);
288
- return createRequire(fromRequire.resolve("pg/package.json"));
289
- }
290
- function resolvePgCjsDependency(fromPath, specifier) {
291
- return createPgPackageRequire(fromPath).resolve(specifier);
292
- }
293
- function resolvePgCloudflareWorkerdEntry(fromPath) {
294
- const packageJsonPath = createPgPackageRequire(fromPath).resolve("pg-cloudflare/package.json");
295
- return join(dirname(packageJsonPath), "dist", "index.js");
296
- }
297
- function pgWorkerRequireShim() {
298
- return [
299
- "import * as __voidNodeCrypto from \"node:crypto\";",
300
- "import * as __voidNodeDns from \"node:dns\";",
301
- "import * as __voidNodeEvents from \"node:events\";",
302
- "import * as __voidNodeFs from \"node:fs\";",
303
- "import * as __voidNodeNet from \"node:net\";",
304
- "import * as __voidNodeTls from \"node:tls\";",
305
- "import * as __voidNodeUtil from \"node:util\";",
306
- "import * as __voidNodeUtilTypes from \"node:util/types\";",
307
- "var __voidNodeRequireModules = {",
308
- " crypto: __voidNodeCrypto,",
309
- " dns: __voidNodeDns,",
310
- " events: __voidNodeEvents,",
311
- " fs: __voidNodeFs,",
312
- " net: __voidNodeNet,",
313
- " tls: __voidNodeTls,",
314
- " util: __voidNodeUtil,",
315
- " \"util/types\": __voidNodeUtilTypes,",
316
- "};",
317
- "var __require = (id) => {",
318
- " if (id.startsWith(\"node:\")) id = id.slice(5);",
319
- " const mod = __voidNodeRequireModules[id];",
320
- " if (mod) return mod;",
321
- " throw new Error(`Unsupported require(\"${id}\") in Void PG migration bundle`);",
322
- "};"
323
- ].join("\n");
324
- }
325
- /**
326
- * Bundle a worker entry into a self-contained module.
327
- *
328
- * Used for frameworks whose build output has unbundled bare imports
329
- * (e.g. SvelteKit's `_worker.js` imports from `@sveltejs/kit`).
330
- */
331
- async function bundleEntry(root, entry) {
332
- const tmpDir = join(root, ".void", "bundle");
333
- mkdirSync(tmpDir, { recursive: true });
334
- const outDir = join(tmpDir, "out");
335
- await build({
336
- root: tmpDir,
337
- logLevel: "silent",
338
- build: {
339
- outDir,
340
- emptyOutDir: true,
341
- lib: {
342
- entry,
343
- formats: ["es"],
344
- fileName: "index"
345
- },
346
- rollupOptions: {
347
- external: [/^cloudflare:/, /^node:/],
348
- output: { banner: [
349
- "const __noopCache = {",
350
- " match() { return Promise.resolve(undefined); },",
351
- " put() { return Promise.resolve(); },",
352
- " delete() { return Promise.resolve(false); },",
353
- "};",
354
- "globalThis.caches = { default: __noopCache, open() { return Promise.resolve(__noopCache); } };"
355
- ].join("\n") }
356
- },
357
- minify: false,
358
- target: "esnext"
359
- }
360
- });
361
- return {
362
- entryFilename: selectBundledEntryFilename(readdirSync(outDir)),
363
- outputDir: outDir
364
- };
365
- }
366
- /** Clean up the temporary directories created while generating a deploy wrapper. */
367
- function cleanupWrapper(root) {
368
- const voidDir = join(root, ".void");
369
- for (const directory of [
370
- "handlers",
371
- "migration-handler",
372
- "isr",
373
- "bundle"
374
- ]) rmSync(join(voidDir, directory), {
375
- recursive: true,
376
- force: true
377
- });
378
- }
379
- function generateWrapperSource(renamedEntry, handlersModule, features, migrations, migrationPlanBundle) {
380
- const lines = [];
381
- lines.push(WRAPPER_MARKER);
382
- lines.push(`import original from "./${renamedEntry}";`);
383
- if (features.isr) {
384
- lines.push("import { handleFrameworkIsr } from \"./__void_isr.mjs\";");
385
- lines.push(`const __voidIsrDeploymentId = ${JSON.stringify(crypto.randomUUID())};`);
386
- lines.push(`const __voidIsrPolicy = ${JSON.stringify({
387
- revalidate: features.isr.revalidate,
388
- queryAllowlist: features.isr.queryAllowlist
389
- })};`);
390
- }
391
- if (features.crons.length > 0) lines.push(`import { handleScheduled } from "./${handlersModule}";`);
392
- if (features.queues.length > 0) lines.push(`import { handleQueue, handleQueueRelay } from "./${handlersModule}";`);
393
- if (migrations && migrations.length > 0) {
394
- lines.push(`import { createMigrationHandler } from "./__void_migration_handler.mjs";`);
395
- lines.push(`const __migrations = ${JSON.stringify(migrations)};`);
396
- lines.push(`const __migrationPlanBundle = ${JSON.stringify(migrationPlanBundle)};`);
397
- }
398
- lines.push("");
399
- const needsFetchWrap = features.readiness || features.crons.length > 0 || features.queues.length > 0 || migrations && migrations.length > 0 || !!features.isr;
400
- if (needsFetchWrap) {
401
- lines.push("async function wrappedFetch(request, env, ctx) {");
402
- lines.push(" const url = new URL(request.url);");
403
- if (features.isr) {
404
- lines.push(" env.__VOID_ISR_DEPLOYMENT_ID ??= __voidIsrDeploymentId;");
405
- lines.push(" env.__VOID_ISR_HOST = url.hostname;");
406
- }
407
- if (features.readiness || features.crons.length > 0 || features.queues.length > 0 || features.hasMigrations) {
408
- lines.push(" if (request.method === \"GET\" && url.pathname === \"/__void/ready\") {");
409
- lines.push(" if (typeof original?.fetch !== \"function\") {");
410
- lines.push(" return Response.json({ ready: false, error: \"worker entry has no fetch handler\" }, { status: 503, headers: { \"cache-control\": \"no-store\" } });");
411
- lines.push(" }");
412
- lines.push(` return Response.json({ ready: true${features.versionMetadataBinding ? `, versionId: env[${JSON.stringify(features.versionMetadataBinding)}]?.id` : ""} }${features.versionMetadataBinding ? ", { headers: { \"cache-control\": \"no-store\" } }" : ""});`);
413
- lines.push(" }");
414
- }
415
- if (features.queues.length > 0) {
416
- lines.push(" if (request.method === \"POST\" && url.pathname === \"/__void/queue\") {");
417
- lines.push(" const expected = env?.__VOID_PROXY_TOKEN;");
418
- lines.push(" if (!expected || request.headers.get(\"x-void-internal\") !== expected) {");
419
- lines.push(" return Response.json({ error: \"unauthorized\" }, { status: 401 });");
420
- lines.push(" }");
421
- lines.push(" try {");
422
- lines.push(" return Response.json(await handleQueueRelay(await request.json(), env, ctx));");
423
- lines.push(" } catch {");
424
- lines.push(" return Response.json({ error: \"Invalid queue payload\" }, { status: 400 });");
425
- lines.push(" }");
426
- lines.push(" }");
427
- }
428
- if (migrations && migrations.length > 0) {
429
- lines.push(" if (request.method === \"POST\" && url.pathname === \"/__void/migrate\") {");
430
- lines.push(" const handler = createMigrationHandler(env, __migrations);");
431
- lines.push(" return handler(request);");
432
- lines.push(" }");
433
- lines.push(" if (request.method === \"GET\" && url.pathname === \"/__void/migrate/capabilities\") {");
434
- lines.push(" const handler = createMigrationHandler(env, __migrations, undefined, __migrationPlanBundle);");
435
- lines.push(" return handler(request);");
436
- lines.push(" }");
437
- lines.push(" if (request.method === \"POST\" && url.pathname === \"/__void/migrate/app\") {");
438
- lines.push(" const handler = createMigrationHandler(env, __migrations, undefined, __migrationPlanBundle);");
439
- lines.push(" return handler(request);");
440
- lines.push(" }");
441
- lines.push(" if (request.method === \"GET\" && url.pathname.startsWith(\"/__void/migrate/app/attempt/\")) {");
442
- lines.push(" const handler = createMigrationHandler(env, __migrations, undefined, __migrationPlanBundle);");
443
- lines.push(" return handler(request);");
444
- lines.push(" }");
445
- }
446
- if (features.crons.length > 0) {
447
- lines.push(" if (request.method === \"POST\" && url.pathname === \"/__void/scheduled\") {");
448
- lines.push(" const __token = request.headers.get(\"x-void-internal\");");
449
- lines.push(" const __expected = env?.__VOID_PROXY_TOKEN || env?.CRON_SECRET;");
450
- lines.push(" if (!__expected || __token !== __expected) {");
451
- lines.push(" return new Response(JSON.stringify({ error: 'unauthorized' }), {");
452
- lines.push(" status: 401,");
453
- lines.push(" headers: { \"Content-Type\": \"application/json\" },");
454
- lines.push(" });");
455
- lines.push(" }");
456
- lines.push(" try {");
457
- lines.push(" const { cron, scheduledTime } = await request.json();");
458
- lines.push(" const controller = { cron, scheduledTime, noRetry() {} };");
459
- lines.push(" await handleScheduled(controller, env, ctx);");
460
- lines.push(" return new Response(JSON.stringify({ ok: true }), {");
461
- lines.push(" headers: { \"Content-Type\": \"application/json\" },");
462
- lines.push(" });");
463
- lines.push(" } catch (err) {");
464
- lines.push(" return new Response(JSON.stringify({ error: String(err) }), {");
465
- lines.push(" status: 500,");
466
- lines.push(" headers: { \"Content-Type\": \"application/json\" },");
467
- lines.push(" });");
468
- lines.push(" }");
469
- lines.push(" }");
470
- }
471
- if (features.isr) {
472
- lines.push(" if (env.ISR_CACHE && request.headers.get(\"upgrade\")?.toLowerCase() !== \"websocket\") {");
473
- lines.push(" const cached = await handleFrameworkIsr(request, env, ctx, { ...__voidIsrPolicy, deploymentId: __voidIsrDeploymentId }, (req) => original.fetch(req, env, ctx));");
474
- lines.push(" if (cached) return cached;");
475
- lines.push(" }");
476
- }
477
- lines.push(" return original.fetch(request, env, ctx);");
478
- lines.push("}");
479
- lines.push("");
480
- }
481
- lines.push("export default {");
482
- if (needsFetchWrap) lines.push(" fetch: wrappedFetch,");
483
- else lines.push(" fetch: original.fetch,");
484
- if (features.crons.length > 0) lines.push(features.isr ? " scheduled(controller, env, ctx) { env.__VOID_ISR_DEPLOYMENT_ID ??= __voidIsrDeploymentId; return handleScheduled(controller, env, ctx); }," : " scheduled: handleScheduled,");
485
- if (features.queues.length > 0) lines.push(features.isr ? " queue(batch, env, ctx) { env.__VOID_ISR_DEPLOYMENT_ID ??= __voidIsrDeploymentId; return handleQueue(batch, env, ctx); }," : " queue: handleQueue,");
486
- lines.push("};");
487
- return lines.join("\n");
488
- }
489
- function generateHandlersSource(root, features) {
490
- const lines = [];
491
- const paths = readProjectPaths(root);
492
- if (features.crons.length > 0) {
493
- for (let i = 0; i < features.crons.length; i++) {
494
- const absPath = join(paths.cronsDir, features.crons[i].filePath);
495
- lines.push(`import cronHandler${i} from "${absPath}";`);
496
- }
497
- lines.push("");
498
- lines.push("export async function handleScheduled(controller, env, ctx) {");
499
- lines.push(" const tasks = [];");
500
- for (let i = 0; i < features.crons.length; i++) {
501
- lines.push(` if (${JSON.stringify(features.crons[i].crons)}.includes(controller.cron)) {`);
502
- lines.push(" tasks.push((async () => {");
503
- lines.push(` if (typeof cronHandler${i} === "function") {`);
504
- lines.push(` await cronHandler${i}(controller, env, ctx);`);
505
- lines.push(` } else if (cronHandler${i} && typeof cronHandler${i}.default === "function") {`);
506
- lines.push(` await cronHandler${i}.default(controller, env, ctx);`);
507
- lines.push(" }");
508
- lines.push(" })());");
509
- lines.push(" }");
510
- }
511
- lines.push(" const results = await Promise.allSettled(tasks);");
512
- lines.push(" const errors = results.filter(result => result.status === \"rejected\").map(result => result.reason);");
513
- lines.push(" if (errors.length) throw new AggregateError(errors, \"Scheduled jobs failed\");");
514
- lines.push("}");
515
- }
516
- if (features.queues.length > 0) {
517
- lines.push("");
518
- for (let i = 0; i < features.queues.length; i++) {
519
- const absPath = join(paths.queuesDir, features.queues[i].filePath);
520
- lines.push(`import queueHandler${i} from "${absPath}";`);
521
- }
522
- lines.push("");
523
- lines.push(generateQueueResolverSource(features.queues.map((queue) => queue.name)));
524
- lines.push("");
525
- lines.push("export async function handleQueue(batch, env, ctx) {");
526
- lines.push(" const queueSuffix = batch.queue;");
527
- lines.push(" const __queueIndex = __resolveQueueIndex(queueSuffix);");
528
- lines.push(" if (__queueIndex === -1) {");
529
- lines.push(" batch.retryAll();");
530
- lines.push(" throw new Error(`No unambiguous queue handler matches \"${String(queueSuffix)}\"`);");
531
- lines.push(" }");
532
- lines.push(" switch (__queueIndex) {");
533
- for (let i = 0; i < features.queues.length; i++) {
534
- lines.push(` case ${i}:`);
535
- lines.push(` if (typeof queueHandler${i} === "function") {`);
536
- lines.push(` await queueHandler${i}(batch, env);`);
537
- lines.push(` } else if (queueHandler${i} && typeof queueHandler${i}.default === "function") {`);
538
- lines.push(` await queueHandler${i}.default(batch, env);`);
539
- lines.push(` }`);
540
- lines.push(` return;`);
541
- }
542
- lines.push(" }");
543
- lines.push("}");
544
- lines.push(`
545
- export async function handleQueueRelay(payload, env, ctx) {
546
- if (!payload || typeof payload.queue !== "string" || !Array.isArray(payload.messages) ||
547
- payload.messages.some(m => !m || typeof m.id !== "string" || typeof m.timestamp !== "string" || !Number.isFinite(Date.parse(m.timestamp)))) {
548
- throw new Error("Invalid queue payload");
549
- }
550
- const decisions = new Map();
551
- const messages = payload.messages.map(m => {
552
- const decide = (decision) => { if (!decisions.has(m.id)) decisions.set(m.id, decision); };
553
- return {
554
- id: m.id, timestamp: new Date(m.timestamp), body: m.body, attempts: m.attempts,
555
- ack() { decide({ action: "ack" }); },
556
- retry(options) { decide({ action: "retry", ...(options?.delaySeconds != null ? { delaySeconds: options.delaySeconds } : {}) }); },
557
- };
558
- });
559
- const batch = {
560
- queue: payload.queue, messages,
561
- ackAll() { for (const message of messages) message.ack(); },
562
- retryAll(options) { for (const message of messages) message.retry(options); },
563
- };
564
- let ok = true;
565
- try { await handleQueue(batch, env, ctx); } catch { ok = false; }
566
- return { ok, ...(decisions.size ? { decisions: Object.fromEntries(decisions) } : {}) };
567
- }`);
568
- }
569
- return lines.join("\n");
570
- }
571
- //#endregion
572
34
  //#region src/cli/deploy-helpers.ts
573
35
  const log = {
574
36
  error: (message) => log$1.error(formatCloudflareUserMessage(message)),
@@ -880,15 +342,16 @@ function toManifestSchedulesAndQueues(jobs, queues) {
880
342
  }
881
343
  /**
882
344
  * If the project has an `env.ts`, validate its schema against the union of
883
- * production env files and remote secret names. Hard-error before upload so
345
+ * build-shell public values and remote secret names. Hard-error before upload so
884
346
  * deploys never ship missing required env vars.
885
347
  */
886
- async function assertEnvSchemaValid(root, client, projectId) {
348
+ async function assertEnvSchemaValid(root, client, projectId, workerVars) {
887
349
  if (findEnvFile(root) == null) return;
888
350
  const remoteSecrets = await fetchRemoteSecretNames(client, projectId);
889
351
  const { hasSchema, report } = await validateProdEnv(root, {
890
352
  productionOnly: true,
891
- remoteSecrets
353
+ remoteSecrets,
354
+ workerVars
892
355
  });
893
356
  if (!hasSchema || report.valid) return;
894
357
  const formatted = formatEnvReport(report);
@@ -1866,13 +1329,21 @@ function toMigrationsManifest(migrations, dialect) {
1866
1329
  * builder itself stays I/O-free.
1867
1330
  */
1868
1331
  function buildVoidManifest(opts) {
1869
- const { bindings, migrations, schedules, ssr, framework, revalidate, pages, pathRevalidate, queues, prerender, assetConfig, options, hashedAssetsPrefix, headerRules, redirectRules, fallbackRules, dialect, webSockets } = opts;
1332
+ const { bindings, migrations, schedules, ssr, framework, revalidate, pages, pathRevalidate, vars, queues, prerender, assetConfig, options, hashedAssetsPrefix, headerRules, redirectRules, fallbackRules, dialect, webSockets } = opts;
1870
1333
  const resolvedDialect = dialect ?? "sqlite";
1871
1334
  const manifest = {
1872
1335
  version: 3,
1873
1336
  assetManifestVersion: 2,
1874
1337
  bindings: {}
1875
1338
  };
1339
+ if (opts.durableObjects?.length) {
1340
+ manifest.version = 4;
1341
+ manifest.durableObjects = { bindings: opts.durableObjects.map(({ bindingName, className }) => ({
1342
+ bindingName,
1343
+ className,
1344
+ storage: "sqlite"
1345
+ })) };
1346
+ }
1876
1347
  if (opts.hasEmailHandlers) manifest.emailProtocolVersion = 1;
1877
1348
  if (bindings.needsAuth) manifest.auth = true;
1878
1349
  applyResourceBindings(manifest, bindings, migrations?.length ?? 0, resolvedDialect, options?.bindingNames);
@@ -1906,6 +1377,7 @@ function buildVoidManifest(opts) {
1906
1377
  resolvedFallbackRules = chain.fallbackRules;
1907
1378
  }
1908
1379
  if (resolvedAssetConfig) manifest.assetConfig = resolvedAssetConfig;
1380
+ if (vars && Object.keys(vars).length > 0) manifest.vars = vars;
1909
1381
  if (options?.workerMain) manifest.workerMain = options.workerMain;
1910
1382
  if (options?.compatibilityDate) manifest.compatibilityDate = options.compatibilityDate;
1911
1383
  if (options?.compatibilityFlags && options.compatibilityFlags.length > 0) manifest.compatibilityFlags = options.compatibilityFlags;
@@ -1979,6 +1451,7 @@ function buildFrameworkManifest(opts) {
1979
1451
  if (opts.revalidateQueryAllowlist && Object.keys(opts.revalidateQueryAllowlist).length > 0) manifest.revalidateQueryAllowlist = opts.revalidateQueryAllowlist;
1980
1452
  if (opts.prerender && opts.prerender.length > 0) manifest.prerender = opts.prerender;
1981
1453
  if (opts.assetConfig) manifest.assetConfig = opts.assetConfig;
1454
+ if (opts.vars && Object.keys(opts.vars).length > 0) manifest.vars = opts.vars;
1982
1455
  manifest.ssr = true;
1983
1456
  manifest.framework = opts.frameworkName;
1984
1457
  manifest.type = "framework";
@@ -2020,161 +1493,6 @@ function collectAssetFiles(root, isIgnored, dir = root) {
2020
1493
  return files;
2021
1494
  }
2022
1495
  //#endregion
2023
- //#region src/cli/deploy-managed-framework.ts
2024
- /**
2025
- * Class B/C framework deploy: build with framework CLI, package with preset output paths.
2026
- */
2027
- async function runFrameworkDeploy(root, config, client, detected, fwPreset, voidConfig, skipBuild, gitMetadata, cliLog) {
2028
- log.info(`${detected.name} framework deploy`);
2029
- cliLog?.info("deploy_mode", {
2030
- mode: "framework",
2031
- framework: detected.name
2032
- });
2033
- const buildCmd = voidConfig.inference?.build ?? formatProjectCommand(root, fwPreset.buildCommand);
2034
- if (!skipBuild) {
2035
- log.step(`Building (${buildCmd})...`);
2036
- cliLog?.info("build_start", { command: buildCmd });
2037
- const buildStartedAt = Date.now();
2038
- execSync(voidConfig.inference?.build ?? resolveProjectCommand(root, fwPreset.buildCommand), {
2039
- cwd: root,
2040
- stdio: "inherit",
2041
- env: buildEnv({ ...MANAGED_DEPLOY_BUILD_ENV }, { localBinRoot: root })
2042
- });
2043
- cliLog?.info("build_end", { durationMs: Date.now() - buildStartedAt });
2044
- } else cliLog?.info("build_skipped", { reason: "skipBuild" });
2045
- const workerDir = join(root, fwPreset.workerDir);
2046
- const assetsDir = join(root, fwPreset.assetsDir);
2047
- const frameworkAssetIgnorePatterns = fwPreset.workerDir === fwPreset.assetsDir && fwPreset.workerMain === "_worker.js" ? [`/${fwPreset.workerMain}`, "/_routes.json"] : [];
2048
- const { headerRules, redirectRules, fallbackRules } = mergeAndLintRoutingRules(assetsDir, voidConfig.routing);
2049
- warnIgnoredNotFoundForFramework(voidConfig.routing?.notFound, detected.name);
2050
- if (!existsSync(workerDir)) {
2051
- log.error(`deploy: Worker output '${fwPreset.workerDir}' not found. Run '${buildCmd}' first.`);
2052
- process.exit(1);
2053
- }
2054
- const analysis = analyzeApplicationSync(root, {
2055
- config: voidConfig,
2056
- environment: "prod"
2057
- });
2058
- const { paths, bindings, authEnabled, dialect } = analysis;
2059
- if (authEnabled) {
2060
- log.error("deploy: Void-managed Better Auth is only supported in Void apps. Use Better Auth's official integration for this framework instead.");
2061
- process.exit(1);
2062
- }
2063
- if (bindings.needsLive) {
2064
- log.error("deploy: void/live is currently supported in Void apps only.");
2065
- process.exit(1);
2066
- }
2067
- assertDeploySchemaDriftFree(root, dialect);
2068
- const validatedMigrations = validateDeployMigrations(paths.migrationsDir, analysis.migrations);
2069
- if (dialect !== "sqlite" && analysis.needsDatabase) await ensureManagedHyperdrive(client, config.projectId, dialect);
2070
- const rawJobs = analysis.jobs;
2071
- const rawQueues = analysis.queues;
2072
- const originalEntry = join(workerDir, fwPreset.workerMain);
2073
- const wrapperFeatures = {
2074
- crons: rawJobs,
2075
- queues: rawQueues,
2076
- hasMigrations: validatedMigrations != null && validatedMigrations.length > 0,
2077
- migrationDialect: dialect
2078
- };
2079
- let actualWorkerDir = workerDir;
2080
- let actualWorkerMain = fwPreset.workerMain;
2081
- if (fwPreset.bundle) {
2082
- log.step("Bundling worker...");
2083
- const bundleResult = await bundleEntry(root, originalEntry);
2084
- actualWorkerDir = bundleResult.outputDir;
2085
- actualWorkerMain = bundleResult.entryFilename;
2086
- log.info("Worker bundled");
2087
- }
2088
- if (needsWrapper(wrapperFeatures)) {
2089
- log.step("Generating wrapper...");
2090
- await generateDeployWrapperIfNeeded(root, actualWorkerDir, actualWorkerMain, wrapperFeatures);
2091
- log.info("Wrapper generated");
2092
- }
2093
- const wranglerCompat = resolveDeployWranglerCompat(root, voidConfig, workerDir, { dialect });
2094
- const revalidate = collectRevalidate(voidConfig, null);
2095
- const prerender = voidConfig.routing?.isr === false ? void 0 : voidConfig.routing?.prerender;
2096
- const { schedules, queues } = toManifestSchedulesAndQueues(rawJobs, rawQueues);
2097
- await assertEnvSchemaValid(root, client, config.projectId);
2098
- const s = createSpinner();
2099
- const onProgress = (msg) => s.message(msg);
2100
- s.start("Checking for changes...");
2101
- cliLog?.info("preflight_start", { dir: assetsDir });
2102
- const { assetManifest, assetFiles } = await collectAndHashAssets(assetsDir, onProgress, { ignorePatterns: frameworkAssetIgnorePatterns });
2103
- const { needed, skipped } = await client.preflight(config.projectId, assetManifest, true);
2104
- s.stop("Checked for changes");
2105
- cliLog?.info("preflight_end", {
2106
- total: Object.keys(assetManifest).length,
2107
- needed: needed.length,
2108
- skipped
2109
- });
2110
- if (skipped > 0) log.info(`Skipping ${formatCount(skipped, "unchanged asset")}`);
2111
- s.start("Packaging...");
2112
- cliLog?.info("package_start", {
2113
- mode: "framework",
2114
- framework: detected.name
2115
- });
2116
- const packageStartedAt = Date.now();
2117
- const packageOptions = {
2118
- bindingNames: analysis.bindingNames,
2119
- compatibilityDate: wranglerCompat?.compatibilityDate,
2120
- compatibilityFlags: wranglerCompat?.compatibilityFlags,
2121
- cpuMs: voidConfig.worker?.limits?.cpu_ms
2122
- };
2123
- const manifest = buildFrameworkManifest({
2124
- frameworkName: detected.name,
2125
- workerMain: actualWorkerMain,
2126
- bindings,
2127
- migrations: validatedMigrations,
2128
- schedules,
2129
- queues,
2130
- revalidate,
2131
- revalidateQueryAllowlist: voidConfig.routing?.revalidateQueryAllowlist,
2132
- prerender,
2133
- assetConfig: { not_found_handling: "none" },
2134
- packageOptions,
2135
- hashedAssetsPrefix: fwPreset.hashedAssetsPrefix ?? "assets",
2136
- headerRules,
2137
- redirectRules,
2138
- fallbackRules,
2139
- dialect
2140
- });
2141
- const workerFiles = collectWorkerFiles(actualWorkerDir);
2142
- cliLog?.info("package_end", {
2143
- mode: "framework",
2144
- durationMs: Date.now() - packageStartedAt
2145
- });
2146
- const result = await streamDirectR2Deploy({
2147
- client,
2148
- projectId: config.projectId,
2149
- manifest,
2150
- assetManifest,
2151
- assetFiles,
2152
- needed,
2153
- gitMetadata,
2154
- preflightUsed: skipped > 0,
2155
- workerFiles,
2156
- spinner: s,
2157
- cliLog
2158
- });
2159
- note(formatDeploySummary({
2160
- workers: result.workers,
2161
- assets: result.assets,
2162
- unchangedAssets: skipped,
2163
- migrations: result.migrations,
2164
- cronJobs: schedules.length,
2165
- queues: queues.length,
2166
- prerenderedPages: prerender?.length,
2167
- revalidate,
2168
- framework: detected.name
2169
- }), result.url);
2170
- cleanupWrapper(root);
2171
- warnUnpublishedRouting(result);
2172
- printDeploySuccess(result.published !== false);
2173
- }
2174
- function assertManagedDurableStateSupported(root) {
2175
- if (scanDurableObjectModules(root).length > 0) throw new Error("deploy: typed Durable State modules in durable-objects/ are not yet supported by the Void managed platform. Deploy to your own Cloudflare account with `void deploy --platform cloudflare`.");
2176
- }
2177
- //#endregion
2178
1496
  //#region src/cli/deploy-managed-static.ts
2179
1497
  /**
2180
1498
  * Assemble the Void deploy manifest, deriving the route-aware ISR `pages` table
@@ -2274,4 +1592,4 @@ async function runStaticDeploy(root, config, client, preset, skipBuild, gitMetad
2274
1592
  printDeploySuccess(result.published !== false);
2275
1593
  }
2276
1594
  //#endregion
2277
- export { resolveDeployLiveBindingConfig as A, generateDeployWrapperIfNeeded as C, hasPrerenderSources as D, hasNonPageBackend as E, resolveStaticDeployPreset as F, toManifestSchedulesAndQueues as I, validateDeployMigrations as L, resolveDeployWranglerCompat as M, resolveFullDeployBuildCommand as N, log as O, resolveStaticBuildCommand as P, needsWrapper as R, ensureManagedHyperdrive as S, getGitCommit as T, hasDeploySchemaDrift as _, buildStaticManifest as a, assertWorkerMainUploaded as b, detectNonSpaFallbackWarning as c, printDeploySuccess as d, mergeAndLintRoutingRules as f, getDeploySchemaDriftMessage as g, assertDeploySchemaDriftFree as h, runFrameworkDeploy as i, resolveDeployWorkerMain as j, promptDeployProjectConfig as k, formatDeploySummary as l, warnUnpublishedRouting as m, runStaticDeploy as n, collectAndHashAssets as o, streamDirectR2Deploy as p, assertManagedDurableStateSupported as r, collectWorkerFiles as s, assembleVoidManifest as t, printDeployContext as u, assertEnvSchemaValid as v, getExitCode as w, createProjectFromSlug as x, assertProjectDeployAccess as y };
1595
+ export { resolveDeployLiveBindingConfig as A, generateDeployWrapperIfNeeded as C, hasPrerenderSources as D, hasNonPageBackend as E, resolveStaticDeployPreset as F, toManifestSchedulesAndQueues as I, validateDeployMigrations as L, resolveDeployWranglerCompat as M, resolveFullDeployBuildCommand as N, log as O, resolveStaticBuildCommand as P, ensureManagedHyperdrive as S, getGitCommit as T, hasDeploySchemaDrift as _, collectAndHashAssets as a, assertWorkerMainUploaded as b, formatDeploySummary as c, mergeAndLintRoutingRules as d, streamDirectR2Deploy as f, getDeploySchemaDriftMessage as g, assertDeploySchemaDriftFree as h, buildStaticManifest as i, resolveDeployWorkerMain as j, promptDeployProjectConfig as k, printDeployContext as l, warnUnpublishedRouting as m, runStaticDeploy as n, collectWorkerFiles as o, warnIgnoredNotFoundForFramework as p, buildFrameworkManifest as r, detectNonSpaFallbackWarning as s, assembleVoidManifest as t, printDeploySuccess as u, assertEnvSchemaValid as v, getExitCode as w, createProjectFromSlug as x, assertProjectDeployAccess as y };