miniflare 0.0.0-48eeff467 → 0.0.0-4e33f2cdc

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.
@@ -58,6 +58,13 @@ export declare class __MiniflareFunctionWrapper {
58
58
 
59
59
  export declare type AnyHeaders = http.IncomingHttpHeaders | string[];
60
60
 
61
+ export declare type AssetReverseMap = {
62
+ [pathHash: string]: {
63
+ filePath: string;
64
+ contentType: string;
65
+ };
66
+ };
67
+
61
68
  export declare const ASSETS_PLUGIN: Plugin<typeof AssetsOptionsSchema>;
62
69
 
63
70
  export declare const AssetsOptionsSchema: z.ZodObject<{
@@ -141,7 +148,19 @@ export declare function base64Encode(value: string): string;
141
148
 
142
149
  export { BodyInit }
143
150
 
144
- export declare const buildAssetsManifest: (dir: string) => Promise<Uint8Array>;
151
+ /**
152
+ * The Asset Manifest and Asset Reverse Map are used to map a request path to an asset.
153
+ * 1. Hash path of request
154
+ * 2. Use this path hash to find the manifest entry
155
+ * 3. Get content hash from manifest entry
156
+ * 4a. In prod, use content hash to get asset from KV
157
+ * 4b. In dev, we fake out the KV store and use the file system instead.
158
+ * Use content hash to get file path from asset reverse map.
159
+ */
160
+ export declare const buildAssetManifest: (dir: string) => Promise<{
161
+ encodedAssetManifest: Uint8Array;
162
+ assetsReverseMap: AssetReverseMap;
163
+ }>;
145
164
 
146
165
  export declare const CACHE_PLUGIN: Plugin<typeof CacheOptionsSchema, typeof CacheSharedOptionsSchema>;
147
166
 
@@ -1347,6 +1366,7 @@ export declare const DURABLE_OBJECTS_PLUGIN_NAME = "do";
1347
1366
  export declare const DURABLE_OBJECTS_STORAGE_SERVICE_NAME = "do:storage";
1348
1367
 
1349
1368
  export declare type DurableObjectClassNames = Map<string, Map<string, {
1369
+ enableSql?: boolean;
1350
1370
  unsafeUniqueKey?: UnsafeUniqueKey;
1351
1371
  unsafePreventEviction?: boolean;
1352
1372
  }>>;
@@ -1355,16 +1375,19 @@ export declare const DurableObjectsOptionsSchema: z.ZodObject<{
1355
1375
  durableObjects: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodObject<{
1356
1376
  className: z.ZodString;
1357
1377
  scriptName: z.ZodOptional<z.ZodString>;
1378
+ useSQLite: z.ZodOptional<z.ZodBoolean>;
1358
1379
  unsafeUniqueKey: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<typeof kUnsafeEphemeralUniqueKey>]>>;
1359
1380
  unsafePreventEviction: z.ZodOptional<z.ZodBoolean>;
1360
1381
  }, "strip", z.ZodTypeAny, {
1361
1382
  className: string;
1362
1383
  scriptName?: string | undefined;
1384
+ useSQLite?: boolean | undefined;
1363
1385
  unsafeUniqueKey?: string | typeof kUnsafeEphemeralUniqueKey | undefined;
1364
1386
  unsafePreventEviction?: boolean | undefined;
1365
1387
  }, {
1366
1388
  className: string;
1367
1389
  scriptName?: string | undefined;
1390
+ useSQLite?: boolean | undefined;
1368
1391
  unsafeUniqueKey?: string | typeof kUnsafeEphemeralUniqueKey | undefined;
1369
1392
  unsafePreventEviction?: boolean | undefined;
1370
1393
  }>]>>>;
@@ -1372,6 +1395,7 @@ export declare const DurableObjectsOptionsSchema: z.ZodObject<{
1372
1395
  durableObjects?: Record<string, string | {
1373
1396
  className: string;
1374
1397
  scriptName?: string | undefined;
1398
+ useSQLite?: boolean | undefined;
1375
1399
  unsafeUniqueKey?: string | typeof kUnsafeEphemeralUniqueKey | undefined;
1376
1400
  unsafePreventEviction?: boolean | undefined;
1377
1401
  }> | undefined;
@@ -1379,6 +1403,7 @@ export declare const DurableObjectsOptionsSchema: z.ZodObject<{
1379
1403
  durableObjects?: Record<string, string | {
1380
1404
  className: string;
1381
1405
  scriptName?: string | undefined;
1406
+ useSQLite?: boolean | undefined;
1382
1407
  unsafeUniqueKey?: string | typeof kUnsafeEphemeralUniqueKey | undefined;
1383
1408
  unsafePreventEviction?: boolean | undefined;
1384
1409
  }> | undefined;
@@ -1667,6 +1692,11 @@ export declare interface LogOptions {
1667
1692
  suffix?: string;
1668
1693
  }
1669
1694
 
1695
+ export declare type ManifestEntry = {
1696
+ pathHash: Uint8Array;
1697
+ contentHash: Uint8Array;
1698
+ };
1699
+
1670
1700
  export declare interface MatcherRegExps {
1671
1701
  include: RegExp[];
1672
1702
  exclude: RegExp[];
@@ -1720,7 +1750,7 @@ export declare class Miniflare {
1720
1750
  export declare class MiniflareCoreError extends MiniflareError<MiniflareCoreErrorCode> {
1721
1751
  }
1722
1752
 
1723
- export declare type MiniflareCoreErrorCode = "ERR_RUNTIME_FAILURE" | "ERR_DISPOSED" | "ERR_MODULE_PARSE" | "ERR_MODULE_STRING_SCRIPT" | "ERR_MODULE_DYNAMIC_SPEC" | "ERR_MODULE_RULE" | "ERR_PERSIST_UNSUPPORTED" | "ERR_PERSIST_REMOTE_UNAUTHENTICATED" | "ERR_PERSIST_REMOTE_UNSUPPORTED" | "ERR_FUTURE_COMPATIBILITY_DATE" | "ERR_NO_WORKERS" | "ERR_VALIDATION" | "ERR_DUPLICATE_NAME" | "ERR_DIFFERENT_UNIQUE_KEYS" | "ERR_DIFFERENT_PREVENT_EVICTION" | "ERR_MULTIPLE_OUTBOUNDS" | "ERR_INVALID_WRAPPED" | "ERR_CYCLIC";
1753
+ export declare type MiniflareCoreErrorCode = "ERR_RUNTIME_FAILURE" | "ERR_DISPOSED" | "ERR_MODULE_PARSE" | "ERR_MODULE_STRING_SCRIPT" | "ERR_MODULE_DYNAMIC_SPEC" | "ERR_MODULE_RULE" | "ERR_PERSIST_UNSUPPORTED" | "ERR_PERSIST_REMOTE_UNAUTHENTICATED" | "ERR_PERSIST_REMOTE_UNSUPPORTED" | "ERR_FUTURE_COMPATIBILITY_DATE" | "ERR_NO_WORKERS" | "ERR_VALIDATION" | "ERR_DUPLICATE_NAME" | "ERR_DIFFERENT_STORAGE_BACKEND" | "ERR_DIFFERENT_UNIQUE_KEYS" | "ERR_DIFFERENT_PREVENT_EVICTION" | "ERR_MULTIPLE_OUTBOUNDS" | "ERR_INVALID_WRAPPED" | "ERR_CYCLIC";
1724
1754
 
1725
1755
  export declare class MiniflareError<Code extends string | number = string | number> extends Error {
1726
1756
  readonly code: Code;
@@ -1800,6 +1830,7 @@ export declare class NoOpLog extends Log {
1800
1830
  export declare function normaliseDurableObject(designator: NonNullable<z.infer<typeof DurableObjectsOptionsSchema>["durableObjects"]>[string]): {
1801
1831
  className: string;
1802
1832
  serviceName?: string;
1833
+ enableSql?: boolean;
1803
1834
  unsafeUniqueKey?: UnsafeUniqueKey;
1804
1835
  unsafePreventEviction?: boolean;
1805
1836
  };
@@ -2974,16 +3005,19 @@ export declare const PLUGINS: {
2974
3005
  durableObjects: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodObject<{
2975
3006
  className: z.ZodString;
2976
3007
  scriptName: z.ZodOptional<z.ZodString>;
3008
+ useSQLite: z.ZodOptional<z.ZodBoolean>;
2977
3009
  unsafeUniqueKey: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<kUnsafeEphemeralUniqueKey>]>>;
2978
3010
  unsafePreventEviction: z.ZodOptional<z.ZodBoolean>;
2979
3011
  }, "strip", z.ZodTypeAny, {
2980
3012
  className: string;
2981
3013
  scriptName?: string | undefined;
3014
+ useSQLite?: boolean | undefined;
2982
3015
  unsafeUniqueKey?: string | kUnsafeEphemeralUniqueKey | undefined;
2983
3016
  unsafePreventEviction?: boolean | undefined;
2984
3017
  }, {
2985
3018
  className: string;
2986
3019
  scriptName?: string | undefined;
3020
+ useSQLite?: boolean | undefined;
2987
3021
  unsafeUniqueKey?: string | kUnsafeEphemeralUniqueKey | undefined;
2988
3022
  unsafePreventEviction?: boolean | undefined;
2989
3023
  }>]>>>;
@@ -2991,6 +3025,7 @@ export declare const PLUGINS: {
2991
3025
  durableObjects?: Record<string, string | {
2992
3026
  className: string;
2993
3027
  scriptName?: string | undefined;
3028
+ useSQLite?: boolean | undefined;
2994
3029
  unsafeUniqueKey?: string | kUnsafeEphemeralUniqueKey | undefined;
2995
3030
  unsafePreventEviction?: boolean | undefined;
2996
3031
  }> | undefined;
@@ -2998,6 +3033,7 @@ export declare const PLUGINS: {
2998
3033
  durableObjects?: Record<string, string | {
2999
3034
  className: string;
3000
3035
  scriptName?: string | undefined;
3036
+ useSQLite?: boolean | undefined;
3001
3037
  unsafeUniqueKey?: string | kUnsafeEphemeralUniqueKey | undefined;
3002
3038
  unsafePreventEviction?: boolean | undefined;
3003
3039
  }> | undefined;
@@ -4174,6 +4210,7 @@ export declare interface Worker_Binding_WrappedBinding {
4174
4210
  export declare type Worker_DurableObjectNamespace = {
4175
4211
  className?: string;
4176
4212
  preventEviction?: boolean;
4213
+ enableSql?: boolean;
4177
4214
  } & ({
4178
4215
  uniqueKey?: string;
4179
4216
  } | {
package/dist/src/index.js CHANGED
@@ -669,6 +669,24 @@ var require_workerd_capnp = __commonJS({
669
669
  capnp_ts_1.Struct.setUint16(0, 8, this);
670
670
  capnp_ts_1.Struct.setText(1, value, this);
671
671
  }
672
+ adoptNamedExports(value) {
673
+ capnp_ts_1.Struct.adopt(value, capnp_ts_1.Struct.getPointer(2, this));
674
+ }
675
+ disownNamedExports() {
676
+ return capnp_ts_1.Struct.disown(this.getNamedExports());
677
+ }
678
+ getNamedExports() {
679
+ return capnp_ts_1.Struct.getList(2, capnp.TextList, this);
680
+ }
681
+ hasNamedExports() {
682
+ return !capnp_ts_1.Struct.isNull(capnp_ts_1.Struct.getPointer(2, this));
683
+ }
684
+ initNamedExports(length) {
685
+ return capnp_ts_1.Struct.initList(2, capnp.TextList, length, this);
686
+ }
687
+ setNamedExports(value) {
688
+ capnp_ts_1.Struct.copyFrom(value, capnp_ts_1.Struct.getPointer(2, this));
689
+ }
672
690
  toString() {
673
691
  return "Worker_Module_" + super.toString();
674
692
  }
@@ -686,7 +704,7 @@ var require_workerd_capnp = __commonJS({
686
704
  Worker_Module3.NODE_JS_COMPAT_MODULE = Worker_Module_Which.NODE_JS_COMPAT_MODULE;
687
705
  Worker_Module3.PYTHON_MODULE = Worker_Module_Which.PYTHON_MODULE;
688
706
  Worker_Module3.PYTHON_REQUIREMENT = Worker_Module_Which.PYTHON_REQUIREMENT;
689
- Worker_Module3._capnp = { displayName: "Module", id: "d9d87a63770a12f3", size: new capnp_ts_1.ObjectSize(8, 2) };
707
+ Worker_Module3._capnp = { displayName: "Module", id: "d9d87a63770a12f3", size: new capnp_ts_1.ObjectSize(8, 3) };
690
708
  var Worker_Binding_Type_Which;
691
709
  (function(Worker_Binding_Type_Which2) {
692
710
  Worker_Binding_Type_Which2[Worker_Binding_Type_Which2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
@@ -1668,6 +1686,12 @@ var require_workerd_capnp = __commonJS({
1668
1686
  setPreventEviction(value) {
1669
1687
  capnp_ts_1.Struct.setBit(16, value, this);
1670
1688
  }
1689
+ getEnableSql() {
1690
+ return capnp_ts_1.Struct.getBit(17, this);
1691
+ }
1692
+ setEnableSql(value) {
1693
+ capnp_ts_1.Struct.setBit(17, value, this);
1694
+ }
1671
1695
  toString() {
1672
1696
  return "Worker_DurableObjectNamespace_" + super.toString();
1673
1697
  }
@@ -2523,7 +2547,7 @@ __export(src_exports, {
2523
2547
  _transformsForContentEncodingAndContentType: () => _transformsForContentEncodingAndContentType,
2524
2548
  base64Decode: () => base64Decode,
2525
2549
  base64Encode: () => base64Encode,
2526
- buildAssetsManifest: () => buildAssetsManifest,
2550
+ buildAssetManifest: () => buildAssetManifest,
2527
2551
  compileModuleRules: () => compileModuleRules,
2528
2552
  coupleWebSocket: () => coupleWebSocket,
2529
2553
  createFetchMock: () => createFetchMock,
@@ -4563,7 +4587,7 @@ var import_undici4 = require("undici");
4563
4587
  // src/plugins/assets/index.ts
4564
4588
  var import_node_crypto = __toESM(require("node:crypto"));
4565
4589
  var import_promises7 = __toESM(require("node:fs/promises"));
4566
- var import_node_path = __toESM(require("node:path"));
4590
+ var import_node_path2 = __toESM(require("node:path"));
4567
4591
 
4568
4592
  // ../workers-shared/utils/constants.ts
4569
4593
  var HEADER_SIZE = 20;
@@ -4592,10 +4616,13 @@ var AssetConfigSchema = import_zod4.z.object({
4592
4616
  });
4593
4617
 
4594
4618
  // ../workers-shared/utils/helpers.ts
4619
+ var import_node_path = require("node:path");
4595
4620
  var import_mime = __toESM(require_mime());
4596
- var encodeFilePath = (filePath, sep) => {
4597
- const encodedPath = filePath.split(sep).map((segment) => encodeURIComponent(segment)).join("/");
4598
- return "/" + encodedPath;
4621
+ var normalizeFilePath = (relativeFilepath) => {
4622
+ if ((0, import_node_path.isAbsolute)(relativeFilepath)) {
4623
+ throw new Error(`Expected relative path`);
4624
+ }
4625
+ return "/" + relativeFilepath.split(import_node_path.sep).join("/");
4599
4626
  };
4600
4627
  var getContentType = (absFilePath) => {
4601
4628
  let contentType = (0, import_mime.getType)(absFilePath) || "application/octet-stream";
@@ -5337,6 +5364,7 @@ var DurableObjectsOptionsSchema = import_zod8.z.object({
5337
5364
  import_zod8.z.object({
5338
5365
  className: import_zod8.z.string(),
5339
5366
  scriptName: import_zod8.z.string().optional(),
5367
+ useSQLite: import_zod8.z.boolean().optional(),
5340
5368
  // Allow `uniqueKey` to be customised. We use in Wrangler when setting
5341
5369
  // up stub Durable Objects that proxy requests to Durable Objects in
5342
5370
  // another `workerd` process, to ensure the IDs created by the stub
@@ -5355,9 +5383,16 @@ function normaliseDurableObject(designator) {
5355
5383
  const isObject = typeof designator === "object";
5356
5384
  const className = isObject ? designator.className : designator;
5357
5385
  const serviceName = isObject && designator.scriptName !== void 0 ? getUserServiceName(designator.scriptName) : void 0;
5386
+ const enableSql = isObject ? designator.useSQLite : void 0;
5358
5387
  const unsafeUniqueKey = isObject ? designator.unsafeUniqueKey : void 0;
5359
5388
  const unsafePreventEviction = isObject ? designator.unsafePreventEviction : void 0;
5360
- return { className, serviceName, unsafeUniqueKey, unsafePreventEviction };
5389
+ return {
5390
+ className,
5391
+ serviceName,
5392
+ enableSql,
5393
+ unsafeUniqueKey,
5394
+ unsafePreventEviction
5395
+ };
5361
5396
  }
5362
5397
  var DURABLE_OBJECTS_PLUGIN_NAME = "do";
5363
5398
  var DURABLE_OBJECTS_STORAGE_SERVICE_NAME = `${DURABLE_OBJECTS_PLUGIN_NAME}:storage`;
@@ -7218,16 +7253,21 @@ Ensure ${stringName} doesn't include unbundled \`import\`s.`
7218
7253
  compatibilityFlags: options.compatibilityFlags,
7219
7254
  bindings: workerBindings,
7220
7255
  durableObjectNamespaces: classNamesEntries.map(
7221
- ([className, { unsafeUniqueKey, unsafePreventEviction }]) => {
7256
+ ([
7257
+ className,
7258
+ { enableSql, unsafeUniqueKey, unsafePreventEviction }
7259
+ ]) => {
7222
7260
  if (unsafeUniqueKey === kUnsafeEphemeralUniqueKey) {
7223
7261
  return {
7224
7262
  className,
7263
+ enableSql,
7225
7264
  ephemeralLocal: kVoid,
7226
7265
  preventEviction: unsafePreventEviction
7227
7266
  };
7228
7267
  } else {
7229
7268
  return {
7230
7269
  className,
7270
+ enableSql,
7231
7271
  // This `uniqueKey` will (among other things) be used as part of the
7232
7272
  // path when persisting to the file-system. `-` is invalid in
7233
7273
  // JavaScript class names, but safe on filesystems (incl. Windows).
@@ -7462,12 +7502,14 @@ var ASSETS_PLUGIN = {
7462
7502
  if (!options.assets) {
7463
7503
  return [];
7464
7504
  }
7465
- const assetsReverseMap = await createReverseMap(options.assets?.path);
7466
7505
  const storageServiceName = `${ASSETS_PLUGIN_NAME}:storage`;
7467
7506
  const storageService = {
7468
7507
  name: storageServiceName,
7469
7508
  disk: { path: options.assets.path, writable: true }
7470
7509
  };
7510
+ const { encodedAssetManifest, assetsReverseMap } = await buildAssetManifest(
7511
+ options.assets.path
7512
+ );
7471
7513
  const namespaceService = {
7472
7514
  name: ASSETS_KV_SERVICE_NAME,
7473
7515
  worker: {
@@ -7486,12 +7528,11 @@ var ASSETS_PLUGIN = {
7486
7528
  },
7487
7529
  {
7488
7530
  name: "ASSETS_REVERSE_MAP",
7489
- json: assetsReverseMap
7531
+ json: JSON.stringify(assetsReverseMap)
7490
7532
  }
7491
7533
  ]
7492
7534
  }
7493
7535
  };
7494
- const assetsManifest = await buildAssetsManifest(options.assets.path);
7495
7536
  const assetService = {
7496
7537
  name: ASSETS_SERVICE_NAME,
7497
7538
  worker: {
@@ -7509,7 +7550,7 @@ var ASSETS_PLUGIN = {
7509
7550
  },
7510
7551
  {
7511
7552
  name: "ASSETS_MANIFEST",
7512
- data: assetsManifest
7553
+ data: encodedAssetManifest
7513
7554
  },
7514
7555
  {
7515
7556
  name: "CONFIG",
@@ -7547,20 +7588,21 @@ var ASSETS_PLUGIN = {
7547
7588
  return [storageService, namespaceService, assetService, routerService];
7548
7589
  }
7549
7590
  };
7550
- var buildAssetsManifest = async (dir) => {
7551
- const manifest = await walk(dir);
7591
+ var buildAssetManifest = async (dir) => {
7592
+ const { manifest, assetsReverseMap } = await walk(dir);
7552
7593
  const sortedAssetManifest = sortManifest(manifest);
7553
7594
  const encodedAssetManifest = encodeManifest(sortedAssetManifest);
7554
- return encodedAssetManifest;
7595
+ return { encodedAssetManifest, assetsReverseMap };
7555
7596
  };
7556
7597
  var walk = async (dir) => {
7557
7598
  const files = await import_promises7.default.readdir(dir, { recursive: true });
7558
7599
  const manifest = [];
7600
+ const assetsReverseMap = {};
7559
7601
  let counter = 0;
7560
7602
  await Promise.all(
7561
7603
  files.map(async (file) => {
7562
- const filepath = import_node_path.default.join(dir, file);
7563
- const relativeFilepath = import_node_path.default.relative(dir, filepath);
7604
+ const filepath = import_node_path2.default.join(dir, file);
7605
+ const relativeFilepath = import_node_path2.default.relative(dir, filepath);
7564
7606
  const filestat = await import_promises7.default.stat(filepath);
7565
7607
  if (filestat.isSymbolicLink() || filestat.isDirectory()) {
7566
7608
  return;
@@ -7582,9 +7624,19 @@ Cloudflare Workers supports assets with sizes of up to ${prettyBytes(
7582
7624
  Ensure all assets in your assets directory "${dir}" conform with the Workers maximum size requirement.`
7583
7625
  );
7584
7626
  }
7585
- manifest.push(
7586
- await hashPath(encodeFilePath(relativeFilepath, import_node_path.default.sep))
7587
- );
7627
+ const [pathHash, contentHash] = await Promise.all([
7628
+ hashPath(normalizeFilePath(relativeFilepath)),
7629
+ // used absolute filepath here so that changes to the enclosing asset folder will be registered
7630
+ hashPath(filepath + filestat.mtimeMs.toString())
7631
+ ]);
7632
+ manifest.push({
7633
+ pathHash,
7634
+ contentHash
7635
+ });
7636
+ assetsReverseMap[bytesToHex(contentHash)] = {
7637
+ filePath: relativeFilepath,
7638
+ contentType: getContentType(filepath)
7639
+ };
7588
7640
  counter++;
7589
7641
  }
7590
7642
  })
@@ -7596,23 +7648,23 @@ Cloudflare Workers supports up to ${MAX_ASSET_COUNT.toLocaleString()} assets in
7596
7648
  Ensure your assets directory contains a maximum of ${MAX_ASSET_COUNT.toLocaleString()} files, and that you have specified your assets directory correctly.`
7597
7649
  );
7598
7650
  }
7599
- return manifest;
7651
+ return { manifest, assetsReverseMap };
7600
7652
  };
7601
7653
  var sortManifest = (manifest) => {
7602
7654
  return manifest.sort(comparisonFn);
7603
7655
  };
7604
7656
  var comparisonFn = (a, b) => {
7605
- if (a.length < b.length) {
7657
+ if (a.pathHash.length < b.pathHash.length) {
7606
7658
  return -1;
7607
7659
  }
7608
- if (a.length > b.length) {
7660
+ if (a.pathHash.length > b.pathHash.length) {
7609
7661
  return 1;
7610
7662
  }
7611
- for (const [i, v] of a.entries()) {
7612
- if (v < b[i]) {
7663
+ for (const [i, v] of a.pathHash.entries()) {
7664
+ if (v < b.pathHash[i]) {
7613
7665
  return -1;
7614
7666
  }
7615
- if (v > b[i]) {
7667
+ if (v > b.pathHash[i]) {
7616
7668
  return 1;
7617
7669
  }
7618
7670
  }
@@ -7624,34 +7676,14 @@ var encodeManifest = (manifest) => {
7624
7676
  );
7625
7677
  for (const [i, entry] of manifest.entries()) {
7626
7678
  const entryOffset = HEADER_SIZE + i * ENTRY_SIZE;
7627
- assetManifestBytes.set(entry, entryOffset + PATH_HASH_OFFSET);
7628
- assetManifestBytes.set(entry, entryOffset + CONTENT_HASH_OFFSET);
7679
+ assetManifestBytes.set(entry.pathHash, entryOffset + PATH_HASH_OFFSET);
7680
+ assetManifestBytes.set(
7681
+ entry.contentHash,
7682
+ entryOffset + CONTENT_HASH_OFFSET
7683
+ );
7629
7684
  }
7630
7685
  return assetManifestBytes;
7631
7686
  };
7632
- var createReverseMap = async (dir) => {
7633
- const files = await import_promises7.default.readdir(dir, { recursive: true });
7634
- const assetsReverseMap = {};
7635
- await Promise.all(
7636
- files.map(async (file) => {
7637
- const filepath = import_node_path.default.join(dir, file);
7638
- const relativeFilepath = import_node_path.default.relative(dir, filepath);
7639
- const filestat = await import_promises7.default.stat(filepath);
7640
- if (filestat.isSymbolicLink() || filestat.isDirectory()) {
7641
- return;
7642
- } else {
7643
- const pathHash = bytesToHex(
7644
- await hashPath(encodeFilePath(relativeFilepath, import_node_path.default.sep))
7645
- );
7646
- assetsReverseMap[pathHash] = {
7647
- filePath: relativeFilepath,
7648
- contentType: getContentType(filepath)
7649
- };
7650
- }
7651
- })
7652
- );
7653
- return JSON.stringify(assetsReverseMap);
7654
- };
7655
7687
  var bytesToHex = (buffer) => {
7656
7688
  return [...new Uint8Array(buffer)].map((b) => b.toString(16).padStart(2, "0")).join("");
7657
7689
  };
@@ -8953,6 +8985,7 @@ function getDurableObjectClassNames(allWorkerOpts) {
8953
8985
  className,
8954
8986
  // Fallback to current worker service if name not defined
8955
8987
  serviceName = workerServiceName,
8988
+ enableSql,
8956
8989
  unsafeUniqueKey,
8957
8990
  unsafePreventEviction
8958
8991
  } = normaliseDurableObject(designator);
@@ -8963,6 +8996,14 @@ function getDurableObjectClassNames(allWorkerOpts) {
8963
8996
  }
8964
8997
  if (classNames.has(className)) {
8965
8998
  const existingInfo = classNames.get(className);
8999
+ if (existingInfo?.enableSql !== enableSql) {
9000
+ throw new MiniflareCoreError(
9001
+ "ERR_DIFFERENT_STORAGE_BACKEND",
9002
+ `Different storage backends defined for Durable Object "${className}" in "${serviceName}": ${JSON.stringify(
9003
+ enableSql
9004
+ )} and ${JSON.stringify(existingInfo?.enableSql)}`
9005
+ );
9006
+ }
8966
9007
  if (existingInfo?.unsafeUniqueKey !== unsafeUniqueKey) {
8967
9008
  throw new MiniflareCoreError(
8968
9009
  "ERR_DIFFERENT_UNIQUE_KEYS",
@@ -8980,7 +9021,11 @@ function getDurableObjectClassNames(allWorkerOpts) {
8980
9021
  );
8981
9022
  }
8982
9023
  } else {
8983
- classNames.set(className, { unsafeUniqueKey, unsafePreventEviction });
9024
+ classNames.set(className, {
9025
+ enableSql,
9026
+ unsafeUniqueKey,
9027
+ unsafePreventEviction
9028
+ });
8984
9029
  }
8985
9030
  }
8986
9031
  }
@@ -9034,8 +9079,15 @@ function getQueueProducers(allWorkerOpts) {
9034
9079
  ])
9035
9080
  );
9036
9081
  }
9037
- for (const [bindingName, opts] of Object.entries(workerProducers)) {
9038
- queueProducers.set(bindingName, { workerName, ...opts });
9082
+ const producersIterable = Object.entries(
9083
+ workerProducers
9084
+ );
9085
+ for (const [bindingName, opts] of producersIterable) {
9086
+ if (typeof opts === "string") {
9087
+ queueProducers.set(bindingName, { workerName, queueName: opts });
9088
+ } else {
9089
+ queueProducers.set(bindingName, { workerName, ...opts });
9090
+ }
9039
9091
  }
9040
9092
  }
9041
9093
  }
@@ -9316,7 +9368,10 @@ var Miniflare2 = class {
9316
9368
  }
9317
9369
  (0, import_assert12.default)(typeof service === "function");
9318
9370
  try {
9319
- const response = await service(request, this);
9371
+ let response = await service(request, this);
9372
+ if (!(response instanceof Response)) {
9373
+ response = new Response(response.body, response);
9374
+ }
9320
9375
  return import_zod21.z.instanceof(Response).parse(response);
9321
9376
  } catch (e) {
9322
9377
  return new Response(e?.stack ?? e, { status: 500 });
@@ -10142,7 +10197,7 @@ var Miniflare2 = class {
10142
10197
  _transformsForContentEncodingAndContentType,
10143
10198
  base64Decode,
10144
10199
  base64Encode,
10145
- buildAssetsManifest,
10200
+ buildAssetManifest,
10146
10201
  compileModuleRules,
10147
10202
  coupleWebSocket,
10148
10203
  createFetchMock,