Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 46 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,31 @@ edition = "2021"
publish = false

[workspace]
members = ["crates/winit", "crates/freya", "crates/elements", "crates/components", "crates/hooks", "crates/core", "crates/testing", "crates/devtools", "crates/torin", "crates/engine", "./examples/installer", "crates/native-core", "crates/native-core-macro", "crates/router", "crates/router-macro", "crates/ragnarok"]
members = [
"crates/winit",
"crates/freya",
"crates/elements",
"crates/components",
"crates/hooks",
"crates/core",
"crates/testing",
"crates/devtools",
"crates/torin",
"crates/engine",
"./examples/installer",
"crates/native-core",
"crates/native-core-macro",
"crates/router",
"crates/router-macro",
"crates/ragnarok",
]

[features]
tracing-subscriber = ["freya/tracing-subscriber"]
devtools = ["freya/devtools"]
use_camera = ["freya/use_camera"]
custom-tokio-rt = ["freya/custom-tokio-rt"]
hot-reloading = ["freya/hot-reloading"]
performance-overlay = ["freya/performance-overlay"]
fade-cached-incremental-areas = ["freya/fade-cached-incremental-areas"]
disable-zoom-shortcuts = ["freya/disable-zoom-shortcuts"]
Expand All @@ -25,7 +43,7 @@ dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.7.
dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.7.0-alpha.3" }
dioxus-signals = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.7.0-alpha.3" }
dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.7.0-alpha.3" }
generational-box = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.7.0-alpha.3" }
generational-box = { git = "https://github.com/DioxusLabs/dioxus", tag = "v0.7.0-alpha.3" }

[workspace.dependencies]
freya = { path = "crates/freya", version = "0.4" }
Expand All @@ -46,16 +64,26 @@ ragnarok = { path = "crates/ragnarok", version = "0.1.0" }
freya-native-core-macro = { path = "crates/native-core-macro", version = "0.4" }
freya-native-core = { path = "crates/native-core", version = "0.4" }

dioxus = { version = "0.7.0-alpha.3", default-features = false, features = ["macro", "signals", "hooks"] }
dioxus = { version = "0.7.0-alpha.3", default-features = false, features = [
"macro",
"signals",
"hooks",
] }
dioxus-rsx = { version = "0.7.0-alpha.3" }
dioxus-core-macro = { version = "0.7.0-alpha.3" }
dioxus-hooks = { version = "0.7.0-alpha.3" }
dioxus-signals = { version = "0.7.0-alpha.3" }
dioxus-core = { version = "0.7.0-alpha.3" }
dioxus-lib = { version = "0.7.0-alpha.3", default-features = false, features = ["macro", "signals", "hooks"] }
dioxus-lib = { version = "0.7.0-alpha.3", default-features = false, features = [
"macro",
"signals",
"hooks",
] }
dioxus-devtools = { version = "0.7.0-alpha.3" }
generational-box = { version = "0.7.0-alpha.3" }

dioxus-clipboard = "0.2.0"

dioxus-clipboard = { git = "https://github.com/RobertasJ/dioxus-clipboard.git", branch = "feat/dioxus-0.7" }
dioxus-i18n = "0.4.1"

skia-safe = { version = "0.87.0", features = ["gl", "textlayout", "svg"] }
Expand All @@ -65,10 +93,19 @@ glutin = "0.32.0"
glutin-winit = "0.5.0"
raw-window-handle = "0.6.0"
winit = "0.30.0"
tokio = { version = "1", features = ["sync", "rt-multi-thread", "time", "macros"] }
accesskit = { version = "0.19.0", features = ["serde"]}
tokio = { version = "1", features = [
"sync",
"rt-multi-thread",
"time",
"macros",
] }
accesskit = { version = "0.19.0", features = ["serde"] }
accesskit_winit = "0.27.0"
shipyard = { version = "0.8", features = ["proc", "std", "parallel"], default-features = false }
shipyard = { version = "0.8", features = [
"proc",
"std",
"parallel",
], default-features = false }
smallvec = "1.13.1"

