forked from RustLangES/RustLangES.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.rs
46 lines (37 loc) · 942 Bytes
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
pub mod app;
pub mod components;
pub mod extras;
pub mod models;
pub mod pages;
use wasm_bindgen::prelude::wasm_bindgen;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
fn log(msg: String);
#[wasm_bindgen(js_namespace = console)]
fn warn(msg: String);
#[wasm_bindgen(js_namespace = console)]
fn error(msg: String);
}
#[macro_export]
macro_rules! log {
($($t:tt)*) => {
if cfg!(debug_assertions) {
log(format_args!($($t)*).to_string())
}
}
}
#[macro_export]
macro_rules! warn {
($($t:tt)*) => (warn(format_args!($($t)*).to_string()))
}
#[macro_export]
macro_rules! error {
($($t:tt)*) => (error(format_args!($($t)*).to_string()))
}
#[wasm_bindgen]
pub fn hydrate() {
#[cfg(target_arch = "wasm32")]
std::panic::set_hook(Box::new(|info: &std::panic::PanicInfo| error!("{info}")));
leptos::leptos_dom::HydrationCtx::stop_hydrating();
}