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

+7 -7
View File
@@ -30,7 +30,7 @@ fn extract_single_text_node(children: &Element, component: &str) -> Option<Strin
// The title's children must be in one of two forms:
// 1. rsx! { "static text" }
// 2. rsx! { "title: {dynamic_text}" }
match vnode.template.get() {
match vnode.template {
// rsx! { "static text" }
Template {
roots: &[TemplateNode::Text { text }],
@@ -91,7 +91,7 @@ pub struct TitleProps {
pub fn Title(props: TitleProps) -> Element {
let children = props.children;
let Some(text) = extract_single_text_node(&children, "Title") else {
return rsx! {};
return VNode::empty();
};
// Update the title as it changes. NOTE: We don't use use_effect here because we need this to run on the server
@@ -109,7 +109,7 @@ pub fn Title(props: TitleProps) -> Element {
*last_text = text;
}
rsx! {}
VNode::empty()
}
/// Props for the [`Meta`] component
@@ -176,7 +176,7 @@ pub fn Meta(props: MetaProps) -> Element {
document.create_meta(props);
});
rsx! {}
VNode::empty()
}
#[derive(Clone, Props, PartialEq)]
@@ -271,7 +271,7 @@ pub fn Script(props: ScriptProps) -> Element {
document.create_script(props);
});
rsx! {}
VNode::empty()
}
#[derive(Clone, Props, PartialEq)]
@@ -349,7 +349,7 @@ pub fn Style(props: StyleProps) -> Element {
document.create_style(props);
});
rsx! {}
VNode::empty()
}
use super::*;
@@ -462,7 +462,7 @@ pub fn Link(props: LinkProps) -> Element {
document.create_link(props);
});
rsx! {}
VNode::empty()
}
fn get_or_insert_root_context<T: Default + Clone + 'static>() -> T {