Improve compile times by splitting out rsx-hotreload from rsx (#2971)

* fix imports, migrate over rsx-hotreload
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-09-16 17:35:05 -07:00
1 parent b67122dd2a
commit 463e67cd12
41 files changed
+188 -190

No files matched your search

File diff suppressed because it is too large. Load diff
-31
View File
@@ -1,31 +0,0 @@
use dioxus_rsx::hot_reload::diff_rsx;
use syn::File;
macro_rules! assert_rsx_changed {
(
$( #[doc = $doc:expr] )*
$name:ident
) => {
$( #[doc = $doc] )*
#[test]
fn $name() {
let old = include_str!(concat!("./valid/", stringify!($name), ".old.rsx"));
let new = include_str!(concat!("./valid/", stringify!($name), ".new.rsx"));
let (old, new) = load_files(old, new);
assert!(diff_rsx(&new, &old).is_some());
}
};
}
fn load_files(old: &str, new: &str) -> (File, File) {
let old = syn::parse_file(old).unwrap();
let new = syn::parse_file(new).unwrap();
(old, new)
}
assert_rsx_changed![combo];
assert_rsx_changed![expr];
assert_rsx_changed![for_];
assert_rsx_changed![if_];
assert_rsx_changed![let_];
assert_rsx_changed![nested];
@@ -1 +0,0 @@
dioxus_core :: TemplateNode :: Element { tag : dioxus_elements :: elements :: circle :: TAG_NAME , namespace : dioxus_elements :: elements :: circle :: NAME_SPACE , attrs : & [dioxus_core :: TemplateAttribute :: Dynamic { id : 0usize } , dioxus_core :: TemplateAttribute :: Dynamic { id : 1usize } , dioxus_core :: TemplateAttribute :: Dynamic { id : 2usize } , dioxus_core :: TemplateAttribute :: Static { name : dioxus_elements :: elements :: circle :: stroke . 0 , namespace : dioxus_elements :: elements :: circle :: stroke . 1 , value : "green" , } , dioxus_core :: TemplateAttribute :: Static { name : dioxus_elements :: elements :: circle :: fill . 0 , namespace : dioxus_elements :: elements :: circle :: fill . 1 , value : "yellow" , } ,] , children : & [] , }
-11
View File
@@ -1,11 +0,0 @@
rsx! {
circle {
cx: 50,
cy: 50,
r: 40,
stroke: "green",
fill: "yellow"
}
}
-68
View File
@@ -1,68 +0,0 @@
// This test is used by playwright configured in the root of the repo
use dioxus::prelude::*;
fn app() -> Element {
let mut num = use_signal(|| 0);
let mut eval_result = use_signal(String::new);
let a = 123;
rsx! {
div {
"hello axum! {num}"
button { class: "increment-button", onclick: move |_| num += 1, "Increment" }
}
svg {
circle {
cx: 50,
cy: 50,
r: 40,
stroke: "green",
fill: "yellow"
}
}
div {
class: "raw-attribute-div",
"raw-attribute": "raw-attribute-value"
}
div { class: "hidden-attribute-div", hidden: true }
div {
class: "dangerous-inner-html-div",
dangerous_inner_html: "<p>hello dangerous inner html</p>"
}
input { value: "hello input" }
div { class: "style-div", color: "red", "colored text" }
div { class: "style-div", color: "red", "colored text" }
button {
class: "eval-button",
onclick: move |_| async move {
let mut eval = eval(
r#"
window.document.title = 'Hello from Dioxus Eval!';
dioxus.send("returned eval value");
"#,
);
let result = eval.recv().await;
if let Ok(serde_json::Value::String(string)) = result {
eval_result.set(string);
}
},
"Eval!!!!"
"Eval!!!!"
"Eval!!!!!"
"Eval!!!!"
"Eval!!!!"
"Eval!!!!"
}
div { class: "eval-result", "{eval_result}" }
}
}
fn main() {
// tracing_wasm::set_as_global_default_with_config(
// tracing_wasm::WASMLayerConfigBuilder::default()
// .set_max_level(tracing::Level::TRACE)
// .build(),
// );
launch(app);
}
-57
View File
@@ -1,57 +0,0 @@
// This test is used by playwright configured in the root of the repo
use dioxus::prelude::*;
fn app() -> Element {
let mut num = use_signal(|| 0);
let mut eval_result = use_signal(String::new);
let a = 123;
rsx! {
div {
"hello axum! {num}"
button { class: "increment-button", onclick: move |_| num += 1, "Increment" }
}
svg { circle { cx: 50, cy: 50, r: 40, stroke: "green", fill: "yellow" } }
div { class: "raw-attribute-div", "raw-attribute": "raw-attribute-value" }
div { class: "hidden-attribute-div", hidden: true }
div {
class: "dangerous-inner-html-div",
dangerous_inner_html: "<p>hello dangerous inner html</p>"
}
input { value: "hello input" }
div { class: "style-div", color: "red", "colored text" }
div { class: "style-div", color: "red", "colored text" }
button {
class: "eval-button",
onclick: move |_| async move {
let mut eval = eval(
r#"
window.document.title = 'Hello from Dioxus Eval!';
dioxus.send("returned eval value");
"#,
);
let result = eval.recv().await;
if let Ok(serde_json::Value::String(string)) = result {
eval_result.set(string);
}
},
"Eval!!!!"
"Eval!!!!"
"Eval!!!!!"
"Eval!!!!"
"Eval!!!!"
}
div { class: "eval-result", "{eval_result}" }
}
}
fn main() {
// tracing_wasm::set_as_global_default_with_config(
// tracing_wasm::WASMLayerConfigBuilder::default()
// .set_max_level(tracing::Level::TRACE)
// .build(),
// );
launch(app);
}
-17
View File
@@ -1,17 +0,0 @@
use dioxus::prelude::*;
pub fn CoolChild() -> Element {
let head_ = rsx! {
div {
div { "asasddasdasd" }
div { "asasdd1asaassdd23asasddasd" }
div { "aasdsdsaasdsddasd" }
}
};
rsx! {
div {
{head_}
}
}
}
-17
View File
@@ -1,17 +0,0 @@
use dioxus::prelude::*;
pub fn CoolChild() -> Element {
let head_ = rsx! {
div {
div { "asasddasdasd" }
div { "asasdd1asaassdd23asasddasd" }
// div { "aasdsdsaasdsddasd" }
}
};
rsx! {
div {
{head_}
}
}
}
-9
View File
@@ -1,9 +0,0 @@
use dioxus::prelude::*;
pub fn CoolChild() -> Element {
rsx! {
for items in vec![1, 2, 3] {
div { "asasddasdasd" }
}
}
}
-10
View File
@@ -1,10 +0,0 @@
use dioxus::prelude::*;
pub fn CoolChild() -> Element {
rsx! {
for items in vec![1, 2, 3] {
div { "123" }
div { "asasddasdasd" }
}
}
}
-10
View File
@@ -1,10 +0,0 @@
use dioxus::prelude::*;
pub fn CoolChild() -> Element {
rsx! {
if cond() {
div { "123" }
div { "asasddasdasd" }
}
}
}
-9
View File
@@ -1,9 +0,0 @@
use dioxus::prelude::*;
pub fn CoolChild() -> Element {
rsx! {
if cond() {
div { "asasddasdasd" }
}
}
}
-12
View File
@@ -1,12 +0,0 @@
use dioxus::prelude::*;
pub fn CoolChild() -> Element {
let head_ = rsx! {
div {
div { "asasddasdasd" }
div { "asasdd1asaassdd23asasddasd" }
}
};
head_
}
-12
View File
@@ -1,12 +0,0 @@
use dioxus::prelude::*;
pub fn CoolChild() -> Element {
let head_ = rsx! {
div {
div { "asasddasdasd" }
div { "asasdd1asaassdd23asasddasdasd" }
}
};
head_
}
-10
View File
@@ -1,10 +0,0 @@
use dioxus::prelude::*;
pub fn CoolChild() -> Element {
rsx! {
ForLoop {
div { "123" }
div { "asasddasdasd" }
}
}
}
-9
View File
@@ -1,9 +0,0 @@
use dioxus::prelude::*;
pub fn CoolChild() -> Element {
rsx! {
ForLoop {
div { "asasddasdasd" }
}
}
}