rsbuild-plugin-cloudflare 0.0.4 → 0.0.5
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/README.md +2 -2
- package/dist/index.mjs +248 -122
- package/dist/{package-B-VELg8f.mjs → package-Dbs6JNJH.mjs} +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -238,8 +238,8 @@ Other differences:
|
|
|
238
238
|
bare specifier isn't recognised as it. Rsbuild doesn't use that `index.html`
|
|
239
239
|
as the page's template unless `html.template` is set to it. Without a client,
|
|
240
240
|
as in the Vite plugin, the client output has only the public assets (and the
|
|
241
|
-
assets that the entry
|
|
242
|
-
or a prerender Worker.
|
|
241
|
+
assets that the entry and prerender Workers import), and `assetsOnly` requires
|
|
242
|
+
public assets or a prerender Worker.
|
|
243
243
|
- `devOnly` and `assetsOnly` functions are called when the config is resolved,
|
|
244
244
|
to choose the Worker environments to build, rather than lazily at build time.
|
|
245
245
|
- Additional modules (e.g. `.wasm` and `.txt` imports) are emitted at the root
|
package/dist/index.mjs
CHANGED
|
@@ -15,9 +15,9 @@ import process$1, { exit, stdin, stdout } from "node:process";
|
|
|
15
15
|
import os, { arch, release, tmpdir } from "node:os";
|
|
16
16
|
import tty from "node:tty";
|
|
17
17
|
import P from "node:readline";
|
|
18
|
+
import http, { validateHeaderName, validateHeaderValue } from "node:http";
|
|
18
19
|
import url, { URL as URL$1, URLSearchParams as URLSearchParams$1, fileURLToPath, pathToFileURL } from "node:url";
|
|
19
20
|
import net, { createServer } from "node:net";
|
|
20
|
-
import http from "node:http";
|
|
21
21
|
import events, { EventEmitter, once } from "node:events";
|
|
22
22
|
import crypto2, { createCipheriv, createDecipheriv, createHash, randomBytes, randomUUID, webcrypto } from "node:crypto";
|
|
23
23
|
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
@@ -500,14 +500,8 @@ __name$3(copyProcessEnv, "copyProcessEnv");
|
|
|
500
500
|
|
|
501
501
|
//#endregion
|
|
502
502
|
//#region ../../workers-sdk/packages/vite-plugin-cloudflare/src/build-output-env.ts
|
|
503
|
-
/** Internal caller name set by the `cf-vite` delegate. */
|
|
504
|
-
const CLI_DISPLAY_NAME_ENV_VAR = "CLOUDFLARE_VITE_CLI_DISPLAY_NAME";
|
|
505
503
|
/** Shared build context flag set by Cloudflare tooling for Preview builds. */
|
|
506
504
|
const PREVIEW_BUILD_ENV_VAR = "CLOUDFLARE_PREVIEW_BUILD";
|
|
507
|
-
/** Return the CLI name used in actionable messages. */
|
|
508
|
-
function getCliDisplayName() {
|
|
509
|
-
return process.env[CLI_DISPLAY_NAME_ENV_VAR] === "cf" ? "cf" : "Wrangler";
|
|
510
|
-
}
|
|
511
505
|
/** Whether Cloudflare tooling requested Preview Build Output. */
|
|
512
506
|
function isPreviewBuild() {
|
|
513
507
|
return process.env[PREVIEW_BUILD_ENV_VAR] === "true";
|
|
@@ -3609,6 +3603,28 @@ function parseNodeCompatibilityFlags(compatibilityFlags) {
|
|
|
3609
3603
|
}
|
|
3610
3604
|
__name$3(parseNodeCompatibilityFlags, "parseNodeCompatibilityFlags");
|
|
3611
3605
|
|
|
3606
|
+
//#endregion
|
|
3607
|
+
//#region ../../workers-sdk/packages/workers-utils/dist/chunk-LKAZ432M.mjs
|
|
3608
|
+
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
3609
|
+
var safeHeaders = /* @__PURE__ */ new Set([
|
|
3610
|
+
"accept",
|
|
3611
|
+
"accept-encoding",
|
|
3612
|
+
"content-type",
|
|
3613
|
+
"content-length",
|
|
3614
|
+
"content-encoding",
|
|
3615
|
+
"transfer-encoding",
|
|
3616
|
+
"user-agent",
|
|
3617
|
+
"cf-ray",
|
|
3618
|
+
"date",
|
|
3619
|
+
"server",
|
|
3620
|
+
"retry-after",
|
|
3621
|
+
"retry-after-ms"
|
|
3622
|
+
]);
|
|
3623
|
+
function sanitizeHeaders(headers) {
|
|
3624
|
+
return Object.fromEntries(Array.from(headers, ([name, value]) => [name, safeHeaders.has(name.toLowerCase()) ? value : "[REDACTED]"]));
|
|
3625
|
+
}
|
|
3626
|
+
__name$3(sanitizeHeaders, "sanitizeHeaders");
|
|
3627
|
+
|
|
3612
3628
|
//#endregion
|
|
3613
3629
|
//#region ../../workers-sdk/packages/workers-utils/dist/chunk-KKQ5N4ER.mjs
|
|
3614
3630
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
@@ -25212,7 +25228,7 @@ function formatConfigSnippet(snippet, configPath, formatted = true) {
|
|
|
25212
25228
|
__name$3(formatConfigSnippet, "formatConfigSnippet");
|
|
25213
25229
|
|
|
25214
25230
|
//#endregion
|
|
25215
|
-
//#region ../../workers-sdk/packages/workers-utils/dist/chunk-
|
|
25231
|
+
//#region ../../workers-sdk/packages/workers-utils/dist/chunk-YCYD7AWO.mjs
|
|
25216
25232
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
25217
25233
|
function getBooleanEnvironmentVariableFactory(options) {
|
|
25218
25234
|
return () => {
|
|
@@ -25417,7 +25433,7 @@ function getGlobalWranglerCachePath() {
|
|
|
25417
25433
|
__name$3(getGlobalWranglerCachePath, "getGlobalWranglerCachePath");
|
|
25418
25434
|
|
|
25419
25435
|
//#endregion
|
|
25420
|
-
//#region ../../workers-sdk/packages/workers-utils/dist/chunk-
|
|
25436
|
+
//#region ../../workers-sdk/packages/workers-utils/dist/chunk-XGAZGBK5.mjs
|
|
25421
25437
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
25422
25438
|
var getC3CommandFromEnv = getEnvironmentVariableFactory({
|
|
25423
25439
|
variableName: "WRANGLER_C3_COMMAND",
|
|
@@ -25545,6 +25561,61 @@ var getCfFetchPathFromEnv = getEnvironmentVariableFactory({ variableName: "CLOUD
|
|
|
25545
25561
|
var getWranglerCacheDirFromEnv = getEnvironmentVariableFactory({ variableName: "WRANGLER_CACHE_DIR" });
|
|
25546
25562
|
var getCloudflaredPathFromEnv = getEnvironmentVariableFactory({ variableName: "CLOUDFLARED_PATH" });
|
|
25547
25563
|
|
|
25564
|
+
//#endregion
|
|
25565
|
+
//#region ../../workers-sdk/packages/workers-utils/dist/chunk-QEOOH2WK.mjs
|
|
25566
|
+
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
25567
|
+
var protectedHeaders = /* @__PURE__ */ new Set([
|
|
25568
|
+
"host",
|
|
25569
|
+
"content-type",
|
|
25570
|
+
"content-encoding",
|
|
25571
|
+
"content-length",
|
|
25572
|
+
"connection",
|
|
25573
|
+
"transfer-encoding",
|
|
25574
|
+
"upgrade",
|
|
25575
|
+
"te",
|
|
25576
|
+
"trailer"
|
|
25577
|
+
]);
|
|
25578
|
+
function configurationError(message) {
|
|
25579
|
+
return new UserError(`CLOUDFLARE_API_HEADERS ${message}`, { telemetryMessage: "cfetch custom api headers invalid configuration" });
|
|
25580
|
+
}
|
|
25581
|
+
__name$3(configurationError, "configurationError");
|
|
25582
|
+
function getCustomApiHeaders() {
|
|
25583
|
+
const raw = process.env.CLOUDFLARE_API_HEADERS;
|
|
25584
|
+
if (!raw) return {};
|
|
25585
|
+
let parsed;
|
|
25586
|
+
try {
|
|
25587
|
+
parsed = JSON.parse(raw);
|
|
25588
|
+
} catch {
|
|
25589
|
+
throw configurationError("must be a JSON object with string values.");
|
|
25590
|
+
}
|
|
25591
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw configurationError("must be a JSON object with string values.");
|
|
25592
|
+
const headers = {};
|
|
25593
|
+
for (const [name, value] of Object.entries(parsed)) {
|
|
25594
|
+
if (typeof value !== "string") throw configurationError("must contain only string values.");
|
|
25595
|
+
try {
|
|
25596
|
+
validateHeaderName(name);
|
|
25597
|
+
validateHeaderValue(name, value);
|
|
25598
|
+
} catch {
|
|
25599
|
+
throw configurationError("contains an invalid HTTP header name or value.");
|
|
25600
|
+
}
|
|
25601
|
+
const key = name.toLowerCase();
|
|
25602
|
+
if (protectedHeaders.has(key)) throw configurationError(`cannot set the protected header "${name}".`);
|
|
25603
|
+
if (Object.hasOwn(headers, key)) throw configurationError(`contains duplicate header "${name}".`);
|
|
25604
|
+
Object.defineProperty(headers, key, {
|
|
25605
|
+
value,
|
|
25606
|
+
enumerable: true,
|
|
25607
|
+
configurable: true,
|
|
25608
|
+
writable: true
|
|
25609
|
+
});
|
|
25610
|
+
}
|
|
25611
|
+
return headers;
|
|
25612
|
+
}
|
|
25613
|
+
__name$3(getCustomApiHeaders, "getCustomApiHeaders");
|
|
25614
|
+
function addCustomApiHeaders(headers) {
|
|
25615
|
+
for (const [name, value] of Object.entries(getCustomApiHeaders())) headers.set(name, value);
|
|
25616
|
+
}
|
|
25617
|
+
__name$3(addCustomApiHeaders, "addCustomApiHeaders");
|
|
25618
|
+
|
|
25548
25619
|
//#endregion
|
|
25549
25620
|
//#region ../../workers-sdk/node_modules/.pnpm/undici@7.30.1/node_modules/undici/lib/core/symbols.js
|
|
25550
25621
|
var require_symbols = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_modules/.pnpm/undici@7.30.1/node_modules/undici/lib/core/symbols.js": ((exports, module) => {
|
|
@@ -42370,7 +42441,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
42370
42441
|
}
|
|
42371
42442
|
}
|
|
42372
42443
|
};
|
|
42373
|
-
var Headers$
|
|
42444
|
+
var Headers$7 = class Headers$7 {
|
|
42374
42445
|
#guard;
|
|
42375
42446
|
/**
|
|
42376
42447
|
* @type {HeadersList}
|
|
@@ -42391,7 +42462,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
42391
42462
|
}
|
|
42392
42463
|
}
|
|
42393
42464
|
append(name, value) {
|
|
42394
|
-
webidl$11.brandCheck(this, Headers$
|
|
42465
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
42395
42466
|
webidl$11.argumentLengthCheck(arguments, 2, "Headers.append");
|
|
42396
42467
|
const prefix = "Headers.append";
|
|
42397
42468
|
name = webidl$11.converters.ByteString(name, prefix, "name");
|
|
@@ -42399,7 +42470,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
42399
42470
|
return appendHeader(this, name, value);
|
|
42400
42471
|
}
|
|
42401
42472
|
delete(name) {
|
|
42402
|
-
webidl$11.brandCheck(this, Headers$
|
|
42473
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
42403
42474
|
webidl$11.argumentLengthCheck(arguments, 1, "Headers.delete");
|
|
42404
42475
|
name = webidl$11.converters.ByteString(name, "Headers.delete", "name");
|
|
42405
42476
|
if (!isValidHeaderName$1(name)) throw webidl$11.errors.invalidArgument({
|
|
@@ -42412,7 +42483,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
42412
42483
|
this.#headersList.delete(name, false);
|
|
42413
42484
|
}
|
|
42414
42485
|
get(name) {
|
|
42415
|
-
webidl$11.brandCheck(this, Headers$
|
|
42486
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
42416
42487
|
webidl$11.argumentLengthCheck(arguments, 1, "Headers.get");
|
|
42417
42488
|
const prefix = "Headers.get";
|
|
42418
42489
|
name = webidl$11.converters.ByteString(name, prefix, "name");
|
|
@@ -42424,7 +42495,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
42424
42495
|
return this.#headersList.get(name, false);
|
|
42425
42496
|
}
|
|
42426
42497
|
has(name) {
|
|
42427
|
-
webidl$11.brandCheck(this, Headers$
|
|
42498
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
42428
42499
|
webidl$11.argumentLengthCheck(arguments, 1, "Headers.has");
|
|
42429
42500
|
const prefix = "Headers.has";
|
|
42430
42501
|
name = webidl$11.converters.ByteString(name, prefix, "name");
|
|
@@ -42436,7 +42507,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
42436
42507
|
return this.#headersList.contains(name, false);
|
|
42437
42508
|
}
|
|
42438
42509
|
set(name, value) {
|
|
42439
|
-
webidl$11.brandCheck(this, Headers$
|
|
42510
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
42440
42511
|
webidl$11.argumentLengthCheck(arguments, 2, "Headers.set");
|
|
42441
42512
|
const prefix = "Headers.set";
|
|
42442
42513
|
name = webidl$11.converters.ByteString(name, prefix, "name");
|
|
@@ -42456,7 +42527,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
42456
42527
|
this.#headersList.set(name, value, false);
|
|
42457
42528
|
}
|
|
42458
42529
|
getSetCookie() {
|
|
42459
|
-
webidl$11.brandCheck(this, Headers$
|
|
42530
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
42460
42531
|
const list$1 = this.#headersList.cookies;
|
|
42461
42532
|
if (list$1) return [...list$1];
|
|
42462
42533
|
return [];
|
|
@@ -42485,13 +42556,13 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
42485
42556
|
target.#headersList = list$1;
|
|
42486
42557
|
}
|
|
42487
42558
|
};
|
|
42488
|
-
const { getHeadersGuard: getHeadersGuard$2, setHeadersGuard: setHeadersGuard$2, getHeadersList: getHeadersList$2, setHeadersList: setHeadersList$2 } = Headers$
|
|
42489
|
-
Reflect.deleteProperty(Headers$
|
|
42490
|
-
Reflect.deleteProperty(Headers$
|
|
42491
|
-
Reflect.deleteProperty(Headers$
|
|
42492
|
-
Reflect.deleteProperty(Headers$
|
|
42493
|
-
iteratorMixin("Headers", Headers$
|
|
42494
|
-
Object.defineProperties(Headers$
|
|
42559
|
+
const { getHeadersGuard: getHeadersGuard$2, setHeadersGuard: setHeadersGuard$2, getHeadersList: getHeadersList$2, setHeadersList: setHeadersList$2 } = Headers$7;
|
|
42560
|
+
Reflect.deleteProperty(Headers$7, "getHeadersGuard");
|
|
42561
|
+
Reflect.deleteProperty(Headers$7, "setHeadersGuard");
|
|
42562
|
+
Reflect.deleteProperty(Headers$7, "getHeadersList");
|
|
42563
|
+
Reflect.deleteProperty(Headers$7, "setHeadersList");
|
|
42564
|
+
iteratorMixin("Headers", Headers$7, headersListSortAndCombine, 0, 1);
|
|
42565
|
+
Object.defineProperties(Headers$7.prototype, {
|
|
42495
42566
|
append: kEnumerableProperty$9,
|
|
42496
42567
|
delete: kEnumerableProperty$9,
|
|
42497
42568
|
get: kEnumerableProperty$9,
|
|
@@ -42507,7 +42578,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
42507
42578
|
webidl$11.converters.HeadersInit = function(V$1, prefix, argument) {
|
|
42508
42579
|
if (webidl$11.util.Type(V$1) === webidl$11.util.Types.OBJECT) {
|
|
42509
42580
|
const iterator = Reflect.get(V$1, Symbol.iterator);
|
|
42510
|
-
if (!util$4.types.isProxy(V$1) && iterator === Headers$
|
|
42581
|
+
if (!util$4.types.isProxy(V$1) && iterator === Headers$7.prototype.entries) try {
|
|
42511
42582
|
return getHeadersList$2(V$1).entriesList;
|
|
42512
42583
|
} catch {}
|
|
42513
42584
|
if (typeof iterator === "function") return webidl$11.converters["sequence<sequence<ByteString>>"](V$1, prefix, argument, iterator.bind(V$1));
|
|
@@ -42522,7 +42593,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
42522
42593
|
module.exports = {
|
|
42523
42594
|
fill: fill$1,
|
|
42524
42595
|
compareHeaderName,
|
|
42525
|
-
Headers: Headers$
|
|
42596
|
+
Headers: Headers$7,
|
|
42526
42597
|
HeadersList: HeadersList$3,
|
|
42527
42598
|
getHeadersGuard: getHeadersGuard$2,
|
|
42528
42599
|
setHeadersGuard: setHeadersGuard$2,
|
|
@@ -42534,7 +42605,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
42534
42605
|
//#endregion
|
|
42535
42606
|
//#region ../../workers-sdk/node_modules/.pnpm/undici@7.30.1/node_modules/undici/lib/web/fetch/response.js
|
|
42536
42607
|
var require_response = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_modules/.pnpm/undici@7.30.1/node_modules/undici/lib/web/fetch/response.js": ((exports, module) => {
|
|
42537
|
-
const { Headers: Headers$
|
|
42608
|
+
const { Headers: Headers$6, HeadersList: HeadersList$2, fill, getHeadersGuard: getHeadersGuard$1, setHeadersGuard: setHeadersGuard$1, setHeadersList: setHeadersList$1 } = require_headers();
|
|
42538
42609
|
const { extractBody: extractBody$2, cloneBody: cloneBody$1, mixinBody: mixinBody$1, streamRegistry, bodyUnusable: bodyUnusable$1 } = require_body();
|
|
42539
42610
|
const util$3 = require_util$5();
|
|
42540
42611
|
const nodeUtil$1 = __require$2("node:util");
|
|
@@ -42588,7 +42659,7 @@ var require_response = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mo
|
|
|
42588
42659
|
if (body !== null) body = webidl$10.converters.BodyInit(body, "Response", "body");
|
|
42589
42660
|
init = webidl$10.converters.ResponseInit(init);
|
|
42590
42661
|
this.#state = makeResponse$1({});
|
|
42591
|
-
this.#headers = new Headers$
|
|
42662
|
+
this.#headers = new Headers$6(kConstruct$6);
|
|
42592
42663
|
setHeadersGuard$1(this.#headers, "response");
|
|
42593
42664
|
setHeadersList$1(this.#headers, this.#state.headersList);
|
|
42594
42665
|
let bodyWithType = null;
|
|
@@ -42827,7 +42898,7 @@ var require_response = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mo
|
|
|
42827
42898
|
function fromInnerResponse$2(innerResponse, guard) {
|
|
42828
42899
|
const response = new Response$3(kConstruct$6);
|
|
42829
42900
|
setResponseState(response, innerResponse);
|
|
42830
|
-
const headers = new Headers$
|
|
42901
|
+
const headers = new Headers$6(kConstruct$6);
|
|
42831
42902
|
setResponseHeaders(response, headers);
|
|
42832
42903
|
setHeadersList$1(headers, innerResponse.headersList);
|
|
42833
42904
|
setHeadersGuard$1(headers, guard);
|
|
@@ -42881,7 +42952,7 @@ var require_response = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mo
|
|
|
42881
42952
|
//#region ../../workers-sdk/node_modules/.pnpm/undici@7.30.1/node_modules/undici/lib/web/fetch/request.js
|
|
42882
42953
|
var require_request = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_modules/.pnpm/undici@7.30.1/node_modules/undici/lib/web/fetch/request.js": ((exports, module) => {
|
|
42883
42954
|
const { extractBody: extractBody$1, mixinBody, cloneBody, bodyUnusable } = require_body();
|
|
42884
|
-
const { Headers: Headers$
|
|
42955
|
+
const { Headers: Headers$5, fill: fillHeaders, HeadersList: HeadersList$1, setHeadersGuard, getHeadersGuard, setHeadersList, getHeadersList: getHeadersList$1 } = require_headers();
|
|
42885
42956
|
const util$2 = require_util$5();
|
|
42886
42957
|
const nodeUtil = __require$2("node:util");
|
|
42887
42958
|
const { isValidHTTPToken, sameOrigin: sameOrigin$1, environmentSettingsObject: environmentSettingsObject$3 } = require_util$4();
|
|
@@ -43057,7 +43128,7 @@ var require_request = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
43057
43128
|
abort: abort$1
|
|
43058
43129
|
}, abort$1);
|
|
43059
43130
|
}
|
|
43060
|
-
this.#headers = new Headers$
|
|
43131
|
+
this.#headers = new Headers$5(kConstruct$5);
|
|
43061
43132
|
setHeadersList(this.#headers, request$2.headersList);
|
|
43062
43133
|
setHeadersGuard(this.#headers, "request");
|
|
43063
43134
|
if (mode === "no-cors") {
|
|
@@ -43330,7 +43401,7 @@ var require_request = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
43330
43401
|
setRequestState(request$2, innerRequest);
|
|
43331
43402
|
setRequestDispatcher(request$2, dispatcher);
|
|
43332
43403
|
setRequestSignal(request$2, signal);
|
|
43333
|
-
const headers = new Headers$
|
|
43404
|
+
const headers = new Headers$5(kConstruct$5);
|
|
43334
43405
|
setRequestHeaders(request$2, headers);
|
|
43335
43406
|
setHeadersList(headers, innerRequest.headersList);
|
|
43336
43407
|
setHeadersGuard(headers, guard);
|
|
@@ -45324,8 +45395,8 @@ var require_cookies = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_mod
|
|
|
45324
45395
|
const { parseSetCookie } = require_parse();
|
|
45325
45396
|
const { stringify: stringify$2 } = require_util$2();
|
|
45326
45397
|
const { webidl: webidl$5 } = require_webidl();
|
|
45327
|
-
const { Headers: Headers$
|
|
45328
|
-
const brandChecks = webidl$5.brandCheckMultiple([Headers$
|
|
45398
|
+
const { Headers: Headers$4 } = require_headers();
|
|
45399
|
+
const brandChecks = webidl$5.brandCheckMultiple([Headers$4, globalThis.Headers].filter(Boolean));
|
|
45329
45400
|
/**
|
|
45330
45401
|
* @typedef {Object} Cookie
|
|
45331
45402
|
* @property {string} name
|
|
@@ -46184,7 +46255,7 @@ var require_connection = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_
|
|
|
46184
46255
|
const { parseExtensions, isClosed: isClosed$1, isClosing: isClosing$1, isEstablished: isEstablished$2, isConnecting: isConnecting$1, validateCloseCodeAndReason: validateCloseCodeAndReason$1 } = require_util$1();
|
|
46185
46256
|
const { makeRequest: makeRequest$1 } = require_request();
|
|
46186
46257
|
const { fetching: fetching$1 } = require_fetch();
|
|
46187
|
-
const { Headers: Headers$
|
|
46258
|
+
const { Headers: Headers$3, getHeadersList } = require_headers();
|
|
46188
46259
|
const { getDecodeSplit } = require_util$4();
|
|
46189
46260
|
const { WebsocketFrameSend: WebsocketFrameSend$4 } = require_frame();
|
|
46190
46261
|
const assert$2 = __require$2("node:assert");
|
|
@@ -46212,7 +46283,7 @@ var require_connection = /* @__PURE__ */ __commonJS$2({ "../../workers-sdk/node_
|
|
|
46212
46283
|
redirect: "error",
|
|
46213
46284
|
useURLCredentials: true
|
|
46214
46285
|
});
|
|
46215
|
-
if (options.headers) request$2.headersList = getHeadersList(new Headers$
|
|
46286
|
+
if (options.headers) request$2.headersList = getHeadersList(new Headers$3(options.headers));
|
|
46216
46287
|
const keyValue = crypto.randomBytes(16).toString("base64");
|
|
46217
46288
|
request$2.headersList.append("sec-websocket-key", keyValue, true);
|
|
46218
46289
|
request$2.headersList.append("sec-websocket-version", "13", true);
|
|
@@ -53847,7 +53918,7 @@ function mapWorkerMetadataBindings(bindings) {
|
|
|
53847
53918
|
}, {});
|
|
53848
53919
|
}
|
|
53849
53920
|
__name$3(mapWorkerMetadataBindings, "mapWorkerMetadataBindings");
|
|
53850
|
-
var DEFAULT_COMPAT_DATE = "2026-11-
|
|
53921
|
+
var DEFAULT_COMPAT_DATE = "2026-11-10";
|
|
53851
53922
|
function constructWranglerConfig(config$3) {
|
|
53852
53923
|
const mappedBindings = mapWorkerMetadataBindings(config$3.bindings);
|
|
53853
53924
|
const durableObjectClassNames = config$3.bindings.filter((binding) => binding.type === "durable_object_namespace" && binding.script_name === config$3.name).map((durableObject) => durableObject.class_name);
|
|
@@ -55018,6 +55089,53 @@ function getWranglerTmpDir(projectRoot, prefix, cleanup = true) {
|
|
|
55018
55089
|
};
|
|
55019
55090
|
}
|
|
55020
55091
|
__name$3(getWranglerTmpDir, "getWranglerTmpDir");
|
|
55092
|
+
var MetricsRegistry = class {
|
|
55093
|
+
static {
|
|
55094
|
+
__name$3(this, "MetricsRegistry");
|
|
55095
|
+
}
|
|
55096
|
+
counters = [];
|
|
55097
|
+
/**
|
|
55098
|
+
* Create and register a new counter metric.
|
|
55099
|
+
*
|
|
55100
|
+
* @param name - The metric name (e.g. "service_request_total")
|
|
55101
|
+
* @param help - A human-readable description of the metric
|
|
55102
|
+
* @returns A Counter that can be incremented
|
|
55103
|
+
*/
|
|
55104
|
+
createCounter(name, help) {
|
|
55105
|
+
const entry = {
|
|
55106
|
+
name,
|
|
55107
|
+
help,
|
|
55108
|
+
value: 0
|
|
55109
|
+
};
|
|
55110
|
+
this.counters.push(entry);
|
|
55111
|
+
return {
|
|
55112
|
+
inc: /* @__PURE__ */ __name$3(() => {
|
|
55113
|
+
entry.value++;
|
|
55114
|
+
}, "inc"),
|
|
55115
|
+
add: /* @__PURE__ */ __name$3((amount) => {
|
|
55116
|
+
if (amount < 0) throw new Error("Counter value cannot decrease");
|
|
55117
|
+
entry.value += amount;
|
|
55118
|
+
}, "add")
|
|
55119
|
+
};
|
|
55120
|
+
}
|
|
55121
|
+
/**
|
|
55122
|
+
* Serialize all registered metrics in Prometheus text exposition format.
|
|
55123
|
+
*
|
|
55124
|
+
* @see https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format
|
|
55125
|
+
*/
|
|
55126
|
+
metrics() {
|
|
55127
|
+
return this.counters.map((c$1) => {
|
|
55128
|
+
let result = "";
|
|
55129
|
+
if (c$1.help.length > 0) result += `# HELP ${c$1.name} ${c$1.help}
|
|
55130
|
+
`;
|
|
55131
|
+
result += `# TYPE ${c$1.name} counter
|
|
55132
|
+
`;
|
|
55133
|
+
result += `${c$1.name} ${c$1.value}
|
|
55134
|
+
`;
|
|
55135
|
+
return result;
|
|
55136
|
+
}).join("");
|
|
55137
|
+
}
|
|
55138
|
+
};
|
|
55021
55139
|
function buildDetailedError(message, ...extra) {
|
|
55022
55140
|
return new ParseError({
|
|
55023
55141
|
text: message,
|
|
@@ -55031,9 +55149,7 @@ function maybeThrowFriendlyError(error$3) {
|
|
|
55031
55149
|
}
|
|
55032
55150
|
__name$3(maybeThrowFriendlyError, "maybeThrowFriendlyError");
|
|
55033
55151
|
function logHeaders(headers, logger$2) {
|
|
55034
|
-
|
|
55035
|
-
clone$2.delete("Authorization");
|
|
55036
|
-
logger$2.debugWithSanitization?.("HEADERS:", JSON.stringify(Object.fromEntries(clone$2), null, 2));
|
|
55152
|
+
logger$2.debugWithSanitization?.("HEADERS:", JSON.stringify(sanitizeHeaders(headers), null, 2));
|
|
55037
55153
|
}
|
|
55038
55154
|
__name$3(logHeaders, "logHeaders");
|
|
55039
55155
|
async function performApiFetchBase(complianceConfig, resource, init = {}, userAgent, logger$2, queryParams, abortSignal, credentials) {
|
|
@@ -55044,11 +55160,15 @@ async function performApiFetchBase(complianceConfig, resource, init = {}, userAg
|
|
|
55044
55160
|
addAuthorizationHeader(headers, credentials);
|
|
55045
55161
|
headers.set("User-Agent", userAgent);
|
|
55046
55162
|
maybeAddTraceHeader(headers);
|
|
55163
|
+
addCustomApiHeaders(headers);
|
|
55047
55164
|
const queryString = queryParams ? `?${queryParams.toString()}` : "";
|
|
55048
55165
|
logger$2.debug(`-- START CF API REQUEST: ${method} ${getCloudflareApiBaseUrl(complianceConfig)}${resource}`);
|
|
55049
55166
|
logger$2.debugWithSanitization?.("QUERY STRING:", queryString);
|
|
55050
55167
|
logHeaders(headers, logger$2);
|
|
55051
|
-
logger$2.debugWithSanitization?.("INIT:", JSON.stringify({
|
|
55168
|
+
logger$2.debugWithSanitization?.("INIT:", JSON.stringify({
|
|
55169
|
+
...init,
|
|
55170
|
+
headers: sanitizeHeaders(new import_undici$3.Headers(init.headers))
|
|
55171
|
+
}, null, 2));
|
|
55052
55172
|
if (logger$2.debugWithSanitization !== void 0 && init.body instanceof import_undici$3.FormData && (logger$2.loggerLevel === void 0 || logger$2.loggerLevel === "debug")) logger$2.debugWithSanitization?.("BODY:", getSanitizeLogs() ? "<multipart body>" : await new import_undici$3.Response(init.body).text(), null, 2);
|
|
55053
55173
|
logger$2.debug("-- END CF API REQUEST");
|
|
55054
55174
|
return await (0, import_undici$3.fetch)(`${getCloudflareApiBaseUrl(complianceConfig)}${resource}${queryString}`, {
|
|
@@ -55254,6 +55374,7 @@ async function fetchKVGetValueBase(complianceConfig, accountId, namespaceId, key
|
|
|
55254
55374
|
addAuthorizationHeader(headers, credentials);
|
|
55255
55375
|
headers.set("User-Agent", userAgent);
|
|
55256
55376
|
maybeAddTraceHeader(headers);
|
|
55377
|
+
addCustomApiHeaders(headers);
|
|
55257
55378
|
const resource = `${getCloudflareApiBaseUrl(complianceConfig)}/accounts/${accountId}/storage/kv/namespaces/${namespaceId}/values/${key}`;
|
|
55258
55379
|
logger$2.debug(`-- START CF API REQUEST: GET ${resource}`);
|
|
55259
55380
|
logger$2.debug("-- END CF API REQUEST");
|
|
@@ -56540,7 +56661,7 @@ function classifyIdentifier(identifier) {
|
|
|
56540
56661
|
__name$3(classifyIdentifier, "classifyIdentifier");
|
|
56541
56662
|
|
|
56542
56663
|
//#endregion
|
|
56543
|
-
//#region ../../workers-sdk/packages/workers-auth/dist/chunk-
|
|
56664
|
+
//#region ../../workers-sdk/packages/workers-auth/dist/chunk-FI73VDSN.mjs
|
|
56544
56665
|
var import_undici$2 = require_undici();
|
|
56545
56666
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
56546
56667
|
var hasWarnedAboutDeprecatedV1ApiToken = false;
|
|
@@ -56937,9 +57058,11 @@ function getCachedTemporaryPreviewAccount(storage) {
|
|
|
56937
57058
|
}
|
|
56938
57059
|
__name$1(getCachedTemporaryPreviewAccount, "getCachedTemporaryPreviewAccount");
|
|
56939
57060
|
async function requestPowSolution(temporaryAccountLogger, cliDisplayName) {
|
|
57061
|
+
const headers = new import_undici$2.Headers({ "Content-Type": "application/json" });
|
|
57062
|
+
addCustomApiHeaders(headers);
|
|
56940
57063
|
const response = await (0, import_undici$2.fetch)(getTemporaryPreviewChallengeUrl(), {
|
|
56941
57064
|
method: "POST",
|
|
56942
|
-
headers
|
|
57065
|
+
headers,
|
|
56943
57066
|
body: "{}"
|
|
56944
57067
|
});
|
|
56945
57068
|
if (!response.ok) throw new FatalError(`Failed to request a proof-of-work challenge (${response.status} ${response.statusText}).`, { telemetryMessage: "deploy temporary account challenge failed" });
|
|
@@ -56963,9 +57086,11 @@ async function requestPowSolution(temporaryAccountLogger, cliDisplayName) {
|
|
|
56963
57086
|
__name$1(requestPowSolution, "requestPowSolution");
|
|
56964
57087
|
async function createTemporaryPreviewAccount(temporaryAccountLogger, request$2, cliDisplayName = "Wrangler") {
|
|
56965
57088
|
const pow = await requestPowSolution(temporaryAccountLogger, cliDisplayName);
|
|
57089
|
+
const headers = new import_undici$2.Headers({ "Content-Type": "application/json" });
|
|
57090
|
+
addCustomApiHeaders(headers);
|
|
56966
57091
|
const response = await (0, import_undici$2.fetch)(getTemporaryPreviewUrl(), {
|
|
56967
57092
|
method: "POST",
|
|
56968
|
-
headers
|
|
57093
|
+
headers,
|
|
56969
57094
|
body: JSON.stringify({
|
|
56970
57095
|
termsOfService: TEMPORARY_TERMS_URLS.termsOfService,
|
|
56971
57096
|
privacyPolicy: TEMPORARY_TERMS_URLS.privacyPolicy,
|
|
@@ -59057,7 +59182,7 @@ var AuthenticationError = class extends UserError {
|
|
|
59057
59182
|
};
|
|
59058
59183
|
|
|
59059
59184
|
//#endregion
|
|
59060
|
-
//#region ../../workers-sdk/packages/workers-auth/dist/chunk-
|
|
59185
|
+
//#region ../../workers-sdk/packages/workers-auth/dist/chunk-S7BI7HY6.mjs
|
|
59061
59186
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
59062
59187
|
function createPreferences(getConfigPath) {
|
|
59063
59188
|
function getUserPreferencesPath() {
|
|
@@ -61288,6 +61413,8 @@ const ROUTER_WORKER_NAME = "__router-worker__";
|
|
|
61288
61413
|
const ASSET_WORKER_NAME = "__asset-worker__";
|
|
61289
61414
|
const VITE_PROXY_WORKER_NAME = "__vite_proxy_worker__";
|
|
61290
61415
|
const PROXY_SHARED_SECRET = randomUUID();
|
|
61416
|
+
/** The CLI named in actionable messages. The plugin is only compatible with `cf`. */
|
|
61417
|
+
const CLI_DISPLAY_NAME = "cf";
|
|
61291
61418
|
const kRequestType = Symbol("kRequestType");
|
|
61292
61419
|
|
|
61293
61420
|
//#endregion
|
|
@@ -61832,12 +61959,15 @@ var PluginContext = class {
|
|
|
61832
61959
|
/**
|
|
61833
61960
|
* Disposes the Miniflare instance and clears the export types it was configured with.
|
|
61834
61961
|
* A server created later in the same process starts again from its own config.
|
|
61962
|
+
* The shared instance is cleared before it is disposed, so that overlapping calls,
|
|
61963
|
+
* such as from concurrent restarts, dispose it only once.
|
|
61835
61964
|
*/
|
|
61836
61965
|
async disposeMiniflare() {
|
|
61837
|
-
|
|
61966
|
+
const miniflare = this.#sharedContext.miniflare;
|
|
61838
61967
|
this.#sharedContext.miniflare = void 0;
|
|
61839
61968
|
this.#sharedContext.workerNameToExportTypesMap = void 0;
|
|
61840
61969
|
this.#sharedContext.auth = void 0;
|
|
61970
|
+
await miniflare?.dispose();
|
|
61841
61971
|
}
|
|
61842
61972
|
get miniflare() {
|
|
61843
61973
|
assert(this.#sharedContext.miniflare, "Expected `miniflare` to be defined");
|
|
@@ -65397,7 +65527,9 @@ var getHeaders = /* @__PURE__ */ __name$2(async (config$3, options) => {
|
|
|
65397
65527
|
else if (isBlob(options.body)) headers["Content-Type"] = options.body.type || "application/octet-stream";
|
|
65398
65528
|
else if (isString$1(options.body)) headers["Content-Type"] = "text/plain";
|
|
65399
65529
|
else headers["Content-Type"] = "application/json";
|
|
65400
|
-
|
|
65530
|
+
const requestHeaders = new Headers(headers);
|
|
65531
|
+
addCustomApiHeaders(requestHeaders);
|
|
65532
|
+
return requestHeaders;
|
|
65401
65533
|
}, "getHeaders");
|
|
65402
65534
|
var getRequestBody = /* @__PURE__ */ __name$2((options) => {
|
|
65403
65535
|
if (options.body !== void 0) if (options.mediaType?.includes("/json")) return JSON.stringify(options.body);
|
|
@@ -65524,9 +65656,7 @@ var requestPaginated = /* @__PURE__ */ __name$2((config$3, options) => {
|
|
|
65524
65656
|
}, "requestPaginated");
|
|
65525
65657
|
var debugLogRequest = /* @__PURE__ */ __name$2(async (config$3, url$2, headers, body) => {
|
|
65526
65658
|
config$3.LOGGER?.debug(`-- START CF API REQUEST: ${url$2}`);
|
|
65527
|
-
|
|
65528
|
-
logHeaders$1.delete("Authorization");
|
|
65529
|
-
config$3.LOGGER?.debugWithSanitization("HEADERS:", JSON.stringify(logHeaders$1, null, 2));
|
|
65659
|
+
config$3.LOGGER?.debugWithSanitization("HEADERS:", JSON.stringify(sanitizeHeaders(headers), null, 2));
|
|
65530
65660
|
config$3.LOGGER?.debugWithSanitization("BODY:", JSON.stringify(body instanceof FormData ? await new Response(body).text() : body, null, 2));
|
|
65531
65661
|
config$3.LOGGER?.debug("-- END CF API REQUEST");
|
|
65532
65662
|
}, "debugLogRequest");
|
|
@@ -67284,22 +67414,6 @@ ${hint}`;
|
|
|
67284
67414
|
return message;
|
|
67285
67415
|
}
|
|
67286
67416
|
__name$2(getFailedToRunDockerErrorMessage, "getFailedToRunDockerErrorMessage");
|
|
67287
|
-
function getContainerIdsByImageTags(dockerPath, imageTags) {
|
|
67288
|
-
const ids = /* @__PURE__ */ new Set();
|
|
67289
|
-
for (const imageTag of imageTags) getContainerIdsFromImage(dockerPath, imageTag).forEach((id) => ids.add(id));
|
|
67290
|
-
return Array.from(ids);
|
|
67291
|
-
}
|
|
67292
|
-
__name$2(getContainerIdsByImageTags, "getContainerIdsByImageTags");
|
|
67293
|
-
var getContainerIdsFromImage = /* @__PURE__ */ __name$2((dockerPath, ancestorImage) => {
|
|
67294
|
-
return runDockerCmdWithOutput(dockerPath, [
|
|
67295
|
-
"ps",
|
|
67296
|
-
"-a",
|
|
67297
|
-
"--filter",
|
|
67298
|
-
`ancestor=${ancestorImage}`,
|
|
67299
|
-
"--format",
|
|
67300
|
-
"{{.ID}}"
|
|
67301
|
-
]).split("\n").filter((line) => line.trim());
|
|
67302
|
-
}, "getContainerIdsFromImage");
|
|
67303
67417
|
function generateContainerBuildId() {
|
|
67304
67418
|
return randomUUID().slice(0, 8);
|
|
67305
67419
|
}
|
|
@@ -67381,9 +67495,9 @@ async function prepareContainerImagesForDev(args) {
|
|
|
67381
67495
|
if (process.platform === "win32") throw new UserError("Local development with containers is currently not supported on Windows. You should use WSL instead. You can also set `enable_containers` to false if you do not need to develop the container part of your application.", { telemetryMessage: false });
|
|
67382
67496
|
await verifyDockerInstalled({
|
|
67383
67497
|
dockerPath,
|
|
67384
|
-
operation: "running dev",
|
|
67498
|
+
operation: args.operation ?? "running dev",
|
|
67385
67499
|
imageNoun: containerOptions.length !== 1 ? "the configured images" : "the configured image",
|
|
67386
|
-
hint:
|
|
67500
|
+
hint: args.dockerUnavailableHint
|
|
67387
67501
|
});
|
|
67388
67502
|
for (const options of containerOptions) {
|
|
67389
67503
|
if ("dockerfile" in options) {
|
|
@@ -67753,6 +67867,7 @@ async function tagAndPushImage({ pathToDocker, sourceTag, targetTag, externalAcc
|
|
|
67753
67867
|
sourceTag,
|
|
67754
67868
|
namespacedImageTag
|
|
67755
67869
|
]);
|
|
67870
|
+
await runDockerCmd(pathToDocker, ["push", namespacedImageTag]);
|
|
67756
67871
|
if (cleanupSourceTag) {
|
|
67757
67872
|
logger$1.debug(`Untagging built image: ${sourceTag}.`);
|
|
67758
67873
|
await runDockerCmd(pathToDocker, [
|
|
@@ -67761,7 +67876,6 @@ async function tagAndPushImage({ pathToDocker, sourceTag, targetTag, externalAcc
|
|
|
67761
67876
|
sourceTag
|
|
67762
67877
|
]);
|
|
67763
67878
|
}
|
|
67764
|
-
await runDockerCmd(pathToDocker, ["push", namespacedImageTag]);
|
|
67765
67879
|
return namespacedImageTag;
|
|
67766
67880
|
}
|
|
67767
67881
|
__name$2(tagAndPushImage, "tagAndPushImage");
|
|
@@ -67954,17 +68068,15 @@ async function buildContainerImages(containers, pathToDocker, verifyDockerIsRunn
|
|
|
67954
68068
|
__name$2(buildContainerImages, "buildContainerImages");
|
|
67955
68069
|
async function pushBuiltContainerImage(builtImage, versionId, pathToDocker, accountId, complianceConfig) {
|
|
67956
68070
|
try {
|
|
67957
|
-
|
|
68071
|
+
return await pushImageIfChanged({
|
|
67958
68072
|
pathToDocker,
|
|
67959
68073
|
sourceTag: builtImage.localTag,
|
|
67960
68074
|
targetTag: getContainerImageTag(builtImage.container, versionId),
|
|
67961
68075
|
containerConfig: builtImage.container,
|
|
67962
68076
|
accountId,
|
|
67963
68077
|
complianceConfig,
|
|
67964
|
-
cleanupSourceTag:
|
|
68078
|
+
cleanupSourceTag: false
|
|
67965
68079
|
});
|
|
67966
|
-
builtImage.localTagCleaned = true;
|
|
67967
|
-
return imageRef;
|
|
67968
68080
|
} catch (error$3) {
|
|
67969
68081
|
if (error$3 instanceof Error) throw new UserError(error$3.message, {
|
|
67970
68082
|
cause: error$3,
|
|
@@ -69067,6 +69179,20 @@ function createContainerPreviewPlanForCfConfig(options) {
|
|
|
69067
69179
|
});
|
|
69068
69180
|
}
|
|
69069
69181
|
__name$2(createContainerPreviewPlanForCfConfig, "createContainerPreviewPlanForCfConfig");
|
|
69182
|
+
function createMiniflareExports(options) {
|
|
69183
|
+
const workerExports = {};
|
|
69184
|
+
for (const [name, workerExport] of Object.entries(options.exports ?? {})) if (workerExport.type === "durable-object" && "storage" in workerExport) {
|
|
69185
|
+
const containerName = "container" in workerExport ? workerExport.container : void 0;
|
|
69186
|
+
const container = containerName === void 0 ? void 0 : options.containerRuntimeOptions?.get(name);
|
|
69187
|
+
assert(containerName === void 0 || container !== void 0, `Expected runtime options for Container-backed Durable Object export "${name}".`);
|
|
69188
|
+
workerExports[name] = {
|
|
69189
|
+
...workerExport,
|
|
69190
|
+
container
|
|
69191
|
+
};
|
|
69192
|
+
} else workerExports[name] = workerExport;
|
|
69193
|
+
return workerExports;
|
|
69194
|
+
}
|
|
69195
|
+
__name$2(createMiniflareExports, "createMiniflareExports");
|
|
69070
69196
|
function createContainerPlanForCfConfig(options) {
|
|
69071
69197
|
const containersByName = indexContainersByName(options.containers);
|
|
69072
69198
|
const containerOptions = [];
|
|
@@ -70284,7 +70410,7 @@ __name(createWorkerUploadForm, "createWorkerUploadForm");
|
|
|
70284
70410
|
//#endregion
|
|
70285
70411
|
//#region ../../workers-sdk/packages/remote-bindings/dist/index.mjs
|
|
70286
70412
|
var import_undici = require_undici();
|
|
70287
|
-
var version$2 = "0.0.
|
|
70413
|
+
var version$2 = "0.0.63";
|
|
70288
70414
|
var NoDefaultValueProvided = class extends UserError {
|
|
70289
70415
|
constructor() {
|
|
70290
70416
|
super("This command cannot be run in a non-interactive context", { telemetryMessage: "remote bindings prompt default missing" });
|
|
@@ -79456,7 +79582,7 @@ async function getDevMiniflareOptions$1(ctx, viteDevServer) {
|
|
|
79456
79582
|
account_id: settings.accountId,
|
|
79457
79583
|
profileDir: resolvedViteConfig.root
|
|
79458
79584
|
}, preExistingRemoteProxySession ?? null, getRemoteBindingsAuth(resolvedViteConfig.root, settings.accountId, () => ctx.getCloudflareAuth(resolvedViteConfig.root, createLogger$1(viteDevServer.config.logger))), {
|
|
79459
|
-
cliDisplayName:
|
|
79585
|
+
cliDisplayName: CLI_DISPLAY_NAME,
|
|
79460
79586
|
logger: createRemoteBindingsLogger(viteDevServer.config.logger)
|
|
79461
79587
|
});
|
|
79462
79588
|
if (remoteProxySessionData) remoteProxySessionsDataMap.set(worker.config.name, remoteProxySessionData);
|
|
@@ -79629,7 +79755,7 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
|
79629
79755
|
account_id: resolvedPluginConfig.settings.accountId,
|
|
79630
79756
|
profileDir: resolvedViteConfig.root
|
|
79631
79757
|
}, preExistingRemoteProxySessionData ?? null, getRemoteBindingsAuth(resolvedViteConfig.root, resolvedPluginConfig.settings.accountId, () => ctx.getCloudflareAuth(resolvedViteConfig.root, createLogger$1(vitePreviewServer.config.logger))), {
|
|
79632
|
-
cliDisplayName:
|
|
79758
|
+
cliDisplayName: CLI_DISPLAY_NAME,
|
|
79633
79759
|
logger: createRemoteBindingsLogger(vitePreviewServer.config.logger)
|
|
79634
79760
|
});
|
|
79635
79761
|
if (remoteProxySessionData) remoteProxySessionsDataMap.set(workerConfig.name, remoteProxySessionData);
|
|
@@ -79686,26 +79812,6 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
|
79686
79812
|
containerOptions: containerPlansByWorkerName.size === 0 ? void 0 : containerOptions
|
|
79687
79813
|
};
|
|
79688
79814
|
}
|
|
79689
|
-
/**
|
|
79690
|
-
* Replaces authored Container names on Durable Object exports with workerd's
|
|
79691
|
-
* local Container runtime metadata.
|
|
79692
|
-
*
|
|
79693
|
-
* @param options - Worker exports and their planned local Container metadata.
|
|
79694
|
-
* @returns Exports accepted by Miniflare's native Worker config schema.
|
|
79695
|
-
*/
|
|
79696
|
-
function createMiniflareExports(options) {
|
|
79697
|
-
const workerExports = {};
|
|
79698
|
-
for (const [name, workerExport] of Object.entries(options.exports ?? {})) if (workerExport.type === "durable-object" && "storage" in workerExport) {
|
|
79699
|
-
const containerName = "container" in workerExport ? workerExport.container : void 0;
|
|
79700
|
-
const container = containerName === void 0 ? void 0 : options.containerRuntimeOptions?.get(name);
|
|
79701
|
-
assert(containerName === void 0 || container !== void 0, `Expected runtime options for Container-backed Durable Object export "${name}".`);
|
|
79702
|
-
workerExports[name] = {
|
|
79703
|
-
...workerExport,
|
|
79704
|
-
container
|
|
79705
|
-
};
|
|
79706
|
-
} else workerExports[name] = workerExport;
|
|
79707
|
-
return workerExports;
|
|
79708
|
-
}
|
|
79709
79815
|
function resolveLocalBindingsByWorkerName(workerConfigs, localEnv, devVars, remoteBindings, mode, logger$2) {
|
|
79710
79816
|
const resolvedLocalBindingsByWorkerName = /* @__PURE__ */ new Map();
|
|
79711
79817
|
for (const config$3 of workerConfigs) resolvedLocalBindingsByWorkerName.set(config$3.name, resolveLocalBindings(config$3.env, {
|
|
@@ -86388,7 +86494,6 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
86388
86494
|
Object.assign(process.env, Object.fromEntries(Object.entries(localEnv.values).filter(([name]) => name.startsWith("CLOUDFLARE_"))));
|
|
86389
86495
|
const types$5 = normalizeTypes(pluginConfig.types);
|
|
86390
86496
|
const shared = {
|
|
86391
|
-
cliDisplayName: getCliDisplayName(),
|
|
86392
86497
|
persistState: pluginConfig.persistState ?? true,
|
|
86393
86498
|
inspectorPort: pluginConfig.inspectorPort,
|
|
86394
86499
|
types: types$5,
|
|
@@ -87084,32 +87189,37 @@ function createDebugMiddleware(workerNames, getResolvedInspectorPort) {
|
|
|
87084
87189
|
};
|
|
87085
87190
|
}
|
|
87086
87191
|
/**
|
|
87087
|
-
*
|
|
87088
|
-
* many were moved
|
|
87192
|
+
* Transfers the assets that a Worker imports to the client build, and logs how
|
|
87193
|
+
* many were transferred. As in the Vite plugin's `buildApp`, they're moved,
|
|
87194
|
+
* unless the Worker's originals must be kept (the prerender Worker's), when
|
|
87195
|
+
* they're copied.
|
|
87089
87196
|
*
|
|
87090
87197
|
* @param options The assets and build directories.
|
|
87091
87198
|
* @param options.importedAssetPaths The assets' paths relative to both directories.
|
|
87092
|
-
* @param options.
|
|
87199
|
+
* @param options.workerBuildDirectory The Worker's build directory.
|
|
87093
87200
|
* @param options.clientBuildDirectory The client build directory.
|
|
87094
|
-
* @param options.
|
|
87201
|
+
* @param options.environmentName The Worker's environment name.
|
|
87202
|
+
* @param options.preserveOriginalAssets Whether to copy rather than move the assets.
|
|
87095
87203
|
* @param options.root The project root.
|
|
87096
|
-
* @param options.logger Logs the
|
|
87204
|
+
* @param options.logger Logs the transferred assets.
|
|
87097
87205
|
*/
|
|
87098
|
-
function
|
|
87099
|
-
const
|
|
87206
|
+
function transferImportedAssets({ importedAssetPaths, workerBuildDirectory, clientBuildDirectory, environmentName, preserveOriginalAssets, root, logger: logger$2 }) {
|
|
87207
|
+
const transferredAssetPaths = [];
|
|
87100
87208
|
for (const assetPath of importedAssetPaths) {
|
|
87101
|
-
const src$1 = path$1.join(
|
|
87209
|
+
const src$1 = path$1.join(workerBuildDirectory, assetPath);
|
|
87102
87210
|
const dest = path$1.join(clientBuildDirectory, assetPath);
|
|
87103
87211
|
if (!fs$1.existsSync(src$1)) continue;
|
|
87104
|
-
if (fs$1.existsSync(dest))
|
|
87105
|
-
|
|
87212
|
+
if (fs$1.existsSync(dest)) {
|
|
87213
|
+
if (!preserveOriginalAssets) fs$1.unlinkSync(src$1);
|
|
87214
|
+
} else {
|
|
87106
87215
|
const destDir = path$1.dirname(dest);
|
|
87107
87216
|
fs$1.mkdirSync(destDir, { recursive: true });
|
|
87108
|
-
fs$1.
|
|
87109
|
-
|
|
87217
|
+
if (preserveOriginalAssets) fs$1.copyFileSync(src$1, dest);
|
|
87218
|
+
else fs$1.renameSync(src$1, dest);
|
|
87219
|
+
transferredAssetPaths.push(dest);
|
|
87110
87220
|
}
|
|
87111
87221
|
}
|
|
87112
|
-
if (
|
|
87222
|
+
if (transferredAssetPaths.length) logger$2.info([`${import_picocolors.default.green("✓")} ${transferredAssetPaths.length} asset${transferredAssetPaths.length > 1 ? "s" : ""} ${preserveOriginalAssets ? "copied" : "moved"} from "${environmentName}" to "client" build output.`, ...transferredAssetPaths.map((assetPath) => import_picocolors.default.dim(path$1.relative(root, assetPath)))].join("\n"));
|
|
87113
87223
|
}
|
|
87114
87224
|
|
|
87115
87225
|
//#endregion
|
|
@@ -87561,8 +87671,11 @@ function cloudflare(options = {}) {
|
|
|
87561
87671
|
/** The latest bundles, keyed by Worker name. */
|
|
87562
87672
|
const manifests = /* @__PURE__ */ new Map();
|
|
87563
87673
|
let manifestsChanged = false;
|
|
87564
|
-
/**
|
|
87565
|
-
|
|
87674
|
+
/**
|
|
87675
|
+
* The assets that the entry and prerender Workers import, keyed by
|
|
87676
|
+
* environment name, which a build transfers to the client output.
|
|
87677
|
+
*/
|
|
87678
|
+
const importedAssets = /* @__PURE__ */ new Map();
|
|
87566
87679
|
/** The Worker environments whose latest dev build failed. */
|
|
87567
87680
|
const failedEnvironments = /* @__PURE__ */ new Set();
|
|
87568
87681
|
let devServer;
|
|
@@ -87718,11 +87831,10 @@ function cloudflare(options = {}) {
|
|
|
87718
87831
|
});
|
|
87719
87832
|
manifestsChanged = true;
|
|
87720
87833
|
if (action === "build") {
|
|
87721
|
-
if (
|
|
87722
|
-
environmentName: environment.name,
|
|
87834
|
+
if (isAssetEnvironment(environment.name)) importedAssets.set(environment.name, {
|
|
87723
87835
|
distPath: environment.distPath,
|
|
87724
87836
|
paths: getImportedAssetPaths(stats.compilation)
|
|
87725
|
-
};
|
|
87837
|
+
});
|
|
87726
87838
|
await removeUnemittedFiles(environment.distPath, stats.compilation);
|
|
87727
87839
|
}
|
|
87728
87840
|
});
|
|
@@ -87776,14 +87888,18 @@ function cloudflare(options = {}) {
|
|
|
87776
87888
|
for (const name of publicDirs) if (fs$1.existsSync(name)) await fs$2.cp(name, assetsDir, { recursive: true });
|
|
87777
87889
|
if (resolvedPluginConfig.prerenderWorkerEnvironmentName) await fs$2.mkdir(assetsDir, { recursive: true });
|
|
87778
87890
|
}
|
|
87779
|
-
|
|
87780
|
-
|
|
87781
|
-
|
|
87782
|
-
|
|
87783
|
-
|
|
87784
|
-
|
|
87785
|
-
|
|
87786
|
-
|
|
87891
|
+
for (const environmentName of resolvedPluginConfig.environmentNameToWorkerMap.keys()) {
|
|
87892
|
+
const assets = importedAssets.get(environmentName);
|
|
87893
|
+
if (assets) transferImportedAssets({
|
|
87894
|
+
importedAssetPaths: assets.paths,
|
|
87895
|
+
workerBuildDirectory: assets.distPath,
|
|
87896
|
+
clientBuildDirectory: assetsDir,
|
|
87897
|
+
environmentName,
|
|
87898
|
+
preserveOriginalAssets: environmentName === resolvedPluginConfig.prerenderWorkerEnvironmentName,
|
|
87899
|
+
root,
|
|
87900
|
+
logger: logger$2
|
|
87901
|
+
});
|
|
87902
|
+
}
|
|
87787
87903
|
if (resolvedPluginConfig.type === "assets-only") await writeWorkerConfig({
|
|
87788
87904
|
root,
|
|
87789
87905
|
config: resolvedPluginConfig.config
|
|
@@ -87815,6 +87931,16 @@ function cloudflare(options = {}) {
|
|
|
87815
87931
|
mode: ctx.resolvedViteConfig.mode
|
|
87816
87932
|
});
|
|
87817
87933
|
});
|
|
87934
|
+
/**
|
|
87935
|
+
* Whether a build transfers the assets that an environment's Worker
|
|
87936
|
+
* imports to the client output: the entry Worker's and the prerender
|
|
87937
|
+
* Worker's, as in the Vite plugin's `buildApp`.
|
|
87938
|
+
*/
|
|
87939
|
+
function isAssetEnvironment(environmentName) {
|
|
87940
|
+
assertIsNotPreview(ctx);
|
|
87941
|
+
const { resolvedPluginConfig } = ctx;
|
|
87942
|
+
return environmentName === resolvedPluginConfig.prerenderWorkerEnvironmentName || resolvedPluginConfig.type === "workers" && environmentName === resolvedPluginConfig.entryWorkerEnvironmentName;
|
|
87943
|
+
}
|
|
87818
87944
|
async function startOrUpdateMiniflare(miniflareOptions) {
|
|
87819
87945
|
await ctx.startOrUpdateMiniflare(miniflareOptions);
|
|
87820
87946
|
miniflareCreated = true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region ../../workers-sdk/packages/vite-plugin-cloudflare/package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@cloudflare/vite-plugin",
|
|
4
|
-
version: "2.0.0-beta.v.
|
|
4
|
+
version: "2.0.0-beta.v.15",
|
|
5
5
|
description: "Cloudflare plugin for Vite",
|
|
6
6
|
keywords: [
|
|
7
7
|
"cloudflare",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsbuild-plugin-cloudflare",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Cloudflare plugin for Rsbuild (experimental)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@cloudflare/build-output-utils": "0.9.
|
|
38
|
-
"@cloudflare/config": "0.
|
|
39
|
-
"@cloudflare/runtime-types": "0.1.
|
|
37
|
+
"@cloudflare/build-output-utils": "0.9.13",
|
|
38
|
+
"@cloudflare/config": "0.32.0",
|
|
39
|
+
"@cloudflare/runtime-types": "0.1.26",
|
|
40
40
|
"@cloudflare/unenv-preset": "2.16.2",
|
|
41
|
-
"miniflare": "5.
|
|
41
|
+
"miniflare": "5.20261110.1-beta",
|
|
42
42
|
"unenv": "2.0.0-rc.24",
|
|
43
43
|
"ws": "8.21.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@cloudflare/workers-tsconfig": "link:../../workers-sdk/packages/workers-tsconfig",
|
|
47
|
-
"@cloudflare/workers-types": "5.
|
|
47
|
+
"@cloudflare/workers-types": "5.20261110.1",
|
|
48
48
|
"@cloudflare/workers-utils": "link:../../workers-sdk/packages/workers-utils",
|
|
49
|
-
"@rsbuild/core": "^2.3.
|
|
49
|
+
"@rsbuild/core": "^2.3.2",
|
|
50
50
|
"@types/node": "22.15.17",
|
|
51
51
|
"cf": "1.0.0-beta.17",
|
|
52
52
|
"get-port": "^7.2.0",
|