Update `web-sys` & `wasm-bindgen` (#4980)

This PR updates web-sys & wasm to the newest version.

(this was already part of the POC #4954 )

* Closes <https://github.com/emilk/egui/issues/4961>
* Closes <https://github.com/emilk/egui/issues/4958>
* [x] I have followed the instructions in the PR template
This commit is contained in:
Nicolas 2024-08-26 11:38:30 +02:00 committed by GitHub
parent e9522cf765
commit 560b2989a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 28 additions and 36 deletions

View File

@ -108,7 +108,7 @@ jobs:
- name: wasm-bindgen - name: wasm-bindgen
uses: jetli/wasm-bindgen-action@v0.1.0 uses: jetli/wasm-bindgen-action@v0.1.0
with: with:
version: "0.2.92" version: "0.2.93"
- run: ./scripts/wasm_bindgen_check.sh --skip-setup - run: ./scripts/wasm_bindgen_check.sh --skip-setup

View File

@ -2235,9 +2235,9 @@ dependencies = [
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.69" version = "0.3.70"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a"
dependencies = [ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
@ -4208,19 +4208,20 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.92" version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"once_cell",
"wasm-bindgen-macro", "wasm-bindgen-macro",
] ]
[[package]] [[package]]
name = "wasm-bindgen-backend" name = "wasm-bindgen-backend"
version = "0.2.92" version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"log", "log",
@ -4245,9 +4246,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.92" version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf"
dependencies = [ dependencies = [
"quote", "quote",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
@ -4255,9 +4256,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro-support" name = "wasm-bindgen-macro-support"
version = "0.2.92" version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -4268,9 +4269,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-shared" name = "wasm-bindgen-shared"
version = "0.2.92" version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
[[package]] [[package]]
name = "wayland-backend" name = "wayland-backend"
@ -4383,9 +4384,9 @@ dependencies = [
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.69" version = "0.3.70"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",

View File

@ -90,7 +90,7 @@ thiserror = "1.0.37"
web-time = "1.1.0" # Timekeeping for native and web web-time = "1.1.0" # Timekeeping for native and web
wasm-bindgen = "0.2" wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4" wasm-bindgen-futures = "0.4"
web-sys = "0.3.58" web-sys = "0.3.70"
wgpu = { version = "22.1.0", default-features = false, features = [ wgpu = { version = "22.1.0", default-features = false, features = [
# Make the renderer `Sync` even on wasm32, because it makes the code simpler: # Make the renderer `Sync` even on wasm32, because it makes the code simpler:
"fragile-send-sync-non-atomic-wasm", "fragile-send-sync-non-atomic-wasm",

View File

@ -767,8 +767,8 @@ pub(crate) fn install_resize_observer(runner_ref: &WebRunner) -> Result<(), JsVa
}) as Box<dyn FnMut(js_sys::Array)>); }) as Box<dyn FnMut(js_sys::Array)>);
let observer = web_sys::ResizeObserver::new(closure.as_ref().unchecked_ref())?; let observer = web_sys::ResizeObserver::new(closure.as_ref().unchecked_ref())?;
let mut options = web_sys::ResizeObserverOptions::new(); let options = web_sys::ResizeObserverOptions::new();
options.box_(web_sys::ResizeObserverBoxOptions::ContentBox); options.set_box(web_sys::ResizeObserverBoxOptions::ContentBox);
if let Some(runner_lock) = runner_ref.try_lock() { if let Some(runner_lock) = runner_ref.try_lock() {
observer.observe_with_options(runner_lock.canvas(), &options); observer.observe_with_options(runner_lock.canvas(), &options);
drop(runner_lock); drop(runner_lock);

View File

@ -171,23 +171,14 @@ fn set_cursor_icon(cursor: egui::CursorIcon) -> Option<()> {
#[cfg(web_sys_unstable_apis)] #[cfg(web_sys_unstable_apis)]
fn set_clipboard_text(s: &str) { fn set_clipboard_text(s: &str) {
if let Some(window) = web_sys::window() { if let Some(window) = web_sys::window() {
if let Some(clipboard) = window.navigator().clipboard() { let promise = window.navigator().clipboard().write_text(s);
let promise = clipboard.write_text(s); let future = wasm_bindgen_futures::JsFuture::from(promise);
let future = wasm_bindgen_futures::JsFuture::from(promise); let future = async move {
let future = async move { if let Err(err) = future.await {
if let Err(err) = future.await { log::error!("Copy/cut action failed: {}", string_from_js_value(&err));
log::error!("Copy/cut action failed: {}", string_from_js_value(&err));
}
};
wasm_bindgen_futures::spawn_local(future);
} else {
let is_secure_context = window.is_secure_context();
if is_secure_context {
log::warn!("window.navigator.clipboard is null; can't copy text");
} else {
log::warn!("window.navigator.clipboard is null; can't copy text, probably because we're not in a secure context. See https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts");
} }
} };
wasm_bindgen_futures::spawn_local(future);
} }
} }

View File

@ -77,6 +77,6 @@ rfd = { version = "0.13", optional = true }
# web: # web:
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "=0.2.92" wasm-bindgen = "=0.2.93"
wasm-bindgen-futures.workspace = true wasm-bindgen-futures.workspace = true
web-sys.workspace = true web-sys.workspace = true

View File

@ -7,4 +7,4 @@ cd "$script_path/.."
rustup target add wasm32-unknown-unknown rustup target add wasm32-unknown-unknown
# For generating JS bindings: # For generating JS bindings:
cargo install --quiet wasm-bindgen-cli --version 0.2.92 cargo install --quiet wasm-bindgen-cli --version 0.2.93