|
declare module "stream/web" { |
|
|
|
|
|
interface ReadableWritablePair<R = any, W = any> { |
|
readable: ReadableStream<R>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writable: WritableStream<W>; |
|
} |
|
interface StreamPipeOptions { |
|
preventAbort?: boolean; |
|
preventCancel?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preventClose?: boolean; |
|
signal?: AbortSignal; |
|
} |
|
interface ReadableStreamGenericReader { |
|
readonly closed: Promise<undefined>; |
|
cancel(reason?: any): Promise<void>; |
|
} |
|
interface ReadableStreamDefaultReadValueResult<T> { |
|
done: false; |
|
value: T; |
|
} |
|
interface ReadableStreamDefaultReadDoneResult { |
|
done: true; |
|
value?: undefined; |
|
} |
|
type ReadableStreamController<T> = ReadableStreamDefaultController<T>; |
|
type ReadableStreamDefaultReadResult<T> = |
|
| ReadableStreamDefaultReadValueResult<T> |
|
| ReadableStreamDefaultReadDoneResult; |
|
interface ReadableStreamReadValueResult<T> { |
|
done: false; |
|
value: T; |
|
} |
|
interface ReadableStreamReadDoneResult<T> { |
|
done: true; |
|
value?: T; |
|
} |
|
type ReadableStreamReadResult<T> = ReadableStreamReadValueResult<T> | ReadableStreamReadDoneResult<T>; |
|
interface ReadableByteStreamControllerCallback { |
|
(controller: ReadableByteStreamController): void | PromiseLike<void>; |
|
} |
|
interface UnderlyingSinkAbortCallback { |
|
(reason?: any): void | PromiseLike<void>; |
|
} |
|
interface UnderlyingSinkCloseCallback { |
|
(): void | PromiseLike<void>; |
|
} |
|
interface UnderlyingSinkStartCallback { |
|
(controller: WritableStreamDefaultController): any; |
|
} |
|
interface UnderlyingSinkWriteCallback<W> { |
|
(chunk: W, controller: WritableStreamDefaultController): void | PromiseLike<void>; |
|
} |
|
interface UnderlyingSourceCancelCallback { |
|
(reason?: any): void | PromiseLike<void>; |
|
} |
|
interface UnderlyingSourcePullCallback<R> { |
|
(controller: ReadableStreamController<R>): void | PromiseLike<void>; |
|
} |
|
interface UnderlyingSourceStartCallback<R> { |
|
(controller: ReadableStreamController<R>): any; |
|
} |
|
interface TransformerFlushCallback<O> { |
|
(controller: TransformStreamDefaultController<O>): void | PromiseLike<void>; |
|
} |
|
interface TransformerStartCallback<O> { |
|
(controller: TransformStreamDefaultController<O>): any; |
|
} |
|
interface TransformerTransformCallback<I, O> { |
|
(chunk: I, controller: TransformStreamDefaultController<O>): void | PromiseLike<void>; |
|
} |
|
interface UnderlyingByteSource { |
|
autoAllocateChunkSize?: number; |
|
cancel?: ReadableStreamErrorCallback; |
|
pull?: ReadableByteStreamControllerCallback; |
|
start?: ReadableByteStreamControllerCallback; |
|
type: "bytes"; |
|
} |
|
interface UnderlyingSource<R = any> { |
|
cancel?: UnderlyingSourceCancelCallback; |
|
pull?: UnderlyingSourcePullCallback<R>; |
|
start?: UnderlyingSourceStartCallback<R>; |
|
type?: undefined; |
|
} |
|
interface UnderlyingSink<W = any> { |
|
abort?: UnderlyingSinkAbortCallback; |
|
close?: UnderlyingSinkCloseCallback; |
|
start?: UnderlyingSinkStartCallback; |
|
type?: undefined; |
|
write?: UnderlyingSinkWriteCallback<W>; |
|
} |
|
interface ReadableStreamErrorCallback { |
|
(reason: any): void | PromiseLike<void>; |
|
} |
|
|
|
interface ReadableStream<R = any> { |
|
readonly locked: boolean; |
|
cancel(reason?: any): Promise<void>; |
|
getReader(): ReadableStreamDefaultReader<R>; |
|
getReader(options: { mode: "byob" }): ReadableStreamBYOBReader; |
|
pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>; |
|
pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>; |
|
tee(): [ReadableStream<R>, ReadableStream<R>]; |
|
values(options?: { preventCancel?: boolean }): AsyncIterableIterator<R>; |
|
[Symbol.asyncIterator](): AsyncIterableIterator<R>; |
|
} |
|
const ReadableStream: { |
|
prototype: ReadableStream; |
|
new(underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>; |
|
new<R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>; |
|
}; |
|
interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader { |
|
read(): Promise<ReadableStreamDefaultReadResult<R>>; |
|
releaseLock(): void; |
|
} |
|
interface ReadableStreamBYOBReader extends ReadableStreamGenericReader { |
|
read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>; |
|
releaseLock(): void; |
|
} |
|
const ReadableStreamDefaultReader: { |
|
prototype: ReadableStreamDefaultReader; |
|
new<R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>; |
|
}; |
|
const ReadableStreamBYOBReader: any; |
|
const ReadableStreamBYOBRequest: any; |
|
interface ReadableByteStreamController { |
|
readonly byobRequest: undefined; |
|
readonly desiredSize: number | null; |
|
close(): void; |
|
enqueue(chunk: ArrayBufferView): void; |
|
error(error?: any): void; |
|
} |
|
const ReadableByteStreamController: { |
|
prototype: ReadableByteStreamController; |
|
new(): ReadableByteStreamController; |
|
}; |
|
interface ReadableStreamDefaultController<R = any> { |
|
readonly desiredSize: number | null; |
|
close(): void; |
|
enqueue(chunk?: R): void; |
|
error(e?: any): void; |
|
} |
|
const ReadableStreamDefaultController: { |
|
prototype: ReadableStreamDefaultController; |
|
new(): ReadableStreamDefaultController; |
|
}; |
|
interface Transformer<I = any, O = any> { |
|
flush?: TransformerFlushCallback<O>; |
|
readableType?: undefined; |
|
start?: TransformerStartCallback<O>; |
|
transform?: TransformerTransformCallback<I, O>; |
|
writableType?: undefined; |
|
} |
|
interface TransformStream<I = any, O = any> { |
|
readonly readable: ReadableStream<O>; |
|
readonly writable: WritableStream<I>; |
|
} |
|
const TransformStream: { |
|
prototype: TransformStream; |
|
new<I = any, O = any>( |
|
transformer?: Transformer<I, O>, |
|
writableStrategy?: QueuingStrategy<I>, |
|
readableStrategy?: QueuingStrategy<O>, |
|
): TransformStream<I, O>; |
|
}; |
|
interface TransformStreamDefaultController<O = any> { |
|
readonly desiredSize: number | null; |
|
enqueue(chunk?: O): void; |
|
error(reason?: any): void; |
|
terminate(): void; |
|
} |
|
const TransformStreamDefaultController: { |
|
prototype: TransformStreamDefaultController; |
|
new(): TransformStreamDefaultController; |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
interface WritableStream<W = any> { |
|
readonly locked: boolean; |
|
abort(reason?: any): Promise<void>; |
|
close(): Promise<void>; |
|
getWriter(): WritableStreamDefaultWriter<W>; |
|
} |
|
const WritableStream: { |
|
prototype: WritableStream; |
|
new<W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>; |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
interface WritableStreamDefaultWriter<W = any> { |
|
readonly closed: Promise<undefined>; |
|
readonly desiredSize: number | null; |
|
readonly ready: Promise<undefined>; |
|
abort(reason?: any): Promise<void>; |
|
close(): Promise<void>; |
|
releaseLock(): void; |
|
write(chunk?: W): Promise<void>; |
|
} |
|
const WritableStreamDefaultWriter: { |
|
prototype: WritableStreamDefaultWriter; |
|
new<W = any>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>; |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
interface WritableStreamDefaultController { |
|
error(e?: any): void; |
|
} |
|
const WritableStreamDefaultController: { |
|
prototype: WritableStreamDefaultController; |
|
new(): WritableStreamDefaultController; |
|
}; |
|
interface QueuingStrategy<T = any> { |
|
highWaterMark?: number; |
|
size?: QueuingStrategySize<T>; |
|
} |
|
interface QueuingStrategySize<T = any> { |
|
(chunk?: T): number; |
|
} |
|
interface QueuingStrategyInit { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
highWaterMark: number; |
|
} |
|
|
|
|
|
|
|
|
|
interface ByteLengthQueuingStrategy extends QueuingStrategy<ArrayBufferView> { |
|
readonly highWaterMark: number; |
|
readonly size: QueuingStrategySize<ArrayBufferView>; |
|
} |
|
const ByteLengthQueuingStrategy: { |
|
prototype: ByteLengthQueuingStrategy; |
|
new(init: QueuingStrategyInit): ByteLengthQueuingStrategy; |
|
}; |
|
|
|
|
|
|
|
|
|
interface CountQueuingStrategy extends QueuingStrategy { |
|
readonly highWaterMark: number; |
|
readonly size: QueuingStrategySize; |
|
} |
|
const CountQueuingStrategy: { |
|
prototype: CountQueuingStrategy; |
|
new(init: QueuingStrategyInit): CountQueuingStrategy; |
|
}; |
|
interface TextEncoderStream { |
|
|
|
readonly encoding: "utf-8"; |
|
readonly readable: ReadableStream<Uint8Array>; |
|
readonly writable: WritableStream<string>; |
|
readonly [Symbol.toStringTag]: string; |
|
} |
|
const TextEncoderStream: { |
|
prototype: TextEncoderStream; |
|
new(): TextEncoderStream; |
|
}; |
|
interface TextDecoderOptions { |
|
fatal?: boolean; |
|
ignoreBOM?: boolean; |
|
} |
|
type BufferSource = ArrayBufferView | ArrayBuffer; |
|
interface TextDecoderStream { |
|
|
|
readonly encoding: string; |
|
|
|
readonly fatal: boolean; |
|
|
|
readonly ignoreBOM: boolean; |
|
readonly readable: ReadableStream<string>; |
|
readonly writable: WritableStream<BufferSource>; |
|
readonly [Symbol.toStringTag]: string; |
|
} |
|
const TextDecoderStream: { |
|
prototype: TextDecoderStream; |
|
new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream; |
|
}; |
|
interface CompressionStream<R = any, W = any> { |
|
readonly readable: ReadableStream<R>; |
|
readonly writable: WritableStream<W>; |
|
} |
|
const CompressionStream: { |
|
prototype: CompressionStream; |
|
new<R = any, W = any>(format: string): CompressionStream<R, W>; |
|
}; |
|
interface DecompressionStream<R = any, W = any> { |
|
readonly readable: ReadableStream<R>; |
|
readonly writable: WritableStream<W>; |
|
} |
|
const DecompressionStream: { |
|
prototype: DecompressionStream; |
|
new<R = any, W = any>(format: string): DecompressionStream<R, W>; |
|
}; |
|
} |
|
declare module "node:stream/web" { |
|
export * from "stream/web"; |
|
} |
|
|