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/common.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        /// Roll up all the values from the node into a JS object that we can deserialize
41        pub fn collectFormValues(node: JsValue) -> JsValue;
42    }
43
44    #[wasm_bindgen(module = "/src/js/hydrate.js")]
45    extern "C" {
46        /// Register a callback that that will be called to hydrate a node at the given id with data from the server
47        pub fn register_rehydrate_chunk_for_streaming(
48            closure: &wasm_bindgen::closure::Closure<dyn FnMut(Vec<u32>, js_sys::Uint8Array)>,
49        );
50
51        /// Register a callback that that will be called to hydrate a node at the given id with data from the server
52        pub fn register_rehydrate_chunk_for_streaming_debug(
53            closure: &wasm_bindgen::closure::Closure<
54                dyn FnMut(Vec<u32>, js_sys::Uint8Array, Option<Vec<String>>, Option<Vec<String>>),
55            >,
56        );
57    }
58
59    #[wasm_bindgen(module = "/src/js/patch_console.js")]
60    extern "C" {
61        pub fn monkeyPatchConsole(ws: JsValue);
62    }
63}