dioxus_interpreter_js/
lib.rs

1#![allow(clippy::empty_docs)]
2#![doc = include_str!("../README.md")]
3#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
4#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
5
6/// The base class that the JS channel will extend
7pub static INTERPRETER_JS: &str = include_str!("./js/core.js");
8
9/// The code explicitly for desktop/liveview that bridges the eval gap between the two
10pub static NATIVE_JS: &str = include_str!("./js/native.js");
11
12/// The code that handles initializing data used for fullstack data streaming
13pub static INITIALIZE_STREAMING_JS: &str = include_str!("./js/initialize_streaming.js");
14
15#[cfg(all(feature = "binary-protocol", feature = "sledgehammer"))]
16mod write_native_mutations;
17
18#[cfg(all(feature = "binary-protocol", feature = "sledgehammer"))]
19pub use write_native_mutations::*;
20
21#[cfg(feature = "sledgehammer")]
22pub mod unified_bindings;
23
24#[cfg(feature = "sledgehammer")]
25pub use unified_bindings::*;
26
27// Common bindings for minimal usage.
28#[cfg(all(feature = "minimal_bindings", feature = "webonly"))]
29pub mod minimal_bindings {
30    use wasm_bindgen::{prelude::wasm_bindgen, JsValue};
31
32    /// Some useful snippets that we use to share common functionality between the different platforms we support.
33    ///
34    /// This maintains some sort of consistency between web, desktop, and liveview
35    #[wasm_bindgen(module = "/src/js/set_attribute.js")]
36    extern "C" {
37        /// Set the attribute of the node
38        pub fn setAttributeInner(node: JsValue, name: &str, value: JsValue, ns: Option<&str>);
39    }
40
41    #[wasm_bindgen(module = "/src/js/hydrate.js")]
42    extern "C" {
43        /// Register a callback that that will be called to hydrate a node at the given id with data from the server
44        pub fn register_rehydrate_chunk_for_streaming(
45            closure: &wasm_bindgen::closure::Closure<dyn FnMut(Vec<u32>, js_sys::Uint8Array)>,
46        );
47
48        /// Register a callback that that will be called to hydrate a node at the given id with data from the server
49        pub fn register_rehydrate_chunk_for_streaming_debug(
50            closure: &wasm_bindgen::closure::Closure<
51                dyn FnMut(Vec<u32>, js_sys::Uint8Array, Option<Vec<String>>, Option<Vec<String>>),
52            >,
53        );
54    }
55
56    #[wasm_bindgen(module = "/src/js/patch_console.js")]
57    extern "C" {
58        pub fn monkeyPatchConsole(ws: JsValue);
59    }
60}