1#![cfg_attr(not(feature = "std"), no_std)]
2
3#[cfg(not(feature = "std"))]
4extern crate alloc;
5
6pub mod shared;
7pub use shared::keystore::*;
8pub use shared::shell::*;
9
10mod error;
11mod imp;
12
13pub use imp::*;
14
15#[cfg(all(feature = "std", target_family = "wasm"))]
16pub use {tokio, wasm_bindgen_futures::spawn_local as spawn};
17
18#[cfg(all(feature = "std", not(target_family = "wasm")))]
19pub use {tokio, tokio::task::spawn};
20
21#[cfg(all(feature = "std", target_family = "wasm"))]
22pub use wasmtimer::tokio as time;
23
24#[cfg(all(feature = "std", not(target_family = "wasm")))]
25pub use tokio::time;
26
27#[cfg(all(feature = "std", not(feature = "wasm-bindgen")))]
28pub fn log(s: &str) {
29 println!("{}", s);
30}
31
32#[cfg(feature = "wasm-bindgen")]
33use wasm_bindgen::prelude::*;
34
35#[cfg(feature = "wasm-bindgen")]
36pub fn into_js_error(err: impl core::error::Error) -> JsValue {
37 #[cfg(not(feature = "std"))]
38 use alloc::string::ToString;
39
40 js_sys::Error::new(&err.to_string()).into()
41}
42
43#[cfg(feature = "wasm-bindgen")]
44#[wasm_bindgen]
45extern "C" {
46 #[wasm_bindgen(js_namespace = console)]
47 pub fn log(s: &str);
48}