wrangler 4.139.0 → 4.141.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.
@@ -235,6 +235,10 @@ var init_exports = __esm({
235
235
  });
236
236
 
237
237
  // ../workers-utils/src/config/durable-object-exports.ts
238
+ function isLiveDurableObjectExport(exportConfig) {
239
+ const state3 = exportConfig.state ?? "created";
240
+ return state3 === "created" || state3 === "expecting-transfer";
241
+ }
238
242
  function getDurableObjectExports(exports$1) {
239
243
  return partitionExports(exports$1)["durable-object"];
240
244
  }
@@ -245,6 +249,7 @@ var init_durable_object_exports = __esm({
245
249
  "../workers-utils/src/config/durable-object-exports.ts"() {
246
250
  init_import_meta_url();
247
251
  init_exports();
252
+ __name(isLiveDurableObjectExport, "isLiveDurableObjectExport");
248
253
  __name(getDurableObjectExports, "getDurableObjectExports");
249
254
  __name(hasDurableObjectExports, "hasDurableObjectExports");
250
255
  }
@@ -402,7 +407,7 @@ function getDurableObjectClassNameToUseSQLiteMap(migrations, exports$1) {
402
407
  if (entry.type !== "durable-object") {
403
408
  continue;
404
409
  }
405
- if (entry.state === void 0 || entry.state === "created" || entry.state === "expecting-transfer") {
410
+ if (isLiveDurableObjectExport(entry)) {
406
411
  durableObjectClassNameToUseSQLiteMap.set(
407
412
  className,
408
413
  entry.storage === "sqlite"
@@ -3168,6 +3173,19 @@ function indexLocation(file3, index) {
3168
3173
  }
3169
3174
  return { lineText, line, column, ...file3 };
3170
3175
  }
3176
+ function parseHumanDuration(s8) {
3177
+ const unitsMap = new Map(Object.entries(units));
3178
+ s8 = s8.trim().toLowerCase();
3179
+ let base = 1;
3180
+ for (const [name2, _5] of unitsMap) {
3181
+ if (s8.endsWith(name2)) {
3182
+ s8 = s8.substring(0, s8.length - name2.length);
3183
+ base = unitsMap.get(name2) || 1;
3184
+ break;
3185
+ }
3186
+ }
3187
+ return Number(s8) * base;
3188
+ }
3171
3189
  function parseNonHyphenedUuid(uuid3) {
3172
3190
  if (uuid3 == null || uuid3.includes("-")) {
3173
3191
  return uuid3;
@@ -3237,7 +3255,7 @@ function removeBOMAndValidate(buffer, file3) {
3237
3255
  }
3238
3256
  return content;
3239
3257
  }
3240
- var ParseError, APIError, UNSUPPORTED_BOMS;
3258
+ var ParseError, APIError, units, UNSUPPORTED_BOMS;
3241
3259
  var init_parse2 = __esm({
3242
3260
  "../workers-utils/src/parse.ts"() {
3243
3261
  init_import_meta_url();
@@ -3317,6 +3335,48 @@ var init_parse2 = __esm({
3317
3335
  __name(readFileSyncToBuffer, "readFileSyncToBuffer");
3318
3336
  __name(readFileSync, "readFileSync");
3319
3337
  __name(indexLocation, "indexLocation");
3338
+ units = {
3339
+ nanoseconds: 1e-9,
3340
+ nanosecond: 1e-9,
3341
+ microseconds: 1e-6,
3342
+ microsecond: 1e-6,
3343
+ milliseconds: 1e-3,
3344
+ millisecond: 1e-3,
3345
+ seconds: 1,
3346
+ second: 1,
3347
+ minutes: 60,
3348
+ minute: 60,
3349
+ hours: 3600,
3350
+ hour: 3600,
3351
+ days: 86400,
3352
+ day: 86400,
3353
+ weeks: 604800,
3354
+ week: 604800,
3355
+ month: 18144e3,
3356
+ year: 220752e3,
3357
+ nsecs: 1e-9,
3358
+ nsec: 1e-9,
3359
+ usecs: 1e-6,
3360
+ usec: 1e-6,
3361
+ msecs: 1e-3,
3362
+ msec: 1e-3,
3363
+ secs: 1,
3364
+ sec: 1,
3365
+ mins: 60,
3366
+ min: 60,
3367
+ ns: 1e-9,
3368
+ us: 1e-6,
3369
+ ms: 1e-3,
3370
+ mo: 18144e3,
3371
+ yr: 220752e3,
3372
+ s: 1,
3373
+ m: 60,
3374
+ h: 3600,
3375
+ d: 86400,
3376
+ w: 604800,
3377
+ y: 220752e3
3378
+ };
3379
+ __name(parseHumanDuration, "parseHumanDuration");
3320
3380
  __name(parseNonHyphenedUuid, "parseNonHyphenedUuid");
3321
3381
  __name(parseByteSize, "parseByteSize");
3322
3382
  UNSUPPORTED_BOMS = [
@@ -21200,18 +21260,22 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
21200
21260
  validateDefines(envName),
21201
21261
  {}
21202
21262
  ),
21203
- durable_objects: notInheritable(
21204
- diagnostics,
21205
- topLevelEnv,
21206
- rawConfig,
21207
- rawEnv,
21208
- envName,
21209
- "durable_objects",
21210
- validateBindingsProperty(envName, validateDurableObjectBinding),
21211
- {
21212
- bindings: []
21213
- }
21214
- ),
21263
+ durable_objects: (() => {
21264
+ const durableObjects = notInheritable(
21265
+ diagnostics,
21266
+ topLevelEnv,
21267
+ rawConfig,
21268
+ rawEnv,
21269
+ envName,
21270
+ "durable_objects",
21271
+ validateDurableObjectsProperty(envName, true),
21272
+ { bindings: [] }
21273
+ );
21274
+ return {
21275
+ ...durableObjects,
21276
+ bindings: durableObjects.bindings ?? []
21277
+ };
21278
+ })(),
21215
21279
  workflows: notInheritable(
21216
21280
  diagnostics,
21217
21281
  topLevelEnv,
@@ -22995,8 +23059,7 @@ function warnIfDurableObjectsHaveNoLifecycleConfig(diagnostics, durableObjects,
22995
23059
  if (entry === void 0 || entry.type !== "durable-object") {
22996
23060
  return false;
22997
23061
  }
22998
- const state3 = entry.state ?? "created";
22999
- return state3 === "created" || state3 === "expecting-transfer";
23062
+ return isLiveDurableObjectExport(entry);
23000
23063
  }, "exportsCovers");
23001
23064
  const uncoveredByExports = exportedDurableObjects.filter(
23002
23065
  (binding) => typeof binding.class_name !== "string" || !exportsCovers(binding.class_name)
@@ -23218,7 +23281,7 @@ function isDockerfile(imagePath, configPath) {
23218
23281
  }
23219
23282
  return false;
23220
23283
  }
23221
- var bucketFormatMessage, friendlyBindingNames, bindingTypeFriendlyNames, ENGLISH, ALLOWED_INSTANCE_TYPES, isRoute, isRouteArray, validateTailConsumers, validateStreamingTailConsumers, validateAndNormalizeRules, ARTIFACTS_EVENT_TYPE_SET, validateTriggers, validateRules, validateRule, validateDefines, validateVars, validateSecrets, validateBindingsProperty, validateUnsafeSettings, validateDurableObjectBinding, workflowNameFormatMessage, validateWorkflowBinding, validateCflogfwdrObject, validateCflogfwdrBinding, validateAssetsConfig, validateNamedSimpleBinding, validateAIBinding, validateVersionMetadataBinding, validateUnsafeBinding, validateBindingArray, validateCloudchamberConfig, validateKVBinding, validateSendEmailBinding, validateQueueBinding, validateR2Binding, validateD1Binding, validateVectorizeBinding, validateAISearchNamespaceBinding, validateAISearchBinding, validateAgentMemoryBinding, validateHyperdriveBinding, validateVpcServiceBinding, validateVpcNetworkBinding, validateBindingsHaveUniqueNames, validateServiceBinding, validateAnalyticsEngineBinding, validateWorkerNamespaceBinding, validateMTlsCertificateBinding, validateConsumer, validateConnectHandler, validateCompatibilityDate, validatePipelineBinding, validateSecretsStoreSecretBinding, validateArtifactsBinding, validateHelloWorldBinding, validateFlagshipBinding, validateWorkerLoaderBinding, validateRateLimitBinding, validatePreviewsConfig, validateMigrations, VALID_EXPORT_STORAGES, JS_IDENTIFIER_RE, validateExports, CONTAINER_OBSERVABILITY_TARGET_INSTANCE_PERCENTAGE_MIN, CONTAINER_OBSERVABILITY_TARGET_INSTANCE_PERCENTAGE_MAX, CONTAINER_OBSERVABILITY_TARGET_INSTANCE_COUNT_MIN, validateContainerObservability, validateObservability, validateAccess, validateCache, validatePythonModules;
23284
+ var bucketFormatMessage, friendlyBindingNames, bindingTypeFriendlyNames, ENGLISH, ALLOWED_INSTANCE_TYPES, isRoute, isRouteArray, validateTailConsumers, validateStreamingTailConsumers, validateAndNormalizeRules, ARTIFACTS_EVENT_TYPE_SET, validateTriggers, validateRules, validateRule, validateDefines, validateVars, validateSecrets, validateBindingsProperty, DURABLE_OBJECTS_CODE_UPDATE_MAX_DELAY_SECONDS, MILLISECOND_PRECISION_TOLERANCE, validateDurableObjectsProperty, validateUnsafeSettings, validateDurableObjectBinding, workflowNameFormatMessage, validateWorkflowBinding, validateCflogfwdrObject, validateCflogfwdrBinding, validateAssetsConfig, validateNamedSimpleBinding, validateAIBinding, validateVersionMetadataBinding, validateUnsafeBinding, validateBindingArray, validateCloudchamberConfig, validateKVBinding, validateSendEmailBinding, validateQueueBinding, validateR2Binding, validateD1Binding, validateVectorizeBinding, validateAISearchNamespaceBinding, validateAISearchBinding, validateAgentMemoryBinding, validateHyperdriveBinding, validateVpcServiceBinding, validateVpcNetworkBinding, validateBindingsHaveUniqueNames, validateServiceBinding, validateAnalyticsEngineBinding, validateWorkerNamespaceBinding, validateMTlsCertificateBinding, validateConsumer, validateConnectHandler, validateCompatibilityDate, validatePipelineBinding, validateSecretsStoreSecretBinding, validateArtifactsBinding, validateHelloWorldBinding, validateFlagshipBinding, validateWorkerLoaderBinding, validateRateLimitBinding, validatePreviewsConfig, validateMigrations, VALID_EXPORT_STORAGES, JS_IDENTIFIER_RE, validateExports, CONTAINER_OBSERVABILITY_TARGET_INSTANCE_PERCENTAGE_MIN, CONTAINER_OBSERVABILITY_TARGET_INSTANCE_PERCENTAGE_MAX, CONTAINER_OBSERVABILITY_TARGET_INSTANCE_COUNT_MIN, validateContainerObservability, validateObservability, validateAccess, validateCache, validatePythonModules;
23222
23285
  var init_validation = __esm({
23223
23286
  "../workers-utils/src/config/validation.ts"() {
23224
23287
  init_import_meta_url();
@@ -23761,6 +23824,85 @@ Please add a binding for each to "${fieldPath}.bindings":
23761
23824
  }
23762
23825
  return isValid;
23763
23826
  }, "validateBindingsProperty");
23827
+ DURABLE_OBJECTS_CODE_UPDATE_MAX_DELAY_SECONDS = 24 * 60 * 60;
23828
+ MILLISECOND_PRECISION_TOLERANCE = 1e-6;
23829
+ validateDurableObjectsProperty = /* @__PURE__ */ __name((envName, allowMissingBindings = false, allowCodeUpdateStrategy = true) => (diagnostics, field, value, config2) => {
23830
+ const fieldPath = config2 === void 0 ? `${field}` : `env.${envName}.${field}`;
23831
+ if (value === void 0) {
23832
+ return true;
23833
+ }
23834
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
23835
+ diagnostics.errors.push(
23836
+ `The field "${fieldPath}" should be an object but got ${JSON.stringify(value)}.`
23837
+ );
23838
+ return false;
23839
+ }
23840
+ validateAdditionalProperties(
23841
+ diagnostics,
23842
+ fieldPath,
23843
+ Object.keys(value),
23844
+ allowCodeUpdateStrategy ? ["bindings", "code_update_strategy"] : ["bindings"]
23845
+ );
23846
+ const bindingsContainer = allowMissingBindings && !hasProperty(value, "bindings") ? { ...value, bindings: [] } : value;
23847
+ let isValid = validateBindingsProperty(
23848
+ envName,
23849
+ validateDurableObjectBinding
23850
+ )(diagnostics, field, bindingsContainer, config2);
23851
+ if (!allowCodeUpdateStrategy) {
23852
+ return isValid;
23853
+ }
23854
+ if (!hasProperty(value, "code_update_strategy") || value.code_update_strategy === void 0) {
23855
+ return isValid;
23856
+ }
23857
+ const strategy = value.code_update_strategy;
23858
+ const strategyPath = `${fieldPath}.code_update_strategy`;
23859
+ if (typeof strategy !== "object" || strategy === null || Array.isArray(strategy)) {
23860
+ diagnostics.errors.push(
23861
+ `The field "${strategyPath}" should be an object but got ${JSON.stringify(strategy)}.`
23862
+ );
23863
+ return false;
23864
+ }
23865
+ validateAdditionalProperties(
23866
+ diagnostics,
23867
+ strategyPath,
23868
+ Object.keys(strategy),
23869
+ ["mode", "max_delay"]
23870
+ );
23871
+ isValid = validateRequiredProperty(
23872
+ diagnostics,
23873
+ strategyPath,
23874
+ "mode",
23875
+ hasProperty(strategy, "mode") ? strategy.mode : void 0,
23876
+ "string",
23877
+ ["immediate", "deferred"]
23878
+ ) && isValid;
23879
+ const maxDelay = hasProperty(strategy, "max_delay") ? strategy.max_delay : void 0;
23880
+ const maxDelayHasValidType = validateOptionalProperty(
23881
+ diagnostics,
23882
+ strategyPath,
23883
+ "max_delay",
23884
+ maxDelay,
23885
+ "number"
23886
+ );
23887
+ isValid = maxDelayHasValidType && isValid;
23888
+ if (maxDelayHasValidType && typeof maxDelay === "number" && (!Number.isFinite(maxDelay) || maxDelay < 0 || maxDelay > DURABLE_OBJECTS_CODE_UPDATE_MAX_DELAY_SECONDS)) {
23889
+ diagnostics.errors.push(
23890
+ `Expected "${strategyPath}.max_delay" to be between 0 and ${DURABLE_OBJECTS_CODE_UPDATE_MAX_DELAY_SECONDS} seconds but got ${JSON.stringify(maxDelay)}.`
23891
+ );
23892
+ isValid = false;
23893
+ }
23894
+ if (maxDelayHasValidType && typeof maxDelay === "number" && Number.isFinite(maxDelay) && maxDelay >= 0 && maxDelay <= DURABLE_OBJECTS_CODE_UPDATE_MAX_DELAY_SECONDS) {
23895
+ const milliseconds = maxDelay * 1e3;
23896
+ const roundedMilliseconds = Math.round(milliseconds);
23897
+ if (maxDelay > 0 && roundedMilliseconds === 0 || Math.abs(milliseconds - roundedMilliseconds) > MILLISECOND_PRECISION_TOLERANCE) {
23898
+ diagnostics.errors.push(
23899
+ `Expected "${strategyPath}.max_delay" to use millisecond precision but got ${JSON.stringify(maxDelay)}.`
23900
+ );
23901
+ isValid = false;
23902
+ }
23903
+ }
23904
+ return isValid;
23905
+ }, "validateDurableObjectsProperty");
23764
23906
  validateUnsafeSettings = /* @__PURE__ */ __name((envName) => (diagnostics, field, value, config2) => {
23765
23907
  const fieldPath = config2 === void 0 ? `${field}` : `env.${envName}.${field}`;
23766
23908
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
@@ -25626,7 +25768,7 @@ ${resolution}`);
25626
25768
  previews,
25627
25769
  `${field}.placement`
25628
25770
  );
25629
- isValid = validateBindingsProperty(envName, validateDurableObjectBinding)(
25771
+ isValid = validateDurableObjectsProperty(envName, false, false)(
25630
25772
  diagnostics,
25631
25773
  `${field}.durable_objects`,
25632
25774
  previews.durable_objects,
@@ -27179,7 +27321,7 @@ var DEFAULT_COMPAT_DATE;
27179
27321
  var init_default_compat_date = __esm({
27180
27322
  "../workers-utils/src/default-compat-date.ts"() {
27181
27323
  init_import_meta_url();
27182
- DEFAULT_COMPAT_DATE = "2026-09-23";
27324
+ DEFAULT_COMPAT_DATE = "2026-09-25";
27183
27325
  }
27184
27326
  });
27185
27327
 
@@ -62482,7 +62624,7 @@ var name, version2;
62482
62624
  var init_package = __esm({
62483
62625
  "package.json"() {
62484
62626
  name = "wrangler";
62485
- version2 = "4.139.0";
62627
+ version2 = "4.141.0";
62486
62628
  }
62487
62629
  });
62488
62630
 
@@ -124309,12 +124451,11 @@ var init_cloudflare = __esm({
124309
124451
  cloudflare_default = Cloudflare;
124310
124452
  }
124311
124453
  });
124312
-
124313
- // ../workers-auth/dist/chunk-O6YSETKJ.mjs
124314
124454
  var __defProp2, __name2;
124315
- var init_chunk_O6YSETKJ = __esm({
124316
- "../workers-auth/dist/chunk-O6YSETKJ.mjs"() {
124455
+ var init_chunk_VAZEJK55 = __esm({
124456
+ "../workers-auth/dist/chunk-VAZEJK55.mjs"() {
124317
124457
  init_import_meta_url();
124458
+ nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
124318
124459
  __defProp2 = Object.defineProperty;
124319
124460
  __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
124320
124461
  }
@@ -126810,12 +126951,13 @@ function scrubEncryptedCredentials(options) {
126810
126951
  return { backendAvailable: false, encryptedFileExisted };
126811
126952
  }
126812
126953
  var import_undici3, hasWarnedAboutDeprecatedV1ApiToken, getCloudflareAPITokenFromEnv, getCloudflareGlobalAuthKeyFromEnv, getCloudflareGlobalAuthEmailFromEnv, ACCOUNT_ID_PATTERN, getAuthDomainFromEnv, getAuthUrlFromEnv, getTokenUrlFromEnv, getRevokeUrlFromEnv, readCloudflareAccountIdFromEnv, DEVICE_AUTH_PATH, getAccessClientIdFromEnv, getAccessClientSecretFromEnv, getCfAuthorizationTokenFromEnv, getCloudflareAuthUseKeyringFromEnv, headersCache, usesAccessCache, RECOMMENDED_CODE_VERIFIER_LENGTH, RECOMMENDED_STATE_LENGTH, PKCE_CHARSET, generateVerificationUrl, generateAuthUrl, POW_MAX_ITERATIONS, TEMPORARY_TERMS_URLS, TEMPORARY_TERMS_PROMPT, TEMPORARY_TERMS_NOTICE, TEMPORARY_TERMS_ERROR, EVENT_ACCOUNT_ERRORS, esm_default3, ErrorOAuth2, ErrorUnknown, ErrorNoAuthCode, ErrorInvalidReturnedStateParam, ErrorInvalidJson, ErrorInvalidScope, ErrorInvalidRequest, ErrorInvalidToken, ErrorAuthenticationGrant, ErrorUnauthorizedClient, ErrorAccessDenied, ErrorUnsupportedResponseType, ErrorServerError, ErrorTemporarilyUnavailable, ErrorAccessTokenResponse, ErrorInvalidClient, ErrorInvalidGrant, ErrorUnsupportedGrantType, DEVICE_FLOW_MAX_DURATION_SECONDS, DEVICE_FLOW_MIN_POLL_INTERVAL_SECONDS, RESERVED_PROFILE_NAMES, BARE_KEY2, HAS_WELLFORMED2, FILE_FORMATS, USER_AUTH_CONFIG_PATH, FileCredentialStore, KEY_LENGTH_BYTES, IV_LENGTH_BYTES, TAG_LENGTH_BYTES, ALGORITHM_LABEL, CIPHER_NAME, EncryptedFileCredentialStore, PINNED_KEYRING_VERSION, npmRunner, cachedBindingPathByDir, entryFactoryOverride, runner, cachedProbeResult, LinuxSecretToolKeyProvider, SECURITY_EXIT_ITEM_NOT_FOUND, runner2, MacSecurityKeyProvider, NapiKeyringKeyProvider, testProviderFactory, sessionFlags;
126813
- var init_chunk_WMSASLDV = __esm({
126814
- "../workers-auth/dist/chunk-WMSASLDV.mjs"() {
126954
+ var init_chunk_RV27PEH3 = __esm({
126955
+ "../workers-auth/dist/chunk-RV27PEH3.mjs"() {
126815
126956
  init_import_meta_url();
126816
- init_chunk_O6YSETKJ();
126957
+ init_chunk_VAZEJK55();
126817
126958
  init_src();
126818
126959
  import_undici3 = __toESM(require_undici(), 1);
126960
+ nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
126819
126961
  hasWarnedAboutDeprecatedV1ApiToken = false;
126820
126962
  __name(readStoredAuthState, "readStoredAuthState");
126821
126963
  __name2(readStoredAuthState, "readStoredAuthState");
@@ -127786,12 +127928,11 @@ var init_chunk_WMSASLDV = __esm({
127786
127928
  __name2(scrubEncryptedCredentials, "scrubEncryptedCredentials");
127787
127929
  }
127788
127930
  });
127789
-
127790
- // ../workers-auth/dist/index.mjs
127791
127931
  var init_dist2 = __esm({
127792
127932
  "../workers-auth/dist/index.mjs"() {
127793
127933
  init_import_meta_url();
127794
- init_chunk_WMSASLDV();
127934
+ init_chunk_RV27PEH3();
127935
+ nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
127795
127936
  }
127796
127937
  });
127797
127938
  function createPreferences(getConfigPath2) {
@@ -128699,12 +128840,13 @@ function createAuthConfigFileHelpers(deps) {
128699
128840
  };
128700
128841
  }
128701
128842
  var millisecondsInMinute, minutesInYear, minutesInMonth, minutesInDay, constructFromSymbol, defaultOptions2, formatDistanceLocale, formatDistance, dateFormats, timeFormats, dateTimeFormats, formatLong, formatRelativeLocale, formatRelative, eraValues, quarterValues, monthValues, dayValues, dayPeriodValues, formattingDayPeriodValues, ordinalNumber, localize, matchOrdinalNumberPattern, parseOrdinalNumberPattern, matchEraPatterns, parseEraPatterns, matchQuarterPatterns, parseQuarterPatterns, matchMonthPatterns, parseMonthPatterns, matchDayPatterns, parseDayPatterns, matchDayPeriodPatterns, parseDayPeriodPatterns, match, enUS, MEMBERSHIPS_INACCESSIBLE_CODES, DIRECTORY_BINDINGS_FILE, ENCRYPTED_PROFILE_CONFIG_EXTENSION;
128702
- var init_chunk_V6MEAFHI = __esm({
128703
- "../workers-auth/dist/chunk-V6MEAFHI.mjs"() {
128843
+ var init_chunk_2JQZNT7W = __esm({
128844
+ "../workers-auth/dist/chunk-2JQZNT7W.mjs"() {
128704
128845
  init_import_meta_url();
128705
- init_chunk_WMSASLDV();
128706
- init_chunk_O6YSETKJ();
128846
+ init_chunk_RV27PEH3();
128847
+ init_chunk_VAZEJK55();
128707
128848
  init_src();
128849
+ nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
128708
128850
  __name(createPreferences, "createPreferences");
128709
128851
  __name2(createPreferences, "createPreferences");
128710
128852
  millisecondsInMinute = 6e4;
@@ -129216,9 +129358,10 @@ var DefaultScopes, DefaultScopeKeys, WRANGLER_KEYRING_SERVICE_NAME, WRANGLER_CLI
129216
129358
  var init_wrangler = __esm({
129217
129359
  "../workers-auth/dist/wrangler/index.mjs"() {
129218
129360
  init_import_meta_url();
129219
- init_chunk_V6MEAFHI();
129220
- init_chunk_O6YSETKJ();
129361
+ init_chunk_2JQZNT7W();
129362
+ init_chunk_VAZEJK55();
129221
129363
  init_src();
129364
+ nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
129222
129365
  DefaultScopes = {
129223
129366
  "account:read": "See your account info such as account details, analytics, and memberships.",
129224
129367
  "user:read": "See your user info such as name, email address, and account memberships.",
@@ -135505,10 +135648,21 @@ function convertExports(config2, result) {
135505
135648
  const converted = {};
135506
135649
  const unknownExports = {};
135507
135650
  for (const [exportName, value] of Object.entries(exports$2)) {
135508
- if (value.type === "worker" || value.type === "workflow") {
135651
+ if (value.type === "worker") {
135509
135652
  converted[exportName] = value;
135510
135653
  continue;
135511
135654
  }
135655
+ if (value.type === "workflow") {
135656
+ const { defaultRetention, ...workflow } = value;
135657
+ converted[exportName] = {
135658
+ ...workflow,
135659
+ ...defaultRetention !== void 0 && { default_retention: {
135660
+ ...defaultRetention.successRetention !== void 0 && { success_retention: defaultRetention.successRetention },
135661
+ ...defaultRetention.errorRetention !== void 0 && { error_retention: defaultRetention.errorRetention }
135662
+ } }
135663
+ };
135664
+ continue;
135665
+ }
135512
135666
  if (value.type !== "durable-object") {
135513
135667
  unknownExports[exportName] = value;
135514
135668
  continue;
@@ -136288,9 +136442,9 @@ var init_dist3 = __esm({
136288
136442
  limits: strictObject({ steps: number2().int().min(1).optional() }).optional(),
136289
136443
  concurrency: strictObject({ limit: number2().int().min(1).optional() }).optional(),
136290
136444
  schedules: union([string2().min(1), array(string2().min(1)).min(1)]).optional(),
136291
- default_retention: strictObject({
136292
- success_retention: WorkflowRetentionSchema.optional(),
136293
- error_retention: WorkflowRetentionSchema.optional()
136445
+ defaultRetention: strictObject({
136446
+ successRetention: WorkflowRetentionSchema.optional(),
136447
+ errorRetention: WorkflowRetentionSchema.optional()
136294
136448
  }).optional()
136295
136449
  });
136296
136450
  DurableObjectCreatedSqliteExportSchema = DurableObjectCreatedExportSchema.extend({ storage: literal("sqlite") });
@@ -136512,11 +136666,13 @@ var init_dist3 = __esm({
136512
136666
  }, "../../node_modules/.pnpm/ts-dedent@2.2.0/node_modules/ts-dedent/dist/index.js") });
136513
136667
  import_dist = require_dist2();
136514
136668
  __name(generateTypes, "generateTypes");
136669
+ nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
136515
136670
  __defProp3 = Object.defineProperty;
136516
136671
  __name3 = /* @__PURE__ */ __name((target, value) => __defProp3(target, "name", {
136517
136672
  value,
136518
136673
  configurable: true
136519
136674
  }), "__name");
136675
+ nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
136520
136676
  UserError2 = class extends Error {
136521
136677
  static {
136522
136678
  __name(this, "UserError");
@@ -136776,11 +136932,13 @@ var init_dist4 = __esm({
136776
136932
  __name(getWorkerConfigPath, "getWorkerConfigPath");
136777
136933
  __name(getWorkerBundleDir, "getWorkerBundleDir");
136778
136934
  __name(getWorkerAssetsDir, "getWorkerAssetsDir");
136935
+ nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
136779
136936
  __defProp4 = Object.defineProperty;
136780
136937
  __name4 = /* @__PURE__ */ __name((target, value) => __defProp4(target, "name", {
136781
136938
  value,
136782
136939
  configurable: true
136783
136940
  }), "__name");
136941
+ nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
136784
136942
  __name(isDirectory2, "isDirectory");
136785
136943
  __name4(isDirectory2, "isDirectory");
136786
136944
  __name(removeDir2, "removeDir");
@@ -140144,10 +140302,12 @@ async function pushImageIfChanged({
140144
140302
  const parsedRemoteManifest = JSON.parse(remoteManifest);
140145
140303
  if (parsedRemoteManifest.Descriptor.digest === hash2) {
140146
140304
  logger3.log("Image already exists remotely, skipping push");
140147
- logger3.debug(
140148
- `Untagging built image: ${sourceTag} since there was no change.`
140149
- );
140150
- await runDockerCmd(pathToDocker, ["image", "rm", sourceTag]);
140305
+ if (cleanupSourceTag !== false) {
140306
+ logger3.debug(
140307
+ `Untagging built image: ${sourceTag} since there was no change.`
140308
+ );
140309
+ await runDockerCmd(pathToDocker, ["image", "rm", sourceTag]);
140310
+ }
140151
140311
  return { remoteDigest: remoteDigest2 };
140152
140312
  }
140153
140313
  } catch (error53) {
@@ -141845,7 +142005,7 @@ async function getCreds(permissions, complianceConfig) {
141845
142005
  function isValidImageTag(value) {
141846
142006
  return IMAGE_TAG_REGEXP.test(value);
141847
142007
  }
141848
- var require$1, __create2, __defProp5, __getOwnPropDesc2, __getOwnPropNames3, __getProtoOf2, __hasOwnProp2, __name5, __require2, __commonJS3, __copyProps2, __toESM2, require_constants7, require_buffer_util, require_limiter, require_permessage_deflate2, require_validation, require_receiver2, require_sender2, require_event_target, require_extension, require_websocket2, require_stream, require_subprotocol, require_websocket_server, ApiError, CancelError2, CancelablePromise, OpenAPI, isDefined, isString2, isStringWithValue, isBlob3, isErrorResponse, base643, getQueryString, getUrl, getFormData, resolve10, getHeaders2, getRequestBody, isResponseSchemaV4, parseResponseSchemaV4, sendRequest, getResponseHeader, getResponseBody, catchErrorCodes, executeRequest, buildApiResult, request, requestPaginated, debugLogRequest, debugLogResponse, ApplicationRollout, AssignIPv4, AssignIPv6, BadRequestWithCodeError, ContainerImagePreparationStatus, CreateApplicationRolloutRequest, DeploymentMutationError, DeploymentNotFoundError, ExternalRegistryKind, ImageRegistryAlreadyExistsError, ImageRegistryIsPublic, ImageRegistryNotAllowedError, ImageRegistryNotFoundError, ImageRegistryProtocolAlreadyExists, ImageRegistryProtocolIsReferencedError, ImageRegistryProtocolNotFound, InstanceType, ProvisionerConfiguration, RolloutStep, SchedulingPolicy, SecretNameAlreadyExists, SecretNotFound, SSHPublicKeyNotFoundError, UpdateApplicationRolloutRequest, AccountService, ApplicationsService, ContainerImagePreparationsService, DeploymentsService, ImageRegistriesService, PlacementsService, RolloutsService, SshPublicKeysService, noop, logger3, fetchResult3, fetchPagedListResult3, getCloudflareRegistryWithAccountNamespace, MF_DEV_CONTAINER_PREFIX, getDevContainerImageName, runDockerCmd, runDockerCmdWithOutput, isDockerRunning, verifyDockerInstalled, cleanupContainers, getContainerIdsFromImage, DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE, getAndValidateRegistryType, MB, MiB, instanceTypes, LEGACY_TO_CANONICAL, MAX_DOCKER_REPOSITORY_NAME_LENGTH, DIGEST_SUFFIX_REGEXP, DIGEST_VALUE_REGEXP, TAG_SUFFIX_REGEXP, BUILD_OUTPUT_IMAGE_NAMESPACE, DOCKER_REPOSITORY_NAME_LENGTH, Diff, doAction, configRolloutStepsToAPI, MAX_DOCKER_REPOSITORY_NAME_LENGTH2, MAX_NAMED_IMAGE_SLUG_LENGTH, IMAGE_ID_HASH_LENGTH, import_websocket, containersSshOptions, MAX_REPOSITORY_LENGTH, REPOSITORY_COMPONENT_REGEXP, TAG_REGEXP, IMAGE_TAG_REGEXP;
142008
+ var require$13, __create2, __defProp5, __getOwnPropDesc2, __getOwnPropNames3, __getProtoOf2, __hasOwnProp2, __name5, __require2, __commonJS3, __copyProps2, __toESM2, require_constants7, require_buffer_util, require_limiter, require_permessage_deflate2, require_validation, require_receiver2, require_sender2, require_event_target, require_extension, require_websocket2, require_stream, require_subprotocol, require_websocket_server, ApiError, CancelError2, CancelablePromise, OpenAPI, isDefined, isString2, isStringWithValue, isBlob3, isErrorResponse, base643, getQueryString, getUrl, getFormData, resolve10, getHeaders2, getRequestBody, isResponseSchemaV4, parseResponseSchemaV4, sendRequest, getResponseHeader, getResponseBody, catchErrorCodes, executeRequest, buildApiResult, request, requestPaginated, debugLogRequest, debugLogResponse, ApplicationRollout, AssignIPv4, AssignIPv6, BadRequestWithCodeError, ContainerImagePreparationStatus, CreateApplicationRolloutRequest, DeploymentMutationError, DeploymentNotFoundError, ExternalRegistryKind, ImageRegistryAlreadyExistsError, ImageRegistryIsPublic, ImageRegistryNotAllowedError, ImageRegistryNotFoundError, ImageRegistryProtocolAlreadyExists, ImageRegistryProtocolIsReferencedError, ImageRegistryProtocolNotFound, InstanceType, ProvisionerConfiguration, RolloutStep, SchedulingPolicy, SecretNameAlreadyExists, SecretNotFound, SSHPublicKeyNotFoundError, UpdateApplicationRolloutRequest, AccountService, ApplicationsService, ContainerImagePreparationsService, DeploymentsService, ImageRegistriesService, PlacementsService, RolloutsService, SshPublicKeysService, noop, logger3, fetchResult3, fetchPagedListResult3, getCloudflareRegistryWithAccountNamespace, MF_DEV_CONTAINER_PREFIX, getDevContainerImageName, runDockerCmd, runDockerCmdWithOutput, isDockerRunning, verifyDockerInstalled, cleanupContainers, getContainerIdsFromImage, DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE, getAndValidateRegistryType, MB, MiB, instanceTypes, LEGACY_TO_CANONICAL, MAX_DOCKER_REPOSITORY_NAME_LENGTH, DIGEST_SUFFIX_REGEXP, DIGEST_VALUE_REGEXP, TAG_SUFFIX_REGEXP, BUILD_OUTPUT_IMAGE_NAMESPACE, DOCKER_REPOSITORY_NAME_LENGTH, Diff, doAction, configRolloutStepsToAPI, MAX_DOCKER_REPOSITORY_NAME_LENGTH2, MAX_NAMED_IMAGE_SLUG_LENGTH, IMAGE_ID_HASH_LENGTH, import_websocket, containersSshOptions, MAX_REPOSITORY_LENGTH, REPOSITORY_COMPONENT_REGEXP, TAG_REGEXP, IMAGE_TAG_REGEXP;
141849
142009
  var init_dist9 = __esm({
141850
142010
  "../containers-shared/dist/index.mjs"() {
141851
142011
  init_import_meta_url();
@@ -141858,7 +142018,7 @@ var init_dist9 = __esm({
141858
142018
  init_colors();
141859
142019
  init_src();
141860
142020
  init_interactive();
141861
- require$1 = nodeModule.createRequire(typeof __filename === "string" ? __filename : import_meta_url);
142021
+ require$13 = nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
141862
142022
  __create2 = Object.create;
141863
142023
  __defProp5 = Object.defineProperty;
141864
142024
  __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -141866,10 +142026,10 @@ var init_dist9 = __esm({
141866
142026
  __getProtoOf2 = Object.getPrototypeOf;
141867
142027
  __hasOwnProp2 = Object.prototype.hasOwnProperty;
141868
142028
  __name5 = /* @__PURE__ */ __name((target, value) => __defProp5(target, "name", { value, configurable: true }), "__name");
141869
- __require2 = /* @__PURE__ */ ((x7) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x7, {
141870
- get: /* @__PURE__ */ __name((a8, b11) => (typeof require$1 !== "undefined" ? require$1 : a8)[b11], "get")
142029
+ __require2 = /* @__PURE__ */ ((x7) => typeof require$13 !== "undefined" ? require$13 : typeof Proxy !== "undefined" ? new Proxy(x7, {
142030
+ get: /* @__PURE__ */ __name((a8, b11) => (typeof require$13 !== "undefined" ? require$13 : a8)[b11], "get")
141871
142031
  }) : x7)(function(x7) {
141872
- if (typeof require$1 !== "undefined") return require$1.apply(this, arguments);
142032
+ if (typeof require$13 !== "undefined") return require$13.apply(this, arguments);
141873
142033
  throw Error('Dynamic require of "' + x7 + '" is not supported');
141874
142034
  });
141875
142035
  __commonJS3 = /* @__PURE__ */ __name((cb2, mod2) => /* @__PURE__ */ __name(function __require22() {
@@ -162517,7 +162677,7 @@ async function fetchDeployableVersions(complianceConfig, accountId, workerName,
162517
162677
  }
162518
162678
  return versions2;
162519
162679
  }
162520
- async function createDeployment(complianceConfig, accountId, workerName, versionTraffic, message, force) {
162680
+ async function createDeployment(complianceConfig, accountId, workerName, versionTraffic, message, force, codeUpdateStrategy) {
162521
162681
  return await fetchResult(
162522
162682
  complianceConfig,
162523
162683
  `/accounts/${accountId}/workers/scripts/${workerName}/deployments${force ? "?force=true" : ""}`,
@@ -162531,7 +162691,8 @@ async function createDeployment(complianceConfig, accountId, workerName, version
162531
162691
  ),
162532
162692
  annotations: {
162533
162693
  "workers/message": message
162534
- }
162694
+ },
162695
+ code_update_strategy: codeUpdateStrategy
162535
162696
  })
162536
162697
  }
162537
162698
  );
@@ -162816,6 +162977,7 @@ function createWorkerUploadForm(worker, bindings, options) {
162816
162977
  main: main2,
162817
162978
  sourceMaps,
162818
162979
  migrations,
162980
+ code_update_strategy,
162819
162981
  exports: configuredExports,
162820
162982
  compatibility_date,
162821
162983
  compatibility_flags,
@@ -163498,6 +163660,7 @@ function createWorkerUploadForm(worker, bindings, options) {
163498
163660
  compatibility_flags
163499
163661
  },
163500
163662
  ...migrations && { migrations },
163663
+ ...code_update_strategy && { code_update_strategy },
163501
163664
  ...configuredExports && Object.keys(configuredExports).length > 0 && {
163502
163665
  exports: configuredExports
163503
163666
  },
@@ -175123,6 +175286,9 @@ async function deployWorker(props, config2, buildResult, callbacks) {
175123
175286
  printBundleSize(bundleSize);
175124
175287
  const canUseNewVersionsDeploymentsApi = workerExists && props.dispatchNamespace === void 0 && format9 === "modules" && migrations === void 0 && !hasDurableObjectExports(config2.exports) && !config2.first_party_worker && props.containers.source === void 0 && // Rollout skip can recover Container metadata absent from local config.
175125
175288
  containerMetadata === void 0;
175289
+ if (!canUseNewVersionsDeploymentsApi) {
175290
+ worker.code_update_strategy = props.durableObjectsCodeUpdateStrategy;
175291
+ }
175126
175292
  let workerBundle;
175127
175293
  const dockerPath = getDockerPath();
175128
175294
  if (isDryRun) {
@@ -175195,13 +175361,16 @@ async function deployWorker(props, config2, buildResult, callbacks) {
175195
175361
  );
175196
175362
  const versionMap = /* @__PURE__ */ new Map();
175197
175363
  versionMap.set(versionResult.id, 100);
175364
+ const unsafeMetadata = config2.unsafe?.metadata;
175365
+ const codeUpdateStrategy = unsafeMetadata !== void 0 && "code_update_strategy" in unsafeMetadata ? unsafeMetadata.code_update_strategy : props.durableObjectsCodeUpdateStrategy;
175198
175366
  await createDeployment(
175199
175367
  config2,
175200
175368
  accountId,
175201
175369
  scriptName,
175202
175370
  versionMap,
175203
175371
  props.message,
175204
- void 0
175372
+ void 0,
175373
+ codeUpdateStrategy
175205
175374
  );
175206
175375
  const nextTags = applyServiceAndEnvironmentTags(config2, tags);
175207
175376
  try {
@@ -175401,12 +175570,16 @@ async function deployWorker(props, config2, buildResult, callbacks) {
175401
175570
  });
175402
175571
  }
175403
175572
  }
175404
- await deployContainers(config2, containerDeployments, {
175405
- versionId,
175406
- accountId,
175407
- scriptName,
175408
- dispatchNamespace: props.dispatchNamespace
175409
- });
175573
+ await deployContainers(
175574
+ { ...config2, containers: props.containers.source },
175575
+ containerDeployments,
175576
+ {
175577
+ versionId,
175578
+ accountId,
175579
+ scriptName,
175580
+ dispatchNamespace: props.dispatchNamespace
175581
+ }
175582
+ );
175410
175583
  }
175411
175584
  if (!skipContainerChanges && durableObjectContainerConfig.length > 0) {
175412
175585
  assert38__default.default(versionId && accountId);
@@ -176630,7 +176803,7 @@ function getDeclaredDOClassNames(config2) {
176630
176803
  for (const [className, entry] of Object.entries(
176631
176804
  getDurableObjectExports(config2.exports)
176632
176805
  )) {
176633
- if (entry.state === void 0 || entry.state === "created" || entry.state === "expecting-transfer") {
176806
+ if (isLiveDurableObjectExport(entry)) {
176634
176807
  declared.add(className);
176635
176808
  }
176636
176809
  }
@@ -176762,7 +176935,7 @@ function getPreviewExports(exports$1) {
176762
176935
  }
176763
176936
  return previewExports;
176764
176937
  }
176765
- async function prepareContainersForPreview(config2, workerName, previewSlug, callbacks) {
176938
+ async function prepareContainersForPreview(config2, workerName, previewSlug, callbacks, localImageReferences) {
176766
176939
  const previewContainers = config2.previews?.containers ?? [];
176767
176940
  if (previewContainers.length === 0 || !callbacks.getNormalizedContainerOptions) {
176768
176941
  return { scopedContainerConfig: void 0, normalisedContainerConfig: [] };
@@ -176782,11 +176955,11 @@ async function prepareContainersForPreview(config2, workerName, previewSlug, cal
176782
176955
  const containersNeedingDocker = normalisedContainerConfig.filter(
176783
176956
  (container) => "dockerfile" in container
176784
176957
  );
176785
- if (containersNeedingDocker.length > 0) {
176958
+ if (containersNeedingDocker.length > 0 || localImageReferences.size > 0) {
176786
176959
  await verifyDockerInstalled({
176787
176960
  dockerPath: getDockerPath(),
176788
176961
  operation: "creating a preview",
176789
- imageNoun: containersNeedingDocker.length !== 1 ? "the configured images" : "the configured image",
176962
+ imageNoun: containersNeedingDocker.length + localImageReferences.size !== 1 ? "the configured images" : "the configured image",
176790
176963
  hint: 'If you cannot run Docker locally, set "image" to a prebuilt registry image instead of a Dockerfile path for the affected entries in "previews.containers".'
176791
176964
  });
176792
176965
  }
@@ -177207,7 +177380,7 @@ async function provisionParentWorker(config2, accountId, workerName, json2) {
177207
177380
  preview_urls ?? workers_dev
177208
177381
  );
177209
177382
  }
177210
- async function runPreview(accountId, args, config2, buildResult, assetsOptions, callbacks, workerName, replaceTailConsumersAfterCreate = false) {
177383
+ async function runPreview(accountId, args, config2, buildResult, assetsOptions, callbacks, workerName, replaceTailConsumersAfterCreate = false, localImageReferences = /* @__PURE__ */ new Map()) {
177211
177384
  let secrets;
177212
177385
  if (args.secretsFile) {
177213
177386
  secrets = (await parseBulkInputToObject(args.secretsFile))?.content;
@@ -177286,7 +177459,8 @@ async function runPreview(accountId, args, config2, buildResult, assetsOptions,
177286
177459
  config2,
177287
177460
  workerName,
177288
177461
  previewResource.slug,
177289
- callbacks
177462
+ callbacks,
177463
+ localImageReferences
177290
177464
  );
177291
177465
  const deploymentRequest = await assemblePreviewDeploymentSettings(
177292
177466
  config2,
@@ -177324,7 +177498,7 @@ async function runPreview(accountId, args, config2, buildResult, assetsOptions,
177324
177498
  normalisedContainerConfig,
177325
177499
  deployment,
177326
177500
  accountId,
177327
- { quiet: args.json === true }
177501
+ { quiet: args.json === true, localImageReferences }
177328
177502
  );
177329
177503
  } catch (error53) {
177330
177504
  logger.warn(
@@ -178807,9 +178981,10 @@ var CF_KEYRING_SERVICE_NAME, CF_CLI_NAME, CF_DISPLAY_NAME, CF_OAUTH_CALLBACK_URL
178807
178981
  var init_cf = __esm({
178808
178982
  "../workers-auth/dist/cf/index.mjs"() {
178809
178983
  init_import_meta_url();
178810
- init_chunk_V6MEAFHI();
178811
- init_chunk_O6YSETKJ();
178984
+ init_chunk_2JQZNT7W();
178985
+ init_chunk_VAZEJK55();
178812
178986
  init_src();
178987
+ nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
178813
178988
  CF_KEYRING_SERVICE_NAME = "cloudflare";
178814
178989
  CF_CLI_NAME = "cf";
178815
178990
  CF_DISPLAY_NAME = "cf";
@@ -179812,7 +179987,7 @@ var init_dist14 = __esm({
179812
179987
  init_wrapper();
179813
179988
  init_create_worker_upload_form();
179814
179989
  import_undici13 = __toESM(require_undici(), 1);
179815
- version3 = "0.0.34";
179990
+ version3 = "0.0.36";
179816
179991
  NoDefaultValueProvided2 = class extends UserError {
179817
179992
  static {
179818
179993
  __name(this, "NoDefaultValueProvided");
@@ -212776,6 +212951,98 @@ var init_collectKeyValues = __esm({
212776
212951
  }
212777
212952
  });
212778
212953
 
212954
+ // src/versions/deployment-args.ts
212955
+ function parseDurableObjectsCodeUpdateMode(value) {
212956
+ if (typeof value !== "string") {
212957
+ throwInvalidCodeUpdateMode();
212958
+ }
212959
+ const [mode, duration3, ...extraValues] = value.trim().split(/\s+/);
212960
+ if (mode === "immediate" && duration3 === void 0) {
212961
+ return { mode };
212962
+ }
212963
+ if (mode === "deferred" && duration3 !== void 0 && extraValues.length === 0) {
212964
+ const seconds = parseHumanDuration(duration3);
212965
+ if (/\d/.test(duration3) && Number.isFinite(seconds) && seconds >= 0 && seconds <= MAX_DURABLE_OBJECTS_CODE_UPDATE_DELAY_SECONDS && hasMillisecondPrecision(seconds)) {
212966
+ return { mode, max_delay: seconds };
212967
+ }
212968
+ throw new CommandLineArgsError(
212969
+ 'The duration passed to "--durable-objects-code-update-mode deferred" must be between 0 seconds and 24 hours and use millisecond precision.',
212970
+ { telemetryMessage: "durable objects code update delay invalid" }
212971
+ );
212972
+ }
212973
+ throwInvalidCodeUpdateMode();
212974
+ }
212975
+ function hasMillisecondPrecision(seconds) {
212976
+ const milliseconds = seconds * 1e3;
212977
+ const roundedMilliseconds = Math.round(milliseconds);
212978
+ return (seconds === 0 || roundedMilliseconds > 0) && Math.abs(milliseconds - roundedMilliseconds) <= 1e-6;
212979
+ }
212980
+ function throwInvalidCodeUpdateMode() {
212981
+ throw new CommandLineArgsError(
212982
+ 'The argument "--durable-objects-code-update-mode" must be either "immediate" or "deferred <duration>".',
212983
+ { telemetryMessage: "durable objects code update mode invalid" }
212984
+ );
212985
+ }
212986
+ function normalizeDurableObjectsCodeUpdateModeArgs(argv) {
212987
+ const normalizedArgv = [];
212988
+ for (let i8 = 0; i8 < argv.length; i8++) {
212989
+ const arg = argv[i8];
212990
+ if (arg === "--") {
212991
+ normalizedArgv.push(...argv.slice(i8));
212992
+ break;
212993
+ }
212994
+ const separateMode = arg === DURABLE_OBJECTS_CODE_UPDATE_MODE_FLAG;
212995
+ const inlineMode = arg.startsWith(
212996
+ `${DURABLE_OBJECTS_CODE_UPDATE_MODE_FLAG}=`
212997
+ ) ? arg.slice(DURABLE_OBJECTS_CODE_UPDATE_MODE_FLAG.length + 1) : void 0;
212998
+ const mode = separateMode ? argv[i8 + 1] : inlineMode;
212999
+ const durationIndex = i8 + (separateMode ? 2 : 1);
213000
+ const duration3 = argv[durationIndex];
213001
+ if (mode === "deferred" && duration3 !== void 0 && (!duration3.startsWith("-") || Number.isFinite(parseHumanDuration(duration3)))) {
213002
+ normalizedArgv.push(
213003
+ `${DURABLE_OBJECTS_CODE_UPDATE_MODE_FLAG}=deferred ${duration3}`
213004
+ );
213005
+ i8 = durationIndex;
213006
+ continue;
213007
+ }
213008
+ normalizedArgv.push(arg);
213009
+ }
213010
+ return normalizedArgv;
213011
+ }
213012
+ function resolveDurableObjectsCodeUpdateStrategy(codeUpdateMode, codeUpdateStrategy) {
213013
+ const strategy = codeUpdateMode ?? codeUpdateStrategy ?? DEFAULT_DURABLE_OBJECTS_CODE_UPDATE_STRATEGY;
213014
+ return strategy.mode === "immediate" ? { mode: "immediate" } : {
213015
+ mode: "deferred",
213016
+ max_delay: strategy.max_delay ?? DEFAULT_DURABLE_OBJECTS_CODE_UPDATE_STRATEGY.max_delay
213017
+ };
213018
+ }
213019
+ var DEFAULT_DURABLE_OBJECTS_CODE_UPDATE_STRATEGY, MAX_DURABLE_OBJECTS_CODE_UPDATE_DELAY_SECONDS, DURABLE_OBJECTS_CODE_UPDATE_MODE_FLAG, durableObjectsCodeUpdateModeArg;
213020
+ var init_deployment_args = __esm({
213021
+ "src/versions/deployment-args.ts"() {
213022
+ init_import_meta_url();
213023
+ init_src();
213024
+ DEFAULT_DURABLE_OBJECTS_CODE_UPDATE_STRATEGY = {
213025
+ mode: "deferred",
213026
+ max_delay: 300
213027
+ };
213028
+ MAX_DURABLE_OBJECTS_CODE_UPDATE_DELAY_SECONDS = 24 * 60 * 60;
213029
+ DURABLE_OBJECTS_CODE_UPDATE_MODE_FLAG = "--durable-objects-code-update-mode";
213030
+ __name(parseDurableObjectsCodeUpdateMode, "parseDurableObjectsCodeUpdateMode");
213031
+ __name(hasMillisecondPrecision, "hasMillisecondPrecision");
213032
+ __name(throwInvalidCodeUpdateMode, "throwInvalidCodeUpdateMode");
213033
+ __name(normalizeDurableObjectsCodeUpdateModeArgs, "normalizeDurableObjectsCodeUpdateModeArgs");
213034
+ __name(resolveDurableObjectsCodeUpdateStrategy, "resolveDurableObjectsCodeUpdateStrategy");
213035
+ durableObjectsCodeUpdateModeArg = {
213036
+ "durable-objects-code-update-mode": {
213037
+ describe: "How to update Durable Object code: immediate, or deferred followed by a maximum delay (for example, deferred 30s)",
213038
+ type: "string",
213039
+ requiresArg: true,
213040
+ coerce: parseDurableObjectsCodeUpdateMode
213041
+ }
213042
+ };
213043
+ }
213044
+ });
213045
+
212779
213046
  // src/deployment-bundle/merge-config-args.ts
212780
213047
  async function mergeSharedConfigArgs(command2, args, config2) {
212781
213048
  const entry = await getEntry(args, config2, command2);
@@ -212881,6 +213148,10 @@ async function mergeDeployConfigArgs(args, config2) {
212881
213148
  dispatchNamespace: args.dispatchNamespace,
212882
213149
  oldAssetTtl: args.oldAssetTtl,
212883
213150
  containersRollout: args.containersRollout,
213151
+ durableObjectsCodeUpdateStrategy: resolveDurableObjectsCodeUpdateStrategy(
213152
+ args.durableObjectsCodeUpdateMode,
213153
+ config2.durable_objects.code_update_strategy
213154
+ ),
212884
213155
  containers: {
212885
213156
  ...shared.containers,
212886
213157
  standard: {
@@ -212964,6 +213235,7 @@ var init_merge_config_args = __esm({
212964
213235
  init_user3();
212965
213236
  init_collectKeyValues();
212966
213237
  init_getScriptName();
213238
+ init_deployment_args();
212967
213239
  init_entry();
212968
213240
  init_route_zone_args();
212969
213241
  __name(mergeSharedConfigArgs, "mergeSharedConfigArgs");
@@ -264452,6 +264724,7 @@ var init_dist15 = __esm({
264452
264724
  __toESM(require_main4(), 1);
264453
264725
  esprimaParser = __toESM(require_esprima3(), 1);
264454
264726
  typescriptParser = __toESM(require_typescript2(), 1);
264727
+ nodeModule.createRequire(import_meta_url || (typeof __filename === "string" ? __filename : "/"));
264455
264728
  __defProp6 = Object.defineProperty;
264456
264729
  __name6 = /* @__PURE__ */ __name((target, value) => __defProp6(target, "name", { value, configurable: true }), "__name");
264457
264730
  __name(parseJs, "parseJs");
@@ -265291,7 +265564,7 @@ var init_packages3 = __esm({
265291
265564
  init_command2();
265292
265565
  init_src();
265293
265566
  installPackages = /* @__PURE__ */ __name(async (packageManager, packages, config2 = {}) => {
265294
- const { force, dev: dev2, startText, doneText } = config2;
265567
+ const { cwd: cwd2 = process.cwd(), force, dev: dev2, startText, doneText } = config2;
265295
265568
  const isWorkspaceRoot = config2.isWorkspaceRoot ?? false;
265296
265569
  if (packages.length === 0) {
265297
265570
  let cmd$1;
@@ -265313,7 +265586,7 @@ var init_packages3 = __esm({
265313
265586
  ...force === true ? ["--force"] : [],
265314
265587
  ...getWorkspaceInstallRootFlag(packageManager, isWorkspaceRoot)
265315
265588
  ], {
265316
- cwd: process.cwd(),
265589
+ cwd: cwd2,
265317
265590
  startText,
265318
265591
  doneText,
265319
265592
  silent: true
@@ -265347,12 +265620,13 @@ var init_packages3 = __esm({
265347
265620
  ...force === true ? ["--force"] : [],
265348
265621
  ...getWorkspaceInstallRootFlag(packageManager, isWorkspaceRoot)
265349
265622
  ], {
265623
+ cwd: cwd2,
265350
265624
  startText,
265351
265625
  doneText,
265352
265626
  silent: true
265353
265627
  });
265354
265628
  if (packageManager === "npm") {
265355
- const pkgJsonPath = path28__namespace.default.join(process.cwd(), "package.json");
265629
+ const pkgJsonPath = path28__namespace.default.join(cwd2, "package.json");
265356
265630
  const pkgJson = parsePackageJSON(readFileSync(pkgJsonPath), pkgJsonPath);
265357
265631
  const deps = config2.dev ? pkgJson.devDependencies : pkgJson.dependencies;
265358
265632
  assert38__default.default(deps, "dependencies should be defined");
@@ -288527,6 +288801,7 @@ var init_deploy3 = __esm({
288527
288801
  init_sites2();
288528
288802
  init_detect_agent();
288529
288803
  init_getScriptName();
288804
+ init_deployment_args();
288530
288805
  init_autoconfig2();
288531
288806
  init_open_next();
288532
288807
  __name(parseEventCode, "parseEventCode");
@@ -288541,6 +288816,7 @@ var init_deploy3 = __esm({
288541
288816
  args: {
288542
288817
  ...experimentalNewConfigArg,
288543
288818
  ...sharedDeployVersionsArgs,
288819
+ ...durableObjectsCodeUpdateModeArg,
288544
288820
  "event-code": {
288545
288821
  describe: "Create a temporary account for an event",
288546
288822
  type: "string",
@@ -299334,6 +299610,7 @@ async function runPagesToWorkersDeploy(delegation) {
299334
299610
  oldAssetTtl: void 0,
299335
299611
  dispatchNamespace: void 0,
299336
299612
  containersRollout: void 0,
299613
+ durableObjectsCodeUpdateMode: void 0,
299337
299614
  path: void 0,
299338
299615
  script: void 0,
299339
299616
  name: void 0,
@@ -302626,6 +302903,7 @@ async function toEnvironment(deploymentConfig, accountId) {
302626
302903
  deploymentConfig.durable_object_namespaces ?? {}
302627
302904
  )) {
302628
302905
  configObj.durable_objects ??= { bindings: [] };
302906
+ configObj.durable_objects.bindings ??= [];
302629
302907
  if (ns.class_name && ns.class_name !== "") {
302630
302908
  configObj.durable_objects.bindings.push({
302631
302909
  name: name2,
@@ -340275,7 +340553,8 @@ async function deployPreviewContainers(scopedConfig, normalisedContainerConfig,
340275
340553
  scopedConfig,
340276
340554
  normalisedContainerConfig,
340277
340555
  deployment,
340278
- accountId
340556
+ accountId,
340557
+ options.localImageReferences
340279
340558
  );
340280
340559
  }
340281
340560
  const previousLogLevel = getLogLevel();
@@ -340287,14 +340566,15 @@ async function deployPreviewContainers(scopedConfig, normalisedContainerConfig,
340287
340566
  scopedConfig,
340288
340567
  normalisedContainerConfig,
340289
340568
  deployment,
340290
- accountId
340569
+ accountId,
340570
+ options.localImageReferences
340291
340571
  )
340292
340572
  );
340293
340573
  } finally {
340294
340574
  setLogLevel(previousLogLevel);
340295
340575
  }
340296
340576
  }
340297
- async function applyPreviewContainers(scopedConfig, normalisedContainerConfig, deployment, accountId) {
340577
+ async function applyPreviewContainers(scopedConfig, normalisedContainerConfig, deployment, accountId, localImageReferences) {
340298
340578
  initContainersSharedContext({ logger: logger2, fetchPagedListResult: fetchPagedListResult2, fetchResult: fetchResult2 });
340299
340579
  await fillOpenAPIConfiguration(scopedConfig, containersScope);
340300
340580
  const dockerPath = getDockerPath();
@@ -340322,7 +340602,19 @@ async function applyPreviewContainers(scopedConfig, normalisedContainerConfig, d
340322
340602
  );
340323
340603
  }
340324
340604
  let imageRef;
340325
- if ("dockerfile" in container) {
340605
+ const localImageReference = localImageReferences?.get(container.class_name);
340606
+ if (localImageReference !== void 0) {
340607
+ imageRef = await pushImageIfChanged({
340608
+ pathToDocker: dockerPath,
340609
+ sourceTag: localImageReference,
340610
+ targetTag: localImageReference,
340611
+ accountId,
340612
+ complianceConfig: scopedConfig,
340613
+ containerConfig: container,
340614
+ // Build Output can be uploaded again without rebuilding the image.
340615
+ cleanupSourceTag: false
340616
+ });
340617
+ } else if ("dockerfile" in container) {
340326
340618
  imageRef = await buildContainer(
340327
340619
  { ...container, name: container.name.toLowerCase() },
340328
340620
  deployment.id,
@@ -342819,6 +343111,7 @@ var init_subscription_types = __esm({
342819
343111
  EventSourceType = /* @__PURE__ */ ((EventSourceType2) => {
342820
343112
  EventSourceType2["ARTIFACTS"] = "artifacts";
342821
343113
  EventSourceType2["ARTIFACTS_REPO"] = "artifacts.repo";
343114
+ EventSourceType2["BROWSER_RUN"] = "browserRun";
342822
343115
  EventSourceType2["EMAIL_SENDING"] = "email.sending";
342823
343116
  EventSourceType2["IMAGES"] = "images";
342824
343117
  EventSourceType2["KV"] = "kv";
@@ -342841,6 +343134,8 @@ function parseSourceArgument(source, args) {
342841
343134
  return { type: "artifacts" /* ARTIFACTS */ };
342842
343135
  case "artifacts.repo" /* ARTIFACTS_REPO */:
342843
343136
  return { type: "artifacts.repo" /* ARTIFACTS_REPO */ };
343137
+ case "browserRun" /* BROWSER_RUN */:
343138
+ return { type: "browserRun" /* BROWSER_RUN */ };
342844
343139
  case "email.sending" /* EMAIL_SENDING */:
342845
343140
  if (!args.zoneId) {
342846
343141
  throw new UserError(
@@ -352140,14 +352435,15 @@ async function fetchDeployableVersions2(complianceConfig, accountId, workerName,
352140
352435
  versionCache
352141
352436
  );
352142
352437
  }
352143
- async function createDeployment2(complianceConfig, accountId, workerName, versionTraffic, message, force) {
352438
+ async function createDeployment2(complianceConfig, accountId, workerName, versionTraffic, message, force, codeUpdateStrategy) {
352144
352439
  return createDeployment(
352145
352440
  complianceConfig,
352146
352441
  accountId,
352147
352442
  workerName,
352148
352443
  versionTraffic,
352149
352444
  message,
352150
- force
352445
+ force,
352446
+ codeUpdateStrategy
352151
352447
  );
352152
352448
  }
352153
352449
  async function patchNonVersionedScriptSettings2(complianceConfig, accountId, workerName, settings) {
@@ -352606,6 +352902,7 @@ var init_deploy6 = __esm({
352606
352902
  init_user3();
352607
352903
  init_render_labelled_values();
352608
352904
  init_api4();
352905
+ init_deployment_args();
352609
352906
  init_src3();
352610
352907
  EPSILON = 1e-3;
352611
352908
  BLANK_INPUT2 = "-";
@@ -352624,6 +352921,7 @@ var init_deploy6 = __esm({
352624
352921
  },
352625
352922
  args: {
352626
352923
  ...experimentalNewConfigArg,
352924
+ ...durableObjectsCodeUpdateModeArg,
352627
352925
  name: {
352628
352926
  describe: "Name of the worker",
352629
352927
  type: "string",
@@ -352785,7 +353083,12 @@ var init_deploy6 = __esm({
352785
353083
  accountId,
352786
353084
  workerName,
352787
353085
  confirmedVersionTraffic,
352788
- message
353086
+ message,
353087
+ void 0,
353088
+ resolveDurableObjectsCodeUpdateStrategy(
353089
+ args.durableObjectsCodeUpdateMode,
353090
+ config2.durable_objects.code_update_strategy
353091
+ )
352789
353092
  );
352790
353093
  }
352791
353094
  });
@@ -353302,9 +353605,11 @@ var init_rollback = __esm({
353302
353605
  init_user3();
353303
353606
  init_api4();
353304
353607
  init_deploy6();
353608
+ init_deployment_args();
353305
353609
  CANNOT_ROLLBACK_WITH_MODIFIED_SECERT_CODE = 10220;
353306
353610
  versionsRollbackCommand = createCommand({
353307
353611
  args: {
353612
+ ...durableObjectsCodeUpdateModeArg,
353308
353613
  "version-id": {
353309
353614
  describe: "The ID of the Worker Version to rollback to",
353310
353615
  type: "string",
@@ -353389,7 +353694,12 @@ Rolling back to a previous deployment will not rollback any of the bound resourc
353389
353694
  accountId,
353390
353695
  workerName,
353391
353696
  rollbackTraffic,
353392
- message
353697
+ message,
353698
+ void 0,
353699
+ resolveDurableObjectsCodeUpdateStrategy(
353700
+ args.durableObjectsCodeUpdateMode,
353701
+ config2.durable_objects.code_update_strategy
353702
+ )
353393
353703
  );
353394
353704
  } catch (e11) {
353395
353705
  if (e11 instanceof APIError && e11.code === CANNOT_ROLLBACK_WITH_MODIFIED_SECERT_CODE) {
@@ -353410,7 +353720,11 @@ Rolling back to a previous deployment will not rollback any of the bound resourc
353410
353720
  workerName,
353411
353721
  rollbackTraffic,
353412
353722
  message,
353413
- true
353723
+ true,
353724
+ resolveDurableObjectsCodeUpdateStrategy(
353725
+ args.durableObjectsCodeUpdateMode,
353726
+ config2.durable_objects.code_update_strategy
353727
+ )
353414
353728
  );
353415
353729
  } else {
353416
353730
  cancel("Aborting rollback...");
@@ -359313,7 +359627,9 @@ function createCLIParser(argv) {
359313
359627
  requiresArg: true
359314
359628
  }
359315
359629
  };
359316
- const wrangler = yargs_default(argv).strict().showHelpOnFail(false).fail((msg, error53) => {
359630
+ const wrangler = yargs_default(
359631
+ normalizeDurableObjectsCodeUpdateModeArgs(argv)
359632
+ ).strict().showHelpOnFail(false).fail((msg, error53) => {
359317
359633
  if (!error53 || error53.name === "YError") {
359318
359634
  error53 = new CommandLineArgsError(msg, {
359319
359635
  telemetryMessage: "yargs validation error"
@@ -361540,6 +361856,7 @@ var init_src7 = __esm({
361540
361856
  init_upsert();
361541
361857
  init_versions8();
361542
361858
  init_deploy6();
361859
+ init_deployment_args();
361543
361860
  init_deployments5();
361544
361861
  init_list32();
361545
361862
  init_status3();
@@ -362814,10 +363131,11 @@ var init_DevEnv = __esm({
362814
363131
  `, event.cause);
362815
363132
  logger2.debug("=> Error contextual data:", event.data);
362816
363133
  } else if (event.source === "ProxyController" && event.reason.startsWith("Error inside ProxyWorker")) {
362817
- const detail = event.cause.message || event.cause.cause?.message || "unknown error";
362818
363134
  logger2.error(
362819
- `${event.reason} (the affected request failed; the dev server continues): ${detail}`
363135
+ `${event.reason} (the affected request failed; the dev server continues): ${event.cause.message || "unknown error"}`
362820
363136
  );
363137
+ logger2.debug(`Error in ${event.source}: ${event.reason}
363138
+ `, event.cause);
362821
363139
  logger2.debug("=> Error contextual data:", event.data);
362822
363140
  } else if (event.source === "ConfigController" && event.cause instanceof ParseError) {
362823
363141
  logger2.error(event.cause);