wip: prepare to change our fragment pattern. Add some more docs

This commit is contained in:
Jonathan Kelley 2021-12-18 15:17:32 -05:00
parent 2b928372fb
commit 2c3a046426
10 changed files with 108 additions and 71 deletions

View file

@ -1,44 +1,55 @@
[package]
name = "dioxus"
version = "0.1.1"
version = "0.1.2"
authors = ["Jonathan Kelley"]
edition = "2018"
description = "Core functionality for Dioxus - a concurrent renderer-agnostic Virtual DOM for interactive user experiences"
license = "MIT/Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
repository = "https://github.com/DioxusLabs/dioxus/"
homepage = "https://dioxuslabs.com"
documentation = "https://dioxuslabs.com"
keywords = ["dom", "ui", "gui", "react", "wasm"]
[dependencies]
dioxus-core = { path = "./packages/core", version ="^0.1.3"}
dioxus-router = { path = "./packages/router", optional = true }
dioxus-core-macro = { path = "./packages/core-macro", optional = true }
dioxus-core = { path = "./packages/core", version = "^0.1.3" }
dioxus-html = { path = "./packages/html", optional = true }
dioxus-core-macro = { path = "./packages/core-macro", optional = true }
dioxus-hooks = { path = "./packages/hooks", optional = true }
dioxus-ssr = { path = "./packages/ssr", optional = true }
dioxus-web = { path = "./packages/web", optional = true }
dioxus-desktop = { path = "./packages/desktop", optional = true }
dioxus-hooks = { path = "./packages/hooks", optional = true }
dioxus-ssr = { path = "./packages/ssr", optional = true }
dioxus-router = { path = "./packages/router", optional = true }
dioxus-mobile = { path = "./packages/mobile", optional = true }
dioxus-liveview = { path = "./packages/liveview", optional = true }
[features]
# core
default = ["core"]
core = ["macro", "hooks", "html"]
default = ["macro", "hooks", "html"]
macro = ["dioxus-core-macro"]
hooks = ["dioxus-hooks"]
html = ["dioxus-html"]
router = ["dioxus-router"]
liveview = ["dioxus-liveview"]
# utilities
atoms = []
# targets
ssr = ["dioxus-ssr"]
web = ["dioxus-web"]
desktop = ["dioxus-desktop"]
mobile = ["dioxus-mobile"]
[workspace]
members = [
"packages/core",
"packages/core-macro",
"packages/html",
"packages/hooks",
"packages/web",
"packages/ssr",
"packages/desktop",
"packages/mobile",
]
[dev-dependencies]
futures-util = "0.3.17"
log = "0.4.14"
@ -48,7 +59,6 @@ serde = { version = "1.0.131", features = ["derive"] }
im-rc = "15.0.0"
fxhash = "0.2.1"
anyhow = "1.0.51"
# reqwest = "0.11.4"
serde_json = "1.0.73"
simple_logger = "1.16.0"
@ -69,31 +79,3 @@ wasm-bindgen = { version = "0.2.78", features = ["enable-interning"] }
[dev-dependencies.getrandom]
version = "0.2.3"
features = ["js"]
[workspace]
members = [
"packages/core",
"packages/core-macro",
"packages/html",
"packages/hooks",
"packages/web",
"packages/ssr",
"packages/desktop",
"packages/mobile",
]
[[example]]
required-features = ["desktop"]
name = "webview"
path = "./examples/webview.rs"
[[example]]
required-features = ["desktop"]
name = "tailwind"
path = "./examples/tailwind.rs"
# [patch.crates-io]
# wasm-bindgen = { path = "../Tinkering/wasm-bindgen" }

View file

@ -85,6 +85,18 @@ If you know React, then you already know Dioxus.
<tr>
</table>
Available cargo features:
- default: core (macro, hooks, html)
- macro: support for `Props` and `rsx` macros
- hooks: foundational hooks like `use_state`, `use_ref`, etc.
- html: the entire namespace of `html` elements, their listeners, and attributes
- router: a cross-platform (web and desktop) solution for global app routing
- liveview: a threadpool to spawn new VirtualDoms and their handles in
- ssr: render the virtualdom to a string
- web: render the your app on the web
- desktop: render your app locally rendered with webview
- mobile: render your app on your device rendered with webview
## Examples:
| File Navigator (Desktop) | Bluetooth scanner (Desktop) | TodoMVC (All platforms) | Tailwind (Liveview) |

View file

