@cloudflare/workers-types 3.2.0 → 3.3.0

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.
Files changed (2) hide show
  1. package/index.d.ts +88 -10
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -10,8 +10,10 @@ declare class AbortController {
10
10
  declare class AbortSignal extends EventTarget {
11
11
  constructor();
12
12
  static abort(reason?: any): AbortSignal;
13
+ static timeout(delay: number): AbortSignal;
13
14
  readonly aborted: boolean;
14
15
  readonly reason: any;
16
+ throwIfAborted(): void;
15
17
  }
16
18
 
17
19
  interface BasicImageTransformations {
@@ -36,10 +38,11 @@ interface BasicImageTransformations {
36
38
  * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
37
39
  * and height. If the image has an aspect ratio different from the ratio
38
40
  * of width and height, it will be cropped to fit.
39
- * - crop: The image will shrunk and cropped to fit within the area
40
- * specified by width and height. The image won’t be enlarged. For images
41
- * smaller than the given dimensions its the same as scale-down. For
42
- * images larger than the given dimensions, its the same as cover.
41
+ * - crop: The image will be shrunk and cropped to fit within the area
42
+ * specified by width and height. The image will not be enlarged. For images
43
+ * smaller than the given dimensions it's the same as scale-down. For
44
+ * images larger than the given dimensions, it's the same as cover.
45
+ * See also trim.
43
46
  * - pad: Resizes to the maximum size that fits within the given width and
44
47
  * height, and then fills the remaining area with a background color
45
48
  * (white by default). Use of this mode is not recommended, as the same
@@ -267,6 +270,11 @@ declare class DOMException extends Error {
267
270
  static readonly DATA_CLONE_ERR: number;
268
271
  }
269
272
 
273
+ declare class DigestStream extends WritableStream {
274
+ constructor(algorithm: string | SubtleCryptoHashAlgorithm);
275
+ readonly digest: Promise<ArrayBuffer>;
276
+ }
277
+
270
278
  interface Doctype {
271
279
  readonly name: string | null;
272
280
  readonly publicId: string | null;
@@ -763,7 +771,16 @@ interface ReadResult {
763
771
  done: boolean;
764
772
  }
765
773
 
766
- declare abstract class ReadableStream {
774
+ interface ReadableByteStreamController {
775
+ readonly byobRequest: ReadableStreamBYOBRequest | null;
776
+ readonly desiredSize: number | null;
777
+ close(): void;
778
+ enqueue(chunk: ArrayBufferView): void;
779
+ error(reason: any): void;
780
+ }
781
+
782
+ declare class ReadableStream {
783
+ constructor(underlyingSource?: Object, queuingStrategy?: Object);
767
784
  readonly locked: boolean;
768
785
  cancel(reason?: any): Promise<void>;
769
786
  getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
@@ -782,6 +799,20 @@ declare class ReadableStreamBYOBReader {
782
799
  readAtLeast(minBytes: number, view: Uint8Array): Promise<ReadableStreamReadResult<Uint8Array>>;
783
800
  }
784
801
 
802
+ interface ReadableStreamBYOBRequest {
803
+ readonly view: Uint8Array | null;
804
+ respond(bytesWritten: number): void;
805
+ respondWithNewView(view: ArrayBufferView): void;
806
+ readonly atLeast: number | null;
807
+ }
808
+
809
+ interface ReadableStreamDefaultController {
810
+ readonly desiredSize: number | null;
811
+ close(): void;
812
+ enqueue(chunk?: any): void;
813
+ error(reason: any): void;
814
+ }
815
+
785
816
  declare class ReadableStreamDefaultReader {
786
817
  constructor(stream: ReadableStream);
787
818
  readonly closed: Promise<void>;
@@ -909,6 +940,13 @@ interface RequestInitCfPropertiesImage extends BasicImageTransformations {
909
940
  * easier to specify higher-DPI sizes in <img srcset>.
910
941
  */
911
942
  dpr?: number;
943
+ /**
944
+ * An object with four properties {left, top, right, bottom} that specify
945
+ * a number of pixels to cut off on each side. Allows removal of borders
946
+ * or cutting out a specific fragment of an image. Trimming is performed
947
+ * before resizing or rotation. Takes dpr into account.
948
+ */
949
+ trim?: { left?: number; top?: number; right?: number; bottom?: number; };
912
950
  /**
913
951
  * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
914
952
  * make images look worse, but load faster. The default is 85. It applies only
@@ -925,6 +963,15 @@ interface RequestInitCfPropertiesImage extends BasicImageTransformations {
925
963
  * (before and after resizing), source image’s MIME type, file size, etc.
926
964
  */
927
965
  format?: "avif" | "webp" | "json";
966
+ /**
967
+ * Whether to preserve animation frames from input files. Default is true.
968
+ * Setting it to false reduces animations to still images. This setting is
969
+ * recommended when enlarging images or processing arbitrary user content,
970
+ * because large GIF animations can weigh tens or even hundreds of megabytes.
971
+ * It is also useful to set anim:false when using format:"json" to get the
972
+ * response quicker without the number of frames.
973
+ */
974
+ anim?: boolean;
928
975
  /**
929
976
  * What EXIF data should be preserved in the output image. Note that EXIF
930
977
  * rotation and embedded color profiles are always applied ("baked in" into
@@ -939,6 +986,17 @@ interface RequestInitCfPropertiesImage extends BasicImageTransformations {
939
986
  * output formats always discard metadata.
940
987
  */
941
988
  metadata?: "keep" | "copyright" | "none";
989
+ /**
990
+ * Strength of sharpening filter to apply to the image. Floating-point
991
+ * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
992
+ * recommended value for downscaled images.
993
+ */
994
+ sharpen?: number;
995
+ /**
996
+ * Radius of a blur filter (approximate gaussian). Maximum supported radius
997
+ * is 250.
998
+ */
999
+ blur?: number;
942
1000
  /**
943
1001
  * Overlays are drawn in the order they appear in the array (last array
944
1002
  * entry is the topmost layer).
@@ -1044,6 +1102,14 @@ declare abstract class ScheduledEvent extends Event {
1044
1102
  waitUntil(promise: Promise<any>): void;
1045
1103
  }
1046
1104
 
1105
+ interface Scheduler {
1106
+ wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
1107
+ }
1108
+
1109
+ interface SchedulerWaitOptions {
1110
+ signal?: AbortSignal;
1111
+ }
1112
+
1047
1113
  interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
1048
1114
  btoa(data: string): string;
1049
1115
  atob(data: string): string;
@@ -1054,10 +1120,12 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
1054
1120
  queueMicrotask(task: Function): void;
1055
1121
  structuredClone(value: any, options?: ServiceWorkerGlobalScopeStructuredCloneOptions): any;
1056
1122
  fetch(request: Request | string, requestInitr?: RequestInit | Request): Promise<Response>;
1057
- readonly self: ServiceWorkerGlobalScope;
1058
- readonly crypto: Crypto;
1059
- readonly caches: CacheStorage;
1123
+ self: ServiceWorkerGlobalScope;
1124
+ crypto: Crypto;
1125
+ caches: CacheStorage;
1126
+ scheduler: Scheduler;
1060
1127
  readonly console: Console;
1128
+ origin: void;
1061
1129
  }
1062
1130
 
1063
1131
  interface ServiceWorkerGlobalScopeStructuredCloneOptions {
@@ -1251,13 +1319,19 @@ declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEv
1251
1319
 
1252
1320
  declare type WorkerGlobalScopeEventMap = { fetch: FetchEvent; scheduled: ScheduledEvent; unhandledrejection: PromiseRejectionEvent; rejectionhandled: PromiseRejectionEvent; };
1253
1321
 
1254
- declare abstract class WritableStream {
1322
+ declare class WritableStream {
1323
+ constructor(underlyingSink?: Object, queuingStrategy?: Object);
1255
1324
  readonly locked: boolean;
1256
1325
  abort(reason: any): Promise<void>;
1257
1326
  close(): Promise<void>;
1258
1327
  getWriter(): WritableStreamDefaultWriter;
1259
1328
  }
1260
1329
 
1330
+ interface WritableStreamDefaultController {
1331
+ readonly signal: AbortSignal;
1332
+ error(reason?: any): void;
1333
+ }
1334
+
1261
1335
  declare class WritableStreamDefaultWriter {
1262
1336
  constructor(stream: WritableStream);
1263
1337
  readonly closed: Promise<void>;
@@ -1295,10 +1369,14 @@ declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlob
1295
1369
 
1296
1370
  declare function fetch(request: Request | string, requestInitr?: RequestInit | Request): Promise<Response>;
1297
1371
 
1372
+ declare const origin: void;
1373
+
1298
1374
  declare function queueMicrotask(task: Function): void;
1299
1375
 
1300
1376
  declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
1301
1377
 
1378
+ declare const scheduler: Scheduler;
1379
+
1302
1380
  declare const self: ServiceWorkerGlobalScope;
1303
1381
 
1304
1382
  declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
@@ -1314,7 +1392,7 @@ type EventContext<Env, P extends string, Data> = {
1314
1392
  request: Request;
1315
1393
  waitUntil: (promise: Promise<any>) => void;
1316
1394
  next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
1317
- env: Env;
1395
+ env: Env & { ASSETS: { fetch: typeof fetch }};
1318
1396
  params: Params<P>;
1319
1397
  data: Data;
1320
1398
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/workers-types",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "TypeScript typings for Cloudflare Workers",
5
5
  "repository": {
6
6
  "type": "git",