forked from whatwg/streams
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite to use Web IDL, and generally modernize
Closes whatwg#963. Normative changes to widely-implemented features, roughly in order of most disruptive to least-disruptive: * For the queuing strategy classes, their size and highWaterMark properties are now getters on the prototype, instead of data properties on the prototype and instance (respectively). Closes whatwg#1005. In particular this means that attempts to set either of them post-creation will throw a TypeError. Chromium already ships these semantics. * Functions which take a dictionary no longer accept non-objects. * For the queuing strategy classes, their highWaterMark property will no longer return a non-number from their highWaterMark properties, if one was passed to the constructor. Instead, NaN will be returned. * All methods and accessors are now enumerable, per Web IDL defaults, instead of non-enumerable, per ECMAScript defaults. * All classes are now exposed globally. Formerly, ReadableStreamDefaultReader, ReadableStreamBYOBReader, ReadableStreamDefaultController, ReadableByteStreamController, WritableStreamDefaultWriter, WritableStreamDefaultController, and TransformStreamDefaultController were not exposed. Closes whatwg#586. * All classes now have [Symbol.toStringTag] properties. Closes whatwg#952. * Some functions have changed their length property value. * Some exceptions are thrown earlier, at argument-conversion time. * Property lookup in options arguments now happens earlier, at argument-conversion time, and in alphabetical order, per dictionary rules. Normative changes to unimplemented features: * ReadableStream's getIterator() method has been renamed to values() as part of adopting Web IDL's infrastructure for async iterators. * The byobRequest property on ReadableByteStreamController now returns null when there is no BYOB request, instead of returning undefined. * The view property on ReadableStreamBYOBRequest now returns null when the view cannot be written into, instead of returning undefined. * Various byte-stream-related APIs that used to specifically prohibit detached buffers now check for zero-length views or buffers, which is a more general category. * The async iterator's next() and return() methods now behave more like async generators, e.g. returning promises fulfilled with { value: undefined, done: true } after return()ing the iterator, instead of returning a rejected promise. Editorial changes: * All APIs are specified to using Web IDL now, instead of using a modified version of the ECMAScript specification conventions. We continue using abstract operations and completion records for now, and we have to drop down to the ECMAScript level in a couple places (notably for dealing with %ObjectPrototype% vs. null-prototype iteration result objects, and transferring array buffers). But overall this removes a lot of type-checking and conversion boilerplate from the specification. Closes whatwg#963. Closes whatwg#1017. See whatwg#1036 for further followup on the iteration result objects. * Individual abstract operations, constructors, methods, and properties no longer have their own heading. They are instead lumped together in sections. Closes whatwg#885. * The constructors, methods, and properties are now documented in a per-class block, using the usual WHATWG "domintro" style. Closes whatwg#907. * Abstract operations are now consistently alphabetized within their section. Closes whatwg#684. * By using Bikeshed's <div algorithm> feature, we now get automatic identifier highlighting. Closes whatwg#687. * Switched to 100-character line limits, 1-space indents, and omitting end tags, per WHATWG conventions. * Removed usage of emu-algify in favor of using some more of Bikeshed's built-in features, plus manually annotating a few things. * Switched to concise Bikeshed linking syntax, e.g. [=term=] and [$AbstractOp$]. * Eliminated a number of utility abstract operations, especially around calling functions, by better using Web IDL. Other bug fixes: * Web IDL makes constructor behavior clear, so this closes whatwg#965.
- Loading branch information
1 parent
32ac410
commit 7dbcfed
Showing
61 changed files
with
7,419 additions
and
7,697 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,3 @@ | |
/deploy_key.pub | ||
/index.html | ||
/review.sh | ||
/index.html.* | ||
/node_modules/ | ||
/npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
{ | ||
"src_file": "index.bs", | ||
"type": "bikeshed", | ||
"params": { | ||
"force": 1, | ||
"md-status": "LS-PR", | ||
"md-Text-Macro": "PR-NUMBER {{ pull_request.number }}" | ||
}, | ||
"post_processing": { | ||
"name": "emu-algify", | ||
"options": { | ||
"throwingIndicators": true | ||
} | ||
} | ||
"src_file": "index.bs", | ||
"type": "bikeshed", | ||
"params": { | ||
"force": 1, | ||
"md-status": "LS-PR", | ||
"md-Text-Macro": "PR-NUMBER {{ pull_request.number }}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,25 @@ SHELL=/bin/bash -o pipefail | |
.PHONY: local remote deploy review | ||
|
||
remote: index.bs | ||
curl https://api.csswg.org/bikeshed/ -f -F [email protected] > index.html.postbs -F md-Text-Macro="SNAPSHOT-LINK LOCAL COPY" | ||
node_modules/.bin/emu-algify --throwing-indicators < index.html.postbs > index.html | ||
@ (HTTP_STATUS=$$(curl https://api.csswg.org/bikeshed/ \ | ||
--output index.html \ | ||
--write-out "%{http_code}" \ | ||
--header "Accept: text/plain, text/html" \ | ||
-F die-on=warning \ | ||
-F md-Text-Macro="COMMIT-SHA LOCAL COPY" \ | ||
-F [email protected]) && \ | ||
[[ "$$HTTP_STATUS" -eq "200" ]]) || ( \ | ||
echo ""; cat index.html; echo ""; \ | ||
rm -f index.html; \ | ||
exit 22 \ | ||
); | ||
|
||
local: index.bs | ||
bikeshed spec index.bs index.html.postbs --md-Text-Macro="SNAPSHOT-LINK LOCAL COPY" | ||
node_modules/.bin/emu-algify --throwing-indicators < index.html.postbs > index.html | ||
bikeshed spec index.bs index.html --md-Text-Macro="COMMIT-SHA LOCAL COPY" | ||
|
||
deploy: index.bs | ||
curl --remote-name --fail https://resources.whatwg.org/build/deploy.sh | ||
EXTRA_FILES="demos/* demos/**/*" \ | ||
POST_BUILD_STEP='node_modules/.bin/emu-algify --throwing-indicators < "$$DIR/index.html" > "$$DIR/index.html.tmp"; mv "$$DIR/index.html.tmp" "$$DIR/index.html"' \ | ||
bash ./deploy.sh | ||
|
||
review: index.bs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
web-platform-tests/ | ||
coverage/ | ||
generated/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ package-lock.json | |
|
||
.nyc_output/ | ||
coverage/ | ||
generated/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
/* eslint-disable no-console, no-process-exit */ | ||
const { mkdirSync } = require('fs'); | ||
const path = require('path'); | ||
const Transformer = require('webidl2js'); | ||
|
||
const input = path.resolve(__dirname, './lib'); | ||
const output = path.resolve(__dirname, './generated'); | ||
|
||
mkdirSync(output, { recursive: true }); | ||
|
||
const transformer = new Transformer({ | ||
implSuffix: '-impl', | ||
suppressErrors: true // until https://github.com/jsdom/webidl2js/pull/123 lands | ||
}); | ||
|
||
transformer.addSource(input, input); | ||
transformer.generate(output) | ||
.catch(err => { | ||
console.error(err.stack); | ||
process.exit(1); | ||
}); |
26 changes: 26 additions & 0 deletions
26
reference-implementation/lib/ByteLengthQueuingStrategy-impl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
exports.implementation = class ByteLengthQueuingStrategyImpl { | ||
constructor(globalObject, [{ highWaterMark }]) { | ||
this._globalObject = globalObject; | ||
this.highWaterMark = highWaterMark; | ||
} | ||
|
||
get size() { | ||
initializeSizeFunction(this._globalObject); | ||
return sizeFunctionWeakMap.get(this._globalObject); | ||
} | ||
}; | ||
|
||
const sizeFunctionWeakMap = new WeakMap(); | ||
function initializeSizeFunction(globalObject) { | ||
if (sizeFunctionWeakMap.has(globalObject)) { | ||
return; | ||
} | ||
|
||
// We need to set the 'name' property: | ||
// eslint-disable-next-line prefer-arrow-callback | ||
sizeFunctionWeakMap.set(globalObject, function size(chunk) { | ||
return chunk.byteLength; | ||
}); | ||
} |
7 changes: 7 additions & 0 deletions
7
reference-implementation/lib/ByteLengthQueuingStrategy.webidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[Exposed=(Window,Worker,Worklet)] | ||
interface ByteLengthQueuingStrategy { | ||
constructor(QueuingStrategyInit init); | ||
|
||
readonly attribute unrestricted double highWaterMark; | ||
readonly attribute Function size; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
exports.implementation = class CountQueuingStrategyImpl { | ||
constructor(globalObject, [{ highWaterMark }]) { | ||
this._globalObject = globalObject; | ||
this.highWaterMark = highWaterMark; | ||
} | ||
|
||
get size() { | ||
initializeSizeFunction(this._globalObject); | ||
return sizeFunctionWeakMap.get(this._globalObject); | ||
} | ||
}; | ||
|
||
const sizeFunctionWeakMap = new WeakMap(); | ||
function initializeSizeFunction(globalObject) { | ||
if (sizeFunctionWeakMap.has(globalObject)) { | ||
return; | ||
} | ||
|
||
// We need to set the 'name' property: | ||
// eslint-disable-next-line prefer-arrow-callback | ||
sizeFunctionWeakMap.set(globalObject, function size() { | ||
return 1; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[Exposed=(Window,Worker,Worklet)] | ||
interface CountQueuingStrategy { | ||
constructor(QueuingStrategyInit init); | ||
|
||
readonly attribute unrestricted double highWaterMark; | ||
readonly attribute Function size; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dictionary QueuingStrategy { | ||
unrestricted double highWaterMark; | ||
QueuingStrategySize size; | ||
}; | ||
|
||
callback QueuingStrategySize = unrestricted double (optional any chunk); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dictionary QueuingStrategyInit { | ||
required unrestricted double highWaterMark; | ||
}; |
Oops, something went wrong.