Skip to content

Commit 89cfa62

Browse files
authored
Rename Response based compile + instantiate *Streaming. (#1068)
Clarify how the source parameter is resolved. Clarify how the result of instantiate* is described.
1 parent abb557a commit 89cfa62

File tree

2 files changed

+36
-28
lines changed

2 files changed

+36
-28
lines changed

JS.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,19 @@ If neither of the following overloads match, then the returned `Promise` is
113113
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).
114114

115115
```
116-
Promise<{module:WebAssembly.Module, instance:WebAssembly.Instance}>
116+
dictionary WebAssemblyInstantiatedSource {
117+
required WebAssembly.Module module;
118+
required WebAssembly.Instance instance;
119+
};
120+
121+
Promise<WebAssemblyInstantiatedSource>
117122
instantiate(BufferSource bytes [, importObject])
118123
```
119124

120-
This description applies if the first argument is a
121-
[`BufferSource`](https://heycam.github.io/webidl/#common-BufferSource).
125+
If the given `bytes` argument is not a
126+
[`BufferSource`](https://heycam.github.io/webidl/#common-BufferSource),
127+
the returned `Promise` is [rejected](http://tc39.github.io/ecma262/#sec-rejectpromise)
128+
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).
122129

123130
This function starts an asynchronous task that first compiles a `WebAssembly.Module`
124131
from `bytes` as described in the [`WebAssembly.Module` constructor](#webassemblymodule-constructor)

Web.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,24 @@ Non-web embeddings are not required to support these additional methods.
3131

3232
:cyclone: Added for milestone 2, developers must feature detect.
3333

34-
In Web embeddings, the following overloads are added (in addition to the core
35-
JS API method of the same name).
34+
In Web embeddings, the following methods are added.
3635

3736
```
38-
Promise<WebAssembly.Module> compile(Response source)
39-
40-
Promise<WebAssembly.Module> compile(Promise<Response> source)
37+
Promise<WebAssembly.Module> compileStreaming(source)
4138
```
4239

43-
Developers can set the argument `source` with either a promise that resolves
44-
with a
40+
`source` is unconditionally passed through the built-in value
41+
of `Promise.resolve`.
42+
If the result is not a `Response` object, then the returned `Promise` is
43+
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise)
44+
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).
45+
This allows developers to pass either a promise that resolves
46+
to a
4547
[`Response`](https://fetch.spec.whatwg.org/#response-class)
4648
object or a
4749
[`Response`](https://fetch.spec.whatwg.org/#response-class)
4850
object (which is automatically cast to a
49-
promise).
50-
If when unwrapped that `Promise` is not a `Response` object, then the returned `Promise` is
51-
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise)
52-
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).
51+
promise) for the `source`.
5352
Renderer-side
5453
security checks about tainting for cross-origin content are tied to the types
5554
of filtered responses defined in
@@ -62,7 +61,7 @@ with the resulting `WebAssembly.Module` object. On failure, the `Promise` is
6261
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise) with a
6362
`WebAssembly.CompileError`.
6463

65-
The `Promise<Response>` is used as the source of the bytes to compile.
64+
The resolved `Response` is used as the source of the bytes to compile.
6665
MIME type information is
6766
[`extracted`](https://fetch.spec.whatwg.org/#concept-header-extract-mime-type)
6867
from the `Response`, WebAssembly `source` data must have a MIME type of `application/wasm`,
@@ -75,27 +74,29 @@ MIME type mismatch or `opaque` response types
7574

7675
:cyclone: Added for milestone 2, developers must feature detect.
7776

78-
In Web embeddings, the following overloads are added (in addition to the core
79-
JS API method of the same name).
77+
In Web embeddings, the following methods are added.
8078

8179
```
82-
Promise<{module:WebAssembly.Module, instance:WebAssembly.Instance}>
83-
instantiate(Response source [, importObject])
80+
dictionary WebAssemblyInstantiatedSource {
81+
required WebAssembly.Module module;
82+
required WebAssembly.Instance instance;
83+
};
8484
85-
Promise<{module:WebAssembly.Module, instance:WebAssembly.Instance}>
86-
instantiate(Promise<Response> source [, importObject])
85+
Promise<InstantiatedSource> instantiateStreaming(source [, importObject])
8786
```
8887

89-
Developers can set the argument `source` with either a promise that resolves
90-
with a
88+
`source` is unconditionally passed through the built-in value
89+
of `Promise.resolve`.
90+
If the result is not a `Response` object, then the returned `Promise` is
91+
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise)
92+
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).
93+
This allows developers to pass either a promise that resolves
94+
to a
9195
[`Response`](https://fetch.spec.whatwg.org/#response-class)
9296
object or a
9397
[`Response`](https://fetch.spec.whatwg.org/#response-class)
9498
object (which is automatically cast to a
95-
promise).
96-
If when unwrapped that `Promise` is not a `Response` object, then the returned `Promise` is
97-
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise)
98-
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).
99+
promise) for the `source`.
99100
Renderer-side
100101
security checks about tainting for cross-origin content are tied to the types
101102
of filtered responses defined in
@@ -114,7 +115,7 @@ On failure, the `Promise` is
114115
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise) with a
115116
`WebAssembly.CompileError`, `WebAssembly.LinkError`, or `WebAssembly.RuntimeError`, depending on the cause of failure.
116117

117-
The `Promise<Response>` is used as the source of the bytes to compile.
118+
The resolved `Response` is used as the source of the bytes to compile.
118119
MIME type information is
119120
[`extracted`](https://fetch.spec.whatwg.org/#concept-header-extract-mime-type)
120121
from the `Response`, WebAssembly `source` data must have a MIME type of `application/wasm`,

0 commit comments

Comments
 (0)