wip: more examples

This commit is contained in:
Jonathan Kelley committed 2021-07-11 19:31:07 -04:00
1 parent 304259d818
commit 56e7eb83a9
21 files changed
+162 -236

No files matched your search

+2 -1
View File
@@ -14,6 +14,7 @@ dioxus-html = { path = "./packages/html", optional = true }
dioxus-web = { path = "./packages/web", optional = true } dioxus-web = { path = "./packages/web", optional = true }
dioxus-webview = { path = "./packages/webview", optional = true } dioxus-webview = { path = "./packages/webview", optional = true }
dioxus-hooks = { path = "./packages/hooks", optional = true } dioxus-hooks = { path = "./packages/hooks", optional = true }
dioxus-ssr = { path = "./packages/ssr", optional = true }
[features] [features]
@@ -30,7 +31,7 @@ default = [
] ]
atoms = [] atoms = []
macro = ["dioxus-core-macro"] macro = ["dioxus-core-macro"]
ssr = [] ssr = ["dioxus-ssr"]
hooks = ["dioxus-hooks"] hooks = ["dioxus-hooks"]
router = [] router = []
html = ["dioxus-html"] html = ["dioxus-html"]
+27 -27
View File
@@ -12,7 +12,7 @@ fn App(cx: Context<()>) -> VNode {
let mut count = use_state(cx, || 0); let mut count = use_state(cx, || 0);
cx.render(rsx! { cx.render(rsx! {
h1 { "Hi-Five counter: {count}" } h1 { "High-Five counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" } button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" } button { onclick: move |_| count -= 1, "Down low!" }
}) })
@@ -96,32 +96,32 @@ Dioxus is heavily inspired by React, but we want your transition to feel like an
### Phase 1: The Basics ### Phase 1: The Basics
| Feature | Dioxus | React | Notes for Dioxus | | Feature | Dioxus | React | Notes for Dioxus |
| ----------------------- | ------ | ----- | ----------------------------------------------------- | | ----------------------- | ------ | ----- | ----------------------------------------------------------- |
| Conditional Rendering | ✅ | ✅ | if/then to hide/show component | | Conditional Rendering | ✅ | ✅ | if/then to hide/show component |
| Map, Iterator | ✅ | ✅ | map/filter/reduce to produce rsx! | | Map, Iterator | ✅ | ✅ | map/filter/reduce to produce rsx! |
| Keyed Components | ✅ | ✅ | advanced diffing with keys | | Keyed Components | ✅ | ✅ | advanced diffing with keys |
| Web | ✅ | ✅ | renderer for web browser | | Web | ✅ | ✅ | renderer for web browser |
| Desktop (webview) | ✅ | ✅ | renderer for desktop | | Desktop (webview) | ✅ | ✅ | renderer for desktop |
| Shared State (Context) | ✅ | ✅ | share state through the tree | | Shared State (Context) | ✅ | ✅ | share state through the tree |
| Hook | ✅ | ✅ | memory cells in components | | Hooks | ✅ | ✅ | memory cells in components |
| SSR | ✅ | ✅ | render directly to string | | SSR | ✅ | ✅ | render directly to string |
| Component Children | ✅ | ✅ | cx.children() as a list of nodes | | Component Children | ✅ | ✅ | cx.children() as a list of nodes |
| Headless components | ✅ | ✅ | components that don't return real elements | | Headless components | ✅ | ✅ | components that don't return real elements |
| Fragments | ✅ | ✅ | multiple elements without a real root | | Fragments | ✅ | ✅ | multiple elements without a real root |
| Manual Props | ✅ | ✅ | Manually pass in props with spread syntax | | Manual Props | ✅ | ✅ | Manually pass in props with spread syntax |
| Controlled Inputs | ✅ | ✅ | stateful wrappers around inputs | | Controlled Inputs | ✅ | ✅ | stateful wrappers around inputs |
| CSS/Inline Styles | ✅ | ✅ | syntax for inline styles/attribute groups | | CSS/Inline Styles | ✅ | ✅ | syntax for inline styles/attribute groups |
| Custom elements | ✅ | ✅ | Define new element primitives | | Custom elements | ✅ | ✅ | Define new element primitives |
| Suspense | 🛠 | ✅ | schedule future render from future/promise | | Suspense | 🛠 | ✅ | schedule future render from future/promise |
| Cooperative Scheduling | 🛠 | ✅ | Prioritize important events over non-important events | | Cooperative Scheduling | 🛠 | ✅ | Prioritize important events over non-important events |
| NodeRef | 🛠 | ✅ | gain direct access to nodes [1] | | Fine-grained reactivity | 🛠 | ❓ | Skip diffing for fine-grain updates |
| Fine-grained reactivity | 🛠 | ❓ | Skip diffing for fine-grain updates | | Compile-time correct | ✅ | ❓ | Throw errors on invalid template layouts |
| Compile-time correct | ✅ | ❓ | Throw errors on invalid template layouts | | Runs natively | ✅ | ❓ | runs as a portable binary w/o a runtime (Node) |
| Runs natively | ✅ | ❓ | runs as a portable binary w/o a runtime (Node) | | 1st class global state | ✅ | ❓ | redux/recoil/mobx on top of context |
| 1st class global state | ✅ | ❓ | redux/recoil/mobx on top of context | | Subtree Memoization | ✅ | ❓ | skip diffing static element subtrees |
| Subtree Memoization | ✅ | ❓ | skip diffing static element subtrees | | Heuristic Engine | 🛠 | ❓ | track component memory usage to minimize future allocations |
| Heuristic Engine | ✅ | ❓ | track component memory usage to minimize allocations | | NodeRef | 🛠 | ✅ | gain direct access to nodes [1] |
- [1] Currently blocked until we figure out a cross-platform way of exposing an imperative Node API. - [1] Currently blocked until we figure out a cross-platform way of exposing an imperative Node API.
-60
View File
@@ -1,60 +0,0 @@
fn main() {}
struct Title(String);
struct Position([f32; 3]);
struct Velocity([f32; 3]);
type Batch<T> = fn(&mut T) -> ();
static Atom: Batch<(Title, Position, Velocity)> = |_| {};
enum VNode<'a> {
El(El<'a>),
Text(&'a str),
Fragment(&'a [VNode<'a>]),
}
struct El<'a> {
name: &'static str,
key: Option<&'a str>,
attrs: &'a [(&'static str, AttrType<'a>)],
children: &'a [El<'a>],
}
enum AttrType<'a> {
Numeric(usize),
Text(&'a str),
}
fn example() {
use AttrType::Numeric;
let el = El {
name: "div",
attrs: &[("type", Numeric(10)), ("type", Numeric(10))],
key: None,
children: &[],
};
}
use dioxus::prelude::bumpalo::Bump;
trait IntoVnode {
fn into_vnode<'a>(self, b: &'a Bump) -> VNode<'a>;
}
impl<'a> IntoIterator for VNode<'a> {
type Item = VNode<'a>;
type IntoIter = std::iter::Once<VNode<'a>>;
#[inline]
fn into_iter(self) -> Self::IntoIter {
std::iter::once(self)
}
}
fn take_iterable<F: IntoVnode>(f: impl IntoIterator<Item = F>) {
let iter = f.into_iter();
let b = Bump::new();
for f in iter {
let v = f.into_vnode(&b);
}
}
+3 -3
View File
@@ -1,10 +1,10 @@
//! Example: README.md showcase //! Example: README.md showcase
//! //!
//! The example from the README.md //! The example from the README.md.
use dioxus::prelude::*; use dioxus::prelude::*;
fn main() { fn main() {
dioxus::web::launch(App) dioxus::desktop::launch(App, |c| c);
} }
static App: FC<()> = |cx| { static App: FC<()> = |cx| {
@@ -12,7 +12,7 @@ static App: FC<()> = |cx| {
cx.render(rsx! { cx.render(rsx! {
div { div {
h1 { "Hifive counter: {count}" } h1 { "High-Five counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" } button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" } button { onclick: move |_| count -= 1, "Down low!" }
} }
-2
View File
@@ -10,8 +10,6 @@
//! We don't support building new webcomponents with Dioxus, however. //! We don't support building new webcomponents with Dioxus, however.
//! //!
use dioxus::{builder::ElementBuilder, prelude::NodeFactory};
fn main() {} fn main() {}
mod dioxus_elements { mod dioxus_elements {
+17
View File
@@ -0,0 +1,17 @@
use dioxus::prelude::*;
use dioxus::ssr;
fn main() {
let mut vdom = VirtualDom::new(App);
vdom.rebuild_in_place();
println!("{}", ssr::render_root(&vdom));
}
const App: FC<()> = |cx| {
cx.render(rsx!(
div {
h1 { "Title" }
p { "Body" }
}
))
};
+15
View File
@@ -0,0 +1,15 @@
use dioxus::prelude::*;
fn main() {}
static App: FC<()> = |cx| {
//
cx.render(rsx!(
div {
h1 {}
}
))
};
#[test]
fn blah() {}
+4 -13
View File
@@ -1,24 +1,15 @@
fn main() {} fn main() {}
use dioxus::*;
use dioxus_core as dioxus; use dioxus_core as dioxus;
use dioxus_core::prelude::*; use dioxus_core::prelude::*;
mod dioxus_elements {
use super::*;
pub struct div;
impl DioxusElement for div {
const TAG_NAME: &'static str = "str";
const NAME_SPACE: Option<&'static str> = None;
}
}
static Example: FC<()> = |cx| { static Example: FC<()> = |cx| {
let list = (0..10).map(|f| { let list = (0..10).map(|f| LazyNodes::new(move |f| todo!()));
//
LazyNodes::new(move |f: NodeFactory| todo!())
});
cx.render(LazyNodes::new(move |cx| { cx.render(LazyNodes::new(move |cx| {
let bump = cx.bump(); let bump = cx.bump();
dioxus_core::builder::ElementBuilder::new(&cx, "h1") cx.raw_element("div")
.children([ .children([
cx.text(format_args!("hello")), cx.text(format_args!("hello")),
cx.text(format_args!("hello")), cx.text(format_args!("hello")),
+1
View File
@@ -7,6 +7,7 @@
fn main() {} fn main() {}
use dioxus_core::prelude::*; use dioxus_core::prelude::*;
use dioxus_core::*;
use std::rc::Rc; use std::rc::Rc;
struct AppProps { struct AppProps {
+4 -1
View File
@@ -44,6 +44,7 @@ pub fn fc_to_builder<T: Properties>(_: FC<T>) -> T::Builder {
T::builder() T::builder()
} }
use crate::nodebuilder::LazyNodes;
/// Create inline fragments /// Create inline fragments
/// ///
/// Fragments capture a series of children without rendering extra nodes. /// Fragments capture a series of children without rendering extra nodes.
@@ -53,5 +54,7 @@ pub fn fc_to_builder<T: Properties>(_: FC<T>) -> T::Builder {
use crate::prelude::*; use crate::prelude::*;
#[allow(non_upper_case_globals, non_snake_case)] #[allow(non_upper_case_globals, non_snake_case)]
pub fn Fragment<'a>(cx: Context<'a, ()>) -> VNode<'a> { pub fn Fragment<'a>(cx: Context<'a, ()>) -> VNode<'a> {
cx.render(LazyNodes::new(move |f| f.fragment_from_iter(cx.children()))) cx.render(LazyNodes::new(move |f| {
f.fragment_from_iter(cx.children())
}))
} }
+2 -2
View File
@@ -125,8 +125,8 @@ pub mod on {
use std::{fmt::Debug, ops::Deref, rc::Rc}; use std::{fmt::Debug, ops::Deref, rc::Rc};
use crate::{ use crate::{
builder::ElementBuilder, innerlude::ElementBuilder,
builder::NodeFactory, innerlude::NodeFactory,
innerlude::{Attribute, Listener, RealDomNode, VNode}, innerlude::{Attribute, Listener, RealDomNode, VNode},
}; };
use std::cell::Cell; use std::cell::Cell;
+15 -30
View File
@@ -28,10 +28,6 @@ pub mod tasks;
pub mod util; pub mod util;
pub mod virtual_dom; pub mod virtual_dom;
pub mod builder {
pub use super::nodebuilder::*;
}
// types used internally that are important // types used internally that are important
pub(crate) mod innerlude { pub(crate) mod innerlude {
pub use crate::bumpframe::*; pub use crate::bumpframe::*;
@@ -43,6 +39,7 @@ pub(crate) mod innerlude {
pub use crate::nodebuilder::*; pub use crate::nodebuilder::*;
pub use crate::nodes::*; pub use crate::nodes::*;
pub use crate::scope::*; pub use crate::scope::*;
pub use crate::serialize::*;
pub use crate::tasks::*; pub use crate::tasks::*;
pub use crate::util::*; pub use crate::util::*;
pub use crate::virtual_dom::*; pub use crate::virtual_dom::*;
@@ -54,35 +51,23 @@ pub(crate) mod innerlude {
pub use dioxus_core_macro::{html, rsx}; pub use dioxus_core_macro::{html, rsx};
} }
/// Re-export common types for ease of development use. pub use crate::{
/// Essential when working with the html! macro innerlude::{
DioxusElement, DomEdit, LazyNodes, NodeFactory, RealDom, RealDomNode, ScopeIdx, FC,
},
virtual_dom::VirtualDom,
};
pub mod prelude { pub mod prelude {
pub use crate::component::{fc_to_builder, Fragment, Properties}; pub use crate::component::{fc_to_builder, Fragment, Properties};
pub use crate::context::Context; pub use crate::context::Context;
use crate::nodes; pub use crate::innerlude::{LazyNodes, NodeFactory, FC};
pub use crate::styles::{AsAttr, StyleBuilder}; pub use crate::nodebuilder::DioxusElement;
pub use crate::nodes::VNode;
pub use crate::util::RealDomNode; pub use crate::VirtualDom;
pub use crate::virtual_dom::VirtualDom;
pub use nodes::*;
pub use crate::nodebuilder::LazyNodes;
pub use crate::nodebuilder::{DioxusElement, NodeFactory};
// pub use nodes::iterables::IterableNodes;
/// This type alias is an internal way of abstracting over the static functions that represent components.
pub use crate::innerlude::FC;
// expose our bumpalo type
pub use bumpalo;
pub use bumpalo::Bump;
// Re-export the FC macro
pub use crate::nodebuilder as builder;
// pub use dioxus_core_macro::fc;
pub use dioxus_core_macro::{format_args_f, html, rsx, Props}; pub use dioxus_core_macro::{format_args_f, html, rsx, Props};
}
pub use crate::diff::DiffMachine; pub mod exports {
pub use crate::virtual_dom::ScopeIdx; // export important things here
} }
+15 -2
View File
@@ -14,9 +14,8 @@ use bumpalo::Bump;
use crate::{ use crate::{
events::VirtualEvent, events::VirtualEvent,
innerlude::{Properties, RealDomNode, Scope, VComponent, VText, FC}, innerlude::{Properties, RealDomNode, Scope, VComponent, VFragment, VText, FC},
nodes::{Attribute, Listener, NodeKey, VNode}, nodes::{Attribute, Listener, NodeKey, VNode},
prelude::{VElement, VFragment},
}; };
/// A virtual DOM element builder. /// A virtual DOM element builder.
@@ -647,6 +646,20 @@ impl<'a> NodeFactory<'a> {
VNode::text(self.bump(), args) VNode::text(self.bump(), args)
} }
/// Create an element builder
pub fn raw_element<'b>(
&'b self,
tag: &'static str,
) -> ElementBuilder<
'a,
'b,
bumpalo::collections::Vec<'a, Listener<'a>>,
bumpalo::collections::Vec<'a, Attribute<'a>>,
bumpalo::collections::Vec<'a, VNode<'a>>,
> {
ElementBuilder::new(self, tag)
}
/// Create an element builder /// Create an element builder
pub fn element<'b>( pub fn element<'b>(
&'b self, &'b self,
+1 -1
View File
@@ -7,7 +7,7 @@
//! //!
//! //!
use crate::prelude::ScopeIdx; use crate::innerlude::ScopeIdx;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// A `DomEdit` represents a serialzied form of the VirtualDom's trait-based API. This allows streaming edits across the /// A `DomEdit` represents a serialzied form of the VirtualDom's trait-based API. This allows streaming edits across the
+1 -1
View File
@@ -19,7 +19,7 @@ use std::{
use futures_util::{Future, Stream, StreamExt}; use futures_util::{Future, Stream, StreamExt};
use slotmap::{DefaultKey, SlotMap}; use slotmap::{DefaultKey, SlotMap};
use crate::{events::EventTrigger, prelude::ScopeIdx}; use crate::{events::EventTrigger, innerlude::ScopeIdx};
pub type TaskSubmitter = Arc<dyn Fn(DTask)>; pub type TaskSubmitter = Arc<dyn Fn(DTask)>;
+1 -1
View File
@@ -7,7 +7,7 @@
//! of the Rsx and Html macros. Each element comes with a substantial amount of documentation on how to best use it, hopefully //! of the Rsx and Html macros. Each element comes with a substantial amount of documentation on how to best use it, hopefully
//! making the development cycle quick. //! making the development cycle quick.
use dioxus_core::prelude::{DioxusElement, NodeFactory}; use dioxus_core::{DioxusElement, NodeFactory};
macro_rules! builder_constructors { macro_rules! builder_constructors {
( $( $(#[$attr:meta])* $name:ident; )* ) => { ( $( $(#[$attr:meta])* $name:ident; )* ) => {
+34 -11
View File
@@ -16,7 +16,7 @@ pub fn render_root(vdom: &VirtualDom) -> String {
pub struct SsrConfig { pub struct SsrConfig {
// currently not supported - control if we indent the HTML output // currently not supported - control if we indent the HTML output
_indent: bool, indent: bool,
// Control if elements are written onto a new line // Control if elements are written onto a new line
newline: bool, newline: bool,
@@ -30,7 +30,7 @@ pub struct SsrConfig {
impl Default for SsrConfig { impl Default for SsrConfig {
fn default() -> Self { fn default() -> Self {
Self { Self {
_indent: false, indent: false,
newline: false, newline: false,
_skip_components: false, _skip_components: false,
@@ -68,10 +68,23 @@ impl<'a> TextRenderer<'a> {
} }
} }
fn html_render(&self, node: &VNode, f: &mut std::fmt::Formatter) -> std::fmt::Result { fn html_render(&self, node: &VNode, f: &mut std::fmt::Formatter, il: u16) -> std::fmt::Result {
match node { match node {
VNode::Text(text) => write!(f, "{}", text.text)?, VNode::Text(text) => {
if self.cfg.indent {
for _ in 0..il {
write!(f, " ")?;
}
}
write!(f, "{}", text.text)?
}
VNode::Element(el) => { VNode::Element(el) => {
if self.cfg.indent {
for _ in 0..il {
write!(f, " ")?;
}
}
write!(f, "<{}", el.tag_name)?; write!(f, "<{}", el.tag_name)?;
for attr in el.attributes { for attr in el.attributes {
write!(f, " {}=\"{}\"", attr.name, attr.value)?; write!(f, " {}=\"{}\"", attr.name, attr.value)?;
@@ -82,16 +95,26 @@ impl<'a> TextRenderer<'a> {
} }
for child in el.children { for child in el.children {
self.html_render(child, f)?; self.html_render(child, f, il + 1)?;
} }
match self.cfg.newline {
true => write!(f, "\n</{}>", el.tag_name)?, if self.cfg.newline {
false => write!(f, "</{}>", el.tag_name)?, write!(f, "\n")?;
}
if self.cfg.indent {
for _ in 0..il {
write!(f, " ")?;
}
}
write!(f, "</{}>", el.tag_name)?;
if self.cfg.newline {
write!(f, "\n")?;
} }
} }
VNode::Fragment(frag) => { VNode::Fragment(frag) => {
for child in frag.children { for child in frag.children {
self.html_render(child, f)?; self.html_render(child, f, il + 1)?;
} }
} }
VNode::Component(vcomp) => { VNode::Component(vcomp) => {
@@ -105,7 +128,7 @@ impl<'a> TextRenderer<'a> {
.frames .frames
.current_head_node(); .current_head_node();
self.html_render(new_node, f)?; self.html_render(new_node, f, il + 1)?;
} }
VNode::Suspended { .. } => todo!(), VNode::Suspended { .. } => todo!(),
} }
@@ -117,7 +140,7 @@ impl Display for TextRenderer<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let root = self.vdom.base_scope(); let root = self.vdom.base_scope();
let root_node = root.root(); let root_node = root.root();
self.html_render(root_node, f) self.html_render(root_node, f, 0)
} }
} }
-28
View File
@@ -444,31 +444,3 @@ pub fn intern_cache() {
wasm_bindgen::intern(s); wasm_bindgen::intern(s);
} }
} }
#[cfg(test)]
mod tests {
use std::env;
use super::*;
use dioxus::prelude::bumpalo;
use dioxus::prelude::format_args_f;
use dioxus_core as dioxus;
use dioxus_core::prelude::html;
fn simple_patch() {
env::set_var("RUST_LOG", "trace");
pretty_env_logger::init();
log::info!("Hello!");
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(|cx| {
todo!()
// cx.render(html! {
// <div>
// "Hello world"
// <button onclick={move |_| log::info!("button1 clicked!")}> "click me" </button>
// <button onclick={move |_| log::info!("button2 clicked!")}> "click me" </button>
// </div>
// })
}))
}
}
+2 -2
View File
@@ -2,7 +2,7 @@ use std::{collections::HashMap, rc::Rc, sync::Arc};
use dioxus_core::{ use dioxus_core::{
events::{EventTrigger, VirtualEvent}, events::{EventTrigger, VirtualEvent},
prelude::{RealDomNode, ScopeIdx}, RealDomNode, ScopeIdx,
}; };
use fxhash::FxHashMap; use fxhash::FxHashMap;
use slotmap::{DefaultKey, Key, KeyData}; use slotmap::{DefaultKey, Key, KeyData};
@@ -192,7 +192,7 @@ impl<'a> dioxus_core::diff::RealDom<'a> for WebsysDom {
fn new_event_listener( fn new_event_listener(
&mut self, &mut self,
event: &'static str, event: &'static str,
scope: dioxus_core::prelude::ScopeIdx, scope: ScopeIdx,
_element_id: usize, _element_id: usize,
real_id: RealDomNode, real_id: RealDomNode,
) { ) {
+2 -4
View File
@@ -1,8 +1,6 @@
//! webview dom //! webview dom
use dioxus_core as dioxus; use dioxus_core::{DomEdit, RealDom, RealDomNode, ScopeIdx};
use dioxus_core::prelude::*;
use dioxus_core::{diff::RealDom, serialize::DomEdit, virtual_dom::VirtualDom};
use DomEdit::*; use DomEdit::*;
pub struct WebviewRegistry {} pub struct WebviewRegistry {}
@@ -80,7 +78,7 @@ impl<'bump> RealDom<'bump> for WebviewDom<'bump> {
fn new_event_listener( fn new_event_listener(
&mut self, &mut self,
event: &'static str, event: &'static str,
scope: dioxus_core::prelude::ScopeIdx, scope: ScopeIdx,
element_id: usize, element_id: usize,
realnode: RealDomNode, realnode: RealDomNode,
) { ) {
+16 -47
View File
@@ -165,60 +165,29 @@
//! //!
//! In reality, you'll want to integrate analytics, logging, crash-protection and more. //! In reality, you'll want to integrate analytics, logging, crash-protection and more.
pub mod prelude {
//! A glob import that includes helper types like FC, rsx!, html!, and required traits
pub use dioxus_core::prelude::*;
pub use dioxus_core_macro::fc;
pub use dioxus_hooks::*;
pub use dioxus_html as dioxus_elements;
}
// pub mod builder {
// // pub use dioxus_core::builder::*;
// }
pub use dioxus_core::builder;
pub use dioxus_core::events;
// pub mod events {
// // pub use dioxus_core::events::*;
// }
// Just a heads-up, the core functionality of dioxus rests in Dioxus-Core. This crate just wraps a bunch of utilities // Just a heads-up, the core functionality of dioxus rests in Dioxus-Core. This crate just wraps a bunch of utilities
// together and exports their namespaces to something predicatble. // together and exports their namespaces to something predicatble.
#[cfg(feature = "core")] #[cfg(feature = "core")]
pub mod core { pub use dioxus_core as core;
//! Core functionality that includes the VirtualDOM, diffing, and Context APIs
// Re-export core completely #[cfg(feature = "core")]
pub use dioxus_core::*; pub use dioxus_core::events;
}
// Input elements work differently on different platforms.
// This module helps abstract over Selects, TextInputs, TextAreas, Radios, etc for a cross-platform input experience
pub mod inputs {
//! Cross-platform abstractions over user inputs
}
#[cfg(feature = "web")] #[cfg(feature = "web")]
pub mod web { pub use dioxus_web as web;
//! A web-sys based renderer for building fast and interactive web applications
use dioxus_core::prelude::{Properties, FC};
pub fn launch<P: Properties>(f: FC<P>) {}
}
#[cfg(feature = "ssr")] #[cfg(feature = "ssr")]
pub mod ssr { pub use dioxus_ssr as ssr;
//! A dedicated renderer for writing a Dioxus VirtualDOM to a string
} #[cfg(feature = "hooks")]
#[cfg(feature = "ssr")] pub use dioxus_hooks as hooks;
pub mod hooks {
//! Useful hooks like use_state, use_ref
}
#[cfg(feature = "ssr")]
pub mod router {
//! A cross-platform router implementation
}
#[cfg(feature = "ssr")]
pub mod testing {
//! Tools to make it easier to write tests for Dioxus components
}
#[cfg(feature = "atoms")]
pub mod atoms {}
#[cfg(feature = "desktop")] #[cfg(feature = "desktop")]
pub use dioxus_webview as desktop; pub use dioxus_webview as desktop;
pub mod prelude {
//! A glob import that includes helper types like FC, rsx!, html!, and required traits
pub use dioxus_core::prelude::*;
pub use dioxus_hooks::*;
pub use dioxus_html as dioxus_elements;
}