diff --git a/source b/source index bf6b1fb9326..ac38ed953aa 100644 --- a/source +++ b/source @@ -64211,6 +64211,21 @@ o............A....e response has a MIME type that is not a JavaScript MIME type.

+
+

The following sample shows how a bytes module script can be imported from inside + a JavaScript module script:

+ +
<script type="module">
+ import logoBytes from "https://resources.whatwg.org/logo.png" with { type: "bytes" };
+
+ console.log("Binary data length:", logoBytes.byteLength);
+</script>
+ +

The bytes module script will return a Uint8Array object containing + the raw bytes of the fetched resource. Unlike JSON module scripts + which require a specific MIME type, bytes modules can be used to import binary data from any resource.

+
+
Processing model
@@ -112104,7 +112119,7 @@ document.querySelector("button").addEventListener("click", bound); script">JavaScript module scripts;

  • a Synthetic Module Record, for CSS module - scripts and JSON module scripts;

  • + scripts, JSON module scripts, and bytes module scripts;

  • a WebAssembly Module Record, for WebAssembly module scripts; or

  • @@ -112206,6 +112221,14 @@ document.querySelector("button").addEventListener("click", bound); --> +
  • +

    A module script is a bytes module script if its record is a Synthetic Module Record, and it + was created via the create a bytes module + script algorithm. bytes module scripts represent binary data as Uint8Array + backed by an immutable ArrayBuffer.

    +
  • +
  • A module script is a WebAssembly module script if its record is a WebAssembly Module @@ -112213,11 +112236,11 @@ document.querySelector("button").addEventListener("click", bound);

  • -

    As CSS style sheets and JSON documents do not import dependent modules, and do not +

    As CSS style sheets, JSON documents, and binary data do not import dependent modules, and do not throw exceptions on evaluation, the fetch options and base URL of CSS module scripts and JSON module - scripts and are always null.

    + module script">CSS module scripts, JSON module + scripts, and bytes module scripts are always null.

    The active script is determined by the following algorithm:

    @@ -113112,6 +113135,10 @@ document.querySelector("button").addEventListener("click", bound); settingsObject, response's URL, and options.

    +
  • If moduleType is "bytes", then set moduleScript to + the result of creating a bytes module script given bodyBytes and + settingsObject.

  • +
  • Otherwise:

      @@ -113432,6 +113459,36 @@ document.querySelector("button").addEventListener("click", bound);
    1. Return script.

    +

    To create a bytes module script, given a + byte sequence bytes and an environment settings object settings:

    + +
      +
    1. Let script be a new module script that this algorithm will + subsequently initialize.

    2. + +
    3. Set script's settings + object to settings.

    4. + +
    5. Set script's base URL and + fetch options to null.

    6. + +
    7. Set script's parse error and + error to rethrow to null.

    8. + +
    9. Let result be a new Uint8Array object, in settings's + realm, whose backing bytes are bytes.

    10. + +
    11. Let record be CreateBytesModule(immutableBytes).

    12. + + JSIMPORTBYTES +
    13. Set script's record to record.

    14. + +
    15. Return script.

    16. +
    + +

    User agents that support JavaScript must also implement the Import Bytes proposal. + The following terms are defined there, and used in this specification: JSIMPORTBYTES

    +

    The module type from module request steps, given a ModuleRequest Record moduleRequest, are as follows:

    @@ -113467,7 +113524,7 @@ document.querySelector("button").addEventListener("click", bound);
    1. If moduleType is not "javascript-or-wasm", "css", or "json", then return false.

    2. + data-x="">css", "json", or "bytes", then return false.

    3. If moduleType is "css" and the CSSStyleSheet interface is not exposed in @@ -113488,6 +113545,9 @@ document.querySelector("button").addEventListener("click", bound);

    4. If moduleType is "css", then return "style".
    5. +
    6. If moduleType is "bytes", then return "empty".
    7. +
    8. Return defaultDestination.
    @@ -150175,6 +150235,9 @@ INSERT INTERFACES HERE
    [JSINTL]
    ECMAScript Internationalization API Specification. Ecma International.
    +
    [JSIMPORTBYTES]
    +
    Import Bytes. Ecma International.
    +
    [JSON]
    The JavaScript Object Notation (JSON) Data Interchange Format, T. Bray. IETF.