Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Optional web support for hot-reload crate #1527

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/hot-reload/Cargo.toml
Expand Up @@ -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 }
Expand All @@ -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"]
8 changes: 5 additions & 3 deletions packages/hot-reload/src/file_watcher.rs
Expand Up @@ -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<Ctx: HotReloadingContext = HtmlCtx> {
#[cfg(feature = "file_watcher")]
use dioxus_html::HtmlCtx;

pub struct Config<Ctx: HotReloadingContext> {
root_path: &'static str,
listening_paths: &'static [&'static str],
excluded_paths: &'static [&'static str],
Expand All @@ -39,6 +40,7 @@ impl<Ctx: HotReloadingContext> Default for Config<Ctx> {
}
}

#[cfg(feature = "file_watcher")]
impl Config<HtmlCtx> {
pub const fn new() -> Self {
Self {
Expand Down
4 changes: 2 additions & 2 deletions packages/hot-reload/src/lib.rs
Expand Up @@ -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
Expand Down