Merge branch 'master' into router-typesafe

This commit is contained in:
Evan Almloff committed 2023-06-28 08:56:07 -07:00
1 parent 0600a1bb49
commit 7b1f0c9412
33 files changed
+370 -303

No files matched your search

+41 -6
View File
@@ -37,6 +37,41 @@ members = [
"examples/PWA-example", "examples/PWA-example",
] ]
# dependencies that are shared across packages
[workspace.dependencies]
dioxus = { path = "packages/dioxus" }
dioxus-core = { path = "packages/core" }
dioxus-core-macro = { path = "packages/core-macro" }
dioxus-router = { path = "packages/router" }
dioxus-router-macro = { path = "packages/router-macro" }
dioxus-html = { path = "packages/html" }
dioxus-hooks = { path = "packages/hooks" }
dioxus-web = { path = "packages/web" }
dioxus-ssr = { path = "packages/ssr" }
dioxus-desktop = { path = "packages/desktop" }
dioxus-mobile = { path = "packages/mobile" }
dioxus-interpreter-js = { path = "packages/interpreter" }
fermi = { path = "packages/fermi" }
dioxus-liveview = { path = "packages/liveview" }
dioxus-autofmt = { path = "packages/autofmt" }
dioxus-rsx = { path = "packages/rsx" }
dioxus-tui = { path = "packages/dioxus-tui" }
rink = { path = "packages/rink" }
dioxus-native-core = { path = "packages/native-core" }
dioxus-native-core-macro = { path = "packages/native-core-macro" }
dioxus-rsx-rosetta = { path = "packages/rsx-rosetta" }
dioxus-signals = { path = "packages/signals" }
dioxus-hot-reload = { path = "packages/hot-reload" }
dioxus-fullstack = { path = "packages/fullstack" }
dioxus_server_macro = { path = "packages/fullstack/server-macro" }
log = "0.4.19"
tokio = "1.28"
slab = "0.4.2"
futures-channel = "0.3.21"
futures-util = { version = "0.3", default-features = false }
rustc-hash = "1.1.0"
wasm-bindgen = "0.2.79"
# This is a "virtual package" # This is a "virtual package"
# It is not meant to be published, but is used so "cargo run --example XYZ" works properly # It is not meant to be published, but is used so "cargo run --example XYZ" works properly
[package] [package]
@@ -54,12 +89,12 @@ rust-version = "1.60.0"
publish = false publish = false
[dev-dependencies] [dev-dependencies]
dioxus = { path = "./packages/dioxus" } dioxus = { workspace = true }
dioxus-desktop = { path = "./packages/desktop", features = ["transparent"] } dioxus-desktop = { workspace = true, features = ["transparent"] }
dioxus-ssr = { path = "./packages/ssr" } dioxus-ssr = { workspace = true }
dioxus-router = { path = "./packages/router" } dioxus-router = { workspace = true }
dioxus-signals = { path = "./packages/signals" } dioxus-signals = { workspace = true }
fermi = { path = "./packages/fermi" } fermi = { workspace = true }
futures-util = "0.3.21" futures-util = "0.3.21"
log = "0.4.14" log = "0.4.14"
num-format = "0.4.0" num-format = "0.4.0"
+1 -1
View File
@@ -12,7 +12,7 @@ keywords = ["dom", "ui", "gui", "react"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-rsx = { path = "../rsx", version = "^0.0.3" } dioxus-rsx = { workspace = true }
proc-macro2 = { version = "1.0.6", features = ["span-locations"] } proc-macro2 = { version = "1.0.6", features = ["span-locations"] }
quote = "1.0" quote = "1.0"
syn = { version = "1.0.11", features = ["full", "extra-traits"] } syn = { version = "1.0.11", features = ["full", "extra-traits"] }
+1 -1
View File
@@ -18,7 +18,7 @@ proc-macro = true
proc-macro2 = { version = "1.0" } proc-macro2 = { version = "1.0" }
quote = "1.0" quote = "1.0"
syn = { version = "1.0", features = ["full", "extra-traits"] } syn = { version = "1.0", features = ["full", "extra-traits"] }
dioxus-rsx = { path = "../rsx", version = "^0.0.3" } dioxus-rsx = { workspace = true }
# testing # testing
[dev-dependencies] [dev-dependencies]
+7 -7
View File
@@ -18,23 +18,23 @@ keywords = ["dom", "ui", "gui", "react"]
bumpalo = { version = "3.6", features = ["collections", "boxed"] } bumpalo = { version = "3.6", features = ["collections", "boxed"] }
# faster hashmaps # faster hashmaps
rustc-hash = "1.1.0" rustc-hash = { workspace = true }
# Used in diffing # Used in diffing
longest-increasing-subsequence = "0.1.0" longest-increasing-subsequence = "0.1.0"
futures-util = { version = "0.3", default-features = false, features = [ futures-util = { workspace = true, default-features = false, features = [
"alloc", "alloc",
] } ] }
slab = "0.4" slab = { workspace = true }
futures-channel = "0.3.21" futures-channel = { workspace = true }
indexmap = "1.7" indexmap = "1.7"
smallbox = "0.8.1" smallbox = "0.8.1"
log = "0.4.17" log = { workspace = true }
# Serialize the Edits for use in Webview/Liveview instances # Serialize the Edits for use in Webview/Liveview instances
serde = { version = "1", features = ["derive"], optional = true } serde = { version = "1", features = ["derive"], optional = true }
@@ -42,8 +42,8 @@ serde = { version = "1", features = ["derive"], optional = true }
bumpslab = { version = "0.2.0" } bumpslab = { version = "0.2.0" }
[dev-dependencies] [dev-dependencies]
tokio = { version = "1", features = ["full"] } tokio = { workspace = true, features = ["full"] }
dioxus = { path = "../dioxus" } dioxus = { workspace = true }
pretty_assertions = "1.3.0" pretty_assertions = "1.3.0"
rand = "0.8.5" rand = "0.8.5"
+13 -13
View File
@@ -12,31 +12,31 @@ keywords = ["dom", "ui", "gui", "react"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-core = { path = "../core", version = "^0.3.0", features = ["serialize"] } dioxus-core = { workspace = true, features = ["serialize"] }
dioxus-html = { path = "../html", features = ["serialize", "native-bind"], version = "^0.3.0" } dioxus-html = { workspace = true, features = ["serialize", "native-bind"] }
dioxus-interpreter-js = { path = "../interpreter", version = "^0.3.0" } dioxus-interpreter-js = { workspace = true }
dioxus-hot-reload = { path = "../hot-reload", optional = true } dioxus-hot-reload = { workspace = true, optional = true }
serde = "1.0.136" serde = "1.0.136"
serde_json = "1.0.79" serde_json = "1.0.79"
thiserror = "1.0.30" thiserror = "1.0.30"
log = "0.4.14" log = { workspace = true }
wry = { version = "0.27.2" } wry = { version = "0.27.2" }
futures-channel = "0.3.21" futures-channel = { workspace = true }
tokio = { version = "1.27", features = [ tokio = { workspace = true, features = [
"sync", "sync",
"rt-multi-thread", "rt-multi-thread",
"rt", "rt",
"time", "time",
"macros", "macros",
"fs", "fs",
], optional = true, default-features = false } ], optional = true }
webbrowser = "0.8.0" webbrowser = "0.8.0"
infer = "0.11.0" infer = "0.11.0"
dunce = "1.0.2" dunce = "1.0.2"
slab = "0.4" slab = { workspace = true }
futures-util = "0.3.25" futures-util = { workspace = true }
rfd = "0.11.3" rfd = "0.11.3"
urlencoding = "2.1.2" urlencoding = "2.1.2"
@@ -56,9 +56,9 @@ tray = ["wry/tray"]
hot-reload = ["dioxus-hot-reload"] hot-reload = ["dioxus-hot-reload"]
[dev-dependencies] [dev-dependencies]
dioxus-core-macro = { path = "../core-macro" } dioxus-core-macro = { workspace = true }
dioxus-hooks = { path = "../hooks" } dioxus-hooks = { workspace = true }
dioxus = { path = "../dioxus" } dioxus = { workspace = true }
exitcode = "1.1.2" exitcode = "1.1.2"
scraper = "0.16.0" scraper = "0.16.0"
+10
View File
@@ -23,6 +23,7 @@ pub struct Config {
pub(crate) custom_head: Option<String>, pub(crate) custom_head: Option<String>,
pub(crate) custom_index: Option<String>, pub(crate) custom_index: Option<String>,
pub(crate) root_name: String, pub(crate) root_name: String,
pub(crate) background_color: Option<(u8, u8, u8, u8)>,
} }
type DropHandler = Box<dyn Fn(&Window, FileDropEvent) -> bool>; type DropHandler = Box<dyn Fn(&Window, FileDropEvent) -> bool>;
@@ -50,6 +51,7 @@ impl Config {
custom_head: None, custom_head: None,
custom_index: None, custom_index: None,
root_name: "main".to_string(), root_name: "main".to_string(),
background_color: None,
} }
} }
@@ -137,6 +139,14 @@ impl Config {
self.root_name = name.into(); self.root_name = name.into();
self self
} }
/// Sets the background color of the WebView.
/// This will be set before the HTML is rendered and can be used to prevent flashing when the page loads.
/// Accepts a color in RGBA format
pub fn with_background_color(mut self, color: (u8, u8, u8, u8)) -> Self {
self.background_color = Some(color);
self
}
} }
impl Default for Config { impl Default for Config {
+4
View File
@@ -64,6 +64,10 @@ pub fn build(
webview = webview.with_browser_accelerator_keys(false); webview = webview.with_browser_accelerator_keys(false);
} }
if let Some(color) = cfg.background_color {
webview = webview.with_background_color(color);
}
// These are commented out because wry is currently broken in wry // These are commented out because wry is currently broken in wry
// let mut web_context = WebContext::new(cfg.data_dir.clone()); // let mut web_context = WebContext::new(cfg.data_dir.clone());
// .with_web_context(&mut web_context); // .with_web_context(&mut web_context);
+9 -9
View File
@@ -13,21 +13,21 @@ license = "MIT/Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus = { path = "../dioxus", version = "^0.3.0" } dioxus = { workspace = true }
dioxus-core = { path = "../core", version = "^0.3.0", features = ["serialize"] } dioxus-core = { workspace = true, features = ["serialize"] }
dioxus-html = { path = "../html", version = "^0.3.0" } dioxus-html = { workspace = true }
dioxus-native-core = { path = "../native-core", version = "^0.2.0", features = ["dioxus"] } dioxus-native-core = { workspace = true, features = ["dioxus"] }
dioxus-native-core-macro = { path = "../native-core-macro", version = "^0.3.0" } dioxus-native-core-macro = { workspace = true }
dioxus-hot-reload = { path = "../hot-reload", optional = true } dioxus-hot-reload = { workspace = true, optional = true }
rink = { path = "../rink" } rink = { workspace = true }
crossterm = "0.23.0" crossterm = "0.23.0"
tokio = { version = "1.15.0", features = ["full"] } tokio = { workspace = true, features = ["full"] }
futures = "0.3.19" futures = "0.3.19"
taffy = "0.3.12" taffy = "0.3.12"
[dev-dependencies] [dev-dependencies]
dioxus = { path = "../dioxus" } dioxus = { workspace = true }
tokio = { version = "1" } tokio = { version = "1" }
criterion = "0.3.5" criterion = "0.3.5"
+10 -10
View File
@@ -12,14 +12,14 @@ keywords = ["dom", "ui", "gui", "react", "wasm"]
rust-version = "1.65.0" rust-version = "1.65.0"
[dependencies] [dependencies]
dioxus-core = { path = "../core", version = "^0.3.0" } dioxus-core = { workspace = true }
dioxus-html = { path = "../html", version = "^0.3.0", optional = true } dioxus-html = { workspace = true, optional = true }
dioxus-core-macro = { path = "../core-macro", version = "^0.3.0", optional = true } dioxus-core-macro = { workspace = true, optional = true }
dioxus-hooks = { path = "../hooks", version = "^0.3.0", optional = true } dioxus-hooks = { workspace = true, optional = true }
dioxus-rsx = { path = "../rsx", version = "^0.0.3", optional = true } dioxus-rsx = { workspace = true, optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
dioxus-hot-reload = { path = "../hot-reload", version = "0.1.0", optional = true } dioxus-hot-reload = { workspace = true, optional = true }
[features] [features]
default = ["macro", "hooks", "html", "hot-reload"] default = ["macro", "hooks", "html", "hot-reload"]
@@ -30,14 +30,14 @@ hot-reload = ["dioxus-hot-reload"]
[dev-dependencies] [dev-dependencies]
futures-util = "0.3.21" futures-util = { workspace = true }
log = "0.4.14" log = { workspace = true }
rand = { version = "0.8.4", features = ["small_rng"] } rand = { version = "0.8.4", features = ["small_rng"] }
criterion = "0.3.5" criterion = "0.3.5"
thiserror = "1.0.30" thiserror = "1.0.30"
env_logger = "0.10.0" env_logger = "0.10.0"
tokio = { version = "1.21.2", features = ["full"] } tokio = { workspace = true, features = ["full"] }
# dioxus-edit-stream = { path = "../edit-stream" } # dioxus-edit-stream = { workspace = true }
[[bench]] [[bench]]
+2 -2
View File
@@ -13,9 +13,9 @@ keywords = ["dom", "ui", "gui", "react", "state-management"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-core = { path = "../core", version = "^0.3.0" } dioxus-core = { workspace = true }
im-rc = { version = "15.0.0", features = ["serde"] } im-rc = { version = "15.0.0", features = ["serde"] }
log = "0.4.14" log = { workspace = true }
[dev-dependencies] [dev-dependencies]
closure = "0.3.0" closure = "0.3.0"
+6 -6
View File
@@ -9,22 +9,22 @@
<div align="center"> <div align="center">
<!-- Crates version --> <!-- Crates version -->
<a href="https://crates.io/crates/dioxus"> <a href="https://crates.io/crates/fermi">
<img src="https://img.shields.io/crates/v/dioxus.svg?style=flat-square" <img src="https://img.shields.io/crates/v/fermi.svg?style=flat-square"
alt="Crates.io version" /> alt="Crates.io version" />
</a> </a>
<!-- Downloads --> <!-- Downloads -->
<a href="https://crates.io/crates/dioxus"> <a href="https://crates.io/crates/fermi">
<img src="https://img.shields.io/crates/d/dioxus.svg?style=flat-square" <img src="https://img.shields.io/crates/d/fermi.svg?style=flat-square"
alt="Download" /> alt="Download" />
</a> </a>
<!-- docs --> <!-- docs -->
<a href="https://docs.rs/dioxus"> <a href="https://docs.rs/fermi">
<img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square" <img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square"
alt="docs.rs docs" /> alt="docs.rs docs" />
</a> </a>
<!-- CI --> <!-- CI -->
<a href="https://github.com/jkelleyrtp/dioxus/actions"> <a href="https://github.com/DioxusLabs/dioxus/actions">
<img src="https://github.com/dioxuslabs/dioxus/actions/workflows/main.yml/badge.svg" <img src="https://github.com/dioxuslabs/dioxus/actions/workflows/main.yml/badge.svg"
alt="CI status" /> alt="CI status" />
</a> </a>
+7 -7
View File
@@ -30,30 +30,30 @@ salvo = { version = "0.37.7", optional = true, features = ["serve-static", "ws"]
serde = "1.0.159" serde = "1.0.159"
# Dioxus + SSR # Dioxus + SSR
dioxus = { path = "../dioxus", version = "^0.3.0" } dioxus = { workspace = true }
dioxus-ssr = { path = "../ssr", version = "^0.3.0", optional = true } dioxus-ssr = { workspace = true, optional = true }
hyper = { version = "0.14.25", optional = true } hyper = { version = "0.14.25", optional = true }
http = { version = "0.2.9", optional = true } http = { version = "0.2.9", optional = true }
# Router Intigration # Router Intigration
dioxus-router = { path = "../router", version = "^0.3.0", optional = true } dioxus-router = { workspace = true, optional = true }
log = "0.4.17" log = { workspace = true }
once_cell = "1.17.1" once_cell = "1.17.1"
thiserror = "1.0.40" thiserror = "1.0.40"
tokio = { version = "1.27.0", features = ["full"], optional = true } tokio = { workspace = true, features = ["full"], optional = true }
object-pool = "0.5.4" object-pool = "0.5.4"
anymap = "0.12.1" anymap = "0.12.1"
serde_json = { version = "1.0.95", optional = true } serde_json = { version = "1.0.95", optional = true }
tokio-stream = { version = "0.1.12", features = ["sync"], optional = true } tokio-stream = { version = "0.1.12", features = ["sync"], optional = true }
futures-util = { version = "0.3.28", optional = true } futures-util = { workspace = true, optional = true }
postcard = { version = "1.0.4", features = ["use-std"] } postcard = { version = "1.0.4", features = ["use-std"] }
yazi = "0.1.5" yazi = "0.1.5"
base64 = "0.21.0" base64 = "0.21.0"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
dioxus-hot-reload = { path = "../hot-reload" } dioxus-hot-reload = { workspace = true }
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys = { version = "0.3.61", features = ["Window", "Document", "Element", "HtmlDocument", "Storage", "console"] } web-sys = { version = "0.3.61", features = ["Window", "Document", "Element", "HtmlDocument", "Storage", "console"] }
@@ -7,12 +7,12 @@ publish = false
[lib] [lib]
[dependencies] [dependencies]
dioxus-desktop = { path = "../../../desktop", optional = true } dioxus-desktop = { workspace = true, optional = true }
dioxus = { path = "../../../dioxus" } dioxus = { workspace = true }
dioxus-router = { path = "../../../router" } dioxus-router = { workspace = true }
dioxus-fullstack = { path = "../../" } dioxus-fullstack = { workspace = true }
axum = { version = "0.6.12", optional = true } axum = { version = "0.6.12", optional = true }
tokio = { version = "1.27.0", features = ["full"], optional = true } tokio = { workspace = true, features = ["full"], optional = true }
serde = "1.0.159" serde = "1.0.159"
[features] [features]
@@ -7,11 +7,11 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true } dioxus-web = { workspace = true, features=["hydrate"], optional = true }
dioxus = { path = "../../../dioxus" } dioxus = { workspace = true }
dioxus-fullstack = { path = "../../" } dioxus-fullstack = { workspace = true }
axum = { version = "0.6.12", optional = true } axum = { version = "0.6.12", optional = true }
tokio = { version = "1.27.0", features = ["full"], optional = true } tokio = { workspace = true, features = ["full"], optional = true }
serde = "1.0.159" serde = "1.0.159"
execute = "0.2.12" execute = "0.2.12"
@@ -7,12 +7,12 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-web = { path = "../../../web", features = ["hydrate"], optional = true } dioxus-web = { workspace = true, features = ["hydrate"], optional = true }
dioxus = { path = "../../../dioxus" } dioxus = { workspace = true }
dioxus-router = { path = "../../../router" } dioxus-router = { workspace = true}
dioxus-fullstack = { path = "../../", features = ["router"] } dioxus-fullstack = { workspace = true, features = ["router"] }
axum = { version = "0.6.12", optional = true } axum = { version = "0.6.12", optional = true }
tokio = { version = "1.27.0", features = ["full"], optional = true } tokio = {workspace = true, features = ["full"], optional = true }
serde = { version = "1.0.159", features = ["derive"] } serde = { version = "1.0.159", features = ["derive"] }
[features] [features]
@@ -7,10 +7,10 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true } dioxus-web = { workspace = true, features=["hydrate"], optional = true }
dioxus = { path = "../../../dioxus" } dioxus = { workspace = true }
dioxus-fullstack = { path = "../../" } dioxus-fullstack = { workspace = true }
tokio = { version = "1.27.0", features = ["full"], optional = true } tokio = { workspace = true, features = ["full"], optional = true }
serde = "1.0.159" serde = "1.0.159"
salvo = { version = "0.37.9", optional = true } salvo = { version = "0.37.9", optional = true }
execute = "0.2.12" execute = "0.2.12"
@@ -7,10 +7,10 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-web = { path = "../../../web", features=["hydrate"], optional = true } dioxus-web = { workspace = true, features=["hydrate"], optional = true }
dioxus = { path = "../../../dioxus" } dioxus = { workspace = true }
dioxus-fullstack = { path = "../../" } dioxus-fullstack = { workspace = true }
tokio = { version = "1.27.0", features = ["full"], optional = true } tokio = { workspace = true, features = ["full"], optional = true }
serde = "1.0.159" serde = "1.0.159"
warp = { version = "0.3.3", optional = true } warp = { version = "0.3.3", optional = true }
execute = "0.2.12" execute = "0.2.12"
+6 -6
View File
@@ -12,12 +12,12 @@ keywords = ["dom", "ui", "gui", "react"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-core = { path = "../../packages/core", version = "^0.3.0" } dioxus-core = { workspace = true }
futures-channel = "0.3.21" futures-channel = { workspace = true }
log = "0.4" log = { workspace = true }
[dev-dependencies] [dev-dependencies]
futures-util = { version = "0.3", default-features = false } futures-util = { workspace = true, default-features = false }
dioxus-core = { path = "../../packages/core", version = "^0.3.0" } dioxus-core = { workspace = true }
dioxus = { path = "../../packages/dioxus", version = "^0.3.0" } dioxus = { workspace = true }
+3 -3
View File
@@ -12,9 +12,9 @@ keywords = ["dom", "ui", "gui", "react", "hot-reloading"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-rsx = { path = "../rsx" , version = "^0.0.3" } dioxus-rsx = { workspace = true }
dioxus-core = { path = "../core", features = ["serialize"], version = "^0.3.2"} dioxus-core = { workspace = true, features = ["serialize"] }
dioxus-html = { path = "../html", features = ["hot-reload-context"], version = "^0.3.0" } dioxus-html = { workspace = true, features = ["hot-reload-context"] }
interprocess = { version = "1.2.1" } interprocess = { version = "1.2.1" }
notify = "5.0.0" notify = "5.0.0"
+168 -150
View File
@@ -159,172 +159,190 @@ pub fn init<Ctx: HotReloadingContext + Send + 'static>(cfg: Config<Ctx>) {
} }
let file_map = Arc::new(Mutex::new(file_map)); let file_map = Arc::new(Mutex::new(file_map));
if let Ok(local_socket_stream) = LocalSocketListener::bind("@dioxusin") { #[cfg(target_os = "macos")]
let aborted = Arc::new(Mutex::new(false)); {
// On unix, if you force quit the application, it can leave the file socket open
// listen for connections // This will cause the local socket listener to fail to open
std::thread::spawn({ // We check if the file socket is already open from an old session and then delete it
let file_map = file_map.clone(); let paths = ["./dioxusin", "./@dioxusin"];
let channels = channels.clone(); for path in paths {
let aborted = aborted.clone(); let path = PathBuf::from(path);
let _ = local_socket_stream.set_nonblocking(true); if path.exists() {
move || { let _ = std::fs::remove_file(path);
loop {
if let Ok(mut connection) = local_socket_stream.accept() {
// send any templates than have changed before the socket connected
let templates: Vec<_> = {
file_map
.lock()
.unwrap()
.map
.values()
.filter_map(|(_, template_slot)| *template_slot)
.collect()
};
for template in templates {
if !send_msg(
HotReloadMsg::UpdateTemplate(template),
&mut connection,
) {
continue;
}
}
channels.lock().unwrap().push(connection);
if log {
println!("Connected to hot reloading 🚀");
}
}
if *aborted.lock().unwrap() {
break;
}
}
} }
}); }
}
// watch for changes match LocalSocketListener::bind("@dioxusin") {
std::thread::spawn(move || { Ok(local_socket_stream) => {
let mut last_update_time = chrono::Local::now().timestamp(); let aborted = Arc::new(Mutex::new(false));
let (tx, rx) = std::sync::mpsc::channel(); // listen for connections
std::thread::spawn({
let mut watcher = RecommendedWatcher::new(tx, notify::Config::default()).unwrap(); let file_map = file_map.clone();
for path in listening_paths {
let full_path = crate_dir.join(path);
if let Err(err) = watcher.watch(&full_path, RecursiveMode::Recursive) {
if log {
println!(
"hot reloading failed to start watching {full_path:?}:\n{err:?}",
);
}
}
}
let mut rebuild = {
let aborted = aborted.clone();
let channels = channels.clone(); let channels = channels.clone();
let aborted = aborted.clone();
let _ = local_socket_stream.set_nonblocking(true);
move || { move || {
if let Some(rebuild_callback) = &mut rebuild_with { loop {
if log { if let Ok(mut connection) = local_socket_stream.accept() {
println!("Rebuilding the application..."); // send any templates than have changed before the socket connected
} let templates: Vec<_> = {
let shutdown = rebuild_callback(); file_map
.lock()
if shutdown { .unwrap()
*aborted.lock().unwrap() = true; .map
} .values()
.filter_map(|(_, template_slot)| *template_slot)
for channel in &mut *channels.lock().unwrap() { .collect()
send_msg(HotReloadMsg::Shutdown, channel); };
} for template in templates {
if !send_msg(
return shutdown; HotReloadMsg::UpdateTemplate(template),
} else if log { &mut connection,
println!( ) {
"Rebuild needed... shutting down hot reloading.\nManually rebuild the application to view futher changes." continue;
); }
}
true
}
};
for evt in rx {
if chrono::Local::now().timestamp_millis() >= last_update_time {
if let Ok(evt) = evt {
let real_paths = evt
.paths
.iter()
.filter(|path| {
// skip non rust files
matches!(
path.extension().and_then(|p| p.to_str()),
Some("rs" | "toml" | "css" | "html" | "js")
) &&
// skip excluded paths
!excluded_paths.iter().any(|p| path.starts_with(p)) &&
// respect .gitignore
!gitignore
.matched_path_or_any_parents(path, false)
.is_ignore()
})
.collect::<Vec<_>>();
// Give time for the change to take effect before reading the file
if !real_paths.is_empty() {
std::thread::sleep(std::time::Duration::from_millis(10));
}
let mut channels = channels.lock().unwrap();
for path in real_paths {
// if this file type cannot be hot reloaded, rebuild the application
if path.extension().and_then(|p| p.to_str()) != Some("rs")
&& rebuild()
{
return;
} }
// find changes to the rsx in the file channels.lock().unwrap().push(connection);
match file_map if log {
.lock() println!("Connected to hot reloading 🚀");
.unwrap() }
.update_rsx(path, crate_dir.as_path()) }
{ if *aborted.lock().unwrap() {
Ok(UpdateResult::UpdatedRsx(msgs)) => { break;
for msg in msgs { }
let mut i = 0; }
while i < channels.len() { }
let channel = &mut channels[i]; });
if send_msg(
HotReloadMsg::UpdateTemplate(msg), // watch for changes
channel, std::thread::spawn(move || {
) { let mut last_update_time = chrono::Local::now().timestamp();
i += 1;
} else { let (tx, rx) = std::sync::mpsc::channel();
channels.remove(i);
let mut watcher =
RecommendedWatcher::new(tx, notify::Config::default()).unwrap();
for path in listening_paths {
let full_path = crate_dir.join(path);
if let Err(err) = watcher.watch(&full_path, RecursiveMode::Recursive) {
if log {
println!(
"hot reloading failed to start watching {full_path:?}:\n{err:?}",
);
}
}
}
let mut rebuild = {
let aborted = aborted.clone();
let channels = channels.clone();
move || {
if let Some(rebuild_callback) = &mut rebuild_with {
if log {
println!("Rebuilding the application...");
}
let shutdown = rebuild_callback();
if shutdown {
*aborted.lock().unwrap() = true;
}
for channel in &mut *channels.lock().unwrap() {
send_msg(HotReloadMsg::Shutdown, channel);
}
return shutdown;
} else if log {
println!(
"Rebuild needed... shutting down hot reloading.\nManually rebuild the application to view futher changes."
);
}
true
}
};
for evt in rx {
if chrono::Local::now().timestamp_millis() >= last_update_time {
if let Ok(evt) = evt {
let real_paths = evt
.paths
.iter()
.filter(|path| {
// skip non rust files
matches!(
path.extension().and_then(|p| p.to_str()),
Some("rs" | "toml" | "css" | "html" | "js")
) &&
// skip excluded paths
!excluded_paths.iter().any(|p| path.starts_with(p)) &&
// respect .gitignore
!gitignore
.matched_path_or_any_parents(path, false)
.is_ignore()
})
.collect::<Vec<_>>();
// Give time for the change to take effect before reading the file
if !real_paths.is_empty() {
std::thread::sleep(std::time::Duration::from_millis(10));
}
let mut channels = channels.lock().unwrap();
for path in real_paths {
// if this file type cannot be hot reloaded, rebuild the application
if path.extension().and_then(|p| p.to_str()) != Some("rs")
&& rebuild()
{
return;
}
// find changes to the rsx in the file
match file_map
.lock()
.unwrap()
.update_rsx(path, crate_dir.as_path())
{
Ok(UpdateResult::UpdatedRsx(msgs)) => {
for msg in msgs {
let mut i = 0;
while i < channels.len() {
let channel = &mut channels[i];
if send_msg(
HotReloadMsg::UpdateTemplate(msg),
channel,
) {
i += 1;
} else {
channels.remove(i);
}
} }
} }
} }
} Ok(UpdateResult::NeedsRebuild) => {
Ok(UpdateResult::NeedsRebuild) => { drop(channels);
drop(channels); if rebuild() {
if rebuild() { return;
return; }
break;
} }
break; Err(err) => {
} if log {
Err(err) => { println!(
if log { "hot reloading failed to update rsx:\n{err:?}"
println!( );
"hot reloading failed to update rsx:\n{err:?}" }
);
} }
} }
} }
} }
last_update_time = chrono::Local::now().timestamp_millis();
} }
last_update_time = chrono::Local::now().timestamp_millis();
} }
} });
}); }
Err(error) => println!("failed to connect to hot reloading\n{error}"),
} }
} }
} }
+4 -4
View File
@@ -11,17 +11,17 @@ documentation = "https://dioxuslabs.com"
keywords = ["dom", "ui", "gui", "react"] keywords = ["dom", "ui", "gui", "react"]
[dependencies] [dependencies]
dioxus-core = { path = "../core", version = "^0.3.0" } dioxus-core = { workspace = true }
dioxus-rsx = { path = "../rsx", version = "^0.0.3", optional = true } dioxus-rsx = { workspace = true, optional = true }
serde = { version = "1", features = ["derive"], optional = true } serde = { version = "1", features = ["derive"], optional = true }
serde_repr = { version = "0.1", optional = true } serde_repr = { version = "0.1", optional = true }
wasm-bindgen = { version = "0.2.79", optional = true } wasm-bindgen = { workspace = true, optional = true }
euclid = "0.22.7" euclid = "0.22.7"
enumset = "1.0.11" enumset = "1.0.11"
keyboard-types = "0.6.2" keyboard-types = "0.6.2"
async-trait = "0.1.58" async-trait = "0.1.58"
serde-value = "0.7.0" serde-value = "0.7.0"
tokio = { version = "1.27", features = ["fs", "io-util"], optional = true } tokio = { workspace = true, features = ["fs", "io-util"], optional = true }
rfd = { version = "0.11.3", optional = true } rfd = { version = "0.11.3", optional = true }
[dependencies.web-sys] [dependencies.web-sys]
+1 -1
View File
@@ -13,7 +13,7 @@ keywords = ["dom", "ui", "gui", "react", "wasm"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
wasm-bindgen = { version = "0.2.79", optional = true } wasm-bindgen = { workspace = true, optional = true }
js-sys = { version = "0.3.56", optional = true } js-sys = { version = "0.3.56", optional = true }
web-sys = { version = "0.3.56", optional = true, features = ["Element", "Node"] } web-sys = { version = "0.3.56", optional = true, features = ["Element", "Node"] }
sledgehammer_bindgen = { version = "0.2.1", optional = true } sledgehammer_bindgen = { version = "0.2.1", optional = true }
+11 -11
View File
@@ -14,21 +14,21 @@ license = "MIT/Apache-2.0"
[dependencies] [dependencies]
thiserror = "1.0.38" thiserror = "1.0.38"
log = "0.4.14" log = { workspace = true }
slab = "0.4" slab = { workspace = true }
futures-util = { version = "0.3.25", default-features = false, features = [ futures-util = { workspace = true, default-features = false, features = [
"sink", "sink",
] } ] }
futures-channel = { version = "0.3.25", features = ["sink"] } futures-channel = { workspace = true }
tokio = { version = "1.22.0", features = ["time", "macros"] } tokio = { workspace = true, features = ["time", "macros"] }
tokio-stream = { version = "0.1.11", features = ["net"] } tokio-stream = { version = "0.1.11", features = ["net"] }
tokio-util = { version = "0.7.4", features = ["rt"] } tokio-util = { version = "0.7.4", features = ["rt"] }
serde = { version = "1.0.151", features = ["derive"] } serde = { version = "1.0.151", features = ["derive"] }
serde_json = "1.0.91" serde_json = "1.0.91"
dioxus-html = { path = "../html", features = ["serialize"], version = "^0.3.0" } dioxus-html = { workspace = true, features = ["serialize"] }
dioxus-core = { path = "../core", features = ["serialize"], version = "^0.3.0" } dioxus-core = { workspace = true, features = ["serialize"] }
dioxus-interpreter-js = { path = "../interpreter", version = "0.3.0" } dioxus-interpreter-js = { workspace = true }
dioxus-hot-reload = { path = "../hot-reload", optional = true } dioxus-hot-reload = { workspace = true, optional = true }
# warp # warp
warp = { version = "0.3.3", optional = true } warp = { version = "0.3.3", optional = true }
@@ -47,8 +47,8 @@ once_cell = "1.17.1"
[dev-dependencies] [dev-dependencies]
pretty_env_logger = { version = "0.5.0" } pretty_env_logger = { version = "0.5.0" }
tokio = { version = "1.22.0", features = ["full"] } tokio = { workspace = true, features = ["full"] }
dioxus = { path = "../dioxus", version = "0.3.0" } dioxus = { workspace = true }
warp = "0.3.3" warp = "0.3.3"
axum = { version = "0.6.1", features = ["ws"] } axum = { version = "0.6.1", features = ["ws"] }
salvo = { version = "0.37.7", features = ["affix", "ws"] } salvo = { version = "0.37.7", features = ["affix", "ws"] }
+1 -1
View File
@@ -12,7 +12,7 @@ license = "MIT/Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-desktop = { path = "../desktop", version = "^0.3.0" } dioxus-desktop = { workspace = true }
[lib] [lib]
doctest = false doctest = false
+3 -3
View File
@@ -20,7 +20,7 @@ quote = "1.0"
[dev-dependencies] [dev-dependencies]
smallvec = "1.6" smallvec = "1.6"
rustc-hash = "1.1.0" rustc-hash = { workspace = true }
anymap = "0.12.1" anymap = "0.12.1"
dioxus = { path = "../dioxus" } dioxus = { workspace = true }
dioxus-native-core = { path = "../native-core" } dioxus-native-core = { workspace = true }
+7 -7
View File
@@ -11,14 +11,14 @@ keywords = ["dom", "ui", "gui", "react"]
[dependencies] [dependencies]
dioxus-core = { path = "../core", version = "^0.3.0", optional = true } dioxus-core = { workspace = true, optional = true }
keyboard-types = "0.6.2" keyboard-types = "0.6.2"
taffy = "0.3.12" taffy = "0.3.12"
smallvec = "1.6" smallvec = "1.6"
rustc-hash = "1.1.0" rustc-hash = { workspace = true }
anymap = "1.0.0-beta.2" anymap = "1.0.0-beta.2"
slab = "0.4" slab = { workspace = true }
parking_lot = { version = "0.12.1", features = ["send_guard"] } parking_lot = { version = "0.12.1", features = ["send_guard"] }
crossbeam-deque = "0.8.2" crossbeam-deque = "0.8.2"
dashmap = "5.4.0" dashmap = "5.4.0"
@@ -32,10 +32,10 @@ shipyard = { version = "0.6.2", features = ["proc", "std"], default-features = f
[dev-dependencies] [dev-dependencies]
rand = "0.8.5" rand = "0.8.5"
dioxus = { path = "../dioxus", version = "^0.3.0" } dioxus = { workspace = true }
tokio = { version = "*", features = ["full"] } tokio = { workspace = true, features = ["full"] }
dioxus-native-core = { path = ".", features = ["dioxus"] } dioxus-native-core = { workspace = true, features = ["dioxus"] }
dioxus-native-core-macro = { path = "../native-core-macro" } dioxus-native-core-macro = { workspace = true }
[features] [features]
default = [] default = []
+6 -6
View File
@@ -13,20 +13,20 @@ license = "MIT/Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-html = { path = "../html", version = "^0.3.0" } dioxus-html = { workspace = true }
dioxus-native-core = { path = "../native-core", version = "^0.2.0" } dioxus-native-core = { workspace = true }
dioxus-native-core-macro = { path = "../native-core-macro", version = "^0.3.0" } dioxus-native-core-macro = { workspace = true }
tui = "0.17.0" tui = "0.17.0"
crossterm = "0.23.0" crossterm = "0.23.0"
anyhow = "1.0.42" anyhow = "1.0.42"
tokio = { version = "1.15.0", features = ["full"] } tokio = { workspace = true, features = ["full"] }
futures = "0.3.19" futures = "0.3.19"
taffy = "0.3.12" taffy = "0.3.12"
smallvec = "1.6" smallvec = "1.6"
rustc-hash = "1.1.0" rustc-hash = { workspace = true }
anymap = "1.0.0-beta.2" anymap = "1.0.0-beta.2"
futures-channel = "0.3.25" futures-channel = { workspace = true }
shipyard = { version = "0.6.2", features = ["proc", "std"], default-features = false } shipyard = { version = "0.6.2", features = ["proc", "std"], default-features = false }
once_cell = "1.17.1" once_cell = "1.17.1"
+9 -9
View File
@@ -12,19 +12,19 @@ keywords = ["dom", "ui", "gui", "react", "wasm"]
[dependencies] [dependencies]
anyhow = "1.0.66" anyhow = "1.0.66"
dioxus = { path="../dioxus" } dioxus = { workspace = true }
dioxus-router-macro = { path="../router-macro" } dioxus-router-macro = { workspace = true }
gloo = { version = "0.8.0", optional = true } gloo = { version = "0.8.0", optional = true }
log = "0.4.17" log = { workspace = true }
serde = { version = "1.0.163", features = ["derive"], optional = true } serde = { version = "1", features = ["derive"], optional = true }
thiserror = "1.0.37" thiserror = "1.0.37"
url = "2.3.1" url = "2.3.1"
wasm-bindgen = { version = "0.2.86", optional = true } wasm-bindgen = { workspace = true, optional = true }
web-sys = { version = "0.3.60", optional = true, features = ["ScrollRestoration"] } web-sys = { version = "0.3.60", optional = true, features = ["ScrollRestoration"] }
js-sys = { version = "0.3.63", optional = true } js-sys = { version = "0.3.63", optional = true }
gloo-utils = { version = "0.1.6", optional = true } gloo-utils = { version = "0.1.6", optional = true }
dioxus-ssr = { path = "../ssr", optional = true } dioxus-ssr = { workspace = true, optional = true }
tokio = { version = "1.28", features = ["full"], optional = true } tokio = { workspace = true, features = ["full"], optional = true }
[features] [features]
default = ["web"] default = ["web"]
@@ -52,8 +52,8 @@ dioxus-desktop = { path = "../desktop" }
[target.'cfg(target_family = "wasm")'.dev-dependencies] [target.'cfg(target_family = "wasm")'.dev-dependencies]
console_error_panic_hook = "0.1.7" console_error_panic_hook = "0.1.7"
dioxus-router = { path = ".", features = ["web"] } dioxus-router = { workspace = true, features = ["web"] }
dioxus-web = { path= "../web" } dioxus-web = { workspace = true }
gloo = "0.8.0" gloo = "0.8.0"
wasm-bindgen-test = "0.3.33" wasm-bindgen-test = "0.3.33"
wasm-logger = "0.2.0" wasm-logger = "0.2.0"
+2 -2
View File
@@ -13,8 +13,8 @@ keywords = ["dom", "ui", "gui", "react"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-autofmt = { path = "../autofmt", version = "0.3.0" } dioxus-autofmt = { workspace = true }
dioxus-rsx = { path = "../rsx" , version = "^0.0.3" } dioxus-rsx = { workspace = true }
html_parser = "0.6.3" html_parser = "0.6.3"
proc-macro2 = "1.0.49" proc-macro2 = "1.0.49"
quote = "1.0.23" quote = "1.0.23"
+1 -1
View File
@@ -13,7 +13,7 @@ keywords = ["dom", "ui", "gui", "react"]
[dependencies] [dependencies]
proc-macro2 = { version = "1.0", features = ["span-locations"] } proc-macro2 = { version = "1.0", features = ["span-locations"] }
dioxus-core = { path = "../core", version = "^0.3.0"} dioxus-core = { workspace = true}
syn = { version = "1.0", features = ["full", "extra-traits"] } syn = { version = "1.0", features = ["full", "extra-traits"] }
quote = { version = "1.0" } quote = { version = "1.0" }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
+2 -2
View File
@@ -6,5 +6,5 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-core = { path = "../core" } dioxus-core = { workspace = true }
slab = "0.4.7" slab = { workspace = true }
+2 -2
View File
@@ -13,7 +13,7 @@ keywords = ["dom", "ui", "gui", "react", "ssr"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dioxus-core = { path = "../core", version = "^0.3.0", features = ["serialize"] } dioxus-core = { workspace = true, features = ["serialize"] }
askama_escape = "0.10.3" askama_escape = "0.10.3"
thiserror = "1.0.23" thiserror = "1.0.23"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
@@ -23,7 +23,7 @@ http = "0.2.9"
tokio = { version = "1.28", features = ["full"] } tokio = { version = "1.28", features = ["full"] }
[dev-dependencies] [dev-dependencies]
dioxus = { path = "../dioxus", version = "0.3.0" } dioxus = { workspace = true }
fern = { version = "0.6.0", features = ["colored"] } fern = { version = "0.6.0", features = ["colored"] }
anyhow = "1.0" anyhow = "1.0"
argh = "0.1.4" argh = "0.1.4"
+11 -11
View File
@@ -11,25 +11,25 @@ documentation = "https://dioxuslabs.com"
keywords = ["dom", "ui", "gui", "react", "wasm"] keywords = ["dom", "ui", "gui", "react", "wasm"]
[dependencies] [dependencies]
dioxus-core = { path = "../core", version = "^0.3.0", features = ["serialize"] } dioxus-core = { workspace = true, features = ["serialize"] }
dioxus-html = { path = "../html", version = "^0.3.0", features = ["wasm-bind"] } dioxus-html = { workspace = true, features = ["wasm-bind"] }
dioxus-interpreter-js = { path = "../interpreter", version = "^0.3.0", features = [ dioxus-interpreter-js = { workspace = true, features = [
"sledgehammer", "sledgehammer",
"minimal_bindings", "minimal_bindings",
] } ] }
js-sys = "0.3.56" js-sys = "0.3.56"
wasm-bindgen = { version = "0.2.79", features = ["enable-interning"] } wasm-bindgen = { workspace = true, features = ["enable-interning"] }
wasm-bindgen-futures = "0.4.29" wasm-bindgen-futures = "0.4.29"
log = "0.4.14" log = { workspace = true }
rustc-hash = "1.1.0" rustc-hash = { workspace = true }
console_error_panic_hook = { version = "0.1.7", optional = true } console_error_panic_hook = { version = "0.1.7", optional = true }
once_cell = "1.9.0" once_cell = "1.9.0"
anyhow = "1.0.53" anyhow = "1.0.53"
gloo-timers = { version = "0.2.3", features = ["futures"] } gloo-timers = { version = "0.2.3", features = ["futures"] }
futures-util = "0.3.19" futures-util = { workspace = true, features = ["std", "async-await", "async-await-macro"] }
smallstr = "0.2.0" smallstr = "0.2.0"
futures-channel = "0.3.21" futures-channel = { workspace = true }
serde_json = { version = "1.0" } serde_json = { version = "1.0" }
serde = { version = "1.0" } serde = { version = "1.0" }
serde-wasm-bindgen = "0.4.5" serde-wasm-bindgen = "0.4.5"
@@ -89,8 +89,8 @@ panic_hook = ["console_error_panic_hook"]
hydrate = [] hydrate = []
[dev-dependencies] [dev-dependencies]
dioxus = { path = "../dioxus", version = "0.3.0" } dioxus = { workspace = true }
wasm-bindgen-test = "0.3.29" wasm-bindgen-test = "0.3.29"
dioxus-ssr = { path = "../ssr", version = "0.3.0"} dioxus-ssr = { workspace = true}
wasm-logger = "0.2.0" wasm-logger = "0.2.0"
dioxus-web = { path = ".", features = ["hydrate"] } dioxus-web = { workspace = true, features = ["hydrate"] }