miniflare 0.0.0-e2214012f → 0.0.0-e2f5756c2

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.
@@ -74,20 +74,26 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
74
74
  binding: z.ZodOptional<z.ZodString>;
75
75
  routingConfig: z.ZodOptional<z.ZodObject<{
76
76
  has_user_worker: z.ZodOptional<z.ZodBoolean>;
77
+ invoke_user_worker_ahead_of_assets: z.ZodOptional<z.ZodBoolean>;
77
78
  }, "strip", z.ZodTypeAny, {
78
79
  has_user_worker?: boolean;
80
+ invoke_user_worker_ahead_of_assets?: boolean;
79
81
  }, {
80
82
  has_user_worker?: boolean;
83
+ invoke_user_worker_ahead_of_assets?: boolean;
81
84
  }>>;
82
85
  assetConfig: z.ZodOptional<z.ZodObject<{
83
86
  html_handling: z.ZodOptional<z.ZodEnum<["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]>>;
84
87
  not_found_handling: z.ZodOptional<z.ZodEnum<["single-page-application", "404-page", "none"]>>;
88
+ serve_directly: z.ZodOptional<z.ZodBoolean>;
85
89
  }, "strip", z.ZodTypeAny, {
86
90
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
87
91
  not_found_handling?: "none" | "single-page-application" | "404-page";
92
+ serve_directly?: boolean;
88
93
  }, {
89
94
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
90
95
  not_found_handling?: "none" | "single-page-application" | "404-page";
96
+ serve_directly?: boolean;
91
97
  }>>;
92
98
  }, "strip", z.ZodTypeAny, {
93
99
  directory: string;
@@ -95,10 +101,12 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
95
101
  binding?: string | undefined;
96
102
  routingConfig?: {
97
103
  has_user_worker?: boolean;
104
+ invoke_user_worker_ahead_of_assets?: boolean;
98
105
  } | undefined;
99
106
  assetConfig?: {
100
107
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
101
108
  not_found_handling?: "none" | "single-page-application" | "404-page";
109
+ serve_directly?: boolean;
102
110
  } | undefined;
103
111
  }, {
104
112
  directory: string;
@@ -106,10 +114,12 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
106
114
  binding?: string | undefined;
107
115
  routingConfig?: {
108
116
  has_user_worker?: boolean;
117
+ invoke_user_worker_ahead_of_assets?: boolean;
109
118
  } | undefined;
110
119
  assetConfig?: {
111
120
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
112
121
  not_found_handling?: "none" | "single-page-application" | "404-page";
122
+ serve_directly?: boolean;
113
123
  } | undefined;
114
124
  }>>;
115
125
  }, "strip", z.ZodTypeAny, {
@@ -119,10 +129,12 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
119
129
  binding?: string | undefined;
120
130
  routingConfig?: {
121
131
  has_user_worker?: boolean;
132
+ invoke_user_worker_ahead_of_assets?: boolean;
122
133
  } | undefined;
123
134
  assetConfig?: {
124
135
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
125
136
  not_found_handling?: "none" | "single-page-application" | "404-page";
137
+ serve_directly?: boolean;
126
138
  } | undefined;
127
139
  } | undefined;
128
140
  }, {
@@ -132,10 +144,12 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
132
144
  binding?: string | undefined;
133
145
  routingConfig?: {
134
146
  has_user_worker?: boolean;
147
+ invoke_user_worker_ahead_of_assets?: boolean;
135
148
  } | undefined;
136
149
  assetConfig?: {
137
150
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
138
151
  not_found_handling?: "none" | "single-page-application" | "404-page";
152
+ serve_directly?: boolean;
139
153
  } | undefined;
140
154
  } | undefined;
141
155
  }>;
