Fix wasm32 with atomics

This commit is contained in:
Zac Harrold
2025-02-05 15:40:13 +11:00
parent 1cf1433f07
commit 17673a13a8
2 changed files with 10 additions and 2 deletions

View File

@@ -68,7 +68,7 @@ v6 = ["atomic"]
v7 = ["rng"]
v8 = []
js = ["dep:wasm-bindgen"]
js = ["dep:wasm-bindgen", "dep:js-sys"]
rng = ["dep:getrandom"]
rng-getrandom = ["rng", "dep:getrandom", "uuid-rng-internal-lib", "uuid-rng-internal-lib/getrandom"]
@@ -173,6 +173,11 @@ version = "0.6"
version = "0.2"
optional = true
# Private
[target.'cfg(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown", target_feature = "atomics"))'.dependencies.js-sys]
version = "0.3"
optional = true
[dev-dependencies.bincode]
version = "1.0"

View File

@@ -244,6 +244,9 @@ mod imp {
*/
use wasm_bindgen::{prelude::wasm_bindgen, JsValue};
#[cfg(target_feature = "atomics")]
use core::convert::TryInto;
// Maximum buffer size allowed in `Crypto.getRandomValuesSize` is 65536 bytes.
// See https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
@@ -287,7 +290,7 @@ mod imp {
return false;
}
sub_buf.copy_to_uninit(chunk);
sub_buf.copy_to(chunk);
}
true