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 + 'static, { - task::Task::spawn(Box::pin(future)); + task::spawn(Box::pin(future)); } struct Inner { diff --git a/crates/futures/src/queue.rs b/crates/futures/src/queue.rs index 2e17eb5ecf1..f2162e60240 100644 --- a/crates/futures/src/queue.rs +++ b/crates/futures/src/queue.rs @@ -19,7 +19,7 @@ struct QueueState { // The queue of Tasks which are to be run in order. In practice this is all the // synchronous work of futures, and each `Task` represents calling `poll` on // a future "at the right time". - tasks: RefCell>>, + tasks: RefCell>>, // This flag indicates whether we've scheduled `run_all` to run in the future. // This is used to ensure that it's only scheduled once. @@ -58,7 +58,7 @@ pub(crate) struct Queue { impl Queue { // Schedule a task to run on the next tick - pub(crate) fn schedule_task(&self, task: Rc) { + pub(crate) fn schedule_task(&self, task: Rc) { self.state.tasks.borrow_mut().push_back(task); // Use queueMicrotask to execute as soon as possible. If it does not exist // fall back to the promise resolution @@ -71,7 +71,7 @@ impl Queue { } } // Append a task to the currently running queue, or schedule it - pub(crate) fn push_task(&self, task: Rc) { + pub(crate) fn push_task(&self, task: Rc) { // It would make sense to run this task on the same tick. For now, we // make the simplifying choice of always scheduling tasks for a future tick. self.schedule_task(task) diff --git a/crates/futures/src/task/multithread.rs b/crates/futures/src/task/multithread.rs index 6cfdfcb5437..73bd2b723cc 100644 --- a/crates/futures/src/task/multithread.rs +++ b/crates/futures/src/task/multithread.rs @@ -1,3 +1,4 @@ +use super::Task as _; use std::cell::RefCell; use std::future::Future; use std::mem::ManuallyDrop; @@ -84,27 +85,8 @@ pub(crate) struct Task { inner: RefCell>, } -impl Task { - pub(crate) fn spawn(future: Pin + 'static>>) { - let atomic = AtomicWaker::new(); - let waker = unsafe { Waker::from_raw(AtomicWaker::into_raw_waker(atomic.clone())) }; - let this = Rc::new(Task { - atomic, - waker, - inner: RefCell::new(None), - }); - - let closure = { - let this = Rc::clone(&this); - Closure::new(move |_| this.run()) - }; - *this.inner.borrow_mut() = Some(Inner { future, closure }); - - // Queue up the Future's work to happen on the next microtask tick. - crate::queue::QUEUE.with(move |queue| queue.schedule_task(this)); - } - - pub(crate) fn run(&self) { +impl super::Task for Task { + fn run(&self) { let mut borrow = self.inner.borrow_mut(); // Same as `singlethread.rs`, handle spurious wakeups happening after we @@ -162,6 +144,27 @@ impl Task { } } +impl Task { + pub(crate) fn spawn(future: Pin + 'static>>) { + let atomic = AtomicWaker::new(); + let waker = unsafe { Waker::from_raw(AtomicWaker::into_raw_waker(atomic.clone())) }; + let this = Rc::new(Task { + atomic, + waker, + inner: RefCell::new(None), + }); + + let closure = { + let this = Rc::clone(&this); + Closure::new(move |_| this.run()) + }; + *this.inner.borrow_mut() = Some(Inner { future, closure }); + + // Queue up the Future's work to happen on the next microtask tick. + crate::queue::QUEUE.with(move |queue| queue.schedule_task(this)); + } +} + fn wait_async(ptr: &AtomicI32, current_value: i32) -> Option { // If `Atomics.waitAsync` isn't defined then we use our fallback, otherwise // we use the native function. diff --git a/crates/futures/src/task/singlethread.rs b/crates/futures/src/task/singlethread.rs index ad52f552400..3f561f6d8a3 100644 --- a/crates/futures/src/task/singlethread.rs +++ b/crates/futures/src/task/singlethread.rs @@ -21,6 +21,38 @@ pub(crate) struct Task { is_queued: Cell, } +impl super::Task for Task { + fn run(&self) { + let mut borrow = self.inner.borrow_mut(); + + // Wakeups can come in after a Future has finished and been destroyed, + // so handle this gracefully by just ignoring the request to run. + let inner = match borrow.as_mut() { + Some(inner) => inner, + None => return, + }; + + // Ensure that if poll calls `waker.wake()` we can get enqueued back on + // the run queue. + self.is_queued.set(false); + + let poll = { + let mut cx = Context::from_waker(&inner.waker); + inner.future.as_mut().poll(&mut cx) + }; + + // If a future has finished (`Ready`) then clean up resources associated + // with the future ASAP. This ensures that we don't keep anything extra + // alive in-memory by accident. Our own struct, `Rc` won't + // actually go away until all wakers referencing us go away, which may + // take quite some time, so ensure that the heaviest of resources are + // released early. + if poll.is_ready() { + *borrow = None; + } + } +} + impl Task { pub(crate) fn spawn(future: Pin + 'static>>) { let this = Rc::new(Self { @@ -97,34 +129,4 @@ impl Task { RawWaker::new(Rc::into_raw(this) as *const (), &VTABLE) } - - pub(crate) fn run(&self) { - let mut borrow = self.inner.borrow_mut(); - - // Wakeups can come in after a Future has finished and been destroyed, - // so handle this gracefully by just ignoring the request to run. - let inner = match borrow.as_mut() { - Some(inner) => inner, - None => return, - }; - - // Ensure that if poll calls `waker.wake()` we can get enqueued back on - // the run queue. - self.is_queued.set(false); - - let poll = { - let mut cx = Context::from_waker(&inner.waker); - inner.future.as_mut().poll(&mut cx) - }; - - // If a future has finished (`Ready`) then clean up resources associated - // with the future ASAP. This ensures that we don't keep anything extra - // alive in-memory by accident. Our own struct, `Rc` won't - // actually go away until all wakers referencing us go away, which may - // take quite some time, so ensure that the heaviest of resources are - // released early. - if poll.is_ready() { - *borrow = None; - } - } } From 6150e210ca4e39f32c7da53745eb496fb2fc1cf9 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Tue, 20 Feb 2024 11:02:21 +0100 Subject: [PATCH 13/25] Revert "Use single-threaded impl when MT is impossible" This reverts commit 7ce38b42d32d897e2d90f52af5f58b9450f388bf. --- 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, 64 insertions(+), 96 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f449256e10..56fb600f0c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,6 @@ * 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 0e43314bf1a..a44ec7c6d27 100644 --- a/crates/futures/src/lib.rs +++ b/crates/futures/src/lib.rs @@ -50,40 +50,18 @@ pub use js_sys; pub use wasm_bindgen; mod task { - use std::future::Future; - use std::pin::Pin; - use cfg_if::cfg_if; - #[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) - } - } - } + cfg_if! { + if #[cfg(target_feature = "atomics")] { + mod wait_async_polyfill; + mod multithread; + pub(crate) use multithread::*; - pub(crate) trait Task { - fn run(&self); + } else { + mod singlethread; + pub(crate) use singlethread::*; + } } } @@ -103,7 +81,7 @@ pub fn spawn_local(future: F) where F: Future + 'static, { - task::spawn(Box::pin(future)); + task::Task::spawn(Box::pin(future)); } struct Inner { diff --git a/crates/futures/src/queue.rs b/crates/futures/src/queue.rs index f2162e60240..2e17eb5ecf1 100644 --- a/crates/futures/src/queue.rs +++ b/crates/futures/src/queue.rs @@ -19,7 +19,7 @@ struct QueueState { // The queue of Tasks which are to be run in order. In practice this is all the // synchronous work of futures, and each `Task` represents calling `poll` on // a future "at the right time". - tasks: RefCell>>, + tasks: RefCell>>, // This flag indicates whether we've scheduled `run_all` to run in the future. // This is used to ensure that it's only scheduled once. @@ -58,7 +58,7 @@ pub(crate) struct Queue { impl Queue { // Schedule a task to run on the next tick - pub(crate) fn schedule_task(&self, task: Rc) { + pub(crate) fn schedule_task(&self, task: Rc) { self.state.tasks.borrow_mut().push_back(task); // Use queueMicrotask to execute as soon as possible. If it does not exist // fall back to the promise resolution @@ -71,7 +71,7 @@ impl Queue { } } // Append a task to the currently running queue, or schedule it - pub(crate) fn push_task(&self, task: Rc) { + pub(crate) fn push_task(&self, task: Rc) { // It would make sense to run this task on the same tick. For now, we // make the simplifying choice of always scheduling tasks for a future tick. self.schedule_task(task) diff --git a/crates/futures/src/task/multithread.rs b/crates/futures/src/task/multithread.rs index 73bd2b723cc..6cfdfcb5437 100644 --- a/crates/futures/src/task/multithread.rs +++ b/crates/futures/src/task/multithread.rs @@ -1,4 +1,3 @@ -use super::Task as _; use std::cell::RefCell; use std::future::Future; use std::mem::ManuallyDrop; @@ -85,8 +84,27 @@ pub(crate) struct Task { inner: RefCell>, } -impl super::Task for Task { - fn run(&self) { +impl Task { + pub(crate) fn spawn(future: Pin + 'static>>) { + let atomic = AtomicWaker::new(); + let waker = unsafe { Waker::from_raw(AtomicWaker::into_raw_waker(atomic.clone())) }; + let this = Rc::new(Task { + atomic, + waker, + inner: RefCell::new(None), + }); + + let closure = { + let this = Rc::clone(&this); + Closure::new(move |_| this.run()) + }; + *this.inner.borrow_mut() = Some(Inner { future, closure }); + + // Queue up the Future's work to happen on the next microtask tick. + crate::queue::QUEUE.with(move |queue| queue.schedule_task(this)); + } + + pub(crate) fn run(&self) { let mut borrow = self.inner.borrow_mut(); // Same as `singlethread.rs`, handle spurious wakeups happening after we @@ -144,27 +162,6 @@ impl super::Task for Task { } } -impl Task { - pub(crate) fn spawn(future: Pin + 'static>>) { - let atomic = AtomicWaker::new(); - let waker = unsafe { Waker::from_raw(AtomicWaker::into_raw_waker(atomic.clone())) }; - let this = Rc::new(Task { - atomic, - waker, - inner: RefCell::new(None), - }); - - let closure = { - let this = Rc::clone(&this); - Closure::new(move |_| this.run()) - }; - *this.inner.borrow_mut() = Some(Inner { future, closure }); - - // Queue up the Future's work to happen on the next microtask tick. - crate::queue::QUEUE.with(move |queue| queue.schedule_task(this)); - } -} - fn wait_async(ptr: &AtomicI32, current_value: i32) -> Option { // If `Atomics.waitAsync` isn't defined then we use our fallback, otherwise // we use the native function. diff --git a/crates/futures/src/task/singlethread.rs b/crates/futures/src/task/singlethread.rs index 3f561f6d8a3..ad52f552400 100644 --- a/crates/futures/src/task/singlethread.rs +++ b/crates/futures/src/task/singlethread.rs @@ -21,38 +21,6 @@ pub(crate) struct Task { is_queued: Cell, } -impl super::Task for Task { - fn run(&self) { - let mut borrow = self.inner.borrow_mut(); - - // Wakeups can come in after a Future has finished and been destroyed, - // so handle this gracefully by just ignoring the request to run. - let inner = match borrow.as_mut() { - Some(inner) => inner, - None => return, - }; - - // Ensure that if poll calls `waker.wake()` we can get enqueued back on - // the run queue. - self.is_queued.set(false); - - let poll = { - let mut cx = Context::from_waker(&inner.waker); - inner.future.as_mut().poll(&mut cx) - }; - - // If a future has finished (`Ready`) then clean up resources associated - // with the future ASAP. This ensures that we don't keep anything extra - // alive in-memory by accident. Our own struct, `Rc` won't - // actually go away until all wakers referencing us go away, which may - // take quite some time, so ensure that the heaviest of resources are - // released early. - if poll.is_ready() { - *borrow = None; - } - } -} - impl Task { pub(crate) fn spawn(future: Pin + 'static>>) { let this = Rc::new(Self { @@ -129,4 +97,34 @@ impl Task { RawWaker::new(Rc::into_raw(this) as *const (), &VTABLE) } + + pub(crate) fn run(&self) { + let mut borrow = self.inner.borrow_mut(); + + // Wakeups can come in after a Future has finished and been destroyed, + // so handle this gracefully by just ignoring the request to run. + let inner = match borrow.as_mut() { + Some(inner) => inner, + None => return, + }; + + // Ensure that if poll calls `waker.wake()` we can get enqueued back on + // the run queue. + self.is_queued.set(false); + + let poll = { + let mut cx = Context::from_waker(&inner.waker); + inner.future.as_mut().poll(&mut cx) + }; + + // If a future has finished (`Ready`) then clean up resources associated + // with the future ASAP. This ensures that we don't keep anything extra + // alive in-memory by accident. Our own struct, `Rc` won't + // actually go away until all wakers referencing us go away, which may + // take quite some time, so ensure that the heaviest of resources are + // released early. + if poll.is_ready() { + *borrow = None; + } + } } From 00ab174fcc1509ce88287679f8d568a2a017d74f Mon Sep 17 00:00:00 2001 From: daxpedda Date: Wed, 21 Feb 2024 23:17:19 +0100 Subject: [PATCH 14/25] Update Rust version for UI tests (#3850) --- .github/workflows/main.yml | 2 +- crates/macro/ui-tests/async-errors.stderr | 44 +++++++++---------- crates/macro/ui-tests/missing-catch.stderr | 16 +++---- crates/macro/ui-tests/start-function.stderr | 28 +++++------- crates/macro/ui-tests/struct-fields.stderr | 14 +++--- .../ui-tests/traits-not-implemented.stderr | 16 +++---- crates/macro/ui-tests/wasm-bindgen.stderr | 8 +++- crates/test-macro/ui-tests/crate.stderr | 5 +++ 8 files changed, 66 insertions(+), 67 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b2851321610..0157c230edc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -246,7 +246,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: rustup update --no-self-update 1.69.0 && rustup default 1.69.0 + - run: rustup update --no-self-update 1.76.0 && rustup default 1.76.0 - run: cargo test -p wasm-bindgen-macro - run: cargo test -p wasm-bindgen-test-macro diff --git a/crates/macro/ui-tests/async-errors.stderr b/crates/macro/ui-tests/async-errors.stderr index a128c73c090..5526851f1d3 100644 --- a/crates/macro/ui-tests/async-errors.stderr +++ b/crates/macro/ui-tests/async-errors.stderr @@ -1,52 +1,48 @@ error[E0277]: the trait bound `Result<(), ()>: IntoJsResult` is not satisfied - --> ui-tests/async-errors.rs:30:1 + --> ui-tests/async-errors.rs:31:24 | -30 | #[wasm_bindgen] - | ^^^^^^^^^^^^^^^ the trait `IntoJsResult` is not implemented for `Result<(), ()>` +31 | pub async fn bad1() -> Result<(), ()> { loop {} } + | ^^^^^^^^^^^^^^ the trait `IntoJsResult` is not implemented for `Result<(), ()>` | = help: the following other types implement trait `IntoJsResult`: Result<(), E> Result - = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Result<(), BadType>: IntoJsResult` is not satisfied - --> ui-tests/async-errors.rs:32:1 + --> ui-tests/async-errors.rs:33:24 | -32 | #[wasm_bindgen] - | ^^^^^^^^^^^^^^^ the trait `IntoJsResult` is not implemented for `Result<(), BadType>` +33 | pub async fn bad2() -> Result<(), BadType> { loop {} } + | ^^^^^^^^^^^^^^^^^^^ the trait `IntoJsResult` is not implemented for `Result<(), BadType>` | = help: the following other types implement trait `IntoJsResult`: Result<(), E> Result - = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `wasm_bindgen::JsValue: From` is not satisfied - --> ui-tests/async-errors.rs:34:1 + --> ui-tests/async-errors.rs:35:24 | -34 | #[wasm_bindgen] - | ^^^^^^^^^^^^^^^ the trait `From` is not implemented for `wasm_bindgen::JsValue` +35 | pub async fn bad3() -> BadType { loop {} } + | ^^^^^^^ the trait `From` is not implemented for `wasm_bindgen::JsValue` | = help: the following other types implement trait `From`: - > - > - > - > - > - > - > - > + > + > + > + > + > + > + > + > and $N others = note: required for `BadType` to implement `Into` = note: required for `BadType` to implement `IntoJsResult` - = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Result: IntoJsResult` is not satisfied - --> ui-tests/async-errors.rs:36:1 + --> ui-tests/async-errors.rs:37:24 | -36 | #[wasm_bindgen] - | ^^^^^^^^^^^^^^^ the trait `IntoJsResult` is not implemented for `Result` +37 | pub async fn bad4() -> Result { loop {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoJsResult` is not implemented for `Result` | = help: the following other types implement trait `IntoJsResult`: Result<(), E> Result - = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/macro/ui-tests/missing-catch.stderr b/crates/macro/ui-tests/missing-catch.stderr index 5e54e41e7f7..02a74e62f00 100644 --- a/crates/macro/ui-tests/missing-catch.stderr +++ b/crates/macro/ui-tests/missing-catch.stderr @@ -5,12 +5,12 @@ error[E0277]: the trait bound `Result` | = help: the following other types implement trait `FromWasmAbi`: - *const T - *mut T - Box<[T]> - Clamped - Option - Option - Option - Option + bool + char + isize + i8 + i16 + i32 + i64 + usize and $N others diff --git a/crates/macro/ui-tests/start-function.stderr b/crates/macro/ui-tests/start-function.stderr index 9cd11976118..cc25189ba49 100644 --- a/crates/macro/ui-tests/start-function.stderr +++ b/crates/macro/ui-tests/start-function.stderr @@ -11,37 +11,33 @@ error: the start function cannot have generics | ^^^ error[E0277]: the trait bound `Result: wasm_bindgen::__rt::Start` is not satisfied - --> ui-tests/start-function.rs:15:1 + --> ui-tests/start-function.rs:16:14 | -15 | #[wasm_bindgen(start)] - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` +16 | fn foo5() -> Result { Err(()) } + | ^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` | = help: the trait `wasm_bindgen::__rt::Start` is implemented for `Result<(), E>` - = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Result: wasm_bindgen::__rt::Start` is not satisfied - --> ui-tests/start-function.rs:18:1 + --> ui-tests/start-function.rs:19:14 | -18 | #[wasm_bindgen(start)] - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` +19 | fn foo6() -> Result { Ok(JsValue::from(1u32)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` | = help: the trait `wasm_bindgen::__rt::Start` is implemented for `Result<(), E>` - = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Result: wasm_bindgen::__rt::Start` is not satisfied - --> ui-tests/start-function.rs:27:1 + --> ui-tests/start-function.rs:28:26 | -27 | #[wasm_bindgen(start)] - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` +28 | async fn foo_async3() -> Result { Err(()) } + | ^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` | = help: the trait `wasm_bindgen::__rt::Start` is implemented for `Result<(), E>` - = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Result: wasm_bindgen::__rt::Start` is not satisfied - --> ui-tests/start-function.rs:30:1 + --> ui-tests/start-function.rs:31:26 | -30 | #[wasm_bindgen(start)] - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` +31 | async fn foo_async4() -> Result { Ok(JsValue::from(1u32)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::Start` is not implemented for `Result` | = help: the trait `wasm_bindgen::__rt::Start` is implemented for `Result<(), E>` - = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/macro/ui-tests/struct-fields.stderr b/crates/macro/ui-tests/struct-fields.stderr index ab17546955e..6e402b2d6ab 100644 --- a/crates/macro/ui-tests/struct-fields.stderr +++ b/crates/macro/ui-tests/struct-fields.stderr @@ -12,17 +12,13 @@ note: required by a bound in `__wbg_get_bar_a::assert_copy` = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Foo: Clone` is not satisfied - --> ui-tests/struct-fields.rs:11:20 + --> ui-tests/struct-fields.rs:12:12 | -11 | #[wasm_bindgen(getter_with_clone)] - | ^---------------- - | | - | ____________________required by a bound introduced by this call - | | -12 | | pub b: Foo, - | |_________^ the trait `Clone` is not implemented for `Foo` +12 | pub b: Foo, + | ^^^ the trait `Clone` is not implemented for `Foo` | help: consider annotating `Foo` with `#[derive(Clone)]` | -3 | #[derive(Clone)] +3 + #[derive(Clone)] +4 | #[wasm_bindgen] | diff --git a/crates/macro/ui-tests/traits-not-implemented.stderr b/crates/macro/ui-tests/traits-not-implemented.stderr index 714050a53b5..883648fae4c 100644 --- a/crates/macro/ui-tests/traits-not-implemented.stderr +++ b/crates/macro/ui-tests/traits-not-implemented.stderr @@ -5,13 +5,13 @@ error[E0277]: the trait bound `A: IntoWasmAbi` is not satisfied | ^^^^^^^^^^^^^^^ the trait `IntoWasmAbi` is not implemented for `A` | = help: the following other types implement trait `IntoWasmAbi`: - &'a (dyn Fn() -> R + 'b) - &'a (dyn Fn(A) -> R + 'b) - &'a (dyn Fn(A, B) -> R + 'b) - &'a (dyn Fn(A, B, C) -> R + 'b) - &'a (dyn Fn(A, B, C, D) -> R + 'b) - &'a (dyn Fn(A, B, C, D, E) -> R + 'b) - &'a (dyn Fn(A, B, C, D, E, F) -> R + 'b) - &'a (dyn Fn(A, B, C, D, E, F, G) -> R + 'b) + bool + char + isize + i8 + i16 + i32 + i64 + usize and $N others = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/macro/ui-tests/wasm-bindgen.stderr b/crates/macro/ui-tests/wasm-bindgen.stderr index 7ed892ebb0a..2ec13836be6 100644 --- a/crates/macro/ui-tests/wasm-bindgen.stderr +++ b/crates/macro/ui-tests/wasm-bindgen.stderr @@ -5,6 +5,12 @@ error[E0433]: failed to resolve: could not find `convert` in `test` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not find `convert` in `test` | = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider importing one of these items + | +3 + use crate::test::test::convert; + | +3 + use wasm_bindgen::convert; + | error[E0425]: cannot find function `future_to_promise` in module `test` --> ui-tests/wasm-bindgen.rs:40:1 @@ -15,5 +21,5 @@ error[E0425]: cannot find function `future_to_promise` in module `test` = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing this function | -3 | use wasm_bindgen_futures::future_to_promise; +3 + use wasm_bindgen_futures::future_to_promise; | diff --git a/crates/test-macro/ui-tests/crate.stderr b/crates/test-macro/ui-tests/crate.stderr index 2bace352ee4..e256cb3f4fe 100644 --- a/crates/test-macro/ui-tests/crate.stderr +++ b/crates/test-macro/ui-tests/crate.stderr @@ -3,3 +3,8 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo` | 17 | #[wasm_bindgen_test(crate = foo)] | ^^^ use of undeclared crate or module `foo` + | +help: consider importing this module + | +5 + use wasm_bindgen_test::__rt; + | From b5a74c85783963456cec0f00edcdeae6d69f1c62 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Thu, 22 Feb 2024 11:06:13 -0500 Subject: [PATCH 15/25] Add `sorted_iter_mut` for NonstandardWitSection.adapters for determinism (#3851) --- CHANGELOG.md | 5 +++++ crates/cli-support/src/externref.rs | 4 ++-- crates/cli-support/src/lib.rs | 10 ++++++++++ crates/cli-support/src/multivalue.rs | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56fb600f0c3..f35f358483b 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 + +* Make .wasm output deterministic when using `--reference-types`. + [#3851](https://github.com/rustwasm/wasm-bindgen/pull/3851) + -------------------------------------------------------------------------------- ## [0.2.91](https://github.com/rustwasm/wasm-bindgen/compare/0.2.90...0.2.91) diff --git a/crates/cli-support/src/externref.rs b/crates/cli-support/src/externref.rs index 51b0db14b72..ef3a726ad9f 100644 --- a/crates/cli-support/src/externref.rs +++ b/crates/cli-support/src/externref.rs @@ -25,7 +25,7 @@ pub fn process(module: &mut Module) -> Result<()> { // Transform all exported functions in the module, using the bindings listed // for each exported function. - for (id, adapter) in section.adapters.iter_mut() { + for (id, adapter) in crate::sorted_iter_mut(&mut section.adapters) { let instructions = match &mut adapter.kind { AdapterKind::Local { instructions } => instructions, AdapterKind::Import { .. } => continue, @@ -77,7 +77,7 @@ pub fn process(module: &mut Module) -> Result<()> { // Additionally we may need to update some adapter instructions other than // those found for the externref pass. These are some general "fringe support" // things necessary to get absolutely everything working. - for (_, adapter) in section.adapters.iter_mut() { + for (_, adapter) in crate::sorted_iter_mut(&mut section.adapters) { let instrs = match &mut adapter.kind { AdapterKind::Local { instructions } => instructions, AdapterKind::Import { .. } => continue, diff --git a/crates/cli-support/src/lib.rs b/crates/cli-support/src/lib.rs index c3e24bd2ff1..bccba23459d 100755 --- a/crates/cli-support/src/lib.rs +++ b/crates/cli-support/src/lib.rs @@ -785,3 +785,13 @@ where pairs.sort_by_key(|(k, _)| *k); pairs.into_iter() } + +/// Like `sorted_iter`, but produces mutable references to the values +fn sorted_iter_mut(map: &mut HashMap) -> impl Iterator +where + K: Ord, +{ + let mut pairs = map.iter_mut().collect::>(); + pairs.sort_by_key(|(k, _)| *k); + pairs.into_iter() +} diff --git a/crates/cli-support/src/multivalue.rs b/crates/cli-support/src/multivalue.rs index 61a20878e63..9fd7071b483 100644 --- a/crates/cli-support/src/multivalue.rs +++ b/crates/cli-support/src/multivalue.rs @@ -14,7 +14,7 @@ pub fn run(module: &mut Module) -> Result<(), Error> { let mut to_xform = Vec::new(); let mut slots = Vec::new(); - for (_, adapter) in adapters.adapters.iter_mut() { + for (_, adapter) in crate::sorted_iter_mut(&mut adapters.adapters) { extract_xform(module, adapter, &mut to_xform, &mut slots); } if to_xform.is_empty() { From 557e2e65188470e578f19a8364d7e6b23eec12fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Gaspard?= Date: Fri, 23 Feb 2024 09:06:00 +0100 Subject: [PATCH 16/25] Introduce impl TryFrom for Number that succeeds iff the value is within the safe range (#3847) --- CHANGELOG.md | 3 +++ crates/js-sys/src/lib.rs | 31 ++++++++++++++++++++++++++++++ crates/js-sys/tests/wasm/Number.rs | 20 ++++++++++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f35f358483b..16e9e1d3963 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ * Add bindings for `CanvasState.reset()`, affecting `CanvasRenderingContext2D` and `OffscreenCanvasRenderingContext2D`. [#3844](https://github.com/rustwasm/wasm-bindgen/pull/3844) +* Add `TryFrom` implementations for `Number`, that allow losslessly converting from 64- and 128-bits numbers. + [#3847](https://github.com/rustwasm/wasm-bindgen/pull/3847) + ### Fixed * Make .wasm output deterministic when using `--reference-types`. diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index b18faf6cae0..a244b7b70a0 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -2793,6 +2793,37 @@ macro_rules! number_from { } number_from!(i8 u8 i16 u16 i32 u32 f32 f64); +/// The error type returned when a checked integral type conversion fails. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct TryFromIntError(()); + +impl fmt::Display for TryFromIntError { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt.write_str("out of range integral type conversion attempted") + } +} + +impl std::error::Error for TryFromIntError {} + +macro_rules! number_try_from { + ($($x:ident)*) => ($( + impl TryFrom<$x> for Number { + type Error = TryFromIntError; + + #[inline] + fn try_from(x: $x) -> Result { + let x_f64 = x as f64; + if x_f64 >= Number::MIN_SAFE_INTEGER && x_f64 <= Number::MAX_SAFE_INTEGER { + Ok(Number::from(x_f64)) + } else { + Err(TryFromIntError(())) + } + } + } + )*) +} +number_try_from!(i64 u64 i128 u128); + // TODO: add this on the next major version, when blanket impl is removed /* impl convert::TryFrom for Number { diff --git a/crates/js-sys/tests/wasm/Number.rs b/crates/js-sys/tests/wasm/Number.rs index 94fd551f33e..31f3f565fe8 100644 --- a/crates/js-sys/tests/wasm/Number.rs +++ b/crates/js-sys/tests/wasm/Number.rs @@ -1,4 +1,7 @@ -use std::f64::{INFINITY, NAN}; +use std::{ + convert::TryFrom, + f64::{INFINITY, NAN}, +}; use js_sys::*; use wasm_bindgen::prelude::*; @@ -71,6 +74,21 @@ fn new() { assert_eq!(Number::from(v).value_of(), 42.); } +#[wasm_bindgen_test] +fn try_from() { + assert_eq!(Number::try_from(42u128).unwrap(), 42.); + assert_eq!( + Number::try_from(Number::MAX_SAFE_INTEGER as u64).unwrap(), + Number::MAX_SAFE_INTEGER + ); + assert_eq!( + Number::try_from(Number::MIN_SAFE_INTEGER as i128).unwrap(), + Number::MIN_SAFE_INTEGER + ); + assert!(Number::try_from(Number::MAX_SAFE_INTEGER as u128 + 1).is_err()); + assert!(Number::try_from(Number::MIN_SAFE_INTEGER as i64 - 1).is_err()); +} + #[wasm_bindgen_test] fn parse_int_float() { assert_eq!(Number::parse_int("42", 10), 42.); From 0c09e154cf37b7e7f2308787d5186056cf85b533 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Fri, 23 Feb 2024 14:00:44 +0100 Subject: [PATCH 17/25] Fix CI (#3853) --- tests/wasm/classes.rs | 4 +--- tests/wasm/closures.rs | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/wasm/classes.rs b/tests/wasm/classes.rs index 6058c0a59da..e590cf7e2eb 100644 --- a/tests/wasm/classes.rs +++ b/tests/wasm/classes.rs @@ -451,9 +451,7 @@ impl RenamedExport { } pub fn foo(&self) {} - pub fn bar(&self, other: &RenamedExport) { - drop(other); - } + pub fn bar(&self, _: &RenamedExport) {} } #[wasm_bindgen_test] diff --git a/tests/wasm/closures.rs b/tests/wasm/closures.rs index 1061dab5ab9..a0247b5d1ca 100644 --- a/tests/wasm/closures.rs +++ b/tests/wasm/closures.rs @@ -432,7 +432,9 @@ fn drop_drops() { } } let a = A; - let x: Closure = Closure::new(move || drop(&a)); + let x: Closure = Closure::new(move || { + let _ = a; + }); drop(x); unsafe { assert!(HIT); @@ -605,25 +607,33 @@ fn call_destroyed_doesnt_segfault() { } let a = A(1, 1); - let a = Closure::wrap(Box::new(move || drop(&a)) as Box); + let a = Closure::wrap(Box::new(move || { + let _ = a; + }) as Box); let b = a.as_ref().clone(); drop(a); call_destroyed(&b); let a = A(2, 2); - let a = Closure::wrap(Box::new(move || drop(&a)) as Box); + let a = Closure::wrap(Box::new(move || { + let _ = a; + }) as Box); let b = a.as_ref().clone(); drop(a); call_destroyed(&b); let a = A(1, 1); - let a = Closure::wrap(Box::new(move |_: &JsValue| drop(&a)) as Box); + let a = Closure::wrap(Box::new(move |_: &JsValue| { + let _ = a; + }) as Box); let b = a.as_ref().clone(); drop(a); call_destroyed(&b); let a = A(2, 2); - let a = Closure::wrap(Box::new(move |_: &JsValue| drop(&a)) as Box); + let a = Closure::wrap(Box::new(move |_: &JsValue| { + let _ = a; + }) as Box); let b = a.as_ref().clone(); drop(a); call_destroyed(&b); From c80bf9a3237a55ebffb9fd7559b7f8681ffa257f Mon Sep 17 00:00:00 2001 From: daxpedda Date: Mon, 26 Feb 2024 11:49:55 +0100 Subject: [PATCH 18/25] Add support for `Option<*const T>`, `Option<*mut T>` and `NonNull` (#3852) Co-authored-by: Liam Murphy <43807659+Liamolucko@users.noreply.github.com> --- CHANGELOG.md | 3 + crates/cli-support/src/descriptor.rs | 3 + crates/cli-support/src/js/binding.rs | 17 ++++- crates/cli-support/src/wit/incoming.rs | 8 +++ crates/cli-support/src/wit/outgoing.rs | 11 +++- crates/cli-support/src/wit/standard.rs | 3 + crates/shared/src/lib.rs | 2 +- crates/shared/src/schema_hash_approval.rs | 2 +- .../non_null.js | 12 ++++ .../src/non_null.rs | 13 ++++ guide/src/SUMMARY.md | 1 + guide/src/reference/types/non-null.md | 17 +++++ guide/src/reference/types/pointers.md | 2 +- src/convert/impls.rs | 62 +++++++++++++++++++ src/describe.rs | 9 +++ tests/wasm/simple.js | 36 +++++++++++ tests/wasm/simple.rs | 61 ++++++++++++++++++ 17 files changed, 256 insertions(+), 6 deletions(-) create mode 100644 examples/guide-supported-types-examples/non_null.js create mode 100644 examples/guide-supported-types-examples/src/non_null.rs create mode 100644 guide/src/reference/types/non-null.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 16e9e1d3963..7ebdefce452 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ * Add `TryFrom` implementations for `Number`, that allow losslessly converting from 64- and 128-bits numbers. [#3847](https://github.com/rustwasm/wasm-bindgen/pull/3847) +* Add support for `Option<*const T>`, `Option<*mut T>` and `NonNull`. + [#3852](https://github.com/rustwasm/wasm-bindgen/pull/3852) + ### Fixed * Make .wasm output deterministic when using `--reference-types`. diff --git a/crates/cli-support/src/descriptor.rs b/crates/cli-support/src/descriptor.rs index e21dae1ed29..62dd766ac7a 100644 --- a/crates/cli-support/src/descriptor.rs +++ b/crates/cli-support/src/descriptor.rs @@ -40,6 +40,7 @@ tys! { RESULT UNIT CLAMPED + NONNULL } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -72,6 +73,7 @@ pub enum Descriptor { Option(Box), Result(Box), Unit, + NonNull, } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -165,6 +167,7 @@ impl Descriptor { CHAR => Descriptor::Char, UNIT => Descriptor::Unit, CLAMPED => Descriptor::_decode(data, true), + NONNULL => Descriptor::NonNull, other => panic!("unknown descriptor: {}", other), } } diff --git a/crates/cli-support/src/js/binding.rs b/crates/cli-support/src/js/binding.rs index 76b61b42f86..f186038bde9 100644 --- a/crates/cli-support/src/js/binding.rs +++ b/crates/cli-support/src/js/binding.rs @@ -652,7 +652,7 @@ fn instruction( Instruction::WasmToInt { output, .. } => { let val = js.pop(); match output { - AdapterType::U32 => js.push(format!("{} >>> 0", val)), + AdapterType::U32 | AdapterType::NonNull => js.push(format!("{} >>> 0", val)), AdapterType::U64 => js.push(format!("BigInt.asUintN(64, {val})")), _ => js.push(val), } @@ -1217,6 +1217,18 @@ fn instruction( let val = js.pop(); js.push(format!("{0} === {1} ? undefined : {0}", val, hole)); } + + Instruction::I32FromOptionNonNull => { + let val = js.pop(); + js.cx.expose_is_like_none(); + js.assert_optional_number(&val); + js.push(format!("isLikeNone({0}) ? 0 : {0}", val)); + } + + Instruction::OptionNonNullFromI32 => { + let val = js.pop(); + js.push(format!("{0} === 0 ? undefined : {0} >>> 0", val)); + } } Ok(()) } @@ -1324,7 +1336,8 @@ fn adapter2ts(ty: &AdapterType, dst: &mut String) { | AdapterType::U16 | AdapterType::U32 | AdapterType::F32 - | AdapterType::F64 => dst.push_str("number"), + | AdapterType::F64 + | AdapterType::NonNull => dst.push_str("number"), AdapterType::I64 | AdapterType::S64 | AdapterType::U64 => dst.push_str("bigint"), AdapterType::String => dst.push_str("string"), AdapterType::Externref => dst.push_str("any"), diff --git a/crates/cli-support/src/wit/incoming.rs b/crates/cli-support/src/wit/incoming.rs index b42541791eb..084e939e624 100644 --- a/crates/cli-support/src/wit/incoming.rs +++ b/crates/cli-support/src/wit/incoming.rs @@ -155,6 +155,8 @@ impl InstructionBuilder<'_, '_> { // Largely synthetic and can't show up Descriptor::ClampedU8 => unreachable!(), + + Descriptor::NonNull => unimplemented!("converting `NonNull` from Wasm to Rust is not implemented"), } Ok(()) } @@ -331,6 +333,12 @@ impl InstructionBuilder<'_, '_> { ); } + Descriptor::NonNull => self.instruction( + &[AdapterType::NonNull.option()], + Instruction::I32FromOptionNonNull, + &[AdapterType::I32], + ), + _ => bail!( "unsupported optional argument type for calling Rust function from JS: {:?}", arg diff --git a/crates/cli-support/src/wit/outgoing.rs b/crates/cli-support/src/wit/outgoing.rs index 41763bdbe00..2c0fceefbcd 100644 --- a/crates/cli-support/src/wit/outgoing.rs +++ b/crates/cli-support/src/wit/outgoing.rs @@ -156,6 +156,8 @@ impl InstructionBuilder<'_, '_> { // Largely synthetic and can't show up Descriptor::ClampedU8 => unreachable!(), + + Descriptor::NonNull => self.outgoing_i32(AdapterType::NonNull), } Ok(()) } @@ -319,6 +321,12 @@ impl InstructionBuilder<'_, '_> { ); } + Descriptor::NonNull => self.instruction( + &[AdapterType::I32], + Instruction::OptionNonNullFromI32, + &[AdapterType::NonNull.option()], + ), + _ => bail!( "unsupported optional argument type for calling JS function from Rust: {:?}", arg @@ -350,7 +358,8 @@ impl InstructionBuilder<'_, '_> { | Descriptor::CachedString | Descriptor::Option(_) | Descriptor::Vector(_) - | Descriptor::Unit => { + | Descriptor::Unit + | Descriptor::NonNull => { // We must throw before reading the Ok type, if there is an error. However, the // structure of ResultAbi is that the Err value + discriminant come last (for // alignment reasons). So the UnwrapResult instruction must come first, but the diff --git a/crates/cli-support/src/wit/standard.rs b/crates/cli-support/src/wit/standard.rs index 95781a6131e..d9a86b81a9d 100644 --- a/crates/cli-support/src/wit/standard.rs +++ b/crates/cli-support/src/wit/standard.rs @@ -88,6 +88,7 @@ pub enum AdapterType { Enum(String), NamedExternref(String), Function, + NonNull, } #[derive(Debug, Clone)] @@ -308,6 +309,8 @@ pub enum Instruction { OptionEnumFromI32 { hole: u32, }, + I32FromOptionNonNull, + OptionNonNullFromI32, } impl AdapterType { diff --git a/crates/shared/src/lib.rs b/crates/shared/src/lib.rs index 991dc0c61c3..f8ad45c7cd3 100644 --- a/crates/shared/src/lib.rs +++ b/crates/shared/src/lib.rs @@ -6,7 +6,7 @@ mod schema_hash_approval; // This gets changed whenever our schema changes. // At this time versions of wasm-bindgen and wasm-bindgen-cli are required to have the exact same // SCHEMA_VERSION in order to work together. -pub const SCHEMA_VERSION: &str = "0.2.88"; +pub const SCHEMA_VERSION: &str = "0.2.92"; #[macro_export] macro_rules! shared_api { diff --git a/crates/shared/src/schema_hash_approval.rs b/crates/shared/src/schema_hash_approval.rs index 702277b74d0..471ccc9beac 100644 --- a/crates/shared/src/schema_hash_approval.rs +++ b/crates/shared/src/schema_hash_approval.rs @@ -8,7 +8,7 @@ // If the schema in this library has changed then: // 1. Bump the version in `crates/shared/Cargo.toml` // 2. Change the `SCHEMA_VERSION` in this library to this new Cargo.toml version -const APPROVED_SCHEMA_FILE_HASH: &str = "2548486983363536439"; +const APPROVED_SCHEMA_FILE_HASH: &str = "11955579329744078753"; #[test] fn schema_version() { diff --git a/examples/guide-supported-types-examples/non_null.js b/examples/guide-supported-types-examples/non_null.js new file mode 100644 index 00000000000..59ff64d80d1 --- /dev/null +++ b/examples/guide-supported-types-examples/non_null.js @@ -0,0 +1,12 @@ +import { + take_pointer_by_value, + return_pointer, +} from './guide_supported_types_examples'; +import { memory } from './guide_supported_types_examples_bg'; + +let ptr = return_pointer(); +let buf = new Uint8Array(memory.buffer); +let value = buf[ptr]; +console.log(`The byte at the ${ptr} address is ${value}`); + +take_pointer_by_value(ptr); diff --git a/examples/guide-supported-types-examples/src/non_null.rs b/examples/guide-supported-types-examples/src/non_null.rs new file mode 100644 index 00000000000..0f524e0eda2 --- /dev/null +++ b/examples/guide-supported-types-examples/src/non_null.rs @@ -0,0 +1,13 @@ +use std::ptr; +use std::ptr::NonNull; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +pub unsafe fn take_pointer_by_value(x: Option>) { + Box::from_raw(x.unwrap().as_ptr()); +} + +#[wasm_bindgen] +pub fn return_pointer() -> Option> { + Some(NonNull::from(Box::leak(Box::new(42)))) +} diff --git a/guide/src/SUMMARY.md b/guide/src/SUMMARY.md index 5d9c362902c..7ba50cd5042 100644 --- a/guide/src/SUMMARY.md +++ b/guide/src/SUMMARY.md @@ -54,6 +54,7 @@ - [`JsValue`](./reference/types/jsvalue.md) - [`Box<[T]>` and `Vec`](./reference/types/boxed-slices.md) - [`*const T` and `*mut T`](./reference/types/pointers.md) + - [`NonNull`](./reference/types/non-null.md) - [Numbers](./reference/types/numbers.md) - [`bool`](./reference/types/bool.md) - [`char`](./reference/types/char.md) diff --git a/guide/src/reference/types/non-null.md b/guide/src/reference/types/non-null.md new file mode 100644 index 00000000000..8e1b9d17f25 --- /dev/null +++ b/guide/src/reference/types/non-null.md @@ -0,0 +1,17 @@ +# `NonNull` + +| `T` parameter | `&T` parameter | `&mut T` parameter | `T` return value | `Option` parameter | `Option` return value | JavaScript representation | +|:---:|:---:|:---:|:---:|:---:|:---:|:---:| +| No | No | No | Yes | Yes | Yes | A JavaScript number value | + +## Example Rust Usage + +```rust +{{#include ../../../../examples/guide-supported-types-examples/src/non_null.rs}} +``` + +## Example JavaScript Usage + +```js +{{#include ../../../../examples/guide-supported-types-examples/non_null.js}} +``` diff --git a/guide/src/reference/types/pointers.md b/guide/src/reference/types/pointers.md index 15ca4eb5c99..98c72194e3d 100644 --- a/guide/src/reference/types/pointers.md +++ b/guide/src/reference/types/pointers.md @@ -2,7 +2,7 @@ | `T` parameter | `&T` parameter | `&mut T` parameter | `T` return value | `Option` parameter | `Option` return value | JavaScript representation | |:---:|:---:|:---:|:---:|:---:|:---:|:---:| -| Yes | No | No | Yes | No | No | A JavaScript number value | +| Yes | No | No | Yes | Yes | Yes | A JavaScript number value | ## Example Rust Usage diff --git a/src/convert/impls.rs b/src/convert/impls.rs index 8f1e3798055..64a40925c84 100644 --- a/src/convert/impls.rs +++ b/src/convert/impls.rs @@ -1,5 +1,6 @@ use core::char; use core::mem::{self, ManuallyDrop}; +use core::ptr::NonNull; use crate::convert::traits::{WasmAbi, WasmPrimitive}; use crate::convert::TryFromJsValue; @@ -223,6 +224,24 @@ impl FromWasmAbi for *const T { } } +impl IntoWasmAbi for Option<*const T> { + type Abi = Option; + + #[inline] + fn into_abi(self) -> Option { + self.map(|ptr| ptr as u32) + } +} + +impl FromWasmAbi for Option<*const T> { + type Abi = Option; + + #[inline] + unsafe fn from_abi(js: Option) -> Option<*const T> { + js.map(|ptr| ptr as *const T) + } +} + impl IntoWasmAbi for *mut T { type Abi = u32; @@ -241,6 +260,49 @@ impl FromWasmAbi for *mut T { } } +impl IntoWasmAbi for Option<*mut T> { + type Abi = Option; + + #[inline] + fn into_abi(self) -> Option { + self.map(|ptr| ptr as u32) + } +} + +impl FromWasmAbi for Option<*mut T> { + type Abi = Option; + + #[inline] + unsafe fn from_abi(js: Option) -> Option<*mut T> { + js.map(|ptr| ptr as *mut T) + } +} + +impl IntoWasmAbi for NonNull { + type Abi = u32; + + #[inline] + fn into_abi(self) -> u32 { + self.as_ptr() as u32 + } +} + +impl OptionIntoWasmAbi for NonNull { + #[inline] + fn none() -> u32 { + 0 + } +} + +impl FromWasmAbi for Option> { + type Abi = u32; + + #[inline] + unsafe fn from_abi(js: Self::Abi) -> Self { + NonNull::new(js as *mut T) + } +} + impl IntoWasmAbi for JsValue { type Abi = u32; diff --git a/src/describe.rs b/src/describe.rs index d3b5fd0b546..23190f71987 100644 --- a/src/describe.rs +++ b/src/describe.rs @@ -3,6 +3,8 @@ #![doc(hidden)] +use core::ptr::NonNull; + use crate::{Clamped, JsError, JsObject, JsValue}; use cfg_if::cfg_if; @@ -46,6 +48,7 @@ tys! { RESULT UNIT CLAMPED + NONNULL } #[inline(always)] // see the wasm-interpreter crate @@ -114,6 +117,12 @@ impl WasmDescribe for *mut T { } } +impl WasmDescribe for NonNull { + fn describe() { + inform(NONNULL) + } +} + impl WasmDescribe for [T] { fn describe() { inform(SLICE); diff --git a/tests/wasm/simple.js b/tests/wasm/simple.js index bc3edce8c0a..bcac3262f49 100644 --- a/tests/wasm/simple.js +++ b/tests/wasm/simple.js @@ -110,3 +110,39 @@ exports.test_string_roundtrip = () => { test('a longer string'); test('a longer 💖 string'); }; + +exports.test_raw_pointers = function() { + const memory32 = new Uint32Array(wasm.__wasm.memory.buffer); + const memory8 = new Uint8Array(wasm.__wasm.memory.buffer); + + const ptr1 = wasm.simple_return_raw_pointer_u32(4294967295); + assert.strictEqual(memory32[ptr1 / 4], 4294967295); + const ptr2 = wasm.simple_return_raw_pointer_u8(42); + assert.strictEqual(memory8[ptr2], 42); + + wasm.simple_raw_pointers_work(ptr1, ptr2); + assert.strictEqual(memory32[ptr1 / 4], 42); + + const ptr3 = wasm.simple_return_raw_pointer_u32(4294967295); + wasm.simple_option_raw_pointers_work(ptr3, ptr2); + assert.strictEqual(memory32[ptr3 / 4], 42); + + assert.strictEqual(wasm.simple_option_raw_pointers_work(0, ptr2), undefined); + assert.strictEqual(wasm.simple_option_raw_pointers_work(null, ptr2), undefined); + assert.strictEqual(wasm.simple_option_raw_pointers_work(undefined, ptr2), undefined); + + assert.strictEqual(wasm.simple_option_raw_pointers_work(ptr1, 0), undefined); + assert.strictEqual(wasm.simple_option_raw_pointers_work(ptr1, null), undefined); + assert.strictEqual(wasm.simple_option_raw_pointers_work(ptr1, undefined), undefined); + + assert.strictEqual(wasm.simple_return_option_null_pointer(), 0) +}; + +exports.test_non_null = function() { + assert.strictEqual(wasm.simple_option_nonnull_work(0), undefined); + assert.strictEqual(wasm.simple_option_nonnull_work(null), undefined); + assert.strictEqual(wasm.simple_option_nonnull_work(undefined), undefined); + + assert.strictEqual(wasm.simple_option_nonnull_work(wasm.simple_return_non_null()), 42); + assert.strictEqual(wasm.simple_option_nonnull_work(wasm.simple_return_option_non_null(43)), 43); +}; diff --git a/tests/wasm/simple.rs b/tests/wasm/simple.rs index 94cad579c56..b6bab8c3874 100644 --- a/tests/wasm/simple.rs +++ b/tests/wasm/simple.rs @@ -1,3 +1,5 @@ +use std::ptr::{self, NonNull}; + use wasm_bindgen::prelude::*; use wasm_bindgen::{intern, unintern}; use wasm_bindgen_test::*; @@ -29,6 +31,9 @@ extern "C" { fn new_renamed() -> Renamed; fn test_string_roundtrip(); + + fn test_raw_pointers(); + fn test_non_null(); } #[wasm_bindgen_test] @@ -56,12 +61,68 @@ pub fn simple_return_and_take_bool(a: bool, b: bool) -> bool { a && b } +#[wasm_bindgen] +pub fn simple_return_raw_pointer_u32(value: u32) -> *mut u32 { + Box::into_raw(Box::new(value)) +} + +#[wasm_bindgen] +pub fn simple_return_raw_pointer_u8(value: u8) -> *const u8 { + Box::into_raw(Box::new(value)) +} + #[wasm_bindgen] pub unsafe fn simple_raw_pointers_work(a: *mut u32, b: *const u8) -> *const u32 { (*a) = (*b) as u32; a } +#[wasm_bindgen] +pub fn simple_return_option_null_pointer() -> Option<*const u32> { + Some(ptr::null()) +} + +#[wasm_bindgen] +pub unsafe fn simple_option_raw_pointers_work( + a: Option<*mut u32>, + b: Option<*const u8>, +) -> Option<*const u32> { + let a = a.and_then(|ptr| ptr.as_mut()); + let b = b.and_then(|ptr| ptr.as_ref()); + + if let (Some(a), Some(b)) = (a, b) { + *a = *b as u32; + Some(a) + } else { + None + } +} + +#[wasm_bindgen_test] +fn raw_pointers() { + test_raw_pointers(); +} + +#[wasm_bindgen] +pub fn simple_return_non_null() -> NonNull { + NonNull::from(Box::leak(Box::new(42))) +} + +#[wasm_bindgen] +pub fn simple_return_option_non_null(value: u32) -> Option> { + Some(NonNull::from(Box::leak(Box::new(value)))) +} + +#[wasm_bindgen] +pub unsafe fn simple_option_nonnull_work(a: Option>) -> Option { + a.map(|ptr| *Box::from_raw(ptr.as_ptr())) +} + +#[wasm_bindgen_test] +fn non_null() { + test_non_null(); +} + #[wasm_bindgen_test] fn string_arguments() { test_string_arguments(); From b9ccb8f3c5e0590ee9934e0a1a88dacde2c53453 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Tue, 27 Feb 2024 22:22:50 +0100 Subject: [PATCH 19/25] Allow using `'static` lifetimes in functions (#3856) Co-authored-by: Liam Murphy <43807659+Liamolucko@users.noreply.github.com> --- CHANGELOG.md | 5 ++ crates/macro-support/src/parser.rs | 12 ++-- crates/macro/ui-tests/invalid-imports-1.rs | 41 ++++++++++++ .../macro/ui-tests/invalid-imports-1.stderr | 65 +++++++++++++++++++ crates/macro/ui-tests/invalid-imports-2.rs | 8 +++ .../macro/ui-tests/invalid-imports-2.stderr | 5 ++ crates/macro/ui-tests/invalid-imports.rs | 2 + crates/macro/ui-tests/invalid-imports.stderr | 6 -- 8 files changed, 133 insertions(+), 11 deletions(-) create mode 100644 crates/macro/ui-tests/invalid-imports-1.rs create mode 100644 crates/macro/ui-tests/invalid-imports-1.stderr create mode 100644 crates/macro/ui-tests/invalid-imports-2.rs create mode 100644 crates/macro/ui-tests/invalid-imports-2.stderr diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ebdefce452..a0c5857479e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,11 @@ * Add support for `Option<*const T>`, `Option<*mut T>` and `NonNull`. [#3852](https://github.com/rustwasm/wasm-bindgen/pull/3852) +### Changed + +* Allow using `'static` lifetimes in functions marked with `#[wasm_bindgen]`. This does not allow references where they were not allowed before! + [#3856](https://github.com/rustwasm/wasm-bindgen/pull/3856) + ### Fixed * Make .wasm output deterministic when using `--reference-types`. diff --git a/crates/macro-support/src/parser.rs b/crates/macro-support/src/parser.rs index eee4f66e95d..5778eb50d41 100644 --- a/crates/macro-support/src/parser.rs +++ b/crates/macro-support/src/parser.rs @@ -1652,12 +1652,14 @@ fn assert_no_lifetimes(sig: &syn::Signature) -> Result<(), Diagnostic> { } impl<'ast> syn::visit::Visit<'ast> for Walk { - fn visit_lifetime(&mut self, i: &'ast syn::Lifetime) { - self.diagnostics.push(err_span!( - i, - "it is currently not sound to use lifetimes in function \ + fn visit_lifetime(&mut self, lifetime: &'ast syn::Lifetime) { + if lifetime.ident != "static" { + self.diagnostics.push(err_span!( + lifetime, + "it is currently not sound to use lifetimes in function \ signatures" - )); + )); + } } } let mut walk = Walk { diff --git a/crates/macro/ui-tests/invalid-imports-1.rs b/crates/macro/ui-tests/invalid-imports-1.rs new file mode 100644 index 00000000000..e73ab2162d3 --- /dev/null +++ b/crates/macro/ui-tests/invalid-imports-1.rs @@ -0,0 +1,41 @@ +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + type A; + + #[wasm_bindgen(method)] + fn f1(); + #[wasm_bindgen(method)] + fn f2(x: u32); + #[wasm_bindgen(method)] + fn f3(x: &&u32); + #[wasm_bindgen(method)] + fn f4(x: &foo::Bar); + #[wasm_bindgen(method)] + fn f4(x: &::Bar); + #[wasm_bindgen(method)] + fn f4(x: &Bar); + #[wasm_bindgen(method)] + fn f4(x: &dyn Fn(T)); + + #[wasm_bindgen(constructor)] + fn f(); + #[wasm_bindgen(constructor)] + fn f() -> ::Bar; + #[wasm_bindgen(constructor)] + fn f() -> &Bar; + + #[wasm_bindgen(catch)] + fn f() -> u32; + #[wasm_bindgen(catch)] + fn f() -> &u32; + #[wasm_bindgen(catch)] + fn f() -> Result<>; + #[wasm_bindgen(catch)] + fn f() -> Result<'a>; + #[wasm_bindgen(catch)] + fn f() -> Result<&'static u32>; +} + +fn main() {} diff --git a/crates/macro/ui-tests/invalid-imports-1.stderr b/crates/macro/ui-tests/invalid-imports-1.stderr new file mode 100644 index 00000000000..24367ed92a9 --- /dev/null +++ b/crates/macro/ui-tests/invalid-imports-1.stderr @@ -0,0 +1,65 @@ +error: imported methods must have at least one argument + --> ui-tests/invalid-imports-1.rs:8:5 + | +8 | fn f1(); + | ^^^^^^^^ + +error: first argument of method must be a shared reference + --> ui-tests/invalid-imports-1.rs:10:14 + | +10 | fn f2(x: u32); + | ^^^ + +error: first argument of method must be a path + --> ui-tests/invalid-imports-1.rs:12:15 + | +12 | fn f3(x: &&u32); + | ^^^^ + +error: paths with type parameters are not supported yet + --> ui-tests/invalid-imports-1.rs:18:15 + | +18 | fn f4(x: &Bar); + | ^^^^^^ + +error: first argument of method must be a path + --> ui-tests/invalid-imports-1.rs:20:15 + | +20 | fn f4(x: &dyn Fn(T)); + | ^^^^^^^^^ + +error: constructor returns must be bare types + --> ui-tests/invalid-imports-1.rs:23:5 + | +23 | fn f(); + | ^^^^^^^ + +error: return value of constructor must be a bare path + --> ui-tests/invalid-imports-1.rs:27:5 + | +27 | fn f() -> &Bar; + | ^^^^^^^^^^^^^^^ + +error: must be Result<...> + --> ui-tests/invalid-imports-1.rs:30:15 + | +30 | fn f() -> u32; + | ^^^ + +error: must be Result<...> + --> ui-tests/invalid-imports-1.rs:32:15 + | +32 | fn f() -> &u32; + | ^^^^ + +error: must have at least one generic parameter + --> ui-tests/invalid-imports-1.rs:34:15 + | +34 | fn f() -> Result<>; + | ^^^^^^^^ + +error: it is currently not sound to use lifetimes in function signatures + --> ui-tests/invalid-imports-1.rs:36:22 + | +36 | fn f() -> Result<'a>; + | ^^ diff --git a/crates/macro/ui-tests/invalid-imports-2.rs b/crates/macro/ui-tests/invalid-imports-2.rs new file mode 100644 index 00000000000..5cf461dec94 --- /dev/null +++ b/crates/macro/ui-tests/invalid-imports-2.rs @@ -0,0 +1,8 @@ +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + fn f() -> &'static u32; +} + +fn main() {} diff --git a/crates/macro/ui-tests/invalid-imports-2.stderr b/crates/macro/ui-tests/invalid-imports-2.stderr new file mode 100644 index 00000000000..aee456ba278 --- /dev/null +++ b/crates/macro/ui-tests/invalid-imports-2.stderr @@ -0,0 +1,5 @@ +error: cannot return references in #[wasm_bindgen] imports yet + --> ui-tests/invalid-imports-2.rs:5:15 + | +5 | fn f() -> &'static u32; + | ^^^^^^^^^^^^ diff --git a/crates/macro/ui-tests/invalid-imports.rs b/crates/macro/ui-tests/invalid-imports.rs index ceb7d33bf81..7fc9e74510a 100644 --- a/crates/macro/ui-tests/invalid-imports.rs +++ b/crates/macro/ui-tests/invalid-imports.rs @@ -36,6 +36,8 @@ extern "C" { fn f() -> Result<>; #[wasm_bindgen(catch)] fn f() -> Result<'a>; + #[wasm_bindgen(catch)] + fn f() -> Result<&'static u32>; } fn main() {} diff --git a/crates/macro/ui-tests/invalid-imports.stderr b/crates/macro/ui-tests/invalid-imports.stderr index c83c040e862..e1fbeb97ba2 100644 --- a/crates/macro/ui-tests/invalid-imports.stderr +++ b/crates/macro/ui-tests/invalid-imports.stderr @@ -1,9 +1,3 @@ -error: it is currently not sound to use lifetimes in function signatures - --> ui-tests/invalid-imports.rs:7:16 - | -7 | fn f() -> &'static u32; - | ^^^^^^^ - error: imported methods must have at least one argument --> ui-tests/invalid-imports.rs:10:5 | From 002307746ee2cbc35d9b904414c7fe6da6c78bbc Mon Sep 17 00:00:00 2001 From: Doug A Date: Wed, 28 Feb 2024 10:59:05 -0400 Subject: [PATCH 20/25] Update passing-rust-closures-to-js.md (#3859) --- guide/src/reference/passing-rust-closures-to-js.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/guide/src/reference/passing-rust-closures-to-js.md b/guide/src/reference/passing-rust-closures-to-js.md index f370154ab83..c44cfa8244e 100644 --- a/guide/src/reference/passing-rust-closures-to-js.md +++ b/guide/src/reference/passing-rust-closures-to-js.md @@ -63,12 +63,6 @@ return but the JavaScript closure still needs to be valid! For this scenario, you need the `Closure` type, which is defined in the `wasm_bindgen` crate, exported in `wasm_bindgen::prelude`, and represents a "long lived" closure. -The `Closure` type is currently behind a feature which needs to be enabled: - -```toml -[dependencies] -wasm-bindgen = {version = "^0.2", features = ["nightly"]} -``` The validity of the JavaScript closure is tied to the lifetime of the `Closure` in Rust. **Once a `Closure` is dropped, it will deallocate its internal memory From 0095fa73c9c6b38e12dcbea471a431c592b9c450 Mon Sep 17 00:00:00 2001 From: Lynn Date: Sat, 2 Mar 2024 08:58:19 +0100 Subject: [PATCH 21/25] Allow overriding headless test URL (#3861) --- CHANGELOG.md | 3 +++ crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0c5857479e..ec4b9281313 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ * Add support for `Option<*const T>`, `Option<*mut T>` and `NonNull`. [#3852](https://github.com/rustwasm/wasm-bindgen/pull/3852) +* Allow overriding the URL used for headless tests by setting `WASM_BINDGEN_TEST_ADDRESS`. + [#3861](https://github.com/rustwasm/wasm-bindgen/pull/3861) + ### Changed * Allow using `'static` lifetimes in functions marked with `#[wasm_bindgen]`. This does not allow references where they were not allowed before! diff --git a/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs b/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs index 7edff27648d..08d9b7fc85c 100644 --- a/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs +++ b/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs @@ -121,7 +121,8 @@ pub fn run(server: &SocketAddr, shell: &Shell, timeout: u64) -> Result<(), Error // Visit our local server to open up the page that runs tests, and then get // some handles to objects on the page which we'll be scraping output from. - let url = format!("http://{}", server); + let url = + std::env::var("WASM_BINDGEN_TEST_ADDRESS").unwrap_or_else(|_| format!("http://{}", server)); shell.status(&format!("Visiting {}...", url)); client.goto(&id, &url)?; shell.status("Loading page elements..."); From 983ec579a3dfca7ccb4f63f1f1adaa48f8bb3bec Mon Sep 17 00:00:00 2001 From: daxpedda Date: Sat, 2 Mar 2024 09:11:13 +0100 Subject: [PATCH 22/25] Add `NonNull` as parameter (#3857) --- CHANGELOG.md | 1 + crates/cli-support/src/js/binding.rs | 11 +++++++++++ crates/cli-support/src/js/mod.rs | 13 +++++++++++++ crates/cli-support/src/wit/incoming.rs | 6 +++++- crates/cli-support/src/wit/standard.rs | 1 + guide/src/reference/types/non-null.md | 2 +- src/convert/impls.rs | 12 ++++++++++-- tests/wasm/simple.js | 3 +++ tests/wasm/simple.rs | 5 +++++ 9 files changed, 50 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec4b9281313..b4c87dd8df4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * Add support for `Option<*const T>`, `Option<*mut T>` and `NonNull`. [#3852](https://github.com/rustwasm/wasm-bindgen/pull/3852) + [#3857](https://github.com/rustwasm/wasm-bindgen/pull/3857) * Allow overriding the URL used for headless tests by setting `WASM_BINDGEN_TEST_ADDRESS`. [#3861](https://github.com/rustwasm/wasm-bindgen/pull/3861) diff --git a/crates/cli-support/src/js/binding.rs b/crates/cli-support/src/js/binding.rs index f186038bde9..4c27d7584e4 100644 --- a/crates/cli-support/src/js/binding.rs +++ b/crates/cli-support/src/js/binding.rs @@ -497,6 +497,11 @@ impl<'a, 'b> JsBuilder<'a, 'b> { self.prelude("}"); } + fn assert_non_null(&mut self, arg: &str) { + self.cx.expose_assert_non_null(); + self.prelude(&format!("_assertNonNull({});", arg)); + } + fn assert_optional_bigint(&mut self, arg: &str) { if !self.cx.config.debug { return; @@ -1218,6 +1223,12 @@ fn instruction( js.push(format!("{0} === {1} ? undefined : {0}", val, hole)); } + Instruction::I32FromNonNull => { + let val = js.pop(); + js.assert_non_null(&val); + js.push(val); + } + Instruction::I32FromOptionNonNull => { let val = js.pop(); js.cx.expose_is_like_none(); diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 2e7744874b4..9a3899c9266 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -2103,6 +2103,19 @@ impl<'a> Context<'a> { ); } + fn expose_assert_non_null(&mut self) { + if !self.should_write_global("assert_non_null") { + return; + } + self.global( + " + function _assertNonNull(n) { + if (typeof(n) !== 'number' || n === 0) throw new Error(`expected a number argument that is not 0, found ${n}`); + } + ", + ); + } + fn expose_make_mut_closure(&mut self) -> Result<(), Error> { if !self.should_write_global("make_mut_closure") { return Ok(()); diff --git a/crates/cli-support/src/wit/incoming.rs b/crates/cli-support/src/wit/incoming.rs index 084e939e624..83bd3b32b16 100644 --- a/crates/cli-support/src/wit/incoming.rs +++ b/crates/cli-support/src/wit/incoming.rs @@ -156,7 +156,11 @@ impl InstructionBuilder<'_, '_> { // Largely synthetic and can't show up Descriptor::ClampedU8 => unreachable!(), - Descriptor::NonNull => unimplemented!("converting `NonNull` from Wasm to Rust is not implemented"), + Descriptor::NonNull => self.instruction( + &[AdapterType::NonNull], + Instruction::I32FromNonNull, + &[AdapterType::I32], + ), } Ok(()) } diff --git a/crates/cli-support/src/wit/standard.rs b/crates/cli-support/src/wit/standard.rs index d9a86b81a9d..104a297abfa 100644 --- a/crates/cli-support/src/wit/standard.rs +++ b/crates/cli-support/src/wit/standard.rs @@ -311,6 +311,7 @@ pub enum Instruction { }, I32FromOptionNonNull, OptionNonNullFromI32, + I32FromNonNull, } impl AdapterType { diff --git a/guide/src/reference/types/non-null.md b/guide/src/reference/types/non-null.md index 8e1b9d17f25..33c2e9b0f16 100644 --- a/guide/src/reference/types/non-null.md +++ b/guide/src/reference/types/non-null.md @@ -2,7 +2,7 @@ | `T` parameter | `&T` parameter | `&mut T` parameter | `T` return value | `Option` parameter | `Option` return value | JavaScript representation | |:---:|:---:|:---:|:---:|:---:|:---:|:---:| -| No | No | No | Yes | Yes | Yes | A JavaScript number value | +| Yes | No | No | Yes | Yes | Yes | A JavaScript number value | ## Example Rust Usage diff --git a/src/convert/impls.rs b/src/convert/impls.rs index 64a40925c84..8d2bf4baf6a 100644 --- a/src/convert/impls.rs +++ b/src/convert/impls.rs @@ -294,12 +294,20 @@ impl OptionIntoWasmAbi for NonNull { } } -impl FromWasmAbi for Option> { +impl FromWasmAbi for NonNull { type Abi = u32; #[inline] unsafe fn from_abi(js: Self::Abi) -> Self { - NonNull::new(js as *mut T) + // SAFETY: Checked in bindings. + NonNull::new_unchecked(js as *mut T) + } +} + +impl OptionFromWasmAbi for NonNull { + #[inline] + fn is_none(js: &u32) -> bool { + *js == 0 } } diff --git a/tests/wasm/simple.js b/tests/wasm/simple.js index bcac3262f49..f66c77479f7 100644 --- a/tests/wasm/simple.js +++ b/tests/wasm/simple.js @@ -139,6 +139,9 @@ exports.test_raw_pointers = function() { }; exports.test_non_null = function() { + assert.strictEqual(wasm.simple_nonnull_work(wasm.simple_return_non_null()), 42); + assert.throws(() => wasm.simple_nonnull_work(0), /expected a number argument that is not 0/); + assert.strictEqual(wasm.simple_option_nonnull_work(0), undefined); assert.strictEqual(wasm.simple_option_nonnull_work(null), undefined); assert.strictEqual(wasm.simple_option_nonnull_work(undefined), undefined); diff --git a/tests/wasm/simple.rs b/tests/wasm/simple.rs index b6bab8c3874..fdef34c68fd 100644 --- a/tests/wasm/simple.rs +++ b/tests/wasm/simple.rs @@ -113,6 +113,11 @@ pub fn simple_return_option_non_null(value: u32) -> Option> { Some(NonNull::from(Box::leak(Box::new(value)))) } +#[wasm_bindgen] +pub unsafe fn simple_nonnull_work(a: NonNull) -> u32 { + *Box::from_raw(a.as_ptr()) +} + #[wasm_bindgen] pub unsafe fn simple_option_nonnull_work(a: Option>) -> Option { a.map(|ptr| *Box::from_raw(ptr.as_ptr())) From 807bdb48e4d6af82fdb894c0b702e869458591a8 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Sat, 2 Mar 2024 11:55:19 +0100 Subject: [PATCH 23/25] Revert "Allow using `'static` lifetimes in functions (#3856)" (#3865) --- CHANGELOG.md | 5 -- crates/macro-support/src/parser.rs | 12 ++-- crates/macro/ui-tests/invalid-imports-1.rs | 41 ------------ .../macro/ui-tests/invalid-imports-1.stderr | 65 ------------------- crates/macro/ui-tests/invalid-imports-2.rs | 8 --- .../macro/ui-tests/invalid-imports-2.stderr | 5 -- crates/macro/ui-tests/invalid-imports.rs | 2 - crates/macro/ui-tests/invalid-imports.stderr | 6 ++ 8 files changed, 11 insertions(+), 133 deletions(-) delete mode 100644 crates/macro/ui-tests/invalid-imports-1.rs delete mode 100644 crates/macro/ui-tests/invalid-imports-1.stderr delete mode 100644 crates/macro/ui-tests/invalid-imports-2.rs delete mode 100644 crates/macro/ui-tests/invalid-imports-2.stderr diff --git a/CHANGELOG.md b/CHANGELOG.md index b4c87dd8df4..8004077535b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,11 +21,6 @@ * Allow overriding the URL used for headless tests by setting `WASM_BINDGEN_TEST_ADDRESS`. [#3861](https://github.com/rustwasm/wasm-bindgen/pull/3861) -### Changed - -* Allow using `'static` lifetimes in functions marked with `#[wasm_bindgen]`. This does not allow references where they were not allowed before! - [#3856](https://github.com/rustwasm/wasm-bindgen/pull/3856) - ### Fixed * Make .wasm output deterministic when using `--reference-types`. diff --git a/crates/macro-support/src/parser.rs b/crates/macro-support/src/parser.rs index 5778eb50d41..eee4f66e95d 100644 --- a/crates/macro-support/src/parser.rs +++ b/crates/macro-support/src/parser.rs @@ -1652,14 +1652,12 @@ fn assert_no_lifetimes(sig: &syn::Signature) -> Result<(), Diagnostic> { } impl<'ast> syn::visit::Visit<'ast> for Walk { - fn visit_lifetime(&mut self, lifetime: &'ast syn::Lifetime) { - if lifetime.ident != "static" { - self.diagnostics.push(err_span!( - lifetime, - "it is currently not sound to use lifetimes in function \ + fn visit_lifetime(&mut self, i: &'ast syn::Lifetime) { + self.diagnostics.push(err_span!( + i, + "it is currently not sound to use lifetimes in function \ signatures" - )); - } + )); } } let mut walk = Walk { diff --git a/crates/macro/ui-tests/invalid-imports-1.rs b/crates/macro/ui-tests/invalid-imports-1.rs deleted file mode 100644 index e73ab2162d3..00000000000 --- a/crates/macro/ui-tests/invalid-imports-1.rs +++ /dev/null @@ -1,41 +0,0 @@ -use wasm_bindgen::prelude::*; - -#[wasm_bindgen] -extern "C" { - type A; - - #[wasm_bindgen(method)] - fn f1(); - #[wasm_bindgen(method)] - fn f2(x: u32); - #[wasm_bindgen(method)] - fn f3(x: &&u32); - #[wasm_bindgen(method)] - fn f4(x: &foo::Bar); - #[wasm_bindgen(method)] - fn f4(x: &::Bar); - #[wasm_bindgen(method)] - fn f4(x: &Bar); - #[wasm_bindgen(method)] - fn f4(x: &dyn Fn(T)); - - #[wasm_bindgen(constructor)] - fn f(); - #[wasm_bindgen(constructor)] - fn f() -> ::Bar; - #[wasm_bindgen(constructor)] - fn f() -> &Bar; - - #[wasm_bindgen(catch)] - fn f() -> u32; - #[wasm_bindgen(catch)] - fn f() -> &u32; - #[wasm_bindgen(catch)] - fn f() -> Result<>; - #[wasm_bindgen(catch)] - fn f() -> Result<'a>; - #[wasm_bindgen(catch)] - fn f() -> Result<&'static u32>; -} - -fn main() {} diff --git a/crates/macro/ui-tests/invalid-imports-1.stderr b/crates/macro/ui-tests/invalid-imports-1.stderr deleted file mode 100644 index 24367ed92a9..00000000000 --- a/crates/macro/ui-tests/invalid-imports-1.stderr +++ /dev/null @@ -1,65 +0,0 @@ -error: imported methods must have at least one argument - --> ui-tests/invalid-imports-1.rs:8:5 - | -8 | fn f1(); - | ^^^^^^^^ - -error: first argument of method must be a shared reference - --> ui-tests/invalid-imports-1.rs:10:14 - | -10 | fn f2(x: u32); - | ^^^ - -error: first argument of method must be a path - --> ui-tests/invalid-imports-1.rs:12:15 - | -12 | fn f3(x: &&u32); - | ^^^^ - -error: paths with type parameters are not supported yet - --> ui-tests/invalid-imports-1.rs:18:15 - | -18 | fn f4(x: &Bar); - | ^^^^^^ - -error: first argument of method must be a path - --> ui-tests/invalid-imports-1.rs:20:15 - | -20 | fn f4(x: &dyn Fn(T)); - | ^^^^^^^^^ - -error: constructor returns must be bare types - --> ui-tests/invalid-imports-1.rs:23:5 - | -23 | fn f(); - | ^^^^^^^ - -error: return value of constructor must be a bare path - --> ui-tests/invalid-imports-1.rs:27:5 - | -27 | fn f() -> &Bar; - | ^^^^^^^^^^^^^^^ - -error: must be Result<...> - --> ui-tests/invalid-imports-1.rs:30:15 - | -30 | fn f() -> u32; - | ^^^ - -error: must be Result<...> - --> ui-tests/invalid-imports-1.rs:32:15 - | -32 | fn f() -> &u32; - | ^^^^ - -error: must have at least one generic parameter - --> ui-tests/invalid-imports-1.rs:34:15 - | -34 | fn f() -> Result<>; - | ^^^^^^^^ - -error: it is currently not sound to use lifetimes in function signatures - --> ui-tests/invalid-imports-1.rs:36:22 - | -36 | fn f() -> Result<'a>; - | ^^ diff --git a/crates/macro/ui-tests/invalid-imports-2.rs b/crates/macro/ui-tests/invalid-imports-2.rs deleted file mode 100644 index 5cf461dec94..00000000000 --- a/crates/macro/ui-tests/invalid-imports-2.rs +++ /dev/null @@ -1,8 +0,0 @@ -use wasm_bindgen::prelude::*; - -#[wasm_bindgen] -extern "C" { - fn f() -> &'static u32; -} - -fn main() {} diff --git a/crates/macro/ui-tests/invalid-imports-2.stderr b/crates/macro/ui-tests/invalid-imports-2.stderr deleted file mode 100644 index aee456ba278..00000000000 --- a/crates/macro/ui-tests/invalid-imports-2.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: cannot return references in #[wasm_bindgen] imports yet - --> ui-tests/invalid-imports-2.rs:5:15 - | -5 | fn f() -> &'static u32; - | ^^^^^^^^^^^^ diff --git a/crates/macro/ui-tests/invalid-imports.rs b/crates/macro/ui-tests/invalid-imports.rs index 7fc9e74510a..ceb7d33bf81 100644 --- a/crates/macro/ui-tests/invalid-imports.rs +++ b/crates/macro/ui-tests/invalid-imports.rs @@ -36,8 +36,6 @@ extern "C" { fn f() -> Result<>; #[wasm_bindgen(catch)] fn f() -> Result<'a>; - #[wasm_bindgen(catch)] - fn f() -> Result<&'static u32>; } fn main() {} diff --git a/crates/macro/ui-tests/invalid-imports.stderr b/crates/macro/ui-tests/invalid-imports.stderr index e1fbeb97ba2..c83c040e862 100644 --- a/crates/macro/ui-tests/invalid-imports.stderr +++ b/crates/macro/ui-tests/invalid-imports.stderr @@ -1,3 +1,9 @@ +error: it is currently not sound to use lifetimes in function signatures + --> ui-tests/invalid-imports.rs:7:16 + | +7 | fn f() -> &'static u32; + | ^^^^^^^ + error: imported methods must have at least one argument --> ui-tests/invalid-imports.rs:10:5 | From 8e992dc906f8cd5ef38479c22c64d4967d8399cf Mon Sep 17 00:00:00 2001 From: daxpedda Date: Mon, 4 Mar 2024 08:51:38 +0100 Subject: [PATCH 24/25] Don't allow invalid Unicode scalar values in `char` (#3866) --- CHANGELOG.md | 3 +++ crates/cli-support/src/js/binding.rs | 22 +++++++++++++++++++--- crates/cli-support/src/js/mod.rs | 13 +++++++++++++ src/convert/impls.rs | 1 + tests/wasm/char.js | 10 ++++++++++ tests/wasm/char.rs | 5 +++++ 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8004077535b..324e8faaa4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,9 @@ * Make .wasm output deterministic when using `--reference-types`. [#3851](https://github.com/rustwasm/wasm-bindgen/pull/3851) +* Don't allow invalid Unicode scalar values in `char`. + [#3866](https://github.com/rustwasm/wasm-bindgen/pull/3866) + -------------------------------------------------------------------------------- ## [0.2.91](https://github.com/rustwasm/wasm-bindgen/compare/0.2.90...0.2.91) diff --git a/crates/cli-support/src/js/binding.rs b/crates/cli-support/src/js/binding.rs index 4c27d7584e4..ebe4e966c43 100644 --- a/crates/cli-support/src/js/binding.rs +++ b/crates/cli-support/src/js/binding.rs @@ -502,6 +502,11 @@ impl<'a, 'b> JsBuilder<'a, 'b> { self.prelude(&format!("_assertNonNull({});", arg)); } + fn assert_char(&mut self, arg: &str) { + self.cx.expose_assert_char(); + self.prelude(&format!("_assertChar({});", arg)); + } + fn assert_optional_bigint(&mut self, arg: &str) { if !self.cx.config.debug { return; @@ -739,7 +744,11 @@ fn instruction( Instruction::I32FromStringFirstChar => { let val = js.pop(); - js.push(format!("{}.codePointAt(0)", val)); + let i = js.tmp(); + js.prelude(&format!("const char{i} = {val}.codePointAt(0);")); + let val = format!("char{i}"); + js.assert_char(&val); + js.push(val); } Instruction::I32FromExternrefOwned => { @@ -816,11 +825,18 @@ fn instruction( Instruction::I32FromOptionChar => { let val = js.pop(); + let i = js.tmp(); js.cx.expose_is_like_none(); - js.push(format!( - "isLikeNone({0}) ? 0xFFFFFF : {0}.codePointAt(0)", + js.prelude(&format!( + "const char{i} = isLikeNone({0}) ? 0xFFFFFF : {0}.codePointAt(0);", val )); + let val = format!("char{i}"); + js.cx.expose_assert_char(); + js.prelude(&format!( + "if ({val} !== 0xFFFFFF) {{ _assertChar({val}); }}" + )); + js.push(val); } Instruction::I32FromOptionEnum { hole } => { diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 9a3899c9266..35bba115fdc 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -2116,6 +2116,19 @@ impl<'a> Context<'a> { ); } + fn expose_assert_char(&mut self) { + if !self.should_write_global("assert_char") { + return; + } + self.global( + " + function _assertChar(c) { + if (typeof(c) === 'number' && (c >= 0x110000 || (c >= 0xD800 && c < 0xE000))) throw new Error(`expected a valid Unicode scalar value, found ${c}`); + } + ", + ); + } + fn expose_make_mut_closure(&mut self) -> Result<(), Error> { if !self.should_write_global("make_mut_closure") { return Ok(()); diff --git a/src/convert/impls.rs b/src/convert/impls.rs index 8d2bf4baf6a..4ecef7821ef 100644 --- a/src/convert/impls.rs +++ b/src/convert/impls.rs @@ -188,6 +188,7 @@ impl FromWasmAbi for char { #[inline] unsafe fn from_abi(js: u32) -> char { + // SAFETY: Checked in bindings. char::from_u32_unchecked(js) } } diff --git a/tests/wasm/char.js b/tests/wasm/char.js index d145333e381..b1ee622808f 100644 --- a/tests/wasm/char.js +++ b/tests/wasm/char.js @@ -6,6 +6,7 @@ exports.js_identity = a => a; exports.js_works = () => { assert.strictEqual(wasm.letter(), 'a'); assert.strictEqual(wasm.face(), '😀'); + assert.strictEqual(wasm.rust_identity(''), '\u0000'); assert.strictEqual(wasm.rust_identity('Ղ'), 'Ղ'); assert.strictEqual(wasm.rust_identity('ҝ'), 'ҝ'); assert.strictEqual(wasm.rust_identity('Δ'), 'Δ'); @@ -14,4 +15,13 @@ exports.js_works = () => { assert.strictEqual(wasm.rust_js_identity('㊻'), '㊻'); wasm.rust_letter('a'); wasm.rust_face('😀'); + + assert.strictEqual(wasm.rust_option_identity(undefined), undefined); + assert.strictEqual(wasm.rust_option_identity(null), undefined); + assert.strictEqual(wasm.rust_option_identity(''), '\u0000'); + assert.strictEqual(wasm.rust_option_identity('\u0000'), '\u0000'); + + assert.throws(() => wasm.rust_identity(55357), /c.codePointAt is not a function/); + assert.throws(() => wasm.rust_identity('\uD83D'), /expected a valid Unicode scalar value, found 55357/); + assert.throws(() => wasm.rust_option_identity('\uD83D'), /expected a valid Unicode scalar value, found 55357/); }; diff --git a/tests/wasm/char.rs b/tests/wasm/char.rs index f852b8d8145..d680a1cae43 100644 --- a/tests/wasm/char.rs +++ b/tests/wasm/char.rs @@ -12,6 +12,11 @@ pub fn rust_identity(c: char) -> char { c } +#[wasm_bindgen] +pub fn rust_option_identity(c: Option) -> Option { + c +} + #[wasm_bindgen] pub fn rust_js_identity(c: char) -> char { js_identity(c) From 2a4a4936238cf11e863353e410f453c94e21c7dd Mon Sep 17 00:00:00 2001 From: daxpedda Date: Mon, 4 Mar 2024 11:25:46 +0100 Subject: [PATCH 25/25] Prepare v0.2.92 release (#3869) --- CHANGELOG.md | 4 +++- Cargo.toml | 10 +++++----- crates/backend/Cargo.toml | 4 ++-- crates/cli-support/Cargo.toml | 14 +++++++------- crates/cli/Cargo.toml | 6 +++--- crates/externref-xform/Cargo.toml | 2 +- crates/futures/Cargo.toml | 8 ++++---- crates/js-sys/Cargo.toml | 10 +++++----- crates/macro-support/Cargo.toml | 6 +++--- crates/macro/Cargo.toml | 10 +++++----- crates/multi-value-xform/Cargo.toml | 2 +- crates/shared/Cargo.toml | 2 +- crates/test-macro/Cargo.toml | 2 +- crates/test/Cargo.toml | 10 +++++----- crates/threads-xform/Cargo.toml | 4 ++-- crates/wasm-conventions/Cargo.toml | 2 +- crates/wasm-interpreter/Cargo.toml | 4 ++-- crates/web-sys/Cargo.toml | 10 +++++----- crates/webidl/Cargo.toml | 2 +- examples/add/Cargo.toml | 2 +- examples/canvas/Cargo.toml | 4 ++-- examples/char/Cargo.toml | 2 +- examples/closures/Cargo.toml | 4 ++-- examples/console_log/Cargo.toml | 4 ++-- examples/deno/Cargo.toml | 2 +- examples/dom/Cargo.toml | 2 +- examples/duck-typed-interfaces/Cargo.toml | 2 +- examples/fetch/Cargo.toml | 6 +++--- examples/guide-supported-types-examples/Cargo.toml | 4 ++-- examples/hello_world/Cargo.toml | 2 +- examples/import_js/crate/Cargo.toml | 2 +- examples/julia_set/Cargo.toml | 2 +- examples/paint/Cargo.toml | 4 ++-- examples/performance/Cargo.toml | 2 +- examples/raytrace-parallel/Cargo.toml | 6 +++--- examples/request-animation-frame/Cargo.toml | 2 +- examples/synchronous-instantiation/Cargo.toml | 2 +- examples/todomvc/Cargo.toml | 4 ++-- examples/wasm-audio-worklet/Cargo.toml | 6 +++--- examples/wasm-in-wasm-imports/Cargo.toml | 6 +++--- examples/wasm-in-wasm/Cargo.toml | 6 +++--- examples/wasm-in-web-worker/Cargo.toml | 2 +- examples/wasm2js/Cargo.toml | 2 +- examples/weather_report/Cargo.toml | 2 +- examples/webaudio/Cargo.toml | 2 +- examples/webgl/Cargo.toml | 4 ++-- examples/webrtc_datachannel/Cargo.toml | 4 ++-- examples/websockets/Cargo.toml | 2 +- examples/webxr/Cargo.toml | 6 +++--- examples/without-a-bundler/Cargo.toml | 2 +- 50 files changed, 108 insertions(+), 106 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 324e8faaa4f..b6c36b45dde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # `wasm-bindgen` Change Log -------------------------------------------------------------------------------- -## Unreleased +## [0.2.92](https://github.com/rustwasm/wasm-bindgen/compare/0.2.91...0.2.92) + +Released 2024-03-04 ### Added diff --git a/Cargo.toml b/Cargo.toml index 08cd2dfaa8e..c06934617d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen Developers"] license = "MIT OR Apache-2.0" readme = "README.md" @@ -42,15 +42,15 @@ xxx_debug_only_print_generated_code = [ ] [dependencies] -wasm-bindgen-macro = { path = "crates/macro", version = "=0.2.91" } +wasm-bindgen-macro = { path = "crates/macro", version = "=0.2.92" } serde = { version = "1.0", optional = true } serde_json = { version = "1.0", optional = true } cfg-if = "1.0.0" [target.'cfg(target_arch = "wasm32")'.dev-dependencies] -js-sys = { path = 'crates/js-sys', version = '0.3.68' } -wasm-bindgen-test = { path = 'crates/test', version = '=0.3.41' } -wasm-bindgen-futures = { path = 'crates/futures', version = '=0.4.41' } +js-sys = { path = 'crates/js-sys', version = '0.3.69' } +wasm-bindgen-test = { path = 'crates/test', version = '=0.3.42' } +wasm-bindgen-futures = { path = 'crates/futures', version = '=0.4.42' } serde_derive = "1.0" wasm-bindgen-test-crate-a = { path = 'tests/crates/a', version = '0.1' } wasm-bindgen-test-crate-b = { path = 'tests/crates/b', version = '0.1' } diff --git a/crates/backend/Cargo.toml b/crates/backend/Cargo.toml index b2dccbbbc4a..3e8a4e5f563 100644 --- a/crates/backend/Cargo.toml +++ b/crates/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-backend" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/backend" @@ -23,4 +23,4 @@ once_cell = "1.12" proc-macro2 = "1.0" quote = '1.0' syn = { version = '2.0', features = ['full'] } -wasm-bindgen-shared = { path = "../shared", version = "=0.2.91" } +wasm-bindgen-shared = { path = "../shared", version = "=0.2.92" } diff --git a/crates/cli-support/Cargo.toml b/crates/cli-support/Cargo.toml index ec12dc3dbdc..48bb44f93f1 100644 --- a/crates/cli-support/Cargo.toml +++ b/crates/cli-support/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-cli-support" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/cli-support" @@ -20,10 +20,10 @@ rustc-demangle = "0.1.13" serde_json = "1.0" tempfile = "3.0" walrus = "0.20.2" -wasm-bindgen-externref-xform = { path = '../externref-xform', version = '=0.2.91' } -wasm-bindgen-multi-value-xform = { path = '../multi-value-xform', version = '=0.2.91' } -wasm-bindgen-shared = { path = "../shared", version = '=0.2.91' } -wasm-bindgen-threads-xform = { path = '../threads-xform', version = '=0.2.91' } -wasm-bindgen-wasm-conventions = { path = '../wasm-conventions', version = '=0.2.91' } -wasm-bindgen-wasm-interpreter = { path = "../wasm-interpreter", version = '=0.2.91' } +wasm-bindgen-externref-xform = { path = '../externref-xform', version = '=0.2.92' } +wasm-bindgen-multi-value-xform = { path = '../multi-value-xform', version = '=0.2.92' } +wasm-bindgen-shared = { path = "../shared", version = '=0.2.92' } +wasm-bindgen-threads-xform = { path = '../threads-xform', version = '=0.2.92' } +wasm-bindgen-wasm-conventions = { path = '../wasm-conventions', version = '=0.2.92' } +wasm-bindgen-wasm-interpreter = { path = "../wasm-interpreter", version = '=0.2.92' } unicode-ident = "1.0.5" diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 81f27693583..8872c8b2797 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-cli" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/cli" @@ -34,8 +34,8 @@ ureq = { version = "2.7", default-features = false, features = [ "gzip", ] } walrus = { version = "0.20.2", features = ['parallel'] } -wasm-bindgen-cli-support = { path = "../cli-support", version = "=0.2.91" } -wasm-bindgen-shared = { path = "../shared", version = "=0.2.91" } +wasm-bindgen-cli-support = { path = "../cli-support", version = "=0.2.92" } +wasm-bindgen-shared = { path = "../shared", version = "=0.2.92" } [dev-dependencies] assert_cmd = "1.0" diff --git a/crates/externref-xform/Cargo.toml b/crates/externref-xform/Cargo.toml index 0b5f80f3779..eb09f087eca 100644 --- a/crates/externref-xform/Cargo.toml +++ b/crates/externref-xform/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-externref-xform" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/externref-xform" diff --git a/crates/futures/Cargo.toml b/crates/futures/Cargo.toml index 860e6d741db..eb389cdba8c 100644 --- a/crates/futures/Cargo.toml +++ b/crates/futures/Cargo.toml @@ -7,14 +7,14 @@ license = "MIT OR Apache-2.0" name = "wasm-bindgen-futures" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/futures" readme = "./README.md" -version = "0.4.41" +version = "0.4.42" edition = "2018" rust-version = "1.57" [dependencies] cfg-if = "1.0.0" -js-sys = { path = "../js-sys", version = '0.3.68' } -wasm-bindgen = { path = "../..", version = '0.2.91' } +js-sys = { path = "../js-sys", version = '0.3.69' } +wasm-bindgen = { path = "../..", version = '0.2.92' } futures-core = { version = '0.3.8', default-features = false, optional = true } [features] @@ -29,6 +29,6 @@ features = [ ] [target.'cfg(target_arch = "wasm32")'.dev-dependencies] -wasm-bindgen-test = { path = '../test', version = '0.3.41' } +wasm-bindgen-test = { path = '../test', version = '0.3.42' } futures-channel-preview = { version = "0.3.0-alpha.18" } futures-lite = { version = "1.11.3", default-features = false } diff --git a/crates/js-sys/Cargo.toml b/crates/js-sys/Cargo.toml index ca5f849f85b..a8c476856bd 100644 --- a/crates/js-sys/Cargo.toml +++ b/crates/js-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "js-sys" -version = "0.3.68" +version = "0.3.69" authors = ["The wasm-bindgen Developers"] readme = "./README.md" categories = ["wasm"] @@ -20,9 +20,9 @@ test = false doctest = false [dependencies] -wasm-bindgen = { path = "../..", version = "0.2.91" } +wasm-bindgen = { path = "../..", version = "0.2.92" } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] -wasm-bindgen-test = { path = '../test', version = '=0.3.41' } -wasm-bindgen-futures = { path = '../futures', version = '0.4.41' } -web-sys = { path = "../web-sys", version = "0.3.68", features = ["Headers", "Response", "ResponseInit"] } +wasm-bindgen-test = { path = '../test', version = '=0.3.42' } +wasm-bindgen-futures = { path = '../futures', version = '0.4.42' } +web-sys = { path = "../web-sys", version = "0.3.69", features = ["Headers", "Response", "ResponseInit"] } diff --git a/crates/macro-support/Cargo.toml b/crates/macro-support/Cargo.toml index 6a13463b9be..e809478d699 100644 --- a/crates/macro-support/Cargo.toml +++ b/crates/macro-support/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-macro-support" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/macro-support" @@ -21,5 +21,5 @@ strict-macro = [] syn = { version = '2.0', features = ['visit', 'full'] } quote = '1.0' proc-macro2 = "1.0" -wasm-bindgen-backend = { path = "../backend", version = "=0.2.91" } -wasm-bindgen-shared = { path = "../shared", version = "=0.2.91" } +wasm-bindgen-backend = { path = "../backend", version = "=0.2.92" } +wasm-bindgen-shared = { path = "../shared", version = "=0.2.92" } diff --git a/crates/macro/Cargo.toml b/crates/macro/Cargo.toml index 46ceac29a36..5aead30add2 100644 --- a/crates/macro/Cargo.toml +++ b/crates/macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-macro" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/macro" @@ -21,11 +21,11 @@ xxx_debug_only_print_generated_code = [] strict-macro = ["wasm-bindgen-macro-support/strict-macro"] [dependencies] -wasm-bindgen-macro-support = { path = "../macro-support", version = "=0.2.91" } +wasm-bindgen-macro-support = { path = "../macro-support", version = "=0.2.92" } quote = "1.0" [dev-dependencies] trybuild = "1.0" -wasm-bindgen = { path = "../..", version = "0.2.91" } -wasm-bindgen-futures = { path = "../futures", version = "0.4.41" } -web-sys = { path = "../web-sys", version = "0.3.68", features = ["Worker"] } +wasm-bindgen = { path = "../..", version = "0.2.92" } +wasm-bindgen-futures = { path = "../futures", version = "0.4.42" } +web-sys = { path = "../web-sys", version = "0.3.69", features = ["Worker"] } diff --git a/crates/multi-value-xform/Cargo.toml b/crates/multi-value-xform/Cargo.toml index dd6a7a0e6f4..a363d87760e 100644 --- a/crates/multi-value-xform/Cargo.toml +++ b/crates/multi-value-xform/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-multi-value-xform" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/multi-value-xform" diff --git a/crates/shared/Cargo.toml b/crates/shared/Cargo.toml index a5d90fcda60..ae438cf53a9 100644 --- a/crates/shared/Cargo.toml +++ b/crates/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-shared" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/shared" diff --git a/crates/test-macro/Cargo.toml b/crates/test-macro/Cargo.toml index 4dccf097327..99c62981876 100644 --- a/crates/test-macro/Cargo.toml +++ b/crates/test-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-test-macro" -version = "0.3.41" +version = "0.3.42" authors = ["The wasm-bindgen Developers"] description = "Internal testing macro for wasm-bindgen" license = "MIT OR Apache-2.0" diff --git a/crates/test/Cargo.toml b/crates/test/Cargo.toml index d7f5dc0794a..001e6814ea0 100644 --- a/crates/test/Cargo.toml +++ b/crates/test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-test" -version = "0.3.41" +version = "0.3.42" authors = ["The wasm-bindgen Developers"] description = "Internal testing crate for wasm-bindgen" license = "MIT OR Apache-2.0" @@ -10,11 +10,11 @@ rust-version = "1.57" [dependencies] console_error_panic_hook = '0.1' -js-sys = { path = '../js-sys', version = '0.3.68' } +js-sys = { path = '../js-sys', version = '0.3.69' } scoped-tls = "1.0" -wasm-bindgen = { path = '../..', version = '0.2.91' } -wasm-bindgen-futures = { path = '../futures', version = '0.4.41' } -wasm-bindgen-test-macro = { path = '../test-macro', version = '=0.3.41' } +wasm-bindgen = { path = '../..', version = '0.2.92' } +wasm-bindgen-futures = { path = '../futures', version = '0.4.42' } +wasm-bindgen-test-macro = { path = '../test-macro', version = '=0.3.42' } gg-alloc = { version = "1.0", optional = true } [lib] diff --git a/crates/threads-xform/Cargo.toml b/crates/threads-xform/Cargo.toml index e55df83bfdb..14edd58207e 100644 --- a/crates/threads-xform/Cargo.toml +++ b/crates/threads-xform/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-threads-xform" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/threads-xform" @@ -15,7 +15,7 @@ rust-version = "1.57" [dependencies] anyhow = "1.0" walrus = "0.20.2" -wasm-bindgen-wasm-conventions = { path = "../wasm-conventions", version = "=0.2.91" } +wasm-bindgen-wasm-conventions = { path = "../wasm-conventions", version = "=0.2.92" } [dev-dependencies] rayon = "1.0" diff --git a/crates/wasm-conventions/Cargo.toml b/crates/wasm-conventions/Cargo.toml index aee55476b0c..02bfc3d762a 100644 --- a/crates/wasm-conventions/Cargo.toml +++ b/crates/wasm-conventions/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-wasm-conventions" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/wasm-conventions" diff --git a/crates/wasm-interpreter/Cargo.toml b/crates/wasm-interpreter/Cargo.toml index 5f53464da0f..879602ec935 100644 --- a/crates/wasm-interpreter/Cargo.toml +++ b/crates/wasm-interpreter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-wasm-interpreter" -version = "0.2.91" +version = "0.2.92" authors = ["The wasm-bindgen Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/main/crates/wasm-interpreter" @@ -16,7 +16,7 @@ rust-version = "1.57" anyhow = "1.0" log = "0.4" walrus = "0.20.2" -wasm-bindgen-wasm-conventions = { path = "../wasm-conventions", version = "0.2.91" } +wasm-bindgen-wasm-conventions = { path = "../wasm-conventions", version = "0.2.92" } [dev-dependencies] tempfile = "3" diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index 66ce7b01134..b1ef8a63c00 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "web-sys" -version = "0.3.68" +version = "0.3.69" authors = ["The wasm-bindgen Developers"] readme = "./README.md" homepage = "https://rustwasm.github.io/wasm-bindgen/web-sys/index.html" @@ -22,12 +22,12 @@ doctest = false test = false [dependencies] -wasm-bindgen = { path = "../..", version = "0.2.91" } -js-sys = { path = '../js-sys', version = '0.3.68' } +wasm-bindgen = { path = "../..", version = "0.2.92" } +js-sys = { path = '../js-sys', version = '0.3.69' } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] -wasm-bindgen-test = { path = '../test', version = '0.3.41' } -wasm-bindgen-futures = { path = '../futures', version = '0.4.41' } +wasm-bindgen-test = { path = '../test', version = '0.3.42' } +wasm-bindgen-futures = { path = '../futures', version = '0.4.42' } # This list is auto-generated by the wasm-bindgen-webidl program [features] diff --git a/crates/webidl/Cargo.toml b/crates/webidl/Cargo.toml index d004298a23f..3f3663ef2a6 100644 --- a/crates/webidl/Cargo.toml +++ b/crates/webidl/Cargo.toml @@ -21,7 +21,7 @@ log = "0.4.1" proc-macro2 = "1.0" quote = '1.0' syn = { version = '2.0', features = ['full'] } -wasm-bindgen-backend = { version = "=0.2.91", path = "../backend" } +wasm-bindgen-backend = { version = "=0.2.92", path = "../backend" } weedle = { git = "https://github.com/rustwasm/weedle.git" } once_cell = "1.12" sourcefile = "0.1" diff --git a/examples/add/Cargo.toml b/examples/add/Cargo.toml index cdeabc31055..5cbc88d4e79 100644 --- a/examples/add/Cargo.toml +++ b/examples/add/Cargo.toml @@ -9,4 +9,4 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" diff --git a/examples/canvas/Cargo.toml b/examples/canvas/Cargo.toml index d0088cc344c..8fc55fc09b0 100644 --- a/examples/canvas/Cargo.toml +++ b/examples/canvas/Cargo.toml @@ -9,8 +9,8 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -js-sys = "0.3.68" -wasm-bindgen = "0.2.91" +js-sys = "0.3.69" +wasm-bindgen = "0.2.92" [dependencies.web-sys] version = "0.3.4" diff --git a/examples/char/Cargo.toml b/examples/char/Cargo.toml index c848952902a..6378d2aab0e 100644 --- a/examples/char/Cargo.toml +++ b/examples/char/Cargo.toml @@ -9,4 +9,4 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" diff --git a/examples/closures/Cargo.toml b/examples/closures/Cargo.toml index 1021f1a35cd..31f0d065a19 100644 --- a/examples/closures/Cargo.toml +++ b/examples/closures/Cargo.toml @@ -9,8 +9,8 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" -js-sys = "0.3.68" +wasm-bindgen = "0.2.92" +js-sys = "0.3.69" [dependencies.web-sys] version = "0.3.4" diff --git a/examples/console_log/Cargo.toml b/examples/console_log/Cargo.toml index 64f5939909e..e5aa71a73f2 100644 --- a/examples/console_log/Cargo.toml +++ b/examples/console_log/Cargo.toml @@ -9,5 +9,5 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" -web-sys = { version = "0.3.68", features = ['console'] } +wasm-bindgen = "0.2.92" +web-sys = { version = "0.3.69", features = ['console'] } diff --git a/examples/deno/Cargo.toml b/examples/deno/Cargo.toml index d2a17d0d6fe..c4f54a9f227 100644 --- a/examples/deno/Cargo.toml +++ b/examples/deno/Cargo.toml @@ -9,4 +9,4 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" diff --git a/examples/dom/Cargo.toml b/examples/dom/Cargo.toml index 4556a2c7eb5..0ce8e8ac8da 100644 --- a/examples/dom/Cargo.toml +++ b/examples/dom/Cargo.toml @@ -9,7 +9,7 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" [dependencies.web-sys] version = "0.3.4" diff --git a/examples/duck-typed-interfaces/Cargo.toml b/examples/duck-typed-interfaces/Cargo.toml index c5f6b1d6108..e7835f2c866 100644 --- a/examples/duck-typed-interfaces/Cargo.toml +++ b/examples/duck-typed-interfaces/Cargo.toml @@ -9,4 +9,4 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" diff --git a/examples/fetch/Cargo.toml b/examples/fetch/Cargo.toml index 0f6e74688f5..4e3e0221f0d 100644 --- a/examples/fetch/Cargo.toml +++ b/examples/fetch/Cargo.toml @@ -9,9 +9,9 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" -js-sys = "0.3.68" -wasm-bindgen-futures = "0.4.41" +wasm-bindgen = "0.2.92" +js-sys = "0.3.69" +wasm-bindgen-futures = "0.4.42" [dependencies.web-sys] version = "0.3.4" diff --git a/examples/guide-supported-types-examples/Cargo.toml b/examples/guide-supported-types-examples/Cargo.toml index c61262759d7..3d7c676ed75 100644 --- a/examples/guide-supported-types-examples/Cargo.toml +++ b/examples/guide-supported-types-examples/Cargo.toml @@ -9,5 +9,5 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" -js-sys = "0.3.68" +wasm-bindgen = "0.2.92" +js-sys = "0.3.69" diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index 5ea4ba06bdc..af785ee9a0e 100644 --- a/examples/hello_world/Cargo.toml +++ b/examples/hello_world/Cargo.toml @@ -9,4 +9,4 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" diff --git a/examples/import_js/crate/Cargo.toml b/examples/import_js/crate/Cargo.toml index cd87a9b86dc..eec97f08e6b 100644 --- a/examples/import_js/crate/Cargo.toml +++ b/examples/import_js/crate/Cargo.toml @@ -8,4 +8,4 @@ edition = "2018" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" diff --git a/examples/julia_set/Cargo.toml b/examples/julia_set/Cargo.toml index e16590c3782..9ec7b105958 100644 --- a/examples/julia_set/Cargo.toml +++ b/examples/julia_set/Cargo.toml @@ -9,7 +9,7 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" [dependencies.web-sys] version = "0.3.4" diff --git a/examples/paint/Cargo.toml b/examples/paint/Cargo.toml index e4a108d5672..8bfe388ca65 100644 --- a/examples/paint/Cargo.toml +++ b/examples/paint/Cargo.toml @@ -9,8 +9,8 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -js-sys = "0.3.68" -wasm-bindgen = "0.2.91" +js-sys = "0.3.69" +wasm-bindgen = "0.2.92" [dependencies.web-sys] version = "0.3.4" diff --git a/examples/performance/Cargo.toml b/examples/performance/Cargo.toml index 46aa55a156e..6893b153ad1 100644 --- a/examples/performance/Cargo.toml +++ b/examples/performance/Cargo.toml @@ -9,7 +9,7 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" humantime = "2" [dependencies.web-sys] diff --git a/examples/raytrace-parallel/Cargo.toml b/examples/raytrace-parallel/Cargo.toml index ebdf77b6037..1120fab045a 100644 --- a/examples/raytrace-parallel/Cargo.toml +++ b/examples/raytrace-parallel/Cargo.toml @@ -10,14 +10,14 @@ crate-type = ["cdylib"] [dependencies] console_error_panic_hook = "0.1" -js-sys = "0.3.68" +js-sys = "0.3.69" rayon = "1.1.0" rayon-core = "1.5.0" raytracer = { git = 'https://github.com/alexcrichton/raytracer', branch = 'update-deps' } serde-wasm-bindgen = "0.4.3" futures-channel-preview = "0.3.0-alpha.18" -wasm-bindgen = "0.2.91" -wasm-bindgen-futures = "0.4.41" +wasm-bindgen = "0.2.92" +wasm-bindgen-futures = "0.4.42" [dependencies.web-sys] version = "0.3.23" diff --git a/examples/request-animation-frame/Cargo.toml b/examples/request-animation-frame/Cargo.toml index 69a7ace580b..1497c24bbe8 100644 --- a/examples/request-animation-frame/Cargo.toml +++ b/examples/request-animation-frame/Cargo.toml @@ -9,7 +9,7 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" [dependencies.web-sys] version = "0.3.4" diff --git a/examples/synchronous-instantiation/Cargo.toml b/examples/synchronous-instantiation/Cargo.toml index bdf4115e491..900e06dca74 100644 --- a/examples/synchronous-instantiation/Cargo.toml +++ b/examples/synchronous-instantiation/Cargo.toml @@ -9,4 +9,4 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" diff --git a/examples/todomvc/Cargo.toml b/examples/todomvc/Cargo.toml index e8966679a0f..e5a030c5e60 100644 --- a/examples/todomvc/Cargo.toml +++ b/examples/todomvc/Cargo.toml @@ -12,8 +12,8 @@ crate-type = ["cdylib"] askama = "0.10.0" [dependencies] -js-sys = "0.3.68" -wasm-bindgen = "0.2.91" +js-sys = "0.3.69" +wasm-bindgen = "0.2.92" askama = "0.10.0" console_error_panic_hook = "0.1.5" diff --git a/examples/wasm-audio-worklet/Cargo.toml b/examples/wasm-audio-worklet/Cargo.toml index 1bcbe841bae..9345765d1c0 100644 --- a/examples/wasm-audio-worklet/Cargo.toml +++ b/examples/wasm-audio-worklet/Cargo.toml @@ -9,9 +9,9 @@ crate-type = ["cdylib"] [dependencies] console_log = "0.2.0" -js-sys = "0.3.68" -wasm-bindgen = "0.2.91" -wasm-bindgen-futures = "0.4.41" +js-sys = "0.3.69" +wasm-bindgen = "0.2.92" +wasm-bindgen-futures = "0.4.42" [dependencies.web-sys] version = "0.3.59" diff --git a/examples/wasm-in-wasm-imports/Cargo.toml b/examples/wasm-in-wasm-imports/Cargo.toml index 5431abe2766..2083ce4bbd3 100644 --- a/examples/wasm-in-wasm-imports/Cargo.toml +++ b/examples/wasm-in-wasm-imports/Cargo.toml @@ -9,6 +9,6 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" -js-sys = "0.3.68" -wasm-bindgen-futures = "0.4.41" +wasm-bindgen = "0.2.92" +js-sys = "0.3.69" +wasm-bindgen-futures = "0.4.42" diff --git a/examples/wasm-in-wasm/Cargo.toml b/examples/wasm-in-wasm/Cargo.toml index b2a8e4837d7..2556bb3d8ef 100644 --- a/examples/wasm-in-wasm/Cargo.toml +++ b/examples/wasm-in-wasm/Cargo.toml @@ -9,6 +9,6 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" -js-sys = "0.3.68" -wasm-bindgen-futures = "0.4.41" +wasm-bindgen = "0.2.92" +js-sys = "0.3.69" +wasm-bindgen-futures = "0.4.42" diff --git a/examples/wasm-in-web-worker/Cargo.toml b/examples/wasm-in-web-worker/Cargo.toml index 8314c662b1e..3505c6264c1 100644 --- a/examples/wasm-in-web-worker/Cargo.toml +++ b/examples/wasm-in-web-worker/Cargo.toml @@ -9,7 +9,7 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" console_error_panic_hook = { version = "0.1.6", optional = true } [dependencies.web-sys] diff --git a/examples/wasm2js/Cargo.toml b/examples/wasm2js/Cargo.toml index d36f812dd9f..d1b32152293 100644 --- a/examples/wasm2js/Cargo.toml +++ b/examples/wasm2js/Cargo.toml @@ -9,4 +9,4 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" diff --git a/examples/weather_report/Cargo.toml b/examples/weather_report/Cargo.toml index 628c24be45a..a7e9d25c509 100644 --- a/examples/weather_report/Cargo.toml +++ b/examples/weather_report/Cargo.toml @@ -16,7 +16,7 @@ chrono = "0.4.11" reqwest = "0.10.6" wasm-bindgen-futures = "0.4.1" json= "*" -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" gloo = "0.2.1" [dependencies.web-sys] diff --git a/examples/webaudio/Cargo.toml b/examples/webaudio/Cargo.toml index a49681852c9..628b967fbea 100644 --- a/examples/webaudio/Cargo.toml +++ b/examples/webaudio/Cargo.toml @@ -9,7 +9,7 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" [dependencies.web-sys] version = "0.3.4" diff --git a/examples/webgl/Cargo.toml b/examples/webgl/Cargo.toml index c1452b377f9..2cea61a990d 100644 --- a/examples/webgl/Cargo.toml +++ b/examples/webgl/Cargo.toml @@ -9,8 +9,8 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -js-sys = "0.3.68" -wasm-bindgen = "0.2.91" +js-sys = "0.3.69" +wasm-bindgen = "0.2.92" [dependencies.web-sys] version = "0.3.4" diff --git a/examples/webrtc_datachannel/Cargo.toml b/examples/webrtc_datachannel/Cargo.toml index 32fcd5dd78d..aa7abf9a026 100644 --- a/examples/webrtc_datachannel/Cargo.toml +++ b/examples/webrtc_datachannel/Cargo.toml @@ -9,9 +9,9 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" js-sys = "0.3" -wasm-bindgen-futures = "0.4.41" +wasm-bindgen-futures = "0.4.42" [dependencies.web-sys] version = "0.3.22" diff --git a/examples/websockets/Cargo.toml b/examples/websockets/Cargo.toml index 97f537d4800..1a8f5b19904 100644 --- a/examples/websockets/Cargo.toml +++ b/examples/websockets/Cargo.toml @@ -9,7 +9,7 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" js-sys = "0.3" [dependencies.web-sys] diff --git a/examples/webxr/Cargo.toml b/examples/webxr/Cargo.toml index 1ed18c404e5..d9f51321769 100644 --- a/examples/webxr/Cargo.toml +++ b/examples/webxr/Cargo.toml @@ -10,9 +10,9 @@ crate-type = ["cdylib"] [dependencies] futures = "0.3.4" -js-sys = "0.3.68" -wasm-bindgen = "0.2.91" -wasm-bindgen-futures = "0.4.41" +js-sys = "0.3.69" +wasm-bindgen = "0.2.92" +wasm-bindgen-futures = "0.4.42" [dependencies.web-sys] version = "0.3.37" diff --git a/examples/without-a-bundler/Cargo.toml b/examples/without-a-bundler/Cargo.toml index b55ed46122c..3c5025647d6 100644 --- a/examples/without-a-bundler/Cargo.toml +++ b/examples/without-a-bundler/Cargo.toml @@ -9,7 +9,7 @@ rust-version = "1.57" crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "0.2.91" +wasm-bindgen = "0.2.92" [dependencies.web-sys] version = "0.3.4"