},
+ ExpectedTag {
+ name: "div",
+ attributes: vec![],
+ is_self_closing: false,
+ }
+ ),
+ // Verify that we can parse a self-closing open tag that does not have any attributes.
+ (
+ quote! {
},
+ ExpectedTag {
+ name: "br",
+ attributes: vec![],
+ is_self_closing: true,
+ }
+ ),
+ // Verify that we can parse an open tag that has one attribute.
+ (
+ quote! {
},
+ ExpectedTag {
+ name: "div",
+ attributes: vec![("id", "hello")],
+ is_self_closing: false,
+ },
+ )
+ ];
+
+ for (tokens, expected_tag) in tests {
+ let tokens_string = tokens.to_string();
+ let tag: Tag = syn::parse2(tokens).unwrap();
+
+ match tag {
+ Tag::Open { name, attrs, is_self_closing, .. } => {
+ assert_eq!(
+ &name.to_string(), expected_tag.name,
+ "{}", tokens_string
+ );
+
+
+ assert_eq!(is_self_closing, expected_tag.is_self_closing, "{}", tokens_string);
+
+ let expected_attrs: HashMap<&'static str, &'static str> =
+ expected_tag.attributes.into_iter().collect();
+
+ assert_eq!(attrs.len(), expected_attrs.len(), "{}", tokens_string);
+ for attr in attrs {
+ let attr_key = attr.key.to_string();
+
+ let Expr::Lit(attr_val) = attr.value else {
+ panic!()
+ };
+ let Lit::Str(attr_val_str) = attr_val.lit else {
+ panic!()
+ };
+
+ let expected_val = expected_attrs.get(attr_key.as_str()).map(|val| val.to_string());
+
+ assert_eq!(
+ Some(attr_val_str.value()),
+ expected_val,
+ );
+ }
+ }
+ not_open => panic!("Should have been an open tag. {:?}", not_open),
+ }
+ }
+ }
+
+ struct ExpectedTag {
+ name: &'static str,
+ attributes: Vec<(&'static str, &'static str)>,
+ is_self_closing: bool,
+ }
+}
\ No newline at end of file
diff --git a/crates/percy-css-macro/Cargo.toml b/crates/percy-css-macro/Cargo.toml
index ce41eaf3..50af0f93 100644
--- a/crates/percy-css-macro/Cargo.toml
+++ b/crates/percy-css-macro/Cargo.toml
@@ -12,6 +12,6 @@ license = "MIT OR Apache-2.0"
proc-macro = true
[dependencies]
-syn = { version = '0.14', features = ['full'] }
-quote = '0.6'
+syn = { version = '2', features = ['full'] }
+quote = '1'
lazy_static = "1.0"
diff --git a/crates/percy-css-macro/src/lib.rs b/crates/percy-css-macro/src/lib.rs
index feb02459..03dd8769 100644
--- a/crates/percy-css-macro/src/lib.rs
+++ b/crates/percy-css-macro/src/lib.rs
@@ -114,7 +114,7 @@ fn write_css_to_file(css_file: &mut File, class: &str, input: TokenStream) {
let first_quote_mark = css.find(r#"""#).unwrap();
let last_quote_mark = css.rfind(r#"""#).unwrap();
css.truncate(last_quote_mark);
- let mut css = css.split_off(first_quote_mark + 1);
+ let css = css.split_off(first_quote_mark + 1);
// Replace :host selectors with the class name of the :host element
// A fake shadow-dom implementation.. if you will..
diff --git a/crates/percy-router-macro-test/src/book_example.rs b/crates/percy-router-macro-test/src/book_example.rs
index 31f6aa8f..0ce56b84 100644
--- a/crates/percy-router-macro-test/src/book_example.rs
+++ b/crates/percy-router-macro-test/src/book_example.rs
@@ -35,7 +35,9 @@ fn provided_data_and_param() {
.view("/users/10/favorite-meal/breakfast")
.unwrap()
.to_string(),
- "
User 10 loves Breakfast
"
+// TODO: Requires proc macro APIs that are currently unstable - https://github.com/rust-lang/rust/issues/54725
+// "
User 10 loves Breakfast
"
+ "
User10lovesBreakfast
"
);
}
diff --git a/crates/percy-router-macro/Cargo.toml b/crates/percy-router-macro/Cargo.toml
index dae3989e..9a8dabef 100644
--- a/crates/percy-router-macro/Cargo.toml
+++ b/crates/percy-router-macro/Cargo.toml
@@ -13,6 +13,6 @@ edition = "2018"
proc-macro = true
[dependencies]
-syn = { version = "0.15", features = ["full", "extra-traits"] }
-quote = "0.6.11"
-proc-macro2 = "0.4"
+syn = { version = "2", features = ["full", "extra-traits"] }
+quote = "1"
+proc-macro2 = "1"
diff --git a/crates/percy-router-macro/src/create_routes_macro.rs b/crates/percy-router-macro/src/create_routes_macro.rs
index b91e6595..b66e2b43 100644
--- a/crates/percy-router-macro/src/create_routes_macro.rs
+++ b/crates/percy-router-macro/src/create_routes_macro.rs
@@ -28,7 +28,7 @@ pub fn create_routes(input: proc_macro::TokenStream) -> proc_macro::TokenStream
let mut tokens = vec![];
for route in routes_to_create.routes {
- let original_fn_name = route.segments.last().unwrap().into_tuple().0;
+ let original_fn_name = route.segments.last().unwrap();
let original_fn_name = original_fn_name.ident.to_string();
let path_to_module_segments =
diff --git a/crates/percy-router-macro/src/route_macro.rs b/crates/percy-router-macro/src/route_macro.rs
index a7742836..9878d7da 100644
--- a/crates/percy-router-macro/src/route_macro.rs
+++ b/crates/percy-router-macro/src/route_macro.rs
@@ -60,14 +60,14 @@ pub fn route(
let route_fn: RouteFn = parse_macro_input!(input as RouteFn);
// my_route
- let route_fn_name = route_fn.route_fn.ident;
+ let route_fn_name = route_fn.route_fn.sig.ident;
// Create a new identifier called `create_my_route`
let create_route = format!("create_{}", route_fn_name);
let create_route = Ident::new(&create_route, route_fn_name.span());
// [id: u8, state: Provided
]
- let params = route_fn.route_fn.decl.inputs;
+ let params = route_fn.route_fn.sig.inputs;
// [u8, Provided]
let _types = as_param_types(¶ms);
@@ -378,7 +378,7 @@ fn as_param_idents(params: &Punctuated) -> Vec<&Ident> {
.map(|arg| {
match arg {
// some_param_name: type
- FnArg::Captured(captured) => match captured.pat {
+ FnArg::Typed(captured) => match captured.pat.as_ref() {
Pat::Ident(ref pat) => &pat.ident,
_ => unimplemented!("TODO: What should happen for other patterns?"),
},
@@ -394,8 +394,8 @@ fn as_param_types(params: &Punctuated) -> Vec<&Type> {
.map(|arg| {
match arg {
// some_param_name: type
- FnArg::Captured(captured) => match captured.pat {
- Pat::Ident(ref _pat) => &captured.ty,
+ FnArg::Typed(captured) => match captured.pat.as_ref() {
+ Pat::Ident(ref _pat) => captured.ty.as_ref(),
_ => unimplemented!("TODO: What should happen for other patterns?"),
},
_ => unimplemented!("TODO: What should happen for non captured args?"),
diff --git a/crates/virtual-node/src/event/virtual_events.rs b/crates/virtual-node/src/event/virtual_events.rs
index 3131c99e..aac2ab53 100644
--- a/crates/virtual-node/src/event/virtual_events.rs
+++ b/crates/virtual-node/src/event/virtual_events.rs
@@ -55,6 +55,7 @@ pub struct VirtualEvents {
// Never changes after creation.
events_id_props_prefix: f64,
}
+
struct VirtualEventsInner {
root: Rc>,
events: HashMap>>>,
@@ -89,6 +90,7 @@ pub struct VirtualEventElement {
events_id: ElementEventsId,
children: Option,
}
+
#[derive(Debug)]
struct VirtualEventElementChildren {
first_child: Rc>,
@@ -322,7 +324,7 @@ impl VirtualEventNode {
/// Remove a child node from it's siblings.
pub fn remove_node_from_siblings(&mut self, child: &Rc>) {
- let mut child = &mut *child.borrow_mut();
+ let child = &mut *child.borrow_mut();
let is_first_sibling = child.previous_sibling.is_none();
let is_last_sibling = child.next_sibling.is_none();
@@ -434,7 +436,7 @@ pub(crate) fn set_events_id(node: &JsValue, events: &VirtualEvents, events_id: E
&ELEMENT_EVENTS_ID_PROP.into(),
&format!("{}{}", events.events_id_props_prefix(), events_id.get()).into(),
)
- .unwrap();
+ .unwrap();
}
#[cfg(test)]
diff --git a/examples/isomorphic/server/Cargo.toml b/examples/isomorphic/server/Cargo.toml
index d98316eb..399db4fc 100644
--- a/examples/isomorphic/server/Cargo.toml
+++ b/examples/isomorphic/server/Cargo.toml
@@ -7,6 +7,7 @@ edition = "2018"
[features]
default = ["with-actix"]
+# TODO: Remove actix-web in favor of axum. Easier to use.
with-actix = ["actix-web", "actix-files", "actix-rt", "serde"]
[dependencies]
@@ -14,9 +15,10 @@ chrono = "0.4.6"
isomorphic-app = { path = "../app" }
env_logger = "0.6.1"
percy-dom = { path = "../../../crates/percy-dom" }
+tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
# with-actix
-actix-web = {optional = true, version = "1.0.3"}
-actix-files = {optional = true, version = "0.1.3"}
-actix-rt = {optional = true, version = "0.2.3"}
-serde = {optional = true, version = "1.0.94"}
+actix-web = { optional = true, version = "4" }
+actix-files = { optional = true, version = "0.6" }
+actix-rt = { optional = true, version = "2.9" }
+serde = { optional = true, version = "1" }
diff --git a/examples/isomorphic/server/src/actix_server.rs b/examples/isomorphic/server/src/actix_server.rs
index b3644fc5..afdacdda 100644
--- a/examples/isomorphic/server/src/actix_server.rs
+++ b/examples/isomorphic/server/src/actix_server.rs
@@ -18,16 +18,16 @@ struct RequestQuery {
/// # Example
///
/// localhost:7878/?init=50
-fn index(query: web::Query) -> impl Responder {
+async fn index(query: web::Query) -> impl Responder {
respond("/".to_string(), query.init)
}
/// # Example
///
/// localhost:7878/contributors?init=1200
-fn catch_all(req: HttpRequest) -> impl Responder {
- let query = web::Query::::extract(&req).unwrap();
- let path = web::Path::::extract(&req).unwrap();
+async fn catch_all(req: HttpRequest) -> impl Responder {
+ let query = web::Query::::extract(&req).await.unwrap();
+ let path = web::Path::::extract(&req).await.unwrap();
respond(path.to_string(), query.init)
}
@@ -41,18 +41,19 @@ fn respond(path: String, init: Option) -> impl Responder {
HttpResponse::Ok().content_type("text/html").body(html)
}
-pub fn serve(static_files: String) {
- let sys = System::new("actix-isomorphic");
+pub async fn serve(static_files: String) {
+ let sys = System::new();
- HttpServer::new(move || {
+ let server = HttpServer::new(move || {
ActixApp::new()
.route("/", web::get().to(index))
.route("/{path}", web::get().to(catch_all))
.service(fs::Files::new("/static", static_files.as_str()).show_files_listing())
})
- .bind("0.0.0.0:7878")
- .unwrap()
- .start();
+ .bind("0.0.0.0:7878")
+ .unwrap();
+ server
+ .run().await.unwrap();
println!("Actix server listening on port 7878");
diff --git a/examples/isomorphic/server/src/main.rs b/examples/isomorphic/server/src/main.rs
index 2f16ec08..f64ad5d5 100644
--- a/examples/isomorphic/server/src/main.rs
+++ b/examples/isomorphic/server/src/main.rs
@@ -4,7 +4,8 @@ use isomorphic_server::rocket_server::rocket;
#[cfg(feature = "with-actix")]
use isomorphic_server::actix_server::serve;
-fn main() {
+#[tokio::main]
+async fn main() {
env_logger::init();
let static_files = {
@@ -27,5 +28,5 @@ fn main() {
// cargo run -p server-www --features with-actix
#[cfg(feature = "with-actix")]
- serve(static_files)
+ serve(static_files).await
}
diff --git a/examples/unit-testing-components/src/main.rs b/examples/unit-testing-components/src/main.rs
index c32f373a..6052ffb9 100644
--- a/examples/unit-testing-components/src/main.rs
+++ b/examples/unit-testing-components/src/main.rs
@@ -72,7 +72,7 @@ mod tests {
.as_vtext_ref()
.expect("Not a text node")
.text,
- " Please fill me up :( I am only 0.2587 percent full :( "
+ "Please fill me up :( I am only 0.2587 percent full :("
)
}
}