@cloudflare/workers-types 3.1.1 → 3.2.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 +29 -3
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -4,13 +4,14 @@
4
4
  declare class AbortController {
5
5
  constructor();
6
6
  readonly signal: AbortSignal;
7
- abort(): void;
7
+ abort(reason?: any): void;
8
8
  }
9
9
 
10
10
  declare class AbortSignal extends EventTarget {
11
11
  constructor();
12
- static abort(): AbortSignal;
12
+ static abort(reason?: any): AbortSignal;
13
13
  readonly aborted: boolean;
14
+ readonly reason: any;
14
15
  }
15
16
 
16
17
  interface BasicImageTransformations {
@@ -1051,6 +1052,7 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
1051
1052
  setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
1052
1053
  clearInterval(timeoutId: number | null): void;
1053
1054
  queueMicrotask(task: Function): void;
1055
+ structuredClone(value: any, options?: ServiceWorkerGlobalScopeStructuredCloneOptions): any;
1054
1056
  fetch(request: Request | string, requestInitr?: RequestInit | Request): Promise<Response>;
1055
1057
  readonly self: ServiceWorkerGlobalScope;
1056
1058
  readonly crypto: Crypto;
@@ -1058,6 +1060,10 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
1058
1060
  readonly console: Console;
1059
1061
  }
1060
1062
 
1063
+ interface ServiceWorkerGlobalScopeStructuredCloneOptions {
1064
+ transfer?: any[];
1065
+ }
1066
+
1061
1067
  declare type StreamPipeOptions = PipeToOptions;
1062
1068
 
1063
1069
  interface StreamQueuingStrategy {
@@ -1235,7 +1241,7 @@ declare abstract class WebSocket extends EventTarget<WebSocketEventMap> {
1235
1241
  close(code?: number, reason?: string): void;
1236
1242
  }
1237
1243
 
1238
- declare type WebSocketEventMap = { close: CloseEvent; message: MessageEvent; };
1244
+ declare type WebSocketEventMap = { close: CloseEvent; message: MessageEvent; error: Event; };
1239
1245
 
1240
1246
  declare const WebSocketPair: { new(): { 0: WebSocket; 1: WebSocket; }; };
1241
1247
 
@@ -1255,6 +1261,7 @@ declare abstract class WritableStream {
1255
1261
  declare class WritableStreamDefaultWriter {
1256
1262
  constructor(stream: WritableStream);
1257
1263
  readonly closed: Promise<void>;
1264
+ readonly ready: Promise<void>;
1258
1265
  readonly desiredSize: number | null;
1259
1266
  abort(reason: any): Promise<void>;
1260
1267
  close(): Promise<void>;
@@ -1298,3 +1305,22 @@ declare function setInterval<Args extends any[]>(callback: (...args: Args) => vo
1298
1305
 
1299
1306
  declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
1300
1307
 
1308
+ declare function structuredClone(value: any, options?: ServiceWorkerGlobalScopeStructuredCloneOptions): any;
1309
+
1310
+ /*** Injected pages.d.ts ***/
1311
+ type Params<P extends string = any> = Record<P, string | string[]>;
1312
+
1313
+ type EventContext<Env, P extends string, Data> = {
1314
+ request: Request;
1315
+ waitUntil: (promise: Promise<any>) => void;
1316
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
1317
+ env: Env;
1318
+ params: Params<P>;
1319
+ data: Data;
1320
+ };
1321
+
1322
+ declare type PagesFunction<
1323
+ Env = unknown,
1324
+ Params extends string = any,
1325
+ Data extends Record<string, unknown> = Record<string, unknown>
1326
+ > = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/workers-types",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "TypeScript typings for Cloudflare Workers",
5
5
  "repository": {
6
6
  "type": "git",