use crate::any_props::BoxedAnyProps; use crate::innerlude::ElementRef; use crate::{arena::ElementId, Element, Event, ScopeId}; use std::ops::Deref; use std::rc::Rc; use std::{ any::{Any, TypeId}, cell::{Cell, RefCell}, fmt::{Arguments, Debug}, }; pub type TemplateId = &'static str; /// The actual state of the component's most recent computation /// /// Because Dioxus accepts components in the form of `async fn(Scope) -> Result`, we need to support both /// sync and async versions. /// /// Dioxus will do its best to immediately resolve any async components into a regular Element, but as an implementor /// you might need to handle the case where there's no node immediately ready. #[derive(Clone)] pub enum RenderReturn { /// A currently-available element Ready(VNode), /// The component aborted rendering early. It might've thrown an error. /// /// In its place we've produced a placeholder to locate its spot in the dom when /// it recovers. Aborted(VPlaceholder), } impl Default for RenderReturn { fn default() -> Self { RenderReturn::Aborted(VPlaceholder::default()) } } /// A reference to a template along with any context needed to hydrate it /// /// The dynamic parts of the template are stored separately from the static parts. This allows faster diffing by skipping /// static parts of the template. #[derive(Debug)] pub struct VNodeInner { /// The key given to the root of this template. /// /// In fragments, this is the key of the first child. In other cases, it is the key of the root. pub key: Option, /// When rendered, this template will be linked to its parent manually pub(crate) parent: RefCell>, /// The IDs for the roots of this template - to be used when moving the template around and removing it from /// the actual Dom pub root_ids: RefCell>, /// The static nodes and static descriptor of the template pub template: Cell