wrangler 4.70.0 → 4.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -10
- package/wrangler-dist/cli.d.ts +1 -3
- package/wrangler-dist/cli.js +179 -152
- package/wrangler-dist/metafile-cjs.json +1 -1
package/wrangler-dist/cli.js
CHANGED
|
@@ -38325,7 +38325,7 @@ async function prepareContainerImagesForDev(args) {
|
|
|
38325
38325
|
await checkExposedPorts(dockerPath, options);
|
|
38326
38326
|
}
|
|
38327
38327
|
}
|
|
38328
|
-
if (!aborted
|
|
38328
|
+
if (!aborted) {
|
|
38329
38329
|
await pullEgressInterceptorImage(dockerPath);
|
|
38330
38330
|
}
|
|
38331
38331
|
}
|
|
@@ -38370,7 +38370,7 @@ var init_images = __esm({
|
|
|
38370
38370
|
init_login();
|
|
38371
38371
|
init_registry2();
|
|
38372
38372
|
init_utils();
|
|
38373
|
-
DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE = "cloudflare/proxy-everything:
|
|
38373
|
+
DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE = "cloudflare/proxy-everything:3f5e832@sha256:816255f5b6ebdc2cdcddb578d803121e7ee9cfe178442da07725d75a66cdcf37";
|
|
38374
38374
|
__name(getEgressInterceptorImage, "getEgressInterceptorImage");
|
|
38375
38375
|
__name(pullEgressInterceptorImage, "pullEgressInterceptorImage");
|
|
38376
38376
|
__name(pullImage, "pullImage");
|
|
@@ -43179,6 +43179,10 @@ function flipObject(obj) {
|
|
|
43179
43179
|
Object.entries(obj).filter(([_5, v8]) => !!v8).map(([k7, v8]) => [v8, k7])
|
|
43180
43180
|
);
|
|
43181
43181
|
}
|
|
43182
|
+
function stripQueryString(modulePath) {
|
|
43183
|
+
const queryIndex = modulePath.indexOf("?");
|
|
43184
|
+
return queryIndex !== -1 ? modulePath.slice(0, queryIndex) : modulePath;
|
|
43185
|
+
}
|
|
43182
43186
|
function createModuleCollector(props) {
|
|
43183
43187
|
const parsedRules = parseRules(props.rules);
|
|
43184
43188
|
const modules = [];
|
|
@@ -43246,16 +43250,17 @@ function createModuleCollector(props) {
|
|
|
43246
43250
|
args.importer
|
|
43247
43251
|
)}". This will stop working in the future. Replace references to "${args.path}" with "./${args.path}";`
|
|
43248
43252
|
);
|
|
43253
|
+
const cleanedPath = stripQueryString(args.path);
|
|
43249
43254
|
const filePath = path3__namespace.default.join(
|
|
43250
43255
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
43251
43256
|
props.wrangler1xLegacyModuleReferences.rootDirectory,
|
|
43252
|
-
|
|
43257
|
+
cleanedPath
|
|
43253
43258
|
);
|
|
43254
43259
|
const fileContent = await fs12.readFile(
|
|
43255
43260
|
filePath
|
|
43256
43261
|
);
|
|
43257
43262
|
const fileHash = crypto2__default.default.createHash("sha1").update(fileContent).digest("hex");
|
|
43258
|
-
const fileName = props.preserveFileNames ?
|
|
43263
|
+
const fileName = props.preserveFileNames ? cleanedPath : `./${fileHash}-${path3__namespace.default.basename(cleanedPath)}`;
|
|
43259
43264
|
const { rule } = rulesMatchers.find(({ regex: regex2 }) => regex2.test(fileName)) || {};
|
|
43260
43265
|
if (rule) {
|
|
43261
43266
|
modules.push({
|
|
@@ -43289,15 +43294,16 @@ function createModuleCollector(props) {
|
|
|
43289
43294
|
if (args.pluginData?.skip) {
|
|
43290
43295
|
return;
|
|
43291
43296
|
}
|
|
43292
|
-
|
|
43297
|
+
const cleanedPath = stripQueryString(args.path);
|
|
43298
|
+
let filePath = path3__namespace.default.join(args.resolveDir, cleanedPath);
|
|
43293
43299
|
if (foundModulePaths.includes(filePath)) {
|
|
43294
|
-
return { path:
|
|
43300
|
+
return { path: cleanedPath, external: true };
|
|
43295
43301
|
}
|
|
43296
43302
|
if (isJavaScriptModuleRule(rule)) {
|
|
43297
43303
|
return;
|
|
43298
43304
|
}
|
|
43299
43305
|
try {
|
|
43300
|
-
const resolved = await build5.resolve(
|
|
43306
|
+
const resolved = await build5.resolve(cleanedPath, {
|
|
43301
43307
|
kind: args.kind,
|
|
43302
43308
|
importer: args.importer,
|
|
43303
43309
|
resolveDir: args.resolveDir,
|
|
@@ -43311,7 +43317,7 @@ function createModuleCollector(props) {
|
|
|
43311
43317
|
} catch {
|
|
43312
43318
|
}
|
|
43313
43319
|
try {
|
|
43314
|
-
const resolved = (0, import_resolve.sync)(
|
|
43320
|
+
const resolved = (0, import_resolve.sync)(cleanedPath, {
|
|
43315
43321
|
basedir: args.resolveDir
|
|
43316
43322
|
});
|
|
43317
43323
|
filePath = resolved;
|
|
@@ -43321,7 +43327,7 @@ function createModuleCollector(props) {
|
|
|
43321
43327
|
filePath
|
|
43322
43328
|
);
|
|
43323
43329
|
const fileHash = crypto2__default.default.createHash("sha1").update(fileContent).digest("hex");
|
|
43324
|
-
const fileName = props.preserveFileNames ?
|
|
43330
|
+
const fileName = props.preserveFileNames ? cleanedPath : `./${fileHash}-${path3__namespace.default.basename(cleanedPath)}`;
|
|
43325
43331
|
modules.push({
|
|
43326
43332
|
name: fileName,
|
|
43327
43333
|
filePath,
|
|
@@ -43409,6 +43415,7 @@ var init_module_collection = __esm({
|
|
|
43409
43415
|
PythonRequirement: "python-requirement"
|
|
43410
43416
|
};
|
|
43411
43417
|
ModuleTypeToRuleType = flipObject(RuleTypeToModuleType);
|
|
43418
|
+
__name(stripQueryString, "stripQueryString");
|
|
43412
43419
|
modulesWatchRegexp = /^wrangler:modules-watch$/;
|
|
43413
43420
|
modulesWatchNamespace = "wrangler-modules-watch";
|
|
43414
43421
|
noopModuleCollector = {
|
|
@@ -51084,7 +51091,7 @@ var name, version;
|
|
|
51084
51091
|
var init_package = __esm({
|
|
51085
51092
|
"package.json"() {
|
|
51086
51093
|
name = "wrangler";
|
|
51087
|
-
version = "4.
|
|
51094
|
+
version = "4.72.0";
|
|
51088
51095
|
}
|
|
51089
51096
|
});
|
|
51090
51097
|
|
|
@@ -170042,9 +170049,6 @@ async function executeLocally({
|
|
|
170042
170049
|
if (Array.isArray(value)) {
|
|
170043
170050
|
value = `[${value.join(", ")}]`;
|
|
170044
170051
|
}
|
|
170045
|
-
if (value === null) {
|
|
170046
|
-
value = "null";
|
|
170047
|
-
}
|
|
170048
170052
|
return [key, value];
|
|
170049
170053
|
})
|
|
170050
170054
|
)
|
|
@@ -220851,11 +220855,14 @@ async function patchConfig(config, id, body) {
|
|
|
220851
220855
|
}
|
|
220852
220856
|
);
|
|
220853
220857
|
}
|
|
220858
|
+
var PostgresSslmode, MySqlSslmode;
|
|
220854
220859
|
var init_client4 = __esm({
|
|
220855
220860
|
"src/hyperdrive/client.ts"() {
|
|
220856
220861
|
init_import_meta_url();
|
|
220857
220862
|
init_cfetch();
|
|
220858
220863
|
init_user3();
|
|
220864
|
+
PostgresSslmode = ["require", "verify-ca", "verify-full"];
|
|
220865
|
+
MySqlSslmode = ["REQUIRED", "VERIFY_CA", "VERIFY_IDENTITY"];
|
|
220859
220866
|
__name(createConfig, "createConfig");
|
|
220860
220867
|
__name(deleteConfig, "deleteConfig");
|
|
220861
220868
|
__name(getConfig, "getConfig");
|
|
@@ -220904,13 +220911,19 @@ var init_shared2 = __esm({
|
|
|
220904
220911
|
});
|
|
220905
220912
|
|
|
220906
220913
|
// src/hyperdrive/index.ts
|
|
220914
|
+
function normalizeMysqlSslmode(sslmode) {
|
|
220915
|
+
const mysqlSslmode = MySqlSslmode.find(
|
|
220916
|
+
(mode) => mode.toLowerCase() === sslmode.toLowerCase()
|
|
220917
|
+
);
|
|
220918
|
+
return mysqlSslmode ?? sslmode;
|
|
220919
|
+
}
|
|
220907
220920
|
function getOriginFromArgs(allowPartialOrigin, args) {
|
|
220908
220921
|
if (args.connectionString) {
|
|
220909
220922
|
const url4 = new URL(args.connectionString);
|
|
220910
220923
|
url4.protocol = url4.protocol.toLowerCase();
|
|
220911
|
-
if (url4.port === "" && (url4.protocol == "postgresql:" || url4.protocol
|
|
220924
|
+
if (url4.port === "" && (url4.protocol == "postgresql:" || url4.protocol === "postgres:")) {
|
|
220912
220925
|
url4.port = "5432";
|
|
220913
|
-
} else if (url4.port === "" && url4.protocol
|
|
220926
|
+
} else if (url4.port === "" && url4.protocol === "mysql:") {
|
|
220914
220927
|
url4.port = "3306";
|
|
220915
220928
|
}
|
|
220916
220929
|
if (url4.protocol === "") {
|
|
@@ -220981,7 +220994,7 @@ function getOriginFromArgs(allowPartialOrigin, args) {
|
|
|
220981
220994
|
"You must provide both an Access Client ID and Access Client Secret when configuring Hyperdrive-over-Access"
|
|
220982
220995
|
);
|
|
220983
220996
|
}
|
|
220984
|
-
if (!args.originHost || args.originHost
|
|
220997
|
+
if (!args.originHost || args.originHost === "") {
|
|
220985
220998
|
throw new UserError(
|
|
220986
220999
|
"You must provide an origin hostname for the database"
|
|
220987
221000
|
);
|
|
@@ -221033,17 +221046,16 @@ function getMtlsFromArgs(args) {
|
|
|
221033
221046
|
const mtls = {
|
|
221034
221047
|
ca_certificate_id: args.caCertificateId,
|
|
221035
221048
|
mtls_certificate_id: args.mtlsCertificateId,
|
|
221036
|
-
sslmode: args.sslmode
|
|
221049
|
+
sslmode: args.sslmode ? normalizeMysqlSslmode(args.sslmode) : void 0
|
|
221037
221050
|
};
|
|
221038
221051
|
if (JSON.stringify(mtls) === "{}") {
|
|
221039
221052
|
return void 0;
|
|
221040
221053
|
} else {
|
|
221041
|
-
if (mtls.sslmode
|
|
221042
|
-
throw new UserError("CA not allowed when sslmode = 'require' is set");
|
|
221043
|
-
}
|
|
221044
|
-
if ((mtls.sslmode == "verify-ca" || mtls.sslmode == "verify-full") && !mtls.ca_certificate_id?.trim()) {
|
|
221054
|
+
if (mtls.sslmode && !PostgresSslmode.includes(mtls.sslmode) && !MySqlSslmode.includes(mtls.sslmode)) {
|
|
221045
221055
|
throw new UserError(
|
|
221046
|
-
|
|
221056
|
+
`Invalid sslmode '${mtls.sslmode}'. Valid options are:
|
|
221057
|
+
- PostgreSQL: ${PostgresSslmode.join(", ")}
|
|
221058
|
+
- MySQL: ${MySqlSslmode.join(", ")}`
|
|
221047
221059
|
);
|
|
221048
221060
|
}
|
|
221049
221061
|
return mtls;
|
|
@@ -221058,6 +221070,7 @@ var init_hyperdrive2 = __esm({
|
|
|
221058
221070
|
init_import_meta_url();
|
|
221059
221071
|
init_dist();
|
|
221060
221072
|
init_create_command();
|
|
221073
|
+
init_client4();
|
|
221061
221074
|
hyperdriveNamespace = createNamespace({
|
|
221062
221075
|
metadata: {
|
|
221063
221076
|
description: "\u{1F680} Manage Hyperdrive databases",
|
|
@@ -221066,6 +221079,7 @@ var init_hyperdrive2 = __esm({
|
|
|
221066
221079
|
category: "Storage & databases"
|
|
221067
221080
|
}
|
|
221068
221081
|
});
|
|
221082
|
+
__name(normalizeMysqlSslmode, "normalizeMysqlSslmode");
|
|
221069
221083
|
upsertOptions = /* @__PURE__ */ __name((defaultOriginScheme = void 0) => ({
|
|
221070
221084
|
"connection-string": {
|
|
221071
221085
|
type: "string",
|
|
@@ -221158,8 +221172,9 @@ var init_hyperdrive2 = __esm({
|
|
|
221158
221172
|
},
|
|
221159
221173
|
sslmode: {
|
|
221160
221174
|
type: "string",
|
|
221161
|
-
|
|
221162
|
-
|
|
221175
|
+
coerce: normalizeMysqlSslmode,
|
|
221176
|
+
choices: [...PostgresSslmode, ...MySqlSslmode],
|
|
221177
|
+
description: `Sets sslmode for connecting to database. For PostgreSQL: '${PostgresSslmode.join(", ")}'. For MySQL: '${MySqlSslmode.join(", ")}'.`
|
|
221163
221178
|
},
|
|
221164
221179
|
"origin-connection-limit": {
|
|
221165
221180
|
type: "number",
|
|
@@ -229602,7 +229617,6 @@ ${JSON.stringify(defaultRoutesJSONSpec, null, 2)}`
|
|
|
229602
229617
|
siteInclude: void 0,
|
|
229603
229618
|
siteExclude: void 0,
|
|
229604
229619
|
enableContainers: false,
|
|
229605
|
-
experimentalTailLogs: true,
|
|
229606
229620
|
types: false
|
|
229607
229621
|
})
|
|
229608
229622
|
);
|
|
@@ -273053,11 +273067,15 @@ var init_tail2 = __esm({
|
|
|
273053
273067
|
});
|
|
273054
273068
|
|
|
273055
273069
|
// src/routes.ts
|
|
273056
|
-
async function getWorkersDevSubdomain(complianceConfig, accountId, configPath) {
|
|
273070
|
+
async function getWorkersDevSubdomain(complianceConfig, accountId, configPath, apiToken) {
|
|
273057
273071
|
try {
|
|
273058
273072
|
const { subdomain } = await fetchResult(
|
|
273059
273073
|
complianceConfig,
|
|
273060
|
-
`/accounts/${accountId}/workers/subdomain
|
|
273074
|
+
`/accounts/${accountId}/workers/subdomain`,
|
|
273075
|
+
void 0,
|
|
273076
|
+
void 0,
|
|
273077
|
+
void 0,
|
|
273078
|
+
apiToken
|
|
273061
273079
|
);
|
|
273062
273080
|
return `${subdomain}${getComplianceRegionSubdomain(complianceConfig)}.workers.dev`;
|
|
273063
273081
|
} catch (e9) {
|
|
@@ -275978,6 +275996,21 @@ function collectCoreBindingsPerEnvironment(args) {
|
|
|
275978
275996
|
}
|
|
275979
275997
|
__name(collectEnvironmentBindings, "collectEnvironmentBindings");
|
|
275980
275998
|
const { rawConfig } = exports.experimental_readRawConfig(args);
|
|
275999
|
+
const topLevelInheritableBindings = [];
|
|
276000
|
+
for (const inheritableDef of INHERITABLE_BINDINGS) {
|
|
276001
|
+
const bindingName = inheritableDef.getBindingName(rawConfig);
|
|
276002
|
+
if (!bindingName) {
|
|
276003
|
+
continue;
|
|
276004
|
+
}
|
|
276005
|
+
topLevelInheritableBindings.push({
|
|
276006
|
+
binding: {
|
|
276007
|
+
bindingCategory: inheritableDef.bindingCategory,
|
|
276008
|
+
name: bindingName,
|
|
276009
|
+
type: inheritableDef.type
|
|
276010
|
+
},
|
|
276011
|
+
definition: inheritableDef
|
|
276012
|
+
});
|
|
276013
|
+
}
|
|
275981
276014
|
const topLevelBindings = collectEnvironmentBindings(
|
|
275982
276015
|
rawConfig,
|
|
275983
276016
|
TOP_LEVEL_ENV_NAME
|
|
@@ -275987,6 +276020,18 @@ function collectCoreBindingsPerEnvironment(args) {
|
|
|
275987
276020
|
}
|
|
275988
276021
|
for (const [envName, env6] of Object.entries(rawConfig.env ?? {})) {
|
|
275989
276022
|
const envBindings = collectEnvironmentBindings(env6, envName);
|
|
276023
|
+
for (const inheritable3 of topLevelInheritableBindings) {
|
|
276024
|
+
const alreadyHasBinding = envBindings.some(
|
|
276025
|
+
(b11) => b11.bindingCategory === inheritable3.binding.bindingCategory
|
|
276026
|
+
);
|
|
276027
|
+
if (alreadyHasBinding) {
|
|
276028
|
+
continue;
|
|
276029
|
+
}
|
|
276030
|
+
if (inheritable3.definition.hasProperty(env6)) {
|
|
276031
|
+
continue;
|
|
276032
|
+
}
|
|
276033
|
+
envBindings.push(inheritable3.binding);
|
|
276034
|
+
}
|
|
275990
276035
|
if (envBindings.length > 0) {
|
|
275991
276036
|
result.set(envName, envBindings);
|
|
275992
276037
|
}
|
|
@@ -276214,7 +276259,7 @@ function collectPipelinesPerEnvironment(args) {
|
|
|
276214
276259
|
}
|
|
276215
276260
|
return result;
|
|
276216
276261
|
}
|
|
276217
|
-
var typesCommand, validateTypesFile, logHorizontalRule;
|
|
276262
|
+
var typesCommand, validateTypesFile, logHorizontalRule, INHERITABLE_BINDINGS;
|
|
276218
276263
|
var init_type_generation = __esm({
|
|
276219
276264
|
"src/type-generation/index.ts"() {
|
|
276220
276265
|
init_import_meta_url();
|
|
@@ -276483,6 +276528,14 @@ ${content.join("\n")}`,
|
|
|
276483
276528
|
const screenWidth = process.stdout.columns;
|
|
276484
276529
|
logger.log(source_default.dim("\u2500".repeat(Math.min(screenWidth, 60))));
|
|
276485
276530
|
}, "logHorizontalRule");
|
|
276531
|
+
INHERITABLE_BINDINGS = [
|
|
276532
|
+
{
|
|
276533
|
+
bindingCategory: "assets",
|
|
276534
|
+
getBindingName: /* @__PURE__ */ __name((env6) => env6?.assets?.binding, "getBindingName"),
|
|
276535
|
+
hasProperty: /* @__PURE__ */ __name((env6) => env6?.assets !== void 0, "hasProperty"),
|
|
276536
|
+
type: "Fetcher"
|
|
276537
|
+
}
|
|
276538
|
+
];
|
|
276486
276539
|
__name(collectVarsPerEnvironment, "collectVarsPerEnvironment");
|
|
276487
276540
|
__name(collectCoreBindingsPerEnvironment, "collectCoreBindingsPerEnvironment");
|
|
276488
276541
|
__name(collectDurableObjectsPerEnvironment, "collectDurableObjectsPerEnvironment");
|
|
@@ -292288,13 +292341,6 @@ var init_dev2 = __esm({
|
|
|
292288
292341
|
describe: "Show interactive dev session (defaults to true if the terminal supports interactivity)",
|
|
292289
292342
|
type: "boolean"
|
|
292290
292343
|
},
|
|
292291
|
-
"experimental-tail-logs": {
|
|
292292
|
-
type: "boolean",
|
|
292293
|
-
alias: ["x-tail-logs"],
|
|
292294
|
-
describe: "Experimental: Get runtime logs for the remote worker via Workers Tails rather than the Devtools inspector",
|
|
292295
|
-
default: true,
|
|
292296
|
-
hidden: true
|
|
292297
|
-
},
|
|
292298
292344
|
types: {
|
|
292299
292345
|
describe: "Generate types from your Worker configuration",
|
|
292300
292346
|
type: "boolean"
|
|
@@ -293186,7 +293232,7 @@ async function resolveTriggers(config, input) {
|
|
|
293186
293232
|
})) ?? [];
|
|
293187
293233
|
return [...devRoutes, ...queueConsumers, ...crons];
|
|
293188
293234
|
}
|
|
293189
|
-
async function resolveConfig(config, input) {
|
|
293235
|
+
async function resolveConfig(config, input, previousName) {
|
|
293190
293236
|
if (config.pages_build_output_dir && input.dev?.multiworkerPrimary === false) {
|
|
293191
293237
|
throw new UserError(
|
|
293192
293238
|
`You cannot use a Pages project as a service binding target.
|
|
@@ -293219,7 +293265,7 @@ If you are trying to develop Pages and Workers together, please use \`wrangler p
|
|
|
293219
293265
|
config
|
|
293220
293266
|
);
|
|
293221
293267
|
const resolved = {
|
|
293222
|
-
name: getScriptName({ name: input.name, env: input.env }, config) ??
|
|
293268
|
+
name: getScriptName({ name: input.name, env: input.env }, config) ?? previousName ?? crypto.randomUUID(),
|
|
293223
293269
|
config: config.configPath,
|
|
293224
293270
|
compatibilityDate: getDevCompatibilityDate(
|
|
293225
293271
|
entry.projectRoot,
|
|
@@ -293274,9 +293320,7 @@ If you are trying to develop Pages and Workers together, please use \`wrangler p
|
|
|
293274
293320
|
},
|
|
293275
293321
|
assets: assetsOptions,
|
|
293276
293322
|
tailConsumers: config.tail_consumers ?? [],
|
|
293277
|
-
experimental: {
|
|
293278
|
-
tailLogs: !!input.experimental?.tailLogs
|
|
293279
|
-
},
|
|
293323
|
+
experimental: {},
|
|
293280
293324
|
streamingTailConsumers: config.streaming_tail_consumers ?? []
|
|
293281
293325
|
};
|
|
293282
293326
|
if (extractBindingsOfType("analytics_engine", resolved.bindings).length && !resolved.dev.remote && resolved.build.format === "service-worker") {
|
|
@@ -293467,7 +293511,7 @@ var init_ConfigController = __esm({
|
|
|
293467
293511
|
if (!getDisableConfigWatching()) {
|
|
293468
293512
|
await this.#ensureWatchingConfig(fileConfig.configPath);
|
|
293469
293513
|
}
|
|
293470
|
-
const { config: resolvedConfig, printCurrentBindings } = await resolveConfig(fileConfig, input);
|
|
293514
|
+
const { config: resolvedConfig, printCurrentBindings } = await resolveConfig(fileConfig, input, this.latestConfig?.name);
|
|
293471
293515
|
if (signal.aborted) {
|
|
293472
293516
|
return;
|
|
293473
293517
|
}
|
|
@@ -294166,12 +294210,11 @@ var init_ProxyController = __esm({
|
|
|
294166
294210
|
}
|
|
294167
294211
|
}
|
|
294168
294212
|
get inspectorEnabled() {
|
|
294169
|
-
const inVscodeJsDebugTerminal = !!process.env.VSCODE_INSPECTOR_OPTIONS;
|
|
294170
|
-
const shouldEnableInspector = this.latestConfig?.dev.inspector !== false && !inVscodeJsDebugTerminal;
|
|
294171
294213
|
if (this.latestConfig?.dev.remote) {
|
|
294172
|
-
return
|
|
294214
|
+
return false;
|
|
294173
294215
|
}
|
|
294174
|
-
|
|
294216
|
+
const inVscodeJsDebugTerminal = !!process.env.VSCODE_INSPECTOR_OPTIONS;
|
|
294217
|
+
return this.latestConfig?.dev.inspector !== false && !inVscodeJsDebugTerminal;
|
|
294175
294218
|
}
|
|
294176
294219
|
// ******************
|
|
294177
294220
|
// Event Handlers
|
|
@@ -294356,72 +294399,72 @@ var init_ProxyController = __esm({
|
|
|
294356
294399
|
__name(didMiniflareOptionsChange, "didMiniflareOptionsChange");
|
|
294357
294400
|
}
|
|
294358
294401
|
});
|
|
294359
|
-
|
|
294360
|
-
// src/utils/isAbortError.ts
|
|
294361
|
-
function isAbortError(err) {
|
|
294362
|
-
const legacyAbortErroCheck = err.code == "ABORT_ERR";
|
|
294363
|
-
const abortErrorCheck = err instanceof Error && err.name == "AbortError";
|
|
294364
|
-
return legacyAbortErroCheck || abortErrorCheck;
|
|
294365
|
-
}
|
|
294366
|
-
var init_isAbortError = __esm({
|
|
294367
|
-
"src/utils/isAbortError.ts"() {
|
|
294368
|
-
init_import_meta_url();
|
|
294369
|
-
__name(isAbortError, "isAbortError");
|
|
294370
|
-
}
|
|
294371
|
-
});
|
|
294372
294402
|
function switchHost(originalUrl, host, zonePreview) {
|
|
294373
294403
|
const url4 = new Url.URL(originalUrl);
|
|
294374
294404
|
url4.hostname = zonePreview ? host ?? url4.hostname : url4.hostname;
|
|
294375
294405
|
return url4;
|
|
294376
294406
|
}
|
|
294377
|
-
async function
|
|
294407
|
+
async function tryExpandToken(exchangeUrl, ctx, abortSignal) {
|
|
294408
|
+
try {
|
|
294409
|
+
const switchedExchangeUrl = switchHost(exchangeUrl, ctx.host, !!ctx.zone);
|
|
294410
|
+
const headers = {};
|
|
294411
|
+
const accessToken = await getAccessToken(switchedExchangeUrl.hostname);
|
|
294412
|
+
if (accessToken) {
|
|
294413
|
+
headers.cookie = `CF_Authorization=${accessToken}`;
|
|
294414
|
+
}
|
|
294415
|
+
logger.debugWithSanitization(
|
|
294416
|
+
"-- START EXCHANGE API REQUEST:",
|
|
294417
|
+
` GET ${switchedExchangeUrl.href}`
|
|
294418
|
+
);
|
|
294419
|
+
logger.debug("-- END EXCHANGE API REQUEST");
|
|
294420
|
+
const exchangeResponse = await (0, import_undici26.fetch)(switchedExchangeUrl, {
|
|
294421
|
+
signal: abortSignal,
|
|
294422
|
+
headers
|
|
294423
|
+
});
|
|
294424
|
+
const bodyText = await exchangeResponse.text();
|
|
294425
|
+
logger.debug(
|
|
294426
|
+
"-- START EXCHANGE API RESPONSE:",
|
|
294427
|
+
exchangeResponse.statusText,
|
|
294428
|
+
exchangeResponse.status
|
|
294429
|
+
);
|
|
294430
|
+
logger.debug("HEADERS:", JSON.stringify(exchangeResponse.headers, null, 2));
|
|
294431
|
+
logger.debugWithSanitization("RESPONSE:", bodyText);
|
|
294432
|
+
logger.debug("-- END EXCHANGE API RESPONSE");
|
|
294433
|
+
if (!exchangeResponse.ok) {
|
|
294434
|
+
return null;
|
|
294435
|
+
}
|
|
294436
|
+
const body = parseJSON(bodyText);
|
|
294437
|
+
if (typeof body?.token !== "string") {
|
|
294438
|
+
return null;
|
|
294439
|
+
}
|
|
294440
|
+
return body.token;
|
|
294441
|
+
} catch (e9) {
|
|
294442
|
+
if (e9 instanceof Error && e9.name === "AbortError") {
|
|
294443
|
+
throw e9;
|
|
294444
|
+
}
|
|
294445
|
+
return null;
|
|
294446
|
+
}
|
|
294447
|
+
}
|
|
294448
|
+
async function createPreviewSession(complianceConfig, account, ctx, abortSignal, name2) {
|
|
294378
294449
|
const { accountId, apiToken } = account;
|
|
294379
294450
|
const initUrl = ctx.zone ? `/zones/${ctx.zone}/workers/edge-preview` : `/accounts/${accountId}/workers/subdomain/edge-preview`;
|
|
294380
|
-
const { exchange_url } = await fetchResult(
|
|
294381
|
-
|
|
294382
|
-
initUrl,
|
|
294383
|
-
void 0,
|
|
294384
|
-
void 0,
|
|
294385
|
-
abortSignal,
|
|
294386
|
-
apiToken
|
|
294387
|
-
);
|
|
294388
|
-
const switchedExchangeUrl = switchHost(exchange_url, ctx.host, !!ctx.zone);
|
|
294389
|
-
const headers = {};
|
|
294390
|
-
const accessToken = await getAccessToken(switchedExchangeUrl.hostname);
|
|
294391
|
-
if (accessToken) {
|
|
294392
|
-
headers.cookie = `CF_Authorization=${accessToken}`;
|
|
294393
|
-
}
|
|
294394
|
-
logger.debugWithSanitization(
|
|
294395
|
-
"-- START EXCHANGE API REQUEST:",
|
|
294396
|
-
` GET ${switchedExchangeUrl.href}`
|
|
294397
|
-
);
|
|
294398
|
-
logger.debug("-- END EXCHANGE API REQUEST");
|
|
294399
|
-
const exchangeResponse = await (0, import_undici26.fetch)(switchedExchangeUrl, {
|
|
294400
|
-
signal: abortSignal,
|
|
294401
|
-
headers
|
|
294402
|
-
});
|
|
294403
|
-
const bodyText = await exchangeResponse.text();
|
|
294404
|
-
logger.debug(
|
|
294405
|
-
"-- START EXCHANGE API RESPONSE:",
|
|
294406
|
-
exchangeResponse.statusText,
|
|
294407
|
-
exchangeResponse.status
|
|
294408
|
-
);
|
|
294409
|
-
logger.debug("HEADERS:", JSON.stringify(exchangeResponse.headers, null, 2));
|
|
294410
|
-
logger.debugWithSanitization("RESPONSE:", bodyText);
|
|
294411
|
-
logger.debug("-- END EXCHANGE API RESPONSE");
|
|
294451
|
+
const { token, exchange_url } = await fetchResult(complianceConfig, initUrl, void 0, void 0, abortSignal, apiToken);
|
|
294452
|
+
const previewSessionToken = exchange_url ? await tryExpandToken(exchange_url, ctx, abortSignal) ?? token : token;
|
|
294412
294453
|
try {
|
|
294413
|
-
|
|
294414
|
-
|
|
294415
|
-
|
|
294416
|
-
|
|
294417
|
-
|
|
294454
|
+
let host = ctx.host;
|
|
294455
|
+
if (!host) {
|
|
294456
|
+
const subdomain = await getWorkersDevSubdomain(
|
|
294457
|
+
complianceConfig,
|
|
294458
|
+
account.accountId,
|
|
294459
|
+
void 0,
|
|
294460
|
+
apiToken
|
|
294461
|
+
);
|
|
294462
|
+
host = `${name2 ?? crypto2__default.default.randomUUID()}.${subdomain}`;
|
|
294418
294463
|
}
|
|
294419
294464
|
return {
|
|
294420
|
-
|
|
294421
|
-
|
|
294422
|
-
|
|
294423
|
-
prewarmUrl: switchHost(prewarm, ctx.host, !!ctx.zone),
|
|
294424
|
-
inspectorUrl
|
|
294465
|
+
value: previewSessionToken,
|
|
294466
|
+
host,
|
|
294467
|
+
name: name2
|
|
294425
294468
|
};
|
|
294426
294469
|
} catch (e9) {
|
|
294427
294470
|
if (!(e9 instanceof ParseError)) {
|
|
@@ -294434,7 +294477,7 @@ async function createPreviewSession(complianceConfig, account, ctx, abortSignal,
|
|
|
294434
294477
|
}
|
|
294435
294478
|
}
|
|
294436
294479
|
async function createPreviewToken(complianceConfig, account, worker, ctx, session, abortSignal, minimal_mode) {
|
|
294437
|
-
const { value, host
|
|
294480
|
+
const { value, host } = session;
|
|
294438
294481
|
const { accountId } = account;
|
|
294439
294482
|
const url4 = ctx.env && ctx.useServiceEnvironments ? `/accounts/${accountId}/workers/services/${worker.name}/environments/${ctx.env}/edge-preview` : `/accounts/${accountId}/workers/scripts/${worker.name}/edge-preview`;
|
|
294440
294483
|
const mode = ctx.zone ? {
|
|
@@ -294472,9 +294515,7 @@ async function createPreviewToken(complianceConfig, account, worker, ctx, sessio
|
|
|
294472
294515
|
);
|
|
294473
294516
|
return {
|
|
294474
294517
|
value: preview_token,
|
|
294475
|
-
host
|
|
294476
|
-
inspectorUrl,
|
|
294477
|
-
prewarmUrl,
|
|
294518
|
+
host,
|
|
294478
294519
|
tailUrl: tail_url
|
|
294479
294520
|
};
|
|
294480
294521
|
}
|
|
@@ -294488,27 +294529,6 @@ async function createWorkerPreview(complianceConfig, init4, account, ctx, sessio
|
|
|
294488
294529
|
abortSignal,
|
|
294489
294530
|
minimal_mode
|
|
294490
294531
|
);
|
|
294491
|
-
const accessToken = await getAccessToken(token.prewarmUrl.hostname);
|
|
294492
|
-
const headers = { "cf-workers-preview-token": token.value };
|
|
294493
|
-
if (accessToken) {
|
|
294494
|
-
headers.cookie = `CF_Authorization=${accessToken}`;
|
|
294495
|
-
}
|
|
294496
|
-
(0, import_undici26.fetch)(token.prewarmUrl.href, {
|
|
294497
|
-
method: "POST",
|
|
294498
|
-
signal: abortSignal,
|
|
294499
|
-
headers
|
|
294500
|
-
}).then(
|
|
294501
|
-
(response) => {
|
|
294502
|
-
if (!response.ok) {
|
|
294503
|
-
logger.warn("worker failed to prewarm: ", response.statusText);
|
|
294504
|
-
}
|
|
294505
|
-
},
|
|
294506
|
-
(err) => {
|
|
294507
|
-
if (isAbortError(err)) {
|
|
294508
|
-
logger.warn("worker failed to prewarm: ", err);
|
|
294509
|
-
}
|
|
294510
|
-
}
|
|
294511
|
-
);
|
|
294512
294532
|
return token;
|
|
294513
294533
|
}
|
|
294514
294534
|
var import_undici26;
|
|
@@ -294520,14 +294540,28 @@ var init_create_worker_preview = __esm({
|
|
|
294520
294540
|
init_cfetch();
|
|
294521
294541
|
init_create_worker_upload_form();
|
|
294522
294542
|
init_logger();
|
|
294543
|
+
init_routes6();
|
|
294523
294544
|
init_access();
|
|
294524
|
-
init_isAbortError();
|
|
294525
294545
|
__name(switchHost, "switchHost");
|
|
294546
|
+
__name(tryExpandToken, "tryExpandToken");
|
|
294526
294547
|
__name(createPreviewSession, "createPreviewSession");
|
|
294527
294548
|
__name(createPreviewToken, "createPreviewToken");
|
|
294528
294549
|
__name(createWorkerPreview, "createWorkerPreview");
|
|
294529
294550
|
}
|
|
294530
294551
|
});
|
|
294552
|
+
|
|
294553
|
+
// src/utils/isAbortError.ts
|
|
294554
|
+
function isAbortError(err) {
|
|
294555
|
+
const legacyAbortErroCheck = err.code == "ABORT_ERR";
|
|
294556
|
+
const abortErrorCheck = err instanceof Error && err.name == "AbortError";
|
|
294557
|
+
return legacyAbortErroCheck || abortErrorCheck;
|
|
294558
|
+
}
|
|
294559
|
+
var init_isAbortError = __esm({
|
|
294560
|
+
"src/utils/isAbortError.ts"() {
|
|
294561
|
+
init_import_meta_url();
|
|
294562
|
+
__name(isAbortError, "isAbortError");
|
|
294563
|
+
}
|
|
294564
|
+
});
|
|
294531
294565
|
function handlePreviewSessionUploadError(err, accountId) {
|
|
294532
294566
|
assert51__default.default(err && typeof err === "object");
|
|
294533
294567
|
if (!isAbortError(err)) {
|
|
@@ -294757,7 +294791,7 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294757
294791
|
workerAccount,
|
|
294758
294792
|
workerContext,
|
|
294759
294793
|
this.#abortController.signal,
|
|
294760
|
-
props.
|
|
294794
|
+
props.name
|
|
294761
294795
|
);
|
|
294762
294796
|
} catch (err) {
|
|
294763
294797
|
if (err instanceof Error && err.name == "AbortError") {
|
|
@@ -294781,6 +294815,9 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294781
294815
|
if (props.bundleId !== this.#currentBundleId) {
|
|
294782
294816
|
return;
|
|
294783
294817
|
}
|
|
294818
|
+
this.#activeTail?.removeAllListeners("error");
|
|
294819
|
+
this.#activeTail?.on("error", () => {
|
|
294820
|
+
});
|
|
294784
294821
|
this.#activeTail?.terminate();
|
|
294785
294822
|
const { workerAccount, workerContext } = await getWorkerAccountAndContext(
|
|
294786
294823
|
{
|
|
@@ -294794,7 +294831,6 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294794
294831
|
configPath: props.configPath
|
|
294795
294832
|
}
|
|
294796
294833
|
);
|
|
294797
|
-
const scriptId = props.name || (workerContext.zone ? this.#session.id : this.#session.host.split(".")[0]);
|
|
294798
294834
|
if (props.bundleId !== this.#currentBundleId) {
|
|
294799
294835
|
return;
|
|
294800
294836
|
}
|
|
@@ -294803,7 +294839,7 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294803
294839
|
bundle: props.bundle,
|
|
294804
294840
|
modules: props.modules,
|
|
294805
294841
|
accountId: props.accountId,
|
|
294806
|
-
name:
|
|
294842
|
+
name: props.name,
|
|
294807
294843
|
useServiceEnvironments: props.useServiceEnvironments,
|
|
294808
294844
|
env: props.env,
|
|
294809
294845
|
isWorkersSite: props.isWorkersSite,
|
|
@@ -294826,7 +294862,7 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294826
294862
|
this.#abortController.signal,
|
|
294827
294863
|
props.minimal_mode
|
|
294828
294864
|
);
|
|
294829
|
-
if (
|
|
294865
|
+
if (workerPreviewToken.tailUrl) {
|
|
294830
294866
|
this.#activeTail = new import_websocket.default(
|
|
294831
294867
|
workerPreviewToken.tailUrl,
|
|
294832
294868
|
TRACE_VERSION,
|
|
@@ -294874,7 +294910,7 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294874
294910
|
routes,
|
|
294875
294911
|
sendMetrics: config.sendMetrics,
|
|
294876
294912
|
configPath: config.config,
|
|
294877
|
-
|
|
294913
|
+
name: config.name
|
|
294878
294914
|
});
|
|
294879
294915
|
}
|
|
294880
294916
|
#extractRoutes(config) {
|
|
@@ -294918,8 +294954,7 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294918
294954
|
sendMetrics: config.sendMetrics,
|
|
294919
294955
|
configPath: config.config,
|
|
294920
294956
|
bundleId,
|
|
294921
|
-
minimal_mode: config.dev.remote === "minimal"
|
|
294922
|
-
tail_logs: !!config.experimental?.tailLogs
|
|
294957
|
+
minimal_mode: config.dev.remote === "minimal"
|
|
294923
294958
|
});
|
|
294924
294959
|
if (bundleId !== this.#currentBundleId || !token) {
|
|
294925
294960
|
return;
|
|
@@ -294935,14 +294970,6 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294935
294970
|
hostname: token.host,
|
|
294936
294971
|
port: "443"
|
|
294937
294972
|
},
|
|
294938
|
-
...!config.experimental?.tailLogs && token.inspectorUrl ? {
|
|
294939
|
-
userWorkerInspectorUrl: {
|
|
294940
|
-
protocol: token.inspectorUrl.protocol,
|
|
294941
|
-
hostname: token.inspectorUrl.hostname,
|
|
294942
|
-
port: token.inspectorUrl.port.toString(),
|
|
294943
|
-
pathname: token.inspectorUrl.pathname
|
|
294944
|
-
}
|
|
294945
|
-
} : {},
|
|
294946
294973
|
headers: {
|
|
294947
294974
|
"cf-workers-preview-token": token.value,
|
|
294948
294975
|
...accessToken ? { Cookie: `CF_Authorization=${accessToken}` } : {},
|
|
@@ -294967,6 +294994,9 @@ var init_RemoteRuntimeController = __esm({
|
|
|
294967
294994
|
if (this.#session) {
|
|
294968
294995
|
logger.log(source_default.dim("\u2394 Detected changes, restarted server."));
|
|
294969
294996
|
}
|
|
294997
|
+
if (this.#session && config.name !== this.#session.name) {
|
|
294998
|
+
this.#session = void 0;
|
|
294999
|
+
}
|
|
294970
295000
|
this.#session ??= await this.#getPreviewSession(config, auth, routes);
|
|
294971
295001
|
await this.#updatePreviewToken(config, bundle, auth, routes, id);
|
|
294972
295002
|
} catch (error2) {
|
|
@@ -295057,6 +295087,9 @@ var init_RemoteRuntimeController = __esm({
|
|
|
295057
295087
|
logger.debug("RemoteRuntimeController teardown beginning...");
|
|
295058
295088
|
this.#session = void 0;
|
|
295059
295089
|
this.#abortController.abort();
|
|
295090
|
+
this.#activeTail?.removeAllListeners("error");
|
|
295091
|
+
this.#activeTail?.on("error", () => {
|
|
295092
|
+
});
|
|
295060
295093
|
this.#activeTail?.terminate();
|
|
295061
295094
|
logger.debug("RemoteRuntimeController teardown complete");
|
|
295062
295095
|
}
|
|
@@ -295756,8 +295789,7 @@ var init_LocalRuntimeController = __esm({
|
|
|
295756
295789
|
this.containerBeingBuilt = void 0;
|
|
295757
295790
|
}, "onContainerImagePreparationEnd"),
|
|
295758
295791
|
logger,
|
|
295759
|
-
isVite: false
|
|
295760
|
-
compatibilityFlags: data.config.compatibilityFlags
|
|
295792
|
+
isVite: false
|
|
295761
295793
|
});
|
|
295762
295794
|
if (this.containerBeingBuilt) {
|
|
295763
295795
|
this.containerBeingBuilt.abortRequested = false;
|
|
@@ -296023,8 +296055,7 @@ var init_MultiworkerRuntimeController = __esm({
|
|
|
296023
296055
|
this.containerBeingBuilt = void 0;
|
|
296024
296056
|
}, "onContainerImagePreparationEnd"),
|
|
296025
296057
|
logger,
|
|
296026
|
-
isVite: false
|
|
296027
|
-
compatibilityFlags: data.config.compatibilityFlags
|
|
296058
|
+
isVite: false
|
|
296028
296059
|
});
|
|
296029
296060
|
if (this.containerBeingBuilt) {
|
|
296030
296061
|
this.containerBeingBuilt.abortRequested = false;
|
|
@@ -296290,7 +296321,7 @@ function registerDevHotKeys(devEnvs, args, render2 = true) {
|
|
|
296290
296321
|
keys: ["d"],
|
|
296291
296322
|
label: "open devtools",
|
|
296292
296323
|
// Don't display this hotkey if we're in a VSCode debug session
|
|
296293
|
-
disabled: !!process.env.VSCODE_INSPECTOR_OPTIONS || args.remote
|
|
296324
|
+
disabled: !!process.env.VSCODE_INSPECTOR_OPTIONS || args.remote,
|
|
296294
296325
|
handler: /* @__PURE__ */ __name(async () => {
|
|
296295
296326
|
const { inspectorUrl } = await primaryDevEnv.proxy.ready.promise;
|
|
296296
296327
|
if (!inspectorUrl) {
|
|
@@ -298875,10 +298906,7 @@ async function setupDevEnv(devEnv, configPath, auth, args) {
|
|
|
298875
298906
|
}, "site"),
|
|
298876
298907
|
useServiceEnvironments: !(args.legacyEnv ?? true)
|
|
298877
298908
|
},
|
|
298878
|
-
assets: args.assets
|
|
298879
|
-
experimental: {
|
|
298880
|
-
tailLogs: !!args.experimentalTailLogs
|
|
298881
|
-
}
|
|
298909
|
+
assets: args.assets
|
|
298882
298910
|
},
|
|
298883
298911
|
true
|
|
298884
298912
|
);
|
|
@@ -299057,7 +299085,6 @@ unstable_dev()'s behaviour will likely change in future releases`
|
|
|
299057
299085
|
enableContainers: options?.experimental?.enableContainers ?? false,
|
|
299058
299086
|
dockerPath,
|
|
299059
299087
|
containerEngine: options?.experimental?.containerEngine,
|
|
299060
|
-
experimentalTailLogs: true,
|
|
299061
299088
|
types: false
|
|
299062
299089
|
};
|
|
299063
299090
|
const devServer = await run(
|