euclid = "0.22.9"
Expand All @@ -80,7 +117,7 @@ rustc-hash = "2.0.0"

[dev-dependencies]
skia-safe = { workspace = true }
tokio = { workspace = true, features = ["fs"]}
tokio = { workspace = true, features = ["fs"] }
freya = { workspace = true, features = ["network-image"] }
freya-hooks = { workspace = true }
freya-core = { workspace = true }
Expand Down
2 changes: 2 additions & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ categories = ["gui", "asynchronous"]
features = ["freya-engine/mocked-engine"]

[features]
hot-reloading = ["dep:dioxus-devtools"]
rc-dom = []
skia-engine = ["freya-engine/skia-engine"]
fade-cached-incremental-areas = []
Expand All @@ -28,6 +29,7 @@ freya-native-core = { workspace = true }
freya-native-core-macro = { workspace = true }
ragnarok = { workspace = true }

dioxus-devtools = { workspace = true, optional = true }
dioxus-core = { workspace = true }
shipyard = { workspace = true }
keyboard-types = "0.7.0"
Expand Down
11 changes: 9 additions & 2 deletions crates/core/src/event_loop_messages.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use cursor_icon::CursorIcon;
#[cfg(all(debug_assertions, feature = "hot-reloading"))]
use dioxus_devtools::DevserverMsg;
use torin::prelude::{
Area,
CursorPoint,
};
#[cfg(feature = "winit")]
use winit::window::Window;
use winit::window::{
CursorIcon,
Window,
};

