Skip to content

Commit 271893c

Browse files
Update Streams to official WebIDL (#890)
* 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
1 parent 07ea4e8 commit 271893c

10 files changed

+601
-600
lines changed

baselines/dom.generated.d.ts

+107-136
Large diffs are not rendered by default.

baselines/webworker.generated.d.ts

+107-136
Large diffs are not rendered by default.

inputfiles/addedTypes.json

+69-32
Original file line numberDiff line numberDiff line change
@@ -2182,38 +2182,6 @@
21822182
]
21832183
}
21842184
},
2185-
"TextDecoderStream": {
2186-
"properties": {
2187-
"property": {
2188-
"readable": {
2189-
"name": "readable",
2190-
"read-only": 1,
2191-
"override-type": "ReadableStream<string>"
2192-
},
2193-
"writable": {
2194-
"name": "writable",
2195-
"read-only": 1,
2196-
"override-type": "WritableStream<BufferSource>"
2197-
}
2198-
}
2199-
}
2200-
},
2201-
"TextEncoderStream": {
2202-
"properties": {
2203-
"property": {
2204-
"readable": {
2205-
"name": "readable",
2206-
"read-only": 1,
2207-
"override-type": "ReadableStream<Uint8Array>"
2208-
},
2209-
"writable": {
2210-
"name": "writable",
2211-
"read-only": 1,
2212-
"override-type": "WritableStream<string>"
2213-
}
2214-
}
2215-
}
2216-
},
22172185
"Attr": {
22182186
"name": "Attr",
22192187
"properties": {
@@ -2336,6 +2304,44 @@
23362304
}
23372305
}
23382306
}
2307+
},
2308+
"ReadableStreamDefaultReadDoneResult": {
2309+
"name": "ReadableStreamDefaultReadDoneResult",
2310+
"members": {
2311+
"member": {
2312+
"done": {
2313+
"name": "done",
2314+
"override-type": "true",
2315+
"required": 1
2316+
},
2317+
"value": {
2318+
"name": "value",
2319+
"override-type": "undefined"
2320+
}
2321+
}
2322+
}
2323+
},
2324+
"ReadableStreamDefaultReadValueResult": {
2325+
"name": "ReadableStreamDefaultReadValueResult",
2326+
"type-parameters": [
2327+
{
2328+
"name": "T"
2329+
}
2330+
],
2331+
"members": {
2332+
"member": {
2333+
"done": {
2334+
"name": "done",
2335+
"override-type": "false",
2336+
"required": 1
2337+
},
2338+
"value": {
2339+
"name": "value",
2340+
"override-type": "T",
2341+
"required": 1
2342+
}
2343+
}
2344+
}
23392345
}
23402346
}
23412347
},
@@ -2434,6 +2440,37 @@
24342440
"type": "ModuleImports"
24352441
}
24362442
]
2443+
},
2444+
{
2445+
"new-type": "ReadableStreamDefaultReadResult",
2446+
"type-parameters": [
2447+
{
2448+
"name": "T"
2449+
}
2450+
],
2451+
"type": [
2452+
{
2453+
"type": "ReadableStreamDefaultReadValueResult"
2454+
},
2455+
{
2456+
"type": "ReadableStreamDefaultReadDoneResult"
2457+
}
2458+
],
2459+
"override-type": "ReadableStreamDefaultReadValueResult<T> | ReadableStreamDefaultReadDoneResult"
2460+
},
2461+
{
2462+
"new-type": "ReadableStreamReader",
2463+
"type-parameters": [
2464+
{
2465+
"name": "T"
2466+
}
2467+
],
2468+
"type": [
2469+
{
2470+
"type": "ReadableStreamDefaultReader"
2471+
}
2472+
],
2473+
"override-type": "ReadableStreamDefaultReader<T>"
24372474
}
24382475
]
24392476
}

inputfiles/idl/Encoding.commentmap.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"textdecoder": "Returns a new TextDecoder object.\n\nIf label is either not a label or is a label for replacement, throws a RangeError.",
33
"textdecodercommon-encoding": "Returns encoding's name, lowercased.",
4-
"textdecodercommon-fatal": "Returns true if error mode is \"fatal\", and false otherwise.",
5-
"textdecodercommon-ignorebom": "Returns true if ignore BOM flag is set, and false otherwise.",
6-
"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.",
4+
"textdecodercommon-fatal": "Returns true if error mode is \"fatal\", otherwise false.",
5+
"textdecodercommon-ignorebom": "Returns the value of ignore BOM.",
6+
"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.",
77
"textencoder": "Returns a new TextEncoder object.",
88
"textencodercommon-encoding": "Returns \"utf-8\".",
99
"textencoder-encode": "Returns the result of running UTF-8's encoder.",
10-
"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.",
10+
"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.",
1111
"textdecoderstream": "Returns a new TextDecoderStream object.\n\nIf label is either not a label or is a label for replacement, throws a RangeError.",
1212
"generictransformstream-readable": "Returns a readable stream whose chunks are strings resulting from running encoding's decoder on the chunks written to writable.",
1313
"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.",

inputfiles/idl/Encoding.widl

-5
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ interface TextEncoder {
3939
};
4040
TextEncoder includes TextEncoderCommon;
4141

42-
interface mixin GenericTransformStream {
43-
readonly attribute ReadableStream readable;
44-
readonly attribute WritableStream writable;
45-
};
46-
4742
[Exposed=(Window,Worker)]
4843
interface TextDecoderStream {
4944
constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options = {});
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"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.",
33
"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.",
4-
"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.",
4+
"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.",
55
"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.",
66
"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."
77
}

0 commit comments

Comments
 (0)