@cloudflare/vite-plugin 1.68.0 → 1.69.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/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as __toESM$1, i as __require$2, n as __export, r as __name$4, t as __commonJS$1 } from "./chunk-U6NEESU5-
|
|
1
|
+
import { a as __toESM$1, i as __require$2, n as __export, r as __name$4, t as __commonJS$1 } from "./chunk-U6NEESU5-BwoIZAaT.mjs";
|
|
2
2
|
import { builtinModules, createRequire } from "node:module";
|
|
3
3
|
import assert from "node:assert";
|
|
4
4
|
import * as fs from "node:fs";
|
|
@@ -6,13 +6,13 @@ import fs2, { accessSync, appendFileSync, chmodSync, constants, existsSync, mkdi
|
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
import path__default, { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
8
8
|
import os, { arch, release, tmpdir } from "node:os";
|
|
9
|
+
import http, { validateHeaderName, validateHeaderValue } from "node:http";
|
|
9
10
|
import * as util from "node:util";
|
|
10
11
|
import { TextDecoder as TextDecoder$1, TextEncoder as TextEncoder$1, format, inspect, isDeepStrictEqual, promisify, stripVTControlCharacters, styleText } from "node:util";
|
|
11
12
|
import process5, { exit, stdin, stdout } from "node:process";
|
|
12
13
|
import tty from "node:tty";
|
|
13
14
|
import url, { URL as URL$1, URLSearchParams as URLSearchParams$1, fileURLToPath, pathToFileURL } from "node:url";
|
|
14
15
|
import net, { createServer } from "node:net";
|
|
15
|
-
import http from "node:http";
|
|
16
16
|
import events, { EventEmitter, once } from "node:events";
|
|
17
17
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
18
18
|
import crypto2, { createCipheriv, createDecipheriv, createHash, randomBytes, randomUUID, webcrypto } from "node:crypto";
|
|
@@ -65,7 +65,7 @@ var __toESM$2 = (mod$1, isNodeMode, target$1) => (target$1 = mod$1 != null ? __c
|
|
|
65
65
|
var __require$3 = /* @__PURE__ */ createRequire(import.meta.url);
|
|
66
66
|
|
|
67
67
|
//#endregion
|
|
68
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.
|
|
68
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-2Q77CKVU.mjs
|
|
69
69
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
70
70
|
function isCompatDate(str) {
|
|
71
71
|
return /^\d{4}-\d{2}-\d{2}$/.test(str);
|
|
@@ -104,7 +104,7 @@ function stripRedundantNodejsCompatFlags(compatibilityDate, compatibilityFlags)
|
|
|
104
104
|
__name$4(stripRedundantNodejsCompatFlags, "stripRedundantNodejsCompatFlags");
|
|
105
105
|
|
|
106
106
|
//#endregion
|
|
107
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.
|
|
107
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-NDNWG7VN.mjs
|
|
108
108
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
109
109
|
function getNodeCompat(compatibilityDate = "2000-01-01", compatibilityFlags) {
|
|
110
110
|
const { hasNodejsAlsFlag, hasNodejsCompatFlag, hasNoNodejsCompatFlag, hasNodejsCompatV2Flag, hasNoNodejsCompatV2Flag, hasExperimentalNodejsCompatV2Flag } = parseNodeCompatibilityFlags(compatibilityFlags);
|
|
@@ -139,7 +139,29 @@ function parseNodeCompatibilityFlags(compatibilityFlags) {
|
|
|
139
139
|
__name$4(parseNodeCompatibilityFlags, "parseNodeCompatibilityFlags");
|
|
140
140
|
|
|
141
141
|
//#endregion
|
|
142
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.
|
|
142
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-K5SN2X7U.mjs
|
|
143
|
+
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
144
|
+
var safeHeaders = /* @__PURE__ */ new Set([
|
|
145
|
+
"accept",
|
|
146
|
+
"accept-encoding",
|
|
147
|
+
"content-type",
|
|
148
|
+
"content-length",
|
|
149
|
+
"content-encoding",
|
|
150
|
+
"transfer-encoding",
|
|
151
|
+
"user-agent",
|
|
152
|
+
"cf-ray",
|
|
153
|
+
"date",
|
|
154
|
+
"server",
|
|
155
|
+
"retry-after",
|
|
156
|
+
"retry-after-ms"
|
|
157
|
+
]);
|
|
158
|
+
function sanitizeHeaders(headers) {
|
|
159
|
+
return Object.fromEntries(Array.from(headers, ([name, value]) => [name, safeHeaders.has(name.toLowerCase()) ? value : "[REDACTED]"]));
|
|
160
|
+
}
|
|
161
|
+
__name$4(sanitizeHeaders, "sanitizeHeaders");
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-XEBMRQST.mjs
|
|
143
165
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
144
166
|
var external_exports$1 = {};
|
|
145
167
|
__export(external_exports$1, {
|
|
@@ -13028,8 +13050,8 @@ function generateMultipleOfCheck(doc, ctx, def, accessor) {
|
|
|
13028
13050
|
}
|
|
13029
13051
|
__name$4(generateMultipleOfCheck, "generateMultipleOfCheck");
|
|
13030
13052
|
function generateNumberFormatCheck(doc, def, accessor) {
|
|
13031
|
-
const format$
|
|
13032
|
-
switch (format$
|
|
13053
|
+
const format$4 = def.format;
|
|
13054
|
+
switch (format$4) {
|
|
13033
13055
|
case "safeint":
|
|
13034
13056
|
doc.write(`if (!Number.isSafeInteger(${accessor})) return INVALID;`);
|
|
13035
13057
|
break;
|
|
@@ -13045,21 +13067,21 @@ function generateNumberFormatCheck(doc, def, accessor) {
|
|
|
13045
13067
|
case "float64":
|
|
13046
13068
|
doc.write(`if (!Number.isFinite(${accessor})) return INVALID;`);
|
|
13047
13069
|
break;
|
|
13048
|
-
default: throw new ZodCompileUnsupportedError(`number format ${format$
|
|
13070
|
+
default: throw new ZodCompileUnsupportedError(`number format ${format$4}`);
|
|
13049
13071
|
}
|
|
13050
13072
|
}
|
|
13051
13073
|
__name$4(generateNumberFormatCheck, "generateNumberFormatCheck");
|
|
13052
13074
|
function generateBigIntFormatCheck(doc, def, accessor) {
|
|
13053
|
-
const format$
|
|
13054
|
-
if (!format$
|
|
13055
|
-
switch (format$
|
|
13075
|
+
const format$4 = def.format;
|
|
13076
|
+
if (!format$4) return;
|
|
13077
|
+
switch (format$4) {
|
|
13056
13078
|
case "int64":
|
|
13057
13079
|
doc.write(`if (${accessor} < -9223372036854775808n || ${accessor} > 9223372036854775807n) return INVALID;`);
|
|
13058
13080
|
break;
|
|
13059
13081
|
case "uint64":
|
|
13060
13082
|
doc.write(`if (${accessor} < 0n || ${accessor} > 18446744073709551615n) return INVALID;`);
|
|
13061
13083
|
break;
|
|
13062
|
-
default: throw new ZodCompileUnsupportedError(`bigint format ${format$
|
|
13084
|
+
default: throw new ZodCompileUnsupportedError(`bigint format ${format$4}`);
|
|
13063
13085
|
}
|
|
13064
13086
|
}
|
|
13065
13087
|
__name$4(generateBigIntFormatCheck, "generateBigIntFormatCheck");
|
|
@@ -13236,8 +13258,8 @@ function generateStringFormatCheck(doc, ctx, def, accessor, needsValue = true) {
|
|
|
13236
13258
|
doc.write(`if (!${patternConst}.test(${accessor})) return INVALID;`);
|
|
13237
13259
|
return accessor;
|
|
13238
13260
|
}
|
|
13239
|
-
const format$
|
|
13240
|
-
switch (format$
|
|
13261
|
+
const format$4 = def.format;
|
|
13262
|
+
switch (format$4) {
|
|
13241
13263
|
case "regex": throw new ZodCompileUnsupportedError("regex format without a pattern");
|
|
13242
13264
|
case "lowercase":
|
|
13243
13265
|
doc.write(`if (${accessor} !== ${accessor}.toLowerCase()) return INVALID;`);
|
|
@@ -13258,7 +13280,7 @@ function generateStringFormatCheck(doc, ctx, def, accessor, needsValue = true) {
|
|
|
13258
13280
|
doc.write(`if (${accessor}.slice(-${suffix.length}) !== ${esc$1(suffix)}) return INVALID;`);
|
|
13259
13281
|
break;
|
|
13260
13282
|
}
|
|
13261
|
-
default: throw new ZodCompileUnsupportedError(`string format ${format$
|
|
13283
|
+
default: throw new ZodCompileUnsupportedError(`string format ${format$4}`);
|
|
13262
13284
|
}
|
|
13263
13285
|
return accessor;
|
|
13264
13286
|
}
|
|
@@ -15394,12 +15416,12 @@ function _stringbool(Classes, _params) {
|
|
|
15394
15416
|
}
|
|
15395
15417
|
__name$4(_stringbool, "_stringbool");
|
|
15396
15418
|
/* @__NO_SIDE_EFFECTS__ */
|
|
15397
|
-
function _stringFormat(Class2, format$
|
|
15419
|
+
function _stringFormat(Class2, format$4, fnOrRegex, _params = {}) {
|
|
15398
15420
|
const params = normalizeParams$1(_params);
|
|
15399
15421
|
const def = {
|
|
15400
15422
|
check: "string_format",
|
|
15401
15423
|
type: "string",
|
|
15402
|
-
format: format$
|
|
15424
|
+
format: format$4,
|
|
15403
15425
|
fn: typeof fnOrRegex === "function" ? fnOrRegex : (val) => fnOrRegex.test(val),
|
|
15404
15426
|
...params
|
|
15405
15427
|
};
|
|
@@ -15857,9 +15879,9 @@ var addPattern$1 = /* @__PURE__ */ __name$4((agg, pattern) => {
|
|
|
15857
15879
|
var intersectMime$1 = /* @__PURE__ */ __name$4((agg, mime) => {
|
|
15858
15880
|
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
15859
15881
|
}, "intersectMime");
|
|
15860
|
-
var setFormat$1 = /* @__PURE__ */ __name$4((agg, format$
|
|
15861
|
-
agg.format = format$
|
|
15862
|
-
if (format$
|
|
15882
|
+
var setFormat$1 = /* @__PURE__ */ __name$4((agg, format$4) => {
|
|
15883
|
+
agg.format = format$4;
|
|
15884
|
+
if (format$4.includes("int")) agg.isInt = true;
|
|
15863
15885
|
}, "setFormat");
|
|
15864
15886
|
var minContributor$1 = /* @__PURE__ */ __name$4((agg, def) => narrowMin$1(agg, "minimum", def.minimum), "minContributor");
|
|
15865
15887
|
var maxContributor$1 = /* @__PURE__ */ __name$4((agg, def) => narrowMax$1(agg, "maximum", def.maximum), "maxContributor");
|
|
@@ -15921,13 +15943,13 @@ var exactPattern$1 = /* @__PURE__ */ __name$4((p$2) => exactPatterns$1.get(p$2)
|
|
|
15921
15943
|
var stringProcessor$1 = /* @__PURE__ */ __name$4((schema, ctx, _json, _params) => {
|
|
15922
15944
|
const json2 = _json;
|
|
15923
15945
|
json2.type = "string";
|
|
15924
|
-
const { minimum, maximum, format: format$
|
|
15946
|
+
const { minimum, maximum, format: format$4, patterns, contentEncoding, laxFormat } = aggregateChecks$1(schema);
|
|
15925
15947
|
if (typeof minimum === "number") json2.minLength = minimum;
|
|
15926
15948
|
if (typeof maximum === "number") json2.maxLength = maximum;
|
|
15927
|
-
if (format$
|
|
15928
|
-
json2.format = formatMap$1[format$
|
|
15949
|
+
if (format$4) {
|
|
15950
|
+
json2.format = formatMap$1[format$4] ?? format$4;
|
|
15929
15951
|
if (json2.format === "") delete json2.format;
|
|
15930
|
-
if (format$
|
|
15952
|
+
if (format$4 === "time" || laxFormat) delete json2.format;
|
|
15931
15953
|
}
|
|
15932
15954
|
if (contentEncoding) json2.contentEncoding = contentEncoding;
|
|
15933
15955
|
if (patterns && patterns.size > 0) {
|
|
@@ -16233,7 +16255,7 @@ function stringifyKeyNames$1(bySchema, json2, visited) {
|
|
|
16233
16255
|
const numericType = !types$4.includes("string") && types$4.some((t$5) => t$5 === "number" || t$5 === "integer");
|
|
16234
16256
|
const values = json2.enum ?? (json2.const !== void 0 ? [json2.const] : void 0);
|
|
16235
16257
|
if (!numericType && !values?.some((v) => typeof v === "number")) return json2;
|
|
16236
|
-
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format: format$
|
|
16258
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format: format$4, id,...rest } = json2;
|
|
16237
16259
|
if (rest.enum) rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
16238
16260
|
else if (typeof rest.const === "number") rest.const = String(rest.const);
|
|
16239
16261
|
if (!numericType) return rest;
|
|
@@ -17361,8 +17383,8 @@ var ZodCustomStringFormat = /* @__PURE__ */ $constructor$1("ZodCustomStringForma
|
|
|
17361
17383
|
$ZodCustomStringFormat.init(inst, def);
|
|
17362
17384
|
ZodStringFormat$1.init(inst, def);
|
|
17363
17385
|
});
|
|
17364
|
-
function stringFormat(format$
|
|
17365
|
-
return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, format$
|
|
17386
|
+
function stringFormat(format$4, fnOrRegex, _params = {}) {
|
|
17387
|
+
return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, format$4, fnOrRegex, _params);
|
|
17366
17388
|
}
|
|
17367
17389
|
__name$4(stringFormat, "stringFormat");
|
|
17368
17390
|
function hostname2(_params) {
|
|
@@ -17378,10 +17400,10 @@ function currencyCode2(_params) {
|
|
|
17378
17400
|
}
|
|
17379
17401
|
__name$4(currencyCode2, "currencyCode");
|
|
17380
17402
|
function hash(alg, params) {
|
|
17381
|
-
const format$
|
|
17382
|
-
const regex$1 = regexes_exports$1[format$
|
|
17383
|
-
if (!regex$1) throw new Error(`Unrecognized hash format: ${format$
|
|
17384
|
-
return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, format$
|
|
17403
|
+
const format$4 = `${alg}_${params?.enc ?? "hex"}`;
|
|
17404
|
+
const regex$1 = regexes_exports$1[format$4];
|
|
17405
|
+
if (!regex$1) throw new Error(`Unrecognized hash format: ${format$4}`);
|
|
17406
|
+
return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, format$4, regex$1, params);
|
|
17385
17407
|
}
|
|
17386
17408
|
__name$4(hash, "hash");
|
|
17387
17409
|
var ZodNumber$1 = /* @__PURE__ */ $constructor$1("ZodNumber", (inst, def) => {
|
|
@@ -18696,33 +18718,33 @@ function convertBaseSchema(schema, ctx) {
|
|
|
18696
18718
|
case "string": {
|
|
18697
18719
|
let stringSchema = z.string();
|
|
18698
18720
|
if (schema.format) {
|
|
18699
|
-
const format$
|
|
18700
|
-
if (format$
|
|
18701
|
-
else if (format$
|
|
18702
|
-
else if (format$
|
|
18703
|
-
else if (format$
|
|
18704
|
-
else if (format$
|
|
18705
|
-
else if (format$
|
|
18706
|
-
else if (format$
|
|
18707
|
-
else if (format$
|
|
18708
|
-
else if (format$
|
|
18709
|
-
else if (format$
|
|
18710
|
-
else if (format$
|
|
18711
|
-
else if (format$
|
|
18712
|
-
else if (format$
|
|
18713
|
-
else if (format$
|
|
18714
|
-
else if (format$
|
|
18715
|
-
else if (format$
|
|
18716
|
-
else if (format$
|
|
18717
|
-
else if (format$
|
|
18718
|
-
else if (format$
|
|
18719
|
-
else if (format$
|
|
18720
|
-
else if (format$
|
|
18721
|
-
else if (format$
|
|
18722
|
-
else if (format$
|
|
18723
|
-
else if (format$
|
|
18724
|
-
else if (format$
|
|
18725
|
-
else if (format$
|
|
18721
|
+
const format$4 = schema.format;
|
|
18722
|
+
if (format$4 === "email") stringSchema = stringSchema.check(z.email());
|
|
18723
|
+
else if (format$4 === "uri" || format$4 === "uri-reference") stringSchema = stringSchema.check(z.url());
|
|
18724
|
+
else if (format$4 === "uuid" || format$4 === "guid") stringSchema = stringSchema.check(z.uuid());
|
|
18725
|
+
else if (format$4 === "date-time") stringSchema = stringSchema.check(z.iso.datetime({ offset: true }));
|
|
18726
|
+
else if (format$4 === "date") stringSchema = stringSchema.check(z.iso.date());
|
|
18727
|
+
else if (format$4 === "time") stringSchema = stringSchema.check(z.regex(fullTime));
|
|
18728
|
+
else if (format$4 === "duration") stringSchema = stringSchema.check(z.iso.duration());
|
|
18729
|
+
else if (format$4 === "hostname") stringSchema = stringSchema.check(z.hostname());
|
|
18730
|
+
else if (format$4 === "ipv4") stringSchema = stringSchema.check(z.ipv4());
|
|
18731
|
+
else if (format$4 === "ipv6") stringSchema = stringSchema.check(z.ipv6());
|
|
18732
|
+
else if (format$4 === "mac") stringSchema = stringSchema.check(z.mac());
|
|
18733
|
+
else if (format$4 === "cidr") stringSchema = stringSchema.check(z.cidrv4());
|
|
18734
|
+
else if (format$4 === "cidr-v6") stringSchema = stringSchema.check(z.cidrv6());
|
|
18735
|
+
else if (format$4 === "base64") stringSchema = stringSchema.check(z.base64());
|
|
18736
|
+
else if (format$4 === "base64url") stringSchema = stringSchema.check(z.base64url());
|
|
18737
|
+
else if (format$4 === "e164") stringSchema = stringSchema.check(z.e164());
|
|
18738
|
+
else if (format$4 === "credit_card") stringSchema = stringSchema.check(z.creditCard());
|
|
18739
|
+
else if (format$4 === "iban") stringSchema = stringSchema.check(z.iban());
|
|
18740
|
+
else if (format$4 === "jwt") stringSchema = stringSchema.check(z.jwt());
|
|
18741
|
+
else if (format$4 === "emoji") stringSchema = stringSchema.check(z.emoji());
|
|
18742
|
+
else if (format$4 === "nanoid") stringSchema = stringSchema.check(z.nanoid());
|
|
18743
|
+
else if (format$4 === "cuid") stringSchema = stringSchema.check(z.cuid());
|
|
18744
|
+
else if (format$4 === "cuid2") stringSchema = stringSchema.check(z.cuid2());
|
|
18745
|
+
else if (format$4 === "ulid") stringSchema = stringSchema.check(z.ulid());
|
|
18746
|
+
else if (format$4 === "xid") stringSchema = stringSchema.check(z.xid());
|
|
18747
|
+
else if (format$4 === "ksuid") stringSchema = stringSchema.check(z.ksuid());
|
|
18726
18748
|
}
|
|
18727
18749
|
if (typeof schema.minLength === "number") stringSchema = stringSchema.min(schema.minLength);
|
|
18728
18750
|
if (typeof schema.maxLength === "number") stringSchema = stringSchema.max(schema.maxLength);
|
|
@@ -19188,7 +19210,7 @@ function formatZodError(error62) {
|
|
|
19188
19210
|
__name$4(formatZodError, "formatZodError");
|
|
19189
19211
|
|
|
19190
19212
|
//#endregion
|
|
19191
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.
|
|
19213
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-M3RITKR3.mjs
|
|
19192
19214
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
19193
19215
|
function dedent$1(templ) {
|
|
19194
19216
|
var values = [];
|
|
@@ -19226,7 +19248,7 @@ __name$4(dedent$1, "dedent");
|
|
|
19226
19248
|
var esm_default$1 = dedent$1;
|
|
19227
19249
|
|
|
19228
19250
|
//#endregion
|
|
19229
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.
|
|
19251
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-OWPFSLY6.mjs
|
|
19230
19252
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
19231
19253
|
var UserError = class extends Error {
|
|
19232
19254
|
static {
|
|
@@ -19285,7 +19307,7 @@ function createFatalError(message, isJson, options) {
|
|
|
19285
19307
|
__name$4(createFatalError, "createFatalError");
|
|
19286
19308
|
|
|
19287
19309
|
//#endregion
|
|
19288
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.
|
|
19310
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-AAQI36FL.mjs
|
|
19289
19311
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
19290
19312
|
function hasKnownExportType(entry) {
|
|
19291
19313
|
const type = entry?.type;
|
|
@@ -19784,7 +19806,7 @@ var CharacterCodes;
|
|
|
19784
19806
|
CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
|
|
19785
19807
|
CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
|
|
19786
19808
|
})(CharacterCodes || (CharacterCodes = {}));
|
|
19787
|
-
function format$
|
|
19809
|
+
function format$3(documentText, range, options) {
|
|
19788
19810
|
let initialIndentLevel;
|
|
19789
19811
|
let formatText;
|
|
19790
19812
|
let formatTextStart;
|
|
@@ -19918,7 +19940,7 @@ function format$2(documentText, range, options) {
|
|
|
19918
19940
|
}
|
|
19919
19941
|
return editOperations;
|
|
19920
19942
|
}
|
|
19921
|
-
__name$4(format$
|
|
19943
|
+
__name$4(format$3, "format");
|
|
19922
19944
|
function repeat(s, count) {
|
|
19923
19945
|
let result = "";
|
|
19924
19946
|
for (let i$1 = 0; i$1 < count; i$1++) result += s;
|
|
@@ -20474,7 +20496,7 @@ function withFormatting(text, edit, options) {
|
|
|
20474
20496
|
while (begin > 0 && !isEOL(newText, begin - 1)) begin--;
|
|
20475
20497
|
while (end < newText.length && !isEOL(newText, end)) end++;
|
|
20476
20498
|
}
|
|
20477
|
-
const edits = format$
|
|
20499
|
+
const edits = format$3(newText, {
|
|
20478
20500
|
offset: begin,
|
|
20479
20501
|
length: end - begin
|
|
20480
20502
|
}, {
|
|
@@ -20573,7 +20595,7 @@ function printParseErrorCode(code) {
|
|
|
20573
20595
|
}
|
|
20574
20596
|
__name$4(printParseErrorCode, "printParseErrorCode");
|
|
20575
20597
|
function format2(documentText, range, options) {
|
|
20576
|
-
return format$
|
|
20598
|
+
return format$3(documentText, range, options);
|
|
20577
20599
|
}
|
|
20578
20600
|
__name$4(format2, "format");
|
|
20579
20601
|
function modify(text, path3, value, options) {
|
|
@@ -21372,10 +21394,10 @@ var APIError = class extends ParseError {
|
|
|
21372
21394
|
* derived from the response's `Retry-After` header (if present).
|
|
21373
21395
|
*/
|
|
21374
21396
|
retryAfterMs;
|
|
21375
|
-
constructor({ status: status$
|
|
21397
|
+
constructor({ status: status$2, retryAfterMs,...rest }) {
|
|
21376
21398
|
super(rest);
|
|
21377
21399
|
this.name = this.constructor.name;
|
|
21378
|
-
this.#status = status$
|
|
21400
|
+
this.#status = status$2;
|
|
21379
21401
|
this.retryAfterMs = retryAfterMs;
|
|
21380
21402
|
}
|
|
21381
21403
|
get status() {
|
|
@@ -21800,7 +21822,7 @@ function formatConfigSnippet(snippet, configPath, formatted = true) {
|
|
|
21800
21822
|
__name$4(formatConfigSnippet, "formatConfigSnippet");
|
|
21801
21823
|
|
|
21802
21824
|
//#endregion
|
|
21803
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.
|
|
21825
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-QSRIB43D.mjs
|
|
21804
21826
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
21805
21827
|
function getBooleanEnvironmentVariableFactory(options) {
|
|
21806
21828
|
return () => {
|
|
@@ -21845,7 +21867,7 @@ var getDockerPath$1 = getEnvironmentVariableFactory({
|
|
|
21845
21867
|
});
|
|
21846
21868
|
|
|
21847
21869
|
//#endregion
|
|
21848
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.
|
|
21870
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-MIA26B4M.mjs
|
|
21849
21871
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
21850
21872
|
function isDirectory(path$2) {
|
|
21851
21873
|
return fs2.statSync(path$2, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
@@ -21873,7 +21895,7 @@ function removeDirSync$1(dirPath) {
|
|
|
21873
21895
|
__name$4(removeDirSync$1, "removeDirSync");
|
|
21874
21896
|
|
|
21875
21897
|
//#endregion
|
|
21876
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.
|
|
21898
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-MV2OJK3L.mjs
|
|
21877
21899
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
21878
21900
|
function isWindows() {
|
|
21879
21901
|
return /^win/i.test(process.platform);
|
|
@@ -22005,7 +22027,7 @@ function getGlobalWranglerCachePath() {
|
|
|
22005
22027
|
__name$4(getGlobalWranglerCachePath, "getGlobalWranglerCachePath");
|
|
22006
22028
|
|
|
22007
22029
|
//#endregion
|
|
22008
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.
|
|
22030
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-FR75DWDU.mjs
|
|
22009
22031
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
22010
22032
|
var getC3CommandFromEnv = getEnvironmentVariableFactory({
|
|
22011
22033
|
variableName: "WRANGLER_C3_COMMAND",
|
|
@@ -22133,12 +22155,67 @@ var getCfFetchPathFromEnv = getEnvironmentVariableFactory({ variableName: "CLOUD
|
|
|
22133
22155
|
var getWranglerCacheDirFromEnv = getEnvironmentVariableFactory({ variableName: "WRANGLER_CACHE_DIR" });
|
|
22134
22156
|
var getCloudflaredPathFromEnv = getEnvironmentVariableFactory({ variableName: "CLOUDFLARED_PATH" });
|
|
22135
22157
|
|
|
22158
|
+
//#endregion
|
|
22159
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/chunk-BRZKTVPN.mjs
|
|
22160
|
+
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
22161
|
+
var protectedHeaders = /* @__PURE__ */ new Set([
|
|
22162
|
+
"host",
|
|
22163
|
+
"content-type",
|
|
22164
|
+
"content-encoding",
|
|
22165
|
+
"content-length",
|
|
22166
|
+
"connection",
|
|
22167
|
+
"transfer-encoding",
|
|
22168
|
+
"upgrade",
|
|
22169
|
+
"te",
|
|
22170
|
+
"trailer"
|
|
22171
|
+
]);
|
|
22172
|
+
function configurationError(message) {
|
|
22173
|
+
return new UserError(`CLOUDFLARE_API_HEADERS ${message}`, { telemetryMessage: "cfetch custom api headers invalid configuration" });
|
|
22174
|
+
}
|
|
22175
|
+
__name$4(configurationError, "configurationError");
|
|
22176
|
+
function getCustomApiHeaders() {
|
|
22177
|
+
const raw = process.env.CLOUDFLARE_API_HEADERS;
|
|
22178
|
+
if (!raw) return {};
|
|
22179
|
+
let parsed;
|
|
22180
|
+
try {
|
|
22181
|
+
parsed = JSON.parse(raw);
|
|
22182
|
+
} catch {
|
|
22183
|
+
throw configurationError("must be a JSON object with string values.");
|
|
22184
|
+
}
|
|
22185
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw configurationError("must be a JSON object with string values.");
|
|
22186
|
+
const headers = {};
|
|
22187
|
+
for (const [name, value] of Object.entries(parsed)) {
|
|
22188
|
+
if (typeof value !== "string") throw configurationError("must contain only string values.");
|
|
22189
|
+
try {
|
|
22190
|
+
validateHeaderName(name);
|
|
22191
|
+
validateHeaderValue(name, value);
|
|
22192
|
+
} catch {
|
|
22193
|
+
throw configurationError("contains an invalid HTTP header name or value.");
|
|
22194
|
+
}
|
|
22195
|
+
const key = name.toLowerCase();
|
|
22196
|
+
if (protectedHeaders.has(key)) throw configurationError(`cannot set the protected header "${name}".`);
|
|
22197
|
+
if (Object.hasOwn(headers, key)) throw configurationError(`contains duplicate header "${name}".`);
|
|
22198
|
+
Object.defineProperty(headers, key, {
|
|
22199
|
+
value,
|
|
22200
|
+
enumerable: true,
|
|
22201
|
+
configurable: true,
|
|
22202
|
+
writable: true
|
|
22203
|
+
});
|
|
22204
|
+
}
|
|
22205
|
+
return headers;
|
|
22206
|
+
}
|
|
22207
|
+
__name$4(getCustomApiHeaders, "getCustomApiHeaders");
|
|
22208
|
+
function addCustomApiHeaders(headers) {
|
|
22209
|
+
for (const [name, value] of Object.entries(getCustomApiHeaders())) headers.set(name, value);
|
|
22210
|
+
}
|
|
22211
|
+
__name$4(addCustomApiHeaders, "addCustomApiHeaders");
|
|
22212
|
+
|
|
22136
22213
|
//#endregion
|
|
22137
22214
|
//#region ../../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
22138
22215
|
const ANSI_BACKGROUND_OFFSET$1 = 10;
|
|
22139
22216
|
const wrapAnsi16$1 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
|
|
22140
22217
|
const wrapAnsi256$1 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`;
|
|
22141
|
-
const wrapAnsi16m$1 = (offset = 0) => (red$
|
|
22218
|
+
const wrapAnsi16m$1 = (offset = 0) => (red$2, green$2, blue$2) => `\u001B[${38 + offset};2;${red$2};${green$2};${blue$2}m`;
|
|
22142
22219
|
const styles$2 = {
|
|
22143
22220
|
modifier: {
|
|
22144
22221
|
reset: [0, 0],
|
|
@@ -22226,13 +22303,13 @@ function assembleStyles$1() {
|
|
|
22226
22303
|
styles$2.bgColor.ansi16m = wrapAnsi16m$1(ANSI_BACKGROUND_OFFSET$1);
|
|
22227
22304
|
Object.defineProperties(styles$2, {
|
|
22228
22305
|
rgbToAnsi256: {
|
|
22229
|
-
value(red$
|
|
22230
|
-
if (red$
|
|
22231
|
-
if (red$
|
|
22232
|
-
if (red$
|
|
22233
|
-
return Math.round((red$
|
|
22306
|
+
value(red$2, green$2, blue$2) {
|
|
22307
|
+
if (red$2 === green$2 && green$2 === blue$2) {
|
|
22308
|
+
if (red$2 < 8) return 16;
|
|
22309
|
+
if (red$2 > 248) return 231;
|
|
22310
|
+
return Math.round((red$2 - 8) / 247 * 24) + 232;
|
|
22234
22311
|
}
|
|
22235
|
-
return 16 + 36 * Math.round(red$
|
|
22312
|
+
return 16 + 36 * Math.round(red$2 / 255 * 5) + 6 * Math.round(green$2 / 255 * 5) + Math.round(blue$2 / 255 * 5);
|
|
22236
22313
|
},
|
|
22237
22314
|
enumerable: false
|
|
22238
22315
|
},
|
|
@@ -22263,30 +22340,30 @@ function assembleStyles$1() {
|
|
|
22263
22340
|
value(code) {
|
|
22264
22341
|
if (code < 8) return 30 + code;
|
|
22265
22342
|
if (code < 16) return 90 + (code - 8);
|
|
22266
|
-
let red$
|
|
22267
|
-
let green$
|
|
22268
|
-
let blue$
|
|
22343
|
+
let red$2;
|
|
22344
|
+
let green$2;
|
|
22345
|
+
let blue$2;
|
|
22269
22346
|
if (code >= 232) {
|
|
22270
|
-
red$
|
|
22271
|
-
green$
|
|
22272
|
-
blue$
|
|
22347
|
+
red$2 = ((code - 232) * 10 + 8) / 255;
|
|
22348
|
+
green$2 = red$2;
|
|
22349
|
+
blue$2 = red$2;
|
|
22273
22350
|
} else {
|
|
22274
22351
|
code -= 16;
|
|
22275
22352
|
const remainder = code % 36;
|
|
22276
|
-
red$
|
|
22277
|
-
green$
|
|
22278
|
-
blue$
|
|
22353
|
+
red$2 = Math.floor(code / 36) / 5;
|
|
22354
|
+
green$2 = Math.floor(remainder / 6) / 5;
|
|
22355
|
+
blue$2 = remainder % 6 / 5;
|
|
22279
22356
|
}
|
|
22280
|
-
const value = Math.max(red$
|
|
22357
|
+
const value = Math.max(red$2, green$2, blue$2) * 2;
|
|
22281
22358
|
if (value === 0) return 30;
|
|
22282
|
-
let result = 30 + (Math.round(blue$
|
|
22359
|
+
let result = 30 + (Math.round(blue$2) << 2 | Math.round(green$2) << 1 | Math.round(red$2));
|
|
22283
22360
|
if (value === 2) result += 60;
|
|
22284
22361
|
return result;
|
|
22285
22362
|
},
|
|
22286
22363
|
enumerable: false
|
|
22287
22364
|
},
|
|
22288
22365
|
rgbToAnsi: {
|
|
22289
|
-
value: (red$
|
|
22366
|
+
value: (red$2, green$2, blue$2) => styles$2.ansi256ToAnsi(styles$2.rgbToAnsi256(red$2, green$2, blue$2)),
|
|
22290
22367
|
enumerable: false
|
|
22291
22368
|
},
|
|
22292
22369
|
hexToAnsi: {
|
|
@@ -31594,9 +31671,9 @@ var require_socks5_client = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.
|
|
|
31594
31671
|
handleAuthResponse() {
|
|
31595
31672
|
if (this.buffer.length < 2) return;
|
|
31596
31673
|
const version$5 = this.buffer[0];
|
|
31597
|
-
const status$
|
|
31674
|
+
const status$2 = this.buffer[1];
|
|
31598
31675
|
if (version$5 !== 1) throw new Socks5ProxyError(`Invalid auth sub-negotiation version: ${version$5}`, "UND_ERR_SOCKS5_AUTH_VERSION");
|
|
31599
|
-
if (status$
|
|
31676
|
+
if (status$2 !== 0) throw new Socks5ProxyError("Authentication failed", "UND_ERR_SOCKS5_AUTH_FAILED");
|
|
31600
31677
|
this.buffer = this.buffer.subarray(2);
|
|
31601
31678
|
debug$6("authentication successful");
|
|
31602
31679
|
this.markAuthenticated();
|
|
@@ -39362,7 +39439,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
39362
39439
|
}
|
|
39363
39440
|
}
|
|
39364
39441
|
};
|
|
39365
|
-
var Headers$
|
|
39442
|
+
var Headers$7 = class Headers$7 {
|
|
39366
39443
|
#guard;
|
|
39367
39444
|
/**
|
|
39368
39445
|
* @type {HeadersList}
|
|
@@ -39383,7 +39460,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
39383
39460
|
}
|
|
39384
39461
|
}
|
|
39385
39462
|
append(name, value) {
|
|
39386
|
-
webidl$11.brandCheck(this, Headers$
|
|
39463
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
39387
39464
|
webidl$11.argumentLengthCheck(arguments, 2, "Headers.append");
|
|
39388
39465
|
const prefix = "Headers.append";
|
|
39389
39466
|
name = webidl$11.converters.ByteString(name, prefix, "name");
|
|
@@ -39391,7 +39468,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
39391
39468
|
return appendHeader(this, name, value);
|
|
39392
39469
|
}
|
|
39393
39470
|
delete(name) {
|
|
39394
|
-
webidl$11.brandCheck(this, Headers$
|
|
39471
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
39395
39472
|
webidl$11.argumentLengthCheck(arguments, 1, "Headers.delete");
|
|
39396
39473
|
name = webidl$11.converters.ByteString(name, "Headers.delete", "name");
|
|
39397
39474
|
if (!isValidHeaderName$1(name)) throw webidl$11.errors.invalidArgument({
|
|
@@ -39404,7 +39481,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
39404
39481
|
this.#headersList.delete(name, false);
|
|
39405
39482
|
}
|
|
39406
39483
|
get(name) {
|
|
39407
|
-
webidl$11.brandCheck(this, Headers$
|
|
39484
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
39408
39485
|
webidl$11.argumentLengthCheck(arguments, 1, "Headers.get");
|
|
39409
39486
|
const prefix = "Headers.get";
|
|
39410
39487
|
name = webidl$11.converters.ByteString(name, prefix, "name");
|
|
@@ -39416,7 +39493,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
39416
39493
|
return this.#headersList.get(name, false);
|
|
39417
39494
|
}
|
|
39418
39495
|
has(name) {
|
|
39419
|
-
webidl$11.brandCheck(this, Headers$
|
|
39496
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
39420
39497
|
webidl$11.argumentLengthCheck(arguments, 1, "Headers.has");
|
|
39421
39498
|
const prefix = "Headers.has";
|
|
39422
39499
|
name = webidl$11.converters.ByteString(name, prefix, "name");
|
|
@@ -39428,7 +39505,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
39428
39505
|
return this.#headersList.contains(name, false);
|
|
39429
39506
|
}
|
|
39430
39507
|
set(name, value) {
|
|
39431
|
-
webidl$11.brandCheck(this, Headers$
|
|
39508
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
39432
39509
|
webidl$11.argumentLengthCheck(arguments, 2, "Headers.set");
|
|
39433
39510
|
const prefix = "Headers.set";
|
|
39434
39511
|
name = webidl$11.converters.ByteString(name, prefix, "name");
|
|
@@ -39448,7 +39525,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
39448
39525
|
this.#headersList.set(name, value, false);
|
|
39449
39526
|
}
|
|
39450
39527
|
getSetCookie() {
|
|
39451
|
-
webidl$11.brandCheck(this, Headers$
|
|
39528
|
+
webidl$11.brandCheck(this, Headers$7);
|
|
39452
39529
|
const list$1 = this.#headersList.cookies;
|
|
39453
39530
|
if (list$1) return [...list$1];
|
|
39454
39531
|
return [];
|
|
@@ -39477,13 +39554,13 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
39477
39554
|
target$1.#headersList = list$1;
|
|
39478
39555
|
}
|
|
39479
39556
|
};
|
|
39480
|
-
const { getHeadersGuard: getHeadersGuard$2, setHeadersGuard: setHeadersGuard$2, getHeadersList: getHeadersList$2, setHeadersList: setHeadersList$2 } = Headers$
|
|
39481
|
-
Reflect.deleteProperty(Headers$
|
|
39482
|
-
Reflect.deleteProperty(Headers$
|
|
39483
|
-
Reflect.deleteProperty(Headers$
|
|
39484
|
-
Reflect.deleteProperty(Headers$
|
|
39485
|
-
iteratorMixin("Headers", Headers$
|
|
39486
|
-
Object.defineProperties(Headers$
|
|
39557
|
+
const { getHeadersGuard: getHeadersGuard$2, setHeadersGuard: setHeadersGuard$2, getHeadersList: getHeadersList$2, setHeadersList: setHeadersList$2 } = Headers$7;
|
|
39558
|
+
Reflect.deleteProperty(Headers$7, "getHeadersGuard");
|
|
39559
|
+
Reflect.deleteProperty(Headers$7, "setHeadersGuard");
|
|
39560
|
+
Reflect.deleteProperty(Headers$7, "getHeadersList");
|
|
39561
|
+
Reflect.deleteProperty(Headers$7, "setHeadersList");
|
|
39562
|
+
iteratorMixin("Headers", Headers$7, headersListSortAndCombine, 0, 1);
|
|
39563
|
+
Object.defineProperties(Headers$7.prototype, {
|
|
39487
39564
|
append: kEnumerableProperty$9,
|
|
39488
39565
|
delete: kEnumerableProperty$9,
|
|
39489
39566
|
get: kEnumerableProperty$9,
|
|
@@ -39499,7 +39576,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
39499
39576
|
webidl$11.converters.HeadersInit = function(V$1, prefix, argument) {
|
|
39500
39577
|
if (webidl$11.util.Type(V$1) === webidl$11.util.Types.OBJECT) {
|
|
39501
39578
|
const iterator = Reflect.get(V$1, Symbol.iterator);
|
|
39502
|
-
if (!util$4.types.isProxy(V$1) && iterator === Headers$
|
|
39579
|
+
if (!util$4.types.isProxy(V$1) && iterator === Headers$7.prototype.entries) try {
|
|
39503
39580
|
return getHeadersList$2(V$1).entriesList;
|
|
39504
39581
|
} catch {}
|
|
39505
39582
|
if (typeof iterator === "function") return webidl$11.converters["sequence<sequence<ByteString>>"](V$1, prefix, argument, iterator.bind(V$1));
|
|
@@ -39514,7 +39591,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
39514
39591
|
module.exports = {
|
|
39515
39592
|
fill: fill$1,
|
|
39516
39593
|
compareHeaderName,
|
|
39517
|
-
Headers: Headers$
|
|
39594
|
+
Headers: Headers$7,
|
|
39518
39595
|
HeadersList: HeadersList$3,
|
|
39519
39596
|
getHeadersGuard: getHeadersGuard$2,
|
|
39520
39597
|
setHeadersGuard: setHeadersGuard$2,
|
|
@@ -39526,7 +39603,7 @@ var require_headers = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
39526
39603
|
//#endregion
|
|
39527
39604
|
//#region ../../node_modules/.pnpm/undici@7.30.1/node_modules/undici/lib/web/fetch/response.js
|
|
39528
39605
|
var require_response = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/undici@7.30.1/node_modules/undici/lib/web/fetch/response.js": ((exports, module) => {
|
|
39529
|
-
const { Headers: Headers$
|
|
39606
|
+
const { Headers: Headers$6, HeadersList: HeadersList$2, fill, getHeadersGuard: getHeadersGuard$1, setHeadersGuard: setHeadersGuard$1, setHeadersList: setHeadersList$1 } = require_headers();
|
|
39530
39607
|
const { extractBody: extractBody$2, cloneBody: cloneBody$1, mixinBody: mixinBody$1, streamRegistry, bodyUnusable: bodyUnusable$1 } = require_body();
|
|
39531
39608
|
const util$3 = require_util$5();
|
|
39532
39609
|
const nodeUtil$1 = __require$3("node:util");
|
|
@@ -39557,19 +39634,19 @@ var require_response = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/
|
|
|
39557
39634
|
});
|
|
39558
39635
|
return responseObject;
|
|
39559
39636
|
}
|
|
39560
|
-
static redirect(url$2, status$
|
|
39637
|
+
static redirect(url$2, status$2 = 302) {
|
|
39561
39638
|
webidl$10.argumentLengthCheck(arguments, 1, "Response.redirect");
|
|
39562
39639
|
url$2 = webidl$10.converters.USVString(url$2);
|
|
39563
|
-
status$
|
|
39640
|
+
status$2 = webidl$10.converters["unsigned short"](status$2);
|
|
39564
39641
|
let parsedURL;
|
|
39565
39642
|
try {
|
|
39566
39643
|
parsedURL = new URL(url$2, relevantRealm.settingsObject.baseUrl);
|
|
39567
39644
|
} catch (err) {
|
|
39568
39645
|
throw new TypeError(`Failed to parse URL from ${url$2}`, { cause: err });
|
|
39569
39646
|
}
|
|
39570
|
-
if (!redirectStatusSet$1.has(status$
|
|
39647
|
+
if (!redirectStatusSet$1.has(status$2)) throw new RangeError(`Invalid status code ${status$2}`);
|
|
39571
39648
|
const responseObject = fromInnerResponse$2(makeResponse$1({}), "immutable");
|
|
39572
|
-
responseObject.#state.status = status$
|
|
39649
|
+
responseObject.#state.status = status$2;
|
|
39573
39650
|
const value = isomorphicEncode$1(URLSerializer$3(parsedURL));
|
|
39574
39651
|
responseObject.#state.headersList.append("location", value, true);
|
|
39575
39652
|
return responseObject;
|
|
@@ -39580,7 +39657,7 @@ var require_response = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/
|
|
|
39580
39657
|
if (body !== null) body = webidl$10.converters.BodyInit(body, "Response", "body");
|
|
39581
39658
|
init = webidl$10.converters.ResponseInit(init);
|
|
39582
39659
|
this.#state = makeResponse$1({});
|
|
39583
|
-
this.#headers = new Headers$
|
|
39660
|
+
this.#headers = new Headers$6(kConstruct$6);
|
|
39584
39661
|
setHeadersGuard$1(this.#headers, "response");
|
|
39585
39662
|
setHeadersList$1(this.#headers, this.#state.headersList);
|
|
39586
39663
|
let bodyWithType = null;
|
|
@@ -39819,7 +39896,7 @@ var require_response = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/
|
|
|
39819
39896
|
function fromInnerResponse$2(innerResponse, guard) {
|
|
39820
39897
|
const response = new Response$3(kConstruct$6);
|
|
39821
39898
|
setResponseState(response, innerResponse);
|
|
39822
|
-
const headers = new Headers$
|
|
39899
|
+
const headers = new Headers$6(kConstruct$6);
|
|
39823
39900
|
setResponseHeaders(response, headers);
|
|
39824
39901
|
setHeadersList$1(headers, innerResponse.headersList);
|
|
39825
39902
|
setHeadersGuard$1(headers, guard);
|
|
@@ -39873,7 +39950,7 @@ var require_response = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/
|
|
|
39873
39950
|
//#region ../../node_modules/.pnpm/undici@7.30.1/node_modules/undici/lib/web/fetch/request.js
|
|
39874
39951
|
var require_request = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/undici@7.30.1/node_modules/undici/lib/web/fetch/request.js": ((exports, module) => {
|
|
39875
39952
|
const { extractBody: extractBody$1, mixinBody, cloneBody, bodyUnusable } = require_body();
|
|
39876
|
-
const { Headers: Headers$
|
|
39953
|
+
const { Headers: Headers$5, fill: fillHeaders, HeadersList: HeadersList$1, setHeadersGuard, getHeadersGuard, setHeadersList, getHeadersList: getHeadersList$1 } = require_headers();
|
|
39877
39954
|
const util$2 = require_util$5();
|
|
39878
39955
|
const nodeUtil = __require$3("node:util");
|
|
39879
39956
|
const { isValidHTTPToken, sameOrigin: sameOrigin$1, environmentSettingsObject: environmentSettingsObject$3 } = require_util$4();
|
|
@@ -40049,7 +40126,7 @@ var require_request = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
40049
40126
|
abort: abort$1
|
|
40050
40127
|
}, abort$1);
|
|
40051
40128
|
}
|
|
40052
|
-
this.#headers = new Headers$
|
|
40129
|
+
this.#headers = new Headers$5(kConstruct$5);
|
|
40053
40130
|
setHeadersList(this.#headers, request$2.headersList);
|
|
40054
40131
|
setHeadersGuard(this.#headers, "request");
|
|
40055
40132
|
if (mode === "no-cors") {
|
|
@@ -40322,7 +40399,7 @@ var require_request = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
40322
40399
|
setRequestState(request$2, innerRequest);
|
|
40323
40400
|
setRequestDispatcher(request$2, dispatcher);
|
|
40324
40401
|
setRequestSignal(request$2, signal);
|
|
40325
|
-
const headers = new Headers$
|
|
40402
|
+
const headers = new Headers$5(kConstruct$5);
|
|
40326
40403
|
setRequestHeaders(request$2, headers);
|
|
40327
40404
|
setHeadersList(headers, innerRequest.headersList);
|
|
40328
40405
|
setHeadersGuard(headers, guard);
|
|
@@ -41147,9 +41224,9 @@ var require_fetch = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/und
|
|
|
41147
41224
|
})();
|
|
41148
41225
|
}
|
|
41149
41226
|
try {
|
|
41150
|
-
const { body, status: status$
|
|
41227
|
+
const { body, status: status$2, statusText, headersList, socket } = await dispatch({ body: requestBody });
|
|
41151
41228
|
if (socket) response = makeResponse({
|
|
41152
|
-
status: status$
|
|
41229
|
+
status: status$2,
|
|
41153
41230
|
statusText,
|
|
41154
41231
|
headersList,
|
|
41155
41232
|
socket
|
|
@@ -41158,7 +41235,7 @@ var require_fetch = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/und
|
|
|
41158
41235
|
const iterator = body[Symbol.asyncIterator]();
|
|
41159
41236
|
fetchParams.controller.next = () => iterator.next();
|
|
41160
41237
|
response = makeResponse({
|
|
41161
|
-
status: status$
|
|
41238
|
+
status: status$2,
|
|
41162
41239
|
statusText,
|
|
41163
41240
|
headersList
|
|
41164
41241
|
});
|
|
@@ -41262,8 +41339,8 @@ var require_fetch = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/und
|
|
|
41262
41339
|
onResponseStarted() {
|
|
41263
41340
|
timingInfo.finalNetworkResponseStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability);
|
|
41264
41341
|
},
|
|
41265
|
-
onHeaders(status$
|
|
41266
|
-
if (status$
|
|
41342
|
+
onHeaders(status$2, rawHeaders, resume$1, statusText) {
|
|
41343
|
+
if (status$2 < 200) return false;
|
|
41267
41344
|
const headersList = new HeadersList();
|
|
41268
41345
|
for (let i$1 = 0; i$1 < rawHeaders.length; i$1 += 2) {
|
|
41269
41346
|
const nameStr = bufferToLowerCasedHeaderName(rawHeaders[i$1]);
|
|
@@ -41271,9 +41348,9 @@ var require_fetch = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/und
|
|
|
41271
41348
|
if (Array.isArray(value) && !Buffer.isBuffer(rawHeaders[i$1 + 1])) for (const val of value) headersList.append(nameStr, val.toString("latin1"), true);
|
|
41272
41349
|
else headersList.append(nameStr, value.toString("latin1"), true);
|
|
41273
41350
|
}
|
|
41274
|
-
const willFollow = headersList.get("location", true) && request$2.redirect === "follow" && redirectStatusSet.has(status$
|
|
41351
|
+
const willFollow = headersList.get("location", true) && request$2.redirect === "follow" && redirectStatusSet.has(status$2);
|
|
41275
41352
|
const decoders = [];
|
|
41276
|
-
if (request$2.method !== "HEAD" && request$2.method !== "CONNECT" && !nullBodyStatus.includes(status$
|
|
41353
|
+
if (request$2.method !== "HEAD" && request$2.method !== "CONNECT" && !nullBodyStatus.includes(status$2) && !willFollow) {
|
|
41277
41354
|
const contentEncoding = headersList.get("content-encoding", true);
|
|
41278
41355
|
/** @type {string[]} */
|
|
41279
41356
|
const codings = contentEncoding ? contentEncoding.toLowerCase().split(",") : [];
|
|
@@ -41309,7 +41386,7 @@ var require_fetch = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/und
|
|
|
41309
41386
|
this.body = new Readable({ read: resume$1 });
|
|
41310
41387
|
const onError$1 = this.onError.bind(this);
|
|
41311
41388
|
resolve$4({
|
|
41312
|
-
status: status$
|
|
41389
|
+
status: status$2,
|
|
41313
41390
|
statusText,
|
|
41314
41391
|
headersList,
|
|
41315
41392
|
body: decoders.length ? pipeline$1(this.body, ...decoders, (err) => {
|
|
@@ -41335,8 +41412,8 @@ var require_fetch = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/und
|
|
|
41335
41412
|
fetchParams.controller.terminate(error$3);
|
|
41336
41413
|
reject(error$3);
|
|
41337
41414
|
},
|
|
41338
|
-
onRequestUpgrade(_controller, status$
|
|
41339
|
-
if (socket.session != null && status$
|
|
41415
|
+
onRequestUpgrade(_controller, status$2, headers, socket) {
|
|
41416
|
+
if (socket.session != null && status$2 !== 200 || socket.session == null && status$2 !== 101) return false;
|
|
41340
41417
|
const headersList = new HeadersList();
|
|
41341
41418
|
for (const [name, value] of Object.entries(headers)) {
|
|
41342
41419
|
if (value == null) continue;
|
|
@@ -41345,15 +41422,15 @@ var require_fetch = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/und
|
|
|
41345
41422
|
else headersList.append(headerName, String(value), true);
|
|
41346
41423
|
}
|
|
41347
41424
|
resolve$4({
|
|
41348
|
-
status: status$
|
|
41349
|
-
statusText: STATUS_CODES[status$
|
|
41425
|
+
status: status$2,
|
|
41426
|
+
statusText: STATUS_CODES[status$2],
|
|
41350
41427
|
headersList,
|
|
41351
41428
|
socket
|
|
41352
41429
|
});
|
|
41353
41430
|
return true;
|
|
41354
41431
|
},
|
|
41355
|
-
onUpgrade(status$
|
|
41356
|
-
if (socket.session != null && status$
|
|
41432
|
+
onUpgrade(status$2, rawHeaders, socket) {
|
|
41433
|
+
if (socket.session != null && status$2 !== 200 || socket.session == null && status$2 !== 101) return false;
|
|
41357
41434
|
const headersList = new HeadersList();
|
|
41358
41435
|
for (let i$1 = 0; i$1 < rawHeaders.length; i$1 += 2) {
|
|
41359
41436
|
const nameStr = bufferToLowerCasedHeaderName(rawHeaders[i$1]);
|
|
@@ -41362,8 +41439,8 @@ var require_fetch = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/und
|
|
|
41362
41439
|
else headersList.append(nameStr, value.toString("latin1"), true);
|
|
41363
41440
|
}
|
|
41364
41441
|
resolve$4({
|
|
41365
|
-
status: status$
|
|
41366
|
-
statusText: STATUS_CODES[status$
|
|
41442
|
+
status: status$2,
|
|
41443
|
+
statusText: STATUS_CODES[status$2],
|
|
41367
41444
|
headersList,
|
|
41368
41445
|
socket
|
|
41369
41446
|
});
|
|
@@ -42316,8 +42393,8 @@ var require_cookies = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/u
|
|
|
42316
42393
|
const { parseSetCookie } = require_parse$2();
|
|
42317
42394
|
const { stringify: stringify$2 } = require_util$2();
|
|
42318
42395
|
const { webidl: webidl$5 } = require_webidl();
|
|
42319
|
-
const { Headers: Headers$
|
|
42320
|
-
const brandChecks = webidl$5.brandCheckMultiple([Headers$
|
|
42396
|
+
const { Headers: Headers$4 } = require_headers();
|
|
42397
|
+
const brandChecks = webidl$5.brandCheckMultiple([Headers$4, globalThis.Headers].filter(Boolean));
|
|
42321
42398
|
/**
|
|
42322
42399
|
* @typedef {Object} Cookie
|
|
42323
42400
|
* @property {string} name
|
|
@@ -43176,7 +43253,7 @@ var require_connection = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnp
|
|
|
43176
43253
|
const { parseExtensions, isClosed: isClosed$1, isClosing: isClosing$1, isEstablished: isEstablished$2, isConnecting: isConnecting$1, validateCloseCodeAndReason: validateCloseCodeAndReason$1 } = require_util$1();
|
|
43177
43254
|
const { makeRequest: makeRequest$1 } = require_request();
|
|
43178
43255
|
const { fetching: fetching$1 } = require_fetch();
|
|
43179
|
-
const { Headers: Headers$
|
|
43256
|
+
const { Headers: Headers$3, getHeadersList } = require_headers();
|
|
43180
43257
|
const { getDecodeSplit } = require_util$4();
|
|
43181
43258
|
const { WebsocketFrameSend: WebsocketFrameSend$4 } = require_frame();
|
|
43182
43259
|
const assert$3 = __require$3("node:assert");
|
|
@@ -43204,7 +43281,7 @@ var require_connection = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnp
|
|
|
43204
43281
|
redirect: "error",
|
|
43205
43282
|
useURLCredentials: true
|
|
43206
43283
|
});
|
|
43207
|
-
if (options.headers) request$2.headersList = getHeadersList(new Headers$
|
|
43284
|
+
if (options.headers) request$2.headersList = getHeadersList(new Headers$3(options.headers));
|
|
43208
43285
|
const keyValue = crypto.randomBytes(16).toString("base64");
|
|
43209
43286
|
request$2.headersList.append("sec-websocket-key", keyValue, true);
|
|
43210
43287
|
request$2.headersList.append("sec-websocket-version", "13", true);
|
|
@@ -45475,7 +45552,7 @@ var require_undici = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/un
|
|
|
45475
45552
|
}) });
|
|
45476
45553
|
|
|
45477
45554
|
//#endregion
|
|
45478
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.
|
|
45555
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-utils@0.53.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@22.1_dccf70b6c9730ef30ad05bcacf8c8eff/node_modules/@cloudflare/workers-utils/dist/index.mjs
|
|
45479
45556
|
var import_undici$3 = require_undici();
|
|
45480
45557
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
45481
45558
|
var require_vendors$1 = __commonJS$1({ "../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json"(exports$1, module$1) {
|
|
@@ -45889,8 +45966,8 @@ var require_command_exists$2 = __commonJS$1({ "../../node_modules/.pnpm/command-
|
|
|
45889
45966
|
var commandExistsUnix$1 = /* @__PURE__ */ __name$4(function(commandName, cleanedCommandName, callback$1) {
|
|
45890
45967
|
fileNotExists$1(commandName, function(isFile) {
|
|
45891
45968
|
if (!isFile) {
|
|
45892
|
-
exec$3("command -v " + cleanedCommandName + " 2>/dev/null && { echo >&1 " + cleanedCommandName + "; exit 0; }", function(error$3, stdout$
|
|
45893
|
-
callback$1(null, !!stdout$
|
|
45969
|
+
exec$3("command -v " + cleanedCommandName + " 2>/dev/null && { echo >&1 " + cleanedCommandName + "; exit 0; }", function(error$3, stdout$3, stderr$2) {
|
|
45970
|
+
callback$1(null, !!stdout$3);
|
|
45894
45971
|
});
|
|
45895
45972
|
return;
|
|
45896
45973
|
}
|
|
@@ -45958,7 +46035,7 @@ var require_command_exists$2 = __commonJS$1({ "../../node_modules/.pnpm/command-
|
|
|
45958
46035
|
var require_command_exists2 = __commonJS$1({ "../../node_modules/.pnpm/command-exists@1.2.9/node_modules/command-exists/index.js"(exports$1, module$1) {
|
|
45959
46036
|
module$1.exports = require_command_exists$2();
|
|
45960
46037
|
} });
|
|
45961
|
-
var require_path = __commonJS$1({ "../../node_modules/.pnpm/minimatch@5.1.
|
|
46038
|
+
var require_path = __commonJS$1({ "../../node_modules/.pnpm/minimatch@5.1.9/node_modules/minimatch/lib/path.js"(exports$1, module$1) {
|
|
45962
46039
|
module$1.exports = typeof process === "object" && process && process.platform === "win32" ? { sep: "\\" } : { sep: "/" };
|
|
45963
46040
|
} });
|
|
45964
46041
|
var require_balanced_match = __commonJS$1({ "../../node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports$1, module$1) {
|
|
@@ -46012,7 +46089,7 @@ var require_balanced_match = __commonJS$1({ "../../node_modules/.pnpm/balanced-m
|
|
|
46012
46089
|
}
|
|
46013
46090
|
__name$4(range, "range");
|
|
46014
46091
|
} });
|
|
46015
|
-
var require_brace_expansion = __commonJS$1({ "../../node_modules/.pnpm/brace-expansion@2.
|
|
46092
|
+
var require_brace_expansion = __commonJS$1({ "../../node_modules/.pnpm/brace-expansion@2.1.7/node_modules/brace-expansion/index.js"(exports$1, module$1) {
|
|
46016
46093
|
var balanced = require_balanced_match();
|
|
46017
46094
|
module$1.exports = expandTop;
|
|
46018
46095
|
var escSlash = "\0SLASH" + Math.random() + "\0";
|
|
@@ -46020,6 +46097,10 @@ var require_brace_expansion = __commonJS$1({ "../../node_modules/.pnpm/brace-exp
|
|
|
46020
46097
|
var escClose = "\0CLOSE" + Math.random() + "\0";
|
|
46021
46098
|
var escComma = "\0COMMA" + Math.random() + "\0";
|
|
46022
46099
|
var escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
46100
|
+
var EXPANSION_MAX = 1e5;
|
|
46101
|
+
var EXPANSION_MAX_LENGTH = 4e6;
|
|
46102
|
+
var EXPANSION_MAX_DEPTH = 1e3;
|
|
46103
|
+
var EXPANSION_MAX_REWRITES = 1e3;
|
|
46023
46104
|
function numeric$1(str) {
|
|
46024
46105
|
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
|
46025
46106
|
}
|
|
@@ -46032,29 +46113,46 @@ var require_brace_expansion = __commonJS$1({ "../../node_modules/.pnpm/brace-exp
|
|
|
46032
46113
|
return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
|
|
46033
46114
|
}
|
|
46034
46115
|
__name$4(unescapeBraces, "unescapeBraces");
|
|
46116
|
+
function pushAll(target$1, items) {
|
|
46117
|
+
for (var i$1 = 0; i$1 < items.length; i$1++) target$1.push(items[i$1]);
|
|
46118
|
+
}
|
|
46119
|
+
__name$4(pushAll, "pushAll");
|
|
46035
46120
|
function parseCommaParts(str) {
|
|
46036
|
-
if (!str) return [""];
|
|
46037
46121
|
var parts = [];
|
|
46038
|
-
var
|
|
46039
|
-
|
|
46040
|
-
|
|
46041
|
-
|
|
46042
|
-
|
|
46043
|
-
|
|
46044
|
-
|
|
46045
|
-
|
|
46046
|
-
|
|
46047
|
-
|
|
46048
|
-
|
|
46049
|
-
|
|
46050
|
-
|
|
46051
|
-
|
|
46122
|
+
var carry = "";
|
|
46123
|
+
for (;;) {
|
|
46124
|
+
var m = balanced("{", "}", str);
|
|
46125
|
+
if (!m) {
|
|
46126
|
+
var tail$1 = str.split(",");
|
|
46127
|
+
tail$1[0] = carry + tail$1[0];
|
|
46128
|
+
pushAll(parts, tail$1);
|
|
46129
|
+
return parts;
|
|
46130
|
+
}
|
|
46131
|
+
var pre = m.pre;
|
|
46132
|
+
var body = m.body;
|
|
46133
|
+
var post = m.post;
|
|
46134
|
+
var p$2 = pre.split(",");
|
|
46135
|
+
p$2[0] = carry + p$2[0];
|
|
46136
|
+
p$2[p$2.length - 1] += "{" + body + "}";
|
|
46137
|
+
if (!post.length) {
|
|
46138
|
+
pushAll(parts, p$2);
|
|
46139
|
+
return parts;
|
|
46140
|
+
}
|
|
46141
|
+
carry = p$2.pop();
|
|
46142
|
+
pushAll(parts, p$2);
|
|
46143
|
+
str = post;
|
|
46144
|
+
}
|
|
46052
46145
|
}
|
|
46053
46146
|
__name$4(parseCommaParts, "parseCommaParts");
|
|
46054
|
-
function expandTop(str) {
|
|
46147
|
+
function expandTop(str, options) {
|
|
46055
46148
|
if (!str) return [];
|
|
46149
|
+
options = options || {};
|
|
46150
|
+
var max = options.max == null ? EXPANSION_MAX : options.max;
|
|
46151
|
+
var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
|
|
46152
|
+
var maxDepth = options.maxDepth == null ? EXPANSION_MAX_DEPTH : options.maxDepth;
|
|
46153
|
+
var maxRewrites = options.maxRewrites == null ? EXPANSION_MAX_REWRITES : options.maxRewrites;
|
|
46056
46154
|
if (str.substr(0, 2) === "{}") str = "\\{\\}" + str.substr(2);
|
|
46057
|
-
return expand(escapeBraces(str), true).map(unescapeBraces);
|
|
46155
|
+
return expand(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
|
46058
46156
|
}
|
|
46059
46157
|
__name$4(expandTop, "expandTop");
|
|
46060
46158
|
function embrace(str) {
|
|
@@ -46073,84 +46171,129 @@ var require_brace_expansion = __commonJS$1({ "../../node_modules/.pnpm/brace-exp
|
|
|
46073
46171
|
return i$1 >= y;
|
|
46074
46172
|
}
|
|
46075
46173
|
__name$4(gte$4, "gte");
|
|
46076
|
-
function
|
|
46077
|
-
var
|
|
46078
|
-
var
|
|
46079
|
-
|
|
46080
|
-
|
|
46081
|
-
|
|
46082
|
-
|
|
46083
|
-
|
|
46084
|
-
|
|
46174
|
+
function combine(acc, pre, values, max, maxLength, dropEmpties) {
|
|
46175
|
+
var out = [];
|
|
46176
|
+
var length = 0;
|
|
46177
|
+
for (var a = 0; a < acc.length; a++) for (var v = 0; v < values.length; v++) {
|
|
46178
|
+
if (out.length >= max) return out;
|
|
46179
|
+
var expansion = acc[a] + pre + values[v];
|
|
46180
|
+
if (dropEmpties && !expansion) continue;
|
|
46181
|
+
if (length + expansion.length > maxLength) return out;
|
|
46182
|
+
out.push(expansion);
|
|
46183
|
+
length += expansion.length;
|
|
46085
46184
|
}
|
|
46086
|
-
|
|
46185
|
+
return out;
|
|
46186
|
+
}
|
|
46187
|
+
__name$4(combine, "combine");
|
|
46188
|
+
function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|
46189
|
+
var n2 = body.split(/\.\./);
|
|
46190
|
+
var N = [];
|
|
46191
|
+
if (n2[0] === void 0 || n2[1] === void 0) return N;
|
|
46192
|
+
var x = numeric$1(n2[0]);
|
|
46193
|
+
var y = numeric$1(n2[1]);
|
|
46194
|
+
var width = Math.max(n2[0].length, n2[1].length);
|
|
46195
|
+
var incr = n2.length === 3 && n2[2] !== void 0 ? Math.max(Math.abs(numeric$1(n2[2])), 1) : 1;
|
|
46196
|
+
var test = lte$4;
|
|
46197
|
+
if (y < x) {
|
|
46198
|
+
incr *= -1;
|
|
46199
|
+
test = gte$4;
|
|
46200
|
+
}
|
|
46201
|
+
var pad = n2.some(isPadded);
|
|
46202
|
+
var length = 0;
|
|
46203
|
+
for (var i$1 = x; test(i$1, y) && N.length < max; i$1 += incr) {
|
|
46204
|
+
var c$1;
|
|
46205
|
+
if (isAlphaSequence) {
|
|
46206
|
+
c$1 = String.fromCharCode(i$1);
|
|
46207
|
+
if (c$1 === "\\") c$1 = "";
|
|
46208
|
+
} else {
|
|
46209
|
+
c$1 = String(i$1);
|
|
46210
|
+
if (pad) {
|
|
46211
|
+
var need = width - c$1.length;
|
|
46212
|
+
if (need > 0) {
|
|
46213
|
+
var z$1 = new Array(need + 1).join("0");
|
|
46214
|
+
if (i$1 < 0) c$1 = "-" + z$1 + c$1.slice(1);
|
|
46215
|
+
else c$1 = z$1 + c$1;
|
|
46216
|
+
}
|
|
46217
|
+
}
|
|
46218
|
+
}
|
|
46219
|
+
if (length + c$1.length > maxLength) break;
|
|
46220
|
+
N.push(c$1);
|
|
46221
|
+
length += c$1.length;
|
|
46222
|
+
}
|
|
46223
|
+
return N;
|
|
46224
|
+
}
|
|
46225
|
+
__name$4(expandSequence, "expandSequence");
|
|
46226
|
+
function expand(str, max, maxLength, maxDepth, depth$1, maxRewrites, isTop) {
|
|
46227
|
+
if (depth$1 > maxDepth) return [str];
|
|
46228
|
+
var acc = [""];
|
|
46229
|
+
var rewrites = 0;
|
|
46230
|
+
var dropEmpties = false;
|
|
46231
|
+
var firstGroup = true;
|
|
46232
|
+
for (;;) {
|
|
46233
|
+
const m = balanced("{", "}", str);
|
|
46234
|
+
if (!m) return combine(acc, str, [""], max, maxLength, dropEmpties);
|
|
46235
|
+
const pre = m.pre;
|
|
46236
|
+
if (/\$$/.test(pre)) {
|
|
46237
|
+
acc = combine(acc, pre + "{" + m.body + "}", [""], max, maxLength, dropEmpties && !m.post.length);
|
|
46238
|
+
firstGroup = false;
|
|
46239
|
+
if (!m.post.length) break;
|
|
46240
|
+
str = m.post;
|
|
46241
|
+
continue;
|
|
46242
|
+
}
|
|
46087
46243
|
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
46088
46244
|
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
46089
46245
|
var isSequence = isNumericSequence || isAlphaSequence;
|
|
46090
46246
|
var isOptions = m.body.indexOf(",") >= 0;
|
|
46091
46247
|
if (!isSequence && !isOptions) {
|
|
46092
|
-
if (m.post.match(
|
|
46248
|
+
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
|
46249
|
+
rewrites++;
|
|
46093
46250
|
str = m.pre + "{" + m.body + escClose + m.post;
|
|
46094
|
-
|
|
46251
|
+
isTop = true;
|
|
46252
|
+
continue;
|
|
46095
46253
|
}
|
|
46096
|
-
return [
|
|
46254
|
+
return combine(acc, pre + "{" + m.body + "}" + m.post, [""], max, maxLength, dropEmpties);
|
|
46097
46255
|
}
|
|
46098
|
-
|
|
46099
|
-
|
|
46100
|
-
|
|
46101
|
-
n2 = parseCommaParts(m.body);
|
|
46102
|
-
if (n2.length === 1) {
|
|
46103
|
-
n2 = expand(n2[0], false).map(embrace);
|
|
46104
|
-
if (n2.length === 1) return post.map(function(p$2) {
|
|
46105
|
-
return m.pre + n2[0] + p$2;
|
|
46106
|
-
});
|
|
46107
|
-
}
|
|
46256
|
+
if (firstGroup) {
|
|
46257
|
+
dropEmpties = isTop && !isSequence;
|
|
46258
|
+
firstGroup = false;
|
|
46108
46259
|
}
|
|
46109
|
-
var
|
|
46110
|
-
if (isSequence)
|
|
46111
|
-
|
|
46112
|
-
var
|
|
46113
|
-
|
|
46114
|
-
|
|
46115
|
-
|
|
46116
|
-
|
|
46117
|
-
|
|
46118
|
-
|
|
46260
|
+
var values;
|
|
46261
|
+
if (isSequence) values = expandSequence(m.body, isAlphaSequence, max, maxLength);
|
|
46262
|
+
else {
|
|
46263
|
+
var n2 = parseCommaParts(m.body);
|
|
46264
|
+
if (n2.length === 1 && n2[0] !== void 0) {
|
|
46265
|
+
n2 = expand(n2[0], max, maxLength, maxDepth, depth$1 + 1, maxRewrites, false).map(embrace);
|
|
46266
|
+
if (n2.length === 1) {
|
|
46267
|
+
acc = combine(acc, pre + n2[0], [""], max, maxLength, dropEmpties && !m.post.length);
|
|
46268
|
+
if (!m.post.length) break;
|
|
46269
|
+
str = m.post;
|
|
46270
|
+
continue;
|
|
46271
|
+
}
|
|
46119
46272
|
}
|
|
46120
|
-
var
|
|
46121
|
-
|
|
46122
|
-
|
|
46123
|
-
|
|
46124
|
-
|
|
46125
|
-
|
|
46126
|
-
|
|
46127
|
-
|
|
46128
|
-
|
|
46129
|
-
if (
|
|
46130
|
-
|
|
46131
|
-
|
|
46132
|
-
var z$1 = new Array(need + 1).join("0");
|
|
46133
|
-
if (i$1 < 0) c$1 = "-" + z$1 + c$1.slice(1);
|
|
46134
|
-
else c$1 = z$1 + c$1;
|
|
46135
|
-
}
|
|
46136
|
-
}
|
|
46273
|
+
var dropsEmpties = dropEmpties && !m.post.length && !pre;
|
|
46274
|
+
for (var d$1 = 0; dropsEmpties && d$1 < acc.length; d$1++) if (acc[d$1]) dropsEmpties = false;
|
|
46275
|
+
values = [];
|
|
46276
|
+
var valuesLength = 0;
|
|
46277
|
+
outer: for (var j$1 = 0; j$1 < n2.length; j$1++) {
|
|
46278
|
+
var expanded = expand(n2[j$1], max, maxLength, maxDepth, depth$1 + 1, maxRewrites, false);
|
|
46279
|
+
for (var k = 0; k < expanded.length; k++) {
|
|
46280
|
+
var v = expanded[k];
|
|
46281
|
+
if (dropsEmpties && !v) continue;
|
|
46282
|
+
if (values.length >= max || valuesLength + v.length > maxLength) break outer;
|
|
46283
|
+
values.push(v);
|
|
46284
|
+
valuesLength += v.length;
|
|
46137
46285
|
}
|
|
46138
|
-
N.push(c$1);
|
|
46139
46286
|
}
|
|
46140
|
-
} else {
|
|
46141
|
-
N = [];
|
|
46142
|
-
for (var j$1 = 0; j$1 < n2.length; j$1++) N.push.apply(N, expand(n2[j$1], false));
|
|
46143
|
-
}
|
|
46144
|
-
for (var j$1 = 0; j$1 < N.length; j$1++) for (var k = 0; k < post.length; k++) {
|
|
46145
|
-
var expansion = pre + N[j$1] + post[k];
|
|
46146
|
-
if (!isTop || isSequence || expansion) expansions.push(expansion);
|
|
46147
46287
|
}
|
|
46288
|
+
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
|
|
46289
|
+
if (!m.post.length) break;
|
|
46290
|
+
str = m.post;
|
|
46148
46291
|
}
|
|
46149
|
-
return
|
|
46292
|
+
return acc;
|
|
46150
46293
|
}
|
|
46151
46294
|
__name$4(expand, "expand");
|
|
46152
46295
|
} });
|
|
46153
|
-
var require_minimatch = __commonJS$1({ "../../node_modules/.pnpm/minimatch@5.1.
|
|
46296
|
+
var require_minimatch = __commonJS$1({ "../../node_modules/.pnpm/minimatch@5.1.9/node_modules/minimatch/minimatch.js"(exports$1, module$1) {
|
|
46154
46297
|
var minimatch = module$1.exports = (p$2, pattern, options = {}) => {
|
|
46155
46298
|
assertValidPattern(pattern);
|
|
46156
46299
|
if (!options.nocomment && pattern.charAt(0) === "#") return false;
|
|
@@ -46253,6 +46396,7 @@ var require_minimatch = __commonJS$1({ "../../node_modules/.pnpm/minimatch@5.1.6
|
|
|
46253
46396
|
assertValidPattern(pattern);
|
|
46254
46397
|
if (!options) options = {};
|
|
46255
46398
|
this.options = options;
|
|
46399
|
+
this.maxGlobstarRecursion = options.maxGlobstarRecursion !== void 0 ? options.maxGlobstarRecursion : 200;
|
|
46256
46400
|
this.set = [];
|
|
46257
46401
|
this.pattern = pattern;
|
|
46258
46402
|
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
|
|
@@ -46301,54 +46445,96 @@ var require_minimatch = __commonJS$1({ "../../node_modules/.pnpm/minimatch@5.1.6
|
|
|
46301
46445
|
this.negate = negate;
|
|
46302
46446
|
}
|
|
46303
46447
|
matchOne(file$2, pattern, partial$2) {
|
|
46304
|
-
|
|
46305
|
-
this.
|
|
46306
|
-
|
|
46307
|
-
|
|
46308
|
-
|
|
46309
|
-
|
|
46310
|
-
|
|
46311
|
-
|
|
46448
|
+
if (pattern.indexOf(GLOBSTAR) !== -1) return this._matchGlobstar(file$2, pattern, partial$2, 0, 0);
|
|
46449
|
+
return this._matchOne(file$2, pattern, partial$2, 0, 0);
|
|
46450
|
+
}
|
|
46451
|
+
_matchGlobstar(file$2, pattern, partial$2, fileIndex, patternIndex) {
|
|
46452
|
+
let firstgs = -1;
|
|
46453
|
+
for (let i$1 = patternIndex; i$1 < pattern.length; i$1++) if (pattern[i$1] === GLOBSTAR) {
|
|
46454
|
+
firstgs = i$1;
|
|
46455
|
+
break;
|
|
46456
|
+
}
|
|
46457
|
+
let lastgs = -1;
|
|
46458
|
+
for (let i$1 = pattern.length - 1; i$1 >= 0; i$1--) if (pattern[i$1] === GLOBSTAR) {
|
|
46459
|
+
lastgs = i$1;
|
|
46460
|
+
break;
|
|
46461
|
+
}
|
|
46462
|
+
const head = pattern.slice(patternIndex, firstgs);
|
|
46463
|
+
const body = partial$2 ? pattern.slice(firstgs + 1) : pattern.slice(firstgs + 1, lastgs);
|
|
46464
|
+
const tail$1 = partial$2 ? [] : pattern.slice(lastgs + 1);
|
|
46465
|
+
if (head.length) {
|
|
46466
|
+
const fileHead = file$2.slice(fileIndex, fileIndex + head.length);
|
|
46467
|
+
if (!this._matchOne(fileHead, head, partial$2, 0, 0)) return false;
|
|
46468
|
+
fileIndex += head.length;
|
|
46469
|
+
}
|
|
46470
|
+
let fileTailMatch = 0;
|
|
46471
|
+
if (tail$1.length) {
|
|
46472
|
+
if (tail$1.length + fileIndex > file$2.length) return false;
|
|
46473
|
+
const tailStart = file$2.length - tail$1.length;
|
|
46474
|
+
if (this._matchOne(file$2, tail$1, partial$2, tailStart, 0)) fileTailMatch = tail$1.length;
|
|
46475
|
+
else {
|
|
46476
|
+
if (file$2[file$2.length - 1] !== "" || fileIndex + tail$1.length === file$2.length) return false;
|
|
46477
|
+
if (!this._matchOne(file$2, tail$1, partial$2, tailStart - 1, 0)) return false;
|
|
46478
|
+
fileTailMatch = tail$1.length + 1;
|
|
46479
|
+
}
|
|
46480
|
+
}
|
|
46481
|
+
if (!body.length) {
|
|
46482
|
+
let sawSome = !!fileTailMatch;
|
|
46483
|
+
for (let i$1 = fileIndex; i$1 < file$2.length - fileTailMatch; i$1++) {
|
|
46484
|
+
const f = String(file$2[i$1]);
|
|
46485
|
+
sawSome = true;
|
|
46486
|
+
if (f === "." || f === ".." || !this.options.dot && f.charAt(0) === ".") return false;
|
|
46487
|
+
}
|
|
46488
|
+
return partial$2 || sawSome;
|
|
46489
|
+
}
|
|
46490
|
+
const bodySegments = [[[], 0]];
|
|
46491
|
+
let currentBody = bodySegments[0];
|
|
46492
|
+
let nonGsParts = 0;
|
|
46493
|
+
const nonGsPartsSums = [0];
|
|
46494
|
+
for (const b of body) if (b === GLOBSTAR) {
|
|
46495
|
+
nonGsPartsSums.push(nonGsParts);
|
|
46496
|
+
currentBody = [[], 0];
|
|
46497
|
+
bodySegments.push(currentBody);
|
|
46498
|
+
} else {
|
|
46499
|
+
currentBody[0].push(b);
|
|
46500
|
+
nonGsParts++;
|
|
46501
|
+
}
|
|
46502
|
+
let idx = bodySegments.length - 1;
|
|
46503
|
+
const fileLength = file$2.length - fileTailMatch;
|
|
46504
|
+
for (const b of bodySegments) b[1] = fileLength - (nonGsPartsSums[idx--] + b[0].length);
|
|
46505
|
+
return !!this._matchGlobStarBodySections(file$2, bodySegments, fileIndex, 0, partial$2, 0, !!fileTailMatch);
|
|
46506
|
+
}
|
|
46507
|
+
_matchGlobStarBodySections(file$2, bodySegments, fileIndex, bodyIndex, partial$2, globStarDepth, sawTail) {
|
|
46508
|
+
const bs = bodySegments[bodyIndex];
|
|
46509
|
+
if (!bs) {
|
|
46510
|
+
for (let i$1 = fileIndex; i$1 < file$2.length; i$1++) {
|
|
46511
|
+
sawTail = true;
|
|
46512
|
+
const f = file$2[i$1];
|
|
46513
|
+
if (f === "." || f === ".." || !this.options.dot && f.charAt(0) === ".") return false;
|
|
46514
|
+
}
|
|
46515
|
+
return sawTail;
|
|
46516
|
+
}
|
|
46517
|
+
const [body, after] = bs;
|
|
46518
|
+
while (fileIndex <= after) {
|
|
46519
|
+
if (this._matchOne(file$2.slice(0, fileIndex + body.length), body, partial$2, fileIndex, 0) && globStarDepth < this.maxGlobstarRecursion) {
|
|
46520
|
+
const sub = this._matchGlobStarBodySections(file$2, bodySegments, fileIndex + body.length, bodyIndex + 1, partial$2, globStarDepth + 1, sawTail);
|
|
46521
|
+
if (sub !== false) return sub;
|
|
46522
|
+
}
|
|
46523
|
+
const f = file$2[fileIndex];
|
|
46524
|
+
if (f === "." || f === ".." || !this.options.dot && f.charAt(0) === ".") return false;
|
|
46525
|
+
fileIndex++;
|
|
46526
|
+
}
|
|
46527
|
+
return partial$2 || null;
|
|
46528
|
+
}
|
|
46529
|
+
_matchOne(file$2, pattern, partial$2, fileIndex, patternIndex) {
|
|
46530
|
+
let fi, pi, fl, pl;
|
|
46531
|
+
for (fi = fileIndex, pi = patternIndex, fl = file$2.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
46312
46532
|
this.debug("matchOne loop");
|
|
46313
|
-
|
|
46314
|
-
|
|
46533
|
+
const p$2 = pattern[pi];
|
|
46534
|
+
const f = file$2[fi];
|
|
46315
46535
|
this.debug(pattern, p$2, f);
|
|
46316
|
-
if (p$2 === false) return false;
|
|
46317
|
-
|
|
46318
|
-
this.debug("GLOBSTAR", [
|
|
46319
|
-
pattern,
|
|
46320
|
-
p$2,
|
|
46321
|
-
f
|
|
46322
|
-
]);
|
|
46323
|
-
var fr = fi;
|
|
46324
|
-
var pr = pi + 1;
|
|
46325
|
-
if (pr === pl) {
|
|
46326
|
-
this.debug("** at the end");
|
|
46327
|
-
for (; fi < fl; fi++) if (file$2[fi] === "." || file$2[fi] === ".." || !options.dot && file$2[fi].charAt(0) === ".") return false;
|
|
46328
|
-
return true;
|
|
46329
|
-
}
|
|
46330
|
-
while (fr < fl) {
|
|
46331
|
-
var swallowee = file$2[fr];
|
|
46332
|
-
this.debug("\nglobstar while", file$2, fr, pattern, pr, swallowee);
|
|
46333
|
-
if (this.matchOne(file$2.slice(fr), pattern.slice(pr), partial$2)) {
|
|
46334
|
-
this.debug("globstar found match!", fr, fl, swallowee);
|
|
46335
|
-
return true;
|
|
46336
|
-
} else {
|
|
46337
|
-
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
|
|
46338
|
-
this.debug("dot detected!", file$2, fr, pattern, pr);
|
|
46339
|
-
break;
|
|
46340
|
-
}
|
|
46341
|
-
this.debug("globstar swallow a segment, and continue");
|
|
46342
|
-
fr++;
|
|
46343
|
-
}
|
|
46344
|
-
}
|
|
46345
|
-
if (partial$2) {
|
|
46346
|
-
this.debug("\n>>> no match, partial?", file$2, fr, pattern, pr);
|
|
46347
|
-
if (fr === fl) return true;
|
|
46348
|
-
}
|
|
46349
|
-
return false;
|
|
46350
|
-
}
|
|
46351
|
-
var hit;
|
|
46536
|
+
if (p$2 === false || p$2 === GLOBSTAR) return false;
|
|
46537
|
+
let hit;
|
|
46352
46538
|
if (typeof p$2 === "string") {
|
|
46353
46539
|
hit = f === p$2;
|
|
46354
46540
|
this.debug("string match", p$2, f, hit);
|
|
@@ -46438,6 +46624,7 @@ var require_minimatch = __commonJS$1({ "../../node_modules/.pnpm/minimatch@5.1.6
|
|
|
46438
46624
|
re$5 += c$1;
|
|
46439
46625
|
continue;
|
|
46440
46626
|
}
|
|
46627
|
+
if (c$1 === "*" && stateChar === "*") continue;
|
|
46441
46628
|
this.debug("call clearStateChar %j", stateChar);
|
|
46442
46629
|
clearStateChar();
|
|
46443
46630
|
stateChar = c$1;
|
|
@@ -48883,6 +49070,10 @@ var validateD1Binding = /* @__PURE__ */ __name$4((diagnostics, field, value) =>
|
|
|
48883
49070
|
diagnostics.errors.push(`"${field}" bindings should, optionally, have a string "database_name" field but got ${JSON.stringify(value)}.`);
|
|
48884
49071
|
isValid = false;
|
|
48885
49072
|
}
|
|
49073
|
+
if (!isOptionalProperty(value, "jurisdiction", "string")) {
|
|
49074
|
+
diagnostics.errors.push(`"${field}" bindings should, optionally, have a string "jurisdiction" field but got ${JSON.stringify(value)}.`);
|
|
49075
|
+
isValid = false;
|
|
49076
|
+
}
|
|
48886
49077
|
if (!isOptionalProperty(value, "migrations_dir", "string")) {
|
|
48887
49078
|
diagnostics.errors.push(`"${field}" bindings should, optionally, have a string "migrations_dir" field but got ${JSON.stringify(value)}.`);
|
|
48888
49079
|
isValid = false;
|
|
@@ -48900,6 +49091,7 @@ var validateD1Binding = /* @__PURE__ */ __name$4((diagnostics, field, value) =>
|
|
|
48900
49091
|
"database_id",
|
|
48901
49092
|
"database_internal_env",
|
|
48902
49093
|
"database_name",
|
|
49094
|
+
"jurisdiction",
|
|
48903
49095
|
"migrations_dir",
|
|
48904
49096
|
"migrations_pattern",
|
|
48905
49097
|
"migrations_table",
|
|
@@ -50269,6 +50461,7 @@ var BINDING_LOCAL_SUPPORT = {
|
|
|
50269
50461
|
service: "local-and-remote",
|
|
50270
50462
|
queue: "local-and-remote",
|
|
50271
50463
|
flagship: "local-and-remote",
|
|
50464
|
+
artifacts: "remote-default-with-local-opt-in",
|
|
50272
50465
|
analytics_engine: "local-and-remote",
|
|
50273
50466
|
vectorize: "remote",
|
|
50274
50467
|
mtls_certificate: "remote",
|
|
@@ -50278,7 +50471,6 @@ var BINDING_LOCAL_SUPPORT = {
|
|
|
50278
50471
|
ai_search: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
50279
50472
|
ai_search_namespace: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
50280
50473
|
media: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
50281
|
-
artifacts: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
50282
50474
|
vpc_service: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
50283
50475
|
vpc_network: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
50284
50476
|
agent_memory: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
@@ -50289,9 +50481,23 @@ function getBindingLocalSupport(type) {
|
|
|
50289
50481
|
return "local-only";
|
|
50290
50482
|
}
|
|
50291
50483
|
__name$4(getBindingLocalSupport, "getBindingLocalSupport");
|
|
50292
|
-
function
|
|
50484
|
+
function resolveBindingRemote(type, remote, { remoteBindingsDisabled = false } = {}) {
|
|
50485
|
+
switch (getBindingLocalSupport(type)) {
|
|
50486
|
+
case "DO-NOT-USE-this-resource-will-never-have-a-local-simulator": return true;
|
|
50487
|
+
case "local-only": return false;
|
|
50488
|
+
case "remote-default-with-local-opt-in": return !remoteBindingsDisabled && remote !== false;
|
|
50489
|
+
case "local-and-remote":
|
|
50490
|
+
case "remote": return !remoteBindingsDisabled && remote === true;
|
|
50491
|
+
}
|
|
50492
|
+
}
|
|
50493
|
+
__name$4(resolveBindingRemote, "resolveBindingRemote");
|
|
50494
|
+
function validateBindingRemoteSetting(type, remote, warn, { binding, remoteBindingsDisabled = false, configFormat: configFormat2 = "wrangler" } = {}) {
|
|
50495
|
+
const remoteSetting = /* @__PURE__ */ __name$4((value) => configFormat2 === "cloudflare-config" ? `\`dev: { remote: ${value} }\`` : `\`remote: ${value}\``, "remoteSetting");
|
|
50293
50496
|
switch (getBindingLocalSupport(type)) {
|
|
50294
50497
|
case "local-and-remote": return;
|
|
50498
|
+
case "remote-default-with-local-opt-in":
|
|
50499
|
+
if (remote === void 0 && !remoteBindingsDisabled) warn(`${binding === void 0 ? `${getBindingTypeFriendlyName(type)} bindings use` : `${getBindingTypeFriendlyName(type)} binding ${binding} uses`} the deployed resource. Set ${remoteSetting(false)} to use the local simulator, or ${remoteSetting(true)} to silence this warning.`);
|
|
50500
|
+
return;
|
|
50295
50501
|
case "local-only":
|
|
50296
50502
|
if (remote === true) throw new UserError(`${getBindingTypeFriendlyName(type)} bindings do not support accessing remote resources.`, { telemetryMessage: "utils bindings unsupported remote resources" });
|
|
50297
50503
|
return;
|
|
@@ -50692,7 +50898,7 @@ function mapWorkerMetadataBindings(bindings) {
|
|
|
50692
50898
|
}, {});
|
|
50693
50899
|
}
|
|
50694
50900
|
__name$4(mapWorkerMetadataBindings, "mapWorkerMetadataBindings");
|
|
50695
|
-
var DEFAULT_COMPAT_DATE = "2026-11-
|
|
50901
|
+
var DEFAULT_COMPAT_DATE = "2026-11-10";
|
|
50696
50902
|
function constructWranglerConfig(config$2) {
|
|
50697
50903
|
const mappedBindings = mapWorkerMetadataBindings(config$2.bindings);
|
|
50698
50904
|
const durableObjectClassNames = config$2.bindings.filter((binding) => binding.type === "durable_object_namespace" && binding.script_name === config$2.name).map((durableObject) => durableObject.class_name);
|
|
@@ -51062,8 +51268,8 @@ function getBindings(config$2, options) {
|
|
|
51062
51268
|
});
|
|
51063
51269
|
}
|
|
51064
51270
|
__name$4(getBindings, "getBindings");
|
|
51065
|
-
var { dim: dim$
|
|
51066
|
-
var brandColor$
|
|
51271
|
+
var { dim: dim$2, white: white$2 } = source_default;
|
|
51272
|
+
var brandColor$2 = source_default.hex("#BD5B08");
|
|
51067
51273
|
var isConnectedStatusExplained = false;
|
|
51068
51274
|
function printBindings(bindings, options) {
|
|
51069
51275
|
const { containers = [], log: log$2, streamingTailConsumers = [], tailConsumers = [] } = options;
|
|
@@ -51286,12 +51492,12 @@ function printBindings(bindings, options) {
|
|
|
51286
51492
|
mode: getMode({ isSimulatedLocally: true })
|
|
51287
51493
|
};
|
|
51288
51494
|
}));
|
|
51289
|
-
if (artifacts.length > 0) output$1.push(...artifacts.map(({ binding, namespace }) => {
|
|
51495
|
+
if (artifacts.length > 0) output$1.push(...artifacts.map(({ binding, namespace, remote }) => {
|
|
51290
51496
|
return {
|
|
51291
51497
|
name: binding,
|
|
51292
51498
|
type: getBindingTypeFriendlyName("artifacts"),
|
|
51293
51499
|
value: namespace,
|
|
51294
|
-
mode: getMode({ isSimulatedLocally:
|
|
51500
|
+
mode: getMode({ isSimulatedLocally: !resolveBindingRemote("artifacts", remote, { remoteBindingsDisabled: context.remoteBindingsDisabled }) })
|
|
51295
51501
|
};
|
|
51296
51502
|
}));
|
|
51297
51503
|
if (unsafe_hello_world.length > 0) output$1.push(...unsafe_hello_world.map(({ binding, enable_timer }) => {
|
|
@@ -51497,13 +51703,13 @@ function printBindings(bindings, options) {
|
|
|
51497
51703
|
const shouldWrap = bindingLength + columnGapSpaces + maxTypeLength + columnGapSpaces + maxModeLength >= process.stdout.columns;
|
|
51498
51704
|
log$2(title2);
|
|
51499
51705
|
const columnGap = shouldWrap ? " ".repeat(columnGapSpacesWrapped) : " ".repeat(columnGapSpaces);
|
|
51500
|
-
log$2(`${padEndAnsi(dim$
|
|
51706
|
+
log$2(`${padEndAnsi(dim$2(headings.binding), shouldWrap ? bindingPrefix.length + maxNameLength : bindingLength)}${columnGap}${padEndAnsi(dim$2(headings.resource), maxTypeLength)}${columnGap}${hasMode ? dim$2(headings.mode) : ""}`);
|
|
51501
51707
|
for (const binding of output$1) {
|
|
51502
|
-
const bindingValue = dim$
|
|
51503
|
-
const bindingString = padEndAnsi(`${white$
|
|
51708
|
+
const bindingValue = dim$2(typeof binding.value === "symbol" ? source_default.italic("inherited") : binding.value ?? "");
|
|
51709
|
+
const bindingString = padEndAnsi(`${white$2(`env.${binding.name}`)}${binding.value && !shouldWrap ? ` (${bindingValue})` : ""}`, shouldWrap ? bindingPrefix.length + maxNameLength : bindingLength);
|
|
51504
51710
|
const suffix = shouldWrap ? binding.value ? `
|
|
51505
51711
|
${bindingValue}` : "" : "";
|
|
51506
|
-
log$2(`${bindingString}${columnGap}${brandColor$
|
|
51712
|
+
log$2(`${bindingString}${columnGap}${brandColor$2(binding.type.padEnd(maxTypeLength))}${columnGap}${hasMode ? binding.mode : ""}${suffix}`);
|
|
51507
51713
|
}
|
|
51508
51714
|
log$2("");
|
|
51509
51715
|
}
|
|
@@ -51539,7 +51745,7 @@ ${containers.map((container) => container.scheduling_policy === "durable_object"
|
|
|
51539
51745
|
log$2(JSON.stringify(context.unsafeMetadata, null, 2));
|
|
51540
51746
|
}
|
|
51541
51747
|
if (hasConnectionStatus && !isConnectedStatusExplained) {
|
|
51542
|
-
log$2(dim$
|
|
51748
|
+
log$2(dim$2(`
|
|
51543
51749
|
Service bindings, Durable Object bindings, and Tail consumers connect to other Wrangler or Vite dev processes running locally, with their connection status indicated by ${source_default.green("[connected]")} or ${source_default.red("[not connected]")}. For more details, refer to https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#local-development
|
|
51544
51750
|
`));
|
|
51545
51751
|
isConnectedStatusExplained = true;
|
|
@@ -51553,12 +51759,12 @@ __name$4(padEndAnsi, "padEndAnsi");
|
|
|
51553
51759
|
function createGetMode({ isProvisioning = false, isLocalDev = false }) {
|
|
51554
51760
|
return /* @__PURE__ */ __name$4(function bindingMode({ isSimulatedLocally, connected } = {}) {
|
|
51555
51761
|
if (isProvisioning || !isLocalDev) return;
|
|
51556
|
-
if (isSimulatedLocally === void 0) return dim$
|
|
51762
|
+
if (isSimulatedLocally === void 0) return dim$2("not supported");
|
|
51557
51763
|
return `${isSimulatedLocally ? source_default.blue("local") : source_default.yellow("remote")}${connected === void 0 ? "" : connected ? source_default.green(" [connected]") : source_default.red(" [not connected]")}`;
|
|
51558
51764
|
}, "bindingMode");
|
|
51559
51765
|
}
|
|
51560
51766
|
__name$4(createGetMode, "createGetMode");
|
|
51561
|
-
var import_ci_info$
|
|
51767
|
+
var import_ci_info$2 = __toESM$1(require_ci_info$1());
|
|
51562
51768
|
function isTtyInteractive() {
|
|
51563
51769
|
try {
|
|
51564
51770
|
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
@@ -51568,16 +51774,16 @@ function isTtyInteractive() {
|
|
|
51568
51774
|
}
|
|
51569
51775
|
__name$4(isTtyInteractive, "isTtyInteractive");
|
|
51570
51776
|
function isInteractive$1() {
|
|
51571
|
-
if (import_ci_info$
|
|
51777
|
+
if (import_ci_info$2.default.CLOUDFLARE_PAGES || import_ci_info$2.default.CLOUDFLARE_WORKERS) return false;
|
|
51572
51778
|
return isTtyInteractive();
|
|
51573
51779
|
}
|
|
51574
51780
|
__name$4(isInteractive$1, "isInteractive");
|
|
51575
51781
|
function isNonInteractiveOrCI() {
|
|
51576
|
-
return !isInteractive$1() || import_ci_info$
|
|
51782
|
+
return !isInteractive$1() || import_ci_info$2.default.isCI;
|
|
51577
51783
|
}
|
|
51578
51784
|
__name$4(isNonInteractiveOrCI, "isNonInteractiveOrCI");
|
|
51579
51785
|
function isCI() {
|
|
51580
|
-
return import_ci_info$
|
|
51786
|
+
return import_ci_info$2.default.isCI;
|
|
51581
51787
|
}
|
|
51582
51788
|
__name$4(isCI, "isCI");
|
|
51583
51789
|
var arrayFormatter = new Intl.ListFormat("en-US", {
|
|
@@ -51876,9 +52082,7 @@ function maybeThrowFriendlyError(error$3) {
|
|
|
51876
52082
|
}
|
|
51877
52083
|
__name$4(maybeThrowFriendlyError, "maybeThrowFriendlyError");
|
|
51878
52084
|
function logHeaders(headers, logger$2) {
|
|
51879
|
-
|
|
51880
|
-
clone$2.delete("Authorization");
|
|
51881
|
-
logger$2.debugWithSanitization?.("HEADERS:", JSON.stringify(Object.fromEntries(clone$2), null, 2));
|
|
52085
|
+
logger$2.debugWithSanitization?.("HEADERS:", JSON.stringify(sanitizeHeaders(headers), null, 2));
|
|
51882
52086
|
}
|
|
51883
52087
|
__name$4(logHeaders, "logHeaders");
|
|
51884
52088
|
async function performApiFetchBase(complianceConfig, resource, init = {}, userAgent, logger$2, queryParams, abortSignal, credentials) {
|
|
@@ -51889,12 +52093,16 @@ async function performApiFetchBase(complianceConfig, resource, init = {}, userAg
|
|
|
51889
52093
|
addAuthorizationHeader(headers, credentials);
|
|
51890
52094
|
headers.set("User-Agent", userAgent);
|
|
51891
52095
|
maybeAddTraceHeader(headers);
|
|
52096
|
+
addCustomApiHeaders(headers);
|
|
51892
52097
|
const queryString = queryParams ? `?${queryParams.toString()}` : "";
|
|
51893
52098
|
logger$2.debug(`-- START CF API REQUEST: ${method} ${getCloudflareApiBaseUrl(complianceConfig)}${resource}`);
|
|
51894
52099
|
logger$2.debugWithSanitization?.("QUERY STRING:", queryString);
|
|
51895
52100
|
logHeaders(headers, logger$2);
|
|
51896
|
-
logger$2.debugWithSanitization?.("INIT:", JSON.stringify({
|
|
51897
|
-
|
|
52101
|
+
logger$2.debugWithSanitization?.("INIT:", JSON.stringify({
|
|
52102
|
+
...init,
|
|
52103
|
+
headers: sanitizeHeaders(new import_undici$3.Headers(init.headers))
|
|
52104
|
+
}, null, 2));
|
|
52105
|
+
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);
|
|
51898
52106
|
logger$2.debug("-- END CF API REQUEST");
|
|
51899
52107
|
return await (0, import_undici$3.fetch)(`${getCloudflareApiBaseUrl(complianceConfig)}${resource}${queryString}`, {
|
|
51900
52108
|
method,
|
|
@@ -51947,9 +52155,9 @@ async function fetchInternalBase(complianceConfig, resource, init = {}, userAgen
|
|
|
51947
52155
|
}
|
|
51948
52156
|
__name$4(fetchInternalBase, "fetchInternalBase");
|
|
51949
52157
|
async function fetchResultBase(complianceConfig, resource, init = {}, userAgent, logger$2, queryParams, abortSignal, credentials) {
|
|
51950
|
-
const { response: json$1, status: status$
|
|
52158
|
+
const { response: json$1, status: status$2, retryAfterMs } = await fetchInternalBase(complianceConfig, resource, init, userAgent, logger$2, queryParams, abortSignal, credentials);
|
|
51951
52159
|
if (json$1.success) return json$1.result;
|
|
51952
|
-
else throwFetchError(resource, json$1, status$
|
|
52160
|
+
else throwFetchError(resource, json$1, status$2, retryAfterMs);
|
|
51953
52161
|
}
|
|
51954
52162
|
__name$4(fetchResultBase, "fetchResultBase");
|
|
51955
52163
|
async function fetchListResultBase(complianceConfig, resource, init = {}, userAgent, logger$2, queryParams, credentials) {
|
|
@@ -51961,12 +52169,12 @@ async function fetchListResultBase(complianceConfig, resource, init = {}, userAg
|
|
|
51961
52169
|
queryParams = new URLSearchParams$1(queryParams);
|
|
51962
52170
|
queryParams.set("cursor", cursor$1);
|
|
51963
52171
|
}
|
|
51964
|
-
const { response: json$1, status: status$
|
|
52172
|
+
const { response: json$1, status: status$2, retryAfterMs } = await fetchInternalBase(complianceConfig, resource, init, userAgent, logger$2, queryParams, void 0, credentials);
|
|
51965
52173
|
if (json$1.success) {
|
|
51966
52174
|
results.push(...json$1.result);
|
|
51967
52175
|
if (hasCursor(json$1.result_info)) cursor$1 = json$1.result_info?.cursor;
|
|
51968
52176
|
else getMoreResults = false;
|
|
51969
|
-
} else throwFetchError(resource, json$1, status$
|
|
52177
|
+
} else throwFetchError(resource, json$1, status$2, retryAfterMs);
|
|
51970
52178
|
}
|
|
51971
52179
|
return results;
|
|
51972
52180
|
}
|
|
@@ -52053,7 +52261,7 @@ function escapeCharacter(character) {
|
|
|
52053
52261
|
}).join("");
|
|
52054
52262
|
}
|
|
52055
52263
|
__name$4(escapeCharacter, "escapeCharacter");
|
|
52056
|
-
function throwFetchError(resource, response, status$
|
|
52264
|
+
function throwFetchError(resource, response, status$2, retryAfterMs) {
|
|
52057
52265
|
const errors$1 = response.errors ?? [];
|
|
52058
52266
|
for (const error2$1 of errors$1) maybeThrowFriendlyError(error2$1);
|
|
52059
52267
|
const notes = [...errors$1.map((err) => ({ text: renderError(err) })), ...response.messages?.map((msg) => ({ text: typeof msg === "string" ? msg : msg.message ?? String(msg) })) ?? []];
|
|
@@ -52066,7 +52274,7 @@ function throwFetchError(resource, response, status$1, retryAfterMs) {
|
|
|
52066
52274
|
const error$3 = new APIError({
|
|
52067
52275
|
text: `A request to the Cloudflare API (${resource}) failed.`,
|
|
52068
52276
|
notes,
|
|
52069
|
-
status: status$
|
|
52277
|
+
status: status$2,
|
|
52070
52278
|
retryAfterMs,
|
|
52071
52279
|
telemetryMessage: false
|
|
52072
52280
|
});
|
|
@@ -52078,7 +52286,7 @@ function throwFetchError(resource, response, status$1, retryAfterMs) {
|
|
|
52078
52286
|
throw error$3;
|
|
52079
52287
|
}
|
|
52080
52288
|
__name$4(throwFetchError, "throwFetchError");
|
|
52081
|
-
function throwWAFBlockError(headers, method, resource, status$
|
|
52289
|
+
function throwWAFBlockError(headers, method, resource, status$2, statusText, retryAfterMs) {
|
|
52082
52290
|
const rayId = extractWAFBlockRayId(headers);
|
|
52083
52291
|
throw new APIError({
|
|
52084
52292
|
text: "The Cloudflare API responded with a WAF block page instead of the expected JSON response",
|
|
@@ -52086,9 +52294,9 @@ function throwWAFBlockError(headers, method, resource, status$1, statusText, ret
|
|
|
52086
52294
|
{ text: "Cloudflare's firewall (WAF) blocked this API request. This is usually a false positive." },
|
|
52087
52295
|
...rayId ? [{ text: `Cloudflare Ray ID: ${rayId}` }] : [],
|
|
52088
52296
|
{ text: rayId ? "If the issue persists, please open a Cloudflare Support ticket and include the Ray ID above." : "If the issue persists, please open a Cloudflare Support ticket. You can find the Cloudflare Ray ID on the block page in your browser." },
|
|
52089
|
-
{ text: `${method} ${resource} -> ${status$
|
|
52297
|
+
{ text: `${method} ${resource} -> ${status$2} ${statusText}` }
|
|
52090
52298
|
],
|
|
52091
|
-
status: status$
|
|
52299
|
+
status: status$2,
|
|
52092
52300
|
retryAfterMs,
|
|
52093
52301
|
telemetryMessage: false
|
|
52094
52302
|
});
|
|
@@ -52099,6 +52307,7 @@ async function fetchKVGetValueBase(complianceConfig, accountId, namespaceId, key
|
|
|
52099
52307
|
addAuthorizationHeader(headers, credentials);
|
|
52100
52308
|
headers.set("User-Agent", userAgent);
|
|
52101
52309
|
maybeAddTraceHeader(headers);
|
|
52310
|
+
addCustomApiHeaders(headers);
|
|
52102
52311
|
const resource = `${getCloudflareApiBaseUrl(complianceConfig)}/accounts/${accountId}/storage/kv/namespaces/${namespaceId}/values/${key}`;
|
|
52103
52312
|
logger$2.debug(`-- START CF API REQUEST: GET ${resource}`);
|
|
52104
52313
|
logger$2.debug("-- END CF API REQUEST");
|
|
@@ -52875,7 +53084,7 @@ function compareVersions(a, b) {
|
|
|
52875
53084
|
__name$4(compareVersions, "compareVersions");
|
|
52876
53085
|
async function openInBrowser(url$2, logger$2) {
|
|
52877
53086
|
try {
|
|
52878
|
-
const { default: open$3 } = await import("./open-PCXX3ZDZ-
|
|
53087
|
+
const { default: open$3 } = await import("./open-PCXX3ZDZ-D_I6kTEq.mjs");
|
|
52879
53088
|
(await open$3(url$2)).on("error", (err) => {
|
|
52880
53089
|
handleBrowserOpenError(url$2, err, logger$2);
|
|
52881
53090
|
});
|
|
@@ -57247,6 +57456,18 @@ function createHeadersForIncomingMessage(req) {
|
|
|
57247
57456
|
}
|
|
57248
57457
|
return headers;
|
|
57249
57458
|
}
|
|
57459
|
+
/**
|
|
57460
|
+
* Constructs a URL from an origin-form request target on the selected origin.
|
|
57461
|
+
*
|
|
57462
|
+
* @param target The incoming path and query, including its leading slash
|
|
57463
|
+
* @param origin The origin selected from the connection and request headers
|
|
57464
|
+
* @returns A URL whose origin cannot be overridden by the request target
|
|
57465
|
+
* @throws {TypeError} If the target is not in origin form
|
|
57466
|
+
*/
|
|
57467
|
+
function resolveRequestTarget(target$1, origin) {
|
|
57468
|
+
if (!target$1.startsWith("/")) throw new TypeError("Expected an origin-form request target");
|
|
57469
|
+
return new URL(`${new URL(origin).origin}${target$1}`);
|
|
57470
|
+
}
|
|
57250
57471
|
function createRequestForIncomingMessage(req, res, options) {
|
|
57251
57472
|
const controller = new AbortController();
|
|
57252
57473
|
res.on("close", () => {
|
|
@@ -57257,7 +57478,7 @@ function createRequestForIncomingMessage(req, res, options) {
|
|
|
57257
57478
|
const protocol = options?.protocol ?? getScheme(req) ?? ("encrypted" in req.socket && req.socket.encrypted ? "https:" : "http:");
|
|
57258
57479
|
const host = options?.host ?? getAuthority(req) ?? headers.get("Host") ?? "localhost";
|
|
57259
57480
|
if (headers.get("Host") !== host) headers.set("Host", host);
|
|
57260
|
-
const url$2 =
|
|
57481
|
+
const url$2 = resolveRequestTarget(req.url ?? "/", `${protocol}//${host}`);
|
|
57261
57482
|
const init = {
|
|
57262
57483
|
method,
|
|
57263
57484
|
headers,
|
|
@@ -57483,11 +57704,13 @@ var PluginContext = class {
|
|
|
57483
57704
|
/**
|
|
57484
57705
|
* Disposes the Miniflare instance and clears the export types it was configured with.
|
|
57485
57706
|
* A server created later in the same process starts again from its own config.
|
|
57707
|
+
* Clear the shared instance first so overlapping restarts dispose it only once.
|
|
57486
57708
|
*/
|
|
57487
57709
|
async disposeMiniflare() {
|
|
57488
|
-
|
|
57710
|
+
const miniflare = this.#sharedContext.miniflare;
|
|
57489
57711
|
this.#sharedContext.miniflare = void 0;
|
|
57490
57712
|
this.#sharedContext.workerNameToExportTypesMap = void 0;
|
|
57713
|
+
await miniflare?.dispose();
|
|
57491
57714
|
}
|
|
57492
57715
|
get miniflare() {
|
|
57493
57716
|
assert(this.#sharedContext.miniflare, "Expected `miniflare` to be defined");
|
|
@@ -63156,8 +63379,8 @@ function isErrorStackTraceLimitWritable() {
|
|
|
63156
63379
|
* @returns {T}
|
|
63157
63380
|
*/
|
|
63158
63381
|
function hideStackFrames(wrappedFunction) {
|
|
63159
|
-
const hidden$
|
|
63160
|
-
Object.defineProperty(wrappedFunction, "name", { value: hidden$
|
|
63382
|
+
const hidden$2 = nodeInternalPrefix + wrappedFunction.name;
|
|
63383
|
+
Object.defineProperty(wrappedFunction, "name", { value: hidden$2 });
|
|
63161
63384
|
return wrappedFunction;
|
|
63162
63385
|
}
|
|
63163
63386
|
const captureLargerStackTrace = hideStackFrames(
|
|
@@ -63377,8 +63600,8 @@ function getFileProtocolModuleFormat(url$2, _context, ignoreErrors) {
|
|
|
63377
63600
|
if (packageType === "none" || packageType === "commonjs") return "commonjs";
|
|
63378
63601
|
return "module";
|
|
63379
63602
|
}
|
|
63380
|
-
const format$
|
|
63381
|
-
if (format$
|
|
63603
|
+
const format$4 = extensionFormatMap[value];
|
|
63604
|
+
if (format$4) return format$4;
|
|
63382
63605
|
if (ignoreErrors) return;
|
|
63383
63606
|
throw new ERR_UNKNOWN_FILE_EXTENSION(value, fileURLToPath(url$2));
|
|
63384
63607
|
}
|
|
@@ -66687,8 +66910,8 @@ function parseRedirects(input$1, { htmlHandling = void 0, maxStaticRules = MAX_S
|
|
|
66687
66910
|
continue;
|
|
66688
66911
|
}
|
|
66689
66912
|
const to = toResult[0];
|
|
66690
|
-
const status$
|
|
66691
|
-
if (isNaN(status$
|
|
66913
|
+
const status$2 = Number(str_status);
|
|
66914
|
+
if (isNaN(status$2) || !PERMITTED_STATUS_CODES.has(status$2)) {
|
|
66692
66915
|
invalid.push({
|
|
66693
66916
|
line,
|
|
66694
66917
|
lineNumber: i$1 + 1,
|
|
@@ -66716,7 +66939,7 @@ function parseRedirects(input$1, { htmlHandling = void 0, maxStaticRules = MAX_S
|
|
|
66716
66939
|
continue;
|
|
66717
66940
|
}
|
|
66718
66941
|
seen_paths.add(from);
|
|
66719
|
-
if (status$
|
|
66942
|
+
if (status$2 === 200) {
|
|
66720
66943
|
if (urlHasHost(to)) {
|
|
66721
66944
|
invalid.push({
|
|
66722
66945
|
line,
|
|
@@ -66729,7 +66952,7 @@ function parseRedirects(input$1, { htmlHandling = void 0, maxStaticRules = MAX_S
|
|
|
66729
66952
|
rules.push({
|
|
66730
66953
|
from,
|
|
66731
66954
|
to,
|
|
66732
|
-
status: status$
|
|
66955
|
+
status: status$2,
|
|
66733
66956
|
lineNumber: i$1 + 1
|
|
66734
66957
|
});
|
|
66735
66958
|
}
|
|
@@ -72588,9 +72811,9 @@ const addPattern = (agg, pattern) => {
|
|
|
72588
72811
|
const intersectMime = (agg, mime) => {
|
|
72589
72812
|
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
72590
72813
|
};
|
|
72591
|
-
const setFormat = (agg, format$
|
|
72592
|
-
agg.format = format$
|
|
72593
|
-
if (format$
|
|
72814
|
+
const setFormat = (agg, format$4) => {
|
|
72815
|
+
agg.format = format$4;
|
|
72816
|
+
if (format$4.includes("int")) agg.isInt = true;
|
|
72594
72817
|
};
|
|
72595
72818
|
const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
|
|
72596
72819
|
const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
@@ -72651,13 +72874,13 @@ const exactPattern = (p$2) => exactPatterns.get(p$2) ?? p$2;
|
|
|
72651
72874
|
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
72652
72875
|
const json$1 = _json;
|
|
72653
72876
|
json$1.type = "string";
|
|
72654
|
-
const { minimum, maximum, format: format$
|
|
72877
|
+
const { minimum, maximum, format: format$4, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
72655
72878
|
if (typeof minimum === "number") json$1.minLength = minimum;
|
|
72656
72879
|
if (typeof maximum === "number") json$1.maxLength = maximum;
|
|
72657
|
-
if (format$
|
|
72658
|
-
json$1.format = formatMap[format$
|
|
72880
|
+
if (format$4) {
|
|
72881
|
+
json$1.format = formatMap[format$4] ?? format$4;
|
|
72659
72882
|
if (json$1.format === "") delete json$1.format;
|
|
72660
|
-
if (format$
|
|
72883
|
+
if (format$4 === "time" || laxFormat) delete json$1.format;
|
|
72661
72884
|
}
|
|
72662
72885
|
if (contentEncoding) json$1.contentEncoding = contentEncoding;
|
|
72663
72886
|
if (patterns && patterns.size > 0) {
|
|
@@ -72867,7 +73090,7 @@ function stringifyKeyNames(bySchema, json$1, visited) {
|
|
|
72867
73090
|
const numericType = !types$4.includes("string") && types$4.some((t$5) => t$5 === "number" || t$5 === "integer");
|
|
72868
73091
|
const values = json$1.enum ?? (json$1.const !== void 0 ? [json$1.const] : void 0);
|
|
72869
73092
|
if (!numericType && !values?.some((v) => typeof v === "number")) return json$1;
|
|
72870
|
-
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format: format$
|
|
73093
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format: format$4, id,...rest } = json$1;
|
|
72871
73094
|
if (rest.enum) rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
72872
73095
|
else if (typeof rest.const === "number") rest.const = String(rest.const);
|
|
72873
73096
|
if (!numericType) return rest;
|
|
@@ -74103,50 +74326,68 @@ function getHeadersConfigPath(config$2) {
|
|
|
74103
74326
|
//#region src/build.ts
|
|
74104
74327
|
var import_picocolors$4 = /* @__PURE__ */ __toESM$2(require_picocolors(), 1);
|
|
74105
74328
|
const CLIENT_FALLBACK_ENTRY_NAME = "__cloudflare_fallback_entry__";
|
|
74106
|
-
|
|
74107
|
-
|
|
74108
|
-
|
|
74109
|
-
|
|
74110
|
-
|
|
74111
|
-
|
|
74112
|
-
|
|
74113
|
-
|
|
74114
|
-
|
|
74115
|
-
|
|
74116
|
-
|
|
74117
|
-
|
|
74118
|
-
|
|
74119
|
-
|
|
74120
|
-
|
|
74121
|
-
|
|
74329
|
+
/** Build the remaining Worker and client environments and transfer imported assets. */
|
|
74330
|
+
async function buildApp(builder, resolvedPluginConfig, environmentNameToImportedAssetPaths) {
|
|
74331
|
+
const clientEnvironment = builder.environments.client;
|
|
74332
|
+
assert(clientEnvironment, `No "client" environment`);
|
|
74333
|
+
const defaultHtmlPath = path.resolve(builder.config.root, "index.html");
|
|
74334
|
+
const hasClientEntry = clientEnvironment.config.build.rollupOptions.input || fs.existsSync(defaultHtmlPath);
|
|
74335
|
+
const workerEnvironments = [...resolvedPluginConfig.environmentNameToWorkerMap.entries()].filter(([_, worker]) => !resolveDevOnly(worker.devOnly)).map(([environmentName]) => {
|
|
74336
|
+
const environment = builder.environments[environmentName];
|
|
74337
|
+
assert(environment, `"${environmentName}" environment not found`);
|
|
74338
|
+
return environment;
|
|
74339
|
+
});
|
|
74340
|
+
await Promise.all(workerEnvironments.filter((environment) => !environment.isBuilt).map((environment) => builder.build(environment)));
|
|
74341
|
+
const assetEnvironments = workerEnvironments.filter((environment) => environment.name === resolvedPluginConfig.prerenderWorkerEnvironmentName || resolvedPluginConfig.type === "workers" && environment.name === resolvedPluginConfig.entryWorkerEnvironmentName).flatMap((environment) => {
|
|
74342
|
+
return [environment, ...(resolvedPluginConfig.environmentNameToChildEnvironmentNamesMap.get(environment.name) ?? []).map((name) => {
|
|
74343
|
+
const childEnvironment = builder.environments[name];
|
|
74344
|
+
assert(childEnvironment, `"${name}" environment not found`);
|
|
74345
|
+
return childEnvironment;
|
|
74346
|
+
}).filter((childEnvironment) => childEnvironment.isBuilt)].map((assetEnvironment) => ({
|
|
74347
|
+
environment: assetEnvironment,
|
|
74348
|
+
preserveOriginalAssets: environment.name === resolvedPluginConfig.prerenderWorkerEnvironmentName
|
|
74349
|
+
}));
|
|
74350
|
+
});
|
|
74351
|
+
let isClientBuilt = clientEnvironment.isBuilt;
|
|
74352
|
+
if (!isClientBuilt) {
|
|
74353
|
+
if (hasClientEntry) {
|
|
74354
|
+
await builder.build(clientEnvironment);
|
|
74355
|
+
isClientBuilt = true;
|
|
74356
|
+
} else if (assetEnvironments.some(({ environment }) => environmentNameToImportedAssetPaths.get(environment.name)?.size) || getHasPublicAssets(builder.config) || resolvedPluginConfig.prerenderWorkerEnvironmentName) {
|
|
74357
|
+
await fallbackBuild(builder, clientEnvironment);
|
|
74358
|
+
isClientBuilt = true;
|
|
74122
74359
|
}
|
|
74123
|
-
|
|
74124
|
-
|
|
74125
|
-
|
|
74126
|
-
|
|
74127
|
-
|
|
74128
|
-
|
|
74129
|
-
else if (importedAssetPaths.size || getHasPublicAssets(builder.config) || resolvedPluginConfig.prerenderWorkerEnvironmentName) await fallbackBuild(builder, clientEnvironment);
|
|
74130
|
-
else {
|
|
74131
|
-
if (!satisfiesMinimumViteVersion("7.0.0")) removeAssetsField(entryWorkerBuildDirectory);
|
|
74132
|
-
return;
|
|
74360
|
+
}
|
|
74361
|
+
if (!isClientBuilt) {
|
|
74362
|
+
if (resolvedPluginConfig.type === "workers" && workerEnvironments.some((environment) => environment.name === resolvedPluginConfig.entryWorkerEnvironmentName)) {
|
|
74363
|
+
const entry = builder.environments[resolvedPluginConfig.entryWorkerEnvironmentName];
|
|
74364
|
+
assert(entry);
|
|
74365
|
+
removeAssetsField(path.resolve(builder.config.root, entry.config.build.outDir));
|
|
74133
74366
|
}
|
|
74134
|
-
|
|
74135
|
-
|
|
74367
|
+
return;
|
|
74368
|
+
}
|
|
74369
|
+
const clientBuildDirectory = path.resolve(builder.config.root, clientEnvironment.config.build.outDir);
|
|
74370
|
+
for (const { environment, preserveOriginalAssets } of assetEnvironments) {
|
|
74371
|
+
const importedAssetPaths = environmentNameToImportedAssetPaths.get(environment.name);
|
|
74372
|
+
if (!importedAssetPaths?.size) continue;
|
|
74373
|
+
const workerBuildDirectory = path.resolve(builder.config.root, environment.config.build.outDir);
|
|
74374
|
+
const transferredAssetPaths = [];
|
|
74136
74375
|
for (const assetPath of importedAssetPaths) {
|
|
74137
|
-
const src$2 = path.join(
|
|
74376
|
+
const src$2 = path.join(workerBuildDirectory, assetPath);
|
|
74138
74377
|
const dest = path.join(clientBuildDirectory, assetPath);
|
|
74139
74378
|
if (!fs.existsSync(src$2)) continue;
|
|
74140
|
-
if (fs.existsSync(dest))
|
|
74141
|
-
|
|
74379
|
+
if (fs.existsSync(dest)) {
|
|
74380
|
+
if (!preserveOriginalAssets) fs.unlinkSync(src$2);
|
|
74381
|
+
} else {
|
|
74142
74382
|
const destDir = path.dirname(dest);
|
|
74143
74383
|
fs.mkdirSync(destDir, { recursive: true });
|
|
74144
|
-
fs.
|
|
74145
|
-
|
|
74384
|
+
if (preserveOriginalAssets) fs.copyFileSync(src$2, dest);
|
|
74385
|
+
else fs.renameSync(src$2, dest);
|
|
74386
|
+
transferredAssetPaths.push(dest);
|
|
74146
74387
|
}
|
|
74147
74388
|
}
|
|
74148
|
-
if (
|
|
74149
|
-
}
|
|
74389
|
+
if (transferredAssetPaths.length) builder.config.logger.info([`${import_picocolors$4.default.green("✓")} ${transferredAssetPaths.length} asset${transferredAssetPaths.length > 1 ? "s" : ""} ${preserveOriginalAssets ? "copied" : "moved"} from "${environment.name}" to "client" build output.`, ...transferredAssetPaths.map((assetPath) => import_picocolors$4.default.dim(path.relative(builder.config.root, assetPath)))].join("\n"));
|
|
74390
|
+
}
|
|
74150
74391
|
}
|
|
74151
74392
|
function getHasPublicAssets({ publicDir }) {
|
|
74152
74393
|
let hasPublicAssets = false;
|
|
@@ -74165,14 +74406,6 @@ async function fallbackBuild(builder, environment) {
|
|
|
74165
74406
|
const fallbackEntryPath = path.resolve(builder.config.root, environment.config.build.outDir, CLIENT_FALLBACK_ENTRY_NAME);
|
|
74166
74407
|
fs.unlinkSync(fallbackEntryPath);
|
|
74167
74408
|
}
|
|
74168
|
-
function loadViteManifest(directory) {
|
|
74169
|
-
const contents = fs.readFileSync(path.resolve(directory, ".vite", "manifest.json"), "utf-8");
|
|
74170
|
-
return JSON.parse(contents);
|
|
74171
|
-
}
|
|
74172
|
-
function getImportedAssetPaths(viteManifest) {
|
|
74173
|
-
const assetPaths = Object.values(viteManifest).flatMap((chunk) => chunk.assets ?? []);
|
|
74174
|
-
return new Set(assetPaths);
|
|
74175
|
-
}
|
|
74176
74409
|
/**
|
|
74177
74410
|
* Used to remove the `assets` field from the entry Worker config if there are no assets
|
|
74178
74411
|
*/
|
|
@@ -74263,8 +74496,8 @@ var CloudflareDevEnvironment = class extends vite.DevEnvironment {
|
|
|
74263
74496
|
await this.depsOptimizer?.init();
|
|
74264
74497
|
const response = await miniflare.dispatchFetch(new URL(GET_EXPORT_TYPES_PATH, UNKNOWN_HOST), { headers: { [CoreHeaders.ROUTE_OVERRIDE]: workerConfig.name } });
|
|
74265
74498
|
if (!response.ok) {
|
|
74266
|
-
const status$
|
|
74267
|
-
throw new Error(`Failed to fetch export types for Worker "${workerConfig.name}" (${status$
|
|
74499
|
+
const status$2 = [response.status, response.statusText].filter(Boolean).join(" ");
|
|
74500
|
+
throw new Error(`Failed to fetch export types for Worker "${workerConfig.name}" (${status$2}): ${await response.text()}`);
|
|
74268
74501
|
}
|
|
74269
74502
|
return await response.json();
|
|
74270
74503
|
}
|
|
@@ -74322,7 +74555,7 @@ function getWorkerSourcemap(userConfig, environmentName, workerConfig) {
|
|
|
74322
74555
|
function getWorkerCssTarget(userConfig, environmentName) {
|
|
74323
74556
|
return (userConfig.environments?.[environmentName]?.build?.cssTarget ?? userConfig.build?.cssTarget) === void 0 ? defaultCssTarget : void 0;
|
|
74324
74557
|
}
|
|
74325
|
-
function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, environmentName,
|
|
74558
|
+
function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, environmentName, isParentEnvironment, hasNodeJsCompat: hasNodeJsCompat$1 }) {
|
|
74326
74559
|
const rollupOptions = isParentEnvironment ? {
|
|
74327
74560
|
input: { [MAIN_ENTRY_NAME]: VIRTUAL_WORKER_ENTRY },
|
|
74328
74561
|
preserveEntrySignatures: "strict"
|
|
@@ -74346,7 +74579,6 @@ function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, en
|
|
|
74346
74579
|
target,
|
|
74347
74580
|
cssTarget: getWorkerCssTarget(userConfig, environmentName),
|
|
74348
74581
|
emitAssets: true,
|
|
74349
|
-
manifest: isEntryWorker,
|
|
74350
74582
|
outDir: getOutputDirectory(userConfig, environmentName),
|
|
74351
74583
|
sourcemap: getWorkerSourcemap(userConfig, environmentName, workerConfig),
|
|
74352
74584
|
copyPublicDir: false,
|
|
@@ -74574,6 +74806,7 @@ function getServerWatchConfig(userWatch) {
|
|
|
74574
74806
|
* Plugin to handle configuration and config file watching
|
|
74575
74807
|
*/
|
|
74576
74808
|
const configPlugin = createPlugin("config", (ctx) => {
|
|
74809
|
+
const environmentNameToImportedAssetPaths = /* @__PURE__ */ new Map();
|
|
74577
74810
|
return {
|
|
74578
74811
|
config(userConfig, env$3) {
|
|
74579
74812
|
if (ctx.resolvedPluginConfig.type === "preview") return { appType: "custom" };
|
|
@@ -74601,7 +74834,10 @@ const configPlugin = createPlugin("config", (ctx) => {
|
|
|
74601
74834
|
], ...Array.from(ctx.resolvedPluginConfig.configPaths, (configPath) => normalizePath(configPath))] }
|
|
74602
74835
|
},
|
|
74603
74836
|
environments: getEnvironmentsConfig(ctx, userConfig, env$3.mode),
|
|
74604
|
-
builder: { buildApp: userConfig.builder?.buildApp ??
|
|
74837
|
+
builder: { buildApp: userConfig.builder?.buildApp ?? ((builder) => {
|
|
74838
|
+
assertIsNotPreview(ctx);
|
|
74839
|
+
return buildApp(builder, ctx.resolvedPluginConfig, environmentNameToImportedAssetPaths);
|
|
74840
|
+
}) }
|
|
74605
74841
|
};
|
|
74606
74842
|
},
|
|
74607
74843
|
configResolved(resolvedViteConfig) {
|
|
@@ -74632,9 +74868,17 @@ const configPlugin = createPlugin("config", (ctx) => {
|
|
|
74632
74868
|
};
|
|
74633
74869
|
viteDevServer.watcher.on("change", configChangedHandler);
|
|
74634
74870
|
},
|
|
74871
|
+
writeBundle(_options, bundle) {
|
|
74872
|
+
if (!ctx.getWorkerConfig(this.environment.name)) return;
|
|
74873
|
+
const importedAssetPaths = /* @__PURE__ */ new Set();
|
|
74874
|
+
for (const output$1 of Object.values(bundle)) for (const assetPath of output$1.viteMetadata?.importedAssets ?? []) importedAssetPaths.add(assetPath);
|
|
74875
|
+
environmentNameToImportedAssetPaths.set(this.environment.name, importedAssetPaths);
|
|
74876
|
+
},
|
|
74635
74877
|
buildApp: {
|
|
74636
74878
|
order: "post",
|
|
74637
74879
|
async handler(builder) {
|
|
74880
|
+
if (ctx.resolvedPluginConfig.type === "preview") return;
|
|
74881
|
+
await buildApp(builder, ctx.resolvedPluginConfig, environmentNameToImportedAssetPaths);
|
|
74638
74882
|
if (ctx.resolvedPluginConfig.type !== "workers") return;
|
|
74639
74883
|
const workerEnvironments = [...ctx.resolvedPluginConfig.environmentNameToWorkerMap.entries()].filter(([_, worker]) => !resolveDevOnly(worker.devOnly)).map(([environmentName]) => {
|
|
74640
74884
|
const environment = builder.environments[environmentName];
|
|
@@ -74839,7 +75083,7 @@ const generateStaticRoutingRuleMatcher = (rules) => ({ request: request$2 }) =>
|
|
|
74839
75083
|
};
|
|
74840
75084
|
|
|
74841
75085
|
//#endregion
|
|
74842
|
-
//#region ../../node_modules/.pnpm/@cloudflare+build-output-utils@0.9.
|
|
75086
|
+
//#region ../../node_modules/.pnpm/@cloudflare+build-output-utils@0.9.12/node_modules/@cloudflare/build-output-utils/dist/index.mjs
|
|
74843
75087
|
/**
|
|
74844
75088
|
* Initial draft version of the Build Output Specification.
|
|
74845
75089
|
*
|
|
@@ -74951,29 +75195,29 @@ async function writeContainerConfig({ root, config: config$2, directoryName }) {
|
|
|
74951
75195
|
}
|
|
74952
75196
|
|
|
74953
75197
|
//#endregion
|
|
74954
|
-
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.
|
|
74955
|
-
const { white, gray, dim, hidden, bold, cyanBright, bgCyan } = source_default;
|
|
74956
|
-
const brandColor = source_default.hex("#BD5B08");
|
|
74957
|
-
const black = source_default.hex("#111");
|
|
74958
|
-
const blue = source_default.hex("#0E838F");
|
|
74959
|
-
const bgBlue = black.bgHex("#0E838F");
|
|
74960
|
-
const red = source_default.hex("#AB2526");
|
|
74961
|
-
const bgRed = black.bgHex("#AB2526");
|
|
74962
|
-
const green = source_default.hex("#218529");
|
|
74963
|
-
const bgGreen = black.bgHex("#218529");
|
|
74964
|
-
const yellow = source_default.hex("#7F7322");
|
|
74965
|
-
const bgYellow = black.bgHex("#7F7322");
|
|
75198
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.6_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_8ad19c2891441732cf973a4bd95ecdfb/node_modules/@cloudflare/cli-shared-helpers/dist/colors.mjs
|
|
75199
|
+
const { white: white$1, gray: gray$1, dim: dim$1, hidden: hidden$1, bold: bold$1, cyanBright: cyanBright$1, bgCyan: bgCyan$1 } = source_default;
|
|
75200
|
+
const brandColor$1 = source_default.hex("#BD5B08");
|
|
75201
|
+
const black$1 = source_default.hex("#111");
|
|
75202
|
+
const blue$1 = source_default.hex("#0E838F");
|
|
75203
|
+
const bgBlue$1 = black$1.bgHex("#0E838F");
|
|
75204
|
+
const red$1 = source_default.hex("#AB2526");
|
|
75205
|
+
const bgRed$1 = black$1.bgHex("#AB2526");
|
|
75206
|
+
const green$1 = source_default.hex("#218529");
|
|
75207
|
+
const bgGreen$1 = black$1.bgHex("#218529");
|
|
75208
|
+
const yellow$1 = source_default.hex("#7F7322");
|
|
75209
|
+
const bgYellow$1 = black$1.bgHex("#7F7322");
|
|
74966
75210
|
|
|
74967
75211
|
//#endregion
|
|
74968
|
-
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.
|
|
75212
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.6_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_8ad19c2891441732cf973a4bd95ecdfb/node_modules/@cloudflare/cli-shared-helpers/dist/streams.mjs
|
|
74969
75213
|
/**
|
|
74970
75214
|
* This file simply re-exports the process's writeable streams
|
|
74971
75215
|
* The intention is to provide a boundary to mock in tests
|
|
74972
75216
|
* Anywhere in this package that writes to stdout/stderr,
|
|
74973
75217
|
* should use this module to get references to them.
|
|
74974
75218
|
*/
|
|
74975
|
-
const stdout$
|
|
74976
|
-
const stderr = process.stderr;
|
|
75219
|
+
const stdout$2 = process.stdout;
|
|
75220
|
+
const stderr$1 = process.stderr;
|
|
74977
75221
|
|
|
74978
75222
|
//#endregion
|
|
74979
75223
|
//#region ../../node_modules/.pnpm/ci-info@4.4.0/node_modules/ci-info/vendors.json
|
|
@@ -75353,11 +75597,11 @@ var require_ci_info = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pnpm/c
|
|
|
75353
75597
|
}) });
|
|
75354
75598
|
|
|
75355
75599
|
//#endregion
|
|
75356
|
-
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.
|
|
75357
|
-
var import_ci_info = /* @__PURE__ */ __toESM$2(require_ci_info(), 1);
|
|
75600
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.6_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_8ad19c2891441732cf973a4bd95ecdfb/node_modules/@cloudflare/cli-shared-helpers/dist/check-macos-version.mjs
|
|
75601
|
+
var import_ci_info$1 = /* @__PURE__ */ __toESM$2(require_ci_info(), 1);
|
|
75358
75602
|
|
|
75359
75603
|
//#endregion
|
|
75360
|
-
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.
|
|
75604
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.6_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_8ad19c2891441732cf973a4bd95ecdfb/node_modules/@cloudflare/cli-shared-helpers/dist/cursor.mjs
|
|
75361
75605
|
function showCursor(show, stream$2 = process5.stderr) {
|
|
75362
75606
|
if (!stream$2.isTTY) return;
|
|
75363
75607
|
if (show) stream$2.write("\x1B[?25h");
|
|
@@ -75365,8 +75609,8 @@ function showCursor(show, stream$2 = process5.stderr) {
|
|
|
75365
75609
|
}
|
|
75366
75610
|
|
|
75367
75611
|
//#endregion
|
|
75368
|
-
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.
|
|
75369
|
-
const shapes = {
|
|
75612
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.6_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_8ad19c2891441732cf973a4bd95ecdfb/node_modules/@cloudflare/cli-shared-helpers/dist/index.mjs
|
|
75613
|
+
const shapes$1 = {
|
|
75370
75614
|
diamond: "◇",
|
|
75371
75615
|
dash: "─",
|
|
75372
75616
|
radioInactive: "○",
|
|
@@ -75387,17 +75631,17 @@ const shapes = {
|
|
|
75387
75631
|
br: "╯"
|
|
75388
75632
|
}
|
|
75389
75633
|
};
|
|
75390
|
-
const status = {
|
|
75391
|
-
error: bgRed(` ERROR `),
|
|
75392
|
-
warning: bgYellow(` WARNING `),
|
|
75393
|
-
info: bgBlue(` INFO `),
|
|
75394
|
-
success: bgGreen(` SUCCESS `),
|
|
75395
|
-
cancel: white.bgRed(` X `)
|
|
75634
|
+
const status$1 = {
|
|
75635
|
+
error: bgRed$1(` ERROR `),
|
|
75636
|
+
warning: bgYellow$1(` WARNING `),
|
|
75637
|
+
info: bgBlue$1(` INFO `),
|
|
75638
|
+
success: bgGreen$1(` SUCCESS `),
|
|
75639
|
+
cancel: white$1.bgRed(` X `)
|
|
75396
75640
|
};
|
|
75397
|
-
const space = (n$1 = 1) => {
|
|
75398
|
-
return hidden(" ".repeat(n$1));
|
|
75641
|
+
const space$1 = (n$1 = 1) => {
|
|
75642
|
+
return hidden$1(" ".repeat(n$1));
|
|
75399
75643
|
};
|
|
75400
|
-
const LOGGER_LEVELS = {
|
|
75644
|
+
const LOGGER_LEVELS$1 = {
|
|
75401
75645
|
none: -1,
|
|
75402
75646
|
error: 0,
|
|
75403
75647
|
warn: 1,
|
|
@@ -75405,83 +75649,48 @@ const LOGGER_LEVELS = {
|
|
|
75405
75649
|
log: 3,
|
|
75406
75650
|
debug: 4
|
|
75407
75651
|
};
|
|
75408
|
-
let currentLogLevel = "log";
|
|
75409
|
-
function getLogLevel() {
|
|
75410
|
-
return currentLogLevel;
|
|
75652
|
+
let currentLogLevel$1 = "log";
|
|
75653
|
+
function getLogLevel$1() {
|
|
75654
|
+
return currentLogLevel$1;
|
|
75411
75655
|
}
|
|
75412
|
-
const logRaw = (msg) => {
|
|
75413
|
-
if (LOGGER_LEVELS[getLogLevel()] >= LOGGER_LEVELS.log) stdout$
|
|
75656
|
+
const logRaw$1 = (msg) => {
|
|
75657
|
+
if (LOGGER_LEVELS$1[getLogLevel$1()] >= LOGGER_LEVELS$1.log) stdout$2.write(`${msg}\n`);
|
|
75414
75658
|
};
|
|
75415
75659
|
const log$1 = (msg) => {
|
|
75416
|
-
logRaw(msg.split("\n").map((ln) => `${gray(shapes.bar)}${ln.length > 0 ? " " + white(ln) : ""}`).join("\n"));
|
|
75660
|
+
logRaw$1(msg.split("\n").map((ln) => `${gray$1(shapes$1.bar)}${ln.length > 0 ? " " + white$1(ln) : ""}`).join("\n"));
|
|
75417
75661
|
};
|
|
75418
|
-
const newline = () => {
|
|
75662
|
+
const newline$1 = () => {
|
|
75419
75663
|
log$1("");
|
|
75420
75664
|
};
|
|
75421
|
-
const format$
|
|
75422
|
-
const formattedLines = (multiline ? msg.split("\n") : [msg]).map((line, i$1) => (i$1 === 0 ? firstLinePrefix : linePrefix) + space() + formatLine(line));
|
|
75665
|
+
const format$2 = (msg, { linePrefix = gray$1(shapes$1.bar), firstLinePrefix = linePrefix, newlineBefore = false, newlineAfter = false, formatLine = (line) => white$1(line), multiline = true } = {}) => {
|
|
75666
|
+
const formattedLines = (multiline ? msg.split("\n") : [msg]).map((line, i$1) => (i$1 === 0 ? firstLinePrefix : linePrefix) + space$1() + formatLine(line));
|
|
75423
75667
|
if (newlineBefore) formattedLines.unshift(linePrefix);
|
|
75424
75668
|
if (newlineAfter) formattedLines.push(linePrefix);
|
|
75425
75669
|
return formattedLines.join("\n");
|
|
75426
75670
|
};
|
|
75427
75671
|
const updateStatus = (msg, printNewLine = true) => {
|
|
75428
|
-
logRaw(format$
|
|
75429
|
-
firstLinePrefix: gray(shapes.leftT),
|
|
75430
|
-
linePrefix: gray(shapes.bar),
|
|
75672
|
+
logRaw$1(format$2(msg, {
|
|
75673
|
+
firstLinePrefix: gray$1(shapes$1.leftT),
|
|
75674
|
+
linePrefix: gray$1(shapes$1.bar),
|
|
75431
75675
|
newlineAfter: printNewLine
|
|
75432
75676
|
}));
|
|
75433
75677
|
};
|
|
75434
75678
|
const startSection = (heading, subheading, printNewLine = true) => {
|
|
75435
|
-
logRaw(`${gray(shapes.corners.tl)} ${brandColor(heading)} ${subheading ? dim(subheading) : ""}`);
|
|
75436
|
-
if (printNewLine) newline();
|
|
75679
|
+
logRaw$1(`${gray$1(shapes$1.corners.tl)} ${brandColor$1(heading)} ${subheading ? dim$1(subheading) : ""}`);
|
|
75680
|
+
if (printNewLine) newline$1();
|
|
75437
75681
|
};
|
|
75438
75682
|
const endSection = (heading, subheading) => {
|
|
75439
|
-
logRaw(`${gray(shapes.corners.bl)} ${brandColor(heading)} ${subheading ? dim(subheading) : ""}\n`);
|
|
75440
|
-
};
|
|
75441
|
-
const cancel = (msg, { shape = shapes.corners.bl, multiline = false } = {}) => {
|
|
75442
|
-
logRaw(format$1(msg, {
|
|
75443
|
-
firstLinePrefix: `${gray(shape)} ${status.cancel}`,
|
|
75444
|
-
linePrefix: gray(shapes.bar),
|
|
75445
|
-
newlineBefore: true,
|
|
75446
|
-
formatLine: (line) => dim(line),
|
|
75447
|
-
multiline
|
|
75448
|
-
}));
|
|
75683
|
+
logRaw$1(`${gray$1(shapes$1.corners.bl)} ${brandColor$1(heading)} ${subheading ? dim$1(subheading) : ""}\n`);
|
|
75449
75684
|
};
|
|
75450
|
-
const success = (msg, { shape = shapes.corners.bl, multiline = false } = {}) => {
|
|
75451
|
-
logRaw(format$
|
|
75452
|
-
firstLinePrefix: gray(shape) + space() + status.success,
|
|
75453
|
-
linePrefix: gray(shapes.bar),
|
|
75685
|
+
const success = (msg, { shape = shapes$1.corners.bl, multiline = false } = {}) => {
|
|
75686
|
+
logRaw$1(format$2(msg, {
|
|
75687
|
+
firstLinePrefix: gray$1(shape) + space$1() + status$1.success,
|
|
75688
|
+
linePrefix: gray$1(shapes$1.bar),
|
|
75454
75689
|
newlineBefore: true,
|
|
75455
|
-
formatLine: (line) => dim(line),
|
|
75690
|
+
formatLine: (line) => dim$1(line),
|
|
75456
75691
|
multiline
|
|
75457
75692
|
}));
|
|
75458
75693
|
};
|
|
75459
|
-
const stripAnsi = (str) => {
|
|
75460
|
-
const pattern = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
75461
|
-
const regex$1 = RegExp(pattern, "g");
|
|
75462
|
-
return str.replace(linkRegex, "$2").replace(regex$1, "");
|
|
75463
|
-
};
|
|
75464
|
-
const linkRegex = /\u001B\]8;;(?<url>.+)\u001B\\(?<label>.+)\u001B\]8;;\u001B\\/g;
|
|
75465
|
-
const crash = (msg, extra) => {
|
|
75466
|
-
error(msg, extra);
|
|
75467
|
-
exit(1);
|
|
75468
|
-
};
|
|
75469
|
-
const error = (msg, extra, corner = shapes.corners.bl) => {
|
|
75470
|
-
const currentLevel = getLogLevel();
|
|
75471
|
-
if (msg && LOGGER_LEVELS[currentLevel] >= LOGGER_LEVELS.error) stderr.write(`${gray(corner)} ${status.error} ${dim(msg)}\n${extra ? space() + extra + "\n" : ""}`);
|
|
75472
|
-
};
|
|
75473
|
-
|
|
75474
|
-
//#endregion
|
|
75475
|
-
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.3_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_1015a3e98971606dde907233c81fa8ee/node_modules/@cloudflare/cli-shared-helpers/dist/error.mjs
|
|
75476
|
-
/**
|
|
75477
|
-
* Error thrown when an operation is cancelled
|
|
75478
|
-
*/
|
|
75479
|
-
var CancelError$1 = class extends Error {
|
|
75480
|
-
constructor(message, signal) {
|
|
75481
|
-
super(message);
|
|
75482
|
-
this.signal = signal;
|
|
75483
|
-
}
|
|
75484
|
-
};
|
|
75485
75694
|
|
|
75486
75695
|
//#endregion
|
|
75487
75696
|
//#region ../../node_modules/.pnpm/fast-string-truncated-width@1.2.1/node_modules/fast-string-truncated-width/dist/utils.js
|
|
@@ -76206,49 +76415,6 @@ var at = class extends p {
|
|
|
76206
76415
|
}
|
|
76207
76416
|
};
|
|
76208
76417
|
|
|
76209
|
-
//#endregion
|
|
76210
|
-
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.3_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_1015a3e98971606dde907233c81fa8ee/node_modules/@cloudflare/cli-shared-helpers/dist/select-list.mjs
|
|
76211
|
-
var SelectRefreshablePrompt = class extends p {
|
|
76212
|
-
options;
|
|
76213
|
-
cursor = 0;
|
|
76214
|
-
get _value() {
|
|
76215
|
-
return this.options[this.cursor];
|
|
76216
|
-
}
|
|
76217
|
-
changeValue() {
|
|
76218
|
-
this.value = this._value.value;
|
|
76219
|
-
}
|
|
76220
|
-
constructor(opts) {
|
|
76221
|
-
super(opts, false);
|
|
76222
|
-
this.options = opts.options;
|
|
76223
|
-
this.cursor = this.options.findIndex(({ value }) => value === opts.initialValue);
|
|
76224
|
-
if (this.cursor === -1) this.cursor = 0;
|
|
76225
|
-
this.changeValue();
|
|
76226
|
-
this.on("key", (c$1) => {
|
|
76227
|
-
if (c$1 !== "r") return;
|
|
76228
|
-
opts.onRefresh().then((newOptions) => {
|
|
76229
|
-
this.options = [...newOptions];
|
|
76230
|
-
this.cursor = 0;
|
|
76231
|
-
this.changeValue();
|
|
76232
|
-
const that = this;
|
|
76233
|
-
if ("render" in that && typeof that.render === "function") that.render();
|
|
76234
|
-
}).catch(() => {});
|
|
76235
|
-
});
|
|
76236
|
-
this.on("cursor", (key) => {
|
|
76237
|
-
switch (key) {
|
|
76238
|
-
case "left":
|
|
76239
|
-
case "up":
|
|
76240
|
-
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
76241
|
-
break;
|
|
76242
|
-
case "down":
|
|
76243
|
-
case "right":
|
|
76244
|
-
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
76245
|
-
break;
|
|
76246
|
-
}
|
|
76247
|
-
this.changeValue();
|
|
76248
|
-
});
|
|
76249
|
-
}
|
|
76250
|
-
};
|
|
76251
|
-
|
|
76252
76418
|
//#endregion
|
|
76253
76419
|
//#region ../../node_modules/.pnpm/ansi-escapes@5.0.0/node_modules/ansi-escapes/index.js
|
|
76254
76420
|
const ESC = "\x1B[";
|
|
@@ -76568,7 +76734,7 @@ function ansiRegex({ onlyFirst = false } = {}) {
|
|
|
76568
76734
|
//#endregion
|
|
76569
76735
|
//#region ../../node_modules/.pnpm/strip-ansi@7.2.0/node_modules/strip-ansi/index.js
|
|
76570
76736
|
const regex = ansiRegex();
|
|
76571
|
-
function stripAnsi$
|
|
76737
|
+
function stripAnsi$2(string$2) {
|
|
76572
76738
|
if (typeof string$2 !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string$2}\``);
|
|
76573
76739
|
if (!string$2.includes("\x1B") && !string$2.includes("")) return string$2;
|
|
76574
76740
|
return string$2.replace(regex, "");
|
|
@@ -76649,7 +76815,7 @@ function stringWidth(string$2, options = {}) {
|
|
|
76649
76815
|
ambiguousIsNarrow: true,
|
|
76650
76816
|
...options
|
|
76651
76817
|
};
|
|
76652
|
-
string$2 = stripAnsi$
|
|
76818
|
+
string$2 = stripAnsi$2(string$2);
|
|
76653
76819
|
if (string$2.length === 0) return 0;
|
|
76654
76820
|
string$2 = string$2.replace((0, import_emoji_regex.default)(), " ");
|
|
76655
76821
|
const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
|
|
@@ -76677,7 +76843,7 @@ function stringWidth(string$2, options = {}) {
|
|
|
76677
76843
|
const ANSI_BACKGROUND_OFFSET = 10;
|
|
76678
76844
|
const wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
|
|
76679
76845
|
const wrapAnsi256 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`;
|
|
76680
|
-
const wrapAnsi16m = (offset = 0) => (red$
|
|
76846
|
+
const wrapAnsi16m = (offset = 0) => (red$2, green$2, blue$2) => `\u001B[${38 + offset};2;${red$2};${green$2};${blue$2}m`;
|
|
76681
76847
|
const styles = {
|
|
76682
76848
|
modifier: {
|
|
76683
76849
|
reset: [0, 0],
|
|
@@ -76765,13 +76931,13 @@ function assembleStyles() {
|
|
|
76765
76931
|
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
76766
76932
|
Object.defineProperties(styles, {
|
|
76767
76933
|
rgbToAnsi256: {
|
|
76768
|
-
value: (red$
|
|
76769
|
-
if (red$
|
|
76770
|
-
if (red$
|
|
76771
|
-
if (red$
|
|
76772
|
-
return Math.round((red$
|
|
76934
|
+
value: (red$2, green$2, blue$2) => {
|
|
76935
|
+
if (red$2 === green$2 && green$2 === blue$2) {
|
|
76936
|
+
if (red$2 < 8) return 16;
|
|
76937
|
+
if (red$2 > 248) return 231;
|
|
76938
|
+
return Math.round((red$2 - 8) / 247 * 24) + 232;
|
|
76773
76939
|
}
|
|
76774
|
-
return 16 + 36 * Math.round(red$
|
|
76940
|
+
return 16 + 36 * Math.round(red$2 / 255 * 5) + 6 * Math.round(green$2 / 255 * 5) + Math.round(blue$2 / 255 * 5);
|
|
76775
76941
|
},
|
|
76776
76942
|
enumerable: false
|
|
76777
76943
|
},
|
|
@@ -76802,30 +76968,30 @@ function assembleStyles() {
|
|
|
76802
76968
|
value: (code) => {
|
|
76803
76969
|
if (code < 8) return 30 + code;
|
|
76804
76970
|
if (code < 16) return 90 + (code - 8);
|
|
76805
|
-
let red$
|
|
76806
|
-
let green$
|
|
76807
|
-
let blue$
|
|
76971
|
+
let red$2;
|
|
76972
|
+
let green$2;
|
|
76973
|
+
let blue$2;
|
|
76808
76974
|
if (code >= 232) {
|
|
76809
|
-
red$
|
|
76810
|
-
green$
|
|
76811
|
-
blue$
|
|
76975
|
+
red$2 = ((code - 232) * 10 + 8) / 255;
|
|
76976
|
+
green$2 = red$2;
|
|
76977
|
+
blue$2 = red$2;
|
|
76812
76978
|
} else {
|
|
76813
76979
|
code -= 16;
|
|
76814
76980
|
const remainder = code % 36;
|
|
76815
|
-
red$
|
|
76816
|
-
green$
|
|
76817
|
-
blue$
|
|
76981
|
+
red$2 = Math.floor(code / 36) / 5;
|
|
76982
|
+
green$2 = Math.floor(remainder / 6) / 5;
|
|
76983
|
+
blue$2 = remainder % 6 / 5;
|
|
76818
76984
|
}
|
|
76819
|
-
const value = Math.max(red$
|
|
76985
|
+
const value = Math.max(red$2, green$2, blue$2) * 2;
|
|
76820
76986
|
if (value === 0) return 30;
|
|
76821
|
-
let result = 30 + (Math.round(blue$
|
|
76987
|
+
let result = 30 + (Math.round(blue$2) << 2 | Math.round(green$2) << 1 | Math.round(red$2));
|
|
76822
76988
|
if (value === 2) result += 60;
|
|
76823
76989
|
return result;
|
|
76824
76990
|
},
|
|
76825
76991
|
enumerable: false
|
|
76826
76992
|
},
|
|
76827
76993
|
rgbToAnsi: {
|
|
76828
|
-
value: (red$
|
|
76994
|
+
value: (red$2, green$2, blue$2) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red$2, green$2, blue$2)),
|
|
76829
76995
|
enumerable: false
|
|
76830
76996
|
},
|
|
76831
76997
|
hexToAnsi: {
|
|
@@ -76854,7 +77020,7 @@ const wrapWord = (rows, word, columns) => {
|
|
|
76854
77020
|
const characters = [...word];
|
|
76855
77021
|
let isInsideEscape = false;
|
|
76856
77022
|
let isInsideLinkEscape = false;
|
|
76857
|
-
let visible = stringWidth(stripAnsi$
|
|
77023
|
+
let visible = stringWidth(stripAnsi$2(rows[rows.length - 1]));
|
|
76858
77024
|
for (const [index, character] of characters.entries()) {
|
|
76859
77025
|
const characterLength = stringWidth(character);
|
|
76860
77026
|
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
|
|
@@ -77045,7 +77211,7 @@ const fitToTerminalHeight = (stream$2, text) => {
|
|
|
77045
77211
|
const lines = text.split("\n");
|
|
77046
77212
|
const toRemove = lines.length - terminalHeight;
|
|
77047
77213
|
if (toRemove <= 0) return text;
|
|
77048
|
-
return sliceAnsi(text, stripAnsi$
|
|
77214
|
+
return sliceAnsi(text, stripAnsi$2(lines.slice(0, toRemove).join("\n")).length + 1);
|
|
77049
77215
|
};
|
|
77050
77216
|
function createLogUpdate(stream$2, { showCursor: showCursor$1 = false } = {}) {
|
|
77051
77217
|
let previousLineCount = 0;
|
|
@@ -77081,321 +77247,15 @@ function createLogUpdate(stream$2, { showCursor: showCursor$1 = false } = {}) {
|
|
|
77081
77247
|
};
|
|
77082
77248
|
return render;
|
|
77083
77249
|
}
|
|
77084
|
-
const logUpdate$
|
|
77250
|
+
const logUpdate$2 = createLogUpdate(process5.stdout);
|
|
77085
77251
|
const logUpdateStderr = createLogUpdate(process5.stderr);
|
|
77086
77252
|
|
|
77087
77253
|
//#endregion
|
|
77088
|
-
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.
|
|
77089
|
-
const logUpdate = createLogUpdate(stdout$
|
|
77090
|
-
const grayBar = gray(shapes.bar);
|
|
77091
|
-
const blCorner = gray(shapes.corners.bl);
|
|
77092
|
-
const leftT = gray(shapes.leftT);
|
|
77093
|
-
function acceptDefault(promptConfig, renderers, initialValue) {
|
|
77094
|
-
const error$3 = promptConfig.validate?.(initialValue);
|
|
77095
|
-
if (error$3) {
|
|
77096
|
-
const errorMessage = error$3 instanceof Error ? error$3.message : error$3;
|
|
77097
|
-
if (promptConfig.throwOnError) throw new Error(errorMessage);
|
|
77098
|
-
else crash(errorMessage);
|
|
77099
|
-
}
|
|
77100
|
-
logRaw(renderers.submit({ value: initialValue }).join("\n"));
|
|
77101
|
-
return initialValue;
|
|
77102
|
-
}
|
|
77103
|
-
const inputPrompt = async (promptConfig) => {
|
|
77104
|
-
const renderers = {
|
|
77105
|
-
...getRenderers(promptConfig),
|
|
77106
|
-
...promptConfig.renderers
|
|
77107
|
-
};
|
|
77108
|
-
let prompt;
|
|
77109
|
-
const dispatchRender = (props, p$2) => {
|
|
77110
|
-
let state = props.state;
|
|
77111
|
-
if (state === "initial" && promptConfig.initialErrorMessage) {
|
|
77112
|
-
state = "error";
|
|
77113
|
-
props.error = promptConfig.initialErrorMessage;
|
|
77114
|
-
}
|
|
77115
|
-
return renderers[state](props, p$2).join("\n");
|
|
77116
|
-
};
|
|
77117
|
-
if (promptConfig.type === "select") {
|
|
77118
|
-
const initialValue = String(promptConfig.defaultValue);
|
|
77119
|
-
if (promptConfig.acceptDefault) return acceptDefault(promptConfig, renderers, initialValue);
|
|
77120
|
-
prompt = new nt({
|
|
77121
|
-
...promptConfig,
|
|
77122
|
-
options: promptConfig.options.filter((o) => !o.hidden),
|
|
77123
|
-
initialValue,
|
|
77124
|
-
render() {
|
|
77125
|
-
return dispatchRender(this, prompt);
|
|
77126
|
-
}
|
|
77127
|
-
});
|
|
77128
|
-
} else if (promptConfig.type === "confirm") {
|
|
77129
|
-
const initialValue = Boolean(promptConfig.defaultValue);
|
|
77130
|
-
if (promptConfig.acceptDefault) return acceptDefault(promptConfig, renderers, initialValue);
|
|
77131
|
-
prompt = new Q({
|
|
77132
|
-
...promptConfig,
|
|
77133
|
-
initialValue,
|
|
77134
|
-
active: promptConfig.activeText || "",
|
|
77135
|
-
inactive: promptConfig.inactiveText || "",
|
|
77136
|
-
render() {
|
|
77137
|
-
return dispatchRender(this, prompt);
|
|
77138
|
-
}
|
|
77139
|
-
});
|
|
77140
|
-
} else if (promptConfig.type == "multiselect") {
|
|
77141
|
-
let initialValues;
|
|
77142
|
-
if (Array.isArray(promptConfig.defaultValue)) initialValues = promptConfig.defaultValue;
|
|
77143
|
-
else if (promptConfig.defaultValue !== void 0) initialValues = [String(promptConfig.defaultValue)];
|
|
77144
|
-
if (promptConfig.acceptDefault) return acceptDefault(promptConfig, renderers, initialValues);
|
|
77145
|
-
prompt = new it({
|
|
77146
|
-
...promptConfig,
|
|
77147
|
-
options: promptConfig.options,
|
|
77148
|
-
initialValues,
|
|
77149
|
-
render() {
|
|
77150
|
-
return dispatchRender(this, prompt);
|
|
77151
|
-
}
|
|
77152
|
-
});
|
|
77153
|
-
} else if (promptConfig.type === "list") {
|
|
77154
|
-
const initialValue = String(promptConfig.defaultValue);
|
|
77155
|
-
if (promptConfig.acceptDefault) return acceptDefault(promptConfig, renderers, initialValue);
|
|
77156
|
-
prompt = new SelectRefreshablePrompt({
|
|
77157
|
-
...promptConfig,
|
|
77158
|
-
onRefresh: promptConfig.onRefresh ?? (() => Promise.resolve(promptConfig.options)),
|
|
77159
|
-
initialValue,
|
|
77160
|
-
render() {
|
|
77161
|
-
return dispatchRender(this, prompt);
|
|
77162
|
-
}
|
|
77163
|
-
});
|
|
77164
|
-
} else {
|
|
77165
|
-
const initialValue = promptConfig.initialValue ?? String(promptConfig.defaultValue ?? "");
|
|
77166
|
-
if (promptConfig.acceptDefault) return acceptDefault(promptConfig, renderers, initialValue);
|
|
77167
|
-
prompt = new at({
|
|
77168
|
-
...promptConfig,
|
|
77169
|
-
initialValue: promptConfig.initialValue,
|
|
77170
|
-
defaultValue: String(promptConfig.defaultValue ?? ""),
|
|
77171
|
-
render() {
|
|
77172
|
-
return dispatchRender(this, prompt);
|
|
77173
|
-
}
|
|
77174
|
-
});
|
|
77175
|
-
}
|
|
77176
|
-
const input$1 = await prompt.prompt();
|
|
77177
|
-
if (q(input$1)) if (promptConfig.throwOnError) throw new CancelError$1("Operation cancelled");
|
|
77178
|
-
else {
|
|
77179
|
-
cancel("Operation cancelled");
|
|
77180
|
-
process.exit(0);
|
|
77181
|
-
}
|
|
77182
|
-
return input$1;
|
|
77183
|
-
};
|
|
77184
|
-
const renderSubmit = (config$2, value) => {
|
|
77185
|
-
const { question, label } = config$2;
|
|
77186
|
-
if (config$2.type !== "confirm" && !value) return [`${leftT} ${question} ${dim("(skipped)")}`, `${grayBar}`];
|
|
77187
|
-
const content = config$2.type === "confirm" ? `${grayBar} ${brandColor(value)} ${dim(label)}` : `${grayBar} ${brandColor(label)} ${dim(value)}`;
|
|
77188
|
-
return [
|
|
77189
|
-
`${leftT} ${question}`,
|
|
77190
|
-
content,
|
|
77191
|
-
`${grayBar}`
|
|
77192
|
-
];
|
|
77193
|
-
};
|
|
77194
|
-
const getRenderers = (config$2) => {
|
|
77195
|
-
switch (config$2.type) {
|
|
77196
|
-
case "select": return getSelectRenderers(config$2);
|
|
77197
|
-
case "confirm": return getConfirmRenderers(config$2);
|
|
77198
|
-
case "text": return getTextRenderers(config$2);
|
|
77199
|
-
case "multiselect": return getSelectRenderers(config$2);
|
|
77200
|
-
case "list": return getSelectListRenderers(config$2);
|
|
77201
|
-
}
|
|
77202
|
-
};
|
|
77203
|
-
const getTextRenderers = (config$2) => {
|
|
77204
|
-
const { question } = config$2;
|
|
77205
|
-
const helpText = config$2.helpText ?? "";
|
|
77206
|
-
const format$3 = config$2.format ?? ((val) => String(val));
|
|
77207
|
-
const defaultValue = config$2.defaultValue?.toString() ?? "";
|
|
77208
|
-
const activeRenderer = (props) => {
|
|
77209
|
-
const { userInputWithCursor } = props;
|
|
77210
|
-
return [
|
|
77211
|
-
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
77212
|
-
`${space(2)}${format$3(userInputWithCursor || dim(defaultValue))}`,
|
|
77213
|
-
``
|
|
77214
|
-
];
|
|
77215
|
-
};
|
|
77216
|
-
return {
|
|
77217
|
-
initial: () => [
|
|
77218
|
-
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
77219
|
-
`${space(2)}${gray(format$3(defaultValue))}`,
|
|
77220
|
-
``
|
|
77221
|
-
],
|
|
77222
|
-
active: activeRenderer,
|
|
77223
|
-
error: ({ value, error: error$3 }) => [
|
|
77224
|
-
`${leftT} ${status.error} ${dim(error$3)}`,
|
|
77225
|
-
`${grayBar}`,
|
|
77226
|
-
`${blCorner} ${question} ${dim(helpText)}`,
|
|
77227
|
-
`${space(2)}${format$3(value)}`,
|
|
77228
|
-
``
|
|
77229
|
-
],
|
|
77230
|
-
submit: ({ value }) => renderSubmit(config$2, format$3(value ?? "")),
|
|
77231
|
-
cancel: activeRenderer
|
|
77232
|
-
};
|
|
77233
|
-
};
|
|
77234
|
-
const getSelectRenderers = (config$2) => {
|
|
77235
|
-
const { options, question, helpText: _helpText } = config$2;
|
|
77236
|
-
const helpText = _helpText ?? "";
|
|
77237
|
-
const maxItemsPerPage = config$2.maxItemsPerPage ?? 32;
|
|
77238
|
-
const defaultRenderer = ({ cursor: cursor$1 = 0, value }) => {
|
|
77239
|
-
const renderOption = (opt, i$1) => {
|
|
77240
|
-
const { label: optionLabel, value: optionValue } = opt;
|
|
77241
|
-
const active = i$1 === cursor$1;
|
|
77242
|
-
const isInListOfValues = Array.isArray(value) && value.includes(optionValue);
|
|
77243
|
-
const color = isInListOfValues || active ? blue : white;
|
|
77244
|
-
const text = active ? color.underline(optionLabel) : color(optionLabel);
|
|
77245
|
-
const sublabel = opt.sublabel ? color.grey(opt.sublabel) : "";
|
|
77246
|
-
const indicator = isInListOfValues || active && !Array.isArray(value) ? color(opt.activeIcon ?? shapes.radioActive) : color(opt.inactiveIcon ?? shapes.radioInactive);
|
|
77247
|
-
return `${space(2)}${indicator} ${text} ${sublabel}`;
|
|
77248
|
-
};
|
|
77249
|
-
const renderOptionCondition = (_, i$1) => {
|
|
77250
|
-
if (options.length <= maxItemsPerPage) return true;
|
|
77251
|
-
if (i$1 < cursor$1) return options.length - i$1 <= maxItemsPerPage;
|
|
77252
|
-
return cursor$1 + maxItemsPerPage > i$1;
|
|
77253
|
-
};
|
|
77254
|
-
const visibleOptions = options.filter((o) => !o.hidden);
|
|
77255
|
-
const activeOption = visibleOptions.at(cursor$1);
|
|
77256
|
-
const lines = [
|
|
77257
|
-
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
77258
|
-
`${cursor$1 > 0 && options.length > maxItemsPerPage ? `${space(2)}${dim("...")}\n` : ""}${visibleOptions.map(renderOption).filter(renderOptionCondition).join(`\n`)}${cursor$1 + maxItemsPerPage < options.length && options.length > maxItemsPerPage ? `\n${space(2)}${dim("...")}` : ""}`,
|
|
77259
|
-
``
|
|
77260
|
-
];
|
|
77261
|
-
if (activeOption?.description) {
|
|
77262
|
-
const wordSegmenter = new Intl.Segmenter("en", { granularity: "word" });
|
|
77263
|
-
const padding = space(2);
|
|
77264
|
-
const availableWidth = process.stdout.columns - stripAnsi(padding).length * 2;
|
|
77265
|
-
const description = stripAnsi(activeOption.description);
|
|
77266
|
-
const descriptionLines = [];
|
|
77267
|
-
let descriptionLineNumber = 0;
|
|
77268
|
-
for (const data$1 of wordSegmenter.segment(description)) {
|
|
77269
|
-
let line = descriptionLines[descriptionLineNumber] ?? "";
|
|
77270
|
-
if (line.length + data$1.segment.length > availableWidth) {
|
|
77271
|
-
descriptionLineNumber++;
|
|
77272
|
-
line = "";
|
|
77273
|
-
if (data$1.segment.match(/^\s+$/)) continue;
|
|
77274
|
-
}
|
|
77275
|
-
descriptionLines[descriptionLineNumber] = line + data$1.segment;
|
|
77276
|
-
}
|
|
77277
|
-
lines.push(dim(descriptionLines.map((line) => padding + line + padding).join("\n")), ``);
|
|
77278
|
-
}
|
|
77279
|
-
return lines;
|
|
77280
|
-
};
|
|
77281
|
-
return {
|
|
77282
|
-
initial: defaultRenderer,
|
|
77283
|
-
active: defaultRenderer,
|
|
77284
|
-
confirm: defaultRenderer,
|
|
77285
|
-
error: (opts, prompt) => {
|
|
77286
|
-
return [
|
|
77287
|
-
`${leftT} ${status.error} ${dim(opts.error)}`,
|
|
77288
|
-
`${grayBar}`,
|
|
77289
|
-
...defaultRenderer(opts, prompt)
|
|
77290
|
-
];
|
|
77291
|
-
},
|
|
77292
|
-
submit: ({ value }) => {
|
|
77293
|
-
if (Array.isArray(value)) return renderSubmit(config$2, options.filter((o) => value.includes(o.value)).map((o) => o.label).join(", "));
|
|
77294
|
-
return renderSubmit(config$2, options.find((o) => o.value === value)?.label);
|
|
77295
|
-
},
|
|
77296
|
-
cancel: defaultRenderer
|
|
77297
|
-
};
|
|
77298
|
-
};
|
|
77299
|
-
const getSelectListRenderers = (config$2) => {
|
|
77300
|
-
const { question, helpText: _helpText } = config$2;
|
|
77301
|
-
let options = config$2.options;
|
|
77302
|
-
const helpText = _helpText ?? "";
|
|
77303
|
-
const { rows } = stdout$1;
|
|
77304
|
-
const defaultRenderer = ({ cursor: cursor$1, value }, prompt) => {
|
|
77305
|
-
if (prompt instanceof SelectRefreshablePrompt) options = prompt.options;
|
|
77306
|
-
cursor$1 = cursor$1 ?? 0;
|
|
77307
|
-
let smallCursor = 0;
|
|
77308
|
-
const renderOption = (opt, i$1) => {
|
|
77309
|
-
const { label: optionLabel, value: optionValueAny } = opt;
|
|
77310
|
-
const optionValue = optionValueAny.toString();
|
|
77311
|
-
const active = i$1 === smallCursor;
|
|
77312
|
-
const isInListOfValues = Array.isArray(value) && value.includes(optionValue);
|
|
77313
|
-
const color = isInListOfValues || active ? blue : white;
|
|
77314
|
-
const text = active ? color.underline(optionLabel) : color(optionLabel);
|
|
77315
|
-
const indicator = isInListOfValues || active && !Array.isArray(value) ? color(shapes.radioActive) : color(shapes.radioInactive);
|
|
77316
|
-
const indicatorMargin = 2;
|
|
77317
|
-
const detailBulletpointMargin = indicatorMargin + 4;
|
|
77318
|
-
return [`${space(indicatorMargin)}${indicator} ${text}`, ...opt.details.map((detail, j$1) => `${space(detailBulletpointMargin)}${j$1 === opt.details.length - 1 ? gray(shapes.corners.bl) : grayBar} ${detail}`)];
|
|
77319
|
-
};
|
|
77320
|
-
const pages = [];
|
|
77321
|
-
let current = {
|
|
77322
|
-
size: 0,
|
|
77323
|
-
options: []
|
|
77324
|
-
};
|
|
77325
|
-
const VERTICAL_MARGIN = 6;
|
|
77326
|
-
for (const option of options) {
|
|
77327
|
-
const optionHeight = option.details.length + 1;
|
|
77328
|
-
if (current.size + optionHeight > rows - VERTICAL_MARGIN) {
|
|
77329
|
-
pages.push(current.options);
|
|
77330
|
-
current = {
|
|
77331
|
-
size: optionHeight,
|
|
77332
|
-
options: [option]
|
|
77333
|
-
};
|
|
77334
|
-
continue;
|
|
77335
|
-
}
|
|
77336
|
-
current.size += optionHeight;
|
|
77337
|
-
current.options.push(option);
|
|
77338
|
-
}
|
|
77339
|
-
if (current.size !== 0) pages.push(current.options);
|
|
77340
|
-
let isFirstPage = true;
|
|
77341
|
-
let isLastPage = false;
|
|
77342
|
-
let page = [];
|
|
77343
|
-
let len = 0;
|
|
77344
|
-
for (let i$1 = 0; i$1 < pages.length; i$1++) {
|
|
77345
|
-
const pageIter = pages[i$1];
|
|
77346
|
-
if (cursor$1 >= len && pageIter.length + len > cursor$1) {
|
|
77347
|
-
isFirstPage = i$1 === 0;
|
|
77348
|
-
isLastPage = i$1 === pages.length - 1;
|
|
77349
|
-
page = pageIter;
|
|
77350
|
-
smallCursor = cursor$1 - len;
|
|
77351
|
-
break;
|
|
77352
|
-
}
|
|
77353
|
-
len += pageIter.length;
|
|
77354
|
-
}
|
|
77355
|
-
return [
|
|
77356
|
-
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
77357
|
-
...!isFirstPage ? [`${space(2)}${dim("...")}`] : [],
|
|
77358
|
-
...page.map(renderOption).reduce((prev, now) => [...prev, ...now], []),
|
|
77359
|
-
...!isLastPage ? [`${space(2)}${dim("...")}`] : []
|
|
77360
|
-
];
|
|
77361
|
-
};
|
|
77362
|
-
return {
|
|
77363
|
-
initial: defaultRenderer,
|
|
77364
|
-
active: defaultRenderer,
|
|
77365
|
-
confirm: defaultRenderer,
|
|
77366
|
-
error: (opts, prompt) => {
|
|
77367
|
-
return [
|
|
77368
|
-
`${leftT} ${status.error} ${dim(opts.error)}`,
|
|
77369
|
-
`${grayBar}`,
|
|
77370
|
-
...defaultRenderer(opts, prompt)
|
|
77371
|
-
];
|
|
77372
|
-
},
|
|
77373
|
-
submit: ({ value }) => {
|
|
77374
|
-
if (Array.isArray(value)) return renderSubmit(config$2, options.filter((o) => value.includes(o.value)).map((o) => o.value).join(", "));
|
|
77375
|
-
return renderSubmit(config$2, options.find((o) => o.value === value)?.value);
|
|
77376
|
-
},
|
|
77377
|
-
cancel: defaultRenderer
|
|
77378
|
-
};
|
|
77379
|
-
};
|
|
77380
|
-
const getConfirmRenderers = (config$2) => {
|
|
77381
|
-
const { activeText, inactiveText, question, helpText: _helpText } = config$2;
|
|
77382
|
-
const helpText = _helpText ?? "";
|
|
77383
|
-
const active = activeText || "Yes";
|
|
77384
|
-
const inactive = inactiveText || "No";
|
|
77385
|
-
const defaultRenderer = ({ value }) => {
|
|
77386
|
-
const yesColor = value ? blue.underline : dim;
|
|
77387
|
-
const noColor = value ? dim : blue.underline;
|
|
77388
|
-
return [`${blCorner} ${bold(question)} ${dim(helpText)}`, `${space(2)}${yesColor(active)} / ${noColor(inactive)}`];
|
|
77389
|
-
};
|
|
77390
|
-
return {
|
|
77391
|
-
initial: defaultRenderer,
|
|
77392
|
-
active: defaultRenderer,
|
|
77393
|
-
confirm: defaultRenderer,
|
|
77394
|
-
error: defaultRenderer,
|
|
77395
|
-
submit: ({ value }) => renderSubmit(config$2, value ? "yes" : "no"),
|
|
77396
|
-
cancel: defaultRenderer
|
|
77397
|
-
};
|
|
77398
|
-
};
|
|
77254
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.6_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_8ad19c2891441732cf973a4bd95ecdfb/node_modules/@cloudflare/cli-shared-helpers/dist/interactive.mjs
|
|
77255
|
+
const logUpdate$1 = createLogUpdate(stdout$2);
|
|
77256
|
+
const grayBar$1 = gray$1(shapes$1.bar);
|
|
77257
|
+
const blCorner$1 = gray$1(shapes$1.corners.bl);
|
|
77258
|
+
const leftT$1 = gray$1(shapes$1.leftT);
|
|
77399
77259
|
const spinnerFrames = {
|
|
77400
77260
|
clockwise: [
|
|
77401
77261
|
"┤",
|
|
@@ -77429,7 +77289,7 @@ const ellipsisFrames = [
|
|
|
77429
77289
|
" .",
|
|
77430
77290
|
""
|
|
77431
77291
|
];
|
|
77432
|
-
const spinner = (frames = spinnerFrames.clockwise, color = brandColor) => {
|
|
77292
|
+
const spinner = (frames = spinnerFrames.clockwise, color = brandColor$1) => {
|
|
77433
77293
|
const frameRate = 120;
|
|
77434
77294
|
let loop = null;
|
|
77435
77295
|
let startMsg;
|
|
@@ -77443,7 +77303,7 @@ const spinner = (frames = spinnerFrames.clockwise, color = brandColor) => {
|
|
|
77443
77303
|
helpText ||= ``;
|
|
77444
77304
|
currentMsg = msg;
|
|
77445
77305
|
startMsg = currentMsg;
|
|
77446
|
-
if (helpText !== void 0 && helpText.length > 0) startMsg += ` ${dim(helpText)}`;
|
|
77306
|
+
if (helpText !== void 0 && helpText.length > 0) startMsg += ` ${dim$1(helpText)}`;
|
|
77447
77307
|
if (isInteractive()) {
|
|
77448
77308
|
let index = 0;
|
|
77449
77309
|
clearLoop();
|
|
@@ -77451,25 +77311,25 @@ const spinner = (frames = spinnerFrames.clockwise, color = brandColor) => {
|
|
|
77451
77311
|
index++;
|
|
77452
77312
|
const spinnerFrame = frames[index % frames.length];
|
|
77453
77313
|
const ellipsisFrame = ellipsisFrames[index % ellipsisFrames.length];
|
|
77454
|
-
if (msg) logUpdate(`${color(spinnerFrame)} ${currentMsg} ${ellipsisFrame}`);
|
|
77314
|
+
if (msg) logUpdate$1(`${color(spinnerFrame)} ${currentMsg} ${ellipsisFrame}`);
|
|
77455
77315
|
}, frameRate);
|
|
77456
|
-
} else logRaw(`${leftT} ${startMsg}`);
|
|
77316
|
+
} else logRaw$1(`${leftT$1} ${startMsg}`);
|
|
77457
77317
|
},
|
|
77458
77318
|
update(msg) {
|
|
77459
77319
|
currentMsg = msg;
|
|
77460
77320
|
},
|
|
77461
77321
|
stop(msg) {
|
|
77462
77322
|
if (isInteractive()) {
|
|
77463
|
-
logUpdate.clear();
|
|
77323
|
+
logUpdate$1.clear();
|
|
77464
77324
|
if (msg) {
|
|
77465
|
-
logUpdate(`${leftT} ${startMsg}\n${grayBar} ${msg}`);
|
|
77466
|
-
logUpdate.done();
|
|
77467
|
-
newline();
|
|
77325
|
+
logUpdate$1(`${leftT$1} ${startMsg}\n${grayBar$1} ${msg}`);
|
|
77326
|
+
logUpdate$1.done();
|
|
77327
|
+
newline$1();
|
|
77468
77328
|
}
|
|
77469
77329
|
clearLoop();
|
|
77470
77330
|
} else {
|
|
77471
|
-
if (msg !== void 0) logRaw(`${grayBar} ${msg}`);
|
|
77472
|
-
newline();
|
|
77331
|
+
if (msg !== void 0) logRaw$1(`${grayBar$1} ${msg}`);
|
|
77332
|
+
newline$1();
|
|
77473
77333
|
}
|
|
77474
77334
|
}
|
|
77475
77335
|
};
|
|
@@ -77486,7 +77346,7 @@ function isInteractive() {
|
|
|
77486
77346
|
}
|
|
77487
77347
|
|
|
77488
77348
|
//#endregion
|
|
77489
|
-
//#region ../../node_modules/.pnpm/@cloudflare+containers-shared@0.
|
|
77349
|
+
//#region ../../node_modules/.pnpm/@cloudflare+containers-shared@0.25.0_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_0a45a91436b8909d46077db2686f7758/node_modules/@cloudflare/containers-shared/dist/index.mjs
|
|
77490
77350
|
const require$1$1 = createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
77491
77351
|
var __create = Object.create;
|
|
77492
77352
|
var __defProp$2 = Object.defineProperty;
|
|
@@ -79377,7 +79237,7 @@ var require_extension = __commonJS({ "../../node_modules/.pnpm/ws@8.21.0/node_mo
|
|
|
79377
79237
|
return offers;
|
|
79378
79238
|
}
|
|
79379
79239
|
__name$2(parse$14, "parse");
|
|
79380
|
-
function format$
|
|
79240
|
+
function format$4(extensions) {
|
|
79381
79241
|
return Object.keys(extensions).map((extension2) => {
|
|
79382
79242
|
let configurations = extensions[extension2];
|
|
79383
79243
|
if (!Array.isArray(configurations)) configurations = [configurations];
|
|
@@ -79390,9 +79250,9 @@ var require_extension = __commonJS({ "../../node_modules/.pnpm/ws@8.21.0/node_mo
|
|
|
79390
79250
|
}).join(", ");
|
|
79391
79251
|
}).join(", ");
|
|
79392
79252
|
}
|
|
79393
|
-
__name$2(format$
|
|
79253
|
+
__name$2(format$4, "format");
|
|
79394
79254
|
module$1.exports = {
|
|
79395
|
-
format: format$
|
|
79255
|
+
format: format$4,
|
|
79396
79256
|
parse: parse$14
|
|
79397
79257
|
};
|
|
79398
79258
|
} });
|
|
@@ -79411,7 +79271,7 @@ var require_websocket = __commonJS({ "../../node_modules/.pnpm/ws@8.21.0/node_mo
|
|
|
79411
79271
|
var { isBlob: isBlob2 } = require_validation();
|
|
79412
79272
|
var { BINARY_TYPES, CLOSE_TIMEOUT, EMPTY_BUFFER: EMPTY_BUFFER$1, GUID, kForOnEventAttribute, kListener: kListener$1, kStatusCode, kWebSocket, NOOP } = require_constants$1();
|
|
79413
79273
|
var { EventTarget: { addEventListener, removeEventListener } } = require_event_target();
|
|
79414
|
-
var { format: format$
|
|
79274
|
+
var { format: format$4, parse: parse$14 } = require_extension();
|
|
79415
79275
|
var { toBuffer: toBuffer$1 } = require_buffer_util();
|
|
79416
79276
|
var kAborted = Symbol("kAborted");
|
|
79417
79277
|
var protocolVersions = [8, 13];
|
|
@@ -79918,7 +79778,7 @@ var require_websocket = __commonJS({ "../../node_modules/.pnpm/ws@8.21.0/node_mo
|
|
|
79918
79778
|
isServer: false,
|
|
79919
79779
|
maxPayload: opts.maxPayload
|
|
79920
79780
|
});
|
|
79921
|
-
opts.headers["Sec-WebSocket-Extensions"] = format$
|
|
79781
|
+
opts.headers["Sec-WebSocket-Extensions"] = format$4({ [PerMessageDeflate2.extensionName]: perMessageDeflate.offer() });
|
|
79922
79782
|
}
|
|
79923
79783
|
if (protocols.length) {
|
|
79924
79784
|
for (const protocol of protocols) {
|
|
@@ -80698,7 +80558,7 @@ var ApiError = class extends Error {
|
|
|
80698
80558
|
this.request = request2;
|
|
80699
80559
|
}
|
|
80700
80560
|
};
|
|
80701
|
-
var CancelError = class extends Error {
|
|
80561
|
+
var CancelError$1 = class extends Error {
|
|
80702
80562
|
static {
|
|
80703
80563
|
__name$2(this, "CancelError");
|
|
80704
80564
|
}
|
|
@@ -80771,7 +80631,7 @@ var CancelablePromise = class {
|
|
|
80771
80631
|
return;
|
|
80772
80632
|
}
|
|
80773
80633
|
this.#cancelHandlers.length = 0;
|
|
80774
|
-
this.#reject?.(new CancelError("Request aborted"));
|
|
80634
|
+
this.#reject?.(new CancelError$1("Request aborted"));
|
|
80775
80635
|
}
|
|
80776
80636
|
get isCancelled() {
|
|
80777
80637
|
return this.#isCancelled;
|
|
@@ -80878,7 +80738,9 @@ var getHeaders = /* @__PURE__ */ __name$2(async (config$2, options) => {
|
|
|
80878
80738
|
else if (isBlob(options.body)) headers["Content-Type"] = options.body.type || "application/octet-stream";
|
|
80879
80739
|
else if (isString(options.body)) headers["Content-Type"] = "text/plain";
|
|
80880
80740
|
else headers["Content-Type"] = "application/json";
|
|
80881
|
-
|
|
80741
|
+
const requestHeaders = new Headers(headers);
|
|
80742
|
+
addCustomApiHeaders(requestHeaders);
|
|
80743
|
+
return requestHeaders;
|
|
80882
80744
|
}, "getHeaders");
|
|
80883
80745
|
var getRequestBody = /* @__PURE__ */ __name$2((options) => {
|
|
80884
80746
|
if (options.body !== void 0) if (options.mediaType?.includes("/json")) return JSON.stringify(options.body);
|
|
@@ -81005,9 +80867,7 @@ var requestPaginated = /* @__PURE__ */ __name$2((config$2, options) => {
|
|
|
81005
80867
|
}, "requestPaginated");
|
|
81006
80868
|
var debugLogRequest = /* @__PURE__ */ __name$2(async (config$2, url$2, headers, body) => {
|
|
81007
80869
|
config$2.LOGGER?.debug(`-- START CF API REQUEST: ${url$2}`);
|
|
81008
|
-
|
|
81009
|
-
logHeaders$1.delete("Authorization");
|
|
81010
|
-
config$2.LOGGER?.debugWithSanitization("HEADERS:", JSON.stringify(logHeaders$1, null, 2));
|
|
80870
|
+
config$2.LOGGER?.debugWithSanitization("HEADERS:", JSON.stringify(sanitizeHeaders(headers), null, 2));
|
|
81011
80871
|
config$2.LOGGER?.debugWithSanitization("BODY:", JSON.stringify(body instanceof FormData ? await new Response(body).text() : body, null, 2));
|
|
81012
80872
|
config$2.LOGGER?.debug("-- END CF API REQUEST");
|
|
81013
80873
|
}, "debugLogRequest");
|
|
@@ -82713,8 +82573,8 @@ async function getDockerSecurityOptions(dockerPath, dockerHost) {
|
|
|
82713
82573
|
], {
|
|
82714
82574
|
encoding: "utf8",
|
|
82715
82575
|
timeout: 5e3
|
|
82716
|
-
}, (error$3, stdout$
|
|
82717
|
-
if (error$3 === null) resolve2(stdout$
|
|
82576
|
+
}, (error$3, stdout$3) => {
|
|
82577
|
+
if (error$3 === null) resolve2(stdout$3);
|
|
82718
82578
|
else reject(error$3);
|
|
82719
82579
|
});
|
|
82720
82580
|
});
|
|
@@ -82765,36 +82625,6 @@ ${hint}`;
|
|
|
82765
82625
|
return message;
|
|
82766
82626
|
}
|
|
82767
82627
|
__name$2(getFailedToRunDockerErrorMessage, "getFailedToRunDockerErrorMessage");
|
|
82768
|
-
var cleanupContainers = /* @__PURE__ */ __name$2((dockerPath, imageTags) => {
|
|
82769
|
-
try {
|
|
82770
|
-
const containerIds = getContainerIdsByImageTags(dockerPath, imageTags);
|
|
82771
|
-
if (containerIds.length === 0) return true;
|
|
82772
|
-
runDockerCmdWithOutput(dockerPath, [
|
|
82773
|
-
"rm",
|
|
82774
|
-
"--force",
|
|
82775
|
-
...containerIds
|
|
82776
|
-
]);
|
|
82777
|
-
return true;
|
|
82778
|
-
} catch {
|
|
82779
|
-
return false;
|
|
82780
|
-
}
|
|
82781
|
-
}, "cleanupContainers");
|
|
82782
|
-
function getContainerIdsByImageTags(dockerPath, imageTags) {
|
|
82783
|
-
const ids = /* @__PURE__ */ new Set();
|
|
82784
|
-
for (const imageTag of imageTags) getContainerIdsFromImage(dockerPath, imageTag).forEach((id) => ids.add(id));
|
|
82785
|
-
return Array.from(ids);
|
|
82786
|
-
}
|
|
82787
|
-
__name$2(getContainerIdsByImageTags, "getContainerIdsByImageTags");
|
|
82788
|
-
var getContainerIdsFromImage = /* @__PURE__ */ __name$2((dockerPath, ancestorImage) => {
|
|
82789
|
-
return runDockerCmdWithOutput(dockerPath, [
|
|
82790
|
-
"ps",
|
|
82791
|
-
"-a",
|
|
82792
|
-
"--filter",
|
|
82793
|
-
`ancestor=${ancestorImage}`,
|
|
82794
|
-
"--format",
|
|
82795
|
-
"{{.ID}}"
|
|
82796
|
-
]).split("\n").filter((line) => line.trim());
|
|
82797
|
-
}, "getContainerIdsFromImage");
|
|
82798
82628
|
function generateContainerBuildId() {
|
|
82799
82629
|
return randomUUID().slice(0, 8);
|
|
82800
82630
|
}
|
|
@@ -82876,9 +82706,9 @@ async function prepareContainerImagesForDev(args) {
|
|
|
82876
82706
|
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 });
|
|
82877
82707
|
await verifyDockerInstalled({
|
|
82878
82708
|
dockerPath,
|
|
82879
|
-
operation: "running dev",
|
|
82709
|
+
operation: args.operation ?? "running dev",
|
|
82880
82710
|
imageNoun: containerOptions.length !== 1 ? "the configured images" : "the configured image",
|
|
82881
|
-
hint: `To suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your ${args.configFileName} or pass --enable-containers=false.`
|
|
82711
|
+
hint: args.disableContainersHint ?? `To suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your ${args.configFileName} or pass --enable-containers=false.`
|
|
82882
82712
|
});
|
|
82883
82713
|
for (const options of containerOptions) {
|
|
82884
82714
|
if ("dockerfile" in options) {
|
|
@@ -83015,13 +82845,13 @@ async function dockerImageInspect(dockerPath, options) {
|
|
|
83015
82845
|
"pipe",
|
|
83016
82846
|
"pipe"
|
|
83017
82847
|
] });
|
|
83018
|
-
let stdout$
|
|
83019
|
-
let stderr$
|
|
83020
|
-
proc.stdout.on("data", (chunk) => stdout$
|
|
83021
|
-
proc.stderr.on("data", (chunk) => stderr$
|
|
82848
|
+
let stdout$3 = "";
|
|
82849
|
+
let stderr$2 = "";
|
|
82850
|
+
proc.stdout.on("data", (chunk) => stdout$3 += chunk);
|
|
82851
|
+
proc.stderr.on("data", (chunk) => stderr$2 += chunk);
|
|
83022
82852
|
proc.on("close", (code) => {
|
|
83023
|
-
if (code !== 0) return reject(new UserError(`failed inspecting image locally: ${stderr$
|
|
83024
|
-
resolve2(stdout$
|
|
82853
|
+
if (code !== 0) return reject(new UserError(`failed inspecting image locally: ${stderr$2.trim()}`, { telemetryMessage: false }));
|
|
82854
|
+
resolve2(stdout$3.trim());
|
|
83025
82855
|
});
|
|
83026
82856
|
proc.on("error", (err) => reject(err));
|
|
83027
82857
|
});
|
|
@@ -83248,6 +83078,7 @@ async function tagAndPushImage({ pathToDocker, sourceTag, targetTag, externalAcc
|
|
|
83248
83078
|
sourceTag,
|
|
83249
83079
|
namespacedImageTag
|
|
83250
83080
|
]);
|
|
83081
|
+
await runDockerCmd(pathToDocker, ["push", namespacedImageTag]);
|
|
83251
83082
|
if (cleanupSourceTag) {
|
|
83252
83083
|
logger$1.debug(`Untagging built image: ${sourceTag}.`);
|
|
83253
83084
|
await runDockerCmd(pathToDocker, [
|
|
@@ -83256,7 +83087,6 @@ async function tagAndPushImage({ pathToDocker, sourceTag, targetTag, externalAcc
|
|
|
83256
83087
|
sourceTag
|
|
83257
83088
|
]);
|
|
83258
83089
|
}
|
|
83259
|
-
await runDockerCmd(pathToDocker, ["push", namespacedImageTag]);
|
|
83260
83090
|
return namespacedImageTag;
|
|
83261
83091
|
}
|
|
83262
83092
|
__name$2(tagAndPushImage, "tagAndPushImage");
|
|
@@ -83449,17 +83279,15 @@ async function buildContainerImages(containers, pathToDocker, verifyDockerIsRunn
|
|
|
83449
83279
|
__name$2(buildContainerImages, "buildContainerImages");
|
|
83450
83280
|
async function pushBuiltContainerImage(builtImage, versionId, pathToDocker, accountId, complianceConfig) {
|
|
83451
83281
|
try {
|
|
83452
|
-
|
|
83282
|
+
return await pushImageIfChanged({
|
|
83453
83283
|
pathToDocker,
|
|
83454
83284
|
sourceTag: builtImage.localTag,
|
|
83455
83285
|
targetTag: getContainerImageTag(builtImage.container, versionId),
|
|
83456
83286
|
containerConfig: builtImage.container,
|
|
83457
83287
|
accountId,
|
|
83458
83288
|
complianceConfig,
|
|
83459
|
-
cleanupSourceTag:
|
|
83289
|
+
cleanupSourceTag: false
|
|
83460
83290
|
});
|
|
83461
|
-
builtImage.localTagCleaned = true;
|
|
83462
|
-
return imageRef;
|
|
83463
83291
|
} catch (error$3) {
|
|
83464
83292
|
if (error$3 instanceof Error) throw new UserError(error$3.message, {
|
|
83465
83293
|
cause: error$3,
|
|
@@ -83869,7 +83697,7 @@ var Diff = class {
|
|
|
83869
83697
|
`;
|
|
83870
83698
|
});
|
|
83871
83699
|
context.length = 0;
|
|
83872
|
-
for (const l of result.value.split("\n")) if (l) output$1 += `${result.added ? green("+") : red("-")} ${l}
|
|
83700
|
+
for (const l of result.value.split("\n")) if (l) output$1 += `${result.added ? green$1("+") : red$1("-")} ${l}
|
|
83873
83701
|
`;
|
|
83874
83702
|
state = "diff";
|
|
83875
83703
|
} else {
|
|
@@ -84239,7 +84067,7 @@ async function apply(args, containerConfig, config$2, accountId) {
|
|
|
84239
84067
|
startSection("Deploy a container application", "deploy changes to your application");
|
|
84240
84068
|
let prevApp = (await promiseSpinner(ApplicationsService.listApplications(), { message: "Loading applications" })).find((app) => app.name === containerConfig.name);
|
|
84241
84069
|
const imageRef = "remoteDigest" in args.imageRef ? args.imageRef.remoteDigest : args.imageRef.newTag;
|
|
84242
|
-
log$1(dim("Container application changes\n"));
|
|
84070
|
+
log$1(dim$1("Container application changes\n"));
|
|
84243
84071
|
let migratedLegacyObservability = false;
|
|
84244
84072
|
if (prevApp !== void 0) {
|
|
84245
84073
|
if (!prevApp.durable_objects?.namespace_id) throw new FatalError("The previous deploy of this container application was not associated with a durable object", { telemetryMessage: "containers deploy previous durable object missing" });
|
|
@@ -84253,7 +84081,7 @@ async function apply(args, containerConfig, config$2, accountId) {
|
|
|
84253
84081
|
application: { observability: migrationObservability },
|
|
84254
84082
|
id: prevApp.id,
|
|
84255
84083
|
name: prevApp.name,
|
|
84256
|
-
successMessage: `Migrated observability configuration for ${brandColor(prevApp.name)} (Application ID: ${prevApp.id})`
|
|
84084
|
+
successMessage: `Migrated observability configuration for ${brandColor$1(prevApp.name)} (Application ID: ${prevApp.id})`
|
|
84257
84085
|
});
|
|
84258
84086
|
prevApp = migrateLegacyObservabilityState(prevApp, migrationObservability);
|
|
84259
84087
|
migratedLegacyObservability = true;
|
|
@@ -84273,18 +84101,18 @@ async function apply(args, containerConfig, config$2, accountId) {
|
|
|
84273
84101
|
const diff$2 = new Diff(formatContainerSnippetForDisplay(normalisedPrevApp, config$2.configPath), formatContainerSnippetForDisplay(nowContainer, config$2.configPath));
|
|
84274
84102
|
if (diff$2.changes === 0) {
|
|
84275
84103
|
if (migratedLegacyObservability) {
|
|
84276
|
-
newline();
|
|
84104
|
+
newline$1();
|
|
84277
84105
|
endSection("Applied changes");
|
|
84278
84106
|
return;
|
|
84279
84107
|
}
|
|
84280
|
-
updateStatus(`no changes ${brandColor(prevApp.name)}`);
|
|
84108
|
+
updateStatus(`no changes ${brandColor$1(prevApp.name)}`);
|
|
84281
84109
|
endSection("No changes to be made");
|
|
84282
84110
|
return;
|
|
84283
84111
|
}
|
|
84284
|
-
updateStatus(`${brandColor.underline("EDIT")} ${prevApp.name}`, false);
|
|
84285
|
-
newline();
|
|
84112
|
+
updateStatus(`${brandColor$1.underline("EDIT")} ${prevApp.name}`, false);
|
|
84113
|
+
newline$1();
|
|
84286
84114
|
diff$2.print();
|
|
84287
|
-
newline();
|
|
84115
|
+
newline$1();
|
|
84288
84116
|
if (containerConfig.rollout_kind !== "none") await doAction({
|
|
84289
84117
|
action: "modify",
|
|
84290
84118
|
application: modifyReq,
|
|
@@ -84297,18 +84125,18 @@ async function apply(args, containerConfig, config$2, accountId) {
|
|
|
84297
84125
|
});
|
|
84298
84126
|
else {
|
|
84299
84127
|
log$1("Skipping application rollout");
|
|
84300
|
-
newline();
|
|
84128
|
+
newline$1();
|
|
84301
84129
|
}
|
|
84302
84130
|
} else {
|
|
84303
|
-
updateStatus(bold.underline(green.underline("NEW")) + ` ${appConfig.name}`);
|
|
84131
|
+
updateStatus(bold$1.underline(green$1.underline("NEW")) + ` ${appConfig.name}`);
|
|
84304
84132
|
formatContainerSnippetForDisplay(appConfig, config$2.configPath).trimEnd().split("\n").forEach((el) => log$1(` ${el}`));
|
|
84305
|
-
newline();
|
|
84133
|
+
newline$1();
|
|
84306
84134
|
await doAction({
|
|
84307
84135
|
action: "create",
|
|
84308
84136
|
application: appConfig
|
|
84309
84137
|
});
|
|
84310
84138
|
}
|
|
84311
|
-
newline();
|
|
84139
|
+
newline$1();
|
|
84312
84140
|
endSection("Applied changes");
|
|
84313
84141
|
}
|
|
84314
84142
|
__name$2(apply, "apply");
|
|
@@ -84326,7 +84154,7 @@ function formatError(err) {
|
|
|
84326
84154
|
if (maybeError.error !== void 0) {
|
|
84327
84155
|
const message = [];
|
|
84328
84156
|
message.push(`${maybeError.error}`);
|
|
84329
|
-
if (maybeError.details !== void 0 && typeof maybeError.details === "object") for (const key in maybeError.details) message.push(`${brandColor(key)} ${maybeError.details[key]}`);
|
|
84157
|
+
if (maybeError.details !== void 0 && typeof maybeError.details === "object") for (const key in maybeError.details) message.push(`${brandColor$1(key)} ${maybeError.details[key]}`);
|
|
84330
84158
|
return message.join("\n");
|
|
84331
84159
|
}
|
|
84332
84160
|
} catch {}
|
|
@@ -84346,7 +84174,7 @@ ${formatError(err)}`, { telemetryMessage: "containers deploy create misconfigura
|
|
|
84346
84174
|
throw new UserError(`Error creating application:
|
|
84347
84175
|
${formatError(err)}`, { telemetryMessage: "containers deploy create request failed" });
|
|
84348
84176
|
}
|
|
84349
|
-
success(`Created application ${brandColor(action.application.name)} (Application ID: ${application.id})`, { shape: shapes.bar });
|
|
84177
|
+
success(`Created application ${brandColor$1(action.application.name)} (Application ID: ${application.id})`, { shape: shapes$1.bar });
|
|
84350
84178
|
}
|
|
84351
84179
|
if (action.action === "modify") {
|
|
84352
84180
|
try {
|
|
@@ -84378,7 +84206,7 @@ ${err.message}`, { telemetryMessage: "containers deploy rollout unexpected error
|
|
|
84378
84206
|
throw new UserError(`Error rolling out application "${action.name}":
|
|
84379
84207
|
${formatError(err)}`, { telemetryMessage: "containers deploy rollout request failed" });
|
|
84380
84208
|
}
|
|
84381
|
-
success(action.successMessage ?? `Modified application ${brandColor(action.name)} (Application ID: ${action.id})`, { shape: shapes.bar });
|
|
84209
|
+
success(action.successMessage ?? `Modified application ${brandColor$1(action.name)} (Application ID: ${action.id})`, { shape: shapes$1.bar });
|
|
84382
84210
|
}
|
|
84383
84211
|
}, "doAction");
|
|
84384
84212
|
function cleanApplicationFromAPI(prev, currentConfig, accountId, observabilityWriteTarget, complianceConfig) {
|
|
@@ -84683,7 +84511,7 @@ async function sshCommand(sshArgs, userAgent) {
|
|
|
84683
84511
|
child.on("error", reject);
|
|
84684
84512
|
child.on("exit", (code) => {
|
|
84685
84513
|
if (code !== 255) resolve2(void 0);
|
|
84686
|
-
else reject(new Error(["SSH exited unsuccessfully. Is the container running?", `${bold("NOTE:")} SSH does not automatically wake a container or count as activity to keep a container alive`].join("\n")));
|
|
84514
|
+
else reject(new Error(["SSH exited unsuccessfully. Is the container running?", `${bold$1("NOTE:")} SSH does not automatically wake a container or count as activity to keep a container alive`].join("\n")));
|
|
84687
84515
|
});
|
|
84688
84516
|
});
|
|
84689
84517
|
showCursor(true);
|
|
@@ -84958,79 +84786,6 @@ function isValidImageTag(value) {
|
|
|
84958
84786
|
}
|
|
84959
84787
|
__name$2(isValidImageTag, "isValidImageTag");
|
|
84960
84788
|
|
|
84961
|
-
//#endregion
|
|
84962
|
-
//#region src/container-cleanup.ts
|
|
84963
|
-
/** Owns Container cleanup for one server session, including failed attempts. */
|
|
84964
|
-
function createContainerCleanup() {
|
|
84965
|
-
const pendingImages = /* @__PURE__ */ new Map();
|
|
84966
|
-
let restarting = false;
|
|
84967
|
-
function cleanupContainerImages() {
|
|
84968
|
-
for (const [dockerPath, imageTags] of pendingImages) if (cleanupContainers(dockerPath, imageTags)) pendingImages.delete(dockerPath);
|
|
84969
|
-
if (pendingImages.size === 0) process.off("exit", cleanupContainerImages);
|
|
84970
|
-
}
|
|
84971
|
-
return {
|
|
84972
|
-
cleanup: cleanupContainerImages,
|
|
84973
|
-
get isRestarting() {
|
|
84974
|
-
return restarting;
|
|
84975
|
-
},
|
|
84976
|
-
async restart(action) {
|
|
84977
|
-
if (restarting) return action();
|
|
84978
|
-
cleanupContainerImages();
|
|
84979
|
-
restarting = true;
|
|
84980
|
-
try {
|
|
84981
|
-
await action();
|
|
84982
|
-
} finally {
|
|
84983
|
-
restarting = false;
|
|
84984
|
-
}
|
|
84985
|
-
},
|
|
84986
|
-
track(dockerPath, imageTags) {
|
|
84987
|
-
const tags = new Set([...pendingImages.get(dockerPath) ?? [], ...imageTags]);
|
|
84988
|
-
if (tags.size === 0) return;
|
|
84989
|
-
pendingImages.set(dockerPath, tags);
|
|
84990
|
-
process.off("exit", cleanupContainerImages);
|
|
84991
|
-
process.on("exit", cleanupContainerImages);
|
|
84992
|
-
}
|
|
84993
|
-
};
|
|
84994
|
-
}
|
|
84995
|
-
const containerCleanupKey = Symbol("vite-plugin-cloudflare:container-cleanup");
|
|
84996
|
-
/**
|
|
84997
|
-
* Retains Container cleanup across config reloads for one server session.
|
|
84998
|
-
*/
|
|
84999
|
-
function getDevContainerCleanup(server) {
|
|
85000
|
-
let cleanup = server.config.inlineConfig[containerCleanupKey];
|
|
85001
|
-
if (!cleanup) {
|
|
85002
|
-
cleanup = createContainerCleanup();
|
|
85003
|
-
const inlineConfig = {
|
|
85004
|
-
...server.config.inlineConfig,
|
|
85005
|
-
[containerCleanupKey]: cleanup
|
|
85006
|
-
};
|
|
85007
|
-
server.config = {
|
|
85008
|
-
...server.config,
|
|
85009
|
-
inlineConfig
|
|
85010
|
-
};
|
|
85011
|
-
}
|
|
85012
|
-
attachContainerCleanup(server, cleanup);
|
|
85013
|
-
return cleanup;
|
|
85014
|
-
}
|
|
85015
|
-
function attachContainerCleanup(server, cleanup) {
|
|
85016
|
-
if (server.close[containerCleanupKey] === cleanup) return;
|
|
85017
|
-
const restartServer = server.restart.bind(server);
|
|
85018
|
-
server.restart = (...args) => cleanup.restart(async () => {
|
|
85019
|
-
await restartServer(...args);
|
|
85020
|
-
if (!server.config.plugins.some((plugin) => plugin.name === "vite-plugin-cloudflare:dev")) attachContainerCleanup(server, cleanup);
|
|
85021
|
-
});
|
|
85022
|
-
const closeServer = server.close.bind(server);
|
|
85023
|
-
const closeWithCleanup = async () => {
|
|
85024
|
-
try {
|
|
85025
|
-
await closeServer();
|
|
85026
|
-
} finally {
|
|
85027
|
-
if (!cleanup.isRestarting) cleanup.cleanup();
|
|
85028
|
-
}
|
|
85029
|
-
};
|
|
85030
|
-
closeWithCleanup[containerCleanupKey] = cleanup;
|
|
85031
|
-
server.close = closeWithCleanup;
|
|
85032
|
-
}
|
|
85033
|
-
|
|
85034
84789
|
//#endregion
|
|
85035
84790
|
//#region src/containers.ts
|
|
85036
84791
|
/**
|
|
@@ -85099,7 +84854,482 @@ function getDockerPath() {
|
|
|
85099
84854
|
}
|
|
85100
84855
|
|
|
85101
84856
|
//#endregion
|
|
85102
|
-
//#region ../../node_modules/.pnpm/@cloudflare+
|
|
84857
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.3_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_1015a3e98971606dde907233c81fa8ee/node_modules/@cloudflare/cli-shared-helpers/dist/colors.mjs
|
|
84858
|
+
const { white, gray, dim, hidden, bold, cyanBright, bgCyan } = source_default;
|
|
84859
|
+
const brandColor = source_default.hex("#BD5B08");
|
|
84860
|
+
const black = source_default.hex("#111");
|
|
84861
|
+
const blue = source_default.hex("#0E838F");
|
|
84862
|
+
const bgBlue = black.bgHex("#0E838F");
|
|
84863
|
+
const red = source_default.hex("#AB2526");
|
|
84864
|
+
const bgRed = black.bgHex("#AB2526");
|
|
84865
|
+
const green = source_default.hex("#218529");
|
|
84866
|
+
const bgGreen = black.bgHex("#218529");
|
|
84867
|
+
const yellow = source_default.hex("#7F7322");
|
|
84868
|
+
const bgYellow = black.bgHex("#7F7322");
|
|
84869
|
+
|
|
84870
|
+
//#endregion
|
|
84871
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.3_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_1015a3e98971606dde907233c81fa8ee/node_modules/@cloudflare/cli-shared-helpers/dist/error.mjs
|
|
84872
|
+
/**
|
|
84873
|
+
* Error thrown when an operation is cancelled
|
|
84874
|
+
*/
|
|
84875
|
+
var CancelError = class extends Error {
|
|
84876
|
+
constructor(message, signal) {
|
|
84877
|
+
super(message);
|
|
84878
|
+
this.signal = signal;
|
|
84879
|
+
}
|
|
84880
|
+
};
|
|
84881
|
+
|
|
84882
|
+
//#endregion
|
|
84883
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.3_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_1015a3e98971606dde907233c81fa8ee/node_modules/@cloudflare/cli-shared-helpers/dist/select-list.mjs
|
|
84884
|
+
var SelectRefreshablePrompt = class extends p {
|
|
84885
|
+
options;
|
|
84886
|
+
cursor = 0;
|
|
84887
|
+
get _value() {
|
|
84888
|
+
return this.options[this.cursor];
|
|
84889
|
+
}
|
|
84890
|
+
changeValue() {
|
|
84891
|
+
this.value = this._value.value;
|
|
84892
|
+
}
|
|
84893
|
+
constructor(opts) {
|
|
84894
|
+
super(opts, false);
|
|
84895
|
+
this.options = opts.options;
|
|
84896
|
+
this.cursor = this.options.findIndex(({ value }) => value === opts.initialValue);
|
|
84897
|
+
if (this.cursor === -1) this.cursor = 0;
|
|
84898
|
+
this.changeValue();
|
|
84899
|
+
this.on("key", (c$1) => {
|
|
84900
|
+
if (c$1 !== "r") return;
|
|
84901
|
+
opts.onRefresh().then((newOptions) => {
|
|
84902
|
+
this.options = [...newOptions];
|
|
84903
|
+
this.cursor = 0;
|
|
84904
|
+
this.changeValue();
|
|
84905
|
+
const that = this;
|
|
84906
|
+
if ("render" in that && typeof that.render === "function") that.render();
|
|
84907
|
+
}).catch(() => {});
|
|
84908
|
+
});
|
|
84909
|
+
this.on("cursor", (key) => {
|
|
84910
|
+
switch (key) {
|
|
84911
|
+
case "left":
|
|
84912
|
+
case "up":
|
|
84913
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
84914
|
+
break;
|
|
84915
|
+
case "down":
|
|
84916
|
+
case "right":
|
|
84917
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
84918
|
+
break;
|
|
84919
|
+
}
|
|
84920
|
+
this.changeValue();
|
|
84921
|
+
});
|
|
84922
|
+
}
|
|
84923
|
+
};
|
|
84924
|
+
|
|
84925
|
+
//#endregion
|
|
84926
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.3_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_1015a3e98971606dde907233c81fa8ee/node_modules/@cloudflare/cli-shared-helpers/dist/streams.mjs
|
|
84927
|
+
/**
|
|
84928
|
+
* This file simply re-exports the process's writeable streams
|
|
84929
|
+
* The intention is to provide a boundary to mock in tests
|
|
84930
|
+
* Anywhere in this package that writes to stdout/stderr,
|
|
84931
|
+
* should use this module to get references to them.
|
|
84932
|
+
*/
|
|
84933
|
+
const stdout$1 = process.stdout;
|
|
84934
|
+
const stderr = process.stderr;
|
|
84935
|
+
|
|
84936
|
+
//#endregion
|
|
84937
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.3_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_1015a3e98971606dde907233c81fa8ee/node_modules/@cloudflare/cli-shared-helpers/dist/check-macos-version.mjs
|
|
84938
|
+
var import_ci_info = /* @__PURE__ */ __toESM$2(require_ci_info(), 1);
|
|
84939
|
+
|
|
84940
|
+
//#endregion
|
|
84941
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.3_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_1015a3e98971606dde907233c81fa8ee/node_modules/@cloudflare/cli-shared-helpers/dist/index.mjs
|
|
84942
|
+
const shapes = {
|
|
84943
|
+
diamond: "◇",
|
|
84944
|
+
dash: "─",
|
|
84945
|
+
radioInactive: "○",
|
|
84946
|
+
radioActive: "●",
|
|
84947
|
+
backActive: "◀",
|
|
84948
|
+
backInactive: "◁",
|
|
84949
|
+
bar: "│",
|
|
84950
|
+
leftT: "├",
|
|
84951
|
+
rigthT: "┤",
|
|
84952
|
+
arrows: {
|
|
84953
|
+
left: "‹",
|
|
84954
|
+
right: "›"
|
|
84955
|
+
},
|
|
84956
|
+
corners: {
|
|
84957
|
+
tl: "╭",
|
|
84958
|
+
bl: "╰",
|
|
84959
|
+
tr: "╮",
|
|
84960
|
+
br: "╯"
|
|
84961
|
+
}
|
|
84962
|
+
};
|
|
84963
|
+
const status = {
|
|
84964
|
+
error: bgRed(` ERROR `),
|
|
84965
|
+
warning: bgYellow(` WARNING `),
|
|
84966
|
+
info: bgBlue(` INFO `),
|
|
84967
|
+
success: bgGreen(` SUCCESS `),
|
|
84968
|
+
cancel: white.bgRed(` X `)
|
|
84969
|
+
};
|
|
84970
|
+
const space = (n$1 = 1) => {
|
|
84971
|
+
return hidden(" ".repeat(n$1));
|
|
84972
|
+
};
|
|
84973
|
+
const LOGGER_LEVELS = {
|
|
84974
|
+
none: -1,
|
|
84975
|
+
error: 0,
|
|
84976
|
+
warn: 1,
|
|
84977
|
+
info: 2,
|
|
84978
|
+
log: 3,
|
|
84979
|
+
debug: 4
|
|
84980
|
+
};
|
|
84981
|
+
let currentLogLevel = "log";
|
|
84982
|
+
function getLogLevel() {
|
|
84983
|
+
return currentLogLevel;
|
|
84984
|
+
}
|
|
84985
|
+
const logRaw = (msg) => {
|
|
84986
|
+
if (LOGGER_LEVELS[getLogLevel()] >= LOGGER_LEVELS.log) stdout$1.write(`${msg}\n`);
|
|
84987
|
+
};
|
|
84988
|
+
const format$1 = (msg, { linePrefix = gray(shapes.bar), firstLinePrefix = linePrefix, newlineBefore = false, newlineAfter = false, formatLine = (line) => white(line), multiline = true } = {}) => {
|
|
84989
|
+
const formattedLines = (multiline ? msg.split("\n") : [msg]).map((line, i$1) => (i$1 === 0 ? firstLinePrefix : linePrefix) + space() + formatLine(line));
|
|
84990
|
+
if (newlineBefore) formattedLines.unshift(linePrefix);
|
|
84991
|
+
if (newlineAfter) formattedLines.push(linePrefix);
|
|
84992
|
+
return formattedLines.join("\n");
|
|
84993
|
+
};
|
|
84994
|
+
const cancel = (msg, { shape = shapes.corners.bl, multiline = false } = {}) => {
|
|
84995
|
+
logRaw(format$1(msg, {
|
|
84996
|
+
firstLinePrefix: `${gray(shape)} ${status.cancel}`,
|
|
84997
|
+
linePrefix: gray(shapes.bar),
|
|
84998
|
+
newlineBefore: true,
|
|
84999
|
+
formatLine: (line) => dim(line),
|
|
85000
|
+
multiline
|
|
85001
|
+
}));
|
|
85002
|
+
};
|
|
85003
|
+
const stripAnsi = (str) => {
|
|
85004
|
+
const pattern = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
85005
|
+
const regex$1 = RegExp(pattern, "g");
|
|
85006
|
+
return str.replace(linkRegex, "$2").replace(regex$1, "");
|
|
85007
|
+
};
|
|
85008
|
+
const linkRegex = /\u001B\]8;;(?<url>.+)\u001B\\(?<label>.+)\u001B\]8;;\u001B\\/g;
|
|
85009
|
+
const crash = (msg, extra) => {
|
|
85010
|
+
error(msg, extra);
|
|
85011
|
+
exit(1);
|
|
85012
|
+
};
|
|
85013
|
+
const error = (msg, extra, corner = shapes.corners.bl) => {
|
|
85014
|
+
const currentLevel = getLogLevel();
|
|
85015
|
+
if (msg && LOGGER_LEVELS[currentLevel] >= LOGGER_LEVELS.error) stderr.write(`${gray(corner)} ${status.error} ${dim(msg)}\n${extra ? space() + extra + "\n" : ""}`);
|
|
85016
|
+
};
|
|
85017
|
+
|
|
85018
|
+
//#endregion
|
|
85019
|
+
//#region ../../node_modules/.pnpm/@cloudflare+cli-shared-helpers@0.3.3_vitest@5.0.4_@opentelemetry+api@1.9.1_@types+node@_1015a3e98971606dde907233c81fa8ee/node_modules/@cloudflare/cli-shared-helpers/dist/interactive.mjs
|
|
85020
|
+
const logUpdate = createLogUpdate(stdout$1);
|
|
85021
|
+
const grayBar = gray(shapes.bar);
|
|
85022
|
+
const blCorner = gray(shapes.corners.bl);
|
|
85023
|
+
const leftT = gray(shapes.leftT);
|
|
85024
|
+
function acceptDefault(promptConfig, renderers, initialValue) {
|
|
85025
|
+
const error$3 = promptConfig.validate?.(initialValue);
|
|
85026
|
+
if (error$3) {
|
|
85027
|
+
const errorMessage = error$3 instanceof Error ? error$3.message : error$3;
|
|
85028
|
+
if (promptConfig.throwOnError) throw new Error(errorMessage);
|
|
85029
|
+
else crash(errorMessage);
|
|
85030
|
+
}
|
|
85031
|
+
logRaw(renderers.submit({ value: initialValue }).join("\n"));
|
|
85032
|
+
return initialValue;
|
|
85033
|
+
}
|
|
85034
|
+
const inputPrompt = async (promptConfig) => {
|
|
85035
|
+
const renderers = {
|
|
85036
|
+
...getRenderers(promptConfig),
|
|
85037
|
+
...promptConfig.renderers
|
|
85038
|
+
};
|
|
85039
|
+
let prompt;
|
|
85040
|
+
const dispatchRender = (props, p$2) => {
|
|
85041
|
+
let state = props.state;
|
|
85042
|
+
if (state === "initial" && promptConfig.initialErrorMessage) {
|
|
85043
|
+
state = "error";
|
|
85044
|
+
props.error = promptConfig.initialErrorMessage;
|
|
85045
|
+
}
|
|
85046
|
+
return renderers[state](props, p$2).join("\n");
|
|
85047
|
+
};
|
|
85048
|
+
if (promptConfig.type === "select") {
|
|
85049
|
+
const initialValue = String(promptConfig.defaultValue);
|
|
85050
|
+
if (promptConfig.acceptDefault) return acceptDefault(promptConfig, renderers, initialValue);
|
|
85051
|
+
prompt = new nt({
|
|
85052
|
+
...promptConfig,
|
|
85053
|
+
options: promptConfig.options.filter((o) => !o.hidden),
|
|
85054
|
+
initialValue,
|
|
85055
|
+
render() {
|
|
85056
|
+
return dispatchRender(this, prompt);
|
|
85057
|
+
}
|
|
85058
|
+
});
|
|
85059
|
+
} else if (promptConfig.type === "confirm") {
|
|
85060
|
+
const initialValue = Boolean(promptConfig.defaultValue);
|
|
85061
|
+
if (promptConfig.acceptDefault) return acceptDefault(promptConfig, renderers, initialValue);
|
|
85062
|
+
prompt = new Q({
|
|
85063
|
+
...promptConfig,
|
|
85064
|
+
initialValue,
|
|
85065
|
+
active: promptConfig.activeText || "",
|
|
85066
|
+
inactive: promptConfig.inactiveText || "",
|
|
85067
|
+
render() {
|
|
85068
|
+
return dispatchRender(this, prompt);
|
|
85069
|
+
}
|
|
85070
|
+
});
|
|
85071
|
+
} else if (promptConfig.type == "multiselect") {
|
|
85072
|
+
let initialValues;
|
|
85073
|
+
if (Array.isArray(promptConfig.defaultValue)) initialValues = promptConfig.defaultValue;
|
|
85074
|
+
else if (promptConfig.defaultValue !== void 0) initialValues = [String(promptConfig.defaultValue)];
|
|
85075
|
+
if (promptConfig.acceptDefault) return acceptDefault(promptConfig, renderers, initialValues);
|
|
85076
|
+
prompt = new it({
|
|
85077
|
+
...promptConfig,
|
|
85078
|
+
options: promptConfig.options,
|
|
85079
|
+
initialValues,
|
|
85080
|
+
render() {
|
|
85081
|
+
return dispatchRender(this, prompt);
|
|
85082
|
+
}
|
|
85083
|
+
});
|
|
85084
|
+
} else if (promptConfig.type === "list") {
|
|
85085
|
+
const initialValue = String(promptConfig.defaultValue);
|
|
85086
|
+
if (promptConfig.acceptDefault) return acceptDefault(promptConfig, renderers, initialValue);
|
|
85087
|
+
prompt = new SelectRefreshablePrompt({
|
|
85088
|
+
...promptConfig,
|
|
85089
|
+
onRefresh: promptConfig.onRefresh ?? (() => Promise.resolve(promptConfig.options)),
|
|
85090
|
+
initialValue,
|
|
85091
|
+
render() {
|
|
85092
|
+
return dispatchRender(this, prompt);
|
|
85093
|
+
}
|
|
85094
|
+
});
|
|
85095
|
+
} else {
|
|
85096
|
+
const initialValue = promptConfig.initialValue ?? String(promptConfig.defaultValue ?? "");
|
|
85097
|
+
if (promptConfig.acceptDefault) return acceptDefault(promptConfig, renderers, initialValue);
|
|
85098
|
+
prompt = new at({
|
|
85099
|
+
...promptConfig,
|
|
85100
|
+
initialValue: promptConfig.initialValue,
|
|
85101
|
+
defaultValue: String(promptConfig.defaultValue ?? ""),
|
|
85102
|
+
render() {
|
|
85103
|
+
return dispatchRender(this, prompt);
|
|
85104
|
+
}
|
|
85105
|
+
});
|
|
85106
|
+
}
|
|
85107
|
+
const input$1 = await prompt.prompt();
|
|
85108
|
+
if (q(input$1)) if (promptConfig.throwOnError) throw new CancelError("Operation cancelled");
|
|
85109
|
+
else {
|
|
85110
|
+
cancel("Operation cancelled");
|
|
85111
|
+
process.exit(0);
|
|
85112
|
+
}
|
|
85113
|
+
return input$1;
|
|
85114
|
+
};
|
|
85115
|
+
const renderSubmit = (config$2, value) => {
|
|
85116
|
+
const { question, label } = config$2;
|
|
85117
|
+
if (config$2.type !== "confirm" && !value) return [`${leftT} ${question} ${dim("(skipped)")}`, `${grayBar}`];
|
|
85118
|
+
const content = config$2.type === "confirm" ? `${grayBar} ${brandColor(value)} ${dim(label)}` : `${grayBar} ${brandColor(label)} ${dim(value)}`;
|
|
85119
|
+
return [
|
|
85120
|
+
`${leftT} ${question}`,
|
|
85121
|
+
content,
|
|
85122
|
+
`${grayBar}`
|
|
85123
|
+
];
|
|
85124
|
+
};
|
|
85125
|
+
const getRenderers = (config$2) => {
|
|
85126
|
+
switch (config$2.type) {
|
|
85127
|
+
case "select": return getSelectRenderers(config$2);
|
|
85128
|
+
case "confirm": return getConfirmRenderers(config$2);
|
|
85129
|
+
case "text": return getTextRenderers(config$2);
|
|
85130
|
+
case "multiselect": return getSelectRenderers(config$2);
|
|
85131
|
+
case "list": return getSelectListRenderers(config$2);
|
|
85132
|
+
}
|
|
85133
|
+
};
|
|
85134
|
+
const getTextRenderers = (config$2) => {
|
|
85135
|
+
const { question } = config$2;
|
|
85136
|
+
const helpText = config$2.helpText ?? "";
|
|
85137
|
+
const format$4 = config$2.format ?? ((val) => String(val));
|
|
85138
|
+
const defaultValue = config$2.defaultValue?.toString() ?? "";
|
|
85139
|
+
const activeRenderer = (props) => {
|
|
85140
|
+
const { userInputWithCursor } = props;
|
|
85141
|
+
return [
|
|
85142
|
+
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
85143
|
+
`${space(2)}${format$4(userInputWithCursor || dim(defaultValue))}`,
|
|
85144
|
+
``
|
|
85145
|
+
];
|
|
85146
|
+
};
|
|
85147
|
+
return {
|
|
85148
|
+
initial: () => [
|
|
85149
|
+
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
85150
|
+
`${space(2)}${gray(format$4(defaultValue))}`,
|
|
85151
|
+
``
|
|
85152
|
+
],
|
|
85153
|
+
active: activeRenderer,
|
|
85154
|
+
error: ({ value, error: error$3 }) => [
|
|
85155
|
+
`${leftT} ${status.error} ${dim(error$3)}`,
|
|
85156
|
+
`${grayBar}`,
|
|
85157
|
+
`${blCorner} ${question} ${dim(helpText)}`,
|
|
85158
|
+
`${space(2)}${format$4(value)}`,
|
|
85159
|
+
``
|
|
85160
|
+
],
|
|
85161
|
+
submit: ({ value }) => renderSubmit(config$2, format$4(value ?? "")),
|
|
85162
|
+
cancel: activeRenderer
|
|
85163
|
+
};
|
|
85164
|
+
};
|
|
85165
|
+
const getSelectRenderers = (config$2) => {
|
|
85166
|
+
const { options, question, helpText: _helpText } = config$2;
|
|
85167
|
+
const helpText = _helpText ?? "";
|
|
85168
|
+
const maxItemsPerPage = config$2.maxItemsPerPage ?? 32;
|
|
85169
|
+
const defaultRenderer = ({ cursor: cursor$1 = 0, value }) => {
|
|
85170
|
+
const renderOption = (opt, i$1) => {
|
|
85171
|
+
const { label: optionLabel, value: optionValue } = opt;
|
|
85172
|
+
const active = i$1 === cursor$1;
|
|
85173
|
+
const isInListOfValues = Array.isArray(value) && value.includes(optionValue);
|
|
85174
|
+
const color = isInListOfValues || active ? blue : white;
|
|
85175
|
+
const text = active ? color.underline(optionLabel) : color(optionLabel);
|
|
85176
|
+
const sublabel = opt.sublabel ? color.grey(opt.sublabel) : "";
|
|
85177
|
+
const indicator = isInListOfValues || active && !Array.isArray(value) ? color(opt.activeIcon ?? shapes.radioActive) : color(opt.inactiveIcon ?? shapes.radioInactive);
|
|
85178
|
+
return `${space(2)}${indicator} ${text} ${sublabel}`;
|
|
85179
|
+
};
|
|
85180
|
+
const renderOptionCondition = (_, i$1) => {
|
|
85181
|
+
if (options.length <= maxItemsPerPage) return true;
|
|
85182
|
+
if (i$1 < cursor$1) return options.length - i$1 <= maxItemsPerPage;
|
|
85183
|
+
return cursor$1 + maxItemsPerPage > i$1;
|
|
85184
|
+
};
|
|
85185
|
+
const visibleOptions = options.filter((o) => !o.hidden);
|
|
85186
|
+
const activeOption = visibleOptions.at(cursor$1);
|
|
85187
|
+
const lines = [
|
|
85188
|
+
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
85189
|
+
`${cursor$1 > 0 && options.length > maxItemsPerPage ? `${space(2)}${dim("...")}\n` : ""}${visibleOptions.map(renderOption).filter(renderOptionCondition).join(`\n`)}${cursor$1 + maxItemsPerPage < options.length && options.length > maxItemsPerPage ? `\n${space(2)}${dim("...")}` : ""}`,
|
|
85190
|
+
``
|
|
85191
|
+
];
|
|
85192
|
+
if (activeOption?.description) {
|
|
85193
|
+
const wordSegmenter = new Intl.Segmenter("en", { granularity: "word" });
|
|
85194
|
+
const padding = space(2);
|
|
85195
|
+
const availableWidth = process.stdout.columns - stripAnsi(padding).length * 2;
|
|
85196
|
+
const description = stripAnsi(activeOption.description);
|
|
85197
|
+
const descriptionLines = [];
|
|
85198
|
+
let descriptionLineNumber = 0;
|
|
85199
|
+
for (const data$1 of wordSegmenter.segment(description)) {
|
|
85200
|
+
let line = descriptionLines[descriptionLineNumber] ?? "";
|
|
85201
|
+
if (line.length + data$1.segment.length > availableWidth) {
|
|
85202
|
+
descriptionLineNumber++;
|
|
85203
|
+
line = "";
|
|
85204
|
+
if (data$1.segment.match(/^\s+$/)) continue;
|
|
85205
|
+
}
|
|
85206
|
+
descriptionLines[descriptionLineNumber] = line + data$1.segment;
|
|
85207
|
+
}
|
|
85208
|
+
lines.push(dim(descriptionLines.map((line) => padding + line + padding).join("\n")), ``);
|
|
85209
|
+
}
|
|
85210
|
+
return lines;
|
|
85211
|
+
};
|
|
85212
|
+
return {
|
|
85213
|
+
initial: defaultRenderer,
|
|
85214
|
+
active: defaultRenderer,
|
|
85215
|
+
confirm: defaultRenderer,
|
|
85216
|
+
error: (opts, prompt) => {
|
|
85217
|
+
return [
|
|
85218
|
+
`${leftT} ${status.error} ${dim(opts.error)}`,
|
|
85219
|
+
`${grayBar}`,
|
|
85220
|
+
...defaultRenderer(opts, prompt)
|
|
85221
|
+
];
|
|
85222
|
+
},
|
|
85223
|
+
submit: ({ value }) => {
|
|
85224
|
+
if (Array.isArray(value)) return renderSubmit(config$2, options.filter((o) => value.includes(o.value)).map((o) => o.label).join(", "));
|
|
85225
|
+
return renderSubmit(config$2, options.find((o) => o.value === value)?.label);
|
|
85226
|
+
},
|
|
85227
|
+
cancel: defaultRenderer
|
|
85228
|
+
};
|
|
85229
|
+
};
|
|
85230
|
+
const getSelectListRenderers = (config$2) => {
|
|
85231
|
+
const { question, helpText: _helpText } = config$2;
|
|
85232
|
+
let options = config$2.options;
|
|
85233
|
+
const helpText = _helpText ?? "";
|
|
85234
|
+
const { rows } = stdout$1;
|
|
85235
|
+
const defaultRenderer = ({ cursor: cursor$1, value }, prompt) => {
|
|
85236
|
+
if (prompt instanceof SelectRefreshablePrompt) options = prompt.options;
|
|
85237
|
+
cursor$1 = cursor$1 ?? 0;
|
|
85238
|
+
let smallCursor = 0;
|
|
85239
|
+
const renderOption = (opt, i$1) => {
|
|
85240
|
+
const { label: optionLabel, value: optionValueAny } = opt;
|
|
85241
|
+
const optionValue = optionValueAny.toString();
|
|
85242
|
+
const active = i$1 === smallCursor;
|
|
85243
|
+
const isInListOfValues = Array.isArray(value) && value.includes(optionValue);
|
|
85244
|
+
const color = isInListOfValues || active ? blue : white;
|
|
85245
|
+
const text = active ? color.underline(optionLabel) : color(optionLabel);
|
|
85246
|
+
const indicator = isInListOfValues || active && !Array.isArray(value) ? color(shapes.radioActive) : color(shapes.radioInactive);
|
|
85247
|
+
const indicatorMargin = 2;
|
|
85248
|
+
const detailBulletpointMargin = indicatorMargin + 4;
|
|
85249
|
+
return [`${space(indicatorMargin)}${indicator} ${text}`, ...opt.details.map((detail, j$1) => `${space(detailBulletpointMargin)}${j$1 === opt.details.length - 1 ? gray(shapes.corners.bl) : grayBar} ${detail}`)];
|
|
85250
|
+
};
|
|
85251
|
+
const pages = [];
|
|
85252
|
+
let current = {
|
|
85253
|
+
size: 0,
|
|
85254
|
+
options: []
|
|
85255
|
+
};
|
|
85256
|
+
const VERTICAL_MARGIN = 6;
|
|
85257
|
+
for (const option of options) {
|
|
85258
|
+
const optionHeight = option.details.length + 1;
|
|
85259
|
+
if (current.size + optionHeight > rows - VERTICAL_MARGIN) {
|
|
85260
|
+
pages.push(current.options);
|
|
85261
|
+
current = {
|
|
85262
|
+
size: optionHeight,
|
|
85263
|
+
options: [option]
|
|
85264
|
+
};
|
|
85265
|
+
continue;
|
|
85266
|
+
}
|
|
85267
|
+
current.size += optionHeight;
|
|
85268
|
+
current.options.push(option);
|
|
85269
|
+
}
|
|
85270
|
+
if (current.size !== 0) pages.push(current.options);
|
|
85271
|
+
let isFirstPage = true;
|
|
85272
|
+
let isLastPage = false;
|
|
85273
|
+
let page = [];
|
|
85274
|
+
let len = 0;
|
|
85275
|
+
for (let i$1 = 0; i$1 < pages.length; i$1++) {
|
|
85276
|
+
const pageIter = pages[i$1];
|
|
85277
|
+
if (cursor$1 >= len && pageIter.length + len > cursor$1) {
|
|
85278
|
+
isFirstPage = i$1 === 0;
|
|
85279
|
+
isLastPage = i$1 === pages.length - 1;
|
|
85280
|
+
page = pageIter;
|
|
85281
|
+
smallCursor = cursor$1 - len;
|
|
85282
|
+
break;
|
|
85283
|
+
}
|
|
85284
|
+
len += pageIter.length;
|
|
85285
|
+
}
|
|
85286
|
+
return [
|
|
85287
|
+
`${blCorner} ${bold(question)} ${dim(helpText)}`,
|
|
85288
|
+
...!isFirstPage ? [`${space(2)}${dim("...")}`] : [],
|
|
85289
|
+
...page.map(renderOption).reduce((prev, now) => [...prev, ...now], []),
|
|
85290
|
+
...!isLastPage ? [`${space(2)}${dim("...")}`] : []
|
|
85291
|
+
];
|
|
85292
|
+
};
|
|
85293
|
+
return {
|
|
85294
|
+
initial: defaultRenderer,
|
|
85295
|
+
active: defaultRenderer,
|
|
85296
|
+
confirm: defaultRenderer,
|
|
85297
|
+
error: (opts, prompt) => {
|
|
85298
|
+
return [
|
|
85299
|
+
`${leftT} ${status.error} ${dim(opts.error)}`,
|
|
85300
|
+
`${grayBar}`,
|
|
85301
|
+
...defaultRenderer(opts, prompt)
|
|
85302
|
+
];
|
|
85303
|
+
},
|
|
85304
|
+
submit: ({ value }) => {
|
|
85305
|
+
if (Array.isArray(value)) return renderSubmit(config$2, options.filter((o) => value.includes(o.value)).map((o) => o.value).join(", "));
|
|
85306
|
+
return renderSubmit(config$2, options.find((o) => o.value === value)?.value);
|
|
85307
|
+
},
|
|
85308
|
+
cancel: defaultRenderer
|
|
85309
|
+
};
|
|
85310
|
+
};
|
|
85311
|
+
const getConfirmRenderers = (config$2) => {
|
|
85312
|
+
const { activeText, inactiveText, question, helpText: _helpText } = config$2;
|
|
85313
|
+
const helpText = _helpText ?? "";
|
|
85314
|
+
const active = activeText || "Yes";
|
|
85315
|
+
const inactive = inactiveText || "No";
|
|
85316
|
+
const defaultRenderer = ({ value }) => {
|
|
85317
|
+
const yesColor = value ? blue.underline : dim;
|
|
85318
|
+
const noColor = value ? dim : blue.underline;
|
|
85319
|
+
return [`${blCorner} ${bold(question)} ${dim(helpText)}`, `${space(2)}${yesColor(active)} / ${noColor(inactive)}`];
|
|
85320
|
+
};
|
|
85321
|
+
return {
|
|
85322
|
+
initial: defaultRenderer,
|
|
85323
|
+
active: defaultRenderer,
|
|
85324
|
+
confirm: defaultRenderer,
|
|
85325
|
+
error: defaultRenderer,
|
|
85326
|
+
submit: ({ value }) => renderSubmit(config$2, value ? "yes" : "no"),
|
|
85327
|
+
cancel: defaultRenderer
|
|
85328
|
+
};
|
|
85329
|
+
};
|
|
85330
|
+
|
|
85331
|
+
//#endregion
|
|
85332
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-auth@0.18.0_msw@2.14.6_@types+node@22.15.17_typescript@5.8.3__vites_69e32aac282690b5ef63ca4b07ec9e49/node_modules/@cloudflare/workers-auth/dist/chunk-VAZEJK55.mjs
|
|
85103
85333
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
85104
85334
|
var __defProp$1 = Object.defineProperty;
|
|
85105
85335
|
var __name$1 = (target$1, value) => __defProp$1(target$1, "name", {
|
|
@@ -85108,7 +85338,7 @@ var __name$1 = (target$1, value) => __defProp$1(target$1, "name", {
|
|
|
85108
85338
|
});
|
|
85109
85339
|
|
|
85110
85340
|
//#endregion
|
|
85111
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-auth@0.
|
|
85341
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-auth@0.18.0_msw@2.14.6_@types+node@22.15.17_typescript@5.8.3__vites_69e32aac282690b5ef63ca4b07ec9e49/node_modules/@cloudflare/workers-auth/dist/chunk-Q5KVZMHK.mjs
|
|
85112
85342
|
var import_undici$2 = require_undici();
|
|
85113
85343
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
85114
85344
|
var hasWarnedAboutDeprecatedV1ApiToken = false;
|
|
@@ -85184,6 +85414,7 @@ function validateAccountId(accountId, source) {
|
|
|
85184
85414
|
return accountId;
|
|
85185
85415
|
}
|
|
85186
85416
|
__name$1(validateAccountId, "validateAccountId");
|
|
85417
|
+
var getCloudflareAuthProfileFromEnv = getEnvironmentVariableFactory({ variableName: "CLOUDFLARE_AUTH_PROFILE" });
|
|
85187
85418
|
var getAuthDomainFromEnv = getEnvironmentVariableFactory({
|
|
85188
85419
|
variableName: "WRANGLER_AUTH_DOMAIN",
|
|
85189
85420
|
defaultValue: /* @__PURE__ */ __name$1(() => getCloudflareApiEnvironmentFromEnv() === "staging" ? "dash.staging.cloudflare.com" : "dash.cloudflare.com", "defaultValue")
|
|
@@ -85242,14 +85473,14 @@ async function domainUsesAccess(domain$1, logger$2, previewToken) {
|
|
|
85242
85473
|
logger$2.debug("Access switch not cached for:", domain$1);
|
|
85243
85474
|
try {
|
|
85244
85475
|
const controller = new AbortController();
|
|
85245
|
-
const cancel$
|
|
85476
|
+
const cancel$2 = setTimeout(() => {
|
|
85246
85477
|
controller.abort();
|
|
85247
85478
|
}, 1e3);
|
|
85248
85479
|
const output$1 = await (0, import_undici$2.fetch)(buildProbeUrl(domain$1, previewToken), {
|
|
85249
85480
|
redirect: "manual",
|
|
85250
85481
|
signal: controller.signal
|
|
85251
85482
|
});
|
|
85252
|
-
clearTimeout(cancel$
|
|
85483
|
+
clearTimeout(cancel$2);
|
|
85253
85484
|
const usesAccess = !!(output$1.status === 302 && output$1.headers.get("location")?.includes("cloudflareaccess.com"));
|
|
85254
85485
|
if (usesAccess || !previewToken) {
|
|
85255
85486
|
logger$2.debug("Caching access switch for:", domain$1);
|
|
@@ -85504,9 +85735,11 @@ function getCachedTemporaryPreviewAccount(storage) {
|
|
|
85504
85735
|
}
|
|
85505
85736
|
__name$1(getCachedTemporaryPreviewAccount, "getCachedTemporaryPreviewAccount");
|
|
85506
85737
|
async function requestPowSolution(temporaryAccountLogger, cliDisplayName) {
|
|
85738
|
+
const headers = new import_undici$2.Headers({ "Content-Type": "application/json" });
|
|
85739
|
+
addCustomApiHeaders(headers);
|
|
85507
85740
|
const response = await (0, import_undici$2.fetch)(getTemporaryPreviewChallengeUrl(), {
|
|
85508
85741
|
method: "POST",
|
|
85509
|
-
headers
|
|
85742
|
+
headers,
|
|
85510
85743
|
body: "{}"
|
|
85511
85744
|
});
|
|
85512
85745
|
if (!response.ok) throw new FatalError(`Failed to request a proof-of-work challenge (${response.status} ${response.statusText}).`, { telemetryMessage: "deploy temporary account challenge failed" });
|
|
@@ -85530,9 +85763,11 @@ async function requestPowSolution(temporaryAccountLogger, cliDisplayName) {
|
|
|
85530
85763
|
__name$1(requestPowSolution, "requestPowSolution");
|
|
85531
85764
|
async function createTemporaryPreviewAccount(temporaryAccountLogger, request$2, cliDisplayName = "Wrangler") {
|
|
85532
85765
|
const pow = await requestPowSolution(temporaryAccountLogger, cliDisplayName);
|
|
85766
|
+
const headers = new import_undici$2.Headers({ "Content-Type": "application/json" });
|
|
85767
|
+
addCustomApiHeaders(headers);
|
|
85533
85768
|
const response = await (0, import_undici$2.fetch)(getTemporaryPreviewUrl(), {
|
|
85534
85769
|
method: "POST",
|
|
85535
|
-
headers
|
|
85770
|
+
headers,
|
|
85536
85771
|
body: JSON.stringify({
|
|
85537
85772
|
termsOfService: TEMPORARY_TERMS_URLS.termsOfService,
|
|
85538
85773
|
privacyPolicy: TEMPORARY_TERMS_URLS.privacyPolicy,
|
|
@@ -86156,13 +86391,13 @@ function getPositiveNumberMember(body, key) {
|
|
|
86156
86391
|
}
|
|
86157
86392
|
__name$1(getPositiveNumberMember, "getPositiveNumberMember");
|
|
86158
86393
|
function describeUnusableResponse(response, body) {
|
|
86159
|
-
const status$
|
|
86394
|
+
const status$2 = `HTTP ${response.status} ${response.statusText}`.trim();
|
|
86160
86395
|
const description = getStringMember(body, "error_description");
|
|
86161
|
-
return description ? `${status$
|
|
86396
|
+
return description ? `${status$2}: ${description}` : status$2;
|
|
86162
86397
|
}
|
|
86163
86398
|
__name$1(describeUnusableResponse, "describeUnusableResponse");
|
|
86164
|
-
function isRetryableStatus(status$
|
|
86165
|
-
return status$
|
|
86399
|
+
function isRetryableStatus(status$2) {
|
|
86400
|
+
return status$2 >= 500 || status$2 === 429;
|
|
86166
86401
|
}
|
|
86167
86402
|
__name$1(isRetryableStatus, "isRetryableStatus");
|
|
86168
86403
|
function asDeviceAuthorizationResponse(body) {
|
|
@@ -86678,10 +86913,11 @@ function createProfileStore(args) {
|
|
|
86678
86913
|
configs: args.configs,
|
|
86679
86914
|
bindings,
|
|
86680
86915
|
resolve(resolveArgs) {
|
|
86681
|
-
|
|
86682
|
-
|
|
86683
|
-
|
|
86684
|
-
|
|
86916
|
+
const profile = resolveArgs.profile || getCloudflareAuthProfileFromEnv();
|
|
86917
|
+
if (profile) {
|
|
86918
|
+
if (profile === "default") return "default";
|
|
86919
|
+
validateProfileName(profile);
|
|
86920
|
+
return profile;
|
|
86685
86921
|
}
|
|
86686
86922
|
const dirProfile = bindings.getProfileForDirectory(resolveArgs.cwd);
|
|
86687
86923
|
if (dirProfile) return dirProfile;
|
|
@@ -86864,12 +87100,12 @@ var FILE_FORMATS = {
|
|
|
86864
87100
|
stringify: /* @__PURE__ */ __name$1((value) => JSON.stringify(value, null, " "), "stringify")
|
|
86865
87101
|
}
|
|
86866
87102
|
};
|
|
86867
|
-
function parseFile(format$
|
|
86868
|
-
return FILE_FORMATS[format$
|
|
87103
|
+
function parseFile(format$4, raw) {
|
|
87104
|
+
return FILE_FORMATS[format$4].parse(raw);
|
|
86869
87105
|
}
|
|
86870
87106
|
__name$1(parseFile, "parseFile");
|
|
86871
|
-
function stringifyFile(format$
|
|
86872
|
-
return FILE_FORMATS[format$
|
|
87107
|
+
function stringifyFile(format$4, value) {
|
|
87108
|
+
return FILE_FORMATS[format$4].stringify(value);
|
|
86873
87109
|
}
|
|
86874
87110
|
__name$1(stringifyFile, "stringifyFile");
|
|
86875
87111
|
var USER_AUTH_CONFIG_PATH = "config";
|
|
@@ -86895,10 +87131,10 @@ var FileCredentialStore = class {
|
|
|
86895
87131
|
* @param format on-disk file format (defaults to TOML for wrangler's
|
|
86896
87132
|
* historical layout; cf and other CLIs pass JSON).
|
|
86897
87133
|
*/
|
|
86898
|
-
constructor(configPath, profile, format$
|
|
87134
|
+
constructor(configPath, profile, format$4 = "toml") {
|
|
86899
87135
|
this.configPath = configPath;
|
|
86900
87136
|
this.profile = profile;
|
|
86901
|
-
this.format = format$
|
|
87137
|
+
this.format = format$4;
|
|
86902
87138
|
}
|
|
86903
87139
|
static {
|
|
86904
87140
|
__name$1(this, "FileCredentialStore");
|
|
@@ -86994,12 +87230,12 @@ var EncryptedFileCredentialStore = class {
|
|
|
86994
87230
|
* @param format on-disk format of the plaintext sibling file and the
|
|
86995
87231
|
* encrypted payload (defaults to TOML for wrangler).
|
|
86996
87232
|
*/
|
|
86997
|
-
constructor(configPath, keyProvider, onPlaintextMigration, profile, format$
|
|
87233
|
+
constructor(configPath, keyProvider, onPlaintextMigration, profile, format$4 = "toml") {
|
|
86998
87234
|
this.configPath = configPath;
|
|
86999
87235
|
this.keyProvider = keyProvider;
|
|
87000
87236
|
this.onPlaintextMigration = onPlaintextMigration;
|
|
87001
87237
|
this.profile = profile;
|
|
87002
|
-
this.format = format$
|
|
87238
|
+
this.format = format$4;
|
|
87003
87239
|
}
|
|
87004
87240
|
static {
|
|
87005
87241
|
__name$1(this, "EncryptedFileCredentialStore");
|
|
@@ -87623,7 +87859,7 @@ var AuthenticationError = class extends UserError {
|
|
|
87623
87859
|
};
|
|
87624
87860
|
|
|
87625
87861
|
//#endregion
|
|
87626
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-auth@0.
|
|
87862
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-auth@0.18.0_msw@2.14.6_@types+node@22.15.17_typescript@5.8.3__vites_69e32aac282690b5ef63ca4b07ec9e49/node_modules/@cloudflare/workers-auth/dist/chunk-PCKGSFVR.mjs
|
|
87627
87863
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
87628
87864
|
function createPreferences(getConfigPath) {
|
|
87629
87865
|
function getUserPreferencesPath() {
|
|
@@ -88268,14 +88504,14 @@ function formatDistanceToNowStrict(date$2, options) {
|
|
|
88268
88504
|
return formatDistanceStrict(date$2, constructNow(date$2), options);
|
|
88269
88505
|
}
|
|
88270
88506
|
__name$1(formatDistanceToNowStrict, "formatDistanceToNowStrict");
|
|
88271
|
-
function createFileStorage(format$
|
|
88507
|
+
function createFileStorage(format$4, getPath) {
|
|
88272
88508
|
return {
|
|
88273
88509
|
read: /* @__PURE__ */ __name$1(() => {
|
|
88274
88510
|
const filePath = getPath();
|
|
88275
88511
|
if (!existsSync(filePath)) return;
|
|
88276
88512
|
const contents = readFileSync$1(filePath);
|
|
88277
88513
|
try {
|
|
88278
|
-
return parseFile(format$
|
|
88514
|
+
return parseFile(format$4, contents);
|
|
88279
88515
|
} catch {
|
|
88280
88516
|
return;
|
|
88281
88517
|
}
|
|
@@ -88283,7 +88519,7 @@ function createFileStorage(format$3, getPath) {
|
|
|
88283
88519
|
write(config$2) {
|
|
88284
88520
|
const configPath = getPath();
|
|
88285
88521
|
mkdirSync(path__default.dirname(configPath), { recursive: true });
|
|
88286
|
-
writeFileSync(configPath, stringifyFile(format$
|
|
88522
|
+
writeFileSync(configPath, stringifyFile(format$4, config$2), {
|
|
88287
88523
|
encoding: "utf-8",
|
|
88288
88524
|
mode: 384
|
|
88289
88525
|
});
|
|
@@ -88350,7 +88586,19 @@ function createCloudflareAuth(descriptor, ctx) {
|
|
|
88350
88586
|
const NOT_LOGGED_IN_WHOAMI_TIP = `
|
|
88351
88587
|
Run \`${descriptor.commands.whoami}\` to check your current authentication status.`;
|
|
88352
88588
|
const preferences = createPreferences(descriptor.getConfigPath);
|
|
88589
|
+
const persistAccountSelection = descriptor.persistAccountSelection ?? false;
|
|
88353
88590
|
const configCache = createConfigCache(logger$2, descriptor.cacheNamespace ? { namespace: descriptor.cacheNamespace } : void 0);
|
|
88591
|
+
let accountSelection;
|
|
88592
|
+
let accountSelectionPromise;
|
|
88593
|
+
function clearAccountSelection() {
|
|
88594
|
+
accountSelection = void 0;
|
|
88595
|
+
}
|
|
88596
|
+
__name$1(clearAccountSelection, "clearAccountSelection");
|
|
88597
|
+
function purgeAccountCaches() {
|
|
88598
|
+
clearAccountSelection();
|
|
88599
|
+
configCache.purgeConfigCaches();
|
|
88600
|
+
}
|
|
88601
|
+
__name$1(purgeAccountCaches, "purgeAccountCaches");
|
|
88354
88602
|
const credentialStorage = createCredentialStorageContext({
|
|
88355
88603
|
serviceName: descriptor.keyringServiceName,
|
|
88356
88604
|
getConfigPath: descriptor.getConfigPath,
|
|
@@ -88366,7 +88614,7 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
|
|
|
88366
88614
|
isNonInteractiveOrCI,
|
|
88367
88615
|
openInBrowser: /* @__PURE__ */ __name$1((url$2) => openInBrowser(url$2, logger$2), "openInBrowser"),
|
|
88368
88616
|
hasEnvCredentials: /* @__PURE__ */ __name$1(() => getAuthFromEnv({ allowGlobalAuthKey }) !== void 0, "hasEnvCredentials"),
|
|
88369
|
-
purgeOnLoginOrLogout:
|
|
88617
|
+
purgeOnLoginOrLogout: purgeAccountCaches,
|
|
88370
88618
|
clientId: descriptor.clientId,
|
|
88371
88619
|
consent: descriptor.consent,
|
|
88372
88620
|
cliDisplayName: descriptor.displayName,
|
|
@@ -88448,6 +88696,7 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
|
|
|
88448
88696
|
}
|
|
88449
88697
|
__name$1(readAuthCredentials, "readAuthCredentials");
|
|
88450
88698
|
function writeAuthCredentials(config$2) {
|
|
88699
|
+
clearAccountSelection();
|
|
88451
88700
|
credentialStorage.storageFactory(getActiveProfile()).write(config$2);
|
|
88452
88701
|
}
|
|
88453
88702
|
__name$1(writeAuthCredentials, "writeAuthCredentials");
|
|
@@ -88457,11 +88706,28 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
|
|
|
88457
88706
|
return `${descriptor.accountCachePrefix}-${profile}.json`;
|
|
88458
88707
|
}
|
|
88459
88708
|
__name$1(getAccountCacheFileName, "getAccountCacheFileName");
|
|
88460
|
-
function
|
|
88461
|
-
|
|
88709
|
+
function retainAccountSelection(account) {
|
|
88710
|
+
accountSelection = {
|
|
88711
|
+
account,
|
|
88712
|
+
profile: getActiveProfile()
|
|
88713
|
+
};
|
|
88714
|
+
if (persistAccountSelection) configCache.saveToConfigCache(getAccountCacheFileName(), { account });
|
|
88715
|
+
}
|
|
88716
|
+
__name$1(retainAccountSelection, "retainAccountSelection");
|
|
88717
|
+
function resolveAccountSelection() {
|
|
88718
|
+
const profile = getActiveProfile();
|
|
88719
|
+
if (persistAccountSelection) {
|
|
88720
|
+
const account = getAccountFromCache();
|
|
88721
|
+
accountSelection = account ? {
|
|
88722
|
+
account,
|
|
88723
|
+
profile
|
|
88724
|
+
} : void 0;
|
|
88725
|
+
} else if (accountSelection?.profile !== profile) clearAccountSelection();
|
|
88726
|
+
return accountSelection?.account;
|
|
88462
88727
|
}
|
|
88463
|
-
__name$1(
|
|
88728
|
+
__name$1(resolveAccountSelection, "resolveAccountSelection");
|
|
88464
88729
|
function getAccountFromCache() {
|
|
88730
|
+
if (!persistAccountSelection) return;
|
|
88465
88731
|
return configCache.getConfigCache(getAccountCacheFileName()).account;
|
|
88466
88732
|
}
|
|
88467
88733
|
__name$1(getAccountFromCache, "getAccountFromCache");
|
|
@@ -88473,12 +88739,12 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
|
|
|
88473
88739
|
while (getMoreResults) {
|
|
88474
88740
|
queryParams = new URLSearchParams$1(queryParams);
|
|
88475
88741
|
queryParams.set("page", String(page));
|
|
88476
|
-
const { response: json$1, status: status$
|
|
88742
|
+
const { response: json$1, status: status$2 } = await fetchInternalBase(complianceConfig, resource, {}, ctx.userAgent, logger$2, queryParams, void 0, credentials);
|
|
88477
88743
|
if (json$1.success) {
|
|
88478
88744
|
results.push(...json$1.result);
|
|
88479
88745
|
if (hasMorePages(json$1.result_info)) page = page + 1;
|
|
88480
88746
|
else getMoreResults = false;
|
|
88481
|
-
} else throwFetchError(resource, json$1, status$
|
|
88747
|
+
} else throwFetchError(resource, json$1, status$2);
|
|
88482
88748
|
}
|
|
88483
88749
|
return results;
|
|
88484
88750
|
}
|
|
@@ -88495,14 +88761,14 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
|
|
|
88495
88761
|
if (getErrorCode(membershipsRes.reason) === 9106) throw new UserError(`Failed to automatically retrieve account IDs for the logged in user.
|
|
88496
88762
|
You may have incorrect permissions on your API token, or an environment variable such as CLOUDFLARE_API_TOKEN, CLOUDFLARE_API_KEY, or CLOUDFLARE_EMAIL may be set to an invalid value.
|
|
88497
88763
|
Check your environment and unset or correct any Cloudflare credential variables, or run \`${descriptor.commands.login}\` to re-authenticate.
|
|
88498
|
-
You can also skip this account check by adding an
|
|
88764
|
+
You can also skip this account check by adding an account ID to your ${descriptor.getConfigFileLabel()} file, or by setting the value of CLOUDFLARE_ACCOUNT_ID`, { telemetryMessage: "user account fetch permission denied" });
|
|
88499
88765
|
throw new UserError(`Failed to automatically retrieve account IDs for the logged in user.
|
|
88500
|
-
You may have incorrect permissions on your API token, or your authentication may have expired. Try running \`${descriptor.commands.login}\` to re-authenticate. You can also skip this account check by adding an
|
|
88766
|
+
You may have incorrect permissions on your API token, or your authentication may have expired. Try running \`${descriptor.commands.login}\` to re-authenticate. You can also skip this account check by adding an account ID to your ${descriptor.getConfigFileLabel()} file, or by setting the value of CLOUDFLARE_ACCOUNT_ID`, { telemetryMessage: "user account fetch permission denied" });
|
|
88501
88767
|
} else throw membershipsRes.reason;
|
|
88502
88768
|
const membershipIds = new Set(membershipsRes.value.map((m) => m.account.id));
|
|
88503
88769
|
const usableAccounts = accountsRes.value.filter((a) => membershipIds.has(a.id));
|
|
88504
88770
|
if (usableAccounts.length === 0 && throwOnEmpty) throw new UserError(`Failed to automatically retrieve account IDs for the logged in user.
|
|
88505
|
-
In a non-interactive environment, it is mandatory to specify an account ID, either by assigning its value to CLOUDFLARE_ACCOUNT_ID, or
|
|
88771
|
+
In a non-interactive environment, it is mandatory to specify an account ID, either by assigning its value to CLOUDFLARE_ACCOUNT_ID, or in your ${descriptor.getConfigFileLabel()} file.
|
|
88506
88772
|
Alternatively, try running \`${descriptor.commands.login}\` to re-authenticate.`, { telemetryMessage: "user account fetch empty" });
|
|
88507
88773
|
return usableAccounts;
|
|
88508
88774
|
}
|
|
@@ -88510,18 +88776,16 @@ Alternatively, try running \`${descriptor.commands.login}\` to re-authenticate.`
|
|
|
88510
88776
|
function getActiveAccountId(config$2) {
|
|
88511
88777
|
const temporaryAccount = oauthFlow.getActiveTemporaryAccount();
|
|
88512
88778
|
if (temporaryAccount) return temporaryAccount.account.id;
|
|
88513
|
-
if (config$2.account_id) return validateAccountId(config$2.account_id, `set
|
|
88779
|
+
if (config$2.account_id) return validateAccountId(config$2.account_id, `set in your ${descriptor.getConfigFileLabel()} file`);
|
|
88514
88780
|
const envAccountId = getCloudflareAccountIdFromEnv();
|
|
88515
88781
|
if (envAccountId) return envAccountId;
|
|
88516
|
-
return
|
|
88782
|
+
return resolveAccountSelection()?.id;
|
|
88517
88783
|
}
|
|
88518
88784
|
__name$1(getActiveAccountId, "getActiveAccountId");
|
|
88519
|
-
async function
|
|
88520
|
-
const activeAccountId = getActiveAccountId(config$2);
|
|
88521
|
-
if (activeAccountId) return activeAccountId;
|
|
88785
|
+
async function selectAccountId(config$2) {
|
|
88522
88786
|
const accounts = await fetchAllAccounts(config$2);
|
|
88523
88787
|
if (accounts.length === 1) {
|
|
88524
|
-
|
|
88788
|
+
retainAccountSelection({
|
|
88525
88789
|
id: accounts[0].id,
|
|
88526
88790
|
name: accounts[0].name
|
|
88527
88791
|
});
|
|
@@ -88534,7 +88798,7 @@ Alternatively, try running \`${descriptor.commands.login}\` to re-authenticate.`
|
|
|
88534
88798
|
})) });
|
|
88535
88799
|
const account = accounts.find((a) => a.id === accountID);
|
|
88536
88800
|
if (!account) throw new Error("Selected account not found in accounts list");
|
|
88537
|
-
|
|
88801
|
+
retainAccountSelection({
|
|
88538
88802
|
id: account.id,
|
|
88539
88803
|
name: account.name
|
|
88540
88804
|
});
|
|
@@ -88543,13 +88807,22 @@ Alternatively, try running \`${descriptor.commands.login}\` to re-authenticate.`
|
|
|
88543
88807
|
if (ctx.isNoDefaultValueProvidedError(e)) {
|
|
88544
88808
|
const redactAccountName = isCI();
|
|
88545
88809
|
throw new UserError(`More than one account available but unable to select one in non-interactive mode.
|
|
88546
|
-
Please set the appropriate
|
|
88810
|
+
Please set the appropriate account ID in your ${descriptor.getConfigFileLabel()} file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable.
|
|
88547
88811
|
Available accounts are (\`<name>\`: \`<account_id>\`):
|
|
88548
88812
|
${accounts.map((account) => ` \`${redactAccountName ? "(redacted)" : account.name}\`: \`${account.id}\``).join("\n")}`, { telemetryMessage: "user account selection unavailable" });
|
|
88549
88813
|
}
|
|
88550
88814
|
throw e;
|
|
88551
88815
|
}
|
|
88552
88816
|
}
|
|
88817
|
+
__name$1(selectAccountId, "selectAccountId");
|
|
88818
|
+
async function getOrSelectAccountId(config$2) {
|
|
88819
|
+
const activeAccountId = getActiveAccountId(config$2);
|
|
88820
|
+
if (activeAccountId) return activeAccountId;
|
|
88821
|
+
accountSelectionPromise ??= selectAccountId(config$2).finally(() => {
|
|
88822
|
+
accountSelectionPromise = void 0;
|
|
88823
|
+
});
|
|
88824
|
+
return accountSelectionPromise;
|
|
88825
|
+
}
|
|
88553
88826
|
__name$1(getOrSelectAccountId, "getOrSelectAccountId");
|
|
88554
88827
|
async function requireAuth(config$2) {
|
|
88555
88828
|
if (oauthFlow.isTemporaryAllowed()) {
|
|
@@ -88595,10 +88868,10 @@ __name$1(createCloudflareAuth, "createCloudflareAuth");
|
|
|
88595
88868
|
var DIRECTORY_BINDINGS_FILE = "profiles/directory-bindings.json";
|
|
88596
88869
|
var ENCRYPTED_PROFILE_CONFIG_EXTENSION = ".enc";
|
|
88597
88870
|
function createCloudflareProfileStore(ctx) {
|
|
88598
|
-
const { logger: logger$2, getConfigPath, keyringServiceName, format: format$
|
|
88599
|
-
const plaintextExtension = `.${format$
|
|
88871
|
+
const { logger: logger$2, getConfigPath, keyringServiceName, format: format$4 } = ctx;
|
|
88872
|
+
const plaintextExtension = `.${format$4}`;
|
|
88600
88873
|
function plaintextPath(profile) {
|
|
88601
|
-
return getAuthConfigFilePath$2(getConfigPath(), profile, format$
|
|
88874
|
+
return getAuthConfigFilePath$2(getConfigPath(), profile, format$4);
|
|
88602
88875
|
}
|
|
88603
88876
|
__name$1(plaintextPath, "plaintextPath");
|
|
88604
88877
|
function encryptedPath(profile) {
|
|
@@ -88626,9 +88899,9 @@ function createCloudflareProfileStore(ctx) {
|
|
|
88626
88899
|
serviceName: keyringServiceName,
|
|
88627
88900
|
configPath: getConfigPath(),
|
|
88628
88901
|
profile,
|
|
88629
|
-
format: format$
|
|
88902
|
+
format: format$4
|
|
88630
88903
|
});
|
|
88631
|
-
createFileStorage(format$
|
|
88904
|
+
createFileStorage(format$4, () => plaintextPath(profile)).clear();
|
|
88632
88905
|
if (encryptedFileExisted && !backendAvailable) logger$2.warn(`Removed the credential files for profile "${profile}", but the keyring backend was not reachable on this host so its keyring entry could not be cleared. Clear it manually if it persists.`);
|
|
88633
88906
|
}
|
|
88634
88907
|
};
|
|
@@ -88657,7 +88930,7 @@ function createCloudflareProfileStore(ctx) {
|
|
|
88657
88930
|
}
|
|
88658
88931
|
__name$1(createCloudflareProfileStore, "createCloudflareProfileStore");
|
|
88659
88932
|
function createKeyringPreference(deps) {
|
|
88660
|
-
const { loginCommand, createProfileCommand, keyringServiceName, getConfigPath, format: format$
|
|
88933
|
+
const { loginCommand, createProfileCommand, keyringServiceName, getConfigPath, format: format$4, preferences } = deps;
|
|
88661
88934
|
const { readUserPreferences: readUserPreferences$2, updateUserPreferences: updateUserPreferences$2 } = preferences;
|
|
88662
88935
|
function describeProfile(profile) {
|
|
88663
88936
|
return profile ?? "default";
|
|
@@ -88670,7 +88943,7 @@ function createKeyringPreference(deps) {
|
|
|
88670
88943
|
logger: logger$2,
|
|
88671
88944
|
getConfigPath,
|
|
88672
88945
|
keyringServiceName,
|
|
88673
|
-
format: format$
|
|
88946
|
+
format: format$4
|
|
88674
88947
|
});
|
|
88675
88948
|
for (const name of profileStore.configs.list()) {
|
|
88676
88949
|
try {
|
|
@@ -88693,7 +88966,7 @@ function createKeyringPreference(deps) {
|
|
|
88693
88966
|
serviceName: keyringServiceName,
|
|
88694
88967
|
configPath: getConfigPath(),
|
|
88695
88968
|
profile,
|
|
88696
|
-
format: format$
|
|
88969
|
+
format: format$4
|
|
88697
88970
|
});
|
|
88698
88971
|
cleared.push(describeProfile(profile));
|
|
88699
88972
|
if (!backendAvailable) unreachable.push(describeProfile(profile));
|
|
@@ -88730,9 +89003,9 @@ function createKeyringPreference(deps) {
|
|
|
88730
89003
|
}
|
|
88731
89004
|
__name$1(createKeyringPreference, "createKeyringPreference");
|
|
88732
89005
|
function createAuthConfigFileHelpers(deps) {
|
|
88733
|
-
const { getConfigPath, format: format$
|
|
89006
|
+
const { getConfigPath, format: format$4 } = deps;
|
|
88734
89007
|
function getAuthConfigFilePath2(profile) {
|
|
88735
|
-
return getAuthConfigFilePath$2(getConfigPath(), profile, format$
|
|
89008
|
+
return getAuthConfigFilePath$2(getConfigPath(), profile, format$4);
|
|
88736
89009
|
}
|
|
88737
89010
|
__name$1(getAuthConfigFilePath2, "getAuthConfigFilePath");
|
|
88738
89011
|
function getEncryptedAuthConfigFilePath2(profile) {
|
|
@@ -88740,7 +89013,7 @@ function createAuthConfigFileHelpers(deps) {
|
|
|
88740
89013
|
}
|
|
88741
89014
|
__name$1(getEncryptedAuthConfigFilePath2, "getEncryptedAuthConfigFilePath");
|
|
88742
89015
|
function defaultAuthConfigStorage$2(profile) {
|
|
88743
|
-
return createFileStorage(format$
|
|
89016
|
+
return createFileStorage(format$4, () => getAuthConfigFilePath2(profile));
|
|
88744
89017
|
}
|
|
88745
89018
|
__name$1(defaultAuthConfigStorage$2, "defaultAuthConfigStorage");
|
|
88746
89019
|
function writeAuthConfigFile$2(config$2, profile) {
|
|
@@ -88762,7 +89035,7 @@ function createAuthConfigFileHelpers(deps) {
|
|
|
88762
89035
|
__name$1(createAuthConfigFileHelpers, "createAuthConfigFileHelpers");
|
|
88763
89036
|
|
|
88764
89037
|
//#endregion
|
|
88765
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-auth@0.
|
|
89038
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-auth@0.18.0_msw@2.14.6_@types+node@22.15.17_typescript@5.8.3__vites_69e32aac282690b5ef63ca4b07ec9e49/node_modules/@cloudflare/workers-auth/dist/cf/index.mjs
|
|
88766
89039
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
88767
89040
|
var CF_KEYRING_SERVICE_NAME = "cloudflare";
|
|
88768
89041
|
var CF_CLI_NAME = "cf";
|
|
@@ -88829,7 +89102,6 @@ var CF_CLIENT_REGISTERED_SCOPES = [
|
|
|
88829
89102
|
"email_sending:read",
|
|
88830
89103
|
"email_sending:write",
|
|
88831
89104
|
"firstpartytags:write",
|
|
88832
|
-
"hyperdrive-planetscale:setup",
|
|
88833
89105
|
"images:read",
|
|
88834
89106
|
"images:write",
|
|
88835
89107
|
"lb:edit",
|
|
@@ -89083,6 +89355,7 @@ var CF_CLIENT_REGISTERED_SCOPES = [
|
|
|
89083
89355
|
"fraud-feedback.write",
|
|
89084
89356
|
"healthcheck.read",
|
|
89085
89357
|
"healthcheck.write",
|
|
89358
|
+
"hyperdrive-planetscale.setup",
|
|
89086
89359
|
"http-applications.read",
|
|
89087
89360
|
"http-applications.write",
|
|
89088
89361
|
"http-ddos-managed-ruleset.read",
|
|
@@ -89272,19 +89545,16 @@ var CF_CLIENT_REGISTERED_SCOPES = [
|
|
|
89272
89545
|
"zone.read",
|
|
89273
89546
|
"zone.write"
|
|
89274
89547
|
];
|
|
89275
|
-
var
|
|
89548
|
+
var CF_UNGRANTABLE_SCOPE_SET = new Set([
|
|
89276
89549
|
"billing:read",
|
|
89277
89550
|
"billing:write",
|
|
89278
89551
|
"email_routing:read",
|
|
89279
89552
|
"email_sending:read",
|
|
89280
89553
|
"notebook-managed:read",
|
|
89281
89554
|
"oauth_account_ssl_and_certificates_write"
|
|
89282
|
-
];
|
|
89283
|
-
var CF_EXPLICIT_ONLY_SCOPES = ["hyperdrive-planetscale:setup"];
|
|
89284
|
-
var CF_UNGRANTABLE_SCOPE_SET = new Set(CF_REGISTERED_BUT_UNGRANTABLE_SCOPES);
|
|
89555
|
+
]);
|
|
89285
89556
|
var CF_REQUESTABLE_SCOPES = CF_CLIENT_REGISTERED_SCOPES.filter((scope) => !CF_UNGRANTABLE_SCOPE_SET.has(scope));
|
|
89286
|
-
var
|
|
89287
|
-
var DefaultScopeKeys$1 = CF_REQUESTABLE_SCOPES.filter((scope) => !CF_EXPLICIT_ONLY_SCOPE_SET.has(scope));
|
|
89557
|
+
var DefaultScopeKeys$1 = [...CF_REQUESTABLE_SCOPES];
|
|
89288
89558
|
function setLoginScopeKeys$1(scopes) {
|
|
89289
89559
|
DefaultScopeKeys$1 = scopes;
|
|
89290
89560
|
}
|
|
@@ -89333,7 +89603,7 @@ var CF_CLI = {
|
|
|
89333
89603
|
fileFormat: "json",
|
|
89334
89604
|
accountCachePrefix: "cloudflare-account",
|
|
89335
89605
|
cacheNamespace: "cloudflare",
|
|
89336
|
-
getConfigFileLabel: /* @__PURE__ */ __name$1(() => "
|
|
89606
|
+
getConfigFileLabel: /* @__PURE__ */ __name$1(() => "cloudflare.config.ts", "getConfigFileLabel"),
|
|
89337
89607
|
getDefaultScopeKeys: /* @__PURE__ */ __name$1(() => DefaultScopeKeys$1, "getDefaultScopeKeys")
|
|
89338
89608
|
};
|
|
89339
89609
|
var cfPreferences = createPreferences(getCfConfigPath);
|
|
@@ -89365,7 +89635,7 @@ function setKeyringPreference$1(enabled, ctx) {
|
|
|
89365
89635
|
__name$1(setKeyringPreference$1, "setKeyringPreference");
|
|
89366
89636
|
|
|
89367
89637
|
//#endregion
|
|
89368
|
-
//#region ../../node_modules/.pnpm/@cloudflare+workers-auth@0.
|
|
89638
|
+
//#region ../../node_modules/.pnpm/@cloudflare+workers-auth@0.18.0_msw@2.14.6_@types+node@22.15.17_typescript@5.8.3__vites_69e32aac282690b5ef63ca4b07ec9e49/node_modules/@cloudflare/workers-auth/dist/wrangler/index.mjs
|
|
89369
89639
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
89370
89640
|
var DefaultScopes = {
|
|
89371
89641
|
"k2.read": "See K2 stream configurations and bind existing streams to Workers.",
|
|
@@ -89458,6 +89728,7 @@ var WRANGLER_CLI = {
|
|
|
89458
89728
|
getConfigPath: getGlobalConfigPath,
|
|
89459
89729
|
getTemporaryAccountConfigPath: getTemporaryPreviewAccountConfigPath,
|
|
89460
89730
|
fileFormat: "toml",
|
|
89731
|
+
persistAccountSelection: true,
|
|
89461
89732
|
accountCachePrefix: "wrangler-account",
|
|
89462
89733
|
getConfigFileLabel: /* @__PURE__ */ __name$1(() => configFileName(void 0), "getConfigFileLabel"),
|
|
89463
89734
|
getDefaultScopeKeys: /* @__PURE__ */ __name$1(() => DefaultScopeKeys, "getDefaultScopeKeys")
|
|
@@ -89491,7 +89762,7 @@ function setKeyringPreference(enabled, ctx) {
|
|
|
89491
89762
|
__name$1(setKeyringPreference, "setKeyringPreference");
|
|
89492
89763
|
|
|
89493
89764
|
//#endregion
|
|
89494
|
-
//#region ../../node_modules/.pnpm/@cloudflare+deploy-helpers@0.
|
|
89765
|
+
//#region ../../node_modules/.pnpm/@cloudflare+deploy-helpers@0.26.2_@types+node@22.15.17_vitest@5.0.4_@opentelemetry+api@_fcf0f41b380f341c027ce71b7f886269/node_modules/@cloudflare/deploy-helpers/dist/chunk-U6NEESU5.mjs
|
|
89495
89766
|
const require$1 = createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
89496
89767
|
var __defProp = Object.defineProperty;
|
|
89497
89768
|
var __name = (target$1, value) => __defProp(target$1, "name", {
|
|
@@ -89539,8 +89810,8 @@ var require_command_exists$1 = /* @__PURE__ */ __commonJS$2({ "../../node_module
|
|
|
89539
89810
|
var commandExistsUnix = function(commandName, cleanedCommandName, callback$1) {
|
|
89540
89811
|
fileNotExists(commandName, function(isFile) {
|
|
89541
89812
|
if (!isFile) {
|
|
89542
|
-
exec("command -v " + cleanedCommandName + " 2>/dev/null && { echo >&1 " + cleanedCommandName + "; exit 0; }", function(error$3, stdout$
|
|
89543
|
-
callback$1(null, !!stdout$
|
|
89813
|
+
exec("command -v " + cleanedCommandName + " 2>/dev/null && { echo >&1 " + cleanedCommandName + "; exit 0; }", function(error$3, stdout$3, stderr$2) {
|
|
89814
|
+
callback$1(null, !!stdout$3);
|
|
89544
89815
|
});
|
|
89545
89816
|
return;
|
|
89546
89817
|
}
|
|
@@ -89613,7 +89884,7 @@ var require_command_exists = /* @__PURE__ */ __commonJS$2({ "../../node_modules/
|
|
|
89613
89884
|
}) });
|
|
89614
89885
|
|
|
89615
89886
|
//#endregion
|
|
89616
|
-
//#region ../../node_modules/.pnpm/@cloudflare+deploy-helpers@0.
|
|
89887
|
+
//#region ../../node_modules/.pnpm/@cloudflare+deploy-helpers@0.26.2_@types+node@22.15.17_vitest@5.0.4_@opentelemetry+api@_fcf0f41b380f341c027ce71b7f886269/node_modules/@cloudflare/deploy-helpers/dist/chunk-DSGVRFIS.mjs
|
|
89617
89888
|
var import_undici$1 = require_undici();
|
|
89618
89889
|
var import_command_exists = require_command_exists();
|
|
89619
89890
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
@@ -90234,7 +90505,7 @@ function getRemoteBindingsAuthHook(auth, accountId, profileDir, logger$1$1) {
|
|
|
90234
90505
|
apiToken: remoteBindingsAuth.requireApiToken()
|
|
90235
90506
|
});
|
|
90236
90507
|
}
|
|
90237
|
-
var ProxyServerWorker_default = "// ../../node_modules/.pnpm/capnweb@0.12.0/node_modules/capnweb/dist/index-workers.js\nimport * as cfw from \"cloudflare:workers\";\nvar WORKERS_MODULE_SYMBOL = /* @__PURE__ */ Symbol(\"workers-module\");\nglobalThis[WORKERS_MODULE_SYMBOL] = cfw;\nif (!Symbol.dispose) Symbol.dispose = /* @__PURE__ */ Symbol.for(\"dispose\");\nif (!Symbol.asyncDispose) Symbol.asyncDispose = /* @__PURE__ */ Symbol.for(\"asyncDispose\");\nif (!Promise.withResolvers) Promise.withResolvers = function() {\n let resolve;\n let reject;\n return {\n promise: new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n }),\n resolve,\n reject\n };\n};\nvar workersModule = globalThis[WORKERS_MODULE_SYMBOL];\nvar RpcTarget$1 = workersModule ? workersModule.RpcTarget : class {\n};\nvar AsyncFunction = (async function() {\n}).constructor;\nvar BUFFER_PROTOTYPE = typeof Buffer !== \"undefined\" ? Buffer.prototype : void 0;\nfunction typeForRpc(value) {\n switch (typeof value) {\n case \"boolean\":\n case \"number\":\n case \"string\":\n return \"primitive\";\n case \"undefined\":\n return \"undefined\";\n case \"object\":\n case \"function\":\n break;\n case \"bigint\":\n return \"bigint\";\n default:\n return \"unsupported\";\n }\n if (value === null) return \"primitive\";\n let prototype = Object.getPrototypeOf(value);\n switch (prototype) {\n case Object.prototype:\n return \"object\";\n case Function.prototype:\n case AsyncFunction.prototype:\n return \"function\";\n case Array.prototype:\n return \"array\";\n case Date.prototype:\n return \"date\";\n case Uint8Array.prototype:\n case BUFFER_PROTOTYPE:\n case ArrayBuffer.prototype:\n case DataView.prototype:\n case Int8Array.prototype:\n case Uint8ClampedArray.prototype:\n case Int16Array.prototype:\n case Uint16Array.prototype:\n case Int32Array.prototype:\n case Uint32Array.prototype:\n case BigInt64Array.prototype:\n case BigUint64Array.prototype:\n case Float32Array.prototype:\n case Float64Array.prototype:\n return \"bytes\";\n case WritableStream.prototype:\n return \"writable\";\n case ReadableStream.prototype:\n return \"readable\";\n case URL.prototype:\n return \"url\";\n case Headers.prototype:\n return \"headers\";\n case Request.prototype:\n return \"request\";\n case Response.prototype:\n return \"response\";\n case Blob.prototype:\n return \"blob\";\n case RpcStub$1.prototype:\n return \"stub\";\n case RpcPromise$1.prototype:\n return \"rpc-promise\";\n default:\n if (workersModule) {\n if (prototype == workersModule.RpcStub.prototype || value instanceof workersModule.ServiceStub) return \"rpc-target\";\n else if (prototype == workersModule.RpcPromise.prototype || prototype == workersModule.RpcProperty.prototype) return \"rpc-thenable\";\n }\n if (value instanceof RpcTarget$1) return \"rpc-target\";\n if (value instanceof Error) return \"error\";\n return \"unsupported\";\n }\n}\nfunction mapNotLoaded() {\n throw new Error(\"RPC map() implementation was not loaded.\");\n}\nvar mapImpl = {\n applyMap: mapNotLoaded,\n sendMap: mapNotLoaded\n};\nfunction streamNotLoaded() {\n throw new Error(\"Stream implementation was not loaded.\");\n}\nvar streamImpl = {\n createWritableStreamHook: streamNotLoaded,\n createWritableStreamFromHook: streamNotLoaded,\n createReadableStreamHook: streamNotLoaded\n};\nvar StubHook = class {\n stream(path, args) {\n let hook = this.call(path, args);\n let pulled;\n try {\n pulled = hook.pull();\n } catch (err) {\n hook.dispose();\n throw err;\n }\n let promise;\n if (pulled instanceof Promise) promise = pulled.then((p) => {\n p.dispose();\n });\n else {\n pulled.dispose();\n promise = Promise.resolve();\n }\n return { promise };\n }\n};\nvar ErrorStubHook = class extends StubHook {\n error;\n constructor(error) {\n super();\n this.error = error;\n }\n call(path, args) {\n args.dispose();\n return this;\n }\n map(path, captures, instructions) {\n for (let cap of captures) cap.dispose();\n return this;\n }\n get(path) {\n return this;\n }\n dup() {\n return this;\n }\n pull() {\n return Promise.reject(this.error);\n }\n ignoreUnhandledRejections() {\n }\n dispose() {\n }\n onBroken(callback) {\n try {\n callback(this.error);\n } catch (err) {\n Promise.resolve(err);\n }\n }\n};\nvar DISPOSED_HOOK = new ErrorStubHook(/* @__PURE__ */ new Error(\"Attempted to use RPC stub after it has been disposed.\"));\nvar doCall = (hook, path, params) => {\n return hook.call(path, params);\n};\nfunction withCallInterceptor(interceptor, callback) {\n let oldValue = doCall;\n doCall = interceptor;\n try {\n return callback();\n } finally {\n doCall = oldValue;\n }\n}\nvar RAW_STUB = /* @__PURE__ */ Symbol(\"realStub\");\nvar PROXY_HANDLERS = {\n apply(target, thisArg, argumentsList) {\n let stub = target.raw;\n return new RpcPromise$1(doCall(stub.hook, stub.pathIfPromise || [], RpcPayload.fromAppParams(argumentsList)), []);\n },\n get(target, prop, receiver) {\n let stub = target.raw;\n if (prop === RAW_STUB) return stub;\n else if (prop in RpcPromise$1.prototype) return stub[prop];\n else if (typeof prop === \"string\") return new RpcPromise$1(stub.hook, stub.pathIfPromise ? [...stub.pathIfPromise, prop] : [prop]);\n else if (prop === Symbol.dispose && (!stub.pathIfPromise || stub.pathIfPromise.length == 0)) return () => {\n stub.hook.dispose();\n stub.hook = DISPOSED_HOOK;\n };\n else return;\n },\n has(target, prop) {\n let stub = target.raw;\n if (prop === RAW_STUB) return true;\n else if (prop in RpcPromise$1.prototype) return prop in stub;\n else if (typeof prop === \"string\") return true;\n else if (prop === Symbol.dispose && (!stub.pathIfPromise || stub.pathIfPromise.length == 0)) return true;\n else return false;\n },\n construct(target, args) {\n throw new Error(\"An RPC stub cannot be used as a constructor.\");\n },\n defineProperty(target, property, attributes) {\n throw new Error(\"Can't define properties on RPC stubs.\");\n },\n deleteProperty(target, p) {\n throw new Error(\"Can't delete properties on RPC stubs.\");\n },\n getOwnPropertyDescriptor(target, p) {\n },\n getPrototypeOf(target) {\n return Object.getPrototypeOf(target.raw);\n },\n isExtensible(target) {\n return false;\n },\n ownKeys(target) {\n return [];\n },\n preventExtensions(target) {\n return true;\n },\n set(target, p, newValue, receiver) {\n throw new Error(\"Can't assign properties on RPC stubs.\");\n },\n setPrototypeOf(target, v) {\n throw new Error(\"Can't override prototype of RPC stubs.\");\n }\n};\nvar RpcStub$1 = class RpcStub$12 extends RpcTarget$1 {\n constructor(hook, pathIfPromise) {\n super();\n if (!(hook instanceof StubHook)) {\n let value = hook;\n if (value instanceof RpcTarget$1 || value instanceof Function) hook = TargetStubHook.create(value, void 0);\n else hook = new PayloadStubHook(RpcPayload.fromAppReturn(value));\n if (pathIfPromise) throw new TypeError(\"RpcStub constructor expected one argument, received two.\");\n }\n this.hook = hook;\n this.pathIfPromise = pathIfPromise;\n let func = () => {\n };\n func.raw = this;\n return new Proxy(func, PROXY_HANDLERS);\n }\n hook;\n pathIfPromise;\n dup() {\n let target = this[RAW_STUB];\n if (target.pathIfPromise) return new RpcStub$12(target.hook.get(target.pathIfPromise));\n else return new RpcStub$12(target.hook.dup());\n }\n onRpcBroken(callback) {\n this[RAW_STUB].hook.onBroken(callback);\n }\n map(func) {\n let { hook, pathIfPromise } = this[RAW_STUB];\n return mapImpl.sendMap(hook, pathIfPromise || [], func);\n }\n toString() {\n return \"[object RpcStub]\";\n }\n};\nvar RpcPromise$1 = class extends RpcStub$1 {\n constructor(hook, pathIfPromise) {\n if (hook instanceof StubHook) super(hook, pathIfPromise ?? []);\n else {\n if (pathIfPromise !== void 0) throw new TypeError(\"RpcPromise constructor expected one argument, received two.\");\n let kind = typeForRpc(hook);\n if (kind === \"rpc-promise\") {\n let raw = unwrapStubAndPath(hook);\n if (raw.pathIfPromise.length > 0) super(raw.hook, raw.pathIfPromise);\n else {\n let adopted = raw.hook;\n raw.hook = DISPOSED_HOOK;\n super(adopted, []);\n }\n } else if (kind === \"rpc-thenable\") super(TargetStubHook.create(hook, void 0), []);\n else {\n let promiseHook = new PromiseStubHook(Promise.resolve(hook).then((value) => new PayloadStubHook(RpcPayload.fromAppReturn(value))));\n promiseHook.ignoreUnhandledRejections();\n super(promiseHook, []);\n }\n }\n }\n then(onfulfilled, onrejected) {\n return pullPromise(this).then(...arguments);\n }\n catch(onrejected) {\n return pullPromise(this).catch(...arguments);\n }\n finally(onfinally) {\n return pullPromise(this).finally(...arguments);\n }\n toString() {\n return \"[object RpcPromise]\";\n }\n};\nfunction unwrapStubTakingOwnership(stub) {\n let { hook, pathIfPromise } = stub[RAW_STUB];\n if (pathIfPromise && pathIfPromise.length > 0) return hook.get(pathIfPromise);\n else return hook;\n}\nfunction unwrapStubAndDup(stub) {\n let { hook, pathIfPromise } = stub[RAW_STUB];\n if (pathIfPromise) return hook.get(pathIfPromise);\n else return hook.dup();\n}\nfunction unwrapStubNoProperties(stub) {\n let { hook, pathIfPromise } = stub[RAW_STUB];\n if (pathIfPromise && pathIfPromise.length > 0) return;\n return hook;\n}\nfunction unwrapStubOrParent(stub) {\n return stub[RAW_STUB].hook;\n}\nfunction unwrapStubAndPath(stub) {\n return stub[RAW_STUB];\n}\nasync function pullPromise(promise) {\n let { hook, pathIfPromise } = promise[RAW_STUB];\n if (pathIfPromise.length > 0) hook = hook.get(pathIfPromise);\n return (await hook.pull()).deliverResolve();\n}\nvar RpcPayload = class RpcPayload2 {\n value;\n source;\n hooks;\n promises;\n static fromAppParams(value) {\n return new RpcPayload2(value, \"params\");\n }\n static fromAppReturn(value) {\n return new RpcPayload2(value, \"return\");\n }\n static fromArray(array) {\n let hooks = [];\n let promises = [];\n let resultArray = [];\n for (let payload of array) {\n payload.ensureDeepCopied();\n for (let hook of payload.hooks) hooks.push(hook);\n for (let promise of payload.promises) {\n if (promise.parent === payload) promise = {\n parent: resultArray,\n property: resultArray.length,\n promise: promise.promise\n };\n promises.push(promise);\n }\n resultArray.push(payload.value);\n }\n return new RpcPayload2(resultArray, \"owned\", hooks, promises);\n }\n static forEvaluate(hooks, promises) {\n return new RpcPayload2(null, \"owned\", hooks, promises);\n }\n static deepCopyFrom(value, oldParent, owner) {\n let result = new RpcPayload2(null, \"owned\", [], []);\n result.value = result.deepCopy(value, oldParent, \"value\", result, true, owner);\n return result;\n }\n constructor(value, source, hooks, promises) {\n this.value = value;\n this.source = source;\n this.hooks = hooks;\n this.promises = promises;\n }\n rpcTargets;\n getHookForRpcTarget(target, parent, dupStubs = true) {\n if (this.source === \"params\") {\n if (dupStubs) {\n let dupable = target;\n if (typeof dupable.dup === \"function\") target = dupable.dup();\n }\n return TargetStubHook.create(target, parent);\n } else if (this.source === \"return\") {\n let hook = this.rpcTargets?.get(target);\n if (hook) if (dupStubs) return hook.dup();\n else {\n this.rpcTargets?.delete(target);\n return hook;\n }\n else {\n hook = TargetStubHook.create(target, parent);\n if (dupStubs) {\n if (!this.rpcTargets) this.rpcTargets = /* @__PURE__ */ new Map();\n this.rpcTargets.set(target, hook);\n return hook.dup();\n } else return hook;\n }\n } else throw new Error(\"owned payload shouldn't contain raw RpcTargets\");\n }\n getHookForWritableStream(stream, parent, dupStubs = true) {\n if (this.source === \"params\") return streamImpl.createWritableStreamHook(stream);\n else if (this.source === \"return\") {\n let hook = this.rpcTargets?.get(stream);\n if (hook) if (dupStubs) return hook.dup();\n else {\n this.rpcTargets?.delete(stream);\n return hook;\n }\n else {\n hook = streamImpl.createWritableStreamHook(stream);\n if (dupStubs) {\n if (!this.rpcTargets) this.rpcTargets = /* @__PURE__ */ new Map();\n this.rpcTargets.set(stream, hook);\n return hook.dup();\n } else return hook;\n }\n } else throw new Error(\"owned payload shouldn't contain raw WritableStreams\");\n }\n getHookForReadableStream(stream, parent, dupStubs = true) {\n if (this.source === \"params\") return streamImpl.createReadableStreamHook(stream);\n else if (this.source === \"return\") {\n let hook = this.rpcTargets?.get(stream);\n if (hook) if (dupStubs) return hook.dup();\n else {\n this.rpcTargets?.delete(stream);\n return hook;\n }\n else {\n hook = streamImpl.createReadableStreamHook(stream);\n if (dupStubs) {\n if (!this.rpcTargets) this.rpcTargets = /* @__PURE__ */ new Map();\n this.rpcTargets.set(stream, hook);\n return hook.dup();\n } else return hook;\n }\n } else throw new Error(\"owned payload shouldn't contain raw ReadableStreams\");\n }\n deepCopy(value, oldParent, property, parent, dupStubs, owner) {\n switch (typeForRpc(value)) {\n case \"unsupported\":\n return value;\n case \"primitive\":\n case \"bigint\":\n case \"date\":\n case \"bytes\":\n case \"blob\":\n case \"url\":\n case \"error\":\n case \"undefined\":\n return value;\n case \"array\": {\n let array = value;\n let len = array.length;\n let result = new Array(len);\n for (let i = 0; i < len; i++) result[i] = this.deepCopy(array[i], array, i, result, dupStubs, owner);\n return result;\n }\n case \"object\": {\n let result = {};\n let object = value;\n for (let i in object) result[i] = this.deepCopy(object[i], object, i, result, dupStubs, owner);\n return result;\n }\n case \"stub\":\n case \"rpc-promise\": {\n let stub = value;\n let hook;\n if (dupStubs) hook = unwrapStubAndDup(stub);\n else hook = unwrapStubTakingOwnership(stub);\n if (stub instanceof RpcPromise$1) {\n let promise = new RpcPromise$1(hook, []);\n this.promises.push({\n parent,\n property,\n promise\n });\n return promise;\n } else {\n this.hooks.push(hook);\n return new RpcStub$1(hook);\n }\n }\n case \"function\":\n case \"rpc-target\": {\n let target = value;\n let hook;\n if (owner) hook = owner.getHookForRpcTarget(target, oldParent, dupStubs);\n else hook = TargetStubHook.create(target, oldParent);\n this.hooks.push(hook);\n return new RpcStub$1(hook);\n }\n case \"rpc-thenable\": {\n let target = value;\n let promise;\n if (owner) promise = new RpcPromise$1(owner.getHookForRpcTarget(target, oldParent, dupStubs), []);\n else promise = new RpcPromise$1(TargetStubHook.create(target, oldParent), []);\n this.promises.push({\n parent,\n property,\n promise\n });\n return promise;\n }\n case \"writable\": {\n let stream = value;\n let hook;\n if (owner) hook = owner.getHookForWritableStream(stream, oldParent, dupStubs);\n else hook = streamImpl.createWritableStreamHook(stream);\n this.hooks.push(hook);\n return stream;\n }\n case \"readable\": {\n let stream = value;\n let hook;\n if (owner) hook = owner.getHookForReadableStream(stream, oldParent, dupStubs);\n else hook = streamImpl.createReadableStreamHook(stream);\n this.hooks.push(hook);\n return stream;\n }\n case \"headers\":\n return new Headers(value);\n case \"request\": {\n let req = value;\n if (req.body) this.deepCopy(req.body, req, \"body\", req, dupStubs, owner);\n return new Request(req);\n }\n case \"response\": {\n let resp = value;\n if (resp.body) this.deepCopy(resp.body, resp, \"body\", resp, dupStubs, owner);\n return new Response(resp.body, resp);\n }\n default:\n throw new Error(\"unreachable\");\n }\n }\n ensureDeepCopied() {\n if (this.source !== \"owned\") {\n let dupStubs = this.source === \"params\";\n this.hooks = [];\n this.promises = [];\n try {\n this.value = this.deepCopy(this.value, void 0, \"value\", this, dupStubs, this);\n } catch (err) {\n this.hooks = void 0;\n this.promises = void 0;\n throw err;\n }\n this.source = \"owned\";\n if (this.rpcTargets && this.rpcTargets.size > 0) throw new Error(\"Not all rpcTargets were accounted for in deep-copy?\");\n this.rpcTargets = void 0;\n }\n }\n deliverTo(parent, property, promises) {\n this.ensureDeepCopied();\n if (this.value instanceof RpcPromise$1) RpcPayload2.deliverRpcPromiseTo(this.value, parent, property, promises);\n else {\n parent[property] = this.value;\n for (let record of this.promises) RpcPayload2.deliverRpcPromiseTo(record.promise, record.parent, record.property, promises);\n }\n }\n static deliverRpcPromiseTo(promise, parent, property, promises) {\n let hook = unwrapStubNoProperties(promise);\n if (!hook) throw new Error(\"property promises should have been resolved earlier\");\n let inner = hook.pull();\n if (inner instanceof RpcPayload2) inner.deliverTo(parent, property, promises);\n else promises.push(inner.then((payload) => {\n let subPromises = [];\n payload.deliverTo(parent, property, subPromises);\n if (subPromises.length > 0) return Promise.all(subPromises);\n }));\n }\n async deliverCall(func, thisArg) {\n try {\n let promises = [];\n this.deliverTo(this, \"value\", promises);\n if (promises.length > 0) await Promise.all(promises);\n let result = Function.prototype.apply.call(func, thisArg, this.value);\n if (result instanceof RpcPromise$1) return RpcPayload2.fromAppReturn(result);\n else return RpcPayload2.fromAppReturn(await result);\n } finally {\n this.dispose();\n }\n }\n async deliverStreamWrite(writer) {\n try {\n let promises = [];\n this.deliverTo(this, \"value\", promises);\n if (promises.length > 0) await Promise.all(promises);\n let chunk = this.value[0];\n if ((this.hooks.length > 0 || this.promises.length > 0) && chunk instanceof Object) {\n if (!(Symbol.dispose in chunk)) Object.defineProperty(chunk, Symbol.dispose, {\n value: () => this.dispose(),\n writable: true,\n enumerable: false,\n configurable: true\n });\n await writer.write(chunk);\n return RpcPayload2.fromAppReturn(void 0);\n }\n await writer.write(chunk);\n this.dispose();\n return RpcPayload2.fromAppReturn(void 0);\n } catch (err) {\n this.dispose();\n throw err;\n }\n }\n async deliverResolve() {\n try {\n let promises = [];\n this.deliverTo(this, \"value\", promises);\n if (promises.length > 0) await Promise.all(promises);\n let result = this.value;\n if (result instanceof Object) {\n if (!(Symbol.dispose in result)) Object.defineProperty(result, Symbol.dispose, {\n value: () => this.dispose(),\n writable: true,\n enumerable: false,\n configurable: true\n });\n }\n return result;\n } catch (err) {\n this.dispose();\n throw err;\n }\n }\n dispose() {\n if (this.source === \"owned\") {\n this.hooks.forEach((hook) => hook.dispose());\n this.promises.forEach((promise) => promise.promise[Symbol.dispose]());\n } else if (this.source === \"return\") {\n this.disposeImpl(this.value, void 0);\n if (this.rpcTargets && this.rpcTargets.size > 0) throw new Error(\"Not all rpcTargets were accounted for in disposeImpl()?\");\n }\n this.source = \"owned\";\n this.hooks = [];\n this.promises = [];\n }\n disposeImpl(value, parent) {\n switch (typeForRpc(value)) {\n case \"unsupported\":\n case \"primitive\":\n case \"bigint\":\n case \"bytes\":\n case \"blob\":\n case \"date\":\n case \"url\":\n case \"error\":\n case \"undefined\":\n return;\n case \"array\": {\n let array = value;\n let len = array.length;\n for (let i = 0; i < len; i++) this.disposeImpl(array[i], array);\n return;\n }\n case \"object\": {\n let object = value;\n for (let i in object) this.disposeImpl(object[i], object);\n return;\n }\n case \"stub\":\n case \"rpc-promise\": {\n let hook = unwrapStubNoProperties(value);\n if (hook) hook.dispose();\n return;\n }\n case \"function\":\n case \"rpc-target\": {\n let target = value;\n let hook = this.rpcTargets?.get(target);\n if (hook) {\n hook.dispose();\n this.rpcTargets.delete(target);\n } else disposeRpcTarget(target);\n return;\n }\n case \"rpc-thenable\":\n return;\n case \"headers\":\n return;\n case \"request\": {\n let req = value;\n if (req.body) this.disposeImpl(req.body, req);\n return;\n }\n case \"response\": {\n let resp = value;\n if (resp.body) this.disposeImpl(resp.body, resp);\n return;\n }\n case \"writable\": {\n let stream = value;\n let hook = this.rpcTargets?.get(stream);\n if (hook) this.rpcTargets.delete(stream);\n else hook = streamImpl.createWritableStreamHook(stream);\n hook.dispose();\n return;\n }\n case \"readable\": {\n let stream = value;\n let hook = this.rpcTargets?.get(stream);\n if (hook) this.rpcTargets.delete(stream);\n else hook = streamImpl.createReadableStreamHook(stream);\n hook.dispose();\n return;\n }\n default:\n return;\n }\n }\n ignoreUnhandledRejections() {\n if (this.hooks) {\n this.hooks.forEach((hook) => {\n hook.ignoreUnhandledRejections();\n });\n this.promises.forEach((promise) => unwrapStubOrParent(promise.promise).ignoreUnhandledRejections());\n } else this.ignoreUnhandledRejectionsImpl(this.value);\n }\n ignoreUnhandledRejectionsImpl(value) {\n switch (typeForRpc(value)) {\n case \"unsupported\":\n case \"primitive\":\n case \"bigint\":\n case \"bytes\":\n case \"blob\":\n case \"date\":\n case \"error\":\n case \"undefined\":\n case \"function\":\n case \"rpc-target\":\n case \"writable\":\n case \"readable\":\n case \"url\":\n case \"headers\":\n case \"request\":\n case \"response\":\n return;\n case \"array\": {\n let array = value;\n let len = array.length;\n for (let i = 0; i < len; i++) this.ignoreUnhandledRejectionsImpl(array[i]);\n return;\n }\n case \"object\": {\n let object = value;\n for (let i in object) this.ignoreUnhandledRejectionsImpl(object[i]);\n return;\n }\n case \"stub\":\n case \"rpc-promise\":\n unwrapStubOrParent(value).ignoreUnhandledRejections();\n return;\n case \"rpc-thenable\":\n value.then((_) => {\n }, (_) => {\n });\n return;\n default:\n return;\n }\n }\n};\nfunction followPath(value, parent, path, owner) {\n for (let i = 0; i < path.length; i++) {\n parent = value;\n let part = path[i];\n if (part in Object.prototype) {\n value = void 0;\n continue;\n }\n switch (typeForRpc(value)) {\n case \"object\":\n case \"function\":\n if (Object.hasOwn(value, part)) value = value[part];\n else value = void 0;\n break;\n case \"array\":\n if (Number.isInteger(part) && part >= 0) value = value[part];\n else value = void 0;\n break;\n case \"rpc-target\":\n case \"rpc-thenable\":\n if (Object.hasOwn(value, part)) throw new TypeError(`Attempted to access property '${part}', which is an instance property of the RpcTarget. To avoid leaking private internals, instance properties cannot be accessed over RPC. If you want to make this property available over RPC, define it as a method or getter on the class, instead of an instance property.`);\n else value = value[part];\n owner = null;\n break;\n case \"stub\":\n case \"rpc-promise\": {\n let { hook, pathIfPromise } = unwrapStubAndPath(value);\n return {\n hook,\n remainingPath: pathIfPromise ? pathIfPromise.concat(path.slice(i)) : path.slice(i)\n };\n }\n case \"writable\":\n value = void 0;\n break;\n case \"readable\":\n value = void 0;\n break;\n case \"primitive\":\n case \"bigint\":\n case \"bytes\":\n case \"blob\":\n case \"date\":\n case \"error\":\n case \"url\":\n case \"headers\":\n case \"request\":\n case \"response\":\n value = void 0;\n break;\n case \"undefined\":\n value = value[part];\n break;\n case \"unsupported\":\n if (i === 0) throw new TypeError(`RPC stub points at a non-serializable type.`);\n else {\n let prefix = path.slice(0, i).join(\".\");\n let remainder = path.slice(0, i).join(\".\");\n throw new TypeError(`'${prefix}' is not a serializable type, so property ${remainder} cannot be accessed.`);\n }\n default:\n throw new TypeError(\"unreachable\");\n }\n }\n if (value instanceof RpcPromise$1) {\n let { hook, pathIfPromise } = unwrapStubAndPath(value);\n return {\n hook,\n remainingPath: pathIfPromise || []\n };\n }\n return {\n value,\n parent,\n owner\n };\n}\nvar ValueStubHook = class extends StubHook {\n call(path, args) {\n let followResult;\n try {\n let { value, owner } = this.getValue();\n followResult = followPath(value, void 0, path, owner);\n } catch (err) {\n args.dispose();\n return new ErrorStubHook(err);\n }\n if (followResult.hook) return followResult.hook.call(followResult.remainingPath, args);\n if (typeof followResult.value != \"function\") {\n args.dispose();\n return new ErrorStubHook(/* @__PURE__ */ new TypeError(`'${path.join(\".\")}' is not a function.`));\n }\n return new PromiseStubHook(args.deliverCall(followResult.value, followResult.parent).then((payload) => {\n return new PayloadStubHook(payload);\n }));\n }\n map(path, captures, instructions) {\n try {\n let followResult;\n try {\n let { value, owner } = this.getValue();\n followResult = followPath(value, void 0, path, owner);\n } catch (err) {\n for (let cap of captures) cap.dispose();\n throw err;\n }\n if (followResult.hook) return followResult.hook.map(followResult.remainingPath, captures, instructions);\n return mapImpl.applyMap(followResult.value, followResult.parent, followResult.owner, captures, instructions);\n } catch (err) {\n return new ErrorStubHook(err);\n }\n }\n get(path) {\n try {\n let { value, owner } = this.getValue();\n if (path.length === 0 && owner === null) {\n if (value instanceof Object && \"then\" in value) return this.dup();\n throw new Error(\"Can't dup an RpcTarget stub as a promise.\");\n }\n let followResult = followPath(value, void 0, path, owner);\n if (followResult.hook) return followResult.hook.get(followResult.remainingPath);\n return new PayloadStubHook(RpcPayload.deepCopyFrom(followResult.value, followResult.parent, followResult.owner));\n } catch (err) {\n return new ErrorStubHook(err);\n }\n }\n};\nvar PayloadStubHook = class PayloadStubHook2 extends ValueStubHook {\n constructor(payload) {\n super();\n this.payload = payload;\n }\n payload;\n getPayload() {\n if (this.payload) return this.payload;\n else throw new Error(\"Attempted to use an RPC StubHook after it was disposed.\");\n }\n getValue() {\n let payload = this.getPayload();\n return {\n value: payload.value,\n owner: payload\n };\n }\n dup() {\n let thisPayload = this.getPayload();\n return new PayloadStubHook2(RpcPayload.deepCopyFrom(thisPayload.value, void 0, thisPayload));\n }\n pull() {\n return this.getPayload();\n }\n ignoreUnhandledRejections() {\n if (this.payload) this.payload.ignoreUnhandledRejections();\n }\n dispose() {\n if (this.payload) {\n this.payload.dispose();\n this.payload = void 0;\n }\n }\n onBroken(callback) {\n if (this.payload) {\n if (this.payload.value instanceof RpcStub$1) this.payload.value.onRpcBroken(callback);\n }\n }\n};\nfunction disposeRpcTarget(target) {\n if (Symbol.dispose in target) try {\n target[Symbol.dispose]();\n } catch (err) {\n Promise.reject(err);\n }\n}\nvar TargetStubHook = class TargetStubHook2 extends ValueStubHook {\n static create(value, parent) {\n if (typeof value !== \"function\") parent = void 0;\n return new TargetStubHook2(value, parent);\n }\n constructor(target, parent, dupFrom) {\n super();\n this.target = target;\n this.parent = parent;\n if (dupFrom) {\n if (dupFrom.refcount) {\n this.refcount = dupFrom.refcount;\n ++this.refcount.count;\n }\n } else if (Symbol.dispose in target) this.refcount = { count: 1 };\n }\n target;\n parent;\n refcount;\n getTarget() {\n if (this.target) return this.target;\n else throw new Error(\"Attempted to use an RPC StubHook after it was disposed.\");\n }\n getValue() {\n return {\n value: this.getTarget(),\n owner: null\n };\n }\n dup() {\n return new TargetStubHook2(this.getTarget(), this.parent, this);\n }\n pull() {\n let target = this.getTarget();\n if (\"then\" in target) return Promise.resolve(target).then((resolution) => {\n return RpcPayload.fromAppReturn(resolution);\n });\n else return Promise.reject(/* @__PURE__ */ new Error(\"Tried to resolve a non-promise stub.\"));\n }\n ignoreUnhandledRejections() {\n }\n dispose() {\n if (this.target) {\n if (this.refcount) {\n if (--this.refcount.count == 0) disposeRpcTarget(this.target);\n }\n this.target = void 0;\n }\n }\n onBroken(callback) {\n let target = this.target;\n if (target && \"then\" in target) Promise.resolve(target).then(() => {\n }, callback);\n }\n};\nvar PromiseStubHook = class PromiseStubHook2 extends StubHook {\n promise;\n resolution;\n constructor(promise) {\n super();\n this.promise = promise.then((res) => {\n this.resolution = res;\n return res;\n });\n }\n call(path, args) {\n args.ensureDeepCopied();\n return new PromiseStubHook2(this.promise.then((hook) => hook.call(path, args), (err) => {\n args.dispose();\n throw err;\n }));\n }\n stream(path, args) {\n args.ensureDeepCopied();\n return { promise: this.promise.then((hook) => hook.stream(path, args).promise, (err) => {\n args.dispose();\n throw err;\n }) };\n }\n map(path, captures, instructions) {\n return new PromiseStubHook2(this.promise.then((hook) => hook.map(path, captures, instructions), (err) => {\n for (let cap of captures) cap.dispose();\n throw err;\n }));\n }\n get(path) {\n return new PromiseStubHook2(this.promise.then((hook) => hook.get(path)));\n }\n dup() {\n if (this.resolution) return this.resolution.dup();\n else return new PromiseStubHook2(this.promise.then((hook) => hook.dup()));\n }\n pull() {\n if (this.resolution) return this.resolution.pull();\n else return this.promise.then((hook) => hook.pull());\n }\n ignoreUnhandledRejections() {\n if (this.resolution) this.resolution.ignoreUnhandledRejections();\n else this.promise.then((res) => {\n res.ignoreUnhandledRejections();\n }, (err) => {\n });\n }\n dispose() {\n this.promise.then((hook) => hook.dispose(), () => {\n });\n }\n onBroken(callback) {\n if (this.resolution) this.resolution.onBroken(callback);\n else this.promise.then((hook) => {\n hook.onBroken(callback);\n }, callback);\n }\n};\nvar DEFAULT_LIMITS = {\n maxBigIntDigits: 16384,\n maxDepth: 256,\n maxMessageSize: 32 * 1024 * 1024\n};\nvar NATIVE_LITTLE_ENDIAN = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;\nvar BYTE_CONTAINER_TYPE_NAMES = [\n \"ArrayBuffer\",\n \"DataView\",\n \"Int8Array\",\n \"Uint8Array\",\n \"Uint8ClampedArray\",\n \"Int16Array\",\n \"Uint16Array\",\n \"Int32Array\",\n \"Uint32Array\",\n \"BigInt64Array\",\n \"BigUint64Array\",\n \"Float32Array\",\n \"Float64Array\"\n];\nfunction isValidByteContainerName(value) {\n return BYTE_CONTAINER_TYPE_NAMES.includes(value);\n}\nvar TYPED_ARRAY_ELEMENT_SIZE = {\n ArrayBuffer: void 0,\n DataView: void 0,\n Int8Array: void 0,\n Uint8Array: void 0,\n Uint8ClampedArray: void 0,\n Int16Array: 2,\n Uint16Array: 2,\n Int32Array: 4,\n Uint32Array: 4,\n BigInt64Array: 8,\n BigUint64Array: 8,\n Float32Array: 4,\n Float64Array: 8\n};\nvar BYTE_CONTAINER_PROTOTYPES = {\n ArrayBuffer: ArrayBuffer.prototype,\n DataView: DataView.prototype,\n Int8Array: Int8Array.prototype,\n Uint8ClampedArray: Uint8ClampedArray.prototype,\n Int16Array: Int16Array.prototype,\n Uint16Array: Uint16Array.prototype,\n Int32Array: Int32Array.prototype,\n Uint32Array: Uint32Array.prototype,\n BigInt64Array: BigInt64Array.prototype,\n BigUint64Array: BigUint64Array.prototype,\n Float32Array: Float32Array.prototype,\n Float64Array: Float64Array.prototype\n};\nvar BYTE_CONTAINER_TYPE_BY_PROTOTYPE = /* @__PURE__ */ new Map();\nfor (let type of Object.keys(BYTE_CONTAINER_PROTOTYPES)) BYTE_CONTAINER_TYPE_BY_PROTOTYPE.set(BYTE_CONTAINER_PROTOTYPES[type], type);\nfunction swapByteOrder(bytes, elementSize) {\n if (elementSize !== 2 && elementSize !== 4 && elementSize !== 8) throw new RangeError(`Unsupported element size: ${elementSize}`);\n let view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n for (let offset = 0; offset < bytes.byteLength; offset += elementSize) switch (elementSize) {\n case 2:\n view.setUint16(offset, view.getUint16(offset, false), true);\n break;\n case 4:\n view.setUint32(offset, view.getUint32(offset, false), true);\n break;\n case 8:\n view.setBigUint64(offset, view.getBigUint64(offset, false), true);\n break;\n }\n}\nvar NullExporter = class {\n exportStub(stub) {\n throw new Error(\"Cannot serialize RPC stubs without an RPC session.\");\n }\n exportPromise(stub) {\n throw new Error(\"Cannot serialize RPC stubs without an RPC session.\");\n }\n getImport(hook) {\n }\n unexport(ids) {\n }\n createPipe(readable) {\n throw new Error(\"Cannot create pipes without an RPC session.\");\n }\n onSendError(error) {\n }\n};\nvar NULL_EXPORTER = new NullExporter();\nasync function streamToBlob(stream, type) {\n let b = await new Response(stream).blob();\n return b.type === type ? b : b.slice(0, b.size, type);\n}\nvar ERROR_TYPES = {\n __proto__: null,\n Error,\n EvalError,\n RangeError,\n ReferenceError,\n SyntaxError,\n TypeError,\n URIError,\n AggregateError\n};\nvar Devaluator = class Devaluator2 {\n exporter;\n source;\n encodingLevel;\n constructor(exporter, source, encodingLevel) {\n this.exporter = exporter;\n this.source = source;\n this.encodingLevel = encodingLevel;\n }\n static devaluate(value, parent, exporter = NULL_EXPORTER, source, encodingLevel = \"string\") {\n let devaluator = new Devaluator2(exporter, source, encodingLevel);\n try {\n return devaluator.devaluateImpl(value, parent, 0);\n } catch (err) {\n if (devaluator.exports) try {\n exporter.unexport(devaluator.exports);\n } catch (err2) {\n }\n throw err;\n }\n }\n exports;\n devaluateImpl(value, parent, depth) {\n if (depth >= 256) throw new Error(\"Serialization exceeded maximum allowed depth. (Does the message contain cycles?)\");\n switch (typeForRpc(value)) {\n case \"unsupported\": {\n let msg;\n try {\n msg = `Cannot serialize value: ${value}`;\n } catch (err) {\n msg = \"Cannot serialize value: (couldn't stringify value)\";\n }\n throw new TypeError(msg);\n }\n case \"primitive\":\n if (typeof value === \"number\" && !isFinite(value)) {\n if (this.encodingLevel === \"structuredClonable\") return value;\n if (value === Infinity) return [\"inf\"];\n else if (value === -Infinity) return [\"-inf\"];\n else return [\"nan\"];\n } else return value;\n case \"object\": {\n let object = value;\n let result = {};\n for (let key in object) result[key] = this.devaluateImpl(object[key], object, depth + 1);\n return result;\n }\n case \"array\": {\n let array = value;\n let len = array.length;\n let result = new Array(len);\n for (let i = 0; i < len; i++) result[i] = this.devaluateImpl(array[i], array, depth + 1);\n return [result];\n }\n case \"bigint\":\n if (this.encodingLevel === \"structuredClonable\") return value;\n return [\"bigint\", value.toString()];\n case \"date\": {\n if (this.encodingLevel === \"structuredClonable\") return value;\n const time = value.getTime();\n return [\"date\", Number.isNaN(time) ? null : time];\n }\n case \"bytes\": {\n let alternateTypeName = BYTE_CONTAINER_TYPE_BY_PROTOTYPE.get(Object.getPrototypeOf(value));\n let bytes;\n if (alternateTypeName === \"ArrayBuffer\") bytes = new Uint8Array(value);\n else if (alternateTypeName === void 0) bytes = value;\n else {\n let view = value;\n bytes = new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n let elementSize = TYPED_ARRAY_ELEMENT_SIZE[alternateTypeName];\n if (!NATIVE_LITTLE_ENDIAN && elementSize) {\n bytes = bytes.slice();\n swapByteOrder(bytes, elementSize);\n }\n }\n if (this.encodingLevel === \"structuredClonable\" || this.encodingLevel === \"jsonCompatibleWithBytes\") return alternateTypeName === void 0 ? [\"bytes\", bytes] : [\n \"bytes\",\n bytes,\n alternateTypeName\n ];\n let b64;\n if (bytes.toBase64) b64 = bytes.toBase64({ omitPadding: true });\n else if (typeof Buffer !== \"undefined\") b64 = (bytes instanceof Buffer ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)).toString(\"base64\");\n else {\n let binary = \"\";\n for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);\n b64 = btoa(binary);\n }\n b64 = b64.replace(/=+$/, \"\");\n return alternateTypeName === void 0 ? [\"bytes\", b64] : [\n \"bytes\",\n b64,\n alternateTypeName\n ];\n }\n case \"url\":\n return [\"url\", value.href];\n case \"headers\":\n return [\"headers\", [...value]];\n case \"request\": {\n let req = value;\n let init = {};\n if (req.method !== \"GET\") init.method = req.method;\n let headers = [...req.headers];\n if (headers.length > 0) init.headers = headers;\n if (req.body) {\n init.body = this.devaluateImpl(req.body, req, depth + 1);\n init.duplex = req.duplex || \"half\";\n } else if (req.body === void 0 && ![\n \"GET\",\n \"HEAD\",\n \"OPTIONS\",\n \"TRACE\",\n \"DELETE\"\n ].includes(req.method)) {\n let bodyPromise = req.arrayBuffer();\n let readable = new ReadableStream({ async start(controller) {\n try {\n controller.enqueue(new Uint8Array(await bodyPromise));\n controller.close();\n } catch (err) {\n controller.error(err);\n }\n } });\n let hook = streamImpl.createReadableStreamHook(readable);\n init.body = [\"readable\", this.exporter.createPipe(readable, hook)];\n init.duplex = req.duplex || \"half\";\n }\n if (req.cache && req.cache !== \"default\") init.cache = req.cache;\n if (req.redirect !== \"follow\") init.redirect = req.redirect;\n if (req.integrity) init.integrity = req.integrity;\n if (req.mode && req.mode !== \"cors\") init.mode = req.mode;\n if (req.credentials && req.credentials !== \"same-origin\") init.credentials = req.credentials;\n if (req.referrer && req.referrer !== \"about:client\") init.referrer = req.referrer;\n if (req.referrerPolicy) init.referrerPolicy = req.referrerPolicy;\n if (req.keepalive) init.keepalive = req.keepalive;\n let cfReq = req;\n if (cfReq.cf) init.cf = cfReq.cf;\n if (cfReq.encodeResponseBody && cfReq.encodeResponseBody !== \"automatic\") init.encodeResponseBody = cfReq.encodeResponseBody;\n return [\n \"request\",\n req.url,\n init\n ];\n }\n case \"response\": {\n let resp = value;\n let body = this.devaluateImpl(resp.body, resp, depth + 1);\n let init = {};\n if (resp.status !== 200) init.status = resp.status;\n if (resp.statusText) init.statusText = resp.statusText;\n let headers = [...resp.headers];\n if (headers.length > 0) init.headers = headers;\n let cfResp = resp;\n if (cfResp.cf) init.cf = cfResp.cf;\n if (cfResp.encodeBody && cfResp.encodeBody !== \"automatic\") init.encodeBody = cfResp.encodeBody;\n if (cfResp.webSocket) throw new TypeError(\"Can't serialize a Response containing a webSocket.\");\n return [\n \"response\",\n body,\n init\n ];\n }\n case \"blob\": {\n let blob = value;\n let readable = blob.stream();\n let hook = streamImpl.createReadableStreamHook(readable);\n let importId = this.exporter.createPipe(readable, hook);\n return [\n \"blob\",\n blob.type,\n [\"readable\", importId]\n ];\n }\n case \"error\": {\n let e = value;\n let rewritten = this.exporter.onSendError(e);\n if (rewritten) e = rewritten;\n let anyE = e;\n let props;\n let captureProp = (key, val) => {\n let exportsBefore = this.exports?.length ?? 0;\n try {\n let encoded = this.devaluateImpl(val, e, depth + 1);\n if (!props) props = {};\n props[key] = encoded;\n } catch (err) {\n if (this.exports && this.exports.length > exportsBefore) {\n let tail = this.exports.splice(exportsBefore);\n try {\n this.exporter.unexport(tail);\n } catch (err2) {\n }\n }\n }\n };\n for (let key of Object.keys(e)) {\n if (key === \"name\" || key === \"message\" || key === \"stack\") continue;\n captureProp(key, anyE[key]);\n }\n if (\"cause\" in e) captureProp(\"cause\", anyE.cause);\n if (e instanceof AggregateError) captureProp(\"errors\", e.errors);\n let result = [\n \"error\",\n e.name,\n e.message\n ];\n if (props) {\n result.push(rewritten && rewritten.stack ? rewritten.stack : null);\n result.push(props);\n } else if (rewritten && rewritten.stack) result.push(rewritten.stack);\n return result;\n }\n case \"undefined\":\n if (this.encodingLevel === \"structuredClonable\") return;\n return [\"undefined\"];\n case \"stub\":\n case \"rpc-promise\": {\n if (!this.source) throw new Error(\"Can't serialize RPC stubs in this context.\");\n let { hook, pathIfPromise } = unwrapStubAndPath(value);\n let importId = this.exporter.getImport(hook);\n if (importId !== void 0) if (pathIfPromise) if (pathIfPromise.length > 0) return [\n \"pipeline\",\n importId,\n pathIfPromise\n ];\n else return [\"pipeline\", importId];\n else return [\"import\", importId];\n if (pathIfPromise) hook = hook.get(pathIfPromise);\n else hook = hook.dup();\n return this.devaluateHook(pathIfPromise ? \"promise\" : \"export\", hook);\n }\n case \"function\":\n case \"rpc-target\": {\n if (!this.source) throw new Error(\"Can't serialize RPC stubs in this context.\");\n let hook = this.source.getHookForRpcTarget(value, parent);\n return this.devaluateHook(\"export\", hook);\n }\n case \"rpc-thenable\": {\n if (!this.source) throw new Error(\"Can't serialize RPC stubs in this context.\");\n let hook = this.source.getHookForRpcTarget(value, parent);\n return this.devaluateHook(\"promise\", hook);\n }\n case \"writable\": {\n if (!this.source) throw new Error(\"Can't serialize WritableStream in this context.\");\n let hook = this.source.getHookForWritableStream(value, parent);\n return this.devaluateHook(\"writable\", hook);\n }\n case \"readable\": {\n if (!this.source) throw new Error(\"Can't serialize ReadableStream in this context.\");\n let ws = value;\n let hook = this.source.getHookForReadableStream(ws, parent);\n return [\"readable\", this.exporter.createPipe(ws, hook)];\n }\n default:\n throw new Error(\"unreachable\");\n }\n }\n devaluateHook(type, hook) {\n if (!this.exports) this.exports = [];\n let exportId = type === \"promise\" ? this.exporter.exportPromise(hook) : this.exporter.exportStub(hook);\n this.exports.push(exportId);\n return [type, exportId];\n }\n};\nvar NullImporter = class {\n importStub(idx) {\n throw new Error(\"Cannot deserialize RPC stubs without an RPC session.\");\n }\n importPromise(idx) {\n throw new Error(\"Cannot deserialize RPC stubs without an RPC session.\");\n }\n getExport(idx) {\n }\n getPipeReadable(exportId) {\n throw new Error(\"Cannot retrieve pipe readable without an RPC session.\");\n }\n getLimits() {\n return DEFAULT_LIMITS;\n }\n};\nvar NULL_IMPORTER = new NullImporter();\nfunction fixBrokenRequestBody(request, body) {\n return new RpcPromise$1(new PromiseStubHook(new Response(body).arrayBuffer().then((arrayBuffer) => {\n let bytes = new Uint8Array(arrayBuffer);\n let result = new Request(request, { body: bytes });\n return new PayloadStubHook(RpcPayload.fromAppReturn(result));\n })), []);\n}\nfunction streamToBlobPromise(stream, type) {\n return new RpcPromise$1(new PromiseStubHook(streamToBlob(stream, type).then((blob) => {\n return new PayloadStubHook(RpcPayload.fromAppReturn(blob));\n })), []);\n}\nvar Evaluator = class Evaluator2 {\n importer;\n encodingLevel;\n limits;\n constructor(importer, encodingLevel = \"string\") {\n this.importer = importer;\n this.encodingLevel = encodingLevel;\n this.limits = importer.getLimits();\n }\n hooks = [];\n promises = [];\n evaluate(value) {\n return this.evaluateWithDepth(value, 0);\n }\n evaluateWithDepth(value, depth) {\n let payload = RpcPayload.forEvaluate(this.hooks, this.promises);\n try {\n payload.value = this.evaluateImpl(value, payload, \"value\", depth);\n return payload;\n } catch (err) {\n payload.dispose();\n throw err;\n }\n }\n evaluateCopy(value) {\n return this.evaluate(structuredClone(value));\n }\n evaluateImpl(value, parent, property, depth) {\n let maxDepth = this.limits.maxDepth;\n if (depth >= maxDepth) throw new TypeError(`Deserialization exceeded maximum allowed message depth of ${maxDepth}.`);\n if (this.encodingLevel === \"structuredClonable\") {\n if (value instanceof Date || typeof value === \"bigint\") return value;\n }\n if (value instanceof Array) {\n if (value.length == 1 && value[0] instanceof Array) {\n let result = value[0];\n for (let i = 0; i < result.length; i++) result[i] = this.evaluateImpl(result[i], result, i, depth + 1);\n return result;\n } else switch (value[0]) {\n case \"bigint\":\n if (typeof value[1] == \"string\") {\n let digits = value[1];\n let maxBigIntDigits = this.limits.maxBigIntDigits;\n if (digits.length > maxBigIntDigits) throw new TypeError(`Deserialized bigint exceeds maximum length of ${maxBigIntDigits} digits.`);\n return BigInt(digits);\n }\n break;\n case \"date\":\n if (value[1] === null) return /* @__PURE__ */ new Date(NaN);\n if (typeof value[1] == \"number\") return new Date(value[1]);\n break;\n case \"bytes\": {\n let bytes;\n if (value[1] instanceof Uint8Array) bytes = value[1];\n else if (typeof value[1] == \"string\") if (typeof Buffer !== \"undefined\") bytes = Buffer.from(value[1], \"base64\");\n else if (Uint8Array.fromBase64) bytes = Uint8Array.fromBase64(value[1]);\n else {\n let bs = atob(value[1]);\n let len = bs.length;\n bytes = new Uint8Array(len);\n for (let i = 0; i < len; i++) bytes[i] = bs.charCodeAt(i);\n }\n else break;\n if (value.length === 2) return bytes;\n if (typeof value[2] !== \"string\") throw new TypeError(`Unknown bytes type marker type: ${typeof value[2]}`);\n if (!isValidByteContainerName(value[2])) {\n let marker2 = value[2].slice(0, 64);\n throw new TypeError(`Unknown bytes type marker: ${marker2}`);\n }\n let marker = value[2];\n let elementSize = TYPED_ARRAY_ELEMENT_SIZE[marker];\n if (elementSize !== void 0 && bytes.byteLength % elementSize !== 0) throw new TypeError(`Invalid byte length ${bytes.byteLength} for ${marker}; expected a multiple of ${elementSize}`);\n let buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);\n if (!NATIVE_LITTLE_ENDIAN && elementSize !== void 0) swapByteOrder(new Uint8Array(buffer), elementSize);\n switch (marker) {\n case \"ArrayBuffer\":\n return buffer;\n case \"DataView\":\n return new DataView(buffer);\n case \"Int8Array\":\n return new Int8Array(buffer);\n case \"Uint8Array\":\n return new Uint8Array(buffer);\n case \"Uint8ClampedArray\":\n return new Uint8ClampedArray(buffer);\n case \"Int16Array\":\n return new Int16Array(buffer);\n case \"Uint16Array\":\n return new Uint16Array(buffer);\n case \"Int32Array\":\n return new Int32Array(buffer);\n case \"Uint32Array\":\n return new Uint32Array(buffer);\n case \"BigInt64Array\":\n return new BigInt64Array(buffer);\n case \"BigUint64Array\":\n return new BigUint64Array(buffer);\n case \"Float32Array\":\n return new Float32Array(buffer);\n case \"Float64Array\":\n return new Float64Array(buffer);\n default:\n }\n }\n case \"error\":\n if (value.length >= 3 && typeof value[1] === \"string\" && typeof value[2] === \"string\") {\n let cls = ERROR_TYPES[value[1]] || Error;\n let result = cls === AggregateError ? new cls([], value[2]) : new cls(value[2]);\n if (typeof value[3] === \"string\") result.stack = value[3];\n if (value.length >= 5) {\n let props = value[4];\n if (!props || typeof props !== \"object\" || Array.isArray(props)) break;\n let anyResult = result;\n let propsObj = props;\n for (let key of Object.keys(propsObj)) {\n if (key === \"name\" || key === \"message\" || key === \"stack\") continue;\n if (key in Object.prototype || key === \"toJSON\") {\n this.evaluateImpl(propsObj[key], result, key, depth + 1);\n continue;\n }\n anyResult[key] = this.evaluateImpl(propsObj[key], result, key, depth + 1);\n }\n }\n return result;\n }\n break;\n case \"undefined\":\n if (value.length === 1) return;\n break;\n case \"inf\":\n return Infinity;\n case \"-inf\":\n return -Infinity;\n case \"nan\":\n return NaN;\n case \"url\":\n if (value.length === 2 && typeof value[1] === \"string\") return new URL(value[1]);\n break;\n case \"headers\":\n if (value.length === 2 && value[1] instanceof Array) return new Headers(value[1]);\n break;\n case \"request\": {\n if (value.length !== 3 || typeof value[1] !== \"string\") break;\n let url = value[1];\n let init = value[2];\n if (typeof init !== \"object\" || init === null) break;\n if (init.body) {\n init.body = this.evaluateImpl(init.body, init, \"body\", depth + 1);\n if (init.body === null || typeof init.body === \"string\" || init.body instanceof Uint8Array || init.body instanceof ReadableStream) {\n } else throw new TypeError(\"Request body must be of type ReadableStream.\");\n }\n if (init.signal) {\n init.signal = this.evaluateImpl(init.signal, init, \"signal\", depth + 1);\n if (!(init.signal instanceof AbortSignal)) throw new TypeError(\"Request siganl must be of type AbortSignal.\");\n }\n if (init.headers && !(init.headers instanceof Array)) throw new TypeError(\"Request headers must be serialized as an array of pairs.\");\n let result = new Request(url, init);\n if (init.body instanceof ReadableStream && result.body === void 0) {\n let promise = fixBrokenRequestBody(result, init.body);\n this.promises.push({\n promise,\n parent,\n property\n });\n return promise;\n } else return result;\n }\n case \"response\": {\n if (value.length !== 3) break;\n let body = this.evaluateImpl(value[1], parent, property, depth + 1);\n if (body === null || typeof body === \"string\" || body instanceof Uint8Array || body instanceof ReadableStream) {\n } else throw new TypeError(\"Response body must be of type ReadableStream.\");\n let init = value[2];\n if (typeof init !== \"object\" || init === null) break;\n if (init.webSocket) throw new TypeError(\"Can't deserialize a Response containing a webSocket.\");\n if (init.headers && !(init.headers instanceof Array)) throw new TypeError(\"Request headers must be serialized as an array of pairs.\");\n return new Response(body, init);\n }\n case \"blob\": {\n if (value.length !== 3 || typeof value[1] !== \"string\") break;\n let contentType = value[1];\n let content = this.evaluateImpl(value[2], parent, property, depth + 1);\n if (!(content instanceof ReadableStream)) throw new TypeError(\"Blob content must be serialized as a ReadableStream.\");\n let promise = streamToBlobPromise(content, contentType);\n this.promises.push({\n promise,\n parent,\n property\n });\n return promise;\n }\n case \"import\":\n case \"pipeline\": {\n if (value.length < 2 || value.length > 4) break;\n if (typeof value[1] != \"number\") break;\n let hook = this.importer.getExport(value[1]);\n if (!hook) throw new Error(`no such entry on exports table: ${value[1]}`);\n let isPromise = value[0] == \"pipeline\";\n let addStub = (hook2) => {\n if (isPromise) {\n let promise = new RpcPromise$1(hook2, []);\n this.promises.push({\n promise,\n parent,\n property\n });\n return promise;\n } else {\n this.hooks.push(hook2);\n return new RpcPromise$1(hook2, []);\n }\n };\n if (value.length == 2) if (isPromise) return addStub(hook.get([]));\n else return addStub(hook.dup());\n let path = value[2];\n if (!(path instanceof Array)) break;\n if (!path.every((part) => {\n return typeof part == \"string\" || typeof part == \"number\";\n })) break;\n if (value.length == 3) return addStub(hook.get(path));\n let args = value[3];\n if (!(args instanceof Array)) break;\n args = new Evaluator2(this.importer).evaluateWithDepth([args], depth);\n return addStub(hook.call(path, args));\n }\n case \"remap\": {\n if (value.length !== 5 || typeof value[1] !== \"number\" || !(value[2] instanceof Array) || !(value[3] instanceof Array) || !(value[4] instanceof Array)) break;\n let hook = this.importer.getExport(value[1]);\n if (!hook) throw new Error(`no such entry on exports table: ${value[1]}`);\n let path = value[2];\n if (!path.every((part) => {\n return typeof part == \"string\" || typeof part == \"number\";\n })) break;\n let captures = value[3].map((cap) => {\n if (!(cap instanceof Array) || cap.length !== 2 || cap[0] !== \"import\" && cap[0] !== \"export\" || typeof cap[1] !== \"number\") throw new TypeError(`unknown map capture: ${JSON.stringify(cap)}`);\n if (cap[0] === \"export\") return this.importer.importStub(cap[1]);\n else {\n let exp = this.importer.getExport(cap[1]);\n if (!exp) throw new Error(`no such entry on exports table: ${cap[1]}`);\n return exp.dup();\n }\n });\n let instructions = value[4];\n let promise = new RpcPromise$1(hook.map(path, captures, instructions), []);\n this.promises.push({\n promise,\n parent,\n property\n });\n return promise;\n }\n case \"export\":\n case \"promise\":\n if (typeof value[1] == \"number\") if (value[0] == \"promise\") {\n let promise = new RpcPromise$1(this.importer.importPromise(value[1]), []);\n this.promises.push({\n parent,\n property,\n promise\n });\n return promise;\n } else {\n let hook = this.importer.importStub(value[1]);\n this.hooks.push(hook);\n return new RpcStub$1(hook);\n }\n break;\n case \"writable\":\n if (typeof value[1] == \"number\") {\n let hook = this.importer.importStub(value[1]);\n let stream = streamImpl.createWritableStreamFromHook(hook);\n this.hooks.push(hook);\n return stream;\n }\n break;\n case \"readable\":\n if (typeof value[1] == \"number\") {\n let stream = this.importer.getPipeReadable(value[1]);\n let hook = streamImpl.createReadableStreamHook(stream);\n this.hooks.push(hook);\n return stream;\n }\n break;\n }\n throw new TypeError(`unknown special value: ${JSON.stringify(value)}`);\n } else if (value instanceof Object) {\n let result = value;\n for (let key in result) if (key in Object.prototype || key === \"toJSON\") {\n this.evaluateImpl(result[key], result, key, depth + 1);\n delete result[key];\n } else result[key] = this.evaluateImpl(result[key], result, key, depth + 1);\n return result;\n } else return value;\n }\n};\nvar ESTIMATED_OBJECT_OVERHEAD = 16;\nvar ESTIMATED_ENTRY_OVERHEAD = 8;\nvar ESTIMATED_BINARY_OVERHEAD = 16;\nvar MAX_ESTIMATE_DEPTH = 64;\nfunction estimateStringSize(value) {\n return 2 + value.length * 3;\n}\nfunction estimateEncodedSize(value, seen, depth = 0) {\n if (depth >= MAX_ESTIMATE_DEPTH) return ESTIMATED_ENTRY_OVERHEAD;\n switch (typeof value) {\n case \"string\":\n return estimateStringSize(value);\n case \"number\":\n return 16;\n case \"bigint\":\n return 16;\n case \"boolean\":\n return 8;\n case \"undefined\":\n return 16;\n case \"object\": {\n if (value === null) return 8;\n if (ArrayBuffer.isView(value)) return ESTIMATED_BINARY_OVERHEAD + value.byteLength;\n if (value instanceof ArrayBuffer) return ESTIMATED_BINARY_OVERHEAD + value.byteLength;\n if (typeof Blob !== \"undefined\" && value instanceof Blob) return ESTIMATED_BINARY_OVERHEAD + value.size;\n if (value instanceof Date) return 16;\n seen ??= /* @__PURE__ */ new WeakSet();\n if (seen.has(value)) return ESTIMATED_ENTRY_OVERHEAD;\n seen.add(value);\n if (value instanceof Array) {\n let size2 = ESTIMATED_OBJECT_OVERHEAD;\n for (let item of value) size2 += ESTIMATED_ENTRY_OVERHEAD + estimateEncodedSize(item, seen, depth + 1);\n return size2;\n }\n if (value instanceof Error) {\n let size2 = ESTIMATED_OBJECT_OVERHEAD + estimateStringSize(value.name) + estimateStringSize(value.message) + estimateStringSize(value.stack ?? \"\");\n for (let key of Object.keys(value)) size2 += ESTIMATED_ENTRY_OVERHEAD + estimateStringSize(key) + estimateEncodedSize(value[key], seen, depth + 1);\n return size2;\n }\n let size = ESTIMATED_OBJECT_OVERHEAD;\n for (let key of Object.keys(value)) size += ESTIMATED_ENTRY_OVERHEAD + estimateStringSize(key) + estimateEncodedSize(value[key], seen, depth + 1);\n return size;\n }\n default:\n return 16;\n }\n}\nvar ImportTableEntry = class {\n session;\n importId;\n constructor(session, importId, pulling) {\n this.session = session;\n this.importId = importId;\n if (pulling) this.activePull = Promise.withResolvers();\n }\n localRefcount = 0;\n remoteRefcount = 1;\n activePull;\n resolution;\n onBrokenRegistrations;\n resolve(resolution) {\n if (this.localRefcount == 0) {\n resolution.dispose();\n return;\n }\n this.resolution = resolution;\n this.sendRelease();\n if (this.onBrokenRegistrations) {\n for (let i of this.onBrokenRegistrations) {\n let callback = this.session.onBrokenCallbacks[i];\n let endIndex = this.session.onBrokenCallbacks.length;\n resolution.onBroken(callback);\n if (this.session.onBrokenCallbacks[endIndex] === callback) delete this.session.onBrokenCallbacks[endIndex];\n else delete this.session.onBrokenCallbacks[i];\n }\n this.onBrokenRegistrations = void 0;\n }\n if (this.activePull) {\n this.activePull.resolve();\n this.activePull = void 0;\n }\n }\n async awaitResolution() {\n if (!this.activePull) {\n this.session.sendPull(this.importId);\n this.activePull = Promise.withResolvers();\n }\n await this.activePull.promise;\n return this.resolution.pull();\n }\n dispose() {\n if (this.resolution) this.resolution.dispose();\n else {\n this.abort(/* @__PURE__ */ new Error(\"RPC was canceled because the RpcPromise was disposed.\"));\n this.sendRelease();\n }\n }\n abort(error) {\n if (!this.resolution) {\n this.resolution = new ErrorStubHook(error);\n if (this.activePull) {\n this.activePull.reject(error);\n this.activePull = void 0;\n }\n this.onBrokenRegistrations = void 0;\n }\n }\n onBroken(callback) {\n if (this.resolution) this.resolution.onBroken(callback);\n else {\n let index = this.session.onBrokenCallbacks.length;\n this.session.onBrokenCallbacks.push(callback);\n if (!this.onBrokenRegistrations) this.onBrokenRegistrations = [];\n this.onBrokenRegistrations.push(index);\n }\n }\n sendRelease() {\n if (this.remoteRefcount > 0) {\n this.session.sendRelease(this.importId, this.remoteRefcount);\n this.remoteRefcount = 0;\n }\n }\n};\nvar RpcImportHook = class RpcImportHook2 extends StubHook {\n isPromise;\n entry;\n constructor(isPromise, entry) {\n super();\n this.isPromise = isPromise;\n ++entry.localRefcount;\n this.entry = entry;\n }\n collectPath(path) {\n return this;\n }\n getEntry() {\n if (this.entry) return this.entry;\n else throw new Error(\"This RpcImportHook was already disposed.\");\n }\n getEntryTakingOwnership(disposeOwned) {\n try {\n return this.getEntry();\n } catch (err) {\n disposeOwned();\n throw err;\n }\n }\n call(path, args) {\n let entry = this.getEntryTakingOwnership(() => args.dispose());\n if (entry.resolution) return entry.resolution.call(path, args);\n else return entry.session.sendCall(entry.importId, path, args);\n }\n stream(path, args) {\n let entry = this.getEntryTakingOwnership(() => args.dispose());\n if (entry.resolution) return entry.resolution.stream(path, args);\n else return entry.session.sendStream(entry.importId, path, args);\n }\n map(path, captures, instructions) {\n let entry = this.getEntryTakingOwnership(() => {\n for (let cap of captures) cap.dispose();\n });\n if (entry.resolution) return entry.resolution.map(path, captures, instructions);\n else return entry.session.sendMap(entry.importId, path, captures, instructions);\n }\n get(path) {\n let entry = this.getEntry();\n if (entry.resolution) return entry.resolution.get(path);\n else return entry.session.sendCall(entry.importId, path);\n }\n dup() {\n return new RpcImportHook2(false, this.getEntry());\n }\n pull() {\n let entry = this.getEntry();\n if (!this.isPromise) throw new Error(\"Can't pull this hook because it's not a promise hook.\");\n if (entry.resolution) return entry.resolution.pull();\n return entry.awaitResolution();\n }\n ignoreUnhandledRejections() {\n }\n dispose() {\n let entry = this.entry;\n this.entry = void 0;\n if (entry) {\n if (--entry.localRefcount === 0) entry.dispose();\n }\n }\n onBroken(callback) {\n if (this.entry) this.entry.onBroken(callback);\n }\n};\nvar RpcMainHook = class extends RpcImportHook {\n session;\n constructor(entry) {\n super(false, entry);\n this.session = entry.session;\n }\n dispose() {\n if (this.session) {\n let session = this.session;\n this.session = void 0;\n session.shutdown();\n }\n }\n};\nvar RpcSessionImpl = class {\n transport;\n options;\n exports = [];\n reverseExports = /* @__PURE__ */ new Map();\n imports = [];\n abortReason;\n cancelReadLoop;\n nextExportId = -1;\n onBatchDone;\n pullCount = 0;\n onBrokenCallbacks = [];\n encodingLevel;\n limits;\n constructor(transport, mainHook, options) {\n this.transport = transport;\n this.options = options;\n let level = \"string\";\n if (\"encodingLevel\" in transport) {\n let raw = transport.encodingLevel;\n if (raw !== void 0) {\n if (raw !== \"string\" && raw !== \"jsonCompatible\" && raw !== \"jsonCompatibleWithBytes\" && raw !== \"structuredClonable\") throw new TypeError(`Unknown transport encodingLevel: ${String(raw)}`);\n level = raw;\n }\n }\n this.encodingLevel = level;\n this.limits = {\n ...DEFAULT_LIMITS,\n ...options.limits\n };\n this.exports.push({\n hook: mainHook,\n refcount: 1\n });\n this.imports.push(new ImportTableEntry(this, 0, false));\n this.readLoop().catch((err) => this.abort(err));\n }\n getMainImport() {\n return new RpcMainHook(this.imports[0]);\n }\n shutdown() {\n this.abort(/* @__PURE__ */ new Error(\"RPC session was shut down by disposing the main stub\"), false);\n }\n exportStub(hook) {\n if (this.abortReason) throw this.abortReason;\n let existingExportId = this.reverseExports.get(hook);\n if (existingExportId !== void 0) {\n ++this.exports[existingExportId].refcount;\n return existingExportId;\n } else {\n let exportId = this.nextExportId--;\n this.exports[exportId] = {\n hook,\n refcount: 1\n };\n this.reverseExports.set(hook, exportId);\n return exportId;\n }\n }\n exportPromise(hook) {\n if (this.abortReason) throw this.abortReason;\n let exportId = this.nextExportId--;\n this.exports[exportId] = {\n hook,\n refcount: 1\n };\n this.reverseExports.set(hook, exportId);\n this.ensureResolvingExport(exportId);\n return exportId;\n }\n unexport(ids) {\n for (let id of ids) this.releaseExport(id, 1);\n }\n releaseExport(exportId, refcount) {\n let entry = this.exports[exportId];\n if (!entry) throw new Error(`no such export ID: ${exportId}`);\n if (entry.refcount < refcount) throw new Error(`refcount would go negative: ${entry.refcount} < ${refcount}`);\n entry.refcount -= refcount;\n if (entry.refcount === 0) {\n delete this.exports[exportId];\n this.reverseExports.delete(entry.hook);\n entry.hook.dispose();\n }\n }\n onSendError(error) {\n if (this.options.onSendError) return this.options.onSendError(error);\n }\n ensureResolvingExport(exportId) {\n let exp = this.exports[exportId];\n if (!exp) throw new Error(`no such export ID: ${exportId}`);\n if (!exp.pull) {\n let resolve = async () => {\n let hook = exp.hook;\n for (; ; ) {\n let payload = await hook.pull();\n if (payload.value instanceof RpcStub$1) {\n let { hook: inner, pathIfPromise } = unwrapStubAndPath(payload.value);\n if (pathIfPromise && pathIfPromise.length == 0) {\n if (this.getImport(hook) === void 0) {\n hook = inner;\n continue;\n }\n }\n }\n return payload;\n }\n };\n let autoRelease = exp.autoRelease;\n ++this.pullCount;\n exp.pull = resolve().then((payload) => {\n let value = Devaluator.devaluate(payload.value, void 0, this, payload, this.encodingLevel);\n this.send([\n \"resolve\",\n exportId,\n value\n ]);\n if (autoRelease) this.releaseExport(exportId, 1);\n }, (error) => {\n this.send([\n \"reject\",\n exportId,\n Devaluator.devaluate(error, void 0, this, void 0, this.encodingLevel)\n ]);\n if (autoRelease) this.releaseExport(exportId, 1);\n }).catch((error) => {\n try {\n this.send([\n \"reject\",\n exportId,\n Devaluator.devaluate(error, void 0, this, void 0, this.encodingLevel)\n ]);\n if (autoRelease) this.releaseExport(exportId, 1);\n } catch (error2) {\n this.abort(error2);\n }\n }).finally(() => {\n if (--this.pullCount === 0) {\n if (this.onBatchDone) this.onBatchDone.resolve();\n }\n });\n }\n }\n getImport(hook) {\n if (hook instanceof RpcImportHook && hook.entry && hook.entry.session === this) return hook.entry.importId;\n else return;\n }\n importStub(idx) {\n if (this.abortReason) throw this.abortReason;\n let entry = this.imports[idx];\n if (!entry) {\n entry = new ImportTableEntry(this, idx, false);\n this.imports[idx] = entry;\n }\n return new RpcImportHook(false, entry);\n }\n importPromise(idx) {\n if (this.abortReason) throw this.abortReason;\n if (this.imports[idx]) return new ErrorStubHook(/* @__PURE__ */ new Error(\"Bug in RPC system: The peer sent a promise reusing an existing export ID.\"));\n let entry = new ImportTableEntry(this, idx, true);\n this.imports[idx] = entry;\n return new RpcImportHook(true, entry);\n }\n getExport(idx) {\n return this.exports[idx]?.hook;\n }\n getPipeReadable(exportId) {\n let entry = this.exports[exportId];\n if (!entry || !entry.pipeReadable) throw new Error(`Export ${exportId} is not a pipe or its readable end was already consumed.`);\n let readable = entry.pipeReadable;\n entry.pipeReadable = void 0;\n return readable;\n }\n getLimits() {\n return this.limits;\n }\n createPipe(readable, readableHook) {\n if (this.abortReason) throw this.abortReason;\n this.send([\"pipe\"]);\n let importId = this.imports.length;\n let entry = new ImportTableEntry(this, importId, false);\n this.imports.push(entry);\n let hook = new RpcImportHook(false, entry);\n let writable = streamImpl.createWritableStreamFromHook(hook);\n readable.pipeTo(writable).catch(() => {\n }).finally(() => readableHook.dispose());\n return importId;\n }\n send(msg) {\n if (this.abortReason !== void 0) return 0;\n if (this.encodingLevel === \"string\") {\n let msgText;\n try {\n msgText = JSON.stringify(msg);\n } catch (err) {\n try {\n this.abort(err);\n } catch (err2) {\n }\n throw err;\n }\n try {\n let sent = this.transport.send(msgText);\n if (sent !== void 0 && typeof sent.catch === \"function\") sent.catch((err) => this.abort(err, false));\n } catch (err) {\n queueMicrotask(() => this.abort(err, false));\n }\n return msgText.length;\n } else try {\n let size = this.transport.send(msg);\n if (typeof size === \"number\") return size;\n let thenable = size;\n if (thenable && typeof thenable.then === \"function\") Promise.resolve(thenable).catch((err) => this.abort(err, false));\n return;\n } catch (err) {\n queueMicrotask(() => this.abort(err, false));\n return;\n }\n }\n sendCall(id, path, args) {\n if (this.abortReason) {\n args?.dispose();\n throw this.abortReason;\n }\n let value = [\n \"pipeline\",\n id,\n path\n ];\n if (args) {\n let devalue;\n try {\n devalue = Devaluator.devaluate(args.value, void 0, this, args, this.encodingLevel);\n } catch (err) {\n args.dispose();\n throw err;\n }\n value.push(devalue[0]);\n }\n this.send([\"push\", value]);\n let entry = new ImportTableEntry(this, this.imports.length, false);\n this.imports.push(entry);\n return new RpcImportHook(true, entry);\n }\n sendStream(id, path, args) {\n if (this.abortReason) {\n args.dispose();\n throw this.abortReason;\n }\n let value = [\n \"pipeline\",\n id,\n path\n ];\n let devalue;\n try {\n devalue = Devaluator.devaluate(args.value, void 0, this, args, this.encodingLevel);\n } catch (err) {\n args.dispose();\n throw err;\n }\n value.push(devalue[0]);\n let msg = [\"stream\", value];\n let size = this.send(msg);\n if (size === void 0) size = estimateEncodedSize(msg);\n let importId = this.imports.length;\n let entry = new ImportTableEntry(this, importId, true);\n entry.remoteRefcount = 0;\n entry.localRefcount = 1;\n this.imports.push(entry);\n return {\n promise: entry.awaitResolution().then((p) => {\n p.dispose();\n delete this.imports[importId];\n }, (err) => {\n delete this.imports[importId];\n throw err;\n }),\n size\n };\n }\n sendMap(id, path, captures, instructions) {\n if (this.abortReason) {\n for (let cap of captures) cap.dispose();\n throw this.abortReason;\n }\n let value = [\n \"remap\",\n id,\n path,\n captures.map((hook) => {\n let importId = this.getImport(hook);\n if (importId !== void 0) return [\"import\", importId];\n else return [\"export\", this.exportStub(hook)];\n }),\n instructions\n ];\n this.send([\"push\", value]);\n let entry = new ImportTableEntry(this, this.imports.length, false);\n this.imports.push(entry);\n return new RpcImportHook(true, entry);\n }\n sendPull(id) {\n if (this.abortReason) throw this.abortReason;\n this.send([\"pull\", id]);\n }\n sendRelease(id, remoteRefcount) {\n if (this.abortReason) return;\n this.send([\n \"release\",\n id,\n remoteRefcount\n ]);\n delete this.imports[id];\n }\n abort(error, trySendAbortMessage = true) {\n if (this.abortReason !== void 0) return;\n this.cancelReadLoop?.(error);\n this.cancelReadLoop = void 0;\n if (trySendAbortMessage) try {\n let abortMsg = [\"abort\", Devaluator.devaluate(error, void 0, this, void 0, this.encodingLevel)];\n if (this.encodingLevel === \"string\") {\n let sent = this.transport.send(JSON.stringify(abortMsg));\n if (sent !== void 0 && typeof sent.catch === \"function\") sent.catch((err) => {\n });\n } else {\n let result = this.transport.send(abortMsg);\n if (result && typeof result.then === \"function\") Promise.resolve(result).catch((err) => {\n });\n }\n } catch (err) {\n }\n if (error === void 0) error = \"undefined\";\n this.abortReason = error;\n if (this.onBatchDone) this.onBatchDone.reject(error);\n if (this.transport.abort) try {\n this.transport.abort(error);\n } catch (err) {\n Promise.resolve(err);\n }\n for (let i in this.onBrokenCallbacks) try {\n this.onBrokenCallbacks[i](error);\n } catch (err) {\n Promise.resolve(err);\n }\n for (let i in this.imports) this.imports[i].abort(error);\n for (let i in this.exports) this.exports[i].hook.dispose();\n }\n async readLoop() {\n while (!this.abortReason) {\n let readCanceled = Promise.withResolvers();\n this.cancelReadLoop = readCanceled.reject;\n let raw;\n try {\n raw = await Promise.race([this.transport.receive(), readCanceled.promise]);\n } finally {\n if (this.cancelReadLoop === readCanceled.reject) this.cancelReadLoop = void 0;\n }\n if (this.encodingLevel === \"string\" && raw.length > this.limits.maxMessageSize) throw new TypeError(`Incoming message exceeds maximum size of ${this.limits.maxMessageSize} UTF-16 code units.`);\n if (this.abortReason) break;\n let msg = this.encodingLevel === \"string\" ? JSON.parse(raw) : raw;\n if (msg instanceof Array) switch (msg[0]) {\n case \"push\":\n if (msg.length > 1) {\n let hook = new PayloadStubHook(new Evaluator(this, this.encodingLevel).evaluate(msg[1]));\n hook.ignoreUnhandledRejections();\n this.exports.push({\n hook,\n refcount: 1\n });\n continue;\n }\n break;\n case \"stream\":\n if (msg.length > 1) {\n let hook = new PayloadStubHook(new Evaluator(this, this.encodingLevel).evaluate(msg[1]));\n hook.ignoreUnhandledRejections();\n let exportId = this.exports.length;\n this.exports.push({\n hook,\n refcount: 1,\n autoRelease: true\n });\n this.ensureResolvingExport(exportId);\n continue;\n }\n break;\n case \"pipe\": {\n let { readable, writable } = new TransformStream();\n let hook = streamImpl.createWritableStreamHook(writable);\n this.exports.push({\n hook,\n refcount: 1,\n pipeReadable: readable\n });\n continue;\n }\n case \"pull\": {\n let exportId = msg[1];\n if (typeof exportId == \"number\") {\n this.ensureResolvingExport(exportId);\n continue;\n }\n break;\n }\n case \"resolve\":\n case \"reject\": {\n let importId = msg[1];\n if (typeof importId == \"number\" && msg.length > 2) {\n let imp = this.imports[importId];\n if (imp) if (msg[0] == \"resolve\") imp.resolve(new PayloadStubHook(new Evaluator(this, this.encodingLevel).evaluate(msg[2])));\n else {\n let payload = new Evaluator(this, this.encodingLevel).evaluate(msg[2]);\n payload.dispose();\n imp.resolve(new ErrorStubHook(payload.value));\n }\n else if (msg[0] == \"resolve\") new Evaluator(this, this.encodingLevel).evaluate(msg[2]).dispose();\n continue;\n }\n break;\n }\n case \"release\": {\n let exportId = msg[1];\n let refcount = msg[2];\n if (typeof exportId == \"number\" && typeof refcount == \"number\") {\n this.releaseExport(exportId, refcount);\n continue;\n }\n break;\n }\n case \"abort\": {\n let payload = new Evaluator(this, this.encodingLevel).evaluate(msg[1]);\n payload.dispose();\n this.abort(payload.value, false);\n break;\n }\n }\n throw new Error(`bad RPC message: ${JSON.stringify(msg)}`);\n }\n }\n async drain() {\n if (this.abortReason) throw this.abortReason;\n if (this.pullCount > 0) {\n let { promise, resolve, reject } = Promise.withResolvers();\n this.onBatchDone = {\n resolve,\n reject\n };\n await promise;\n }\n }\n getStats() {\n let result = {\n imports: 0,\n exports: 0\n };\n for (let i in this.imports) ++result.imports;\n for (let i in this.exports) ++result.exports;\n return result;\n }\n};\nvar RpcSession$1 = class {\n #session;\n #mainStub;\n constructor(transport, localMain, options = {}) {\n let mainHook;\n if (localMain) mainHook = new PayloadStubHook(RpcPayload.fromAppReturn(localMain));\n else mainHook = new ErrorStubHook(/* @__PURE__ */ new Error(\"This connection has no main object.\"));\n this.#session = new RpcSessionImpl(transport, mainHook, options);\n this.#mainStub = new RpcStub$1(this.#session.getMainImport());\n }\n getRemoteMain() {\n return this.#mainStub;\n }\n getStats() {\n return this.#session.getStats();\n }\n drain() {\n return this.#session.drain();\n }\n};\nfunction newWebSocketRpcSession$1(webSocket, localMain, options) {\n if (typeof webSocket === \"string\") webSocket = new WebSocket(webSocket);\n return new RpcSession$1(new WebSocketTransport(webSocket), localMain, options).getRemoteMain();\n}\nfunction newWorkersWebSocketRpcResponse(request, localMain, options) {\n if (request.headers.get(\"Upgrade\")?.toLowerCase() !== \"websocket\") return new Response(\"This endpoint only accepts WebSocket requests.\", { status: 400 });\n let pair = new WebSocketPair();\n let server = pair[0];\n server.accept();\n newWebSocketRpcSession$1(server, localMain, options);\n return new Response(null, {\n status: 101,\n webSocket: pair[1]\n });\n}\nvar WebSocketTransport = class {\n constructor(webSocket) {\n this.#webSocket = webSocket;\n webSocket.binaryType = \"arraybuffer\";\n if (webSocket.readyState === WebSocket.CONNECTING) {\n this.#sendQueue = [];\n webSocket.addEventListener(\"open\", (event) => {\n try {\n for (let message of this.#sendQueue) webSocket.send(message);\n } catch (err) {\n this.#receivedError(err);\n }\n this.#sendQueue = void 0;\n });\n }\n webSocket.addEventListener(\"message\", (event) => {\n if (this.#error) {\n } else if (typeof event.data === \"string\" || event.data instanceof ArrayBuffer) if (this.#receiveResolver) {\n this.#receiveResolver(event.data);\n this.#receiveResolver = void 0;\n this.#receiveRejecter = void 0;\n } else this.#receiveQueue.push(event.data);\n else this.#receivedError(/* @__PURE__ */ new TypeError(\"Received unexpected message type from WebSocket.\"));\n });\n webSocket.addEventListener(\"close\", (event) => {\n this.#receivedError(/* @__PURE__ */ new Error(`Peer closed WebSocket: ${event.code} ${event.reason}`));\n });\n webSocket.addEventListener(\"error\", (event) => {\n this.#receivedError(/* @__PURE__ */ new Error(`WebSocket connection failed.`));\n });\n }\n #webSocket;\n #sendQueue;\n #receiveResolver;\n #receiveRejecter;\n #receiveQueue = [];\n #error;\n send(message) {\n if (this.#sendQueue === void 0) this.#webSocket.send(message);\n else this.#sendQueue.push(message);\n }\n receive() {\n if (this.#receiveQueue.length > 0) return Promise.resolve(this.#receiveQueue.shift());\n else if (this.#error) return Promise.reject(this.#error);\n else return new Promise((resolve, reject) => {\n this.#receiveResolver = resolve;\n this.#receiveRejecter = reject;\n });\n }\n abort(reason) {\n let message;\n if (reason instanceof Error) message = reason.message;\n else message = `${reason}`;\n let reasonBytes = new TextEncoder().encode(message);\n if (reasonBytes.length > 123) message = new TextDecoder().decode(reasonBytes.subarray(0, 123), { stream: true });\n this.#webSocket.close(3e3, message);\n if (!this.#error) this.#error = reason;\n }\n #receivedError(reason) {\n if (!this.#error) {\n this.#error = reason;\n if (this.#receiveRejecter) {\n this.#receiveRejecter(reason);\n this.#receiveResolver = void 0;\n this.#receiveRejecter = void 0;\n }\n }\n }\n};\nvar BatchServerTransport = class {\n constructor(batch) {\n this.#batchToReceive = batch;\n }\n #batchToSend = [];\n #batchToReceive;\n #allReceived = Promise.withResolvers();\n send(message) {\n this.#batchToSend.push(message);\n }\n async receive() {\n let msg = this.#batchToReceive.shift();\n if (msg !== void 0) return msg;\n else {\n this.#allReceived.resolve();\n return new Promise((r) => {\n });\n }\n }\n abort(reason) {\n this.#allReceived.reject(reason);\n }\n whenAllReceived() {\n return this.#allReceived.promise;\n }\n getResponseBody() {\n return this.#batchToSend.join(\"\\n\");\n }\n};\nasync function newHttpBatchRpcResponse(request, localMain, options) {\n if (request.method !== \"POST\") return new Response(\"This endpoint only accepts POST requests.\", { status: 405 });\n let body = await request.text();\n let transport = new BatchServerTransport(body === \"\" ? [] : body.split(\"\\n\"));\n let rpc = new RpcSession$1(transport, localMain, options);\n await transport.whenAllReceived();\n await rpc.drain();\n return new Response(transport.getResponseBody());\n}\nvar currentMapBuilder;\nvar MapBuilder = class {\n context;\n captureMap = /* @__PURE__ */ new Map();\n instructions = [];\n constructor(subject, path) {\n if (currentMapBuilder) this.context = {\n parent: currentMapBuilder,\n captures: [],\n subject: currentMapBuilder.capture(subject),\n path\n };\n else this.context = {\n parent: void 0,\n captures: [],\n subject,\n path\n };\n currentMapBuilder = this;\n }\n unregister() {\n currentMapBuilder = this.context.parent;\n }\n makeInput() {\n return new MapVariableHook(this, 0);\n }\n makeOutput(result) {\n let devalued;\n try {\n devalued = Devaluator.devaluate(result.value, void 0, this, result);\n } finally {\n result.dispose();\n }\n this.instructions.push(devalued);\n if (this.context.parent) {\n this.context.parent.instructions.push([\n \"remap\",\n this.context.subject,\n this.context.path,\n this.context.captures.map((cap) => [\"import\", cap]),\n this.instructions\n ]);\n return new MapVariableHook(this.context.parent, this.context.parent.instructions.length);\n } else return this.context.subject.map(this.context.path, this.context.captures, this.instructions);\n }\n pushCall(hook, path, params) {\n let devalued = Devaluator.devaluate(params.value, void 0, this, params);\n devalued = devalued[0];\n let subject = this.capture(hook.dup());\n this.instructions.push([\n \"pipeline\",\n subject,\n path,\n devalued\n ]);\n return new MapVariableHook(this, this.instructions.length);\n }\n pushGet(hook, path) {\n let subject = this.capture(hook.dup());\n this.instructions.push([\n \"pipeline\",\n subject,\n path\n ]);\n return new MapVariableHook(this, this.instructions.length);\n }\n capture(hook) {\n if (hook instanceof MapVariableHook && hook.mapper === this) return hook.idx;\n let result = this.captureMap.get(hook);\n if (result === void 0) {\n if (this.context.parent) {\n let parentIdx = this.context.parent.capture(hook);\n this.context.captures.push(parentIdx);\n } else this.context.captures.push(hook);\n result = -this.context.captures.length;\n this.captureMap.set(hook, result);\n }\n return result;\n }\n exportStub(hook) {\n throw new Error(\"Can't construct an RpcTarget or RPC callback inside a mapper function. Try creating a new RpcStub outside the callback first, then using it inside the callback.\");\n }\n exportPromise(hook) {\n return this.exportStub(hook);\n }\n getImport(hook) {\n return this.capture(hook);\n }\n unexport(ids) {\n }\n createPipe(readable) {\n throw new Error(\"Cannot send ReadableStream inside a mapper function.\");\n }\n onSendError(error) {\n }\n};\nmapImpl.sendMap = (hook, path, func) => {\n let builder = new MapBuilder(hook, path);\n let result;\n try {\n result = RpcPayload.fromAppReturn(withCallInterceptor(builder.pushCall.bind(builder), () => {\n return func(new RpcPromise$1(builder.makeInput(), []));\n }));\n } finally {\n builder.unregister();\n }\n if (result instanceof Promise) {\n result.catch((err) => {\n });\n throw new Error(\"RPC map() callbacks cannot be async.\");\n }\n return new RpcPromise$1(builder.makeOutput(result), []);\n};\nfunction throwMapperBuilderUseError() {\n throw new Error(\"Attempted to use an abstract placeholder from a mapper function. Please make sure your map function has no side effects.\");\n}\nvar MapVariableHook = class extends StubHook {\n mapper;\n idx;\n constructor(mapper, idx) {\n super();\n this.mapper = mapper;\n this.idx = idx;\n }\n dup() {\n return this;\n }\n dispose() {\n }\n get(path) {\n if (path.length == 0) return this;\n else if (currentMapBuilder) return currentMapBuilder.pushGet(this, path);\n else throwMapperBuilderUseError();\n }\n call(path, args) {\n args.dispose();\n throwMapperBuilderUseError();\n }\n map(path, captures, instructions) {\n for (let cap of captures) cap.dispose();\n throwMapperBuilderUseError();\n }\n pull() {\n throwMapperBuilderUseError();\n }\n ignoreUnhandledRejections() {\n }\n onBroken(callback) {\n throwMapperBuilderUseError();\n }\n};\nvar MapApplicator = class {\n captures;\n variables;\n constructor(captures, input) {\n this.captures = captures;\n this.variables = [input];\n }\n dispose() {\n for (let variable of this.variables) variable.dispose();\n }\n apply(instructions) {\n try {\n if (instructions.length < 1) throw new Error(\"Invalid empty mapper function.\");\n for (let instruction of instructions.slice(0, -1)) {\n let payload = new Evaluator(this).evaluateCopy(instruction);\n if (payload.value instanceof RpcStub$1) {\n let hook = unwrapStubNoProperties(payload.value);\n if (hook) {\n this.variables.push(hook);\n continue;\n }\n }\n this.variables.push(new PayloadStubHook(payload));\n }\n return new Evaluator(this).evaluateCopy(instructions[instructions.length - 1]);\n } finally {\n for (let variable of this.variables) variable.dispose();\n }\n }\n importStub(idx) {\n throw new Error(\"A mapper function cannot refer to exports.\");\n }\n importPromise(idx) {\n return this.importStub(idx);\n }\n getExport(idx) {\n if (idx < 0) return this.captures[-idx - 1];\n else return this.variables[idx];\n }\n getPipeReadable(exportId) {\n throw new Error(\"A mapper function cannot use pipe readables.\");\n }\n getLimits() {\n return DEFAULT_LIMITS;\n }\n};\nfunction applyMapToElement(input, parent, owner, captures, instructions) {\n let mapper = new MapApplicator(captures, new PayloadStubHook(RpcPayload.deepCopyFrom(input, parent, owner)));\n try {\n return mapper.apply(instructions);\n } finally {\n mapper.dispose();\n }\n}\nmapImpl.applyMap = (input, parent, owner, captures, instructions) => {\n try {\n let result;\n if (input instanceof RpcPromise$1) throw new Error(\"applyMap() can't be called on RpcPromise\");\n else if (input instanceof Array) {\n let payloads = [];\n try {\n for (let elem of input) payloads.push(applyMapToElement(elem, input, owner, captures, instructions));\n } catch (err) {\n for (let payload of payloads) payload.dispose();\n throw err;\n }\n result = RpcPayload.fromArray(payloads);\n } else if (input === null || input === void 0) result = RpcPayload.fromAppReturn(input);\n else result = applyMapToElement(input, parent, owner, captures, instructions);\n return new PayloadStubHook(result);\n } finally {\n for (let cap of captures) cap.dispose();\n }\n};\nvar WritableStreamStubHook = class WritableStreamStubHook2 extends StubHook {\n state;\n static create(stream) {\n return new WritableStreamStubHook2({\n refcount: 1,\n writer: stream.getWriter(),\n closed: false\n });\n }\n constructor(state, dupFrom) {\n super();\n this.state = state;\n if (dupFrom) ++state.refcount;\n }\n getState() {\n if (this.state) return this.state;\n else throw new Error(\"Attempted to use a WritableStreamStubHook after it was disposed.\");\n }\n call(path, args) {\n try {\n let state = this.getState();\n if (path.length !== 1 || typeof path[0] !== \"string\") throw new Error(\"WritableStream stub only supports direct method calls\");\n const method = path[0];\n if (method !== \"write\" && method !== \"close\" && method !== \"abort\") throw new Error(`Unknown WritableStream method: ${method}`);\n if (method === \"close\" || method === \"abort\") state.closed = true;\n return new PromiseStubHook((method === \"write\" ? args.deliverStreamWrite(state.writer) : args.deliverCall(state.writer[method], state.writer)).then((payload) => new PayloadStubHook(payload)));\n } catch (err) {\n args.dispose();\n return new ErrorStubHook(err);\n }\n }\n map(path, captures, instructions) {\n for (let cap of captures) cap.dispose();\n return new ErrorStubHook(/* @__PURE__ */ new Error(\"Cannot use map() on a WritableStream\"));\n }\n get(path) {\n return new ErrorStubHook(/* @__PURE__ */ new Error(\"Cannot access properties on a WritableStream stub\"));\n }\n dup() {\n return new WritableStreamStubHook2(this.getState(), this);\n }\n pull() {\n return Promise.reject(/* @__PURE__ */ new Error(\"Cannot pull a WritableStream stub\"));\n }\n ignoreUnhandledRejections() {\n }\n dispose() {\n let state = this.state;\n this.state = void 0;\n if (state) {\n if (--state.refcount === 0) {\n if (!state.closed) state.writer.abort(/* @__PURE__ */ new Error(\"WritableStream RPC stub was disposed without calling close()\")).catch(() => {\n });\n state.writer.releaseLock();\n }\n }\n }\n onBroken(callback) {\n }\n};\nvar INITIAL_WINDOW = 256 * 1024;\nvar MAX_WINDOW = 1024 * 1024 * 1024;\nvar MIN_WINDOW = 64 * 1024;\nvar STARTUP_GROWTH_FACTOR = 2;\nvar STEADY_GROWTH_FACTOR = 1.25;\nvar DECAY_FACTOR = 0.9;\nvar STARTUP_EXIT_ROUNDS = 3;\nvar FlowController = class {\n now;\n window = INITIAL_WINDOW;\n bytesInFlight = 0;\n inStartupPhase = true;\n delivered = 0;\n deliveredTime = 0;\n firstAckTime = 0;\n firstAckDelivered = 0;\n minRtt = Infinity;\n roundsWithoutIncrease = 0;\n lastRoundWindow = 0;\n roundStartTime = 0;\n constructor(now) {\n this.now = now;\n }\n onSend(size) {\n this.bytesInFlight += size;\n let token = {\n sentTime: this.now(),\n size,\n deliveredAtSend: this.delivered,\n deliveredTimeAtSend: this.deliveredTime,\n windowAtSend: this.window,\n windowFullAtSend: this.bytesInFlight >= this.window\n };\n return {\n token,\n shouldBlock: token.windowFullAtSend\n };\n }\n onError(token) {\n this.bytesInFlight -= token.size;\n }\n onAck(token) {\n let ackTime = this.now();\n this.delivered += token.size;\n this.deliveredTime = ackTime;\n this.bytesInFlight -= token.size;\n let rtt = ackTime - token.sentTime;\n this.minRtt = Math.min(this.minRtt, rtt);\n if (this.firstAckTime === 0) {\n this.firstAckTime = ackTime;\n this.firstAckDelivered = this.delivered;\n } else {\n let baseTime;\n let baseDelivered;\n if (token.deliveredTimeAtSend === 0) {\n baseTime = this.firstAckTime;\n baseDelivered = this.firstAckDelivered;\n } else {\n baseTime = token.deliveredTimeAtSend;\n baseDelivered = token.deliveredAtSend;\n }\n let interval = ackTime - baseTime;\n let bandwidth = (this.delivered - baseDelivered) / interval;\n let growthFactor = this.inStartupPhase ? STARTUP_GROWTH_FACTOR : STEADY_GROWTH_FACTOR;\n let newWindow = bandwidth * this.minRtt * growthFactor;\n newWindow = Math.min(newWindow, token.windowAtSend * growthFactor);\n if (token.windowFullAtSend) newWindow = Math.max(newWindow, token.windowAtSend * DECAY_FACTOR);\n else newWindow = Math.max(newWindow, this.window);\n this.window = Math.max(Math.min(newWindow, MAX_WINDOW), MIN_WINDOW);\n if (this.inStartupPhase && token.sentTime >= this.roundStartTime) {\n if (this.window > this.lastRoundWindow * STEADY_GROWTH_FACTOR) this.roundsWithoutIncrease = 0;\n else if (++this.roundsWithoutIncrease >= STARTUP_EXIT_ROUNDS) this.inStartupPhase = false;\n this.roundStartTime = ackTime;\n this.lastRoundWindow = this.window;\n }\n }\n return this.bytesInFlight < this.window;\n }\n};\nfunction createWritableStreamFromHook(hook) {\n let pendingError = void 0;\n let hookDisposed = false;\n let fc = new FlowController(() => performance.now());\n let windowResolve;\n let windowReject;\n const disposeHook = () => {\n if (!hookDisposed) {\n hookDisposed = true;\n hook.dispose();\n }\n };\n return new WritableStream({\n write(chunk, controller) {\n if (pendingError !== void 0) throw pendingError;\n const payload = RpcPayload.fromAppParams([chunk]);\n const { promise, size } = hook.stream([\"write\"], payload);\n if (size === void 0) return promise.catch((err) => {\n if (pendingError === void 0) pendingError = err;\n throw err;\n });\n else {\n let { token, shouldBlock } = fc.onSend(size);\n promise.then(() => {\n if (fc.onAck(token) && windowResolve) {\n windowResolve();\n windowResolve = void 0;\n windowReject = void 0;\n }\n }, (err) => {\n fc.onError(token);\n if (pendingError === void 0) {\n pendingError = err;\n controller.error(err);\n disposeHook();\n }\n if (windowReject) {\n windowReject(err);\n windowResolve = void 0;\n windowReject = void 0;\n }\n });\n if (shouldBlock) return new Promise((resolve, reject) => {\n windowResolve = resolve;\n windowReject = reject;\n });\n }\n },\n async close() {\n if (pendingError !== void 0) {\n disposeHook();\n throw pendingError;\n }\n const { promise } = hook.stream([\"close\"], RpcPayload.fromAppParams([]));\n try {\n await promise;\n } catch (err) {\n throw pendingError ?? err;\n } finally {\n disposeHook();\n }\n },\n abort(reason) {\n if (pendingError !== void 0) return;\n pendingError = reason ?? /* @__PURE__ */ new Error(\"WritableStream was aborted\");\n if (windowReject) {\n windowReject(pendingError);\n windowResolve = void 0;\n windowReject = void 0;\n }\n const { promise } = hook.stream([\"abort\"], RpcPayload.fromAppParams([reason]));\n promise.then(() => disposeHook(), () => disposeHook());\n }\n });\n}\nvar ReadableStreamStubHook = class ReadableStreamStubHook2 extends StubHook {\n state;\n static create(stream) {\n return new ReadableStreamStubHook2({\n refcount: 1,\n stream,\n canceled: false\n });\n }\n constructor(state, dupFrom) {\n super();\n this.state = state;\n if (dupFrom) ++state.refcount;\n }\n call(path, args) {\n args.dispose();\n return new ErrorStubHook(/* @__PURE__ */ new Error(\"Cannot call methods on a ReadableStream stub\"));\n }\n map(path, captures, instructions) {\n for (let cap of captures) cap.dispose();\n return new ErrorStubHook(/* @__PURE__ */ new Error(\"Cannot use map() on a ReadableStream\"));\n }\n get(path) {\n return new ErrorStubHook(/* @__PURE__ */ new Error(\"Cannot access properties on a ReadableStream stub\"));\n }\n dup() {\n let state = this.state;\n if (!state) throw new Error(\"Attempted to dup a ReadableStreamStubHook after it was disposed.\");\n return new ReadableStreamStubHook2(state, this);\n }\n pull() {\n return Promise.reject(/* @__PURE__ */ new Error(\"Cannot pull a ReadableStream stub\"));\n }\n ignoreUnhandledRejections() {\n }\n dispose() {\n let state = this.state;\n this.state = void 0;\n if (state) {\n if (--state.refcount === 0) {\n if (!state.canceled) {\n state.canceled = true;\n if (!state.stream.locked) state.stream.cancel(/* @__PURE__ */ new Error(\"ReadableStream RPC stub was disposed without being consumed\")).catch(() => {\n });\n }\n }\n }\n }\n onBroken(callback) {\n }\n};\nstreamImpl.createWritableStreamHook = WritableStreamStubHook.create;\nstreamImpl.createWritableStreamFromHook = createWritableStreamFromHook;\nstreamImpl.createReadableStreamHook = ReadableStreamStubHook.create;\nasync function newWorkersRpcResponse(request, localMain, options) {\n if (request.method === \"POST\") {\n let response = await newHttpBatchRpcResponse(request, localMain, options);\n response.headers.set(\"Access-Control-Allow-Origin\", \"*\");\n return response;\n } else if (request.headers.get(\"Upgrade\")?.toLowerCase() === \"websocket\") return newWorkersWebSocketRpcResponse(request, localMain, options);\n else return new Response(\"This endpoint only accepts POST or WebSocket requests.\", { status: 400 });\n}\n\n// templates/remoteBindings/ProxyServerWorker.ts\nimport { EmailMessage } from \"cloudflare:email\";\nvar BindingNotFoundError = class extends Error {\n constructor(name) {\n super(`Binding ${name ? `\"${name}\"` : \"\"} not found`);\n }\n};\nfunction getExposedJSRPCBinding(request, env) {\n const url = new URL(request.url);\n const bindingName = url.searchParams.get(\"MF-Binding\");\n if (!bindingName) {\n throw new BindingNotFoundError();\n }\n const targetBinding = env[bindingName];\n if (!targetBinding) {\n throw new BindingNotFoundError(bindingName);\n }\n if (targetBinding.constructor.name === \"Hyperdrive\") {\n const hyperdrive = targetBinding;\n return {\n getConnectionString() {\n return hyperdrive.connectionString;\n },\n connect() {\n const socket = hyperdrive.connect();\n return { readable: socket.readable, writable: socket.writable };\n }\n };\n }\n if (targetBinding.constructor.name === \"AnalyticsEngine\") {\n const dataset = targetBinding;\n return {\n writeDataPoint(event) {\n dataset.writeDataPoint(event);\n }\n };\n }\n if (targetBinding.constructor.name === \"SendEmail\") {\n return {\n async send(e) {\n if (\"EmailMessage::raw\" in e) {\n const message = new EmailMessage(\n e.from,\n e.to,\n e[\"EmailMessage::raw\"]\n );\n return targetBinding.send(message);\n } else {\n return targetBinding.send(e);\n }\n }\n };\n }\n const dispatchNamespaceOptions = url.searchParams.get(\n \"MF-Dispatch-Namespace-Options\"\n );\n if (dispatchNamespaceOptions) {\n const { name, args, options } = JSON.parse(dispatchNamespaceOptions);\n return targetBinding.get(name, args, options);\n }\n return targetBinding;\n}\nfunction getExposedFetcher(request, env) {\n const bindingName = request.headers.get(\"MF-Binding\");\n if (!bindingName) {\n throw new BindingNotFoundError();\n }\n const targetBinding = env[bindingName];\n if (!targetBinding) {\n throw new BindingNotFoundError(bindingName);\n }\n const dispatchNamespaceOptions = request.headers.get(\n \"MF-Dispatch-Namespace-Options\"\n );\n if (dispatchNamespaceOptions) {\n const { name, args, options } = JSON.parse(dispatchNamespaceOptions);\n return targetBinding.get(name, args, options);\n }\n return targetBinding;\n}\nfunction isJSRPCBinding(request) {\n const url = new URL(request.url);\n return request.headers.has(\"Upgrade\") && url.searchParams.has(\"MF-Binding\");\n}\nfunction isConnectBinding(request) {\n return request.headers.get(\"Upgrade\") === \"websocket\" && request.headers.has(\"MF-Connect-Address\");\n}\nfunction handleConnect(request, env) {\n const address = request.headers.get(\"MF-Connect-Address\");\n if (address === null) {\n return new Response(\"Missing MF-Connect-Address header\", { status: 400 });\n }\n const fetcher = getExposedFetcher(request, env);\n const { 0: client, 1: server } = new WebSocketPair();\n server.accept();\n const socket = fetcher.connect(address);\n pipeSocketOverWebSocket(socket, server).catch(() => {\n });\n return new Response(null, { status: 101, webSocket: client });\n}\nfunction truncateCloseReason(reason) {\n const bytes = new TextEncoder().encode(reason);\n if (bytes.length <= 123) {\n return reason;\n }\n let end = 123;\n while (end > 0 && ((bytes[end] ?? 0) & 192) === 128) {\n end--;\n }\n return new TextDecoder().decode(bytes.subarray(0, end));\n}\nasync function pipeSocketOverWebSocket(socket, ws) {\n const writer = socket.writable.getWriter();\n const reader = socket.readable.getReader();\n let wsClosed = false;\n function closeWebSocket(code, reason) {\n if (wsClosed) {\n return;\n }\n wsClosed = true;\n try {\n ws.close(\n code,\n reason === void 0 ? void 0 : truncateCloseReason(reason)\n );\n } catch {\n }\n }\n let writeChain = Promise.resolve();\n let writerClosed = false;\n function closeWriter() {\n if (writerClosed) {\n return Promise.resolve();\n }\n writerClosed = true;\n return writeChain.then(() => writer.close());\n }\n let resolveFromWs;\n let rejectFromWs;\n const fromWebSocket = new Promise((resolve, reject) => {\n resolveFromWs = resolve;\n rejectFromWs = reject;\n });\n ws.addEventListener(\"message\", (event) => {\n const chunk = typeof event.data === \"string\" ? new TextEncoder().encode(event.data) : new Uint8Array(event.data);\n writeChain = writeChain.then(() => writer.write(chunk)).catch((error) => {\n closeWebSocket(\n 1011,\n error?.message ?? \"socket write failed\"\n );\n reader.cancel().catch(() => {\n });\n rejectFromWs(error);\n });\n });\n ws.addEventListener(\"close\", (event) => {\n wsClosed = true;\n reader.cancel().catch(() => {\n });\n if (event.code === 1011) {\n rejectFromWs(\n new Error(event.reason || \"Remote tunnel closed with an error\")\n );\n return;\n }\n closeWriter().then(resolveFromWs, rejectFromWs);\n });\n ws.addEventListener(\"error\", () => {\n wsClosed = true;\n reader.cancel().catch(() => {\n });\n rejectFromWs(new Error(\"Tunnel WebSocket errored\"));\n });\n const toWebSocket = (async () => {\n try {\n for (; ; ) {\n const { value, done } = await reader.read();\n if (done) {\n break;\n }\n if (wsClosed) {\n break;\n }\n ws.send(\n value.buffer.slice(\n value.byteOffset,\n value.byteOffset + value.byteLength\n )\n );\n }\n closeWebSocket(1e3);\n } catch (error) {\n closeWebSocket(1011, error?.message ?? \"socket read failed\");\n throw error;\n } finally {\n reader.releaseLock();\n closeWriter().then(resolveFromWs, rejectFromWs);\n }\n })();\n await Promise.all([toWebSocket, fromWebSocket]);\n}\nvar ProxyServerWorker_default = {\n async fetch(request, env) {\n try {\n if (isConnectBinding(request)) {\n return handleConnect(request, env);\n } else if (isJSRPCBinding(request)) {\n return await newWorkersRpcResponse(\n request,\n getExposedJSRPCBinding(request, env)\n );\n } else {\n const fetcher = getExposedFetcher(request, env);\n const originalHeaders = new Headers();\n for (const [name, value] of request.headers) {\n if (name.startsWith(\"mf-header-\")) {\n originalHeaders.set(name.slice(\"mf-header-\".length), value);\n } else if (name === \"upgrade\") {\n originalHeaders.set(name, value);\n }\n }\n return await fetcher.fetch(\n request.headers.get(\"MF-URL\") ?? \"http://example.com\",\n new Request(request, {\n redirect: \"manual\",\n headers: originalHeaders\n })\n );\n }\n } catch (e) {\n if (e instanceof BindingNotFoundError) {\n return new Response(e.message, { status: 400 });\n }\n return new Response(e.message, { status: 500 });\n }\n }\n};\nexport {\n ProxyServerWorker_default as default\n};\n";
|
|
90508
|
+
var ProxyServerWorker_default = "// ../../node_modules/.pnpm/capnweb@0.12.0/node_modules/capnweb/dist/index-workers.js\nimport * as cfw from \"cloudflare:workers\";\nvar WORKERS_MODULE_SYMBOL = /* @__PURE__ */ Symbol(\"workers-module\");\nglobalThis[WORKERS_MODULE_SYMBOL] = cfw;\nif (!Symbol.dispose) Symbol.dispose = /* @__PURE__ */ Symbol.for(\"dispose\");\nif (!Symbol.asyncDispose) Symbol.asyncDispose = /* @__PURE__ */ Symbol.for(\"asyncDispose\");\nif (!Promise.withResolvers) Promise.withResolvers = function() {\n let resolve;\n let reject;\n return {\n promise: new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n }),\n resolve,\n reject\n };\n};\nvar workersModule = globalThis[WORKERS_MODULE_SYMBOL];\nvar RpcTarget$1 = workersModule ? workersModule.RpcTarget : class {\n};\nvar AsyncFunction = (async function() {\n}).constructor;\nvar BUFFER_PROTOTYPE = typeof Buffer !== \"undefined\" ? Buffer.prototype : void 0;\nfunction typeForRpc(value) {\n switch (typeof value) {\n case \"boolean\":\n case \"number\":\n case \"string\":\n return \"primitive\";\n case \"undefined\":\n return \"undefined\";\n case \"object\":\n case \"function\":\n break;\n case \"bigint\":\n return \"bigint\";\n default:\n return \"unsupported\";\n }\n if (value === null) return \"primitive\";\n let prototype = Object.getPrototypeOf(value);\n switch (prototype) {\n case Object.prototype:\n return \"object\";\n case Function.prototype:\n case AsyncFunction.prototype:\n return \"function\";\n case Array.prototype:\n return \"array\";\n case Date.prototype:\n return \"date\";\n case Uint8Array.prototype:\n case BUFFER_PROTOTYPE:\n case ArrayBuffer.prototype:\n case DataView.prototype:\n case Int8Array.prototype:\n case Uint8ClampedArray.prototype:\n case Int16Array.prototype:\n case Uint16Array.prototype:\n case Int32Array.prototype:\n case Uint32Array.prototype:\n case BigInt64Array.prototype:\n case BigUint64Array.prototype:\n case Float32Array.prototype:\n case Float64Array.prototype:\n return \"bytes\";\n case WritableStream.prototype:\n return \"writable\";\n case ReadableStream.prototype:\n return \"readable\";\n case URL.prototype:\n return \"url\";\n case Headers.prototype:\n return \"headers\";\n case Request.prototype:\n return \"request\";\n case Response.prototype:\n return \"response\";\n case Blob.prototype:\n return \"blob\";\n case RpcStub$1.prototype:\n return \"stub\";\n case RpcPromise$1.prototype:\n return \"rpc-promise\";\n default:\n if (workersModule) {\n if (prototype == workersModule.RpcStub.prototype || value instanceof workersModule.ServiceStub) return \"rpc-target\";\n else if (prototype == workersModule.RpcPromise.prototype || prototype == workersModule.RpcProperty.prototype) return \"rpc-thenable\";\n }\n if (value instanceof RpcTarget$1) return \"rpc-target\";\n if (value instanceof Error) return \"error\";\n return \"unsupported\";\n }\n}\nfunction mapNotLoaded() {\n throw new Error(\"RPC map() implementation was not loaded.\");\n}\nvar mapImpl = {\n applyMap: mapNotLoaded,\n sendMap: mapNotLoaded\n};\nfunction streamNotLoaded() {\n throw new Error(\"Stream implementation was not loaded.\");\n}\nvar streamImpl = {\n createWritableStreamHook: streamNotLoaded,\n createWritableStreamFromHook: streamNotLoaded,\n createReadableStreamHook: streamNotLoaded\n};\nvar StubHook = class {\n stream(path, args) {\n let hook = this.call(path, args);\n let pulled;\n try {\n pulled = hook.pull();\n } catch (err) {\n hook.dispose();\n throw err;\n }\n let promise;\n if (pulled instanceof Promise) promise = pulled.then((p) => {\n p.dispose();\n });\n else {\n pulled.dispose();\n promise = Promise.resolve();\n }\n return { promise };\n }\n};\nvar ErrorStubHook = class extends StubHook {\n error;\n constructor(error) {\n super();\n this.error = error;\n }\n call(path, args) {\n args.dispose();\n return this;\n }\n map(path, captures, instructions) {\n for (let cap of captures) cap.dispose();\n return this;\n }\n get(path) {\n return this;\n }\n dup() {\n return this;\n }\n pull() {\n return Promise.reject(this.error);\n }\n ignoreUnhandledRejections() {\n }\n dispose() {\n }\n onBroken(callback) {\n try {\n callback(this.error);\n } catch (err) {\n Promise.resolve(err);\n }\n }\n};\nvar DISPOSED_HOOK = new ErrorStubHook(/* @__PURE__ */ new Error(\"Attempted to use RPC stub after it has been disposed.\"));\nvar doCall = (hook, path, params) => {\n return hook.call(path, params);\n};\nfunction withCallInterceptor(interceptor, callback) {\n let oldValue = doCall;\n doCall = interceptor;\n try {\n return callback();\n } finally {\n doCall = oldValue;\n }\n}\nvar RAW_STUB = /* @__PURE__ */ Symbol(\"realStub\");\nvar PROXY_HANDLERS = {\n apply(target, thisArg, argumentsList) {\n let stub = target.raw;\n return new RpcPromise$1(doCall(stub.hook, stub.pathIfPromise || [], RpcPayload.fromAppParams(argumentsList)), []);\n },\n get(target, prop, receiver) {\n let stub = target.raw;\n if (prop === RAW_STUB) return stub;\n else if (prop in RpcPromise$1.prototype) return stub[prop];\n else if (typeof prop === \"string\") return new RpcPromise$1(stub.hook, stub.pathIfPromise ? [...stub.pathIfPromise, prop] : [prop]);\n else if (prop === Symbol.dispose && (!stub.pathIfPromise || stub.pathIfPromise.length == 0)) return () => {\n stub.hook.dispose();\n stub.hook = DISPOSED_HOOK;\n };\n else return;\n },\n has(target, prop) {\n let stub = target.raw;\n if (prop === RAW_STUB) return true;\n else if (prop in RpcPromise$1.prototype) return prop in stub;\n else if (typeof prop === \"string\") return true;\n else if (prop === Symbol.dispose && (!stub.pathIfPromise || stub.pathIfPromise.length == 0)) return true;\n else return false;\n },\n construct(target, args) {\n throw new Error(\"An RPC stub cannot be used as a constructor.\");\n },\n defineProperty(target, property, attributes) {\n throw new Error(\"Can't define properties on RPC stubs.\");\n },\n deleteProperty(target, p) {\n throw new Error(\"Can't delete properties on RPC stubs.\");\n },\n getOwnPropertyDescriptor(target, p) {\n },\n getPrototypeOf(target) {\n return Object.getPrototypeOf(target.raw);\n },\n isExtensible(target) {\n return false;\n },\n ownKeys(target) {\n return [];\n },\n preventExtensions(target) {\n return true;\n },\n set(target, p, newValue, receiver) {\n throw new Error(\"Can't assign properties on RPC stubs.\");\n },\n setPrototypeOf(target, v) {\n throw new Error(\"Can't override prototype of RPC stubs.\");\n }\n};\nvar RpcStub$1 = class RpcStub$12 extends RpcTarget$1 {\n constructor(hook, pathIfPromise) {\n super();\n if (!(hook instanceof StubHook)) {\n let value = hook;\n if (value instanceof RpcTarget$1 || value instanceof Function) hook = TargetStubHook.create(value, void 0);\n else hook = new PayloadStubHook(RpcPayload.fromAppReturn(value));\n if (pathIfPromise) throw new TypeError(\"RpcStub constructor expected one argument, received two.\");\n }\n this.hook = hook;\n this.pathIfPromise = pathIfPromise;\n let func = () => {\n };\n func.raw = this;\n return new Proxy(func, PROXY_HANDLERS);\n }\n hook;\n pathIfPromise;\n dup() {\n let target = this[RAW_STUB];\n if (target.pathIfPromise) return new RpcStub$12(target.hook.get(target.pathIfPromise));\n else return new RpcStub$12(target.hook.dup());\n }\n onRpcBroken(callback) {\n this[RAW_STUB].hook.onBroken(callback);\n }\n map(func) {\n let { hook, pathIfPromise } = this[RAW_STUB];\n return mapImpl.sendMap(hook, pathIfPromise || [], func);\n }\n toString() {\n return \"[object RpcStub]\";\n }\n};\nvar RpcPromise$1 = class extends RpcStub$1 {\n constructor(hook, pathIfPromise) {\n if (hook instanceof StubHook) super(hook, pathIfPromise ?? []);\n else {\n if (pathIfPromise !== void 0) throw new TypeError(\"RpcPromise constructor expected one argument, received two.\");\n let kind = typeForRpc(hook);\n if (kind === \"rpc-promise\") {\n let raw = unwrapStubAndPath(hook);\n if (raw.pathIfPromise.length > 0) super(raw.hook, raw.pathIfPromise);\n else {\n let adopted = raw.hook;\n raw.hook = DISPOSED_HOOK;\n super(adopted, []);\n }\n } else if (kind === \"rpc-thenable\") super(TargetStubHook.create(hook, void 0), []);\n else {\n let promiseHook = new PromiseStubHook(Promise.resolve(hook).then((value) => new PayloadStubHook(RpcPayload.fromAppReturn(value))));\n promiseHook.ignoreUnhandledRejections();\n super(promiseHook, []);\n }\n }\n }\n then(onfulfilled, onrejected) {\n return pullPromise(this).then(...arguments);\n }\n catch(onrejected) {\n return pullPromise(this).catch(...arguments);\n }\n finally(onfinally) {\n return pullPromise(this).finally(...arguments);\n }\n toString() {\n return \"[object RpcPromise]\";\n }\n};\nfunction unwrapStubTakingOwnership(stub) {\n let { hook, pathIfPromise } = stub[RAW_STUB];\n if (pathIfPromise && pathIfPromise.length > 0) return hook.get(pathIfPromise);\n else return hook;\n}\nfunction unwrapStubAndDup(stub) {\n let { hook, pathIfPromise } = stub[RAW_STUB];\n if (pathIfPromise) return hook.get(pathIfPromise);\n else return hook.dup();\n}\nfunction unwrapStubNoProperties(stub) {\n let { hook, pathIfPromise } = stub[RAW_STUB];\n if (pathIfPromise && pathIfPromise.length > 0) return;\n return hook;\n}\nfunction unwrapStubOrParent(stub) {\n return stub[RAW_STUB].hook;\n}\nfunction unwrapStubAndPath(stub) {\n return stub[RAW_STUB];\n}\nasync function pullPromise(promise) {\n let { hook, pathIfPromise } = promise[RAW_STUB];\n if (pathIfPromise.length > 0) hook = hook.get(pathIfPromise);\n return (await hook.pull()).deliverResolve();\n}\nvar RpcPayload = class RpcPayload2 {\n value;\n source;\n hooks;\n promises;\n static fromAppParams(value) {\n return new RpcPayload2(value, \"params\");\n }\n static fromAppReturn(value) {\n return new RpcPayload2(value, \"return\");\n }\n static fromArray(array) {\n let hooks = [];\n let promises = [];\n let resultArray = [];\n for (let payload of array) {\n payload.ensureDeepCopied();\n for (let hook of payload.hooks) hooks.push(hook);\n for (let promise of payload.promises) {\n if (promise.parent === payload) promise = {\n parent: resultArray,\n property: resultArray.length,\n promise: promise.promise\n };\n promises.push(promise);\n }\n resultArray.push(payload.value);\n }\n return new RpcPayload2(resultArray, \"owned\", hooks, promises);\n }\n static forEvaluate(hooks, promises) {\n return new RpcPayload2(null, \"owned\", hooks, promises);\n }\n static deepCopyFrom(value, oldParent, owner) {\n let result = new RpcPayload2(null, \"owned\", [], []);\n result.value = result.deepCopy(value, oldParent, \"value\", result, true, owner);\n return result;\n }\n constructor(value, source, hooks, promises) {\n this.value = value;\n this.source = source;\n this.hooks = hooks;\n this.promises = promises;\n }\n rpcTargets;\n getHookForRpcTarget(target, parent, dupStubs = true) {\n if (this.source === \"params\") {\n if (dupStubs) {\n let dupable = target;\n if (typeof dupable.dup === \"function\") target = dupable.dup();\n }\n return TargetStubHook.create(target, parent);\n } else if (this.source === \"return\") {\n let hook = this.rpcTargets?.get(target);\n if (hook) if (dupStubs) return hook.dup();\n else {\n this.rpcTargets?.delete(target);\n return hook;\n }\n else {\n hook = TargetStubHook.create(target, parent);\n if (dupStubs) {\n if (!this.rpcTargets) this.rpcTargets = /* @__PURE__ */ new Map();\n this.rpcTargets.set(target, hook);\n return hook.dup();\n } else return hook;\n }\n } else throw new Error(\"owned payload shouldn't contain raw RpcTargets\");\n }\n getHookForWritableStream(stream, parent, dupStubs = true) {\n if (this.source === \"params\") return streamImpl.createWritableStreamHook(stream);\n else if (this.source === \"return\") {\n let hook = this.rpcTargets?.get(stream);\n if (hook) if (dupStubs) return hook.dup();\n else {\n this.rpcTargets?.delete(stream);\n return hook;\n }\n else {\n hook = streamImpl.createWritableStreamHook(stream);\n if (dupStubs) {\n if (!this.rpcTargets) this.rpcTargets = /* @__PURE__ */ new Map();\n this.rpcTargets.set(stream, hook);\n return hook.dup();\n } else return hook;\n }\n } else throw new Error(\"owned payload shouldn't contain raw WritableStreams\");\n }\n getHookForReadableStream(stream, parent, dupStubs = true) {\n if (this.source === \"params\") return streamImpl.createReadableStreamHook(stream);\n else if (this.source === \"return\") {\n let hook = this.rpcTargets?.get(stream);\n if (hook) if (dupStubs) return hook.dup();\n else {\n this.rpcTargets?.delete(stream);\n return hook;\n }\n else {\n hook = streamImpl.createReadableStreamHook(stream);\n if (dupStubs) {\n if (!this.rpcTargets) this.rpcTargets = /* @__PURE__ */ new Map();\n this.rpcTargets.set(stream, hook);\n return hook.dup();\n } else return hook;\n }\n } else throw new Error(\"owned payload shouldn't contain raw ReadableStreams\");\n }\n deepCopy(value, oldParent, property, parent, dupStubs, owner) {\n switch (typeForRpc(value)) {\n case \"unsupported\":\n return value;\n case \"primitive\":\n case \"bigint\":\n case \"date\":\n case \"bytes\":\n case \"blob\":\n case \"url\":\n case \"error\":\n case \"undefined\":\n return value;\n case \"array\": {\n let array = value;\n let len = array.length;\n let result = new Array(len);\n for (let i = 0; i < len; i++) result[i] = this.deepCopy(array[i], array, i, result, dupStubs, owner);\n return result;\n }\n case \"object\": {\n let result = {};\n let object = value;\n for (let i in object) result[i] = this.deepCopy(object[i], object, i, result, dupStubs, owner);\n return result;\n }\n case \"stub\":\n case \"rpc-promise\": {\n let stub = value;\n let hook;\n if (dupStubs) hook = unwrapStubAndDup(stub);\n else hook = unwrapStubTakingOwnership(stub);\n if (stub instanceof RpcPromise$1) {\n let promise = new RpcPromise$1(hook, []);\n this.promises.push({\n parent,\n property,\n promise\n });\n return promise;\n } else {\n this.hooks.push(hook);\n return new RpcStub$1(hook);\n }\n }\n case \"function\":\n case \"rpc-target\": {\n let target = value;\n let hook;\n if (owner) hook = owner.getHookForRpcTarget(target, oldParent, dupStubs);\n else hook = TargetStubHook.create(target, oldParent);\n this.hooks.push(hook);\n return new RpcStub$1(hook);\n }\n case \"rpc-thenable\": {\n let target = value;\n let promise;\n if (owner) promise = new RpcPromise$1(owner.getHookForRpcTarget(target, oldParent, dupStubs), []);\n else promise = new RpcPromise$1(TargetStubHook.create(target, oldParent), []);\n this.promises.push({\n parent,\n property,\n promise\n });\n return promise;\n }\n case \"writable\": {\n let stream = value;\n let hook;\n if (owner) hook = owner.getHookForWritableStream(stream, oldParent, dupStubs);\n else hook = streamImpl.createWritableStreamHook(stream);\n this.hooks.push(hook);\n return stream;\n }\n case \"readable\": {\n let stream = value;\n let hook;\n if (owner) hook = owner.getHookForReadableStream(stream, oldParent, dupStubs);\n else hook = streamImpl.createReadableStreamHook(stream);\n this.hooks.push(hook);\n return stream;\n }\n case \"headers\":\n return new Headers(value);\n case \"request\": {\n let req = value;\n if (req.body) this.deepCopy(req.body, req, \"body\", req, dupStubs, owner);\n return new Request(req);\n }\n case \"response\": {\n let resp = value;\n if (resp.body) this.deepCopy(resp.body, resp, \"body\", resp, dupStubs, owner);\n return new Response(resp.body, resp);\n }\n default:\n throw new Error(\"unreachable\");\n }\n }\n ensureDeepCopied() {\n if (this.source !== \"owned\") {\n let dupStubs = this.source === \"params\";\n this.hooks = [];\n this.promises = [];\n try {\n this.value = this.deepCopy(this.value, void 0, \"value\", this, dupStubs, this);\n } catch (err) {\n this.hooks = void 0;\n this.promises = void 0;\n throw err;\n }\n this.source = \"owned\";\n if (this.rpcTargets && this.rpcTargets.size > 0) throw new Error(\"Not all rpcTargets were accounted for in deep-copy?\");\n this.rpcTargets = void 0;\n }\n }\n deliverTo(parent, property, promises) {\n this.ensureDeepCopied();\n if (this.value instanceof RpcPromise$1) RpcPayload2.deliverRpcPromiseTo(this.value, parent, property, promises);\n else {\n parent[property] = this.value;\n for (let record of this.promises) RpcPayload2.deliverRpcPromiseTo(record.promise, record.parent, record.property, promises);\n }\n }\n static deliverRpcPromiseTo(promise, parent, property, promises) {\n let hook = unwrapStubNoProperties(promise);\n if (!hook) throw new Error(\"property promises should have been resolved earlier\");\n let inner = hook.pull();\n if (inner instanceof RpcPayload2) inner.deliverTo(parent, property, promises);\n else promises.push(inner.then((payload) => {\n let subPromises = [];\n payload.deliverTo(parent, property, subPromises);\n if (subPromises.length > 0) return Promise.all(subPromises);\n }));\n }\n async deliverCall(func, thisArg) {\n try {\n let promises = [];\n this.deliverTo(this, \"value\", promises);\n if (promises.length > 0) await Promise.all(promises);\n let result = Function.prototype.apply.call(func, thisArg, this.value);\n if (result instanceof RpcPromise$1) return RpcPayload2.fromAppReturn(result);\n else return RpcPayload2.fromAppReturn(await result);\n } finally {\n this.dispose();\n }\n }\n async deliverStreamWrite(writer) {\n try {\n let promises = [];\n this.deliverTo(this, \"value\", promises);\n if (promises.length > 0) await Promise.all(promises);\n let chunk = this.value[0];\n if ((this.hooks.length > 0 || this.promises.length > 0) && chunk instanceof Object) {\n if (!(Symbol.dispose in chunk)) Object.defineProperty(chunk, Symbol.dispose, {\n value: () => this.dispose(),\n writable: true,\n enumerable: false,\n configurable: true\n });\n await writer.write(chunk);\n return RpcPayload2.fromAppReturn(void 0);\n }\n await writer.write(chunk);\n this.dispose();\n return RpcPayload2.fromAppReturn(void 0);\n } catch (err) {\n this.dispose();\n throw err;\n }\n }\n async deliverResolve() {\n try {\n let promises = [];\n this.deliverTo(this, \"value\", promises);\n if (promises.length > 0) await Promise.all(promises);\n let result = this.value;\n if (result instanceof Object) {\n if (!(Symbol.dispose in result)) Object.defineProperty(result, Symbol.dispose, {\n value: () => this.dispose(),\n writable: true,\n enumerable: false,\n configurable: true\n });\n }\n return result;\n } catch (err) {\n this.dispose();\n throw err;\n }\n }\n dispose() {\n if (this.source === \"owned\") {\n this.hooks.forEach((hook) => hook.dispose());\n this.promises.forEach((promise) => promise.promise[Symbol.dispose]());\n } else if (this.source === \"return\") {\n this.disposeImpl(this.value, void 0);\n if (this.rpcTargets && this.rpcTargets.size > 0) throw new Error(\"Not all rpcTargets were accounted for in disposeImpl()?\");\n }\n this.source = \"owned\";\n this.hooks = [];\n this.promises = [];\n }\n disposeImpl(value, parent) {\n switch (typeForRpc(value)) {\n case \"unsupported\":\n case \"primitive\":\n case \"bigint\":\n case \"bytes\":\n case \"blob\":\n case \"date\":\n case \"url\":\n case \"error\":\n case \"undefined\":\n return;\n case \"array\": {\n let array = value;\n let len = array.length;\n for (let i = 0; i < len; i++) this.disposeImpl(array[i], array);\n return;\n }\n case \"object\": {\n let object = value;\n for (let i in object) this.disposeImpl(object[i], object);\n return;\n }\n case \"stub\":\n case \"rpc-promise\": {\n let hook = unwrapStubNoProperties(value);\n if (hook) hook.dispose();\n return;\n }\n case \"function\":\n case \"rpc-target\": {\n let target = value;\n let hook = this.rpcTargets?.get(target);\n if (hook) {\n hook.dispose();\n this.rpcTargets.delete(target);\n } else disposeRpcTarget(target);\n return;\n }\n case \"rpc-thenable\":\n return;\n case \"headers\":\n return;\n case \"request\": {\n let req = value;\n if (req.body) this.disposeImpl(req.body, req);\n return;\n }\n case \"response\": {\n let resp = value;\n if (resp.body) this.disposeImpl(resp.body, resp);\n return;\n }\n case \"writable\": {\n let stream = value;\n let hook = this.rpcTargets?.get(stream);\n if (hook) this.rpcTargets.delete(stream);\n else hook = streamImpl.createWritableStreamHook(stream);\n hook.dispose();\n return;\n }\n case \"readable\": {\n let stream = value;\n let hook = this.rpcTargets?.get(stream);\n if (hook) this.rpcTargets.delete(stream);\n else hook = streamImpl.createReadableStreamHook(stream);\n hook.dispose();\n return;\n }\n default:\n return;\n }\n }\n ignoreUnhandledRejections() {\n if (this.hooks) {\n this.hooks.forEach((hook) => {\n hook.ignoreUnhandledRejections();\n });\n this.promises.forEach((promise) => unwrapStubOrParent(promise.promise).ignoreUnhandledRejections());\n } else this.ignoreUnhandledRejectionsImpl(this.value);\n }\n ignoreUnhandledRejectionsImpl(value) {\n switch (typeForRpc(value)) {\n case \"unsupported\":\n case \"primitive\":\n case \"bigint\":\n case \"bytes\":\n case \"blob\":\n case \"date\":\n case \"error\":\n case \"undefined\":\n case \"function\":\n case \"rpc-target\":\n case \"writable\":\n case \"readable\":\n case \"url\":\n case \"headers\":\n case \"request\":\n case \"response\":\n return;\n case \"array\": {\n let array = value;\n let len = array.length;\n for (let i = 0; i < len; i++) this.ignoreUnhandledRejectionsImpl(array[i]);\n return;\n }\n case \"object\": {\n let object = value;\n for (let i in object) this.ignoreUnhandledRejectionsImpl(object[i]);\n return;\n }\n case \"stub\":\n case \"rpc-promise\":\n unwrapStubOrParent(value).ignoreUnhandledRejections();\n return;\n case \"rpc-thenable\":\n value.then((_) => {\n }, (_) => {\n });\n return;\n default:\n return;\n }\n }\n};\nfunction followPath(value, parent, path, owner) {\n for (let i = 0; i < path.length; i++) {\n parent = value;\n let part = path[i];\n if (part in Object.prototype) {\n value = void 0;\n continue;\n }\n switch (typeForRpc(value)) {\n case \"object\":\n case \"function\":\n if (Object.hasOwn(value, part)) value = value[part];\n else value = void 0;\n break;\n case \"array\":\n if (Number.isInteger(part) && part >= 0) value = value[part];\n else value = void 0;\n break;\n case \"rpc-target\":\n case \"rpc-thenable\":\n if (Object.hasOwn(value, part)) throw new TypeError(`Attempted to access property '${part}', which is an instance property of the RpcTarget. To avoid leaking private internals, instance properties cannot be accessed over RPC. If you want to make this property available over RPC, define it as a method or getter on the class, instead of an instance property.`);\n else value = value[part];\n owner = null;\n break;\n case \"stub\":\n case \"rpc-promise\": {\n let { hook, pathIfPromise } = unwrapStubAndPath(value);\n return {\n hook,\n remainingPath: pathIfPromise ? pathIfPromise.concat(path.slice(i)) : path.slice(i)\n };\n }\n case \"writable\":\n value = void 0;\n break;\n case \"readable\":\n value = void 0;\n break;\n case \"primitive\":\n case \"bigint\":\n case \"bytes\":\n case \"blob\":\n case \"date\":\n case \"error\":\n case \"url\":\n case \"headers\":\n case \"request\":\n case \"response\":\n value = void 0;\n break;\n case \"undefined\":\n value = value[part];\n break;\n case \"unsupported\":\n if (i === 0) throw new TypeError(`RPC stub points at a non-serializable type.`);\n else {\n let prefix = path.slice(0, i).join(\".\");\n let remainder = path.slice(0, i).join(\".\");\n throw new TypeError(`'${prefix}' is not a serializable type, so property ${remainder} cannot be accessed.`);\n }\n default:\n throw new TypeError(\"unreachable\");\n }\n }\n if (value instanceof RpcPromise$1) {\n let { hook, pathIfPromise } = unwrapStubAndPath(value);\n return {\n hook,\n remainingPath: pathIfPromise || []\n };\n }\n return {\n value,\n parent,\n owner\n };\n}\nvar ValueStubHook = class extends StubHook {\n call(path, args) {\n let followResult;\n try {\n let { value, owner } = this.getValue();\n followResult = followPath(value, void 0, path, owner);\n } catch (err) {\n args.dispose();\n return new ErrorStubHook(err);\n }\n if (followResult.hook) return followResult.hook.call(followResult.remainingPath, args);\n if (typeof followResult.value != \"function\") {\n args.dispose();\n return new ErrorStubHook(/* @__PURE__ */ new TypeError(`'${path.join(\".\")}' is not a function.`));\n }\n return new PromiseStubHook(args.deliverCall(followResult.value, followResult.parent).then((payload) => {\n return new PayloadStubHook(payload);\n }));\n }\n map(path, captures, instructions) {\n try {\n let followResult;\n try {\n let { value, owner } = this.getValue();\n followResult = followPath(value, void 0, path, owner);\n } catch (err) {\n for (let cap of captures) cap.dispose();\n throw err;\n }\n if (followResult.hook) return followResult.hook.map(followResult.remainingPath, captures, instructions);\n return mapImpl.applyMap(followResult.value, followResult.parent, followResult.owner, captures, instructions);\n } catch (err) {\n return new ErrorStubHook(err);\n }\n }\n get(path) {\n try {\n let { value, owner } = this.getValue();\n if (path.length === 0 && owner === null) {\n if (value instanceof Object && \"then\" in value) return this.dup();\n throw new Error(\"Can't dup an RpcTarget stub as a promise.\");\n }\n let followResult = followPath(value, void 0, path, owner);\n if (followResult.hook) return followResult.hook.get(followResult.remainingPath);\n return new PayloadStubHook(RpcPayload.deepCopyFrom(followResult.value, followResult.parent, followResult.owner));\n } catch (err) {\n return new ErrorStubHook(err);\n }\n }\n};\nvar PayloadStubHook = class PayloadStubHook2 extends ValueStubHook {\n constructor(payload) {\n super();\n this.payload = payload;\n }\n payload;\n getPayload() {\n if (this.payload) return this.payload;\n else throw new Error(\"Attempted to use an RPC StubHook after it was disposed.\");\n }\n getValue() {\n let payload = this.getPayload();\n return {\n value: payload.value,\n owner: payload\n };\n }\n dup() {\n let thisPayload = this.getPayload();\n return new PayloadStubHook2(RpcPayload.deepCopyFrom(thisPayload.value, void 0, thisPayload));\n }\n pull() {\n return this.getPayload();\n }\n ignoreUnhandledRejections() {\n if (this.payload) this.payload.ignoreUnhandledRejections();\n }\n dispose() {\n if (this.payload) {\n this.payload.dispose();\n this.payload = void 0;\n }\n }\n onBroken(callback) {\n if (this.payload) {\n if (this.payload.value instanceof RpcStub$1) this.payload.value.onRpcBroken(callback);\n }\n }\n};\nfunction disposeRpcTarget(target) {\n if (Symbol.dispose in target) try {\n target[Symbol.dispose]();\n } catch (err) {\n Promise.reject(err);\n }\n}\nvar TargetStubHook = class TargetStubHook2 extends ValueStubHook {\n static create(value, parent) {\n if (typeof value !== \"function\") parent = void 0;\n return new TargetStubHook2(value, parent);\n }\n constructor(target, parent, dupFrom) {\n super();\n this.target = target;\n this.parent = parent;\n if (dupFrom) {\n if (dupFrom.refcount) {\n this.refcount = dupFrom.refcount;\n ++this.refcount.count;\n }\n } else if (Symbol.dispose in target) this.refcount = { count: 1 };\n }\n target;\n parent;\n refcount;\n getTarget() {\n if (this.target) return this.target;\n else throw new Error(\"Attempted to use an RPC StubHook after it was disposed.\");\n }\n getValue() {\n return {\n value: this.getTarget(),\n owner: null\n };\n }\n dup() {\n return new TargetStubHook2(this.getTarget(), this.parent, this);\n }\n pull() {\n let target = this.getTarget();\n if (\"then\" in target) return Promise.resolve(target).then((resolution) => {\n return RpcPayload.fromAppReturn(resolution);\n });\n else return Promise.reject(/* @__PURE__ */ new Error(\"Tried to resolve a non-promise stub.\"));\n }\n ignoreUnhandledRejections() {\n }\n dispose() {\n if (this.target) {\n if (this.refcount) {\n if (--this.refcount.count == 0) disposeRpcTarget(this.target);\n }\n this.target = void 0;\n }\n }\n onBroken(callback) {\n let target = this.target;\n if (target && \"then\" in target) Promise.resolve(target).then(() => {\n }, callback);\n }\n};\nvar PromiseStubHook = class PromiseStubHook2 extends StubHook {\n promise;\n resolution;\n constructor(promise) {\n super();\n this.promise = promise.then((res) => {\n this.resolution = res;\n return res;\n });\n }\n call(path, args) {\n args.ensureDeepCopied();\n return new PromiseStubHook2(this.promise.then((hook) => hook.call(path, args), (err) => {\n args.dispose();\n throw err;\n }));\n }\n stream(path, args) {\n args.ensureDeepCopied();\n return { promise: this.promise.then((hook) => hook.stream(path, args).promise, (err) => {\n args.dispose();\n throw err;\n }) };\n }\n map(path, captures, instructions) {\n return new PromiseStubHook2(this.promise.then((hook) => hook.map(path, captures, instructions), (err) => {\n for (let cap of captures) cap.dispose();\n throw err;\n }));\n }\n get(path) {\n return new PromiseStubHook2(this.promise.then((hook) => hook.get(path)));\n }\n dup() {\n if (this.resolution) return this.resolution.dup();\n else return new PromiseStubHook2(this.promise.then((hook) => hook.dup()));\n }\n pull() {\n if (this.resolution) return this.resolution.pull();\n else return this.promise.then((hook) => hook.pull());\n }\n ignoreUnhandledRejections() {\n if (this.resolution) this.resolution.ignoreUnhandledRejections();\n else this.promise.then((res) => {\n res.ignoreUnhandledRejections();\n }, (err) => {\n });\n }\n dispose() {\n this.promise.then((hook) => hook.dispose(), () => {\n });\n }\n onBroken(callback) {\n if (this.resolution) this.resolution.onBroken(callback);\n else this.promise.then((hook) => {\n hook.onBroken(callback);\n }, callback);\n }\n};\nvar DEFAULT_LIMITS = {\n maxBigIntDigits: 16384,\n maxDepth: 256,\n maxMessageSize: 32 * 1024 * 1024\n};\nvar NATIVE_LITTLE_ENDIAN = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;\nvar BYTE_CONTAINER_TYPE_NAMES = [\n \"ArrayBuffer\",\n \"DataView\",\n \"Int8Array\",\n \"Uint8Array\",\n \"Uint8ClampedArray\",\n \"Int16Array\",\n \"Uint16Array\",\n \"Int32Array\",\n \"Uint32Array\",\n \"BigInt64Array\",\n \"BigUint64Array\",\n \"Float32Array\",\n \"Float64Array\"\n];\nfunction isValidByteContainerName(value) {\n return BYTE_CONTAINER_TYPE_NAMES.includes(value);\n}\nvar TYPED_ARRAY_ELEMENT_SIZE = {\n ArrayBuffer: void 0,\n DataView: void 0,\n Int8Array: void 0,\n Uint8Array: void 0,\n Uint8ClampedArray: void 0,\n Int16Array: 2,\n Uint16Array: 2,\n Int32Array: 4,\n Uint32Array: 4,\n BigInt64Array: 8,\n BigUint64Array: 8,\n Float32Array: 4,\n Float64Array: 8\n};\nvar BYTE_CONTAINER_PROTOTYPES = {\n ArrayBuffer: ArrayBuffer.prototype,\n DataView: DataView.prototype,\n Int8Array: Int8Array.prototype,\n Uint8ClampedArray: Uint8ClampedArray.prototype,\n Int16Array: Int16Array.prototype,\n Uint16Array: Uint16Array.prototype,\n Int32Array: Int32Array.prototype,\n Uint32Array: Uint32Array.prototype,\n BigInt64Array: BigInt64Array.prototype,\n BigUint64Array: BigUint64Array.prototype,\n Float32Array: Float32Array.prototype,\n Float64Array: Float64Array.prototype\n};\nvar BYTE_CONTAINER_TYPE_BY_PROTOTYPE = /* @__PURE__ */ new Map();\nfor (let type of Object.keys(BYTE_CONTAINER_PROTOTYPES)) BYTE_CONTAINER_TYPE_BY_PROTOTYPE.set(BYTE_CONTAINER_PROTOTYPES[type], type);\nfunction swapByteOrder(bytes, elementSize) {\n if (elementSize !== 2 && elementSize !== 4 && elementSize !== 8) throw new RangeError(`Unsupported element size: ${elementSize}`);\n let view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n for (let offset = 0; offset < bytes.byteLength; offset += elementSize) switch (elementSize) {\n case 2:\n view.setUint16(offset, view.getUint16(offset, false), true);\n break;\n case 4:\n view.setUint32(offset, view.getUint32(offset, false), true);\n break;\n case 8:\n view.setBigUint64(offset, view.getBigUint64(offset, false), true);\n break;\n }\n}\nvar NullExporter = class {\n exportStub(stub) {\n throw new Error(\"Cannot serialize RPC stubs without an RPC session.\");\n }\n exportPromise(stub) {\n throw new Error(\"Cannot serialize RPC stubs without an RPC session.\");\n }\n getImport(hook) {\n }\n unexport(ids) {\n }\n createPipe(readable) {\n throw new Error(\"Cannot create pipes without an RPC session.\");\n }\n onSendError(error) {\n }\n};\nvar NULL_EXPORTER = new NullExporter();\nasync function streamToBlob(stream, type) {\n let b = await new Response(stream).blob();\n return b.type === type ? b : b.slice(0, b.size, type);\n}\nvar ERROR_TYPES = {\n __proto__: null,\n Error,\n EvalError,\n RangeError,\n ReferenceError,\n SyntaxError,\n TypeError,\n URIError,\n AggregateError\n};\nvar Devaluator = class Devaluator2 {\n exporter;\n source;\n encodingLevel;\n constructor(exporter, source, encodingLevel) {\n this.exporter = exporter;\n this.source = source;\n this.encodingLevel = encodingLevel;\n }\n static devaluate(value, parent, exporter = NULL_EXPORTER, source, encodingLevel = \"string\") {\n let devaluator = new Devaluator2(exporter, source, encodingLevel);\n try {\n return devaluator.devaluateImpl(value, parent, 0);\n } catch (err) {\n if (devaluator.exports) try {\n exporter.unexport(devaluator.exports);\n } catch (err2) {\n }\n throw err;\n }\n }\n exports;\n devaluateImpl(value, parent, depth) {\n if (depth >= 256) throw new Error(\"Serialization exceeded maximum allowed depth. (Does the message contain cycles?)\");\n switch (typeForRpc(value)) {\n case \"unsupported\": {\n let msg;\n try {\n msg = `Cannot serialize value: ${value}`;\n } catch (err) {\n msg = \"Cannot serialize value: (couldn't stringify value)\";\n }\n throw new TypeError(msg);\n }\n case \"primitive\":\n if (typeof value === \"number\" && !isFinite(value)) {\n if (this.encodingLevel === \"structuredClonable\") return value;\n if (value === Infinity) return [\"inf\"];\n else if (value === -Infinity) return [\"-inf\"];\n else return [\"nan\"];\n } else return value;\n case \"object\": {\n let object = value;\n let result = {};\n for (let key in object) result[key] = this.devaluateImpl(object[key], object, depth + 1);\n return result;\n }\n case \"array\": {\n let array = value;\n let len = array.length;\n let result = new Array(len);\n for (let i = 0; i < len; i++) result[i] = this.devaluateImpl(array[i], array, depth + 1);\n return [result];\n }\n case \"bigint\":\n if (this.encodingLevel === \"structuredClonable\") return value;\n return [\"bigint\", value.toString()];\n case \"date\": {\n if (this.encodingLevel === \"structuredClonable\") return value;\n const time = value.getTime();\n return [\"date\", Number.isNaN(time) ? null : time];\n }\n case \"bytes\": {\n let alternateTypeName = BYTE_CONTAINER_TYPE_BY_PROTOTYPE.get(Object.getPrototypeOf(value));\n let bytes;\n if (alternateTypeName === \"ArrayBuffer\") bytes = new Uint8Array(value);\n else if (alternateTypeName === void 0) bytes = value;\n else {\n let view = value;\n bytes = new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n let elementSize = TYPED_ARRAY_ELEMENT_SIZE[alternateTypeName];\n if (!NATIVE_LITTLE_ENDIAN && elementSize) {\n bytes = bytes.slice();\n swapByteOrder(bytes, elementSize);\n }\n }\n if (this.encodingLevel === \"structuredClonable\" || this.encodingLevel === \"jsonCompatibleWithBytes\") return alternateTypeName === void 0 ? [\"bytes\", bytes] : [\n \"bytes\",\n bytes,\n alternateTypeName\n ];\n let b64;\n if (bytes.toBase64) b64 = bytes.toBase64({ omitPadding: true });\n else if (typeof Buffer !== \"undefined\") b64 = (bytes instanceof Buffer ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)).toString(\"base64\");\n else {\n let binary = \"\";\n for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);\n b64 = btoa(binary);\n }\n b64 = b64.replace(/=+$/, \"\");\n return alternateTypeName === void 0 ? [\"bytes\", b64] : [\n \"bytes\",\n b64,\n alternateTypeName\n ];\n }\n case \"url\":\n return [\"url\", value.href];\n case \"headers\":\n return [\"headers\", [...value]];\n case \"request\": {\n let req = value;\n let init = {};\n if (req.method !== \"GET\") init.method = req.method;\n let headers = [...req.headers];\n if (headers.length > 0) init.headers = headers;\n if (req.body) {\n init.body = this.devaluateImpl(req.body, req, depth + 1);\n init.duplex = req.duplex || \"half\";\n } else if (req.body === void 0 && ![\n \"GET\",\n \"HEAD\",\n \"OPTIONS\",\n \"TRACE\",\n \"DELETE\"\n ].includes(req.method)) {\n let bodyPromise = req.arrayBuffer();\n let readable = new ReadableStream({ async start(controller) {\n try {\n controller.enqueue(new Uint8Array(await bodyPromise));\n controller.close();\n } catch (err) {\n controller.error(err);\n }\n } });\n let hook = streamImpl.createReadableStreamHook(readable);\n init.body = [\"readable\", this.exporter.createPipe(readable, hook)];\n init.duplex = req.duplex || \"half\";\n }\n if (req.cache && req.cache !== \"default\") init.cache = req.cache;\n if (req.redirect !== \"follow\") init.redirect = req.redirect;\n if (req.integrity) init.integrity = req.integrity;\n if (req.mode && req.mode !== \"cors\") init.mode = req.mode;\n if (req.credentials && req.credentials !== \"same-origin\") init.credentials = req.credentials;\n if (req.referrer && req.referrer !== \"about:client\") init.referrer = req.referrer;\n if (req.referrerPolicy) init.referrerPolicy = req.referrerPolicy;\n if (req.keepalive) init.keepalive = req.keepalive;\n let cfReq = req;\n if (cfReq.cf) init.cf = cfReq.cf;\n if (cfReq.encodeResponseBody && cfReq.encodeResponseBody !== \"automatic\") init.encodeResponseBody = cfReq.encodeResponseBody;\n return [\n \"request\",\n req.url,\n init\n ];\n }\n case \"response\": {\n let resp = value;\n let body = this.devaluateImpl(resp.body, resp, depth + 1);\n let init = {};\n if (resp.status !== 200) init.status = resp.status;\n if (resp.statusText) init.statusText = resp.statusText;\n let headers = [...resp.headers];\n if (headers.length > 0) init.headers = headers;\n let cfResp = resp;\n if (cfResp.cf) init.cf = cfResp.cf;\n if (cfResp.encodeBody && cfResp.encodeBody !== \"automatic\") init.encodeBody = cfResp.encodeBody;\n if (cfResp.webSocket) throw new TypeError(\"Can't serialize a Response containing a webSocket.\");\n return [\n \"response\",\n body,\n init\n ];\n }\n case \"blob\": {\n let blob = value;\n let readable = blob.stream();\n let hook = streamImpl.createReadableStreamHook(readable);\n let importId = this.exporter.createPipe(readable, hook);\n return [\n \"blob\",\n blob.type,\n [\"readable\", importId]\n ];\n }\n case \"error\": {\n let e = value;\n let rewritten = this.exporter.onSendError(e);\n if (rewritten) e = rewritten;\n let anyE = e;\n let props;\n let captureProp = (key, val) => {\n let exportsBefore = this.exports?.length ?? 0;\n try {\n let encoded = this.devaluateImpl(val, e, depth + 1);\n if (!props) props = {};\n props[key] = encoded;\n } catch (err) {\n if (this.exports && this.exports.length > exportsBefore) {\n let tail = this.exports.splice(exportsBefore);\n try {\n this.exporter.unexport(tail);\n } catch (err2) {\n }\n }\n }\n };\n for (let key of Object.keys(e)) {\n if (key === \"name\" || key === \"message\" || key === \"stack\") continue;\n captureProp(key, anyE[key]);\n }\n if (\"cause\" in e) captureProp(\"cause\", anyE.cause);\n if (e instanceof AggregateError) captureProp(\"errors\", e.errors);\n let result = [\n \"error\",\n e.name,\n e.message\n ];\n if (props) {\n result.push(rewritten && rewritten.stack ? rewritten.stack : null);\n result.push(props);\n } else if (rewritten && rewritten.stack) result.push(rewritten.stack);\n return result;\n }\n case \"undefined\":\n if (this.encodingLevel === \"structuredClonable\") return;\n return [\"undefined\"];\n case \"stub\":\n case \"rpc-promise\": {\n if (!this.source) throw new Error(\"Can't serialize RPC stubs in this context.\");\n let { hook, pathIfPromise } = unwrapStubAndPath(value);\n let importId = this.exporter.getImport(hook);\n if (importId !== void 0) if (pathIfPromise) if (pathIfPromise.length > 0) return [\n \"pipeline\",\n importId,\n pathIfPromise\n ];\n else return [\"pipeline\", importId];\n else return [\"import\", importId];\n if (pathIfPromise) hook = hook.get(pathIfPromise);\n else hook = hook.dup();\n return this.devaluateHook(pathIfPromise ? \"promise\" : \"export\", hook);\n }\n case \"function\":\n case \"rpc-target\": {\n if (!this.source) throw new Error(\"Can't serialize RPC stubs in this context.\");\n let hook = this.source.getHookForRpcTarget(value, parent);\n return this.devaluateHook(\"export\", hook);\n }\n case \"rpc-thenable\": {\n if (!this.source) throw new Error(\"Can't serialize RPC stubs in this context.\");\n let hook = this.source.getHookForRpcTarget(value, parent);\n return this.devaluateHook(\"promise\", hook);\n }\n case \"writable\": {\n if (!this.source) throw new Error(\"Can't serialize WritableStream in this context.\");\n let hook = this.source.getHookForWritableStream(value, parent);\n return this.devaluateHook(\"writable\", hook);\n }\n case \"readable\": {\n if (!this.source) throw new Error(\"Can't serialize ReadableStream in this context.\");\n let ws = value;\n let hook = this.source.getHookForReadableStream(ws, parent);\n return [\"readable\", this.exporter.createPipe(ws, hook)];\n }\n default:\n throw new Error(\"unreachable\");\n }\n }\n devaluateHook(type, hook) {\n if (!this.exports) this.exports = [];\n let exportId = type === \"promise\" ? this.exporter.exportPromise(hook) : this.exporter.exportStub(hook);\n this.exports.push(exportId);\n return [type, exportId];\n }\n};\nvar NullImporter = class {\n importStub(idx) {\n throw new Error(\"Cannot deserialize RPC stubs without an RPC session.\");\n }\n importPromise(idx) {\n throw new Error(\"Cannot deserialize RPC stubs without an RPC session.\");\n }\n getExport(idx) {\n }\n getPipeReadable(exportId) {\n throw new Error(\"Cannot retrieve pipe readable without an RPC session.\");\n }\n getLimits() {\n return DEFAULT_LIMITS;\n }\n};\nvar NULL_IMPORTER = new NullImporter();\nfunction fixBrokenRequestBody(request, body) {\n return new RpcPromise$1(new PromiseStubHook(new Response(body).arrayBuffer().then((arrayBuffer) => {\n let bytes = new Uint8Array(arrayBuffer);\n let result = new Request(request, { body: bytes });\n return new PayloadStubHook(RpcPayload.fromAppReturn(result));\n })), []);\n}\nfunction streamToBlobPromise(stream, type) {\n return new RpcPromise$1(new PromiseStubHook(streamToBlob(stream, type).then((blob) => {\n return new PayloadStubHook(RpcPayload.fromAppReturn(blob));\n })), []);\n}\nvar Evaluator = class Evaluator2 {\n importer;\n encodingLevel;\n limits;\n constructor(importer, encodingLevel = \"string\") {\n this.importer = importer;\n this.encodingLevel = encodingLevel;\n this.limits = importer.getLimits();\n }\n hooks = [];\n promises = [];\n evaluate(value) {\n return this.evaluateWithDepth(value, 0);\n }\n evaluateWithDepth(value, depth) {\n let payload = RpcPayload.forEvaluate(this.hooks, this.promises);\n try {\n payload.value = this.evaluateImpl(value, payload, \"value\", depth);\n return payload;\n } catch (err) {\n payload.dispose();\n throw err;\n }\n }\n evaluateCopy(value) {\n return this.evaluate(structuredClone(value));\n }\n evaluateImpl(value, parent, property, depth) {\n let maxDepth = this.limits.maxDepth;\n if (depth >= maxDepth) throw new TypeError(`Deserialization exceeded maximum allowed message depth of ${maxDepth}.`);\n if (this.encodingLevel === \"structuredClonable\") {\n if (value instanceof Date || typeof value === \"bigint\") return value;\n }\n if (value instanceof Array) {\n if (value.length == 1 && value[0] instanceof Array) {\n let result = value[0];\n for (let i = 0; i < result.length; i++) result[i] = this.evaluateImpl(result[i], result, i, depth + 1);\n return result;\n } else switch (value[0]) {\n case \"bigint\":\n if (typeof value[1] == \"string\") {\n let digits = value[1];\n let maxBigIntDigits = this.limits.maxBigIntDigits;\n if (digits.length > maxBigIntDigits) throw new TypeError(`Deserialized bigint exceeds maximum length of ${maxBigIntDigits} digits.`);\n return BigInt(digits);\n }\n break;\n case \"date\":\n if (value[1] === null) return /* @__PURE__ */ new Date(NaN);\n if (typeof value[1] == \"number\") return new Date(value[1]);\n break;\n case \"bytes\": {\n let bytes;\n if (value[1] instanceof Uint8Array) bytes = value[1];\n else if (typeof value[1] == \"string\") if (typeof Buffer !== \"undefined\") bytes = Buffer.from(value[1], \"base64\");\n else if (Uint8Array.fromBase64) bytes = Uint8Array.fromBase64(value[1]);\n else {\n let bs = atob(value[1]);\n let len = bs.length;\n bytes = new Uint8Array(len);\n for (let i = 0; i < len; i++) bytes[i] = bs.charCodeAt(i);\n }\n else break;\n if (value.length === 2) return bytes;\n if (typeof value[2] !== \"string\") throw new TypeError(`Unknown bytes type marker type: ${typeof value[2]}`);\n if (!isValidByteContainerName(value[2])) {\n let marker2 = value[2].slice(0, 64);\n throw new TypeError(`Unknown bytes type marker: ${marker2}`);\n }\n let marker = value[2];\n let elementSize = TYPED_ARRAY_ELEMENT_SIZE[marker];\n if (elementSize !== void 0 && bytes.byteLength % elementSize !== 0) throw new TypeError(`Invalid byte length ${bytes.byteLength} for ${marker}; expected a multiple of ${elementSize}`);\n let buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);\n if (!NATIVE_LITTLE_ENDIAN && elementSize !== void 0) swapByteOrder(new Uint8Array(buffer), elementSize);\n switch (marker) {\n case \"ArrayBuffer\":\n return buffer;\n case \"DataView\":\n return new DataView(buffer);\n case \"Int8Array\":\n return new Int8Array(buffer);\n case \"Uint8Array\":\n return new Uint8Array(buffer);\n case \"Uint8ClampedArray\":\n return new Uint8ClampedArray(buffer);\n case \"Int16Array\":\n return new Int16Array(buffer);\n case \"Uint16Array\":\n return new Uint16Array(buffer);\n case \"Int32Array\":\n return new Int32Array(buffer);\n case \"Uint32Array\":\n return new Uint32Array(buffer);\n case \"BigInt64Array\":\n return new BigInt64Array(buffer);\n case \"BigUint64Array\":\n return new BigUint64Array(buffer);\n case \"Float32Array\":\n return new Float32Array(buffer);\n case \"Float64Array\":\n return new Float64Array(buffer);\n default:\n }\n }\n case \"error\":\n if (value.length >= 3 && typeof value[1] === \"string\" && typeof value[2] === \"string\") {\n let cls = ERROR_TYPES[value[1]] || Error;\n let result = cls === AggregateError ? new cls([], value[2]) : new cls(value[2]);\n if (typeof value[3] === \"string\") result.stack = value[3];\n if (value.length >= 5) {\n let props = value[4];\n if (!props || typeof props !== \"object\" || Array.isArray(props)) break;\n let anyResult = result;\n let propsObj = props;\n for (let key of Object.keys(propsObj)) {\n if (key === \"name\" || key === \"message\" || key === \"stack\") continue;\n if (key in Object.prototype || key === \"toJSON\") {\n this.evaluateImpl(propsObj[key], result, key, depth + 1);\n continue;\n }\n anyResult[key] = this.evaluateImpl(propsObj[key], result, key, depth + 1);\n }\n }\n return result;\n }\n break;\n case \"undefined\":\n if (value.length === 1) return;\n break;\n case \"inf\":\n return Infinity;\n case \"-inf\":\n return -Infinity;\n case \"nan\":\n return NaN;\n case \"url\":\n if (value.length === 2 && typeof value[1] === \"string\") return new URL(value[1]);\n break;\n case \"headers\":\n if (value.length === 2 && value[1] instanceof Array) return new Headers(value[1]);\n break;\n case \"request\": {\n if (value.length !== 3 || typeof value[1] !== \"string\") break;\n let url = value[1];\n let init = value[2];\n if (typeof init !== \"object\" || init === null) break;\n if (init.body) {\n init.body = this.evaluateImpl(init.body, init, \"body\", depth + 1);\n if (init.body === null || typeof init.body === \"string\" || init.body instanceof Uint8Array || init.body instanceof ReadableStream) {\n } else throw new TypeError(\"Request body must be of type ReadableStream.\");\n }\n if (init.signal) {\n init.signal = this.evaluateImpl(init.signal, init, \"signal\", depth + 1);\n if (!(init.signal instanceof AbortSignal)) throw new TypeError(\"Request siganl must be of type AbortSignal.\");\n }\n if (init.headers && !(init.headers instanceof Array)) throw new TypeError(\"Request headers must be serialized as an array of pairs.\");\n let result = new Request(url, init);\n if (init.body instanceof ReadableStream && result.body === void 0) {\n let promise = fixBrokenRequestBody(result, init.body);\n this.promises.push({\n promise,\n parent,\n property\n });\n return promise;\n } else return result;\n }\n case \"response\": {\n if (value.length !== 3) break;\n let body = this.evaluateImpl(value[1], parent, property, depth + 1);\n if (body === null || typeof body === \"string\" || body instanceof Uint8Array || body instanceof ReadableStream) {\n } else throw new TypeError(\"Response body must be of type ReadableStream.\");\n let init = value[2];\n if (typeof init !== \"object\" || init === null) break;\n if (init.webSocket) throw new TypeError(\"Can't deserialize a Response containing a webSocket.\");\n if (init.headers && !(init.headers instanceof Array)) throw new TypeError(\"Request headers must be serialized as an array of pairs.\");\n return new Response(body, init);\n }\n case \"blob\": {\n if (value.length !== 3 || typeof value[1] !== \"string\") break;\n let contentType = value[1];\n let content = this.evaluateImpl(value[2], parent, property, depth + 1);\n if (!(content instanceof ReadableStream)) throw new TypeError(\"Blob content must be serialized as a ReadableStream.\");\n let promise = streamToBlobPromise(content, contentType);\n this.promises.push({\n promise,\n parent,\n property\n });\n return promise;\n }\n case \"import\":\n case \"pipeline\": {\n if (value.length < 2 || value.length > 4) break;\n if (typeof value[1] != \"number\") break;\n let hook = this.importer.getExport(value[1]);\n if (!hook) throw new Error(`no such entry on exports table: ${value[1]}`);\n let isPromise = value[0] == \"pipeline\";\n let addStub = (hook2) => {\n if (isPromise) {\n let promise = new RpcPromise$1(hook2, []);\n this.promises.push({\n promise,\n parent,\n property\n });\n return promise;\n } else {\n this.hooks.push(hook2);\n return new RpcPromise$1(hook2, []);\n }\n };\n if (value.length == 2) if (isPromise) return addStub(hook.get([]));\n else return addStub(hook.dup());\n let path = value[2];\n if (!(path instanceof Array)) break;\n if (!path.every((part) => {\n return typeof part == \"string\" || typeof part == \"number\";\n })) break;\n if (value.length == 3) return addStub(hook.get(path));\n let args = value[3];\n if (!(args instanceof Array)) break;\n args = new Evaluator2(this.importer).evaluateWithDepth([args], depth);\n return addStub(hook.call(path, args));\n }\n case \"remap\": {\n if (value.length !== 5 || typeof value[1] !== \"number\" || !(value[2] instanceof Array) || !(value[3] instanceof Array) || !(value[4] instanceof Array)) break;\n let hook = this.importer.getExport(value[1]);\n if (!hook) throw new Error(`no such entry on exports table: ${value[1]}`);\n let path = value[2];\n if (!path.every((part) => {\n return typeof part == \"string\" || typeof part == \"number\";\n })) break;\n let captures = value[3].map((cap) => {\n if (!(cap instanceof Array) || cap.length !== 2 || cap[0] !== \"import\" && cap[0] !== \"export\" || typeof cap[1] !== \"number\") throw new TypeError(`unknown map capture: ${JSON.stringify(cap)}`);\n if (cap[0] === \"export\") return this.importer.importStub(cap[1]);\n else {\n let exp = this.importer.getExport(cap[1]);\n if (!exp) throw new Error(`no such entry on exports table: ${cap[1]}`);\n return exp.dup();\n }\n });\n let instructions = value[4];\n let promise = new RpcPromise$1(hook.map(path, captures, instructions), []);\n this.promises.push({\n promise,\n parent,\n property\n });\n return promise;\n }\n case \"export\":\n case \"promise\":\n if (typeof value[1] == \"number\") if (value[0] == \"promise\") {\n let promise = new RpcPromise$1(this.importer.importPromise(value[1]), []);\n this.promises.push({\n parent,\n property,\n promise\n });\n return promise;\n } else {\n let hook = this.importer.importStub(value[1]);\n this.hooks.push(hook);\n return new RpcStub$1(hook);\n }\n break;\n case \"writable\":\n if (typeof value[1] == \"number\") {\n let hook = this.importer.importStub(value[1]);\n let stream = streamImpl.createWritableStreamFromHook(hook);\n this.hooks.push(hook);\n return stream;\n }\n break;\n case \"readable\":\n if (typeof value[1] == \"number\") {\n let stream = this.importer.getPipeReadable(value[1]);\n let hook = streamImpl.createReadableStreamHook(stream);\n this.hooks.push(hook);\n return stream;\n }\n break;\n }\n throw new TypeError(`unknown special value: ${JSON.stringify(value)}`);\n } else if (value instanceof Object) {\n let result = value;\n for (let key in result) if (key in Object.prototype || key === \"toJSON\") {\n this.evaluateImpl(result[key], result, key, depth + 1);\n delete result[key];\n } else result[key] = this.evaluateImpl(result[key], result, key, depth + 1);\n return result;\n } else return value;\n }\n};\nvar ESTIMATED_OBJECT_OVERHEAD = 16;\nvar ESTIMATED_ENTRY_OVERHEAD = 8;\nvar ESTIMATED_BINARY_OVERHEAD = 16;\nvar MAX_ESTIMATE_DEPTH = 64;\nfunction estimateStringSize(value) {\n return 2 + value.length * 3;\n}\nfunction estimateEncodedSize(value, seen, depth = 0) {\n if (depth >= MAX_ESTIMATE_DEPTH) return ESTIMATED_ENTRY_OVERHEAD;\n switch (typeof value) {\n case \"string\":\n return estimateStringSize(value);\n case \"number\":\n return 16;\n case \"bigint\":\n return 16;\n case \"boolean\":\n return 8;\n case \"undefined\":\n return 16;\n case \"object\": {\n if (value === null) return 8;\n if (ArrayBuffer.isView(value)) return ESTIMATED_BINARY_OVERHEAD + value.byteLength;\n if (value instanceof ArrayBuffer) return ESTIMATED_BINARY_OVERHEAD + value.byteLength;\n if (typeof Blob !== \"undefined\" && value instanceof Blob) return ESTIMATED_BINARY_OVERHEAD + value.size;\n if (value instanceof Date) return 16;\n seen ??= /* @__PURE__ */ new WeakSet();\n if (seen.has(value)) return ESTIMATED_ENTRY_OVERHEAD;\n seen.add(value);\n if (value instanceof Array) {\n let size2 = ESTIMATED_OBJECT_OVERHEAD;\n for (let item of value) size2 += ESTIMATED_ENTRY_OVERHEAD + estimateEncodedSize(item, seen, depth + 1);\n return size2;\n }\n if (value instanceof Error) {\n let size2 = ESTIMATED_OBJECT_OVERHEAD + estimateStringSize(value.name) + estimateStringSize(value.message) + estimateStringSize(value.stack ?? \"\");\n for (let key of Object.keys(value)) size2 += ESTIMATED_ENTRY_OVERHEAD + estimateStringSize(key) + estimateEncodedSize(value[key], seen, depth + 1);\n return size2;\n }\n let size = ESTIMATED_OBJECT_OVERHEAD;\n for (let key of Object.keys(value)) size += ESTIMATED_ENTRY_OVERHEAD + estimateStringSize(key) + estimateEncodedSize(value[key], seen, depth + 1);\n return size;\n }\n default:\n return 16;\n }\n}\nvar ImportTableEntry = class {\n session;\n importId;\n constructor(session, importId, pulling) {\n this.session = session;\n this.importId = importId;\n if (pulling) this.activePull = Promise.withResolvers();\n }\n localRefcount = 0;\n remoteRefcount = 1;\n activePull;\n resolution;\n onBrokenRegistrations;\n resolve(resolution) {\n if (this.localRefcount == 0) {\n resolution.dispose();\n return;\n }\n this.resolution = resolution;\n this.sendRelease();\n if (this.onBrokenRegistrations) {\n for (let i of this.onBrokenRegistrations) {\n let callback = this.session.onBrokenCallbacks[i];\n let endIndex = this.session.onBrokenCallbacks.length;\n resolution.onBroken(callback);\n if (this.session.onBrokenCallbacks[endIndex] === callback) delete this.session.onBrokenCallbacks[endIndex];\n else delete this.session.onBrokenCallbacks[i];\n }\n this.onBrokenRegistrations = void 0;\n }\n if (this.activePull) {\n this.activePull.resolve();\n this.activePull = void 0;\n }\n }\n async awaitResolution() {\n if (!this.activePull) {\n this.session.sendPull(this.importId);\n this.activePull = Promise.withResolvers();\n }\n await this.activePull.promise;\n return this.resolution.pull();\n }\n dispose() {\n if (this.resolution) this.resolution.dispose();\n else {\n this.abort(/* @__PURE__ */ new Error(\"RPC was canceled because the RpcPromise was disposed.\"));\n this.sendRelease();\n }\n }\n abort(error) {\n if (!this.resolution) {\n this.resolution = new ErrorStubHook(error);\n if (this.activePull) {\n this.activePull.reject(error);\n this.activePull = void 0;\n }\n this.onBrokenRegistrations = void 0;\n }\n }\n onBroken(callback) {\n if (this.resolution) this.resolution.onBroken(callback);\n else {\n let index = this.session.onBrokenCallbacks.length;\n this.session.onBrokenCallbacks.push(callback);\n if (!this.onBrokenRegistrations) this.onBrokenRegistrations = [];\n this.onBrokenRegistrations.push(index);\n }\n }\n sendRelease() {\n if (this.remoteRefcount > 0) {\n this.session.sendRelease(this.importId, this.remoteRefcount);\n this.remoteRefcount = 0;\n }\n }\n};\nvar RpcImportHook = class RpcImportHook2 extends StubHook {\n isPromise;\n entry;\n constructor(isPromise, entry) {\n super();\n this.isPromise = isPromise;\n ++entry.localRefcount;\n this.entry = entry;\n }\n collectPath(path) {\n return this;\n }\n getEntry() {\n if (this.entry) return this.entry;\n else throw new Error(\"This RpcImportHook was already disposed.\");\n }\n getEntryTakingOwnership(disposeOwned) {\n try {\n return this.getEntry();\n } catch (err) {\n disposeOwned();\n throw err;\n }\n }\n call(path, args) {\n let entry = this.getEntryTakingOwnership(() => args.dispose());\n if (entry.resolution) return entry.resolution.call(path, args);\n else return entry.session.sendCall(entry.importId, path, args);\n }\n stream(path, args) {\n let entry = this.getEntryTakingOwnership(() => args.dispose());\n if (entry.resolution) return entry.resolution.stream(path, args);\n else return entry.session.sendStream(entry.importId, path, args);\n }\n map(path, captures, instructions) {\n let entry = this.getEntryTakingOwnership(() => {\n for (let cap of captures) cap.dispose();\n });\n if (entry.resolution) return entry.resolution.map(path, captures, instructions);\n else return entry.session.sendMap(entry.importId, path, captures, instructions);\n }\n get(path) {\n let entry = this.getEntry();\n if (entry.resolution) return entry.resolution.get(path);\n else return entry.session.sendCall(entry.importId, path);\n }\n dup() {\n return new RpcImportHook2(false, this.getEntry());\n }\n pull() {\n let entry = this.getEntry();\n if (!this.isPromise) throw new Error(\"Can't pull this hook because it's not a promise hook.\");\n if (entry.resolution) return entry.resolution.pull();\n return entry.awaitResolution();\n }\n ignoreUnhandledRejections() {\n }\n dispose() {\n let entry = this.entry;\n this.entry = void 0;\n if (entry) {\n if (--entry.localRefcount === 0) entry.dispose();\n }\n }\n onBroken(callback) {\n if (this.entry) this.entry.onBroken(callback);\n }\n};\nvar RpcMainHook = class extends RpcImportHook {\n session;\n constructor(entry) {\n super(false, entry);\n this.session = entry.session;\n }\n dispose() {\n if (this.session) {\n let session = this.session;\n this.session = void 0;\n session.shutdown();\n }\n }\n};\nvar RpcSessionImpl = class {\n transport;\n options;\n exports = [];\n reverseExports = /* @__PURE__ */ new Map();\n imports = [];\n abortReason;\n cancelReadLoop;\n nextExportId = -1;\n onBatchDone;\n pullCount = 0;\n onBrokenCallbacks = [];\n encodingLevel;\n limits;\n constructor(transport, mainHook, options) {\n this.transport = transport;\n this.options = options;\n let level = \"string\";\n if (\"encodingLevel\" in transport) {\n let raw = transport.encodingLevel;\n if (raw !== void 0) {\n if (raw !== \"string\" && raw !== \"jsonCompatible\" && raw !== \"jsonCompatibleWithBytes\" && raw !== \"structuredClonable\") throw new TypeError(`Unknown transport encodingLevel: ${String(raw)}`);\n level = raw;\n }\n }\n this.encodingLevel = level;\n this.limits = {\n ...DEFAULT_LIMITS,\n ...options.limits\n };\n this.exports.push({\n hook: mainHook,\n refcount: 1\n });\n this.imports.push(new ImportTableEntry(this, 0, false));\n this.readLoop().catch((err) => this.abort(err));\n }\n getMainImport() {\n return new RpcMainHook(this.imports[0]);\n }\n shutdown() {\n this.abort(/* @__PURE__ */ new Error(\"RPC session was shut down by disposing the main stub\"), false);\n }\n exportStub(hook) {\n if (this.abortReason) throw this.abortReason;\n let existingExportId = this.reverseExports.get(hook);\n if (existingExportId !== void 0) {\n ++this.exports[existingExportId].refcount;\n return existingExportId;\n } else {\n let exportId = this.nextExportId--;\n this.exports[exportId] = {\n hook,\n refcount: 1\n };\n this.reverseExports.set(hook, exportId);\n return exportId;\n }\n }\n exportPromise(hook) {\n if (this.abortReason) throw this.abortReason;\n let exportId = this.nextExportId--;\n this.exports[exportId] = {\n hook,\n refcount: 1\n };\n this.reverseExports.set(hook, exportId);\n this.ensureResolvingExport(exportId);\n return exportId;\n }\n unexport(ids) {\n for (let id of ids) this.releaseExport(id, 1);\n }\n releaseExport(exportId, refcount) {\n let entry = this.exports[exportId];\n if (!entry) throw new Error(`no such export ID: ${exportId}`);\n if (entry.refcount < refcount) throw new Error(`refcount would go negative: ${entry.refcount} < ${refcount}`);\n entry.refcount -= refcount;\n if (entry.refcount === 0) {\n delete this.exports[exportId];\n this.reverseExports.delete(entry.hook);\n entry.hook.dispose();\n }\n }\n onSendError(error) {\n if (this.options.onSendError) return this.options.onSendError(error);\n }\n ensureResolvingExport(exportId) {\n let exp = this.exports[exportId];\n if (!exp) throw new Error(`no such export ID: ${exportId}`);\n if (!exp.pull) {\n let resolve = async () => {\n let hook = exp.hook;\n for (; ; ) {\n let payload = await hook.pull();\n if (payload.value instanceof RpcStub$1) {\n let { hook: inner, pathIfPromise } = unwrapStubAndPath(payload.value);\n if (pathIfPromise && pathIfPromise.length == 0) {\n if (this.getImport(hook) === void 0) {\n hook = inner;\n continue;\n }\n }\n }\n return payload;\n }\n };\n let autoRelease = exp.autoRelease;\n ++this.pullCount;\n exp.pull = resolve().then((payload) => {\n let value = Devaluator.devaluate(payload.value, void 0, this, payload, this.encodingLevel);\n this.send([\n \"resolve\",\n exportId,\n value\n ]);\n if (autoRelease) this.releaseExport(exportId, 1);\n }, (error) => {\n this.send([\n \"reject\",\n exportId,\n Devaluator.devaluate(error, void 0, this, void 0, this.encodingLevel)\n ]);\n if (autoRelease) this.releaseExport(exportId, 1);\n }).catch((error) => {\n try {\n this.send([\n \"reject\",\n exportId,\n Devaluator.devaluate(error, void 0, this, void 0, this.encodingLevel)\n ]);\n if (autoRelease) this.releaseExport(exportId, 1);\n } catch (error2) {\n this.abort(error2);\n }\n }).finally(() => {\n if (--this.pullCount === 0) {\n if (this.onBatchDone) this.onBatchDone.resolve();\n }\n });\n }\n }\n getImport(hook) {\n if (hook instanceof RpcImportHook && hook.entry && hook.entry.session === this) return hook.entry.importId;\n else return;\n }\n importStub(idx) {\n if (this.abortReason) throw this.abortReason;\n let entry = this.imports[idx];\n if (!entry) {\n entry = new ImportTableEntry(this, idx, false);\n this.imports[idx] = entry;\n }\n return new RpcImportHook(false, entry);\n }\n importPromise(idx) {\n if (this.abortReason) throw this.abortReason;\n if (this.imports[idx]) return new ErrorStubHook(/* @__PURE__ */ new Error(\"Bug in RPC system: The peer sent a promise reusing an existing export ID.\"));\n let entry = new ImportTableEntry(this, idx, true);\n this.imports[idx] = entry;\n return new RpcImportHook(true, entry);\n }\n getExport(idx) {\n return this.exports[idx]?.hook;\n }\n getPipeReadable(exportId) {\n let entry = this.exports[exportId];\n if (!entry || !entry.pipeReadable) throw new Error(`Export ${exportId} is not a pipe or its readable end was already consumed.`);\n let readable = entry.pipeReadable;\n entry.pipeReadable = void 0;\n return readable;\n }\n getLimits() {\n return this.limits;\n }\n createPipe(readable, readableHook) {\n if (this.abortReason) throw this.abortReason;\n this.send([\"pipe\"]);\n let importId = this.imports.length;\n let entry = new ImportTableEntry(this, importId, false);\n this.imports.push(entry);\n let hook = new RpcImportHook(false, entry);\n let writable = streamImpl.createWritableStreamFromHook(hook);\n readable.pipeTo(writable).catch(() => {\n }).finally(() => readableHook.dispose());\n return importId;\n }\n send(msg) {\n if (this.abortReason !== void 0) return 0;\n if (this.encodingLevel === \"string\") {\n let msgText;\n try {\n msgText = JSON.stringify(msg);\n } catch (err) {\n try {\n this.abort(err);\n } catch (err2) {\n }\n throw err;\n }\n try {\n let sent = this.transport.send(msgText);\n if (sent !== void 0 && typeof sent.catch === \"function\") sent.catch((err) => this.abort(err, false));\n } catch (err) {\n queueMicrotask(() => this.abort(err, false));\n }\n return msgText.length;\n } else try {\n let size = this.transport.send(msg);\n if (typeof size === \"number\") return size;\n let thenable = size;\n if (thenable && typeof thenable.then === \"function\") Promise.resolve(thenable).catch((err) => this.abort(err, false));\n return;\n } catch (err) {\n queueMicrotask(() => this.abort(err, false));\n return;\n }\n }\n sendCall(id, path, args) {\n if (this.abortReason) {\n args?.dispose();\n throw this.abortReason;\n }\n let value = [\n \"pipeline\",\n id,\n path\n ];\n if (args) {\n let devalue;\n try {\n devalue = Devaluator.devaluate(args.value, void 0, this, args, this.encodingLevel);\n } catch (err) {\n args.dispose();\n throw err;\n }\n value.push(devalue[0]);\n }\n this.send([\"push\", value]);\n let entry = new ImportTableEntry(this, this.imports.length, false);\n this.imports.push(entry);\n return new RpcImportHook(true, entry);\n }\n sendStream(id, path, args) {\n if (this.abortReason) {\n args.dispose();\n throw this.abortReason;\n }\n let value = [\n \"pipeline\",\n id,\n path\n ];\n let devalue;\n try {\n devalue = Devaluator.devaluate(args.value, void 0, this, args, this.encodingLevel);\n } catch (err) {\n args.dispose();\n throw err;\n }\n value.push(devalue[0]);\n let msg = [\"stream\", value];\n let size = this.send(msg);\n if (size === void 0) size = estimateEncodedSize(msg);\n let importId = this.imports.length;\n let entry = new ImportTableEntry(this, importId, true);\n entry.remoteRefcount = 0;\n entry.localRefcount = 1;\n this.imports.push(entry);\n return {\n promise: entry.awaitResolution().then((p) => {\n p.dispose();\n delete this.imports[importId];\n }, (err) => {\n delete this.imports[importId];\n throw err;\n }),\n size\n };\n }\n sendMap(id, path, captures, instructions) {\n if (this.abortReason) {\n for (let cap of captures) cap.dispose();\n throw this.abortReason;\n }\n let value = [\n \"remap\",\n id,\n path,\n captures.map((hook) => {\n let importId = this.getImport(hook);\n if (importId !== void 0) return [\"import\", importId];\n else return [\"export\", this.exportStub(hook)];\n }),\n instructions\n ];\n this.send([\"push\", value]);\n let entry = new ImportTableEntry(this, this.imports.length, false);\n this.imports.push(entry);\n return new RpcImportHook(true, entry);\n }\n sendPull(id) {\n if (this.abortReason) throw this.abortReason;\n this.send([\"pull\", id]);\n }\n sendRelease(id, remoteRefcount) {\n if (this.abortReason) return;\n this.send([\n \"release\",\n id,\n remoteRefcount\n ]);\n delete this.imports[id];\n }\n abort(error, trySendAbortMessage = true) {\n if (this.abortReason !== void 0) return;\n this.cancelReadLoop?.(error);\n this.cancelReadLoop = void 0;\n if (trySendAbortMessage) try {\n let abortMsg = [\"abort\", Devaluator.devaluate(error, void 0, this, void 0, this.encodingLevel)];\n if (this.encodingLevel === \"string\") {\n let sent = this.transport.send(JSON.stringify(abortMsg));\n if (sent !== void 0 && typeof sent.catch === \"function\") sent.catch((err) => {\n });\n } else {\n let result = this.transport.send(abortMsg);\n if (result && typeof result.then === \"function\") Promise.resolve(result).catch((err) => {\n });\n }\n } catch (err) {\n }\n if (error === void 0) error = \"undefined\";\n this.abortReason = error;\n if (this.onBatchDone) this.onBatchDone.reject(error);\n if (this.transport.abort) try {\n this.transport.abort(error);\n } catch (err) {\n Promise.resolve(err);\n }\n for (let i in this.onBrokenCallbacks) try {\n this.onBrokenCallbacks[i](error);\n } catch (err) {\n Promise.resolve(err);\n }\n for (let i in this.imports) this.imports[i].abort(error);\n for (let i in this.exports) this.exports[i].hook.dispose();\n }\n async readLoop() {\n while (!this.abortReason) {\n let readCanceled = Promise.withResolvers();\n this.cancelReadLoop = readCanceled.reject;\n let raw;\n try {\n raw = await Promise.race([this.transport.receive(), readCanceled.promise]);\n } finally {\n if (this.cancelReadLoop === readCanceled.reject) this.cancelReadLoop = void 0;\n }\n if (this.encodingLevel === \"string\" && raw.length > this.limits.maxMessageSize) throw new TypeError(`Incoming message exceeds maximum size of ${this.limits.maxMessageSize} UTF-16 code units.`);\n if (this.abortReason) break;\n let msg = this.encodingLevel === \"string\" ? JSON.parse(raw) : raw;\n if (msg instanceof Array) switch (msg[0]) {\n case \"push\":\n if (msg.length > 1) {\n let hook = new PayloadStubHook(new Evaluator(this, this.encodingLevel).evaluate(msg[1]));\n hook.ignoreUnhandledRejections();\n this.exports.push({\n hook,\n refcount: 1\n });\n continue;\n }\n break;\n case \"stream\":\n if (msg.length > 1) {\n let hook = new PayloadStubHook(new Evaluator(this, this.encodingLevel).evaluate(msg[1]));\n hook.ignoreUnhandledRejections();\n let exportId = this.exports.length;\n this.exports.push({\n hook,\n refcount: 1,\n autoRelease: true\n });\n this.ensureResolvingExport(exportId);\n continue;\n }\n break;\n case \"pipe\": {\n let { readable, writable } = new TransformStream();\n let hook = streamImpl.createWritableStreamHook(writable);\n this.exports.push({\n hook,\n refcount: 1,\n pipeReadable: readable\n });\n continue;\n }\n case \"pull\": {\n let exportId = msg[1];\n if (typeof exportId == \"number\") {\n this.ensureResolvingExport(exportId);\n continue;\n }\n break;\n }\n case \"resolve\":\n case \"reject\": {\n let importId = msg[1];\n if (typeof importId == \"number\" && msg.length > 2) {\n let imp = this.imports[importId];\n if (imp) if (msg[0] == \"resolve\") imp.resolve(new PayloadStubHook(new Evaluator(this, this.encodingLevel).evaluate(msg[2])));\n else {\n let payload = new Evaluator(this, this.encodingLevel).evaluate(msg[2]);\n payload.dispose();\n imp.resolve(new ErrorStubHook(payload.value));\n }\n else if (msg[0] == \"resolve\") new Evaluator(this, this.encodingLevel).evaluate(msg[2]).dispose();\n continue;\n }\n break;\n }\n case \"release\": {\n let exportId = msg[1];\n let refcount = msg[2];\n if (typeof exportId == \"number\" && typeof refcount == \"number\") {\n this.releaseExport(exportId, refcount);\n continue;\n }\n break;\n }\n case \"abort\": {\n let payload = new Evaluator(this, this.encodingLevel).evaluate(msg[1]);\n payload.dispose();\n this.abort(payload.value, false);\n break;\n }\n }\n throw new Error(`bad RPC message: ${JSON.stringify(msg)}`);\n }\n }\n async drain() {\n if (this.abortReason) throw this.abortReason;\n if (this.pullCount > 0) {\n let { promise, resolve, reject } = Promise.withResolvers();\n this.onBatchDone = {\n resolve,\n reject\n };\n await promise;\n }\n }\n getStats() {\n let result = {\n imports: 0,\n exports: 0\n };\n for (let i in this.imports) ++result.imports;\n for (let i in this.exports) ++result.exports;\n return result;\n }\n};\nvar RpcSession$1 = class {\n #session;\n #mainStub;\n constructor(transport, localMain, options = {}) {\n let mainHook;\n if (localMain) mainHook = new PayloadStubHook(RpcPayload.fromAppReturn(localMain));\n else mainHook = new ErrorStubHook(/* @__PURE__ */ new Error(\"This connection has no main object.\"));\n this.#session = new RpcSessionImpl(transport, mainHook, options);\n this.#mainStub = new RpcStub$1(this.#session.getMainImport());\n }\n getRemoteMain() {\n return this.#mainStub;\n }\n getStats() {\n return this.#session.getStats();\n }\n drain() {\n return this.#session.drain();\n }\n};\nfunction newWebSocketRpcSession$1(webSocket, localMain, options) {\n if (typeof webSocket === \"string\") webSocket = new WebSocket(webSocket);\n return new RpcSession$1(new WebSocketTransport(webSocket), localMain, options).getRemoteMain();\n}\nfunction newWorkersWebSocketRpcResponse(request, localMain, options) {\n if (request.headers.get(\"Upgrade\")?.toLowerCase() !== \"websocket\") return new Response(\"This endpoint only accepts WebSocket requests.\", { status: 400 });\n let pair = new WebSocketPair();\n let server = pair[0];\n server.accept();\n newWebSocketRpcSession$1(server, localMain, options);\n return new Response(null, {\n status: 101,\n webSocket: pair[1]\n });\n}\nvar WebSocketTransport = class {\n constructor(webSocket) {\n this.#webSocket = webSocket;\n webSocket.binaryType = \"arraybuffer\";\n if (webSocket.readyState === WebSocket.CONNECTING) {\n this.#sendQueue = [];\n webSocket.addEventListener(\"open\", (event) => {\n try {\n for (let message of this.#sendQueue) webSocket.send(message);\n } catch (err) {\n this.#receivedError(err);\n }\n this.#sendQueue = void 0;\n });\n }\n webSocket.addEventListener(\"message\", (event) => {\n if (this.#error) {\n } else if (typeof event.data === \"string\" || event.data instanceof ArrayBuffer) if (this.#receiveResolver) {\n this.#receiveResolver(event.data);\n this.#receiveResolver = void 0;\n this.#receiveRejecter = void 0;\n } else this.#receiveQueue.push(event.data);\n else this.#receivedError(/* @__PURE__ */ new TypeError(\"Received unexpected message type from WebSocket.\"));\n });\n webSocket.addEventListener(\"close\", (event) => {\n this.#receivedError(/* @__PURE__ */ new Error(`Peer closed WebSocket: ${event.code} ${event.reason}`));\n });\n webSocket.addEventListener(\"error\", (event) => {\n this.#receivedError(/* @__PURE__ */ new Error(`WebSocket connection failed.`));\n });\n }\n #webSocket;\n #sendQueue;\n #receiveResolver;\n #receiveRejecter;\n #receiveQueue = [];\n #error;\n send(message) {\n if (this.#sendQueue === void 0) this.#webSocket.send(message);\n else this.#sendQueue.push(message);\n }\n receive() {\n if (this.#receiveQueue.length > 0) return Promise.resolve(this.#receiveQueue.shift());\n else if (this.#error) return Promise.reject(this.#error);\n else return new Promise((resolve, reject) => {\n this.#receiveResolver = resolve;\n this.#receiveRejecter = reject;\n });\n }\n abort(reason) {\n let message;\n if (reason instanceof Error) message = reason.message;\n else message = `${reason}`;\n let reasonBytes = new TextEncoder().encode(message);\n if (reasonBytes.length > 123) message = new TextDecoder().decode(reasonBytes.subarray(0, 123), { stream: true });\n this.#webSocket.close(3e3, message);\n if (!this.#error) this.#error = reason;\n }\n #receivedError(reason) {\n if (!this.#error) {\n this.#error = reason;\n if (this.#receiveRejecter) {\n this.#receiveRejecter(reason);\n this.#receiveResolver = void 0;\n this.#receiveRejecter = void 0;\n }\n }\n }\n};\nvar BatchServerTransport = class {\n constructor(batch) {\n this.#batchToReceive = batch;\n }\n #batchToSend = [];\n #batchToReceive;\n #allReceived = Promise.withResolvers();\n send(message) {\n this.#batchToSend.push(message);\n }\n async receive() {\n let msg = this.#batchToReceive.shift();\n if (msg !== void 0) return msg;\n else {\n this.#allReceived.resolve();\n return new Promise((r) => {\n });\n }\n }\n abort(reason) {\n this.#allReceived.reject(reason);\n }\n whenAllReceived() {\n return this.#allReceived.promise;\n }\n getResponseBody() {\n return this.#batchToSend.join(\"\\n\");\n }\n};\nasync function newHttpBatchRpcResponse(request, localMain, options) {\n if (request.method !== \"POST\") return new Response(\"This endpoint only accepts POST requests.\", { status: 405 });\n let body = await request.text();\n let transport = new BatchServerTransport(body === \"\" ? [] : body.split(\"\\n\"));\n let rpc = new RpcSession$1(transport, localMain, options);\n await transport.whenAllReceived();\n await rpc.drain();\n return new Response(transport.getResponseBody());\n}\nvar currentMapBuilder;\nvar MapBuilder = class {\n context;\n captureMap = /* @__PURE__ */ new Map();\n instructions = [];\n constructor(subject, path) {\n if (currentMapBuilder) this.context = {\n parent: currentMapBuilder,\n captures: [],\n subject: currentMapBuilder.capture(subject),\n path\n };\n else this.context = {\n parent: void 0,\n captures: [],\n subject,\n path\n };\n currentMapBuilder = this;\n }\n unregister() {\n currentMapBuilder = this.context.parent;\n }\n makeInput() {\n return new MapVariableHook(this, 0);\n }\n makeOutput(result) {\n let devalued;\n try {\n devalued = Devaluator.devaluate(result.value, void 0, this, result);\n } finally {\n result.dispose();\n }\n this.instructions.push(devalued);\n if (this.context.parent) {\n this.context.parent.instructions.push([\n \"remap\",\n this.context.subject,\n this.context.path,\n this.context.captures.map((cap) => [\"import\", cap]),\n this.instructions\n ]);\n return new MapVariableHook(this.context.parent, this.context.parent.instructions.length);\n } else return this.context.subject.map(this.context.path, this.context.captures, this.instructions);\n }\n pushCall(hook, path, params) {\n let devalued = Devaluator.devaluate(params.value, void 0, this, params);\n devalued = devalued[0];\n let subject = this.capture(hook.dup());\n this.instructions.push([\n \"pipeline\",\n subject,\n path,\n devalued\n ]);\n return new MapVariableHook(this, this.instructions.length);\n }\n pushGet(hook, path) {\n let subject = this.capture(hook.dup());\n this.instructions.push([\n \"pipeline\",\n subject,\n path\n ]);\n return new MapVariableHook(this, this.instructions.length);\n }\n capture(hook) {\n if (hook instanceof MapVariableHook && hook.mapper === this) return hook.idx;\n let result = this.captureMap.get(hook);\n if (result === void 0) {\n if (this.context.parent) {\n let parentIdx = this.context.parent.capture(hook);\n this.context.captures.push(parentIdx);\n } else this.context.captures.push(hook);\n result = -this.context.captures.length;\n this.captureMap.set(hook, result);\n }\n return result;\n }\n exportStub(hook) {\n throw new Error(\"Can't construct an RpcTarget or RPC callback inside a mapper function. Try creating a new RpcStub outside the callback first, then using it inside the callback.\");\n }\n exportPromise(hook) {\n return this.exportStub(hook);\n }\n getImport(hook) {\n return this.capture(hook);\n }\n unexport(ids) {\n }\n createPipe(readable) {\n throw new Error(\"Cannot send ReadableStream inside a mapper function.\");\n }\n onSendError(error) {\n }\n};\nmapImpl.sendMap = (hook, path, func) => {\n let builder = new MapBuilder(hook, path);\n let result;\n try {\n result = RpcPayload.fromAppReturn(withCallInterceptor(builder.pushCall.bind(builder), () => {\n return func(new RpcPromise$1(builder.makeInput(), []));\n }));\n } finally {\n builder.unregister();\n }\n if (result instanceof Promise) {\n result.catch((err) => {\n });\n throw new Error(\"RPC map() callbacks cannot be async.\");\n }\n return new RpcPromise$1(builder.makeOutput(result), []);\n};\nfunction throwMapperBuilderUseError() {\n throw new Error(\"Attempted to use an abstract placeholder from a mapper function. Please make sure your map function has no side effects.\");\n}\nvar MapVariableHook = class extends StubHook {\n mapper;\n idx;\n constructor(mapper, idx) {\n super();\n this.mapper = mapper;\n this.idx = idx;\n }\n dup() {\n return this;\n }\n dispose() {\n }\n get(path) {\n if (path.length == 0) return this;\n else if (currentMapBuilder) return currentMapBuilder.pushGet(this, path);\n else throwMapperBuilderUseError();\n }\n call(path, args) {\n args.dispose();\n throwMapperBuilderUseError();\n }\n map(path, captures, instructions) {\n for (let cap of captures) cap.dispose();\n throwMapperBuilderUseError();\n }\n pull() {\n throwMapperBuilderUseError();\n }\n ignoreUnhandledRejections() {\n }\n onBroken(callback) {\n throwMapperBuilderUseError();\n }\n};\nvar MapApplicator = class {\n captures;\n variables;\n constructor(captures, input) {\n this.captures = captures;\n this.variables = [input];\n }\n dispose() {\n for (let variable of this.variables) variable.dispose();\n }\n apply(instructions) {\n try {\n if (instructions.length < 1) throw new Error(\"Invalid empty mapper function.\");\n for (let instruction of instructions.slice(0, -1)) {\n let payload = new Evaluator(this).evaluateCopy(instruction);\n if (payload.value instanceof RpcStub$1) {\n let hook = unwrapStubNoProperties(payload.value);\n if (hook) {\n this.variables.push(hook);\n continue;\n }\n }\n this.variables.push(new PayloadStubHook(payload));\n }\n return new Evaluator(this).evaluateCopy(instructions[instructions.length - 1]);\n } finally {\n for (let variable of this.variables) variable.dispose();\n }\n }\n importStub(idx) {\n throw new Error(\"A mapper function cannot refer to exports.\");\n }\n importPromise(idx) {\n return this.importStub(idx);\n }\n getExport(idx) {\n if (idx < 0) return this.captures[-idx - 1];\n else return this.variables[idx];\n }\n getPipeReadable(exportId) {\n throw new Error(\"A mapper function cannot use pipe readables.\");\n }\n getLimits() {\n return DEFAULT_LIMITS;\n }\n};\nfunction applyMapToElement(input, parent, owner, captures, instructions) {\n let mapper = new MapApplicator(captures, new PayloadStubHook(RpcPayload.deepCopyFrom(input, parent, owner)));\n try {\n return mapper.apply(instructions);\n } finally {\n mapper.dispose();\n }\n}\nmapImpl.applyMap = (input, parent, owner, captures, instructions) => {\n try {\n let result;\n if (input instanceof RpcPromise$1) throw new Error(\"applyMap() can't be called on RpcPromise\");\n else if (input instanceof Array) {\n let payloads = [];\n try {\n for (let elem of input) payloads.push(applyMapToElement(elem, input, owner, captures, instructions));\n } catch (err) {\n for (let payload of payloads) payload.dispose();\n throw err;\n }\n result = RpcPayload.fromArray(payloads);\n } else if (input === null || input === void 0) result = RpcPayload.fromAppReturn(input);\n else result = applyMapToElement(input, parent, owner, captures, instructions);\n return new PayloadStubHook(result);\n } finally {\n for (let cap of captures) cap.dispose();\n }\n};\nvar WritableStreamStubHook = class WritableStreamStubHook2 extends StubHook {\n state;\n static create(stream) {\n return new WritableStreamStubHook2({\n refcount: 1,\n writer: stream.getWriter(),\n closed: false\n });\n }\n constructor(state, dupFrom) {\n super();\n this.state = state;\n if (dupFrom) ++state.refcount;\n }\n getState() {\n if (this.state) return this.state;\n else throw new Error(\"Attempted to use a WritableStreamStubHook after it was disposed.\");\n }\n call(path, args) {\n try {\n let state = this.getState();\n if (path.length !== 1 || typeof path[0] !== \"string\") throw new Error(\"WritableStream stub only supports direct method calls\");\n const method = path[0];\n if (method !== \"write\" && method !== \"close\" && method !== \"abort\") throw new Error(`Unknown WritableStream method: ${method}`);\n if (method === \"close\" || method === \"abort\") state.closed = true;\n return new PromiseStubHook((method === \"write\" ? args.deliverStreamWrite(state.writer) : args.deliverCall(state.writer[method], state.writer)).then((payload) => new PayloadStubHook(payload)));\n } catch (err) {\n args.dispose();\n return new ErrorStubHook(err);\n }\n }\n map(path, captures, instructions) {\n for (let cap of captures) cap.dispose();\n return new ErrorStubHook(/* @__PURE__ */ new Error(\"Cannot use map() on a WritableStream\"));\n }\n get(path) {\n return new ErrorStubHook(/* @__PURE__ */ new Error(\"Cannot access properties on a WritableStream stub\"));\n }\n dup() {\n return new WritableStreamStubHook2(this.getState(), this);\n }\n pull() {\n return Promise.reject(/* @__PURE__ */ new Error(\"Cannot pull a WritableStream stub\"));\n }\n ignoreUnhandledRejections() {\n }\n dispose() {\n let state = this.state;\n this.state = void 0;\n if (state) {\n if (--state.refcount === 0) {\n if (!state.closed) state.writer.abort(/* @__PURE__ */ new Error(\"WritableStream RPC stub was disposed without calling close()\")).catch(() => {\n });\n state.writer.releaseLock();\n }\n }\n }\n onBroken(callback) {\n }\n};\nvar INITIAL_WINDOW = 256 * 1024;\nvar MAX_WINDOW = 1024 * 1024 * 1024;\nvar MIN_WINDOW = 64 * 1024;\nvar STARTUP_GROWTH_FACTOR = 2;\nvar STEADY_GROWTH_FACTOR = 1.25;\nvar DECAY_FACTOR = 0.9;\nvar STARTUP_EXIT_ROUNDS = 3;\nvar FlowController = class {\n now;\n window = INITIAL_WINDOW;\n bytesInFlight = 0;\n inStartupPhase = true;\n delivered = 0;\n deliveredTime = 0;\n firstAckTime = 0;\n firstAckDelivered = 0;\n minRtt = Infinity;\n roundsWithoutIncrease = 0;\n lastRoundWindow = 0;\n roundStartTime = 0;\n constructor(now) {\n this.now = now;\n }\n onSend(size) {\n this.bytesInFlight += size;\n let token = {\n sentTime: this.now(),\n size,\n deliveredAtSend: this.delivered,\n deliveredTimeAtSend: this.deliveredTime,\n windowAtSend: this.window,\n windowFullAtSend: this.bytesInFlight >= this.window\n };\n return {\n token,\n shouldBlock: token.windowFullAtSend\n };\n }\n onError(token) {\n this.bytesInFlight -= token.size;\n }\n onAck(token) {\n let ackTime = this.now();\n this.delivered += token.size;\n this.deliveredTime = ackTime;\n this.bytesInFlight -= token.size;\n let rtt = ackTime - token.sentTime;\n this.minRtt = Math.min(this.minRtt, rtt);\n if (this.firstAckTime === 0) {\n this.firstAckTime = ackTime;\n this.firstAckDelivered = this.delivered;\n } else {\n let baseTime;\n let baseDelivered;\n if (token.deliveredTimeAtSend === 0) {\n baseTime = this.firstAckTime;\n baseDelivered = this.firstAckDelivered;\n } else {\n baseTime = token.deliveredTimeAtSend;\n baseDelivered = token.deliveredAtSend;\n }\n let interval = ackTime - baseTime;\n let bandwidth = (this.delivered - baseDelivered) / interval;\n let growthFactor = this.inStartupPhase ? STARTUP_GROWTH_FACTOR : STEADY_GROWTH_FACTOR;\n let newWindow = bandwidth * this.minRtt * growthFactor;\n newWindow = Math.min(newWindow, token.windowAtSend * growthFactor);\n if (token.windowFullAtSend) newWindow = Math.max(newWindow, token.windowAtSend * DECAY_FACTOR);\n else newWindow = Math.max(newWindow, this.window);\n this.window = Math.max(Math.min(newWindow, MAX_WINDOW), MIN_WINDOW);\n if (this.inStartupPhase && token.sentTime >= this.roundStartTime) {\n if (this.window > this.lastRoundWindow * STEADY_GROWTH_FACTOR) this.roundsWithoutIncrease = 0;\n else if (++this.roundsWithoutIncrease >= STARTUP_EXIT_ROUNDS) this.inStartupPhase = false;\n this.roundStartTime = ackTime;\n this.lastRoundWindow = this.window;\n }\n }\n return this.bytesInFlight < this.window;\n }\n};\nfunction createWritableStreamFromHook(hook) {\n let pendingError = void 0;\n let hookDisposed = false;\n let fc = new FlowController(() => performance.now());\n let windowResolve;\n let windowReject;\n const disposeHook = () => {\n if (!hookDisposed) {\n hookDisposed = true;\n hook.dispose();\n }\n };\n return new WritableStream({\n write(chunk, controller) {\n if (pendingError !== void 0) throw pendingError;\n const payload = RpcPayload.fromAppParams([chunk]);\n const { promise, size } = hook.stream([\"write\"], payload);\n if (size === void 0) return promise.catch((err) => {\n if (pendingError === void 0) pendingError = err;\n throw err;\n });\n else {\n let { token, shouldBlock } = fc.onSend(size);\n promise.then(() => {\n if (fc.onAck(token) && windowResolve) {\n windowResolve();\n windowResolve = void 0;\n windowReject = void 0;\n }\n }, (err) => {\n fc.onError(token);\n if (pendingError === void 0) {\n pendingError = err;\n controller.error(err);\n disposeHook();\n }\n if (windowReject) {\n windowReject(err);\n windowResolve = void 0;\n windowReject = void 0;\n }\n });\n if (shouldBlock) return new Promise((resolve, reject) => {\n windowResolve = resolve;\n windowReject = reject;\n });\n }\n },\n async close() {\n if (pendingError !== void 0) {\n disposeHook();\n throw pendingError;\n }\n const { promise } = hook.stream([\"close\"], RpcPayload.fromAppParams([]));\n try {\n await promise;\n } catch (err) {\n throw pendingError ?? err;\n } finally {\n disposeHook();\n }\n },\n abort(reason) {\n if (pendingError !== void 0) return;\n pendingError = reason ?? /* @__PURE__ */ new Error(\"WritableStream was aborted\");\n if (windowReject) {\n windowReject(pendingError);\n windowResolve = void 0;\n windowReject = void 0;\n }\n const { promise } = hook.stream([\"abort\"], RpcPayload.fromAppParams([reason]));\n promise.then(() => disposeHook(), () => disposeHook());\n }\n });\n}\nvar ReadableStreamStubHook = class ReadableStreamStubHook2 extends StubHook {\n state;\n static create(stream) {\n return new ReadableStreamStubHook2({\n refcount: 1,\n stream,\n canceled: false\n });\n }\n constructor(state, dupFrom) {\n super();\n this.state = state;\n if (dupFrom) ++state.refcount;\n }\n call(path, args) {\n args.dispose();\n return new ErrorStubHook(/* @__PURE__ */ new Error(\"Cannot call methods on a ReadableStream stub\"));\n }\n map(path, captures, instructions) {\n for (let cap of captures) cap.dispose();\n return new ErrorStubHook(/* @__PURE__ */ new Error(\"Cannot use map() on a ReadableStream\"));\n }\n get(path) {\n return new ErrorStubHook(/* @__PURE__ */ new Error(\"Cannot access properties on a ReadableStream stub\"));\n }\n dup() {\n let state = this.state;\n if (!state) throw new Error(\"Attempted to dup a ReadableStreamStubHook after it was disposed.\");\n return new ReadableStreamStubHook2(state, this);\n }\n pull() {\n return Promise.reject(/* @__PURE__ */ new Error(\"Cannot pull a ReadableStream stub\"));\n }\n ignoreUnhandledRejections() {\n }\n dispose() {\n let state = this.state;\n this.state = void 0;\n if (state) {\n if (--state.refcount === 0) {\n if (!state.canceled) {\n state.canceled = true;\n if (!state.stream.locked) state.stream.cancel(/* @__PURE__ */ new Error(\"ReadableStream RPC stub was disposed without being consumed\")).catch(() => {\n });\n }\n }\n }\n }\n onBroken(callback) {\n }\n};\nstreamImpl.createWritableStreamHook = WritableStreamStubHook.create;\nstreamImpl.createWritableStreamFromHook = createWritableStreamFromHook;\nstreamImpl.createReadableStreamHook = ReadableStreamStubHook.create;\nasync function newWorkersRpcResponse(request, localMain, options) {\n if (request.method === \"POST\") {\n let response = await newHttpBatchRpcResponse(request, localMain, options);\n response.headers.set(\"Access-Control-Allow-Origin\", \"*\");\n return response;\n } else if (request.headers.get(\"Upgrade\")?.toLowerCase() === \"websocket\") return newWorkersWebSocketRpcResponse(request, localMain, options);\n else return new Response(\"This endpoint only accepts POST or WebSocket requests.\", { status: 400 });\n}\n\n// templates/remoteBindings/ProxyServerWorker.ts\nimport { EmailMessage } from \"cloudflare:email\";\nvar BindingNotFoundError = class extends Error {\n constructor(name) {\n super(`Binding ${name ? `\"${name}\"` : \"\"} not found`);\n }\n};\nfunction getExposedJSRPCBinding(request, env) {\n const url = new URL(request.url);\n const bindingName = url.searchParams.get(\"MF-Binding\");\n if (!bindingName) {\n throw new BindingNotFoundError();\n }\n const targetBinding = env[bindingName];\n if (!targetBinding) {\n throw new BindingNotFoundError(bindingName);\n }\n if (targetBinding.constructor.name === \"Hyperdrive\") {\n const hyperdrive = targetBinding;\n return {\n getConnectionString() {\n return hyperdrive.connectionString;\n },\n connect() {\n const socket = hyperdrive.connect();\n return { readable: socket.readable, writable: socket.writable };\n }\n };\n }\n if (targetBinding.constructor.name === \"AnalyticsEngine\") {\n const dataset = targetBinding;\n return {\n writeDataPoint(event) {\n dataset.writeDataPoint(event);\n }\n };\n }\n if (targetBinding.constructor.name === \"SendEmail\") {\n return {\n async send(e) {\n if (\"EmailMessage::raw\" in e) {\n const message = new EmailMessage(\n e.from,\n e.to,\n e[\"EmailMessage::raw\"]\n );\n return targetBinding.send(message);\n } else {\n return targetBinding.send(e);\n }\n }\n };\n }\n const dispatchNamespaceOptions = url.searchParams.get(\n \"MF-Dispatch-Namespace-Options\"\n );\n if (dispatchNamespaceOptions) {\n const { name, args, options } = JSON.parse(dispatchNamespaceOptions);\n return targetBinding.get(name, args, options);\n }\n return targetBinding;\n}\nfunction getExposedFetcher(request, env) {\n const bindingName = request.headers.get(\"MF-Binding\");\n if (!bindingName) {\n throw new BindingNotFoundError();\n }\n const targetBinding = env[bindingName];\n if (!targetBinding) {\n throw new BindingNotFoundError(bindingName);\n }\n const dispatchNamespaceOptions = request.headers.get(\n \"MF-Dispatch-Namespace-Options\"\n );\n if (dispatchNamespaceOptions) {\n const { name, args, options } = JSON.parse(dispatchNamespaceOptions);\n return targetBinding.get(name, args, options);\n }\n return targetBinding;\n}\nfunction isJSRPCBinding(request) {\n const url = new URL(request.url);\n return request.headers.has(\"Upgrade\") && url.searchParams.has(\"MF-Binding\");\n}\nfunction isConnectBinding(request) {\n return request.headers.get(\"Upgrade\") === \"websocket\" && request.headers.has(\"MF-Connect-Address\");\n}\nfunction handleConnect(request, env) {\n const address = request.headers.get(\"MF-Connect-Address\");\n if (address === null) {\n return new Response(\"Missing MF-Connect-Address header\", { status: 400 });\n }\n const fetcher = getExposedFetcher(request, env);\n const { 0: client, 1: server } = new WebSocketPair();\n server.accept();\n const socket = fetcher.connect(address);\n pipeSocketOverWebSocket(socket, server).catch(() => {\n });\n return new Response(null, { status: 101, webSocket: client });\n}\nfunction truncateCloseReason(reason) {\n const bytes = new TextEncoder().encode(reason);\n if (bytes.length <= 123) {\n return reason;\n }\n let end = 123;\n while (end > 0 && ((bytes[end] ?? 0) & 192) === 128) {\n end--;\n }\n return new TextDecoder().decode(bytes.subarray(0, end));\n}\nasync function pipeSocketOverWebSocket(socket, ws) {\n const writer = socket.writable.getWriter();\n const reader = socket.readable.getReader();\n let wsClosed = false;\n function closeWebSocket(code, reason) {\n if (wsClosed) {\n return;\n }\n wsClosed = true;\n try {\n ws.close(\n code,\n reason === void 0 ? void 0 : truncateCloseReason(reason)\n );\n } catch {\n }\n }\n let writeChain = Promise.resolve();\n let writerClosed = false;\n function closeWriter() {\n if (writerClosed) {\n return Promise.resolve();\n }\n writerClosed = true;\n return writeChain.then(() => writer.close());\n }\n let resolveFromWs;\n let rejectFromWs;\n const fromWebSocket = new Promise((resolve, reject) => {\n resolveFromWs = resolve;\n rejectFromWs = reject;\n });\n ws.addEventListener(\"message\", (event) => {\n const chunk = typeof event.data === \"string\" ? new TextEncoder().encode(event.data) : new Uint8Array(event.data);\n writeChain = writeChain.then(() => writer.write(chunk)).catch((error) => {\n closeWebSocket(\n 1011,\n error?.message ?? \"socket write failed\"\n );\n reader.cancel().catch(() => {\n });\n rejectFromWs(error);\n });\n });\n ws.addEventListener(\"close\", (event) => {\n wsClosed = true;\n reader.cancel().catch(() => {\n });\n if (event.code === 1011) {\n rejectFromWs(\n new Error(event.reason || \"Remote tunnel closed with an error\")\n );\n return;\n }\n closeWriter().then(resolveFromWs, rejectFromWs);\n });\n ws.addEventListener(\"error\", () => {\n wsClosed = true;\n reader.cancel().catch(() => {\n });\n rejectFromWs(new Error(\"Tunnel WebSocket errored\"));\n });\n const toWebSocket = (async () => {\n try {\n for (; ; ) {\n const { value, done } = await reader.read();\n if (done) {\n break;\n }\n if (wsClosed) {\n break;\n }\n ws.send(\n value.buffer.slice(\n value.byteOffset,\n value.byteOffset + value.byteLength\n )\n );\n }\n closeWebSocket(1e3);\n } catch (error) {\n closeWebSocket(1011, error?.message ?? \"socket read failed\");\n throw error;\n } finally {\n reader.releaseLock();\n closeWriter().then(resolveFromWs, rejectFromWs);\n }\n })();\n await Promise.all([toWebSocket, fromWebSocket]);\n}\nfunction markForwardedResponse(response) {\n if (response.webSocket) {\n return response;\n }\n const marked = new Response(response.body, response);\n marked.headers.set(\"MF-Forwarded-Response\", \"true\");\n return marked;\n}\nvar ProxyServerWorker_default = {\n async fetch(request, env) {\n try {\n if (isConnectBinding(request)) {\n return handleConnect(request, env);\n } else if (isJSRPCBinding(request)) {\n return await newWorkersRpcResponse(\n request,\n getExposedJSRPCBinding(request, env)\n );\n } else {\n const fetcher = getExposedFetcher(request, env);\n const originalHeaders = new Headers();\n for (const [name, value] of request.headers) {\n if (name.startsWith(\"mf-header-\")) {\n originalHeaders.set(name.slice(\"mf-header-\".length), value);\n } else if (name === \"upgrade\") {\n originalHeaders.set(name, value);\n }\n }\n const response = await fetcher.fetch(\n request.headers.get(\"MF-URL\") ?? \"http://example.com\",\n new Request(request, {\n redirect: \"manual\",\n headers: originalHeaders\n })\n );\n return markForwardedResponse(response);\n }\n } catch (e) {\n if (e instanceof BindingNotFoundError) {\n return new Response(e.message, { status: 400 });\n }\n return new Response(e.message, { status: 500 });\n }\n }\n};\nexport {\n ProxyServerWorker_default as default\n};\n";
|
|
90238
90509
|
let logger;
|
|
90239
90510
|
function initLogger(value) {
|
|
90240
90511
|
logger = value;
|
|
@@ -91090,10 +91361,7 @@ function getInternalLogger(logger$1$1) {
|
|
|
91090
91361
|
};
|
|
91091
91362
|
}
|
|
91092
91363
|
function pickRemoteBindings(bindings) {
|
|
91093
|
-
return Object.fromEntries(Object.entries(bindings ?? {}).filter(([, binding]) =>
|
|
91094
|
-
if (getBindingLocalSupport(binding.type) === "DO-NOT-USE-this-resource-will-never-have-a-local-simulator") return true;
|
|
91095
|
-
return "remote" in binding && binding.remote;
|
|
91096
|
-
}));
|
|
91364
|
+
return Object.fromEntries(Object.entries(bindings ?? {}).filter(([, binding]) => resolveBindingRemote(binding.type, "remote" in binding ? binding.remote : void 0)));
|
|
91097
91365
|
}
|
|
91098
91366
|
/** Potentially starts or updates a remote proxy session. */
|
|
91099
91367
|
async function maybeStartOrUpdateRemoteProxySession(workerConfigObject, preExistingRemoteProxySessionData, auth, context, startSession = startRemoteProxySession) {
|
|
@@ -93358,11 +93626,11 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJS$2({ "../../node_modules/.pn
|
|
|
93358
93626
|
output: ""
|
|
93359
93627
|
};
|
|
93360
93628
|
const opts = options || {};
|
|
93361
|
-
const format$
|
|
93629
|
+
const format$4 = opts.format || (posix$1 ? utils$1.toPosixSlashes : null);
|
|
93362
93630
|
let match = input$1 === glob;
|
|
93363
|
-
let output$1 = match && format$
|
|
93631
|
+
let output$1 = match && format$4 ? format$4(input$1) : input$1;
|
|
93364
93632
|
if (match === false) {
|
|
93365
|
-
output$1 = format$
|
|
93633
|
+
output$1 = format$4 ? format$4(input$1) : input$1;
|
|
93366
93634
|
match = output$1 === glob;
|
|
93367
93635
|
}
|
|
93368
93636
|
if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch$2.matchBase(input$1, regex$1, options, posix$1);
|
|
@@ -93757,8 +94025,8 @@ function buildCrawler(options, patterns) {
|
|
|
93757
94025
|
const matcher = (0, import_picomatch.default)(processed.match, matchOptions);
|
|
93758
94026
|
const ignore$1 = (0, import_picomatch.default)(processed.ignore, matchOptions);
|
|
93759
94027
|
const partialMatcher = getPartialMatcher(processed.match, matchOptions);
|
|
93760
|
-
const format$
|
|
93761
|
-
const excludeFormatter = absolute$1 ? format$
|
|
94028
|
+
const format$4 = buildFormat(cwd, root, absolute$1);
|
|
94029
|
+
const excludeFormatter = absolute$1 ? format$4 : buildFormat(cwd, root, true);
|
|
93762
94030
|
const excludePredicate = (_, p$2) => {
|
|
93763
94031
|
const relativePath = excludeFormatter(p$2, true);
|
|
93764
94032
|
return relativePath !== "." && !partialMatcher(relativePath) || ignore$1(relativePath);
|
|
@@ -93767,12 +94035,12 @@ function buildCrawler(options, patterns) {
|
|
|
93767
94035
|
if (options.deep !== void 0) maxDepth = Math.round(options.deep - props.depthOffset);
|
|
93768
94036
|
const crawler = new Builder({
|
|
93769
94037
|
filters: [debug$7 ? (p$2, isDirectory$2) => {
|
|
93770
|
-
const path$2 = format$
|
|
94038
|
+
const path$2 = format$4(p$2, isDirectory$2);
|
|
93771
94039
|
const matches = matcher(path$2) && !ignore$1(path$2);
|
|
93772
94040
|
if (matches) log(`matched ${path$2}`);
|
|
93773
94041
|
return matches;
|
|
93774
94042
|
} : (p$2, isDirectory$2) => {
|
|
93775
|
-
const path$2 = format$
|
|
94043
|
+
const path$2 = format$4(p$2, isDirectory$2);
|
|
93776
94044
|
return matcher(path$2) && !ignore$1(path$2);
|
|
93777
94045
|
}],
|
|
93778
94046
|
exclude: debug$7 ? (_, p$2) => {
|
|
@@ -94319,7 +94587,7 @@ function handleWebSocket(httpServer, miniflare, entryWorkerName, viteWebSocketEn
|
|
|
94319
94587
|
const rawHost = request$2.headers.host ?? UNKNOWN_HOST;
|
|
94320
94588
|
const protocol = getForwardedProto(request$2) ?? "http:";
|
|
94321
94589
|
const base = /^https?:\/\//i.test(rawHost) ? rawHost : `${protocol}//${rawHost}`;
|
|
94322
|
-
const url$2 =
|
|
94590
|
+
const url$2 = resolveRequestTarget(request$2.url ?? "/", base);
|
|
94323
94591
|
const isViteRequest = request$2.headers["sec-websocket-protocol"]?.startsWith("vite");
|
|
94324
94592
|
const isDevToolsRequest = url$2.pathname === "/__devtools/__ws";
|
|
94325
94593
|
const isSandboxRequest = hasSandboxOrigin(url$2.origin);
|
|
@@ -94397,7 +94665,6 @@ var import_picocolors$2 = /* @__PURE__ */ __toESM$2(require_picocolors(), 1);
|
|
|
94397
94665
|
const devPlugin = createPlugin("dev", (ctx) => {
|
|
94398
94666
|
return { async configureServer(viteDevServer) {
|
|
94399
94667
|
assertIsNotPreview(ctx);
|
|
94400
|
-
const containerCleanup = getDevContainerCleanup(viteDevServer);
|
|
94401
94668
|
const initialOptions = await getDevMiniflareOptions(ctx, viteDevServer);
|
|
94402
94669
|
let containerOptionsByWorker = initialOptions.containerOptionsByWorker;
|
|
94403
94670
|
await ctx.startOrUpdateMiniflare(initialOptions.miniflareOptions);
|
|
@@ -94461,9 +94728,9 @@ const devPlugin = createPlugin("dev", (ctx) => {
|
|
|
94461
94728
|
request$2.headers.set(CoreHeaders.ROUTE_OVERRIDE, entryWorkerName);
|
|
94462
94729
|
return ctx.miniflare.dispatchFetch(request$2, { redirect: "manual" });
|
|
94463
94730
|
});
|
|
94464
|
-
viteDevServer.middlewares.use(
|
|
94731
|
+
viteDevServer.middlewares.use(function cloudflarePreMiddleware(req, res, next) {
|
|
94465
94732
|
assert(req.url, `req.url not defined`);
|
|
94466
|
-
const request$2 = new Request(
|
|
94733
|
+
const request$2 = new Request(resolveRequestTarget(req.url, UNKNOWN_HOST));
|
|
94467
94734
|
if (req[kRequestType] === "asset") next();
|
|
94468
94735
|
else if (excludeRulesMatcher({ request: request$2 })) {
|
|
94469
94736
|
req[kRequestType] = "asset";
|
|
@@ -94480,7 +94747,6 @@ const devPlugin = createPlugin("dev", (ctx) => {
|
|
|
94480
94747
|
logger: viteDevServer.config.logger,
|
|
94481
94748
|
viteConfigFile: viteDevServer.config.configFile
|
|
94482
94749
|
});
|
|
94483
|
-
containerCleanup.track(getDockerPath(), [...containerOptionsByWorker.values()].flatMap((options) => options.map(({ image_tag }) => image_tag)));
|
|
94484
94750
|
viteDevServer.config.logger.info(import_picocolors$2.default.dim(import_picocolors$2.default.yellow("\n⚡️ Containers successfully built. To rebuild your containers during development, restart the Vite dev server (r + enter).")));
|
|
94485
94751
|
}
|
|
94486
94752
|
}
|
|
@@ -94789,14 +95055,9 @@ const previewPlugin = createPlugin("preview", (ctx) => {
|
|
|
94789
95055
|
return { async configurePreviewServer(vitePreviewServer) {
|
|
94790
95056
|
assertIsPreview(ctx);
|
|
94791
95057
|
const dockerPath = getDockerPath();
|
|
94792
|
-
const containerCleanup = createContainerCleanup();
|
|
94793
95058
|
const closePreviewServer = vitePreviewServer.close.bind(vitePreviewServer);
|
|
94794
95059
|
vitePreviewServer.close = async () => {
|
|
94795
|
-
|
|
94796
|
-
await Promise.all([ctx.disposeMiniflare(), closePreviewServer()]);
|
|
94797
|
-
} finally {
|
|
94798
|
-
containerCleanup.cleanup();
|
|
94799
|
-
}
|
|
95060
|
+
await Promise.all([ctx.disposeMiniflare(), closePreviewServer()]);
|
|
94800
95061
|
};
|
|
94801
95062
|
const { miniflareOptions, containerOptionsByWorker } = await getPreviewMiniflareOptions(ctx, vitePreviewServer);
|
|
94802
95063
|
await ctx.startOrUpdateMiniflare(miniflareOptions);
|
|
@@ -94819,7 +95080,6 @@ const previewPlugin = createPlugin("preview", (ctx) => {
|
|
|
94819
95080
|
logger: vitePreviewServer.config.logger,
|
|
94820
95081
|
viteConfigFile: vitePreviewServer.config.configFile
|
|
94821
95082
|
});
|
|
94822
|
-
containerCleanup.track(dockerPath, [...containerOptionsByWorker.values()].flatMap((options) => options.map(({ image_tag }) => image_tag)));
|
|
94823
95083
|
vitePreviewServer.config.logger.info(import_picocolors$1.default.dim(import_picocolors$1.default.yellow("\n⚡️ Containers successfully built.\n")));
|
|
94824
95084
|
}
|
|
94825
95085
|
handleWebSocket(vitePreviewServer.httpServer, ctx.miniflare);
|
|
@@ -94978,14 +95238,14 @@ const canAccessPowerShell = async () => {
|
|
|
94978
95238
|
};
|
|
94979
95239
|
const wslDefaultBrowser = async () => {
|
|
94980
95240
|
const psPath = await powerShellPath();
|
|
94981
|
-
const { stdout: stdout$
|
|
94982
|
-
return stdout$
|
|
95241
|
+
const { stdout: stdout$3 } = await executePowerShell(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { powerShellPath: psPath });
|
|
95242
|
+
return stdout$3.trim();
|
|
94983
95243
|
};
|
|
94984
95244
|
const convertWslPathToWindows = async (path$2) => {
|
|
94985
95245
|
if (/^[a-z]+:\/\//i.test(path$2)) return path$2;
|
|
94986
95246
|
try {
|
|
94987
|
-
const { stdout: stdout$
|
|
94988
|
-
return stdout$
|
|
95247
|
+
const { stdout: stdout$3 } = await execFile$1("wslpath", ["-aw", path$2], { encoding: "utf8" });
|
|
95248
|
+
return stdout$3.trim();
|
|
94989
95249
|
} catch {
|
|
94990
95250
|
return path$2;
|
|
94991
95251
|
}
|
|
@@ -95019,12 +95279,12 @@ function defineLazyProperty(object$2, propertyName, valueGetter) {
|
|
|
95019
95279
|
const execFileAsync$3 = promisify(execFile);
|
|
95020
95280
|
async function defaultBrowserId() {
|
|
95021
95281
|
if (process5.platform !== "darwin") throw new Error("macOS only");
|
|
95022
|
-
const { stdout: stdout$
|
|
95282
|
+
const { stdout: stdout$3 } = await execFileAsync$3("defaults", [
|
|
95023
95283
|
"read",
|
|
95024
95284
|
"com.apple.LaunchServices/com.apple.launchservices.secure",
|
|
95025
95285
|
"LSHandlers"
|
|
95026
95286
|
]);
|
|
95027
|
-
const browserId = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout$
|
|
95287
|
+
const browserId = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout$3)?.groups.id ?? "com.apple.Safari";
|
|
95028
95288
|
if (browserId === "com.apple.safari") return "com.apple.Safari";
|
|
95029
95289
|
return browserId;
|
|
95030
95290
|
}
|
|
@@ -95037,12 +95297,12 @@ async function runAppleScript(script, { humanReadableOutput = true, signal } = {
|
|
|
95037
95297
|
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
95038
95298
|
const execOptions = {};
|
|
95039
95299
|
if (signal) execOptions.signal = signal;
|
|
95040
|
-
const { stdout: stdout$
|
|
95300
|
+
const { stdout: stdout$3 } = await execFileAsync$2("osascript", [
|
|
95041
95301
|
"-e",
|
|
95042
95302
|
script,
|
|
95043
95303
|
outputArguments
|
|
95044
95304
|
], execOptions);
|
|
95045
|
-
return stdout$
|
|
95305
|
+
return stdout$3.trim();
|
|
95046
95306
|
}
|
|
95047
95307
|
|
|
95048
95308
|
//#endregion
|
|
@@ -95123,14 +95383,14 @@ const windowsBrowserProgIds = {
|
|
|
95123
95383
|
const _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
95124
95384
|
var UnknownBrowserError = class extends Error {};
|
|
95125
95385
|
async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
|
|
95126
|
-
const { stdout: stdout$
|
|
95386
|
+
const { stdout: stdout$3 } = await _execFileAsync("reg", [
|
|
95127
95387
|
"QUERY",
|
|
95128
95388
|
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
95129
95389
|
"/v",
|
|
95130
95390
|
"ProgId"
|
|
95131
95391
|
]);
|
|
95132
|
-
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout$
|
|
95133
|
-
if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout$
|
|
95392
|
+
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout$3);
|
|
95393
|
+
if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout$3)}`);
|
|
95134
95394
|
const { id } = match.groups;
|
|
95135
95395
|
const browser = windowsBrowserProgIds[id];
|
|
95136
95396
|
if (!browser) throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
|
|
@@ -95150,12 +95410,12 @@ async function defaultBrowser() {
|
|
|
95150
95410
|
};
|
|
95151
95411
|
}
|
|
95152
95412
|
if (process5.platform === "linux") {
|
|
95153
|
-
const { stdout: stdout$
|
|
95413
|
+
const { stdout: stdout$3 } = await execFileAsync("xdg-mime", [
|
|
95154
95414
|
"query",
|
|
95155
95415
|
"default",
|
|
95156
95416
|
"x-scheme-handler/http"
|
|
95157
95417
|
]);
|
|
95158
|
-
const id = stdout$
|
|
95418
|
+
const id = stdout$3.trim();
|
|
95159
95419
|
return {
|
|
95160
95420
|
name: titleize(id.replace(/.desktop$/, "").replace("-", " ")),
|
|
95161
95421
|
id
|
|
@@ -95555,6 +95815,11 @@ function cloudflare(pluginConfig = {}) {
|
|
|
95555
95815
|
ctx.beginRestartingDevServer();
|
|
95556
95816
|
debuglog("From server.restart(): Restarting server...");
|
|
95557
95817
|
await restartServer();
|
|
95818
|
+
if (!viteDevServer.config.plugins.some((plugin) => plugin.name === "vite-plugin-cloudflare:dev")) try {
|
|
95819
|
+
await ctx.disposeMiniflare();
|
|
95820
|
+
} catch (error$3) {
|
|
95821
|
+
debuglog("Failed to dispose Miniflare instance:", error$3);
|
|
95822
|
+
}
|
|
95558
95823
|
debuglog("From server.restart(): Restarted server...");
|
|
95559
95824
|
} finally {
|
|
95560
95825
|
ctx.endRestartingDevServer();
|