Simplify cli-config, hotreload -> devtools (drop to 0 deps, fast compile times) (#2975)

* simplify cli-config crate
* clean up configs
* add devtools crate, update cargo imports
* fix serve addr, fix websocket proxy issue
* add comment about opt profiles
* rename hot-reload to devtools
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-09-17 17:18:23 -07:00
1 parent 8203ee571f
commit 3fb1f739d1
58 files changed
+1131 -1654

No files matched your search

@@ -7,7 +7,7 @@ use std::fmt::Display;
use std::time::Duration;
use dioxus_core::ScopeId;
use dioxus_hot_reload::{DevserverMsg, HotReloadMsg};
use dioxus_devtools::{DevserverMsg, HotReloadMsg};
use dioxus_html::prelude::eval;
use futures_channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender};
use js_sys::JsString;
+12 -12
View File
@@ -39,8 +39,8 @@ mod document;
#[cfg(feature = "document")]
pub use document::WebDocument;
#[cfg(all(feature = "hot_reload", debug_assertions))]
mod hot_reload;
#[cfg(all(feature = "devtools", debug_assertions))]
mod devtools;
mod hydration;
#[allow(unused)]
@@ -67,8 +67,8 @@ pub async fn run(mut virtual_dom: VirtualDom, web_config: Config) -> ! {
console_error_panic_hook::set_once();
}
#[cfg(all(feature = "hot_reload", debug_assertions))]
let mut hotreload_rx = hot_reload::init();
#[cfg(all(feature = "devtools", debug_assertions))]
let mut hotreload_rx = devtools::init();
let runtime = virtual_dom.runtime();
@@ -123,7 +123,7 @@ pub async fn run(mut virtual_dom: VirtualDom, web_config: Config) -> ! {
loop {
// if virtual dom has nothing, wait for it to have something before requesting idle time
// if there is work then this future resolves immediately.
#[cfg(all(feature = "hot_reload", debug_assertions))]
#[cfg(all(feature = "devtools", debug_assertions))]
let template;
#[allow(unused)]
let mut hydration_work: Option<SuspenseMessage> = None;
@@ -137,15 +137,15 @@ pub async fn run(mut virtual_dom: VirtualDom, web_config: Config) -> ! {
.flatten();
let mut rx_hydration = hydration_receiver_iter.select_next_some();
#[cfg(all(feature = "hot_reload", debug_assertions))]
#[cfg(all(feature = "devtools", debug_assertions))]
#[allow(unused)]
{
let mut hot_reload_next = hotreload_rx.select_next_some();
let mut devtools_next = hotreload_rx.select_next_some();
select! {
_ = work => {
template = None;
},
new_template = hot_reload_next => {
new_template = devtools_next => {
template = Some(new_template);
},
hydration_data = rx_hydration => {
@@ -158,7 +158,7 @@ pub async fn run(mut virtual_dom: VirtualDom, web_config: Config) -> ! {
}
}
#[cfg(not(all(feature = "hot_reload", debug_assertions)))]
#[cfg(not(all(feature = "devtools", debug_assertions)))]
#[allow(unused)]
{
select! {
@@ -173,13 +173,13 @@ pub async fn run(mut virtual_dom: VirtualDom, web_config: Config) -> ! {
}
}
#[cfg(all(feature = "hot_reload", debug_assertions))]
#[cfg(all(feature = "devtools", debug_assertions))]
if let Some(hr_msg) = template {
// Replace all templates
dioxus_hot_reload::apply_changes(&mut virtual_dom, &hr_msg);
dioxus_devtools::apply_changes(&virtual_dom, &hr_msg);
if !hr_msg.assets.is_empty() {
crate::hot_reload::invalidate_browser_asset_cache();
crate::devtools::invalidate_browser_asset_cache();
}
}