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'
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 457b09cf550..0157c230edc 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,10 +77,10 @@ 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
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- uses: ./.github/actions/setup-geckodriver
@@ -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,10 +117,10 @@ 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
+ # - uses: actions/setup-node@v4
# with:
# node-version: '20'
# - uses: ./.github/actions/setup-geckodriver
@@ -138,10 +138,10 @@ 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
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- run: cargo test
@@ -158,10 +158,10 @@ 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
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- uses: ./.github/actions/setup-geckodriver
@@ -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,10 +187,10 @@ 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
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- uses: ./.github/actions/setup-geckodriver
@@ -203,10 +203,10 @@ 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
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- run: cargo test -p wasm-bindgen-webidl
@@ -221,10 +221,10 @@ 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
+ - uses: actions/setup-node@v4
with:
node-version: '20'
- run: cd crates/typescript-tests && ./run.sh
@@ -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,15 +245,15 @@ jobs:
name: Run UI compile-fail tests
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
- - run: rustup update --no-self-update 1.69.0 && rustup default 1.69.0
+ - uses: actions/checkout@v4
+ - 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
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
@@ -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
@@ -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
@@ -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
@@ -303,12 +303,12 @@ jobs:
- build_nightly
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
- - uses: actions/download-artifact@v3
+ - uses: actions/checkout@v4
+ - 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
@@ -320,12 +320,12 @@ 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
- 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
@@ -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
@@ -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*"
@@ -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
@@ -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*"
@@ -366,12 +366,12 @@ 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:
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*"
@@ -379,14 +379,14 @@ 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: |
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*"
@@ -394,12 +394,12 @@ 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:
RUSTFLAGS: -Ctarget-feature=+crt-static
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: dist_windows
path: "target/release/wasm*"
@@ -407,12 +407,12 @@ 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
- run: (cd guide && mdbook build)
- - uses: actions/upload-artifact@v3
+ - uses: actions/upload-artifact@v4
with:
name: doc_book
path: guide/book/html
@@ -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
@@ -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
@@ -452,10 +452,10 @@ 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
+ - 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,11 +496,11 @@ 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
- - uses: JamesIves/github-pages-deploy-action@v4.4.1
+ - uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: gh-pages
@@ -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 }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20c87a0e073..b6c36b45dde 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,16 +1,51 @@
# `wasm-bindgen` Change Log
--------------------------------------------------------------------------------
+## [0.2.92](https://github.com/rustwasm/wasm-bindgen/compare/0.2.91...0.2.92)
+
+Released 2024-03-04
+
+### Added
+
+* 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)
+
+* 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)
+ [#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)
+
+### Fixed
+
+* 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)
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`.
@@ -53,6 +88,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
@@ -95,6 +132,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.
@@ -123,6 +162,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
@@ -287,6 +328,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/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/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
|
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-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/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/js/binding.rs b/crates/cli-support/src/js/binding.rs
index 76b61b42f86..ebe4e966c43 100644
--- a/crates/cli-support/src/js/binding.rs
+++ b/crates/cli-support/src/js/binding.rs
@@ -497,6 +497,16 @@ 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_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;
@@ -652,7 +662,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),
}
@@ -734,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 => {
@@ -811,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 } => {
@@ -1217,6 +1238,24 @@ fn instruction(
let val = js.pop();
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();
+ 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 +1363,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/js/mod.rs b/crates/cli-support/src/js/mod.rs
index 2e7744874b4..35bba115fdc 100644
--- a/crates/cli-support/src/js/mod.rs
+++ b/crates/cli-support/src/js/mod.rs
@@ -2103,6 +2103,32 @@ 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_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/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() {
diff --git a/crates/cli-support/src/wit/incoming.rs b/crates/cli-support/src/wit/incoming.rs
index b42541791eb..83bd3b32b16 100644
--- a/crates/cli-support/src/wit/incoming.rs
+++ b/crates/cli-support/src/wit/incoming.rs
@@ -155,6 +155,12 @@ impl InstructionBuilder<'_, '_> {
// Largely synthetic and can't show up
Descriptor::ClampedU8 => unreachable!(),
+
+ Descriptor::NonNull => self.instruction(
+ &[AdapterType::NonNull],
+ Instruction::I32FromNonNull,
+ &[AdapterType::I32],
+ ),
}
Ok(())
}
@@ -331,6 +337,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..104a297abfa 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,9 @@ pub enum Instruction {
OptionEnumFromI32 {
hole: u32,
},
+ I32FromOptionNonNull,
+ OptionNonNullFromI32,
+ I32FromNonNull,
}
impl AdapterType {
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/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...");
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/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.);
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/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/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/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/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-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;
+ |
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/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);
+});
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 11f287f5c24..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]
@@ -1102,6 +1102,7 @@ RtcOfferAnswerOptions = []
RtcOfferOptions = []
RtcOutboundRtpStreamStats = []
RtcPeerConnection = ["EventTarget"]
+RtcPeerConnectionIceErrorEvent = ["Event"]
RtcPeerConnectionIceEvent = ["Event"]
RtcPeerConnectionIceEventInit = []
RtcPeerConnectionState = []
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/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/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/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/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 {
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;
+};
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;
+};
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/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/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"
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/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
diff --git a/guide/src/reference/types/non-null.md b/guide/src/reference/types/non-null.md
new file mode 100644
index 00000000000..33c2e9b0f16
--- /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 |
+|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
+| Yes | 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..4ecef7821ef 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;
@@ -187,6 +188,7 @@ impl FromWasmAbi for char {
#[inline]
unsafe fn from_abi(js: u32) -> char {
+ // SAFETY: Checked in bindings.
char::from_u32_unchecked(js)
}
}
@@ -223,6 +225,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 +261,57 @@ 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 NonNull {
+ type Abi = u32;
+
+ #[inline]
+ unsafe fn from_abi(js: Self::Abi) -> Self {
+ // SAFETY: Checked in bindings.
+ NonNull::new_unchecked(js as *mut T)
+ }
+}
+
+impl OptionFromWasmAbi for NonNull {
+ #[inline]
+ fn is_none(js: &u32) -> bool {
+ *js == 0
+ }
+}
+
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/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)
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);
diff --git a/tests/wasm/simple.js b/tests/wasm/simple.js
index bc3edce8c0a..f66c77479f7 100644
--- a/tests/wasm/simple.js
+++ b/tests/wasm/simple.js
@@ -110,3 +110,42 @@ 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_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);
+
+ 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..fdef34c68fd 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,73 @@ 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_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()))
+}
+
+#[wasm_bindgen_test]
+fn non_null() {
+ test_non_null();
+}
+
#[wasm_bindgen_test]
fn string_arguments() {
test_string_arguments();