From 129d0a68ff746e29625aa9d4d4ffbf9cd967ad48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Esp=C3=ADn?= Date: Fri, 20 Oct 2023 19:59:49 +0200 Subject: [PATCH] feat: Optional web support for hot-reload crate (#1527) * feat: Optional web support for hot-reload crate * rename feature * tweak * tweak --- packages/hot-reload/Cargo.toml | 7 ++++--- packages/hot-reload/src/file_watcher.rs | 8 +++++--- packages/hot-reload/src/lib.rs | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/hot-reload/Cargo.toml b/packages/hot-reload/Cargo.toml index b724ad685..70057114a 100644 --- a/packages/hot-reload/Cargo.toml +++ b/packages/hot-reload/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["dom", "ui", "gui", "react", "hot-reloading"] [dependencies] dioxus-rsx = { workspace = true } dioxus-core = { workspace = true, features = ["serialize"] } -dioxus-html = { workspace = true } +dioxus-html = { workspace = true, optional = true } interprocess-docfix = { version = "1.2.2" } notify = { version = "5.0.0", optional = true } @@ -24,5 +24,6 @@ once_cell = { version = "1.17.0", optional = true } ignore = { version = "0.4.19", optional = true } [features] -default = [] -file_watcher = ["ignore", "chrono", "notify", "execute", "once_cell", "ignore", "dioxus-html/hot-reload-context"] +default = ["dioxus-html"] +custom_file_watcher = ["ignore", "chrono", "notify", "execute", "once_cell", "ignore"] +file_watcher = ["custom_file_watcher", "dioxus-html/hot-reload-context"] diff --git a/packages/hot-reload/src/file_watcher.rs b/packages/hot-reload/src/file_watcher.rs index 48d97dfa7..2509dd789 100644 --- a/packages/hot-reload/src/file_watcher.rs +++ b/packages/hot-reload/src/file_watcher.rs @@ -13,11 +13,12 @@ use dioxus_rsx::{ }; use interprocess_docfix::local_socket::{LocalSocketListener, LocalSocketStream}; use notify::{RecommendedWatcher, RecursiveMode, Watcher}; - -pub use dioxus_html::HtmlCtx; use serde::{Deserialize, Serialize}; -pub struct Config { +#[cfg(feature = "file_watcher")] +use dioxus_html::HtmlCtx; + +pub struct Config { root_path: &'static str, listening_paths: &'static [&'static str], excluded_paths: &'static [&'static str], @@ -39,6 +40,7 @@ impl Default for Config { } } +#[cfg(feature = "file_watcher")] impl Config { pub const fn new() -> Self { Self { diff --git a/packages/hot-reload/src/lib.rs b/packages/hot-reload/src/lib.rs index f7906b141..68692b72b 100644 --- a/packages/hot-reload/src/lib.rs +++ b/packages/hot-reload/src/lib.rs @@ -6,9 +6,9 @@ pub use dioxus_html::HtmlCtx; use interprocess_docfix::local_socket::LocalSocketStream; use serde::{Deserialize, Serialize}; -#[cfg(feature = "file_watcher")] +#[cfg(feature = "custom_file_watcher")] mod file_watcher; -#[cfg(feature = "file_watcher")] +#[cfg(feature = "custom_file_watcher")] pub use file_watcher::*; /// A message the hot reloading server sends to the client