diff --git a/Cargo.lock b/Cargo.lock index b9d5c8d9f..2f7536466 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -561,7 +561,7 @@ dependencies = [ [[package]] name = "dioxus-cli" -version = "0.2.0" +version = "0.2.1" dependencies = [ "anyhow", "atty", @@ -574,7 +574,6 @@ dependencies = [ "colored 2.0.0", "convert_case", "ctrlc", - "dioxus-core", "dioxus-rsx", "dirs 4.0.0", "fern", diff --git a/Cargo.toml b/Cargo.toml index ed6ce7a18..4825bec74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-cli" -version = "0.2.0" +version = "0.2.1" authors = ["Jonathan Kelley"] edition = "2021" description = "CLI tool for developing, testing, and publishing Dioxus apps" @@ -58,8 +58,6 @@ zip = "0.6.2" tower = "0.4.12" syn = { version = "1.0", features = ["full", "extra-traits"] } - -dioxus-core = { git = "https://github.com/dioxuslabs/dioxus/" } dioxus-rsx = { git = "https://github.com/dioxuslabs/dioxus/" } proc-macro2 = { version = "1.0", features = ["span-locations"] } diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index 7b6a43951..4be6a4d30 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -2,7 +2,6 @@ use axum::{ extract::{ws::Message, Extension, TypedHeader, WebSocketUpgrade}, response::IntoResponse, }; -use dioxus_core::{prelude::TemplateId, CodeLocation, OwnedCodeLocation, SetTemplateMsg}; use dioxus_rsx::try_parse_template; use std::{path::PathBuf, sync::Arc}; @@ -21,7 +20,7 @@ use syn::spanned::Spanned; use tokio::sync::broadcast; pub struct HotReloadState { - pub messages: broadcast::Sender, + pub messages: broadcast::Sender, pub build_manager: Arc, pub last_file_rebuild: Arc>, pub watcher_config: CrateConfig, @@ -75,7 +74,7 @@ pub async fn hot_reload_handler( log::info!("🔥 Hot Reload WebSocket connected"); { // update any rsx calls that changed before the websocket connected. - let mut messages = Vec::new(); + // let mut messages = Vec::new(); { log::info!("🔮 Finding updates since last compile..."); @@ -98,11 +97,11 @@ pub async fn hot_reload_handler( if let DiffResult::RsxChanged(changed) = find_rsx(&new_file, &old_file) { for (old, new) in changed.into_iter() { - let hr = get_location( - &state.watcher_config.crate_dir, - k, - old.to_token_stream(), - ); + // let hr = get_location( + // &state.watcher_config.crate_dir, + // k, + // old.to_token_stream(), + // ); // get the original source code to preserve whitespace let span = new.span(); let start = span.start(); @@ -125,32 +124,32 @@ pub async fn hot_reload_handler( } let rsx = lines.join("\n"); - let old_dyn_ctx = try_parse_template( - &format!("{}", old.tokens), - hr.to_owned(), - None, - ) - .map(|(_, old_dyn_ctx)| old_dyn_ctx); - if let Ok((template, _)) = - try_parse_template(&rsx, hr.to_owned(), old_dyn_ctx.ok()) - { - messages.push(SetTemplateMsg(TemplateId(hr), template)); - } + // let old_dyn_ctx = try_parse_template( + // &format!("{}", old.tokens), + // hr.to_owned(), + // None, + // ) + // .map(|(_, old_dyn_ctx)| old_dyn_ctx); + // if let Ok((template, _)) = + // try_parse_template(&rsx, hr.to_owned(), old_dyn_ctx.ok()) + // { + // // messages.push(SetTemplateMsg(TemplateId(hr), template)); + // } } } } } } } - for msg in messages { - if socket - .send(Message::Text(serde_json::to_string(&msg).unwrap())) - .await - .is_err() - { - return; - } - } + // for msg in messages { + // if socket + // .send(Message::Text(serde_json::to_string(&msg).unwrap())) + // .await + // .is_err() + // { + // return; + // } + // } log::info!("finished"); } @@ -173,13 +172,13 @@ pub async fn hot_reload_handler( }) } -pub fn get_location(crate_path: &Path, path: &Path, ts: TokenStream) -> CodeLocation { - let span = ts.span().start(); - let relative = path.strip_prefix(crate_path).unwrap(); - CodeLocation::Dynamic(Box::new(OwnedCodeLocation { - file_path: relative.display().to_string(), - crate_path: crate_path.display().to_string(), - line: span.line as u32, - column: span.column as u32 + 1, - })) -} +// pub fn get_location(crate_path: &Path, path: &Path, ts: TokenStream) -> CodeLocation { +// let span = ts.span().start(); +// let relative = path.strip_prefix(crate_path).unwrap(); +// CodeLocation::Dynamic(Box::new(OwnedCodeLocation { +// file_path: relative.display().to_string(), +// crate_path: crate_path.display().to_string(), +// line: span.line as u32, +// column: span.column as u32 + 1, +// })) +// } diff --git a/src/server/mod.rs b/src/server/mod.rs index dde48f69c..830f013b1 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -8,7 +8,6 @@ use axum::{ }; use cargo_metadata::diagnostic::Diagnostic; use colored::Colorize; -use dioxus_core::{prelude::TemplateId, SetTemplateMsg}; use dioxus_rsx::try_parse_template; use notify::{RecommendedWatcher, Watcher}; use syn::spanned::Spanned; @@ -139,55 +138,55 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { } DiffResult::RsxChanged(changed) => { log::info!("🪁 reloading rsx"); - for (old, new) in changed.into_iter() { - let hr = get_location( - &crate_dir, - &path.to_path_buf(), - old.to_token_stream(), - ); - // get the original source code to preserve whitespace - let span = new.span(); - let start = span.start(); - let end = span.end(); - let mut lines: Vec<_> = src - .lines() - .skip(start.line - 1) - .take(end.line - start.line + 1) - .collect(); - if let Some(first) = lines.first_mut() { - *first = first.split_at(start.column).1; - } - if let Some(last) = lines.last_mut() { - // if there is only one line the start index of last line will be the start of the rsx!, not the start of the line - if start.line == end.line { - *last = last - .split_at(end.column - start.column) - .0; - } else { - *last = last.split_at(end.column).0; - } - } - let rsx = lines.join("\n"); + // for (old, new) in changed.into_iter() { + // let hr = get_location( + // &crate_dir, + // &path.to_path_buf(), + // old.to_token_stream(), + // ); + // // get the original source code to preserve whitespace + // let span = new.span(); + // let start = span.start(); + // let end = span.end(); + // let mut lines: Vec<_> = src + // .lines() + // .skip(start.line - 1) + // .take(end.line - start.line + 1) + // .collect(); + // if let Some(first) = lines.first_mut() { + // *first = first.split_at(start.column).1; + // } + // if let Some(last) = lines.last_mut() { + // // if there is only one line the start index of last line will be the start of the rsx!, not the start of the line + // if start.line == end.line { + // *last = last + // .split_at(end.column - start.column) + // .0; + // } else { + // *last = last.split_at(end.column).0; + // } + // } + // let rsx = lines.join("\n"); - let old_dyn_ctx = try_parse_template( - &format!("{}", old.tokens), - hr.to_owned(), - None, - ) - .map(|(_, old_dyn_ctx)| old_dyn_ctx); - if let Ok((template, _)) = try_parse_template( - &rsx, - hr.to_owned(), - old_dyn_ctx.ok(), - ) { - messages.push(SetTemplateMsg( - TemplateId(hr), - template, - )); - } else { - needs_rebuild = true; - } - } + // let old_dyn_ctx = try_parse_template( + // &format!("{}", old.tokens), + // hr.to_owned(), + // None, + // ) + // .map(|(_, old_dyn_ctx)| old_dyn_ctx); + // // if let Ok((template, _)) = try_parse_template( + // // &rsx, + // // hr.to_owned(), + // // old_dyn_ctx.ok(), + // // ) { + // // messages.push(SetTemplateMsg( + // // TemplateId(hr), + // // template, + // // )); + // // } else { + // // needs_rebuild = true; + // // } + // } } } }