2021-07-15 07:38:09 +00:00
|
|
|
#![allow(non_snake_case)]
|
2021-07-29 22:04:09 +00:00
|
|
|
#![doc = include_str!("../README.md")]
|
2021-01-14 07:56:41 +00:00
|
|
|
|
2021-11-03 23:55:02 +00:00
|
|
|
pub(crate) mod diff;
|
|
|
|
pub(crate) mod lazynodes;
|
|
|
|
pub(crate) mod mutations;
|
|
|
|
pub(crate) mod nodes;
|
2021-12-21 03:33:13 +00:00
|
|
|
pub(crate) mod scopes;
|
2021-11-03 23:55:02 +00:00
|
|
|
pub(crate) mod virtual_dom;
|
2021-02-03 07:26:04 +00:00
|
|
|
|
2021-02-12 21:11:33 +00:00
|
|
|
pub(crate) mod innerlude {
|
2021-12-13 00:47:13 +00:00
|
|
|
pub(crate) use crate::diff::*;
|
2021-11-01 06:41:23 +00:00
|
|
|
pub use crate::lazynodes::*;
|
2021-08-22 21:08:25 +00:00
|
|
|
pub use crate::mutations::*;
|
2021-05-15 16:03:08 +00:00
|
|
|
pub use crate::nodes::*;
|
2021-12-21 03:33:13 +00:00
|
|
|
pub use crate::scopes::*;
|
2021-05-15 16:03:08 +00:00
|
|
|
pub use crate::virtual_dom::*;
|
2021-11-01 06:41:23 +00:00
|
|
|
|
2021-12-18 20:17:32 +00:00
|
|
|
/// An [`Element`] is a possibly-none [`VNode`] created by calling `render` on [`Scope`] or [`ScopeState`].
|
|
|
|
///
|
|
|
|
/// Any [`None`] [`Element`] will automatically be coerced into a placeholder [`VNode`] with the [`VNode::Placeholder`] variant.
|
2021-12-14 07:27:59 +00:00
|
|
|
pub type Element<'a> = Option<VNode<'a>>;
|
2021-12-18 20:17:32 +00:00
|
|
|
|
|
|
|
/// A [`Component`] is a function that takes a [`Scope`] and returns an [`Element`].
|
|
|
|
///
|
|
|
|
/// Components can be used in other components with two syntax options:
|
|
|
|
/// - lowercase as a function call with named arguments (rust style)
|
|
|
|
/// - uppercase as an element (react style)
|
|
|
|
///
|
|
|
|
/// ## Rust-Style
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// fn example(cx: Scope<Props>) -> Element {
|
|
|
|
/// // ...
|
|
|
|
/// }
|
|
|
|
///
|
|
|
|
/// rsx!(
|
|
|
|
/// example()
|
|
|
|
/// )
|
|
|
|
/// ```
|
|
|
|
/// ## React-Style
|
|
|
|
/// ```rust
|
|
|
|
/// fn Example(cx: Scope<Props>) -> Element {
|
|
|
|
/// // ...
|
|
|
|
/// }
|
|
|
|
///
|
|
|
|
/// rsx!(
|
|
|
|
/// Example {}
|
|
|
|
/// )
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// ## As a closure
|
|
|
|
/// This particular type alias lets you even use static closures for pure/static components:
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// static Example: Component<Props> = |cx| {
|
|
|
|
/// // ...
|
|
|
|
/// };
|
|
|
|
/// ```
|
2021-12-25 22:18:05 +00:00
|
|
|
pub type Component<P = ()> = fn(Scope<P>) -> Element;
|
|
|
|
|
|
|
|
/// A list of attributes
|
|
|
|
///
|
|
|
|
pub type Attributes<'a> = Option<&'a [Attribute<'a>]>;
|
2021-07-11 23:31:07 +00:00
|
|
|
}
|
2021-02-12 05:29:46 +00:00
|
|
|
|
2021-08-31 16:28:44 +00:00
|
|
|
pub use crate::innerlude::{
|
2021-12-14 07:27:59 +00:00
|
|
|
Attribute, Component, DioxusElement, DomEdit, Element, ElementId, EventHandler, EventPriority,
|
|
|
|
IntoVNode, LazyNodes, Listener, Mutations, NodeFactory, Properties, SchedulerMsg, Scope,
|
2021-12-26 19:22:30 +00:00
|
|
|
ScopeId, ScopeState, TaskId, UserEvent, VComponent, VElement, VFragment, VNode, VPlaceholder,
|
|
|
|
VText, VirtualDom,
|
2021-08-31 16:28:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
pub mod prelude {
|
2021-12-14 07:27:59 +00:00
|
|
|
pub use crate::innerlude::Scope;
|
2021-12-10 02:19:31 +00:00
|
|
|
pub use crate::innerlude::{
|
2021-12-25 22:18:05 +00:00
|
|
|
Attributes, Component, DioxusElement, Element, EventHandler, LazyNodes, NodeFactory,
|
|
|
|
ScopeState,
|
2021-12-10 02:19:31 +00:00
|
|
|
};
|
2021-08-31 16:28:44 +00:00
|
|
|
pub use crate::nodes::VNode;
|
2021-12-21 06:11:27 +00:00
|
|
|
pub use crate::virtual_dom::{fc_to_builder, Fragment, Properties};
|
2021-08-31 16:28:44 +00:00
|
|
|
pub use crate::VirtualDom;
|
|
|
|
}
|
|
|
|
|
2021-07-11 23:31:07 +00:00
|
|
|
pub mod exports {
|
2021-08-25 19:54:33 +00:00
|
|
|
//! Important dependencies that are used by the rest of the library
|
2021-12-15 03:48:20 +00:00
|
|
|
//! Feel free to just add the dependencies in your own Crates.toml
|
2021-07-15 08:09:28 +00:00
|
|
|
pub use bumpalo;
|
2021-10-04 05:28:04 +00:00
|
|
|
pub use futures_channel;
|
2021-01-15 01:56:28 +00:00
|
|
|
}
|
2021-12-21 03:33:13 +00:00
|
|
|
|
|
|
|
/// Functions that wrap unsafe functionality to prevent us from misusing it at the callsite
|
|
|
|
pub(crate) mod unsafe_utils {
|
|
|
|
use crate::VNode;
|
|
|
|
|
|
|
|
pub unsafe fn extend_vnode<'a, 'b>(node: &'a VNode<'a>) -> &'b VNode<'b> {
|
|
|
|
std::mem::transmute(node)
|
|
|
|
}
|
|
|
|
}
|