From 70c8f18e471f5ce61ae6a916ba83db14f6709c32 Mon Sep 17 00:00:00 2001 From: "autodecl-bot[bot]" <91285878+autodecl-bot[bot]@users.noreply.github.com> Date: Mon, 6 Dec 2021 20:14:08 +0000 Subject: [PATCH] Updated types for 2021.12.300 --- index.d.ts | 51 +++++- src/workers.json | 424 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 473 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 59ac8c44..6afa0793 100644 --- a/index.d.ts +++ b/index.d.ts @@ -10,8 +10,10 @@ declare class AbortController { declare class AbortSignal extends EventTarget { constructor(); static abort(reason?: any): AbortSignal; + static timeout(delay: number): AbortSignal; readonly aborted: boolean; readonly reason: any; + throwIfAborted(): void; } interface BasicImageTransformations { @@ -268,6 +270,11 @@ declare class DOMException extends Error { static readonly DATA_CLONE_ERR: number; } +declare class DigestStream extends WritableStream { + constructor(algorithm: string | SubtleCryptoHashAlgorithm); + readonly digest: Promise; +} + interface Doctype { readonly name: string | null; readonly publicId: string | null; @@ -764,7 +771,16 @@ interface ReadResult { done: boolean; } -declare abstract class ReadableStream { +interface ReadableByteStreamController { + readonly byobRequest: ReadableStreamBYOBRequest | null; + readonly desiredSize: number | null; + close(): void; + enqueue(chunk: ArrayBufferView): void; + error(reason: any): void; +} + +declare class ReadableStream { + constructor(underlyingSource?: Object, queuingStrategy?: Object); readonly locked: boolean; cancel(reason?: any): Promise; getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader; @@ -783,6 +799,20 @@ declare class ReadableStreamBYOBReader { readAtLeast(minBytes: number, view: Uint8Array): Promise>; } +interface ReadableStreamBYOBRequest { + readonly view: Uint8Array | null; + respond(bytesWritten: number): void; + respondWithNewView(view: ArrayBufferView): void; + readonly atLeast: number | null; +} + +interface ReadableStreamDefaultController { + readonly desiredSize: number | null; + close(): void; + enqueue(chunk?: any): void; + error(reason: any): void; +} + declare class ReadableStreamDefaultReader { constructor(stream: ReadableStream); readonly closed: Promise; @@ -1072,6 +1102,14 @@ declare abstract class ScheduledEvent extends Event { waitUntil(promise: Promise): void; } +interface Scheduler { + wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise; +} + +interface SchedulerWaitOptions { + signal?: AbortSignal; +} + interface ServiceWorkerGlobalScope extends WorkerGlobalScope { btoa(data: string): string; atob(data: string): string; @@ -1085,6 +1123,7 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope { readonly self: ServiceWorkerGlobalScope; readonly crypto: Crypto; readonly caches: CacheStorage; + readonly scheduler: Scheduler; readonly console: Console; } @@ -1279,13 +1318,19 @@ declare abstract class WorkerGlobalScope extends EventTarget; close(): Promise; getWriter(): WritableStreamDefaultWriter; } +interface WritableStreamDefaultController { + readonly signal: AbortSignal; + error(reason?: any): void; +} + declare class WritableStreamDefaultWriter { constructor(stream: WritableStream); readonly closed: Promise; @@ -1327,6 +1372,8 @@ declare function queueMicrotask(task: Function): void; declare function removeEventListener(type: Type, handler: EventListenerOrEventListenerObject, options?: EventTargetEventListenerOptions | boolean): void; +declare const scheduler: Scheduler; + declare const self: ServiceWorkerGlobalScope; declare function setInterval(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; diff --git a/src/workers.json b/src/workers.json index a1aa5e50..7c230d09 100644 --- a/src/workers.json +++ b/src/workers.json @@ -63,6 +63,23 @@ }, "static": true }, + { + "name": "timeout", + "type": { + "params": [ + { + "name": "delay", + "type": { + "name": "integer" + } + } + ], + "returns": { + "name": "AbortSignal" + } + }, + "static": true + }, { "name": "aborted", "type": { @@ -76,6 +93,15 @@ "name": "any" }, "readonly": true + }, + { + "name": "throwIfAborted", + "type": { + "params": [], + "returns": { + "name": "void" + } + } } ], "extends": [ @@ -1105,6 +1131,19 @@ "name": "string" } } + }, + { + "name": "DigestStream", + "type": { + "name": "typeof", + "args": [ + { + "name": "DigestStream" + } + ] + }, + "static": true, + "readonly": true } ], "kind": "class" @@ -1580,6 +1619,50 @@ ], "kind": "class" }, + "DigestStream": { + "name": "DigestStream", + "members": [ + { + "name": "constructor", + "type": { + "params": [ + { + "name": "algorithm", + "type": { + "name": "|", + "args": [ + { + "name": "string" + }, + { + "name": "SubtleCryptoHashAlgorithm" + } + ] + } + } + ] + } + }, + { + "name": "digest", + "type": { + "name": "Promise", + "args": [ + { + "name": "ArrayBuffer" + } + ] + }, + "readonly": true + } + ], + "extends": [ + { + "name": "WritableStream" + } + ], + "kind": "class" + }, "Doctype": { "name": "Doctype", "members": [ @@ -6619,9 +6702,107 @@ ], "kind": "struct" }, + "ReadableByteStreamController": { + "name": "ReadableByteStreamController", + "members": [ + { + "name": "byobRequest", + "type": { + "name": "|", + "args": [ + { + "name": "ReadableStreamBYOBRequest" + }, + { + "name": "null" + } + ] + }, + "readonly": true + }, + { + "name": "desiredSize", + "type": { + "name": "|", + "args": [ + { + "name": "integer" + }, + { + "name": "null" + } + ] + }, + "readonly": true + }, + { + "name": "close", + "type": { + "params": [], + "returns": { + "name": "void" + } + } + }, + { + "name": "enqueue", + "type": { + "params": [ + { + "name": "chunk", + "type": { + "name": "ArrayBufferView" + } + } + ], + "returns": { + "name": "void" + } + } + }, + { + "name": "error", + "type": { + "params": [ + { + "name": "reason", + "type": { + "name": "any" + } + } + ], + "returns": { + "name": "void" + } + } + } + ], + "kind": "class" + }, "ReadableStream": { "name": "ReadableStream", "members": [ + { + "name": "constructor", + "type": { + "params": [ + { + "name": "underlyingSource", + "type": { + "name": "Object", + "optional": true + } + }, + { + "name": "queuingStrategy", + "type": { + "name": "Object", + "optional": true + } + } + ] + } + }, { "name": "locked", "type": { @@ -6881,6 +7062,137 @@ ], "kind": "class" }, + "ReadableStreamBYOBRequest": { + "name": "ReadableStreamBYOBRequest", + "members": [ + { + "name": "view", + "type": { + "name": "|", + "args": [ + { + "name": "Uint8Array" + }, + { + "name": "null" + } + ] + }, + "readonly": true + }, + { + "name": "respond", + "type": { + "params": [ + { + "name": "bytesWritten", + "type": { + "name": "integer" + } + } + ], + "returns": { + "name": "void" + } + } + }, + { + "name": "respondWithNewView", + "type": { + "params": [ + { + "name": "view", + "type": { + "name": "ArrayBufferView" + } + } + ], + "returns": { + "name": "void" + } + } + }, + { + "name": "atLeast", + "type": { + "name": "|", + "args": [ + { + "name": "integer" + }, + { + "name": "null" + } + ] + }, + "readonly": true + } + ], + "kind": "class" + }, + "ReadableStreamDefaultController": { + "name": "ReadableStreamDefaultController", + "members": [ + { + "name": "desiredSize", + "type": { + "name": "|", + "args": [ + { + "name": "integer" + }, + { + "name": "null" + } + ] + }, + "readonly": true + }, + { + "name": "close", + "type": { + "params": [], + "returns": { + "name": "void" + } + } + }, + { + "name": "enqueue", + "type": { + "params": [ + { + "name": "chunk", + "type": { + "name": "any", + "optional": true + } + } + ], + "returns": { + "name": "void" + } + } + }, + { + "name": "error", + "type": { + "params": [ + { + "name": "reason", + "type": { + "name": "any" + } + } + ], + "returns": { + "name": "void" + } + } + } + ], + "kind": "class" + }, "ReadableStreamDefaultReader": { "name": "ReadableStreamDefaultReader", "members": [ @@ -7996,6 +8308,53 @@ ], "kind": "class" }, + "Scheduler": { + "name": "Scheduler", + "members": [ + { + "name": "wait", + "type": { + "params": [ + { + "name": "delay", + "type": { + "name": "integer" + } + }, + { + "name": "maybeOptions", + "type": { + "name": "SchedulerWaitOptions", + "optional": true + } + } + ], + "returns": { + "name": "Promise", + "args": [ + { + "name": "void" + } + ] + } + } + } + ], + "kind": "class" + }, + "SchedulerWaitOptions": { + "name": "SchedulerWaitOptions", + "members": [ + { + "name": "signal", + "type": { + "name": "AbortSignal", + "optional": true + } + } + ], + "kind": "struct" + }, "ServiceWorkerGlobalScope": { "name": "ServiceWorkerGlobalScope", "members": [ @@ -8317,6 +8676,13 @@ }, "readonly": true }, + { + "name": "scheduler", + "type": { + "name": "Scheduler" + }, + "readonly": true + }, { "name": "Event", "type": { @@ -10713,6 +11079,27 @@ "WritableStream": { "name": "WritableStream", "members": [ + { + "name": "constructor", + "type": { + "params": [ + { + "name": "underlyingSink", + "type": { + "name": "Object", + "optional": true + } + }, + { + "name": "queuingStrategy", + "type": { + "name": "Object", + "optional": true + } + } + ] + } + }, { "name": "locked", "type": { @@ -10767,6 +11154,36 @@ ], "kind": "class" }, + "WritableStreamDefaultController": { + "name": "WritableStreamDefaultController", + "members": [ + { + "name": "signal", + "type": { + "name": "AbortSignal" + }, + "readonly": true + }, + { + "name": "error", + "type": { + "params": [ + { + "name": "reason", + "type": { + "name": "any", + "optional": true + } + } + ], + "returns": { + "name": "void" + } + } + } + ], + "kind": "class" + }, "WritableStreamDefaultWriter": { "name": "WritableStreamDefaultWriter", "members": [ @@ -11211,6 +11628,13 @@ ], "kind": "function" }, + "scheduler": { + "name": "scheduler", + "type": { + "name": "Scheduler" + }, + "kind": "variable" + }, "self": { "name": "self", "type": {