use crate::{cfg::ConfigOptsServe, BuildResult, Result}; use dioxus_cli_config::CrateConfig; use cargo_metadata::diagnostic::Diagnostic; use dioxus_core::Template; use dioxus_html::HtmlCtx; use dioxus_rsx::hot_reload::*; use notify::{RecommendedWatcher, Watcher}; use std::sync::{Arc, Mutex}; use tokio::sync::broadcast::{self}; mod output; use output::*; pub mod desktop; pub mod fullstack; pub mod web; /// Sets up a file watcher async fn setup_file_watcher Result + Send + 'static>( build_with: F, config: &CrateConfig, web_info: Option, hot_reload: Option, ) -> Result { let mut last_update_time = chrono::Local::now().timestamp(); // file watcher: check file change let allow_watch_path = config.dioxus_config.web.watcher.watch_path.clone(); let watcher_config = config.clone(); let mut watcher = notify::recommended_watcher(move |info: notify::Result| { let config = watcher_config.clone(); if let Ok(e) = info { match e.kind { notify::EventKind::Create(_) | notify::EventKind::Remove(_) | notify::EventKind::Modify(_) => { if chrono::Local::now().timestamp() > last_update_time { let mut needs_full_rebuild; if let Some(hot_reload) = &hot_reload { // find changes to the rsx in the file let mut rsx_file_map = hot_reload.file_map.lock().unwrap(); let mut messages: Vec