miniflare 0.0.0-98944bfb8 → 0.0.0-994121908

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,32 @@ 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>;
78
+ account_id: z.ZodOptional<z.ZodNumber>;
79
+ script_id: z.ZodOptional<z.ZodNumber>;
77
80
  }, "strip", z.ZodTypeAny, {
78
81
  has_user_worker?: boolean;
82
+ invoke_user_worker_ahead_of_assets?: boolean;
83
+ account_id?: number;
84
+ script_id?: number;
79
85
  }, {
80
86
  has_user_worker?: boolean;
87
+ invoke_user_worker_ahead_of_assets?: boolean;
88
+ account_id?: number;
89
+ script_id?: number;
81
90
  }>>;
82
91
  assetConfig: z.ZodOptional<z.ZodObject<{
83
92
  html_handling: z.ZodOptional<z.ZodEnum<["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]>>;
84
93
  not_found_handling: z.ZodOptional<z.ZodEnum<["single-page-application", "404-page", "none"]>>;
94
+ serve_directly: z.ZodOptional<z.ZodBoolean>;
85
95
  }, "strip", z.ZodTypeAny, {
86
96
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
87
97
  not_found_handling?: "none" | "single-page-application" | "404-page";
98
+ serve_directly?: boolean;
88
99
  }, {
89
100
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
90
101
  not_found_handling?: "none" | "single-page-application" | "404-page";
102
+ serve_directly?: boolean;
91
103
  }>>;
92
104
  }, "strip", z.ZodTypeAny, {
93
105
  directory: string;
@@ -95,10 +107,14 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
95
107
  binding?: string | undefined;
96
108
  routingConfig?: {
97
109
  has_user_worker?: boolean;
110
+ invoke_user_worker_ahead_of_assets?: boolean;
111
+ account_id?: number;
112
+ script_id?: number;
98
113
  } | undefined;
99
114
  assetConfig?: {
100
115
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
101
116
  not_found_handling?: "none" | "single-page-application" | "404-page";
117
+ serve_directly?: boolean;
102
118
  } | undefined;
103
119
  }, {
104
120
  directory: string;
@@ -106,10 +122,14 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
106
122
  binding?: string | undefined;
107
123
  routingConfig?: {
108
124
  has_user_worker?: boolean;
125
+ invoke_user_worker_ahead_of_assets?: boolean;
126
+ account_id?: number;
127
+ script_id?: number;
109
128
  } | undefined;
110
129
  assetConfig?: {
111
130
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
112
131
  not_found_handling?: "none" | "single-page-application" | "404-page";
132
+ serve_directly?: boolean;
113
133
  } | undefined;
114
134
  }>>;
115
135
  }, "strip", z.ZodTypeAny, {
@@ -119,10 +139,14 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
119
139
  binding?: string | undefined;
120
140
  routingConfig?: {
121
141
  has_user_worker?: boolean;
142
+ invoke_user_worker_ahead_of_assets?: boolean;
143
+ account_id?: number;
144
+ script_id?: number;
122
145
  } | undefined;
123
146
  assetConfig?: {
124
147
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
125
148
  not_found_handling?: "none" | "single-page-application" | "404-page";
149
+ serve_directly?: boolean;
126
150
  } | undefined;
127
151
  } | undefined;
128
152
  }, {
@@ -132,10 +156,14 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
132
156
  binding?: string | undefined;
133
157
  routingConfig?: {
134
158
  has_user_worker?: boolean;
159
+ invoke_user_worker_ahead_of_assets?: boolean;
160
+ account_id?: number;
161
+ script_id?: number;
135
162
  } | undefined;
136
163
  assetConfig?: {
137
164
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
138
165
  not_found_handling?: "none" | "single-page-application" | "404-page";
166
+ serve_directly?: boolean;
139
167
  } | undefined;
140
168
  } | undefined;
141
169
  }>;