@@ -1431,8 +1445,6 @@ export declare const DurableObjectsSharedOptionsSchema: z.ZodObject<{
1431
1445
 
1432
1446
  export declare function encodeSitesKey(key: string): string;
1433
1447
 
1434
- export declare const ENTRY_SOCKET_HTTP_OPTIONS: HttpOptions;
1435
-
1436
1448
  export declare class ErrorEvent extends Event {
1437
1449
  readonly error: Error | null;
1438
1450
  constructor(type: "error", init?: {
@@ -3259,20 +3271,26 @@ export declare const PLUGINS: {
3259
3271
  binding: z.ZodOptional<z.ZodString>;
3260
3272
  routingConfig: z.ZodOptional<z.ZodObject<{
3261
3273
  has_user_worker: z.ZodOptional<z.ZodBoolean>;
3274
+ invoke_user_worker_ahead_of_assets: z.ZodOptional<z.ZodBoolean>;
3262
3275
  }, "strip", z.ZodTypeAny, {
3263
3276
  has_user_worker?: boolean;
3277
+ invoke_user_worker_ahead_of_assets?: boolean;
3264
3278
  }, {
3265
3279
  has_user_worker?: boolean;
3280
+ invoke_user_worker_ahead_of_assets?: boolean;
3266
3281
  }>>;
3267
3282
  assetConfig: z.ZodOptional<z.ZodObject<{
3268
3283
  html_handling: z.ZodOptional<z.ZodEnum<["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]>>;
3269
3284
  not_found_handling: z.ZodOptional<z.ZodEnum<["single-page-application", "404-page", "none"]>>;
3285
+ serve_directly: z.ZodOptional<z.ZodBoolean>;
3270
3286
  }, "strip", z.ZodTypeAny, {
3271
3287
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3272
3288
  not_found_handling?: "none" | "single-page-application" | "404-page";
3289
+ serve_directly?: boolean;
3273
3290
  }, {
3274
3291
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3275
3292
  not_found_handling?: "none" | "single-page-application" | "404-page";
3293
+ serve_directly?: boolean;
3276
3294
  }>>;
3277
3295
  }, "strip", z.ZodTypeAny, {
3278
3296
  directory: string;
@@ -3280,10 +3298,12 @@ export declare const PLUGINS: {
3280
3298
  binding?: string | undefined;
3281
3299
  routingConfig?: {
3282
3300
  has_user_worker?: boolean;
3301
+ invoke_user_worker_ahead_of_assets?: boolean;
3283
3302
  } | undefined;
3284
3303
  assetConfig?: {
3285
3304
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3286
3305
  not_found_handling?: "none" | "single-page-application" | "404-page";
3306
+ serve_directly?: boolean;
3287
3307
  } | undefined;
3288
3308
  }, {
3289
3309
  directory: string;
@@ -3291,10 +3311,12 @@ export declare const PLUGINS: {
3291
3311
  binding?: string | undefined;
3292
3312
  routingConfig?: {
3293
3313
  has_user_worker?: boolean;
3314
+ invoke_user_worker_ahead_of_assets?: boolean;
3294
3315
  } | undefined;
3295
3316
  assetConfig?: {
3296
3317
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3297
3318
  not_found_handling?: "none" | "single-page-application" | "404-page";
3319
+ serve_directly?: boolean;
3298
3320
  } | undefined;
3299
3321
  }>>;
3300
3322
  }, "strip", z.ZodTypeAny, {
@@ -3304,10 +3326,12 @@ export declare const PLUGINS: {
3304
3326
  binding?: string | undefined;
3305
3327
  routingConfig?: {
3306
3328
  has_user_worker?: boolean;
3329
+ invoke_user_worker_ahead_of_assets?: boolean;
3307
3330
  } | undefined;
3308
3331
  assetConfig?: {
3309
3332
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3310
3333
  not_found_handling?: "none" | "single-page-application" | "404-page";
3334
+ serve_directly?: boolean;
3311
3335
  } | undefined;
3312
3336
  } | undefined;
3313
3337
  }, {
@@ -3317,10 +3341,12 @@ export declare const PLUGINS: {
3317
3341
  binding?: string | undefined;
3318
3342
  routingConfig?: {
3319
3343
  has_user_worker?: boolean;
3344
+ invoke_user_worker_ahead_of_assets?: boolean;
3320
3345
  } | undefined;
3321
3346
  assetConfig?: {
3322
3347
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3323
3348
  not_found_handling?: "none" | "single-page-application" | "404-page";
3349
+ serve_directly?: boolean;
3324
3350
  } | undefined;
3325
3351
  } | undefined;
3326
3352
  }>>;
package/dist/src/index.js CHANGED
@@ -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,
@@ -3788,7 +3787,7 @@ var QueueConsumerOptionsSchema = /* @__PURE__ */ import_zod2.z.object({
3788
3787
  // https://developers.cloudflare.com/queues/platform/configuration/#consumer
3789
3788
  // https://developers.cloudflare.com/queues/platform/limits/
3790
3789
  maxBatchSize: import_zod2.z.number().min(0).max(100).optional(),
3791
- maxBatchTimeout: import_zod2.z.number().min(0).max(30).optional(),
3790
+ maxBatchTimeout: import_zod2.z.number().min(0).max(60).optional(),
3792
3791
  // seconds
3793
3792
  maxRetires: import_zod2.z.number().min(0).max(100).optional(),
3794
3793
  // deprecated
@@ -4540,11 +4539,6 @@ ez/dHA==
4540
4539
  `;
4541
4540
 
4542
4541
  // src/http/server.ts
4543
- var ENTRY_SOCKET_HTTP_OPTIONS = {
4544
- // Even though we inject a `cf` object in the entry worker, allow it to
4545
- // be customised via `dispatchFetch`
4546
- cfBlobHeader: CoreHeaders.CF_BLOB
4547
- };
4548
4542
  async function getEntrySocketHttpOptions(coreOpts) {
4549
4543
  let privateKey = void 0;
4550
4544
  let certificateChain = void 0;
@@ -4561,7 +4555,6 @@ async function getEntrySocketHttpOptions(coreOpts) {
4561
4555
  if (privateKey && certificateChain) {
4562
4556
  return {
4563
4557
  https: {
4564
- options: ENTRY_SOCKET_HTTP_OPTIONS,
4565
4558
  tlsOptions: {
4566
4559
  keypair: {
4567
4560
  privateKey,
@@ -4571,7 +4564,7 @@ async function getEntrySocketHttpOptions(coreOpts) {
4571
4564
  }
4572
4565
  };
4573
4566
  } else {
4574
- return { http: ENTRY_SOCKET_HTTP_OPTIONS };
4567
+ return { http: {} };
4575
4568
  }
4576
4569
  }
4577
4570
  function valueOrFile(value, filePath) {
@@ -4616,7 +4609,8 @@ var MAX_ASSET_SIZE = 25 * 1024 * 1024;
4616
4609
  // ../workers-shared/utils/types.ts
4617
4610
  var import_zod4 = require("zod");
4618
4611
  var RoutingConfigSchema = import_zod4.z.object({
4619
- 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()
4620
4614
  });
4621
4615
  var AssetConfigSchema = import_zod4.z.object({
4622
4616
  html_handling: import_zod4.z.enum([
@@ -4625,7 +4619,8 @@ var AssetConfigSchema = import_zod4.z.object({
4625
4619
  "drop-trailing-slash",
4626
4620
  "none"
4627
4621
  ]).optional(),
4628
- 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()
4629
4624
  });
4630
4625
 
4631
4626
  // ../workers-shared/utils/helpers.ts
@@ -4645,7 +4640,7 @@ var getContentType = (absFilePath) => {
4645
4640
  return contentType;
4646
4641
  };
4647
4642
 
4648
- // ../../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
4649
4644
  var BYTE_UNITS = [
4650
4645
  "B",
4651
4646
  "kB",
@@ -4659,7 +4654,7 @@ var BYTE_UNITS = [
4659
4654
  ];
4660
4655
  var BIBYTE_UNITS = [
4661
4656
  "B",
4662
- "kiB",
4657
+ "KiB",
4663
4658
  "MiB",
4664
4659
  "GiB",
4665
4660
  "TiB",
@@ -4706,11 +4701,13 @@ function prettyBytes(number, options) {
4706
4701
  options = {
4707
4702
  bits: false,
4708
4703
  binary: false,
4704
+ space: true,
4709
4705
  ...options
4710
4706
  };
4711
4707
  const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
4708
+ const separator = options.space ? " " : "";
4712
4709
  if (options.signed && number === 0) {
4713
- return ` 0 ${UNITS[0]}`;
4710
+ return ` 0${separator}${UNITS[0]}`;
4714
4711
  }
4715
4712
  const isNegative = number < 0;
4716
4713
  const prefix = isNegative ? "-" : options.signed ? "+" : "";
@@ -4726,7 +4723,7 @@ function prettyBytes(number, options) {
4726
4723
  }
4727
4724
  if (number < 1) {
4728
4725
  const numberString2 = toLocaleString(number, options.locale, localeOptions);
4729
- return prefix + numberString2 + " " + UNITS[0];
4726
+ return prefix + numberString2 + separator + UNITS[0];
4730
4727
  }
4731
4728
  const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
4732
4729
  number /= (options.binary ? 1024 : 1e3) ** exponent;
@@ -4735,7 +4732,7 @@ function prettyBytes(number, options) {
4735
4732
  }
4736
4733
  const numberString = toLocaleString(Number(number), options.locale, localeOptions);
4737
4734
  const unit = UNITS[exponent];
4738
- return prefix + numberString + " " + unit;
4735
+ return prefix + numberString + separator + unit;
4739
4736
  }
4740
4737
 
4741
4738
  // embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/assets/assets.worker.ts
@@ -7085,11 +7082,20 @@ function validateCompatibilityDate(log, compatibilityDate) {
7085
7082
  }
7086
7083
  return compatibilityDate;
7087
7084
  }
7088
- function buildJsonBindings(bindings) {
7089
- return Object.entries(bindings).map(([name, value]) => ({
7090
- name,
7091
- json: JSON.stringify(value)
7092
- }));
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
+ });
7093
7099
  }
7094
7100
  var WRAPPED_MODULE_PREFIX = "miniflare-internal:wrapped:";
7095
7101
  function workerNameToWrappedModule(workerName) {
@@ -7106,7 +7112,7 @@ var CORE_PLUGIN = {
7106
7112
  getBindings(options, workerIndex) {
7107
7113
  const bindings = [];
7108
7114
  if (options.bindings !== void 0) {
7109
- bindings.push(...buildJsonBindings(options.bindings));
7115
+ bindings.push(...buildBindings(options.bindings));
7110
7116
  }
7111
7117
  if (options.wasmBindings !== void 0) {
7112
7118
  bindings.push(
@@ -7155,7 +7161,7 @@ var CORE_PLUGIN = {
7155
7161
  const entrypoint = isObject ? designator.entrypoint : void 0;
7156
7162
  const bindings2 = isObject ? designator.bindings : void 0;
7157
7163
  const moduleName2 = workerNameToWrappedModule(scriptName);
7158
- const innerBindings = bindings2 === void 0 ? [] : buildJsonBindings(bindings2);
7164
+ const innerBindings = bindings2 === void 0 ? [] : buildBindings(bindings2);
7159
7165
  return {
7160
7166
  name,
7161
7167
  wrapped: { moduleName: moduleName2, entrypoint, innerBindings }
@@ -8546,7 +8552,7 @@ var RatelimitOptionsSchema = import_zod19.z.object({
8546
8552
  var RATELIMIT_PLUGIN_NAME = "ratelimit";
8547
8553
  var SERVICE_RATELIMIT_PREFIX = `${RATELIMIT_PLUGIN_NAME}`;
8548
8554
  var SERVICE_RATELIMIT_MODULE = `cloudflare-internal:${SERVICE_RATELIMIT_PREFIX}:module`;
8549
- function buildJsonBindings2(bindings) {
8555
+ function buildJsonBindings(bindings) {
8550
8556
  return Object.entries(bindings).map(([name, value]) => ({
8551
8557
  name,
8552
8558
  json: JSON.stringify(value)
@@ -8563,7 +8569,7 @@ var RATELIMIT_PLUGIN = {
8563
8569
  name,
8564
8570
  wrapped: {
8565
8571
  moduleName: SERVICE_RATELIMIT_MODULE,
8566
- innerBindings: buildJsonBindings2({
8572
+ innerBindings: buildJsonBindings({
8567
8573
  namespaceId: name,
8568
8574
  limit: config.simple.limit,
8569
8575
  period: config.simple.period
@@ -8666,13 +8672,15 @@ var WORKFLOWS_PLUGIN = {
8666
8672
  sharedOptions.workflowsPersist
8667
8673
  );
8668
8674
  await import_promises12.default.mkdir(persistPath, { recursive: true });
8669
- const storageService = {
8670
- name: WORKFLOWS_STORAGE_SERVICE_NAME,
8675
+ const storageServices = Object.entries(
8676
+ options.workflows ?? {}
8677
+ ).map(([_, workflow]) => ({
8678
+ name: `${WORKFLOWS_STORAGE_SERVICE_NAME}-${workflow.name}`,
8671
8679
  disk: { path: persistPath, writable: true }
8672
- };
8680
+ }));
8673
8681
  const services = Object.entries(options.workflows ?? {}).map(
8674
8682
  ([_bindingName, workflow]) => {
8675
- const uniqueKey = `miniflare-workflows`;
8683
+ const uniqueKey = `miniflare-workflows-${workflow.name}`;
8676
8684
  const workflowsBinding = {
8677
8685
  name: `${WORKFLOWS_PLUGIN_NAME}:${workflow.name}`,
8678
8686
  worker: {
@@ -8691,8 +8699,9 @@ var WORKFLOWS_PLUGIN = {
8691
8699
  preventEviction: true
8692
8700
  }
8693
8701
  ],
8694
- // this might conflict between workflows
8695
- durableObjectStorage: { localDisk: WORKFLOWS_STORAGE_SERVICE_NAME },
8702
+ durableObjectStorage: {
8703
+ localDisk: `${WORKFLOWS_STORAGE_SERVICE_NAME}-${workflow.name}`
8704
+ },
8696
8705
  bindings: [
8697
8706
  {
8698
8707
  name: "ENGINE",
@@ -8714,7 +8723,7 @@ var WORKFLOWS_PLUGIN = {
8714
8723
  if (services.length === 0) {
8715
8724
  return [];
8716
8725
  }
8717
- return [storageService, ...services];
8726
+ return [...storageServices, ...services];
8718
8727
  },
8719
8728
  getPersistPath({ workflowsPersist }, tmpPath) {
8720
8729
  return getPersistPath(WORKFLOWS_PLUGIN_NAME, tmpPath, workflowsPersist);
@@ -9761,7 +9770,7 @@ var Miniflare2 = class {
9761
9770
  sockets.push({
9762
9771
  name: SOCKET_ENTRY_LOCAL,
9763
9772
  service: { name: SERVICE_ENTRY },
9764
- http: ENTRY_SOCKET_HTTP_OPTIONS,
9773
+ http: {},
9765
9774
  address: "127.0.0.1:0"
9766
9775
  });
9767
9776
  }
@@ -10315,7 +10324,6 @@ var Miniflare2 = class {
10315
10324
  DispatchFetchDispatcher,
10316
10325
  DurableObjectsOptionsSchema,
10317
10326
  DurableObjectsSharedOptionsSchema,
10318
- ENTRY_SOCKET_HTTP_OPTIONS,
10319
10327
  ErrorEvent,
10320
10328
  File,
10321
10329
  FormData,