mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 20:53:06 +00:00
fix: disable hotreloaidng stuff
This commit is contained in:
parent
aa05dc3054
commit
7d49f71cd5
4 changed files with 87 additions and 92 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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"] }
|
||||
|
|
|
@ -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<SetTemplateMsg>,
|
||||
pub messages: broadcast::Sender<String>,
|
||||
pub build_manager: Arc<BuildManager>,
|
||||
pub last_file_rebuild: Arc<Mutex<FileMap>>,
|
||||
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,
|
||||
// }))
|
||||
// }
|
||||
|
|
|
@ -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;
|
||||
// // }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue