miniflare 0.0.0-e7ea6005c → 0.0.0-e8aaa3930

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/index.js CHANGED
@@ -95,11 +95,11 @@ var require_Mime = __commonJS({
95
95
  }
96
96
  }
97
97
  };
98
- Mime.prototype.getType = function(path27) {
99
- path27 = String(path27);
100
- let last = path27.replace(/^.*[/\\]/, "").toLowerCase();
98
+ Mime.prototype.getType = function(path28) {
99
+ path28 = String(path28);
100
+ let last = path28.replace(/^.*[/\\]/, "").toLowerCase();
101
101
  let ext = last.replace(/^.*\./, "").toLowerCase();
102
- let hasPath = last.length < path27.length;
102
+ let hasPath = last.length < path28.length;
103
103
  let hasDot = ext.length < last.length - 1;
104
104
  return (hasDot || !hasPath) && this._types[ext] || null;
105
105
  };
@@ -2456,7 +2456,6 @@ __export(src_exports, {
2456
2456
  DispatchFetchDispatcher: () => DispatchFetchDispatcher,
2457
2457
  DurableObjectsOptionsSchema: () => DurableObjectsOptionsSchema,
2458
2458
  DurableObjectsSharedOptionsSchema: () => DurableObjectsSharedOptionsSchema,
2459
- ENTRY_SOCKET_HTTP_OPTIONS: () => ENTRY_SOCKET_HTTP_OPTIONS,
2460
2459
  ErrorEvent: () => ErrorEvent,
2461
2460
  File: () => import_undici4.File,
2462
2461
  FormData: () => import_undici4.FormData,
@@ -2535,10 +2534,15 @@ __export(src_exports, {
2535
2534
  TlsOptions_Version: () => import_workerd_capnp.TlsOptions_Version,
2536
2535
  TypedEventTarget: () => TypedEventTarget,
2537
2536
  WORKER_BINDING_SERVICE_LOOPBACK: () => WORKER_BINDING_SERVICE_LOOPBACK,
2537
+ WORKFLOWS_PLUGIN: () => WORKFLOWS_PLUGIN,
2538
+ WORKFLOWS_PLUGIN_NAME: () => WORKFLOWS_PLUGIN_NAME,
2539
+ WORKFLOWS_STORAGE_SERVICE_NAME: () => WORKFLOWS_STORAGE_SERVICE_NAME,
2538
2540
  WaitGroup: () => WaitGroup,
2539
2541
  WebSocket: () => WebSocket,
2540
2542
  WebSocketPair: () => WebSocketPair,
2541
2543
  Worker_Binding_CryptoKey_Usage: () => import_workerd_capnp.Worker_Binding_CryptoKey_Usage,
2544
+ WorkflowsOptionsSchema: () => WorkflowsOptionsSchema,
2545
+ WorkflowsSharedOptionsSchema: () => WorkflowsSharedOptionsSchema,
2542
2546
  __MiniflareFunctionWrapper: () => __MiniflareFunctionWrapper,
2543
2547
  _enableControlEndpoints: () => _enableControlEndpoints,
2544
2548
  _forceColour: () => _forceColour,
@@ -2612,11 +2616,11 @@ __export(src_exports, {
2612
2616
  module.exports = __toCommonJS(src_exports);
2613
2617
  var import_assert12 = __toESM(require("assert"));
2614
2618
  var import_crypto3 = __toESM(require("crypto"));
2615
- var import_fs21 = __toESM(require("fs"));
2619
+ var import_fs22 = __toESM(require("fs"));
2616
2620
  var import_http6 = __toESM(require("http"));
2617
2621
  var import_net = __toESM(require("net"));
2618
2622
  var import_os2 = __toESM(require("os"));
2619
- var import_path25 = __toESM(require("path"));
2623
+ var import_path26 = __toESM(require("path"));
2620
2624
  var import_web5 = require("stream/web");
2621
2625
  var import_util5 = __toESM(require("util"));
2622
2626
  var import_zlib = __toESM(require("zlib"));
@@ -2703,7 +2707,7 @@ function zod_worker_default() {
2703
2707
 
2704
2708
  // src/index.ts
2705
2709
  var import_ws3 = require("ws");
2706
- var import_zod21 = require("zod");
2710
+ var import_zod22 = require("zod");
2707
2711
 
2708
2712
  // src/cf.ts
2709
2713
  var import_assert = __toESM(require("assert"));
@@ -3311,12 +3315,12 @@ function createHTTPRevivers(impl) {
3311
3315
  },
3312
3316
  Request(value) {
3313
3317
  (0, import_node_assert.default)(Array.isArray(value));
3314
- const [method, url17, headers, cf, body] = value;
3318
+ const [method, url18, headers, cf, body] = value;
3315
3319
  (0, import_node_assert.default)(typeof method === "string");
3316
- (0, import_node_assert.default)(typeof url17 === "string");
3320
+ (0, import_node_assert.default)(typeof url18 === "string");
3317
3321
  (0, import_node_assert.default)(headers instanceof impl.Headers);
3318
3322
  (0, import_node_assert.default)(body === null || impl.isReadableStream(body));
3319
- return new impl.Request(url17, {
3323
+ return new impl.Request(url18, {
3320
3324
  method,
3321
3325
  headers,
3322
3326
  cf,
@@ -3445,23 +3449,23 @@ function parseWithReadableStreams(impl, stringified, revivers2) {
3445
3449
  }
3446
3450
 
3447
3451
  // src/workers/core/routing.ts
3448
- function matchRoutes(routes, url17) {
3452
+ function matchRoutes(routes, url18) {
3449
3453
  for (const route of routes) {
3450
- if (route.protocol && route.protocol !== url17.protocol)
3454
+ if (route.protocol && route.protocol !== url18.protocol)
3451
3455
  continue;
3452
3456
  if (route.allowHostnamePrefix) {
3453
- if (!url17.hostname.endsWith(route.hostname))
3457
+ if (!url18.hostname.endsWith(route.hostname))
3454
3458
  continue;
3455
3459
  } else {
3456
- if (url17.hostname !== route.hostname)
3460
+ if (url18.hostname !== route.hostname)
3457
3461
  continue;
3458
3462
  }
3459
- const path27 = url17.pathname + url17.search;
3463
+ const path28 = url18.pathname + url18.search;
3460
3464
  if (route.allowPathSuffix) {
3461
- if (!path27.startsWith(route.path))
3465
+ if (!path28.startsWith(route.path))
3462
3466
  continue;
3463
3467
  } else {
3464
- if (path27 !== route.path)
3468
+ if (path28 !== route.path)
3465
3469
  continue;
3466
3470
  }
3467
3471
  return route.target;
@@ -3706,8 +3710,8 @@ function decodeSitesKey(key) {
3706
3710
  return key.startsWith(SITES_NO_CACHE_PREFIX) ? decodeURIComponent(key.substring(SITES_NO_CACHE_PREFIX.length)) : key;
3707
3711
  }
3708
3712
  function isSitesRequest(request) {
3709
- const url17 = new URL(request.url);
3710
- return url17.pathname.startsWith(`/${SITES_NO_CACHE_PREFIX}`);
3713
+ const url18 = new URL(request.url);
3714
+ return url18.pathname.startsWith(`/${SITES_NO_CACHE_PREFIX}`);
3711
3715
  }
3712
3716
  function serialiseRegExp(regExp) {
3713
3717
  const str = regExp.toString();
@@ -3783,7 +3787,7 @@ var QueueConsumerOptionsSchema = /* @__PURE__ */ import_zod2.z.object({
3783
3787
  // https://developers.cloudflare.com/queues/platform/configuration/#consumer
3784
3788
  // https://developers.cloudflare.com/queues/platform/limits/
3785
3789
  maxBatchSize: import_zod2.z.number().min(0).max(100).optional(),
3786
- maxBatchTimeout: import_zod2.z.number().min(0).max(30).optional(),
3790
+ maxBatchTimeout: import_zod2.z.number().min(0).max(60).optional(),
3787
3791
  // seconds
3788
3792
  maxRetires: import_zod2.z.number().min(0).max(100).optional(),
3789
3793
  // deprecated
@@ -3861,8 +3865,8 @@ var Response = class extends import_undici3.Response {
3861
3865
  Object.setPrototypeOf(response, Response.prototype);
3862
3866
  return response;
3863
3867
  }
3864
- static redirect(url17, status) {
3865
- const response = import_undici3.Response.redirect(url17, status);
3868
+ static redirect(url18, status) {
3869
+ const response = import_undici3.Response.redirect(url18, status);
3866
3870
  Object.setPrototypeOf(response, Response.prototype);
3867
3871
  return response;
3868
3872
  }
@@ -4370,14 +4374,14 @@ async function fetch3(input, init2) {
4370
4374
  const requestInit = init2;
4371
4375
  const request = new Request(input, requestInit);
4372
4376
  if (request.method === "GET" && request.headers.get("upgrade") === "websocket") {
4373
- const url17 = new URL(request.url);
4374
- if (url17.protocol !== "http:" && url17.protocol !== "https:") {
4377
+ const url18 = new URL(request.url);
4378
+ if (url18.protocol !== "http:" && url18.protocol !== "https:") {
4375
4379
  throw new TypeError(
4376
- `Fetch API cannot load: ${url17.toString()}.
4380
+ `Fetch API cannot load: ${url18.toString()}.
4377
4381
  Make sure you're using http(s):// URLs for WebSocket requests via fetch.`
4378
4382
  );
4379
4383
  }
4380
- url17.protocol = url17.protocol.replace("http", "ws");
4384
+ url18.protocol = url18.protocol.replace("http", "ws");
4381
4385
  const headers = {};
4382
4386
  let protocols;
4383
4387
  for (const [key, value] of request.headers.entries()) {
@@ -4389,10 +4393,10 @@ Make sure you're using http(s):// URLs for WebSocket requests via fetch.`
4389
4393
  }
4390
4394
  let rejectUnauthorized;
4391
4395
  if (requestInit.dispatcher instanceof DispatchFetchDispatcher) {
4392
- requestInit.dispatcher.addHeaders(headers, url17.pathname + url17.search);
4396
+ requestInit.dispatcher.addHeaders(headers, url18.pathname + url18.search);
4393
4397
  rejectUnauthorized = { rejectUnauthorized: false };
4394
4398
  }
4395
- const ws = new import_ws2.default(url17, protocols, {
4399
+ const ws = new import_ws2.default(url18, protocols, {
4396
4400
  followRedirects: request.redirect === "follow",
4397
4401
  headers,
4398
4402
  ...rejectUnauthorized
@@ -4451,8 +4455,8 @@ var DispatchFetchDispatcher = class extends undici.Dispatcher {
4451
4455
  this.cfBlobJson = JSON.stringify(cfBlob);
4452
4456
  }
4453
4457
  cfBlobJson;
4454
- addHeaders(headers, path27) {
4455
- const originalURL = this.userRuntimeOrigin + path27;
4458
+ addHeaders(headers, path28) {
4459
+ const originalURL = this.userRuntimeOrigin + path28;
4456
4460
  addHeader(headers, CoreHeaders.ORIGINAL_URL, originalURL);
4457
4461
  addHeader(headers, CoreHeaders.DISABLE_PRETTY_ERROR, "true");
4458
4462
  if (this.cfBlobJson !== void 0) {
@@ -4465,16 +4469,16 @@ var DispatchFetchDispatcher = class extends undici.Dispatcher {
4465
4469
  origin = this.actualRuntimeOrigin;
4466
4470
  if (origin === this.actualRuntimeOrigin) {
4467
4471
  options.origin = origin;
4468
- let path27 = options.path;
4472
+ let path28 = options.path;
4469
4473
  if (options.query !== void 0) {
4470
- const url17 = new URL(path27, "http://placeholder/");
4474
+ const url18 = new URL(path28, "http://placeholder/");
4471
4475
  for (const [key, value] of Object.entries(options.query)) {
4472
- url17.searchParams.append(key, value);
4476
+ url18.searchParams.append(key, value);
4473
4477
  }
4474
- path27 = url17.pathname + url17.search;
4478
+ path28 = url18.pathname + url18.search;
4475
4479
  }
4476
4480
  options.headers ??= {};
4477
- this.addHeaders(options.headers, path27);
4481
+ this.addHeaders(options.headers, path28);
4478
4482
  return this.runtimeDispatcher.dispatch(options, handler);
4479
4483
  } else {
4480
4484
  return this.globalDispatcher.dispatch(options, handler);
@@ -4535,11 +4539,6 @@ ez/dHA==
4535
4539
  `;
4536
4540
 
4537
4541
  // src/http/server.ts
4538
- var ENTRY_SOCKET_HTTP_OPTIONS = {
4539
- // Even though we inject a `cf` object in the entry worker, allow it to
4540
- // be customised via `dispatchFetch`
4541
- cfBlobHeader: CoreHeaders.CF_BLOB
4542
- };
4543
4542
  async function getEntrySocketHttpOptions(coreOpts) {
4544
4543
  let privateKey = void 0;
4545
4544
  let certificateChain = void 0;
@@ -4556,7 +4555,6 @@ async function getEntrySocketHttpOptions(coreOpts) {
4556
4555
  if (privateKey && certificateChain) {
4557
4556
  return {
4558
4557
  https: {
4559
- options: ENTRY_SOCKET_HTTP_OPTIONS,
4560
4558
  tlsOptions: {
4561
4559
  keypair: {
4562
4560
  privateKey,
@@ -4566,7 +4564,7 @@ async function getEntrySocketHttpOptions(coreOpts) {
4566
4564
  }
4567
4565
  };
4568
4566
  } else {
4569
- return { http: ENTRY_SOCKET_HTTP_OPTIONS };
4567
+ return { http: {} };
4570
4568
  }
4571
4569
  }
4572
4570
  function valueOrFile(value, filePath) {
@@ -4611,7 +4609,8 @@ var MAX_ASSET_SIZE = 25 * 1024 * 1024;
4611
4609
  // ../workers-shared/utils/types.ts
4612
4610
  var import_zod4 = require("zod");
4613
4611
  var RoutingConfigSchema = import_zod4.z.object({
4614
- has_user_worker: import_zod4.z.boolean().optional()
4612
+ has_user_worker: import_zod4.z.boolean().optional(),
4613
+ invoke_user_worker_ahead_of_assets: import_zod4.z.boolean().optional()
4615
4614
  });
4616
4615
  var AssetConfigSchema = import_zod4.z.object({
4617
4616
  html_handling: import_zod4.z.enum([
@@ -4620,7 +4619,8 @@ var AssetConfigSchema = import_zod4.z.object({
4620
4619
  "drop-trailing-slash",
4621
4620
  "none"
4622
4621
  ]).optional(),
4623
- not_found_handling: import_zod4.z.enum(["single-page-application", "404-page", "none"]).optional()
4622
+ not_found_handling: import_zod4.z.enum(["single-page-application", "404-page", "none"]).optional(),
4623
+ serve_directly: import_zod4.z.boolean().optional()
4624
4624
  });
4625
4625
 
4626
4626
  // ../workers-shared/utils/helpers.ts
@@ -4640,7 +4640,7 @@ var getContentType = (absFilePath) => {
4640
4640
  return contentType;
4641
4641
  };
4642
4642
 
4643
- // ../../node_modules/.pnpm/pretty-bytes@6.0.0/node_modules/pretty-bytes/index.js
4643
+ // ../../node_modules/.pnpm/pretty-bytes@6.1.1/node_modules/pretty-bytes/index.js
4644
4644
  var BYTE_UNITS = [
4645
4645
  "B",
4646
4646
  "kB",
@@ -4654,7 +4654,7 @@ var BYTE_UNITS = [
4654
4654
  ];
4655
4655
  var BIBYTE_UNITS = [
4656
4656
  "B",
4657
- "kiB",
4657
+ "KiB",
4658
4658
  "MiB",
4659
4659
  "GiB",
4660
4660
  "TiB",
@@ -4701,11 +4701,13 @@ function prettyBytes(number, options) {
4701
4701
  options = {
4702
4702
  bits: false,
4703
4703
  binary: false,
4704
+ space: true,
4704
4705
  ...options
4705
4706
  };
4706
4707
  const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
4708
+ const separator = options.space ? " " : "";
4707
4709
  if (options.signed && number === 0) {
4708
- return ` 0 ${UNITS[0]}`;
4710
+ return ` 0${separator}${UNITS[0]}`;
4709
4711
  }
4710
4712
  const isNegative = number < 0;
4711
4713
  const prefix = isNegative ? "-" : options.signed ? "+" : "";
@@ -4721,7 +4723,7 @@ function prettyBytes(number, options) {
4721
4723
  }
4722
4724
  if (number < 1) {
4723
4725
  const numberString2 = toLocaleString(number, options.locale, localeOptions);
4724
- return prefix + numberString2 + " " + UNITS[0];
4726
+ return prefix + numberString2 + separator + UNITS[0];
4725
4727
  }
4726
4728
  const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
4727
4729
  number /= (options.binary ? 1024 : 1e3) ** exponent;
@@ -4730,7 +4732,7 @@ function prettyBytes(number, options) {
4730
4732
  }
4731
4733
  const numberString = toLocaleString(Number(number), options.locale, localeOptions);
4732
4734
  const unit = UNITS[exponent];
4733
- return prefix + numberString + " " + unit;
4735
+ return prefix + numberString + separator + unit;
4734
4736
  }
4735
4737
 
4736
4738
  // embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/assets/assets.worker.ts
@@ -5086,12 +5088,12 @@ var kUnsafeEphemeralUniqueKey = Symbol.for(
5086
5088
  var import_url11 = require("url");
5087
5089
  var RouterError = class extends MiniflareError {
5088
5090
  };
5089
- function routeSpecificity(url17) {
5090
- const hostParts = url17.host.split(".");
5091
+ function routeSpecificity(url18) {
5092
+ const hostParts = url18.host.split(".");
5091
5093
  let hostScore = hostParts.length;
5092
5094
  if (hostParts[0] === "*")
5093
5095
  hostScore -= 2;
5094
- const pathParts = url17.pathname.split("/");
5096
+ const pathParts = url18.pathname.split("/");
5095
5097
  let pathScore = pathParts.length;
5096
5098
  if (pathParts[pathParts.length - 1] === "*")
5097
5099
  pathScore -= 2;
@@ -5105,30 +5107,30 @@ function parseRoutes(allRoutes) {
5105
5107
  let urlInput = route;
5106
5108
  if (!hasProtocol)
5107
5109
  urlInput = `https://${urlInput}`;
5108
- const url17 = new import_url11.URL(urlInput);
5109
- const specificity = routeSpecificity(url17);
5110
- const protocol = hasProtocol ? url17.protocol : void 0;
5111
- const internationalisedAllowHostnamePrefix = url17.hostname.startsWith("xn--*");
5112
- const allowHostnamePrefix = url17.hostname.startsWith("*") || internationalisedAllowHostnamePrefix;
5113
- const anyHostname = url17.hostname === "*";
5110
+ const url18 = new import_url11.URL(urlInput);
5111
+ const specificity = routeSpecificity(url18);
5112
+ const protocol = hasProtocol ? url18.protocol : void 0;
5113
+ const internationalisedAllowHostnamePrefix = url18.hostname.startsWith("xn--*");
5114
+ const allowHostnamePrefix = url18.hostname.startsWith("*") || internationalisedAllowHostnamePrefix;
5115
+ const anyHostname = url18.hostname === "*";
5114
5116
  if (allowHostnamePrefix && !anyHostname) {
5115
- let hostname = url17.hostname;
5117
+ let hostname = url18.hostname;
5116
5118
  if (internationalisedAllowHostnamePrefix) {
5117
5119
  hostname = (0, import_url11.domainToUnicode)(hostname);
5118
5120
  }
5119
- url17.hostname = hostname.substring(1);
5121
+ url18.hostname = hostname.substring(1);
5120
5122
  }
5121
- const allowPathSuffix = url17.pathname.endsWith("*");
5123
+ const allowPathSuffix = url18.pathname.endsWith("*");
5122
5124
  if (allowPathSuffix) {
5123
- url17.pathname = url17.pathname.substring(0, url17.pathname.length - 1);
5125
+ url18.pathname = url18.pathname.substring(0, url18.pathname.length - 1);
5124
5126
  }
5125
- if (url17.search) {
5127
+ if (url18.search) {
5126
5128
  throw new RouterError(
5127
5129
  "ERR_QUERY_STRING",
5128
5130
  `Route "${route}" for "${target}" contains a query string. This is not allowed.`
5129
5131
  );
5130
5132
  }
5131
- if (url17.toString().includes("*") && !anyHostname) {
5133
+ if (url18.toString().includes("*") && !anyHostname) {
5132
5134
  throw new RouterError(
5133
5135
  "ERR_INFIX_WILDCARD",
5134
5136
  `Route "${route}" for "${target}" contains an infix wildcard. This is not allowed.`
@@ -5140,8 +5142,8 @@ function parseRoutes(allRoutes) {
5140
5142
  specificity,
5141
5143
  protocol,
5142
5144
  allowHostnamePrefix,
5143
- hostname: anyHostname ? "" : url17.hostname,
5144
- path: url17.pathname,
5145
+ hostname: anyHostname ? "" : url18.hostname,
5146
+ path: url18.pathname,
5145
5147
  allowPathSuffix
5146
5148
  });
5147
5149
  }
@@ -5182,11 +5184,11 @@ function namespaceEntries(namespaces) {
5182
5184
  return [];
5183
5185
  }
5184
5186
  }
5185
- function maybeParseURL(url17) {
5186
- if (typeof url17 !== "string" || import_path14.default.isAbsolute(url17))
5187
+ function maybeParseURL(url18) {
5188
+ if (typeof url18 !== "string" || import_path14.default.isAbsolute(url18))
5187
5189
  return;
5188
5190
  try {
5189
- return new URL(url17);
5191
+ return new URL(url18);
5190
5192
  } catch {
5191
5193
  }
5192
5194
  }
@@ -5195,16 +5197,16 @@ function getPersistPath(pluginName, tmpPath, persist) {
5195
5197
  if (persist === void 0 || persist === false) {
5196
5198
  return memoryishPath;
5197
5199
  }
5198
- const url17 = maybeParseURL(persist);
5199
- if (url17 !== void 0) {
5200
- if (url17.protocol === "memory:") {
5200
+ const url18 = maybeParseURL(persist);
5201
+ if (url18 !== void 0) {
5202
+ if (url18.protocol === "memory:") {
5201
5203
  return memoryishPath;
5202
- } else if (url17.protocol === "file:") {
5203
- return (0, import_url12.fileURLToPath)(url17);
5204
+ } else if (url18.protocol === "file:") {
5205
+ return (0, import_url12.fileURLToPath)(url18);
5204
5206
  }
5205
5207
  throw new MiniflareCoreError(
5206
5208
  "ERR_PERSIST_UNSUPPORTED",
5207
- `Unsupported "${url17.protocol}" persistence protocol for storage: ${url17.href}`
5209
+ `Unsupported "${url18.protocol}" persistence protocol for storage: ${url18.href}`
5208
5210
  );
5209
5211
  }
5210
5212
  return persist === true ? import_path14.default.join(DEFAULT_PERSIST_ROOT, pluginName) : persist;
@@ -5824,60 +5826,60 @@ function createJavaScriptModule(code, name, modulePath, type) {
5824
5826
  }
5825
5827
  var encoder = new import_util.TextEncoder();
5826
5828
  var decoder = new import_util.TextDecoder();
5827
- function contentsToString(contents17) {
5828
- return typeof contents17 === "string" ? contents17 : decoder.decode(contents17);
5829
+ function contentsToString(contents18) {
5830
+ return typeof contents18 === "string" ? contents18 : decoder.decode(contents18);
5829
5831
  }
5830
- function contentsToArray(contents17) {
5831
- return typeof contents17 === "string" ? encoder.encode(contents17) : contents17;
5832
+ function contentsToArray(contents18) {
5833
+ return typeof contents18 === "string" ? encoder.encode(contents18) : contents18;
5832
5834
  }
5833
5835
  function convertModuleDefinition(modulesRoot, def) {
5834
5836
  const name = moduleName(modulesRoot, def.path);
5835
- const contents17 = def.contents ?? (0, import_fs12.readFileSync)(def.path);
5837
+ const contents18 = def.contents ?? (0, import_fs12.readFileSync)(def.path);
5836
5838
  switch (def.type) {
5837
5839
  case "ESModule":
5838
5840
  case "CommonJS":
5839
5841
  case "NodeJsCompatModule":
5840
5842
  return createJavaScriptModule(
5841
- contentsToString(contents17),
5843
+ contentsToString(contents18),
5842
5844
  name,
5843
5845
  import_path15.default.resolve(modulesRoot, def.path),
5844
5846
  def.type
5845
5847
  );
5846
5848
  case "Text":
5847
- return { name, text: contentsToString(contents17) };
5849
+ return { name, text: contentsToString(contents18) };
5848
5850
  case "Data":
5849
- return { name, data: contentsToArray(contents17) };
5851
+ return { name, data: contentsToArray(contents18) };
5850
5852
  case "CompiledWasm":
5851
- return { name, wasm: contentsToArray(contents17) };
5853
+ return { name, wasm: contentsToArray(contents18) };
5852
5854
  case "PythonModule":
5853
- return { name, pythonModule: contentsToString(contents17) };
5855
+ return { name, pythonModule: contentsToString(contents18) };
5854
5856
  case "PythonRequirement":
5855
- return { name, pythonRequirement: contentsToString(contents17) };
5857
+ return { name, pythonRequirement: contentsToString(contents18) };
5856
5858
  default:
5857
5859
  const exhaustive = def.type;
5858
5860
  import_assert5.default.fail(`Unreachable: ${exhaustive} modules are unsupported`);
5859
5861
  }
5860
5862
  }
5861
5863
  function convertWorkerModule(mod) {
5862
- const path27 = mod.name;
5863
- (0, import_assert5.default)(path27 !== void 0);
5864
+ const path28 = mod.name;
5865
+ (0, import_assert5.default)(path28 !== void 0);
5864
5866
  const m = mod;
5865
5867
  if ("esModule" in m)
5866
- return { path: path27, type: "ESModule" };
5868
+ return { path: path28, type: "ESModule" };
5867
5869
  else if ("commonJsModule" in m)
5868
- return { path: path27, type: "CommonJS" };
5870
+ return { path: path28, type: "CommonJS" };
5869
5871
  else if ("nodeJsCompatModule" in m)
5870
- return { path: path27, type: "NodeJsCompatModule" };
5872
+ return { path: path28, type: "NodeJsCompatModule" };
5871
5873
  else if ("text" in m)
5872
- return { path: path27, type: "Text" };
5874
+ return { path: path28, type: "Text" };
5873
5875
  else if ("data" in m)
5874
- return { path: path27, type: "Data" };
5876
+ return { path: path28, type: "Data" };
5875
5877
  else if ("wasm" in m)
5876
- return { path: path27, type: "CompiledWasm" };
5878
+ return { path: path28, type: "CompiledWasm" };
5877
5879
  else if ("pythonModule" in m)
5878
- return { path: path27, type: "PythonModule" };
5880
+ return { path: path28, type: "PythonModule" };
5879
5881
  else if ("pythonRequirement" in m)
5880
- return { path: path27, type: "PythonRequirement" };
5882
+ return { path: path28, type: "PythonRequirement" };
5881
5883
  (0, import_assert5.default)(
5882
5884
  !("json" in m || "fallbackService" in m),
5883
5885
  "Unreachable: json or fallbackService modules aren't generated"
@@ -6080,8 +6082,8 @@ function getSourceMapper() {
6080
6082
  // src/plugins/core/errors/index.ts
6081
6083
  function maybeGetDiskFile(filePath) {
6082
6084
  try {
6083
- const contents17 = import_fs13.default.readFileSync(filePath, "utf8");
6084
- return { path: filePath, contents: contents17 };
6085
+ const contents18 = import_fs13.default.readFileSync(filePath, "utf8");
6086
+ return { path: filePath, contents: contents18 };
6085
6087
  } catch (e) {
6086
6088
  if (e.code !== "ENOENT")
6087
6089
  throw e;
@@ -6096,8 +6098,8 @@ function maybeGetFile(workerSrcOpts, fileSpecifier) {
6096
6098
  const modulesRoot = srcOpts.modulesRoot ?? "";
6097
6099
  for (const module2 of srcOpts.modules) {
6098
6100
  if (module2.contents !== void 0 && import_path16.default.resolve(modulesRoot, module2.path) === filePath) {
6099
- const contents17 = contentsToString(module2.contents);
6100
- return { path: filePath, contents: contents17 };
6101
+ const contents18 = contentsToString(module2.contents);
6102
+ return { path: filePath, contents: contents18 };
6101
6103
  }
6102
6104
  }
6103
6105
  } else if ("script" in srcOpts && "scriptPath" in srcOpts && srcOpts.script !== void 0 && srcOpts.scriptPath !== void 0) {
@@ -6281,7 +6283,7 @@ var SynchronousFetcher = class {
6281
6283
  transferList: [this.#channel.port2]
6282
6284
  });
6283
6285
  }
6284
- fetch(url17, init2) {
6286
+ fetch(url18, init2) {
6285
6287
  this.#ensureWorker();
6286
6288
  Atomics.store(
6287
6289
  this.#notifyHandle,
@@ -6294,7 +6296,7 @@ var SynchronousFetcher = class {
6294
6296
  this.#channel.port1.postMessage({
6295
6297
  id,
6296
6298
  method: init2.method,
6297
- url: url17.toString(),
6299
+ url: url18.toString(),
6298
6300
  headers: init2.headers,
6299
6301
  body: init2.body
6300
6302
  });
@@ -6414,8 +6416,8 @@ var ProxyClient = class {
6414
6416
  }
6415
6417
  };
6416
6418
  var ProxyClientBridge = class {
6417
- constructor(url17, dispatchFetch) {
6418
- this.url = url17;
6419
+ constructor(url18, dispatchFetch) {
6420
+ this.url = url18;
6419
6421
  this.dispatchFetch = dispatchFetch;
6420
6422
  this.#finalizationRegistry = new FinalizationRegistry(this.#finalizeProxy);
6421
6423
  }
@@ -7080,11 +7082,20 @@ function validateCompatibilityDate(log, compatibilityDate) {
7080
7082
  }
7081
7083
  return compatibilityDate;
7082
7084
  }
7083
- function buildJsonBindings(bindings) {
7084
- return Object.entries(bindings).map(([name, value]) => ({
7085
- name,
7086
- json: JSON.stringify(value)
7087
- }));
7085
+ function buildBindings(bindings) {
7086
+ return Object.entries(bindings).map(([name, value]) => {
7087
+ if (typeof value === "string") {
7088
+ return {
7089
+ name,
7090
+ text: value
7091
+ };
7092
+ } else {
7093
+ return {
7094
+ name,
7095
+ json: JSON.stringify(value)
7096
+ };
7097
+ }
7098
+ });
7088
7099
  }
7089
7100
  var WRAPPED_MODULE_PREFIX = "miniflare-internal:wrapped:";
7090
7101
  function workerNameToWrappedModule(workerName) {
@@ -7101,7 +7112,7 @@ var CORE_PLUGIN = {
7101
7112
  getBindings(options, workerIndex) {
7102
7113
  const bindings = [];
7103
7114
  if (options.bindings !== void 0) {
7104
- bindings.push(...buildJsonBindings(options.bindings));
7115
+ bindings.push(...buildBindings(options.bindings));
7105
7116
  }
7106
7117
  if (options.wasmBindings !== void 0) {
7107
7118
  bindings.push(
@@ -7113,7 +7124,7 @@ var CORE_PLUGIN = {
7113
7124
  if (options.textBlobBindings !== void 0) {
7114
7125
  bindings.push(
7115
7126
  ...Object.entries(options.textBlobBindings).map(
7116
- ([name, path27]) => import_promises6.default.readFile(path27, "utf8").then((text) => ({ name, text }))
7127
+ ([name, path28]) => import_promises6.default.readFile(path28, "utf8").then((text) => ({ name, text }))
7117
7128
  )
7118
7129
  );
7119
7130
  }
@@ -7150,7 +7161,7 @@ var CORE_PLUGIN = {
7150
7161
  const entrypoint = isObject ? designator.entrypoint : void 0;
7151
7162
  const bindings2 = isObject ? designator.bindings : void 0;
7152
7163
  const moduleName2 = workerNameToWrappedModule(scriptName);
7153
- const innerBindings = bindings2 === void 0 ? [] : buildJsonBindings(bindings2);
7164
+ const innerBindings = bindings2 === void 0 ? [] : buildBindings(bindings2);
7154
7165
  return {
7155
7166
  name,
7156
7167
  wrapped: { moduleName: moduleName2, entrypoint, innerBindings }
@@ -7186,7 +7197,7 @@ var CORE_PLUGIN = {
7186
7197
  if (options.textBlobBindings !== void 0) {
7187
7198
  bindingEntries2.push(
7188
7199
  ...Object.entries(options.textBlobBindings).map(
7189
- ([name, path27]) => import_promises6.default.readFile(path27, "utf8").then((text) => [name, text])
7200
+ ([name, path28]) => import_promises6.default.readFile(path28, "utf8").then((text) => [name, text])
7190
7201
  )
7191
7202
  );
7192
7203
  }
@@ -7759,9 +7770,9 @@ var encodeManifest = (manifest) => {
7759
7770
  var bytesToHex = (buffer) => {
7760
7771
  return [...new Uint8Array(buffer)].map((b) => b.toString(16).padStart(2, "0")).join("");
7761
7772
  };
7762
- var hashPath = async (path27) => {
7773
+ var hashPath = async (path28) => {
7763
7774
  const encoder3 = new TextEncoder();
7764
- const data = encoder3.encode(path27);
7775
+ const data = encoder3.encode(path28);
7765
7776
  const hashBuffer = await import_node_crypto.default.subtle.digest("SHA-256", data.buffer);
7766
7777
  return new Uint8Array(hashBuffer, 0, PATH_HASH_SIZE);
7767
7778
  };
@@ -7902,55 +7913,55 @@ var D1_PLUGIN = {
7902
7913
  var import_node_assert3 = __toESM(require("node:assert"));
7903
7914
  var import_zod15 = require("zod");
7904
7915
  var HYPERDRIVE_PLUGIN_NAME = "hyperdrive";
7905
- function hasPostgresProtocol(url17) {
7906
- return url17.protocol === "postgresql:" || url17.protocol === "postgres:";
7916
+ function hasPostgresProtocol(url18) {
7917
+ return url18.protocol === "postgresql:" || url18.protocol === "postgres:";
7907
7918
  }
7908
- function getPort(url17) {
7909
- if (url17.port !== "")
7910
- return url17.port;
7911
- if (hasPostgresProtocol(url17))
7919
+ function getPort(url18) {
7920
+ if (url18.port !== "")
7921
+ return url18.port;
7922
+ if (hasPostgresProtocol(url18))
7912
7923
  return "5432";
7913
- import_node_assert3.default.fail(`Expected known protocol, got ${url17.protocol}`);
7924
+ import_node_assert3.default.fail(`Expected known protocol, got ${url18.protocol}`);
7914
7925
  }
7915
- var HyperdriveSchema = import_zod15.z.union([import_zod15.z.string().url(), import_zod15.z.instanceof(URL)]).transform((url17, ctx) => {
7916
- if (typeof url17 === "string")
7917
- url17 = new URL(url17);
7918
- if (url17.protocol === "") {
7926
+ var HyperdriveSchema = import_zod15.z.union([import_zod15.z.string().url(), import_zod15.z.instanceof(URL)]).transform((url18, ctx) => {
7927
+ if (typeof url18 === "string")
7928
+ url18 = new URL(url18);
7929
+ if (url18.protocol === "") {
7919
7930
  ctx.addIssue({
7920
7931
  code: import_zod15.z.ZodIssueCode.custom,
7921
7932
  message: "You must specify the database protocol - e.g. 'postgresql'."
7922
7933
  });
7923
- } else if (!hasPostgresProtocol(url17)) {
7934
+ } else if (!hasPostgresProtocol(url18)) {
7924
7935
  ctx.addIssue({
7925
7936
  code: import_zod15.z.ZodIssueCode.custom,
7926
7937
  message: "Only PostgreSQL or PostgreSQL compatible databases are currently supported."
7927
7938
  });
7928
7939
  }
7929
- if (url17.host === "") {
7940
+ if (url18.host === "") {
7930
7941
  ctx.addIssue({
7931
7942
  code: import_zod15.z.ZodIssueCode.custom,
7932
7943
  message: "You must provide a hostname or IP address in your connection string - e.g. 'user:password@database-hostname.example.com:5432/databasename"
7933
7944
  });
7934
7945
  }
7935
- if (url17.pathname === "") {
7946
+ if (url18.pathname === "") {
7936
7947
  ctx.addIssue({
7937
7948
  code: import_zod15.z.ZodIssueCode.custom,
7938
7949
  message: "You must provide a database name as the path component - e.g. /postgres"
7939
7950
  });
7940
7951
  }
7941
- if (url17.username === "") {
7952
+ if (url18.username === "") {
7942
7953
  ctx.addIssue({
7943
7954
  code: import_zod15.z.ZodIssueCode.custom,
7944
7955
  message: "You must provide a username - e.g. 'user:password@database.example.com:port/databasename'"
7945
7956
  });
7946
7957
  }
7947
- if (url17.password === "") {
7958
+ if (url18.password === "") {
7948
7959
  ctx.addIssue({
7949
7960
  code: import_zod15.z.ZodIssueCode.custom,
7950
7961
  message: "You must provide a password - e.g. 'user:password@database.example.com:port/databasename' "
7951
7962
  });
7952
7963
  }
7953
- return url17;
7964
+ return url18;
7954
7965
  });
7955
7966
  var HyperdriveInputOptionsSchema = import_zod15.z.object({
7956
7967
  hyperdrives: import_zod15.z.record(import_zod15.z.string(), HyperdriveSchema).optional()
@@ -7959,9 +7970,9 @@ var HYPERDRIVE_PLUGIN = {
7959
7970
  options: HyperdriveInputOptionsSchema,
7960
7971
  getBindings(options) {
7961
7972
  return Object.entries(options.hyperdrives ?? {}).map(
7962
- ([name, url17]) => {
7963
- const database = url17.pathname.replace("/", "");
7964
- const scheme = url17.protocol.replace(":", "");
7973
+ ([name, url18]) => {
7974
+ const database = url18.pathname.replace("/", "");
7975
+ const scheme = url18.protocol.replace(":", "");
7965
7976
  return {
7966
7977
  name,
7967
7978
  hyperdrive: {
@@ -7969,8 +7980,8 @@ var HYPERDRIVE_PLUGIN = {
7969
7980
  name: `${HYPERDRIVE_PLUGIN_NAME}:${name}`
7970
7981
  },
7971
7982
  database: decodeURIComponent(database),
7972
- user: decodeURIComponent(url17.username),
7973
- password: decodeURIComponent(url17.password),
7983
+ user: decodeURIComponent(url18.username),
7984
+ password: decodeURIComponent(url18.password),
7974
7985
  scheme
7975
7986
  }
7976
7987
  };
@@ -7979,11 +7990,11 @@ var HYPERDRIVE_PLUGIN = {
7979
7990
  },
7980
7991
  getNodeBindings(options) {
7981
7992
  return Object.fromEntries(
7982
- Object.entries(options.hyperdrives ?? {}).map(([name, url17]) => {
7993
+ Object.entries(options.hyperdrives ?? {}).map(([name, url18]) => {
7983
7994
  const connectionOverrides = {
7984
- connectionString: `${url17}`,
7985
- port: Number.parseInt(url17.port),
7986
- host: url17.hostname
7995
+ connectionString: `${url18}`,
7996
+ port: Number.parseInt(url18.port),
7997
+ host: url18.hostname
7987
7998
  };
7988
7999
  const proxyNodeBinding = new ProxyNodeBinding({
7989
8000
  get(target, prop) {
@@ -7996,10 +8007,10 @@ var HYPERDRIVE_PLUGIN = {
7996
8007
  },
7997
8008
  async getServices({ options }) {
7998
8009
  return Object.entries(options.hyperdrives ?? {}).map(
7999
- ([name, url17]) => ({
8010
+ ([name, url18]) => ({
8000
8011
  name: `${HYPERDRIVE_PLUGIN_NAME}:${name}`,
8001
8012
  external: {
8002
- address: `${url17.hostname}:${getPort(url17)}`,
8013
+ address: `${url18.hostname}:${getPort(url18)}`,
8003
8014
  tcp: {}
8004
8015
  }
8005
8016
  })
@@ -8541,7 +8552,7 @@ var RatelimitOptionsSchema = import_zod19.z.object({
8541
8552
  var RATELIMIT_PLUGIN_NAME = "ratelimit";
8542
8553
  var SERVICE_RATELIMIT_PREFIX = `${RATELIMIT_PLUGIN_NAME}`;
8543
8554
  var SERVICE_RATELIMIT_MODULE = `cloudflare-internal:${SERVICE_RATELIMIT_PREFIX}:module`;
8544
- function buildJsonBindings2(bindings) {
8555
+ function buildJsonBindings(bindings) {
8545
8556
  return Object.entries(bindings).map(([name, value]) => ({
8546
8557
  name,
8547
8558
  json: JSON.stringify(value)
@@ -8558,7 +8569,7 @@ var RATELIMIT_PLUGIN = {
8558
8569
  name,
8559
8570
  wrapped: {
8560
8571
  moduleName: SERVICE_RATELIMIT_MODULE,
8561
- innerBindings: buildJsonBindings2({
8572
+ innerBindings: buildJsonBindings({
8562
8573
  namespaceId: name,
8563
8574
  limit: config.simple.limit,
8564
8575
  period: config.simple.period
@@ -8600,6 +8611,125 @@ var RATELIMIT_PLUGIN = {
8600
8611
  }
8601
8612
  };
8602
8613
 
8614
+ // src/plugins/workflows/index.ts
8615
+ var import_promises12 = __toESM(require("fs/promises"));
8616
+
8617
+ // embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/workflows/binding.worker.ts
8618
+ var import_fs21 = __toESM(require("fs"));
8619
+ var import_path25 = __toESM(require("path"));
8620
+ var import_url21 = __toESM(require("url"));
8621
+ var contents17;
8622
+ function binding_worker_default() {
8623
+ if (contents17 !== void 0)
8624
+ return contents17;
8625
+ const filePath = import_path25.default.join(__dirname, "workers", "workflows/binding.worker.js");
8626
+ contents17 = import_fs21.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url21.default.pathToFileURL(filePath);
8627
+ return contents17;
8628
+ }
8629
+
8630
+ // src/plugins/workflows/index.ts
8631
+ var import_zod20 = require("zod");
8632
+ var WorkflowsOptionsSchema = import_zod20.z.object({
8633
+ workflows: import_zod20.z.record(
8634
+ import_zod20.z.object({
8635
+ name: import_zod20.z.string(),
8636
+ className: import_zod20.z.string(),
8637
+ scriptName: import_zod20.z.string().optional()
8638
+ })
8639
+ ).optional()
8640
+ });
8641
+ var WorkflowsSharedOptionsSchema = import_zod20.z.object({
8642
+ workflowsPersist: PersistenceSchema
8643
+ });
8644
+ var WORKFLOWS_PLUGIN_NAME = "workflows";
8645
+ var WORKFLOWS_STORAGE_SERVICE_NAME = `${WORKFLOWS_PLUGIN_NAME}:storage`;
8646
+ var WORKFLOWS_PLUGIN = {
8647
+ options: WorkflowsOptionsSchema,
8648
+ sharedOptions: WorkflowsSharedOptionsSchema,
8649
+ async getBindings(options) {
8650
+ return Object.entries(options.workflows ?? {}).map(
8651
+ ([bindingName, workflow]) => ({
8652
+ name: bindingName,
8653
+ service: {
8654
+ name: `${WORKFLOWS_PLUGIN_NAME}:${workflow.name}`,
8655
+ entrypoint: "WorkflowBinding"
8656
+ }
8657
+ })
8658
+ );
8659
+ },
8660
+ async getNodeBindings(options) {
8661
+ return Object.fromEntries(
8662
+ Object.keys(options.workflows ?? {}).map((bindingName) => [
8663
+ bindingName,
8664
+ new ProxyNodeBinding()
8665
+ ])
8666
+ );
8667
+ },
8668
+ async getServices({ options, sharedOptions, tmpPath }) {
8669
+ const persistPath = getPersistPath(
8670
+ WORKFLOWS_PLUGIN_NAME,
8671
+ tmpPath,
8672
+ sharedOptions.workflowsPersist
8673
+ );
8674
+ await import_promises12.default.mkdir(persistPath, { recursive: true });
8675
+ const storageServices = Object.entries(
8676
+ options.workflows ?? {}
8677
+ ).map(([_, workflow]) => ({
8678
+ name: `${WORKFLOWS_STORAGE_SERVICE_NAME}-${workflow.name}`,
8679
+ disk: { path: persistPath, writable: true }
8680
+ }));
8681
+ const services = Object.entries(options.workflows ?? {}).map(
8682
+ ([_bindingName, workflow]) => {
8683
+ const uniqueKey = `miniflare-workflows-${workflow.name}`;
8684
+ const workflowsBinding = {
8685
+ name: `${WORKFLOWS_PLUGIN_NAME}:${workflow.name}`,
8686
+ worker: {
8687
+ compatibilityDate: "2024-10-22",
8688
+ modules: [
8689
+ {
8690
+ name: "workflows.mjs",
8691
+ esModule: binding_worker_default()
8692
+ }
8693
+ ],
8694
+ durableObjectNamespaces: [
8695
+ {
8696
+ className: "Engine",
8697
+ enableSql: true,
8698
+ uniqueKey,
8699
+ preventEviction: true
8700
+ }
8701
+ ],
8702
+ durableObjectStorage: {
8703
+ localDisk: `${WORKFLOWS_STORAGE_SERVICE_NAME}-${workflow.name}`
8704
+ },
8705
+ bindings: [
8706
+ {
8707
+ name: "ENGINE",
8708
+ durableObjectNamespace: { className: "Engine" }
8709
+ },
8710
+ {
8711
+ name: "USER_WORKFLOW",
8712
+ service: {
8713
+ name: getUserServiceName(workflow.scriptName),
8714
+ entrypoint: workflow.className
8715
+ }
8716
+ }
8717
+ ]
8718
+ }
8719
+ };
8720
+ return workflowsBinding;
8721
+ }
8722
+ );
8723
+ if (services.length === 0) {
8724
+ return [];
8725
+ }
8726
+ return [...storageServices, ...services];
8727
+ },
8728
+ getPersistPath({ workflowsPersist }, tmpPath) {
8729
+ return getPersistPath(WORKFLOWS_PLUGIN_NAME, tmpPath, workflowsPersist);
8730
+ }
8731
+ };
8732
+
8603
8733
  // src/plugins/index.ts
8604
8734
  var PLUGINS = {
8605
8735
  [CORE_PLUGIN_NAME2]: CORE_PLUGIN,
@@ -8611,7 +8741,8 @@ var PLUGINS = {
8611
8741
  [R2_PLUGIN_NAME]: R2_PLUGIN,
8612
8742
  [HYPERDRIVE_PLUGIN_NAME]: HYPERDRIVE_PLUGIN,
8613
8743
  [RATELIMIT_PLUGIN_NAME]: RATELIMIT_PLUGIN,
8614
- [ASSETS_PLUGIN_NAME]: ASSETS_PLUGIN
8744
+ [ASSETS_PLUGIN_NAME]: ASSETS_PLUGIN,
8745
+ [WORKFLOWS_PLUGIN_NAME]: WORKFLOWS_PLUGIN
8615
8746
  };
8616
8747
  var PLUGIN_ENTRIES = Object.entries(PLUGINS);
8617
8748
 
@@ -8717,8 +8848,8 @@ function hasMultipleDistinctMessages(issues, atDepth) {
8717
8848
  }
8718
8849
  return false;
8719
8850
  }
8720
- function annotate(groupCounts, annotated, input, issue, path27, groupId) {
8721
- if (path27.length === 0) {
8851
+ function annotate(groupCounts, annotated, input, issue, path28, groupId) {
8852
+ if (path28.length === 0) {
8722
8853
  if (issue.code === "invalid_union") {
8723
8854
  const unionIssues = issue.unionErrors.flatMap(({ issues }) => issues);
8724
8855
  let newGroupId;
@@ -8765,7 +8896,7 @@ function annotate(groupCounts, annotated, input, issue, path27, groupId) {
8765
8896
  [kGroupId]: groupId
8766
8897
  };
8767
8898
  }
8768
- const [head, ...tail] = path27;
8899
+ const [head, ...tail] = path28;
8769
8900
  (0, import_assert11.default)(isRecord(input), "Expected object/array input for nested issue");
8770
8901
  if (annotated === void 0) {
8771
8902
  if (Array.isArray(input)) {
@@ -8975,7 +9106,7 @@ function validateOptions(opts) {
8975
9106
  );
8976
9107
  const sharedRootPath = multipleWorkers ? getRootPath(sharedOpts) : "";
8977
9108
  const workerRootPaths = workerOpts.map(
8978
- (opts2) => import_path25.default.resolve(sharedRootPath, getRootPath(opts2))
9109
+ (opts2) => import_path26.default.resolve(sharedRootPath, getRootPath(opts2))
8979
9110
  );
8980
9111
  try {
8981
9112
  for (const [key, plugin] of PLUGIN_ENTRIES) {
@@ -8991,7 +9122,7 @@ function validateOptions(opts) {
8991
9122
  }
8992
9123
  }
8993
9124
  } catch (e) {
8994
- if (e instanceof import_zod21.z.ZodError) {
9125
+ if (e instanceof import_zod22.z.ZodError) {
8995
9126
  let formatted;
8996
9127
  try {
8997
9128
  formatted = formatZodError(e, opts);
@@ -9403,7 +9534,7 @@ var Miniflare2 = class {
9403
9534
  }
9404
9535
  }
9405
9536
  });
9406
- this.#tmpPath = import_path25.default.join(
9537
+ this.#tmpPath = import_path26.default.join(
9407
9538
  import_os2.default.tmpdir(),
9408
9539
  `miniflare-${import_crypto3.default.randomBytes(16).toString("hex")}`
9409
9540
  );
@@ -9411,7 +9542,7 @@ var Miniflare2 = class {
9411
9542
  this.#removeExitHook = (0, import_exit_hook.default)(() => {
9412
9543
  void this.#runtime?.dispose();
9413
9544
  try {
9414
- import_fs21.default.rmSync(this.#tmpPath, { force: true, recursive: true });
9545
+ import_fs22.default.rmSync(this.#tmpPath, { force: true, recursive: true });
9415
9546
  } catch (e) {
9416
9547
  this.#log.debug(`Unable to remove temporary directory: ${String(e)}`);
9417
9548
  }
@@ -9448,7 +9579,7 @@ var Miniflare2 = class {
9448
9579
  if (!(response instanceof Response)) {
9449
9580
  response = new Response(response.body, response);
9450
9581
  }
9451
- return import_zod21.z.instanceof(Response).parse(response);
9582
+ return import_zod22.z.instanceof(Response).parse(response);
9452
9583
  } catch (e) {
9453
9584
  return new Response(e?.stack ?? e, { status: 500 });
9454
9585
  }
@@ -9473,11 +9604,11 @@ var Miniflare2 = class {
9473
9604
  (0, import_assert12.default)(!Array.isArray(cfBlob));
9474
9605
  const cf = cfBlob ? JSON.parse(cfBlob) : void 0;
9475
9606
  const originalUrl = headers.get(CoreHeaders.ORIGINAL_URL);
9476
- const url17 = new URL(originalUrl ?? req.url ?? "", "http://localhost");
9607
+ const url18 = new URL(originalUrl ?? req.url ?? "", "http://localhost");
9477
9608
  headers.delete(CoreHeaders.ORIGINAL_URL);
9478
9609
  const noBody = req.method === "GET" || req.method === "HEAD";
9479
9610
  const body = noBody ? void 0 : safeReadableStreamFrom(req);
9480
- const request = new Request(url17, {
9611
+ const request = new Request(url18, {
9481
9612
  method: req.method,
9482
9613
  headers,
9483
9614
  body,
@@ -9498,13 +9629,13 @@ var Miniflare2 = class {
9498
9629
  request,
9499
9630
  this
9500
9631
  );
9501
- } else if (url17.pathname === "/core/error") {
9632
+ } else if (url18.pathname === "/core/error") {
9502
9633
  response = await handlePrettyErrorRequest(
9503
9634
  this.#log,
9504
9635
  this.#workerSrcOpts,
9505
9636
  request
9506
9637
  );
9507
- } else if (url17.pathname === "/core/log") {
9638
+ } else if (url18.pathname === "/core/log") {
9508
9639
  const level = parseInt(request.headers.get(SharedHeaders.LOG_LEVEL));
9509
9640
  (0, import_assert12.default)(
9510
9641
  0 /* NONE */ <= level && level <= 5 /* VERBOSE */,
@@ -9639,7 +9770,7 @@ var Miniflare2 = class {
9639
9770
  sockets.push({
9640
9771
  name: SOCKET_ENTRY_LOCAL,
9641
9772
  service: { name: SERVICE_ENTRY },
9642
- http: ENTRY_SOCKET_HTTP_OPTIONS,
9773
+ http: {},
9643
9774
  address: "127.0.0.1:0"
9644
9775
  });
9645
9776
  }
@@ -9654,6 +9785,11 @@ var Miniflare2 = class {
9654
9785
  const workerOpts = allWorkerOpts[i];
9655
9786
  const workerName = workerOpts.core.name ?? "";
9656
9787
  const isModulesWorker = Boolean(workerOpts.core.modules);
9788
+ if (workerOpts.workflows.workflows) {
9789
+ for (const workflow of Object.values(workerOpts.workflows.workflows)) {
9790
+ workflow.scriptName ??= workerOpts.core.name;
9791
+ }
9792
+ }
9657
9793
  const workerBindings = [];
9658
9794
  allWorkerBindings.set(workerName, workerBindings);
9659
9795
  const additionalModules = [];
@@ -9986,11 +10122,11 @@ var Miniflare2 = class {
9986
10122
  (0, import_assert12.default)(this.#runtimeEntryURL !== void 0);
9987
10123
  (0, import_assert12.default)(this.#runtimeDispatcher !== void 0);
9988
10124
  const forward = new Request(input, init2);
9989
- const url17 = new URL(forward.url);
10125
+ const url18 = new URL(forward.url);
9990
10126
  const actualRuntimeOrigin = this.#runtimeEntryURL.origin;
9991
- const userRuntimeOrigin = url17.origin;
9992
- url17.protocol = this.#runtimeEntryURL.protocol;
9993
- url17.host = this.#runtimeEntryURL.host;
10127
+ const userRuntimeOrigin = url18.origin;
10128
+ url18.protocol = this.#runtimeEntryURL.protocol;
10129
+ url18.host = this.#runtimeEntryURL.host;
9994
10130
  if (forward.body !== null && forward.headers.get("Content-Length") === "0") {
9995
10131
  forward.headers.delete("Content-Length");
9996
10132
  }
@@ -10004,7 +10140,7 @@ var Miniflare2 = class {
10004
10140
  );
10005
10141
  const forwardInit = forward;
10006
10142
  forwardInit.dispatcher = dispatcher;
10007
- const response = await fetch3(url17, forwardInit);
10143
+ const response = await fetch3(url18, forwardInit);
10008
10144
  const stack = response.headers.get(CoreHeaders.ERROR_STACK);
10009
10145
  if (response.status === 500 && stack !== null) {
10010
10146
  const caught = JsonErrorSchema.parse(await response.json());
@@ -10154,7 +10290,7 @@ var Miniflare2 = class {
10154
10290
  await this.#proxyClient?.dispose();
10155
10291
  await this.#runtime?.dispose();
10156
10292
  await this.#stopLoopbackServer();
10157
- await import_fs21.default.promises.rm(this.#tmpPath, { force: true, recursive: true });
10293
+ await import_fs22.default.promises.rm(this.#tmpPath, { force: true, recursive: true });
10158
10294
  maybeInstanceRegistry?.delete(this);
10159
10295
  }
10160
10296
  }
@@ -10188,7 +10324,6 @@ var Miniflare2 = class {
10188
10324
  DispatchFetchDispatcher,
10189
10325
  DurableObjectsOptionsSchema,
10190
10326
  DurableObjectsSharedOptionsSchema,
10191
- ENTRY_SOCKET_HTTP_OPTIONS,
10192
10327
  ErrorEvent,
10193
10328
  File,
10194
10329
  FormData,
@@ -10267,10 +10402,15 @@ var Miniflare2 = class {
10267
10402
  TlsOptions_Version,
10268
10403
  TypedEventTarget,
10269
10404
  WORKER_BINDING_SERVICE_LOOPBACK,
10405
+ WORKFLOWS_PLUGIN,
10406
+ WORKFLOWS_PLUGIN_NAME,
10407
+ WORKFLOWS_STORAGE_SERVICE_NAME,
10270
10408
  WaitGroup,
10271
10409
  WebSocket,
10272
10410
  WebSocketPair,
10273
10411
  Worker_Binding_CryptoKey_Usage,
10412
+ WorkflowsOptionsSchema,
10413
+ WorkflowsSharedOptionsSchema,
10274
10414
  __MiniflareFunctionWrapper,
10275
10415
  _enableControlEndpoints,
10276
10416
  _forceColour,