Skip to content

Commit

Permalink
Update Streams to official WebIDL (#890)
Browse files Browse the repository at this point in the history
* Use official WebIDL for Streams

* Add type parameter to ReadableStreamDefaultReader constructor

* Add type parameter to WritableStreamDefaultWriter constructor

* Remove async iterator on ReadableStream for now

* Remove support for "local" IDLs from idlfetcher

* Fix Transformer callbacks

* Move TextDecoder/EncoderStream modifications to overridingTypes

* Use "force-references" in constructor overrides

* Remove obsolete nullable overrides

* Update baselines

* Remove WritableStream.close

* Remove types for readable byte streams

* Update baselines

* Update Streams and Encoding IDL

* Update baselines
  • Loading branch information
MattiasBuelens authored Dec 11, 2020
1 parent 07ea4e8 commit 271893c
Show file tree
Hide file tree
Showing 10 changed files with 601 additions and 600 deletions.
243 changes: 107 additions & 136 deletions baselines/dom.generated.d.ts

Large diffs are not rendered by default.

243 changes: 107 additions & 136 deletions baselines/webworker.generated.d.ts

Large diffs are not rendered by default.

101 changes: 69 additions & 32 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -2182,38 +2182,6 @@
]
}
},
"TextDecoderStream": {
"properties": {
"property": {
"readable": {
"name": "readable",
"read-only": 1,
"override-type": "ReadableStream<string>"
},
"writable": {
"name": "writable",
"read-only": 1,
"override-type": "WritableStream<BufferSource>"
}
}
}
},
"TextEncoderStream": {
"properties": {
"property": {
"readable": {
"name": "readable",
"read-only": 1,
"override-type": "ReadableStream<Uint8Array>"
},
"writable": {
"name": "writable",
"read-only": 1,
"override-type": "WritableStream<string>"
}
}
}
},
"Attr": {
"name": "Attr",
"properties": {
Expand Down Expand Up @@ -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
}
}
}
}
}
},
Expand Down Expand Up @@ -2434,6 +2440,37 @@
"type": "ModuleImports"
}
]
},
{
"new-type": "ReadableStreamDefaultReadResult",
"type-parameters": [
{
"name": "T"
}
],
"type": [
{
"type": "ReadableStreamDefaultReadValueResult"
},
{
"type": "ReadableStreamDefaultReadDoneResult"
}
],
"override-type": "ReadableStreamDefaultReadValueResult<T> | ReadableStreamDefaultReadDoneResult"
},
{
"new-type": "ReadableStreamReader",
"type-parameters": [
{
"name": "T"
}
],
"type": [
{
"type": "ReadableStreamDefaultReader"
}
],
"override-type": "ReadableStreamDefaultReader<T>"
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions inputfiles/idl/Encoding.commentmap.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
5 changes: 0 additions & 5 deletions inputfiles/idl/Encoding.widl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {});
Expand Down
2 changes: 1 addition & 1 deletion inputfiles/idl/Streams.commentmap.json
Original file line number Diff line number Diff line change
@@ -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."
}
Loading

0 comments on commit 271893c

Please sign in to comment.