From f8b1b09f47354b24e3d59cc5fafb0654d1b89f93 Mon Sep 17 00:00:00 2001 From: Steven Date: Sun, 14 Sep 2025 22:21:35 -0400 Subject: [PATCH 1/6] add import bytes --- source | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 5 deletions(-) diff --git a/source b/source index bf6b1fb9326..d985b9313d9 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,20 @@ 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 +112242,11 @@ document.querySelector("button").addEventListener("click", bound);

  • -

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

    As CSS stylesheets, 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 +113141,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 +113465,31 @@ 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. Set script's record to the result + of CreateDefaultExportSyntheticModule(result).

    12. + +
    13. Return script.

    14. +
    +

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

    @@ -113467,7 +113525,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 +113546,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.
    From 183a2cef491547552e4c4aca88c65164a171d26d Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 16 Sep 2025 19:56:13 -0400 Subject: [PATCH 2/6] make "bytes module script" lowercase --- source | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source b/source index d985b9313d9..d14a21da05b 100644 --- a/source +++ b/source @@ -64221,7 +64221,7 @@ o............A....e console.log("Binary data length:", logoBytes.byteLength); </script> -

    The Bytes module script will return a Uint8Array object containing +

    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.

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

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

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

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

  • @@ -112222,15 +112222,15 @@ document.querySelector("button").addEventListener("click", bound);
  • -

    A module script is a Bytes module script if its 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 + was created via the create a Bytes module + script algorithm. bytes module scripts represent binary data as Uint8Array backed by an immutable ArrayBuffer.

  • @@ -112246,7 +112246,7 @@ document.querySelector("button").addEventListener("click", bound); throw exceptions on evaluation, the fetch options and base URL of CSS module scripts, JSON module - scripts, and Bytes module scripts are always null.

    + scripts, and bytes module scripts are always null.

    The active script is determined by the following algorithm:

    @@ -113142,7 +113142,7 @@ document.querySelector("button").addEventListener("click", bound); data-x="concept-response-url">URL, and options.

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

  • @@ -113465,7 +113465,7 @@ document.querySelector("button").addEventListener("click", bound);
  • Return script.

  • -

    To create a Bytes module script, given a +

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

      From b894372e009a0cc1a874d86618a6cb4c00aaba40 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 16 Sep 2025 20:03:03 -0400 Subject: [PATCH 3/6] add references to Uint8Array & ArrayBuffer --- source | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source b/source index d14a21da05b..a60032b9f7b 100644 --- a/source +++ b/source @@ -112224,9 +112224,9 @@ document.querySelector("button").addEventListener("click", bound);
    1. 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.

      + was created via the create a bytes module + script algorithm. bytes module scripts represent binary data as Uint8Array + backed by an immutable ArrayBuffer.

    2. From e5b97571bff570038668f31bebe4111ef0c4418f Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 16 Sep 2025 20:04:46 -0400 Subject: [PATCH 5/6] "stylesheets" => "style sheets" --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index 1d3f4b2c73a..d7a89eb41ec 100644 --- a/source +++ b/source @@ -112236,7 +112236,7 @@ document.querySelector("button").addEventListener("click", bound);
    3. -

      As CSS stylesheets, JSON documents, and binary data 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, JSON module From 98286550611bd8ecb13ad526092288689baa5405 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 16 Sep 2025 20:22:23 -0400 Subject: [PATCH 6/6] add ref to JSIMPORTBYTES --- source | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source b/source index d7a89eb41ec..ac38ed953aa 100644 --- a/source +++ b/source @@ -113478,12 +113478,17 @@ document.querySelector("button").addEventListener("click", bound);

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

    5. -
    6. Set script's record to the result - of CreateDefaultExportSyntheticModule(result).

    7. +
    8. Let record be CreateBytesModule(immutableBytes).

    9. + + JSIMPORTBYTES +
    10. Set script's record to record.

    11. Return script.

    +

    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:

    @@ -150230,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.