sauron_core/
dom.rs

1//! This module provides functionalities for
2//! manipulating the actual Document Object Model in the browser
3
4pub use cmd::Cmd;
5pub use component::Component;
6pub use effects::Effects;
7
8mod cmd;
9mod component;
10mod effects;
11
12use cfg_if::cfg_if;
13
14cfg_if! {if #[cfg(feature = "with-dom")] {
15    mod application;
16    mod dom_node;
17    mod dom_patch;
18    mod dom_attr;
19    mod http;
20    mod program;
21    mod raf;
22    mod ric;
23    mod window;
24    mod document;
25    mod time;
26    mod timeout;
27
28    pub mod events;
29    pub mod dispatch;
30    pub mod util;
31
32    pub use application::{Application, Measurements, SkipDiff, skip_if, skip_diff, SkipPath};
33    pub use component::{stateful_component, StatefulComponent, StatefulModel, StatelessModel};
34    pub use component::component;
35    pub use dispatch::Dispatch;
36    pub use document::Document;
37    pub use dom_patch::{DomPatch, PatchVariant, apply_dom_patches, convert_patches};
38    pub use dom_attr::{DomAttr, DomAttrValue, GroupedDomAttrValues};
39    pub use dom_node::DomNode;
40    pub use dom_node::create_dom_node;
41    pub use http::Http;
42    pub use program::{MountAction, MountTarget, Program, MountProcedure};
43    pub use util::{
44        document, history, now, performance,
45        spawn_local, window, inject_style,
46    };
47    pub use raf::{request_animation_frame, AnimationFrameHandle};
48    pub use ric::{request_idle_callback, IdleCallbackHandle, IdleDeadline};
49    pub use timeout::{delay, request_timeout_callback, TimeoutCallbackHandle};
50    pub use window::Window;
51    pub use time::Time;
52
53    use crate::dom::events::MountEvent;
54
55    /// Map the Event to DomEvent, which are browser events
56    #[derive(Debug, Clone)]
57    pub enum Event {
58        /// native dome events web_sys::Events
59        WebEvent(web_sys::Event),
60        /// custom event here follows
61        MountEvent(MountEvent),
62    }
63
64}}
65
66/// When event is not needed, such as just rendering the dom
67/// tree in server side application
68#[cfg(not(feature = "with-dom"))]
69pub type Event = ();