Hotreloading of for/if/body, formatted strings, literals, component props, nested rsx, light CLI rewrite, cli TUI (#2258)

Hotreload the contents of for loops, if chains, component bodies, props, attributes, and any literals discovered in rsx!
Add a TUI renderer to the CLI.
Improve the CLI build system to be async and parallel.
Refactor RSX to allow partial expansion of expressions.
Merge autofmt implementations for consistency.
Merge the representation of elements and components under the hood.
Add a diagnostics system for rsx for improved error messages.
Drop interprocess and move to websockets for communication between the CLI and the server.
Assign IDs to nodes and attributes in a stable way to be used in non compiler contexts.
Add hotreloading to any body of component/for loop/if chain/etc.

---------

Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
Co-authored-by: Liam Mitchell <liamkarlmitchell@gmail.com>
This commit is contained in:
authored and GitHub committed 2024-07-17 19:11:18 -07:00
1 parent 176e67e5b7
commit 88af3e7eff
181 files changed
+12755 -10806

No files matched your search

+11 -17
View File
@@ -24,17 +24,14 @@ impl VNode {
// If hot reloading is enabled, we need to make sure we're using the latest template
#[cfg(debug_assertions)]
{
let (path, byte_index) = new.template.get().name.rsplit_once(':').unwrap();
if let Some(map) = dom.templates.get(path) {
let byte_index = byte_index.parse::<usize>().unwrap();
if let Some(&template) = map.get(&byte_index) {
new.template.set(template);
if template != self.template.get() {
let mount_id = self.mount.get();
let parent = dom.mounts[mount_id.0].parent;
self.replace(std::slice::from_ref(new), parent, dom, to);
return;
}
let name = new.template.get().name;
if let Some(template) = dom.templates.get(name).cloned() {
new.template.set(template);
if template != self.template.get() {
let mount_id = self.mount.get();
let parent = dom.mounts[mount_id.0].parent;
self.replace(std::slice::from_ref(new), parent, dom, to);
return;
}
}
}
@@ -576,12 +573,7 @@ impl VNode {
#[cfg(debug_assertions)]
{
let template = self.template.get();
let (path, byte_index) = template.name.rsplit_once(':').unwrap();
if let Some(new_template) = dom
.templates
.get(path)
.and_then(|map| map.get(&byte_index.parse().unwrap()))
{
if let Some(new_template) = dom.templates.get(template.name) {
self.template.set(*new_template);
}
};
@@ -625,6 +617,7 @@ impl VNode {
// Walk the roots, creating nodes and assigning IDs
// nodes in an iterator of (dynamic_node_index, path)
let nodes_sorted = template.breadth_first_node_paths();
let attrs_sorted = template.breadth_first_attribute_paths();
@@ -811,6 +804,7 @@ impl VNode {
dynamic_attrbiutes_iter.next_if(from_root_node)
{
let attribute = &self.dynamic_attrs[attribute_idx];
let id = match last_path {
// If the last path was exactly the same, we can reuse the id
Some((path, id)) if path == attribute_path => id,