wip: more tweaks

This commit is contained in:
Jonathan Kelley committed 2022-11-14 18:09:09 -08:00
1 parent baab2b9b4f
commit 7a6b58d793
4 files changed
+41 -21

No files matched your search

+4 -2
View File
@@ -46,8 +46,10 @@ flate2 = "1.0.22"
tar = "0.4.38" tar = "0.4.38"
tower = "0.4.12" tower = "0.4.12"
dioxus-rsx = { git = "https://github.com/dioxuslabs/dioxus.git" } dioxus-rsx = { path = "../../dioxus/packages/rsx" }
dioxus-autofmt = { git = "https://github.com/dioxuslabs/dioxus.git" } dioxus-autofmt = { path = "../../dioxus/packages/autofmt" }
# dioxus-rsx = { git = "https://github.com/dioxuslabs/dioxus.git" }
# dioxus-autofmt = { git = "https://github.com/dioxuslabs/dioxus.git" }
[[bin]] [[bin]]
path = "src/main.rs" path = "src/main.rs"
+1 -1
View File
@@ -14,7 +14,7 @@ export async function activate(context: vscode.ExtensionContext) {
} }
context.subscriptions.push( context.subscriptions.push(
vscode.commands.registerTextEditorCommand('editor.action.clipboardPasteAction', onPasteHandler), // vscode.commands.registerTextEditorCommand('editor.action.clipboardPasteAction', onPasteHandler),
vscode.commands.registerCommand('extension.htmlToDioxusRsx', translateBlock), vscode.commands.registerCommand('extension.htmlToDioxusRsx', translateBlock),
vscode.commands.registerCommand('extension.htmlToDioxusComponent', translateComponent), vscode.commands.registerCommand('extension.htmlToDioxusComponent', translateComponent),
vscode.commands.registerCommand('extension.formatRsx', fmtSelection), vscode.commands.registerCommand('extension.formatRsx', fmtSelection),
+15
View File
@@ -13,6 +13,7 @@ pub struct Autoformat {
} }
impl Autoformat { impl Autoformat {
// Todo: autoformat the entire crate
pub fn autoformat(self) -> Result<()> { pub fn autoformat(self) -> Result<()> {
if let Some(raw) = self.raw { if let Some(raw) = self.raw {
if let Some(inner) = dioxus_autofmt::fmt_block(&raw, 0) { if let Some(inner) = dioxus_autofmt::fmt_block(&raw, 0) {
@@ -59,3 +60,17 @@ rsx! {
dbg!(out); dbg!(out);
} }
/*
parse the whole doc
find all the comment blocks
*/
+21 -18
View File
@@ -34,26 +34,29 @@ pub async fn startup(config: CrateConfig) -> Result<()> {
// file watcher: check file change // file watcher: check file change
let watcher_conf = config.clone(); let watcher_conf = config.clone();
let mut watcher = RecommendedWatcher::new(move |_: notify::Result<notify::Event>| { let mut watcher = RecommendedWatcher::new(
if chrono::Local::now().timestamp() > last_update_time { move |_: notify::Result<notify::Event>| {
log::info!("Start to rebuild project..."); if chrono::Local::now().timestamp() > last_update_time {
if builder::build(&watcher_conf).is_ok() { log::info!("Start to rebuild project...");
// change the websocket reload state to true; if builder::build(&watcher_conf).is_ok() {
// the page will auto-reload. // change the websocket reload state to true;
if watcher_conf // the page will auto-reload.
.dioxus_config if watcher_conf
.web .dioxus_config
.watcher .web
.reload_html .watcher
.unwrap_or(false) .reload_html
{ .unwrap_or(false)
let _ = Serve::regen_dev_page(&watcher_conf); {
let _ = Serve::regen_dev_page(&watcher_conf);
}
let _ = reload_tx.send("reload".into());
last_update_time = chrono::Local::now().timestamp();
} }
let _ = reload_tx.send("reload".into());
last_update_time = chrono::Local::now().timestamp();
} }
} },
}) notify::Config::default(),
)
.unwrap(); .unwrap();
let allow_watch_path = config let allow_watch_path = config
.dioxus_config .dioxus_config