@ -51,9 +51,10 @@ dioxus-html = { path = "../html" }
fern = { version = "0.6.0", features = ["colored"] }
rand = { version = "0.8.4", features = ["small_rng"] }
simple_logger = "1.13.0"
dioxus-core-macro = { path = "../core-macro", version ="^0.1.2"}
dioxus-core-macro = { path = "../core-macro", version = "^0.1.2" }
# dioxus-hooks = { path = "../hooks" }
criterion = "0.3.5"
thiserror = "1.0.30"
[features]
default = []

View file

@ -0,0 +1,10 @@
//! Handling errors and early aborts
//!
//!
//!
//!
use dioxus_core::prelude::*;
use thiserror::Error;
fn main() {}

View file

@ -20,7 +20,47 @@ pub(crate) mod innerlude {
pub(crate) use crate::scopearena::*;
pub use crate::virtual_dom::*;
/// 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.
pub type Element<'a> = Option<VNode<'a>>;
/// 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| {
/// // ...
/// };
/// ```
pub type Component<P> = for<'a> fn(Scope<'a, P>) -> Element<'a>;
}

View file

@ -1,6 +1,6 @@
[package]
name = "dioxus-desktop"
version = "0.0.0"
version = "0.1.0"
authors = ["Jonathan Kelley"]
edition = "2018"
description = "Dioxus VirtualDOM renderer for a remote webview instance"
@ -12,7 +12,7 @@ keywords = ["dom", "ui", "gui", "react", "wasm"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus-core = { path = "../core", version ="^0.1.3", features = ["serialize"] }
dioxus-core = { path = "../core", version = "^0.1.3", features = ["serialize"] }
argh = "0.1.4"
serde = "1.0.120"
serde_json = "1.0.61"
@ -20,7 +20,7 @@ thiserror = "1.0.23"
log = "0.4.13"
html-escape = "0.2.9"
wry = "0.12.2"
futures-channel = "0.3.18"
futures-channel = "0.3"
tokio = { version = "1.12.0", features = [
"sync",
"rt-multi-thread",

View file

@ -1,16 +1,10 @@
//! Dioxus Desktop Renderer
//!
//! Render the Dioxus VirtualDom using the platform's native WebView implementation.
//!
mod cfg;
mod escape;
mod events;
pub use wry;
pub use wry::application as tao;
// mod desktop_context;
use cfg::DesktopConfig;
use dioxus_core::*;
use std::{
@ -18,15 +12,17 @@ use std::{
sync::atomic::AtomicBool,
sync::{Arc, RwLock},
};
use tao::{
accelerator::{Accelerator, SysMods},
event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoop, EventLoopWindowTarget},
keyboard::{KeyCode, ModifiersState},
menu::{MenuBar, MenuItem},
window::{Window, WindowId},
};
pub use wry;
pub use wry::application as tao;
use wry::{
application::{
accelerator::{Accelerator, SysMods},
event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoop, EventLoopWindowTarget},
keyboard::{KeyCode, ModifiersState},
menu::{MenuBar, MenuItem},
window::{Window, WindowId},
},
webview::RpcRequest,
webview::{WebView, WebViewBuilder},
};

View file

@ -12,8 +12,7 @@ keywords = ["dom", "ui", "gui", "react", "wasm"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus-core = { path = "../core", version ="^0.1.3"}
# Serialize the Edits for use in Webview/Liveview instances
dioxus-core = { path = "../core", version = "^0.1.3" }
serde = { version = "1", features = ["derive"], optional = true }
serde_repr = { version = "0.1.7", optional = true }

View file

@ -11,9 +11,9 @@ keywords = ["dom", "ui", "gui", "react", "wasm"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus-core = { path = "../core", version ="^0.1.3", default-features = false }
dioxus-html = { path = "../html", version ="^0.1.0", default-features = false }
dioxus-core-macro = { path = "../core-macro", version ="^0.1.2"}
dioxus-core = { path = "../core", version = "^0.1.3", default-features = false }
dioxus-html = { path = "../html", version = "^0.1.0", default-features = false }
dioxus-core-macro = { path = "../core-macro", version = "^0.1.2" }
web-sys = { version = "0.3", features = [
"Attr",
@ -33,7 +33,7 @@ serde_urlencoded = "0.7"
wasm-bindgen = "0.2"
js-sys = "0.3"
gloo = "0.5"
gloo = "0.4"
route-recognizer = "0.3.1"
url = "2.2.2"
url_serde = "0.2.0"

View file

@ -182,9 +182,6 @@
//! We've put a lot of work into making Dioxus ergonomic and *familiar*.
//! Our target audience is TypeSrcipt developers looking to switch to Rust for the web - so we need to be comparabale to React.
// 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.
#[cfg(feature = "core")]
pub use dioxus_core as core;
#[cfg(feature = "hooks")]