diff --git a/source b/source index 6cce41c8b7f..4274d6296c2 100644 --- a/source +++ b/source @@ -4499,6 +4499,17 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute +
The following terms are defined in WebAssembly JavaScript Interface: ESM Integration: WASMESM
+ +a Synthetic Module Record, for CSS module - scripts and JSON module scripts
a WebAssembly Module Record, for WebAssembly module scripts; or
null, representing a parsing failure.
Module scripts can be classified into three types:
+Module scripts can be classified into four types:
A module script is a JavaScript module script if @@ -106242,6 +106256,13 @@ document.querySelector("button").addEventListener("click", bound); testing if something is a JSON module script in algorithms, instead of just referring to the concept, then we should consider adding a type item to the module script struct. --> +
A module script is a WebAssembly module script if + its record is a WebAssembly Module + Record.
+As CSS stylesheets and JSON documents do not import dependent modules, and do not @@ -107050,7 +107071,7 @@ document.querySelector("button").addEventListener("click", bound); algorithm accepting null (on failure) or a module script (on success).
Let moduleType be "javascript".
Let moduleType be "javascript-or-wasm".
If moduleRequest was given, then set moduleType to the result of running the module type from module request steps given @@ -107059,8 +107080,8 @@ document.querySelector("button").addEventListener("click", bound);
Assert: the result of running the module type allowed steps given moduleType and settingsObject is true. Otherwise, we would not have reached this point because a failure would have been raised when inspecting - moduleRequest.[[Attributes]] in create - a JavaScript module script or fetch a single imported module script.
Let moduleMap be settingsObject's module map.
Let sourceText be the result of UTF-8 - decoding bodyBytes.
Let mimeType be the result of extracting a MIME type from response's header list.
If mimeType is a JavaScript MIME type and moduleType
- is "javascript", then set moduleScript to the result of
- creating a JavaScript module script given sourceText,
+
If mimeType's essence is
+ "application/wasm" and moduleType is "javascript-or-wasm", then set moduleScript to the result of
+ creating a WebAssembly module script given bodyBytes,
settingsObject, response's URL, and options.
If the MIME type essence of mimeType is "text/css"
- and moduleType is "css", then set moduleScript to
- the result of creating a CSS module script given sourceText and
- settingsObject.
If mimeType is a JSON MIME type and
- moduleType is "json", then set moduleScript to
- the result of creating a JSON module script given sourceText and
- settingsObject.
Otherwise:
+Let sourceText be the result of UTF-8 + decoding bodyBytes.
If mimeType is a JavaScript MIME type and moduleType
+ is "javascript-or-wasm", then set moduleScript to the result of
+ creating a JavaScript module script given sourceText,
+ settingsObject, response's URL, and options.
If the MIME type essence of mimeType is "text/css"
+ and moduleType is "css", then set moduleScript to
+ the result of creating a CSS module script given sourceText and
+ settingsObject.
If mimeType is a JSON MIME type and
+ moduleType is "json", then set moduleScript to
+ the result of creating a JSON module script given sourceText and
+ settingsObject.
Set moduleMap[(url, @@ -107325,68 +107358,61 @@ document.querySelector("button").addEventListener("click", bound);
For each ModuleRequest record - requested of result.[[RequestedModules]]:
+Set script's record to + result.
If requested.[[Attributes]] contains a Record entry
- such that entry.[[Key]] is not "type", then:
Return script.
Let error be a new SyntaxError exception.
To create a WebAssembly module script, + given a byte sequence bodyBytes, an environment settings + object settings, a URL baseURL, and a script fetch + options options:
-Set script's parse error - to error.
If scripting is disabled for + settings, then set bodyBytes to the byte sequence 0x00 0x61 0x73 0x6d 0x01 + 0x00 0x00 0x00.
-Return script.
This byte sequence corresponds to an empty WebAssembly module with only the magic + bytes and version number provided.
+ -The JavaScript specification re-performs this validation when loading - script's dependencies. It is duplicated here to skip unnecessary work given that, - in case of an invalid attribute key, loading the module graph would fail anyway. Additionally, - this makes the errors reported for invalid static imports consistent with dynamic imports, for - which invalid attributes are reported before calling into HTML and thus before validating the - imported specifier.
- +Let script be a new module script that this algorithm will + subsequently initialize.
Resolve a module specifier given script and - requested.[[Specifier]], catching any exceptions.
Set script's settings + object to settings.
If the previous step threw an exception, then:
+Set script's base URL to + baseURL.
Set script's parse error - to that exception.
Set script's fetch + options to options.
Return script.
Set script's parse error and + error to rethrow to null.
Let moduleType be the result of running the module type from module - request steps given requested.
Let result be the result of parsing a + WebAssembly module given bodyBytes, + settings's realm, and + script.
-If the result of running the module type allowed steps given - moduleType and settings is false, then:
+Passing script as the last parameter here ensures + result.[[HostDefined]] will be script.
+Let error be a new TypeError exception.
If the previous step threw an error error, then:
-Set script's parse error - to error.
Set script's parse error to + error.
Return script.
Return script.
This step is essentially validating all of the requested module specifiers and - type attributes. We treat a module with unresolvable module specifiers or unsupported type - attributes the same as one that cannot be parsed; in both cases, a syntactic issue makes it - impossible to ever contemplate linking the module later.
Set script's record to @@ -107395,6 +107421,11 @@ document.querySelector("button").addEventListener("click", bound);
Return script.
WebAssembly JavaScript Interface: ESM Integration specifies the + hooks for the WebAssembly integration with ECMA-262 module loading. This includes support both + for direct dependency imports, as well as for source phase imports, which support virtualization + and multi-instantiation. WASMESM
+To create a CSS module script, given a string source and an environment settings object settings:
@@ -107469,7 +107500,7 @@ document.querySelector("button").addEventListener("click", bound); Record moduleRequest, are as follows:Let moduleType be "javascript".
Let moduleType be "javascript-or-wasm".
If moduleRequest.[[Attributes]] has a Record entry such @@ -107477,14 +107508,15 @@ document.querySelector("button").addEventListener("click", bound);
If entry.[[Value]] is "javascript", then set
+
If entry.[[Value]] is "javascript-or-wasm", then set
moduleType to null.
This specification uses the "javascript" module type
- internally for JavaScript module scripts, so
- this step is needed to prevent modules from being imported using a "javascript" type attribute (a null moduleType will cause the
- module type allowed check to fail).
This specification uses the "javascript-or-wasm" module
+ type internally for JavaScript module scripts or
+ WebAssembly module scripts, so this step is
+ needed to prevent modules from being imported using a
+ "javascript-or-wasm" type attribute (a null moduleType will
+ cause the module type allowed check to fail).
Otherwise, set moduleType to entry.[[Value]].
If moduleType is not " If moduleType is not "javascript", "javascript-or-wasm", "css", or "json", then return false.
If moduleType is "css" and the
@@ -109472,8 +109504,8 @@ dictionary PromiseRejectionEventInit : EventInittuples consisting of a URL record and a string.
The URL record is the request URL at which
the module was fetched, and the string indicates the type of the module (e.g. "javascript"). The module map's values are either a module
- script, null (used to represent failed fetches), or a placeholder value "javascript-or-wasm"). The module map's values are either a
+ module script, null (used to represent failed fetches), or a placeholder value "fetching". Module maps are used to ensure
that imported module scripts are only fetched, parsed, and evaluated once per
Document or worker.
javascript" type):
+ data-x="">javascript-or-wasm" type):
import "https://example.com/module.mjs";
import "https://example.com/module.mjs#map-buster";
@@ -109512,7 +109544,8 @@ import "https://example.com/foo/../module2.mjs";
Since module type is also part of the module map key, the following code will
create two separate entries in the module map (the type is "javascript" for the first, and "css" for the second):
+ data-x="">javascript-or-wasm" for the first, and "css" for the
+ second):
<script type=module>
import "https://example.com/module";
@@ -109646,8 +109679,8 @@ import "https://example.com/foo/../module2.mjs";
Let fetchReferrer be "client".
If referrer is a Script Record or a Module Record, then:
+If referrer is a Script Record or a Cyclic Module + Record, then:
Set referencingScript to referrer.[[HostDefined]].
@@ -109663,10 +109696,10 @@ import "https://example.com/foo/../module2.mjs";referrer is usually a Script Record or a Module Record, but it will not be so for event handlers per the get the current value of the event - handler algorithm. For example, given:
+referrer is usually a Script Record or a Cyclic Module + Record, but it will not be so for event handlers per the get the current value of the event handler + algorithm. For example, given:
<button onclick="import('./foo.mjs')">Click me</button>
@@ -109677,6 +109710,81 @@ import "https://example.com/foo/../module2.mjs";
If referrer is a Cyclic Module Record and moduleRequest + is equal to the first element of referrer.[[RequestedModules]], then:
+ +
For each ModuleRequest record + requested of referrer.[[RequestedModules]]:
+ +If moduleRequest.[[Attributes]] contains a Record entry
+ such that entry.[[Key]] is not "type", then:
Let completion be Completion Record { [[Type]]: throw,
+ [[Value]]: a new SyntaxError exception, [[Target]]: empty }.
Perform FinishLoadingImportedModule(referrer, + moduleRequest, payload, completion).
Return.
The JavaScript specification re-performs this validation but it is duplicated + here to avoid unnecessarily loading any of the dependencies on validation failure.
+Resolve a module specifier given referencingScript and + moduleRequest.[[Specifier]], catching any exceptions. If they throw an exception, let + resolutionError be the thrown exception.
If the previous step threw an exception, then:
+ +Let completion be Completion Record { [[Type]]: throw, + [[Value]]: resolutionError, [[Target]]: empty }.
Perform FinishLoadingImportedModule(referrer, + moduleRequest, payload, completion).
Return.
Let moduleType be the result of running the module type from module + request steps given moduleRequest.
If the result of running the module type allowed steps given + moduleType and settings is false, then:
+ +Let completion be Completion Record { [[Type]]: throw,
+ [[Value]]: a new TypeError exception, [[Target]]: empty }.
Perform FinishLoadingImportedModule(referrer, + moduleRequest, payload, completion).
Return.
This step is essentially validating all of the requested module specifiers and + type attributes when the first call to HostLoadImportedModule for a static module + dependency list is made, to avoid further loading operations in the case any one of the + dependencies has a static error. We treat a module with unresolvable module specifiers or + unsupported type attributes the same as one that cannot be parsed; in both cases, a syntactic + issue makes it impossible to ever contemplate linking the module later.
+Disallow further import maps given settingsObject.
Let url be the result of resolving a
@@ -142958,6 +143066,9 @@ INSERT INTERFACES HERE
application/rss+xmlapplication/wasmapplication/x-www-form-urlencoded