Conversation
| <li><p>Set <var>script</var>'s <span data-x="concept-script-parse-error">parse error</span> and | ||
| <span data-x="concept-script-error-to-rethrow">error to rethrow</span> to null.</p></li> | ||
|
|
||
| <li><p>Let <var>result</var> be a new <code>Uint8Array</code> object, in <var>settings</var>'s |
There was a problem hiding this comment.
You may want to use the creating an ArrayBufferView operation here (see e.g. the bytes() method on Response), although this does not allow you to specify specifically an immutable ArrayBuffer (yet?).
I don't think "backing bytes" is really a concept which exists anywhere.
There was a problem hiding this comment.
Yeah, you might have to add a new argument for that or a separate operation.
There was a problem hiding this comment.
I'm not sure I fully understand. Mind leaving a code suggestion?
There was a problem hiding this comment.
This is the algorithm where creation of Uint8Array&friends is defined: https://github.com/whatwg/webidl/blob/a79e69ef7398ece546e526a1eebec977363c7304/index.bs#L9277-L9291
It needs to take a new parameter (I guess either a boolean or an enum like preserveResizability of https://tc39.es/proposal-immutable-arraybuffer/#sec-arraybuffercopyanddetach), propagate it to https://github.com/whatwg/webidl/blob/a79e69ef7398ece546e526a1eebec977363c7304/index.bs#L9252 and then call AllocateImmutableArrayBuffer (or ArrayBufferCopyAndDetach, depending on what is simpler) appropriately.
There was a problem hiding this comment.
More precisely, as mentioned below, HTML should only be creating the ArrayBuffer, and then calling CreateBytesModule from the proposal.
So it's only the create an ArrayBuffer algorithm which needs updated with the new parameter, not the algorithm for creating new views like Uint8Array.
There was a problem hiding this comment.
So it sounds like I need to create a PR to the whatwg/webidl repo to modify create an ArrayBuffer before proceeding with this whatwg/html PR. Is that correct?
source
Outdated
| script</span> algorithm. Bytes module scripts represent binary data as Uint8Array backed by | ||
| an immutable ArrayBuffer.</p> |
There was a problem hiding this comment.
Might need to add references for both Uint8Array and Immutable Array Buffer here.
source
Outdated
| <!-- | ||
| This definition is not super-rigorous, but it doesn't need to be for now. If we ever start | ||
| testing if something is a Bytes module script in algorithms, instead of just referring to the | ||
| concept, then we should consider adding a type item to the module script struct. | ||
| --> |
There was a problem hiding this comment.
This definition is perfectly rigorous IMO - a bytes module script === the output of the creating a bytes module script steps. That's the definition.
| <li><p>Let <var>result</var> be a new <code>Uint8Array</code> object, in <var>settings</var>'s | ||
| <span data-x="environment settings object's realm">realm</span>, whose backing bytes are <var>bytes</var>.</p></li> |
There was a problem hiding this comment.
This needs to initialize and reference the immutable array buffer spec as well, as a direct reference to https://tc39.es/proposal-immutable-arraybuffer/#sec-arraybuffer-objects.
Also we only need to create the ArrayBuffer here that is immutable, the Uint8Array typed array view is added on the TC39 spec side.
There was a problem hiding this comment.
I'm not sure I fully understand. Mind leaving a code suggestion?
There was a problem hiding this comment.
I think we want to use Web IDL for this, similar to what the Encoding Standard does for instance. But to make the backing buffer immutable we'll have to make a small change to Web IDL to allow for that.
There was a problem hiding this comment.
So it sounds like I need to create a PR to the whatwg/webidl repo to modify create an ArrayBuffer before proceeding with this whatwg/html PR. Is that correct?
source
Outdated
| <li><p>Set <var>script</var>'s <span data-x="concept-script-record">record</span> to the result | ||
| of <span>CreateDefaultExportSyntheticModule</span>(<var>result</var>).</p></li> |
There was a problem hiding this comment.
Rather than calling CreatedefaultExportSyntheticModule directly, it would be good to reference the TC39 spec here by making this:
<li><p>Let <var>record</var> be <span>CreateBytesModule</span>(<var>immutableBytes</var>).</p>
<li><p>Set <var>script</var>'s <span data-x="concept-script-record">record</span> to <var>record</var>.</p></li>
sort of thing.
Where CreateBytesModule is then a reference to the https://tc39.es/proposal-import-bytes/ spec.
There was a problem hiding this comment.
Added in 9828655
@guybedford @nicolo-ribaudo How's that look now?
| <li><p>Set <var>script</var>'s <span data-x="concept-script-parse-error">parse error</span> and | ||
| <span data-x="concept-script-error-to-rethrow">error to rethrow</span> to null.</p></li> | ||
|
|
||
| <li><p>Let <var>result</var> be a new <code>Uint8Array</code> object, in <var>settings</var>'s |
There was a problem hiding this comment.
Yeah, you might have to add a new argument for that or a separate operation.
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
To see how to link to a proposal, search for <ref>JSDYNAMICCODEBRANDCHECKS</ref> and [JSDYNAMICCODEBRANDCHECKS] through the document.
b6deeac to
e5b9757
Compare
source
Outdated
|
|
||
| <p>The <span>bytes module script</span> will return a <code>Uint8Array</code> object containing | ||
| the raw bytes of the fetched resource. Unlike <span data-x="JSON module script">JSON module scripts</span> | ||
| which require a specific MIME type, bytes modules can be used to import binary data from any resource.</p> |
There was a problem hiding this comment.
| which require a specific MIME type, bytes modules can be used to import binary data from any resource.</p> | |
| which require a specific MIME type, bytes module scripts can be used to import binary data from any resource.</p> |
There was a problem hiding this comment.
Fixed in 9896faa
(for some reason, github wouldn't accept the suggestion)
source
Outdated
| <p>A <span>module script</span> is a <dfn export>bytes module script</dfn> if its <span | ||
| data-x="concept-script-record">record</span> is a <span>Synthetic Module Record</span>, and it | ||
| was created via the <span data-x="creating a bytes module script">create a bytes module | ||
| script</span> algorithm. bytes module scripts represent binary data as <code>Uint8Array</code> |
There was a problem hiding this comment.
| script</span> algorithm. bytes module scripts represent binary data as <code>Uint8Array</code> | |
| script</span> algorithm. Bytes module scripts represent binary data as <code>Uint8Array</code> |
There was a problem hiding this comment.
Fixed in 9896faa
(for some reason, github wouldn't accept the suggestion)
source
Outdated
|
|
||
| <li><p>Let <var>record</var> be <span>CreateBytesModule</span>(<var>immutableBytes</var>).</p></li> | ||
|
|
||
| <ref>JSIMPORTBYTES</ref> |
There was a problem hiding this comment.
This appears in the wrong place. It should usually appear just before a </p>.
source
Outdated
| <p>User agents that support JavaScript must also implement the <cite>Import Bytes</cite> proposal. | ||
| The following terms are defined there, and used in this specification: <ref>JSIMPORTBYTES</ref></p> |
There was a problem hiding this comment.
This seems to be in the wrong place as well?
There was a problem hiding this comment.
"this" meaning the <ref>? Is there a better place to put it?
source
Outdated
| <var>settingsObject</var>, <var>response</var>'s <span | ||
| data-x="concept-response-url">URL</span>, and <var>options</var>.</p></li> | ||
|
|
||
| <li><p>If <var>moduleType</var> is "<code data-x="">bytes</code>", then set <var>moduleScript</var> to |
There was a problem hiding this comment.
I would move this before <li><p>Let <var>referrerPolicy</var> be the result of ..., and put the steps from it to the one that created the various other module scrips in an Else clause.
It's just an editorial suggestion to make it clear that those steps are useless for bytes module scripts, it does not actually affect behavior.
source
Outdated
| <pre><code class="html" data-x=""><script type="module"> | ||
| import logoBytes from "https://resources.whatwg.org/logo.png" with { type: "bytes" }; | ||
|
|
||
| console.log("Binary data length:", logoBytes.byteLength); |
There was a problem hiding this comment.
| console.log("Binary data length:", logoBytes.byteLength); | |
| console.log("Number of raw bytes:", logoBytes.byteLength); |
(Not a big fan of "binary data".)
source
Outdated
|
|
||
| <li><p>a <span>Synthetic Module Record</span>, for <span data-x="CSS module script">CSS module | ||
| scripts</span> and <span data-x="JSON module script">JSON module scripts</span>;</p></li> | ||
| scripts</span>, <span data-x="JSON module script">JSON module scripts</span>, and <span data-x="bytes module script">bytes module scripts</span>;</p></li> |
There was a problem hiding this comment.
Needs wrapping at 100 columns as per guidelines.
source
Outdated
| </ul> | ||
|
|
||
| <p class="note">As CSS style sheets and JSON documents do not import dependent modules, and do not | ||
| <p class="note">As CSS style sheets, JSON documents, and binary data do not import dependent modules, and do not |
There was a problem hiding this comment.
Maybe "As CSS style sheets and plain data ..." (which then encompasses both and also text in the future).
| <li><p>Set <var>script</var>'s <span data-x="concept-script-parse-error">parse error</span> and | ||
| <span data-x="concept-script-error-to-rethrow">error to rethrow</span> to null.</p></li> | ||
|
|
||
| <li><p>Let <var>result</var> be a new <code>Uint8Array</code> object, in <var>settings</var>'s |
bytesdestination w3c/webappsec-csp#803bytessec-fetch-dest and accept fetch#1912(See WHATWG Working Mode: Changes for more details.)