//! Parse the root tokens in the rsx!{} macro //! ========================================= //! //! This parsing path emerges directly from the macro call, with `RsxRender` being the primary entrance into parsing. //! This feature must support: //! - [x] Optionally rendering if the `in XYZ` pattern is present //! - [x] Fragments as top-level element (through ambiguous) //! - [x] Components as top-level element (through ambiguous) //! - [x] Tags as top-level elements (through ambiguous) //! - [x] Good errors if parsing fails //! //! Any errors in using rsx! will likely occur when people start using it, so the first errors must be really helpful. #[macro_use] mod errors; mod component; mod element; mod hot_reloading_context; mod ifmt; mod node; use std::{collections::HashMap, hash::Hash}; // Re-export the namespaces into each other pub use component::*; use dioxus_core::{Template, TemplateAttribute, TemplateNode}; pub use element::*; use hot_reloading_context::Empty; pub use hot_reloading_context::HotReloadingContext; pub use ifmt::*; use internment::Intern; pub use node::*; // imports use proc_macro2::TokenStream as TokenStream2; use quote::{quote, ToTokens, TokenStreamExt}; use syn::{ parse::{Parse, ParseStream}, Result, Token, }; // interns a object into a static object, resusing the value if it already exists fn intern(s: impl Into>) -> &'static T { s.into().as_ref() } /// Fundametnally, every CallBody is a template #[derive(Default, Debug)] pub struct CallBody { pub roots: Vec, // set this after pub inline_cx: bool, phantom: std::marker::PhantomData, } impl CallBody { /// This will try to create a new template from the current body and the previous body. This will return None if the rsx has some dynamic part that has changed. /// This function intentionally leaks memory to create a static template. /// Keeping the template static allows us to simplify the core of dioxus and leaking memory in dev mode is less of an issue. /// the previous_location is the location of the previous template at the time the template was originally compiled. pub fn update_template( &self, template: Option>, location: &'static str, ) -> Option