Switch to a pool of dynamic values for hot reloading (#2705)

* create the dynamic value pool

* assign ids to dynamic formatted segments

* separate the rendering and literal pools

* rsx output compiles again

* more examples compiling with new rsx expansion

* update template body explanation

* all workspace examples compile

* fix formatted segments in keys

* start hot reload diffing

* fix component literal hot reloading

* start integrate new hot reloading with the CLI

* simple hot reloads working

* Fix hot reloading blocks with components

* implement hot reloading for if chains

* Fix hot reloading after a template requires a full rebuild

* Fix hot reloading any attribute values

* remove unsafe from hot reload utils

* Fix hot reloading empty rsx

* add more hot reloading tests

* reorganize hot reload module

* fix web hydration

* fix empty rsx nodes in autoformatting

* fix tests

* remove path sorting logic from core

* make template names more consistent in debug mode

* fix quote_as_hot_reload_literal for explicitly typed literals

* fix can_be_shorthand for string literals

* fix formatted single dynamic expression

* Fix usize component properties and playwright tests

* remove default implementation for TemplateBody

* add a bunch more comments for diffing, scoring and why this scoring system is optimal
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-07-30 17:16:27 +00:00
1 parent f3ca1484a1
commit 34bdcd15cf
40 files changed
+2288 -1897

No files matched your search

+4 -14
View File
@@ -1,11 +1,7 @@
#[cfg(feature = "hot_reload")]
use dioxus_core::TemplateNode;
use crate::{
literal::{HotLiteral, HotLiteralType},
location::DynIdx,
IfmtInput,
};
use crate::{literal::HotLiteral, location::DynIdx, HotReloadFormattedSegment, IfmtInput};
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::ToTokens;
use quote::{quote, TokenStreamExt};
@@ -17,8 +13,7 @@ use syn::{
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub struct TextNode {
pub input: IfmtInput,
pub hr_idx: DynIdx,
pub input: HotReloadFormattedSegment,
pub dyn_idx: DynIdx,
}
@@ -26,7 +21,6 @@ impl Parse for TextNode {
fn parse(input: ParseStream) -> Result<Self> {
Ok(Self {
input: input.parse()?,
hr_idx: DynIdx::default(),
dyn_idx: DynIdx::default(),
})
}
@@ -44,10 +38,7 @@ impl ToTokens for TextNode {
// todo:
// Use the RsxLiteral implementation to spit out a hotreloadable variant of this string
// This is not super efficient since we're doing a bit of cloning
let as_lit = HotLiteral {
hr_idx: self.hr_idx.clone(),
value: HotLiteralType::Fmted(txt.clone()),
};
let as_lit = HotLiteral::Fmted(txt.clone());
tokens.append_all(quote! {
dioxus_core::DynamicNode::Text(dioxus_core::VText::new( #as_lit ))
@@ -63,9 +54,8 @@ impl TextNode {
segments: vec![],
};
Self {
input: ifmt,
input: ifmt.into(),
dyn_idx: Default::default(),
hr_idx: Default::default(),
}
}