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>
74 lines
2.1 KiB
Rust
74 lines
2.1 KiB
Rust
#[doc(hidden)]
|
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
|
#[cfg_attr(feature = "serialize", serde(bound(deserialize = "'de: 'static")))]
|
|
#[derive(Debug, PartialEq, Clone)]
|
|
pub struct HotreloadedLiteral {
|
|
pub name: String,
|
|
pub value: HotReloadLiteral,
|
|
}
|
|
|
|
#[doc(hidden)]
|
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
|
#[cfg_attr(feature = "serialize", serde(bound(deserialize = "'de: 'static")))]
|
|
#[derive(Debug, PartialEq, Clone)]
|
|
pub enum HotReloadLiteral {
|
|
Fmted(FmtedSegments),
|
|
Float(f64),
|
|
Int(i64),
|
|
Bool(bool),
|
|
}
|
|
|
|
#[doc(hidden)]
|
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
|
#[cfg_attr(feature = "serialize", serde(bound(deserialize = "'de: 'static")))]
|
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
|
pub struct FmtedSegments {
|
|
pub segments: Vec<FmtSegment>,
|
|
}
|
|
|
|
impl FmtedSegments {
|
|
pub fn new(segments: Vec<FmtSegment>) -> Self {
|
|
Self { segments }
|
|
}
|
|
|
|
/// Render the formatted string by stitching together the segments
|
|
pub fn render_with(&self, dynamic_nodes: Vec<String>) -> String {
|
|
let mut out = String::new();
|
|
|
|
for segment in &self.segments {
|
|
match segment {
|
|
FmtSegment::Literal { value } => out.push_str(value),
|
|
FmtSegment::Dynamic { id } => out.push_str(&dynamic_nodes[*id]),
|
|
}
|
|
}
|
|
|
|
out
|
|
}
|
|
|
|
/// Update the segments with new segments
|
|
///
|
|
/// this will change how we render the formatted string
|
|
pub fn update_segments(&mut self, new_segments: Vec<FmtSegment>) {
|
|
self.segments = new_segments;
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "serialize")]
|
|
use crate::nodes::deserialize_string_leaky;
|
|
|
|
#[doc(hidden)]
|
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
|
pub enum FmtSegment {
|
|
Literal {
|
|
#[cfg_attr(
|
|
feature = "serialize",
|
|
serde(deserialize_with = "deserialize_string_leaky")
|
|
)]
|
|
value: &'static str,
|
|
},
|
|
Dynamic {
|
|
id: usize,
|
|
},
|
|
}
|