Skip to main content

flow_rs_wasm/
lib.rs

1//! # Leptos Flow WASM
2//!
3//! WASM bindings and utilities for Leptos Flow providing direct JavaScript
4//! interoperability for non-Leptos applications.
5
6use wasm_bindgen::prelude::*;
7
8// Re-export core functionality
9pub use flow_rs_core as core;
10pub use flow_rs_renderer as renderer;
11
12pub mod bindings;
13pub mod utils;
14
15/// Initialize the WASM module
16#[wasm_bindgen(start)]
17pub fn init() {
18    #[cfg(feature = "console_error_panic_hook")]
19    console_error_panic_hook::set_once();
20
21    #[cfg(feature = "debug")]
22    {
23        use tracing::Level;
24        use tracing_wasm::WASMLayerConfigBuilder;
25
26        let config = WASMLayerConfigBuilder::default()
27            .set_max_level(Level::INFO)
28            .build();
29
30        tracing_wasm::set_as_global_default_with_config(config);
31
32        tracing::info!("Leptos Flow WASM initialized");
33    }
34}
35
36/// Export WASM-compatible types and functions
37pub mod wasm_exports {
38    #[allow(unused_imports)]
39    use super::*;
40    pub use crate::bindings::*;
41}
42
43#[cfg(test)]
44mod tests {
45    use super::*;
46    use wasm_bindgen_test::*;
47
48    wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
49
50    #[wasm_bindgen_test]
51    fn test_init() {
52        init();
53        // If we reach here, initialization was successful
54    }
55}