@cloudflare/workers-types 2.2.2 → 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.
package/index.d.ts CHANGED
@@ -1,26 +1,17 @@
1
- interface FetchEvent {
2
- passThroughOnException: () => void;
1
+ // This file is auto-generated. DO NOT MODIFY.
2
+ // Please refer to the Auto-Generation section of the README.md.
3
+
4
+ declare class AbortController {
5
+ constructor();
6
+ readonly signal: AbortSignal;
7
+ abort(reason?: any): void;
3
8
  }
4
9
 
5
- interface ScheduledEvent {
6
- /**
7
- * The type of event. This will always return `"scheduled"`.
8
- */
9
- type: string;
10
- /**
11
- * The time the `ScheduledEvent` was scheduled to be executed in
12
- * milliseconds since January 1, 1970, UTC.
13
- * It can be parsed as `new Date(event.scheduledTime)`
14
- */
15
- scheduledTime: number;
16
- /**
17
- * Use this method to notify the runtime to wait for asynchronous tasks
18
- * (e.g. logging, analytics to third-party services, streaming and caching).
19
- * The first `event.waitUntil` to fail will be observed and recorded as the
20
- * status in the Cron Trigger Past Events table. Otherwise, it will be
21
- * reported as a Success.
22
- */
23
- waitUntil(promise: Promise<any>): void;
10
+ declare class AbortSignal extends EventTarget {
11
+ constructor();
12
+ static abort(reason?: any): AbortSignal;
13
+ readonly aborted: boolean;
14
+ readonly reason: any;
24
15
  }
25
16
 
26
17
  interface BasicImageTransformations {
@@ -55,11 +46,11 @@ interface BasicImageTransformations {
55
46
  * effect can be more efficiently achieved with the contain mode and the
56
47
  * CSS object-fit: contain property.
57
48
  */
58
- fit?: 'scale-down' | 'contain' | 'cover' | 'crop' | 'pad';
49
+ fit?: "scale-down" | "contain" | "cover" | "crop" | "pad";
59
50
  /**
60
51
  * When cropping with fit: "cover", this defines the side or point that should
61
52
  * be left uncropped. The value is either a string
62
- * "left", "right", "top", "bottom" or "center" (the default),
53
+ * "left", "right", "top", "bottom", "auto", or "center" (the default),
63
54
  * or an object {x, y} containing focal point coordinates in the original
64
55
  * image expressed as fractions ranging from 0.0 (top or left) to 1.0
65
56
  * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
@@ -68,7 +59,7 @@ interface BasicImageTransformations {
68
59
  * preserve as much as possible around a point at 20% of the height of the
69
60
  * source image.
70
61
  */
71
- gravity?: 'left' | 'right' | 'top' | 'bottom' | 'center' | { x: number; y: number };
62
+ gravity?: "left" | "right" | "top" | "bottom" | "center" | "auto" | BasicImageTransformationsGravityCoordinates;
72
63
  /**
73
64
  * Background color to add underneath the image. Applies only to images with
74
65
  * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…),
@@ -82,155 +73,499 @@ interface BasicImageTransformations {
82
73
  rotate?: 0 | 90 | 180 | 270 | 360;
83
74
  }
84
75
 
85
- interface RequestInitCfProperties {
86
- /**
87
- * In addition to the properties you can set in the RequestInit dict
88
- * that you pass as an argument to the Request constructor, you can
89
- * set certain properties of a `cf` object to control how Cloudflare
90
- * features are applied to that new Request.
91
- *
92
- * Note: Currently, these properties cannot be tested in the
93
- * playground.
94
- */
95
- cacheEverything?: boolean;
96
- /**
97
- * A request's cache key is what determines if two requests are
98
- * "the same" for caching purposes. If a request has the same cache key
99
- * as some previous request, then we can serve the same cached response for
100
- * both. (e.g. 'some-key')
101
- *
102
- * Only available for Enterprise customers.
103
- */
104
- cacheKey?: string;
105
- /**
106
- * Force response to be cached for a given number of seconds. (e.g. 300)
107
- */
108
- cacheTtl?: number;
109
- /**
110
- * Force response to be cached for a given number of seconds based on the Origin status code.
111
- * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
112
- */
113
- cacheTtlByStatus?: { [key: string]: number };
114
- scrapeShield?: boolean;
115
- apps?: boolean;
116
- image?: BasicImageTransformations & {
117
- /**
118
- * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
119
- * easier to specify higher-DPI sizes in <img srcset>.
120
- */
121
- dpr?: number;
122
- /**
123
- * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
124
- * make images look worse, but load faster. The default is 85. It applies only
125
- * to JPEG and WebP images. It doesn’t have any effect on PNG.
126
- */
127
- quality?: number;
128
- /**
129
- * Output format to generate. It can be:
130
- * - avif: generate images in AVIF format.
131
- * - webp: generate images in Google WebP format. Set quality to 100 to get
132
- * the WebP-lossless format.
133
- * - json: instead of generating an image, outputs information about the
134
- * image, in JSON format. The JSON object will contain image size
135
- * (before and after resizing), source image’s MIME type, file size, etc.
136
- */
137
- format?: 'avif' | 'webp' | 'json';
138
- /**
139
- * What EXIF data should be preserved in the output image. Note that EXIF
140
- * rotation and embedded color profiles are always applied ("baked in" into
141
- * the image), and aren't affected by this option. Note that if the Polish
142
- * feature is enabled, all metadata may have been removed already and this
143
- * option may have no effect.
144
- * - keep: Preserve most of EXIF metadata, including GPS location if there's
145
- * any.
146
- * - copyright: Only keep the copyright tag, and discard everything else.
147
- * This is the default behavior for JPEG files.
148
- * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
149
- * output formats always discard metadata.
150
- */
151
- metadata?: 'keep' | 'copyright' | 'none';
152
- /**
153
- * Overlays are drawn in the order they appear in the array (last array
154
- * entry is the topmost layer).
155
- */
156
- draw?: (BasicImageTransformations & {
157
- /**
158
- * Absolute URL of the image file to use for the drawing. It can be any of
159
- * the supported file formats. For drawing of watermarks or non-rectangular
160
- * overlays we recommend using PNG or WebP images.
161
- */
162
- url: string;
163
- /**
164
- * Floating-point number between 0 (transparent) and 1 (opaque).
165
- * For example, opacity: 0.5 makes overlay semitransparent.
166
- */
167
- opacity?: number;
168
- /**
169
- * - If set to true, the overlay image will be tiled to cover the entire
170
- * area. This is useful for stock-photo-like watermarks.
171
- * - If set to "x", the overlay image will be tiled horizontally only
172
- * (form a line).
173
- * - If set to "y", the overlay image will be tiled vertically only
174
- * (form a line).
175
- */
176
- repeat?: true | 'x' | 'y';
177
- /**
178
- * Position of the overlay image relative to a given edge. Each property is
179
- * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
180
- * positions left side of the overlay 10 pixels from the left edge of the
181
- * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
182
- * of the background image.
183
- *
184
- * Setting both left & right, or both top & bottom is an error.
185
- *
186
- * If no position is specified, the image will be centered.
187
- */
188
- top?: number;
189
- left?: number;
190
- bottom?: number;
191
- right?: number;
192
- })[];
193
- };
194
- minify?: {
195
- javascript?: boolean;
196
- css?: boolean;
197
- html?: boolean;
198
- };
199
- mirage?: boolean;
200
- /**
201
- * Redirects the request to an alternate origin server. You can use this,
202
- * for example, to implement load balancing across several origins.
203
- * (e.g.us-east.example.com)
204
- *
205
- * Note - For security reasons, the hostname set in resolveOverride must
206
- * be proxied on the same Cloudflare zone of the incoming request.
207
- * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
208
- * resolve to a host under a different domain or a DNS only domain first
209
- * declare a CNAME record within your own zone’s DNS mapping to the
210
- * external hostname, set proxy on Cloudflare, then set resolveOverride
211
- * to point to that CNAME record.
212
- */
213
- resolveOverride?: string;
76
+ interface BasicImageTransformationsGravityCoordinates {
77
+ x: number;
78
+ y: number;
79
+ }
80
+
81
+ declare class Blob {
82
+ constructor(bits?: BlobBits, options?: BlobOptions);
83
+ readonly size: number;
84
+ readonly type: string;
85
+ slice(start?: number, end?: number, type?: string): Blob;
86
+ arrayBuffer(): Promise<ArrayBuffer>;
87
+ text(): Promise<string>;
88
+ stream(): ReadableStream;
89
+ }
90
+
91
+ declare type BlobBits = (ArrayBuffer | string | Blob)[];
92
+
93
+ interface BlobOptions {
94
+ type?: string;
95
+ }
96
+
97
+ declare abstract class Body {
98
+ readonly body: ReadableStream | null;
99
+ readonly bodyUsed: boolean;
100
+ arrayBuffer(): Promise<ArrayBuffer>;
101
+ text(): Promise<string>;
102
+ json<T>(): Promise<T>;
103
+ formData(): Promise<FormData>;
104
+ blob(): Promise<Blob>;
105
+ }
106
+
107
+ declare type BodyInit = ReadableStream | string | ArrayBuffer | Blob | URLSearchParams | FormData;
108
+
109
+ /**
110
+ * Back compat for code migrating to older definitions.
111
+ * @deprecated Use BodyInit instead.
112
+ */
113
+ declare type BodyInitializer = BodyInit;
114
+
115
+ declare abstract class Cache {
116
+ delete(request: Request | string, options?: CacheQueryOptions): Promise<boolean>;
117
+ match(request: Request | string, options?: CacheQueryOptions): Promise<Response | undefined>;
118
+ put(request: Request | string, response: Response): Promise<void>;
119
+ }
120
+
121
+ interface CacheQueryOptions {
122
+ ignoreMethod?: boolean;
123
+ }
124
+
125
+ declare abstract class CacheStorage {
126
+ open(cacheName: string): Promise<Cache>;
127
+ readonly default: Cache;
128
+ }
129
+
130
+ interface CfRequestInit extends Omit<RequestInit, "cf"> {
131
+ cf?: RequestInitCfProperties;
132
+ }
133
+
134
+ /**
135
+ * Back compat support with older types.
136
+ * @deprecated Use CfRequestInit instead.
137
+ */
138
+ declare type CfRequestInitializerDict = CfRequestInit;
139
+
140
+ declare class CloseEvent extends Event {
141
+ constructor(type: string, initializer: CloseEventInit);
142
+ readonly code: number;
143
+ readonly reason: string;
144
+ readonly wasClean: boolean;
145
+ }
146
+
147
+ interface CloseEventInit {
148
+ code?: number;
149
+ reason?: string;
150
+ wasClean?: boolean;
151
+ }
152
+
153
+ /**
154
+ * Back compat for code migrating from older definitions.
155
+ * @deprecated Use CloseEventInit instead.
156
+ */
157
+ declare type CloseEventInitializer = CloseEventInit;
158
+
159
+ interface Comment {
160
+ text: string;
161
+ readonly removed: boolean;
162
+ before(content: Content, options?: ContentOptions): Comment;
163
+ after(content: Content, options?: ContentOptions): Comment;
164
+ replace(content: Content, options?: ContentOptions): Comment;
165
+ remove(): Comment;
166
+ }
167
+
168
+ interface Console {
169
+ debug(...data: any[]): void;
170
+ error(...data: any[]): void;
171
+ info(...data: any[]): void;
172
+ log(...data: any[]): void;
173
+ warn(...data: any[]): void;
174
+ }
175
+
176
+ declare type Content = string | ReadableStream | Response;
177
+
178
+ interface ContentOptions {
179
+ html?: boolean;
180
+ }
181
+
182
+ declare abstract class Crypto {
183
+ readonly subtle: SubtleCrypto;
184
+ getRandomValues<T extends Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array>(buffer: T): T;
185
+ randomUUID(): string;
186
+ }
187
+
188
+ declare abstract class CryptoKey {
189
+ readonly type: string;
190
+ readonly extractable: boolean;
191
+ readonly algorithm: CryptoKeyAlgorithmVariant;
192
+ readonly usages: string[];
193
+ }
194
+
195
+ interface CryptoKeyAesKeyAlgorithm {
196
+ name: string;
197
+ length: number;
198
+ }
199
+
200
+ declare type CryptoKeyAlgorithmVariant = CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyVoprfKeyAlgorithm | CryptoKeyOprfKeyAlgorithm;
201
+
202
+ interface CryptoKeyEllipticKeyAlgorithm {
203
+ name: string;
204
+ namedCurve: string;
205
+ }
206
+
207
+ interface CryptoKeyHmacKeyAlgorithm {
208
+ name: string;
209
+ hash: CryptoKeyKeyAlgorithm;
210
+ length: number;
211
+ }
212
+
213
+ interface CryptoKeyKeyAlgorithm {
214
+ name: string;
215
+ }
216
+
217
+ interface CryptoKeyOprfKeyAlgorithm {
218
+ name: string;
219
+ namedCurve: string;
220
+ }
221
+
222
+ interface CryptoKeyPair {
223
+ publicKey: CryptoKey;
224
+ privateKey: CryptoKey;
225
+ }
226
+
227
+ interface CryptoKeyRsaKeyAlgorithm {
228
+ name: string;
229
+ modulusLength: number;
230
+ publicExponent: ArrayBuffer;
231
+ hash?: CryptoKeyKeyAlgorithm;
232
+ }
233
+
234
+ interface CryptoKeyVoprfKeyAlgorithm {
235
+ name: string;
236
+ hash: CryptoKeyKeyAlgorithm;
237
+ namedCurve: string;
238
+ }
239
+
240
+ declare class DOMException extends Error {
241
+ constructor(message?: string, name?: string);
242
+ readonly code: number;
243
+ static readonly INDEX_SIZE_ERR: number;
244
+ static readonly DOMSTRING_SIZE_ERR: number;
245
+ static readonly HIERARCHY_REQUEST_ERR: number;
246
+ static readonly WRONG_DOCUMENT_ERR: number;
247
+ static readonly INVALID_CHARACTER_ERR: number;
248
+ static readonly NO_DATA_ALLOWED_ERR: number;
249
+ static readonly NO_MODIFICATION_ALLOWED_ERR: number;
250
+ static readonly NOT_FOUND_ERR: number;
251
+ static readonly NOT_SUPPORTED_ERR: number;
252
+ static readonly INUSE_ATTRIBUTE_ERR: number;
253
+ static readonly INVALID_STATE_ERR: number;
254
+ static readonly SYNTAX_ERR: number;
255
+ static readonly INVALID_MODIFICATION_ERR: number;
256
+ static readonly NAMESPACE_ERR: number;
257
+ static readonly INVALID_ACCESS_ERR: number;
258
+ static readonly VALIDATION_ERR: number;
259
+ static readonly TYPE_MISMATCH_ERR: number;
260
+ static readonly SECURITY_ERR: number;
261
+ static readonly NETWORK_ERR: number;
262
+ static readonly ABORT_ERR: number;
263
+ static readonly URL_MISMATCH_ERR: number;
264
+ static readonly QUOTA_EXCEEDED_ERR: number;
265
+ static readonly TIMEOUT_ERR: number;
266
+ static readonly INVALID_NODE_TYPE_ERR: number;
267
+ static readonly DATA_CLONE_ERR: number;
268
+ }
269
+
270
+ interface Doctype {
271
+ readonly name: string | null;
272
+ readonly publicId: string | null;
273
+ readonly systemId: string | null;
274
+ }
275
+
276
+ interface DocumentEnd {
277
+ append(content: Content, options?: ContentOptions): DocumentEnd;
278
+ }
279
+
280
+ interface DurableObject {
281
+ fetch(request: Request): Promise<Response>;
282
+ }
283
+
284
+ interface DurableObjectGetOptions {
285
+ allowConcurrency?: boolean;
286
+ noCache?: boolean;
287
+ }
288
+
289
+ interface DurableObjectId {
290
+ toString(): string;
291
+ equals(other: DurableObjectId): boolean;
292
+ readonly name?: string;
293
+ }
294
+
295
+ interface DurableObjectListOptions {
296
+ start?: string;
297
+ end?: string;
298
+ prefix?: string;
299
+ reverse?: boolean;
300
+ limit?: number;
301
+ allowConcurrency?: boolean;
302
+ noCache?: boolean;
303
+ }
304
+
305
+ interface DurableObjectNamespace {
306
+ newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId;
307
+ idFromName(name: string): DurableObjectId;
308
+ idFromString(id: string): DurableObjectId;
309
+ get(id: DurableObjectId): DurableObjectStub;
310
+ }
311
+
312
+ interface DurableObjectNamespaceNewUniqueIdOptions {
313
+ jurisdiction?: string;
314
+ }
315
+
316
+ interface DurableObjectPutOptions {
317
+ allowConcurrency?: boolean;
318
+ allowUnconfirmed?: boolean;
319
+ noCache?: boolean;
320
+ }
321
+
322
+ interface DurableObjectState {
323
+ waitUntil(promise: Promise<any>): void;
324
+ readonly id: DurableObjectId | string;
325
+ readonly storage: DurableObjectStorage;
326
+ blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
327
+ }
328
+
329
+ interface DurableObjectStorage {
330
+ get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
331
+ get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
332
+ list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
333
+ put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
334
+ put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
335
+ delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
336
+ delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
337
+ deleteAll(options?: DurableObjectPutOptions): Promise<void>;
338
+ transaction<T>(closure: (txn: DurableObjectTransaction) => Promise<T>): Promise<T>;
339
+ }
340
+
341
+ /**
342
+ *
343
+ * @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
344
+ */
345
+ declare type DurableObjectStorageOperationsGetOptions = DurableObjectGetOptions;
346
+
347
+ /**
348
+ *
349
+ * @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
350
+ */
351
+ declare type DurableObjectStorageOperationsListOptions = DurableObjectListOptions;
352
+
353
+ /**
354
+ *
355
+ * @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
356
+ */
357
+ declare type DurableObjectStorageOperationsPutOptions = DurableObjectPutOptions;
358
+
359
+ interface DurableObjectStub extends Fetcher {
360
+ readonly id: DurableObjectId;
361
+ readonly name?: string;
362
+ }
363
+
364
+ interface DurableObjectTransaction {
365
+ get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T>;
366
+ get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
367
+ list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
368
+ put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
369
+ put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
370
+ delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
371
+ delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
372
+ rollback(): void;
373
+ }
374
+
375
+ interface Element {
376
+ tagName: string;
377
+ readonly attributes: IterableIterator<string[]>;
378
+ readonly removed: boolean;
379
+ readonly namespaceURI: string;
380
+ getAttribute(name: string): string | null;
381
+ hasAttribute(name: string): boolean;
382
+ setAttribute(name: string, value: string): Element;
383
+ removeAttribute(name: string): Element;
384
+ before(content: Content, options?: ContentOptions): Element;
385
+ after(content: Content, options?: ContentOptions): Element;
386
+ prepend(content: Content, options?: ContentOptions): Element;
387
+ append(content: Content, options?: ContentOptions): Element;
388
+ replace(content: Content, options?: ContentOptions): Element;
389
+ remove(): Element;
390
+ removeAndKeepContent(): Element;
391
+ setInnerContent(content: Content, options?: ContentOptions): Element;
392
+ }
393
+
394
+ declare class Event {
395
+ constructor(type: string, init?: EventInit);
396
+ readonly type: string;
397
+ readonly eventPhase: number;
398
+ readonly composed: boolean;
399
+ readonly bubbles: boolean;
400
+ readonly cancelable: boolean;
401
+ readonly defaultPrevented: boolean;
402
+ readonly returnValue: boolean;
403
+ readonly currentTarget?: EventTarget;
404
+ readonly srcElement?: EventTarget;
405
+ readonly timeStamp: number;
406
+ readonly isTrusted: boolean;
407
+ cancelBubble: boolean;
408
+ stopImmediatePropagation(): void;
409
+ preventDefault(): void;
410
+ stopPropagation(): void;
411
+ composedPath(): EventTarget[];
412
+ static readonly NONE: number;
413
+ static readonly CAPTURING_PHASE: number;
414
+ static readonly AT_TARGET: number;
415
+ static readonly BUBBLING_PHASE: number;
416
+ }
417
+
418
+ interface EventInit {
419
+ bubbles?: boolean;
420
+ cancelable?: boolean;
421
+ composed?: boolean;
422
+ }
423
+
424
+ declare type EventListener<EventType extends Event = Event> = (event: EventType) => void;
425
+
426
+ interface EventListenerObject<EventType extends Event = Event> {
427
+ handleEvent(event: EventType): void;
428
+ }
429
+
430
+ declare type EventListenerOrEventListenerObject<EventType extends Event = Event> = EventListener<EventType> | EventListenerObject<EventType>;
431
+
432
+ declare class EventTarget<EventMap extends Record<string, Event> = Record<string, Event>> {
433
+ constructor();
434
+ addEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
435
+ removeEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
436
+ dispatchEvent(event: EventMap[keyof EventMap]): boolean;
437
+ }
438
+
439
+ interface EventTargetAddEventListenerOptions {
440
+ capture?: boolean;
441
+ passive?: boolean;
442
+ once?: boolean;
443
+ signal?: AbortSignal;
444
+ }
445
+
446
+ interface EventTargetEventListenerOptions {
447
+ capture?: boolean;
448
+ }
449
+
450
+ interface ExecutionContext {
451
+ waitUntil(promise: Promise<any>): void;
452
+ passThroughOnException(): void;
453
+ }
454
+
455
+ interface ExportedHandler<Env = unknown> {
456
+ fetch?: ExportedHandlerFetchHandler<Env>;
457
+ scheduled?: ExportedHandlerScheduledHandler<Env>;
458
+ }
459
+
460
+ declare type ExportedHandlerFetchHandler<Env = unknown> = (request: Request, env: Env, ctx: ExecutionContext) => Response | Promise<Response>;
461
+
462
+ declare type ExportedHandlerScheduledHandler<Env = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
463
+
464
+ declare abstract class FetchEvent extends Event {
465
+ readonly request: Request;
466
+ respondWith(promise: Response | Promise<Response>): void;
467
+ passThroughOnException(): void;
468
+ waitUntil(promise: Promise<any>): void;
469
+ }
470
+
471
+ declare abstract class Fetcher {
472
+ fetch(requestOrUrl: Request | string, requestInit?: RequestInit | Request): Promise<Response>;
473
+ }
474
+
475
+ declare class File extends Blob {
476
+ constructor(bits?: BlobBits, name?: string, options?: FileOptions);
477
+ readonly name: string;
478
+ readonly lastModified: number;
479
+ }
480
+
481
+ interface FileOptions {
482
+ type?: string;
483
+ lastModified?: number;
484
+ }
485
+
486
+ declare class FixedLengthStream extends TransformStream {
487
+ constructor(expectedLength: number);
488
+ }
489
+
490
+ declare class FormData {
491
+ constructor();
492
+ append(name: string, value: string): void;
493
+ append(name: string, value: Blob, filename?: string): void;
494
+ delete(name: string): void;
495
+ get(name: string): File | string | null;
496
+ getAll(name: string): (File | string)[];
497
+ has(name: string): boolean;
498
+ set(name: string, value: string): void;
499
+ set(name: string, value: Blob, filename?: string): void;
500
+ entries(): IterableIterator<([key: string, value: File | string])[]>;
501
+ keys(): IterableIterator<string>;
502
+ values(): IterableIterator<File | string>;
503
+ forEach<This = unknown>(callback: (this: This, key: string, value: File | string, parent: FormData) => void, thisArg?: This): void;
504
+ [Symbol.iterator](): IterableIterator<([key: string, value: File | string])[]>;
505
+ }
506
+
507
+ declare class HTMLRewriter {
508
+ constructor();
509
+ on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter;
510
+ onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
511
+ transform(response: Response): Response;
512
+ }
513
+
514
+ interface HTMLRewriterDocumentContentHandlers {
515
+ doctype?(doctype: Doctype): void | Promise<void>;
516
+ comments?(comment: Comment): void | Promise<void>;
517
+ text?(text: Text): void | Promise<void>;
518
+ end?(end: DocumentEnd): void | Promise<void>;
519
+ }
520
+
521
+ interface HTMLRewriterElementContentHandlers {
522
+ element?(element: Element): void | Promise<void>;
523
+ comments?(comment: Comment): void | Promise<void>;
524
+ text?(text: Text): void | Promise<void>;
525
+ }
526
+
527
+ declare class Headers {
528
+ constructor(init?: HeadersInit);
529
+ get(name: string): string | null;
530
+ getAll(name: string): string[];
531
+ has(name: string): boolean;
532
+ set(name: string, value: string): void;
533
+ append(name: string, value: string): void;
534
+ delete(name: string): void;
535
+ forEach<This = unknown>(callback: (this: This, key: string, value: string, parent: Headers) => void, thisArg?: This): void;
536
+ entries(): IterableIterator<[key: string, value: string]>;
537
+ keys(): IterableIterator<string>;
538
+ values(): IterableIterator<string>;
539
+ [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
214
540
  }
215
541
 
542
+ declare type HeadersInit = Headers | Record<string, string> | ([key: string, value: string])[];
543
+
544
+ /**
545
+ * Back compat for code migrating to older definitions.
546
+ * @deprecated Use HeadersInit instead.
547
+ */
548
+ declare type HeadersInitializer = HeadersInit;
549
+
550
+ /**
551
+ * In addition to the properties on the standard Request object,
552
+ * the cf object contains extra information about the request provided
553
+ * by Cloudflare's edge.
554
+ *
555
+ * Note: Currently, settings in the cf object cannot be accessed in the
556
+ * playground.
557
+ */
216
558
  interface IncomingRequestCfProperties {
217
559
  /**
218
- * In addition to the properties on the standard Request object,
219
- * the cf object contains extra information about the request provided
220
- * by Cloudflare's edge.
221
- *
222
- * Note: Currently, settings in the cf object cannot be accessed in the
223
- * playground.
560
+ * (e.g. 395747)
224
561
  */
562
+ asn: number;
225
563
  /**
226
- * (e.g. 395747)
564
+ * The organisation which owns the ASN of the incoming request.
565
+ * (e.g. Google Cloud)
227
566
  */
228
- asn: number;
229
- botManagement?: {
230
- score: number;
231
- staticResource: boolean;
232
- verifiedBot: boolean;
233
- };
567
+ asOrganization: string;
568
+ botManagement?: IncomingRequestCfPropertiesBotManagement;
234
569
  city?: string;
235
570
  clientTcpRtt: number;
236
571
  clientTrustScore?: number;
@@ -271,446 +606,721 @@ interface IncomingRequestCfProperties {
271
606
  timezone?: string;
272
607
  tlsVersion: string;
273
608
  tlsCipher: string;
274
- tlsClientAuth: {
275
- certIssuerDNLegacy: string;
276
- certIssuerDN: string;
277
- certPresented: '0' | '1';
278
- certSubjectDNLegacy: string;
279
- certSubjectDN: string;
280
- certNotBefore: string; // In format "Dec 22 19:39:00 2018 GMT"
281
- certNotAfter: string; // In format "Dec 22 19:39:00 2018 GMT"
282
- certSerial: string;
283
- certFingerprintSHA1: string;
284
- certVerified: string; // “SUCCESS”, “FAILED:reason”, “NONE”
285
- };
286
- }
287
-
288
- interface CfRequestInit extends Omit<RequestInit, 'cf'> {
289
- cf?: RequestInitCfProperties;
290
- }
291
-
292
- interface RequestInit {
293
- /**
294
- * cf is a union of these two types because there are multiple
295
- * scenarios in which it might be one or the other. If you need
296
- * a type that only contains RequestInitCfProperties, use the
297
- * CfRequestInit type.
298
- *
299
- * IncomingRequestCfProperties is required to allow
300
- * new Request(someUrl, event.request)
301
- *
302
- * RequestInitCfProperties is required to allow
303
- * new Request(event.request, {cf: { ... } })
304
- * fetch(someUrl, {cf: { ... } })
305
- */
306
- cf?: IncomingRequestCfProperties | RequestInitCfProperties;
609
+ tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth;
307
610
  }
308
611
 
309
- declare function addEventListener(type: 'fetch', handler: (event: FetchEvent) => void): void;
310
- declare function addEventListener(type: 'scheduled', handler: (event: ScheduledEvent) => void): void;
311
-
312
- interface Request {
313
- cf: IncomingRequestCfProperties;
612
+ interface IncomingRequestCfPropertiesBotManagement {
613
+ score: number;
614
+ staticResource: boolean;
615
+ verifiedBot: boolean;
314
616
  }
315
617
 
316
- interface FormData {
317
- [Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>;
618
+ interface IncomingRequestCfPropertiesTLSClientAuth {
619
+ certIssuerDNLegacy: string;
620
+ certIssuerDN: string;
621
+ certPresented: "0" | "1";
622
+ certSubjectDNLegacy: string;
623
+ certSubjectDN: string;
318
624
  /**
319
- * Returns an array of key, value pairs for every entry in the list.
625
+ * In format "Dec 22 19:39:00 2018 GMT"
320
626
  */
321
- entries(): IterableIterator<[string, FormDataEntryValue]>;
627
+ certNotBefore: string;
322
628
  /**
323
- * Returns a list of keys in the list.
629
+ * In format "Dec 22 19:39:00 2018 GMT"
324
630
  */
325
- keys(): IterableIterator<string>;
631
+ certNotAfter: string;
632
+ certSerial: string;
633
+ certFingerprintSHA1: string;
326
634
  /**
327
- * Returns a list of values in the list.
635
+ * "SUCCESS", "FAILED:reason", "NONE"
328
636
  */
329
- values(): IterableIterator<FormDataEntryValue>;
637
+ certVerified: string;
330
638
  }
331
639
 
332
- interface Headers {
333
- [Symbol.iterator](): IterableIterator<[string, string]>;
334
- /**
335
- * Returns an iterator allowing to go through all key/value pairs contained in this object.
336
- */
337
- entries(): IterableIterator<[string, string]>;
338
- /**
339
- * Returns an iterator allowing to go through all keys of the key/value pairs contained in this object.
340
- */
341
- keys(): IterableIterator<string>;
342
- /**
343
- * Returns an iterator allowing to go through all values of the key/value pairs contained in this object.
344
- */
345
- values(): IterableIterator<string>;
640
+ interface JsonWebKey {
641
+ kty: string;
642
+ use?: string;
643
+ key_ops?: string[];
644
+ alg?: string;
645
+ ext?: boolean;
646
+ crv?: string;
647
+ x?: string;
648
+ y?: string;
649
+ d?: string;
650
+ n?: string;
651
+ e?: string;
652
+ p?: string;
653
+ q?: string;
654
+ dp?: string;
655
+ dq?: string;
656
+ qi?: string;
657
+ oth?: RsaOtherPrimesInfo[];
658
+ k?: string;
346
659
  }
347
660
 
348
- interface URLSearchParams {
349
- [Symbol.iterator](): IterableIterator<[string, string]>;
350
- /**
351
- * Returns an array of key, value pairs for every entry in the search params.
352
- */
353
- entries(): IterableIterator<[string, string]>;
354
- /**
355
- * Returns a list of keys in the search params.
356
- */
357
- keys(): IterableIterator<string>;
358
- /**
359
- * Returns a list of values in the search params.
360
- */
361
- values(): IterableIterator<string>;
661
+ /**
662
+ * Workers KV is a global, low-latency, key-value data store. It supports exceptionally high read volumes with low-latency,
663
+ * making it possible to build highly dynamic APIs and websites which respond as quickly as a cached static file would.
664
+ */
665
+ interface KVNamespace {
666
+ get(key: string, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<string | null>;
667
+ get(key: string, type: "text"): Promise<string | null>;
668
+ get<ExpectedValue = unknown>(key: string, type: "json"): Promise<ExpectedValue | null>;
669
+ get(key: string, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
670
+ get(key: string, type: "stream"): Promise<ReadableStream | null>;
671
+ get(key: string, options: KVNamespaceGetOptions<"text">): Promise<string | null>;
672
+ get<ExpectedValue = unknown>(key: string, options: KVNamespaceGetOptions<"json">): Promise<ExpectedValue | null>;
673
+ get(key: string, options: KVNamespaceGetOptions<"arrayBuffer">): Promise<ArrayBuffer | null>;
674
+ get(key: string, options: KVNamespaceGetOptions<"stream">): Promise<ReadableStream | null>;
675
+ list<Metadata = unknown>(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult<Metadata>>;
676
+ /**
677
+ * Creates a new key-value pair, or updates the value for a particular key.
678
+ * @param key key to associate with the value. A key cannot be empty, `.` or `..`. All other keys are valid.
679
+ * @param value value to store. The type is inferred. The maximum size of a value is 25MB.
680
+ * @returns Returns a `Promise` that you should `await` on in order to verify a successful update.
681
+ * @example
682
+ * await NAMESPACE.put(key, value)
683
+ */
684
+ put(key: string, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise<void>;
685
+ getWithMetadata<Metadata = unknown>(key: string, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
686
+ getWithMetadata<Metadata = unknown>(key: string, type: "text"): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
687
+ getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: string, type: "json"): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
688
+ getWithMetadata<Metadata = unknown>(key: string, type: "arrayBuffer"): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
689
+ getWithMetadata<Metadata = unknown>(key: string, type: "stream"): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
690
+ getWithMetadata<Metadata = unknown>(key: string, options: KVNamespaceGetOptions<"text">): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
691
+ getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: string, options: KVNamespaceGetOptions<"json">): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
692
+ getWithMetadata<Metadata = unknown>(key: string, options: KVNamespaceGetOptions<"arrayBuffer">): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
693
+ getWithMetadata<Metadata = unknown>(key: string, options: KVNamespaceGetOptions<"stream">): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
694
+ delete(name: string): Promise<void>;
362
695
  }
363
696
 
364
- interface ContentOptions {
365
- /**
366
- * Controls the way the HTMLRewriter treats inserted content.
367
- *
368
- * - true: Raw HTML
369
- * - false: (Default) Text and any HTML will be escaped
370
- */
371
- html: boolean;
697
+ interface KVNamespaceGetOptions<Type> {
698
+ type: Type;
699
+ cacheTtl?: number;
372
700
  }
373
701
 
374
- interface Element {
375
- /**
376
- * The namespace URI of the element according to Infra Spec
377
- * (https://infra.spec.whatwg.org/#namespaces).
378
- */
379
- namespaceURI: string;
380
- /**
381
- * e.g. "div"
382
- */
383
- tagName: string;
384
- /**
385
- * Read-Only - key/value pairs of attributes.
386
- */
387
- readonly attributes: IterableIterator<[string, string]>;
388
- /**
389
- * Indicates whether the element was removed/replaced in a previous handler
390
- */
391
- removed: boolean;
702
+ interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
703
+ value: Value | null;
704
+ metadata: Metadata | null;
705
+ }
392
706
 
393
- /**
394
- * Returns the value for a given attribute name on the element, or null if it isn’t found.
395
- */
396
- getAttribute(name: string): string | null;
397
- /**
398
- * Returns a boolean indicating whether an attribute exists on the element.
399
- */
400
- hasAttribute(name: string): boolean;
401
- /**
402
- * Sets an attribute to a provided value, creating the attribute if it doesn’t exist.
403
- */
404
- setAttribute(name: string, value: string): Element;
405
- /**
406
- * Removes the attribute.
407
- */
408
- removeAttribute(name: string): Element;
409
- /**
410
- * Inserts content before the element.
411
- */
412
- before(content: string, options?: ContentOptions): Element;
413
- /**
414
- * Inserts content right after the element.
415
- */
416
- after(content: string, options?: ContentOptions): Element;
417
- /**
418
- * Inserts content right after the start tag of the element.
419
- */
420
- prepend(content: string, options?: ContentOptions): Element;
421
- /**
422
- * Inserts content right before the end tag of the element.
423
- */
424
- append(content: string, options?: ContentOptions): Element;
425
- /**
426
- * Removes the element and inserts content in place of it.
427
- */
428
- replace(content: string, options?: ContentOptions): Element;
429
- /**
430
- * Replaces content of the element.
431
- */
432
- setInnerContent(content: string, options?: ContentOptions): Element;
433
- /**
434
- * Removes the element with all its content.
435
- */
436
- remove(): Element;
437
- /**
438
- * Removes the start tag and end tag of the element, but keeps its inner content intact.
439
- */
440
- removeAndKeepContent(): Element;
707
+ interface KVNamespaceListKey<Metadata> {
708
+ name: string;
709
+ expiration?: number;
710
+ metadata?: Metadata;
441
711
  }
442
712
 
443
- interface Text {
444
- /**
445
- * Indicates whether the element was removed/replaced in a previous handler.
446
- */
447
- removed: boolean;
448
- /**
449
- * Read-Only - The text contents of the chunk. Could be empty if the chunk
450
- * is the last chunk of the text node.
451
- */
452
- readonly text: string;
713
+ interface KVNamespaceListOptions {
714
+ limit?: number;
715
+ prefix?: string | null;
716
+ cursor?: string | null;
717
+ }
718
+
719
+ interface KVNamespaceListResult<Metadata> {
720
+ keys: KVNamespaceListKey<Metadata>[];
721
+ list_complete: boolean;
722
+ cursor?: string;
723
+ }
724
+
725
+ interface KVNamespacePutOptions {
726
+ expiration?: number;
727
+ expirationTtl?: number;
728
+ metadata?: any | null;
729
+ }
730
+
731
+ declare class MessageEvent extends Event {
732
+ constructor(type: string, initializer: MessageEventInit);
733
+ readonly data: ArrayBuffer | string;
734
+ }
735
+
736
+ interface MessageEventInit {
737
+ data: ArrayBuffer | string;
738
+ }
739
+
740
+ /**
741
+ * Back compat for code migrating from older definitions.
742
+ * @deprecated Use MessageEventInit instead.
743
+ */
744
+ declare type MessageEventInitializer = MessageEventInit;
745
+
746
+ /**
747
+ * Transitionary name.
748
+ * @deprecated Use StreamPipeOptions
749
+ */
750
+ interface PipeToOptions {
751
+ preventClose?: boolean;
752
+ preventAbort?: boolean;
753
+ preventCancel?: boolean;
754
+ }
755
+
756
+ declare abstract class PromiseRejectionEvent extends Event {
757
+ readonly promise: Promise<any>;
758
+ readonly reason: any;
759
+ }
760
+
761
+ interface ReadResult {
762
+ value?: any;
763
+ done: boolean;
764
+ }
765
+
766
+ declare abstract class ReadableStream {
767
+ readonly locked: boolean;
768
+ cancel(reason?: any): Promise<void>;
769
+ getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
770
+ getReader(): ReadableStreamDefaultReader;
771
+ pipeThrough(transform: ReadableStreamTransform, options?: PipeToOptions): ReadableStream;
772
+ pipeTo(destination: WritableStream, options?: PipeToOptions): Promise<void>;
773
+ tee(): [ReadableStream, ReadableStream];
774
+ }
775
+
776
+ declare class ReadableStreamBYOBReader {
777
+ constructor(stream: ReadableStream);
778
+ readonly closed: Promise<void>;
779
+ cancel(reason?: any): Promise<void>;
780
+ read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
781
+ releaseLock(): void;
782
+ readAtLeast(minBytes: number, view: Uint8Array): Promise<ReadableStreamReadResult<Uint8Array>>;
783
+ }
784
+
785
+ declare class ReadableStreamDefaultReader {
786
+ constructor(stream: ReadableStream);
787
+ readonly closed: Promise<void>;
788
+ cancel(reason?: any): Promise<void>;
789
+ read(): Promise<ReadableStreamReadResult<any>>;
790
+ releaseLock(): void;
791
+ }
792
+
793
+ interface ReadableStreamGetReaderOptions {
794
+ mode: string;
795
+ }
796
+
797
+ /**
798
+ * Back-compat alias.
799
+ * @deprecated Use StreamPipeOptions
800
+ */
801
+ declare type ReadableStreamPipeToOptions = PipeToOptions;
802
+
803
+ declare type ReadableStreamReadResult<T = any> = { done: true; value: undefined; } | { done: false; value: T; };
804
+
805
+ /**
806
+ * Back-compat alias.
807
+ * @deprecated Use ReadableStreamBYOBReader
808
+ */
809
+ declare type ReadableStreamReadableStreamBYOBReader = ReadableStreamBYOBReader;
810
+
811
+ /**
812
+ * Back-compat alias.
813
+ * @deprecated Use ReadableStreamDefaultReader
814
+ */
815
+ declare type ReadableStreamReadableStreamDefaultReader = ReadableStreamDefaultReader;
816
+
817
+ interface ReadableStreamTransform {
818
+ writable: WritableStream;
819
+ readable: ReadableStream;
820
+ }
821
+
822
+ declare class Request extends Body {
823
+ constructor(input: Request | string, init?: RequestInit | Request);
824
+ clone(): Request;
825
+ readonly method: string;
826
+ readonly url: string;
827
+ readonly headers: Headers;
828
+ readonly redirect: string;
829
+ readonly fetcher: Fetcher | null;
830
+ readonly signal: AbortSignal;
831
+ readonly cf?: IncomingRequestCfProperties;
832
+ }
833
+
834
+ interface RequestInit {
835
+ method?: string;
836
+ headers?: HeadersInit;
837
+ body?: BodyInit | null;
838
+ redirect?: string;
839
+ fetcher?: Fetcher | null;
453
840
  /**
454
- * Read-Only - indicates whether the chunk is the last chunk of the text node.
841
+ * cf is a union of these two types because there are multiple
842
+ * scenarios in which it might be one or the other.
843
+ *
844
+ * IncomingRequestCfProperties is required to allow
845
+ * new Request(someUrl, event.request)
846
+ *
847
+ * RequestInitCfProperties is required to allow
848
+ * new Request(event.request, {cf: { ... } })
849
+ * fetch(someUrl, {cf: { ... } })
455
850
  */
456
- readonly lastInTextNode: boolean;
851
+ cf?: IncomingRequestCfProperties | RequestInitCfProperties;
852
+ signal?: AbortSignal | null;
853
+ }
457
854
 
855
+ /**
856
+ * In addition to the properties you can set in the RequestInit dict
857
+ * that you pass as an argument to the Request constructor, you can
858
+ * set certain properties of a `cf` object to control how Cloudflare
859
+ * features are applied to that new Request.
860
+ *
861
+ * Note: Currently, these properties cannot be tested in the
862
+ * playground.
863
+ */
864
+ interface RequestInitCfProperties {
865
+ cacheEverything?: boolean;
458
866
  /**
459
- * Inserts content before the element.
867
+ * A request's cache key is what determines if two requests are
868
+ * "the same" for caching purposes. If a request has the same cache key
869
+ * as some previous request, then we can serve the same cached response for
870
+ * both. (e.g. 'some-key')
871
+ *
872
+ * Only available for Enterprise customers.
460
873
  */
461
- before(content: string, options?: ContentOptions): Element;
874
+ cacheKey?: string;
462
875
  /**
463
- * Inserts content right after the element.
876
+ * Force response to be cached for a given number of seconds. (e.g. 300)
464
877
  */
465
- after(content: string, options?: ContentOptions): Element;
878
+ cacheTtl?: number;
466
879
  /**
467
- * Removes the element and inserts content in place of it.
880
+ * Force response to be cached for a given number of seconds based on the Origin status code.
881
+ * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
468
882
  */
469
- replace(content: string, options?: ContentOptions): Element;
883
+ cacheTtlByStatus?: Record<string, number>;
884
+ scrapeShield?: boolean;
885
+ apps?: boolean;
886
+ image?: RequestInitCfPropertiesImage;
887
+ minify?: RequestInitCfPropertiesImageMinify;
888
+ mirage?: boolean;
889
+ polish?: 'lossy' | 'lossless' | 'off';
470
890
  /**
471
- * Removes the element with all its content.
891
+ * Redirects the request to an alternate origin server. You can use this,
892
+ * for example, to implement load balancing across several origins.
893
+ * (e.g.us-east.example.com)
894
+ *
895
+ * Note - For security reasons, the hostname set in resolveOverride must
896
+ * be proxied on the same Cloudflare zone of the incoming request.
897
+ * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
898
+ * resolve to a host under a different domain or a DNS only domain first
899
+ * declare a CNAME record within your own zone’s DNS mapping to the
900
+ * external hostname, set proxy on Cloudflare, then set resolveOverride
901
+ * to point to that CNAME record.
472
902
  */
473
- remove(): Element;
903
+ resolveOverride?: string;
474
904
  }
475
905
 
476
- interface Comment {
906
+ interface RequestInitCfPropertiesImage extends BasicImageTransformations {
477
907
  /**
478
- * Indicates whether the element was removed/replaced in a previous handler.
908
+ * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
909
+ * easier to specify higher-DPI sizes in <img srcset>.
479
910
  */
480
- removed: boolean;
911
+ dpr?: number;
481
912
  /**
482
- * This property can be assigned different values, to modify comment’s text.
913
+ * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
914
+ * make images look worse, but load faster. The default is 85. It applies only
915
+ * to JPEG and WebP images. It doesn’t have any effect on PNG.
483
916
  */
484
- text: string;
485
-
486
- /**
487
- * Inserts content before the element.
488
- */
489
- before(content: string, options?: ContentOptions): Element;
917
+ quality?: number;
490
918
  /**
491
- * Inserts content right after the element.
919
+ * Output format to generate. It can be:
920
+ * - avif: generate images in AVIF format.
921
+ * - webp: generate images in Google WebP format. Set quality to 100 to get
922
+ * the WebP-lossless format.
923
+ * - json: instead of generating an image, outputs information about the
924
+ * image, in JSON format. The JSON object will contain image size
925
+ * (before and after resizing), source image’s MIME type, file size, etc.
492
926
  */
493
- after(content: string, options?: ContentOptions): Element;
927
+ format?: "avif" | "webp" | "json";
494
928
  /**
495
- * Removes the element and inserts content in place of it.
929
+ * What EXIF data should be preserved in the output image. Note that EXIF
930
+ * rotation and embedded color profiles are always applied ("baked in" into
931
+ * the image), and aren't affected by this option. Note that if the Polish
932
+ * feature is enabled, all metadata may have been removed already and this
933
+ * option may have no effect.
934
+ * - keep: Preserve most of EXIF metadata, including GPS location if there's
935
+ * any.
936
+ * - copyright: Only keep the copyright tag, and discard everything else.
937
+ * This is the default behavior for JPEG files.
938
+ * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
939
+ * output formats always discard metadata.
496
940
  */
497
- replace(content: string, options?: ContentOptions): Element;
941
+ metadata?: "keep" | "copyright" | "none";
498
942
  /**
499
- * Removes the element with all its content.
943
+ * Overlays are drawn in the order they appear in the array (last array
944
+ * entry is the topmost layer).
500
945
  */
501
- remove(): Element;
946
+ draw?: RequestInitCfPropertiesImageDraw[];
502
947
  }
503
948
 
504
- interface Doctype {
505
- readonly name: string | null;
506
- /**
507
- * Read-Only, The quoted string in the doctype after the PUBLIC atom.
508
- */
509
- readonly publicId: string | null;
510
- /**
511
- * Read-Only, The quoted string in the doctype after the SYSTEM atom or immediately after the publicId.
512
- */
513
- readonly systemId: string | null;
949
+ interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
950
+ /**
951
+ * Absolute URL of the image file to use for the drawing. It can be any of
952
+ * the supported file formats. For drawing of watermarks or non-rectangular
953
+ * overlays we recommend using PNG or WebP images.
954
+ */
955
+ url: string;
956
+ /**
957
+ * Floating-point number between 0 (transparent) and 1 (opaque).
958
+ * For example, opacity: 0.5 makes overlay semitransparent.
959
+ */
960
+ opacity?: number;
961
+ /**
962
+ * - If set to true, the overlay image will be tiled to cover the entire
963
+ * area. This is useful for stock-photo-like watermarks.
964
+ * - If set to "x", the overlay image will be tiled horizontally only
965
+ * (form a line).
966
+ * - If set to "y", the overlay image will be tiled vertically only
967
+ * (form a line).
968
+ */
969
+ repeat?: true | "x" | "y";
970
+ /**
971
+ * Position of the overlay image relative to a given edge. Each property is
972
+ * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
973
+ * positions left side of the overlay 10 pixels from the left edge of the
974
+ * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
975
+ * of the background image.
976
+ *
977
+ * Setting both left & right, or both top & bottom is an error.
978
+ *
979
+ * If no position is specified, the image will be centered.
980
+ */
981
+ top?: number;
982
+ left?: number;
983
+ bottom?: number;
984
+ right?: number;
514
985
  }
515
986
 
516
- interface DocumentEnd {
517
- /**
518
- * Inserts content right after the end of the document.
519
- */
520
- append(content: string, options?: ContentOptions): DocumentEnd;
987
+ interface RequestInitCfPropertiesImageMinify {
988
+ javascript?: boolean;
989
+ css?: boolean;
990
+ html?: boolean;
521
991
  }
522
992
 
523
- interface ElementHandlerOptionals {
524
- /**
525
- * An incoming element, such as `div`
526
- */
527
- element?(element: Element): void | Promise<void>;
528
- /**
529
- * An incoming comment
530
- */
531
- comments?(comment: Comment): void | Promise<void>;
532
- /**
533
- * An incoming piece of text
534
- */
535
- text?(text: Text): void | Promise<void>;
993
+ /**
994
+ * Back compat for code migrating from older definitions.
995
+ * @deprecated Use RequestInit instead.
996
+ */
997
+ declare type RequestInitializerDict = RequestInit;
998
+
999
+ declare class Response extends Body {
1000
+ constructor(bodyInit?: BodyInit | null, maybeInit?: ResponseInit | Response);
1001
+ static redirect(url: string, status?: number): Response;
1002
+ clone(): Response;
1003
+ readonly status: number;
1004
+ readonly statusText: string;
1005
+ readonly headers: Headers;
1006
+ readonly ok: boolean;
1007
+ readonly redirected: boolean;
1008
+ readonly url: string;
1009
+ readonly webSocket: WebSocket | null;
1010
+ readonly cf?: Object;
536
1011
  }
537
1012
 
538
- // See https://stackoverflow.com/a/49725198
539
- type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &
540
- {
541
- [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
542
- }[Keys];
1013
+ interface ResponseInit {
1014
+ status?: number;
1015
+ statusText?: string;
1016
+ headers?: HeadersInit;
1017
+ cf?: Object;
1018
+ webSocket?: WebSocket | null;
1019
+ encodeBody?: string;
1020
+ }
543
1021
 
544
- type ElementHandler = RequireAtLeastOne<ElementHandlerOptionals, 'element' | 'comments' | 'text'>;
1022
+ /**
1023
+ * Back compat for code migrating from older definitions.
1024
+ * @deprecated Use ResponseInit instead.
1025
+ */
1026
+ declare type ResponseInitializerDict = ResponseInit;
545
1027
 
546
- interface DocumentHandler {
547
- /**
548
- * An incoming doctype, such as <!DOCTYPE html>
549
- */
550
- doctype(doctype: Doctype): void | Promise<void>;
551
- /**
552
- * An incoming comment
553
- */
554
- comments(comment: Comment): void | Promise<void>;
555
- /**
556
- * An incoming piece of text
557
- */
558
- text(text: Text): void | Promise<void>;
559
- /**
560
- * The ending of the document
561
- */
562
- end(end: DocumentEnd): void | Promise<void>;
1028
+ interface RsaOtherPrimesInfo {
1029
+ r?: string;
1030
+ d?: string;
1031
+ t?: string;
563
1032
  }
564
1033
 
565
- declare class HTMLRewriter {
566
- constructor();
567
- public on(selector: string, handlers: ElementHandler): HTMLRewriter;
568
- public onDocument(handlers: DocumentHandler): HTMLRewriter;
569
- public transform(response: Response): Response;
1034
+ interface ScheduledController {
1035
+ readonly scheduledTime: number;
1036
+ readonly cron: string;
1037
+ noRetry(): void;
570
1038
  }
571
1039
 
572
- declare interface CacheStorage {
573
- default: Cache;
1040
+ declare abstract class ScheduledEvent extends Event {
1041
+ readonly scheduledTime: number;
1042
+ readonly cron: string;
1043
+ noRetry(): void;
1044
+ waitUntil(promise: Promise<any>): void;
574
1045
  }
575
1046
 
576
- type KVValue<Value> = Promise<Value | null>;
577
- type KVValueWithMetadata<Value, Metadata> = Promise<{
578
- value: Value | null;
579
- metadata: Metadata | null;
580
- }>;
1047
+ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
1048
+ btoa(data: string): string;
1049
+ atob(data: string): string;
1050
+ setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
1051
+ clearTimeout(timeoutId: number | null): void;
1052
+ setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
1053
+ clearInterval(timeoutId: number | null): void;
1054
+ queueMicrotask(task: Function): void;
1055
+ structuredClone(value: any, options?: ServiceWorkerGlobalScopeStructuredCloneOptions): any;
1056
+ fetch(request: Request | string, requestInitr?: RequestInit | Request): Promise<Response>;
1057
+ readonly self: ServiceWorkerGlobalScope;
1058
+ readonly crypto: Crypto;
1059
+ readonly caches: CacheStorage;
1060
+ readonly console: Console;
1061
+ }
581
1062
 
582
- interface KVNamespace {
583
- get(key: string, options?: {cacheTtl?: number;}): KVValue<string>;
584
- get(key: string, type: 'text'): KVValue<string>;
585
- get<ExpectedValue = unknown>(key: string, type: 'json'): KVValue<ExpectedValue>;
586
- get(key: string, type: 'arrayBuffer'): KVValue<ArrayBuffer>;
587
- get(key: string, type: 'stream'): KVValue<ReadableStream>;
588
- get(key: string, options?: {
589
- type: 'text',
590
- cacheTtl?: number;
591
- }): KVValue<string>;
592
- get<ExpectedValue = unknown>(key: string, options?: {
593
- type: 'json',
594
- cacheTtl?: number;
595
- }): KVValue<ExpectedValue>;
596
- get(key: string, options?: {
597
- type: 'arrayBuffer',
598
- cacheTtl?: number;
599
- }): KVValue<ArrayBuffer>;
600
- get(key: string, options?: {
601
- type: 'stream',
602
- cacheTtl?: number;
603
- }): KVValue<ReadableStream>;
604
-
605
- getWithMetadata<Metadata = unknown>(key: string): KVValueWithMetadata<string, Metadata>;
606
- getWithMetadata<Metadata = unknown>(
607
- key: string,
608
- type: 'text'
609
- ): KVValueWithMetadata<string, Metadata>;
610
- getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
611
- key: string,
612
- type: 'json'
613
- ): KVValueWithMetadata<ExpectedValue, Metadata>;
614
- getWithMetadata<Metadata = unknown>(
615
- key: string,
616
- type: 'arrayBuffer'
617
- ): KVValueWithMetadata<ArrayBuffer, Metadata>;
618
- getWithMetadata<Metadata = unknown>(
619
- key: string,
620
- type: 'stream'
621
- ): KVValueWithMetadata<ReadableStream, Metadata>;
622
-
623
- put(
624
- key: string,
625
- value: string | ReadableStream | ArrayBuffer | FormData,
626
- options?: {
627
- expiration?: string | number;
628
- expirationTtl?: string | number;
629
- metadata?: any;
630
- }
631
- ): Promise<void>;
632
-
633
- delete(key: string): Promise<void>;
634
-
635
- list(options?: {
636
- prefix?: string;
637
- limit?: number;
638
- cursor?: string;
639
- }): Promise<{
640
- keys: { name: string; expiration?: number; metadata?: unknown }[];
641
- list_complete: boolean;
642
- cursor?: string;
643
- }>;
644
- }
645
-
646
- interface DurableObjectEntries<T> {
647
- [key: string]: T;
1063
+ interface ServiceWorkerGlobalScopeStructuredCloneOptions {
1064
+ transfer?: any[];
648
1065
  }
649
1066
 
650
- interface DurableObjectListOptions {
651
- start?: string;
652
- end?: string;
653
- reverse?: boolean;
654
- limit?: number;
655
- prefix?: string;
1067
+ declare type StreamPipeOptions = PipeToOptions;
1068
+
1069
+ interface StreamQueuingStrategy {
1070
+ highWaterMark?: number;
1071
+ size(chunk: ArrayBuffer): number;
656
1072
  }
657
1073
 
658
- interface DurableObjectOperator {
659
- get<T = unknown>(key: string): Promise<T>;
660
- get<T = unknown>(keys: Array<string>): Promise<Map<string, T>>;
661
- put<T = unknown>(key: string, value: T): Promise<void>;
662
- put<T = unknown>(entries: DurableObjectEntries<T>): Promise<void>;
663
- delete(key: string): Promise<boolean>;
664
- delete(keys: Array<string>): Promise<number>;
665
- deleteAll(): Promise<void>;
666
- list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
1074
+ declare abstract class SubtleCrypto {
1075
+ encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer): Promise<ArrayBuffer>;
1076
+ decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer): Promise<ArrayBuffer>;
1077
+ sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer): Promise<ArrayBuffer>;
1078
+ verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer, data: ArrayBuffer): Promise<boolean>;
1079
+ digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer): Promise<ArrayBuffer>;
1080
+ generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey | CryptoKeyPair>;
1081
+ deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
1082
+ deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length: number | null): Promise<ArrayBuffer>;
1083
+ importKey(format: string, keyData: ArrayBuffer | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
1084
+ exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
1085
+ wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise<ArrayBuffer>;
1086
+ unwrapKey(format: string, wrappedKey: ArrayBuffer, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
667
1087
  }
668
1088
 
669
- interface DurableObjectTransaction extends DurableObjectOperator {
670
- rollback(): void;
1089
+ interface SubtleCryptoDeriveKeyAlgorithm {
1090
+ name: string;
1091
+ salt?: ArrayBuffer;
1092
+ iterations?: number;
1093
+ hash?: string | SubtleCryptoHashAlgorithm;
1094
+ public?: CryptoKey;
1095
+ info?: ArrayBuffer;
671
1096
  }
672
1097
 
673
- interface DurableObjectStorage extends DurableObjectOperator {
674
- transaction(
675
- closure: (txn: DurableObjectTransaction) => Promise<void>
676
- ): Promise<void>;
1098
+ interface SubtleCryptoEncryptAlgorithm {
1099
+ name: string;
1100
+ iv?: ArrayBuffer;
1101
+ additionalData?: ArrayBuffer;
1102
+ tagLength?: number;
1103
+ counter?: ArrayBuffer;
1104
+ length?: number;
1105
+ label?: ArrayBuffer;
677
1106
  }
678
1107
 
679
- interface DurableObjectState {
680
- id: DurableObjectId;
681
- storage: DurableObjectStorage;
682
- /**
683
- * Use this method to notify the runtime to wait for asynchronous tasks
684
- * (e.g. logging, analytics to third-party services, streaming and caching).
685
- */
686
- waitUntil(promise: Promise<any>): void;
1108
+ interface SubtleCryptoGenerateKeyAlgorithm {
1109
+ name: string;
1110
+ hash?: string | SubtleCryptoHashAlgorithm;
1111
+ modulusLength?: number;
1112
+ publicExponent?: ArrayBuffer;
1113
+ length?: number;
1114
+ namedCurve?: string;
1115
+ }
1116
+
1117
+ interface SubtleCryptoHashAlgorithm {
1118
+ name: string;
1119
+ }
1120
+
1121
+ interface SubtleCryptoImportKeyAlgorithm {
1122
+ name: string;
1123
+ hash?: string | SubtleCryptoHashAlgorithm;
1124
+ length?: number;
1125
+ namedCurve?: string;
1126
+ compressed?: boolean;
687
1127
  }
688
1128
 
689
1129
  /**
690
- * DurableObject is a class that defines a template for creating Durable Objects
1130
+ *
1131
+ * @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
691
1132
  */
692
- interface DurableObject {
693
- fetch: (request: Request) => Promise<Response>;
1133
+ declare type SubtleCryptoJsonWebKey = JsonWebKey;
1134
+
1135
+ /**
1136
+ *
1137
+ * @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
1138
+ */
1139
+ declare type SubtleCryptoJsonWebKeyRsaOtherPrimesInfo = RsaOtherPrimesInfo;
1140
+
1141
+ interface SubtleCryptoSignAlgorithm {
1142
+ name: string;
1143
+ hash?: string | SubtleCryptoHashAlgorithm;
1144
+ dataLength?: number;
1145
+ saltLength?: number;
1146
+ }
1147
+
1148
+ interface Text {
1149
+ readonly text: string;
1150
+ readonly lastInTextNode: boolean;
1151
+ readonly removed: boolean;
1152
+ before(content: Content, options?: ContentOptions): Text;
1153
+ after(content: Content, options?: ContentOptions): Text;
1154
+ replace(content: Content, options?: ContentOptions): Text;
1155
+ remove(): Text;
1156
+ }
1157
+
1158
+ declare class TextDecoder {
1159
+ constructor(label?: "utf-8" | "utf8" | "unicode-1-1-utf-8", options?: TextDecoderConstructorOptions);
1160
+ decode(input?: ArrayBuffer, options?: TextDecoderDecodeOptions): string;
1161
+ readonly encoding: string;
1162
+ readonly fatal: boolean;
1163
+ readonly ignoreBOM: boolean;
1164
+ }
1165
+
1166
+ interface TextDecoderConstructorOptions {
1167
+ fatal: boolean;
1168
+ ignoreBOM: boolean;
1169
+ }
1170
+
1171
+ interface TextDecoderDecodeOptions {
1172
+ stream: boolean;
1173
+ }
1174
+
1175
+ declare class TextEncoder {
1176
+ constructor();
1177
+ encode(input?: string): Uint8Array;
1178
+ encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
1179
+ readonly encoding: string;
1180
+ }
1181
+
1182
+ interface TextEncoderEncodeIntoResult {
1183
+ read: number;
1184
+ written: number;
1185
+ }
1186
+
1187
+ declare class TransformStream {
1188
+ constructor();
1189
+ readonly readable: ReadableStream;
1190
+ readonly writable: WritableStream;
1191
+ }
1192
+
1193
+ declare class URL {
1194
+ constructor(url: string, base?: string);
1195
+ href: string;
1196
+ readonly origin: string;
1197
+ protocol: string;
1198
+ username: string;
1199
+ password: string;
1200
+ host: string;
1201
+ hostname: string;
1202
+ port: string;
1203
+ pathname: string;
1204
+ search: string;
1205
+ readonly searchParams: URLSearchParams;
1206
+ hash: string;
1207
+ toString(): string;
1208
+ toJSON(): string;
1209
+ }
1210
+
1211
+ declare class URLSearchParams {
1212
+ constructor(init?: URLSearchParamsInit);
1213
+ append(name: string, value: string): void;
1214
+ delete(name: string): void;
1215
+ get(name: string): string | null;
1216
+ getAll(name: string): string[];
1217
+ has(name: string): boolean;
1218
+ set(name: string, value: string): void;
1219
+ sort(): void;
1220
+ entries(): IterableIterator<[key: string, value: string]>;
1221
+ keys(): IterableIterator<string>;
1222
+ values(): IterableIterator<string>;
1223
+ forEach<This = unknown>(callback: (this: This, key: string, value: string, parent: URLSearchParams) => void, thisArg?: This): void;
1224
+ [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
1225
+ toString(): string;
694
1226
  }
695
1227
 
1228
+ declare type URLSearchParamsInit = URLSearchParams | string | Record<string, string> | ([key: string, value: string])[];
1229
+
696
1230
  /**
697
- * DurableObjectStub is a client object used to send requests to a remote Durable Object
1231
+ * Back compat for code migrating to older definitions.
1232
+ * This technically isn't part of a standard either way, but the naming
1233
+ * is more consistent.
1234
+ * @deprecated Use URLSearchParamsInit instead.
698
1235
  */
699
- interface DurableObjectStub {
700
- name?: string;
701
- id: DurableObjectId;
702
- fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
1236
+ declare type URLSearchParamsInitializer = URLSearchParamsInit;
1237
+
1238
+ declare abstract class WebSocket extends EventTarget<WebSocketEventMap> {
1239
+ accept(): void;
1240
+ send(message: ArrayBuffer | string): void;
1241
+ close(code?: number, reason?: string): void;
703
1242
  }
704
1243
 
705
- interface DurableObjectId {
706
- name?: string;
707
- toString: () => string;
1244
+ declare type WebSocketEventMap = { close: CloseEvent; message: MessageEvent; error: Event; };
1245
+
1246
+ declare const WebSocketPair: { new(): { 0: WebSocket; 1: WebSocket; }; };
1247
+
1248
+ declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
1249
+
708
1250
  }
709
1251
 
710
- interface DurableObjectNamespace {
711
- newUniqueId: () => DurableObjectId;
712
- idFromName: (name: string) => DurableObjectId;
713
- idFromString: (hexId: string) => DurableObjectId;
1252
+ declare type WorkerGlobalScopeEventMap = { fetch: FetchEvent; scheduled: ScheduledEvent; unhandledrejection: PromiseRejectionEvent; rejectionhandled: PromiseRejectionEvent; };
1253
+
1254
+ declare abstract class WritableStream {
1255
+ readonly locked: boolean;
1256
+ abort(reason: any): Promise<void>;
1257
+ close(): Promise<void>;
1258
+ getWriter(): WritableStreamDefaultWriter;
1259
+ }
714
1260
 
715
- get: (id: DurableObjectId) => DurableObjectStub;
1261
+ declare class WritableStreamDefaultWriter {
1262
+ constructor(stream: WritableStream);
1263
+ readonly closed: Promise<void>;
1264
+ readonly ready: Promise<void>;
1265
+ readonly desiredSize: number | null;
1266
+ abort(reason: any): Promise<void>;
1267
+ close(): Promise<void>;
1268
+ write(chunk: any): Promise<void>;
1269
+ releaseLock(): void;
716
1270
  }
1271
+
1272
+ /**
1273
+ * Back-compat alias.
1274
+ * @deprecated Use WritableStreamDefaultWriter
1275
+ */
1276
+ declare type WritableStreamWritableStreamDefaultWriter = WritableStreamDefaultWriter;
1277
+
1278
+ declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
1279
+
1280
+ declare function atob(data: string): string;
1281
+
1282
+ declare function btoa(data: string): string;
1283
+
1284
+ declare const caches: CacheStorage;
1285
+
1286
+ declare function clearInterval(timeoutId: number | null): void;
1287
+
1288
+ declare function clearTimeout(timeoutId: number | null): void;
1289
+
1290
+ declare const console: Console;
1291
+
1292
+ declare const crypto: Crypto;
1293
+
1294
+ declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean;
1295
+
1296
+ declare function fetch(request: Request | string, requestInitr?: RequestInit | Request): Promise<Response>;
1297
+
1298
+ declare function queueMicrotask(task: Function): void;
1299
+
1300
+ declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
1301
+
1302
+ declare const self: ServiceWorkerGlobalScope;
1303
+
1304
+ declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
1305
+
1306
+ declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
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>;