void 1.2.1 → 1.4.0
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-CdUll_35.mjs → account-cmd-HP8bixYo.mjs} +3 -3
- package/dist/{application-analysis-fEqoSeMp.mjs → application-analysis-DDOQwiXk.mjs} +18 -12
- package/dist/{application-routing-DAhNP4u3.mjs → application-routing-4719u_kf.mjs} +3 -1
- package/dist/auth-g2TQbDLD.d.mts +70 -0
- package/dist/{auth-link-C87vGXM-.mjs → auth-link-CedYpDCy.mjs} +3 -3
- package/dist/{auth-router-6I81r-ix.mjs → auth-router-vafo7x8w.mjs} +11 -6
- package/dist/{better-auth-shared-D-6z0q0f.mjs → better-auth-shared-7FM3Uk2N.mjs} +48 -2
- package/dist/{better-auth-shared-DVk2DkTW.d.mts → better-auth-shared-BHB8kiTE.d.mts} +1 -1
- package/dist/{build-cmd-ex1g-j_e.mjs → build-cmd-9vUAQ1_V.mjs} +1 -1
- package/dist/{cache-oHzrnY3z.mjs → cache-jvwLNb0h.mjs} +1 -1
- package/dist/{cancel-deploy-viAMD0Q_.mjs → cancel-deploy-Dw0UmWKO.mjs} +1 -1
- package/dist/{cf-build-output-BhVxldCw.mjs → cf-build-output-XpNR9zoh.mjs} +122 -5
- package/dist/cf-build-output-bd8Uwv1P.mjs +1 -0
- package/dist/{cf-worker-settings-BECvvTVd.mjs → cf-worker-settings-Dg27RzyT.mjs} +11 -5
- package/dist/cli/cli.mjs +41 -32
- package/dist/cli/cloudflare-operation-process.mjs +35 -8
- package/dist/cli/env-schema-probe.mjs +2 -2
- package/dist/{client-BEkdj1kx.mjs → client-B3LnB_bE.mjs} +8 -1
- package/dist/client-BZb9j66F.mjs +1 -0
- package/dist/{cloudflare-auth-Byo_0_N9.mjs → cloudflare-auth-DyD_kVFr.mjs} +1 -1
- package/dist/{cloudflare-cmd-DMzCv12s.mjs → cloudflare-cmd-D-b_u3T4.mjs} +2 -2
- package/dist/{cloudflare-config-DchHxPTo.mjs → cloudflare-config-CH1AylZT.mjs} +14 -3
- package/dist/{cloudflare-connect-CCRTVg-I.mjs → cloudflare-connect-zTJh8UnN.mjs} +2 -2
- package/dist/{cloudflare-operations-Dh9dEHJj.mjs → cloudflare-operations-Bc-7fN44.mjs} +4 -4
- package/dist/{cloudflare-operations-DsSaw2BT.mjs → cloudflare-operations-BtulCNOg.mjs} +1 -1
- package/dist/{config-BU6hMu1W.mjs → config-BV2ASlpn.mjs} +1 -1
- package/dist/{config-DQfHOKh9.d.mts → config-CAdZVTLN.d.mts} +4 -1
- package/dist/config-D-6q7EBH.mjs +87 -0
- package/dist/{config-DHgSEWT7.mjs → config-OFOAimzt.mjs} +5 -3
- package/dist/config-entry.d.mts +1 -1
- package/dist/{config-BIaXIkkv.mjs → config-tqMM6DwY.mjs} +1 -1
- package/dist/{connect-k7R2rPVA.mjs → connect-BOM6zvFX.mjs} +4 -4
- package/dist/{create-project-DV71ol5d.mjs → create-project-Bxd02EHN.mjs} +1 -1
- package/dist/{create-project-DTuy-l0z.mjs → create-project-C2K0DN2O.mjs} +1 -1
- package/dist/{db-DVOkLH5X.mjs → db-Cdvr3zwG.mjs} +18 -18
- package/dist/{db-types-NGxPwnlt.mjs → db-types-0eCiqYb1.mjs} +1 -1
- package/dist/{delete-BbP5eopu.mjs → delete-lETE6Tpt.mjs} +1 -1
- package/dist/deploy-CX94CmKa.mjs +2 -0
- package/dist/{deploy-7H32EnUs.mjs → deploy-CdM-LAxX.mjs} +473 -148
- package/dist/{deploy-managed-static-DlvcvnQT.mjs → deploy-managed-static-DjeBFG2c.mjs} +43 -20
- package/dist/{deploy-transport-BzGEj0Ge.mjs → deploy-transport-DIq_gFTP.mjs} +14 -13
- package/dist/deploy.d.mts +2 -0
- package/dist/deploy.mjs +8 -5
- package/dist/{dispatch-DoUnxTNo.mjs → dispatch-CLa2LThw.mjs} +76 -7
- package/dist/{domain-CA2wBgra.mjs → domain-DyhNtdYf.mjs} +2 -2
- package/dist/{email-DXpCc77w.mjs → email-DM2wDcBN.mjs} +59 -10
- package/dist/{email-cloudflare-D03g2TkS.mjs → email-cloudflare-PMbAev9Q.mjs} +124 -10
- package/dist/{env-DgOQ9_8S.mjs → env-78hbN-oI.mjs} +3 -3
- package/dist/{env-BJjULvL0.mjs → env-BaMz0j7H.mjs} +6 -1
- package/dist/{env-validation-Dwq3PJzK.mjs → env-validation-B3VobvXm.mjs} +2 -1
- package/dist/{env-validation-BmsdCZEk.mjs → env-validation-BUfFZ6bt.mjs} +1 -1
- package/dist/error-pages-CLIJ7aYq.mjs +37 -0
- package/dist/gen-BhWBT4iu.mjs +1 -0
- package/dist/{gen-BfmcIi2g.mjs → gen-CFmsUsW1.mjs} +3 -3
- package/dist/{github-cmd-CY9LUqLh.mjs → github-cmd-De-_IWbM.mjs} +1 -1
- package/dist/{handler-BbkSPzGF.d.mts → handler-BHktmuTL.d.mts} +4 -2
- package/dist/{headers-D522zd0A.mjs → headers--vaK_chu.mjs} +1 -1
- package/dist/{help-CxSlPpzJ.mjs → help-CKbrhZha.mjs} +16 -1
- package/dist/help-qOZr3wng.mjs +1 -0
- package/dist/index.d.mts +3 -5
- package/dist/index.mjs +370 -140
- package/dist/{info-7VDlhtyy.mjs → info-Yg0-V5Rs.mjs} +4 -4
- package/dist/{init-DxYyOs4-.mjs → init-CDiJQycf.mjs} +241 -206
- package/dist/{link-Ddmod1dZ.mjs → link-Dllip08S.mjs} +2 -2
- package/dist/{list-MogaugiO.mjs → list-BYRP6am0.mjs} +2 -2
- package/dist/{live-Bt8Y_0bg.d.mts → live-BllfDuzA.d.mts} +2 -2
- package/dist/{local-d1-BHBnKWRb.mjs → local-d1-CAwAs9GH.mjs} +1 -1
- package/dist/login-BAPmYnb7.mjs +1 -0
- package/dist/{login-Cttnagmm.mjs → login-PcFy5mlC.mjs} +2 -2
- package/dist/{logs-CAszUWZI.mjs → logs-DmJTBhed.mjs} +2 -2
- package/dist/{migrate-DyT2jJ8y.mjs → migrate-B8S2xTcb.mjs} +5 -66
- package/dist/migrate-BIYTPQE6.mjs +1 -0
- package/dist/nitro.mjs +4 -4
- package/dist/{node-WB7c2N4L.mjs → node-CDOPrGSl.mjs} +5 -5
- package/dist/{operator-args-UnE8Y2eK.mjs → operator-args-BsJIYXaT.mjs} +8 -1
- package/dist/operator-cmd-CjazwOyb.mjs +1 -0
- package/dist/{operator-cmd-skshjMGl.mjs → operator-cmd-DmkmS2wL.mjs} +4 -3
- package/dist/pages/client.d.mts +32 -4
- package/dist/pages/client.mjs +186 -29
- package/dist/pages/index.d.mts +34 -2
- package/dist/pages/index.mjs +96 -55
- package/dist/pages/islands-plugin.d.mts +1 -1
- package/dist/pages/islands-plugin.mjs +9 -3
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/platform-args-BC8_hsDj.mjs +1 -0
- package/dist/{platform-args-DVbVClZl.mjs → platform-args-BMD2gjc_.mjs} +1 -1
- package/dist/{platform-auth-config-C-pm5Qzx.mjs → platform-auth-config-CImnfohz.mjs} +3 -3
- package/dist/{platform-auth-protection-SHhvim1L.mjs → platform-auth-protection-BogLhtHi.mjs} +2 -2
- package/dist/{platform-auth-recovery-DXVWs-wA.mjs → platform-auth-recovery-B-mEaWEi.mjs} +2 -2
- package/dist/{platform-cmd-PiNRkopU.mjs → platform-cmd-CV8NxIIn.mjs} +1 -1
- package/dist/{platform-cmd-D5I1beUX.mjs → platform-cmd-DZK2ixMl.mjs} +4 -4
- package/dist/{platform-domain-jpmBfZeb.mjs → platform-domain-CRvelPGE.mjs} +2 -2
- package/dist/{platform-lifecycle-DyKmuNY6.mjs → platform-lifecycle-CPYY7E9B.mjs} +103 -41
- package/dist/{platform-lifecycle-DH3Yr1qQ.mjs → platform-lifecycle-DwXq7kZt.mjs} +1 -1
- package/dist/{platform-management--vDwSn35.mjs → platform-management-BOnGbMSM.mjs} +1 -1
- package/dist/{platform-management-7m-PLaPJ.mjs → platform-management-lXdgGgAM.mjs} +1 -1
- package/dist/{platform-recovery-BiNpZZab.mjs → platform-recovery-noaALXnE.mjs} +2 -2
- package/dist/{plugin-inference-DUjCd55H.mjs → plugin-inference-CeiB6BG5.mjs} +53 -18
- package/dist/{prepare-BcAE5Sdj.mjs → prepare-BuOS18AM.mjs} +1 -1
- package/dist/{prepare-DA-17DhO.mjs → prepare-D604Yiyr.mjs} +12 -8
- package/dist/prepare-DU-tOpS5.mjs +1 -0
- package/dist/{prerender-render-Cijv7UFo.mjs → prerender-render-CaShbHJ3.mjs} +13 -1
- package/dist/prerender-render.d.mts +1 -0
- package/dist/prerender-render.mjs +1 -1
- package/dist/{project-cmd-DA4K5faU.mjs → project-cmd-DBYqAIbe.mjs} +15 -15
- package/dist/{project-team-CQBNveX3.mjs → project-team-BjCLgTRC.mjs} +1 -1
- package/dist/{project-token-CCalFyQf.mjs → project-token-BB6PwaA9.mjs} +1 -1
- package/dist/{project-tsconfig-Itv1f4WC.mjs → project-tsconfig-CVvk6Z_e.mjs} +24 -2
- package/dist/{project-zero-trust-DPnkiEuT.mjs → project-zero-trust-CWDh1P_t.mjs} +1 -1
- package/dist/{protocol-BBDpJz3G.d.mts → protocol-D5XDySYu.d.mts} +2 -2
- package/dist/{provision-BFLCrnUp.mjs → provision-DfxLCg-d.mjs} +1 -1
- package/dist/{provision-DtROpNNI.mjs → provision-DztLJ97X.mjs} +24 -8
- package/dist/{requests-BpH0kImL.mjs → requests-D_pbzDyz.mjs} +1 -1
- package/dist/{rollback-CXS1tAa-.mjs → rollback-CjfIYsJx.mjs} +2 -2
- package/dist/{route-types-BZi26DVS.mjs → route-types-DvEGmPif.mjs} +109 -30
- package/dist/routes-stub.d.mts +22 -13
- package/dist/runtime/auth.d.mts +2 -2
- package/dist/runtime/better-auth-mysql.d.mts +1 -1
- package/dist/runtime/better-auth-mysql.mjs +1 -1
- package/dist/runtime/better-auth-pg.d.mts +1 -1
- package/dist/runtime/better-auth-pg.mjs +1 -1
- package/dist/runtime/better-auth.d.mts +1 -1
- package/dist/runtime/better-auth.mjs +1 -1
- package/dist/runtime/client-react.d.mts +1 -1
- package/dist/runtime/client-solid.d.mts +1 -1
- package/dist/runtime/client-svelte.d.mts +1 -1
- package/dist/runtime/client-vue.d.mts +1 -1
- package/dist/runtime/client.d.mts +1 -1
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/live-client.d.mts +1 -1
- package/dist/runtime/live.d.mts +1 -1
- package/dist/runtime/log.mjs +19 -1
- package/dist/runtime/routing.d.mts +5 -4
- package/dist/runtime/routing.mjs +14 -73
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws-server.d.mts +3 -3
- package/dist/runtime/ws.d.mts +1 -1
- package/dist/runtime/ws.mjs +4 -2
- package/dist/{scan-8IzYXiU_.mjs → scan-N9WzdcAl.mjs} +302 -23
- package/dist/{secret-BbXHfLAt.mjs → secret-3X0PxmuX.mjs} +9 -12
- package/dist/static-asset-marker-Btf-6oCD.mjs +32 -0
- package/dist/{types-7AIz0OZu.d.mts → types-w72dljaA.d.mts} +6 -1
- package/dist/{version-metadata-tS39iW09.mjs → version-metadata-D2vfMQzv.mjs} +2 -1
- package/dist/worker-conditions-AWFRcFxR.mjs +11 -0
- package/dist/{wrangler-F96NnLyb.mjs → wrangler-I-scB_1t.mjs} +82 -13
- package/dist/wrangler-UnwdISay.mjs +1 -0
- package/dist/{wrapper-D3sZyh2C.mjs → wrapper-BBl1rC32.mjs} +8 -12
- package/dist/{ws-BH-im_tX.d.mts → ws-B3ClMVDh.d.mts} +3 -2
- package/docs/guide/auth.md +4 -2
- package/docs/guide/edge/redirects.md +22 -0
- package/docs/guide/edge/static-assets.md +10 -0
- package/docs/guide/email/domains.md +1 -1
- package/docs/guide/email/receiving.md +2 -0
- package/docs/guide/email/sending.md +1 -1
- package/docs/guide/pages-routing/actions-and-forms.md +43 -13
- package/docs/guide/pages-routing/markdown.md +2 -0
- package/docs/guide/pages-routing/overview.md +33 -2
- package/docs/guide/platform/administration/email.md +18 -0
- package/docs/guide/platform/installation/maintenance.md +3 -1
- package/docs/guide/platform/installation/prerequisites.md +9 -4
- package/docs/guide/platform/installation/uninstall.md +2 -0
- package/docs/guide/queues.md +13 -1
- package/docs/guide/server-routing.md +40 -2
- package/docs/guide/ssg.md +8 -0
- package/docs/guide/type-safety.md +7 -7
- package/docs/guide/websockets.md +4 -2
- package/docs/integrations/cloudflare.md +16 -7
- package/docs/reference/api/auth.md +6 -2
- package/docs/reference/api/deploy.md +9 -5
- package/docs/reference/api/pages.md +6 -4
- package/docs/reference/cli/deploy.md +10 -9
- package/docs/reference/cli/email.md +13 -0
- package/docs/reference/cli/platform-email.md +2 -2
- package/docs/reference/cli.md +1 -0
- package/docs/reference/config.md +11 -1
- package/docs/reference/structure.md +3 -1
- package/package.json +9 -7
- package/schema.json +4 -0
- package/skills/void/SKILL.md +1 -1
- package/templates/assets/icons.svg +49 -0
- package/templates/assets/react.svg +1 -0
- package/templates/assets/solid.svg +1 -0
- package/templates/assets/stack.svg +35 -0
- package/templates/assets/svelte.svg +1 -0
- package/templates/assets/void.svg +5 -0
- package/templates/assets/vue.svg +1 -0
- package/dist/auth-DkcFflXV.d.mts +0 -42
- package/dist/cf-build-output-BJHuSsVN.mjs +0 -1
- package/dist/client-BiRDZTSd.mjs +0 -1
- package/dist/config-CyUJzi3q.mjs +0 -32
- package/dist/deploy-CE0Ev0Ob.mjs +0 -2
- package/dist/gen-NrOlWZaG.mjs +0 -1
- package/dist/help-BeAFFE5C.mjs +0 -1
- package/dist/login-DgDwlKc_.mjs +0 -1
- package/dist/migrate-n49ZeS1X.mjs +0 -1
- package/dist/operator-cmd-d2MvJOrl.mjs +0 -1
- package/dist/parse-filename-DioPHiR9.mjs +0 -77
- package/dist/platform-args-kQrgxScY.mjs +0 -1
- package/dist/prepare-C4I0f--h.mjs +0 -1
- package/dist/wrangler-BLb3_luP.mjs +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { c as getToken, f as removeToken } from "./auth-B6iOCjKI.mjs";
|
|
2
2
|
import { L as log } from "./dist-Cor9XGoz.mjs";
|
|
3
|
-
import { r as PlatformClient } from "./client-
|
|
3
|
+
import { r as PlatformClient } from "./client-B3LnB_bE.mjs";
|
|
4
4
|
import { m as printSuccess } from "./output-BpgYODYx.mjs";
|
|
5
|
-
import { n as runLoginCommand } from "./login-
|
|
5
|
+
import { n as runLoginCommand } from "./login-PcFy5mlC.mjs";
|
|
6
6
|
import { execSync } from "node:child_process";
|
|
7
7
|
//#region src/cli/account-cmd.ts
|
|
8
8
|
async function runAccountCommand(root, args) {
|
|
9
9
|
switch (args.subcommand) {
|
|
10
10
|
case "login": return runLoginCommand(root);
|
|
11
|
-
case "link": return import("./auth-link-
|
|
11
|
+
case "link": return import("./auth-link-CedYpDCy.mjs").then(({ runAuthLink }) => runAuthLink(root, args.connectionId));
|
|
12
12
|
case "logout":
|
|
13
13
|
if (removeToken(root)) printSuccess("Logged out.");
|
|
14
14
|
else log.info("Not logged in.");
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { a as join, i as isAbsolute, t as basename } from "./dist-ipQi0Q8y.mjs";
|
|
2
|
-
import { c as scanWebSocketRoutesSync, d as readResourceDefinition, f as listConventionFiles,
|
|
2
|
+
import { c as scanWebSocketRoutesSync, d as readResourceDefinition, f as listConventionFiles, h as needsApplicationDatabase, i as inferProjectBindings, n as FRAMEWORK_SCAN_DIRS, p as listRouteFiles, r as detectFramework, s as isWebSocketPatternFile } from "./plugin-inference-CeiB6BG5.mjs";
|
|
3
3
|
import { i as resolveProjectPaths, n as readProjectPaths } from "./project-paths-DGu_QZ_Q.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { l as getDatabaseDialect, m as resolveBindingNames } from "./config-
|
|
4
|
+
import { r as findVoidAuthConfig } from "./config-D-6q7EBH.mjs";
|
|
5
|
+
import { l as getDatabaseDialect, m as resolveBindingNames } from "./config-OFOAimzt.mjs";
|
|
6
6
|
import { n as globSync } from "./dist-D15hFhP0.mjs";
|
|
7
|
+
import { m as parseRouteFilename, n as scanPages, p as isRouteEnabledForEnvironment } from "./scan-N9WzdcAl.mjs";
|
|
7
8
|
import { n as isIdentifier, o as moduleExportName } from "./ast-CsZ_q_gc.mjs";
|
|
8
9
|
import { a as staticLiteral, i as staticExportInitializers, o as unwrapStaticExpression, t as bindingNames } from "./ast-bindings-C3yaPs1y.mjs";
|
|
9
10
|
import { n as resourceNameWords } from "./resource-name-C7LVpcRm.mjs";
|
|
10
11
|
import { t as collectMigrations } from "./collect-Dew86qce.mjs";
|
|
11
|
-
import { n as parseRouteFilename, t as isRouteEnabledForEnvironment } from "./parse-filename-DioPHiR9.mjs";
|
|
12
12
|
import { i as scanEmailHandlersSync } from "./email-B9ayYQEG.mjs";
|
|
13
|
-
import { t as scanPages } from "./scan-8IzYXiU_.mjs";
|
|
14
13
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
15
|
-
import { fileURLToPath } from "node:url";
|
|
16
14
|
import { parseSync } from "vite";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
17
16
|
import { isSandboxRegistryImage } from "@void/deploy-core";
|
|
18
17
|
//#region src/crons/scan.ts
|
|
19
18
|
function extractJobName(filePath) {
|
|
@@ -203,12 +202,18 @@ async function scanRoutes(root, options) {
|
|
|
203
202
|
const { paths, inventory } = options;
|
|
204
203
|
const pages = await scanPages(root, {
|
|
205
204
|
output: options.output,
|
|
206
|
-
paths
|
|
205
|
+
paths,
|
|
206
|
+
checkRoutes: options.checkPageRoutes,
|
|
207
|
+
environment: options.environment
|
|
207
208
|
});
|
|
208
|
-
const routes = inventory.routes.map((route) =>
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
209
|
+
const routes = inventory.routes.map((route) => {
|
|
210
|
+
const methods = detectHttpExports(join(paths.routesDir, route.filePath));
|
|
211
|
+
if (methods.includes("HEAD")) throw new Error(`routes: '${route.filePath}' exports HEAD. HEAD requests are answered by the GET handler; remove the HEAD export.`);
|
|
212
|
+
return {
|
|
213
|
+
...route,
|
|
214
|
+
methods
|
|
215
|
+
};
|
|
216
|
+
}).sort(compareRouteSpecificity);
|
|
212
217
|
return {
|
|
213
218
|
...inventory,
|
|
214
219
|
routes,
|
|
@@ -219,7 +224,7 @@ function scanMiddlewareSync(root, paths = readProjectPaths(root)) {
|
|
|
219
224
|
return parseMiddlewareDefinitions(globSync("**/*.{ts,mts,js,mjs}", { cwd: paths.middlewareDir }));
|
|
220
225
|
}
|
|
221
226
|
function scanRoutePatternsSync(root, paths = readProjectPaths(root), environment) {
|
|
222
|
-
return
|
|
227
|
+
return listRouteFiles(paths.routesDir).filter((f) => !isWebSocketPatternFile(f)).map((f) => parseRouteFilename(f)).filter((route) => isRouteEnabledForEnvironment(route, environment)).sort(compareRouteSpecificity);
|
|
223
228
|
}
|
|
224
229
|
const DEFAULT_SANDBOX_CLASS_NAME = "SandboxV1";
|
|
225
230
|
const DEFAULT_SANDBOX_CONTAINER_NAME = "void-sandbox-v1";
|
|
@@ -318,6 +323,7 @@ function analyzeApplicationSync(root, options) {
|
|
|
318
323
|
const inferred = inferProjectBindings(root, {
|
|
319
324
|
paths,
|
|
320
325
|
environment,
|
|
326
|
+
filterPages: !framework,
|
|
321
327
|
bindings: config.inference?.bindings
|
|
322
328
|
}, scanDirs);
|
|
323
329
|
const authConfigPath = findVoidAuthConfig(root, paths);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { l as scanRoutes, t as analyzeApplicationSync } from "./application-analysis-
|
|
1
|
+
import { l as scanRoutes, t as analyzeApplicationSync } from "./application-analysis-DDOQwiXk.mjs";
|
|
2
2
|
//#region src/application-routing.ts
|
|
3
3
|
/** Complete route/page analysis using the same resource and handler inventories. */
|
|
4
4
|
async function completeApplicationAnalysis(analysis) {
|
|
5
5
|
const scan = await scanRoutes(analysis.root, {
|
|
6
6
|
output: analysis.config.output,
|
|
7
7
|
paths: analysis.paths,
|
|
8
|
+
checkPageRoutes: !analysis.framework,
|
|
9
|
+
environment: analysis.framework ? void 0 : analysis.environment,
|
|
8
10
|
inventory: {
|
|
9
11
|
routes: analysis.routes,
|
|
10
12
|
middleware: analysis.middleware,
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { Auth, BetterAuthOptions, Session, User } from "better-auth";
|
|
3
|
+
import { Context, Env } from "hono";
|
|
4
|
+
//#region src/runtime/auth.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Filled in by the generated `.void/auth.d.ts` with the user and session types
|
|
7
|
+
* Better Auth infers from the app's `auth.ts`. Empty when the app has no
|
|
8
|
+
* `auth.ts`, so `AuthUser`/`AuthSession` fall back to Better Auth's base shapes.
|
|
9
|
+
*
|
|
10
|
+
* `AuthUser`/`AuthSession` stay type aliases (not merged interfaces) so they
|
|
11
|
+
* remain assignable to `Record<string, unknown>`, and a union config (a function
|
|
12
|
+
* form that returns different shapes per branch) stays a valid union type.
|
|
13
|
+
*/
|
|
14
|
+
interface VoidAuthTypes {}
|
|
15
|
+
/**
|
|
16
|
+
* Better Auth's inferred `{ user, session }` for an `auth.ts` default export.
|
|
17
|
+
* Used by the generated `.void/auth.d.ts`; it lives here so `better-auth`
|
|
18
|
+
* resolves from Void's own dependencies, not the app's.
|
|
19
|
+
*
|
|
20
|
+
* An `any` default export (an `auth.js` without `allowJs`, or an import that
|
|
21
|
+
* does not resolve) keeps Better Auth's base shapes instead of a user type that
|
|
22
|
+
* accepts any key. The tuple check also catches the error `any` of an untyped
|
|
23
|
+
* import.
|
|
24
|
+
*/
|
|
25
|
+
type InferAuthSession<T> = [unknown] extends [T] ? {
|
|
26
|
+
user: User;
|
|
27
|
+
session: Session;
|
|
28
|
+
} : Auth<Extract<T extends ((...args: Array<never>) => infer R) ? R : T, BetterAuthOptions>>["$Infer"]["Session"];
|
|
29
|
+
type AuthUser = VoidAuthTypes extends {
|
|
30
|
+
user: infer U;
|
|
31
|
+
} ? U : User;
|
|
32
|
+
type AuthSession = VoidAuthTypes extends {
|
|
33
|
+
session: infer S;
|
|
34
|
+
} ? S : Session;
|
|
35
|
+
type AuthState = {
|
|
36
|
+
session: AuthSession;
|
|
37
|
+
user: AuthUser;
|
|
38
|
+
};
|
|
39
|
+
type VoidAuthConfigContext = {
|
|
40
|
+
defaults: BetterAuthOptions;
|
|
41
|
+
env: Record<string, unknown>;
|
|
42
|
+
dialect: "sqlite" | "postgresql" | "mysql";
|
|
43
|
+
request: Request;
|
|
44
|
+
};
|
|
45
|
+
type VoidAuthConfig = BetterAuthOptions | ((ctx: VoidAuthConfigContext) => BetterAuthOptions);
|
|
46
|
+
/**
|
|
47
|
+
* Shared AsyncLocalStorage that holds the authenticated Better Auth state for the
|
|
48
|
+
* current request.
|
|
49
|
+
*
|
|
50
|
+
* Stored on `globalThis` under a `Symbol.for` key so duplicate module loads
|
|
51
|
+
* (e.g. once by void's bundled runtime and once by Vite's SSR module runner
|
|
52
|
+
* when user code imports from `void/auth`) share a single ALS instance. Without
|
|
53
|
+
* this, the middleware writes to one instance and `getUser()` reads another,
|
|
54
|
+
* always returning null.
|
|
55
|
+
*/
|
|
56
|
+
type AuthContextStore = {
|
|
57
|
+
user: AuthUser | null;
|
|
58
|
+
state: AuthState | null;
|
|
59
|
+
};
|
|
60
|
+
declare const authContext: AsyncLocalStorage<AuthContextStore>;
|
|
61
|
+
declare function defineAuth<T extends VoidAuthConfig>(config: T): T;
|
|
62
|
+
declare function getUser(): AuthUser | null;
|
|
63
|
+
declare function getSession(): AuthState | null;
|
|
64
|
+
declare function requireAuth<E extends Env & {
|
|
65
|
+
Variables: {
|
|
66
|
+
user: AuthUser | null;
|
|
67
|
+
};
|
|
68
|
+
}>(c: Context<E>): AuthUser;
|
|
69
|
+
//#endregion
|
|
70
|
+
export { VoidAuthConfig as a, authContext as c, getUser as d, requireAuth as f, InferAuthSession as i, defineAuth as l, AuthState as n, VoidAuthConfigContext as o, AuthUser as r, VoidAuthTypes as s, AuthSession as t, getSession as u };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as getApiUrl, c as getToken, m as savePlatformToken, p as runPlatformLogin, u as openBrowser } from "./auth-B6iOCjKI.mjs";
|
|
2
2
|
import { L as log } from "./dist-Cor9XGoz.mjs";
|
|
3
|
-
import { r as PlatformClient } from "./client-
|
|
3
|
+
import { r as PlatformClient } from "./client-B3LnB_bE.mjs";
|
|
4
4
|
import { l as formatUrl } from "./output-BpgYODYx.mjs";
|
|
5
|
-
import { r as selectPlatformLoginMethod } from "./login-
|
|
6
|
-
import { t as discoverPlatform } from "./platform-cmd-
|
|
5
|
+
import { r as selectPlatformLoginMethod } from "./login-PcFy5mlC.mjs";
|
|
6
|
+
import { t as discoverPlatform } from "./platform-cmd-DZK2ixMl.mjs";
|
|
7
7
|
//#region src/cli/auth-link.ts
|
|
8
8
|
async function runAuthLink(root, connectionId) {
|
|
9
9
|
const token = getToken(root);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as listPlatformConnections } from "./platform-registry-B9mWX9LO.mjs";
|
|
1
|
+
import { c as normalizePlatformApiUrl, s as listPlatformConnections } from "./platform-registry-B9mWX9LO.mjs";
|
|
2
2
|
import { n as readDeploymentPlatform } from "./project-rqDnVsJN.mjs";
|
|
3
3
|
import { K as select, tt as isCancel } from "./dist-Cor9XGoz.mjs";
|
|
4
4
|
//#region src/cli/auth-router.ts
|
|
@@ -39,23 +39,28 @@ async function chooseDestination(root, args, interactive) {
|
|
|
39
39
|
async function runAuthRouter(root, args, interactive = Boolean(process.stdin.isTTY)) {
|
|
40
40
|
const destination = await chooseDestination(root, args, interactive);
|
|
41
41
|
if (destination.platform === "cloudflare") {
|
|
42
|
-
const { runCloudflareCommand } = await import("./cloudflare-cmd-
|
|
42
|
+
const { runCloudflareCommand } = await import("./cloudflare-cmd-D-b_u3T4.mjs");
|
|
43
43
|
await runCloudflareCommand(root, { subcommand: args.subcommand });
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
const { runAccountCommand } = await import("./account-cmd-
|
|
46
|
+
const { runAccountCommand } = await import("./account-cmd-HP8bixYo.mjs");
|
|
47
47
|
const subcommand = args.subcommand === "status" ? "whoami" : args.subcommand;
|
|
48
48
|
if (!destination.apiUrl) {
|
|
49
49
|
await runAccountCommand(root, { subcommand });
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
const previous =
|
|
52
|
+
const previous = {
|
|
53
|
+
VOID_API_URL: process.env.VOID_API_URL,
|
|
54
|
+
VOID_TOKEN: process.env.VOID_TOKEN
|
|
55
|
+
};
|
|
56
|
+
const tokenBound = Boolean(previous.VOID_TOKEN && previous.VOID_API_URL && normalizePlatformApiUrl(previous.VOID_API_URL) === destination.apiUrl);
|
|
53
57
|
process.env.VOID_API_URL = destination.apiUrl;
|
|
58
|
+
if (previous.VOID_TOKEN && !tokenBound) delete process.env.VOID_TOKEN;
|
|
54
59
|
try {
|
|
55
60
|
await runAccountCommand(root, { subcommand });
|
|
56
61
|
} finally {
|
|
57
|
-
|
|
58
|
-
else process.env
|
|
62
|
+
for (const [name, value] of Object.entries(previous)) if (value === void 0) delete process.env[name];
|
|
63
|
+
else process.env[name] = value;
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { i as getVoidAuthProviderSettingEnvNames, o as isVoidSocialAuthProvider, r as getVoidAuthProviderEnvNames } from "./providers-BUHwJlmM.mjs";
|
|
2
|
+
import { t as isUnchangedStaticAsset } from "./static-asset-marker-Btf-6oCD.mjs";
|
|
2
3
|
import { t as authContext } from "./auth-3sGB0zJ1.mjs";
|
|
3
4
|
import { randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
4
5
|
import { betterAuth } from "better-auth";
|
|
@@ -104,8 +105,15 @@ function resolveSocialProviders(env, configuredProviders) {
|
|
|
104
105
|
}
|
|
105
106
|
return Object.keys(providers).length > 0 ? providers : void 0;
|
|
106
107
|
}
|
|
107
|
-
function appendAuthHeaders(c, source, includeCachePolicy) {
|
|
108
|
+
function appendAuthHeaders(c, source, includeCachePolicy, staticAsset) {
|
|
108
109
|
if (!source) return;
|
|
110
|
+
if (staticAsset) {
|
|
111
|
+
source.forEach((value, key) => {
|
|
112
|
+
if (!["cache-control", "pragma"].includes(key.toLowerCase())) c.header(key, value, { append: key.toLowerCase() === "set-cookie" });
|
|
113
|
+
});
|
|
114
|
+
if (includeCachePolicy) c.header("Cache-Control", source.has("set-cookie") ? "private, no-store" : privateCachePolicy(c.res.headers.get("cache-control")));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
109
117
|
const routeDirectives = bareCacheDirectives(c.res.headers.get("cache-control"));
|
|
110
118
|
const keepRoutePolicy = routeDirectives.has("no-store") || routeDirectives.has("private") && routeDirectives.has("no-cache");
|
|
111
119
|
source.forEach((value, key) => {
|
|
@@ -123,6 +131,44 @@ function bareCacheDirectives(policy) {
|
|
|
123
131
|
const directives = (policy ?? "").match(/(?:[^",]|"(?:[^"\\]|\\.)*"?)+/g) ?? [];
|
|
124
132
|
return new Set(directives.map((directive) => directive.trim().toLowerCase()).filter((directive) => !directive.includes("=")));
|
|
125
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* The same policy for one browser only: `public`, `proxy-revalidate`,
|
|
136
|
+
* `s-maxage` and a field-scoped `private` give way to a leading `private`.
|
|
137
|
+
* A policy that is already private or no-store stays as it is.
|
|
138
|
+
*/
|
|
139
|
+
function privateCachePolicy(policy) {
|
|
140
|
+
const directives = splitCacheDirectives(policy ?? "");
|
|
141
|
+
if (directives.length === 0) return "private, no-store";
|
|
142
|
+
const lowered = directives.map((directive) => directive.toLowerCase());
|
|
143
|
+
if (lowered.includes("private") || lowered.includes("no-store")) return policy;
|
|
144
|
+
return ["private", ...directives.filter((_directive, index) => {
|
|
145
|
+
const directive = lowered[index];
|
|
146
|
+
const equals = directive.indexOf("=");
|
|
147
|
+
const name = (equals === -1 ? directive : directive.slice(0, equals)).trim();
|
|
148
|
+
return ![
|
|
149
|
+
"public",
|
|
150
|
+
"proxy-revalidate",
|
|
151
|
+
"s-maxage",
|
|
152
|
+
"private"
|
|
153
|
+
].includes(name);
|
|
154
|
+
})].join(", ");
|
|
155
|
+
}
|
|
156
|
+
function splitCacheDirectives(policy) {
|
|
157
|
+
const directives = [];
|
|
158
|
+
let start = 0;
|
|
159
|
+
let quoted = false;
|
|
160
|
+
for (let index = 0; index < policy.length; index++) {
|
|
161
|
+
const char = policy[index];
|
|
162
|
+
if (quoted && char === "\\") index++;
|
|
163
|
+
else if (char === "\"") quoted = !quoted;
|
|
164
|
+
else if (char === "," && !quoted) {
|
|
165
|
+
directives.push(policy.slice(start, index));
|
|
166
|
+
start = index + 1;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
directives.push(policy.slice(start));
|
|
170
|
+
return directives.map((directive) => directive.trim()).filter(Boolean);
|
|
171
|
+
}
|
|
126
172
|
function resolveUserConfig(userConfig, defaults, request, env, dialect) {
|
|
127
173
|
const mergeEmailAndPasswordDefaults = (options) => {
|
|
128
174
|
if (!defaults.emailAndPassword?.password || !options.emailAndPassword) return options;
|
|
@@ -282,7 +328,7 @@ function createVoidAuthRuntime(dialect, applyMigrations) {
|
|
|
282
328
|
"authorization",
|
|
283
329
|
"cf-access-jwt-assertion"
|
|
284
330
|
].some((header) => c.req.raw.headers.has(header));
|
|
285
|
-
appendAuthHeaders(c, result.headers, state !== null || credentialed || result.headers?.has("set-cookie") === true);
|
|
331
|
+
appendAuthHeaders(c, result.headers, state !== null || credentialed || result.headers?.has("set-cookie") === true, isUnchangedStaticAsset(c));
|
|
286
332
|
}
|
|
287
333
|
async function handleVoidAuthRequest(c, runtime, database) {
|
|
288
334
|
const existingAuth = c.get("__voidAuth");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as VoidAuthProvider } from "./providers-BNKRacMr.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { a as VoidAuthConfig, n as AuthState } from "./auth-g2TQbDLD.mjs";
|
|
3
3
|
import { BetterAuthOptions, betterAuth } from "better-auth";
|
|
4
4
|
import { Context } from "hono";
|
|
5
5
|
import { DBFieldAttribute } from "better-auth/db";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as readProjectConfig } from "./project-rqDnVsJN.mjs";
|
|
2
2
|
import { c as getToken } from "./auth-B6iOCjKI.mjs";
|
|
3
3
|
import { H as outro, L as log } from "./dist-Cor9XGoz.mjs";
|
|
4
|
-
import { n as PlatformApiError, r as PlatformClient } from "./client-
|
|
4
|
+
import { n as PlatformApiError, r as PlatformClient } from "./client-B3LnB_bE.mjs";
|
|
5
5
|
import { f as import_picocolors, i as dim, m as printSuccess } from "./output-BpgYODYx.mjs";
|
|
6
6
|
import { a as resolveProjectBySlug, t as getRequestedProjectSlug } from "./resolve-project-Xoi6eTWY.mjs";
|
|
7
7
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as readProjectConfig } from "./project-rqDnVsJN.mjs";
|
|
2
2
|
import { c as getToken } from "./auth-B6iOCjKI.mjs";
|
|
3
3
|
import { L as log } from "./dist-Cor9XGoz.mjs";
|
|
4
|
-
import { r as PlatformClient } from "./client-
|
|
4
|
+
import { r as PlatformClient } from "./client-B3LnB_bE.mjs";
|
|
5
5
|
import { m as printSuccess, o as formatCount, r as createSpinner } from "./output-BpgYODYx.mjs";
|
|
6
6
|
import { a as resolveProjectBySlug, t as getRequestedProjectSlug } from "./resolve-project-Xoi6eTWY.mjs";
|
|
7
7
|
//#region src/cli/cache.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as readProjectConfig } from "./project-rqDnVsJN.mjs";
|
|
2
2
|
import { c as getToken } from "./auth-B6iOCjKI.mjs";
|
|
3
3
|
import { A as confirm, H as outro, L as log, tt as isCancel } from "./dist-Cor9XGoz.mjs";
|
|
4
|
-
import { r as PlatformClient } from "./client-
|
|
4
|
+
import { r as PlatformClient } from "./client-B3LnB_bE.mjs";
|
|
5
5
|
import { m as printSuccess } from "./output-BpgYODYx.mjs";
|
|
6
6
|
//#region src/cli/cancel-deploy.ts
|
|
7
7
|
const ACTIVE_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { a as join, c as resolve, i as isAbsolute, n as dirname, r as extname, s as relative, t as basename } from "./dist-ipQi0Q8y.mjs";
|
|
2
2
|
import { n as readGeneratedWranglerConfigFile } from "./generated-wrangler-config-DeWj5F9Y.mjs";
|
|
3
|
+
import { t as WORKER_CONDITIONS } from "./worker-conditions-AWFRcFxR.mjs";
|
|
3
4
|
import { copyFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
6
|
import { isRecord } from "@void/deploy-core";
|
|
6
|
-
import { randomUUID } from "node:crypto";
|
|
7
|
+
import { randomBytes, randomUUID } from "node:crypto";
|
|
7
8
|
import { tmpdir } from "node:os";
|
|
8
9
|
import { isDeepStrictEqual } from "node:util";
|
|
9
10
|
import { spawn, spawnSync } from "node:child_process";
|
|
@@ -393,10 +394,24 @@ function copyBundle(source, destination) {
|
|
|
393
394
|
}
|
|
394
395
|
return modules;
|
|
395
396
|
}
|
|
397
|
+
function stagePackageContext(directory, projectRoot) {
|
|
398
|
+
const root = resolve(projectRoot);
|
|
399
|
+
const manifest = join(root, "package.json");
|
|
400
|
+
if (!existsSync(manifest)) return;
|
|
401
|
+
copyFileSync(manifest, join(directory, "package.json"));
|
|
402
|
+
for (let parent = root;; parent = dirname(parent)) {
|
|
403
|
+
const modules = join(parent, "node_modules");
|
|
404
|
+
if (existsSync(modules)) {
|
|
405
|
+
symlinkSync(modules, join(directory, "node_modules"), process.platform === "win32" ? "junction" : "dir");
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
if (parent === dirname(parent)) break;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
396
411
|
/** Create a disposable cf Build Output tree from an existing Cloudflare Worker build. */
|
|
397
|
-
async function prepareCfBuildOutput(workerDirectory, accountId, mode) {
|
|
412
|
+
async function prepareCfBuildOutput(workerDirectory, accountId, mode, projectRoot = workerDirectory) {
|
|
398
413
|
const source = resolve(workerDirectory);
|
|
399
|
-
if (existsSync(getRootConfigPath(source))) return prepareNativeBuildOutput(source, accountId, mode);
|
|
414
|
+
if (existsSync(getRootConfigPath(source))) return prepareNativeBuildOutput(source, accountId, mode, projectRoot);
|
|
400
415
|
if (!existsSync(join(source, "wrangler.json"))) throw new Error(`No Cloudflare Worker build found in ${source}. Pass the project root that contains .cloudflare/output/v0, or the Worker output directory that contains wrangler.json.`);
|
|
401
416
|
const raw = record(JSON.parse(readFileSync(join(source, "wrangler.json"), "utf8")));
|
|
402
417
|
if (!raw) return null;
|
|
@@ -420,6 +435,7 @@ async function prepareCfBuildOutput(workerDirectory, accountId, mode) {
|
|
|
420
435
|
await Promise.all(images.map((image) => image.dispose()));
|
|
421
436
|
};
|
|
422
437
|
try {
|
|
438
|
+
stagePackageContext(directory, projectRoot);
|
|
423
439
|
const bundle = getWorkerBundleDir(directory);
|
|
424
440
|
mkdirSync(bundle, { recursive: true });
|
|
425
441
|
const modules = copyBundle(source, bundle);
|
|
@@ -478,7 +494,7 @@ async function prepareCfBuildOutput(workerDirectory, accountId, mode) {
|
|
|
478
494
|
}
|
|
479
495
|
}
|
|
480
496
|
/** Copy and complete the native artifact without changing the Vite build's inputs or metadata. */
|
|
481
|
-
async function prepareNativeBuildOutput(source, accountId, mode) {
|
|
497
|
+
async function prepareNativeBuildOutput(source, accountId, mode, projectRoot = source) {
|
|
482
498
|
const built = await readBuildOutput(source);
|
|
483
499
|
if (accountId !== void 0 && built.rootConfig.accountId !== void 0 && accountId !== built.rootConfig.accountId || mode !== void 0 && mode !== built.rootConfig.buildContext.mode) return null;
|
|
484
500
|
const directory = mkdtempSync(join(tmpdir(), "void-cf-native-"));
|
|
@@ -489,6 +505,7 @@ async function prepareNativeBuildOutput(source, accountId, mode) {
|
|
|
489
505
|
});
|
|
490
506
|
};
|
|
491
507
|
try {
|
|
508
|
+
stagePackageContext(directory, projectRoot);
|
|
492
509
|
await writeRootConfig(directory, {
|
|
493
510
|
accountId: accountId ?? built.rootConfig.accountId,
|
|
494
511
|
complianceRegion: built.rootConfig.complianceRegion
|
|
@@ -529,6 +546,104 @@ async function prepareNativeBuildOutput(source, accountId, mode) {
|
|
|
529
546
|
throw error;
|
|
530
547
|
}
|
|
531
548
|
}
|
|
549
|
+
const ADDITIONAL_MODULE_FILTER = /\.(?:wasm(?:\?module)?|bin|txt|html|sql)$/;
|
|
550
|
+
const ADDITIONAL_MODULE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
551
|
+
".wasm",
|
|
552
|
+
".bin",
|
|
553
|
+
".txt",
|
|
554
|
+
".html",
|
|
555
|
+
".sql"
|
|
556
|
+
]);
|
|
557
|
+
/** Keep letters, digits, `.`, `_` and `-`: the name ends up inside a JS import string. */
|
|
558
|
+
function safeFileStem(stem) {
|
|
559
|
+
let safe = "";
|
|
560
|
+
for (const char of stem) {
|
|
561
|
+
const code = char.charCodeAt(0);
|
|
562
|
+
safe += code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "." || char === "_" || char === "-" ? char : "_";
|
|
563
|
+
}
|
|
564
|
+
return safe || "module";
|
|
565
|
+
}
|
|
566
|
+
/** The file behind a resolved id that is uploaded as a Worker module, if it is one. */
|
|
567
|
+
function additionalModulePath(id) {
|
|
568
|
+
const query = id.indexOf("?");
|
|
569
|
+
const path = query === -1 ? id : id.slice(0, query);
|
|
570
|
+
if (query !== -1 && !(id.slice(query) === "?module" && path.endsWith(".wasm"))) return;
|
|
571
|
+
return ADDITIONAL_MODULE_EXTENSIONS.has(extname(path)) ? path : void 0;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Keep Wasm, data and text imports out of the bundle and emit each file beside it, as
|
|
575
|
+
* `@cloudflare/vite-plugin` does, so `copyBundle` uploads them as Worker modules.
|
|
576
|
+
*/
|
|
577
|
+
function additionalModulesPlugin() {
|
|
578
|
+
const marker = `__VOID_MODULE_${randomBytes(8).toString("hex")}__`;
|
|
579
|
+
const paths = [];
|
|
580
|
+
const keys = /* @__PURE__ */ new Map();
|
|
581
|
+
const fileNames = /* @__PURE__ */ new Map();
|
|
582
|
+
const usedFileNames = /* @__PURE__ */ new Set();
|
|
583
|
+
return {
|
|
584
|
+
name: "void:additional-modules",
|
|
585
|
+
enforce: "pre",
|
|
586
|
+
resolveId: {
|
|
587
|
+
filter: { id: [ADDITIONAL_MODULE_FILTER, /^#/] },
|
|
588
|
+
async handler(source, importer, options) {
|
|
589
|
+
const resolved = await this.resolve(source, importer, options);
|
|
590
|
+
const path = resolved ? additionalModulePath(resolved.id) : void 0;
|
|
591
|
+
if (!path) return resolved;
|
|
592
|
+
let key = keys.get(path);
|
|
593
|
+
if (key === void 0) {
|
|
594
|
+
key = paths.push(path) - 1;
|
|
595
|
+
keys.set(path, key);
|
|
596
|
+
}
|
|
597
|
+
return {
|
|
598
|
+
id: `${marker}${key}${marker}`,
|
|
599
|
+
external: true
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
renderChunk: {
|
|
604
|
+
filter: { code: marker },
|
|
605
|
+
handler(code, chunk) {
|
|
606
|
+
const emit = (path) => {
|
|
607
|
+
let fileName = fileNames.get(path);
|
|
608
|
+
if (fileName === void 0) {
|
|
609
|
+
const extension = extname(path);
|
|
610
|
+
const stem = safeFileStem(basename(path, extension));
|
|
611
|
+
fileName = stem + extension;
|
|
612
|
+
for (let count = 2; usedFileNames.has(fileName); count++) fileName = `${stem}${count}${extension}`;
|
|
613
|
+
usedFileNames.add(fileName);
|
|
614
|
+
fileNames.set(path, fileName);
|
|
615
|
+
this.emitFile({
|
|
616
|
+
type: "asset",
|
|
617
|
+
fileName,
|
|
618
|
+
originalFileName: path,
|
|
619
|
+
source: readFileSync(path)
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
return fileName;
|
|
623
|
+
};
|
|
624
|
+
let output = "";
|
|
625
|
+
let cursor = 0;
|
|
626
|
+
let start = code.indexOf(marker);
|
|
627
|
+
while (start !== -1) {
|
|
628
|
+
const keyStart = start + marker.length;
|
|
629
|
+
const end = code.indexOf(marker, keyStart);
|
|
630
|
+
if (end === -1) break;
|
|
631
|
+
const keyText = code.slice(keyStart, end);
|
|
632
|
+
const path = keyText === String(Number(keyText)) ? paths[Number(keyText)] : void 0;
|
|
633
|
+
if (path === void 0) {
|
|
634
|
+
start = code.indexOf(marker, keyStart);
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
const importPath = relative(dirname(chunk.fileName), emit(path));
|
|
638
|
+
output += code.slice(cursor, start) + (importPath.startsWith(".") ? importPath : `./${importPath}`);
|
|
639
|
+
cursor = end + marker.length;
|
|
640
|
+
start = code.indexOf(marker, cursor);
|
|
641
|
+
}
|
|
642
|
+
return output + code.slice(cursor);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
}
|
|
532
647
|
/** Bundle a generated Worker entry with Vite, then hand the result to `prepareCfBuildOutput`. */
|
|
533
648
|
async function prepareBundledBuildOutput(options) {
|
|
534
649
|
const scratch = mkdtempSync(join(tmpdir(), options.scratchPrefix));
|
|
@@ -539,6 +654,8 @@ async function prepareBundledBuildOutput(options) {
|
|
|
539
654
|
root: options.projectRoot,
|
|
540
655
|
publicDir: false,
|
|
541
656
|
logLevel: "error",
|
|
657
|
+
plugins: [additionalModulesPlugin()],
|
|
658
|
+
resolve: { conditions: [...WORKER_CONDITIONS, "production"] },
|
|
542
659
|
build: {
|
|
543
660
|
outDir: scratch,
|
|
544
661
|
emptyOutDir: true,
|
|
@@ -556,7 +673,7 @@ async function prepareBundledBuildOutput(options) {
|
|
|
556
673
|
main: "index.js",
|
|
557
674
|
assets: options.assets
|
|
558
675
|
}), { mode: 384 });
|
|
559
|
-
return await prepareCfBuildOutput(scratch, options.accountId);
|
|
676
|
+
return await prepareCfBuildOutput(scratch, options.accountId, void 0, options.projectRoot);
|
|
560
677
|
} finally {
|
|
561
678
|
rmSync(scratch, {
|
|
562
679
|
recursive: true,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as prepareCfBuildOutput } from "./cf-build-output-XpNR9zoh.mjs";
|
|
@@ -16,8 +16,14 @@ function getCfCliVersion(attribution) {
|
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/cli/cf-worker-settings.ts
|
|
18
18
|
/** Version uploads leave Worker-wide settings untouched; publish only explicit configuration. */
|
|
19
|
-
async function
|
|
20
|
-
if (!isRecord(options.observability)) throw new Error("The Cloudflare Worker observability settings were not readable.");
|
|
19
|
+
async function publishCloudflareWorkerSettings(options) {
|
|
20
|
+
if (options.observability !== void 0 && !isRecord(options.observability)) throw new Error("The Cloudflare Worker observability settings were not readable.");
|
|
21
|
+
if (options.logpush !== void 0 && typeof options.logpush !== "boolean") throw new Error("The Cloudflare Worker Logpush setting was not readable.");
|
|
22
|
+
const settings = {
|
|
23
|
+
...options.observability === void 0 ? {} : { observability: options.observability },
|
|
24
|
+
...options.logpush === void 0 ? {} : { logpush: options.logpush }
|
|
25
|
+
};
|
|
26
|
+
if (Object.keys(settings).length === 0) return;
|
|
21
27
|
const endpoint = `${options.apiBaseUrl.replace(/\/$/, "")}/accounts/${encodeURIComponent(options.accountId)}/workers/scripts/${encodeURIComponent(options.workerName)}/script-settings`;
|
|
22
28
|
const response = await fetch(endpoint, {
|
|
23
29
|
method: "PATCH",
|
|
@@ -26,12 +32,12 @@ async function publishCloudflareObservability(options) {
|
|
|
26
32
|
...options.headers,
|
|
27
33
|
"Content-Type": "application/json"
|
|
28
34
|
},
|
|
29
|
-
body: JSON.stringify(
|
|
35
|
+
body: JSON.stringify(settings),
|
|
30
36
|
redirect: "error",
|
|
31
37
|
signal: AbortSignal.timeout(3e4)
|
|
32
38
|
});
|
|
33
39
|
const body = await response.json();
|
|
34
|
-
if (!response.ok || !isRecord(body) || body.success !== true) throw new Error(`Cloudflare did not update Worker
|
|
40
|
+
if (!response.ok || !isRecord(body) || body.success !== true) throw new Error(`Cloudflare did not update Worker settings (HTTP ${response.status}).`);
|
|
35
41
|
}
|
|
36
42
|
//#endregion
|
|
37
|
-
export { getCfCliVersion as n, getVoidUserAgent as r,
|
|
43
|
+
export { getCfCliVersion as n, getVoidUserAgent as r, publishCloudflareWorkerSettings as t };
|