From cf72d6c735fda942a7e70950fd410074f33672a8 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Mon, 9 Dec 2024 15:35:06 +0100 Subject: [PATCH] Remove the `js_sys::Uint8Array` import Co-Authored-By: Artyom Pavlov --- src/backends/wasm_js.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/backends/wasm_js.rs b/src/backends/wasm_js.rs index a0bc7afe..2eb3da4c 100644 --- a/src/backends/wasm_js.rs +++ b/src/backends/wasm_js.rs @@ -7,8 +7,6 @@ pub use crate::util::{inner_u32, inner_u64}; #[cfg(not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none"))))] compile_error!("`wasm_js` backend can be enabled only for OS-less WASM targets!"); -#[cfg(target_feature = "atomics")] -use js_sys::Uint8Array; use wasm_bindgen::{prelude::wasm_bindgen, JsValue}; // Maximum buffer size allowed in `Crypto.getRandomValuesSize` is 65536 bytes. @@ -40,7 +38,7 @@ fn inner(crypto: &Crypto, dest: &mut [MaybeUninit]) -> Result<(), Error> { let buf_len_u32 = buf_len .try_into() .expect("buffer length is bounded by MAX_BUFFER_SIZE"); - let buf = Uint8Array::new_with_length(buf_len_u32); + let buf = js_sys::Uint8Array::new_with_length(buf_len_u32); for chunk in dest.chunks_mut(buf_len) { let chunk_len = chunk .len() @@ -77,5 +75,5 @@ extern "C" { fn get_random_values(this: &Crypto, buf: &mut [MaybeUninit]) -> Result<(), JsValue>; #[cfg(target_feature = "atomics")] #[wasm_bindgen(method, js_name = getRandomValues, catch)] - fn get_random_values(this: &Crypto, buf: &Uint8Array) -> Result<(), JsValue>; + fn get_random_values(this: &Crypto, buf: &js_sys::Uint8Array) -> Result<(), JsValue>; }