@cloudflare/vite-plugin 2.0.0-beta.sha-67fa336fd → 2.0.0-beta.v.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cf-vite.mjs +1 -2
- package/dist/{chunk-53YJWLG7-dSmyuxCA.mjs → chunk-U6NEESU5-BzWFpRaS.mjs} +2 -3
- package/dist/index.d.mts +1 -2
- package/dist/index.mjs +58 -24
- package/dist/{open-NPEHYJ5T-C8ZFejjd.mjs → open-PCXX3ZDZ-BXBWVkHI.mjs} +3 -4
- package/dist/{package-DN5VHrZK.mjs → package-DNE1Ou5k.mjs} +14 -9
- package/dist/workers/asset-worker/index.js +1 -2
- package/dist/workers/router-worker/index.js +1 -2
- package/dist/workers/runner-worker/index.js +1 -2
- package/dist/workers/runner-worker/module-runner-legacy.js +1 -2
- package/dist/workers/runner-worker/module-runner.js +1 -2
- package/dist/workers/vite-proxy-worker/index.js +1 -2
- package/package.json +17 -13
- package/dist/cf-vite.mjs.map +0 -1
- package/dist/chunk-53YJWLG7-dSmyuxCA.mjs.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/open-NPEHYJ5T-C8ZFejjd.mjs.map +0 -1
- package/dist/package-DN5VHrZK.mjs.map +0 -1
- package/dist/workers/asset-worker/index.js.map +0 -1
- package/dist/workers/router-worker/index.js.map +0 -1
- package/dist/workers/runner-worker/index.js.map +0 -1
- package/dist/workers/runner-worker/module-runner-legacy.js.map +0 -1
- package/dist/workers/runner-worker/module-runner.js.map +0 -1
- package/dist/workers/vite-proxy-worker/index.js.map +0 -1
package/dist/cf-vite.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
|
|
3
|
-
//#region ../workers-utils/dist/chunk-
|
|
3
|
+
//#region ../workers-utils/dist/chunk-U6NEESU5.mjs
|
|
4
4
|
const require$1 = createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
5
5
|
var __create = Object.create;
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
@@ -40,5 +40,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
40
40
|
}) : target, mod));
|
|
41
41
|
|
|
42
42
|
//#endregion
|
|
43
|
-
export { __toESM as a, __require as i, __export as n, __name as r, __commonJS as t };
|
|
44
|
-
//# sourceMappingURL=chunk-53YJWLG7-dSmyuxCA.mjs.map
|
|
43
|
+
export { __toESM as a, __require as i, __export as n, __name as r, __commonJS as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -111,5 +111,4 @@ declare function getLocalWorkerdCompatibilityDate(_options?: {
|
|
|
111
111
|
*/
|
|
112
112
|
declare function cloudflare(pluginConfig?: PluginConfig): vite.Plugin[];
|
|
113
113
|
//#endregion
|
|
114
|
-
export { type PluginConfig, type WorkerConfig, cloudflare, getLocalWorkerdCompatibilityDate };
|
|
115
|
-
//# sourceMappingURL=index.d.mts.map
|
|
114
|
+
export { type PluginConfig, type WorkerConfig, cloudflare, getLocalWorkerdCompatibilityDate };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as __toESM$1, i as __require$1, n as __export, r as __name$3, t as __commonJS$1 } from "./chunk-
|
|
1
|
+
import { a as __toESM$1, i as __require$1, n as __export, r as __name$3, t as __commonJS$1 } from "./chunk-U6NEESU5-BzWFpRaS.mjs";
|
|
2
2
|
import { builtinModules, createRequire } from "node:module";
|
|
3
3
|
import * as fs$3 from "node:fs";
|
|
4
4
|
import fs2, { accessSync, appendFileSync, chmodSync, constants, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -63,7 +63,7 @@ var __toESM$2 = (mod$1, isNodeMode, target$1) => (target$1 = mod$1 != null ? __c
|
|
|
63
63
|
var __require$2 = /* @__PURE__ */ createRequire(import.meta.url);
|
|
64
64
|
|
|
65
65
|
//#endregion
|
|
66
|
-
//#region ../workers-utils/dist/chunk-
|
|
66
|
+
//#region ../workers-utils/dist/chunk-CAPCWVOB.mjs
|
|
67
67
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
68
68
|
var external_exports$1 = {};
|
|
69
69
|
__export(external_exports$1, {
|
|
@@ -19067,7 +19067,7 @@ function formatZodError(error62) {
|
|
|
19067
19067
|
__name$3(formatZodError, "formatZodError");
|
|
19068
19068
|
|
|
19069
19069
|
//#endregion
|
|
19070
|
-
//#region ../workers-utils/dist/chunk-
|
|
19070
|
+
//#region ../workers-utils/dist/chunk-M3RITKR3.mjs
|
|
19071
19071
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
19072
19072
|
function dedent$1(templ) {
|
|
19073
19073
|
var values = [];
|
|
@@ -19105,7 +19105,7 @@ __name$3(dedent$1, "dedent");
|
|
|
19105
19105
|
var esm_default$1 = dedent$1;
|
|
19106
19106
|
|
|
19107
19107
|
//#endregion
|
|
19108
|
-
//#region ../workers-utils/dist/chunk-
|
|
19108
|
+
//#region ../workers-utils/dist/chunk-OWPFSLY6.mjs
|
|
19109
19109
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
19110
19110
|
var UserError = class extends Error {
|
|
19111
19111
|
static {
|
|
@@ -19164,7 +19164,7 @@ function createFatalError(message, isJson, options) {
|
|
|
19164
19164
|
__name$3(createFatalError, "createFatalError");
|
|
19165
19165
|
|
|
19166
19166
|
//#endregion
|
|
19167
|
-
//#region ../workers-utils/dist/chunk-
|
|
19167
|
+
//#region ../workers-utils/dist/chunk-2HLTAS5V.mjs
|
|
19168
19168
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
19169
19169
|
function hasKnownExportType(entry) {
|
|
19170
19170
|
const type = entry?.type;
|
|
@@ -21679,7 +21679,7 @@ function formatConfigSnippet(snippet, configPath, formatted = true) {
|
|
|
21679
21679
|
__name$3(formatConfigSnippet, "formatConfigSnippet");
|
|
21680
21680
|
|
|
21681
21681
|
//#endregion
|
|
21682
|
-
//#region ../workers-utils/dist/chunk-
|
|
21682
|
+
//#region ../workers-utils/dist/chunk-QSRIB43D.mjs
|
|
21683
21683
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
21684
21684
|
function getBooleanEnvironmentVariableFactory(options) {
|
|
21685
21685
|
return () => {
|
|
@@ -21724,7 +21724,7 @@ var getDockerPath = getEnvironmentVariableFactory({
|
|
|
21724
21724
|
});
|
|
21725
21725
|
|
|
21726
21726
|
//#endregion
|
|
21727
|
-
//#region ../workers-utils/dist/chunk-
|
|
21727
|
+
//#region ../workers-utils/dist/chunk-MIA26B4M.mjs
|
|
21728
21728
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
21729
21729
|
function isDirectory(path$3) {
|
|
21730
21730
|
return fs2.statSync(path$3, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
@@ -21752,7 +21752,7 @@ function removeDirSync(dirPath) {
|
|
|
21752
21752
|
__name$3(removeDirSync, "removeDirSync");
|
|
21753
21753
|
|
|
21754
21754
|
//#endregion
|
|
21755
|
-
//#region ../workers-utils/dist/chunk-
|
|
21755
|
+
//#region ../workers-utils/dist/chunk-MV2OJK3L.mjs
|
|
21756
21756
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
21757
21757
|
function isWindows() {
|
|
21758
21758
|
return /^win/i.test(process.platform);
|
|
@@ -21884,7 +21884,7 @@ function getGlobalWranglerCachePath() {
|
|
|
21884
21884
|
__name$3(getGlobalWranglerCachePath, "getGlobalWranglerCachePath");
|
|
21885
21885
|
|
|
21886
21886
|
//#endregion
|
|
21887
|
-
//#region ../workers-utils/dist/chunk-
|
|
21887
|
+
//#region ../workers-utils/dist/chunk-FR75DWDU.mjs
|
|
21888
21888
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
21889
21889
|
var getC3CommandFromEnv = getEnvironmentVariableFactory({
|
|
21890
21890
|
variableName: "WRANGLER_C3_COMMAND",
|
|
@@ -52371,7 +52371,7 @@ function compareVersions(a, b) {
|
|
|
52371
52371
|
__name$3(compareVersions, "compareVersions");
|
|
52372
52372
|
async function openInBrowser(url$2, logger$2) {
|
|
52373
52373
|
try {
|
|
52374
|
-
const { default: open$3 } = await import("./open-
|
|
52374
|
+
const { default: open$3 } = await import("./open-PCXX3ZDZ-BXBWVkHI.mjs");
|
|
52375
52375
|
(await open$3(url$2)).on("error", (err) => {
|
|
52376
52376
|
handleBrowserOpenError(url$2, err, logger$2);
|
|
52377
52377
|
});
|
|
@@ -60615,6 +60615,7 @@ function getAssetsConfig(resolvedPluginConfig, entryWorkerConfig, resolvedConfig
|
|
|
60615
60615
|
...workerConfig?.compatibilityFlags ? { compatibility_flags: workerConfig.compatibilityFlags } : {},
|
|
60616
60616
|
...assetsConfig?.htmlHandling ? { html_handling: assetsConfig.htmlHandling } : {},
|
|
60617
60617
|
...assetsConfig?.notFoundHandling ? { not_found_handling: assetsConfig.notFoundHandling } : {},
|
|
60618
|
+
...assetsConfig?.basePath !== void 0 ? { base_path: assetsConfig.basePath } : {},
|
|
60618
60619
|
has_static_routing: resolvedPluginConfig.type === "workers" && resolvedPluginConfig.staticRouting ? true : false
|
|
60619
60620
|
};
|
|
60620
60621
|
if (!resolvedPluginConfig.experimental?.headersAndRedirectsDevModeSupport) return config$3;
|
|
@@ -65442,7 +65443,7 @@ function isInteractive() {
|
|
|
65442
65443
|
}
|
|
65443
65444
|
|
|
65444
65445
|
//#endregion
|
|
65445
|
-
//#region ../workers-auth/dist/chunk-
|
|
65446
|
+
//#region ../workers-auth/dist/chunk-VAZEJK55.mjs
|
|
65446
65447
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
65447
65448
|
var __defProp$2 = Object.defineProperty;
|
|
65448
65449
|
var __name$1 = (target$1, value) => __defProp$2(target$1, "name", {
|
|
@@ -65451,7 +65452,7 @@ var __name$1 = (target$1, value) => __defProp$2(target$1, "name", {
|
|
|
65451
65452
|
});
|
|
65452
65453
|
|
|
65453
65454
|
//#endregion
|
|
65454
|
-
//#region ../workers-auth/dist/chunk-
|
|
65455
|
+
//#region ../workers-auth/dist/chunk-2K52M2W5.mjs
|
|
65455
65456
|
var import_undici$2 = require_undici();
|
|
65456
65457
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
65457
65458
|
var hasWarnedAboutDeprecatedV1ApiToken = false;
|
|
@@ -67936,7 +67937,7 @@ function scrubEncryptedCredentials(options) {
|
|
|
67936
67937
|
__name$1(scrubEncryptedCredentials, "scrubEncryptedCredentials");
|
|
67937
67938
|
|
|
67938
67939
|
//#endregion
|
|
67939
|
-
//#region ../workers-auth/dist/chunk-
|
|
67940
|
+
//#region ../workers-auth/dist/chunk-F2REEYJC.mjs
|
|
67940
67941
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
67941
67942
|
function createPreferences(getConfigPath) {
|
|
67942
67943
|
function getUserPreferencesPath() {
|
|
@@ -87733,7 +87734,7 @@ function setKeyringPreference(enabled, ctx) {
|
|
|
87733
87734
|
__name$1(setKeyringPreference, "setKeyringPreference");
|
|
87734
87735
|
|
|
87735
87736
|
//#endregion
|
|
87736
|
-
//#region ../deploy-helpers/dist/chunk-
|
|
87737
|
+
//#region ../deploy-helpers/dist/chunk-U6NEESU5.mjs
|
|
87737
87738
|
const require$1 = createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
87738
87739
|
var __defProp = Object.defineProperty;
|
|
87739
87740
|
var __name = (target$1, value) => __defProp(target$1, "name", {
|
|
@@ -87855,7 +87856,7 @@ var require_command_exists = /* @__PURE__ */ __commonJS$2({ "../../node_modules/
|
|
|
87855
87856
|
}) });
|
|
87856
87857
|
|
|
87857
87858
|
//#endregion
|
|
87858
|
-
//#region ../deploy-helpers/dist/chunk-
|
|
87859
|
+
//#region ../deploy-helpers/dist/chunk-DSGVRFIS.mjs
|
|
87859
87860
|
var import_undici$1 = require_undici();
|
|
87860
87861
|
var import_command_exists = require_command_exists();
|
|
87861
87862
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
@@ -88426,7 +88427,7 @@ __name(createWorkerUploadForm, "createWorkerUploadForm");
|
|
|
88426
88427
|
//#endregion
|
|
88427
88428
|
//#region ../remote-bindings/dist/index.mjs
|
|
88428
88429
|
var import_undici = require_undici();
|
|
88429
|
-
var version$1 = "0.0.
|
|
88430
|
+
var version$1 = "0.0.49";
|
|
88430
88431
|
var NoDefaultValueProvided = class extends UserError {
|
|
88431
88432
|
constructor() {
|
|
88432
88433
|
super("This command cannot be run in a non-interactive context", { telemetryMessage: "remote bindings prompt default missing" });
|
|
@@ -88481,7 +88482,7 @@ let logger;
|
|
|
88481
88482
|
function initLogger(value) {
|
|
88482
88483
|
logger = value;
|
|
88483
88484
|
}
|
|
88484
|
-
var ProxyWorker_default = "// src/startDevWorker/utils.ts\nimport assert from \"node:assert\";\nvar PREVIEW_TOKEN_REFRESH_INTERVAL = 50 * 60 * 1e3;\nfunction createDeferred(previousDeferred) {\n let resolve, reject;\n const newPromise = new Promise((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n assert(resolve);\n assert(reject);\n previousDeferred?.resolve(newPromise);\n return {\n promise: newPromise,\n resolve,\n reject\n };\n}\nfunction urlFromParts(parts, base = \"http://localhost\") {\n const url = new URL(base);\n Object.assign(url, parts);\n return url;\n}\nfunction rewriteUrlInHeaderValue(value, from, to) {\n return value.replace(\n /(https?:\\/\\/[^/?#\\s,;\"']+)([^\\s,;\"']*)/gi,\n (match, origin, rest) => {\n let url;\n try {\n url = new URL(origin);\n } catch {\n return match;\n }\n if (url.host !== from.host) {\n return match;\n }\n return to.origin + rest;\n }\n );\n}\n\n// templates/startDevWorker/ProxyWorker.ts\nvar ProxyWorker_default = {\n fetch(req, env) {\n const singleton = env.DURABLE_OBJECT.idFromName(\"\");\n const inspectorProxy = env.DURABLE_OBJECT.get(singleton);\n return inspectorProxy.fetch(req);\n }\n};\nvar ProxyWorker = class {\n constructor(_state, env) {\n this.env = env;\n }\n env;\n proxyData;\n requestQueue = /* @__PURE__ */ new Map();\n requestRetryQueue = /* @__PURE__ */ new Map();\n fetch(request) {\n if (isRequestFromProxyController(request, this.env)) {\n return this.processProxyControllerRequest(request);\n }\n const deferred = createDeferred();\n this.requestQueue.set(request, deferred);\n this.processQueue();\n return deferred.promise;\n }\n processProxyControllerRequest(request) {\n const event = request.cf?.hostMetadata;\n switch (event?.type) {\n case \"pause\":\n this.proxyData = void 0;\n break;\n case \"play\":\n this.proxyData = event.proxyData;\n this.processQueue();\n break;\n }\n return new Response(null, { status: 204 });\n }\n /**\n * Process requests that are being retried first, then process newer requests.\n * Requests that are being retried are, by definition, older than requests which haven't been processed yet.\n * We don't need to be more accurate than this re ordering, since the requests are being fired off synchronously.\n */\n *getOrderedQueue() {\n yield* this.requestRetryQueue;\n yield* this.requestQueue;\n }\n processQueue() {\n const { proxyData } = this;\n if (proxyData === void 0) {\n return;\n }\n for (const [request, deferredResponse] of this.getOrderedQueue()) {\n this.requestRetryQueue.delete(request);\n this.requestQueue.delete(request);\n const outerUrl = new URL(request.url);\n const headers = new Headers(request.headers);\n const userWorkerUrl = new URL(request.url);\n Object.assign(userWorkerUrl, proxyData.userWorkerUrl);\n const innerUrl = urlFromParts(\n proxyData.userWorkerInnerUrlOverrides ?? {},\n request.url\n );\n const encoding = request.cf?.clientAcceptEncoding;\n if (encoding !== void 0) {\n headers.set(\"Accept-Encoding\", encoding);\n }\n rewriteUrlRelatedHeaders(headers, outerUrl, innerUrl);\n headers.set(\"MF-Original-URL\", innerUrl.href);\n for (const [key, value] of Object.entries(proxyData.headers ?? {})) {\n if (value === void 0) {\n continue;\n }\n if (key.toLowerCase() === \"cookie\") {\n const existing = request.headers.get(\"cookie\") ?? \"\";\n headers.set(\"cookie\", `${existing};${value}`);\n } else {\n headers.set(key, value);\n }\n }\n void fetch(userWorkerUrl, new Request(request, { headers })).then(async (res) => {\n res = new Response(res.body, res);\n rewriteUrlRelatedHeaders(res.headers, innerUrl, outerUrl);\n await checkForPreviewTokenError(res, this.env, proxyData);\n deferredResponse.resolve(res);\n }).catch((error) => {\n const newUserWorkerUrl = this.proxyData && urlFromParts(this.proxyData.userWorkerUrl);\n if (userWorkerUrl.href === newUserWorkerUrl?.href) {\n void sendMessageToProxyController(this.env, {\n type: \"error\",\n error: {\n name: error.name,\n message: error.message,\n stack: error.stack,\n cause: error.cause\n }\n });\n deferredResponse.reject(error);\n } else if (request.method === \"GET\" || request.method === \"HEAD\") {\n this.requestRetryQueue.set(request, deferredResponse);\n } else {\n deferredResponse.resolve(\n new Response(\n \"Your worker restarted mid-request. Please try sending the request again. Only GET or HEAD requests are retried automatically.\",\n {\n status: 503,\n headers: { \"Retry-After\": \"0\" }\n }\n )\n );\n }\n });\n }\n }\n};\nfunction isRequestFromProxyController(req, env) {\n return req.headers.get(\"Authorization\") === env.PROXY_CONTROLLER_AUTH_SECRET;\n}\nfunction sendMessageToProxyController(env, message) {\n return env.PROXY_CONTROLLER.fetch(\"http://dummy\", {\n method: \"POST\",\n body: JSON.stringify(message)\n });\n}\nasync function checkForPreviewTokenError(response, env, proxyData) {\n if (response.status !== 400) {\n return;\n }\n const clone = response.clone();\n const text = await clone.text();\n if (text.includes(\"Invalid Workers Preview configuration\") || text.includes(\"error code: 1031\")) {\n void sendMessageToProxyController(env, {\n type: \"previewTokenExpired\",\n proxyData\n });\n }\n}\nfunction rewriteUrlRelatedHeaders(headers, from, to) {\n const setCookie = headers.getAll(\"Set-Cookie\");\n headers.delete(\"Set-Cookie\");\n headers.forEach((value, key) => {\n if (typeof value === \"string\" && value.includes(from.host)) {\n headers.set(key, rewriteUrlInHeaderValue(value, from, to));\n }\n });\n for (const cookie of setCookie) {\n headers.append(\n \"Set-Cookie\",\n cookie.replace(\n new RegExp(`Domain=${from.hostname}($|;|,)`),\n `Domain=${to.hostname}$1`\n )\n );\n }\n}\nexport {\n ProxyWorker,\n ProxyWorker_default as default\n};\n";
|
|
88485
|
+
var ProxyWorker_default = "// src/startDevWorker/utils.ts\nimport assert from \"node:assert\";\nvar PREVIEW_TOKEN_REFRESH_INTERVAL = 50 * 60 * 1e3;\nvar PREVIEW_TOKEN_REFRESH_RETRY_INTERVAL = 60 * 1e3;\nfunction createDeferred(previousDeferred) {\n let resolve, reject;\n const newPromise = new Promise((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n assert(resolve);\n assert(reject);\n previousDeferred?.resolve(newPromise);\n return {\n promise: newPromise,\n resolve,\n reject\n };\n}\nfunction urlFromParts(parts, base = \"http://localhost\") {\n const url = new URL(base);\n Object.assign(url, parts);\n return url;\n}\nfunction rewriteUrlInHeaderValue(value, from, to) {\n return value.replace(\n /(https?:\\/\\/[^/?#\\s,;\"']+)([^\\s,;\"']*)/gi,\n (match, origin, rest) => {\n let url;\n try {\n url = new URL(origin);\n } catch {\n return match;\n }\n if (url.host !== from.host) {\n return match;\n }\n return to.origin + rest;\n }\n );\n}\n\n// templates/startDevWorker/ProxyWorker.ts\nvar ProxyWorker_default = {\n fetch(req, env) {\n const singleton = env.DURABLE_OBJECT.idFromName(\"\");\n const inspectorProxy = env.DURABLE_OBJECT.get(singleton);\n return inspectorProxy.fetch(req);\n }\n};\nvar ProxyWorker = class {\n constructor(_state, env) {\n this.env = env;\n }\n env;\n proxyData;\n requestQueue = /* @__PURE__ */ new Map();\n requestRetryQueue = /* @__PURE__ */ new Map();\n fetch(request) {\n if (isRequestFromProxyController(request, this.env)) {\n return this.processProxyControllerRequest(request);\n }\n const deferred = createDeferred();\n this.requestQueue.set(request, deferred);\n this.processQueue();\n return deferred.promise;\n }\n processProxyControllerRequest(request) {\n const event = request.cf?.hostMetadata;\n switch (event?.type) {\n case \"pause\":\n this.proxyData = void 0;\n break;\n case \"play\":\n this.proxyData = event.proxyData;\n this.processQueue();\n break;\n }\n return new Response(null, { status: 204 });\n }\n /**\n * Process requests that are being retried first, then process newer requests.\n * Requests that are being retried are, by definition, older than requests which haven't been processed yet.\n * We don't need to be more accurate than this re ordering, since the requests are being fired off synchronously.\n */\n *getOrderedQueue() {\n yield* this.requestRetryQueue;\n yield* this.requestQueue;\n }\n processQueue() {\n const { proxyData } = this;\n if (proxyData === void 0) {\n return;\n }\n for (const [request, deferredResponse] of this.getOrderedQueue()) {\n this.requestRetryQueue.delete(request);\n this.requestQueue.delete(request);\n const outerUrl = new URL(request.url);\n const headers = new Headers(request.headers);\n const userWorkerUrl = new URL(request.url);\n Object.assign(userWorkerUrl, proxyData.userWorkerUrl);\n const innerUrl = urlFromParts(\n proxyData.userWorkerInnerUrlOverrides ?? {},\n request.url\n );\n const encoding = request.cf?.clientAcceptEncoding;\n if (encoding !== void 0) {\n headers.set(\"Accept-Encoding\", encoding);\n }\n rewriteUrlRelatedHeaders(headers, outerUrl, innerUrl);\n headers.set(\"MF-Original-URL\", innerUrl.href);\n for (const [key, value] of Object.entries(proxyData.headers ?? {})) {\n if (value === void 0) {\n continue;\n }\n if (key.toLowerCase() === \"cookie\") {\n const existing = request.headers.get(\"cookie\") ?? \"\";\n headers.set(\"cookie\", `${existing};${value}`);\n } else {\n headers.set(key, value);\n }\n }\n void fetch(userWorkerUrl, new Request(request, { headers })).then(async (res) => {\n res = new Response(res.body, res);\n rewriteUrlRelatedHeaders(res.headers, innerUrl, outerUrl);\n await checkForPreviewTokenError(res, this.env, proxyData);\n deferredResponse.resolve(res);\n }).catch((error) => {\n const newUserWorkerUrl = this.proxyData && urlFromParts(this.proxyData.userWorkerUrl);\n if (userWorkerUrl.href === newUserWorkerUrl?.href) {\n void sendMessageToProxyController(this.env, {\n type: \"error\",\n error: {\n name: error.name,\n message: error.message,\n stack: error.stack,\n cause: error.cause\n }\n });\n deferredResponse.reject(error);\n } else if (request.method === \"GET\" || request.method === \"HEAD\") {\n this.requestRetryQueue.set(request, deferredResponse);\n } else {\n deferredResponse.resolve(\n new Response(\n \"Your worker restarted mid-request. Please try sending the request again. Only GET or HEAD requests are retried automatically.\",\n {\n status: 503,\n headers: { \"Retry-After\": \"0\" }\n }\n )\n );\n }\n });\n }\n }\n};\nfunction isRequestFromProxyController(req, env) {\n return req.headers.get(\"Authorization\") === env.PROXY_CONTROLLER_AUTH_SECRET;\n}\nfunction sendMessageToProxyController(env, message) {\n return env.PROXY_CONTROLLER.fetch(\"http://dummy\", {\n method: \"POST\",\n body: JSON.stringify(message)\n });\n}\nasync function checkForPreviewTokenError(response, env, proxyData) {\n if (response.status !== 400) {\n return;\n }\n const clone = response.clone();\n const text = await clone.text();\n if (text.includes(\"Invalid Workers Preview configuration\") || text.includes(\"error code: 1031\")) {\n void sendMessageToProxyController(env, {\n type: \"previewTokenExpired\",\n proxyData\n });\n }\n}\nfunction rewriteUrlRelatedHeaders(headers, from, to) {\n const setCookie = headers.getAll(\"Set-Cookie\");\n headers.delete(\"Set-Cookie\");\n headers.forEach((value, key) => {\n if (typeof value === \"string\" && value.includes(from.host)) {\n headers.set(key, rewriteUrlInHeaderValue(value, from, to));\n }\n });\n for (const cookie of setCookie) {\n headers.append(\n \"Set-Cookie\",\n cookie.replace(\n new RegExp(`Domain=${from.hostname}($|;|,)`),\n `Domain=${to.hostname}$1`\n )\n );\n }\n}\nexport {\n ProxyWorker,\n ProxyWorker_default as default\n};\n";
|
|
88485
88486
|
function castLogLevel(level) {
|
|
88486
88487
|
let key = level.toUpperCase();
|
|
88487
88488
|
if (key === "LOG") key = "INFO";
|
|
@@ -88514,6 +88515,15 @@ function castErrorCause(cause) {
|
|
|
88514
88515
|
* Preview tokens expire after 1 hour (hardcoded in the Workers control plane), so we retry after 50 mins.
|
|
88515
88516
|
*/
|
|
88516
88517
|
const PREVIEW_TOKEN_REFRESH_INTERVAL = 3e3 * 1e3;
|
|
88518
|
+
/**
|
|
88519
|
+
* How soon to try again after a proactive preview token refresh fails (e.g.
|
|
88520
|
+
* the machine is offline). A failed refresh must not give up the retry cycle
|
|
88521
|
+
* for good — otherwise a network outage longer than the API's own few quick
|
|
88522
|
+
* retries (see `retryOnAPIFailure`) permanently strands the session even
|
|
88523
|
+
* after connectivity returns, since nothing else re-triggers a refresh
|
|
88524
|
+
* attempt for a long-lived session like `getPlatformProxy()`'s.
|
|
88525
|
+
*/
|
|
88526
|
+
const PREVIEW_TOKEN_REFRESH_RETRY_INTERVAL = 60 * 1e3;
|
|
88517
88527
|
function createDeferred(previousDeferred) {
|
|
88518
88528
|
let resolve$3, reject;
|
|
88519
88529
|
const newPromise = new Promise((_resolve$1, _reject) => {
|
|
@@ -88929,6 +88939,7 @@ var RemoteRuntimeController = class {
|
|
|
88929
88939
|
#latestBundle;
|
|
88930
88940
|
#latestProxyData;
|
|
88931
88941
|
#refreshTimer;
|
|
88942
|
+
#sessionCreatedAt;
|
|
88932
88943
|
#tearingDown = false;
|
|
88933
88944
|
constructor(onError$1, onReloadComplete) {
|
|
88934
88945
|
this.onError = onError$1;
|
|
@@ -88936,7 +88947,9 @@ var RemoteRuntimeController = class {
|
|
|
88936
88947
|
}
|
|
88937
88948
|
async #previewSession(props) {
|
|
88938
88949
|
try {
|
|
88939
|
-
|
|
88950
|
+
const session = await retryOnAPIFailure(() => createPreviewSession(props.complianceConfig, props, this.#abortController.signal, props.name, props.cliDisplayName), logger, void 0, void 0, this.#abortController.signal);
|
|
88951
|
+
if (session) this.#sessionCreatedAt = Date.now();
|
|
88952
|
+
return session;
|
|
88940
88953
|
} catch (err) {
|
|
88941
88954
|
if (err instanceof Error && err.name == "AbortError") return;
|
|
88942
88955
|
handlePreviewSessionCreationError(err, props.accountId);
|
|
@@ -89041,9 +89054,13 @@ var RemoteRuntimeController = class {
|
|
|
89041
89054
|
}
|
|
89042
89055
|
#scheduleRefresh(interval) {
|
|
89043
89056
|
clearTimeout(this.#refreshTimer);
|
|
89057
|
+
const delay = interval === PREVIEW_TOKEN_REFRESH_INTERVAL && this.#sessionCreatedAt !== void 0 ? Math.max(0, PREVIEW_TOKEN_REFRESH_INTERVAL - (Date.now() - this.#sessionCreatedAt)) : interval;
|
|
89044
89058
|
this.#refreshTimer = setTimeout(() => {
|
|
89059
|
+
this.#refreshTimer = void 0;
|
|
89045
89060
|
if (this.#latestProxyData) this.onPreviewTokenExpired();
|
|
89046
|
-
|
|
89061
|
+
else if (!this.#tearingDown) this.#scheduleRefresh(PREVIEW_TOKEN_REFRESH_RETRY_INTERVAL);
|
|
89062
|
+
}, delay);
|
|
89063
|
+
this.#refreshTimer.unref?.();
|
|
89047
89064
|
}
|
|
89048
89065
|
async #onBundleComplete({ config: config$3, bundle }, id) {
|
|
89049
89066
|
if (id !== this.#currentBundleId) return;
|
|
@@ -89071,10 +89088,14 @@ var RemoteRuntimeController = class {
|
|
|
89071
89088
|
logger.warn("Cannot refresh preview token: missing config or bundle data");
|
|
89072
89089
|
return;
|
|
89073
89090
|
}
|
|
89091
|
+
const bundleId = this.#currentBundleId;
|
|
89092
|
+
const abortSignal = this.#abortController.signal;
|
|
89093
|
+
const shouldRetry = () => bundleId === this.#currentBundleId && !abortSignal.aborted && !this.#tearingDown;
|
|
89074
89094
|
try {
|
|
89075
89095
|
const auth = await unwrapHook(this.#latestConfig.auth);
|
|
89076
89096
|
this.#session = await this.#getPreviewSession(this.#latestConfig, auth);
|
|
89077
|
-
if (await this.#updatePreviewToken(this.#latestConfig, this.#latestBundle, auth,
|
|
89097
|
+
if (await this.#updatePreviewToken(this.#latestConfig, this.#latestBundle, auth, bundleId)) logger.log(source_default.green("✔ Preview token refreshed successfully"));
|
|
89098
|
+
else if (shouldRetry()) this.#scheduleRefresh(PREVIEW_TOKEN_REFRESH_RETRY_INTERVAL);
|
|
89078
89099
|
} catch (error$3) {
|
|
89079
89100
|
if (error$3 instanceof Error && error$3.name == "AbortError") return;
|
|
89080
89101
|
this.emitErrorEvent({
|
|
@@ -89084,12 +89105,13 @@ var RemoteRuntimeController = class {
|
|
|
89084
89105
|
source: "RemoteRuntimeController",
|
|
89085
89106
|
data: void 0
|
|
89086
89107
|
});
|
|
89108
|
+
if (shouldRetry()) this.#scheduleRefresh(PREVIEW_TOKEN_REFRESH_RETRY_INTERVAL);
|
|
89087
89109
|
}
|
|
89088
89110
|
}
|
|
89089
89111
|
onUpdateStart() {
|
|
89090
89112
|
this.#abortController.abort();
|
|
89091
89113
|
this.#abortController = new AbortController();
|
|
89092
|
-
|
|
89114
|
+
if (!this.#refreshTimer && this.#latestProxyData && !this.#tearingDown) this.#scheduleRefresh(PREVIEW_TOKEN_REFRESH_RETRY_INTERVAL);
|
|
89093
89115
|
}
|
|
89094
89116
|
onBundleComplete(ev) {
|
|
89095
89117
|
const id = ++this.#currentBundleId;
|
|
@@ -89417,6 +89439,12 @@ function getRemoteBindings(config$3) {
|
|
|
89417
89439
|
remote: binding.dev?.remote
|
|
89418
89440
|
};
|
|
89419
89441
|
break;
|
|
89442
|
+
case "analytics":
|
|
89443
|
+
bindings[name] = {
|
|
89444
|
+
type: "analytics",
|
|
89445
|
+
remote: binding.dev?.remote
|
|
89446
|
+
};
|
|
89447
|
+
break;
|
|
89420
89448
|
case "ai-search":
|
|
89421
89449
|
bindings[name] = {
|
|
89422
89450
|
type: "ai_search",
|
|
@@ -89503,6 +89531,13 @@ function getRemoteBindings(config$3) {
|
|
|
89503
89531
|
remote: binding.dev?.remote
|
|
89504
89532
|
};
|
|
89505
89533
|
break;
|
|
89534
|
+
case "k2":
|
|
89535
|
+
bindings[name] = {
|
|
89536
|
+
type: "k2",
|
|
89537
|
+
stream: binding.stream,
|
|
89538
|
+
remote: binding.dev?.remote
|
|
89539
|
+
};
|
|
89540
|
+
break;
|
|
89506
89541
|
case "queue":
|
|
89507
89542
|
bindings[name] = {
|
|
89508
89543
|
type: "queue",
|
|
@@ -89681,7 +89716,7 @@ function createRemoteBindingsLogger(logger$2) {
|
|
|
89681
89716
|
}
|
|
89682
89717
|
function getWorkerZone(config$3) {
|
|
89683
89718
|
const domain$1 = config$3.domains?.[0];
|
|
89684
|
-
if (domain$1 !== void 0) return getZoneFromRoute(domain$1);
|
|
89719
|
+
if (domain$1 !== void 0) return getZoneFromRoute(typeof domain$1 === "string" ? domain$1 : domain$1.hostname);
|
|
89685
89720
|
const fetchTrigger = config$3.triggers?.find((trigger) => trigger.type === "fetch");
|
|
89686
89721
|
if (fetchTrigger?.type !== "fetch") return;
|
|
89687
89722
|
return getZoneFromRoute(fetchTrigger.zone?.includes(".") ? {
|
|
@@ -91307,5 +91342,4 @@ function cloudflare(pluginConfig = {}) {
|
|
|
91307
91342
|
}
|
|
91308
91343
|
|
|
91309
91344
|
//#endregion
|
|
91310
|
-
export { cloudflare, getLocalWorkerdCompatibilityDate };
|
|
91311
|
-
//# sourceMappingURL=index.mjs.map
|
|
91345
|
+
export { cloudflare, getLocalWorkerdCompatibilityDate };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as __name } from "./chunk-
|
|
1
|
+
import { r as __name } from "./chunk-U6NEESU5-BzWFpRaS.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fs2 from "node:fs";
|
|
4
4
|
import path__default from "node:path";
|
|
@@ -10,7 +10,7 @@ import { Buffer } from "node:buffer";
|
|
|
10
10
|
import fs, { constants as constants$1 } from "node:fs/promises";
|
|
11
11
|
import childProcess, { execFile } from "node:child_process";
|
|
12
12
|
|
|
13
|
-
//#region ../workers-utils/dist/open-
|
|
13
|
+
//#region ../workers-utils/dist/open-PCXX3ZDZ.mjs
|
|
14
14
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
15
15
|
var isDockerCached;
|
|
16
16
|
function hasDockerEnv() {
|
|
@@ -527,5 +527,4 @@ defineLazyProperty(apps, "safari", () => detectPlatformBinary({ darwin: "Safari"
|
|
|
527
527
|
var open_default = open;
|
|
528
528
|
|
|
529
529
|
//#endregion
|
|
530
|
-
export { open_default as default };
|
|
531
|
-
//# sourceMappingURL=open-NPEHYJ5T-C8ZFejjd.mjs.map
|
|
530
|
+
export { open_default as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@cloudflare/vite-plugin",
|
|
4
|
-
version: "2.0.0-beta.
|
|
4
|
+
version: "2.0.0-beta.v.1",
|
|
5
5
|
description: "Cloudflare plugin for Vite",
|
|
6
6
|
keywords: [
|
|
7
7
|
"cloudflare",
|
|
@@ -39,11 +39,11 @@ var package_default = {
|
|
|
39
39
|
"test:watch": "vitest"
|
|
40
40
|
},
|
|
41
41
|
dependencies: {
|
|
42
|
-
"@cloudflare/build-output-utils": "
|
|
43
|
-
"@cloudflare/config": "
|
|
44
|
-
"@cloudflare/runtime-types": "
|
|
45
|
-
"@cloudflare/unenv-preset": "
|
|
46
|
-
"miniflare": "
|
|
42
|
+
"@cloudflare/build-output-utils": "workspace:*",
|
|
43
|
+
"@cloudflare/config": "workspace:*",
|
|
44
|
+
"@cloudflare/runtime-types": "workspace:*",
|
|
45
|
+
"@cloudflare/unenv-preset": "workspace:*",
|
|
46
|
+
"miniflare": "workspace:*",
|
|
47
47
|
"unenv": "2.0.0-rc.24",
|
|
48
48
|
"ws": "catalog:default"
|
|
49
49
|
},
|
|
@@ -79,9 +79,14 @@ var package_default = {
|
|
|
79
79
|
"vitest": "catalog:default"
|
|
80
80
|
},
|
|
81
81
|
peerDependencies: { "vite": "^7.0.0 || ^8.0.0" },
|
|
82
|
-
"workers-sdk": {
|
|
82
|
+
"workers-sdk": {
|
|
83
|
+
"prerelease": true,
|
|
84
|
+
"npmPrerelease": {
|
|
85
|
+
"tag": "beta",
|
|
86
|
+
"numbered": true
|
|
87
|
+
}
|
|
88
|
+
}
|
|
83
89
|
};
|
|
84
90
|
|
|
85
91
|
//#endregion
|
|
86
|
-
export { package_default as default };
|
|
87
|
-
//# sourceMappingURL=package-DN5VHrZK.mjs.map
|
|
92
|
+
export { package_default as default };
|
|
@@ -6411,5 +6411,4 @@ function shouldBlockContentType(response) {
|
|
|
6411
6411
|
}
|
|
6412
6412
|
|
|
6413
6413
|
//#endregion
|
|
6414
|
-
export { RouterInnerEntrypoint, RouterOuterEntrypoint, worker_default as default };
|
|
6415
|
-
//# sourceMappingURL=index.js.map
|
|
6414
|
+
export { RouterInnerEntrypoint, RouterOuterEntrypoint, worker_default as default };
|
|
@@ -453,5 +453,4 @@ function createWorkflowEntrypointWrapper(exportName) {
|
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
//#endregion
|
|
456
|
-
export { __VITE_RUNNER_OBJECT__, createDurableObjectWrapper, createWorkerEntrypointWrapper, createWorkflowEntrypointWrapper };
|
|
457
|
-
//# sourceMappingURL=index.js.map
|
|
456
|
+
export { __VITE_RUNNER_OBJECT__, createDurableObjectWrapper, createWorkerEntrypointWrapper, createWorkflowEntrypointWrapper };
|
|
@@ -1126,5 +1126,4 @@ function exportAll(exports, sourceModule) {
|
|
|
1126
1126
|
}
|
|
1127
1127
|
|
|
1128
1128
|
//#endregion
|
|
1129
|
-
export { ESModulesEvaluator, EvaluatedModules, ModuleRunner, createDefaultImportMeta, createNodeImportMeta, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|
|
1130
|
-
//# sourceMappingURL=module-runner-legacy.js.map
|
|
1129
|
+
export { ESModulesEvaluator, EvaluatedModules, ModuleRunner, createDefaultImportMeta, createNodeImportMeta, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|
|
@@ -1232,5 +1232,4 @@ function exportAll(exports, sourceModule) {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
|
|
1234
1234
|
//#endregion
|
|
1235
|
-
export { ESModulesEvaluator, EvaluatedModules, ModuleRunner, createDefaultImportMeta, createNodeImportMeta, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|
|
1236
|
-
//# sourceMappingURL=module-runner.js.map
|
|
1235
|
+
export { ESModulesEvaluator, EvaluatedModules, ModuleRunner, createDefaultImportMeta, createNodeImportMeta, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.v.1",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@cloudflare/build-output-utils": "0.9.2",
|
|
44
|
-
"@cloudflare/config": "0.26.0",
|
|
45
|
-
"@cloudflare/runtime-types": "0.1.11",
|
|
46
|
-
"@cloudflare/unenv-preset": "2.16.2",
|
|
47
|
-
"miniflare": "5.20261012.0-beta",
|
|
48
43
|
"unenv": "2.0.0-rc.24",
|
|
49
|
-
"ws": "8.21.0"
|
|
44
|
+
"ws": "8.21.0",
|
|
45
|
+
"@cloudflare/config": "0.27.0",
|
|
46
|
+
"@cloudflare/runtime-types": "0.1.12",
|
|
47
|
+
"@cloudflare/build-output-utils": "0.9.3",
|
|
48
|
+
"@cloudflare/unenv-preset": "2.16.2",
|
|
49
|
+
"miniflare": "5.20261012.1-beta"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@cloudflare/workers-types": "^5.20261006.1",
|
|
@@ -70,20 +70,24 @@
|
|
|
70
70
|
"vite": "8.1.5",
|
|
71
71
|
"vite-legacy": "npm:vite@7.1.12",
|
|
72
72
|
"vitest": "4.1.0",
|
|
73
|
-
"@cloudflare/containers-shared": "0.21.7",
|
|
74
73
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
74
|
+
"@cloudflare/containers-shared": "0.22.1",
|
|
75
75
|
"@cloudflare/workers-auth": "0.14.0",
|
|
76
|
-
"@cloudflare/remote-bindings": "0.0.47",
|
|
77
|
-
"@cloudflare/cli-shared-helpers": "0.2.6",
|
|
78
76
|
"@cloudflare/workers-shared": "0.20.1",
|
|
79
|
-
"@cloudflare/
|
|
80
|
-
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
77
|
+
"@cloudflare/remote-bindings": "0.0.49",
|
|
78
|
+
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
79
|
+
"@cloudflare/cli-shared-helpers": "0.2.6",
|
|
80
|
+
"@cloudflare/workers-utils": "0.47.2"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"vite": "^7.0.0 || ^8.0.0"
|
|
84
84
|
},
|
|
85
85
|
"workers-sdk": {
|
|
86
|
-
"prerelease": true
|
|
86
|
+
"prerelease": true,
|
|
87
|
+
"npmPrerelease": {
|
|
88
|
+
"tag": "beta",
|
|
89
|
+
"numbered": true
|
|
90
|
+
}
|
|
87
91
|
},
|
|
88
92
|
"scripts": {
|
|
89
93
|
"build": "tsdown",
|
package/dist/cf-vite.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cf-vite.mjs","names":["nodeParseArgs","out: DevArgs","out: BuildArgs","args: DevArgs","serverOptions: ServerOptions","inlineConfig: InlineConfig","args: BuildArgs"],"sources":["../src/build-output-env.ts","../src/cf-vite.ts"],"sourcesContent":["/** Internal caller name set by the `cf-vite` delegate. */\nexport const CLI_DISPLAY_NAME_ENV_VAR = \"CLOUDFLARE_VITE_CLI_DISPLAY_NAME\";\n\n/** Shared build context flag set by Cloudflare tooling for Preview builds. */\nexport const PREVIEW_BUILD_ENV_VAR = \"CLOUDFLARE_PREVIEW_BUILD\";\n\n/** Return the CLI name used in actionable messages. */\nexport function getCliDisplayName(): \"cf\" | \"Wrangler\" {\n\treturn process.env[CLI_DISPLAY_NAME_ENV_VAR] === \"cf\" ? \"cf\" : \"Wrangler\";\n}\n\n/** Whether Cloudflare tooling requested Preview Build Output. */\nexport function isPreviewBuild(): boolean {\n\treturn process.env[PREVIEW_BUILD_ENV_VAR] === \"true\";\n}\n","/**\n * `cf-vite` delegate binary entry point for `@cloudflare/vite-plugin`.\n *\n * EXPERIMENTAL / internal: spawned by Cloudflare's \"cf-dev\" parent\n * process, not invoked directly by end users. Contract may change.\n *\n * Usage: `<pkgRoot>/bin/cf-vite <verb> [flags...]`. `dev` and `build`\n * are the verbs today; future verbs follow the same shape.\n * Unknown/missing verbs exit 2 (also the parent's version-detection\n * signal).\n *\n * Spawn contract for `dev`: parent uses `stdio: \"inherit\"` and forwards\n * SIGINT/SIGTERM. Accepted flags mirror the sibling `cf-wrangler`\n * delegate (`--mode`, `--port`, `--host`, `--local`) so the parent can\n * drive either impl interchangeably; everything else lives in the user's\n * `vite.config.ts` / `cloudflare.config.ts`. `cf-vite` boots\n * Vite via `createServer()` against the user's own config (expected to\n * include `cloudflare()`); flags are bridged to it as documented inline.\n *\n * `build` runs Vite's full multi-environment app build via\n * `createBuilder().buildApp()` (NOT the legacy single-environment\n * `build()` helper, which would skip the plugin's worker builds). It\n * accepts only `--mode`. Preview build context is supplied through the\n * `CLOUDFLARE_PREVIEW_BUILD` environment variable so framework-owned build\n * commands can use the same contract.\n *\n * Exit codes: 0 graceful, 2 unknown verb / parse error, 130 SIGINT,\n * 143 SIGTERM.\n */\n\nimport { parseArgs as nodeParseArgs } from \"node:util\";\nimport { createBuilder, createServer } from \"vite\";\nimport { CLI_DISPLAY_NAME_ENV_VAR } from \"./build-output-env\";\nimport type { InlineConfig, ServerOptions } from \"vite\";\n\ninterface DevArgs {\n\tmode?: string;\n\tport?: number;\n\thost?: string;\n\tlocal?: boolean;\n}\n\nclass ArgParseError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"ArgParseError\";\n\t}\n}\n\n/** Strict argv parser; mirrors `cf-wrangler`'s flags (unknown → throw). */\nfunction parseDevArgs(argv: string[]): DevArgs {\n\tlet parsed;\n\ttry {\n\t\tparsed = nodeParseArgs({\n\t\t\targs: argv,\n\t\t\toptions: {\n\t\t\t\tmode: { type: \"string\" },\n\t\t\t\thost: { type: \"string\" },\n\t\t\t\t// `node:util.parseArgs` has no `number` type; coerce below.\n\t\t\t\tport: { type: \"string\" },\n\t\t\t\tlocal: { type: \"boolean\" },\n\t\t\t},\n\t\t\tstrict: true,\n\t\t\tallowPositionals: false,\n\t\t});\n\t} catch (err) {\n\t\tthrow new ArgParseError(err instanceof Error ? err.message : String(err));\n\t}\n\n\tconst out: DevArgs = {};\n\tif (parsed.values.mode !== undefined) {\n\t\tout.mode = parsed.values.mode;\n\t}\n\tif (parsed.values.host !== undefined) {\n\t\tout.host = parsed.values.host;\n\t}\n\tif (parsed.values.port !== undefined) {\n\t\tconst raw = parsed.values.port;\n\t\tconst n = Number(raw);\n\t\t// TCP port range; 0 = OS-assigned.\n\t\tif (!Number.isInteger(n) || n < 0 || n > 65535) {\n\t\t\tthrow new ArgParseError(\n\t\t\t\t`--port expects an integer between 0 and 65535, got \"${raw}\"`\n\t\t\t);\n\t\t}\n\t\tout.port = n;\n\t}\n\tif (parsed.values.local !== undefined) {\n\t\tout.local = parsed.values.local;\n\t}\n\n\treturn out;\n}\n\ninterface BuildArgs {\n\tmode?: string;\n}\n\nfunction parseBuildArgs(argv: string[]): BuildArgs {\n\tlet parsed;\n\ttry {\n\t\tparsed = nodeParseArgs({\n\t\t\targs: argv,\n\t\t\toptions: {\n\t\t\t\tmode: { type: \"string\" },\n\t\t\t},\n\t\t\tstrict: true,\n\t\t\tallowPositionals: false,\n\t\t});\n\t} catch (err) {\n\t\tthrow new ArgParseError(err instanceof Error ? err.message : String(err));\n\t}\n\n\tconst out: BuildArgs = {};\n\tif (parsed.values.mode !== undefined) {\n\t\tout.mode = parsed.values.mode;\n\t}\n\n\treturn out;\n}\n\nasync function main(): Promise<number> {\n\tprocess.env[CLI_DISPLAY_NAME_ENV_VAR] = \"cf\";\n\n\t// argv: [0] node [1] cf-vite.mjs [2] verb [3+] forwarded flags.\n\tconst verb = process.argv[2];\n\tconst userArgv = process.argv.slice(3);\n\n\tif (verb === \"dev\") {\n\t\treturn runDev(userArgv);\n\t}\n\n\tif (verb === \"build\") {\n\t\treturn runBuild(userArgv);\n\t}\n\n\t// Format mirrors `cf-wrangler`.\n\tprocess.stderr.write(\n\t\t`Error: unknown subcommand \"${verb ?? \"\"}\".\\n` +\n\t\t\t`Usage: cf-vite <dev|build> [args]\\n`\n\t);\n\treturn 2;\n}\n\nasync function runDev(userArgv: string[]): Promise<number> {\n\tlet args: DevArgs;\n\ttry {\n\t\targs = parseDevArgs(userArgv);\n\t} catch (err) {\n\t\tif (err instanceof ArgParseError) {\n\t\t\tprocess.stderr.write(`Error: ${err.message}\\n`);\n\t\t\treturn 2;\n\t\t}\n\t\tthrow err;\n\t}\n\n\t// Bridge plugin-owned flags via env vars the plugin reads during config\n\t// resolution — must be set before `createServer()`.\n\t// - `--local`: overrides `remoteBindings` outright, mirroring\n\t// `wrangler dev --local` (force local even if config opts into\n\t// remote).\n\tif (args.local) {\n\t\tprocess.env.CLOUDFLARE_VITE_FORCE_LOCAL = \"true\";\n\t}\n\n\t// Bridge Vite-owned flags via inline config; the rest auto-loads from\n\t// the user's `vite.config.{ts,js,mjs}` (which supplies `cloudflare()`).\n\tconst serverOptions: ServerOptions = {};\n\tif (args.port !== undefined) {\n\t\tserverOptions.port = args.port;\n\t}\n\tif (args.host !== undefined) {\n\t\tserverOptions.host = args.host;\n\t}\n\tconst inlineConfig: InlineConfig = { server: serverOptions };\n\tif (args.mode !== undefined) {\n\t\tinlineConfig.mode = args.mode;\n\t}\n\n\tconst server = await createServer(inlineConfig);\n\n\tawait server.listen();\n\tserver.printUrls();\n\tserver.bindCLIShortcuts({ print: true });\n\n\t// Close cleanly on signal so the dev registry entry, workerd\n\t// subprocess, and ports release. `closing` guards against a\n\t// double-signal (e.g. rapid Ctrl+C, or SIGINT then SIGTERM) racing\n\t// two `server.close()` / `process.exit()` calls.\n\tlet closing = false;\n\tconst shutdown = (signal: NodeJS.Signals) => {\n\t\tif (closing) {\n\t\t\treturn;\n\t\t}\n\t\tclosing = true;\n\t\t// Signal handlers can't be async; void the IIFE to avoid unhandled\n\t\t// rejections if `close()` throws.\n\t\tvoid (async () => {\n\t\t\ttry {\n\t\t\t\tawait server.close();\n\t\t\t\tprocess.exit(0);\n\t\t\t} catch {\n\t\t\t\t// Forced-exit: terminate with the 128+N code rather than\n\t\t\t\t// hang. SIGINT=130, SIGTERM=143.\n\t\t\t\tprocess.exit(signal === \"SIGINT\" ? 130 : 143);\n\t\t\t}\n\t\t})();\n\t};\n\tprocess.on(\"SIGINT\", () => shutdown(\"SIGINT\"));\n\tprocess.on(\"SIGTERM\", () => shutdown(\"SIGTERM\"));\n\n\t// Keep the event loop alive until a signal handler exits; Vite's own\n\t// handles (HTTP listener, watchers, workerd) hold the process open.\n\treturn new Promise<number>(() => {});\n}\n\nasync function runBuild(userArgv: string[]): Promise<number> {\n\tlet args: BuildArgs;\n\ttry {\n\t\targs = parseBuildArgs(userArgv);\n\t} catch (err) {\n\t\tif (err instanceof ArgParseError) {\n\t\t\tprocess.stderr.write(`Error: ${err.message}\\n`);\n\t\t\treturn 2;\n\t\t}\n\t\tthrow err;\n\t}\n\n\tconst inlineConfig: InlineConfig = {};\n\tif (args.mode !== undefined) {\n\t\tinlineConfig.mode = args.mode;\n\t}\n\tconst builder = await createBuilder(inlineConfig);\n\tawait builder.buildApp();\n\n\treturn 0;\n}\n\n// Let unhandled rejections propagate — Node prints the stack and exits\n// non-zero, which the parent surfaces via inherited stdio.\nconst exitCode = await main();\nprocess.exit(exitCode);\n"],"mappings":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AAG;;AAGrC,eAAe,SAAS,UAAqC;CAC5D,IAAIC;AACJ,KAAI;AACH,SAAO,eAAe,SAAS;UACvB,KAAK;AACb,MAAI,eAAe,eAAe;AACjC,WAAQ,OAAO,MAAM,UAAU,IAAI,QAAQ,IAAI;AAC/C,UAAO;;AAER,QAAM;;CAGP,MAAMD,eAA6B,EAAE;AACrC,KAAI,KAAK,SAAS,OACjB,cAAa,OAAO,KAAK;AAG1B,QADgB,MAAM,cAAc,aAAa,EACnC,UAAU;AAExB,QAAO;;AAKR,MAAM,WAAW,MAAM,MAAM;AAC7B,QAAQ,KAAK,SAAS"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-53YJWLG7-dSmyuxCA.mjs","names":[],"sources":["../../workers-utils/dist/chunk-53YJWLG7.mjs"],"sourcesContent":["import { createRequire } from 'node:module';\n\nconst require$1 = createRequire(import.meta.url || (typeof __filename === \"string\" ? __filename : \"/\"));\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\nvar __require = /* @__PURE__ */ ((x) => typeof require$1 !== \"undefined\" ? require$1 : typeof Proxy !== \"undefined\" ? new Proxy(x, {\n get: (a, b) => (typeof require$1 !== \"undefined\" ? require$1 : a)[b]\n}) : x)(function(x) {\n if (typeof require$1 !== \"undefined\") return require$1.apply(this, arguments);\n throw Error('Dynamic require of \"' + x + '\" is not supported');\n});\nvar __commonJS = (cb, mod) => function __require2() {\n return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;\n};\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\n\nexport { __commonJS, __export, __name, __require, __toESM };\n//# sourceMappingURL=chunk-53YJWLG7.mjs.map\n//# sourceMappingURL=chunk-53YJWLG7.mjs.map"],"mappings":";;;AAEA,MAAM,YAAY,cAAc,OAAO,KAAK,QAAQ,OAAO,eAAe,WAAW,aAAa,KAAK;AACvG,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,UAAU,QAAQ,UAAU,UAAU,QAAQ,QAAQ;CAAE;CAAO,cAAc;CAAM,CAAC;AACxF,IAAI,YAA4B,kBAAE,MAAM,OAAO,cAAc,cAAc,YAAY,OAAO,UAAU,cAAc,IAAI,MAAM,GAAG,EACjI,MAAM,GAAG,OAAO,OAAO,cAAc,cAAc,YAAY,GAAG,IACnE,CAAC,GAAG,GAAG,SAAS,GAAG;AAClB,KAAI,OAAO,cAAc,YAAa,QAAO,UAAU,MAAM,MAAM,UAAU;AAC7E,OAAM,MAAM,0BAAyB,IAAI,sBAAqB;EAC9D;AACF,IAAI,cAAc,IAAI,QAAQ,SAAS,aAAa;AAClD,QAAO,QAAQ,GAAG,GAAG,kBAAkB,GAAG,CA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