@@ -1431,8 +1459,6 @@ export declare const DurableObjectsSharedOptionsSchema: z.ZodObject<{
1431
1459
 
1432
1460
  export declare function encodeSitesKey(key: string): string;
1433
1461
 
1434
- export declare const ENTRY_SOCKET_HTTP_OPTIONS: HttpOptions;
1435
-
1436
1462
  export declare class ErrorEvent extends Event {
1437
1463
  readonly error: Error | null;
1438
1464
  constructor(type: "error", init?: {
@@ -3259,20 +3285,32 @@ export declare const PLUGINS: {
3259
3285
  binding: z.ZodOptional<z.ZodString>;
3260
3286
  routingConfig: z.ZodOptional<z.ZodObject<{
3261
3287
  has_user_worker: z.ZodOptional<z.ZodBoolean>;
3288
+ invoke_user_worker_ahead_of_assets: z.ZodOptional<z.ZodBoolean>;
3289
+ account_id: z.ZodOptional<z.ZodNumber>;
3290
+ script_id: z.ZodOptional<z.ZodNumber>;
3262
3291
  }, "strip", z.ZodTypeAny, {
3263
3292
  has_user_worker?: boolean;
3293
+ invoke_user_worker_ahead_of_assets?: boolean;
3294
+ account_id?: number;
3295
+ script_id?: number;
3264
3296
  }, {
3265
3297
  has_user_worker?: boolean;
3298
+ invoke_user_worker_ahead_of_assets?: boolean;
3299
+ account_id?: number;
3300
+ script_id?: number;
3266
3301
  }>>;
3267
3302
  assetConfig: z.ZodOptional<z.ZodObject<{
3268
3303
  html_handling: z.ZodOptional<z.ZodEnum<["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]>>;
3269
3304
  not_found_handling: z.ZodOptional<z.ZodEnum<["single-page-application", "404-page", "none"]>>;
3305
+ serve_directly: z.ZodOptional<z.ZodBoolean>;
3270
3306
  }, "strip", z.ZodTypeAny, {
3271
3307
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3272
3308
  not_found_handling?: "none" | "single-page-application" | "404-page";
3309
+ serve_directly?: boolean;
3273
3310
  }, {
3274
3311
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3275
3312
  not_found_handling?: "none" | "single-page-application" | "404-page";
3313
+ serve_directly?: boolean;
3276
3314
  }>>;
3277
3315
  }, "strip", z.ZodTypeAny, {
3278
3316
  directory: string;
@@ -3280,10 +3318,14 @@ export declare const PLUGINS: {
3280
3318
  binding?: string | undefined;
3281
3319
  routingConfig?: {
3282
3320
  has_user_worker?: boolean;
3321
+ invoke_user_worker_ahead_of_assets?: boolean;
3322
+ account_id?: number;
3323
+ script_id?: number;
3283
3324
  } | undefined;
3284
3325
  assetConfig?: {
3285
3326
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3286
3327
  not_found_handling?: "none" | "single-page-application" | "404-page";
3328
+ serve_directly?: boolean;
3287
3329
  } | undefined;
3288
3330
  }, {
3289
3331
  directory: string;
@@ -3291,10 +3333,14 @@ export declare const PLUGINS: {
3291
3333
  binding?: string | undefined;
3292
3334
  routingConfig?: {
3293
3335
  has_user_worker?: boolean;
3336
+ invoke_user_worker_ahead_of_assets?: boolean;
3337
+ account_id?: number;
3338
+ script_id?: number;
3294
3339
  } | undefined;
3295
3340
  assetConfig?: {
3296
3341
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3297
3342
  not_found_handling?: "none" | "single-page-application" | "404-page";
3343
+ serve_directly?: boolean;
3298
3344
  } | undefined;
3299
3345
  }>>;
3300
3346
  }, "strip", z.ZodTypeAny, {
@@ -3304,10 +3350,14 @@ export declare const PLUGINS: {
3304
3350
  binding?: string | undefined;
3305
3351
  routingConfig?: {
3306
3352
  has_user_worker?: boolean;
3353
+ invoke_user_worker_ahead_of_assets?: boolean;
3354
+ account_id?: number;
3355
+ script_id?: number;
3307
3356
  } | undefined;
3308
3357
  assetConfig?: {
3309
3358
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3310
3359
  not_found_handling?: "none" | "single-page-application" | "404-page";
3360
+ serve_directly?: boolean;
3311
3361
  } | undefined;
3312
3362
  } | undefined;
3313
3363
  }, {
@@ -3317,10 +3367,14 @@ export declare const PLUGINS: {
3317
3367
  binding?: string | undefined;
3318
3368
  routingConfig?: {
3319
3369
  has_user_worker?: boolean;
3370
+ invoke_user_worker_ahead_of_assets?: boolean;
3371
+ account_id?: number;
3372
+ script_id?: number;
3320
3373
  } | undefined;
3321
3374
  assetConfig?: {
3322
3375
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
3323
3376
  not_found_handling?: "none" | "single-page-application" | "404-page";
3377
+ serve_directly?: boolean;
3324
3378
  } | undefined;
3325
3379
  } | undefined;
3326
3380
  }>>;
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,11 @@ 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(),
4614
+ // Used for analytics and reporting
4615
+ account_id: import_zod4.z.number().optional(),
4616
+ script_id: import_zod4.z.number().optional()
4620
4617
  });
4621
4618
  var AssetConfigSchema = import_zod4.z.object({
4622
4619
  html_handling: import_zod4.z.enum([
@@ -4625,7 +4622,17 @@ var AssetConfigSchema = import_zod4.z.object({
4625
4622
  "drop-trailing-slash",
4626
4623
  "none"
4627
4624
  ]).optional(),
4628
- not_found_handling: import_zod4.z.enum(["single-page-application", "404-page", "none"]).optional()
4625
+ not_found_handling: import_zod4.z.enum(["single-page-application", "404-page", "none"]).optional(),
4626
+ serve_directly: import_zod4.z.boolean().optional()
4627
+ });
4628
+ var InternalConfigSchema = import_zod4.z.object({
4629
+ // Used for analytics and reporting
4630
+ account_id: import_zod4.z.number().optional(),
4631
+ script_id: import_zod4.z.number().optional()
4632
+ });
4633
+ var AssetWorkerConfigShema = import_zod4.z.object({
4634
+ ...AssetConfigSchema.shape,
4635
+ ...InternalConfigSchema.shape
4629
4636
  });
4630
4637
 
4631
4638
  // ../workers-shared/utils/helpers.ts
@@ -4645,7 +4652,7 @@ var getContentType = (absFilePath) => {
4645
4652
  return contentType;
4646
4653
  };
4647
4654
 
4648
- // ../../node_modules/.pnpm/pretty-bytes@6.0.0/node_modules/pretty-bytes/index.js
4655
+ // ../../node_modules/.pnpm/pretty-bytes@6.1.1/node_modules/pretty-bytes/index.js
4649
4656
  var BYTE_UNITS = [
4650
4657
  "B",
4651
4658
  "kB",
@@ -4659,7 +4666,7 @@ var BYTE_UNITS = [
4659
4666
  ];
4660
4667
  var BIBYTE_UNITS = [
4661
4668
  "B",
4662
- "kiB",
4669
+ "KiB",
4663
4670
  "MiB",
4664
4671
  "GiB",
4665
4672
  "TiB",
@@ -4706,11 +4713,13 @@ function prettyBytes(number, options) {
4706
4713
  options = {
4707
4714
  bits: false,
4708
4715
  binary: false,
4716
+ space: true,
4709
4717
  ...options
4710
4718
  };
4711
4719
  const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
4720
+ const separator = options.space ? " " : "";
4712
4721
  if (options.signed && number === 0) {
4713
- return ` 0 ${UNITS[0]}`;
4722
+ return ` 0${separator}${UNITS[0]}`;
4714
4723
  }
4715
4724
  const isNegative = number < 0;
4716
4725
  const prefix = isNegative ? "-" : options.signed ? "+" : "";
@@ -4726,7 +4735,7 @@ function prettyBytes(number, options) {
4726
4735
  }
4727
4736
  if (number < 1) {
4728
4737
  const numberString2 = toLocaleString(number, options.locale, localeOptions);
4729
- return prefix + numberString2 + " " + UNITS[0];
4738
+ return prefix + numberString2 + separator + UNITS[0];
4730
4739
  }
4731
4740
  const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
4732
4741
  number /= (options.binary ? 1024 : 1e3) ** exponent;
@@ -4735,7 +4744,7 @@ function prettyBytes(number, options) {
4735
4744
  }
4736
4745
  const numberString = toLocaleString(Number(number), options.locale, localeOptions);
4737
4746
  const unit = UNITS[exponent];
4738
- return prefix + numberString + " " + unit;
4747
+ return prefix + numberString + separator + unit;
4739
4748
  }
4740
4749
 
4741
4750
  // embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/assets/assets.worker.ts
@@ -7085,11 +7094,20 @@ function validateCompatibilityDate(log, compatibilityDate) {
7085
7094
  }
7086
7095
  return compatibilityDate;
7087
7096
  }
7088
- function buildJsonBindings(bindings) {
7089
- return Object.entries(bindings).map(([name, value]) => ({
7090
- name,
7091
- json: JSON.stringify(value)
7092
- }));
7097
+ function buildBindings(bindings) {
7098
+ return Object.entries(bindings).map(([name, value]) => {
7099
+ if (typeof value === "string") {
7100
+ return {
7101
+ name,
7102
+ text: value
7103
+ };
7104
+ } else {
7105
+ return {
7106
+ name,
7107
+ json: JSON.stringify(value)
7108
+ };
7109
+ }
7110
+ });
7093
7111
  }
7094
7112
  var WRAPPED_MODULE_PREFIX = "miniflare-internal:wrapped:";
7095
7113
  function workerNameToWrappedModule(workerName) {
@@ -7106,7 +7124,7 @@ var CORE_PLUGIN = {
7106
7124
  getBindings(options, workerIndex) {
7107
7125
  const bindings = [];
7108
7126
  if (options.bindings !== void 0) {
7109
- bindings.push(...buildJsonBindings(options.bindings));
7127
+ bindings.push(...buildBindings(options.bindings));
7110
7128
  }
7111
7129
  if (options.wasmBindings !== void 0) {
7112
7130
  bindings.push(
@@ -7155,7 +7173,7 @@ var CORE_PLUGIN = {
7155
7173
  const entrypoint = isObject ? designator.entrypoint : void 0;
7156
7174
  const bindings2 = isObject ? designator.bindings : void 0;
7157
7175
  const moduleName2 = workerNameToWrappedModule(scriptName);
7158
- const innerBindings = bindings2 === void 0 ? [] : buildJsonBindings(bindings2);
7176
+ const innerBindings = bindings2 === void 0 ? [] : buildBindings(bindings2);
7159
7177
  return {
7160
7178
  name,
7161
7179
  wrapped: { moduleName: moduleName2, entrypoint, innerBindings }
@@ -8546,7 +8564,7 @@ var RatelimitOptionsSchema = import_zod19.z.object({
8546
8564
  var RATELIMIT_PLUGIN_NAME = "ratelimit";
8547
8565
  var SERVICE_RATELIMIT_PREFIX = `${RATELIMIT_PLUGIN_NAME}`;
8548
8566
  var SERVICE_RATELIMIT_MODULE = `cloudflare-internal:${SERVICE_RATELIMIT_PREFIX}:module`;
8549
- function buildJsonBindings2(bindings) {
8567
+ function buildJsonBindings(bindings) {
8550
8568
  return Object.entries(bindings).map(([name, value]) => ({
8551
8569
  name,
8552
8570
  json: JSON.stringify(value)
@@ -8563,7 +8581,7 @@ var RATELIMIT_PLUGIN = {
8563
8581
  name,
8564
8582
  wrapped: {
8565
8583
  moduleName: SERVICE_RATELIMIT_MODULE,
8566
- innerBindings: buildJsonBindings2({
8584
+ innerBindings: buildJsonBindings({
8567
8585
  namespaceId: name,
8568
8586
  limit: config.simple.limit,
8569
8587
  period: config.simple.period
@@ -8666,13 +8684,15 @@ var WORKFLOWS_PLUGIN = {
8666
8684
  sharedOptions.workflowsPersist
8667
8685
  );
8668
8686
  await import_promises12.default.mkdir(persistPath, { recursive: true });
8669
- const storageService = {
8670
- name: WORKFLOWS_STORAGE_SERVICE_NAME,
8687
+ const storageServices = Object.entries(
8688
+ options.workflows ?? {}
8689
+ ).map(([_, workflow]) => ({
8690
+ name: `${WORKFLOWS_STORAGE_SERVICE_NAME}-${workflow.name}`,
8671
8691
  disk: { path: persistPath, writable: true }
8672
- };
8692
+ }));
8673
8693
  const services = Object.entries(options.workflows ?? {}).map(
8674
8694
  ([_bindingName, workflow]) => {
8675
- const uniqueKey = `miniflare-workflows`;
8695
+ const uniqueKey = `miniflare-workflows-${workflow.name}`;
8676
8696
  const workflowsBinding = {
8677
8697
  name: `${WORKFLOWS_PLUGIN_NAME}:${workflow.name}`,
8678
8698
  worker: {
@@ -8691,8 +8711,9 @@ var WORKFLOWS_PLUGIN = {
8691
8711
  preventEviction: true
8692
8712
  }
8693
8713
  ],
8694
- // this might conflict between workflows
8695
- durableObjectStorage: { localDisk: WORKFLOWS_STORAGE_SERVICE_NAME },
8714
+ durableObjectStorage: {
8715
+ localDisk: `${WORKFLOWS_STORAGE_SERVICE_NAME}-${workflow.name}`
8716
+ },
8696
8717
  bindings: [
8697
8718
  {
8698
8719
  name: "ENGINE",
@@ -8714,7 +8735,7 @@ var WORKFLOWS_PLUGIN = {
8714
8735
  if (services.length === 0) {
8715
8736
  return [];
8716
8737
  }
8717
- return [storageService, ...services];
8738
+ return [...storageServices, ...services];
8718
8739
  },
8719
8740
  getPersistPath({ workflowsPersist }, tmpPath) {
8720
8741
  return getPersistPath(WORKFLOWS_PLUGIN_NAME, tmpPath, workflowsPersist);
@@ -9761,7 +9782,7 @@ var Miniflare2 = class {
9761
9782
  sockets.push({
9762
9783
  name: SOCKET_ENTRY_LOCAL,
9763
9784
  service: { name: SERVICE_ENTRY },
9764
- http: ENTRY_SOCKET_HTTP_OPTIONS,
9785
+ http: {},
9765
9786
  address: "127.0.0.1:0"
9766
9787
  });
9767
9788
  }
@@ -10315,7 +10336,6 @@ var Miniflare2 = class {
10315
10336
  DispatchFetchDispatcher,
10316
10337
  DurableObjectsOptionsSchema,
10317
10338
  DurableObjectsSharedOptionsSchema,
10318
- ENTRY_SOCKET_HTTP_OPTIONS,
10319
10339
  ErrorEvent,
10320
10340
  File,
10321
10341
  FormData,