Skip to content

Commit

Permalink
Update hot-reloading for 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Oct 4, 2024
1 parent c1ebb97 commit 0ffe3a5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ selectors = { git = "https://github.com/dioxuslabs/stylo", branch = "blitz" }
html5ever = "0.29" # needs to match stylo markup5ever version
taffy = { git = "https://github.com/dioxuslabs/taffy", rev = "950a0eb1322f15e5d1083f4793b55d52061718de" }
parley = { git = "https://github.com/nicoburns/parley", rev = "186b6e991d08731c0588dc0b247564cbba1c0435" }
dioxus = { git = "https://github.com/dioxuslabs/dioxus", rev = "d0c9b6712d22e8fced9f0b0ac253e266d73eb3d1" }
dioxus-ssr = { git = "https://github.com/dioxuslabs/dioxus", rev = "d0c9b6712d22e8fced9f0b0ac253e266d73eb3d1" }
dioxus = { git = "https://github.com/dioxuslabs/dioxus", rev = "9ffd4b816b8ce291b6ca66cb5c871e107a964f6b" }
dioxus-ssr = { git = "https://github.com/dioxuslabs/dioxus", rev = "9ffd4b816b8ce291b6ca66cb5c871e107a964f6b" }
dioxus-cli-config = { git = "https://github.com/dioxuslabs/dioxus", rev = "9ffd4b816b8ce291b6ca66cb5c871e107a964f6b" }
dioxus-devtools = { git = "https://github.com/dioxuslabs/dioxus", rev = "9ffd4b816b8ce291b6ca66cb5c871e107a964f6b" }
tokio = { version = "1.25.0", features = ["full"] }
tracing = "0.1.40"
vello = { git = "https://github.com/linebender/vello", rev = "aaa9f5f2d0f21f3d038501ea0cf32c989d97aab3", package = "vello", features = [ "wgpu" ] }
Expand Down
6 changes: 3 additions & 3 deletions packages/dioxus-blitz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[features]
accessibility = ["dep:accesskit", "dep:accesskit_winit"]
hot-reload = ["dep:dioxus-cli-config", "dep:dioxus-hot-reload"]
hot-reload = ["dep:dioxus-cli-config", "dep:dioxus-devtools"]
menu = ["dep:muda"]
tracing = ["dep:tracing"]
default = ["accessibility", "hot-reload", "menu", "tracing"]
Expand All @@ -17,8 +17,8 @@ winit = { version = "0.30.2", features = ["rwh_06"] }
muda = { version = "0.11.5", features = ["serde"], optional = true }
tokio = { workspace = true, features = ["full"] }
dioxus = { workspace = true }
dioxus-cli-config = { git = "https://github.com/dioxuslabs/dioxus", rev = "a3aa6ae771a2d0a4d8cb6055c41efc0193b817ef", optional = true }
dioxus-hot-reload = { git = "https://github.com/dioxuslabs/dioxus", rev = "a3aa6ae771a2d0a4d8cb6055c41efc0193b817ef", optional = true }
dioxus-cli-config = { workspace = true, optional = true }
dioxus-devtools = { workspace = true, package = "dioxus-devtools", optional = true }
futures-util = "0.3.30"
vello = { workspace = true }
wgpu = { workspace = true }
Expand Down
14 changes: 7 additions & 7 deletions packages/dioxus-blitz/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,22 @@ impl<Doc: DocumentLike> ApplicationHandler<BlitzEvent> for Application<Doc> {
not(target_os = "android"),
not(target_os = "ios")
))]
BlitzEvent::HotReloadEvent(msg) => match msg {
dioxus_hot_reload::HotReloadMsg::UpdateTemplate(template) => {
BlitzEvent::DevserverEvent(event) => match event {
dioxus_devtools::DevserverMsg::HotReload(hotreload_message) => {
for window in self.windows.values_mut() {
use crate::documents::DioxusDocument;
if let Some(dx_doc) =
window.dom.as_any_mut().downcast_mut::<DioxusDocument>()
{
dx_doc.vdom.replace_template(template);
dioxus_devtools::apply_changes(&dx_doc.vdom, &hotreload_message);
window.handle_blitz_event(BlitzWindowEvent::Poll);
}
}
}
dioxus_hot_reload::HotReloadMsg::Shutdown => event_loop.exit(),
dioxus_hot_reload::HotReloadMsg::UpdateAsset(_asset) => {
// TODO dioxus-desktop seems to handle this by forcing a reload of all stylesheets.
}
dioxus_devtools::DevserverMsg::Shutdown => event_loop.exit(),
dioxus_devtools::DevserverMsg::FullReloadStart => todo!(),
dioxus_devtools::DevserverMsg::FullReloadFailed => todo!(),
dioxus_devtools::DevserverMsg::FullReloadCommand => todo!(),
},
}
}
Expand Down
10 changes: 4 additions & 6 deletions packages/dioxus-blitz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,10 @@ fn launch_with_window<Doc: DocumentLike + 'static>(window: WindowConfig<Doc>, rt
not(target_os = "ios")
))]
{
if let Ok(cfg) = dioxus_cli_config::CURRENT_CONFIG.as_ref() {
dioxus_hot_reload::connect_at(cfg.target_dir.join("dioxusin"), {
let proxy = proxy.clone();
move |template| {
let _ = proxy.send_event(BlitzEvent::HotReloadEvent(template));
}
if let Some(endpoint) = dioxus_cli_config::devserver_ws_endpoint() {
let proxy = proxy.clone();
dioxus_devtools::connect(endpoint, move |event| {
let _ = proxy.send_event(BlitzEvent::DevserverEvent(event));
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dioxus-blitz/src/waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum BlitzEvent {
not(target_os = "android"),
not(target_os = "ios")
))]
HotReloadEvent(dioxus_hot_reload::HotReloadMsg),
DevserverEvent(dioxus_devtools::DevserverMsg),
}
impl From<(WindowId, Resource)> for BlitzEvent {
fn from((window_id, resource): (WindowId, Resource)) -> Self {
Expand Down

0 comments on commit 0ffe3a5

Please sign in to comment.