From d611f8563aec0e7b987b0613f4a81b1cb772a82a Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Tue, 18 Jun 2024 15:37:20 -0400 Subject: [PATCH 01/11] Connect the hot-reloading crate --- packages/dioxus-blitz/Cargo.toml | 6 ++- packages/dioxus-blitz/src/lib.rs | 57 ++++++++++++++++++++++++++--- packages/dioxus-blitz/src/waker.rs | 21 +++++++++-- packages/dioxus-blitz/src/window.rs | 6 +-- 4 files changed, 77 insertions(+), 13 deletions(-) diff --git a/packages/dioxus-blitz/Cargo.toml b/packages/dioxus-blitz/Cargo.toml index a85095c4..213bfa16 100644 --- a/packages/dioxus-blitz/Cargo.toml +++ b/packages/dioxus-blitz/Cargo.toml @@ -3,7 +3,9 @@ name = "dioxus-blitz" version = "0.0.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +hot-reload = [] +default = ["hot-reload"] [dependencies] tao = { version = "0.26.1", features = ["serde"] } @@ -11,6 +13,8 @@ muda = { version = "0.11.5", features = ["serde"] } tokio = { workspace = true, features = ["full"] } dioxus = { workspace = true } dioxus-ssr = { workspace = true } +dioxus-cli-config = { git = "https://github.com/dioxuslabs/dioxus", rev = "a3aa6ae771a2d0a4d8cb6055c41efc0193b817ef" } +dioxus-hot-reload = { git = "https://github.com/dioxuslabs/dioxus", rev = "a3aa6ae771a2d0a4d8cb6055c41efc0193b817ef" } futures-util = "0.3.30" vello = { workspace = true } wgpu = { workspace = true } diff --git a/packages/dioxus-blitz/src/lib.rs b/packages/dioxus-blitz/src/lib.rs index 46e30b88..c31ec937 100644 --- a/packages/dioxus-blitz/src/lib.rs +++ b/packages/dioxus-blitz/src/lib.rs @@ -2,7 +2,7 @@ mod documents; mod waker; mod window; -use crate::waker::{EventData, UserWindowEvent}; +use crate::waker::{EventData, UserEvent}; use crate::{documents::HtmlDocument, window::View}; use blitz::RenderState; @@ -93,7 +93,7 @@ fn launch_with_window(window: View<'static, Doc>) { let _guard = rt.enter(); // Build an event loop for the application - let event_loop = EventLoopBuilder::::with_user_event().build(); + let event_loop = EventLoopBuilder::::with_user_event().build(); let proxy = event_loop.create_proxy(); // Multiwindow ftw @@ -132,6 +132,26 @@ fn launch_with_window(window: View<'static, Doc>) { initial = false; } + // Setup hot-reloading if enabled. + #[cfg(all( + feature = "hot-reload", + debug_assertions, + not(target_os = "android"), + not(target_os = "ios") + ))] + { + let Ok(cfg) = dioxus_cli_config::CURRENT_CONFIG.as_ref() else { + return; + }; + + dioxus_hot_reload::connect_at(cfg.target_dir.join("dioxusin"), { + let proxy = proxy.clone(); + move |template| { + let _ = proxy.send_event(UserEvent::HotReloadEvent(template)); + } + }); + } + match event { // Exit the app when close is request // Not always necessary @@ -143,13 +163,40 @@ fn launch_with_window(window: View<'static, Doc>) { // Nothing else to do, try redrawing? Event::MainEventsCleared => {} - Event::UserEvent(UserWindowEvent(EventData::Poll, id)) => { - if let Some(view) = windows.get_mut(&id) { + Event::UserEvent(UserEvent::Window { + data: EventData::Poll, + window_id, + }) => { + if let Some(view) = windows.get_mut(&window_id) { if view.poll() { view.request_redraw(); } }; } + + #[cfg(all( + feature = "hot-reload", + debug_assertions, + not(target_os = "android"), + not(target_os = "ios") + ))] + Event::UserEvent(UserEvent::HotReloadEvent(msg)) => { + + + match msg { + dioxus_hot_reload::HotReloadMsg::UpdateTemplate(template) => { + dbg!("Update template {:?}", template); + } + dioxus_hot_reload::HotReloadMsg::Shutdown => { + * control_flow = ControlFlow::Exit; + } + dioxus_hot_reload::HotReloadMsg::UpdateAsset(asset) => { + dbg!("Update asset {:?}", asset); + } + } + + } + // Event::UserEvent(_redraw) => { // for (_, view) in windows.iter() { // view.request_redraw(); @@ -157,7 +204,7 @@ fn launch_with_window(window: View<'static, Doc>) { // } Event::NewEvents(_) => { for id in windows.keys() { - _ = proxy.send_event(UserWindowEvent(EventData::Poll, *id)); + _ = proxy.send_event(UserEvent::Window { data: EventData::Poll, window_id: *id }); } } diff --git a/packages/dioxus-blitz/src/waker.rs b/packages/dioxus-blitz/src/waker.rs index 2b391ad4..f7835a61 100644 --- a/packages/dioxus-blitz/src/waker.rs +++ b/packages/dioxus-blitz/src/waker.rs @@ -3,7 +3,20 @@ use std::sync::Arc; use tao::{event_loop::EventLoopProxy, window::WindowId}; #[derive(Debug, Clone)] -pub struct UserWindowEvent(pub EventData, pub WindowId); +pub enum UserEvent { + Window { + window_id: WindowId, + data: EventData, + }, + /// Handle a hotreload event, basically telling us to update our templates + #[cfg(all( + feature = "hot-reload", + debug_assertions, + not(target_os = "android"), + not(target_os = "ios") + ))] + HotReloadEvent(dioxus_hot_reload::HotReloadMsg), +} #[derive(Debug, Clone)] pub enum EventData { @@ -17,9 +30,9 @@ pub enum EventData { /// This lets the VirtualDom "come up for air" and process events while the main thread is blocked by the WebView. /// /// All other IO lives in the Tokio runtime, -pub fn tao_waker(proxy: &EventLoopProxy, id: WindowId) -> std::task::Waker { +pub fn tao_waker(proxy: &EventLoopProxy, id: WindowId) -> std::task::Waker { struct DomHandle { - proxy: EventLoopProxy, + proxy: EventLoopProxy, id: WindowId, } @@ -32,7 +45,7 @@ pub fn tao_waker(proxy: &EventLoopProxy, id: WindowId) -> std:: fn wake_by_ref(arc_self: &Arc) { _ = arc_self .proxy - .send_event(UserWindowEvent(EventData::Poll, arc_self.id)); + .send_event(UserEvent::Window { data: EventData::Poll, window_id: arc_self.id }) } } diff --git a/packages/dioxus-blitz/src/window.rs b/packages/dioxus-blitz/src/window.rs index 5fb5c626..fae38a47 100644 --- a/packages/dioxus-blitz/src/window.rs +++ b/packages/dioxus-blitz/src/window.rs @@ -1,4 +1,4 @@ -use crate::waker::UserWindowEvent; +use crate::waker::UserEvent; use blitz::{RenderState, Renderer, Viewport}; use blitz_dom::DocumentLike; @@ -277,8 +277,8 @@ impl<'a, Doc: DocumentLike> View<'a, Doc> { pub fn resume( &mut self, - event_loop: &EventLoopWindowTarget, - proxy: &EventLoopProxy, + event_loop: &EventLoopWindowTarget, + proxy: &EventLoopProxy, rt: &tokio::runtime::Runtime, ) { let window_builder = || { From e710cdc1e7a96bfb8f065cc4ee9fe2bfc7c5ff41 Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Tue, 18 Jun 2024 16:01:04 -0400 Subject: [PATCH 02/11] Apply template updates from the hot-reload CLI --- .../src/documents/dioxus_document.rs | 3 +- packages/dioxus-blitz/src/lib.rs | 81 +++++++++++-------- packages/dom/Cargo.toml | 2 - packages/dom/src/document.rs | 10 ++- 4 files changed, 57 insertions(+), 39 deletions(-) diff --git a/packages/dioxus-blitz/src/documents/dioxus_document.rs b/packages/dioxus-blitz/src/documents/dioxus_document.rs index 82655f28..6bb23736 100644 --- a/packages/dioxus-blitz/src/documents/dioxus_document.rs +++ b/packages/dioxus-blitz/src/documents/dioxus_document.rs @@ -31,7 +31,7 @@ fn qual_name(local_name: &str, namespace: Option<&str>) -> QualName { } pub struct DioxusDocument { - vdom: VirtualDom, + pub(crate) vdom: VirtualDom, vdom_state: DioxusState, inner: Document, } @@ -122,6 +122,7 @@ impl DocumentLike for DioxusDocument { false } + } impl DioxusDocument { diff --git a/packages/dioxus-blitz/src/lib.rs b/packages/dioxus-blitz/src/lib.rs index c31ec937..dd5728d3 100644 --- a/packages/dioxus-blitz/src/lib.rs +++ b/packages/dioxus-blitz/src/lib.rs @@ -106,6 +106,26 @@ fn launch_with_window(window: View<'static, Doc>) { #[cfg(not(any(target_os = "android", target_os = "ios")))] let mut initial = true; + // Setup hot-reloading if enabled. + #[cfg(all( + feature = "hot-reload", + debug_assertions, + not(target_os = "android"), + not(target_os = "ios") + ))] + { + let Ok(cfg) = dioxus_cli_config::CURRENT_CONFIG.as_ref() else { + return; + }; + + dioxus_hot_reload::connect_at(cfg.target_dir.join("dioxusin"), { + let proxy = proxy.clone(); + move |template| { + let _ = proxy.send_event(UserEvent::HotReloadEvent(template)); + } + }); + } + event_loop.run(move |event, event_loop, control_flow| { *control_flow = ControlFlow::Wait; @@ -132,26 +152,6 @@ fn launch_with_window(window: View<'static, Doc>) { initial = false; } - // Setup hot-reloading if enabled. - #[cfg(all( - feature = "hot-reload", - debug_assertions, - not(target_os = "android"), - not(target_os = "ios") - ))] - { - let Ok(cfg) = dioxus_cli_config::CURRENT_CONFIG.as_ref() else { - return; - }; - - dioxus_hot_reload::connect_at(cfg.target_dir.join("dioxusin"), { - let proxy = proxy.clone(); - move |template| { - let _ = proxy.send_event(UserEvent::HotReloadEvent(template)); - } - }); - } - match event { // Exit the app when close is request // Not always necessary @@ -180,22 +180,32 @@ fn launch_with_window(window: View<'static, Doc>) { not(target_os = "android"), not(target_os = "ios") ))] - Event::UserEvent(UserEvent::HotReloadEvent(msg)) => { - - - match msg { - dioxus_hot_reload::HotReloadMsg::UpdateTemplate(template) => { - dbg!("Update template {:?}", template); + Event::UserEvent(UserEvent::HotReloadEvent(msg)) => match msg { + dioxus_hot_reload::HotReloadMsg::UpdateTemplate(template) => { + dbg!("Update template {:?}", template); + + for window in windows.values_mut() { + if let Some(dx_doc) = window + .renderer + .dom + .as_any_mut() + .downcast_mut::() + { + dx_doc.vdom.replace_template(template); } - dioxus_hot_reload::HotReloadMsg::Shutdown => { - * control_flow = ControlFlow::Exit; - } - dioxus_hot_reload::HotReloadMsg::UpdateAsset(asset) => { - dbg!("Update asset {:?}", asset); + + if window.poll() { + window.request_redraw(); } } - - } + } + dioxus_hot_reload::HotReloadMsg::Shutdown => { + *control_flow = ControlFlow::Exit; + } + dioxus_hot_reload::HotReloadMsg::UpdateAsset(asset) => { + dbg!("Update asset {:?}", asset); + } + }, // Event::UserEvent(_redraw) => { // for (_, view) in windows.iter() { @@ -204,7 +214,10 @@ fn launch_with_window(window: View<'static, Doc>) { // } Event::NewEvents(_) => { for id in windows.keys() { - _ = proxy.send_event(UserEvent::Window { data: EventData::Poll, window_id: *id }); + _ = proxy.send_event(UserEvent::Window { + data: EventData::Poll, + window_id: *id, + }); } } diff --git a/packages/dom/Cargo.toml b/packages/dom/Cargo.toml index 42d13143..56bdf07a 100644 --- a/packages/dom/Cargo.toml +++ b/packages/dom/Cargo.toml @@ -3,8 +3,6 @@ name = "blitz-dom" version = "0.0.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] style = { workspace = true, features = ["servo"] } selectors = { workspace = true } diff --git a/packages/dom/src/document.rs b/packages/dom/src/document.rs index cfda135f..05b3bd19 100644 --- a/packages/dom/src/document.rs +++ b/packages/dom/src/document.rs @@ -4,6 +4,7 @@ use crate::{Node, NodeData, TextNodeData}; // use quadtree_rs::Quadtree; use selectors::{matching::QuirksMode, Element}; use slab::Slab; +use std::any::Any; use std::collections::HashMap; use style::invalidation::element::restyle_hints::RestyleHint; use style::selector_parser::ServoElementSnapshot; @@ -20,7 +21,7 @@ use style_traits::dom::ElementState; use taffy::AvailableSpace; use url::Url; -pub trait DocumentLike: AsRef + AsMut + Into { +pub trait DocumentLike: AsRef + AsMut + Into + 'static { fn poll(&mut self, _cx: std::task::Context) -> bool { // Default implementation does nothing false @@ -30,9 +31,14 @@ pub trait DocumentLike: AsRef + AsMut + Into { // Default implementation does nothing false } + + fn as_any_mut(&mut self) -> &mut dyn Any { + self + } } -impl DocumentLike for Document {} +impl DocumentLike for Document { +} pub struct Document { /// A bump-backed tree From 860e80d97257c5a7d5a6bfba14f246ace7928e86 Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Tue, 18 Jun 2024 19:02:00 -0400 Subject: [PATCH 03/11] Run cargo fmt --- packages/dioxus-blitz/src/documents/dioxus_document.rs | 1 - packages/dioxus-blitz/src/waker.rs | 7 ++++--- packages/dom/src/document.rs | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/dioxus-blitz/src/documents/dioxus_document.rs b/packages/dioxus-blitz/src/documents/dioxus_document.rs index 6bb23736..e612540d 100644 --- a/packages/dioxus-blitz/src/documents/dioxus_document.rs +++ b/packages/dioxus-blitz/src/documents/dioxus_document.rs @@ -122,7 +122,6 @@ impl DocumentLike for DioxusDocument { false } - } impl DioxusDocument { diff --git a/packages/dioxus-blitz/src/waker.rs b/packages/dioxus-blitz/src/waker.rs index f7835a61..b3f830a0 100644 --- a/packages/dioxus-blitz/src/waker.rs +++ b/packages/dioxus-blitz/src/waker.rs @@ -43,9 +43,10 @@ pub fn tao_waker(proxy: &EventLoopProxy, id: WindowId) -> std::task:: impl ArcWake for DomHandle { fn wake_by_ref(arc_self: &Arc) { - _ = arc_self - .proxy - .send_event(UserEvent::Window { data: EventData::Poll, window_id: arc_self.id }) + _ = arc_self.proxy.send_event(UserEvent::Window { + data: EventData::Poll, + window_id: arc_self.id, + }) } } diff --git a/packages/dom/src/document.rs b/packages/dom/src/document.rs index 05b3bd19..3185899d 100644 --- a/packages/dom/src/document.rs +++ b/packages/dom/src/document.rs @@ -37,8 +37,7 @@ pub trait DocumentLike: AsRef + AsMut + Into + 'st } } -impl DocumentLike for Document { -} +impl DocumentLike for Document {} pub struct Document { /// A bump-backed tree From 46a48b468d76448b1a086c85caf746d90d0b6035 Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Tue, 18 Jun 2024 19:17:55 -0400 Subject: [PATCH 04/11] Make hot-reload a non-default feature --- packages/dioxus-blitz/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dioxus-blitz/Cargo.toml b/packages/dioxus-blitz/Cargo.toml index 213bfa16..ea5ab550 100644 --- a/packages/dioxus-blitz/Cargo.toml +++ b/packages/dioxus-blitz/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [features] hot-reload = [] -default = ["hot-reload"] +default = [] [dependencies] tao = { version = "0.26.1", features = ["serde"] } From b09b2f9b5f15873b0b24fffde08c8203d0f79aba Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Thu, 20 Jun 2024 18:21:28 -0400 Subject: [PATCH 05/11] Fix panic on root node and clean up --- packages/dioxus-blitz/src/lib.rs | 14 ++++++++------ packages/dioxus-blitz/src/window.rs | 7 +------ packages/dom/src/document.rs | 4 +++- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/dioxus-blitz/src/lib.rs b/packages/dioxus-blitz/src/lib.rs index dd9f9ae9..1b320639 100644 --- a/packages/dioxus-blitz/src/lib.rs +++ b/packages/dioxus-blitz/src/lib.rs @@ -12,7 +12,7 @@ use documents::DioxusDocument; use muda::{MenuEvent, MenuId}; use std::collections::HashMap; use url::Url; -use winit::event_loop::{EventLoop, EventLoopBuilder}; +use winit::event_loop::EventLoop; use winit::window::WindowId; use winit::{ event::{Event, WindowEvent}, @@ -126,6 +126,9 @@ fn launch_with_window(window: View<'static, Doc>) { }); } + // the move to winit wants us to use a struct with a run method instead of the callback approach + // we want to just keep the callback approach for now + #[allow(deprecated)] event_loop .run(move |event, event_loop| { event_loop.set_control_flow(ControlFlow::Wait); @@ -190,8 +193,6 @@ fn launch_with_window(window: View<'static, Doc>) { ))] Event::UserEvent(UserEvent::HotReloadEvent(msg)) => match msg { dioxus_hot_reload::HotReloadMsg::UpdateTemplate(template) => { - dbg!("Update template {:?}", template); - for window in windows.values_mut() { if let Some(dx_doc) = window .renderer @@ -200,15 +201,16 @@ fn launch_with_window(window: View<'static, Doc>) { .downcast_mut::() { dx_doc.vdom.replace_template(template); - } - if window.poll() { - window.request_redraw(); + if window.poll() { + window.request_redraw(); + } } } } 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. dbg!("Update asset {:?}", asset); } }, diff --git a/packages/dioxus-blitz/src/window.rs b/packages/dioxus-blitz/src/window.rs index b0599100..4a7ebc7a 100644 --- a/packages/dioxus-blitz/src/window.rs +++ b/packages/dioxus-blitz/src/window.rs @@ -1,9 +1,7 @@ use crate::waker::UserEvent; use blitz::{RenderState, Renderer, Viewport}; use blitz_dom::DocumentLike; -use wgpu::rwh::HasWindowHandle; use winit::keyboard::PhysicalKey; -use winit::window::WindowAttributes; use std::sync::Arc; use std::task::Waker; @@ -19,8 +17,6 @@ use winit::event_loop::{ActiveEventLoop, EventLoopProxy}; target_os = "openbsd" ))] use winit::platform::unix::WindowExtUnix; -#[cfg(target_os = "windows")] -use winit::platform::windows::WindowExtWindows; use winit::{event::WindowEvent, keyboard::KeyCode, keyboard::ModifiersState, window::Window}; #[cfg(not(target_os = "macos"))] @@ -224,7 +220,7 @@ impl<'a, Doc: DocumentLike> View<'a, Doc> { }; if let RenderState::Active(state) = &self.renderer.render_state { - state.window.set_cursor_icon(tao_cursor); + state.window.set_cursor(tao_cursor); self.request_redraw(); } } @@ -248,7 +244,6 @@ impl<'a, Doc: DocumentLike> View<'a, Doc> { winit::event::MouseScrollDelta::PixelDelta(offsets) => { self.renderer.scroll_by(offsets.y) } - _ => {} }; self.request_redraw(); } diff --git a/packages/dom/src/document.rs b/packages/dom/src/document.rs index 395c5f91..ab1d5e42 100644 --- a/packages/dom/src/document.rs +++ b/packages/dom/src/document.rs @@ -222,7 +222,9 @@ impl Document { let node = &self.nodes[node_id]; let node_child_idx = node.child_idx; - let parent_id = node.parent.unwrap(); + + // Get this node's parent, or the root node if it has none. + let parent_id = node.parent.unwrap_or_default(); let parent = &mut self.nodes[parent_id]; let mut children = std::mem::take(&mut parent.children); From 5ffa6c287e0308d62f05d5aaa0af09bf6bc81fbc Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Mon, 24 Jun 2024 15:39:21 -0400 Subject: [PATCH 06/11] Undo dependency change --- Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 1ab4812f..f3fc67e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,11 @@ opt-level = 2 # Need to force specific versions of these dependencies [dependencies] +# webrender = "0.61.0" +euclid = { version = "0.22", features = ["serde"] } +# mozbuild = "0.1.0" + +[dev-dependencies] blitz = { path = "./packages/blitz" } blitz-dom = { path = "./packages/dom" } comrak = { version = "0.21.0", default-features = false } From 55a64809ad6597f3c613e58c0a9effee5298524b Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Mon, 24 Jun 2024 15:43:50 -0400 Subject: [PATCH 07/11] Make hot-reload dependencies optional --- packages/dioxus-blitz/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/dioxus-blitz/Cargo.toml b/packages/dioxus-blitz/Cargo.toml index 6e7abc50..3be5106e 100644 --- a/packages/dioxus-blitz/Cargo.toml +++ b/packages/dioxus-blitz/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" edition = "2021" [features] -hot-reload = [] +hot-reload = ["dep:dioxus-cli-config", "dep:dioxus-hot-reload"] default = [] [dependencies] @@ -12,8 +12,8 @@ winit = { version = "0.30.2", features = ["rwh_06"] } muda = { version = "0.11.5", features = ["serde"] } tokio = { workspace = true, features = ["full"] } dioxus = { workspace = true } -dioxus-cli-config = { git = "https://github.com/dioxuslabs/dioxus", rev = "a3aa6ae771a2d0a4d8cb6055c41efc0193b817ef"} -dioxus-hot-reload = { git = "https://github.com/dioxuslabs/dioxus", rev = "a3aa6ae771a2d0a4d8cb6055c41efc0193b817ef"} +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 } futures-util = "0.3.30" vello = { workspace = true } wgpu = { workspace = true } From b3f56b49bfbf61aef42fc3808bf902de23810178 Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Wed, 26 Jun 2024 15:41:09 -0400 Subject: [PATCH 08/11] Remove duplicated comment --- packages/dioxus-blitz/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/dioxus-blitz/src/lib.rs b/packages/dioxus-blitz/src/lib.rs index 2e7290bd..1b320639 100644 --- a/packages/dioxus-blitz/src/lib.rs +++ b/packages/dioxus-blitz/src/lib.rs @@ -126,9 +126,6 @@ fn launch_with_window(window: View<'static, Doc>) { }); } - // the move to winit wants us to use a struct with a run method instead of the callback approach - // we want to just keep the callback approach for now - #[allow(deprecated)] // the move to winit wants us to use a struct with a run method instead of the callback approach // we want to just keep the callback approach for now #[allow(deprecated)] From 2daf3221e7fafe597206cea274dd61104e394b00 Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Sat, 29 Jun 2024 14:33:49 -0400 Subject: [PATCH 09/11] Make hot-reload feature default and rollback patch in Document::insert_before --- packages/dioxus-blitz/Cargo.toml | 2 +- packages/dom/src/document.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/dioxus-blitz/Cargo.toml b/packages/dioxus-blitz/Cargo.toml index 3be5106e..05bbc8b9 100644 --- a/packages/dioxus-blitz/Cargo.toml +++ b/packages/dioxus-blitz/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [features] hot-reload = ["dep:dioxus-cli-config", "dep:dioxus-hot-reload"] -default = [] +default = ["hot-reload"] [dependencies] winit = { version = "0.30.2", features = ["rwh_06"] } diff --git a/packages/dom/src/document.rs b/packages/dom/src/document.rs index ab1d5e42..69f42fe3 100644 --- a/packages/dom/src/document.rs +++ b/packages/dom/src/document.rs @@ -223,8 +223,7 @@ impl Document { let node = &self.nodes[node_id]; let node_child_idx = node.child_idx; - // Get this node's parent, or the root node if it has none. - let parent_id = node.parent.unwrap_or_default(); + let parent_id = node.parent.unwrap(); let parent = &mut self.nodes[parent_id]; let mut children = std::mem::take(&mut parent.children); From 5c68c8cc86d2eee9575194f94effc99e7b104840 Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Sat, 29 Jun 2024 14:37:25 -0400 Subject: [PATCH 10/11] Don't return early with missing CLI config --- packages/dioxus-blitz/src/lib.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/dioxus-blitz/src/lib.rs b/packages/dioxus-blitz/src/lib.rs index 1b320639..c3d29fdc 100644 --- a/packages/dioxus-blitz/src/lib.rs +++ b/packages/dioxus-blitz/src/lib.rs @@ -114,16 +114,14 @@ fn launch_with_window(window: View<'static, Doc>) { not(target_os = "ios") ))] { - let Ok(cfg) = dioxus_cli_config::CURRENT_CONFIG.as_ref() else { - return; - }; - - dioxus_hot_reload::connect_at(cfg.target_dir.join("dioxusin"), { - let proxy = proxy.clone(); - move |template| { - let _ = proxy.send_event(UserEvent::HotReloadEvent(template)); - } - }); + 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(UserEvent::HotReloadEvent(template)); + } + }) + } } // the move to winit wants us to use a struct with a run method instead of the callback approach From baed00e9c46b6fcae27f54cd8a2ae1b934f38cbb Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Sat, 29 Jun 2024 15:35:28 -0400 Subject: [PATCH 11/11] Undo dependency change --- Cargo.toml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cc9407a5..fe6e1913 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,12 +39,9 @@ publish = false opt-level = 2 # Need to force specific versions of these dependencies -[dependencies] +[dev-dependencies] # webrender = "0.61.0" -euclid = { version = "0.22", features = ["serde"] } # mozbuild = "0.1.0" - -[dev-dependencies] blitz = { path = "./packages/blitz" } blitz-dom = { path = "./packages/dom" } comrak = { version = "0.21.0", default-features = false }