diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 7e03be384..c70b271ee 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -1023,13 +1023,6 @@ interface PermissionDescriptor { name: PermissionName; } -interface PipeOptions { - preventAbort?: boolean; - preventCancel?: boolean; - preventClose?: boolean; - signal?: AbortSignal; -} - interface PointerEventInit extends MouseEventInit { height?: number; isPrimary?: boolean; @@ -1138,7 +1131,16 @@ interface PushSubscriptionOptionsInit { interface QueuingStrategy { highWaterMark?: number; - size?: QueuingStrategySizeCallback; + size?: QueuingStrategySize; +} + +interface QueuingStrategyInit { + /** + * Creates a new ByteLengthQueuingStrategy with the provided high water mark. + * + * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw. + */ + highWaterMark: number; } interface RTCAnswerOptions extends RTCOfferAnswerOptions { @@ -1516,16 +1518,26 @@ interface RTCTransportStats extends RTCStats { selectedCandidatePairId?: string; } -interface ReadableStreamReadDoneResult { +interface ReadableStreamDefaultReadDoneResult { done: true; - value?: T; + value?: undefined; } -interface ReadableStreamReadValueResult { +interface ReadableStreamDefaultReadValueResult { done: false; value: T; } +interface ReadableWritablePair { + readable: ReadableStream; + /** + * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use. + * + * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. + */ + writable: WritableStream; +} + interface RegistrationOptions { scope?: string; type?: WorkerType; @@ -1756,6 +1768,30 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat arrayOfDomainStrings?: string[]; } +interface StreamPipeOptions { + preventAbort?: boolean; + preventCancel?: boolean; + /** + * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. + * + * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. + * + * Errors and closures of the source and destination streams propagate as follows: + * + * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination. + * + * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source. + * + * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error. + * + * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source. + * + * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set. + */ + preventClose?: boolean; + signal?: AbortSignal; +} + interface TextDecodeOptions { stream?: boolean; } @@ -1799,10 +1835,10 @@ interface TrackEventInit extends EventInit { } interface Transformer { - flush?: TransformStreamDefaultControllerCallback; + flush?: TransformerFlushCallback; readableType?: undefined; - start?: TransformStreamDefaultControllerCallback; - transform?: TransformStreamDefaultControllerTransformCallback; + start?: TransformerStartCallback; + transform?: TransformerTransformCallback; writableType?: undefined; } @@ -1822,26 +1858,18 @@ interface ULongRange { min?: number; } -interface UnderlyingByteSource { - autoAllocateChunkSize?: number; - cancel?: ReadableStreamErrorCallback; - pull?: ReadableByteStreamControllerCallback; - start?: ReadableByteStreamControllerCallback; - type: "bytes"; -} - interface UnderlyingSink { - abort?: WritableStreamErrorCallback; - close?: WritableStreamDefaultControllerCloseCallback; - start?: WritableStreamDefaultControllerStartCallback; + abort?: UnderlyingSinkAbortCallback; + close?: UnderlyingSinkCloseCallback; + start?: UnderlyingSinkStartCallback; type?: undefined; - write?: WritableStreamDefaultControllerWriteCallback; + write?: UnderlyingSinkWriteCallback; } interface UnderlyingSource { - cancel?: ReadableStreamErrorCallback; - pull?: ReadableStreamDefaultControllerCallback; - start?: ReadableStreamDefaultControllerCallback; + cancel?: UnderlyingSourceCancelCallback; + pull?: UnderlyingSourcePullCallback; + start?: UnderlyingSourceStartCallback; type?: undefined; } @@ -2575,13 +2603,13 @@ declare var BroadcastChannel: { /** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */ interface ByteLengthQueuingStrategy extends QueuingStrategy { - highWaterMark: number; - size(chunk: ArrayBufferView): number; + readonly highWaterMark: number; + readonly size: QueuingStrategySize; } declare var ByteLengthQueuingStrategy: { prototype: ByteLengthQueuingStrategy; - new(options: { highWaterMark: number }): ByteLengthQueuingStrategy; + new(init: QueuingStrategyInit): ByteLengthQueuingStrategy; }; /** A CDATA section that can be used within XML to include extended portions of unescaped text. The symbols < and & don’t need escaping as they normally do when inside a CDATA section. */ @@ -3626,13 +3654,13 @@ declare var ConvolverNode: { /** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */ interface CountQueuingStrategy extends QueuingStrategy { - highWaterMark: number; - size(chunk: any): 1; + readonly highWaterMark: number; + readonly size: QueuingStrategySize; } declare var CountQueuingStrategy: { prototype: CountQueuingStrategy; - new(options: { highWaterMark: number }): CountQueuingStrategy; + new(init: QueuingStrategyInit): CountQueuingStrategy; }; interface Credential { @@ -5625,24 +5653,7 @@ declare var GamepadPose: { }; interface GenericTransformStream { - /** - * Returns a readable stream whose chunks are strings resulting from running encoding's decoder on the chunks written to writable. - */ readonly readable: ReadableStream; - /** - * Returns a writable stream which accepts [AllowShared] BufferSource chunks and runs them through encoding's decoder before making them available to readable. - * - * Typically this will be used via the pipeThrough() method on a ReadableStream source. - * - * ``` - * var decoder = new TextDecoderStream(encoding); - * byteReadable - * .pipeThrough(decoder) - * .pipeTo(textWritable); - * ``` - * - * If the error mode is "fatal" and encoding's decoder returns error, both readable and writable will be errored with a TypeError. - */ readonly writable: WritableStream; } @@ -12491,64 +12502,26 @@ declare var Range: { toString(): string; }; -interface ReadableByteStreamController { - readonly byobRequest: ReadableStreamBYOBRequest | undefined; - readonly desiredSize: number | null; - close(): void; - enqueue(chunk: ArrayBufferView): void; - error(error?: any): void; -} - -declare var ReadableByteStreamController: { - prototype: ReadableByteStreamController; - new(): ReadableByteStreamController; -}; - /** This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object. */ interface ReadableStream { readonly locked: boolean; cancel(reason?: any): Promise; - getReader(options: { mode: "byob" }): ReadableStreamBYOBReader; getReader(): ReadableStreamDefaultReader; - pipeThrough({ writable, readable }: { writable: WritableStream, readable: ReadableStream }, options?: PipeOptions): ReadableStream; - pipeTo(dest: WritableStream, options?: PipeOptions): Promise; + pipeThrough(transform: ReadableWritablePair, options?: StreamPipeOptions): ReadableStream; + pipeTo(dest: WritableStream, options?: StreamPipeOptions): Promise; tee(): [ReadableStream, ReadableStream]; } declare var ReadableStream: { prototype: ReadableStream; - new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number, size?: undefined }): ReadableStream; new(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream; }; -interface ReadableStreamBYOBReader { - readonly closed: Promise; - cancel(reason?: any): Promise; - read(view: T): Promise>; - releaseLock(): void; -} - -declare var ReadableStreamBYOBReader: { - prototype: ReadableStreamBYOBReader; - new(): ReadableStreamBYOBReader; -}; - -interface ReadableStreamBYOBRequest { - readonly view: ArrayBufferView; - respond(bytesWritten: number): void; - respondWithNewView(view: ArrayBufferView): void; -} - -declare var ReadableStreamBYOBRequest: { - prototype: ReadableStreamBYOBRequest; - new(): ReadableStreamBYOBRequest; -}; - interface ReadableStreamDefaultController { readonly desiredSize: number | null; close(): void; enqueue(chunk: R): void; - error(error?: any): void; + error(e?: any): void; } declare var ReadableStreamDefaultController: { @@ -12556,29 +12529,21 @@ declare var ReadableStreamDefaultController: { new(): ReadableStreamDefaultController; }; -interface ReadableStreamDefaultReader { - readonly closed: Promise; - cancel(reason?: any): Promise; - read(): Promise>; +interface ReadableStreamDefaultReader extends ReadableStreamGenericReader { + read(): Promise>; releaseLock(): void; } declare var ReadableStreamDefaultReader: { prototype: ReadableStreamDefaultReader; - new(): ReadableStreamDefaultReader; + new(stream: ReadableStream): ReadableStreamDefaultReader; }; -interface ReadableStreamReader { - cancel(): Promise; - read(): Promise>; - releaseLock(): void; +interface ReadableStreamGenericReader { + readonly closed: Promise; + cancel(reason?: any): Promise; } -declare var ReadableStreamReader: { - prototype: ReadableStreamReader; - new(): ReadableStreamReader; -}; - /** This Fetch API interface represents a resource request. */ interface Request extends Body { /** @@ -15500,14 +15465,14 @@ declare var Text: { /** A decoder for a specific method, that is a specific character encoding, like utf-8, iso-8859-2, koi8, cp1261, gbk, etc. A decoder takes a stream of bytes as input and emits a stream of code points. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays. */ interface TextDecoder extends TextDecoderCommon { /** - * 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 stream. If the invocation without options's stream (or set to false) has no input, it's clearest to omit both arguments. + * 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-stream + * string += decoder.decode(); // end-of-queue * ``` * * If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError. @@ -15526,11 +15491,11 @@ interface TextDecoderCommon { */ readonly encoding: string; /** - * Returns true if error mode is "fatal", and false otherwise. + * Returns true if error mode is "fatal", otherwise false. */ readonly fatal: boolean; /** - * Returns true if ignore BOM flag is set, and false otherwise. + * Returns the value of ignore BOM. */ readonly ignoreBOM: boolean; } @@ -15552,7 +15517,7 @@ interface TextEncoder extends TextEncoderCommon { */ 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 a dictionary whereby read is the number of converted code units of source and written is the number of bytes modified in destination. + * 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. */ encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult; } @@ -18731,7 +18696,7 @@ declare var WritableStream: { /** This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate. */ interface WritableStreamDefaultController { - error(error?: any): void; + error(e?: any): void; } declare var WritableStreamDefaultController: { @@ -18741,9 +18706,9 @@ declare var WritableStreamDefaultController: { /** This Streams API interface is the object returned by WritableStream.getWriter() and once created locks the < writer to the WritableStream ensuring that no other streams can write to the underlying sink. */ interface WritableStreamDefaultWriter { - readonly closed: Promise; + readonly closed: Promise; readonly desiredSize: number | null; - readonly ready: Promise; + readonly ready: Promise; abort(reason?: any): Promise; close(): Promise; releaseLock(): void; @@ -18752,7 +18717,7 @@ interface WritableStreamDefaultWriter { declare var WritableStreamDefaultWriter: { prototype: WritableStreamDefaultWriter; - new(): WritableStreamDefaultWriter; + new(stream: WritableStream): WritableStreamDefaultWriter; }; /** An XML document. It inherits from the generic Document and does not add any specific methods or properties to it: nevertheless, several algorithms behave differently with the two types of documents. */ @@ -19264,7 +19229,7 @@ interface PositionErrorCallback { (positionError: GeolocationPositionError): void; } -interface QueuingStrategySizeCallback { +interface QueuingStrategySize { (chunk: T): number; } @@ -19280,46 +19245,50 @@ interface RTCStatsCallback { (report: RTCStatsReport): void; } -interface ReadableByteStreamControllerCallback { - (controller: ReadableByteStreamController): void | PromiseLike; -} - -interface ReadableStreamDefaultControllerCallback { - (controller: ReadableStreamDefaultController): void | PromiseLike; -} - -interface ReadableStreamErrorCallback { - (reason: any): void | PromiseLike; +interface TransformerFlushCallback { + (controller: TransformStreamDefaultController): void | PromiseLike; } -interface TransformStreamDefaultControllerCallback { +interface TransformerStartCallback { (controller: TransformStreamDefaultController): void | PromiseLike; } -interface TransformStreamDefaultControllerTransformCallback { +interface TransformerTransformCallback { (chunk: I, controller: TransformStreamDefaultController): void | PromiseLike; } -interface VoidFunction { - (): void; +interface UnderlyingSinkAbortCallback { + (reason: any): void | PromiseLike; } -interface WritableStreamDefaultControllerCloseCallback { +interface UnderlyingSinkCloseCallback { (): void | PromiseLike; } -interface WritableStreamDefaultControllerStartCallback { +interface UnderlyingSinkStartCallback { (controller: WritableStreamDefaultController): void | PromiseLike; } -interface WritableStreamDefaultControllerWriteCallback { +interface UnderlyingSinkWriteCallback { (chunk: W, controller: WritableStreamDefaultController): void | PromiseLike; } -interface WritableStreamErrorCallback { +interface UnderlyingSourceCancelCallback { (reason: any): void | PromiseLike; } +interface UnderlyingSourcePullCallback { + (controller: ReadableStreamController): void | PromiseLike; +} + +interface UnderlyingSourceStartCallback { + (controller: ReadableStreamController): void | PromiseLike; +} + +interface VoidFunction { + (): void; +} + interface HTMLElementTagNameMap { "a": HTMLAnchorElement; "abbr": HTMLElement; @@ -19969,7 +19938,8 @@ type ConstrainDouble = number | ConstrainDoubleRange; type ConstrainBoolean = boolean | ConstrainBooleanParameters; type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; type PerformanceEntryList = PerformanceEntry[]; -type ReadableStreamReadResult = ReadableStreamReadValueResult | ReadableStreamReadDoneResult; +type ReadableStreamReader = ReadableStreamDefaultReader; +type ReadableStreamController = ReadableStreamDefaultController; type VibratePattern = number | number[]; type COSEAlgorithmIdentifier = number; type UvmEntry = number[]; @@ -20008,6 +19978,7 @@ type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; /** @deprecated */ type MouseWheelEvent = WheelEvent; type WindowProxy = Window; +type ReadableStreamDefaultReadResult = ReadableStreamDefaultReadValueResult | ReadableStreamDefaultReadDoneResult; type AlignSetting = "center" | "end" | "left" | "right" | "start"; type AnimationPlayState = "finished" | "idle" | "paused" | "running"; type AppendMode = "segments" | "sequence"; diff --git a/baselines/webworker.generated.d.ts b/baselines/webworker.generated.d.ts index f24219da5..0d538c2af 100644 --- a/baselines/webworker.generated.d.ts +++ b/baselines/webworker.generated.d.ts @@ -334,13 +334,6 @@ interface PermissionDescriptor { name: PermissionName; } -interface PipeOptions { - preventAbort?: boolean; - preventCancel?: boolean; - preventClose?: boolean; - signal?: AbortSignal; -} - interface PostMessageOptions { transfer?: any[]; } @@ -383,19 +376,38 @@ interface PushSubscriptionOptionsInit { interface QueuingStrategy { highWaterMark?: number; - size?: QueuingStrategySizeCallback; + size?: QueuingStrategySize; } -interface ReadableStreamReadDoneResult { +interface QueuingStrategyInit { + /** + * Creates a new ByteLengthQueuingStrategy with the provided high water mark. + * + * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw. + */ + highWaterMark: number; +} + +interface ReadableStreamDefaultReadDoneResult { done: true; - value?: T; + value?: undefined; } -interface ReadableStreamReadValueResult { +interface ReadableStreamDefaultReadValueResult { done: false; value: T; } +interface ReadableWritablePair { + readable: ReadableStream; + /** + * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use. + * + * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. + */ + writable: WritableStream; +} + interface RegistrationOptions { scope?: string; type?: WorkerType; @@ -495,6 +507,30 @@ interface StorageEstimate { usage?: number; } +interface StreamPipeOptions { + preventAbort?: boolean; + preventCancel?: boolean; + /** + * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. + * + * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. + * + * Errors and closures of the source and destination streams propagate as follows: + * + * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination. + * + * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source. + * + * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error. + * + * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source. + * + * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set. + */ + preventClose?: boolean; + signal?: AbortSignal; +} + interface SyncEventInit extends ExtendableEventInit { lastChance?: boolean; tag: string; @@ -515,33 +551,25 @@ interface TextEncoderEncodeIntoResult { } interface Transformer { - flush?: TransformStreamDefaultControllerCallback; + flush?: TransformerFlushCallback; readableType?: undefined; - start?: TransformStreamDefaultControllerCallback; - transform?: TransformStreamDefaultControllerTransformCallback; + start?: TransformerStartCallback; + transform?: TransformerTransformCallback; writableType?: undefined; } -interface UnderlyingByteSource { - autoAllocateChunkSize?: number; - cancel?: ReadableStreamErrorCallback; - pull?: ReadableByteStreamControllerCallback; - start?: ReadableByteStreamControllerCallback; - type: "bytes"; -} - interface UnderlyingSink { - abort?: WritableStreamErrorCallback; - close?: WritableStreamDefaultControllerCloseCallback; - start?: WritableStreamDefaultControllerStartCallback; + abort?: UnderlyingSinkAbortCallback; + close?: UnderlyingSinkCloseCallback; + start?: UnderlyingSinkStartCallback; type?: undefined; - write?: WritableStreamDefaultControllerWriteCallback; + write?: UnderlyingSinkWriteCallback; } interface UnderlyingSource { - cancel?: ReadableStreamErrorCallback; - pull?: ReadableStreamDefaultControllerCallback; - start?: ReadableStreamDefaultControllerCallback; + cancel?: UnderlyingSourceCancelCallback; + pull?: UnderlyingSourcePullCallback; + start?: UnderlyingSourceStartCallback; type?: undefined; } @@ -701,13 +729,13 @@ declare var BroadcastChannel: { /** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */ interface ByteLengthQueuingStrategy extends QueuingStrategy { - highWaterMark: number; - size(chunk: ArrayBufferView): number; + readonly highWaterMark: number; + readonly size: QueuingStrategySize; } declare var ByteLengthQueuingStrategy: { prototype: ByteLengthQueuingStrategy; - new(options: { highWaterMark: number }): ByteLengthQueuingStrategy; + new(init: QueuingStrategyInit): ByteLengthQueuingStrategy; }; /** Provides a storage mechanism for Request / Response object pairs that are cached, for example as part of the ServiceWorker life cycle. Note that the Cache interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec. */ @@ -941,13 +969,13 @@ interface ConcatParams extends Algorithm { /** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */ interface CountQueuingStrategy extends QueuingStrategy { - highWaterMark: number; - size(chunk: any): 1; + readonly highWaterMark: number; + readonly size: QueuingStrategySize; } declare var CountQueuingStrategy: { prototype: CountQueuingStrategy; - new(options: { highWaterMark: number }): CountQueuingStrategy; + new(init: QueuingStrategyInit): CountQueuingStrategy; }; /** Basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives. */ @@ -1624,24 +1652,7 @@ declare var FormData: { }; interface GenericTransformStream { - /** - * Returns a readable stream whose chunks are strings resulting from running encoding's decoder on the chunks written to writable. - */ readonly readable: ReadableStream; - /** - * Returns a writable stream which accepts [AllowShared] BufferSource chunks and runs them through encoding's decoder before making them available to readable. - * - * Typically this will be used via the pipeThrough() method on a ReadableStream source. - * - * ``` - * var decoder = new TextDecoderStream(encoding); - * byteReadable - * .pipeThrough(decoder) - * .pipeTo(textWritable); - * ``` - * - * If the error mode is "fatal" and encoding's decoder returns error, both readable and writable will be errored with a TypeError. - */ readonly writable: WritableStream; } @@ -2707,64 +2718,26 @@ declare var PushSubscriptionOptions: { new(): PushSubscriptionOptions; }; -interface ReadableByteStreamController { - readonly byobRequest: ReadableStreamBYOBRequest | undefined; - readonly desiredSize: number | null; - close(): void; - enqueue(chunk: ArrayBufferView): void; - error(error?: any): void; -} - -declare var ReadableByteStreamController: { - prototype: ReadableByteStreamController; - new(): ReadableByteStreamController; -}; - /** This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object. */ interface ReadableStream { readonly locked: boolean; cancel(reason?: any): Promise; - getReader(options: { mode: "byob" }): ReadableStreamBYOBReader; getReader(): ReadableStreamDefaultReader; - pipeThrough({ writable, readable }: { writable: WritableStream, readable: ReadableStream }, options?: PipeOptions): ReadableStream; - pipeTo(dest: WritableStream, options?: PipeOptions): Promise; + pipeThrough(transform: ReadableWritablePair, options?: StreamPipeOptions): ReadableStream; + pipeTo(dest: WritableStream, options?: StreamPipeOptions): Promise; tee(): [ReadableStream, ReadableStream]; } declare var ReadableStream: { prototype: ReadableStream; - new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number, size?: undefined }): ReadableStream; new(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream; }; -interface ReadableStreamBYOBReader { - readonly closed: Promise; - cancel(reason?: any): Promise; - read(view: T): Promise>; - releaseLock(): void; -} - -declare var ReadableStreamBYOBReader: { - prototype: ReadableStreamBYOBReader; - new(): ReadableStreamBYOBReader; -}; - -interface ReadableStreamBYOBRequest { - readonly view: ArrayBufferView; - respond(bytesWritten: number): void; - respondWithNewView(view: ArrayBufferView): void; -} - -declare var ReadableStreamBYOBRequest: { - prototype: ReadableStreamBYOBRequest; - new(): ReadableStreamBYOBRequest; -}; - interface ReadableStreamDefaultController { readonly desiredSize: number | null; close(): void; enqueue(chunk: R): void; - error(error?: any): void; + error(e?: any): void; } declare var ReadableStreamDefaultController: { @@ -2772,29 +2745,21 @@ declare var ReadableStreamDefaultController: { new(): ReadableStreamDefaultController; }; -interface ReadableStreamDefaultReader { - readonly closed: Promise; - cancel(reason?: any): Promise; - read(): Promise>; +interface ReadableStreamDefaultReader extends ReadableStreamGenericReader { + read(): Promise>; releaseLock(): void; } declare var ReadableStreamDefaultReader: { prototype: ReadableStreamDefaultReader; - new(): ReadableStreamDefaultReader; + new(stream: ReadableStream): ReadableStreamDefaultReader; }; -interface ReadableStreamReader { - cancel(): Promise; - read(): Promise>; - releaseLock(): void; +interface ReadableStreamGenericReader { + readonly closed: Promise; + cancel(reason?: any): Promise; } -declare var ReadableStreamReader: { - prototype: ReadableStreamReader; - new(): ReadableStreamReader; -}; - /** This Fetch API interface represents a resource request. */ interface Request extends Body { /** @@ -3108,14 +3073,14 @@ declare var SyncManager: { /** A decoder for a specific method, that is a specific character encoding, like utf-8, iso-8859-2, koi8, cp1261, gbk, etc. A decoder takes a stream of bytes as input and emits a stream of code points. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays. */ interface TextDecoder extends TextDecoderCommon { /** - * 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 stream. If the invocation without options's stream (or set to false) has no input, it's clearest to omit both arguments. + * 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-stream + * string += decoder.decode(); // end-of-queue * ``` * * If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError. @@ -3134,11 +3099,11 @@ interface TextDecoderCommon { */ readonly encoding: string; /** - * Returns true if error mode is "fatal", and false otherwise. + * Returns true if error mode is "fatal", otherwise false. */ readonly fatal: boolean; /** - * Returns true if ignore BOM flag is set, and false otherwise. + * Returns the value of ignore BOM. */ readonly ignoreBOM: boolean; } @@ -3160,7 +3125,7 @@ interface TextEncoder extends TextEncoderCommon { */ 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 a dictionary whereby read is the number of converted code units of source and written is the number of bytes modified in destination. + * 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. */ encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult; } @@ -5539,7 +5504,7 @@ declare var WritableStream: { /** This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate. */ interface WritableStreamDefaultController { - error(error?: any): void; + error(e?: any): void; } declare var WritableStreamDefaultController: { @@ -5549,9 +5514,9 @@ declare var WritableStreamDefaultController: { /** This Streams API interface is the object returned by WritableStream.getWriter() and once created locks the < writer to the WritableStream ensuring that no other streams can write to the underlying sink. */ interface WritableStreamDefaultWriter { - readonly closed: Promise; + readonly closed: Promise; readonly desiredSize: number | null; - readonly ready: Promise; + readonly ready: Promise; abort(reason?: any): Promise; close(): Promise; releaseLock(): void; @@ -5560,7 +5525,7 @@ interface WritableStreamDefaultWriter { declare var WritableStreamDefaultWriter: { prototype: WritableStreamDefaultWriter; - new(): WritableStreamDefaultWriter; + new(stream: WritableStream): WritableStreamDefaultWriter; }; interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap { @@ -5856,50 +5821,54 @@ interface PerformanceObserverCallback { (entries: PerformanceObserverEntryList, observer: PerformanceObserver): void; } -interface QueuingStrategySizeCallback { +interface QueuingStrategySize { (chunk: T): number; } -interface ReadableByteStreamControllerCallback { - (controller: ReadableByteStreamController): void | PromiseLike; -} - -interface ReadableStreamDefaultControllerCallback { - (controller: ReadableStreamDefaultController): void | PromiseLike; -} - -interface ReadableStreamErrorCallback { - (reason: any): void | PromiseLike; +interface TransformerFlushCallback { + (controller: TransformStreamDefaultController): void | PromiseLike; } -interface TransformStreamDefaultControllerCallback { +interface TransformerStartCallback { (controller: TransformStreamDefaultController): void | PromiseLike; } -interface TransformStreamDefaultControllerTransformCallback { +interface TransformerTransformCallback { (chunk: I, controller: TransformStreamDefaultController): void | PromiseLike; } -interface VoidFunction { - (): void; +interface UnderlyingSinkAbortCallback { + (reason: any): void | PromiseLike; } -interface WritableStreamDefaultControllerCloseCallback { +interface UnderlyingSinkCloseCallback { (): void | PromiseLike; } -interface WritableStreamDefaultControllerStartCallback { +interface UnderlyingSinkStartCallback { (controller: WritableStreamDefaultController): void | PromiseLike; } -interface WritableStreamDefaultControllerWriteCallback { +interface UnderlyingSinkWriteCallback { (chunk: W, controller: WritableStreamDefaultController): void | PromiseLike; } -interface WritableStreamErrorCallback { +interface UnderlyingSourceCancelCallback { (reason: any): void | PromiseLike; } +interface UnderlyingSourcePullCallback { + (controller: ReadableStreamController): void | PromiseLike; +} + +interface UnderlyingSourceStartCallback { + (controller: ReadableStreamController): void | PromiseLike; +} + +interface VoidFunction { + (): void; +} + /** * Returns dedicatedWorkerGlobal's name, i.e. the value given to the Worker constructor. Primarily useful for debugging. */ @@ -5977,7 +5946,8 @@ type OnErrorEventHandler = OnErrorEventHandlerNonNull | null; type TimerHandler = string | Function; type PerformanceEntryList = PerformanceEntry[]; type PushMessageDataInit = BufferSource | string; -type ReadableStreamReadResult = ReadableStreamReadValueResult | ReadableStreamReadDoneResult; +type ReadableStreamReader = ReadableStreamDefaultReader; +type ReadableStreamController = ReadableStreamDefaultController; type VibratePattern = number | number[]; type AlgorithmIdentifier = string | Algorithm; type HashAlgorithmIdentifier = AlgorithmIdentifier; @@ -6004,6 +5974,7 @@ type DOMTimeStamp = number; type FormDataEntryValue = File | string; type IDBValidKey = number | string | Date | BufferSource | IDBArrayKey; type Transferable = ArrayBuffer | MessagePort | ImageBitmap | OffscreenCanvas; +type ReadableStreamDefaultReadResult = ReadableStreamDefaultReadValueResult | ReadableStreamDefaultReadDoneResult; type BinaryType = "arraybuffer" | "blob"; type CanvasDirection = "inherit" | "ltr" | "rtl"; type CanvasFillRule = "evenodd" | "nonzero"; diff --git a/inputfiles/addedTypes.json b/inputfiles/addedTypes.json index e27acd704..f12403594 100644 --- a/inputfiles/addedTypes.json +++ b/inputfiles/addedTypes.json @@ -2182,38 +2182,6 @@ ] } }, - "TextDecoderStream": { - "properties": { - "property": { - "readable": { - "name": "readable", - "read-only": 1, - "override-type": "ReadableStream" - }, - "writable": { - "name": "writable", - "read-only": 1, - "override-type": "WritableStream" - } - } - } - }, - "TextEncoderStream": { - "properties": { - "property": { - "readable": { - "name": "readable", - "read-only": 1, - "override-type": "ReadableStream" - }, - "writable": { - "name": "writable", - "read-only": 1, - "override-type": "WritableStream" - } - } - } - }, "Attr": { "name": "Attr", "properties": { @@ -2336,6 +2304,44 @@ } } } + }, + "ReadableStreamDefaultReadDoneResult": { + "name": "ReadableStreamDefaultReadDoneResult", + "members": { + "member": { + "done": { + "name": "done", + "override-type": "true", + "required": 1 + }, + "value": { + "name": "value", + "override-type": "undefined" + } + } + } + }, + "ReadableStreamDefaultReadValueResult": { + "name": "ReadableStreamDefaultReadValueResult", + "type-parameters": [ + { + "name": "T" + } + ], + "members": { + "member": { + "done": { + "name": "done", + "override-type": "false", + "required": 1 + }, + "value": { + "name": "value", + "override-type": "T", + "required": 1 + } + } + } } } }, @@ -2434,6 +2440,37 @@ "type": "ModuleImports" } ] + }, + { + "new-type": "ReadableStreamDefaultReadResult", + "type-parameters": [ + { + "name": "T" + } + ], + "type": [ + { + "type": "ReadableStreamDefaultReadValueResult" + }, + { + "type": "ReadableStreamDefaultReadDoneResult" + } + ], + "override-type": "ReadableStreamDefaultReadValueResult | ReadableStreamDefaultReadDoneResult" + }, + { + "new-type": "ReadableStreamReader", + "type-parameters": [ + { + "name": "T" + } + ], + "type": [ + { + "type": "ReadableStreamDefaultReader" + } + ], + "override-type": "ReadableStreamDefaultReader" } ] } diff --git a/inputfiles/idl/Encoding.commentmap.json b/inputfiles/idl/Encoding.commentmap.json index 39a14c10b..030bbf382 100644 --- a/inputfiles/idl/Encoding.commentmap.json +++ b/inputfiles/idl/Encoding.commentmap.json @@ -1,13 +1,13 @@ { "textdecoder": "Returns a new TextDecoder object.\n\nIf label is either not a label or is a label for replacement, throws a RangeError.", "textdecodercommon-encoding": "Returns encoding's name, lowercased.", - "textdecodercommon-fatal": "Returns true if error mode is \"fatal\", and false otherwise.", - "textdecodercommon-ignorebom": "Returns true if ignore BOM flag is set, and false otherwise.", - "textdecoder-decode": "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 stream. If the invocation without options's stream (or set to false) has no input, it's clearest to omit both arguments.\n\n```\nvar string = \"\", decoder = new TextDecoder(encoding), buffer;\nwhile(buffer = next_chunk()) {\n string += decoder.decode(buffer, {stream:true});\n}\nstring += decoder.decode(); // end-of-stream\n```\n\nIf the error mode is \"fatal\" and encoding's decoder returns error, throws a TypeError.", + "textdecodercommon-fatal": "Returns true if error mode is \"fatal\", otherwise false.", + "textdecodercommon-ignorebom": "Returns the value of ignore BOM.", + "textdecoder-decode": "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.\n\n```\nvar string = \"\", decoder = new TextDecoder(encoding), buffer;\nwhile(buffer = next_chunk()) {\n string += decoder.decode(buffer, {stream:true});\n}\nstring += decoder.decode(); // end-of-queue\n```\n\nIf the error mode is \"fatal\" and encoding's decoder returns error, throws a TypeError.", "textencoder": "Returns a new TextEncoder object.", "textencodercommon-encoding": "Returns \"utf-8\".", "textencoder-encode": "Returns the result of running UTF-8's encoder.", - "textencoder-encodeinto": "Runs the UTF-8 encoder on source, stores the result of that operation into destination, and returns the progress made as a dictionary whereby read is the number of converted code units of source and written is the number of bytes modified in destination.", + "textencoder-encodeinto": "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.", "textdecoderstream": "Returns a new TextDecoderStream object.\n\nIf label is either not a label or is a label for replacement, throws a RangeError.", "generictransformstream-readable": "Returns a readable stream whose chunks are strings resulting from running encoding's decoder on the chunks written to writable.", "generictransformstream-writable": "Returns a writable stream which accepts [AllowShared] BufferSource chunks and runs them through encoding's decoder before making them available to readable.\n\nTypically this will be used via the pipeThrough() method on a ReadableStream source.\n\n```\nvar decoder = new TextDecoderStream(encoding);\nbyteReadable\n .pipeThrough(decoder)\n .pipeTo(textWritable);\n```\n\nIf the error mode is \"fatal\" and encoding's decoder returns error, both readable and writable will be errored with a TypeError.", diff --git a/inputfiles/idl/Encoding.widl b/inputfiles/idl/Encoding.widl index 651226b9a..ee872355e 100644 --- a/inputfiles/idl/Encoding.widl +++ b/inputfiles/idl/Encoding.widl @@ -39,11 +39,6 @@ interface TextEncoder { }; TextEncoder includes TextEncoderCommon; -interface mixin GenericTransformStream { - readonly attribute ReadableStream readable; - readonly attribute WritableStream writable; -}; - [Exposed=(Window,Worker)] interface TextDecoderStream { constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options = {}); diff --git a/inputfiles/idl/Streams.commentmap.json b/inputfiles/idl/Streams.commentmap.json index 47dc90aaa..4ac8f33d9 100644 --- a/inputfiles/idl/Streams.commentmap.json +++ b/inputfiles/idl/Streams.commentmap.json @@ -1,7 +1,7 @@ { "readablestreamgetreaderoptions-mode": "Creates a ReadableStreamBYOBReader and locks the stream to the new reader.\n\nThis call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle \"bring your own buffer\" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.", "readablewritablepair-writable": "Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.\n\nPiping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.", - "streampipeoptions-preventclose": "Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.\n\nPiping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.\n\nErrors and closures of the source and destination streams propagate as follows:\n\nAn error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination.\n\nAn error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source.\n\nWhen this source readable stream closes, destination will be closed, unless preventCancel is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error.\n\nIf destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source.\n\nThe signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.", + "streampipeoptions-preventclose": "Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.\n\nPiping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.\n\nErrors and closures of the source and destination streams propagate as follows:\n\nAn error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination.\n\nAn error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source.\n\nWhen this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error.\n\nIf destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source.\n\nThe signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.", "readablestreamiteratoroptions-preventcancel": "Asynchronously iterates over the chunks in the stream's internal queue.\n\nAsynchronously iterating over the stream will lock it, preventing any other consumer from acquiring a reader. The lock will be released if the async iterator's return() method is called, e.g. by breaking out of the loop.\n\nBy default, calling the async iterator's return() method will also cancel the stream. To prevent this, use the stream's values() method, passing true for the preventCancel option.", "queuingstrategyinit-highwatermark": "Creates a new ByteLengthQueuingStrategy with the provided high water mark.\n\nNote that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw." } diff --git a/inputfiles/idl/Streams.widl b/inputfiles/idl/Streams.widl index 040d5d503..57db5b017 100644 --- a/inputfiles/idl/Streams.widl +++ b/inputfiles/idl/Streams.widl @@ -1,186 +1,221 @@ -[Constructor(optional UnderlyingSource underlyingSource, optional QueuingStrategy strategy), - Constructor(optional UnderlyingByteSource underlyingSource, optional QueuingStrategy strategy), - Exposed=(Window,Worker)] +[Exposed=(Window,Worker,Worklet), Transferable] interface ReadableStream { - readonly attribute boolean locked; - Promise cancel(optional any reason); - ReadableStreamBYOBReader getReader(any options); - ReadableStreamDefaultReader getReader(); - any pipeThrough(any pair, optional PipeOptions options); - Promise pipeTo(WritableStream dest, optional PipeOptions options); - [ReadableStream, ReadableStream] tee(); -}; + constructor(optional object underlyingSource, optional QueuingStrategy strategy = {}); -callback QueuingStrategySizeCallback = double (any chunk); + readonly attribute boolean locked; -dictionary QueuingStrategy { - unrestricted double? highWaterMark; - QueuingStrategySizeCallback? size; + Promise cancel(optional any reason); + ReadableStreamReader getReader(optional ReadableStreamGetReaderOptions options = {}); + ReadableStream pipeThrough(ReadableWritablePair transform, optional StreamPipeOptions options = {}); + Promise pipeTo(WritableStream destination, optional StreamPipeOptions options = {}); + sequence tee(); + + async iterable(optional ReadableStreamIteratorOptions options = {}); }; -callback ReadableByteStreamControllerCallback = any (ReadableByteStreamController controller); -callback ReadableStreamDefaultControllerCallback = any (ReadableStreamDefaultController controller); -callback ReadableStreamErrorCallback = any (any reason); +typedef (ReadableStreamDefaultReader or ReadableStreamBYOBReader) ReadableStreamReader; -dictionary UnderlyingSource { - ReadableStreamDefaultControllerCallback? start; - ReadableStreamDefaultControllerCallback? pull; - ReadableStreamErrorCallback? cancel; +enum ReadableStreamReaderMode { "byob" }; - any type; +dictionary ReadableStreamGetReaderOptions { + ReadableStreamReaderMode mode; }; -dictionary UnderlyingByteSource { - ReadableByteStreamControllerCallback? start; - ReadableByteStreamControllerCallback? pull; - ReadableStreamErrorCallback? cancel; - - required DOMString type; - unsigned long? autoAllocateChunkSize; +dictionary ReadableStreamIteratorOptions { + boolean preventCancel = false; }; -dictionary PipeOptions { - boolean? preventClose; - boolean? preventAbort; - boolean? preventCancel; - AbortSignal? signal; +dictionary ReadableWritablePair { + required ReadableStream readable; + required WritableStream writable; }; -dictionary ReadableStreamReadValueResult { - required boolean done; - required any value; +dictionary StreamPipeOptions { + boolean preventClose = false; + boolean preventAbort = false; + boolean preventCancel = false; + AbortSignal signal; }; -dictionary ReadableStreamReadDoneResult { - required boolean done; - any value; +dictionary UnderlyingSource { + UnderlyingSourceStartCallback start; + UnderlyingSourcePullCallback pull; + UnderlyingSourceCancelCallback cancel; + ReadableStreamType type; + [EnforceRange] unsigned long long autoAllocateChunkSize; }; -[Exposed=(Window,Worker)] -typedef (ReadableStreamReadValueResult or ReadableStreamReadDoneResult) ReadableStreamReadResult; +typedef (ReadableStreamDefaultController or ReadableByteStreamController) ReadableStreamController; + +callback UnderlyingSourceStartCallback = any (ReadableStreamController controller); +callback UnderlyingSourcePullCallback = Promise (ReadableStreamController controller); +callback UnderlyingSourceCancelCallback = Promise (optional any reason); + +enum ReadableStreamType { "bytes" }; + +interface mixin ReadableStreamGenericReader { + readonly attribute Promise closed; -[Exposed=(Window,Worker)] + Promise cancel(optional any reason); +}; + +[Exposed=(Window,Worker,Worklet)] interface ReadableStreamDefaultReader { - readonly attribute Promise closed; + constructor(ReadableStream stream); - Promise cancel(optional any reason); - Promise read(); - void releaseLock(); + Promise read(); + undefined releaseLock(); }; +ReadableStreamDefaultReader includes ReadableStreamGenericReader; -[Exposed=(Window,Worker)] +dictionary ReadableStreamDefaultReadResult { + any value; + boolean done; +}; + +[Exposed=(Window,Worker,Worklet)] interface ReadableStreamBYOBReader { - readonly attribute Promise closed; + constructor(ReadableStream stream); - Promise cancel(optional any reason); - Promise read(ArrayBufferView view); - void releaseLock(); + Promise read(ArrayBufferView view); + undefined releaseLock(); }; +ReadableStreamBYOBReader includes ReadableStreamGenericReader; -[Exposed=(Window,Worker)] +dictionary ReadableStreamBYOBReadResult { + ArrayBufferView value; + boolean done; +}; + +[Exposed=(Window,Worker,Worklet)] interface ReadableStreamDefaultController { - readonly attribute unrestricted double? desiredSize; + readonly attribute unrestricted double? desiredSize; - void close(); - void enqueue(any chunk); - void error(optional any error); + undefined close(); + undefined enqueue(optional any chunk); + undefined error(optional any e); }; -[Exposed=(Window,Worker)] +[Exposed=(Window,Worker,Worklet)] interface ReadableByteStreamController { - readonly attribute ReadableStreamBYOBRequest byobRequest; - readonly attribute unrestricted double? desiredSize; + readonly attribute ReadableStreamBYOBRequest? byobRequest; + readonly attribute unrestricted double? desiredSize; - void close(); - void enqueue(ArrayBufferView chunk); - void error(optional any error); + undefined close(); + undefined enqueue(ArrayBufferView chunk); + undefined error(optional any e); }; -[Exposed=(Window,Worker)] +[Exposed=(Window,Worker,Worklet)] interface ReadableStreamBYOBRequest { - readonly attribute ArrayBufferView view; + readonly attribute ArrayBufferView? view; - void respond(unsigned long bytesWritten); - void respondWithNewView(ArrayBufferView view); + undefined respond([EnforceRange] unsigned long long bytesWritten); + undefined respondWithNewView(ArrayBufferView view); }; -[Constructor(optional UnderlyingSink underlyingSink, optional QueuingStrategy strategy), - Exposed=(Window,Worker)] +[Exposed=(Window,Worker,Worklet), Transferable] interface WritableStream { - readonly attribute boolean locked; - Promise abort(optional any reason); - WritableStreamDefaultWriter getWriter(); -}; + constructor(optional object underlyingSink, optional QueuingStrategy strategy = {}); -callback WritableStreamDefaultControllerStartCallback = any (WritableStreamDefaultController controller); -callback WritableStreamDefaultControllerWriteCallback = any (any chunk, WritableStreamDefaultController controller); -callback WritableStreamDefaultControllerCloseCallback = any (); -callback WritableStreamErrorCallback = any (any reason); + readonly attribute boolean locked; -dictionary UnderlyingSink { - WritableStreamDefaultControllerStartCallback? start; - WritableStreamDefaultControllerWriteCallback? write; - WritableStreamDefaultControllerCloseCallback? close; - WritableStreamErrorCallback? abort; + Promise abort(optional any reason); + Promise close(); + WritableStreamDefaultWriter getWriter(); +}; - any type; +dictionary UnderlyingSink { + UnderlyingSinkStartCallback start; + UnderlyingSinkWriteCallback write; + UnderlyingSinkCloseCallback close; + UnderlyingSinkAbortCallback abort; + any type; }; -[Exposed=(Window,Worker)] +callback UnderlyingSinkStartCallback = any (WritableStreamDefaultController controller); +callback UnderlyingSinkWriteCallback = Promise (any chunk, WritableStreamDefaultController controller); +callback UnderlyingSinkCloseCallback = Promise (); +callback UnderlyingSinkAbortCallback = Promise (optional any reason); + +[Exposed=(Window,Worker,Worklet)] interface WritableStreamDefaultWriter { - readonly attribute Promise closed; - readonly attribute unrestricted double? desiredSize; - readonly attribute Promise ready; + constructor(WritableStream stream); + + readonly attribute Promise closed; + readonly attribute unrestricted double? desiredSize; + readonly attribute Promise ready; - Promise abort(optional any reason); - Promise close(); - void releaseLock(); - Promise write(any chunk); + Promise abort(optional any reason); + Promise close(); + undefined releaseLock(); + Promise write(optional any chunk); }; -[Exposed=(Window,Worker)] +[Exposed=(Window,Worker,Worklet)] interface WritableStreamDefaultController { - void error(optional any error); + undefined error(optional any e); }; -[Constructor(optional Transformer transformer, optional QueuingStrategy writableStrategy, optional QueuingStrategy readableStrategy), - Exposed=(Window,Worker)] +[Exposed=(Window,Worker,Worklet), Transferable] interface TransformStream { - readonly attribute ReadableStream readable; - readonly attribute WritableStream writable; -}; + constructor(optional object transformer, + optional QueuingStrategy writableStrategy = {}, + optional QueuingStrategy readableStrategy = {}); -callback TransformStreamDefaultControllerCallback = any (TransformStreamDefaultController controller); -callback TransformStreamDefaultControllerTransformCallback = any (any chunk, TransformStreamDefaultController controller); + readonly attribute ReadableStream readable; + readonly attribute WritableStream writable; +}; dictionary Transformer { - TransformStreamDefaultControllerCallback? start; - TransformStreamDefaultControllerTransformCallback? transform; - TransformStreamDefaultControllerCallback? flush; - - any readableType; - any writableType; + TransformerStartCallback start; + TransformerTransformCallback transform; + TransformerFlushCallback flush; + any readableType; + any writableType; }; -[Exposed=(Window,Worker)] +callback TransformerStartCallback = any (TransformStreamDefaultController controller); +callback TransformerFlushCallback = Promise (TransformStreamDefaultController controller); +callback TransformerTransformCallback = Promise (any chunk, TransformStreamDefaultController controller); + +[Exposed=(Window,Worker,Worklet)] interface TransformStreamDefaultController { - readonly attribute unrestricted double? desiredSize; + readonly attribute unrestricted double? desiredSize; - void enqueue(any chunk); - void error(optional any reason); - void terminate(); + undefined enqueue(optional any chunk); + undefined error(optional any reason); + undefined terminate(); }; -[Constructor(any options), - Exposed=(Window,Worker)] -interface ByteLengthQueuingStrategy: QueuingStrategy { - attribute unrestricted double highWaterMark; - double size(ArrayBufferView chunk); +dictionary QueuingStrategy { + unrestricted double highWaterMark; + QueuingStrategySize size; +}; + +callback QueuingStrategySize = unrestricted double (optional any chunk); + +dictionary QueuingStrategyInit { + required unrestricted double highWaterMark; +}; + +[Exposed=(Window,Worker,Worklet)] +interface ByteLengthQueuingStrategy { + constructor(QueuingStrategyInit init); + + readonly attribute unrestricted double highWaterMark; + readonly attribute Function size; +}; + +[Exposed=(Window,Worker,Worklet)] +interface CountQueuingStrategy { + constructor(QueuingStrategyInit init); + + readonly attribute unrestricted double highWaterMark; + readonly attribute Function size; }; -[Constructor(any options), - Exposed=(Window,Worker)] -interface CountQueuingStrategy: QueuingStrategy { - attribute unrestricted double highWaterMark; - double size(any chunk); +interface mixin GenericTransformStream { + readonly attribute ReadableStream readable; + readonly attribute WritableStream writable; }; diff --git a/inputfiles/overridingTypes.json b/inputfiles/overridingTypes.json index 4408392f0..883700736 100644 --- a/inputfiles/overridingTypes.json +++ b/inputfiles/overridingTypes.json @@ -214,7 +214,7 @@ "(event: Event | string, source?: string, lineno?: number, colno?: number, error?: Error): any" ] }, - "QueuingStrategySizeCallback": { + "QueuingStrategySize": { "type-parameters": [ { "name": "T", @@ -225,32 +225,37 @@ "(chunk: T): number" ] }, - "ReadableByteStreamControllerCallback": { + "UnderlyingSourceStartCallback": { + "type-parameters": [ + { + "name": "R" + } + ], "override-signatures": [ - "(controller: ReadableByteStreamController): void | PromiseLike" + "(controller: ReadableStreamController): void | PromiseLike" ] }, - "ReadableStreamDefaultControllerCallback": { + "UnderlyingSourcePullCallback": { "type-parameters": [ { "name": "R" } ], "override-signatures": [ - "(controller: ReadableStreamDefaultController): void | PromiseLike" + "(controller: ReadableStreamController): void | PromiseLike" ] }, - "ReadableStreamErrorCallback": { + "UnderlyingSourceCancelCallback": { "override-signatures": [ "(reason: any): void | PromiseLike" ] }, - "WritableStreamDefaultControllerStartCallback": { + "UnderlyingSinkStartCallback": { "override-signatures": [ "(controller: WritableStreamDefaultController): void | PromiseLike" ] }, - "WritableStreamDefaultControllerWriteCallback": { + "UnderlyingSinkWriteCallback": { "type-parameters": [ { "name": "W" @@ -260,17 +265,27 @@ "(chunk: W, controller: WritableStreamDefaultController): void | PromiseLike" ] }, - "WritableStreamDefaultControllerCloseCallback": { + "UnderlyingSinkCloseCallback": { "override-signatures": [ "(): void | PromiseLike" ] }, - "WritableStreamErrorCallback": { + "UnderlyingSinkAbortCallback": { "override-signatures": [ "(reason: any): void | PromiseLike" ] }, - "TransformStreamDefaultControllerCallback": { + "TransformerFlushCallback": { + "type-parameters": [ + { + "name": "O" + } + ], + "override-signatures": [ + "(controller: TransformStreamDefaultController): void | PromiseLike" + ] + }, + "TransformerStartCallback": { "type-parameters": [ { "name": "O" @@ -280,7 +295,7 @@ "(controller: TransformStreamDefaultController): void | PromiseLike" ] }, - "TransformStreamDefaultControllerTransformCallback": { + "TransformerTransformCallback": { "type-parameters": [ { "name": "I" @@ -2216,26 +2231,32 @@ ], "constructor": { "override-signatures": [ - "new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number, size?: undefined }): ReadableStream", "new(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream" + ], + "force-references": [ + { + "type": "UnderlyingSource" + }, + { + "type": "QueuingStrategy" + } ] }, "methods": { "method": { "getReader": { "override-signatures": [ - "getReader(options: { mode: \"byob\" }): ReadableStreamBYOBReader", "getReader(): ReadableStreamDefaultReader" ] }, "pipeThrough": { "override-signatures": [ - "pipeThrough({ writable, readable }: { writable: WritableStream, readable: ReadableStream }, options?: PipeOptions): ReadableStream" + "pipeThrough(transform: ReadableWritablePair, options?: StreamPipeOptions): ReadableStream" ] }, "pipeTo": { "override-signatures": [ - "pipeTo(dest: WritableStream, options?: PipeOptions): Promise" + "pipeTo(dest: WritableStream, options?: StreamPipeOptions): Promise" ] }, "tee": { @@ -2246,35 +2267,6 @@ } } }, - "ReadableStreamReader": { - "override-exposed": "Window Worker", - "type-parameters": [ - { - "name": "R", - "default": "any" - } - ], - "methods": { - "method": { - "read": { - "override-signatures": [ - "read(): Promise>" - ] - } - } - } - }, - "ReadableStreamBYOBReader": { - "methods": { - "method": { - "read": { - "override-signatures": [ - "read(view: T): Promise>" - ] - } - } - } - }, "ReadableStreamDefaultReader": { "type-parameters": [ { @@ -2282,25 +2274,21 @@ "default": "any" } ], + "constructor": { + "override-signatures": [ + "new(stream: ReadableStream): ReadableStreamDefaultReader" + ] + }, "methods": { "method": { "read": { "override-signatures": [ - "read(): Promise>" + "read(): Promise>" ] } } } }, - "ReadableByteStreamController": { - "properties": { - "property": { - "byobRequest": { - "override-type": "ReadableStreamBYOBRequest | undefined" - } - } - } - }, "ReadableStreamDefaultController": { "type-parameters": [ { @@ -2322,6 +2310,14 @@ "constructor": { "override-signatures": [ "new(underlyingSink?: UnderlyingSink, strategy?: QueuingStrategy): WritableStream" + ], + "force-references": [ + { + "type": "UnderlyingSink" + }, + { + "type": "QueuingStrategy" + } ] }, "type-parameters": [ @@ -2347,6 +2343,11 @@ "default": "any" } ], + "constructor": { + "override-signatures": [ + "new(stream: WritableStream): WritableStreamDefaultWriter" + ] + }, "methods": { "method": { "write": { @@ -2381,6 +2382,14 @@ "constructor": { "override-signatures": [ "new(transformer?: Transformer, writableStrategy?: QueuingStrategy, readableStrategy?: QueuingStrategy): TransformStream" + ], + "force-references": [ + { + "type": "Transformer" + }, + { + "type": "QueuingStrategy" + } ] } }, @@ -2403,28 +2412,62 @@ }, "ByteLengthQueuingStrategy": { "extends": "QueuingStrategy", - "constructor": { - "override-signatures": [ - "new(options: { highWaterMark: number }): ByteLengthQueuingStrategy" - ] + "properties": { + "property": { + "size": { + "name": "size", + "override-type": [ + "QueuingStrategySize" + ] + } + } } }, "CountQueuingStrategy": { - "constructor": { - "override-signatures": [ - "new(options: { highWaterMark: number }): CountQueuingStrategy" - ] - }, - "methods": { - "method": { + "extends": "QueuingStrategy", + "properties": { + "property": { "size": { - "override-signatures": [ - "size(chunk: any): 1" + "name": "size", + "override-type": [ + "QueuingStrategySize" ] } } } }, + "TextDecoderStream": { + "properties": { + "property": { + "readable": { + "name": "readable", + "read-only": 1, + "override-type": "ReadableStream" + }, + "writable": { + "name": "writable", + "read-only": 1, + "override-type": "WritableStream" + } + } + } + }, + "TextEncoderStream": { + "properties": { + "property": { + "readable": { + "name": "readable", + "read-only": 1, + "override-type": "ReadableStream" + }, + "writable": { + "name": "writable", + "read-only": 1, + "override-type": "WritableStream" + } + } + } + }, "Permissions": { "methods": { "method": { @@ -2781,24 +2824,6 @@ "[property: string]: string | number | null | undefined" ] }, - "PipeOptions": { - "members": { - "member": { - "preventClose": { - "nullable": 0 - }, - "preventAbort": { - "nullable": 0 - }, - "preventCancel": { - "nullable": 0 - }, - "signal": { - "nullable": 0 - } - } - } - }, "PublicKeyCredentialCreationOptions": { "members": { "member": { @@ -2849,67 +2874,30 @@ ], "members": { "member": { - "highWaterMark": { - "nullable": 0 - }, "size": { - "override-type": "QueuingStrategySizeCallback", - "nullable": 0 + "override-type": "QueuingStrategySize" } } } }, - "ReadableStreamReadDoneResult": { + "ReadableWritablePair": { "type-parameters": [ { - "name": "T" - } - ], - "members": { - "member": { - "done": { - "override-type": "true" - }, - "value": { - "override-type": "T" - } - } - } - }, - "ReadableStreamReadValueResult": { - "type-parameters": [ + "name": "R", + "default": "any" + }, { - "name": "T" + "name": "W", + "default": "any" } ], "members": { "member": { - "done": { - "override-type": "false" - }, - "value": { - "override-type": "T" - } - } - } - }, - "UnderlyingByteSource": { - "members": { - "member": { - "start": { - "nullable": 0 - }, - "pull": { - "nullable": 0 - }, - "cancel": { - "nullable": 0 - }, - "autoAllocateChunkSize": { - "nullable": 0 + "readable": { + "override-type": "ReadableStream" }, - "type": { - "override-type": "\"bytes\"" + "writable": { + "override-type": "WritableStream" } } } @@ -2924,15 +2912,10 @@ "members": { "member": { "start": { - "override-type": "ReadableStreamDefaultControllerCallback", - "nullable": 0 + "override-type": "UnderlyingSourceStartCallback" }, "pull": { - "override-type": "ReadableStreamDefaultControllerCallback", - "nullable": 0 - }, - "cancel": { - "nullable": 0 + "override-type": "UnderlyingSourcePullCallback" }, "type": { "override-type": "undefined" @@ -2949,18 +2932,8 @@ ], "members": { "member": { - "start": { - "nullable": 0 - }, "write": { - "override-type": "WritableStreamDefaultControllerWriteCallback", - "nullable": 0 - }, - "close": { - "nullable": 0 - }, - "abort": { - "nullable": 0 + "override-type": "UnderlyingSinkWriteCallback" }, "type": { "override-type": "undefined" @@ -2991,16 +2964,13 @@ "members": { "member": { "start": { - "override-type": "TransformStreamDefaultControllerCallback", - "nullable": 0 + "override-type": "TransformerStartCallback" }, "transform": { - "override-type": "TransformStreamDefaultControllerTransformCallback", - "nullable": 0 + "override-type": "TransformerTransformCallback" }, "flush": { - "override-type": "TransformStreamDefaultControllerCallback", - "nullable": 0 + "override-type": "TransformerFlushCallback" }, "readableType": { "override-type": "undefined" @@ -3071,8 +3041,8 @@ "new-type": "BodyInit" }, { - "override-type": "ReadableStreamReadValueResult | ReadableStreamReadDoneResult", - "new-type": "ReadableStreamReadResult", + "override-type": "ReadableStreamDefaultController", + "new-type": "ReadableStreamController", "type-parameters": [ { "name": "T" diff --git a/inputfiles/removedTypes.json b/inputfiles/removedTypes.json index 021272ef0..725ceee08 100644 --- a/inputfiles/removedTypes.json +++ b/inputfiles/removedTypes.json @@ -59,6 +59,8 @@ "enums": { "enum": { "ClientType": null, + "ReadableStreamReaderMode": null, + "ReadableStreamType": null, "RequestType": null } }, @@ -246,6 +248,13 @@ "PasswordCredential": null, "Position": null, "PositionError": null, + "ReadableByteStreamController": null, + "ReadableStream": { + "iterator": null + }, + "ReadableStreamBYOBReader": null, + "ReadableStreamBYOBRequest": null, + "ReadableStreamReader": null, "RTCDataChannel": { "properties": { "property": { @@ -380,6 +389,13 @@ "WindowConsole" ] }, + "WritableStream": { + "methods": { + "method": { + "close": null + } + } + }, "XPathNSResolver": null } }, @@ -402,12 +418,22 @@ } }, "ObjectURLOptions": null, + "ReadableStreamBYOBReadResult": null, + "ReadableStreamDefaultReadResult": null, + "ReadableStreamGetReaderOptions": null, "RTCIceGatherOptions": { "members": { "member": { "portRange": null } } + }, + "UnderlyingSource": { + "members": { + "member": { + "autoAllocateChunkSize": null + } + } } } }, diff --git a/src/idlfetcher.ts b/src/idlfetcher.ts index 05ea14340..146cac2e3 100644 --- a/src/idlfetcher.ts +++ b/src/idlfetcher.ts @@ -10,7 +10,6 @@ interface IDLSource { url: string; title: string; deprecated?: boolean; - local?: boolean; } const idlSelector = [ @@ -30,9 +29,6 @@ async function fetchIDLs(filter: string[]) { const idlSources = (require("../inputfiles/idlSources.json") as IDLSource[]) .filter(source => !filter.length || filter.includes(source.title)); await Promise.all(idlSources.map(async source => { - if (source.local) { - return; - } const { idl, comments } = await fetchIDL(source); fs.writeFileSync(path.join(__dirname, `../inputfiles/idl/${source.title}.widl`), idl + '\n'); if (comments) {