use crate::{
accessibility::AccessibilityFocusStrategy,
Expand Down Expand Up @@ -44,6 +48,9 @@ pub enum EventLoopMessage {
/// Callback to access the Window.
#[cfg(feature = "winit")]
WithWindow(Box<dyn FnOnce(&Window) + Send + Sync>),
/// dioxus hot patching events
#[cfg(all(debug_assertions, feature = "hot-reloading"))]
DioxusDevserverEvent(DevserverMsg),
}

#[cfg(feature = "winit")]
Expand Down
37 changes: 30 additions & 7 deletions crates/freya/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,46 @@ no-default-features = true

[features]
# Internal features
default = ["skia", "winit"]
default = ["skia", "winit", "hot-reloading"]
skia = ["freya-engine/skia-engine"]
tracing-subscriber = ["dep:tracing-subscriber"]
mocked-engine-development = ["freya-engine/mocked-engine"] # This is just for the CI
mocked-engine-development = [
"freya-engine/mocked-engine",
] # This is just for the CI
fade-cached-incremental-areas = ["freya-core/fade-cached-incremental-areas"]
docs = ["dep:freya-testing", "dep:dioxus-i18n", "dep:freya-router", "freya-components/docs", "freya-hooks/docs", "plot"]
docs = [
"dep:freya-testing",
"dep:dioxus-i18n",
"dep:freya-router",
"freya-components/docs",
"freya-hooks/docs",
"plot",
]

# User features
network-image = ["freya-components/network-image"]
use_camera = ["freya-hooks/use_camera"]
performance-overlay = []
disable-zoom-shortcuts = ["freya-winit/disable-zoom-shortcuts"]
devtools = ["dep:freya-devtools"]
hot-reloading = [
"dep:dioxus-devtools",
"freya-winit/hot-reloading",
"freya-core/hot-reloading",
"dioxus/devtools",
]
custom-tokio-rt = []
winit = ["freya-core/winit", "freya-hooks/winit", "freya-components/winit", "dep:freya-winit"]
winit = [
"freya-core/winit",
"freya-hooks/winit",
"freya-components/winit",
"dep:freya-winit",
]
plot = ["dep:plotters", "dep:skia-plotters-backend"]

[dependencies]
freya-devtools = { workspace = true, optional = true }
freya-winit = { workspace = true, optional = true}
freya-winit = { workspace = true, optional = true }
freya-elements = { workspace = true }
freya-hooks = { workspace = true }
freya-core = { workspace = true }
Expand All @@ -52,10 +72,13 @@ dioxus = { workspace = true }
dioxus-core-macro = { workspace = true }
dioxus-hooks = { workspace = true }
dioxus-core = { workspace = true }
dioxus-devtools = { workspace = true, optional = true }
dioxus-signals = { workspace = true }

tokio = { workspace = true }
tracing-subscriber = { workspace = true, optional = true, features = ["env-filter"]}
tracing-subscriber = { workspace = true, optional = true, features = [
"env-filter",
] }

# Plot
plotters = { version = "0.3.7", default-features = false, features = [
Expand All @@ -66,4 +89,4 @@ plotters = { version = "0.3.7", default-features = false, features = [
"full_palette",
"colormaps",
], optional = true }
skia-plotters-backend = { version = "0.1", optional = true }
skia-plotters-backend = { version = "0.1", optional = true }
8 changes: 7 additions & 1 deletion crates/winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ features = ["freya-engine/mocked-engine"]
skia-engine = ["freya-engine/skia-engine"]
disable-zoom-shortcuts = []
disable-animation-shortcuts = []
hot-reloading = ["dep:dioxus-devtools"]

[dependencies]
dioxus-devtools = { workspace = true, optional = true }
freya-elements = { workspace = true }
freya-core = { workspace = true, features = ["winit"] }
freya-engine = { workspace = true }
Expand All @@ -44,4 +46,8 @@ futures-task = { workspace = true }
futures-util = { workspace = true }

itertools = "0.13.0"
image = { version = "0.25.0", default-features = false, features = [ "ico", "png", "jpeg"]}
image = { version = "0.25.0", default-features = false, features = [
"ico",
"png",
"jpeg",
] }
24 changes: 24 additions & 0 deletions crates/winit/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ impl<'a, State: Clone + 'static> WinitRenderer<'a, State> {

let mut winit_renderer = WinitRenderer::new(vdom, sdom, config, devtools, proxy);

#[cfg(all(debug_assertions, feature = "hot-reloading"))]
{
dioxus_devtools::connect({
let proxy = event_loop.create_proxy();
move |event| {
println!("got event: {event:#?}");
let _ = proxy.send_event(EventLoopMessage::DioxusDevserverEvent(event));
}
});
}

event_loop.run_app(&mut winit_renderer).unwrap();
}

Expand Down Expand Up @@ -220,6 +231,19 @@ impl<State: Clone> ApplicationHandler<EventLoopMessage> for WinitRenderer<'_, St
EventLoopMessage::WithWindow(use_window) => (use_window)(window),
EventLoopMessage::ExitApp => event_loop.exit(),
EventLoopMessage::PlatformEvent(platform_event) => self.send_event(platform_event),
#[cfg(all(debug_assertions, feature = "hot-reloading"))]
EventLoopMessage::DioxusDevserverEvent(event) => match event {
dioxus_devtools::DevserverMsg::HotReload(hot_reload_msg) => {
if hot_reload_msg.jump_table.is_some() {
dioxus_devtools::apply_changes(&app.vdom, &hot_reload_msg);
} else {
eprintln!("got hot-reload message from dioxus-cli, freya does not work with hot reloading, \
please use hot patching instead by passing --hot-patch and disable hot-reloading with --hot-reload false");
}
}
dioxus_devtools::DevserverMsg::Shutdown => event_loop.exit(),
_ => {}
},
EventLoopMessage::PollVDOM => {
app.poll_vdom(window);
}
Expand Down
7 changes: 4 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
{
devShells.default = pkgs.mkShell rec {
packages = [
openssl
pkg-config
fontconfig
python3
];
buildInputs = [
libxkbcommon
libGL
udev
openssl
pkg-config
fontconfig

# WINIT_UNIX_BACKEND=wayland
wayland
Expand Down