miniflare 0.0.0-e771fe990 → 0.0.0-e7c7235fd

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.
@@ -75,12 +75,18 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
75
75
  routingConfig: z.ZodOptional<z.ZodObject<{
76
76
  has_user_worker: z.ZodOptional<z.ZodBoolean>;
77
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>;
78
80
  }, "strip", z.ZodTypeAny, {
79
81
  has_user_worker?: boolean;
80
82
  invoke_user_worker_ahead_of_assets?: boolean;
83
+ account_id?: number;
84
+ script_id?: number;
81
85
  }, {
82
86
  has_user_worker?: boolean;
83
87
  invoke_user_worker_ahead_of_assets?: boolean;
88
+ account_id?: number;
89
+ script_id?: number;
84
90
  }>>;
85
91
  assetConfig: z.ZodOptional<z.ZodObject<{
86
92
  html_handling: z.ZodOptional<z.ZodEnum<["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]>>;
@@ -102,6 +108,8 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
102
108
  routingConfig?: {
103
109
  has_user_worker?: boolean;
104
110
  invoke_user_worker_ahead_of_assets?: boolean;
111
+ account_id?: number;
112
+ script_id?: number;
105
113
  } | undefined;
106
114
  assetConfig?: {
107
115
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
@@ -115,6 +123,8 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
115
123
  routingConfig?: {
116
124
  has_user_worker?: boolean;
117
125
  invoke_user_worker_ahead_of_assets?: boolean;
126
+ account_id?: number;
127
+ script_id?: number;
118
128
  } | undefined;
119
129
  assetConfig?: {
120
130
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
@@ -130,6 +140,8 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
130
140
  routingConfig?: {
131
141
  has_user_worker?: boolean;
132
142
  invoke_user_worker_ahead_of_assets?: boolean;
143
+ account_id?: number;
144
+ script_id?: number;
133
145
  } | undefined;
134
146
  assetConfig?: {
135
147
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
@@ -145,6 +157,8 @@ export declare const AssetsOptionsSchema: z.ZodObject<{
145
157
  routingConfig?: {
146
158
  has_user_worker?: boolean;
147
159
  invoke_user_worker_ahead_of_assets?: boolean;
160
+ account_id?: number;
161
+ script_id?: number;
148
162
  } | undefined;
149
163
  assetConfig?: {
150
164
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
@@ -1445,8 +1459,6 @@ export declare const DurableObjectsSharedOptionsSchema: z.ZodObject<{
1445
1459
 
1446
1460
  export declare function encodeSitesKey(key: string): string;
1447
1461
 
1448
- export declare const ENTRY_SOCKET_HTTP_OPTIONS: HttpOptions;
1449
-
1450
1462
  export declare class ErrorEvent extends Event {
1451
1463
  readonly error: Error | null;
1452
1464
  constructor(type: "error", init?: {
@@ -3274,12 +3286,18 @@ export declare const PLUGINS: {
3274
3286
  routingConfig: z.ZodOptional<z.ZodObject<{
3275
3287
  has_user_worker: z.ZodOptional<z.ZodBoolean>;
3276
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>;
3277
3291
  }, "strip", z.ZodTypeAny, {
3278
3292
  has_user_worker?: boolean;
3279
3293
  invoke_user_worker_ahead_of_assets?: boolean;
3294
+ account_id?: number;
3295
+ script_id?: number;
3280
3296
  }, {
3281
3297
  has_user_worker?: boolean;
3282
3298
  invoke_user_worker_ahead_of_assets?: boolean;
3299
+ account_id?: number;
3300
+ script_id?: number;
3283
3301
  }>>;
3284
3302
  assetConfig: z.ZodOptional<z.ZodObject<{
3285
3303
  html_handling: z.ZodOptional<z.ZodEnum<["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]>>;
@@ -3301,6 +3319,8 @@ export declare const PLUGINS: {
3301
3319
  routingConfig?: {
3302
3320
  has_user_worker?: boolean;
3303
3321
  invoke_user_worker_ahead_of_assets?: boolean;
3322
+ account_id?: number;
3323
+ script_id?: number;
3304
3324
  } | undefined;
3305
3325
  assetConfig?: {
3306
3326
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
@@ -3314,6 +3334,8 @@ export declare const PLUGINS: {
3314
3334
  routingConfig?: {
3315
3335
  has_user_worker?: boolean;
3316
3336
  invoke_user_worker_ahead_of_assets?: boolean;
3337
+ account_id?: number;
3338
+ script_id?: number;
3317
3339
  } | undefined;
3318
3340
  assetConfig?: {
3319
3341
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
@@ -3329,6 +3351,8 @@ export declare const PLUGINS: {
3329
3351
  routingConfig?: {
3330
3352
  has_user_worker?: boolean;
3331
3353
  invoke_user_worker_ahead_of_assets?: boolean;
3354
+ account_id?: number;
3355
+ script_id?: number;
3332
3356
  } | undefined;
3333
3357
  assetConfig?: {
3334
3358
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
@@ -3344,6 +3368,8 @@ export declare const PLUGINS: {
3344
3368
  routingConfig?: {
3345
3369
  has_user_worker?: boolean;
3346
3370
  invoke_user_worker_ahead_of_assets?: boolean;
3371
+ account_id?: number;
3372
+ script_id?: number;
3347
3373
  } | undefined;
3348
3374
  assetConfig?: {
3349
3375
  html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash";
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,
@@ -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) {
@@ -4617,7 +4610,10 @@ var MAX_ASSET_SIZE = 25 * 1024 * 1024;
4617
4610
  var import_zod4 = require("zod");
4618
4611
  var RoutingConfigSchema = import_zod4.z.object({
4619
4612
  has_user_worker: import_zod4.z.boolean().optional(),
4620
- invoke_user_worker_ahead_of_assets: 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()
4621
4617
  });
4622
4618
  var AssetConfigSchema = import_zod4.z.object({
4623
4619
  html_handling: import_zod4.z.enum([
@@ -4629,6 +4625,15 @@ var AssetConfigSchema = import_zod4.z.object({
4629
4625
  not_found_handling: import_zod4.z.enum(["single-page-application", "404-page", "none"]).optional(),
4630
4626
  serve_directly: import_zod4.z.boolean().optional()
4631
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
4636
+ });
4632
4637
 
4633
4638
  // ../workers-shared/utils/helpers.ts
4634
4639
  var import_node_path = require("node:path");
@@ -4647,7 +4652,7 @@ var getContentType = (absFilePath) => {
4647
4652
  return contentType;
4648
4653
  };
4649
4654
 
4650
- // ../../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
4651
4656
  var BYTE_UNITS = [
4652
4657
  "B",
4653
4658
  "kB",
@@ -4661,7 +4666,7 @@ var BYTE_UNITS = [
4661
4666
  ];
4662
4667
  var BIBYTE_UNITS = [
4663
4668
  "B",
4664
- "kiB",
4669
+ "KiB",
4665
4670
  "MiB",
4666
4671
  "GiB",
4667
4672
  "TiB",
@@ -4708,11 +4713,13 @@ function prettyBytes(number, options) {
4708
4713
  options = {
4709
4714
  bits: false,
4710
4715
  binary: false,
4716
+ space: true,
4711
4717
  ...options
4712
4718
  };
4713
4719
  const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
4720
+ const separator = options.space ? " " : "";
4714
4721
  if (options.signed && number === 0) {
4715
- return ` 0 ${UNITS[0]}`;
4722
+ return ` 0${separator}${UNITS[0]}`;
4716
4723
  }
4717
4724
  const isNegative = number < 0;
4718
4725
  const prefix = isNegative ? "-" : options.signed ? "+" : "";
@@ -4728,7 +4735,7 @@ function prettyBytes(number, options) {
4728
4735
  }
4729
4736
  if (number < 1) {
4730
4737
  const numberString2 = toLocaleString(number, options.locale, localeOptions);
4731
- return prefix + numberString2 + " " + UNITS[0];
4738
+ return prefix + numberString2 + separator + UNITS[0];
4732
4739
  }
4733
4740
  const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
4734
4741
  number /= (options.binary ? 1024 : 1e3) ** exponent;
@@ -4737,7 +4744,7 @@ function prettyBytes(number, options) {
4737
4744
  }
4738
4745
  const numberString = toLocaleString(Number(number), options.locale, localeOptions);
4739
4746
  const unit = UNITS[exponent];
4740
- return prefix + numberString + " " + unit;
4747
+ return prefix + numberString + separator + unit;
4741
4748
  }
4742
4749
 
4743
4750
  // embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/assets/assets.worker.ts
@@ -7087,11 +7094,20 @@ function validateCompatibilityDate(log, compatibilityDate) {
7087
7094
  }
7088
7095
  return compatibilityDate;
7089
7096
  }
7090
- function buildJsonBindings(bindings) {
7091
- return Object.entries(bindings).map(([name, value]) => ({
7092
- name,
7093
- json: JSON.stringify(value)
7094
- }));
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
+ });
7095
7111
  }
7096
7112
  var WRAPPED_MODULE_PREFIX = "miniflare-internal:wrapped:";
7097
7113
  function workerNameToWrappedModule(workerName) {
@@ -7108,7 +7124,7 @@ var CORE_PLUGIN = {
7108
7124
  getBindings(options, workerIndex) {
7109
7125
  const bindings = [];
7110
7126
  if (options.bindings !== void 0) {
7111
- bindings.push(...buildJsonBindings(options.bindings));
7127
+ bindings.push(...buildBindings(options.bindings));
7112
7128
  }
7113
7129
  if (options.wasmBindings !== void 0) {
7114
7130
  bindings.push(
@@ -7157,7 +7173,7 @@ var CORE_PLUGIN = {
7157
7173
  const entrypoint = isObject ? designator.entrypoint : void 0;
7158
7174
  const bindings2 = isObject ? designator.bindings : void 0;
7159
7175
  const moduleName2 = workerNameToWrappedModule(scriptName);
7160
- const innerBindings = bindings2 === void 0 ? [] : buildJsonBindings(bindings2);
7176
+ const innerBindings = bindings2 === void 0 ? [] : buildBindings(bindings2);
7161
7177
  return {
7162
7178
  name,
7163
7179
  wrapped: { moduleName: moduleName2, entrypoint, innerBindings }
@@ -8548,7 +8564,7 @@ var RatelimitOptionsSchema = import_zod19.z.object({
8548
8564
  var RATELIMIT_PLUGIN_NAME = "ratelimit";
8549
8565
  var SERVICE_RATELIMIT_PREFIX = `${RATELIMIT_PLUGIN_NAME}`;
8550
8566
  var SERVICE_RATELIMIT_MODULE = `cloudflare-internal:${SERVICE_RATELIMIT_PREFIX}:module`;
8551
- function buildJsonBindings2(bindings) {
8567
+ function buildJsonBindings(bindings) {
8552
8568
  return Object.entries(bindings).map(([name, value]) => ({
8553
8569
  name,
8554
8570
  json: JSON.stringify(value)
@@ -8565,7 +8581,7 @@ var RATELIMIT_PLUGIN = {
8565
8581
  name,
8566
8582
  wrapped: {
8567
8583
  moduleName: SERVICE_RATELIMIT_MODULE,
8568
- innerBindings: buildJsonBindings2({
8584
+ innerBindings: buildJsonBindings({
8569
8585
  namespaceId: name,
8570
8586
  limit: config.simple.limit,
8571
8587
  period: config.simple.period
@@ -9766,7 +9782,7 @@ var Miniflare2 = class {
9766
9782
  sockets.push({
9767
9783
  name: SOCKET_ENTRY_LOCAL,
9768
9784
  service: { name: SERVICE_ENTRY },
9769
- http: ENTRY_SOCKET_HTTP_OPTIONS,
9785
+ http: {},
9770
9786
  address: "127.0.0.1:0"
9771
9787
  });
9772
9788
  }
@@ -10320,7 +10336,6 @@ var Miniflare2 = class {
10320
10336
  DispatchFetchDispatcher,
10321
10337
  DurableObjectsOptionsSchema,
10322
10338
  DurableObjectsSharedOptionsSchema,
10323
- ENTRY_SOCKET_HTTP_OPTIONS,
10324
10339
  ErrorEvent,
10325
10340
  File,
10326
10341
  FormData,