@cloudflare/workers-types
Version:
TypeScript typings for Cloudflare Workers
1,358 lines (1,357 loc) • 165 kB
TypeScript
/*! *****************************************************************************
Copyright (c) Cloudflare. All rights reserved.
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* eslint-disable */
// noinspection JSUnusedGlobalSymbols
declare class DOMException extends Error {
constructor(message?: string, name?: string);
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */
readonly message: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */
readonly name: string;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
*/
readonly code: number;
readonly stack: any;
static readonly INDEX_SIZE_ERR: number;
static readonly DOMSTRING_SIZE_ERR: number;
static readonly HIERARCHY_REQUEST_ERR: number;
static readonly WRONG_DOCUMENT_ERR: number;
static readonly INVALID_CHARACTER_ERR: number;
static readonly NO_DATA_ALLOWED_ERR: number;
static readonly NO_MODIFICATION_ALLOWED_ERR: number;
static readonly NOT_FOUND_ERR: number;
static readonly NOT_SUPPORTED_ERR: number;
static readonly INUSE_ATTRIBUTE_ERR: number;
static readonly INVALID_STATE_ERR: number;
static readonly SYNTAX_ERR: number;
static readonly INVALID_MODIFICATION_ERR: number;
static readonly NAMESPACE_ERR: number;
static readonly INVALID_ACCESS_ERR: number;
static readonly VALIDATION_ERR: number;
static readonly TYPE_MISMATCH_ERR: number;
static readonly SECURITY_ERR: number;
static readonly NETWORK_ERR: number;
static readonly ABORT_ERR: number;
static readonly URL_MISMATCH_ERR: number;
static readonly QUOTA_EXCEEDED_ERR: number;
static readonly TIMEOUT_ERR: number;
static readonly INVALID_NODE_TYPE_ERR: number;
static readonly DATA_CLONE_ERR: number;
}
declare type WorkerGlobalScopeEventMap = {
fetch: FetchEvent;
scheduled: ScheduledEvent;
queue: QueueEvent;
unhandledrejection: PromiseRejectionEvent;
rejectionhandled: PromiseRejectionEvent;
};
declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
EventTarget: typeof EventTarget;
}
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console) */
declare interface Console {
"assert"(condition?: boolean, ...data: any[]): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static) */
clear(): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static) */
count(label?: string): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static) */
countReset(label?: string): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static) */
debug(...data: any[]): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static) */
dir(item?: any, options?: any): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static) */
dirxml(...data: any[]): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static) */
error(...data: any[]): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static) */
group(...data: any[]): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static) */
groupCollapsed(...data: any[]): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static) */
groupEnd(): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static) */
info(...data: any[]): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static) */
log(...data: any[]): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static) */
table(tabularData?: any, properties?: string[]): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static) */
time(label?: string): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static) */
timeEnd(label?: string): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static) */
timeLog(label?: string, ...data: any[]): void;
timeStamp(label?: string): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static) */
trace(...data: any[]): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static) */
warn(...data: any[]): void;
}
declare const console: Console;
declare type BufferSource = ArrayBufferView | ArrayBuffer;
declare type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array
| BigInt64Array
| BigUint64Array;
declare namespace WebAssembly {
class CompileError extends Error {
constructor(message?: string);
}
class RuntimeError extends Error {
constructor(message?: string);
}
type ValueType =
| "anyfunc"
| "externref"
| "f32"
| "f64"
| "i32"
| "i64"
| "v128";
interface GlobalDescriptor {
value: ValueType;
mutable?: boolean;
}
class Global {
constructor(descriptor: GlobalDescriptor, value?: any);
value: any;
valueOf(): any;
}
type ImportValue = ExportValue | number;
type ModuleImports = Record<string, ImportValue>;
type Imports = Record<string, ModuleImports>;
type ExportValue = Function | Global | Memory | Table;
type Exports = Record<string, ExportValue>;
class Instance {
constructor(module: Module, imports?: Imports);
readonly exports: Exports;
}
interface MemoryDescriptor {
initial: number;
maximum?: number;
shared?: boolean;
}
class Memory {
constructor(descriptor: MemoryDescriptor);
readonly buffer: ArrayBuffer;
grow(delta: number): number;
}
type ImportExportKind = "function" | "global" | "memory" | "table";
interface ModuleExportDescriptor {
kind: ImportExportKind;
name: string;
}
interface ModuleImportDescriptor {
kind: ImportExportKind;
module: string;
name: string;
}
abstract class Module {
static customSections(module: Module, sectionName: string): ArrayBuffer[];
static exports(module: Module): ModuleExportDescriptor[];
static imports(module: Module): ModuleImportDescriptor[];
}
type TableKind = "anyfunc" | "externref";
interface TableDescriptor {
element: TableKind;
initial: number;
maximum?: number;
}
class Table {
constructor(descriptor: TableDescriptor, value?: any);
readonly length: number;
get(index: number): any;
grow(delta: number, value?: any): number;
set(index: number, value?: any): void;
}
function instantiate(module: Module, imports?: Imports): Promise<Instance>;
function validate(bytes: BufferSource): boolean;
}
/**
* This ServiceWorker API interface represents the global execution context of a service worker.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
*/
declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
DOMException: typeof DOMException;
WorkerGlobalScope: typeof WorkerGlobalScope;
btoa(data: string): string;
atob(data: string): string;
setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
setTimeout<Args extends any[]>(
callback: (...args: Args) => void,
msDelay?: number,
...args: Args
): number;
clearTimeout(timeoutId: number | null): void;
setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
setInterval<Args extends any[]>(
callback: (...args: Args) => void,
msDelay?: number,
...args: Args
): number;
clearInterval(timeoutId: number | null): void;
queueMicrotask(task: Function): void;
structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
reportError(error: any): void;
fetch(
input: RequestInfo,
init?: RequestInit<RequestInitCfProperties>,
): Promise<Response>;
self: ServiceWorkerGlobalScope;
crypto: Crypto;
caches: CacheStorage;
scheduler: Scheduler;
performance: Performance;
readonly origin: string;
Event: typeof Event;
ExtendableEvent: typeof ExtendableEvent;
CustomEvent: typeof CustomEvent;
PromiseRejectionEvent: typeof PromiseRejectionEvent;
FetchEvent: typeof FetchEvent;
TailEvent: typeof TailEvent;
TraceEvent: typeof TailEvent;
ScheduledEvent: typeof ScheduledEvent;
MessageEvent: typeof MessageEvent;
CloseEvent: typeof CloseEvent;
ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
ReadableStream: typeof ReadableStream;
WritableStream: typeof WritableStream;
WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
TransformStream: typeof TransformStream;
ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
CountQueuingStrategy: typeof CountQueuingStrategy;
ErrorEvent: typeof ErrorEvent;
CompressionStream: typeof CompressionStream;
DecompressionStream: typeof DecompressionStream;
TextEncoderStream: typeof TextEncoderStream;
TextDecoderStream: typeof TextDecoderStream;
Headers: typeof Headers;
Body: typeof Body;
Request: typeof Request;
Response: typeof Response;
WebSocket: typeof WebSocket;
WebSocketPair: typeof WebSocketPair;
WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
AbortController: typeof AbortController;
AbortSignal: typeof AbortSignal;
TextDecoder: typeof TextDecoder;
TextEncoder: typeof TextEncoder;
URL: typeof URL;
URLSearchParams: typeof URLSearchParams;
URLPattern: typeof URLPattern;
Blob: typeof Blob;
File: typeof File;
FormData: typeof FormData;
Crypto: typeof Crypto;
SubtleCrypto: typeof SubtleCrypto;
CryptoKey: typeof CryptoKey;
CacheStorage: typeof CacheStorage;
Cache: typeof Cache;
FixedLengthStream: typeof FixedLengthStream;
IdentityTransformStream: typeof IdentityTransformStream;
HTMLRewriter: typeof HTMLRewriter;
GPUAdapter: typeof gpuGPUAdapter;
GPUOutOfMemoryError: typeof gpuGPUOutOfMemoryError;
GPUValidationError: typeof gpuGPUValidationError;
GPUInternalError: typeof gpuGPUInternalError;
GPUDeviceLostInfo: typeof gpuGPUDeviceLostInfo;
GPUBufferUsage: typeof gpuGPUBufferUsage;
GPUShaderStage: typeof gpuGPUShaderStage;
GPUMapMode: typeof gpuGPUMapMode;
GPUTextureUsage: typeof gpuGPUTextureUsage;
GPUColorWrite: typeof gpuGPUColorWrite;
}
declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
type: Type,
handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
options?: EventTargetAddEventListenerOptions | boolean,
): void;
declare function removeEventListener<
Type extends keyof WorkerGlobalScopeEventMap,
>(
type: Type,
handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
options?: EventTargetEventListenerOptions | boolean,
): void;
/**
* Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
*/
declare function dispatchEvent(
event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap],
): boolean;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/btoa) */
declare function btoa(data: string): string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/atob) */
declare function atob(data: string): string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/setTimeout) */
declare function setTimeout(
callback: (...args: any[]) => void,
msDelay?: number,
): number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/setTimeout) */
declare function setTimeout<Args extends any[]>(
callback: (...args: Args) => void,
msDelay?: number,
...args: Args
): number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/clearTimeout) */
declare function clearTimeout(timeoutId: number | null): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/setInterval) */
declare function setInterval(
callback: (...args: any[]) => void,
msDelay?: number,
): number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/setInterval) */
declare function setInterval<Args extends any[]>(
callback: (...args: Args) => void,
msDelay?: number,
...args: Args
): number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/clearInterval) */
declare function clearInterval(timeoutId: number | null): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/queueMicrotask) */
declare function queueMicrotask(task: Function): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/structuredClone) */
declare function structuredClone<T>(
value: T,
options?: StructuredSerializeOptions,
): T;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/reportError) */
declare function reportError(error: any): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/fetch) */
declare function fetch(
input: RequestInfo,
init?: RequestInit<RequestInitCfProperties>,
): Promise<Response>;
declare const self: ServiceWorkerGlobalScope;
declare const crypto: Crypto;
declare const caches: CacheStorage;
declare const scheduler: Scheduler;
declare const performance: Performance;
declare const origin: string;
declare interface TestController {}
declare interface ExecutionContext {
waitUntil(promise: Promise<any>): void;
passThroughOnException(): void;
}
declare type ExportedHandlerFetchHandler<
Env = unknown,
CfHostMetadata = unknown,
> = (
request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
env: Env,
ctx: ExecutionContext,
) => Response | Promise<Response>;
declare type ExportedHandlerTailHandler<Env = unknown> = (
events: TraceItem[],
env: Env,
ctx: ExecutionContext,
) => void | Promise<void>;
declare type ExportedHandlerTraceHandler<Env = unknown> = (
traces: TraceItem[],
env: Env,
ctx: ExecutionContext,
) => void | Promise<void>;
declare type ExportedHandlerScheduledHandler<Env = unknown> = (
controller: ScheduledController,
env: Env,
ctx: ExecutionContext,
) => void | Promise<void>;
declare type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (
batch: MessageBatch<Message>,
env: Env,
ctx: ExecutionContext,
) => void | Promise<void>;
declare type ExportedHandlerTestHandler<Env = unknown> = (
controller: TestController,
env: Env,
ctx: ExecutionContext,
) => void | Promise<void>;
declare interface ExportedHandler<
Env = unknown,
QueueHandlerMessage = unknown,
CfHostMetadata = unknown,
> {
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
tail?: ExportedHandlerTailHandler<Env>;
trace?: ExportedHandlerTraceHandler<Env>;
scheduled?: ExportedHandlerScheduledHandler<Env>;
test?: ExportedHandlerTestHandler<Env>;
email?: EmailExportedHandler<Env>;
queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
}
declare interface StructuredSerializeOptions {
transfer?: any[];
}
declare abstract class PromiseRejectionEvent extends Event {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise) */
readonly promise: Promise<any>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason) */
readonly reason: any;
}
/**
* Provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the Performance Timeline API, the Navigation Timing API, the User Timing API, and the Resource Timing API.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance)
*/
declare interface Performance {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/timeOrigin) */
readonly timeOrigin: number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/now) */
now(): number;
}
declare interface AlarmInvocationInfo {
readonly isRetry: boolean;
readonly retryCount: number;
}
declare interface DurableObject {
fetch(request: Request): Response | Promise<Response>;
alarm?(): void | Promise<void>;
webSocketMessage?(
ws: WebSocket,
message: string | ArrayBuffer,
): void | Promise<void>;
webSocketClose?(
ws: WebSocket,
code: number,
reason: string,
wasClean: boolean,
): void | Promise<void>;
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
}
declare type DurableObjectStub<
T extends Rpc.DurableObjectBranded | undefined = undefined,
> = Fetcher<
T,
"alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
> & {
readonly id: DurableObjectId;
readonly name?: string;
};
declare interface DurableObjectId {
toString(): string;
equals(other: DurableObjectId): boolean;
readonly name?: string;
}
declare interface DurableObjectNamespace<
T extends Rpc.DurableObjectBranded | undefined = undefined,
> {
newUniqueId(
options?: DurableObjectNamespaceNewUniqueIdOptions,
): DurableObjectId;
idFromName(name: string): DurableObjectId;
idFromString(id: string): DurableObjectId;
get(
id: DurableObjectId,
options?: DurableObjectNamespaceGetDurableObjectOptions,
): DurableObjectStub<T>;
jurisdiction(
jurisdiction: DurableObjectJurisdiction,
): DurableObjectNamespace<T>;
}
declare type DurableObjectJurisdiction = "eu" | "fedramp";
declare interface DurableObjectNamespaceNewUniqueIdOptions {
jurisdiction?: DurableObjectJurisdiction;
}
declare type DurableObjectLocationHint =
| "wnam"
| "enam"
| "sam"
| "weur"
| "eeur"
| "apac"
| "oc"
| "afr"
| "me";
declare interface DurableObjectNamespaceGetDurableObjectOptions {
locationHint?: DurableObjectLocationHint;
}
declare interface DurableObjectState {
waitUntil(promise: Promise<any>): void;
readonly id: DurableObjectId;
readonly storage: DurableObjectStorage;
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
acceptWebSocket(ws: WebSocket, tags?: string[]): void;
getWebSockets(tag?: string): WebSocket[];
setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
getHibernatableWebSocketEventTimeout(): number | null;
getTags(ws: WebSocket): string[];
}
declare interface DurableObjectTransaction {
get<T = unknown>(
key: string,
options?: DurableObjectGetOptions,
): Promise<T | undefined>;
get<T = unknown>(
keys: string[],
options?: DurableObjectGetOptions,
): Promise<Map<string, T>>;
list<T = unknown>(
options?: DurableObjectListOptions,
): Promise<Map<string, T>>;
put<T>(
key: string,
value: T,
options?: DurableObjectPutOptions,
): Promise<void>;
put<T>(
entries: Record<string, T>,
options?: DurableObjectPutOptions,
): Promise<void>;
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
rollback(): void;
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
setAlarm(
scheduledTime: number | Date,
options?: DurableObjectSetAlarmOptions,
): Promise<void>;
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
}
declare interface DurableObjectStorage {
get<T = unknown>(
key: string,
options?: DurableObjectGetOptions,
): Promise<T | undefined>;
get<T = unknown>(
keys: string[],
options?: DurableObjectGetOptions,
): Promise<Map<string, T>>;
list<T = unknown>(
options?: DurableObjectListOptions,
): Promise<Map<string, T>>;
put<T>(
key: string,
value: T,
options?: DurableObjectPutOptions,
): Promise<void>;
put<T>(
entries: Record<string, T>,
options?: DurableObjectPutOptions,
): Promise<void>;
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
deleteAll(options?: DurableObjectPutOptions): Promise<void>;
transaction<T>(
closure: (txn: DurableObjectTransaction) => Promise<T>,
): Promise<T>;
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
setAlarm(
scheduledTime: number | Date,
options?: DurableObjectSetAlarmOptions,
): Promise<void>;
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
sync(): Promise<void>;
transactionSync<T>(closure: () => T): T;
}
declare interface DurableObjectListOptions {
start?: string;
startAfter?: string;
end?: string;
prefix?: string;
reverse?: boolean;
limit?: number;
allowConcurrency?: boolean;
noCache?: boolean;
}
declare interface DurableObjectGetOptions {
allowConcurrency?: boolean;
noCache?: boolean;
}
declare interface DurableObjectGetAlarmOptions {
allowConcurrency?: boolean;
}
declare interface DurableObjectPutOptions {
allowConcurrency?: boolean;
allowUnconfirmed?: boolean;
noCache?: boolean;
}
declare interface DurableObjectSetAlarmOptions {
allowConcurrency?: boolean;
allowUnconfirmed?: boolean;
}
declare class WebSocketRequestResponsePair {
constructor(request: string, response: string);
get request(): string;
get response(): string;
}
declare interface AnalyticsEngineDataset {
writeDataPoint(event?: AnalyticsEngineDataPoint): void;
}
declare interface AnalyticsEngineDataPoint {
indexes?: ((ArrayBuffer | string) | null)[];
doubles?: number[];
blobs?: ((ArrayBuffer | string) | null)[];
}
declare class Event {
constructor(type: string, init?: EventInit);
/**
* Returns the type of event, e.g. "click", "hashchange", or "submit".
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
*/
readonly type: string;
/**
* Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
*/
readonly eventPhase: number;
/**
* Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
*/
readonly composed: boolean;
/**
* Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
*/
readonly bubbles: boolean;
/**
* Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
*/
readonly cancelable: boolean;
/**
* Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
*/
readonly defaultPrevented: boolean;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
*/
readonly returnValue: boolean;
/**
* Returns the object whose event listener's callback is currently being invoked.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
*/
readonly currentTarget?: EventTarget;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
*/
readonly srcElement?: EventTarget;
/**
* Returns the event's timestamp as the number of milliseconds measured relative to the time origin.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
*/
readonly timeStamp: number;
/**
* Returns true if event was dispatched by the user agent, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
*/
readonly isTrusted: boolean;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
*/
cancelBubble: boolean;
/**
* Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
*/
stopImmediatePropagation(): void;
/**
* If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
*/
preventDefault(): void;
/**
* When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
*/
stopPropagation(): void;
/**
* Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
*/
composedPath(): EventTarget[];
static readonly NONE: number;
static readonly CAPTURING_PHASE: number;
static readonly AT_TARGET: number;
static readonly BUBBLING_PHASE: number;
}
declare interface EventInit {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
}
declare type EventListener<EventType extends Event = Event> = (
event: EventType,
) => void;
declare interface EventListenerObject<EventType extends Event = Event> {
handleEvent(event: EventType): void;
}
declare type EventListenerOrEventListenerObject<
EventType extends Event = Event,
> = EventListener<EventType> | EventListenerObject<EventType>;
declare class EventTarget<
EventMap extends Record<string, Event> = Record<string, Event>,
> {
constructor();
/**
* Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
*
* The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
*
* When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
*
* When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
*
* When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
*
* If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
*
* The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
*/
addEventListener<Type extends keyof EventMap>(
type: Type,
handler: EventListenerOrEventListenerObject<EventMap[Type]>,
options?: EventTargetAddEventListenerOptions | boolean,
): void;
/**
* Removes the event listener in target's event listener list with the same type, callback, and options.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
*/
removeEventListener<Type extends keyof EventMap>(
type: Type,
handler: EventListenerOrEventListenerObject<EventMap[Type]>,
options?: EventTargetEventListenerOptions | boolean,
): void;
/**
* Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
*/
dispatchEvent(event: EventMap[keyof EventMap]): boolean;
}
declare interface EventTargetEventListenerOptions {
capture?: boolean;
}
declare interface EventTargetAddEventListenerOptions {
capture?: boolean;
passive?: boolean;
once?: boolean;
signal?: AbortSignal;
}
declare interface EventTargetHandlerObject {
handleEvent: (event: Event) => any | undefined;
}
declare class AbortController {
constructor();
/**
* Returns the AbortSignal object associated with this object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
*/
readonly signal: AbortSignal;
/**
* Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
*/
abort(reason?: any): void;
}
declare abstract class AbortSignal extends EventTarget {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static) */
static abort(reason?: any): AbortSignal;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static) */
static timeout(delay: number): AbortSignal;
static any(signals: AbortSignal[]): AbortSignal;
/**
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
*/
readonly aborted: boolean;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason) */
readonly reason: any;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
get onabort(): any | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
set onabort(value: any | null);
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted) */
throwIfAborted(): void;
}
declare interface Scheduler {
wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
}
declare interface SchedulerWaitOptions {
signal?: AbortSignal;
}
declare abstract class ExtendableEvent extends Event {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil) */
waitUntil(promise: Promise<any>): void;
}
declare class CustomEvent<T = any> extends Event {
constructor(type: string, init?: CustomEventCustomEventInit);
/**
* Returns any custom data event was created with. Typically used for synthetic events.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
*/
get detail(): T;
}
declare interface CustomEventCustomEventInit {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
detail?: any;
}
declare class Blob {
constructor(
bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[],
options?: BlobOptions,
);
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
readonly size: number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
readonly type: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
slice(start?: number, end?: number, type?: string): Blob;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) */
arrayBuffer(): Promise<ArrayBuffer>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
text(): Promise<string>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream) */
stream(): ReadableStream;
}
declare interface BlobOptions {
type?: string;
}
declare class File extends Blob {
constructor(
bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined,
name: string,
options?: FileOptions,
);
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
readonly name: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
readonly lastModified: number;
}
declare interface FileOptions {
type?: string;
lastModified?: number;
}
declare abstract class CacheStorage {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open) */
open(cacheName: string): Promise<Cache>;
readonly default: Cache;
}
declare abstract class Cache {
delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
match(
request: RequestInfo,
options?: CacheQueryOptions,
): Promise<Response | undefined>;
put(request: RequestInfo, response: Response): Promise<void>;
}
declare interface CacheQueryOptions {
ignoreMethod?: boolean;
}
declare abstract class Crypto {
/**
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
*/
readonly subtle: SubtleCrypto;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) */
getRandomValues<
T extends
| Int8Array
| Uint8Array
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| BigInt64Array
| BigUint64Array,
>(buffer: T): T;
/**
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
*/
randomUUID(): string;
DigestStream: typeof DigestStream;
}
declare abstract class SubtleCrypto {
encrypt(
algorithm: string | SubtleCryptoEncryptAlgorithm,
key: CryptoKey,
plainText: ArrayBuffer | ArrayBufferView,
): Promise<ArrayBuffer>;
decrypt(
algorithm: string | SubtleCryptoEncryptAlgorithm,
key: CryptoKey,
cipherText: ArrayBuffer | ArrayBufferView,
): Promise<ArrayBuffer>;
sign(
algorithm: string | SubtleCryptoSignAlgorithm,
key: CryptoKey,
data: ArrayBuffer | ArrayBufferView,
): Promise<ArrayBuffer>;
verify(
algorithm: string | SubtleCryptoSignAlgorithm,
key: CryptoKey,
signature: ArrayBuffer | ArrayBufferView,
data: ArrayBuffer | ArrayBufferView,
): Promise<boolean>;
digest(
algorithm: string | SubtleCryptoHashAlgorithm,
data: ArrayBuffer | ArrayBufferView,
): Promise<ArrayBuffer>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */
generateKey(
algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
extractable: boolean,
keyUsages: string[],
): Promise<CryptoKey | CryptoKeyPair>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey) */
deriveKey(
algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
baseKey: CryptoKey,
derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
extractable: boolean,
keyUsages: string[],
): Promise<CryptoKey>;
deriveBits(
algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
baseKey: CryptoKey,
length: number | null,
): Promise<ArrayBuffer>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) */
importKey(
format: string,
keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey,
algorithm: string | SubtleCryptoImportKeyAlgorithm,
extractable: boolean,
keyUsages: string[],
): Promise<CryptoKey>;
exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
wrapKey(
format: string,
key: CryptoKey,
wrappingKey: CryptoKey,
wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
): Promise<ArrayBuffer>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey) */
unwrapKey(
format: string,
wrappedKey: ArrayBuffer | ArrayBufferView,
unwrappingKey: CryptoKey,
unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
extractable: boolean,
keyUsages: string[],
): Promise<CryptoKey>;
timingSafeEqual(
a: ArrayBuffer | ArrayBufferView,
b: ArrayBuffer | ArrayBufferView,
): boolean;
}
declare abstract class CryptoKey {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */
readonly type: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */
readonly extractable: boolean;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */
readonly algorithm:
| CryptoKeyKeyAlgorithm
| CryptoKeyAesKeyAlgorithm
| CryptoKeyHmacKeyAlgorithm
| CryptoKeyRsaKeyAlgorithm
| CryptoKeyEllipticKeyAlgorithm
| CryptoKeyArbitraryKeyAlgorithm;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */
readonly usages: string[];
}
declare interface CryptoKeyPair {
publicKey: CryptoKey;
privateKey: CryptoKey;
}
declare interface JsonWebKey {
kty: string;
use?: string;
key_ops?: string[];
alg?: string;
ext?: boolean;
crv?: string;
x?: string;
y?: string;
d?: string;
n?: string;
e?: string;
p?: string;
q?: string;
dp?: string;
dq?: string;
qi?: string;
oth?: RsaOtherPrimesInfo[];
k?: string;
}
declare interface RsaOtherPrimesInfo {
r?: string;
d?: string;
t?: string;
}
declare interface SubtleCryptoDeriveKeyAlgorithm {
name: string;
salt?: ArrayBuffer;
iterations?: number;
hash?: string | SubtleCryptoHashAlgorithm;
$public?: CryptoKey;
info?: ArrayBuffer;
}
declare interface SubtleCryptoEncryptAlgorithm {
name: string;
iv?: ArrayBuffer;
additionalData?: ArrayBuffer;
tagLength?: number;
counter?: ArrayBuffer;
length?: number;
label?: ArrayBuffer;
}
declare interface SubtleCryptoGenerateKeyAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
modulusLength?: number;
publicExponent?: ArrayBuffer;
length?: number;
namedCurve?: string;
}
declare interface SubtleCryptoHashAlgorithm {
name: string;
}
declare interface SubtleCryptoImportKeyAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
length?: number;
namedCurve?: string;
compressed?: boolean;
}
declare interface SubtleCryptoSignAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
dataLength?: number;
saltLength?: number;
}
declare interface CryptoKeyKeyAlgorithm {
name: string;
}
declare interface CryptoKeyAesKeyAlgorithm {
name: string;
length: number;
}
declare interface CryptoKeyHmacKeyAlgorithm {
name: string;
hash: CryptoKeyKeyAlgorithm;
length: number;
}
declare interface CryptoKeyRsaKeyAlgorithm {
name: string;
modulusLength: number;
publicExponent: ArrayBuffer | (ArrayBuffer | ArrayBufferView);
hash?: CryptoKeyKeyAlgorithm;
}
declare interface CryptoKeyEllipticKeyAlgorithm {
name: string;
namedCurve: string;
}
declare interface CryptoKeyArbitraryKeyAlgorithm {
name: string;
hash?: CryptoKeyKeyAlgorithm;
namedCurve?: string;
length?: number;
}
declare class DigestStream extends WritableStream<
ArrayBuffer | ArrayBufferView
> {
constructor(algorithm: string | SubtleCryptoHashAlgorithm);
readonly digest: Promise<ArrayBuffer>;
}
declare class TextDecoder {
constructor(decoder?: string, options?: TextDecoderConstructorOptions);
/**
* Returns the result of running encoding's decoder. The method can be invoked zero or more times with options's stream set to true, and then once without options's stream (or set to false), to process a fragmented input. If the invocation without options's stream (or set to false) has no input, it's clearest to omit both arguments.
*
* ```
* var string = "", decoder = new TextDecoder(encoding), buffer;
* while(buffer = next_chunk()) {
* string += decoder.decode(buffer, {stream:true});
* }
* string += decoder.decode(); // end-of-queue
* ```
*
* If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
*/
decode(
input?: ArrayBuffer | ArrayBufferView,
options?: TextDecoderDecodeOptions,
): string;
readonly encoding: string;
readonly fatal: boolean;
readonly ignoreBOM: boolean;
}
declare class TextEncoder {
constructor();
/**
* Returns the result of running UTF-8's encoder.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
*/
encode(input?: string): Uint8Array;
/**
* Runs the UTF-8 encoder on source, stores the result of that operation into destination, and returns the progress made as an object wherein read is the number of converted code units of source and written is the number of bytes modified in destination.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
*/
encodeInto(
input: string,
buffer: ArrayBuffer | ArrayBufferView,
): TextEncoderEncodeIntoResult;
readonly encoding: string;
}
declare interface TextDecoderConstructorOptions {
fatal: boolean;
ignoreBOM: boolean;
}
declare interface TextDecoderDecodeOptions {
stream: boolean;
}
declare interface TextEncoderEncodeIntoResult {
read: number;
written: number;
}
declare class ErrorEvent extends Event {
constructor(type: string, init?: ErrorEventErrorEventInit);
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename) */
get filename(): string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message) */
get message(): string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno) */
get lineno(): number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno) */
get colno(): number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error) */
get error(): any;
}
declare interface ErrorEventErrorEventInit {
message?: string;
filename?: string;
lineno?: number;
colno?: number;
error?: any;
}
declare class FormData {
constructor();
append(name: string, value: string): void;
append(name: string, value: Blob, filename?: string): void;
delete(name: string): void;
get(name: string): string | null;
getAll(name: string): string[];
has(name: string): boolean;
set(name: string, value: string): void;
set(name: string, value: Blob, filename?: string): void;
/** Returns an array of key, value pairs for every entry in the list. */
entries(): IterableIterator<[key: string, value: string]>;
/** Returns a list of keys in the list. */
keys(): IterableIterator<string>;
/** Returns a list of values in the list. */
values(): IterableIterator<File | string>;
forEach<This = unknown>(
callback: (
this: This,
value: string,
key: string,
parent: FormData,
) => void,
thisArg?: This,
): void;
[Symbol.iterator](): IterableIterator<[key: string, value: string]>;
}
declare interface ContentOptions {
html?: boolean;
}
declare class HTMLRewriter {
constructor();
on(
selector: string,
handlers: HTMLRewriterElementContentHandlers,
): HTMLRewriter;
onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
transform(response: Response): Response;
}
declare interface HTMLRewriterElementContentHandlers {
element?(element: Element): void | Promise<void>;
comments?(comment: Comment): void | Promise<void>;
text?(element: Text): void | Promise<void>;
}
declare interface HTMLRewriterDocumentContentHandlers {
doctype?(doctype: Doctype): void | Promise<void>;
comments?(comment: Comment): void | Promise<void>;
text?(text: Text): void | Promise<void>;
end?(end: DocumentEnd): void | Promise<void>;
}
declare interface Doctype {
readonly name: string | null;
readonly publicId: string | null;
readonly systemId: string | null;
}
declare interface Element {
tagName: string;
readonly attributes: IterableIterator<string[]>;
readonly removed: boolean;
readonly namespaceURI: string;
getAttribute(name: string): string | null;
hasAttribute(name: string): boolean;
setAttribute(name: string, value: string): Element;
removeAttribute(name: string): Element;
before(content: string, options?: ContentOptions): Element;
after(content: string, options?: ContentOptions): Element;
prepend(content: string, options?: ContentOptions): Element;
append(content: string, options?: ContentOptions): Element;
replace(content: string, options?: ContentOptions): Element;
remove(): Element;
removeAndKeepContent(): Element;
setInnerContent(content: string, options?: ContentOptions): Element;
onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
}
declare interface EndTag {
name: string;
before(content: string, options?: ContentOptions): EndTag;
after(content: string, options?: ContentOptions): EndTag;
remove(): EndTag;
}
declare interface Comment {
text: string;
readonly removed: boolean;
before(content: string, options?: ContentOptions): Comment;
after(content: string, options?: ContentOptions): Comment;
replace(content: string, options?: ContentOptions): Comment;
remove(): Comment;
}
declare interface Text {
readonly text: string;
readonly lastInTextNode: boolean;
readonly removed: boolean;
before(content: string, options?: ContentOptions): Text;
after(content: string, options?: ContentOptions): Text;
replace(content: string, options?: ContentOptions): Text;
remove(): Text;
}
declare interface DocumentEnd {
append(content: string, options?: ContentOptions): DocumentEnd;
}
declare abstract class FetchEvent extends ExtendableEvent {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request) */
readonly request: Request;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith) */
respondWith(promise: Response | Promise<Response>): void;
passThroughOnException(): void;
}
declare type HeadersInit =
| Headers
| Iterable<Iterable<string>>
| Record<string, string>;
declare class Headers {
constructor(init?: HeadersInit);
get(name: string): string | null;
getAll(name: string): string[];
has(name: string): boolean;
set(name: string, value: string): void;
append(name: string, value: string): void;
delete(name: string): void;
forEach<This = unknown>(
callback: (this: This, value: string, key: string, parent: Headers) => void,
thisArg?: This,
): void;
/** Returns an iterator allowing to go through all key/value pairs contained in this object. */
entries(): IterableIterator<[key: string, value: string]>;
/** Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
keys(): IterableIterator<string>;
/** Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
values(): IterableIterator<string>;
[Symbol.iterator](): IterableIterator<[key: string, value: string]>;
}
declare type BodyInit =
| ReadableStream<Uint8Array>
| string
| ArrayBuffer
| ArrayBufferView
| Blob
| URLSearchParams
| FormData;
declare abstract class Body {
readonly body: ReadableStream | null;
readonly bodyUsed: boolean;
arrayBuffer(): Promise<ArrayBuffer>;
text(): Promise<string>;
json<T>(): Promise<T>;
formData(): Promise<FormData>;
blob(): Promise<Blob>;
}
declare class Response extends Body {
constructor(body?: BodyInit | null, init?: ResponseInit);
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
static redirect(url: string, status?: number): Response;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
static json(any: any, maybeInit?: ResponseInit | Response): Response;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */
clone(): Response;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */
readonly status: number;
/** [MDN Refe