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.
- package/dist/{account-cmd-Ci00cncT.mjs → account-cmd-BTcUzv9L.mjs} +4 -4
- package/dist/{application-analysis-D72ZQfMZ.mjs → application-analysis-AB_YYWgH.mjs} +1 -1
- package/dist/{application-routing-Dy589Vgn.mjs → application-routing-L7V-TFhZ.mjs} +1 -1
- package/dist/auth-Cbqi1iVX.mjs +1 -0
- package/dist/{auth-link-DWr6Afao.mjs → auth-link-DUJuvRx5.mjs} +4 -4
- package/dist/{auth-router-DP14wVkZ.mjs → auth-router-CIxiMG7i.mjs} +3 -3
- package/dist/{build-cmd-Cr3FJxv0.mjs → build-cmd-BkIv25PA.mjs} +3 -3
- package/dist/{cache-D0Tt28cn.mjs → cache-Ctzfig-W.mjs} +3 -3
- package/dist/{cancel-deploy-CJKvk7AN.mjs → cancel-deploy-CD9o-SsC.mjs} +2 -2
- package/dist/cf-build-output-BU3hqdHu.mjs +1 -0
- package/dist/cli/cli.mjs +31 -31
- package/dist/cli/cloudflare-operation-process.mjs +2 -2
- package/dist/cli/env-schema-probe.d.mts +2 -1
- package/dist/cli/env-schema-probe.mjs +2 -2
- package/dist/client-B60PwCC4.mjs +1 -0
- package/dist/{cloudflare-cmd-CTrn-lXJ.mjs → cloudflare-cmd-BIAF_BIY.mjs} +2 -2
- package/dist/{cloudflare-connect-BosmCNlq.mjs → cloudflare-connect-WjwnVOJA.mjs} +1 -1
- package/dist/{cloudflare-operations-BKdSfNBN.mjs → cloudflare-operations-B42EZeJy.mjs} +3 -3
- package/dist/cloudflare-operations-CrSUFRzJ.mjs +1 -0
- package/dist/collect-Cae8A7Zr.mjs +1 -0
- package/dist/config-QrJWu0IX.mjs +1 -0
- package/dist/{connect-nukQSoEO.mjs → connect-CKtk-EZe.mjs} +5 -5
- package/dist/create-project-B-ewF_Af.mjs +1 -0
- package/dist/{create-project-D4APeBwX.mjs → create-project-yInGo72M.mjs} +3 -3
- package/dist/database-provider.mjs +1 -2
- package/dist/{db-27RztQLy.mjs → db-7I_gfdVq.mjs} +37 -38
- package/dist/db-types-Bb4WBWIs.mjs +49 -0
- package/dist/{delete-BbsZFZIw.mjs → delete-Cy-M1u-r.mjs} +3 -3
- package/dist/deploy-9lgfhrXS.mjs +2 -0
- package/dist/{deploy-B06EQq4t.mjs → deploy-BYYlnsiy.mjs} +176 -21
- package/dist/{deploy-managed-static-CGswbcay.mjs → deploy-managed-static-Ca4TFdmx.mjs} +24 -706
- package/dist/{deploy-transport-BiicfoQW.mjs → deploy-transport-DWlWBe6M.mjs} +1 -1
- package/dist/deploy.mjs +4 -4
- package/dist/discover-ClzFSwns.mjs +1 -0
- package/dist/dispatch-DrTTk8Xg.mjs +431 -0
- package/dist/{dist-D3m88sjf.mjs → dist-BVdsO7Py.mjs} +5 -6
- package/dist/dist-CfgIkieS.mjs +1 -0
- package/dist/{domain-Bfq9n03H.mjs → domain-CZGxPv9u.mjs} +4 -4
- package/dist/edge.mjs +1 -2
- package/dist/{email-DIwaQU4P.mjs → email-DzyNVuoU.mjs} +6 -6
- package/dist/{email-cloudflare-CH053RxK.mjs → email-cloudflare-DfG6UEMm.mjs} +1 -1
- package/dist/{env-BhdWMrNy.mjs → env-0jrMQJI_.mjs} +5 -2
- package/dist/{env-C6ipBLp3.mjs → env-Nx3yf50r.mjs} +4 -4
- package/dist/{env-raw-Cklzcde3.mjs → env-raw-D74P4ebM.mjs} +12 -1
- package/dist/env-validation-BT7z-qpQ.mjs +1 -0
- package/dist/{env-validation-cE0zcmzO.mjs → env-validation-DYxjz_Wo.mjs} +2 -0
- package/dist/{gen-CnN1Xidx.mjs → gen-CufHEf42.mjs} +2 -2
- package/dist/gen-sXyp5DFO.mjs +1 -0
- package/dist/generate-ClI89brV.mjs +1 -0
- package/dist/{github-cmd-BdkU4Nhe.mjs → github-cmd-FU8EjFyU.mjs} +3 -3
- package/dist/{help-Bug7pyK_.mjs → help-BT2hovNI.mjs} +9 -5
- package/dist/help-i2YGGnTH.mjs +1 -0
- package/dist/{inbound-DmkTQeWp.mjs → inbound-BuTfm11U.mjs} +1 -1
- package/dist/index.mjs +551 -303
- package/dist/{info-CujPwtMe.mjs → info-l249eUdH.mjs} +1 -1
- package/dist/{init-ZWOJvc-Z.mjs → init-D0A6M64Q.mjs} +60 -14
- package/dist/{isr-config-DPjXM8J2.mjs → isr-config-fZaJJ8t7.mjs} +1 -30
- package/dist/{link-UEc7bnF4.mjs → link-WMoJFf4i.mjs} +4 -4
- package/dist/{list-CuWeOnzk.mjs → list-CQ2EQEHL.mjs} +4 -4
- package/dist/{live-BxLX-JqJ.mjs → live-BcHoTDFe.mjs} +1 -1
- package/dist/{local-d1-BM3p74mm.mjs → local-d1-BxvQYEFi.mjs} +1 -1
- package/dist/{login-CZ2Cqa-D.mjs → login-C2T1oVG-.mjs} +3 -3
- package/dist/login-XD844Xs-.mjs +1 -0
- package/dist/{logs-TihRcLTk.mjs → logs-DnC1d7xB.mjs} +3 -3
- package/dist/{migrate-uFwojusJ.mjs → migrate-BDIprOYd.mjs} +2 -2
- package/dist/migrate-BRwU-blY.mjs +1 -0
- package/dist/mysql-migration-sql-BIS5vbNk.mjs +241 -0
- package/dist/nitro.d.mts +30 -0
- package/dist/nitro.mjs +88 -0
- package/dist/{node-DoKbo1SZ.mjs → node-cPadMgUO.mjs} +3 -3
- package/dist/operator-cmd-D6gnZsnK.mjs +1 -0
- package/dist/{operator-cmd-C5lCctnc.mjs → operator-cmd-DHieWtFp.mjs} +5 -5
- package/dist/{output-FNHKw5Ac.mjs → output-Ba6ZbrzY.mjs} +1 -1
- package/dist/pages/head.mjs +1 -2
- package/dist/pages/prefetch.mjs +1 -2
- package/dist/pages/serialize.mjs +1 -2
- package/dist/plan-CKX_jWnD.mjs +1 -0
- package/dist/platform-args-B0HeTh0C.mjs +1 -0
- package/dist/{platform-args-C6Mb_I3a.mjs → platform-args-CaCL_1Ch.mjs} +9 -2
- package/dist/{platform-auth-config-CJmNkFT2.mjs → platform-auth-config-Z16-I8nT.mjs} +6 -6
- package/dist/{platform-auth-protection-D5wvsI-Y.mjs → platform-auth-protection-BXwZiJSF.mjs} +4 -4
- package/dist/{platform-auth-recovery-D_0I3n-1.mjs → platform-auth-recovery-CXjfqyOv.mjs} +4 -4
- package/dist/{platform-cmd-DxxZO6e5.mjs → platform-cmd-DaAOiWTl.mjs} +7 -7
- package/dist/platform-cmd-PT4YwMLM.mjs +1 -0
- package/dist/{platform-domain-zLXnW1G_.mjs → platform-domain-CxpvUeo0.mjs} +4 -4
- package/dist/{platform-lifecycle-DOW-wLfx.mjs → platform-lifecycle-DBiS0cJd.mjs} +317 -99
- package/dist/platform-lifecycle-u9pMOvxC.mjs +1 -0
- package/dist/{platform-management-t7HKy4-U.mjs → platform-management-DhEFdQAf.mjs} +67 -9
- package/dist/platform-management-DvBS83rC.mjs +1 -0
- package/dist/{platform-plans-config-CNH6zbPX.mjs → platform-plans-config-BWn1S2Rv.mjs} +2 -2
- package/dist/{platform-recovery-DeucI7A9.mjs → platform-recovery-BUGOB4RC.mjs} +2 -2
- package/dist/{platform-setup-CTf6MMT9.mjs → platform-setup-YvN9VQXV.mjs} +3 -3
- package/dist/prepare-CYT6tAzD.mjs +1 -0
- package/dist/{prepare-CSH9dKTI.mjs → prepare-DEB5SeVJ.mjs} +3 -2
- package/dist/{prepare-C4zfwks4.mjs → prepare-PQCgsny0.mjs} +3 -3
- package/dist/prerender-render.mjs +1 -2
- package/dist/{project-cmd-Dq75AXzy.mjs → project-cmd-DVatD8Ev.mjs} +16 -16
- package/dist/project-slug-6cyz8E7k.mjs +1 -0
- package/dist/{project-team-B3_QcStG.mjs → project-team-DJrWEAG1.mjs} +3 -3
- package/dist/{project-token-CvsRvv2I.mjs → project-token-CBgLBuL6.mjs} +3 -3
- package/dist/project-zdB3fs9G.mjs +1 -0
- package/dist/{project-zero-trust-D1ICiwN_.mjs → project-zero-trust-92gLtZ25.mjs} +3 -3
- package/dist/{provision-DDh7ITVS.mjs → provision-BnSSkiED.mjs} +1 -1
- package/dist/{requests-3CL3BuZh.mjs → requests-7W1Pygt2.mjs} +2 -2
- package/dist/resolve-project-PnhzMtY6.mjs +1 -0
- package/dist/{resolve-project-C_Cu7E8a.mjs → resolve-project-WpwkCB_c.mjs} +1 -1
- package/dist/{rollback-Ce1d_0J9.mjs → rollback-BcASVnwP.mjs} +3 -3
- package/dist/{route-types-IrBuwJ7u.mjs → route-types-BZi26DVS.mjs} +2 -49
- package/dist/{runner-DcVDrzuR.mjs → runner-CabsQ-iM.mjs} +15 -6
- package/dist/runner-So9mYfcm.mjs +1 -0
- package/dist/runner-mysql-BhRaONkO.mjs +146 -0
- package/dist/runner-mysql-DWwE8jKi.mjs +1 -0
- package/dist/{runner-pg-CPd-CB_F.mjs → runner-pg-BRemq_GX.mjs} +2 -2
- package/dist/runner-pg-_Xncr3H5.mjs +1 -0
- package/dist/runtime/ai.mjs +15 -4
- package/dist/runtime/auth-client-react.mjs +1 -2
- package/dist/runtime/auth-client-solid.mjs +1 -2
- package/dist/runtime/auth-client-svelte.mjs +1 -2
- package/dist/runtime/auth-client-vue.mjs +1 -2
- package/dist/runtime/auth-client.mjs +1 -2
- package/dist/runtime/auth.mjs +1 -2
- package/dist/runtime/better-auth-mysql.mjs +4 -1
- package/dist/runtime/db.mjs +6 -2
- package/dist/runtime/durable.d.mts +2 -1
- package/dist/runtime/durable.mjs +1 -1
- package/dist/runtime/email/testing.mjs +1 -1
- package/dist/runtime/email-protocol.mjs +1 -2
- package/dist/runtime/email.mjs +1 -1
- package/dist/runtime/env-public.mjs +2 -2
- package/dist/runtime/env.mjs +1 -2
- package/dist/runtime/isr.mjs +1 -1
- package/dist/runtime/kv.mjs +1 -1
- package/dist/runtime/limits.mjs +1 -2
- package/dist/runtime/live-client.d.mts +2 -1
- package/dist/runtime/live-server.d.mts +2 -1
- package/dist/runtime/live-server.mjs +1 -1
- package/dist/runtime/live.mjs +1 -2
- package/dist/runtime/log.d.mts +2 -1
- package/dist/runtime/migration-handler-mysql.mjs +38 -8
- package/dist/runtime/migration-handler.mjs +1 -2
- package/dist/runtime/queues.mjs +1 -1
- package/dist/runtime/response.mjs +1 -2
- package/dist/runtime/route-url.mjs +1 -2
- package/dist/runtime/routing.d.mts +2 -1
- package/dist/runtime/sandbox-container.mjs +1 -2
- package/dist/runtime/sandbox.mjs +3 -3
- package/dist/runtime/seed.d.mts +2 -1
- package/dist/runtime/sse.mjs +1 -2
- package/dist/runtime/storage.mjs +1 -1
- package/dist/runtime/validator.mjs +1 -2
- package/dist/runtime/ws-server.d.mts +2 -1
- package/dist/runtime/ws-server.mjs +1 -1
- package/dist/{secret-B5J8bBsI.mjs → secret-bg73f1Ge.mjs} +5 -5
- package/dist/{skills-BJsan98C.mjs → skills-C_yRTg0g.mjs} +1 -1
- package/dist/{subcommand-prompt-gQ-NDA-u.mjs → subcommand-prompt-Bm3ZlYgA.mjs} +2 -2
- package/dist/sveltekit.d.mts +2 -1
- package/dist/validate-BQFdf0Pi.mjs +1 -0
- package/dist/wrapper-CwhpNWtH.mjs +663 -0
- package/docs/guide/ai.md +8 -2
- package/docs/guide/database/mysql.md +14 -3
- package/docs/guide/database.md +1 -5
- package/docs/guide/durable-state.md +9 -5
- package/docs/guide/platform/installation/credentials.md +18 -2
- package/docs/guide/platform/installation/domains.md +1 -1
- package/docs/guide/platform/installation/maintenance.md +38 -1
- package/docs/guide/platform/installation/prerequisites.md +6 -2
- package/docs/guide/platform/installation/setup.md +23 -1
- package/docs/guide/platform/installation/uninstall.md +6 -1
- package/docs/guide/sandboxes.md +1 -1
- package/docs/guide/self-hosted-platform.md +1 -1
- package/docs/integrations/cloudflare.md +2 -2
- package/docs/integrations/frameworks/analog.md +3 -11
- package/docs/integrations/frameworks/nuxt.md +7 -10
- package/docs/integrations/nodejs-bun-deno.md +2 -0
- package/docs/reference/api.md +1 -0
- package/docs/reference/cli/platform-installation.md +18 -6
- package/docs/reference/config.md +2 -0
- package/package.json +34 -28
- package/sandbox.Dockerfile +1 -1
- package/skills/void/SKILL.md +1 -1
- package/dist/auth-wn6F8dB8.mjs +0 -2
- package/dist/cf-build-output-2u583yJK.mjs +0 -2
- package/dist/client-C1BjRn3g.mjs +0 -2
- package/dist/cloudflare-operations-Ds-lX3Ts.mjs +0 -2
- package/dist/collect-NUlJMpLY.mjs +0 -2
- package/dist/config-CNnrSMYm.mjs +0 -2
- package/dist/create-project-DL7YXpjj.mjs +0 -2
- package/dist/deploy-Db2ALnQP.mjs +0 -3
- package/dist/discover-CTUiSsfG.mjs +0 -2
- package/dist/dist-Bx1z6Eva.mjs +0 -2
- package/dist/env-validation-CTn-HhG1.mjs +0 -2
- package/dist/gen-F8pSZnhc.mjs +0 -2
- package/dist/generate-Rii9klHB.mjs +0 -2
- package/dist/help-s9q7LTcu.mjs +0 -2
- package/dist/login-DhK7o1oJ.mjs +0 -2
- package/dist/migrate-BgT-hmu8.mjs +0 -2
- package/dist/operator-cmd-Cjk5DiRx.mjs +0 -2
- package/dist/plan-CH2G51je.mjs +0 -2
- package/dist/platform-args-Cm7x-fot.mjs +0 -2
- package/dist/platform-cmd-Cuj4oUVo.mjs +0 -2
- package/dist/platform-lifecycle-_gfnjUBr.mjs +0 -2
- package/dist/platform-management-CYrLvTGH.mjs +0 -2
- package/dist/prepare-dr9uxQSV.mjs +0 -2
- package/dist/project-DiiOBZPF.mjs +0 -2
- package/dist/project-slug-DofjTFd-.mjs +0 -2
- package/dist/resolve-project-B9Hr0D3n.mjs +0 -2
- package/dist/runner-B5huK2eC.mjs +0 -2
- package/dist/runner-mysql-CCtyI0p6.mjs +0 -55
- package/dist/runner-mysql-CaJq-hd6.mjs +0 -2
- package/dist/runner-pg-BJhFZZG4.mjs +0 -2
- package/dist/validate-C9xtFOYR.mjs +0 -2
- package/dist/{sandbox-container-DBKIqDEK.mjs → sandbox-container-a9LRUtii.mjs} +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __toESM } from "./rolldown-runtime-DXIUcv95.mjs";
|
|
2
|
-
import { a as join, c as resolve, n as dirname, s as relative } from "./dist-ipQi0Q8y.mjs";
|
|
2
|
+
import { a as join, c as resolve, n as dirname, o as normalize, s as relative } from "./dist-ipQi0Q8y.mjs";
|
|
3
3
|
import { t as require_picocolors } from "./picocolors-BTps1_gs.mjs";
|
|
4
4
|
import { d as walk, l as inferBindingsFromSource, m as applyBindingOverrides, n as FRAMEWORK_SCAN_DIRS, t as DEFAULT_SCAN_DIRS, u as staticModuleReferences } from "./plugin-inference-DsARdQKE.mjs";
|
|
5
5
|
import { n as readProjectPaths, t as assertNoRootSourceConventionConflicts } from "./project-paths-DMvEeSau.mjs";
|
|
@@ -7,43 +7,44 @@ import { n as loadVoidAuthConfig } from "./config-D0GY5ItR.mjs";
|
|
|
7
7
|
import { c as isNodeTarget, d as readConfig, s as getDatabaseDialect } from "./config-Bx_1SpnO.mjs";
|
|
8
8
|
import { i as isMemberExpression, n as isIdentifier, r as isLiteral } from "./ast-CPGPjb0V.mjs";
|
|
9
9
|
import { t as isRouteEnabledForEnvironment } from "./parse-filename-CUbj-1MP.mjs";
|
|
10
|
-
import { a as hasSandboxSqliteMigration, c as sandboxContainerConfig, i as assertSandboxNamespaceConfig,
|
|
10
|
+
import { a as hasSandboxSqliteMigration, c as sandboxContainerConfig, i as assertSandboxNamespaceConfig, n as DEFAULT_SANDBOX_CLASS_NAME, p as scanJobsSync, r as SANDBOX_MIGRATION_TAG, s as resolveSandboxConfig, t as analyzeApplicationSync, u as scanQueuesSync } from "./application-analysis-AB_YYWgH.mjs";
|
|
11
11
|
import { a as validateSsrEntries, n as SSR_SERVER_ENTRY_RELATIVE_PATHS, o as validateSsrEntry, t as SSR_CLIENT_ENTRY_RELATIVE_PATHS } from "./entry-ehmBvs5w.mjs";
|
|
12
12
|
import { r as hasEmailHandlers } from "./email-BcjSyAL0.mjs";
|
|
13
13
|
import { t as MagicString } from "./dist-Cegxq8gs.mjs";
|
|
14
14
|
import { i as resolveLayoutIds } from "./scan-C0BMdmEd.mjs";
|
|
15
|
-
import { a as resolveDistDir, c as
|
|
15
|
+
import { a as resolveDistDir, c as hasDocumentRoutes, n as collectRevalidate, o as resolveWorkerDirName, r as hasRevalidate, s as hasApiRoutes, t as collectPages, u as resolveAssetRoutingPolicy } from "./isr-config-fZaJJ8t7.mjs";
|
|
16
16
|
import { i as voidWarn, n as voidError, r as voidLog, t as setShowTimestamp } from "./log-vqY3pqwI.mjs";
|
|
17
17
|
import { n as mergeRoutingRules, t as lintRoutingPhases } from "./headers-Di1FsD3e.mjs";
|
|
18
18
|
import { n as readDeploymentPlatform, r as readProjectConfig } from "./project-rqDnVsJN.mjs";
|
|
19
19
|
import { a as restoreCloudflarePreviewPointer, r as materializeCloudflareConfig, s as stashCloudflareDeployPointer } from "./cloudflare-config-DV60XFFK.mjs";
|
|
20
20
|
import { D as syncWranglerBindings, E as resolveLiveBindingConfig, O as syncWranglerDurableObjects, T as readWranglerWebSocketTombstones, a as LIVE_MIGRATION_TAG, d as ensureWranglerCompatibilityDate, f as ensureWranglerNodejsAlsFlag, g as normalizeWranglerCompatibilityFlags, h as nextDurableObjectMigrationTag, k as syncWranglerWebSockets, m as hasDurableObjectSqliteMigration, p as findBindingNameOwner, u as ensureWranglerCompat, v as readExistingLiveBindingConfig, x as readWranglerCompat } from "./wrangler-BYs07Rxy.mjs";
|
|
21
|
-
import { n as writeLocalD1PersistState, t as resolveLocalD1Target } from "./local-d1-
|
|
21
|
+
import { n as writeLocalD1PersistState, t as resolveLocalD1Target } from "./local-d1-BxvQYEFi.mjs";
|
|
22
22
|
import { n as scopedAccessCredentials } from "./cf-access-BM9G0lhO.mjs";
|
|
23
23
|
import { n as ensurePlatformProxyAccess } from "./cf-access-CWP4avfP.mjs";
|
|
24
24
|
import { a as getApiUrl, c as getToken, o as getProxyUrl } from "./auth-B6iOCjKI.mjs";
|
|
25
|
-
import { m as printSuccess } from "./output-
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import { t as discoverSchema } from "./discover-D2PGT63u.mjs";
|
|
25
|
+
import { m as printSuccess } from "./output-Ba6ZbrzY.mjs";
|
|
26
|
+
import { r as writeFileIfChanged } from "./project-tsconfig-bveqhlYA.mjs";
|
|
27
|
+
import { n as drizzlePlugin, t as generateQueueResolverSource } from "./dispatch-DrTTk8Xg.mjs";
|
|
29
28
|
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-Rd6j_8vM.mjs";
|
|
30
29
|
import { n as scanWranglerDotenvKeys } from "./dotenv-CNazY3-w.mjs";
|
|
31
30
|
import { a as isClientEnvKey, c as resolveRemoteMode, i as findReservedEnvKeys, n as LOCAL_ENV_FILE, o as loadLocalEnv, r as findLegacyEnvFiles, s as reservedEnvKeysMessage } from "./env-BJjULvL0.mjs";
|
|
32
31
|
import { n as findEnvFileForPaths, r as generateEnvTypes, t as findEnvFile } from "./env-types-DS2_y4X8.mjs";
|
|
33
32
|
import { t as loadUserEnvFile } from "./load-user-env-DD5qveNU.mjs";
|
|
34
|
-
import { n as INTERNAL_BINDING_PREFIXES, t as INTERNAL_BINDING_EXACT_NAMES } from "./env-raw-
|
|
33
|
+
import { n as INTERNAL_BINDING_PREFIXES, t as INTERNAL_BINDING_EXACT_NAMES } from "./env-raw-D74P4ebM.mjs";
|
|
35
34
|
import { t as ASSET_EXTENSIONS } from "./routing-assets-VkrKIbxE.mjs";
|
|
36
35
|
import { r as selectNativeVersionMetadataBinding, t as CLOUDFLARE_PRESERVE_BINDINGS_BUILD_ENV } from "./version-metadata-DIrqEHQo.mjs";
|
|
37
|
-
import { f as prerenderPages, n as SEND_EMAIL_BINDING, p as prerenderPagesNode } from "./email-cloudflare-
|
|
36
|
+
import { f as prerenderPages, n as SEND_EMAIL_BINDING, p as prerenderPagesNode } from "./email-cloudflare-DfG6UEMm.mjs";
|
|
38
37
|
import { r as defer } from "./validation-error-Dg9Recn1.mjs";
|
|
39
38
|
import { i as safeJsonStringify } from "./protocol-RNP0u7UY.mjs";
|
|
40
|
-
import { n as completeApplicationAnalysis } from "./application-routing-
|
|
39
|
+
import { n as completeApplicationAnalysis } from "./application-routing-L7V-TFhZ.mjs";
|
|
41
40
|
import { n as generateVoidAuthDrizzleSchema, t as generateVoidAuthDatabaseModule } from "./drizzle-CF84FOVM.mjs";
|
|
41
|
+
import { n as generateQueueTypes, t as generateRouteTypes } from "./route-types-BZi26DVS.mjs";
|
|
42
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-BZ1t7-Rv.mjs";
|
|
43
|
-
import
|
|
43
|
+
import module, { builtinModules, createRequire } from "node:module";
|
|
44
|
+
import { chmodSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
44
45
|
import { cloudflare } from "@cloudflare/vite-plugin";
|
|
45
46
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
46
|
-
import { loadEnv, normalizePath, parseSync, resolveEnvPrefix } from "vite";
|
|
47
|
+
import { defaultServerConditions, loadEnv, normalizePath, parseSync, resolveEnvPrefix } from "vite";
|
|
47
48
|
import { appendSqliteClassMigration } from "@void/deploy-core";
|
|
48
49
|
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
49
50
|
import { homedir } from "node:os";
|
|
@@ -488,10 +489,10 @@ function readVoidDevCredentials(root) {
|
|
|
488
489
|
* block the server. On completion, writes project.json and restarts the server.
|
|
489
490
|
*/
|
|
490
491
|
async function runAiSetupPrompt(root, token, apiUrl, server) {
|
|
491
|
-
const { select, text, isCancel, log } = await import("./dist-
|
|
492
|
-
const { PlatformClient } = await import("./client-
|
|
493
|
-
const { attachSelectedPlatform, writeProjectConfig } = await import("./project-
|
|
494
|
-
const { inferDefaultSlug } = await import("./resolve-project-
|
|
492
|
+
const { select, text, isCancel, log } = await import("./dist-CfgIkieS.mjs");
|
|
493
|
+
const { PlatformClient } = await import("./client-B60PwCC4.mjs");
|
|
494
|
+
const { attachSelectedPlatform, writeProjectConfig } = await import("./project-zdB3fs9G.mjs");
|
|
495
|
+
const { inferDefaultSlug } = await import("./resolve-project-PnhzMtY6.mjs");
|
|
495
496
|
const client = new PlatformClient(token, { apiUrl });
|
|
496
497
|
let projects;
|
|
497
498
|
try {
|
|
@@ -517,8 +518,8 @@ async function runAiSetupPrompt(root, token, apiUrl, server) {
|
|
|
517
518
|
let projectId;
|
|
518
519
|
let slug;
|
|
519
520
|
if (result === "__create__") {
|
|
520
|
-
const { validateProjectSlug } = await import("./project-slug-
|
|
521
|
-
const { createProjectWithSlugRetry } = await import("./create-project-
|
|
521
|
+
const { validateProjectSlug } = await import("./project-slug-6cyz8E7k.mjs");
|
|
522
|
+
const { createProjectWithSlugRetry } = await import("./create-project-B-ewF_Af.mjs");
|
|
522
523
|
let created;
|
|
523
524
|
try {
|
|
524
525
|
created = await createProjectWithSlugRetry(client, inferDefaultSlug(root), async (defaultSlug) => {
|
|
@@ -552,7 +553,7 @@ async function runAiSetupPrompt(root, token, apiUrl, server) {
|
|
|
552
553
|
}
|
|
553
554
|
//#endregion
|
|
554
555
|
//#region src/plugin-binding-runtime.ts
|
|
555
|
-
const envModuleResolved
|
|
556
|
+
const envModuleResolved = fileURLToPath(import.meta.resolve("#self/_env"));
|
|
556
557
|
const kvModuleResolved = fileURLToPath(import.meta.resolve("void/kv"));
|
|
557
558
|
const storageModuleResolved = fileURLToPath(import.meta.resolve("void/storage"));
|
|
558
559
|
const VIRTUAL_KV_ID = "\0virtual:void-kv";
|
|
@@ -573,7 +574,7 @@ function bindingRuntimePlugin(bindingNames) {
|
|
|
573
574
|
filter: { id: /^\0virtual:void-(?:kv|storage)$/ },
|
|
574
575
|
handler(id) {
|
|
575
576
|
if (id === VIRTUAL_KV_ID) return `
|
|
576
|
-
import { requireRuntimeBinding } from ${JSON.stringify(envModuleResolved
|
|
577
|
+
import { requireRuntimeBinding } from ${JSON.stringify(envModuleResolved)};
|
|
577
578
|
import { createKV } from ${JSON.stringify(kvModuleResolved)};
|
|
578
579
|
|
|
579
580
|
const namespace = new Proxy({}, {
|
|
@@ -588,7 +589,7 @@ export { createKV };
|
|
|
588
589
|
export const kv = createKV(namespace);
|
|
589
590
|
`;
|
|
590
591
|
if (id === VIRTUAL_STORAGE_ID) return `
|
|
591
|
-
import { requireRuntimeBinding } from ${JSON.stringify(envModuleResolved
|
|
592
|
+
import { requireRuntimeBinding } from ${JSON.stringify(envModuleResolved)};
|
|
592
593
|
export { createStorage } from ${JSON.stringify(storageModuleResolved)};
|
|
593
594
|
|
|
594
595
|
export const storage = new Proxy({}, {
|
|
@@ -696,6 +697,19 @@ function isViteBuildOrPreview() {
|
|
|
696
697
|
const subcommand = process.argv[2];
|
|
697
698
|
return subcommand === "build" || subcommand === "preview";
|
|
698
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* Point Cloudflare remote bindings opened in this process at the login from
|
|
702
|
+
* `void connect` and `void cloudflare login`. The Cloudflare Vite plugin and
|
|
703
|
+
* Wrangler's platform proxy authenticate remote bindings here, in dev, preview
|
|
704
|
+
* and build prerendering. They read cf's login only when `CLOUDFLARE_CF_AUTH`
|
|
705
|
+
* is present (any value), and Wrangler's separate login otherwise. The keyring
|
|
706
|
+
* flag selects the encrypted cf profile that Void's login writes. Environment
|
|
707
|
+
* API tokens still take precedence, and the OAuth token stays in the store.
|
|
708
|
+
*/
|
|
709
|
+
function selectVoidCloudflareLogin() {
|
|
710
|
+
process.env.CLOUDFLARE_CF_AUTH = "true";
|
|
711
|
+
process.env.CLOUDFLARE_AUTH_USE_KEYRING = "true";
|
|
712
|
+
}
|
|
699
713
|
const DEV_TRIGGER_TOKEN_FILE_MODE = 384;
|
|
700
714
|
/**
|
|
701
715
|
* Persist the dev-trigger token at `<root>/.void/dev-trigger-token` so
|
|
@@ -862,199 +876,6 @@ function devTriggersHintPlugin(root, devTriggerToken) {
|
|
|
862
876
|
};
|
|
863
877
|
}
|
|
864
878
|
//#endregion
|
|
865
|
-
//#region src/plugin-drizzle.ts
|
|
866
|
-
const drizzleD1Resolved = fileURLToPath(import.meta.resolve("drizzle-orm/d1"));
|
|
867
|
-
const drizzleOrmResolved = fileURLToPath(import.meta.resolve("drizzle-orm"));
|
|
868
|
-
const envModuleResolved = fileURLToPath(import.meta.resolve("#self/_env"));
|
|
869
|
-
const drizzleNodePgResolved = fileURLToPath(import.meta.resolve("drizzle-orm/node-postgres"));
|
|
870
|
-
const drizzleMysql2Resolved = fileURLToPath(import.meta.resolve("drizzle-orm/mysql2"));
|
|
871
|
-
const pgResolved = fileURLToPath(import.meta.resolve("pg"));
|
|
872
|
-
const mysql2Resolved = fileURLToPath(import.meta.resolve("mysql2"));
|
|
873
|
-
const VIRTUAL_DB_ID = "\0virtual:void-db";
|
|
874
|
-
const VIRTUAL_SCHEMA_DB_ID = "\0virtual:void-db-schema";
|
|
875
|
-
/**
|
|
876
|
-
* Vite plugin for Drizzle integration.
|
|
877
|
-
*
|
|
878
|
-
* - Intercepts `void/db` imports in SSR/worker environments and serves
|
|
879
|
-
* a virtual module that creates a Drizzle DB instance, using the user's
|
|
880
|
-
* schema when present.
|
|
881
|
-
* - Generates `.void/db.d.ts` with proper Drizzle types.
|
|
882
|
-
* - Sets up `@schema` Vite alias for convenient imports when a schema exists.
|
|
883
|
-
* - Updates `.void/tsconfig.json` with TypeScript paths.
|
|
884
|
-
*/
|
|
885
|
-
function drizzlePlugin(root, hasRouteTypes, dialect = "sqlite", options = {}) {
|
|
886
|
-
const outDir = join(root, ".void");
|
|
887
|
-
const paths = readProjectPaths(root);
|
|
888
|
-
const schema = discoverSchema(root, paths);
|
|
889
|
-
const hasDbRuntime = schema != null || options.forceVirtualDb === true;
|
|
890
|
-
const d1BindingName = options.d1BindingName ?? "DB";
|
|
891
|
-
ensureProjectTsconfig(root, hasRouteTypes, hasDbRuntime, schema != null, {
|
|
892
|
-
redirectDbModule: options.redirectDbTypePaths,
|
|
893
|
-
paths
|
|
894
|
-
});
|
|
895
|
-
if (hasDbRuntime) generateDbDts(outDir, schema ?? null, dialect);
|
|
896
|
-
let isBuild = false;
|
|
897
|
-
return {
|
|
898
|
-
name: "void:drizzle",
|
|
899
|
-
enforce: "pre",
|
|
900
|
-
config(_, env) {
|
|
901
|
-
isBuild = env.command === "build";
|
|
902
|
-
if (!schema) return;
|
|
903
|
-
return { resolve: { alias: { "@schema": schema.path } } };
|
|
904
|
-
},
|
|
905
|
-
resolveId: {
|
|
906
|
-
filter: { id: /^(void\/db|@schema|pg$)/ },
|
|
907
|
-
handler(id, importer) {
|
|
908
|
-
if (id === "pg" && isBuild && dialect === "postgresql" && importer === VIRTUAL_DB_ID) return pgResolved;
|
|
909
|
-
if (id === "void/db" && this.environment?.name !== "client") {
|
|
910
|
-
if (!hasDbRuntime) return;
|
|
911
|
-
if (schema && importer) {
|
|
912
|
-
const normalizedImporter = normalizePath(importer);
|
|
913
|
-
const normalizedSchemaPath = normalizePath(schema.path);
|
|
914
|
-
if (schema.type === "file" && normalizedImporter === normalizedSchemaPath) return VIRTUAL_SCHEMA_DB_ID;
|
|
915
|
-
if (schema.type === "directory" && normalizedImporter.startsWith(normalizedSchemaPath)) return VIRTUAL_SCHEMA_DB_ID;
|
|
916
|
-
}
|
|
917
|
-
return VIRTUAL_DB_ID;
|
|
918
|
-
}
|
|
919
|
-
if (schema && (id === "@schema" || id.startsWith("@schema/"))) {
|
|
920
|
-
if (id === "@schema") return schema.path;
|
|
921
|
-
return join(schema.path, id.slice(8));
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
},
|
|
925
|
-
load: {
|
|
926
|
-
filter: { id: /^\0virtual:void-db(?:-schema)?$/ },
|
|
927
|
-
handler(id) {
|
|
928
|
-
if (id === VIRTUAL_SCHEMA_DB_ID) return `
|
|
929
|
-
export { ${DRIZZLE_OPERATORS} } from ${JSON.stringify(drizzleOrmResolved)};
|
|
930
|
-
export const db = {};
|
|
931
|
-
export function createDb() {
|
|
932
|
-
throw new Error("db: createDb() is unavailable when importing void/db from a schema file.");
|
|
933
|
-
}
|
|
934
|
-
`;
|
|
935
|
-
const schemaImport = schema ? `import * as schema from ${JSON.stringify(schema.path)};` : "";
|
|
936
|
-
const drizzleConfig = schema ? dialect === "mysql" ? ", { schema, mode: \"default\" }" : ", { schema }" : "";
|
|
937
|
-
if (dialect === "mysql") return `
|
|
938
|
-
import { drizzle } from ${JSON.stringify(drizzleMysql2Resolved)};
|
|
939
|
-
import { createPool } from ${JSON.stringify(mysql2Resolved)};
|
|
940
|
-
import { getRuntimeBinding, getRuntimeRequestResource } from ${JSON.stringify(envModuleResolved)};
|
|
941
|
-
${schemaImport}
|
|
942
|
-
export { ${DRIZZLE_OPERATORS} } from ${JSON.stringify(drizzleOrmResolved)};
|
|
943
|
-
|
|
944
|
-
const _requestResourceKey = {};
|
|
945
|
-
|
|
946
|
-
function getConnectionString() {
|
|
947
|
-
const url = getRuntimeBinding("DATABASE_URL");
|
|
948
|
-
if (url) return url;
|
|
949
|
-
const hd = getRuntimeBinding("HYPERDRIVE");
|
|
950
|
-
if (hd?.connectionString) return hd.connectionString;
|
|
951
|
-
throw new Error("db: MySQL is not configured. Add DATABASE_URL to .env for local dev, or configure Hyperdrive for production.");
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
function getInstance() {
|
|
955
|
-
return getRuntimeRequestResource(_requestResourceKey, () => {
|
|
956
|
-
const pool = createPool({
|
|
957
|
-
uri: getConnectionString(),
|
|
958
|
-
connectionLimit: 1,
|
|
959
|
-
maxIdle: 1,
|
|
960
|
-
idleTimeout: 1000,
|
|
961
|
-
});
|
|
962
|
-
return drizzle(pool${drizzleConfig});
|
|
963
|
-
});
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
export const db = new Proxy({}, {
|
|
967
|
-
get(_, prop) {
|
|
968
|
-
return Reflect.get(getInstance(), prop);
|
|
969
|
-
},
|
|
970
|
-
});
|
|
971
|
-
|
|
972
|
-
export function createDb(connectionString) {
|
|
973
|
-
return drizzle(connectionString${drizzleConfig});
|
|
974
|
-
}
|
|
975
|
-
`;
|
|
976
|
-
if (dialect === "postgresql") return `
|
|
977
|
-
import { drizzle } from ${JSON.stringify(drizzleNodePgResolved)};
|
|
978
|
-
import pg from "pg";
|
|
979
|
-
import { getRuntimeBinding, getRuntimeRequestResource } from ${JSON.stringify(envModuleResolved)};
|
|
980
|
-
${schemaImport}
|
|
981
|
-
export { ${DRIZZLE_OPERATORS} } from ${JSON.stringify(drizzleOrmResolved)};
|
|
982
|
-
|
|
983
|
-
const _requestResourceKey = {};
|
|
984
|
-
|
|
985
|
-
function getConnectionString() {
|
|
986
|
-
const url = getRuntimeBinding("DATABASE_URL");
|
|
987
|
-
if (url) return url;
|
|
988
|
-
const hd = getRuntimeBinding("HYPERDRIVE");
|
|
989
|
-
if (hd?.connectionString) return hd.connectionString;
|
|
990
|
-
throw new Error("db: PostgreSQL is not configured. Add DATABASE_URL to .env for local dev, or configure Hyperdrive for production.");
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
function getInstance() {
|
|
994
|
-
return getRuntimeRequestResource(_requestResourceKey, () => {
|
|
995
|
-
const pool = new pg.Pool({
|
|
996
|
-
connectionString: getConnectionString(),
|
|
997
|
-
max: 1,
|
|
998
|
-
idleTimeoutMillis: 1000,
|
|
999
|
-
});
|
|
1000
|
-
return drizzle(pool${drizzleConfig});
|
|
1001
|
-
});
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
export const db = new Proxy({}, {
|
|
1005
|
-
get(_, prop) {
|
|
1006
|
-
return Reflect.get(getInstance(), prop);
|
|
1007
|
-
},
|
|
1008
|
-
});
|
|
1009
|
-
|
|
1010
|
-
export function createDb(connectionString) {
|
|
1011
|
-
return drizzle(connectionString${drizzleConfig});
|
|
1012
|
-
}
|
|
1013
|
-
`;
|
|
1014
|
-
return `
|
|
1015
|
-
import { drizzle } from ${JSON.stringify(drizzleD1Resolved)};
|
|
1016
|
-
import { getRuntimeRequestResource, requireRuntimeBinding } from ${JSON.stringify(envModuleResolved)};
|
|
1017
|
-
${schemaImport}
|
|
1018
|
-
export { ${DRIZZLE_OPERATORS} } from ${JSON.stringify(drizzleOrmResolved)};
|
|
1019
|
-
|
|
1020
|
-
const _requestResourceKey = {};
|
|
1021
|
-
|
|
1022
|
-
export const db = new Proxy({}, {
|
|
1023
|
-
get(_, prop) {
|
|
1024
|
-
const instance = getRuntimeRequestResource(
|
|
1025
|
-
_requestResourceKey,
|
|
1026
|
-
() => createDb(requireRuntimeBinding(${JSON.stringify(d1BindingName)})),
|
|
1027
|
-
() => createPrimaryDb(requireRuntimeBinding(${JSON.stringify(d1BindingName)}))
|
|
1028
|
-
);
|
|
1029
|
-
return Reflect.get(instance, prop);
|
|
1030
|
-
},
|
|
1031
|
-
});
|
|
1032
|
-
|
|
1033
|
-
export function createDb(d1) {
|
|
1034
|
-
return drizzle(d1.withSession("first-unconstrained")${drizzleConfig});
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
function createPrimaryDb(d1) {
|
|
1038
|
-
return drizzle(d1.withSession("first-primary")${drizzleConfig});
|
|
1039
|
-
}
|
|
1040
|
-
`;
|
|
1041
|
-
}
|
|
1042
|
-
},
|
|
1043
|
-
async configureServer() {
|
|
1044
|
-
if (!schema) return;
|
|
1045
|
-
const migrationsDir = paths.migrationsDir;
|
|
1046
|
-
if (!(existsSync(migrationsDir) && readdirSync(migrationsDir).some((f) => f.endsWith(".sql")))) {
|
|
1047
|
-
if (dialect === "sqlite") {
|
|
1048
|
-
const { getApplicationTables, getMiniflareDatabasePath } = await import("./runner-B5huK2eC.mjs");
|
|
1049
|
-
if ((await getApplicationTables(getMiniflareDatabasePath(options.localD1PersistRoot ?? join(root, ".void"), options.localD1DatabaseId ?? "local")).catch(() => [])).length > 0) return;
|
|
1050
|
-
}
|
|
1051
|
-
voidWarn(`Schema found but no migrations in ${paths.sourceRelative("db/migrations")}/.\n \`void db push\` syncs the schema to your local DB without creating migration files.
|
|
1052
|
-
Run \`void db generate\` to create migration files for dev startup and deploy.`);
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
};
|
|
1056
|
-
}
|
|
1057
|
-
//#endregion
|
|
1058
879
|
//#region src/plugin-email-dev-inbox.ts
|
|
1059
880
|
const SECURITY_HEADERS = {
|
|
1060
881
|
"Cache-Control": "no-store",
|
|
@@ -2208,6 +2029,17 @@ export const onRequest = defineMiddleware(async (context, next) => {
|
|
|
2208
2029
|
});
|
|
2209
2030
|
`;
|
|
2210
2031
|
}
|
|
2032
|
+
const ASTRO_MIDDLEWARE_CLAIMS = Symbol.for("void.astroDevMiddleware.v1");
|
|
2033
|
+
/**
|
|
2034
|
+
* The dev servers in this process that use the middleware Void wrote, by file path. Astro restarts
|
|
2035
|
+
* the dev server in the same process with a fresh config, so a new plugin instance (from a new
|
|
2036
|
+
* copy of this module, too) is set up before the old server closes. Kept on `globalThis` so both
|
|
2037
|
+
* see the same claim.
|
|
2038
|
+
*/
|
|
2039
|
+
function astroMiddlewareClaims() {
|
|
2040
|
+
const store = globalThis;
|
|
2041
|
+
return store[ASTRO_MIDDLEWARE_CLAIMS] ??= /* @__PURE__ */ new Map();
|
|
2042
|
+
}
|
|
2211
2043
|
/**
|
|
2212
2044
|
* Writes a tiny Astro middleware to the user's project so
|
|
2213
2045
|
* `/__void/scheduled` and `/__void/queue` are intercepted inside Astro's
|
|
@@ -2217,36 +2049,54 @@ export const onRequest = defineMiddleware(async (context, next) => {
|
|
|
2217
2049
|
* already has `src/middleware.ts` we don't overwrite it — instead we log a
|
|
2218
2050
|
* one-shot snippet they can paste into their existing middleware.
|
|
2219
2051
|
*
|
|
2220
|
-
* If we wrote the file we remove it
|
|
2221
|
-
* source tree stays clean. `src/middleware.ts` belongs to the
|
|
2222
|
-
* `.gitignore` line we add for it is removed too; otherwise a
|
|
2223
|
-
* write later would be silently left out of git.
|
|
2052
|
+
* If we wrote the file we remove it when the last dev server using it closes,
|
|
2053
|
+
* so the user's source tree stays clean. `src/middleware.ts` belongs to the
|
|
2054
|
+
* user, so the `.gitignore` line we add for it is removed too; otherwise a
|
|
2055
|
+
* middleware they write later would be silently left out of git.
|
|
2224
2056
|
*/
|
|
2225
2057
|
function astroDevTriggerInjectPlugin(root) {
|
|
2226
2058
|
const middlewarePath = join(root, ASTRO_MIDDLEWARE_RELATIVE);
|
|
2227
2059
|
const middlewareDirIndexPath = join(root, "src", "middleware", "index.ts");
|
|
2228
|
-
|
|
2229
|
-
|
|
2060
|
+
const claims = astroMiddlewareClaims();
|
|
2061
|
+
/** Whether the dev server being set up now holds the middleware Void wrote. */
|
|
2230
2062
|
const ensureFile = () => {
|
|
2063
|
+
const claim = claims.get(middlewarePath);
|
|
2064
|
+
if (claim && existsSync(middlewarePath)) {
|
|
2065
|
+
claim.servers++;
|
|
2066
|
+
return true;
|
|
2067
|
+
}
|
|
2231
2068
|
if (existsSync(middlewarePath) || existsSync(middlewareDirIndexPath)) {
|
|
2232
2069
|
voidWarn("Astro middleware already exists. To enable /__void/scheduled and /__void/queue,\n add the Void dev-trigger middleware to your existing onRequest sequence.\n See https://void.cloud/guide/jobs#local-development.");
|
|
2233
|
-
return;
|
|
2070
|
+
return false;
|
|
2234
2071
|
}
|
|
2235
2072
|
mkdirSync(dirname(middlewarePath), { recursive: true });
|
|
2236
2073
|
writeFileSync(middlewarePath, astroMiddlewareSource(frameworkTriggersDispatchPath(root)));
|
|
2237
|
-
|
|
2074
|
+
if (claim) claim.servers++;
|
|
2075
|
+
else claims.set(middlewarePath, {
|
|
2076
|
+
servers: 1,
|
|
2077
|
+
gitignoreLines: ensureGitignoreLines(root, [ASTRO_MIDDLEWARE_RELATIVE])
|
|
2078
|
+
});
|
|
2079
|
+
return true;
|
|
2238
2080
|
};
|
|
2239
|
-
const
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2081
|
+
const release = () => {
|
|
2082
|
+
const claim = claims.get(middlewarePath);
|
|
2083
|
+
if (!claim || --claim.servers > 0) return;
|
|
2084
|
+
claims.delete(middlewarePath);
|
|
2085
|
+
rmSync(middlewarePath, { force: true });
|
|
2086
|
+
removeGitignoreLines(root, claim.gitignoreLines);
|
|
2243
2087
|
};
|
|
2244
2088
|
return {
|
|
2245
2089
|
name: "void:astro-dev-trigger-inject",
|
|
2246
2090
|
apply: "serve",
|
|
2247
2091
|
configureServer(server) {
|
|
2248
|
-
ensureFile();
|
|
2249
|
-
|
|
2092
|
+
if (!ensureFile()) return;
|
|
2093
|
+
let held = true;
|
|
2094
|
+
const cleanup = () => {
|
|
2095
|
+
if (held) {
|
|
2096
|
+
held = false;
|
|
2097
|
+
release();
|
|
2098
|
+
}
|
|
2099
|
+
};
|
|
2250
2100
|
server.httpServer?.once("close", cleanup);
|
|
2251
2101
|
process.once("exit", cleanup);
|
|
2252
2102
|
}
|
|
@@ -3097,10 +2947,10 @@ export async function fetch(path, options) {
|
|
|
3097
2947
|
* (see `generateClassATriggerWrapper`). Production deploys go through
|
|
3098
2948
|
* `cli/wrapper.ts` instead.
|
|
3099
2949
|
*/
|
|
3100
|
-
function getFrameworkEntry(framework, root, devTriggerToken, notFound) {
|
|
2950
|
+
function getFrameworkEntry(framework, root, devTriggerToken, dialect, notFound) {
|
|
3101
2951
|
const isBuild = isViteBuildOrPreview();
|
|
3102
2952
|
if (!isBuild) writeFrameworkTriggersDispatch(root, devTriggerToken);
|
|
3103
|
-
return generateClassATriggerWrapper(root, framework, getOriginalFrameworkEntry(framework, root), isBuild, void 0, notFound);
|
|
2953
|
+
return generateClassATriggerWrapper(root, framework, getOriginalFrameworkEntry(framework, root), isBuild, dialect, void 0, notFound);
|
|
3104
2954
|
}
|
|
3105
2955
|
/** The framework's own server entry, before our trigger wrapper. */
|
|
3106
2956
|
function getOriginalFrameworkEntry(framework, root) {
|
|
@@ -3117,6 +2967,11 @@ function getOriginalFrameworkEntry(framework, root) {
|
|
|
3117
2967
|
* first, dispatches `/__void/{scheduled,queue}` if it matches, and otherwise
|
|
3118
2968
|
* delegates to the framework's original entry.
|
|
3119
2969
|
*
|
|
2970
|
+
* For PostgreSQL and MySQL, both shapes run the framework inside Void's request scope
|
|
2971
|
+
* (`withRuntimeEnv`), as Void's own handlers do, so void/db keeps one client per request. D1 apps
|
|
2972
|
+
* keep the framework's own fetch: in a request scope, void/db reads D1 through a replica-capable
|
|
2973
|
+
* session instead of the primary.
|
|
2974
|
+
*
|
|
3120
2975
|
* We emit two shapes of the wrapper depending on the Vite command:
|
|
3121
2976
|
*
|
|
3122
2977
|
* - Serve: dispatch is dynamically imported and gets a chance to handle
|
|
@@ -3129,27 +2984,11 @@ function getOriginalFrameworkEntry(framework, root) {
|
|
|
3129
2984
|
* dispatch file (and its transitive user-cron/queue imports + dev token)
|
|
3130
2985
|
* would still ship in the production bundle.
|
|
3131
2986
|
*/
|
|
3132
|
-
function generateClassATriggerWrapper(root, framework, original, isBuild, assetsDir = "assets", notFound) {
|
|
2987
|
+
function generateClassATriggerWrapper(root, framework, original, isBuild, dialect, assetsDir = "assets", notFound) {
|
|
3133
2988
|
const outDir = join(root, ".void");
|
|
3134
2989
|
mkdirSync(outDir, { recursive: true });
|
|
3135
2990
|
const wrapperPath = join(outDir, `${framework}-trigger-wrapper.ts`);
|
|
3136
|
-
const
|
|
3137
|
-
import original from ${JSON.stringify(original)};
|
|
3138
|
-
|
|
3139
|
-
export default {
|
|
3140
|
-
...original,
|
|
3141
|
-
async fetch(request, env, ctx) {
|
|
3142
|
-
return serveWithAssets(request, env, await original.fetch(request, env, ctx));
|
|
3143
|
-
},
|
|
3144
|
-
};
|
|
3145
|
-
${compileAssetFallbackHelper(assetsDir, false, notFound)}
|
|
3146
|
-
` : `// @ts-nocheck — Auto-generated by Void in dev. Do NOT edit.
|
|
3147
|
-
import original from ${JSON.stringify(original)};
|
|
3148
|
-
|
|
3149
|
-
export default {
|
|
3150
|
-
...original,
|
|
3151
|
-
async fetch(request, env, ctx) {
|
|
3152
|
-
if (request.method === "POST") {
|
|
2991
|
+
const fetchBody = isBuild ? ` return serveWithAssets(request, env, await original.fetch(request, env, ctx));` : ` if (request.method === "POST") {
|
|
3153
2992
|
const pathname = new URL(request.url).pathname;
|
|
3154
2993
|
if (pathname === "/__void/scheduled" || pathname === "/__void/queue") {
|
|
3155
2994
|
const { handleDevTrigger } = await import(${JSON.stringify(frameworkTriggersDispatchPath(root))});
|
|
@@ -3157,10 +2996,23 @@ export default {
|
|
|
3157
2996
|
if (response) return response;
|
|
3158
2997
|
}
|
|
3159
2998
|
}
|
|
3160
|
-
return original.fetch(request, env, ctx)
|
|
3161
|
-
|
|
2999
|
+
return original.fetch(request, env, ctx);`;
|
|
3000
|
+
const scoped = dialect !== "sqlite";
|
|
3001
|
+
const fetchMethod = scoped ? ` fetch(request, env, ctx) {
|
|
3002
|
+
return withRuntimeEnv(env, async () => {
|
|
3003
|
+
${fetchBody.replace(/^/gm, " ")}
|
|
3004
|
+
});
|
|
3005
|
+
},` : ` async fetch(request, env, ctx) {
|
|
3006
|
+
${fetchBody}
|
|
3007
|
+
},`;
|
|
3008
|
+
const body = `// @ts-nocheck — Auto-generated by Void ${isBuild ? "for vite build" : "in dev"}. Do NOT edit.
|
|
3009
|
+
import original from ${JSON.stringify(original)};
|
|
3010
|
+
${scoped ? "import { withRuntimeEnv } from \"void/_env\";\n" : ""}
|
|
3011
|
+
export default {
|
|
3012
|
+
...original,
|
|
3013
|
+
${fetchMethod}
|
|
3162
3014
|
};
|
|
3163
|
-
`;
|
|
3015
|
+
${isBuild ? `${compileAssetFallbackHelper(assetsDir, false, notFound)}\n` : ""}`;
|
|
3164
3016
|
writeFileIfChanged(wrapperPath, body);
|
|
3165
3017
|
return wrapperPath;
|
|
3166
3018
|
}
|
|
@@ -3213,10 +3065,207 @@ export default {
|
|
|
3213
3065
|
return entryPath;
|
|
3214
3066
|
}
|
|
3215
3067
|
//#endregion
|
|
3068
|
+
//#region src/installed-packages.ts
|
|
3069
|
+
function readManifest(dir) {
|
|
3070
|
+
try {
|
|
3071
|
+
return JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
3072
|
+
} catch {
|
|
3073
|
+
return;
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
/** The directory Node loads `name` from for code in `fromDir`. Ignores `exports`. */
|
|
3077
|
+
function findInstalledPackage(name, fromDir) {
|
|
3078
|
+
const pnp = module.findPnpApi?.(fromDir);
|
|
3079
|
+
if (pnp) try {
|
|
3080
|
+
const manifest = pnp.resolveToUnqualified(`${name}/package.json`, `${fromDir}/`);
|
|
3081
|
+
return manifest ? dirname(manifest) : void 0;
|
|
3082
|
+
} catch {
|
|
3083
|
+
return;
|
|
3084
|
+
}
|
|
3085
|
+
for (let dir = fromDir;; dir = dirname(dir)) {
|
|
3086
|
+
const candidate = join(dir, "node_modules", name);
|
|
3087
|
+
if (existsSync(join(candidate, "package.json"))) return realpathSync(candidate);
|
|
3088
|
+
if (dirname(dir) === dir) return;
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
function isVoidPackage(name) {
|
|
3092
|
+
return name === "void" || name.startsWith("@void/");
|
|
3093
|
+
}
|
|
3094
|
+
/** The `exports` conditions that an import matches in Vite's SSR graph. */
|
|
3095
|
+
const IMPORT_CONDITIONS = /* @__PURE__ */ new Set([
|
|
3096
|
+
"node",
|
|
3097
|
+
"import",
|
|
3098
|
+
"module",
|
|
3099
|
+
"default"
|
|
3100
|
+
]);
|
|
3101
|
+
/**
|
|
3102
|
+
* Vite's SSR graph also matches `production` or `development`, as NODE_ENV says. Vite sets
|
|
3103
|
+
* NODE_ENV before it runs the plugin hooks that call this.
|
|
3104
|
+
*/
|
|
3105
|
+
function matchesImport(condition) {
|
|
3106
|
+
const mode = process.env.NODE_ENV === "production" ? "production" : "development";
|
|
3107
|
+
return IMPORT_CONDITIONS.has(condition) || condition === mode;
|
|
3108
|
+
}
|
|
3109
|
+
/** The target an import picks from an `exports` value: its first matching key, as in Node. */
|
|
3110
|
+
function importTarget(value) {
|
|
3111
|
+
if (typeof value === "string") return value;
|
|
3112
|
+
if (Array.isArray(value)) {
|
|
3113
|
+
for (const item of value) {
|
|
3114
|
+
const target = importTarget(item);
|
|
3115
|
+
if (target) return target;
|
|
3116
|
+
}
|
|
3117
|
+
return;
|
|
3118
|
+
}
|
|
3119
|
+
if (!value || typeof value !== "object") return;
|
|
3120
|
+
for (const [key, item] of Object.entries(value)) {
|
|
3121
|
+
const target = matchesImport(key) ? importTarget(item) : void 0;
|
|
3122
|
+
if (target) return target;
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
function isFile(path) {
|
|
3126
|
+
try {
|
|
3127
|
+
return statSync(path).isFile();
|
|
3128
|
+
} catch {
|
|
3129
|
+
return false;
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
/** The file an import of the package loads: `exports` ".", then `module`, then `main`. */
|
|
3133
|
+
function findImportEntry(dir, manifest) {
|
|
3134
|
+
const exports = manifest.exports;
|
|
3135
|
+
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");
|
|
3136
|
+
for (const candidate of [
|
|
3137
|
+
entry,
|
|
3138
|
+
`${entry}.js`,
|
|
3139
|
+
`${entry}/index.js`
|
|
3140
|
+
]) {
|
|
3141
|
+
const file = join(dir, candidate);
|
|
3142
|
+
if (isFile(file)) return file;
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
/** Whether Node loads a `.mjs` or `.js` file in the package as an ES module. */
|
|
3146
|
+
function isEsmFile(file, dir, manifest) {
|
|
3147
|
+
if (file.endsWith(".mjs")) return true;
|
|
3148
|
+
if (!file.endsWith(".js")) return false;
|
|
3149
|
+
for (let scope = dirname(file); scope.startsWith(`${dir}/`); scope = dirname(scope)) {
|
|
3150
|
+
const nested = readManifest(scope);
|
|
3151
|
+
if (nested) return nested.type === "module";
|
|
3152
|
+
}
|
|
3153
|
+
return manifest.type === "module";
|
|
3154
|
+
}
|
|
3155
|
+
/** A dynamic `import()` argument that is a single string literal naming a relative file. */
|
|
3156
|
+
const RELATIVE_LITERAL = /^(["'])(\.{1,2}\/[^"']*)\1$/;
|
|
3157
|
+
/** The relative files that a module's imports, re-exports and `import()` calls name. */
|
|
3158
|
+
function relativeImports(code, parsed) {
|
|
3159
|
+
const specifiers = staticModuleReferences(parsed, code).map((reference) => reference.source);
|
|
3160
|
+
for (const { moduleRequest } of parsed.module.dynamicImports) {
|
|
3161
|
+
const literal = RELATIVE_LITERAL.exec(code.slice(moduleRequest.start, moduleRequest.end));
|
|
3162
|
+
if (literal) specifiers.push(literal[2]);
|
|
3163
|
+
}
|
|
3164
|
+
return specifiers.filter((specifier) => /^\.{1,2}\//.test(specifier));
|
|
3165
|
+
}
|
|
3166
|
+
/** The most files of one package that the check reads. A package with more stays with Node. */
|
|
3167
|
+
const MAX_PACKAGE_MODULES = 2e3;
|
|
3168
|
+
/**
|
|
3169
|
+
* Vite's SSR module runner evaluates an inlined package as ES modules. The package's import
|
|
3170
|
+
* entry and every file it reaches through relative imports must be one. So the ES module
|
|
3171
|
+
* wrapper in Node's dual-package guide, or any ES module of the package that imports a
|
|
3172
|
+
* CommonJS file, keeps the package with Node.
|
|
3173
|
+
*/
|
|
3174
|
+
function shipsEsm(packageDir, manifest) {
|
|
3175
|
+
const dir = normalize(packageDir);
|
|
3176
|
+
const entry = findImportEntry(dir, manifest);
|
|
3177
|
+
if (!entry) return false;
|
|
3178
|
+
const files = [entry];
|
|
3179
|
+
const seen = new Set(files);
|
|
3180
|
+
for (const file of files) {
|
|
3181
|
+
if (!isEsmFile(file, dir, manifest)) return false;
|
|
3182
|
+
let code;
|
|
3183
|
+
try {
|
|
3184
|
+
code = readFileSync(file, "utf8");
|
|
3185
|
+
} catch {
|
|
3186
|
+
return false;
|
|
3187
|
+
}
|
|
3188
|
+
const parsed = parseSync(file, code, {
|
|
3189
|
+
lang: "js",
|
|
3190
|
+
sourceType: "module"
|
|
3191
|
+
});
|
|
3192
|
+
if (parsed.errors.length > 0) return false;
|
|
3193
|
+
for (const specifier of relativeImports(code, parsed)) {
|
|
3194
|
+
const next = join(dirname(file), specifier);
|
|
3195
|
+
if (/\.[cm]?js$/.test(next) && !seen.has(next)) {
|
|
3196
|
+
if (seen.size >= MAX_PACKAGE_MODULES) return false;
|
|
3197
|
+
seen.add(next);
|
|
3198
|
+
files.push(next);
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
return true;
|
|
3203
|
+
}
|
|
3204
|
+
/**
|
|
3205
|
+
* Installed ES module packages that list `void` or an `@void/` package as a dependency, among
|
|
3206
|
+
* the app's own dependencies and, through them, the packages they depend on (the rule
|
|
3207
|
+
* vite-plugin-svelte applies to Svelte libraries). Vite leaves a package in node_modules to Node,
|
|
3208
|
+
* whose `void/*` imports then skip Void's plugins: the generated `void/db` and the Node target's
|
|
3209
|
+
* guard. Listing these packages in `ssr.noExternal` keeps them in Vite's graph.
|
|
3210
|
+
*/
|
|
3211
|
+
function findVoidDependentPackages(root) {
|
|
3212
|
+
const app = readManifest(root);
|
|
3213
|
+
if (!app) return [];
|
|
3214
|
+
const found = /* @__PURE__ */ new Set();
|
|
3215
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3216
|
+
const visit = (names, fromDir) => {
|
|
3217
|
+
for (const name of names) {
|
|
3218
|
+
if (isVoidPackage(name)) continue;
|
|
3219
|
+
const dir = findInstalledPackage(name, fromDir);
|
|
3220
|
+
if (!dir || seen.has(dir)) continue;
|
|
3221
|
+
seen.add(dir);
|
|
3222
|
+
const manifest = readManifest(dir);
|
|
3223
|
+
const dependencies = {
|
|
3224
|
+
...manifest?.dependencies,
|
|
3225
|
+
...manifest?.optionalDependencies
|
|
3226
|
+
};
|
|
3227
|
+
if (!manifest || !Object.keys({
|
|
3228
|
+
...dependencies,
|
|
3229
|
+
...manifest.peerDependencies
|
|
3230
|
+
}).some(isVoidPackage) || !shipsEsm(dir, manifest)) continue;
|
|
3231
|
+
found.add(name);
|
|
3232
|
+
visit(Object.keys(dependencies), dir);
|
|
3233
|
+
}
|
|
3234
|
+
};
|
|
3235
|
+
visit(Object.keys({
|
|
3236
|
+
...app.dependencies,
|
|
3237
|
+
...app.devDependencies,
|
|
3238
|
+
...app.optionalDependencies
|
|
3239
|
+
}), root);
|
|
3240
|
+
return [...found].sort();
|
|
3241
|
+
}
|
|
3242
|
+
/** `name` and every package it depends on, as installed for code in `fromDir`. */
|
|
3243
|
+
function findDependencyClosure(name, fromDir) {
|
|
3244
|
+
const found = /* @__PURE__ */ new Set();
|
|
3245
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3246
|
+
const visit = (dependency, from) => {
|
|
3247
|
+
const dir = findInstalledPackage(dependency, from);
|
|
3248
|
+
if (!dir || seen.has(dir)) return;
|
|
3249
|
+
seen.add(dir);
|
|
3250
|
+
found.add(dependency);
|
|
3251
|
+
const manifest = readManifest(dir);
|
|
3252
|
+
for (const next of Object.keys({
|
|
3253
|
+
...manifest?.dependencies,
|
|
3254
|
+
...manifest?.optionalDependencies
|
|
3255
|
+
})) visit(next, dir);
|
|
3256
|
+
};
|
|
3257
|
+
visit(name, fromDir);
|
|
3258
|
+
return [...found].sort();
|
|
3259
|
+
}
|
|
3260
|
+
//#endregion
|
|
3216
3261
|
//#region src/plugin-migration.ts
|
|
3217
3262
|
function readDatabaseUrl(root) {
|
|
3218
3263
|
return loadLocalEnv(root).DATABASE_URL;
|
|
3219
3264
|
}
|
|
3265
|
+
/** DATABASE_URL as Better Auth's local migrations read it: the shell before `.env`. */
|
|
3266
|
+
function readAuthDatabaseUrl(root) {
|
|
3267
|
+
return (process.env.DATABASE_URL ?? readDatabaseUrl(root)) || void 0;
|
|
3268
|
+
}
|
|
3220
3269
|
/**
|
|
3221
3270
|
* Vite plugin that runs local migrations on dev server startup.
|
|
3222
3271
|
* For SQLite/D1: applies migrations to the local miniflare database.
|
|
@@ -3230,33 +3279,53 @@ function migrationPlugin(root, dialect, databaseId = "local", persistRoot = join
|
|
|
3230
3279
|
const migrationsDir = readProjectPaths(root).migrationsDir;
|
|
3231
3280
|
const hasSqlMigrations = existsSync(migrationsDir);
|
|
3232
3281
|
if (!hasSqlMigrations && !auth?.enabled) return;
|
|
3282
|
+
const migrateAuth = async (databaseUrl) => {
|
|
3283
|
+
const { runLocalVoidAuthMigrations } = await import("./node-cPadMgUO.mjs");
|
|
3284
|
+
await runLocalVoidAuthMigrations(root, dialect, persistRoot, databaseId, auth?.configPath, databaseUrl);
|
|
3285
|
+
};
|
|
3286
|
+
const mysqlAuth = dialect === "mysql" && auth?.enabled === true;
|
|
3287
|
+
const logApplied = (applied) => {
|
|
3288
|
+
if (applied.length > 0) voidLog(`Applied ${applied.length} migration(s): ${applied.join(", ")}`);
|
|
3289
|
+
};
|
|
3233
3290
|
try {
|
|
3234
|
-
if (
|
|
3235
|
-
const
|
|
3236
|
-
|
|
3291
|
+
if (dialect !== "sqlite") {
|
|
3292
|
+
const { collectMigrations } = await import("./collect-Cae8A7Zr.mjs");
|
|
3293
|
+
const allMigrations = collectMigrations(migrationsDir);
|
|
3294
|
+
const runFiles = dialect === "mysql" ? allMigrations.length > 0 : hasSqlMigrations;
|
|
3295
|
+
const url = runFiles ? readDatabaseUrl(root) : void 0;
|
|
3296
|
+
const authUrl = mysqlAuth ? readAuthDatabaseUrl(root) : void 0;
|
|
3297
|
+
if (runFiles && !url || mysqlAuth && !authUrl) {
|
|
3237
3298
|
afterServerReady(server, () => {
|
|
3238
3299
|
console.log();
|
|
3239
3300
|
voidError(`DATABASE_URL not found in .env — skipping ${dialect === "mysql" ? "MySQL" : "PostgreSQL"} migrations.`);
|
|
3240
3301
|
});
|
|
3241
3302
|
return;
|
|
3242
3303
|
}
|
|
3243
|
-
const
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3304
|
+
const authWithFiles = authUrl !== void 0 && authUrl === url;
|
|
3305
|
+
if (url) {
|
|
3306
|
+
const { validateMigrations } = await import("./validate-BQFdf0Pi.mjs");
|
|
3307
|
+
const appliedNames = dialect === "mysql" ? await import("./runner-mysql-DWwE8jKi.mjs").then((runner) => runner.getMySqlAppliedMigrations(url)) : await import("./runner-pg-_Xncr3H5.mjs").then((runner) => runner.getPgAppliedMigrations(url));
|
|
3308
|
+
const appliedSet = new Set(appliedNames);
|
|
3309
|
+
const pending = allMigrations.filter((migration) => !appliedSet.has(migration.name));
|
|
3310
|
+
if (pending.length > 0) try {
|
|
3311
|
+
validateMigrations(pending);
|
|
3312
|
+
} catch (err) {
|
|
3313
|
+
voidWarn(err instanceof Error ? err.message : String(err));
|
|
3314
|
+
}
|
|
3315
|
+
const applied = dialect === "mysql" ? await import("./runner-mysql-DWwE8jKi.mjs").then((runner) => runner.runMySqlMigrations(migrationsDir, url, authWithFiles ? async (names) => {
|
|
3316
|
+
logApplied(names);
|
|
3317
|
+
await migrateAuth(url);
|
|
3318
|
+
} : void 0)) : await import("./runner-pg-_Xncr3H5.mjs").then((runner) => runner.runPgMigrations(migrationsDir, url));
|
|
3319
|
+
if (!authWithFiles) logApplied(applied);
|
|
3320
|
+
}
|
|
3321
|
+
if (authUrl && !authWithFiles) {
|
|
3322
|
+
const { withMySqlMigrationLockAt } = await import("./runner-mysql-DWwE8jKi.mjs");
|
|
3323
|
+
await withMySqlMigrationLockAt(authUrl, () => migrateAuth(authUrl));
|
|
3253
3324
|
}
|
|
3254
|
-
const applied = dialect === "mysql" ? await import("./runner-mysql-CaJq-hd6.mjs").then((runner) => runner.runMySqlMigrations(migrationsDir, url)) : await import("./runner-pg-BJhFZZG4.mjs").then((runner) => runner.runPgMigrations(migrationsDir, url));
|
|
3255
|
-
if (applied.length > 0) voidLog(`Applied ${applied.length} migration(s): ${applied.join(", ")}`);
|
|
3256
3325
|
} else if (hasSqlMigrations) {
|
|
3257
|
-
const { runMigrations, getMiniflareDatabasePath, getAppliedMigrations } = await import("./runner-
|
|
3258
|
-
const { collectMigrations } = await import("./collect-
|
|
3259
|
-
const { validateMigrations } = await import("./validate-
|
|
3326
|
+
const { runMigrations, getMiniflareDatabasePath, getAppliedMigrations } = await import("./runner-So9mYfcm.mjs");
|
|
3327
|
+
const { collectMigrations } = await import("./collect-Cae8A7Zr.mjs");
|
|
3328
|
+
const { validateMigrations } = await import("./validate-BQFdf0Pi.mjs");
|
|
3260
3329
|
const dbPath = getMiniflareDatabasePath(persistRoot, databaseId);
|
|
3261
3330
|
const allMigrations = collectMigrations(migrationsDir);
|
|
3262
3331
|
const appliedRows = await getAppliedMigrations(dbPath);
|
|
@@ -3271,8 +3340,7 @@ function migrationPlugin(root, dialect, databaseId = "local", persistRoot = join
|
|
|
3271
3340
|
if (applied.length > 0) voidLog(`Applied ${applied.length} migration(s): ${applied.join(", ")}`);
|
|
3272
3341
|
}
|
|
3273
3342
|
if (auth?.enabled) {
|
|
3274
|
-
|
|
3275
|
-
await runLocalVoidAuthMigrations(root, dialect, persistRoot, databaseId, auth.configPath);
|
|
3343
|
+
if (!mysqlAuth) await migrateAuth();
|
|
3276
3344
|
voidLog("Applied Better Auth migrations");
|
|
3277
3345
|
}
|
|
3278
3346
|
} catch (err) {
|
|
@@ -3309,6 +3377,26 @@ function createCloudflareBuiltinsExternalPlugin() {
|
|
|
3309
3377
|
}
|
|
3310
3378
|
};
|
|
3311
3379
|
}
|
|
3380
|
+
/**
|
|
3381
|
+
* Send a bare `void` import in server code to the handler helpers (`defineScheduled`,
|
|
3382
|
+
* `defineQueue`, ...), as Void apps and the cron/queue deploy bundles do. The package entry is the
|
|
3383
|
+
* Vite plugin: loaded in a worker environment, it pulls Wrangler into the dependency optimizer.
|
|
3384
|
+
*/
|
|
3385
|
+
function createBareVoidRedirectPlugin() {
|
|
3386
|
+
let handlerFile;
|
|
3387
|
+
return {
|
|
3388
|
+
name: "void:bare-void-redirect",
|
|
3389
|
+
resolveId: {
|
|
3390
|
+
order: "pre",
|
|
3391
|
+
filter: { id: /^void$/ },
|
|
3392
|
+
handler() {
|
|
3393
|
+
if (this.environment?.config.consumer === "client") return;
|
|
3394
|
+
handlerFile ??= fileURLToPath(import.meta.resolve("#self/handler"));
|
|
3395
|
+
return handlerFile;
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
};
|
|
3399
|
+
}
|
|
3312
3400
|
function createDefaultWorkerEnvironmentPlugin() {
|
|
3313
3401
|
return {
|
|
3314
3402
|
name: "void:default-worker-environment",
|
|
@@ -3369,16 +3457,58 @@ function createWranglerCompatPersistPlugin(root, config) {
|
|
|
3369
3457
|
}
|
|
3370
3458
|
};
|
|
3371
3459
|
}
|
|
3372
|
-
|
|
3460
|
+
const DATABASE_DRIVER_DEPS = {
|
|
3461
|
+
sqlite: [],
|
|
3462
|
+
postgresql: ["void > pg"],
|
|
3463
|
+
mysql: ["void > mysql2"]
|
|
3464
|
+
};
|
|
3465
|
+
const NODE_BUILTIN = new RegExp(`^(?:node:)?(?:${builtinModules.join("|")})$`);
|
|
3466
|
+
const NODE_BUILTIN_REQUIRE_PREFIX = "\0void:node-require:";
|
|
3467
|
+
/**
|
|
3468
|
+
* The Node built-ins that workerd provides for the given compatibility settings, from the preset
|
|
3469
|
+
* the Cloudflare plugin builds Workers with (a dependency of `@cloudflare/vite-plugin`). Before
|
|
3470
|
+
* 2025-09-15 the preset fills in parts of `node:process` instead of listing it, but workerd
|
|
3471
|
+
* provides that module at every date.
|
|
3472
|
+
*/
|
|
3473
|
+
async function readWorkerdNodeBuiltins(compat) {
|
|
3474
|
+
const vitePlugin = fileURLToPath(import.meta.resolve("@cloudflare/vite-plugin"));
|
|
3475
|
+
const manifestPath = createRequire(vitePlugin).resolve("@cloudflare/unenv-preset/package.json");
|
|
3476
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
3477
|
+
const { getCloudflarePreset } = await import(pathToFileURL(join(dirname(manifestPath), manifest.exports["."].import)).href);
|
|
3478
|
+
const { external } = getCloudflarePreset({
|
|
3479
|
+
compatibilityDate: compat.compatibilityDate,
|
|
3480
|
+
compatibilityFlags: compat.compatibilityFlags ?? []
|
|
3481
|
+
});
|
|
3482
|
+
return /* @__PURE__ */ new Set([...external.map((name) => name.replace(/^node:/, "")), "process"]);
|
|
3483
|
+
}
|
|
3484
|
+
function createServerRuntimeOptimizerPlugin(dialect, readCompat) {
|
|
3485
|
+
let workerdNodeBuiltins;
|
|
3373
3486
|
return {
|
|
3374
3487
|
name: "void:server-runtime-optimizer",
|
|
3375
|
-
configEnvironment(name) {
|
|
3488
|
+
configEnvironment(name, environment) {
|
|
3376
3489
|
if (name === "client") return;
|
|
3377
|
-
if (!
|
|
3490
|
+
if (!environment.resolve?.conditions?.includes("workerd")) return { optimizeDeps: { exclude: ["void"] } };
|
|
3378
3491
|
return { optimizeDeps: {
|
|
3379
3492
|
exclude: ["void"],
|
|
3380
|
-
include: ["void > email-validator"]
|
|
3493
|
+
include: ["void > email-validator", ...DATABASE_DRIVER_DEPS[dialect]]
|
|
3381
3494
|
} };
|
|
3495
|
+
},
|
|
3496
|
+
resolveId: {
|
|
3497
|
+
order: "pre",
|
|
3498
|
+
filter: { id: NODE_BUILTIN },
|
|
3499
|
+
async handler(id, _importer, options) {
|
|
3500
|
+
if (dialect === "sqlite" || options.kind !== "require-call" || this.environment?.mode !== "build" || !this.environment.config.resolve.conditions.includes("workerd")) return;
|
|
3501
|
+
const name = id.replace(/^node:/, "");
|
|
3502
|
+
workerdNodeBuiltins ??= readWorkerdNodeBuiltins(readCompat());
|
|
3503
|
+
if (!(await workerdNodeBuiltins).has(name)) return;
|
|
3504
|
+
return `${NODE_BUILTIN_REQUIRE_PREFIX}${name}`;
|
|
3505
|
+
}
|
|
3506
|
+
},
|
|
3507
|
+
load: {
|
|
3508
|
+
filter: { id: /^\0void:node-require:/ },
|
|
3509
|
+
handler(id) {
|
|
3510
|
+
return `import builtin from "node:${id.slice(19)}";\nexport { builtin as "module.exports" };\n`;
|
|
3511
|
+
}
|
|
3382
3512
|
}
|
|
3383
3513
|
};
|
|
3384
3514
|
}
|
|
@@ -3386,6 +3516,17 @@ function createServerRuntimeOptimizerPlugin(voidOwnsWorkerRuntime) {
|
|
|
3386
3516
|
//#region src/sveltekit-hooks-transform.ts
|
|
3387
3517
|
/** Add Void's dev bindings to SvelteKit's generated get_hooks function. */
|
|
3388
3518
|
function injectSvelteKitHooks(code, id, dispatchPath) {
|
|
3519
|
+
return editGetHooks(code, id, `\n const { withRuntimeEnv } = await import("void/_env");\n const { handleDevTrigger } = await import(${JSON.stringify(dispatchPath)});`, "const __origHandle = handle ?? (({ event, resolve }) => resolve(event));\n handle = async ({ event, resolve }) => {\n const __voidEnv = event.platform?.env ?? (await import('cloudflare:workers')).env;\n return withRuntimeEnv(__voidEnv, async () => {\n const __triggerResp = await handleDevTrigger(event.request, __voidEnv, undefined);\n if (__triggerResp) return __triggerResp;\n return __origHandle({ event, resolve });\n });\n };\n ");
|
|
3520
|
+
}
|
|
3521
|
+
/**
|
|
3522
|
+
* Run each request of a SvelteKit build in Void's request scope. `envModule` is the env module
|
|
3523
|
+
* void/db imports. Kit prerenders in Node, where `cloudflare:workers` does not load and Kit 3
|
|
3524
|
+
* passes no platform, so those requests run outside the scope.
|
|
3525
|
+
*/
|
|
3526
|
+
function injectSvelteKitBuildHooks(code, id, envModule) {
|
|
3527
|
+
return editGetHooks(code, id, `\n const { withRuntimeEnv } = await import(${JSON.stringify(envModule)});`, "const __origHandle = handle ?? (({ event, resolve }) => resolve(event));\n handle = async ({ event, resolve }) => {\n const __voidEnv = event.platform?.env ??\n (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers'\n ? (await import('cloudflare:workers')).env\n : undefined);\n return withRuntimeEnv(__voidEnv, () => __origHandle({ event, resolve }));\n };\n ");
|
|
3528
|
+
}
|
|
3529
|
+
function editGetHooks(code, id, prologue, handleWrapper) {
|
|
3389
3530
|
if (!code.includes("get_hooks")) return;
|
|
3390
3531
|
const hooks = (parseSync(id, code).program.body ?? []).filter((node) => node.type === "ExportNamedDeclaration").map((node) => node.declaration).filter((node) => {
|
|
3391
3532
|
const name = node?.id;
|
|
@@ -3396,8 +3537,8 @@ function injectSvelteKitHooks(code, id, dispatchPath) {
|
|
|
3396
3537
|
const returns = (body?.body)?.filter((node) => node.type === "ReturnStatement" && node.argument?.type === "ObjectExpression") ?? [];
|
|
3397
3538
|
if (body?.type !== "BlockStatement" || body.start === void 0 || returns.length !== 1 || returns[0]?.start === void 0) throw new Error("sveltekit: Expected one object return in generated get_hooks.");
|
|
3398
3539
|
const ms = new MagicString(code);
|
|
3399
|
-
ms.appendLeft(body.start + 1,
|
|
3400
|
-
ms.appendLeft(returns[0].start,
|
|
3540
|
+
ms.appendLeft(body.start + 1, prologue);
|
|
3541
|
+
ms.appendLeft(returns[0].start, handleWrapper);
|
|
3401
3542
|
return {
|
|
3402
3543
|
code: ms.toString(),
|
|
3403
3544
|
map: ms.generateMap({ hires: true })
|
|
@@ -3405,6 +3546,11 @@ function injectSvelteKitHooks(code, id, dispatchPath) {
|
|
|
3405
3546
|
}
|
|
3406
3547
|
//#endregion
|
|
3407
3548
|
//#region src/plugin-framework.ts
|
|
3549
|
+
const handlerFile = fileURLToPath(import.meta.resolve("#self/handler"));
|
|
3550
|
+
const envModuleFile = fileURLToPath(import.meta.resolve("#self/_env"));
|
|
3551
|
+
const voidDir = dirname(fileURLToPath(import.meta.url));
|
|
3552
|
+
const ASTRO_SERVER_ENTRY = "@astrojs/cloudflare/entrypoints/server";
|
|
3553
|
+
const ASTRO_SCOPED_SERVER_ENTRY = "\0void:astro-server-entry";
|
|
3408
3554
|
function createFrameworkPlugins(input) {
|
|
3409
3555
|
const { localD1, root, directCloudflareDestination, bindings, config, dialect, application, bindingNames, websocketRoutes, liveConfig, detected, clientStubsPlugin, serverRuntimeOptimizerPlugin, devTriggerToken, implicitDeployGuard } = input;
|
|
3410
3556
|
const frameworkPersistRoot = localD1.persistRoot;
|
|
@@ -3415,7 +3561,6 @@ function createFrameworkPlugins(input) {
|
|
|
3415
3561
|
name: "void:wrangler-compat",
|
|
3416
3562
|
enforce: "pre",
|
|
3417
3563
|
config(_, env) {
|
|
3418
|
-
if (env.command === "serve" && directCloudflareDestination && bindings.needsAI) process.env.CLOUDFLARE_AUTH_USE_KEYRING = "true";
|
|
3419
3564
|
syncFrameworkCompat(ensureWranglerCompat(root, config));
|
|
3420
3565
|
if (env.command !== "serve") return;
|
|
3421
3566
|
if (ensureWranglerNodejsAlsFlag(root)) voidLog("Synced nodejs_als to Cloudflare config");
|
|
@@ -3468,19 +3613,90 @@ function createFrameworkPlugins(input) {
|
|
|
3468
3613
|
const svelteKitHooksInjectPlugin = {
|
|
3469
3614
|
name: "void:sveltekit-hooks-inject",
|
|
3470
3615
|
apply: "serve",
|
|
3616
|
+
config() {
|
|
3617
|
+
if (detected.class !== "b") return;
|
|
3618
|
+
return { ssr: { noExternal: ["void", ...dialect === "sqlite" ? [] : findVoidDependentPackages(root)] } };
|
|
3619
|
+
},
|
|
3620
|
+
resolveId: {
|
|
3621
|
+
order: "pre",
|
|
3622
|
+
filter: { id: /^void$/ },
|
|
3623
|
+
handler() {
|
|
3624
|
+
if (detected.class !== "b" || this.environment?.name === "client") return;
|
|
3625
|
+
return handlerFile;
|
|
3626
|
+
}
|
|
3627
|
+
},
|
|
3471
3628
|
transform(code, id) {
|
|
3472
3629
|
if (detected.class !== "b") return;
|
|
3473
3630
|
if (!id.includes(".svelte-kit/generated/server/internal") && !id.includes(".svelte-kit/generated/dev/server.js")) return;
|
|
3474
3631
|
return injectSvelteKitHooks(code, id, frameworkTriggersDispatchPath(root));
|
|
3475
3632
|
}
|
|
3476
3633
|
};
|
|
3634
|
+
const astroRequestScopePlugin = detected.name === "astro" && dialect !== "sqlite" ? {
|
|
3635
|
+
name: "void:astro-request-scope",
|
|
3636
|
+
enforce: "pre",
|
|
3637
|
+
resolveId: {
|
|
3638
|
+
filter: { id: /^@astrojs\/cloudflare\/entrypoints\/server(?:\.js)?$/ },
|
|
3639
|
+
handler(_id, importer) {
|
|
3640
|
+
if (importer === ASTRO_SCOPED_SERVER_ENTRY || this.environment?.name === "client") return;
|
|
3641
|
+
return ASTRO_SCOPED_SERVER_ENTRY;
|
|
3642
|
+
}
|
|
3643
|
+
},
|
|
3644
|
+
load: {
|
|
3645
|
+
filter: { id: /^\0void:astro-server-entry$/ },
|
|
3646
|
+
handler() {
|
|
3647
|
+
return `import original from ${JSON.stringify(ASTRO_SERVER_ENTRY)};
|
|
3648
|
+
import { withRuntimeEnv } from ${JSON.stringify(envModuleFile)};
|
|
3649
|
+
export * from ${JSON.stringify(ASTRO_SERVER_ENTRY)};
|
|
3650
|
+
|
|
3651
|
+
export default {
|
|
3652
|
+
...original,
|
|
3653
|
+
fetch(request, env, ctx) {
|
|
3654
|
+
return withRuntimeEnv(env, () => original.fetch(request, env, ctx));
|
|
3655
|
+
},
|
|
3656
|
+
};
|
|
3657
|
+
`;
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
} : void 0;
|
|
3661
|
+
const svelteKitWorkerBuildPlugin = detected.class === "b" && dialect !== "sqlite" ? {
|
|
3662
|
+
name: "void:sveltekit-worker-build",
|
|
3663
|
+
apply: "build",
|
|
3664
|
+
enforce: "pre",
|
|
3665
|
+
configEnvironment(name, environment) {
|
|
3666
|
+
if (name !== "ssr") return;
|
|
3667
|
+
return {
|
|
3668
|
+
resolve: {
|
|
3669
|
+
conditions: environment.resolve?.conditions ? ["workerd", "worker"] : [
|
|
3670
|
+
"workerd",
|
|
3671
|
+
"worker",
|
|
3672
|
+
...defaultServerConditions
|
|
3673
|
+
],
|
|
3674
|
+
noExternal: [
|
|
3675
|
+
"void",
|
|
3676
|
+
"drizzle-orm",
|
|
3677
|
+
dialect === "mysql" ? "mysql2" : "pg",
|
|
3678
|
+
...findDependencyClosure("drizzle-orm", voidDir),
|
|
3679
|
+
...findDependencyClosure(dialect === "mysql" ? "mysql2" : "pg", voidDir),
|
|
3680
|
+
...findVoidDependentPackages(root)
|
|
3681
|
+
]
|
|
3682
|
+
},
|
|
3683
|
+
build: { rolldownOptions: { platform: "neutral" } }
|
|
3684
|
+
};
|
|
3685
|
+
},
|
|
3686
|
+
transform(code, id) {
|
|
3687
|
+
if (!id.includes(".svelte-kit/generated/server/internal") && !id.includes(".svelte-kit/generated/build/server.js")) return;
|
|
3688
|
+
return injectSvelteKitBuildHooks(code, id, envModuleFile);
|
|
3689
|
+
}
|
|
3690
|
+
} : void 0;
|
|
3477
3691
|
return [
|
|
3478
3692
|
devTriggerSecretGuardPlugin(),
|
|
3479
3693
|
createCloudflareBuiltinsExternalPlugin(),
|
|
3480
3694
|
wranglerCompatPlugin,
|
|
3481
3695
|
wranglerSyncPlugin,
|
|
3482
3696
|
...nuxtVite8WebSocketCompatPlugin ? [nuxtVite8WebSocketCompatPlugin] : [],
|
|
3697
|
+
...astroRequestScopePlugin ? [astroRequestScopePlugin] : [],
|
|
3483
3698
|
svelteKitHooksInjectPlugin,
|
|
3699
|
+
...svelteKitWorkerBuildPlugin ? [svelteKitWorkerBuildPlugin] : [],
|
|
3484
3700
|
clientStubsPlugin,
|
|
3485
3701
|
serverRuntimeOptimizerPlugin,
|
|
3486
3702
|
bindingRuntimePlugin(bindingNames),
|
|
@@ -3491,14 +3707,15 @@ function createFrameworkPlugins(input) {
|
|
|
3491
3707
|
d1BindingName: bindingNames?.d1,
|
|
3492
3708
|
forceVirtualDb: bindingNames?.d1 !== void 0,
|
|
3493
3709
|
localD1DatabaseId: localD1.databaseId,
|
|
3494
|
-
localD1PersistRoot: frameworkPersistRoot
|
|
3710
|
+
localD1PersistRoot: frameworkPersistRoot,
|
|
3711
|
+
nitroBundlesServer: detected.name === "nuxt" || detected.name === "analog"
|
|
3495
3712
|
}),
|
|
3496
3713
|
migrationPlugin(root, dialect, localD1.databaseId, frameworkPersistRoot, { enabled: false }),
|
|
3497
3714
|
devTriggersHintPlugin(root, devTriggerToken),
|
|
3498
3715
|
frameworkTriggersPlugin(root, { devTriggerToken }),
|
|
3499
3716
|
...detected.name === "nuxt" ? [nitroDevTriggerInjectPlugin(root, { serverDir: "server" })] : [],
|
|
3500
3717
|
...detected.name === "analog" ? [analogDevTriggerInjectPlugin(root)] : [],
|
|
3501
|
-
...detected.name === "astro" ? [astroDevTriggerInjectPlugin(root)] : [],
|
|
3718
|
+
...detected.name === "astro" ? [createBareVoidRedirectPlugin(), astroDevTriggerInjectPlugin(root)] : [],
|
|
3502
3719
|
implicitDeployGuard
|
|
3503
3720
|
];
|
|
3504
3721
|
}
|
|
@@ -3571,13 +3788,17 @@ function honoMiddleware(getApp) {
|
|
|
3571
3788
|
* single SSR build for API-only apps
|
|
3572
3789
|
*/
|
|
3573
3790
|
function nodeTargetPlugin(target) {
|
|
3791
|
+
const unavailable = (id, root, importer) => {
|
|
3792
|
+
const source = importer ? ` Imported by ${relative(root, importer)}.` : "";
|
|
3793
|
+
return /* @__PURE__ */ new Error(`target: '${id}' is not available with target '${target}'. CF bindings require target: "cloudflare".${source}`);
|
|
3794
|
+
};
|
|
3574
3795
|
return [{
|
|
3575
3796
|
name: "void:node-target",
|
|
3576
3797
|
enforce: "pre",
|
|
3577
3798
|
resolveId: {
|
|
3578
3799
|
filter: { id: CF_ONLY_REGEX },
|
|
3579
|
-
handler(id) {
|
|
3580
|
-
throw
|
|
3800
|
+
handler(id, importer) {
|
|
3801
|
+
throw unavailable(id, this.environment.config.root, importer);
|
|
3581
3802
|
}
|
|
3582
3803
|
},
|
|
3583
3804
|
renderChunk(code, chunk) {
|
|
@@ -3589,8 +3810,13 @@ function nodeTargetPlugin(target) {
|
|
|
3589
3810
|
};
|
|
3590
3811
|
},
|
|
3591
3812
|
config(_, { command }) {
|
|
3592
|
-
if (command !== "build") return;
|
|
3593
3813
|
const root = process.cwd();
|
|
3814
|
+
const ssr = { noExternal: [
|
|
3815
|
+
"void",
|
|
3816
|
+
/^@void\//,
|
|
3817
|
+
...findVoidDependentPackages(root)
|
|
3818
|
+
] };
|
|
3819
|
+
if (command !== "build") return { ssr };
|
|
3594
3820
|
const voidDir = join(root, ".void");
|
|
3595
3821
|
const ssrBuildOptions = {
|
|
3596
3822
|
outDir: "dist/ssr",
|
|
@@ -3607,18 +3833,22 @@ function nodeTargetPlugin(target) {
|
|
|
3607
3833
|
}
|
|
3608
3834
|
};
|
|
3609
3835
|
if (existsSync(readProjectPaths(root).pagesDir)) return {
|
|
3836
|
+
ssr,
|
|
3610
3837
|
build: { outDir: "dist/client" },
|
|
3611
3838
|
environments: { ssr: { build: ssrBuildOptions } },
|
|
3612
3839
|
builder: {}
|
|
3613
3840
|
};
|
|
3614
|
-
return {
|
|
3615
|
-
ssr
|
|
3616
|
-
|
|
3617
|
-
|
|
3841
|
+
return {
|
|
3842
|
+
ssr,
|
|
3843
|
+
build: {
|
|
3844
|
+
ssr: true,
|
|
3845
|
+
...ssrBuildOptions
|
|
3846
|
+
}
|
|
3847
|
+
};
|
|
3618
3848
|
},
|
|
3619
3849
|
async buildApp(builder) {
|
|
3620
3850
|
await builder.build(builder.environments.ssr);
|
|
3621
|
-
await builder.build(builder.environments.client);
|
|
3851
|
+
if (builder.environments.client) await builder.build(builder.environments.client);
|
|
3622
3852
|
},
|
|
3623
3853
|
configureServer(server) {
|
|
3624
3854
|
server.middlewares.use(honoMiddleware(async () => {
|
|
@@ -3636,6 +3866,20 @@ function nodeTargetPlugin(target) {
|
|
|
3636
3866
|
return appPromise;
|
|
3637
3867
|
}));
|
|
3638
3868
|
}
|
|
3869
|
+
}, {
|
|
3870
|
+
name: "void:node-target-cloudflare-modules",
|
|
3871
|
+
apply: "build",
|
|
3872
|
+
enforce: "pre",
|
|
3873
|
+
resolveId: {
|
|
3874
|
+
filter: { id: /^cloudflare:/ },
|
|
3875
|
+
handler(id, importer, options) {
|
|
3876
|
+
if (options.kind === "dynamic-import") return {
|
|
3877
|
+
id,
|
|
3878
|
+
external: true
|
|
3879
|
+
};
|
|
3880
|
+
throw unavailable(id, this.environment.config.root, importer);
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3639
3883
|
}];
|
|
3640
3884
|
}
|
|
3641
3885
|
//#endregion
|
|
@@ -4212,8 +4456,8 @@ function routingPlugin(root, options) {
|
|
|
4212
4456
|
if (!options.target) {
|
|
4213
4457
|
const migrationsDir = paths.migrationsDir;
|
|
4214
4458
|
if (existsSync(migrationsDir) || compileOptions.auth) {
|
|
4215
|
-
const { collectMigrations } = await import("./collect-
|
|
4216
|
-
const { buildMigrationPlanBundle } = await import("./plan-
|
|
4459
|
+
const { collectMigrations } = await import("./collect-Cae8A7Zr.mjs");
|
|
4460
|
+
const { buildMigrationPlanBundle } = await import("./plan-CKX_jWnD.mjs");
|
|
4217
4461
|
const migrations = existsSync(migrationsDir) ? collectMigrations(migrationsDir) : [];
|
|
4218
4462
|
const dialect = getDatabaseDialect(readConfig(root));
|
|
4219
4463
|
compileOptions.migrationHandlerPath = resolveFile(dialect === "postgresql" ? "#self/runtime/migration-handler-pg" : dialect === "mysql" ? "#self/runtime/migration-handler-mysql" : "#self/runtime/migration-handler");
|
|
@@ -4631,25 +4875,28 @@ const scheduledPreviewPointerCleanups = /* @__PURE__ */ new Set();
|
|
|
4631
4875
|
function voidPlugin(options) {
|
|
4632
4876
|
const root = process.cwd();
|
|
4633
4877
|
const directCloudflareDestination = readDeploymentPlatform(root) === "cloudflare";
|
|
4878
|
+
if (directCloudflareDestination) selectVoidCloudflareLogin();
|
|
4634
4879
|
warnIfPackageJsonIsNotEsm(root);
|
|
4635
4880
|
const devTriggerToken = isViteBuildOrPreview() ? crypto.randomUUID() : getOrCreateDevTriggerToken(root);
|
|
4636
4881
|
const config = readConfig(root);
|
|
4637
4882
|
const projectCloudflareConfigPath = !isNodeTarget(config.target) ? materializeCloudflareConfig(root) : void 0;
|
|
4638
4883
|
const cloudflareConfigPath = projectCloudflareConfigPath && existsSync(projectCloudflareConfigPath) ? projectCloudflareConfigPath : void 0;
|
|
4639
4884
|
let previewing = false;
|
|
4885
|
+
const restorePreviewPointer = () => {
|
|
4886
|
+
if (!existsSync(join(root, "void.config.ts"))) return;
|
|
4887
|
+
if (restoreCloudflarePreviewPointer(root) && !scheduledPreviewPointerCleanups.has(root)) {
|
|
4888
|
+
scheduledPreviewPointerCleanups.add(root);
|
|
4889
|
+
process.once("exit", () => {
|
|
4890
|
+
rmSync(join(root, ".wrangler", "deploy", "config.json"), { force: true });
|
|
4891
|
+
});
|
|
4892
|
+
}
|
|
4893
|
+
};
|
|
4640
4894
|
const implicitDeployGuard = {
|
|
4641
4895
|
name: "void:remove-implicit-cloudflare-deploy-pointer",
|
|
4642
4896
|
enforce: "pre",
|
|
4643
4897
|
config(_config, environment) {
|
|
4644
4898
|
previewing = environment.isPreview === true;
|
|
4645
|
-
if (previewing
|
|
4646
|
-
if (restoreCloudflarePreviewPointer(root) && !scheduledPreviewPointerCleanups.has(root)) {
|
|
4647
|
-
scheduledPreviewPointerCleanups.add(root);
|
|
4648
|
-
process.once("exit", () => {
|
|
4649
|
-
rmSync(join(root, ".wrangler", "deploy", "config.json"), { force: true });
|
|
4650
|
-
});
|
|
4651
|
-
}
|
|
4652
|
-
}
|
|
4899
|
+
if (previewing) restorePreviewPointer();
|
|
4653
4900
|
},
|
|
4654
4901
|
closeBundle() {
|
|
4655
4902
|
if (!previewing && existsSync(join(root, "void.config.ts")) && process.env["VOID_CLOUDFLARE_DEPLOY_BUILD"] !== "1") {
|
|
@@ -4682,6 +4929,7 @@ function voidPlugin(options) {
|
|
|
4682
4929
|
assertNoRootSourceConventionConflicts(paths);
|
|
4683
4930
|
const detected = application.framework;
|
|
4684
4931
|
const framework = detected?.class === "a" ? detected.name : void 0;
|
|
4932
|
+
if (detected?.name === "astro" && process.argv[2] === "preview") restorePreviewPointer();
|
|
4685
4933
|
const scanDirs = config.inference?.scanDirs ?? (detected ? FRAMEWORK_SCAN_DIRS : void 0);
|
|
4686
4934
|
const frameworkOwnsCloudflareRuntime = detected !== void 0 && (detected.class === "b" || detected.class === "c");
|
|
4687
4935
|
const localD1PersistRoot = frameworkOwnsCloudflareRuntime ? join(root, ".wrangler", "state") : options?.persistTo ?? join(root, ".void");
|
|
@@ -4699,7 +4947,7 @@ function voidPlugin(options) {
|
|
|
4699
4947
|
const hasInboundEmail = hasEmailHandlers(application.email);
|
|
4700
4948
|
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.");
|
|
4701
4949
|
const clientStubsPlugin = createClientStubsPlugin();
|
|
4702
|
-
const serverRuntimeOptimizerPlugin = createServerRuntimeOptimizerPlugin(
|
|
4950
|
+
const serverRuntimeOptimizerPlugin = createServerRuntimeOptimizerPlugin(dialect, () => readWranglerCompat(root, config));
|
|
4703
4951
|
const queues = framework ? [] : application.queues;
|
|
4704
4952
|
const websocketRoutes = framework ? [] : application.allWebsockets;
|
|
4705
4953
|
const durableObjects = application.durableObjects;
|
|
@@ -4800,7 +5048,6 @@ function voidPlugin(options) {
|
|
|
4800
5048
|
application = getApplicationAnalysis(routeEnvironment);
|
|
4801
5049
|
bindings = application.bindings;
|
|
4802
5050
|
authEnabled = application.authEnabled;
|
|
4803
|
-
if (command === "serve" && directCloudflareDestination && bindings.needsAI) process.env.CLOUDFLARE_AUTH_USE_KEYRING = "true";
|
|
4804
5051
|
if (!framework && !isNodeTarget(config.target)) {
|
|
4805
5052
|
managedCloudflareBuild = command === "build" && Boolean(process.env.VOID_DEPLOY_PROJECT_ID);
|
|
4806
5053
|
assetRoutingPublicDir = userConfig.publicDir === false ? null : typeof userConfig.publicDir === "string" ? resolve(root, userConfig.publicDir) : join(root, "public");
|
|
@@ -4916,7 +5163,7 @@ function voidPlugin(options) {
|
|
|
4916
5163
|
}
|
|
4917
5164
|
};
|
|
4918
5165
|
if (framework) {
|
|
4919
|
-
workerConfig.main = getFrameworkEntry(framework, root, devTriggerToken, config.routing?.notFound);
|
|
5166
|
+
workerConfig.main = getFrameworkEntry(framework, root, devTriggerToken, dialect, config.routing?.notFound);
|
|
4920
5167
|
let notFoundIgnoredWarned = false;
|
|
4921
5168
|
const frameworkBuildWrapperPlugin = {
|
|
4922
5169
|
name: "void:framework-build-wrapper",
|
|
@@ -4926,7 +5173,7 @@ function voidPlugin(options) {
|
|
|
4926
5173
|
notFoundIgnoredWarned = true;
|
|
4927
5174
|
voidWarn(`Void generates no asset routing policy for a ${framework} build, so "routing.notFound" in void.config.ts is not written to the built worker config. During a self-hosted build and direct Cloudflare deployment, it takes effect only if your own Cloudflare config declares a complete \`assets\` policy (\`binding\`, \`directory\`, \`not_found_handling\`, \`run_worker_first\`); otherwise Cloudflare's default applies. Managed \`void deploy\` supplies the policy for you.`);
|
|
4928
5175
|
}
|
|
4929
|
-
generateClassATriggerWrapper(root, framework, getOriginalFrameworkEntry(framework, root), true, resolved.build.assetsDir, config.routing?.notFound);
|
|
5176
|
+
generateClassATriggerWrapper(root, framework, getOriginalFrameworkEntry(framework, root), true, dialect, resolved.build.assetsDir, config.routing?.notFound);
|
|
4930
5177
|
}
|
|
4931
5178
|
};
|
|
4932
5179
|
const existingFlags = workerConfig.compatibility_flags ?? [];
|
|
@@ -4961,6 +5208,7 @@ function voidPlugin(options) {
|
|
|
4961
5208
|
} : void 0;
|
|
4962
5209
|
return [
|
|
4963
5210
|
createCloudflareBuiltinsExternalPlugin(),
|
|
5211
|
+
createBareVoidRedirectPlugin(),
|
|
4964
5212
|
createWorkerEnvironmentSanitizerPlugin([viteEnvironment.name, ...viteEnvironment.childEnvironments ?? []]),
|
|
4965
5213
|
createWranglerCompatPersistPlugin(root, config),
|
|
4966
5214
|
devTriggerSecretGuardPlugin(),
|