Browse Source

remove the hot-reload-macro crate

= 2 năm trước cách đây
mục cha
commit
9e45cbe4a7

+ 0 - 1
Cargo.toml

@@ -21,7 +21,6 @@ members = [
     "packages/rsx-rosetta",
     "packages/rsx-rosetta",
     "packages/signals",
     "packages/signals",
     "packages/hot-reload",
     "packages/hot-reload",
-    "packages/hot-reload-macro",
     "docs/guide",
     "docs/guide",
 ]
 ]
 
 

+ 0 - 13
packages/hot-reload-macro/Cargo.toml

@@ -1,13 +0,0 @@
-[package]
-name = "dioxus-hot-reload-macro"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-syn = { version = "1.0.107", features = ["full"] }
-proc-macro2 = { version = "1.0" }
-
-[lib]
-proc-macro = true

+ 0 - 7
packages/hot-reload-macro/src/lib.rs

@@ -1,7 +0,0 @@
-use proc_macro::TokenStream;
-use syn::__private::quote::quote;
-
-#[proc_macro]
-pub fn hot_reload(_: TokenStream) -> TokenStream {
-    quote!(dioxus_hot_reload::init(core::env!("CARGO_MANIFEST_DIR"))).into()
-}

+ 0 - 1
packages/hot-reload/Cargo.toml

@@ -6,7 +6,6 @@ edition = "2021"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 
 [dependencies]
 [dependencies]
-dioxus-hot-reload-macro = { path = "../hot-reload-macro" }
 dioxus-rsx = { path = "../rsx" }
 dioxus-rsx = { path = "../rsx" }
 dioxus-core = { path = "../core", features = ["serialize"] }
 dioxus-core = { path = "../core", features = ["serialize"] }
 dioxus-html = { path = "../html", features = ["hot-reload-context"] }
 dioxus-html = { path = "../html", features = ["hot-reload-context"] }

+ 12 - 2
packages/hot-reload/src/lib.rs

@@ -6,14 +6,13 @@ use std::{
 };
 };
 
 
 use dioxus_core::Template;
 use dioxus_core::Template;
-pub use dioxus_hot_reload_macro::hot_reload;
 use dioxus_html::HtmlCtx;
 use dioxus_html::HtmlCtx;
 use dioxus_rsx::hot_reload::{FileMap, UpdateResult};
 use dioxus_rsx::hot_reload::{FileMap, UpdateResult};
 use interprocess::local_socket::{LocalSocketListener, LocalSocketStream};
 use interprocess::local_socket::{LocalSocketListener, LocalSocketStream};
 use notify::{RecommendedWatcher, RecursiveMode, Watcher};
 use notify::{RecommendedWatcher, RecursiveMode, Watcher};
 
 
 /// Initialize the hot reloading listener on the given path
 /// Initialize the hot reloading listener on the given path
-pub fn init(path: &'static str) {
+pub fn init(path: &'static str, listening_paths: &'static [&'static str]) {
     if let Ok(crate_dir) = PathBuf::from_str(path) {
     if let Ok(crate_dir) = PathBuf::from_str(path) {
         let temp_file = std::env::temp_dir().join("@dioxusin");
         let temp_file = std::env::temp_dir().join("@dioxusin");
         let channels = Arc::new(Mutex::new(Vec::new()));
         let channels = Arc::new(Mutex::new(Vec::new()));
@@ -109,3 +108,14 @@ pub fn connect(mut f: impl FnMut(Template<'static>) + Send + 'static) {
         }
         }
     });
     });
 }
 }
+
+#[macro_export]
+macro_rules! hot_reload {
+    () => {
+        dioxus_hot_reload::init(core::env!("CARGO_MANIFEST_DIR"), &[])
+    };
+
+    ($($paths: literal,)*,?) => {
+        dioxus_hot_reload::init(core::env!("CARGO_MANIFEST_DIR"), &[$($path,)*])
+    };
+}