@cloudflare/workers-types 3.1.1 → 3.4.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 +528 -116
- package/package.json +8 -4
package/index.d.ts
CHANGED
|
@@ -4,13 +4,16 @@
|
|
|
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
|
+
static timeout(delay: number): AbortSignal;
|
|
13
14
|
readonly aborted: boolean;
|
|
15
|
+
readonly reason: any;
|
|
16
|
+
throwIfAborted(): void;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
interface BasicImageTransformations {
|
|
@@ -35,10 +38,11 @@ interface BasicImageTransformations {
|
|
|
35
38
|
* - cover: Resizes (shrinks or enlarges) to fill the entire area of width
|
|
36
39
|
* and height. If the image has an aspect ratio different from the ratio
|
|
37
40
|
* of width and height, it will be cropped to fit.
|
|
38
|
-
* - crop: The image will shrunk and cropped to fit within the area
|
|
39
|
-
* specified by width and height. The image
|
|
40
|
-
* smaller than the given dimensions it
|
|
41
|
-
* images larger than the given dimensions, it
|
|
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.
|
|
42
46
|
* - pad: Resizes to the maximum size that fits within the given width and
|
|
43
47
|
* height, and then fills the remaining area with a background color
|
|
44
48
|
* (white by default). Use of this mode is not recommended, as the same
|
|
@@ -58,7 +62,14 @@ interface BasicImageTransformations {
|
|
|
58
62
|
* preserve as much as possible around a point at 20% of the height of the
|
|
59
63
|
* source image.
|
|
60
64
|
*/
|
|
61
|
-
gravity?:
|
|
65
|
+
gravity?:
|
|
66
|
+
| "left"
|
|
67
|
+
| "right"
|
|
68
|
+
| "top"
|
|
69
|
+
| "bottom"
|
|
70
|
+
| "center"
|
|
71
|
+
| "auto"
|
|
72
|
+
| BasicImageTransformationsGravityCoordinates;
|
|
62
73
|
/**
|
|
63
74
|
* Background color to add underneath the image. Applies only to images with
|
|
64
75
|
* transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…),
|
|
@@ -103,7 +114,13 @@ declare abstract class Body {
|
|
|
103
114
|
blob(): Promise<Blob>;
|
|
104
115
|
}
|
|
105
116
|
|
|
106
|
-
declare type BodyInit =
|
|
117
|
+
declare type BodyInit =
|
|
118
|
+
| ReadableStream
|
|
119
|
+
| string
|
|
120
|
+
| ArrayBuffer
|
|
121
|
+
| Blob
|
|
122
|
+
| URLSearchParams
|
|
123
|
+
| FormData;
|
|
107
124
|
|
|
108
125
|
/**
|
|
109
126
|
* Back compat for code migrating to older definitions.
|
|
@@ -112,8 +129,14 @@ declare type BodyInit = ReadableStream | string | ArrayBuffer | Blob | URLSearch
|
|
|
112
129
|
declare type BodyInitializer = BodyInit;
|
|
113
130
|
|
|
114
131
|
declare abstract class Cache {
|
|
115
|
-
delete(
|
|
116
|
-
|
|
132
|
+
delete(
|
|
133
|
+
request: Request | string,
|
|
134
|
+
options?: CacheQueryOptions
|
|
135
|
+
): Promise<boolean>;
|
|
136
|
+
match(
|
|
137
|
+
request: Request | string,
|
|
138
|
+
options?: CacheQueryOptions
|
|
139
|
+
): Promise<Response | undefined>;
|
|
117
140
|
put(request: Request | string, response: Response): Promise<void>;
|
|
118
141
|
}
|
|
119
142
|
|
|
@@ -180,7 +203,17 @@ interface ContentOptions {
|
|
|
180
203
|
|
|
181
204
|
declare abstract class Crypto {
|
|
182
205
|
readonly subtle: SubtleCrypto;
|
|
183
|
-
getRandomValues<
|
|
206
|
+
getRandomValues<
|
|
207
|
+
T extends
|
|
208
|
+
| Int8Array
|
|
209
|
+
| Uint8Array
|
|
210
|
+
| Int16Array
|
|
211
|
+
| Uint16Array
|
|
212
|
+
| Int32Array
|
|
213
|
+
| Uint32Array
|
|
214
|
+
| BigInt64Array
|
|
215
|
+
| BigUint64Array
|
|
216
|
+
>(buffer: T): T;
|
|
184
217
|
randomUUID(): string;
|
|
185
218
|
}
|
|
186
219
|
|
|
@@ -196,7 +229,14 @@ interface CryptoKeyAesKeyAlgorithm {
|
|
|
196
229
|
length: number;
|
|
197
230
|
}
|
|
198
231
|
|
|
199
|
-
declare type CryptoKeyAlgorithmVariant =
|
|
232
|
+
declare type CryptoKeyAlgorithmVariant =
|
|
233
|
+
| CryptoKeyKeyAlgorithm
|
|
234
|
+
| CryptoKeyAesKeyAlgorithm
|
|
235
|
+
| CryptoKeyHmacKeyAlgorithm
|
|
236
|
+
| CryptoKeyRsaKeyAlgorithm
|
|
237
|
+
| CryptoKeyEllipticKeyAlgorithm
|
|
238
|
+
| CryptoKeyVoprfKeyAlgorithm
|
|
239
|
+
| CryptoKeyOprfKeyAlgorithm;
|
|
200
240
|
|
|
201
241
|
interface CryptoKeyEllipticKeyAlgorithm {
|
|
202
242
|
name: string;
|
|
@@ -266,6 +306,11 @@ declare class DOMException extends Error {
|
|
|
266
306
|
static readonly DATA_CLONE_ERR: number;
|
|
267
307
|
}
|
|
268
308
|
|
|
309
|
+
declare class DigestStream extends WritableStream {
|
|
310
|
+
constructor(algorithm: string | SubtleCryptoHashAlgorithm);
|
|
311
|
+
readonly digest: Promise<ArrayBuffer>;
|
|
312
|
+
}
|
|
313
|
+
|
|
269
314
|
interface Doctype {
|
|
270
315
|
readonly name: string | null;
|
|
271
316
|
readonly publicId: string | null;
|
|
@@ -302,7 +347,9 @@ interface DurableObjectListOptions {
|
|
|
302
347
|
}
|
|
303
348
|
|
|
304
349
|
interface DurableObjectNamespace {
|
|
305
|
-
newUniqueId(
|
|
350
|
+
newUniqueId(
|
|
351
|
+
options?: DurableObjectNamespaceNewUniqueIdOptions
|
|
352
|
+
): DurableObjectId;
|
|
306
353
|
idFromName(name: string): DurableObjectId;
|
|
307
354
|
idFromString(id: string): DurableObjectId;
|
|
308
355
|
get(id: DurableObjectId): DurableObjectStub;
|
|
@@ -326,31 +373,49 @@ interface DurableObjectState {
|
|
|
326
373
|
}
|
|
327
374
|
|
|
328
375
|
interface DurableObjectStorage {
|
|
329
|
-
get<T = unknown>(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
376
|
+
get<T = unknown>(
|
|
377
|
+
key: string,
|
|
378
|
+
options?: DurableObjectGetOptions
|
|
379
|
+
): Promise<T | undefined>;
|
|
380
|
+
get<T = unknown>(
|
|
381
|
+
keys: string[],
|
|
382
|
+
options?: DurableObjectGetOptions
|
|
383
|
+
): Promise<Map<string, T>>;
|
|
384
|
+
list<T = unknown>(
|
|
385
|
+
options?: DurableObjectListOptions
|
|
386
|
+
): Promise<Map<string, T>>;
|
|
387
|
+
put<T>(
|
|
388
|
+
key: string,
|
|
389
|
+
value: T,
|
|
390
|
+
options?: DurableObjectPutOptions
|
|
391
|
+
): Promise<void>;
|
|
392
|
+
put<T>(
|
|
393
|
+
entries: Record<string, T>,
|
|
394
|
+
options?: DurableObjectPutOptions
|
|
395
|
+
): Promise<void>;
|
|
334
396
|
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
|
|
335
397
|
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
|
|
336
398
|
deleteAll(options?: DurableObjectPutOptions): Promise<void>;
|
|
337
|
-
transaction<T>(
|
|
399
|
+
transaction<T>(
|
|
400
|
+
closure: (txn: DurableObjectTransaction) => Promise<T>
|
|
401
|
+
): Promise<T>;
|
|
338
402
|
}
|
|
339
403
|
|
|
340
404
|
/**
|
|
341
|
-
*
|
|
405
|
+
*
|
|
342
406
|
* @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
|
|
343
407
|
*/
|
|
344
408
|
declare type DurableObjectStorageOperationsGetOptions = DurableObjectGetOptions;
|
|
345
409
|
|
|
346
410
|
/**
|
|
347
|
-
*
|
|
411
|
+
*
|
|
348
412
|
* @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
|
|
349
413
|
*/
|
|
350
|
-
declare type DurableObjectStorageOperationsListOptions =
|
|
414
|
+
declare type DurableObjectStorageOperationsListOptions =
|
|
415
|
+
DurableObjectListOptions;
|
|
351
416
|
|
|
352
417
|
/**
|
|
353
|
-
*
|
|
418
|
+
*
|
|
354
419
|
* @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
|
|
355
420
|
*/
|
|
356
421
|
declare type DurableObjectStorageOperationsPutOptions = DurableObjectPutOptions;
|
|
@@ -362,10 +427,22 @@ interface DurableObjectStub extends Fetcher {
|
|
|
362
427
|
|
|
363
428
|
interface DurableObjectTransaction {
|
|
364
429
|
get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T>;
|
|
365
|
-
get<T = unknown>(
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
430
|
+
get<T = unknown>(
|
|
431
|
+
keys: string[],
|
|
432
|
+
options?: DurableObjectGetOptions
|
|
433
|
+
): Promise<Map<string, T>>;
|
|
434
|
+
list<T = unknown>(
|
|
435
|
+
options?: DurableObjectListOptions
|
|
436
|
+
): Promise<Map<string, T>>;
|
|
437
|
+
put<T>(
|
|
438
|
+
key: string,
|
|
439
|
+
value: T,
|
|
440
|
+
options?: DurableObjectPutOptions
|
|
441
|
+
): Promise<void>;
|
|
442
|
+
put<T>(
|
|
443
|
+
entries: Record<string, T>,
|
|
444
|
+
options?: DurableObjectPutOptions
|
|
445
|
+
): Promise<void>;
|
|
369
446
|
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
|
|
370
447
|
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
|
|
371
448
|
rollback(): void;
|
|
@@ -388,6 +465,14 @@ interface Element {
|
|
|
388
465
|
remove(): Element;
|
|
389
466
|
removeAndKeepContent(): Element;
|
|
390
467
|
setInnerContent(content: Content, options?: ContentOptions): Element;
|
|
468
|
+
onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
interface EndTag {
|
|
472
|
+
name: string;
|
|
473
|
+
before(content: Content, options?: ContentOptions): EndTag;
|
|
474
|
+
after(content: Content, options?: ContentOptions): EndTag;
|
|
475
|
+
remove(): EndTag;
|
|
391
476
|
}
|
|
392
477
|
|
|
393
478
|
declare class Event {
|
|
@@ -420,18 +505,32 @@ interface EventInit {
|
|
|
420
505
|
composed?: boolean;
|
|
421
506
|
}
|
|
422
507
|
|
|
423
|
-
declare type EventListener<EventType extends Event = Event> = (
|
|
508
|
+
declare type EventListener<EventType extends Event = Event> = (
|
|
509
|
+
event: EventType
|
|
510
|
+
) => void;
|
|
424
511
|
|
|
425
512
|
interface EventListenerObject<EventType extends Event = Event> {
|
|
426
513
|
handleEvent(event: EventType): void;
|
|
427
514
|
}
|
|
428
515
|
|
|
429
|
-
declare type EventListenerOrEventListenerObject<
|
|
516
|
+
declare type EventListenerOrEventListenerObject<
|
|
517
|
+
EventType extends Event = Event
|
|
518
|
+
> = EventListener<EventType> | EventListenerObject<EventType>;
|
|
430
519
|
|
|
431
|
-
declare class EventTarget<
|
|
520
|
+
declare class EventTarget<
|
|
521
|
+
EventMap extends Record<string, Event> = Record<string, Event>
|
|
522
|
+
> {
|
|
432
523
|
constructor();
|
|
433
|
-
addEventListener<Type extends keyof EventMap>(
|
|
434
|
-
|
|
524
|
+
addEventListener<Type extends keyof EventMap>(
|
|
525
|
+
type: Type,
|
|
526
|
+
handler: EventListenerOrEventListenerObject<EventMap[Type]>,
|
|
527
|
+
options?: EventTargetAddEventListenerOptions | boolean
|
|
528
|
+
): void;
|
|
529
|
+
removeEventListener<Type extends keyof EventMap>(
|
|
530
|
+
type: Type,
|
|
531
|
+
handler: EventListenerOrEventListenerObject<EventMap[Type]>,
|
|
532
|
+
options?: EventTargetEventListenerOptions | boolean
|
|
533
|
+
): void;
|
|
435
534
|
dispatchEvent(event: EventMap[keyof EventMap]): boolean;
|
|
436
535
|
}
|
|
437
536
|
|
|
@@ -456,9 +555,17 @@ interface ExportedHandler<Env = unknown> {
|
|
|
456
555
|
scheduled?: ExportedHandlerScheduledHandler<Env>;
|
|
457
556
|
}
|
|
458
557
|
|
|
459
|
-
declare type ExportedHandlerFetchHandler<Env = unknown> = (
|
|
558
|
+
declare type ExportedHandlerFetchHandler<Env = unknown> = (
|
|
559
|
+
request: Request,
|
|
560
|
+
env: Env,
|
|
561
|
+
ctx: ExecutionContext
|
|
562
|
+
) => Response | Promise<Response>;
|
|
460
563
|
|
|
461
|
-
declare type ExportedHandlerScheduledHandler<Env = unknown> = (
|
|
564
|
+
declare type ExportedHandlerScheduledHandler<Env = unknown> = (
|
|
565
|
+
controller: ScheduledController,
|
|
566
|
+
env: Env,
|
|
567
|
+
ctx: ExecutionContext
|
|
568
|
+
) => void | Promise<void>;
|
|
462
569
|
|
|
463
570
|
declare abstract class FetchEvent extends Event {
|
|
464
571
|
readonly request: Request;
|
|
@@ -468,7 +575,10 @@ declare abstract class FetchEvent extends Event {
|
|
|
468
575
|
}
|
|
469
576
|
|
|
470
577
|
declare abstract class Fetcher {
|
|
471
|
-
fetch(
|
|
578
|
+
fetch(
|
|
579
|
+
requestOrUrl: Request | string,
|
|
580
|
+
requestInit?: RequestInit | Request
|
|
581
|
+
): Promise<Response>;
|
|
472
582
|
}
|
|
473
583
|
|
|
474
584
|
declare class File extends Blob {
|
|
@@ -496,16 +606,27 @@ declare class FormData {
|
|
|
496
606
|
has(name: string): boolean;
|
|
497
607
|
set(name: string, value: string): void;
|
|
498
608
|
set(name: string, value: Blob, filename?: string): void;
|
|
499
|
-
entries(): IterableIterator<
|
|
609
|
+
entries(): IterableIterator<[key: string, value: File | string]>;
|
|
500
610
|
keys(): IterableIterator<string>;
|
|
501
611
|
values(): IterableIterator<File | string>;
|
|
502
|
-
forEach<This = unknown>(
|
|
503
|
-
|
|
612
|
+
forEach<This = unknown>(
|
|
613
|
+
callback: (
|
|
614
|
+
this: This,
|
|
615
|
+
key: string,
|
|
616
|
+
value: File | string,
|
|
617
|
+
parent: FormData
|
|
618
|
+
) => void,
|
|
619
|
+
thisArg?: This
|
|
620
|
+
): void;
|
|
621
|
+
[Symbol.iterator](): IterableIterator<[key: string, value: File | string]>;
|
|
504
622
|
}
|
|
505
623
|
|
|
506
624
|
declare class HTMLRewriter {
|
|
507
625
|
constructor();
|
|
508
|
-
on(
|
|
626
|
+
on(
|
|
627
|
+
selector: string,
|
|
628
|
+
handlers: HTMLRewriterElementContentHandlers
|
|
629
|
+
): HTMLRewriter;
|
|
509
630
|
onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
|
|
510
631
|
transform(response: Response): Response;
|
|
511
632
|
}
|
|
@@ -531,14 +652,20 @@ declare class Headers {
|
|
|
531
652
|
set(name: string, value: string): void;
|
|
532
653
|
append(name: string, value: string): void;
|
|
533
654
|
delete(name: string): void;
|
|
534
|
-
forEach<This = unknown>(
|
|
655
|
+
forEach<This = unknown>(
|
|
656
|
+
callback: (this: This, key: string, value: string, parent: Headers) => void,
|
|
657
|
+
thisArg?: This
|
|
658
|
+
): void;
|
|
535
659
|
entries(): IterableIterator<[key: string, value: string]>;
|
|
536
660
|
keys(): IterableIterator<string>;
|
|
537
661
|
values(): IterableIterator<string>;
|
|
538
662
|
[Symbol.iterator](): IterableIterator<[key: string, value: string]>;
|
|
539
663
|
}
|
|
540
664
|
|
|
541
|
-
declare type HeadersInit =
|
|
665
|
+
declare type HeadersInit =
|
|
666
|
+
| Headers
|
|
667
|
+
| Record<string, string>
|
|
668
|
+
| [key: string, value: string][];
|
|
542
669
|
|
|
543
670
|
/**
|
|
544
671
|
* Back compat for code migrating to older definitions.
|
|
@@ -550,7 +677,7 @@ declare type HeadersInitializer = HeadersInit;
|
|
|
550
677
|
* In addition to the properties on the standard Request object,
|
|
551
678
|
* the cf object contains extra information about the request provided
|
|
552
679
|
* by Cloudflare's edge.
|
|
553
|
-
*
|
|
680
|
+
*
|
|
554
681
|
* Note: Currently, settings in the cf object cannot be accessed in the
|
|
555
682
|
* playground.
|
|
556
683
|
*/
|
|
@@ -661,35 +788,83 @@ interface JsonWebKey {
|
|
|
661
788
|
* Workers KV is a global, low-latency, key-value data store. It supports exceptionally high read volumes with low-latency,
|
|
662
789
|
* making it possible to build highly dynamic APIs and websites which respond as quickly as a cached static file would.
|
|
663
790
|
*/
|
|
664
|
-
interface KVNamespace {
|
|
665
|
-
get(
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
get(key:
|
|
670
|
-
get
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
791
|
+
interface KVNamespace<K extends string = string> {
|
|
792
|
+
get(
|
|
793
|
+
key: K,
|
|
794
|
+
options?: Partial<KVNamespaceGetOptions<undefined>>
|
|
795
|
+
): Promise<string | null>;
|
|
796
|
+
get(key: K, type: "text"): Promise<string | null>;
|
|
797
|
+
get<ExpectedValue = unknown>(
|
|
798
|
+
key: K,
|
|
799
|
+
type: "json"
|
|
800
|
+
): Promise<ExpectedValue | null>;
|
|
801
|
+
get(key: K, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
|
|
802
|
+
get(key: K, type: "stream"): Promise<ReadableStream | null>;
|
|
803
|
+
get(key: K, options: KVNamespaceGetOptions<"text">): Promise<string | null>;
|
|
804
|
+
get<ExpectedValue = unknown>(
|
|
805
|
+
key: string,
|
|
806
|
+
options: KVNamespaceGetOptions<"json">
|
|
807
|
+
): Promise<ExpectedValue | null>;
|
|
808
|
+
get(
|
|
809
|
+
key: K,
|
|
810
|
+
options: KVNamespaceGetOptions<"arrayBuffer">
|
|
811
|
+
): Promise<ArrayBuffer | null>;
|
|
812
|
+
get(
|
|
813
|
+
key: K,
|
|
814
|
+
options: KVNamespaceGetOptions<"stream">
|
|
815
|
+
): Promise<ReadableStream | null>;
|
|
816
|
+
list<Metadata = unknown>(
|
|
817
|
+
options?: KVNamespaceListOptions
|
|
818
|
+
): Promise<KVNamespaceListResult<Metadata>>;
|
|
675
819
|
/**
|
|
676
820
|
* Creates a new key-value pair, or updates the value for a particular key.
|
|
677
821
|
* @param key key to associate with the value. A key cannot be empty, `.` or `..`. All other keys are valid.
|
|
678
822
|
* @param value value to store. The type is inferred. The maximum size of a value is 25MB.
|
|
679
823
|
* @returns Returns a `Promise` that you should `await` on in order to verify a successful update.
|
|
680
824
|
* @example
|
|
681
|
-
* await NAMESPACE.put(key, value)
|
|
825
|
+
* await NAMESPACE.put(key, value);
|
|
682
826
|
*/
|
|
683
|
-
put(
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
getWithMetadata<Metadata = unknown>(
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
getWithMetadata<Metadata = unknown>(
|
|
827
|
+
put(
|
|
828
|
+
key: K,
|
|
829
|
+
value: string | ArrayBuffer | ArrayBufferView | ReadableStream,
|
|
830
|
+
options?: KVNamespacePutOptions
|
|
831
|
+
): Promise<void>;
|
|
832
|
+
getWithMetadata<Metadata = unknown>(
|
|
833
|
+
key: K,
|
|
834
|
+
options?: Partial<KVNamespaceGetOptions<undefined>>
|
|
835
|
+
): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
|
|
836
|
+
getWithMetadata<Metadata = unknown>(
|
|
837
|
+
key: K,
|
|
838
|
+
type: "text"
|
|
839
|
+
): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
|
|
840
|
+
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
|
|
841
|
+
key: K,
|
|
842
|
+
type: "json"
|
|
843
|
+
): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
|
|
844
|
+
getWithMetadata<Metadata = unknown>(
|
|
845
|
+
key: K,
|
|
846
|
+
type: "arrayBuffer"
|
|
847
|
+
): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
|
|
848
|
+
getWithMetadata<Metadata = unknown>(
|
|
849
|
+
key: K,
|
|
850
|
+
type: "stream"
|
|
851
|
+
): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
|
|
852
|
+
getWithMetadata<Metadata = unknown>(
|
|
853
|
+
key: K,
|
|
854
|
+
options: KVNamespaceGetOptions<"text">
|
|
855
|
+
): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
|
|
856
|
+
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
|
|
857
|
+
key: K,
|
|
858
|
+
options: KVNamespaceGetOptions<"json">
|
|
859
|
+
): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
|
|
860
|
+
getWithMetadata<Metadata = unknown>(
|
|
861
|
+
key: K,
|
|
862
|
+
options: KVNamespaceGetOptions<"arrayBuffer">
|
|
863
|
+
): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
|
|
864
|
+
getWithMetadata<Metadata = unknown>(
|
|
865
|
+
key: K,
|
|
866
|
+
options: KVNamespaceGetOptions<"stream">
|
|
867
|
+
): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
|
|
693
868
|
delete(name: string): Promise<void>;
|
|
694
869
|
}
|
|
695
870
|
|
|
@@ -762,23 +937,60 @@ interface ReadResult {
|
|
|
762
937
|
done: boolean;
|
|
763
938
|
}
|
|
764
939
|
|
|
765
|
-
declare abstract class
|
|
940
|
+
declare abstract class ReadableByteStreamController {
|
|
941
|
+
readonly byobRequest: ReadableStreamBYOBRequest | null;
|
|
942
|
+
readonly desiredSize: number | null;
|
|
943
|
+
close(): void;
|
|
944
|
+
enqueue(chunk: ArrayBufferView): void;
|
|
945
|
+
error(reason: any): void;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
declare class ReadableStream {
|
|
949
|
+
constructor(underlyingSource?: Object, queuingStrategy?: Object);
|
|
766
950
|
readonly locked: boolean;
|
|
767
951
|
cancel(reason?: any): Promise<void>;
|
|
768
952
|
getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
|
|
769
953
|
getReader(): ReadableStreamDefaultReader;
|
|
770
|
-
pipeThrough(
|
|
954
|
+
pipeThrough(
|
|
955
|
+
transform: ReadableStreamTransform,
|
|
956
|
+
options?: PipeToOptions
|
|
957
|
+
): ReadableStream;
|
|
771
958
|
pipeTo(destination: WritableStream, options?: PipeToOptions): Promise<void>;
|
|
772
959
|
tee(): [ReadableStream, ReadableStream];
|
|
960
|
+
values(
|
|
961
|
+
options?: ReadableStreamValuesOptions
|
|
962
|
+
): AsyncIterableIterator<ReadableStreamReadResult>;
|
|
963
|
+
[Symbol.asyncIterator](
|
|
964
|
+
options?: ReadableStreamValuesOptions
|
|
965
|
+
): AsyncIterableIterator<ReadableStreamReadResult>;
|
|
773
966
|
}
|
|
774
967
|
|
|
775
968
|
declare class ReadableStreamBYOBReader {
|
|
776
969
|
constructor(stream: ReadableStream);
|
|
777
970
|
readonly closed: Promise<void>;
|
|
778
971
|
cancel(reason?: any): Promise<void>;
|
|
779
|
-
read<T extends ArrayBufferView>(
|
|
972
|
+
read<T extends ArrayBufferView>(
|
|
973
|
+
view: T
|
|
974
|
+
): Promise<ReadableStreamReadResult<T>>;
|
|
780
975
|
releaseLock(): void;
|
|
781
|
-
readAtLeast(
|
|
976
|
+
readAtLeast(
|
|
977
|
+
minBytes: number,
|
|
978
|
+
view: Uint8Array
|
|
979
|
+
): Promise<ReadableStreamReadResult<Uint8Array>>;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
declare abstract class ReadableStreamBYOBRequest {
|
|
983
|
+
readonly view: Uint8Array | null;
|
|
984
|
+
respond(bytesWritten: number): void;
|
|
985
|
+
respondWithNewView(view: ArrayBufferView): void;
|
|
986
|
+
readonly atLeast: number | null;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
declare abstract class ReadableStreamDefaultController {
|
|
990
|
+
readonly desiredSize: number | null;
|
|
991
|
+
close(): void;
|
|
992
|
+
enqueue(chunk?: any): void;
|
|
993
|
+
error(reason: any): void;
|
|
782
994
|
}
|
|
783
995
|
|
|
784
996
|
declare class ReadableStreamDefaultReader {
|
|
@@ -799,7 +1011,9 @@ interface ReadableStreamGetReaderOptions {
|
|
|
799
1011
|
*/
|
|
800
1012
|
declare type ReadableStreamPipeToOptions = PipeToOptions;
|
|
801
1013
|
|
|
802
|
-
declare type ReadableStreamReadResult<T = any> =
|
|
1014
|
+
declare type ReadableStreamReadResult<T = any> =
|
|
1015
|
+
| { done: true; value: undefined }
|
|
1016
|
+
| { done: false; value: T };
|
|
803
1017
|
|
|
804
1018
|
/**
|
|
805
1019
|
* Back-compat alias.
|
|
@@ -811,13 +1025,18 @@ declare type ReadableStreamReadableStreamBYOBReader = ReadableStreamBYOBReader;
|
|
|
811
1025
|
* Back-compat alias.
|
|
812
1026
|
* @deprecated Use ReadableStreamDefaultReader
|
|
813
1027
|
*/
|
|
814
|
-
declare type ReadableStreamReadableStreamDefaultReader =
|
|
1028
|
+
declare type ReadableStreamReadableStreamDefaultReader =
|
|
1029
|
+
ReadableStreamDefaultReader;
|
|
815
1030
|
|
|
816
1031
|
interface ReadableStreamTransform {
|
|
817
1032
|
writable: WritableStream;
|
|
818
1033
|
readable: ReadableStream;
|
|
819
1034
|
}
|
|
820
1035
|
|
|
1036
|
+
interface ReadableStreamValuesOptions {
|
|
1037
|
+
preventCancel?: boolean;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
821
1040
|
declare class Request extends Body {
|
|
822
1041
|
constructor(input: Request | string, init?: RequestInit | Request);
|
|
823
1042
|
clone(): Request;
|
|
@@ -839,10 +1058,10 @@ interface RequestInit {
|
|
|
839
1058
|
/**
|
|
840
1059
|
* cf is a union of these two types because there are multiple
|
|
841
1060
|
* scenarios in which it might be one or the other.
|
|
842
|
-
*
|
|
1061
|
+
*
|
|
843
1062
|
* IncomingRequestCfProperties is required to allow
|
|
844
1063
|
* new Request(someUrl, event.request)
|
|
845
|
-
*
|
|
1064
|
+
*
|
|
846
1065
|
* RequestInitCfProperties is required to allow
|
|
847
1066
|
* new Request(event.request, {cf: { ... } })
|
|
848
1067
|
* fetch(someUrl, {cf: { ... } })
|
|
@@ -856,7 +1075,7 @@ interface RequestInit {
|
|
|
856
1075
|
* that you pass as an argument to the Request constructor, you can
|
|
857
1076
|
* set certain properties of a `cf` object to control how Cloudflare
|
|
858
1077
|
* features are applied to that new Request.
|
|
859
|
-
*
|
|
1078
|
+
*
|
|
860
1079
|
* Note: Currently, these properties cannot be tested in the
|
|
861
1080
|
* playground.
|
|
862
1081
|
*/
|
|
@@ -867,7 +1086,7 @@ interface RequestInitCfProperties {
|
|
|
867
1086
|
* "the same" for caching purposes. If a request has the same cache key
|
|
868
1087
|
* as some previous request, then we can serve the same cached response for
|
|
869
1088
|
* both. (e.g. 'some-key')
|
|
870
|
-
*
|
|
1089
|
+
*
|
|
871
1090
|
* Only available for Enterprise customers.
|
|
872
1091
|
*/
|
|
873
1092
|
cacheKey?: string;
|
|
@@ -885,12 +1104,12 @@ interface RequestInitCfProperties {
|
|
|
885
1104
|
image?: RequestInitCfPropertiesImage;
|
|
886
1105
|
minify?: RequestInitCfPropertiesImageMinify;
|
|
887
1106
|
mirage?: boolean;
|
|
888
|
-
polish?:
|
|
1107
|
+
polish?: "lossy" | "lossless" | "off";
|
|
889
1108
|
/**
|
|
890
1109
|
* Redirects the request to an alternate origin server. You can use this,
|
|
891
1110
|
* for example, to implement load balancing across several origins.
|
|
892
1111
|
* (e.g.us-east.example.com)
|
|
893
|
-
*
|
|
1112
|
+
*
|
|
894
1113
|
* Note - For security reasons, the hostname set in resolveOverride must
|
|
895
1114
|
* be proxied on the same Cloudflare zone of the incoming request.
|
|
896
1115
|
* Otherwise, the setting is ignored. CNAME hosts are allowed, so to
|
|
@@ -908,6 +1127,13 @@ interface RequestInitCfPropertiesImage extends BasicImageTransformations {
|
|
|
908
1127
|
* easier to specify higher-DPI sizes in <img srcset>.
|
|
909
1128
|
*/
|
|
910
1129
|
dpr?: number;
|
|
1130
|
+
/**
|
|
1131
|
+
* An object with four properties {left, top, right, bottom} that specify
|
|
1132
|
+
* a number of pixels to cut off on each side. Allows removal of borders
|
|
1133
|
+
* or cutting out a specific fragment of an image. Trimming is performed
|
|
1134
|
+
* before resizing or rotation. Takes dpr into account.
|
|
1135
|
+
*/
|
|
1136
|
+
trim?: { left?: number; top?: number; right?: number; bottom?: number };
|
|
911
1137
|
/**
|
|
912
1138
|
* Quality setting from 1-100 (useful values are in 60-90 range). Lower values
|
|
913
1139
|
* make images look worse, but load faster. The default is 85. It applies only
|
|
@@ -924,6 +1150,15 @@ interface RequestInitCfPropertiesImage extends BasicImageTransformations {
|
|
|
924
1150
|
* (before and after resizing), source image’s MIME type, file size, etc.
|
|
925
1151
|
*/
|
|
926
1152
|
format?: "avif" | "webp" | "json";
|
|
1153
|
+
/**
|
|
1154
|
+
* Whether to preserve animation frames from input files. Default is true.
|
|
1155
|
+
* Setting it to false reduces animations to still images. This setting is
|
|
1156
|
+
* recommended when enlarging images or processing arbitrary user content,
|
|
1157
|
+
* because large GIF animations can weigh tens or even hundreds of megabytes.
|
|
1158
|
+
* It is also useful to set anim:false when using format:"json" to get the
|
|
1159
|
+
* response quicker without the number of frames.
|
|
1160
|
+
*/
|
|
1161
|
+
anim?: boolean;
|
|
927
1162
|
/**
|
|
928
1163
|
* What EXIF data should be preserved in the output image. Note that EXIF
|
|
929
1164
|
* rotation and embedded color profiles are always applied ("baked in" into
|
|
@@ -938,6 +1173,17 @@ interface RequestInitCfPropertiesImage extends BasicImageTransformations {
|
|
|
938
1173
|
* output formats always discard metadata.
|
|
939
1174
|
*/
|
|
940
1175
|
metadata?: "keep" | "copyright" | "none";
|
|
1176
|
+
/**
|
|
1177
|
+
* Strength of sharpening filter to apply to the image. Floating-point
|
|
1178
|
+
* number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
|
|
1179
|
+
* recommended value for downscaled images.
|
|
1180
|
+
*/
|
|
1181
|
+
sharpen?: number;
|
|
1182
|
+
/**
|
|
1183
|
+
* Radius of a blur filter (approximate gaussian). Maximum supported radius
|
|
1184
|
+
* is 250.
|
|
1185
|
+
*/
|
|
1186
|
+
blur?: number;
|
|
941
1187
|
/**
|
|
942
1188
|
* Overlays are drawn in the order they appear in the array (last array
|
|
943
1189
|
* entry is the topmost layer).
|
|
@@ -972,9 +1218,9 @@ interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
|
|
|
972
1218
|
* positions left side of the overlay 10 pixels from the left edge of the
|
|
973
1219
|
* image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
|
|
974
1220
|
* of the background image.
|
|
975
|
-
*
|
|
1221
|
+
*
|
|
976
1222
|
* Setting both left & right, or both top & bottom is an error.
|
|
977
|
-
*
|
|
1223
|
+
*
|
|
978
1224
|
* If no position is specified, the image will be centered.
|
|
979
1225
|
*/
|
|
980
1226
|
top?: number;
|
|
@@ -1043,19 +1289,48 @@ declare abstract class ScheduledEvent extends Event {
|
|
|
1043
1289
|
waitUntil(promise: Promise<any>): void;
|
|
1044
1290
|
}
|
|
1045
1291
|
|
|
1292
|
+
interface Scheduler {
|
|
1293
|
+
wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
interface SchedulerWaitOptions {
|
|
1297
|
+
signal?: AbortSignal;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1046
1300
|
interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
1047
1301
|
btoa(data: string): string;
|
|
1048
1302
|
atob(data: string): string;
|
|
1049
|
-
setTimeout<Args extends any[]>(
|
|
1303
|
+
setTimeout<Args extends any[]>(
|
|
1304
|
+
callback: (...args: Args) => void,
|
|
1305
|
+
msDelay?: number,
|
|
1306
|
+
...args: Args
|
|
1307
|
+
): number;
|
|
1050
1308
|
clearTimeout(timeoutId: number | null): void;
|
|
1051
|
-
setInterval<Args extends any[]>(
|
|
1309
|
+
setInterval<Args extends any[]>(
|
|
1310
|
+
callback: (...args: Args) => void,
|
|
1311
|
+
msDelay?: number,
|
|
1312
|
+
...args: Args
|
|
1313
|
+
): number;
|
|
1052
1314
|
clearInterval(timeoutId: number | null): void;
|
|
1053
1315
|
queueMicrotask(task: Function): void;
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1316
|
+
structuredClone(
|
|
1317
|
+
value: any,
|
|
1318
|
+
options?: ServiceWorkerGlobalScopeStructuredCloneOptions
|
|
1319
|
+
): any;
|
|
1320
|
+
fetch(
|
|
1321
|
+
request: Request | string,
|
|
1322
|
+
requestInitr?: RequestInit | Request
|
|
1323
|
+
): Promise<Response>;
|
|
1324
|
+
self: ServiceWorkerGlobalScope;
|
|
1325
|
+
crypto: Crypto;
|
|
1326
|
+
caches: CacheStorage;
|
|
1327
|
+
scheduler: Scheduler;
|
|
1058
1328
|
readonly console: Console;
|
|
1329
|
+
origin: void;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
interface ServiceWorkerGlobalScopeStructuredCloneOptions {
|
|
1333
|
+
transfer?: any[];
|
|
1059
1334
|
}
|
|
1060
1335
|
|
|
1061
1336
|
declare type StreamPipeOptions = PipeToOptions;
|
|
@@ -1066,18 +1341,71 @@ interface StreamQueuingStrategy {
|
|
|
1066
1341
|
}
|
|
1067
1342
|
|
|
1068
1343
|
declare abstract class SubtleCrypto {
|
|
1069
|
-
encrypt(
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1344
|
+
encrypt(
|
|
1345
|
+
algorithm: string | SubtleCryptoEncryptAlgorithm,
|
|
1346
|
+
key: CryptoKey,
|
|
1347
|
+
plainText: ArrayBuffer
|
|
1348
|
+
): Promise<ArrayBuffer>;
|
|
1349
|
+
decrypt(
|
|
1350
|
+
algorithm: string | SubtleCryptoEncryptAlgorithm,
|
|
1351
|
+
key: CryptoKey,
|
|
1352
|
+
cipherText: ArrayBuffer
|
|
1353
|
+
): Promise<ArrayBuffer>;
|
|
1354
|
+
sign(
|
|
1355
|
+
algorithm: string | SubtleCryptoSignAlgorithm,
|
|
1356
|
+
key: CryptoKey,
|
|
1357
|
+
data: ArrayBuffer
|
|
1358
|
+
): Promise<ArrayBuffer>;
|
|
1359
|
+
verify(
|
|
1360
|
+
algorithm: string | SubtleCryptoSignAlgorithm,
|
|
1361
|
+
key: CryptoKey,
|
|
1362
|
+
signature: ArrayBuffer,
|
|
1363
|
+
data: ArrayBuffer
|
|
1364
|
+
): Promise<boolean>;
|
|
1365
|
+
digest(
|
|
1366
|
+
algorithm: string | SubtleCryptoHashAlgorithm,
|
|
1367
|
+
data: ArrayBuffer
|
|
1368
|
+
): Promise<ArrayBuffer>;
|
|
1369
|
+
generateKey(
|
|
1370
|
+
algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
|
|
1371
|
+
extractable: boolean,
|
|
1372
|
+
keyUsages: string[]
|
|
1373
|
+
): Promise<CryptoKey | CryptoKeyPair>;
|
|
1374
|
+
deriveKey(
|
|
1375
|
+
algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
|
|
1376
|
+
baseKey: CryptoKey,
|
|
1377
|
+
derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
|
|
1378
|
+
extractable: boolean,
|
|
1379
|
+
keyUsages: string[]
|
|
1380
|
+
): Promise<CryptoKey>;
|
|
1381
|
+
deriveBits(
|
|
1382
|
+
algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
|
|
1383
|
+
baseKey: CryptoKey,
|
|
1384
|
+
length: number | null
|
|
1385
|
+
): Promise<ArrayBuffer>;
|
|
1386
|
+
importKey(
|
|
1387
|
+
format: string,
|
|
1388
|
+
keyData: ArrayBuffer | JsonWebKey,
|
|
1389
|
+
algorithm: string | SubtleCryptoImportKeyAlgorithm,
|
|
1390
|
+
extractable: boolean,
|
|
1391
|
+
keyUsages: string[]
|
|
1392
|
+
): Promise<CryptoKey>;
|
|
1078
1393
|
exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
|
|
1079
|
-
wrapKey(
|
|
1080
|
-
|
|
1394
|
+
wrapKey(
|
|
1395
|
+
format: string,
|
|
1396
|
+
key: CryptoKey,
|
|
1397
|
+
wrappingKey: CryptoKey,
|
|
1398
|
+
wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm
|
|
1399
|
+
): Promise<ArrayBuffer>;
|
|
1400
|
+
unwrapKey(
|
|
1401
|
+
format: string,
|
|
1402
|
+
wrappedKey: ArrayBuffer,
|
|
1403
|
+
unwrappingKey: CryptoKey,
|
|
1404
|
+
unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
|
|
1405
|
+
unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
|
|
1406
|
+
extractable: boolean,
|
|
1407
|
+
keyUsages: string[]
|
|
1408
|
+
): Promise<CryptoKey>;
|
|
1081
1409
|
}
|
|
1082
1410
|
|
|
1083
1411
|
interface SubtleCryptoDeriveKeyAlgorithm {
|
|
@@ -1121,13 +1449,13 @@ interface SubtleCryptoImportKeyAlgorithm {
|
|
|
1121
1449
|
}
|
|
1122
1450
|
|
|
1123
1451
|
/**
|
|
1124
|
-
*
|
|
1452
|
+
*
|
|
1125
1453
|
* @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
|
|
1126
1454
|
*/
|
|
1127
1455
|
declare type SubtleCryptoJsonWebKey = JsonWebKey;
|
|
1128
1456
|
|
|
1129
1457
|
/**
|
|
1130
|
-
*
|
|
1458
|
+
*
|
|
1131
1459
|
* @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
|
|
1132
1460
|
*/
|
|
1133
1461
|
declare type SubtleCryptoJsonWebKeyRsaOtherPrimesInfo = RsaOtherPrimesInfo;
|
|
@@ -1150,7 +1478,10 @@ interface Text {
|
|
|
1150
1478
|
}
|
|
1151
1479
|
|
|
1152
1480
|
declare class TextDecoder {
|
|
1153
|
-
constructor(
|
|
1481
|
+
constructor(
|
|
1482
|
+
label?: "utf-8" | "utf8" | "unicode-1-1-utf-8",
|
|
1483
|
+
options?: TextDecoderConstructorOptions
|
|
1484
|
+
);
|
|
1154
1485
|
decode(input?: ArrayBuffer, options?: TextDecoderDecodeOptions): string;
|
|
1155
1486
|
readonly encoding: string;
|
|
1156
1487
|
readonly fatal: boolean;
|
|
@@ -1214,12 +1545,24 @@ declare class URLSearchParams {
|
|
|
1214
1545
|
entries(): IterableIterator<[key: string, value: string]>;
|
|
1215
1546
|
keys(): IterableIterator<string>;
|
|
1216
1547
|
values(): IterableIterator<string>;
|
|
1217
|
-
forEach<This = unknown>(
|
|
1548
|
+
forEach<This = unknown>(
|
|
1549
|
+
callback: (
|
|
1550
|
+
this: This,
|
|
1551
|
+
key: string,
|
|
1552
|
+
value: string,
|
|
1553
|
+
parent: URLSearchParams
|
|
1554
|
+
) => void,
|
|
1555
|
+
thisArg?: This
|
|
1556
|
+
): void;
|
|
1218
1557
|
[Symbol.iterator](): IterableIterator<[key: string, value: string]>;
|
|
1219
1558
|
toString(): string;
|
|
1220
1559
|
}
|
|
1221
1560
|
|
|
1222
|
-
declare type URLSearchParamsInit =
|
|
1561
|
+
declare type URLSearchParamsInit =
|
|
1562
|
+
| URLSearchParams
|
|
1563
|
+
| string
|
|
1564
|
+
| Record<string, string>
|
|
1565
|
+
| [key: string, value: string][];
|
|
1223
1566
|
|
|
1224
1567
|
/**
|
|
1225
1568
|
* Back compat for code migrating to older definitions.
|
|
@@ -1233,28 +1576,47 @@ declare abstract class WebSocket extends EventTarget<WebSocketEventMap> {
|
|
|
1233
1576
|
accept(): void;
|
|
1234
1577
|
send(message: ArrayBuffer | string): void;
|
|
1235
1578
|
close(code?: number, reason?: string): void;
|
|
1579
|
+
static readonly READY_STATE_CONNECTING: number;
|
|
1580
|
+
static readonly READY_STATE_OPEN: number;
|
|
1581
|
+
static readonly READY_STATE_CLOSING: number;
|
|
1582
|
+
static readonly READY_STATE_CLOSED: number;
|
|
1583
|
+
readonly readyState: number;
|
|
1236
1584
|
}
|
|
1237
1585
|
|
|
1238
|
-
declare type WebSocketEventMap = {
|
|
1239
|
-
|
|
1240
|
-
|
|
1586
|
+
declare type WebSocketEventMap = {
|
|
1587
|
+
close: CloseEvent;
|
|
1588
|
+
message: MessageEvent;
|
|
1589
|
+
error: Event;
|
|
1590
|
+
};
|
|
1241
1591
|
|
|
1242
|
-
declare
|
|
1592
|
+
declare const WebSocketPair: { new (): { 0: WebSocket; 1: WebSocket } };
|
|
1243
1593
|
|
|
1244
|
-
}
|
|
1594
|
+
declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {}
|
|
1245
1595
|
|
|
1246
|
-
declare type WorkerGlobalScopeEventMap = {
|
|
1596
|
+
declare type WorkerGlobalScopeEventMap = {
|
|
1597
|
+
fetch: FetchEvent;
|
|
1598
|
+
scheduled: ScheduledEvent;
|
|
1599
|
+
unhandledrejection: PromiseRejectionEvent;
|
|
1600
|
+
rejectionhandled: PromiseRejectionEvent;
|
|
1601
|
+
};
|
|
1247
1602
|
|
|
1248
|
-
declare
|
|
1603
|
+
declare class WritableStream {
|
|
1604
|
+
constructor(underlyingSink?: Object, queuingStrategy?: Object);
|
|
1249
1605
|
readonly locked: boolean;
|
|
1250
1606
|
abort(reason: any): Promise<void>;
|
|
1251
1607
|
close(): Promise<void>;
|
|
1252
1608
|
getWriter(): WritableStreamDefaultWriter;
|
|
1253
1609
|
}
|
|
1254
1610
|
|
|
1611
|
+
declare abstract class WritableStreamDefaultController {
|
|
1612
|
+
readonly signal: AbortSignal;
|
|
1613
|
+
error(reason?: any): void;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1255
1616
|
declare class WritableStreamDefaultWriter {
|
|
1256
1617
|
constructor(stream: WritableStream);
|
|
1257
1618
|
readonly closed: Promise<void>;
|
|
1619
|
+
readonly ready: Promise<void>;
|
|
1258
1620
|
readonly desiredSize: number | null;
|
|
1259
1621
|
abort(reason: any): Promise<void>;
|
|
1260
1622
|
close(): Promise<void>;
|
|
@@ -1266,9 +1628,14 @@ declare class WritableStreamDefaultWriter {
|
|
|
1266
1628
|
* Back-compat alias.
|
|
1267
1629
|
* @deprecated Use WritableStreamDefaultWriter
|
|
1268
1630
|
*/
|
|
1269
|
-
declare type WritableStreamWritableStreamDefaultWriter =
|
|
1631
|
+
declare type WritableStreamWritableStreamDefaultWriter =
|
|
1632
|
+
WritableStreamDefaultWriter;
|
|
1270
1633
|
|
|
1271
|
-
declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
|
|
1634
|
+
declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
|
|
1635
|
+
type: Type,
|
|
1636
|
+
handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
|
|
1637
|
+
options?: EventTargetAddEventListenerOptions | boolean
|
|
1638
|
+
): void;
|
|
1272
1639
|
|
|
1273
1640
|
declare function atob(data: string): string;
|
|
1274
1641
|
|
|
@@ -1284,17 +1651,62 @@ declare const console: Console;
|
|
|
1284
1651
|
|
|
1285
1652
|
declare const crypto: Crypto;
|
|
1286
1653
|
|
|
1287
|
-
declare function dispatchEvent(
|
|
1654
|
+
declare function dispatchEvent(
|
|
1655
|
+
event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]
|
|
1656
|
+
): boolean;
|
|
1657
|
+
|
|
1658
|
+
declare function fetch(
|
|
1659
|
+
request: Request | string,
|
|
1660
|
+
requestInitr?: RequestInit | Request
|
|
1661
|
+
): Promise<Response>;
|
|
1288
1662
|
|
|
1289
|
-
declare
|
|
1663
|
+
declare const origin: void;
|
|
1290
1664
|
|
|
1291
1665
|
declare function queueMicrotask(task: Function): void;
|
|
1292
1666
|
|
|
1293
|
-
declare function removeEventListener<
|
|
1667
|
+
declare function removeEventListener<
|
|
1668
|
+
Type extends keyof WorkerGlobalScopeEventMap
|
|
1669
|
+
>(
|
|
1670
|
+
type: Type,
|
|
1671
|
+
handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
|
|
1672
|
+
options?: EventTargetEventListenerOptions | boolean
|
|
1673
|
+
): void;
|
|
1294
1674
|
|
|
1295
|
-
declare const
|
|
1675
|
+
declare const scheduler: Scheduler;
|
|
1296
1676
|
|
|
1297
|
-
declare
|
|
1298
|
-
|
|
1299
|
-
declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
|
|
1677
|
+
declare const self: ServiceWorkerGlobalScope;
|
|
1300
1678
|
|
|
1679
|
+
declare function setInterval<Args extends any[]>(
|
|
1680
|
+
callback: (...args: Args) => void,
|
|
1681
|
+
msDelay?: number,
|
|
1682
|
+
...args: Args
|
|
1683
|
+
): number;
|
|
1684
|
+
|
|
1685
|
+
declare function setTimeout<Args extends any[]>(
|
|
1686
|
+
callback: (...args: Args) => void,
|
|
1687
|
+
msDelay?: number,
|
|
1688
|
+
...args: Args
|
|
1689
|
+
): number;
|
|
1690
|
+
|
|
1691
|
+
declare function structuredClone(
|
|
1692
|
+
value: any,
|
|
1693
|
+
options?: ServiceWorkerGlobalScopeStructuredCloneOptions
|
|
1694
|
+
): any;
|
|
1695
|
+
|
|
1696
|
+
/*** Injected pages.d.ts ***/
|
|
1697
|
+
type Params<P extends string = any> = Record<P, string | string[]>;
|
|
1698
|
+
|
|
1699
|
+
type EventContext<Env, P extends string, Data> = {
|
|
1700
|
+
request: Request;
|
|
1701
|
+
waitUntil: (promise: Promise<any>) => void;
|
|
1702
|
+
next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
|
|
1703
|
+
env: Env & { ASSETS: { fetch: typeof fetch } };
|
|
1704
|
+
params: Params<P>;
|
|
1705
|
+
data: Data;
|
|
1706
|
+
};
|
|
1707
|
+
|
|
1708
|
+
declare type PagesFunction<
|
|
1709
|
+
Env = unknown,
|
|
1710
|
+
Params extends string = any,
|
|
1711
|
+
Data extends Record<string, unknown> = Record<string, unknown>
|
|
1712
|
+
> = (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.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "TypeScript typings for Cloudflare Workers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,17 +13,21 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"export:docs": "node -r esbuild-register export/docs.ts",
|
|
15
15
|
"export:overrides": "node -r esbuild-register export/overrides.ts",
|
|
16
|
+
"prettier:check": "prettier --check '**/*.{md,ts}'",
|
|
17
|
+
"prettier": "prettier --write '**/*.{md,ts}'",
|
|
16
18
|
"test": "tsc"
|
|
17
19
|
},
|
|
18
20
|
"author": "Cloudflare Workers Team <workers@cloudflare.com> (https://workers.cloudflare.com)",
|
|
19
21
|
"license": "BSD-3-Clause",
|
|
20
22
|
"devDependencies": {
|
|
21
|
-
"@
|
|
23
|
+
"@changesets/changelog-github": "^0.4.2",
|
|
24
|
+
"@changesets/cli": "^2.18.1",
|
|
25
|
+
"@types/marked": "^4.0.1",
|
|
22
26
|
"@types/node": "^16.6.1",
|
|
23
27
|
"esbuild": "^0.12.22",
|
|
24
28
|
"esbuild-register": "^3.0.0",
|
|
25
|
-
"marked": "^
|
|
26
|
-
"prettier": "2.
|
|
29
|
+
"marked": "^4.0.10",
|
|
30
|
+
"prettier": "^2.5.1",
|
|
27
31
|
"typescript": "^4.3.5"
|
|
28
32
|
}
|
|
29
33
|
}
|