From b56728f0f46473e648b31719af2b8013db83e024 Mon Sep 17 00:00:00 2001
From: logist322 <53333039+logist322@users.noreply.github.com>
Date: Tue, 6 Feb 2024 16:04:56 +0400
Subject: [PATCH 01/25] Add `RTCRtpTransceiver.setCodecPreferences()` (#3828)
---
CHANGELOG.md | 5 ++++-
.../features/gen_RtcRtpEncodingParameters.rs | 21 +++++++++++++++++++
.../src/features/gen_RtcRtpTransceiver.rs | 7 +++++++
.../webidls/enabled/RTCRtpTransceiver.webidl | 3 +--
.../webidls/unstable/RTCRtpSender.webidl | 3 +++
5 files changed, 36 insertions(+), 3 deletions(-)
create mode 100644 crates/web-sys/webidls/unstable/RTCRtpSender.webidl
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20c87a0e073..8282284769f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,10 +7,13 @@ Released 2024-02-06
### Added
+* Added bindings for the `RTCRtpTransceiver.setCodecPreferences()` and unstable bindings for the `RTCRtpEncodingParameters.scalabilityMode`.
+ [#3828](https://github.com/rustwasm/wasm-bindgen/pull/3828)
+
* Add unstable bindings for the FileSystemAccess API
[#3810](https://github.com/rustwasm/wasm-bindgen/pull/3810)
-* Added support for running tests in shared and service workers with ``wasm_bindgen_test_configure!` `run_in_shared_worker` and `run_in_service_worker`.
+* Added support for running tests in shared and service workers with `wasm_bindgen_test_configure!` `run_in_shared_worker` and `run_in_service_worker`.
[#3804](https://github.com/rustwasm/wasm-bindgen/pull/3804)
* Accept the `--skip` flag with `wasm-bindgen-test-runner`.
diff --git a/crates/web-sys/src/features/gen_RtcRtpEncodingParameters.rs b/crates/web-sys/src/features/gen_RtcRtpEncodingParameters.rs
index a872f8a33f0..4bafe39090c 100644
--- a/crates/web-sys/src/features/gen_RtcRtpEncodingParameters.rs
+++ b/crates/web-sys/src/features/gen_RtcRtpEncodingParameters.rs
@@ -128,6 +128,27 @@ impl RtcRtpEncodingParameters {
let _ = r;
self
}
+ #[cfg(web_sys_unstable_apis)]
+ #[doc = "Change the `scalabilityMode` field of this object."]
+ #[doc = ""]
+ #[doc = "*This API requires the following crate features to be activated: `RtcRtpEncodingParameters`*"]
+ #[doc = ""]
+ #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
+ #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
+ pub fn scalability_mode(&mut self, val: &str) -> &mut Self {
+ use wasm_bindgen::JsValue;
+ let r = ::js_sys::Reflect::set(
+ self.as_ref(),
+ &JsValue::from("scalabilityMode"),
+ &JsValue::from(val),
+ );
+ debug_assert!(
+ r.is_ok(),
+ "setting properties should never fail on our dictionary objects"
+ );
+ let _ = r;
+ self
+ }
#[doc = "Change the `scaleResolutionDownBy` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpEncodingParameters`*"]
diff --git a/crates/web-sys/src/features/gen_RtcRtpTransceiver.rs b/crates/web-sys/src/features/gen_RtcRtpTransceiver.rs
index 98be39537ff..8b8fca690bb 100644
--- a/crates/web-sys/src/features/gen_RtcRtpTransceiver.rs
+++ b/crates/web-sys/src/features/gen_RtcRtpTransceiver.rs
@@ -73,6 +73,13 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `RtcRtpTransceiver`*"]
pub fn get_remote_track_id(this: &RtcRtpTransceiver) -> String;
+ # [wasm_bindgen (method , structural , js_class = "RTCRtpTransceiver" , js_name = setCodecPreferences)]
+ #[doc = "The `setCodecPreferences()` method."]
+ #[doc = ""]
+ #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver/setCodecPreferences)"]
+ #[doc = ""]
+ #[doc = "*This API requires the following crate features to be activated: `RtcRtpTransceiver`*"]
+ pub fn set_codec_preferences(this: &RtcRtpTransceiver, codecs: &::wasm_bindgen::JsValue);
# [wasm_bindgen (method , structural , js_class = "RTCRtpTransceiver" , js_name = stop)]
#[doc = "The `stop()` method."]
#[doc = ""]
diff --git a/crates/web-sys/webidls/enabled/RTCRtpTransceiver.webidl b/crates/web-sys/webidls/enabled/RTCRtpTransceiver.webidl
index fb8d594d741..4c89a032b4c 100644
--- a/crates/web-sys/webidls/enabled/RTCRtpTransceiver.webidl
+++ b/crates/web-sys/webidls/enabled/RTCRtpTransceiver.webidl
@@ -33,8 +33,7 @@ interface RTCRtpTransceiver {
readonly attribute RTCRtpTransceiverDirection? currentDirection;
undefined stop();
- // TODO: bug 1396922
- // undefined setCodecPreferences(sequence codecs);
+ undefined setCodecPreferences(sequence codecs);
[ChromeOnly]
undefined setRemoteTrackId(DOMString trackId);
diff --git a/crates/web-sys/webidls/unstable/RTCRtpSender.webidl b/crates/web-sys/webidls/unstable/RTCRtpSender.webidl
new file mode 100644
index 00000000000..b1b5eb39f7d
--- /dev/null
+++ b/crates/web-sys/webidls/unstable/RTCRtpSender.webidl
@@ -0,0 +1,3 @@
+partial dictionary RTCRtpEncodingParameters {
+ DOMString scalabilityMode;
+};
From 8198d2d25920e1f4fc593e9f8eb9d199e004d731 Mon Sep 17 00:00:00 2001
From: daxpedda
Date: Tue, 6 Feb 2024 20:21:27 +0100
Subject: [PATCH 02/25] Fix crates.io secret
---
.github/workflows/main.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 457b09cf550..70693dd1e7e 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -517,4 +517,4 @@ jobs:
- run: ./publish publish
if: startsWith(github.ref, 'refs/tags/')
env:
- CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
+ CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_PUBLISH_TOKEN }}
From 0d2d56cc5e8b057f678fa64f18056bb6076b61cf Mon Sep 17 00:00:00 2001
From: Dirk Stolle
Date: Thu, 8 Feb 2024 11:17:33 +0100
Subject: [PATCH 03/25] Update actions/checkout in GitHub Actions workflows to
v4 (#3837)
---
.github/workflows/main.yml | 52 +++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 70693dd1e7e..6ab213d78d1 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -24,7 +24,7 @@ jobs:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup component add rustfmt
- run: cargo fmt --all -- --check
@@ -34,7 +34,7 @@ jobs:
name: Check
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: cargo check --all
@@ -43,7 +43,7 @@ jobs:
name: Clippy
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- run: cargo clippy --no-deps --all-features -p wasm-bindgen-backend -- -D warnings
@@ -77,7 +77,7 @@ jobs:
env:
WASM_BINDGEN_SPLIT_LINKED_MODULES: 1
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- uses: actions/setup-node@v3
@@ -102,7 +102,7 @@ jobs:
name: "Run wasm-bindgen crate tests with multithreading enabled"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup default nightly-2024-02-06
- run: rustup target add wasm32-unknown-unknown
- run: rustup component add rust-src
@@ -117,7 +117,7 @@ jobs:
# name: "Run wasm-bindgen crate tests (Windows)"
# runs-on: windows-latest
# steps:
- # - uses: actions/checkout@v3
+ # - uses: actions/checkout@v4
# - run: rustup update --no-self-update stable && rustup default stable
# - run: rustup target add wasm32-unknown-unknown
# - uses: actions/setup-node@v3
@@ -138,7 +138,7 @@ jobs:
name: Run native tests
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- uses: actions/setup-node@v3
@@ -158,7 +158,7 @@ jobs:
name: "Run web-sys crate tests"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- uses: actions/setup-node@v3
@@ -178,7 +178,7 @@ jobs:
name: "Verify that web-sys is compiled correctly"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: cd crates/web-sys && cargo run --release --package wasm-bindgen-webidl -- webidls src/features ./Cargo.toml
- run: git diff --exit-code
@@ -187,7 +187,7 @@ jobs:
name: "Run js-sys crate tests"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- uses: actions/setup-node@v3
@@ -203,7 +203,7 @@ jobs:
name: "Run wasm-bindgen-webidl crate tests"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- uses: actions/setup-node@v3
@@ -221,7 +221,7 @@ jobs:
name: "Test TypeScript output of wasm-bindgen"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- uses: actions/setup-node@v3
@@ -233,7 +233,7 @@ jobs:
name: "Build and test the deno example"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- uses: denoland/setup-deno@v1
@@ -245,7 +245,7 @@ jobs:
name: Run UI compile-fail tests
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update 1.69.0 && rustup default 1.69.0
- run: cargo test -p wasm-bindgen-macro
- run: cargo test -p wasm-bindgen-test-macro
@@ -253,7 +253,7 @@ jobs:
build_examples:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f
@@ -282,7 +282,7 @@ jobs:
build_nightly:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup default nightly-2024-02-06
- run: rustup target add wasm32-unknown-unknown
- run: rustup component add rust-src
@@ -303,7 +303,7 @@ jobs:
- build_nightly
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: examples1
@@ -320,7 +320,7 @@ jobs:
build_benchmarks:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- run: cargo build --manifest-path benchmarks/Cargo.toml --release --target wasm32-unknown-unknown
@@ -333,7 +333,7 @@ jobs:
dist_linux_x86_64_musl:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add x86_64-unknown-linux-musl
- run: sudo apt update -y && sudo apt install musl-tools -y
@@ -350,7 +350,7 @@ jobs:
dist_linux_aarch64_gnu:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add aarch64-unknown-linux-gnu
- run: sudo apt update -y && sudo apt install gcc-aarch64-linux-gnu -y
@@ -366,7 +366,7 @@ jobs:
dist_macos_x86_64:
runs-on: macos-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: cargo build --manifest-path crates/cli/Cargo.toml --release
env:
@@ -379,7 +379,7 @@ jobs:
dist_macos_aarch64:
runs-on: macos-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add aarch64-apple-darwin
- run: |
@@ -394,7 +394,7 @@ jobs:
dist_windows:
runs-on: windows-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: cargo build --manifest-path crates/cli/Cargo.toml --release
env:
@@ -407,7 +407,7 @@ jobs:
doc_book:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: |
curl -L https://github.com/rust-lang/mdBook/releases/download/v0.4.28/mdbook-v0.4.28-x86_64-unknown-linux-gnu.tar.gz | tar xzf -
echo $PWD >> $GITHUB_PATH
@@ -420,7 +420,7 @@ jobs:
doc_api:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- run: rustup update --no-self-update nightly && rustup default nightly
- run: cargo doc --no-deps --features 'serde-serialize'
- run: cargo doc --no-deps --manifest-path crates/js-sys/Cargo.toml
@@ -452,7 +452,7 @@ jobs:
- build_benchmarks
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
From 6eecd5b62461e183dd81a1a0dfc6a046737a4176 Mon Sep 17 00:00:00 2001
From: Dirk Stolle
Date: Thu, 8 Feb 2024 11:18:17 +0100
Subject: [PATCH 04/25] Update actions/setup-node in GitHub Actions workflows
to v4 (#3838)
---
.github/workflows/main.yml | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 6ab213d78d1..4db634ba4ac 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -80,7 +80,7 @@ jobs:
- uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- uses: ./.github/actions/setup-geckodriver
@@ -120,7 +120,7 @@ jobs:
# - uses: actions/checkout@v4
# - run: rustup update --no-self-update stable && rustup default stable
# - run: rustup target add wasm32-unknown-unknown
- # - uses: actions/setup-node@v3
+ # - uses: actions/setup-node@v4
# with:
# node-version: '20'
# - uses: ./.github/actions/setup-geckodriver
@@ -141,7 +141,7 @@ jobs:
- uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- run: cargo test
@@ -161,7 +161,7 @@ jobs:
- uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- uses: ./.github/actions/setup-geckodriver
@@ -190,7 +190,7 @@ jobs:
- uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- uses: ./.github/actions/setup-geckodriver
@@ -206,7 +206,7 @@ jobs:
- uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- run: cargo test -p wasm-bindgen-webidl
@@ -224,7 +224,7 @@ jobs:
- uses: actions/checkout@v4
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- run: cd crates/typescript-tests && ./run.sh
From 1f12124a60629f178ba65eea0785e3941d34827e Mon Sep 17 00:00:00 2001
From: Dirk Stolle
Date: Thu, 8 Feb 2024 11:19:01 +0100
Subject: [PATCH 05/25] Update setup-geckodriver action to use Node.js 20
(#3839)
---
.github/actions/setup-geckodriver/action.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/actions/setup-geckodriver/action.yml b/.github/actions/setup-geckodriver/action.yml
index 40611a1d536..89dd42cad35 100644
--- a/.github/actions/setup-geckodriver/action.yml
+++ b/.github/actions/setup-geckodriver/action.yml
@@ -2,5 +2,5 @@ name: 'Setup Geckodriver'
description: 'Setup Geckodriver'
runs:
- using: node16
+ using: node20
main: 'main.js'
From e9cb333116c02310ef3712b41f3e61ee8bb32b80 Mon Sep 17 00:00:00 2001
From: evdokimovs <49490279+evdokimovs@users.noreply.github.com>
Date: Thu, 8 Feb 2024 14:15:23 +0100
Subject: [PATCH 06/25] Add `RtcPeerConnectionIceErrorEvent` WebAPI (#3835)
---
CHANGELOG.md | 17 +++++++
crates/web-sys/Cargo.toml | 1 +
.../gen_RtcPeerConnectionIceErrorEvent.rs | 50 +++++++++++++++++++
crates/web-sys/src/features/mod.rs | 7 +++
.../RTCPeerConnectionIceErrorEvent.webidl | 18 +++++++
5 files changed, 93 insertions(+)
create mode 100644 crates/web-sys/src/features/gen_RtcPeerConnectionIceErrorEvent.rs
create mode 100644 crates/web-sys/webidls/enabled/RTCPeerConnectionIceErrorEvent.webidl
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8282284769f..1650b86efb5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,15 @@
# `wasm-bindgen` Change Log
--------------------------------------------------------------------------------
+## Unreleased
+
+### Added
+
+* Add bindings for `RTCPeerConnectionIceErrorEvent`.
+ [#3835](https://github.com/rustwasm/wasm-bindgen/pull/3835)
+
+--------------------------------------------------------------------------------
+
## [0.2.91](https://github.com/rustwasm/wasm-bindgen/compare/0.2.90...0.2.91)
Released 2024-02-06
@@ -56,6 +65,8 @@ Released 2024-02-06
* Fixed nighly build of `wasm-bindgen-futures`.
[#3827](https://github.com/rustwasm/wasm-bindgen/pull/3827)
+--------------------------------------------------------------------------------
+
## [0.2.90](https://github.com/rustwasm/wasm-bindgen/compare/0.2.89...0.2.90)
Released 2024-01-06
@@ -98,6 +109,8 @@ Released 2024-01-06
`RtcLifecycleEvent` and `WebrtcGlobalStatisticsReport` features.
[#3723](https://github.com/rustwasm/wasm-bindgen/pull/3723)
+--------------------------------------------------------------------------------
+
## [0.2.89](https://github.com/rustwasm/wasm-bindgen/compare/0.2.88...0.2.89)
Released 2023-11-27.
@@ -126,6 +139,8 @@ Released 2023-11-27.
* Removed Gecko-internal dictionary bindings `Csp`, `CspPolicies`, `CspReport` and `CspReportProperties`.
[#3721](https://github.com/rustwasm/wasm-bindgen/pull/3721)
+--------------------------------------------------------------------------------
+
## [0.2.88](https://github.com/rustwasm/wasm-bindgen/compare/0.2.87...0.2.88)
Released 2023-11-01
@@ -290,6 +305,8 @@ Released 2023-11-01
* Removed `GetNotificationOptions`, `NotificationBehavior` and `Notification.get()` because
they don't exist anymore.
+--------------------------------------------------------------------------------
+
## [0.2.87](https://github.com/rustwasm/wasm-bindgen/compare/0.2.86...0.2.87)
Released 2023-06-12.
diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml
index 11f287f5c24..66ce7b01134 100644
--- a/crates/web-sys/Cargo.toml
+++ b/crates/web-sys/Cargo.toml
@@ -1102,6 +1102,7 @@ RtcOfferAnswerOptions = []
RtcOfferOptions = []
RtcOutboundRtpStreamStats = []
RtcPeerConnection = ["EventTarget"]
+RtcPeerConnectionIceErrorEvent = ["Event"]
RtcPeerConnectionIceEvent = ["Event"]
RtcPeerConnectionIceEventInit = []
RtcPeerConnectionState = []
diff --git a/crates/web-sys/src/features/gen_RtcPeerConnectionIceErrorEvent.rs b/crates/web-sys/src/features/gen_RtcPeerConnectionIceErrorEvent.rs
new file mode 100644
index 00000000000..fd0fc4a29ac
--- /dev/null
+++ b/crates/web-sys/src/features/gen_RtcPeerConnectionIceErrorEvent.rs
@@ -0,0 +1,50 @@
+#![allow(unused_imports)]
+#![allow(clippy::all)]
+use super::*;
+use wasm_bindgen::prelude::*;
+#[wasm_bindgen]
+extern "C" {
+ # [wasm_bindgen (extends = Event , extends = :: js_sys :: Object , js_name = RTCPeerConnectionIceErrorEvent , typescript_type = "RTCPeerConnectionIceErrorEvent")]
+ #[derive(Debug, Clone, PartialEq, Eq)]
+ #[doc = "The `RtcPeerConnectionIceErrorEvent` class."]
+ #[doc = ""]
+ #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnectionIceErrorEvent)"]
+ #[doc = ""]
+ #[doc = "*This API requires the following crate features to be activated: `RtcPeerConnectionIceErrorEvent`*"]
+ pub type RtcPeerConnectionIceErrorEvent;
+ # [wasm_bindgen (structural , method , getter , js_class = "RTCPeerConnectionIceErrorEvent" , js_name = address)]
+ #[doc = "Getter for the `address` field of this object."]
+ #[doc = ""]
+ #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnectionIceErrorEvent/address)"]
+ #[doc = ""]
+ #[doc = "*This API requires the following crate features to be activated: `RtcPeerConnectionIceErrorEvent`*"]
+ pub fn address(this: &RtcPeerConnectionIceErrorEvent) -> Option;
+ # [wasm_bindgen (structural , method , getter , js_class = "RTCPeerConnectionIceErrorEvent" , js_name = port)]
+ #[doc = "Getter for the `port` field of this object."]
+ #[doc = ""]
+ #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnectionIceErrorEvent/port)"]
+ #[doc = ""]
+ #[doc = "*This API requires the following crate features to be activated: `RtcPeerConnectionIceErrorEvent`*"]
+ pub fn port(this: &RtcPeerConnectionIceErrorEvent) -> Option;
+ # [wasm_bindgen (structural , method , getter , js_class = "RTCPeerConnectionIceErrorEvent" , js_name = url)]
+ #[doc = "Getter for the `url` field of this object."]
+ #[doc = ""]
+ #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnectionIceErrorEvent/url)"]
+ #[doc = ""]
+ #[doc = "*This API requires the following crate features to be activated: `RtcPeerConnectionIceErrorEvent`*"]
+ pub fn url(this: &RtcPeerConnectionIceErrorEvent) -> String;
+ # [wasm_bindgen (structural , method , getter , js_class = "RTCPeerConnectionIceErrorEvent" , js_name = errorCode)]
+ #[doc = "Getter for the `errorCode` field of this object."]
+ #[doc = ""]
+ #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnectionIceErrorEvent/errorCode)"]
+ #[doc = ""]
+ #[doc = "*This API requires the following crate features to be activated: `RtcPeerConnectionIceErrorEvent`*"]
+ pub fn error_code(this: &RtcPeerConnectionIceErrorEvent) -> u16;
+ # [wasm_bindgen (structural , method , getter , js_class = "RTCPeerConnectionIceErrorEvent" , js_name = errorText)]
+ #[doc = "Getter for the `errorText` field of this object."]
+ #[doc = ""]
+ #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnectionIceErrorEvent/errorText)"]
+ #[doc = ""]
+ #[doc = "*This API requires the following crate features to be activated: `RtcPeerConnectionIceErrorEvent`*"]
+ pub fn error_text(this: &RtcPeerConnectionIceErrorEvent) -> String;
+}
diff --git a/crates/web-sys/src/features/mod.rs b/crates/web-sys/src/features/mod.rs
index c3bb7d92089..9e5d51569e5 100644
--- a/crates/web-sys/src/features/mod.rs
+++ b/crates/web-sys/src/features/mod.rs
@@ -7495,6 +7495,13 @@ mod gen_RtcPeerConnection;
#[allow(unused_imports)]
pub use gen_RtcPeerConnection::*;
+#[cfg(feature = "RtcPeerConnectionIceErrorEvent")]
+#[allow(non_snake_case)]
+mod gen_RtcPeerConnectionIceErrorEvent;
+#[cfg(feature = "RtcPeerConnectionIceErrorEvent")]
+#[allow(unused_imports)]
+pub use gen_RtcPeerConnectionIceErrorEvent::*;
+
#[cfg(feature = "RtcPeerConnectionIceEvent")]
#[allow(non_snake_case)]
mod gen_RtcPeerConnectionIceEvent;
diff --git a/crates/web-sys/webidls/enabled/RTCPeerConnectionIceErrorEvent.webidl b/crates/web-sys/webidls/enabled/RTCPeerConnectionIceErrorEvent.webidl
new file mode 100644
index 00000000000..91e148ca8e5
--- /dev/null
+++ b/crates/web-sys/webidls/enabled/RTCPeerConnectionIceErrorEvent.webidl
@@ -0,0 +1,18 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnectioniceerrorevent
+ */
+
+[Exposed=Window]
+interface RTCPeerConnectionIceErrorEvent : Event {
+ constructor(DOMString type, RTCPeerConnectionIceErrorEventInit eventInitDict);
+ readonly attribute DOMString? address;
+ readonly attribute unsigned short? port;
+ readonly attribute DOMString url;
+ readonly attribute unsigned short errorCode;
+ readonly attribute USVString errorText;
+};
From 114a4a198c824a0bb6ff7429337f7f8badb0f03e Mon Sep 17 00:00:00 2001
From: Thomas Etter
Date: Thu, 8 Feb 2024 22:24:33 +0100
Subject: [PATCH 07/25] Add a typescript test (not just a compile test) for
enums (#3740)
---
crates/typescript-tests/jest.config.cjs | 17 ++++++++--
crates/typescript-tests/src/enums.ts | 41 +++++++++++++++++--------
2 files changed, 43 insertions(+), 15 deletions(-)
diff --git a/crates/typescript-tests/jest.config.cjs b/crates/typescript-tests/jest.config.cjs
index c63e1456977..2db7cd7178d 100644
--- a/crates/typescript-tests/jest.config.cjs
+++ b/crates/typescript-tests/jest.config.cjs
@@ -4,8 +4,21 @@ module.exports = {
testEnvironment: 'node',
extensionsToTreatAsEsm: [".ts"],
verbose: true,
- // TODO: match all test files
- testMatch: ['**/src/simple_struct.ts', '**/src/typescript_type.ts'],
+ testMatch: ['**/src/*.ts'],
+ // TODO: migrate all test files and remove this
+ testPathIgnorePatterns: [
+ ".*/src/custom_section.ts$",
+ ".*/src/getters_setters.ts$",
+ ".*/src/inspectable.ts$",
+ ".*/src/memory.ts$",
+ ".*/src/omit_definition.ts$",
+ ".*/src/optional_fields.ts$",
+ ".*/src/opt_args_and_ret.ts$",
+ ".*/src/simple_async_fn.ts$",
+ ".*/src/simple_fn.ts$",
+ ".*/src/web_sys.ts$",
+ ".*/src/usize.ts$"
+ ],
injectGlobals: false,
globals: {
'ts-jest':
diff --git a/crates/typescript-tests/src/enums.ts b/crates/typescript-tests/src/enums.ts
index ea246fc847a..595586bee95 100644
--- a/crates/typescript-tests/src/enums.ts
+++ b/crates/typescript-tests/src/enums.ts
@@ -1,13 +1,28 @@
-import * as wbg from '../pkg/typescript_tests';
-
-const a1: wbg.Foo = wbg.Foo.A;
-const a2: wbg.Foo.A = wbg.Foo.A;
-const a3: wbg.Foo.A = 1;
-const b1: wbg.Foo = wbg.Foo.B;
-const b2: wbg.Foo.B = wbg.Foo.B;
-const b3: wbg.Foo.B = 3;
-
-const fn_expects_enum: (_: wbg.Foo) => void = wbg.fn_expects_enum;
-const fn_returns_enum: () => wbg.Foo = wbg.fn_returns_enum;
-const fn_expects_option_enum: (_?: wbg.Foo) => void = wbg.fn_expects_option_enum;
-const fn_returns_option_enum: () => wbg.Foo | undefined = wbg.fn_returns_option_enum;
+import * as wbg from "../pkg/typescript_tests";
+import { expect, jest, test } from "@jest/globals";
+
+test("construction", () => {
+ const a1: wbg.Foo = wbg.Foo.A;
+ const a2: wbg.Foo.A = wbg.Foo.A;
+ expect(a1).toStrictEqual(a2);
+ const a3: wbg.Foo.A = 1;
+ expect(a1).toStrictEqual(a3);
+
+ const b1: wbg.Foo = wbg.Foo.B;
+ const b2: wbg.Foo.B = wbg.Foo.B;
+ expect(b1).toStrictEqual(b2);
+ const b3: wbg.Foo.B = 3;
+ expect(b1).toStrictEqual(b3);
+ expect(a1).not.toStrictEqual(b1);
+});
+
+test("function calls", () => {
+ const fn_expects_enum: (_: wbg.Foo) => void = wbg.fn_expects_enum;
+ const fn_returns_enum: () => wbg.Foo = wbg.fn_returns_enum;
+ const fn_expects_option_enum: (_?: wbg.Foo) => void = wbg.fn_expects_option_enum;
+ const fn_returns_option_enum: () => wbg.Foo | undefined = wbg.fn_returns_option_enum;
+
+ fn_expects_enum(wbg.Foo.B);
+ expect(fn_returns_enum()).toStrictEqual(wbg.Foo.A);
+ expect(fn_returns_option_enum()).toStrictEqual(wbg.Foo.A);
+});
From 9f1d1188cab0c9ad54df734a7945dbdcd0fe67b1 Mon Sep 17 00:00:00 2001
From: Dirk Stolle
Date: Fri, 9 Feb 2024 12:30:25 +0100
Subject: [PATCH 08/25] Update actions/upload-artifact +
actions/download-artifact to v4 (#3842)
---
.github/workflows/main.yml | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 4db634ba4ac..d5e26e66731 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -274,7 +274,7 @@ jobs:
done
env:
RUSTFLAGS: --cfg=web_sys_unstable_apis
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: examples1
path: exbuild
@@ -292,7 +292,7 @@ jobs:
./build.sh && mkdir -p ../../exbuild/$dir && cp -r ./* ../../exbuild/$dir
) || exit 1;
done
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: examples2
path: exbuild
@@ -304,11 +304,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: actions/download-artifact@v3
+ - uses: actions/download-artifact@v4
with:
name: examples1
path: exbuild
- - uses: actions/download-artifact@v3
+ - uses: actions/download-artifact@v4
with:
name: examples2
path: exbuild
@@ -325,7 +325,7 @@ jobs:
- run: rustup target add wasm32-unknown-unknown
- run: cargo build --manifest-path benchmarks/Cargo.toml --release --target wasm32-unknown-unknown
- run: cargo run -p wasm-bindgen-cli -- target/wasm32-unknown-unknown/release/wasm_bindgen_benchmark.wasm --out-dir benchmarks/pkg --target web
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: benchmarks
path: benchmarks
@@ -342,7 +342,7 @@ jobs:
strip -g target/x86_64-unknown-linux-musl/release/wasm-bindgen
strip -g target/x86_64-unknown-linux-musl/release/wasm-bindgen-test-runner
strip -g target/x86_64-unknown-linux-musl/release/wasm2es6js
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: dist_linux_x86_64_musl
path: "target/x86_64-unknown-linux-musl/release/wasm*"
@@ -358,7 +358,7 @@ jobs:
cargo build --manifest-path crates/cli/Cargo.toml --target aarch64-unknown-linux-gnu --features vendored-openssl --release
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: dist_linux_aarch64_gnu
path: "target/aarch64-unknown-linux-gnu/release/wasm*"
@@ -371,7 +371,7 @@ jobs:
- run: cargo build --manifest-path crates/cli/Cargo.toml --release
env:
MACOSX_DEPLOYMENT_TARGET: 10.7
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: dist_macos_x86_64
path: "target/release/wasm*"
@@ -386,7 +386,7 @@ jobs:
cargo build --manifest-path crates/cli/Cargo.toml --target aarch64-apple-darwin --release
env:
MACOSX_DEPLOYMENT_TARGET: 10.7
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: dist_macos_aarch64
path: "target/aarch64-apple-darwin/release/wasm*"
@@ -399,7 +399,7 @@ jobs:
- run: cargo build --manifest-path crates/cli/Cargo.toml --release
env:
RUSTFLAGS: -Ctarget-feature=+crt-static
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: dist_windows
path: "target/release/wasm*"
@@ -412,7 +412,7 @@ jobs:
curl -L https://github.com/rust-lang/mdBook/releases/download/v0.4.28/mdbook-v0.4.28-x86_64-unknown-linux-gnu.tar.gz | tar xzf -
echo $PWD >> $GITHUB_PATH
- run: (cd guide && mdbook build)
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: doc_book
path: guide/book/html
@@ -429,7 +429,7 @@ jobs:
RUSTDOCFLAGS: --cfg=web_sys_unstable_apis
- run: cargo doc --no-deps --manifest-path crates/futures/Cargo.toml
- run: tar czvf docs.tar.gz target/doc
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: doc_api
path: docs.tar.gz
@@ -455,7 +455,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- - uses: actions/download-artifact@v3
+ - uses: actions/download-artifact@v4
with:
path: artifacts
- run: find artifacts
@@ -484,7 +484,7 @@ jobs:
mk x86_64-apple-darwin dist_macos_x86_64
mk aarch64-apple-darwin dist_macos_aarch64
mk x86_64-pc-windows-msvc dist_windows
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: gh-release
path: gh-release
@@ -496,7 +496,7 @@ jobs:
mv artifacts/examples2/* gh-pages/exbuild
mv artifacts/benchmarks gh-pages/benchmarks
tar czf gh-pages.tar.gz gh-pages
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: gh-pages
path: gh-pages.tar.gz
From db91cc2a289423b722090008a33da54001e2ec58 Mon Sep 17 00:00:00 2001
From: Daniel Bergey
Date: Fri, 9 Feb 2024 16:18:21 -0500
Subject: [PATCH 09/25] readme: also link the guide built from the main branch
(#3826)
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 9b1728cfe6e..82a9da42182 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@
- Guide
+ Guide (main branch)
|
API Docs
|
From a396d03d9e2e94186b220ccf0042d4a2e3bbcb6d Mon Sep 17 00:00:00 2001
From: Nulled <63370961+Nul-led@users.noreply.github.com>
Date: Sat, 10 Feb 2024 09:00:36 +0100
Subject: [PATCH 10/25] feat(#3843): Add support for CanvasState.reset (#3844)
---
CHANGELOG.md | 3 +++
.../web-sys/src/features/gen_CanvasRenderingContext2d.rs | 7 +++++++
.../src/features/gen_OffscreenCanvasRenderingContext2d.rs | 7 +++++++
.../webidls/enabled/CanvasRenderingContext2D.webidl | 1 +
4 files changed, 18 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1650b86efb5..56fb600f0c3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,9 @@
* Add bindings for `RTCPeerConnectionIceErrorEvent`.
[#3835](https://github.com/rustwasm/wasm-bindgen/pull/3835)
+* Add bindings for `CanvasState.reset()`, affecting `CanvasRenderingContext2D` and `OffscreenCanvasRenderingContext2D`.
+ [#3844](https://github.com/rustwasm/wasm-bindgen/pull/3844)
+
--------------------------------------------------------------------------------
## [0.2.91](https://github.com/rustwasm/wasm-bindgen/compare/0.2.90...0.2.91)
diff --git a/crates/web-sys/src/features/gen_CanvasRenderingContext2d.rs b/crates/web-sys/src/features/gen_CanvasRenderingContext2d.rs
index c5878c132f0..5d4a7f79c27 100644
--- a/crates/web-sys/src/features/gen_CanvasRenderingContext2d.rs
+++ b/crates/web-sys/src/features/gen_CanvasRenderingContext2d.rs
@@ -1266,6 +1266,13 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CanvasRenderingContext2d`*"]
pub fn stroke_rect(this: &CanvasRenderingContext2d, x: f64, y: f64, w: f64, h: f64);
+ # [wasm_bindgen (method , structural , js_class = "CanvasRenderingContext2D" , js_name = reset)]
+ #[doc = "The `reset()` method."]
+ #[doc = ""]
+ #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/reset)"]
+ #[doc = ""]
+ #[doc = "*This API requires the following crate features to be activated: `CanvasRenderingContext2d`*"]
+ pub fn reset(this: &CanvasRenderingContext2d);
# [wasm_bindgen (method , structural , js_class = "CanvasRenderingContext2D" , js_name = restore)]
#[doc = "The `restore()` method."]
#[doc = ""]
diff --git a/crates/web-sys/src/features/gen_OffscreenCanvasRenderingContext2d.rs b/crates/web-sys/src/features/gen_OffscreenCanvasRenderingContext2d.rs
index aed70a10e68..c795d1a8659 100644
--- a/crates/web-sys/src/features/gen_OffscreenCanvasRenderingContext2d.rs
+++ b/crates/web-sys/src/features/gen_OffscreenCanvasRenderingContext2d.rs
@@ -1222,6 +1222,13 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `OffscreenCanvasRenderingContext2d`*"]
pub fn stroke_rect(this: &OffscreenCanvasRenderingContext2d, x: f64, y: f64, w: f64, h: f64);
+ # [wasm_bindgen (method , structural , js_class = "OffscreenCanvasRenderingContext2D" , js_name = reset)]
+ #[doc = "The `reset()` method."]
+ #[doc = ""]
+ #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvasRenderingContext2D/reset)"]
+ #[doc = ""]
+ #[doc = "*This API requires the following crate features to be activated: `OffscreenCanvasRenderingContext2d`*"]
+ pub fn reset(this: &OffscreenCanvasRenderingContext2d);
# [wasm_bindgen (method , structural , js_class = "OffscreenCanvasRenderingContext2D" , js_name = restore)]
#[doc = "The `restore()` method."]
#[doc = ""]
diff --git a/crates/web-sys/webidls/enabled/CanvasRenderingContext2D.webidl b/crates/web-sys/webidls/enabled/CanvasRenderingContext2D.webidl
index 557246d3333..82157774a2c 100644
--- a/crates/web-sys/webidls/enabled/CanvasRenderingContext2D.webidl
+++ b/crates/web-sys/webidls/enabled/CanvasRenderingContext2D.webidl
@@ -131,6 +131,7 @@ interface mixin CanvasState {
// state
undefined save(); // push state on state stack
undefined restore(); // pop state stack and restore state
+ undefined reset(); // clears the backing buffer, drawing state stack, any defined paths, and styles
};
interface mixin CanvasTransform {
From 12889ef666f9b355585602e268be2b70d7f3ec80 Mon Sep 17 00:00:00 2001
From: Dirk Stolle
Date: Sat, 10 Feb 2024 23:43:24 +0100
Subject: [PATCH 11/25] Update JamesIves/github-pages-deploy-action in GHA
workflow to newest v4 (#3841)
---
.github/workflows/main.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index d5e26e66731..b2851321610 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -500,7 +500,7 @@ jobs:
with:
name: gh-pages
path: gh-pages.tar.gz
- - uses: JamesIves/github-pages-deploy-action@v4.4.1
+ - uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: gh-pages
From 7ce38b42d32d897e2d90f52af5f58b9450f388bf Mon Sep 17 00:00:00 2001
From: daxpedda
Date: Tue, 20 Feb 2024 10:59:25 +0100
Subject: [PATCH 12/25] Use single-threaded impl when MT is impossible
---
CHANGELOG.md | 5 ++
crates/futures/src/lib.rs | 42 +++++++++++++----
crates/futures/src/queue.rs | 6 +--
crates/futures/src/task/multithread.rs | 45 +++++++++---------
crates/futures/src/task/singlethread.rs | 62 +++++++++++++------------
5 files changed, 96 insertions(+), 64 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 56fb600f0c3..6f449256e10 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,11 @@
* Add bindings for `CanvasState.reset()`, affecting `CanvasRenderingContext2D` and `OffscreenCanvasRenderingContext2D`.
[#3844](https://github.com/rustwasm/wasm-bindgen/pull/3844)
+### Fixed
+
+* Allow `wasm-bindgen-futures` to run correctly when using the atomics target feature in an environment that has no support for `Atomics.waitAsync()` and without cross-origin isolation.
+ [#3848](https://github.com/rustwasm/wasm-bindgen/pull/3848)
+
--------------------------------------------------------------------------------
## [0.2.91](https://github.com/rustwasm/wasm-bindgen/compare/0.2.90...0.2.91)
diff --git a/crates/futures/src/lib.rs b/crates/futures/src/lib.rs
index a44ec7c6d27..0e43314bf1a 100644
--- a/crates/futures/src/lib.rs
+++ b/crates/futures/src/lib.rs
@@ -50,18 +50,40 @@ pub use js_sys;
pub use wasm_bindgen;
mod task {
+ use std::future::Future;
+ use std::pin::Pin;
+
use cfg_if::cfg_if;
- cfg_if! {
- if #[cfg(target_feature = "atomics")] {
- mod wait_async_polyfill;
- mod multithread;
- pub(crate) use multithread::*;
+ #[cfg(target_feature = "atomics")]
+ mod multithread;
+ mod singlethread;
+ #[cfg(target_feature = "atomics")]
+ mod wait_async_polyfill;
+
+ pub(crate) fn spawn(future: Pin + 'static>>) {
+ cfg_if! {
+ if #[cfg(target_feature = "atomics")] {
+ #[wasm_bindgen::prelude::wasm_bindgen]
+ extern "C" {
+ /// Returns [`crossOriginIsolated`](https://developer.mozilla.org/en-US/docs/Web/API/crossOriginIsolated) global property.
+ #[wasm_bindgen(js_name = crossOriginIsolated)]
+ static CROSS_ORIGIN_ISOLATED: bool;
+ }
+
+ if *CROSS_ORIGIN_ISOLATED {
+ multithread::Task::spawn(future)
+ } else {
+ singlethread::Task::spawn(future)
+ }
+ } else {
+ singlethread::Task::spawn(future)
+ }
+ }
+ }
- } else {
- mod singlethread;
- pub(crate) use singlethread::*;
- }
+ pub(crate) trait Task {
+ fn run(&self);
}
}
@@ -81,7 +103,7 @@ pub fn spawn_local(future: F)
where
F: Future