diff --git a/examples/calculator.rs b/examples/calculator.rs index 648ccfbc3..2f8d4ee5f 100644 --- a/examples/calculator.rs +++ b/examples/calculator.rs @@ -6,13 +6,13 @@ This calculator version uses React-style state management. All state is held as use dioxus::events::*; use dioxus::html::input_data::keyboard_types::Key; use dioxus::prelude::*; -use dioxus_desktop::{Config, WindowBuilder}; +use dioxus_desktop::{Config, LogicalSize, WindowBuilder}; fn main() { let config = Config::new().with_window( WindowBuilder::default() .with_title("Calculator") - .with_inner_size(dioxus_desktop::LogicalSize::new(300.0, 500.0)), + .with_inner_size(LogicalSize::new(300.0, 500.0)), ); dioxus_desktop::launch_cfg(app, config); diff --git a/examples/pattern_model.rs b/examples/pattern_model.rs index a6c35d17a..2f6cc2803 100644 --- a/examples/pattern_model.rs +++ b/examples/pattern_model.rs @@ -21,7 +21,7 @@ use dioxus::events::*; use dioxus::html::input_data::keyboard_types::Key; use dioxus::html::MouseEvent; use dioxus::prelude::*; -use dioxus_desktop::wry::application::dpi::LogicalSize; +use dioxus_desktop::tao::dpi::LogicalSize; use dioxus_desktop::{Config, WindowBuilder}; fn main() { diff --git a/examples/window_focus.rs b/examples/window_focus.rs index 79a5e5044..612e38d6d 100644 --- a/examples/window_focus.rs +++ b/examples/window_focus.rs @@ -1,7 +1,7 @@ use dioxus::prelude::*; +use dioxus_desktop::tao::event::Event as WryEvent; use dioxus_desktop::tao::event::WindowEvent; use dioxus_desktop::use_wry_event_handler; -use dioxus_desktop::wry::application::event::Event as WryEvent; use dioxus_desktop::{Config, WindowCloseBehaviour}; fn main() { diff --git a/packages/desktop/src/app.rs b/packages/desktop/src/app.rs index a918118b2..3471d6227 100644 --- a/packages/desktop/src/app.rs +++ b/packages/desktop/src/app.rs @@ -87,6 +87,7 @@ impl App

{ // Set the event converter dioxus_html::set_event_converter(Box::new(SerializedHtmlEventConverter)); + // Allow hotreloading to work - but only in debug mode #[cfg(all(feature = "hot-reload", debug_assertions))] app.connect_hotreload(); diff --git a/packages/desktop/src/desktop_context.rs b/packages/desktop/src/desktop_context.rs index d0af4cd80..e81b06656 100644 --- a/packages/desktop/src/desktop_context.rs +++ b/packages/desktop/src/desktop_context.rs @@ -102,13 +102,14 @@ impl DesktopService { /// Send a list of mutations to the webview pub(crate) fn send_edits(&self, edits: Mutations) { - crate::edits::apply_edits( + if let Some(bytes) = crate::edits::apply_edits( edits, &mut self.channel.borrow_mut(), &mut self.templates.borrow_mut(), &self.max_template_count, - ) - .map(|bytes| self.edit_queue.add_edits(bytes)); + ) { + self.edit_queue.add_edits(bytes) + } } /// Create a new window using the props and window builder diff --git a/packages/desktop/src/lib.rs b/packages/desktop/src/lib.rs index 39c046331..2b5d5c950 100644 --- a/packages/desktop/src/lib.rs +++ b/packages/desktop/src/lib.rs @@ -32,6 +32,9 @@ mod launch; // Reexport tao and wry, might want to re-export other important things pub use tao; +pub use tao::dpi::{LogicalPosition, LogicalSize}; +pub use tao::event::WindowEvent; +pub use tao::window::WindowBuilder; pub use wry; // Public exports diff --git a/packages/desktop/src/protocol.rs b/packages/desktop/src/protocol.rs index a62851128..bd9d1f7ac 100644 --- a/packages/desktop/src/protocol.rs +++ b/packages/desktop/src/protocol.rs @@ -11,6 +11,8 @@ use wry::{ static MINIFIED: &str = include_str!("./minified.js"); static DEFAULT_INDEX: &str = include_str!("./index.html"); +// todo: clean this up a bit +#[allow(clippy::too_many_arguments)] pub(super) async fn desktop_handler( request: Request>, custom_head: Option, @@ -107,7 +109,7 @@ fn build_index_file( Response::builder() .header("Content-Type", "text/html") .header("Access-Control-Allow-Origin", "*") - .body(index.into_bytes().into()) + .body(index.into()) } /// Construct the inline script that boots up the page and bridges the webview with rust code. @@ -136,10 +138,10 @@ fn module_loader(root_id: &str, headless: bool) -> String { ) } -//// Get the assset directory, following tauri/cargo-bundles directory discovery approach -//// -//// Defaults to the current directory if no asset directory is found, which is useful for development when the app -//// isn't bundled. +/// Get the assset directory, following tauri/cargo-bundles directory discovery approach +/// +/// Defaults to the current directory if no asset directory is found, which is useful for development when the app +/// isn't bundled. fn get_asset_root_or_default() -> PathBuf { get_asset_root().unwrap_or_else(|| Path::new(".").to_path_buf()) } diff --git a/packages/desktop/src/webview.rs b/packages/desktop/src/webview.rs index 1b1e3b041..b906211e8 100644 --- a/packages/desktop/src/webview.rs +++ b/packages/desktop/src/webview.rs @@ -113,7 +113,7 @@ impl WebviewInstance { } for (name, handler) in cfg.protocols.drain(..) { - webview = webview.with_custom_protocol(name, move |r| handler(r)) + webview = webview.with_custom_protocol(name, handler); } const INITIALIZATION_SCRIPT: &str = r#" diff --git a/packages/router/src/hooks/use_navigator.rs b/packages/router/src/hooks/use_navigator.rs index 9d367d83d..a05cd036f 100644 --- a/packages/router/src/hooks/use_navigator.rs +++ b/packages/router/src/hooks/use_navigator.rs @@ -49,7 +49,6 @@ use crate::prelude::{Navigator, RouterContext}; /// # let _ = vdom.rebuild(); /// ``` #[must_use] -#[deprecated = "Prefer acquiring the router directly with `dioxus_router::router()`"] pub fn use_navigator(cx: &ScopeState) -> &Navigator { &*cx.use_hook(|| { let router = cx