From 0a613a331bb5909c88d125e067c5e0ba78da666f Mon Sep 17 00:00:00 2001 From: Markus Kohlhase Date: Mon, 20 Jan 2025 17:29:25 +0100 Subject: [PATCH 1/7] Make VDOM functions public --- crates/core/src/dom.rs | 44 +- crates/core/src/dom/dom_node.rs | 338 ++++++++------- crates/core/src/dom/dom_patch.rs | 637 +++++++++++++++------------- crates/core/src/dom/program.rs | 104 +++-- examples/patch_dom_node/Cargo.toml | 12 + examples/patch_dom_node/index.html | 9 + examples/patch_dom_node/src/main.rs | 38 ++ 7 files changed, 681 insertions(+), 501 deletions(-) create mode 100644 examples/patch_dom_node/Cargo.toml create mode 100644 examples/patch_dom_node/index.html create mode 100644 examples/patch_dom_node/src/main.rs diff --git a/crates/core/src/dom.rs b/crates/core/src/dom.rs index 882a420c..2201a67e 100644 --- a/crates/core/src/dom.rs +++ b/crates/core/src/dom.rs @@ -12,11 +12,32 @@ mod effects; use cfg_if::cfg_if; cfg_if! {if #[cfg(feature = "with-dom")] { + mod application; + mod dom_node; + mod dom_patch; + mod dom_attr; + mod http; + mod program; + mod raf; + mod ric; + mod window; + mod document; + mod time; + mod timeout; + + pub mod events; + pub mod dispatch; + pub mod util; + pub use application::{Application, Measurements, SkipDiff, skip_if, skip_diff, SkipPath}; pub use component::{stateful_component, StatefulComponent, StatefulModel, StatelessModel}; pub use component::component; - pub use dom_patch::{DomPatch, PatchVariant}; + pub use dispatch::Dispatch; + pub use document::Document; + pub use dom_patch::{DomPatch, PatchVariant, apply_dom_patches, convert_patches}; pub use dom_attr::{DomAttr, DomAttrValue, GroupedDomAttrValues}; + pub use dom_node::DomNode; + pub use dom_node::create_dom_node; pub use http::Http; pub use program::{MountAction, MountTarget, Program, MountProcedure}; pub use util::{ @@ -26,29 +47,10 @@ cfg_if! {if #[cfg(feature = "with-dom")] { pub use raf::{request_animation_frame, AnimationFrameHandle}; pub use ric::{request_idle_callback, IdleCallbackHandle, IdleDeadline}; pub use timeout::{delay, request_timeout_callback, TimeoutCallbackHandle}; - pub use dispatch::Dispatch; - use crate::dom::events::MountEvent; pub use window::Window; - pub use dom_node::DomNode; - pub use document::Document; pub use time::Time; - mod application; - pub mod dispatch; - mod dom_node; - mod dom_patch; - mod dom_attr; - pub mod events; - mod http; - mod program; - pub mod util; - mod raf; - mod ric; - mod window; - mod document; - mod time; - mod timeout; - + use crate::dom::events::MountEvent; /// Map the Event to DomEvent, which are browser events #[derive(Debug, Clone)] diff --git a/crates/core/src/dom/dom_node.rs b/crates/core/src/dom/dom_node.rs index 1fc90396..777bacdc 100644 --- a/crates/core/src/dom/dom_node.rs +++ b/crates/core/src/dom/dom_node.rs @@ -1,26 +1,23 @@ -use crate::dom::component::StatelessModel; -use crate::dom::DomAttr; -use crate::dom::GroupedDomAttrValues; -use crate::dom::StatefulComponent; -use crate::dom::StatefulModel; -use crate::html::lookup; -use crate::vdom::TreePath; -use crate::{ - dom::document, - dom::events::MountEvent, - dom::{Application, Program}, - vdom, - vdom::{Attribute, Leaf}, +use std::{ + borrow::Cow, + cell::{Ref, RefCell}, + fmt, + rc::Rc, }; + use indexmap::IndexMap; -use std::borrow::Cow; -use std::cell::Ref; -use std::cell::RefCell; -use std::fmt; -use std::rc::Rc; use wasm_bindgen::{closure::Closure, JsCast, JsValue}; use web_sys::{self, Node}; +use crate::{ + dom::{ + component::StatelessModel, document, dom_patch, events::MountEvent, Application, DomAttr, + GroupedDomAttrValues, Program, StatefulComponent, StatefulModel, + }, + html::lookup, + vdom::{self, Attribute, Leaf, TreePath}, +}; + pub(crate) type EventClosure = Closure; pub type NamedEventClosures = IndexMap<&'static str, EventClosure>; @@ -33,6 +30,7 @@ pub type NamedEventClosures = IndexMap<&'static str, EventClosure>; pub struct DomNode { pub(crate) inner: DomInner, } + #[derive(Clone)] pub enum DomInner { /// a reference to an element node @@ -648,149 +646,133 @@ where { /// Create a dom node pub fn create_dom_node(&self, node: &vdom::Node) -> DomNode { - match node { - vdom::Node::Element(elm) => self.create_element_node(elm), - vdom::Node::Leaf(leaf) => self.create_leaf_node(leaf), - } + let ev_callback = self.create_ev_callback(); + create_dom_node(node, ev_callback) } - fn create_element_node(&self, elm: &vdom::Element) -> DomNode { - let document = document(); - let element = if let Some(namespace) = elm.namespace() { - document - .create_element_ns(Some(intern(namespace)), intern(elm.tag())) - .expect("Unable to create element") - } else { - document - .create_element(intern(elm.tag())) - .expect("create element") + pub(crate) fn create_ev_callback(&self) -> impl Fn(APP::MSG) + Clone { + let program = self.downgrade(); + let ev_callback = move |msg| { + let mut program = program.upgrade().expect("must upgrade"); + program.dispatch(msg); }; - // TODO: dispatch the mount event recursively after the dom node is mounted into - // the root node - let attrs = Attribute::merge_attributes_of_same_name(elm.attributes().iter()); - - let dom_node = DomNode { - inner: DomInner::Element { - element, - listeners: Rc::new(RefCell::new(None)), - children: Rc::new(RefCell::new(vec![])), - has_mount_callback: elm.has_mount_callback(), - }, - }; - let dom_attrs = attrs.iter().map(|a| self.convert_attr(a)); - dom_node.set_dom_attrs(dom_attrs).expect("set dom attrs"); - let children: Vec = elm - .children() - .iter() - .map(|child| self.create_dom_node(child)) - .collect(); - dom_node.append_children(children); - dom_node - } - - fn create_leaf_node(&self, leaf: &vdom::Leaf) -> DomNode { - match leaf { - Leaf::Text(txt) => DomNode { - inner: DomInner::Text(document().create_text_node(txt)), - }, - Leaf::Symbol(symbol) => DomNode { - inner: DomInner::Symbol(symbol.clone()), - }, - Leaf::Comment(comment) => DomNode { - inner: DomInner::Comment(document().create_comment(comment)), - }, - Leaf::Fragment(nodes) => self.create_fragment_node(nodes), - // NodeList that goes here is only possible when it is the root_node, - // since node_list as children will be unrolled into as child_elements of the parent - // We need to wrap this node_list into doc_fragment since root_node is only 1 element - Leaf::NodeList(nodes) => self.create_fragment_node(nodes), - Leaf::StatefulComponent(comp) => { - //TODO: also put the children and attributes here - DomNode { - inner: DomInner::StatefulComponent { - comp: Rc::clone(&comp.comp), - dom_node: Rc::new(self.create_stateful_component(comp)), - }, - } - } - Leaf::StatelessComponent(comp) => self.create_stateless_component(comp), - Leaf::TemplatedView(view) => { - unreachable!("template view should not be created: {:#?}", view) - } - Leaf::DocType(_) => unreachable!("doc type is never converted"), - } + ev_callback } +} - fn create_fragment_node<'a>( - &self, - nodes: impl IntoIterator>, - ) -> DomNode { - let fragment = document().create_document_fragment(); - let dom_node = DomNode { - inner: DomInner::Fragment { - fragment, - children: Rc::new(RefCell::new(vec![])), - }, - }; - let children = nodes - .into_iter() - .map(|node| self.create_dom_node(node)) - .collect(); - dom_node.append_children(children); - dom_node +/// Create a dom node +pub fn create_dom_node(node: &vdom::Node, ev_callback: F) -> DomNode +where + Msg: 'static, + F: Fn(Msg) + 'static + Clone, +{ + match node { + vdom::Node::Element(elm) => create_element_node(elm, ev_callback), + vdom::Node::Leaf(leaf) => create_leaf_node(leaf, ev_callback), } } -/// A node along with all of the closures that were created for that -/// node's events and all of it's child node's events. -impl Program +fn create_element_node(elm: &vdom::Element, ev_callback: F) -> DomNode where - APP: Application, + Msg: 'static, + F: Fn(Msg) + 'static + Clone, { - /// TODO: register the template if not yet - /// pass a program to leaf component and mount itself and its view to the program - /// There are 2 types of children components of Stateful Component - /// - Internal children - /// - External children - /// Internal children is managed by the Stateful Component - /// while external children are managed by the top level program. - /// The external children can be diffed, and send the patches to the StatefulComponent - /// - The TreePath of the children starts at the external children location - /// The attributes affects the Stateful component state. - /// The attributes can be diff and send the patches to the StatefulComponent - /// - Changes to the attributes will call on attribute_changed of the StatefulComponent - fn create_stateful_component(&self, comp: &StatefulModel) -> DomNode { - let comp_node = self.create_dom_node(&crate::html::div( - [crate::html::attributes::class("component")] - .into_iter() - .chain(comp.attrs.clone()), - [], - )); + let document = document(); + let element = if let Some(namespace) = elm.namespace() { + document + .create_element_ns(Some(intern(namespace)), intern(elm.tag())) + .expect("Unable to create element") + } else { + document + .create_element(intern(elm.tag())) + .expect("create element") + }; + // TODO: dispatch the mount event recursively after the dom node is mounted into + // the root node + let attrs = Attribute::merge_attributes_of_same_name(elm.attributes().iter()); + + let dom_node = DomNode { + inner: DomInner::Element { + element, + listeners: Rc::new(RefCell::new(None)), + children: Rc::new(RefCell::new(vec![])), + has_mount_callback: elm.has_mount_callback(), + }, + }; + let dom_attrs = attrs + .iter() + .map(|a| dom_patch::convert_attr(a, ev_callback.clone())); + dom_node.set_dom_attrs(dom_attrs).expect("set dom attrs"); + let children: Vec = elm + .children() + .iter() + .map(|child| create_dom_node(child, ev_callback.clone())) + .collect(); + dom_node.append_children(children); + dom_node +} - let dom_attrs: Vec = comp.attrs.iter().map(|a| self.convert_attr(a)).collect(); - for dom_attr in dom_attrs.into_iter() { - log::info!("calling attribute changed.."); - comp.comp.borrow_mut().attribute_changed(dom_attr); +fn create_leaf_node(leaf: &vdom::Leaf, ev_callback: F) -> DomNode +where + Msg: 'static, + F: Fn(Msg) + 'static + Clone, +{ + match leaf { + Leaf::Text(txt) => DomNode { + inner: DomInner::Text(document().create_text_node(txt)), + }, + Leaf::Symbol(symbol) => DomNode { + inner: DomInner::Symbol(symbol.clone()), + }, + Leaf::Comment(comment) => DomNode { + inner: DomInner::Comment(document().create_comment(comment)), + }, + Leaf::Fragment(nodes) => create_fragment_node(nodes, ev_callback), + + // NodeList that goes here is only possible when it is the root_node, + // since node_list as children will be unrolled into as child_elements of the parent + // We need to wrap this node_list into doc_fragment since root_node is only 1 element + Leaf::NodeList(nodes) => create_fragment_node(nodes, ev_callback), + + Leaf::StatefulComponent(comp) => { + //TODO: also put the children and attributes here + DomNode { + inner: DomInner::StatefulComponent { + comp: Rc::clone(&comp.comp), + dom_node: Rc::new(create_stateful_component(comp, ev_callback)), + }, + } } + Leaf::StatelessComponent(comp) => create_stateless_component(comp, ev_callback), - // the component children is manually appended to the StatefulComponent - // here to allow the conversion of dom nodes with its event - // listener and removing the generics msg - let created_children = comp - .children - .iter() - .map(|child| self.create_dom_node(child)) - .collect(); - comp.comp.borrow_mut().append_children(created_children); - comp_node + Leaf::TemplatedView(view) => { + unreachable!("template view should not be created: {:#?}", view) + } + Leaf::DocType(_) => unreachable!("doc type is never converted"), } +} - #[allow(unused)] - pub(crate) fn create_stateless_component(&self, comp: &StatelessModel) -> DomNode { - let comp_view = &comp.view; - let real_comp_view = comp_view.unwrap_template_ref(); - self.create_dom_node(real_comp_view) - } +fn create_fragment_node<'a, Msg, F>( + nodes: impl IntoIterator>, + ev_callback: F, +) -> DomNode +where + Msg: 'static, + F: Fn(Msg) + 'static + Clone, +{ + let fragment = document().create_document_fragment(); + let dom_node = DomNode { + inner: DomInner::Fragment { + fragment, + children: Rc::new(RefCell::new(vec![])), + }, + }; + let children = nodes + .into_iter() + .map(|node| create_dom_node(node, ev_callback.clone())) + .collect(); + dom_node.append_children(children); + dom_node } /// render the underlying real dom node into string @@ -845,3 +827,67 @@ pub fn render_real_dom(node: &web_sys::Node, buffer: &mut dyn fmt::Write) -> fmt _ => todo!("for other else"), } } + +#[allow(unused)] +pub(crate) fn create_stateless_component( + comp: &StatelessModel, + ev_callback: F, +) -> DomNode +where + Msg: 'static, + F: Fn(Msg) + 'static + Clone, +{ + let comp_view = &comp.view; + let real_comp_view = comp_view.unwrap_template_ref(); + create_dom_node(real_comp_view, ev_callback) +} + +/// TODO: register the template if not yet +/// pass a program to leaf component and mount itself and its view to the program +/// There are 2 types of children components of Stateful Component +/// - Internal children +/// - External children +/// Internal children is managed by the Stateful Component +/// while external children are managed by the top level program. +/// The external children can be diffed, and send the patches to the StatefulComponent +/// - The TreePath of the children starts at the external children location +/// The attributes affects the Stateful component state. +/// The attributes can be diff and send the patches to the StatefulComponent +/// - Changes to the attributes will call on attribute_changed of the StatefulComponent +fn create_stateful_component(comp: &StatefulModel, ev_callback: F) -> DomNode +where + Msg: 'static, + F: Fn(Msg) + 'static + Clone, +{ + let comp_node = create_dom_node( + &crate::html::div( + [crate::html::attributes::class("component")] + .into_iter() + .chain(comp.attrs.clone()), + [], + ), + ev_callback.clone(), + ); + + let dom_attrs: Vec = comp + .attrs + .iter() + .map(|a| dom_patch::convert_attr(a, ev_callback.clone())) + .collect(); + + for dom_attr in dom_attrs.into_iter() { + log::info!("calling attribute changed.."); + comp.comp.borrow_mut().attribute_changed(dom_attr); + } + + // the component children is manually appended to the StatefulComponent + // here to allow the conversion of dom nodes with its event + // listener and removing the generics msg + let created_children = comp + .children + .iter() + .map(|child| create_dom_node(child, ev_callback.clone())) + .collect(); + comp.comp.borrow_mut().append_children(created_children); + comp_node +} diff --git a/crates/core/src/dom/dom_patch.rs b/crates/core/src/dom/dom_patch.rs index 94f05032..61b1cd30 100644 --- a/crates/core/src/dom/dom_patch.rs +++ b/crates/core/src/dom/dom_patch.rs @@ -1,18 +1,19 @@ -use crate::dom; -use crate::dom::dom_node; -use crate::dom::dom_node::DomInner; -use crate::dom::DomAttr; -use crate::dom::DomAttrValue; -use crate::dom::DomNode; -use crate::dom::{Application, Program}; -use crate::vdom::ComponentEventCallback; -use crate::vdom::EventCallback; -use crate::vdom::TreePath; -use crate::vdom::{Attribute, AttributeValue, Patch, PatchType}; +use std::{cell::RefCell, rc::Rc}; + use indexmap::IndexMap; use wasm_bindgen::closure::Closure; use wasm_bindgen::JsValue; +use crate::{ + dom::{ + self, dom_node, dom_node::DomInner, Application, DomAttr, DomAttrValue, DomNode, Program, + }, + vdom::{ + Attribute, AttributeValue, ComponentEventCallback, EventCallback, Patch, PatchType, + TreePath, + }, +}; + /// a Patch where the virtual nodes are all created in the document. /// This is necessary since the created Node doesn't contain references /// as opposed to Patch which contains reference to the vdom, which makes it hard @@ -146,97 +147,15 @@ impl Program where APP: Application + 'static, { - pub(crate) fn convert_attr(&self, attr: &Attribute) -> DomAttr { - DomAttr { - namespace: attr.namespace, - name: attr.name, - value: attr - .value - .iter() - .filter_map(|v| self.convert_attr_value(v)) - .collect(), - } - } - - fn convert_attr_value(&self, attr_value: &AttributeValue) -> Option { - match attr_value { - AttributeValue::Simple(v) => Some(DomAttrValue::Simple(v.clone())), - AttributeValue::Style(v) => Some(DomAttrValue::Style(v.clone())), - AttributeValue::EventListener(v) => { - Some(DomAttrValue::EventListener(self.convert_event_listener(v))) - } - AttributeValue::ComponentEventListener(v) => Some(DomAttrValue::EventListener( - self.convert_component_event_listener(v), - )), - AttributeValue::Empty => None, - } - } - - fn convert_event_listener( - &self, - event_listener: &EventCallback, - ) -> Closure { - let program = self.downgrade(); - let event_listener = event_listener.clone(); - let closure: Closure = - Closure::new(move |event: web_sys::Event| { - let msg = event_listener.emit(dom::Event::from(event)); - let mut program = program.upgrade().expect("must upgrade"); - program.dispatch(msg); - }); - closure - } - - fn convert_component_event_listener( - &self, - component_callback: &ComponentEventCallback, - ) -> Closure { - let component_callback = component_callback.clone(); - let closure: Closure = - Closure::new(move |event: web_sys::Event| { - component_callback.emit(dom::Event::from(event)); - }); - closure - } /// get the real DOM target node and make a DomPatch object for each of the Patch pub(crate) fn convert_patches( &self, target_node: &DomNode, patches: &[Patch], ) -> Result, JsValue> { - let nodes_to_find: Vec<(&TreePath, Option<&&'static str>)> = patches - .iter() - .map(|patch| (patch.path(), patch.tag())) - .chain( - patches - .iter() - .flat_map(|patch| patch.node_paths()) - .map(|path| (path, None)), - ) - .collect(); - - let nodes_lookup = target_node.find_all_nodes(&nodes_to_find); - - let dom_patches:Vec = patches.iter().map(|patch|{ - let patch_path = patch.path(); - let patch_tag = patch.tag(); - if let Some((target_node, target_parent)) = nodes_lookup.get(patch_path) { - let target_tag = target_node.tag(); - if let (Some(patch_tag), Some(target_tag)) = (patch_tag, target_tag) { - if **patch_tag != target_tag{ - panic!( - "expecting a tag: {patch_tag:?}, but found: {target_tag:?}" - ); - } - } - self.convert_patch(&nodes_lookup, target_node, target_parent, patch) - } else { - unreachable!("Getting here means we didn't find the element of next node that we are supposed to patch, patch_path: {:?}, with tag: {:?}", patch_path, patch_tag); - } - }).collect(); - - Ok(dom_patches) + convert_patches(target_node, patches, self.create_ev_callback()) } + /// convert a virtual DOM Patch into a created DOM node Patch pub fn convert_patch( &self, @@ -245,244 +164,382 @@ where target_parent: &DomNode, patch: &Patch, ) -> DomPatch { - let target_element = target_element.clone(); - let target_parent = target_parent.clone(); - let Patch { - patch_path, - patch_type, - .. - } = patch; + convert_patch( + nodes_lookup, + target_element, + target_parent, + patch, + self.create_ev_callback(), + ) + } +} - let patch_path = patch_path.clone(); +/// get the real DOM target node and make a DomPatch object for each of the Patch +pub fn convert_patches( + target_node: &DomNode, + patches: &[Patch], + ev_callback: F, +) -> Result, JsValue> +where + Msg: 'static, + F: Fn(Msg) + 'static + Clone, +{ + let nodes_to_find: Vec<(&TreePath, Option<&&'static str>)> = patches + .iter() + .map(|patch| (patch.path(), patch.tag())) + .chain( + patches + .iter() + .flat_map(|patch| patch.node_paths()) + .map(|path| (path, None)), + ) + .collect(); - match patch_type { - PatchType::InsertBeforeNode { nodes } => { - let nodes = nodes - .iter() - .map(|for_insert| self.create_dom_node(for_insert)) - .collect(); - DomPatch { - patch_path, - target_element, - target_parent, - patch_variant: PatchVariant::InsertBeforeNode { nodes }, - } - } - PatchType::InsertAfterNode { nodes } => { - let nodes = nodes - .iter() - .map(|for_insert| self.create_dom_node(for_insert)) - .collect(); - DomPatch { - patch_path, - target_element, - target_parent, - patch_variant: PatchVariant::InsertAfterNode { nodes }, + let nodes_lookup = target_node.find_all_nodes(&nodes_to_find); + + let dom_patches:Vec = patches.iter().map(|patch|{ + let patch_path = patch.path(); + let patch_tag = patch.tag(); + if let Some((target_node, target_parent)) = nodes_lookup.get(patch_path) { + let target_tag = target_node.tag(); + if let (Some(patch_tag), Some(target_tag)) = (patch_tag, target_tag) { + if **patch_tag != target_tag{ + panic!( + "expecting a tag: {patch_tag:?}, but found: {target_tag:?}" + ); } } + convert_patch(&nodes_lookup, target_node, target_parent, patch, ev_callback.clone()) + } else { + unreachable!("Getting here means we didn't find the element of next node that we are supposed to patch, patch_path: {:?}, with tag: {:?}", patch_path, patch_tag); + } + }).collect(); - PatchType::AddAttributes { attrs } => { - // we merge the attributes here prior to conversion - let attrs = Attribute::merge_attributes_of_same_name(attrs.iter().copied()); - DomPatch { - patch_path, - target_element, - target_parent, - patch_variant: PatchVariant::AddAttributes { - attrs: attrs.iter().map(|a| self.convert_attr(a)).collect(), - }, - } + Ok(dom_patches) +} + +/// convert a virtual DOM Patch into a created DOM node Patch +pub fn convert_patch( + nodes_lookup: &IndexMap, + target_element: &DomNode, + target_parent: &DomNode, + patch: &Patch, + ev_callback: F, +) -> DomPatch +where + Msg: 'static, + F: Fn(Msg) + 'static + Clone, +{ + let target_element = target_element.clone(); + let target_parent = target_parent.clone(); + let Patch { + patch_path, + patch_type, + .. + } = patch; + + let patch_path = patch_path.clone(); + + match patch_type { + PatchType::InsertBeforeNode { nodes } => { + let nodes = nodes + .iter() + .map(|for_insert| dom::create_dom_node(for_insert, ev_callback.clone())) + .collect(); + DomPatch { + patch_path, + target_element, + target_parent, + patch_variant: PatchVariant::InsertBeforeNode { nodes }, } - PatchType::RemoveAttributes { attrs } => DomPatch { + } + PatchType::InsertAfterNode { nodes } => { + let nodes = nodes + .iter() + .map(|for_insert| dom::create_dom_node(for_insert, ev_callback.clone())) + .collect(); + DomPatch { patch_path, target_element, target_parent, - patch_variant: PatchVariant::RemoveAttributes { - attrs: attrs.iter().map(|a| self.convert_attr(a)).collect(), + patch_variant: PatchVariant::InsertAfterNode { nodes }, + } + } + + PatchType::AddAttributes { attrs } => { + // we merge the attributes here prior to conversion + let attrs = Attribute::merge_attributes_of_same_name(attrs.iter().copied()); + DomPatch { + patch_path, + target_element, + target_parent, + patch_variant: PatchVariant::AddAttributes { + attrs: attrs + .iter() + .map(|a| convert_attr(a, ev_callback.clone())) + .collect(), }, + } + } + PatchType::RemoveAttributes { attrs } => DomPatch { + patch_path, + target_element, + target_parent, + patch_variant: PatchVariant::RemoveAttributes { + attrs: attrs + .iter() + .map(|a| convert_attr(a, ev_callback.clone())) + .collect(), }, + }, - PatchType::ReplaceNode { replacement } => { - let replacement = replacement - .iter() - .map(|node| self.create_dom_node(node)) - .collect(); - DomPatch { - patch_path, - target_element, - target_parent, - patch_variant: PatchVariant::ReplaceNode { replacement }, - } - } - PatchType::RemoveNode => DomPatch { + PatchType::ReplaceNode { replacement } => { + let replacement = replacement + .iter() + .map(|node| dom::create_dom_node(node, ev_callback.clone())) + .collect(); + DomPatch { patch_path, target_element, target_parent, - patch_variant: PatchVariant::RemoveNode, - }, - PatchType::ClearChildren => DomPatch { + patch_variant: PatchVariant::ReplaceNode { replacement }, + } + } + PatchType::RemoveNode => DomPatch { + patch_path, + target_element, + target_parent, + patch_variant: PatchVariant::RemoveNode, + }, + PatchType::ClearChildren => DomPatch { + patch_path, + target_element, + target_parent, + patch_variant: PatchVariant::ClearChildren, + }, + PatchType::MoveBeforeNode { nodes_path } => { + let for_moving = nodes_path + .iter() + .map(|path| { + let (node, _) = nodes_lookup.get(path).expect("must have found the node"); + node.clone() + }) + .collect(); + DomPatch { patch_path, target_element, target_parent, - patch_variant: PatchVariant::ClearChildren, - }, - PatchType::MoveBeforeNode { nodes_path } => { - let for_moving = nodes_path - .iter() - .map(|path| { - let (node, _) = nodes_lookup.get(path).expect("must have found the node"); - node.clone() - }) - .collect(); - DomPatch { - patch_path, - target_element, - target_parent, - patch_variant: PatchVariant::MoveBeforeNode { for_moving }, - } + patch_variant: PatchVariant::MoveBeforeNode { for_moving }, } - PatchType::MoveAfterNode { nodes_path } => { - let for_moving = nodes_path - .iter() - .map(|path| { - let (node, _) = nodes_lookup.get(path).expect("must have found the node"); - node.clone() - }) - .collect(); - DomPatch { - patch_path, - target_element, - target_parent, - patch_variant: PatchVariant::MoveAfterNode { for_moving }, - } + } + PatchType::MoveAfterNode { nodes_path } => { + let for_moving = nodes_path + .iter() + .map(|path| { + let (node, _) = nodes_lookup.get(path).expect("must have found the node"); + node.clone() + }) + .collect(); + DomPatch { + patch_path, + target_element, + target_parent, + patch_variant: PatchVariant::MoveAfterNode { for_moving }, } - PatchType::AppendChildren { children } => { - let children = children - .iter() - .map(|for_insert| self.create_dom_node(for_insert)) - .collect(); + } + PatchType::AppendChildren { children } => { + let children = children + .iter() + .map(|for_insert| dom::create_dom_node(for_insert, ev_callback.clone())) + .collect(); - DomPatch { - patch_path, - target_element, - target_parent, - patch_variant: PatchVariant::AppendChildren { children }, - } + DomPatch { + patch_path, + target_element, + target_parent, + patch_variant: PatchVariant::AppendChildren { children }, } } } +} - /// TODO: this should not have access to root_node, so it can generically - /// apply patch to any dom node - pub(crate) fn apply_dom_patches( - &self, - dom_patches: impl IntoIterator, - ) -> Result<(), JsValue> { - for dom_patch in dom_patches { - self.apply_dom_patch(dom_patch)?; - } - Ok(()) +pub(crate) fn convert_attr(attr: &Attribute, ev_callback: F) -> DomAttr +where + Msg: 'static, + F: Fn(Msg) + 'static + Clone, +{ + DomAttr { + namespace: attr.namespace, + name: attr.name, + value: attr + .value + .iter() + .filter_map(|v| convert_attr_value(v, ev_callback.clone())) + .collect(), } +} - /// apply a dom patch to this root node, - /// return a new root_node if it would replace the original root_node - /// TODO: this should have no access to root_node, so it can be used in general sense - pub(crate) fn apply_dom_patch(&self, dom_patch: DomPatch) -> Result<(), JsValue> { - let DomPatch { - patch_path, - target_element, - target_parent, - patch_variant, - } = dom_patch; +fn convert_attr_value( + attr_value: &AttributeValue, + ev_callback: F, +) -> Option +where + Msg: 'static, + F: Fn(Msg) + 'static, +{ + match attr_value { + AttributeValue::Simple(v) => Some(DomAttrValue::Simple(v.clone())), + AttributeValue::Style(v) => Some(DomAttrValue::Style(v.clone())), + AttributeValue::EventListener(v) => Some(DomAttrValue::EventListener( + convert_event_listener(v, ev_callback), + )), + AttributeValue::ComponentEventListener(v) => Some(DomAttrValue::EventListener( + convert_component_event_listener(v), + )), + AttributeValue::Empty => None, + } +} - match patch_variant { - PatchVariant::InsertBeforeNode { nodes } => { - target_parent.insert_before(&target_element, nodes); - } +fn convert_event_listener( + event_listener: &EventCallback, + callback: F, +) -> Closure +where + Msg: 'static, + F: Fn(Msg) + 'static, +{ + let event_listener = event_listener.clone(); + let closure: Closure = Closure::new(move |event: web_sys::Event| { + let msg = event_listener.emit(dom::Event::from(event)); + callback(msg); + }); + closure +} - PatchVariant::InsertAfterNode { nodes } => { - target_parent.insert_after(&target_element, nodes); - } - PatchVariant::AppendChildren { children } => { - target_element.append_children(children); - } +/// TODO: this should not have access to root_node, so it can generically +/// apply patch to any dom node +pub fn apply_dom_patches( + root_node: Rc>>, + mount_node: Rc>>, + dom_patches: impl IntoIterator, +) -> Result<(), JsValue> { + for dom_patch in dom_patches { + apply_dom_patch(Rc::clone(&root_node), Rc::clone(&mount_node), dom_patch)?; + } + Ok(()) +} - PatchVariant::AddAttributes { attrs } => { - target_element.set_dom_attrs(attrs).unwrap(); - } - PatchVariant::RemoveAttributes { attrs } => { - for attr in attrs.iter() { - for att_value in attr.value.iter() { - match att_value { - DomAttrValue::Simple(_) => { - target_element.remove_dom_attr(attr)?; - } - // it is an event listener - DomAttrValue::EventListener(_) => { - let DomInner::Element { listeners, .. } = &target_element.inner - else { - unreachable!("must be an element"); - }; - if let Some(listener) = listeners.borrow_mut().as_mut() { - listener.retain(|event, _| *event != attr.name) - } - } - DomAttrValue::Style(_) => { - target_element.remove_dom_attr(attr)?; +/// apply a dom patch to this root node, +/// return a new root_node if it would replace the original root_node +/// TODO: this should have no access to root_node, so it can be used in general sense +pub(crate) fn apply_dom_patch( + root_node: Rc>>, + mount_node: Rc>>, + dom_patch: DomPatch, +) -> Result<(), JsValue> { + let DomPatch { + patch_path, + target_element, + target_parent, + patch_variant, + } = dom_patch; + + match patch_variant { + PatchVariant::InsertBeforeNode { nodes } => { + target_parent.insert_before(&target_element, nodes); + } + + PatchVariant::InsertAfterNode { nodes } => { + target_parent.insert_after(&target_element, nodes); + } + PatchVariant::AppendChildren { children } => { + target_element.append_children(children); + } + + PatchVariant::AddAttributes { attrs } => { + target_element.set_dom_attrs(attrs).unwrap(); + } + PatchVariant::RemoveAttributes { attrs } => { + for attr in attrs.iter() { + for att_value in attr.value.iter() { + match att_value { + DomAttrValue::Simple(_) => { + target_element.remove_dom_attr(attr)?; + } + // it is an event listener + DomAttrValue::EventListener(_) => { + let DomInner::Element { listeners, .. } = &target_element.inner else { + unreachable!("must be an element"); + }; + if let Some(listener) = listeners.borrow_mut().as_mut() { + listener.retain(|event, _| *event != attr.name) } - DomAttrValue::Empty => (), } + DomAttrValue::Style(_) => { + target_element.remove_dom_attr(attr)?; + } + DomAttrValue::Empty => (), } } } + } - // This also removes the associated closures and event listeners to the node being replaced - // including the associated closures of the descendant of replaced node - // before it is actully replaced in the DOM - // TODO: make root node a Vec - PatchVariant::ReplaceNode { mut replacement } => { - let first_node = replacement.remove(0); + // This also removes the associated closures and event listeners to the node being replaced + // including the associated closures of the descendant of replaced node + // before it is actully replaced in the DOM + // TODO: make root node a Vec + PatchVariant::ReplaceNode { mut replacement } => { + let first_node = replacement.remove(0); - if target_element.is_fragment() { - assert!( - patch_path.is_empty(), - "this should only happen to root node" - ); - let mut mount_node = self.mount_node.borrow_mut(); + if target_element.is_fragment() { + assert!( + patch_path.is_empty(), + "this should only happen to root node" + ); + let mut mount_node = mount_node.borrow_mut(); + let mount_node = mount_node.as_mut().expect("must have a mount node"); + mount_node.append_children(vec![first_node.clone()]); + mount_node.append_children(replacement); + } else { + if patch_path.path.is_empty() { + let mut mount_node = mount_node.borrow_mut(); let mount_node = mount_node.as_mut().expect("must have a mount node"); - mount_node.append_children(vec![first_node.clone()]); - mount_node.append_children(replacement); + mount_node.replace_child(&target_element, first_node.clone()); } else { - if patch_path.path.is_empty() { - let mut mount_node = self.mount_node.borrow_mut(); - let mount_node = mount_node.as_mut().expect("must have a mount node"); - mount_node.replace_child(&target_element, first_node.clone()); - } else { - target_parent.replace_child(&target_element, first_node.clone()); - } - //insert the rest - target_parent.insert_after(&first_node, replacement); - } - if patch_path.path.is_empty() { - *self.root_node.borrow_mut() = Some(first_node); + target_parent.replace_child(&target_element, first_node.clone()); } + //insert the rest + target_parent.insert_after(&first_node, replacement); } - PatchVariant::RemoveNode => { - target_parent.remove_children(&[&target_element]); - } - PatchVariant::ClearChildren => { - target_element.clear_children(); - } - PatchVariant::MoveBeforeNode { for_moving } => { - target_parent.remove_children(&for_moving.iter().collect::>()); - target_parent.insert_before(&target_element, for_moving); + if patch_path.path.is_empty() { + *root_node.borrow_mut() = Some(first_node); } + } + PatchVariant::RemoveNode => { + target_parent.remove_children(&[&target_element]); + } + PatchVariant::ClearChildren => { + target_element.clear_children(); + } + PatchVariant::MoveBeforeNode { for_moving } => { + target_parent.remove_children(&for_moving.iter().collect::>()); + target_parent.insert_before(&target_element, for_moving); + } - PatchVariant::MoveAfterNode { for_moving } => { - target_parent.remove_children(&for_moving.iter().collect::>()); - target_parent.insert_after(&target_element, for_moving); - } + PatchVariant::MoveAfterNode { for_moving } => { + target_parent.remove_children(&for_moving.iter().collect::>()); + target_parent.insert_after(&target_element, for_moving); } - Ok(()) } + Ok(()) +} + +fn convert_component_event_listener( + component_callback: &ComponentEventCallback, +) -> Closure { + let component_callback = component_callback.clone(); + let closure: Closure = Closure::new(move |event: web_sys::Event| { + component_callback.emit(dom::Event::from(event)); + }); + closure } diff --git a/crates/core/src/dom/program.rs b/crates/core/src/dom/program.rs index 283f7f35..717dc38c 100644 --- a/crates/core/src/dom/program.rs +++ b/crates/core/src/dom/program.rs @@ -1,33 +1,30 @@ -use crate::dom::program::app_context::WeakContext; -#[cfg(feature = "with-raf")] -use crate::dom::request_animation_frame; -#[cfg(feature = "with-ric")] -use crate::dom::request_idle_callback; -use crate::dom::DomNode; -use crate::dom::SkipDiff; -use crate::dom::SkipPath; -use crate::dom::{document, now, IdleDeadline, Measurements}; -use crate::dom::{util::body, AnimationFrameHandle, Application, DomPatch, IdleCallbackHandle}; -use crate::html::{self, attributes::class, text}; -use crate::vdom; -use crate::vdom::diff; -use crate::vdom::diff_recursive; -use crate::vdom::Patch; -use std::collections::hash_map::DefaultHasher; -use std::collections::VecDeque; -use std::hash::{Hash, Hasher}; -use std::mem::ManuallyDrop; use std::{ any::TypeId, cell::{Ref, RefCell, RefMut}, + collections::{hash_map::DefaultHasher, VecDeque}, + hash::{Hash, Hasher}, + mem::ManuallyDrop, rc::Rc, rc::Weak, }; + use wasm_bindgen::{JsCast, JsValue}; -use web_sys; -pub(crate) use app_context::AppContext; -pub use mount_procedure::{MountAction, MountProcedure, MountTarget}; +use crate::{ + dom::{ + document, dom_patch, now, program::app_context::WeakContext, util::body, + AnimationFrameHandle, Application, DomNode, DomPatch, IdleCallbackHandle, IdleDeadline, + Measurements, SkipDiff, SkipPath, + }, + html::{self, attributes::class, text}, + vdom::{self, diff, diff_recursive, Patch}, +}; + +#[cfg(feature = "with-raf")] +use crate::dom::request_animation_frame; + +#[cfg(feature = "with-ric")] +use crate::dom::request_idle_callback; thread_local! { static CANCEL_CNT: RefCell = RefCell::new(0); @@ -38,7 +35,10 @@ thread_local! { } mod app_context; +use self::app_context::AppContext; + mod mount_procedure; +pub use self::mount_procedure::{MountAction, MountProcedure, MountTarget}; /// Program handle the lifecycle of the APP pub struct Program @@ -494,7 +494,13 @@ where ) .expect("must convert patches") } else { - self.create_dom_patch(&view) + let current_vdom = self.app_context.current_vdom(); + create_dom_patch( + &self.root_node, + ¤t_vdom, + &view, + self.create_ev_callback(), + ) }; let total_patches = dom_patches.len(); @@ -563,26 +569,6 @@ where ) } - fn create_dom_patch(&self, new_vdom: &vdom::Node) -> Vec { - let current_vdom = self.app_context.current_vdom(); - let patches = diff(¤t_vdom, new_vdom); - - #[cfg(all(feature = "with-debug", feature = "log-patches"))] - { - log::debug!("There are {} patches", patches.len()); - log::debug!("patches: {patches:#?}"); - } - - self.convert_patches( - self.root_node - .borrow() - .as_ref() - .expect("must have a root node"), - &patches, - ) - .expect("must convert patches") - } - #[cfg(feature = "with-raf")] fn apply_pending_patches_with_raf(&mut self) -> Result<(), JsValue> { let program = Program::downgrade(&self); @@ -601,7 +587,11 @@ where return Ok(()); } let dom_patches: Vec = self.pending_patches.borrow_mut().drain(..).collect(); - self.apply_dom_patches(dom_patches)?; + dom_patch::apply_dom_patches( + Rc::clone(&self.root_node), + Rc::clone(&self.mount_node), + dom_patches, + )?; Ok(()) } @@ -749,6 +739,32 @@ where } } +fn create_dom_patch( + root_node: &Rc>>, + current_vdom: &vdom::Node, + new_vdom: &vdom::Node, + ev_callback: F, +) -> Vec +where + Msg: 'static, + F: Fn(Msg) + 'static + Clone, +{ + let patches = diff(¤t_vdom, new_vdom); + + #[cfg(all(feature = "with-debug", feature = "log-patches"))] + { + log::debug!("There are {} patches", patches.len()); + log::debug!("patches: {patches:#?}"); + } + + dom_patch::convert_patches( + root_node.borrow().as_ref().expect("must have a root node"), + &patches, + ev_callback, + ) + .expect("must convert patches") +} + impl Program where APP: Application, diff --git a/examples/patch_dom_node/Cargo.toml b/examples/patch_dom_node/Cargo.toml new file mode 100644 index 00000000..6b54f086 --- /dev/null +++ b/examples/patch_dom_node/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "patch_dom_node" +version = "0.1.0" +edition = "2021" + +[dependencies] +console_error_panic_hook = "0.1.7" +console_log = { version = "1.0.0", features = ["color"] } +log = "0.4.25" +sauron-core = { version = "0.61.9", path = "../../crates/core" } +sauron-html-parser = { version = "0.61.9", path = "../../crates/html-parser" } +web-sys = "0.3.77" diff --git a/examples/patch_dom_node/index.html b/examples/patch_dom_node/index.html new file mode 100644 index 00000000..60b6255a --- /dev/null +++ b/examples/patch_dom_node/index.html @@ -0,0 +1,9 @@ + + + + + + Sauron • Use VDOM + + + diff --git a/examples/patch_dom_node/src/main.rs b/examples/patch_dom_node/src/main.rs new file mode 100644 index 00000000..1dd3e494 --- /dev/null +++ b/examples/patch_dom_node/src/main.rs @@ -0,0 +1,38 @@ +use std::{cell::RefCell, rc::Rc}; + +use sauron_core::{ + dom::{self, DomNode}, + prelude::Node, + vdom, +}; +use sauron_html_parser::parse_html; + +fn main() { + _ = console_log::init_with_level(log::Level::Debug); + console_error_panic_hook::set_once(); + log::info!("Start example"); + + let ev_callback = |_| {}; + + let body_node = DomNode::from(web_sys::Node::from(dom::util::body())); + let mount_node = Rc::new(RefCell::new(Some(body_node))); + + let old_node: Node<()> = parse_html::<()>("
").unwrap().unwrap(); + let new_node: Node<()> = parse_html::<()>("
Hello world
").unwrap().unwrap(); + + let root = dom::create_dom_node(&old_node, ev_callback); + let root_node = Rc::new(RefCell::new(Some(root))); + + let vdom_patches = vdom::diff(&old_node, &new_node); + log::debug!("Created {} VDOM patch(es)", vdom_patches.len()); + + let dom_patches = dom::convert_patches( + &root_node.borrow().as_ref().unwrap(), + &vdom_patches, + ev_callback, + ) + .unwrap(); + log::debug!("Created {} DOM patch(es)", dom_patches.len()); + + dom::apply_dom_patches(root_node, mount_node, dom_patches).unwrap(); +} From d119ad6db71caa1c0260ec1ea8d1651458696ed4 Mon Sep 17 00:00:00 2001 From: Joachim Schiele Date: Mon, 20 Jan 2025 21:36:14 +0000 Subject: [PATCH 2/7] tiny fixes --- README.md | 1 + examples/patch_dom_node/index.html | 5 ++++- examples/patch_dom_node/src/main.rs | 20 ++++++++++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 461cdac1..a3edc8ae 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Sauron is inspired by elm-lang and is following The Elm Architecture. - html syntax for writing views - elegant macro to write styles - batteries included +- standalone DOM/VirtualDOM patcher, see examples/patch_dom_node ### Devoid of unnecessary framework complexities - **no** framework specific cli needed diff --git a/examples/patch_dom_node/index.html b/examples/patch_dom_node/index.html index 60b6255a..89d867af 100644 --- a/examples/patch_dom_node/index.html +++ b/examples/patch_dom_node/index.html @@ -5,5 +5,8 @@ Sauron • Use VDOM - + + + + diff --git a/examples/patch_dom_node/src/main.rs b/examples/patch_dom_node/src/main.rs index 1dd3e494..6e116356 100644 --- a/examples/patch_dom_node/src/main.rs +++ b/examples/patch_dom_node/src/main.rs @@ -10,29 +10,41 @@ use sauron_html_parser::parse_html; fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); - log::info!("Start example"); + log::info!("Example"); let ev_callback = |_| {}; let body_node = DomNode::from(web_sys::Node::from(dom::util::body())); let mount_node = Rc::new(RefCell::new(Some(body_node))); - let old_node: Node<()> = parse_html::<()>("
").unwrap().unwrap(); - let new_node: Node<()> = parse_html::<()>("
Hello world
").unwrap().unwrap(); + let new_html = r#"
+
+ Hello world! If you can see this text on the webpage then the DOM patching was executed! +
+
+ This is footer1 +
+
"#; + + let old_node: Node<()> = parse_html::<()>("").unwrap().unwrap(); + let new_node: Node<()> = parse_html::<()>(new_html).unwrap().unwrap(); let root = dom::create_dom_node(&old_node, ev_callback); let root_node = Rc::new(RefCell::new(Some(root))); let vdom_patches = vdom::diff(&old_node, &new_node); log::debug!("Created {} VDOM patch(es)", vdom_patches.len()); + log::debug!("Created {:?}", vdom_patches); + // convert vdom patch to real dom patches let dom_patches = dom::convert_patches( &root_node.borrow().as_ref().unwrap(), &vdom_patches, ev_callback, ) .unwrap(); - log::debug!("Created {} DOM patch(es)", dom_patches.len()); + log::debug!("Converted {} DOM patch(es)", dom_patches.len()); + log::debug!("Converted {:?}", dom_patches); dom::apply_dom_patches(root_node, mount_node, dom_patches).unwrap(); } From 2152c5abbddc38d49abdc673d2e265d6300e443d Mon Sep 17 00:00:00 2001 From: Joachim Schiele Date: Sat, 25 Jan 2025 11:50:09 +0000 Subject: [PATCH 3/7] Adding standalone dom/vdom manipulation wasm test --- Cargo.lock | 3126 ++++++++++++++++++++++++++++++++ Cargo.toml | 2 + crates/core/src/dom/program.rs | 13 + crates/html-parser/src/lib.rs | 4 +- rust-toolchain.toml | 6 + tests/dom_vdom_standalone.rs | 72 + 6 files changed, 3221 insertions(+), 2 deletions(-) create mode 100644 Cargo.lock create mode 100644 rust-toolchain.toml create mode 100644 tests/dom_vdom_standalone.rs diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 00000000..7cd98739 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,3126 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anyhow" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" + +[[package]] +name = "arc-reactor" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 1.0.0", + "log", + "sauron", +] + +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +dependencies = [ + "nodrop", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bstr" +version = "1.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531a9155a481e2ee699d4f98f43c0ca4ff8ee1bfd55c31e9e98fb29d2b176fe0" +dependencies = [ + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cc" +version = "1.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets", +] + +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + +[[package]] +name = "clap" +version = "4.5.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" +dependencies = [ + "anstyle", + "clap_lex", +] + +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen", +] + +[[package]] +name = "console_log" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89f72f65e8501878b8a004d5a1afb780987e2ce2b4532c562e367a72c57499f" +dependencies = [ + "log", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "console_log" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8aed40e4edbf4d3b4431ab260b63fdc40f5780a4766824329ea0f1eefe3c0f" +dependencies = [ + "log", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "counter" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", +] + +[[package]] +name = "counter-skip_diff" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", +] + +[[package]] +name = "cpufeatures" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" +dependencies = [ + "libc", +] + +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "is-terminal", + "itertools", + "num-traits", + "once_cell", + "oorandom", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "csr-tailwind-trunk" +version = "0.0.0" +dependencies = [ + "console_error_panic_hook", + "console_log 1.0.0", + "log", + "sauron", +] + +[[package]] +name = "css-color" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a254bc4cf4e80026fd4c6e2dc5e8ec7ab077f4970229507548a441265eaca282" +dependencies = [ + "lazy_static", + "lexical", +] + +[[package]] +name = "css-colors" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22c2bbfc5708f23437b074ba4e699b14fd6d7181a61695bccc8d944b78739236" + +[[package]] +name = "csv" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" +dependencies = [ + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" +dependencies = [ + "memchr", +] + +[[package]] +name = "data-encoding" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e60eed09d8c01d3cee5b7d30acb059b76614c918fa0f992e0dd6eeb10daad6f" + +[[package]] +name = "data-viewer" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "js-sys", + "log", + "restq", + "sauron", + "thiserror", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "delay" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "futures", + "log", + "sauron", + "wasm-bindgen-futures", +] + +[[package]] +name = "derive-where" +version = "1.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62d671cc41a825ebabc75757b62d3d168c577f9149b2d49ece1dad1f72119d25" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "experimentals" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "js-sys", + "log", + "sauron", +] + +[[package]] +name = "fancy-ui" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "css-color", + "css-colors", + "log", + "sauron", + "wasm-bindgen-futures", + "wasm-bindgen-test", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fetch-data" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", + "serde", + "serde_json", + "wasm-bindgen-futures", +] + +[[package]] +name = "fetch-data-component" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", + "serde", + "serde_json", + "wasm-bindgen-futures", +] + +[[package]] +name = "fetch-data-macro-syntax" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "reqwest", + "sauron", + "serde", + "serde_json", + "wasm-bindgen-futures", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.2.0", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if 1.0.0", + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[package]] +name = "headers" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" +dependencies = [ + "base64 0.21.7", + "bytes", + "headers-core", + "http 0.2.12", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http 0.2.12", +] + +[[package]] +name = "hello" +version = "0.1.0" +dependencies = [ + "console_log 1.0.0", + "log", + "sauron", +] + +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + +[[package]] +name = "html-escape" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d1ad449764d627e22bfd7cd5e8868264fc9236e07c752972b4080cd351cb476" +dependencies = [ + "utf8-width", +] + +[[package]] +name = "htmlentity" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd54ae4f69adcc1a43637dcff230852832c3ad50df31a90e0cb5f001dd441359" +dependencies = [ + "anyhow", + "lazy_static", + "thiserror", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.2.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.2.0", + "http-body 1.0.1", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.7", + "http 1.2.0", + "http-body 1.0.1", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" +dependencies = [ + "futures-util", + "http 1.2.0", + "hyper 1.5.2", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.5.2", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.2.0", + "http-body 1.0.1", + "hyper 1.5.2", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "interactive" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "futures", + "js-sys", + "log", + "sauron", +] + +[[package]] +name = "interactive-macro-syntax" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "js-sys", + "log", + "sauron", +] + +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "js-framework-benchmark-sauron" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "getrandom", + "log", + "rand", + "sauron", +] + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lexical" +version = "2.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9d189f82a78aa5c06e64f60cbd6f9ec37fe1cdb453dfd88ac2128c81157dc6c" +dependencies = [ + "cfg-if 0.1.10", + "lexical-core", + "rustc_version", +] + +[[package]] +name = "lexical-core" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34449d00c5d4066537f4dc72320b18e3aa421e8e92669250eecd664c618fefce" +dependencies = [ + "arrayvec", + "cfg-if 0.1.10", + "rustc_version", + "ryu", + "static_assertions", +] + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" + +[[package]] +name = "longest-increasing-subsequence" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3bd0dd2cd90571056fdb71f6275fada10131182f84899f4b2a916e565d81d86" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "minicov" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b" +dependencies = [ + "cc", + "walkdir", +] + +[[package]] +name = "minimal" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", +] + +[[package]] +name = "minimal-macro-syntax" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", +] + +[[package]] +name = "miniz_oxide" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.52.0", +] + +[[package]] +name = "more_fragments" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "futures", + "log", + "sauron", +] + +[[package]] +name = "multer" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01acbdc23469fd8fe07ab135923371d5f5a422fbf9c522158677c8eb15bc51c2" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http 0.2.12", + "httparse", + "log", + "memchr", + "mime", + "spin", + "version_check", +] + +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "now-you-see-me" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "oorandom" +version = "11.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" + +[[package]] +name = "openssl" +version = "0.10.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "patch_dom_node" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 1.0.0", + "log", + "sauron-core", + "sauron-html-parser", + "web-sys", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_macros", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + +[[package]] +name = "pom" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c972d8f86e943ad532d0b04e8965a749ad1d18bb981a9c7b3ae72fe7fd7744b" +dependencies = [ + "bstr", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "version_check", + "yansi", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "reqwest" +version = "0.12.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" +dependencies = [ + "base64 0.22.1", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2 0.4.7", + "http 1.2.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.5.2", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-registry", +] + +[[package]] +name = "resize" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", +] + +[[package]] +name = "restq" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76dd872441ac3496066afbc1ad47e513acefa44202fbc3fa3abfe4cad9fe42c5" +dependencies = [ + "base64 0.22.1", + "chrono", + "csv", + "either", + "log", + "pom", + "serde", + "sqlparser", + "thiserror", + "uuid", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if 1.0.0", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rphtml" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51594c0db5855eee2d5ffe39cdea7921c72065bd662759e53b9e1df3a3e758af" +dependencies = [ + "htmlentity", + "lazy_static", + "thiserror", +] + +[[package]] +name = "rstml" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe542870b8f59dd45ad11d382e5339c9a1047cde059be136a7016095bbdefa77" +dependencies = [ + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn", + "syn_derive", + "thiserror", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustls" +version = "0.23.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "sauron" +version = "0.61.9" +dependencies = [ + "console_error_panic_hook", + "console_log 1.0.0", + "criterion", + "doc-comment", + "log", + "regex", + "sauron", + "sauron-core", + "sauron-html-parser", + "sauron-macro", + "wasm-bindgen-futures", + "wasm-bindgen-test", + "web-sys", +] + +[[package]] +name = "sauron-core" +version = "0.61.9" +dependencies = [ + "cfg-if 1.0.0", + "console_error_panic_hook", + "console_log 1.0.0", + "derive-where", + "doc-comment", + "futures", + "indexmap", + "js-sys", + "log", + "longest-increasing-subsequence", + "once_cell", + "phf", + "sauron", + "serde-wasm-bindgen", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test", + "web-sys", +] + +[[package]] +name = "sauron-html-parser" +version = "0.61.9" +dependencies = [ + "html-escape", + "log", + "rphtml", + "sauron-core", + "thiserror", +] + +[[package]] +name = "sauron-macro" +version = "0.61.9" +dependencies = [ + "once_cell", + "phf", + "proc-macro2", + "quote", + "rstml", + "sauron", + "sauron-core", + "syn", +] + +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-wasm-bindgen" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "serde_derive" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "sqlparser" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf9c7ff146298ffda83a200f8d5084f08dcee1edfc135fcc1d646a45d50ffd6" +dependencies = [ + "log", +] + +[[package]] +name = "ssr-forms" +version = "0.1.0" +dependencies = [ + "chrono", + "sauron", + "serde", + "serde_derive", + "tokio", + "warp", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_assertions" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "svg-clock" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "js-sys", + "log", + "sauron", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "svg-clock-macro-syntax" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "js-sys", + "log", + "sauron", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "svg-graph" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", + "wasm-bindgen", +] + +[[package]] +name = "syn" +version = "2.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +dependencies = [ + "cfg-if 1.0.0", + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "todomvc" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", + "serde", + "serde_derive", + "serde_json", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "todomvc-macro-syntax" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", + "serde", + "serde_derive", + "serde_json", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "tokio" +version = "1.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.2.0", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicase" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" + +[[package]] +name = "unicode-ident" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "744018581f9a3454a9e15beb8a33b017183f1e7c0cd170232a2d1453b23a51c4" +dependencies = [ + "getrandom", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "warp" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4378d202ff965b011c64817db11d5829506d3404edeadb61f190d111da3f231c" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "headers", + "http 0.2.12", + "hyper 0.14.32", + "log", + "mime", + "mime_guess", + "multer", + "percent-encoding", + "pin-project", + "scoped-tls", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-tungstenite", + "tokio-util", + "tower-service", + "tracing", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if 1.0.0", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-bindgen-test" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" +dependencies = [ + "js-sys", + "minicov", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "web-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "window-tab-rows" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "console_log 0.2.2", + "log", + "sauron", + "wasm-bindgen", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index cac380bc..b3502239 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,6 +62,8 @@ features = [ "InputEvent", "console", "Performance", + "Element", + "Window", ] diff --git a/crates/core/src/dom/program.rs b/crates/core/src/dom/program.rs index 717dc38c..299884e9 100644 --- a/crates/core/src/dom/program.rs +++ b/crates/core/src/dom/program.rs @@ -737,6 +737,19 @@ where pub fn dispatch(&mut self, msg: APP::MSG) { self.dispatch_multiple([msg]) } + + /// patch the DOM to reflect the App's view + /// + /// Note: This is in another function so as to allow tests to use this shared code + pub fn create_dom_patch(&self, new_vdom: &vdom::Node) -> Vec { + create_dom_patch( + &self.root_node, + &self.app_context.current_vdom(), + new_vdom, + self.create_ev_callback() + ) + } + } fn create_dom_patch( diff --git a/crates/html-parser/src/lib.rs b/crates/html-parser/src/lib.rs index 2272928c..431a0af3 100644 --- a/crates/html-parser/src/lib.rs +++ b/crates/html-parser/src/lib.rs @@ -30,7 +30,7 @@ pub enum ParseError { InvalidTag(String), } -/// parse the html string and build a node tree +/// parse escaped html strings like "Hello world!" into "Hello world!" and then into a node tree pub fn raw_html(html: &str) -> Node { // decode html entitiesd back since it will be safely converted into text let html = html_escape::decode_html_entities(html); @@ -39,7 +39,7 @@ pub fn raw_html(html: &str) -> Node { .expect("must have a node") } -/// the document is not wrapped with html +/// parse none-escaped html strings as "Hello world!" into a node tree (see also raw_html(...)) pub fn parse_html(html: &str) -> Result>, ParseError> { let doc = Doc::parse( html, diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..a44815df --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,6 @@ +[toolchain] +channel = "stable" +targets = [ + "x86_64-unknown-linux-musl", # used for the backend + "wasm32-unknown-unknown" # used for the frontend +] diff --git a/tests/dom_vdom_standalone.rs b/tests/dom_vdom_standalone.rs new file mode 100644 index 00000000..43b15ae2 --- /dev/null +++ b/tests/dom_vdom_standalone.rs @@ -0,0 +1,72 @@ +use wasm_bindgen_test::*; +use std::{cell::RefCell, rc::Rc}; + +use sauron_core::{ + dom::{self, DomNode}, + prelude::Node, + vdom, +}; +use sauron_html_parser::{raw_html, parse_html}; + +use web_sys::{Element, HtmlElement}; + +wasm_bindgen_test_configure!(run_in_browser); + +// Verify that our DomUpdater's patch method works. +// We test a simple case here, since diff_patch.rs is responsible for testing more complex +// diffing and patching. +#[wasm_bindgen_test] +fn test_dom_vdom_standalone() { + console_log::init_with_level(log::Level::Trace).ok(); + console_error_panic_hook::set_once(); + + let ev_callback = |_| {}; + + let window = web_sys::window().expect("no global `window` exists"); + let document = window.document().expect("should have a document on window"); + + let div: Element = document.create_element("div").unwrap(); + div.set_attribute("id", "here").unwrap(); + document.body().unwrap().append_child(&div).unwrap(); + + let web_sys_node: web_sys::Node = web_sys::Node::from(div); + let div_node = DomNode::from(web_sys_node); + let mount_node = Rc::new(RefCell::new(Some(div_node))); + + let new_html = r#" +
boak
+ "#; + + let old_node: Node<()> = parse_html::<()>("").unwrap().unwrap(); + let new_node: Node<()> = raw_html::<()>(new_html); + let root = dom::create_dom_node(&old_node, ev_callback); + let root_node = Rc::new(RefCell::new(Some(root))); + + let vdom_patches = vdom::diff(&old_node, &new_node); + log::debug!("Created {} VDOM patch(es)", vdom_patches.len()); + log::debug!("Created {:?}", vdom_patches); + + // convert vdom patch to real dom patches + let dom_patches = dom::convert_patches( + &root_node.borrow().as_ref().unwrap(), + &vdom_patches, + ev_callback, + ) + .unwrap(); + log::debug!("Converted {} DOM patch(es)", dom_patches.len()); + log::debug!("Converted {:?}", dom_patches); + + dom::apply_dom_patches(root_node, mount_node, dom_patches).unwrap(); + + let target: Element = document.get_element_by_id("here").unwrap(); + + // Get the inner HTML from the body element + let html_content: String = target.inner_html(); + + assert_eq!( + "
boak
".to_string(), + html_content + ); + +} + From 4fd2f4c8300d5296e71628ba2dc784229392d6eb Mon Sep 17 00:00:00 2001 From: Joachim Schiele Date: Mon, 27 Jan 2025 14:29:14 +0000 Subject: [PATCH 4/7] Error handling for diff() using Result --- .gitignore | 1 + crates/core/src/dom/program.rs | 9 +- crates/core/src/vdom/diff.rs | 124 +++++++++++++++------ crates/core/src/vdom/diff_lis.rs | 18 +-- tests/dom_diff_with_events.rs | 2 +- tests/dom_event_tests.rs | 2 +- tests/dom_insert_before_after_patches.rs | 75 ++++++------- tests/dom_insert_patches.rs | 6 +- tests/dom_keyed_subsequent_updates.rs | 6 +- tests/dom_node_event_recycling.rs | 2 +- tests/dom_passing_reordered_keyed_node.rs | 4 +- tests/dom_patches_keyed.rs | 8 +- tests/dom_patches_text_node.rs | 2 +- tests/dom_remove_node_patches.rs | 2 +- tests/dom_reordered_keyed_nodes.rs | 2 +- tests/dom_replace_node_patches.rs | 4 +- tests/dom_swap_nodes.rs | 6 +- tests/dom_test_update.rs | 2 +- tests/dom_updates_target_dom.rs | 2 +- tests/dom_vdom_standalone.rs | 127 +++++++++++++++++++--- tests/html_diff_classes.rs | 4 +- tests/html_diff_patch_test.rs | 34 +++--- tests/html_right_next_text_siblings.rs | 2 +- tests/html_skip_criteria_test.rs | 6 +- tests/html_style_change.rs | 6 +- tests/html_test.rs | 18 +-- tests/vdom_class_test.rs | 4 +- tests/vdom_diff_keyed_test.rs | 42 +++---- tests/vdom_diff_mixed.rs | 6 +- tests/vdom_diff_node_list.rs | 2 +- tests/vdom_diff_skip_and_replace.rs | 10 +- tests/vdom_diff_tests.rs | 30 ++--- tests/vdom_fragment_test.rs | 2 +- tests/vdom_insert_patches.rs | 8 +- tests/vdom_massive_keyed.rs | 14 +-- tests/vdom_rearranged_keyed_nodes.rs | 2 +- tests/vdom_replace_node_patches.rs | 2 +- tests/vdom_swap_rows.rs | 14 +-- tests/vdom_test_diff_lis.rs | 2 +- 39 files changed, 386 insertions(+), 226 deletions(-) diff --git a/.gitignore b/.gitignore index a6a6eb96..dbc07079 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target/ **/*.rs.bk *.lock +.direnv diff --git a/crates/core/src/dom/program.rs b/crates/core/src/dom/program.rs index 299884e9..61eea9da 100644 --- a/crates/core/src/dom/program.rs +++ b/crates/core/src/dom/program.rs @@ -567,6 +567,7 @@ where new_vdom, &SkipPath::new(TreePath::root(), skip_diff.clone()), ) + .unwrap() } #[cfg(feature = "with-raf")] @@ -746,13 +747,12 @@ where &self.root_node, &self.app_context.current_vdom(), new_vdom, - self.create_ev_callback() + self.create_ev_callback(), ) } - } -fn create_dom_patch( +pub fn create_dom_patch( root_node: &Rc>>, current_vdom: &vdom::Node, new_vdom: &vdom::Node, @@ -762,7 +762,7 @@ where Msg: 'static, F: Fn(Msg) + 'static + Clone, { - let patches = diff(¤t_vdom, new_vdom); + let patches = diff(¤t_vdom, new_vdom).unwrap(); #[cfg(all(feature = "with-debug", feature = "log-patches"))] { @@ -791,6 +791,7 @@ where new_vdom: vdom::Node, ) -> Result { let dom_patches = self.create_dom_patch(&new_vdom); + let total_patches = dom_patches.len(); self.pending_patches.borrow_mut().extend(dom_patches); diff --git a/crates/core/src/vdom/diff.rs b/crates/core/src/vdom/diff.rs index 1a0f4764..1ef527ce 100644 --- a/crates/core/src/vdom/diff.rs +++ b/crates/core/src/vdom/diff.rs @@ -13,6 +13,20 @@ static USE_SKIP_DIFF: bool = true; #[cfg(not(feature = "use-skipdiff"))] static USE_SKIP_DIFF: bool = false; +/// all the possible error when diffing Node(s) +#[derive(Debug, thiserror::Error, Clone, Copy)] +pub enum DiffError { + /// Node list must have already unrolled when creating an element + #[error("Node list must have already unrolled when creating an element")] + UnrollError, + /// Skip diff error + #[error("Skip diff error")] + SkipDiffError, + /// Invalid root node count of: {0} + #[error("Invalid root node count of: {0}")] + InvalidRootNodeCount(usize), +} + /// Return the patches needed for `old_node` to have the same DOM as `new_node` /// /// # Agruments @@ -40,7 +54,7 @@ static USE_SKIP_DIFF: bool = false; /// vec![element("div", vec![attr("key", "2")], vec![])], /// ); /// -/// let diff = diff(&old, &new); +/// let diff = diff(&old, &new).unwrap(); /// assert_eq!( /// diff, /// vec![Patch::remove_node( @@ -50,7 +64,10 @@ static USE_SKIP_DIFF: bool = false; /// ] /// ); /// ``` -pub fn diff<'a, MSG>(old_node: &'a Node, new_node: &'a Node) -> Vec> { +pub fn diff<'a, MSG>( + old_node: &'a Node, + new_node: &'a Node, +) -> Result>, DiffError> { diff_recursive( old_node, new_node, @@ -115,10 +132,10 @@ pub fn diff_recursive<'a, MSG>( old_node: &'a Node, new_node: &'a Node, path: &SkipPath, -) -> Vec> { +) -> Result>, DiffError> { if let Some(skip_diff) = path.skip_diff.as_ref() { if USE_SKIP_DIFF && skip_diff.shall_skip_node() { - return vec![]; + return Err(DiffError::SkipDiffError); } } @@ -136,16 +153,31 @@ pub fn diff_recursive<'a, MSG>( }; // skip diffing if the function evaluates to true if skip(old_node, new_node) { - return vec![]; + return Ok(vec![]); + } + + // multiple root nodes are not supported. this would be two root nodes "
" + // the diff will work but the result is wrong, so instead we bail out here + match new_node { + Node::Leaf(leaf) => match leaf { + Leaf::NodeList(list) => { + if list.len() > 1 { + log::error!("invalid root node cound: input needs exactly one root node and childs, not several root nodes"); + return Err(DiffError::InvalidRootNodeCount(list.len())); + } + } + _ => {} + }, + Node::Element(_) => {} } // replace node and return early if should_replace(old_node, new_node) { - return vec![Patch::replace_node( + return Ok(vec![Patch::replace_node( old_node.tag(), path.path.clone(), vec![new_node], - )]; + )]); } let mut patches = vec![]; @@ -169,10 +201,13 @@ pub fn diff_recursive<'a, MSG>( // we back track since Fragment is not a real node, but it would still // be traversed from the prior call let patch = diff_nodes(None, old_nodes, new_nodes, &path.backtrack()); - patches.extend(patch); + match patch { + Ok(patch) => patches.extend(patch), + Err(e) => return Err(e), + }; } (Leaf::NodeList(_old_elements), Leaf::NodeList(_new_elements)) => { - panic!("Node list must have already unrolled when creating an element"); + return Err(DiffError::UnrollError) } (Leaf::StatelessComponent(old_comp), Leaf::StatelessComponent(new_comp)) => { let new_path = SkipPath { @@ -192,7 +227,10 @@ pub fn diff_recursive<'a, MSG>( "new comp view should not be a template" ); let patch = diff_recursive(old_real_view, new_real_view, &new_path); - patches.extend(patch); + match patch { + Ok(patch) => patches.extend(patch), + Err(e) => return Err(e), + } } (Leaf::StatefulComponent(old_comp), Leaf::StatefulComponent(new_comp)) => { let attr_patches = create_attribute_patches( @@ -201,15 +239,26 @@ pub fn diff_recursive<'a, MSG>( &new_comp.attrs, path, ); - if !attr_patches.is_empty() { - log::info!("stateful component attr_patches: {attr_patches:#?}"); - } - patches.extend(attr_patches); - let patch = diff_nodes(None, &old_comp.children, &new_comp.children, path); - if !patch.is_empty() { - log::info!("stateful component patch: {patch:#?}"); + match attr_patches { + Ok(attr_patches) => { + if !attr_patches.is_empty() { + log::info!("stateful component attr_patches: {attr_patches:#?}"); + } + patches.extend(attr_patches); + let patch = + diff_nodes(None, &old_comp.children, &new_comp.children, path); + match patch { + Ok(patch) => { + if !patch.is_empty() { + log::info!("stateful component patch: {patch:#?}"); + } + patches.extend(patch); + } + Err(e) => return Err(e), + } + } + Err(e) => return Err(e), } - patches.extend(patch); } (Leaf::TemplatedView(_old_view), _) => { unreachable!("templated view should not be diffed..") @@ -238,7 +287,10 @@ pub fn diff_recursive<'a, MSG>( new_element.attributes(), path, ); - patches.extend(attr_patches); + match attr_patches { + Ok(attr_patches) => patches.extend(attr_patches), + Err(e) => return Err(e), + }; } let more_patches = diff_nodes( @@ -247,15 +299,17 @@ pub fn diff_recursive<'a, MSG>( new_element.children(), path, ); - - patches.extend(more_patches); + match more_patches { + Ok(more_patches) => patches.extend(more_patches), + Err(e) => return Err(e), + }; } _ => { unreachable!("Unequal variant discriminants should already have been handled"); } }; - patches + Ok(patches) } fn diff_nodes<'a, MSG>( @@ -263,12 +317,12 @@ fn diff_nodes<'a, MSG>( old_children: &'a [Node], new_children: &'a [Node], path: &SkipPath, -) -> Vec> { +) -> Result>, DiffError> { let diff_as_keyed = is_any_keyed(old_children) || is_any_keyed(new_children); if diff_as_keyed { let keyed_patches = diff_lis::diff_keyed_nodes(old_tag, old_children, new_children, path); - keyed_patches + Ok(keyed_patches) } else { let non_keyed_patches = diff_non_keyed_nodes(old_tag, old_children, new_children, path); non_keyed_patches @@ -290,14 +344,17 @@ fn diff_non_keyed_nodes<'a, MSG>( old_children: &'a [Node], new_children: &'a [Node], path: &SkipPath, -) -> Vec> { - let mut patches = vec![]; +) -> Result>, DiffError> { + let mut patches: Vec> = vec![]; let old_child_count = old_children.len(); let new_child_count = new_children.len(); // if there is no new children, then clear the children of this element if old_child_count > 0 && new_child_count == 0 { - return vec![Patch::clear_children(old_element_tag, path.path.clone())]; + return Ok(vec![Patch::clear_children( + old_element_tag, + path.path.clone(), + )]); } let min_count = cmp::min(old_child_count, new_child_count); @@ -309,7 +366,10 @@ fn diff_non_keyed_nodes<'a, MSG>( let new_child = &new_children.get(index).expect("No new child node"); let more_patches = diff_recursive(old_child, new_child, &child_path); - patches.extend(more_patches); + match more_patches { + Ok(more_patches) => patches.extend(more_patches), + Err(e) => return Err(e), + } } // If there are more new child than old_node child, we make a patch to append the excess element @@ -335,7 +395,7 @@ fn diff_non_keyed_nodes<'a, MSG>( patches.extend(remove_node_patches); } - patches + Ok(patches) } /// @@ -348,7 +408,7 @@ fn create_attribute_patches<'a, MSG>( old_attributes: &'a [Attribute], new_attributes: &'a [Attribute], path: &SkipPath, -) -> Vec> { +) -> Result>, DiffError> { let skip_indices = if let Some(skip_diff) = &path.skip_diff { if let SkipAttrs::Indices(skip_indices) = &skip_diff.skip_attrs { skip_indices.clone() @@ -365,7 +425,7 @@ fn create_attribute_patches<'a, MSG>( // return early if both attributes are empty if old_attributes.is_empty() && new_attributes.is_empty() { - return vec![]; + return Ok(vec![]); } let mut add_attributes: Vec<&Attribute> = vec![]; @@ -440,7 +500,7 @@ fn create_attribute_patches<'a, MSG>( remove_attributes, )); } - patches + Ok(patches) } /// returns true if all the elements in subset is in big_set diff --git a/crates/core/src/vdom/diff_lis.rs b/crates/core/src/vdom/diff_lis.rs index 8926a3d9..b33f3973 100644 --- a/crates/core/src/vdom/diff_lis.rs +++ b/crates/core/src/vdom/diff_lis.rs @@ -112,7 +112,7 @@ fn diff_keyed_ends<'a, MSG>( } let child_path = path.traverse(index); // diff the children and add to patches - let patches = diff_recursive(old, new, &child_path); + let patches = diff_recursive(old, new, &child_path).unwrap(); all_patches.extend(patches); old_index_matched.push(index); left_offset += 1; @@ -158,7 +158,7 @@ fn diff_keyed_ends<'a, MSG>( break; } let child_path = path.traverse(old_index); - let patches = diff_recursive(old, new, &child_path); + let patches: Vec> = diff_recursive(old, new, &child_path).unwrap(); all_patches.extend(patches); right_offset += 1; } @@ -281,11 +281,12 @@ fn diff_keyed_middle<'a, MSG>( } for idx in lis_sequence.iter() { - let patches = diff_recursive( + let patches: Vec> = diff_recursive( &old_children[new_index_to_old_index[*idx]], &new_children[*idx], path, - ); + ) + .unwrap(); all_patches.extend(patches); } @@ -301,7 +302,8 @@ fn diff_keyed_middle<'a, MSG>( if old_index == u32::MAX as usize { new_nodes.push(new_node); } else { - let patches = diff_recursive(&old_children[old_index], new_node, path); + let patches: Vec> = + diff_recursive(&old_children[old_index], new_node, path).unwrap(); all_patches.extend(patches); node_paths.push(path.traverse(left_offset + old_index).path); @@ -339,7 +341,8 @@ fn diff_keyed_middle<'a, MSG>( if old_index == u32::MAX as usize { new_nodes.push(new_node) } else { - let patches = diff_recursive(&old_children[old_index], new_node, path); + let patches: Vec> = + diff_recursive(&old_children[old_index], new_node, path).unwrap(); all_patches.extend(patches); } } @@ -363,7 +366,8 @@ fn diff_keyed_middle<'a, MSG>( if old_index == u32::MAX as usize { new_nodes.push(new_node); } else { - let patches = diff_recursive(&old_children[old_index], new_node, path); + let patches: Vec> = + diff_recursive(&old_children[old_index], new_node, path).unwrap(); all_patches.extend(patches); node_paths.push(path.traverse(left_offset + old_index).path); } diff --git a/tests/dom_diff_with_events.rs b/tests/dom_diff_with_events.rs index 7c6d63d5..75bfbfaa 100644 --- a/tests/dom_diff_with_events.rs +++ b/tests/dom_diff_with_events.rs @@ -21,7 +21,7 @@ fn nodes_with_event_should_not_recycle() { vec![div(vec![class("child")], vec![])], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); log::info!("{:#?}", diff); assert_eq!( diff, diff --git a/tests/dom_event_tests.rs b/tests/dom_event_tests.rs index a3e218c2..8d810124 100644 --- a/tests/dom_event_tests.rs +++ b/tests/dom_event_tests.rs @@ -135,7 +135,7 @@ fn remove_event() { ], vec![], ); - let patch = diff(&old, &new); + let patch = diff(&old, &new).unwrap(); log::debug!("patch: {:?}", patch); let input_event = web_sys::InputEvent::new("input").unwrap(); diff --git a/tests/dom_insert_before_after_patches.rs b/tests/dom_insert_before_after_patches.rs index 09caec9d..3aa5f077 100644 --- a/tests/dom_insert_before_after_patches.rs +++ b/tests/dom_insert_before_after_patches.rs @@ -16,34 +16,14 @@ fn insert_multiple_before_nodes() { let document = web_sys::window().unwrap().document().unwrap(); - let old: Node<()> = main( - vec![class("before_nodes_test1")], - vec![ul( - vec![class("todo")], - vec![ - li(vec![key(1)], vec![text("item1")]), - li(vec![key(2)], vec![text("item2")]), - li(vec![key(3)], vec![text("item3")]), - ], - )], - ); + let old: Node<()> = raw_html::<()>("
"); - let update1: Node<()> = main( - vec![class("before_nodes_test1")], - vec![ul( - vec![class("todo")], - vec![ - li(vec![], vec![text("itemA")]), - li(vec![], vec![text("itemB")]), - li(vec![], vec![text("itemC")]), - li(vec![key(1)], vec![text("item1")]), - li(vec![key(2)], vec![text("item2")]), - li(vec![key(3)], vec![text("item3")]), - ], - )], - ); + let update1: Node<()> = + raw_html::<()>("
"); + + let update2: Node<()> = raw_html::<()>("
foo
"); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); @@ -55,26 +35,43 @@ fn insert_multiple_before_nodes() { .update_dom_with_vdom(old) .expect("must update dom"); - let container = document - .query_selector(".before_nodes_test1") - .expect("must not error") - .expect("must exist"); + // let container = document + // .query_selector(".before_nodes_test1") + // .expect("must not error") + // .expect("must exist"); - let expected = "
  • item1
  • item2
  • item3
"; - assert_eq!(expected, container.outer_html()); + // let expected = "
  • item1
  • item2
  • item3
"; + // assert_eq!(expected, container.outer_html()); simple_program .update_dom_with_vdom(update1) .expect("must not error"); - let container = document - .query_selector(".before_nodes_test1") - .expect("must not error") - .expect("must exist"); + // let container = document + // .query_selector(".before_nodes_test1") + // .expect("must not error") + // .expect("must exist"); + + // let expected1 = "
  • itemA
  • itemB
  • itemC
  • item1
  • item2
  • item3
"; + + // assert_eq!(expected1, container.outer_html()); + + simple_program + .update_dom_with_vdom(update2) + .expect("must not error"); + + //let container = document.body().expect("must not error"); + let container = document.get_element_by_id("there").unwrap(); + + // let container = document + // .query_selector(".before_nodes_test1") + // .expect("must not error") + // .expect("must exist"); - let expected1 = "
  • itemA
  • itemB
  • itemC
  • item1
  • item2
  • item3
"; + let expected1 = "
foo
"; assert_eq!(expected1, container.outer_html()); + assert_eq!(1, 2); } #[wasm_bindgen_test] @@ -111,7 +108,7 @@ fn insert_multiple_after_nodes() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); @@ -179,7 +176,7 @@ fn insert_multiple_in_the_middle() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patching old to update1: {:#?}", patches); let mut old_html = String::new(); diff --git a/tests/dom_insert_patches.rs b/tests/dom_insert_patches.rs index 8b97cd69..8a77bd63 100644 --- a/tests/dom_insert_patches.rs +++ b/tests/dom_insert_patches.rs @@ -41,7 +41,7 @@ fn test_patch_insert_node() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); @@ -108,7 +108,7 @@ fn test_patch_insert_node_in_the_middle() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); @@ -179,7 +179,7 @@ fn multiple_insert_should_work() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); diff --git a/tests/dom_keyed_subsequent_updates.rs b/tests/dom_keyed_subsequent_updates.rs index c145825f..8af21237 100644 --- a/tests/dom_keyed_subsequent_updates.rs +++ b/tests/dom_keyed_subsequent_updates.rs @@ -111,7 +111,7 @@ fn subsequent_updates() { ], ); - let patches1 = diff(&old, &update1); + let patches1 = diff(&old, &update1).unwrap(); log::trace!("patches1: {:#?} at line: {}", patches1, line!()); @@ -276,7 +276,7 @@ fn subsequent_updates() { let root_node_html = root_node.as_ref().unwrap().outer_html(); log::trace!("current root node: {}", root_node_html); } - let patches2 = diff(&update1, &update2); + let patches2 = diff(&update1, &update2).unwrap(); log::trace!("-->patches2: {:#?}", patches2); log::info!("Updating dom with update2"); @@ -381,7 +381,7 @@ fn subsequent_updates() { ], ); - let patches3 = diff(&update2, &update3); + let patches3 = diff(&update2, &update3).unwrap(); log::trace!("\n---->patches3: {:#?}", patches3); simple_program diff --git a/tests/dom_node_event_recycling.rs b/tests/dom_node_event_recycling.rs index d0dfcfb7..659e0acc 100644 --- a/tests/dom_node_event_recycling.rs +++ b/tests/dom_node_event_recycling.rs @@ -40,7 +40,7 @@ fn elements_with_different_event_should_not_be_recycle() { log::info!("cb2: {:#?}", cb2); let new = input(vec![id(elem_id), cb2.clone()], vec![]); - let patches: Vec> = diff(&old, &new); + let patches: Vec> = diff(&old, &new).unwrap(); // FIXME: this should replace the old node with a new one since the even essentially is a new // one. But we have no way of knowing the closure will produce the same result of not log::trace!("patches: {:#?}", patches); diff --git a/tests/dom_passing_reordered_keyed_node.rs b/tests/dom_passing_reordered_keyed_node.rs index 730f6226..5e51b8e4 100644 --- a/tests/dom_passing_reordered_keyed_node.rs +++ b/tests/dom_passing_reordered_keyed_node.rs @@ -34,7 +34,7 @@ fn reordered_keys2() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); @@ -92,7 +92,7 @@ fn reordered_keys3() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); diff --git a/tests/dom_patches_keyed.rs b/tests/dom_patches_keyed.rs index d62c27aa..9e71bbe3 100644 --- a/tests/dom_patches_keyed.rs +++ b/tests/dom_patches_keyed.rs @@ -78,7 +78,7 @@ fn node_patched_properly() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); old.render(&mut old_html).expect("must render"); @@ -151,7 +151,7 @@ fn node_patched_properly_remove_from_start() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); @@ -228,7 +228,7 @@ fn node_patched_properly_text_changed() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); @@ -310,7 +310,7 @@ fn mixed_keyed_and_non_keyed_elements() { ], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); diff --git a/tests/dom_patches_text_node.rs b/tests/dom_patches_text_node.rs index 690553d3..96c2b8e3 100644 --- a/tests/dom_patches_text_node.rs +++ b/tests/dom_patches_text_node.rs @@ -30,7 +30,7 @@ fn patches_text() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); diff --git a/tests/dom_remove_node_patches.rs b/tests/dom_remove_node_patches.rs index 2862a2e1..af116c01 100644 --- a/tests/dom_remove_node_patches.rs +++ b/tests/dom_remove_node_patches.rs @@ -39,7 +39,7 @@ fn test_remove_nodes() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); diff --git a/tests/dom_reordered_keyed_nodes.rs b/tests/dom_reordered_keyed_nodes.rs index dc346ae6..8332eca2 100644 --- a/tests/dom_reordered_keyed_nodes.rs +++ b/tests/dom_reordered_keyed_nodes.rs @@ -40,7 +40,7 @@ fn failing_reordered_keys() { // The patch was: // append key1, item1 // remove nodeidx: 2, [0,0,0] - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); diff --git a/tests/dom_replace_node_patches.rs b/tests/dom_replace_node_patches.rs index b56e4306..87923992 100644 --- a/tests/dom_replace_node_patches.rs +++ b/tests/dom_replace_node_patches.rs @@ -41,7 +41,7 @@ fn test_multiple_replace() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); @@ -107,7 +107,7 @@ fn test_multiple_replace_and_parent_is_replaced_too() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); diff --git a/tests/dom_swap_nodes.rs b/tests/dom_swap_nodes.rs index 330d7608..d580b90f 100644 --- a/tests/dom_swap_nodes.rs +++ b/tests/dom_swap_nodes.rs @@ -47,7 +47,7 @@ fn swap_rows_non_keyed() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); @@ -108,7 +108,7 @@ fn swap_rows_keyed() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); @@ -179,7 +179,7 @@ fn swap_1_and_8() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); log::debug!("patches: {:#?}", patches); let mut old_html = String::new(); diff --git a/tests/dom_test_update.rs b/tests/dom_test_update.rs index ef89ca28..3c85a68d 100644 --- a/tests/dom_test_update.rs +++ b/tests/dom_test_update.rs @@ -98,7 +98,7 @@ fn test1() { ); - let patch = diff(¤t_dom, &target_dom); + let patch = diff(¤t_dom, &target_dom).unwrap(); log::trace!("test update here.."); log::debug!("patches: {:#?}", patch); diff --git a/tests/dom_updates_target_dom.rs b/tests/dom_updates_target_dom.rs index 4ed8324e..75189d9a 100644 --- a/tests/dom_updates_target_dom.rs +++ b/tests/dom_updates_target_dom.rs @@ -105,7 +105,7 @@ fn multiple_match_on_keyed_elements() { ); - let patches = diff(¤t_dom, &target_dom); + let patches = diff(¤t_dom, &target_dom).unwrap(); log::trace!("patches: {:#?}", patches); log::trace!("current_dom: {}", current_dom.render_to_string()); diff --git a/tests/dom_vdom_standalone.rs b/tests/dom_vdom_standalone.rs index 43b15ae2..a636d26f 100644 --- a/tests/dom_vdom_standalone.rs +++ b/tests/dom_vdom_standalone.rs @@ -1,12 +1,12 @@ -use wasm_bindgen_test::*; use std::{cell::RefCell, rc::Rc}; +use wasm_bindgen_test::*; use sauron_core::{ dom::{self, DomNode}, prelude::Node, vdom, }; -use sauron_html_parser::{raw_html, parse_html}; +use sauron_html_parser::{parse_html, raw_html}; use web_sys::{Element, HtmlElement}; @@ -20,8 +20,6 @@ fn test_dom_vdom_standalone() { console_log::init_with_level(log::Level::Trace).ok(); console_error_panic_hook::set_once(); - let ev_callback = |_| {}; - let window = web_sys::window().expect("no global `window` exists"); let document = window.document().expect("should have a document on window"); @@ -31,7 +29,6 @@ fn test_dom_vdom_standalone() { let web_sys_node: web_sys::Node = web_sys::Node::from(div); let div_node = DomNode::from(web_sys_node); - let mount_node = Rc::new(RefCell::new(Some(div_node))); let new_html = r#"
boak
@@ -39,14 +36,15 @@ fn test_dom_vdom_standalone() { let old_node: Node<()> = parse_html::<()>("").unwrap().unwrap(); let new_node: Node<()> = raw_html::<()>(new_html); - let root = dom::create_dom_node(&old_node, ev_callback); - let root_node = Rc::new(RefCell::new(Some(root))); - let vdom_patches = vdom::diff(&old_node, &new_node); + let vdom_patches = vdom::diff(&old_node, &new_node).unwrap(); log::debug!("Created {} VDOM patch(es)", vdom_patches.len()); log::debug!("Created {:?}", vdom_patches); - // convert vdom patch to real dom patches + let ev_callback = |_| {}; + let root: DomNode = dom::create_dom_node(&old_node, ev_callback); + let root_node: Rc>> = Rc::new(RefCell::new(Some(root))); + let dom_patches = dom::convert_patches( &root_node.borrow().as_ref().unwrap(), &vdom_patches, @@ -56,17 +54,116 @@ fn test_dom_vdom_standalone() { log::debug!("Converted {} DOM patch(es)", dom_patches.len()); log::debug!("Converted {:?}", dom_patches); + let mount_node: Rc>> = Rc::new(RefCell::new(Some(div_node))); dom::apply_dom_patches(root_node, mount_node, dom_patches).unwrap(); let target: Element = document.get_element_by_id("here").unwrap(); - - // Get the inner HTML from the body element let html_content: String = target.inner_html(); + assert_eq!("
boak
".to_string(), html_content); +} - assert_eq!( - "
boak
".to_string(), - html_content - ); +#[derive(Clone)] +struct DomUpdater { + id: String, + current_vdom: Node<()>, + root_node: Rc>>, + mount_node: Rc>>, +} +impl DomUpdater { + fn new(id: String) -> Self { + let window = web_sys::window().expect("no global `window` exists"); + let document = window.document().expect("should have a document on window"); + + let div: web_sys::Element = document.create_element("div").unwrap(); + div.set_attribute("id", id.as_str()).unwrap(); + document.body().unwrap().append_child(&div).unwrap(); + + let web_sys_node: web_sys::Node = web_sys::Node::from(div); + let div_node = DomNode::from(web_sys_node); + + let current_vdom: Node<()> = parse_html::<()>("").unwrap().unwrap(); + let ev_callback = |_| {}; + let root: DomNode = dom::create_dom_node(¤t_vdom, ev_callback); + + DomUpdater { + id, + current_vdom, + root_node: Rc::new(RefCell::new(Some(root))), + mount_node: Rc::new(RefCell::new(Some(div_node))), + } + } + fn update(&mut self, next_html: String) { + let new_node: Node<()> = parse_html::<()>(next_html.as_str()).unwrap().unwrap(); + + let old_vdom = self.current_vdom.clone(); + + log::debug!("-------------------------------------------------"); + log::debug!("old_node: {}", old_vdom.render_to_string()); + log::debug!("inner_html: {}", self.inner_html()); + fn same(a: String, b: String) -> String { + if a == b { + "same".to_string() + } else { + "different".to_string() + } + } + log::debug!( + " => {}", + same(old_vdom.render_to_string(), self.inner_html()) + ); + log::debug!("new_node: {}", new_node.render_to_string()); + log::debug!("new_node: {:#?}", new_node); + + let vdom_patches = vdom::diff(&old_vdom, &new_node).unwrap(); + + log::debug!("Created {} VDOM patch(es)", vdom_patches.len()); + log::debug!("Created {:#?}", vdom_patches); + let dom_patches = dom::convert_patches( + self.root_node.borrow().as_ref().unwrap(), + &vdom_patches, + |_| {}, + ) + .unwrap(); + log::debug!("Converted {} DOM patch(es)", dom_patches.len()); + log::debug!("Converted {:#?}", dom_patches); + log::debug!("-------------------------------------------------"); + dom::apply_dom_patches( + Rc::clone(&self.root_node), + Rc::clone(&self.mount_node), + dom_patches, + ) + .unwrap(); + self.current_vdom = new_node.clone(); + + assert_eq!(next_html, self.inner_html()); + } + fn inner_html(&self) -> String { + let window = web_sys::window().expect("no global `window` exists"); + let document = window.document().expect("should have a document on window"); + let target: Element = document.get_element_by_id(self.id.as_str()).unwrap(); + target.inner_html() + } } +#[wasm_bindgen_test] +fn test_dom_vdom_patcher() { + console_log::init_with_level(log::Level::Trace).ok(); + console_error_panic_hook::set_once(); + let id: String = "there".to_string(); + + let mut dom_updater: DomUpdater = DomUpdater::new(id.clone()); + + let html: String = "
".to_string(); + dom_updater.update(html.clone()); + assert_eq!(html.to_string(), dom_updater.inner_html()); + + let html: String = "
".to_string(); + dom_updater.update(html.clone()); + assert_eq!(html, dom_updater.inner_html()); + + let html: String = "
foo
".to_string(); + dom_updater.update(html.clone()); + + assert_eq!(html, dom_updater.inner_html()); +} diff --git a/tests/html_diff_classes.rs b/tests/html_diff_classes.rs index 684681f2..254b77ee 100644 --- a/tests/html_diff_classes.rs +++ b/tests/html_diff_classes.rs @@ -7,7 +7,7 @@ fn class_with_bool_value() { let new = div(vec![class(true)], vec![]); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::add_attributes( &"div", TreePath::new(vec![]), @@ -37,7 +37,7 @@ fn parent_of_matching_keyed_are_ignored() { ], ); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::add_attributes( &"ul", TreePath::new(vec![]), diff --git a/tests/html_diff_patch_test.rs b/tests/html_diff_patch_test.rs index 056d148c..f190d729 100644 --- a/tests/html_diff_patch_test.rs +++ b/tests/html_diff_patch_test.rs @@ -28,7 +28,7 @@ fn nodes_with_event_must_be_replaced() { ], vec![], ); - let patch = diff(&old, &new); + let patch = diff(&old, &new).unwrap(); println!("patch: {:#?}", patch); assert_eq!( @@ -47,7 +47,7 @@ fn change_class_attribute() { let new = div(vec![classes(["class1", "difference_class"])], vec![]); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::add_attributes( &"div", TreePath::new(vec![]), @@ -88,7 +88,7 @@ fn truncate_children() { ], ); assert_eq!( - dbg!(diff(&old, &new)), + dbg!(diff(&old, &new)).unwrap(), vec![ Patch::remove_node(Some(&"div"), TreePath::new(vec![3]),), Patch::remove_node(Some(&"div"), TreePath::new(vec![4]),), @@ -123,7 +123,7 @@ fn truncate_children_different_attributes() { ], ); - let patch = diff(&old, &new); + let patch = diff(&old, &new).unwrap(); dbg!(&patch); assert_eq!( @@ -146,7 +146,7 @@ fn replace_node2() { let old: Node<()> = div(vec![], vec![b(vec![], vec![text("1")]), b(vec![], vec![])]); let new = div(vec![], vec![i(vec![], vec![text("1")]), i(vec![], vec![])]); - let patch = diff(&old, &new); + let patch = diff(&old, &new).unwrap(); dbg!(&patch); assert_eq!( patch, @@ -168,7 +168,7 @@ fn remove_nodes1() { let new = div(vec![], vec![]); //{
}, assert_eq!( - dbg!(diff(&old, &new)), + dbg!(diff(&old, &new).unwrap()), vec![Patch::clear_children(Some(&"div"), TreePath::new(vec![]),),], "Remove all child nodes at and after child sibling index 1", ); @@ -195,7 +195,7 @@ fn remove_nodes2() { let new: Node<()> = div(vec![], vec![span(vec![], vec![b(vec![], vec![])])]); assert_eq!( - dbg!(diff(&old, &new)), + dbg!(diff(&old, &new).unwrap()), vec![ Patch::remove_node(Some(&"i"), TreePath::new(vec![0, 1]),), Patch::remove_node(Some(&"strong"), TreePath::new(vec![1]),), @@ -218,7 +218,7 @@ fn remove_nodes3() { vec![b(vec![], vec![i(vec![], vec![])]), i(vec![], vec![])], ); //{
}, assert_eq!( - dbg!(diff(&old, &new)), + dbg!(diff(&old, &new).unwrap()), vec![ Patch::remove_node(Some(&"i"), TreePath::new(vec![0, 1]),), Patch::replace_node(Some(&"b"), TreePath::new(vec![1]), vec![&i(vec![], vec![])]), @@ -232,7 +232,7 @@ fn add_attributes() { let old: Node<()> = div(vec![], vec![]); //{
}, let new = div(vec![id("hello")], vec![]); //{
}, assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::add_attributes( &"div", TreePath::new(vec![]), @@ -245,7 +245,7 @@ fn add_attributes() { let new = div(vec![id("hello")], vec![]); //{
}, assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::add_attributes( &"div", TreePath::new(vec![]), @@ -260,7 +260,7 @@ fn add_style_attributes() { let old: Node<()> = div(vec![style!("display": "block")], vec![]); let new = div(vec![style!("display": "none")], vec![]); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::add_attributes( &"div", TreePath::new(vec![]), @@ -281,7 +281,7 @@ fn add_style_attributes_1_change() { vec![], ); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::add_attributes( &"div", TreePath::new(vec![]), @@ -307,7 +307,7 @@ fn add_style_attributes_no_changes() { vec![styles([("display", "block"), ("position", "absolute")])], vec![], ); - assert_eq!(diff(&old, &new), vec![],); + assert_eq!(diff(&old, &new).unwrap(), vec![],); } #[test] @@ -315,7 +315,7 @@ fn remove_style_attributes() { let old: Node<()> = div(vec![style!("display": "block")], vec![]); let new = div(vec![], vec![]); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::remove_attributes( &"div", TreePath::new(vec![]), @@ -331,7 +331,7 @@ fn remove_events_will_become_replace_node() { let old: Node<()> = div(vec![event1.clone()], vec![]); let new = div(vec![], vec![]); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::remove_attributes( &"div", TreePath::new(vec![]), @@ -367,7 +367,7 @@ fn text_changed_in_keyed_elements() { )], ); - let patch = diff(&old, &update1); + let patch = diff(&old, &update1).unwrap(); dbg!(&patch); assert_eq!( patch, @@ -401,7 +401,7 @@ fn multiple_style_calls() { ], vec![], ); - let patches = diff(&old, &new); + let patches = diff(&old, &new).unwrap(); println!("patches: {:#?}", patches); assert_eq!( patches, diff --git a/tests/html_right_next_text_siblings.rs b/tests/html_right_next_text_siblings.rs index f05b112d..c960e31e 100644 --- a/tests/html_right_next_text_siblings.rs +++ b/tests/html_right_next_text_siblings.rs @@ -11,7 +11,7 @@ fn comments_next_to_each_other() { ); let new: Node<()> = div(vec![], vec![comment("hello"), comment("world")]); - let patch = diff(&old, &new); + let patch = diff(&old, &new).unwrap(); println!("patch: {:#?}", patch); assert_eq!( patch, diff --git a/tests/html_skip_criteria_test.rs b/tests/html_skip_criteria_test.rs index 1879152e..b43a3b6f 100644 --- a/tests/html_skip_criteria_test.rs +++ b/tests/html_skip_criteria_test.rs @@ -7,7 +7,7 @@ fn must_skip_diff() { let old: Node<()> = div([skip_criteria("line1")], [text("old here")]); let new: Node<()> = div([skip_criteria("line1")], [text("new here")]); - let patch = diff(&old, &new); + let patch = diff(&old, &new).unwrap(); dbg!(&patch); assert_eq!(patch, vec![]); } @@ -17,7 +17,7 @@ fn must_skip_diff_2() { let old: Node<()> = div([skip_criteria(1000)], [text("Regardless of")]); let new: Node<()> = div([skip_criteria(1000)], [text("the difference here")]); - let patch = diff(&old, &new); + let patch = diff(&old, &new).unwrap(); dbg!(&patch); assert_eq!(patch, vec![]); } @@ -27,7 +27,7 @@ fn must_diff() { let old: Node<()> = div([skip_criteria(1000)], [text("Regardless of")]); let new: Node<()> = div([skip_criteria(1001)], [text("the difference here")]); - let patch = diff(&old, &new); + let patch = diff(&old, &new).unwrap(); dbg!(&patch); assert_eq!( patch, diff --git a/tests/html_style_change.rs b/tests/html_style_change.rs index ae442f5d..edee30b6 100644 --- a/tests/html_style_change.rs +++ b/tests/html_style_change.rs @@ -13,7 +13,7 @@ fn style_calcd_changed() { vec![], ); - let patches: Vec> = diff(&old, &new); + let patches: Vec> = diff(&old, &new).unwrap(); let styl = style! {width: format!("calc(50% + {}", px(200))}; let expected: Vec> = vec![Patch::add_attributes(&"div", TreePath::new([]), [&styl])]; @@ -36,7 +36,7 @@ fn style_calcd_changed_with_event() { vec![], ); - let patches: Vec> = diff(&old, &new); + let patches: Vec> = diff(&old, &new).unwrap(); let styl = style! {width: format!("calc(50% + {}", px(200))}; let expected: Vec> = vec![Patch::add_attributes(&"div", TreePath::new([]), [&styl])]; assert_eq!(expected, patches); @@ -91,7 +91,7 @@ fn app_editor_width_allocation_bug() { ], ); - let patches: Vec> = diff(&old, &new); + let patches: Vec> = diff(&old, &new).unwrap(); let styl_1 = style! {width: format!("calc(50% + {}", px(200))}; let styl_2 = style! {width: format!("calc(50% - {}", px(200))}; let expected: Vec> = vec![ diff --git a/tests/html_test.rs b/tests/html_test.rs index c51f286e..7230e2df 100644 --- a/tests/html_test.rs +++ b/tests/html_test.rs @@ -113,7 +113,7 @@ fn replace_node() { let old: Node<()> = div(vec![], vec![]); let new: Node<()> = span(vec![], vec![]); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::replace_node( Some(&"div"), TreePath::new(vec![]), @@ -125,7 +125,7 @@ fn replace_node() { let old: Node<()> = div(vec![], vec![b(vec![], vec![])]); let new: Node<()> = div(vec![], vec![strong(vec![], vec![])]); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::replace_node( Some(&"b"), TreePath::new(vec![0]), @@ -135,7 +135,7 @@ fn replace_node() { let old: Node<()> = div(vec![], vec![b(vec![], vec![text("1")]), b(vec![], vec![])]); let new: Node<()> = div(vec![], vec![i(vec![], vec![text("1")]), i(vec![], vec![])]); - let patch = diff(&old, &new); + let patch = diff(&old, &new).unwrap(); dbg!(&patch); @@ -163,7 +163,7 @@ fn add_children() { ], ); //{
}, assert_eq!( - dbg!(diff(&old, &new)), + dbg!(diff(&old, &new).unwrap()), vec![Patch::append_children( Some(&"div"), TreePath::new(vec![]), @@ -178,7 +178,7 @@ fn add_attributes() { let old: Node<()> = div(vec![], vec![]); let new = div(vec![id("hello")], vec![]); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::add_attributes( &"div", TreePath::new(vec![]), @@ -191,7 +191,7 @@ fn add_attributes() { let new = div(vec![id("hello")], vec![]); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::add_attributes( &"div", TreePath::new(vec![]), @@ -206,7 +206,7 @@ fn remove_attributes() { let old: Node<()> = div(vec![id("hey-there")], vec![]); let new = div(vec![], vec![]); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::remove_attributes( &"div", TreePath::new(vec![]), @@ -222,7 +222,7 @@ fn change_attribute() { let new = div(vec![id("changed")], vec![]); assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::add_attributes( &"div", TreePath::new(vec![]), @@ -238,7 +238,7 @@ fn replace_text_node() { let new = text("New"); //{ New }, assert_eq!( - diff(&old, &new), + diff(&old, &new).unwrap(), vec![Patch::replace_node( None, TreePath::new(vec![]), diff --git a/tests/vdom_class_test.rs b/tests/vdom_class_test.rs index 09df7641..c0a72c7d 100644 --- a/tests/vdom_class_test.rs +++ b/tests/vdom_class_test.rs @@ -14,7 +14,7 @@ fn class_changed() { vec![leaf("Content of class")], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -50,7 +50,7 @@ fn parent_of_matching_keyed_are_ignored() { ], ); - let patches = diff(&old, &new); + let patches = diff(&old, &new).unwrap(); assert_eq!( patches, diff --git a/tests/vdom_diff_keyed_test.rs b/tests/vdom_diff_keyed_test.rs index f869566e..7dba048f 100644 --- a/tests/vdom_diff_keyed_test.rs +++ b/tests/vdom_diff_keyed_test.rs @@ -14,7 +14,7 @@ fn keyed_no_changed() { vec![element("div", vec![attr("key", "1")], vec![])], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!(diff, vec![]); } @@ -35,7 +35,7 @@ fn key_1_removed_at_start() { vec![element("div", vec![attr("key", "2")], vec![])], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::remove_node(Some(&"div"), TreePath::new(vec![0]))] @@ -59,7 +59,7 @@ fn non_unique_keys_matched_at_old() { vec![element("div", vec![attr("key", "2")], vec![])], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::remove_node(Some(&"div"), TreePath::new(vec![1]))] @@ -83,7 +83,7 @@ fn key_2_removed_at_the_end() { vec![element("div", vec![attr("key", "1")], vec![])], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::remove_node(Some(&"div"), TreePath::new(vec![1]),)] @@ -111,7 +111,7 @@ fn key_2_removed_at_the_middle() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::remove_node(Some(&"div"), TreePath::new(vec![1]))] @@ -140,7 +140,7 @@ fn there_are_2_exact_same_keys_in_the_old() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -175,7 +175,7 @@ fn there_are_2_exact_same_keys_in_the_new() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -215,7 +215,7 @@ fn there_are_2_exact_same_keys_in_both_old_and_new() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -251,7 +251,7 @@ fn key_2_inserted_at_start() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( @@ -278,7 +278,7 @@ fn keyed_element_not_reused() { vec![element("div", vec![attr("key", "2")], vec![])], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( @@ -309,7 +309,7 @@ fn key_2_inserted_at_the_end() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -349,7 +349,7 @@ fn test_append_at_sub_level() { )], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff, @@ -385,7 +385,7 @@ fn key_2_inserted_in_the_middle() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -420,7 +420,7 @@ fn key1_removed_at_start_then_key2_has_additional_attributes() { )], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); // we add attrubutes at node index 2, and this will become a node index 1 assert_eq!( @@ -465,7 +465,7 @@ fn deep_nested_key1_removed_at_start_then_key2_has_additional_attributes() { )], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff, @@ -510,7 +510,7 @@ fn deep_nested_more_children_key0_and_key1_removed_at_start_then_key2_has_additi )], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff, @@ -570,7 +570,7 @@ fn deep_nested_keyed_with_non_keyed_children() { )], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff, @@ -630,7 +630,7 @@ fn text_changed_in_keyed_elements() { )], ); - let patch = diff(&old, &update1); + let patch = diff(&old, &update1).unwrap(); dbg!(&patch); assert_eq!( @@ -686,7 +686,7 @@ fn text_changed_in_mixed_keyed_and_non_keyed_elements() { ], ); - let patch = diff(&old, &update1); + let patch = diff(&old, &update1).unwrap(); dbg!(&patch); assert_eq!( patch, @@ -745,7 +745,7 @@ fn test12() { ], ); - let patch = diff(&old, &update1); + let patch = diff(&old, &update1).unwrap(); dbg!(&patch); assert_eq!( patch, @@ -782,7 +782,7 @@ fn remove_first() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff, diff --git a/tests/vdom_diff_mixed.rs b/tests/vdom_diff_mixed.rs index 526bd53f..4b00346a 100644 --- a/tests/vdom_diff_mixed.rs +++ b/tests/vdom_diff_mixed.rs @@ -23,7 +23,7 @@ fn mixed_key_and_no_key_with_no_change() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!(diff, vec![]); } @@ -52,7 +52,7 @@ fn mixed_key_and_no_key_with_2_matched() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff, @@ -87,7 +87,7 @@ fn mixed_key_and_no_key_with_misordered_2_matched() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff --git a/tests/vdom_diff_node_list.rs b/tests/vdom_diff_node_list.rs index c633e731..78c10db3 100644 --- a/tests/vdom_diff_node_list.rs +++ b/tests/vdom_diff_node_list.rs @@ -31,7 +31,7 @@ fn test_node_list() { println!("old: {:#?}", old); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::remove_node(Some(&"li"), TreePath::new(vec![2]),)], diff --git a/tests/vdom_diff_skip_and_replace.rs b/tests/vdom_diff_skip_and_replace.rs index 30ba51c8..a6fa7bfc 100644 --- a/tests/vdom_diff_skip_and_replace.rs +++ b/tests/vdom_diff_skip_and_replace.rs @@ -10,7 +10,7 @@ fn force_replace() { vec![], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::replace_node( @@ -30,7 +30,7 @@ fn force_skip() { vec![], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!(diff, vec![],); } @@ -43,7 +43,7 @@ fn skip_in_attribute() { vec![], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!(diff, vec![],); } @@ -56,7 +56,7 @@ fn replace_true_in_attribute_must_replace_old_node_regardless() { vec![], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::replace_node( @@ -165,7 +165,7 @@ fn replace_and_skip_in_sub_nodes() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::replace_node( diff --git a/tests/vdom_diff_tests.rs b/tests/vdom_diff_tests.rs index dda156b0..7addcafe 100644 --- a/tests/vdom_diff_tests.rs +++ b/tests/vdom_diff_tests.rs @@ -6,7 +6,7 @@ fn test_replace_node() { let old: Node<()> = element("div", vec![], vec![]); let new = element("span", vec![], vec![]); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::replace_node( @@ -22,7 +22,7 @@ fn test_replace_text_node() { let old: Node<()> = leaf("hello"); let new = element("span", vec![], vec![]); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::replace_node(None, TreePath::new(vec![]), vec![&new])], @@ -34,7 +34,7 @@ fn test_replace_node_in_child() { let old: Node<()> = element("main", vec![], vec![element("div", vec![], vec![])]); let new = element("main", vec![], vec![element("span", vec![], vec![])]); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::replace_node( @@ -71,7 +71,7 @@ fn test_205() { ], ); //{
}, assert_eq!( - dbg!(diff(&old, &new)), + dbg!(diff(&old, &new).unwrap()), vec![ Patch::remove_node(Some(&"i"), TreePath::new(vec![0, 1]),), Patch::replace_node( @@ -97,7 +97,7 @@ fn test_no_changed() { vec![], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!(diff, vec![]) } @@ -115,7 +115,7 @@ fn test_attribute_order_changed() { vec![], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!(diff, vec![]) } @@ -133,7 +133,7 @@ fn test_class_changed() { vec![], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::add_attributes( @@ -158,7 +158,7 @@ fn leaf_node_changed() { vec![leaf("text2")], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff, @@ -180,7 +180,7 @@ fn test_class_will_not_be_merged_on_different_calls() { vec![], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_ne!( diff, vec![Patch::add_attributes( @@ -205,7 +205,7 @@ fn test_class_removed() { let new = element("div", vec![attr("id", "some-id")], vec![]); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::remove_attributes( @@ -236,7 +236,7 @@ fn test_multiple_calls_to_style() { vec![], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::add_attributes( @@ -256,7 +256,7 @@ fn inner_html_func_calls() { let new: Node<()> = element("div", vec![attr("inner_html", "

Hello

")], vec![]); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::add_attributes( @@ -284,7 +284,7 @@ fn test_append() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::append_children( @@ -313,7 +313,7 @@ fn test_append_more() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::append_children( @@ -353,7 +353,7 @@ fn test_append_at_sub_level() { )], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff, diff --git a/tests/vdom_fragment_test.rs b/tests/vdom_fragment_test.rs index 49f399cc..81fc7d6a 100644 --- a/tests/vdom_fragment_test.rs +++ b/tests/vdom_fragment_test.rs @@ -27,7 +27,7 @@ fn using_fragments() { element("div", vec![attr("key", "9")], vec![leaf("line9")]), ]); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::insert_before_node( diff --git a/tests/vdom_insert_patches.rs b/tests/vdom_insert_patches.rs index f9923001..b6e546aa 100644 --- a/tests/vdom_insert_patches.rs +++ b/tests/vdom_insert_patches.rs @@ -21,7 +21,7 @@ fn insert_on_deep_level_keyed() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -70,7 +70,7 @@ fn insert_on_deep_multi_level_level_keyed() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -119,7 +119,7 @@ fn insert_on_deep_multi_level_keyed_non_keyed_keyed() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -154,7 +154,7 @@ fn insert_on_deep_level_non_keyed_container() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); diff --git a/tests/vdom_massive_keyed.rs b/tests/vdom_massive_keyed.rs index 836ff102..d097e8d3 100644 --- a/tests/vdom_massive_keyed.rs +++ b/tests/vdom_massive_keyed.rs @@ -35,7 +35,7 @@ fn key_inserted_at_start() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); assert_eq!( diff, vec![Patch::insert_before_node( @@ -85,7 +85,7 @@ fn key_inserted_at_middle() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( @@ -145,7 +145,7 @@ fn wrapped_elements() { )], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff, @@ -203,7 +203,7 @@ fn text_changed() { )], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff, @@ -257,7 +257,7 @@ fn text_changed_non_keyed() { )], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( @@ -350,7 +350,7 @@ fn insert_one_line_at_start() { )], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff, @@ -462,7 +462,7 @@ fn insert_two_lines_at_start() { )], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff --git a/tests/vdom_rearranged_keyed_nodes.rs b/tests/vdom_rearranged_keyed_nodes.rs index 0ae0bc4d..24fc70f6 100644 --- a/tests/vdom_rearranged_keyed_nodes.rs +++ b/tests/vdom_rearranged_keyed_nodes.rs @@ -22,7 +22,7 @@ fn text_changed_keyed() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); assert_eq!( diff --git a/tests/vdom_replace_node_patches.rs b/tests/vdom_replace_node_patches.rs index 2800221e..2974188e 100644 --- a/tests/vdom_replace_node_patches.rs +++ b/tests/vdom_replace_node_patches.rs @@ -31,7 +31,7 @@ fn test_multiple_replace() { )], ); - let patches = diff(&old, &update1); + let patches = diff(&old, &update1).unwrap(); dbg!(&patches); diff --git a/tests/vdom_swap_rows.rs b/tests/vdom_swap_rows.rs index 3479cfbb..11df09df 100644 --- a/tests/vdom_swap_rows.rs +++ b/tests/vdom_swap_rows.rs @@ -29,7 +29,7 @@ fn swap_999() { }), ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -68,7 +68,7 @@ fn swap_rows_non_keyed() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -117,7 +117,7 @@ fn move_key_2_to_after_node_index_6() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -165,7 +165,7 @@ fn move_key_7_to_before_node_index_1() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -213,7 +213,7 @@ fn swap_rows_keyed() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -254,7 +254,7 @@ fn swap_rows_keyed_6_items() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); @@ -293,7 +293,7 @@ fn swap_rows_keyed_5_items() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); diff --git a/tests/vdom_test_diff_lis.rs b/tests/vdom_test_diff_lis.rs index a63aa643..e1c1a2d9 100644 --- a/tests/vdom_test_diff_lis.rs +++ b/tests/vdom_test_diff_lis.rs @@ -40,7 +40,7 @@ fn key_lis_1_to_9() { ], ); - let diff = diff(&old, &new); + let diff = diff(&old, &new).unwrap(); dbg!(&diff); From 2dc6a0eca6d7b8dc4bc738e082a4b64c35e349cd Mon Sep 17 00:00:00 2001 From: Joachim Schiele Date: Mon, 27 Jan 2025 14:38:07 +0000 Subject: [PATCH 5/7] my workdir with nix flake --- examples/patch_dom_node/src/main.rs | 335 +++++++++++++++++++++++++++- flake.lock | 91 ++++++++ flake.nix | 52 +++++ 3 files changed, 467 insertions(+), 11 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/examples/patch_dom_node/src/main.rs b/examples/patch_dom_node/src/main.rs index 6e116356..223f6564 100644 --- a/examples/patch_dom_node/src/main.rs +++ b/examples/patch_dom_node/src/main.rs @@ -5,7 +5,7 @@ use sauron_core::{ prelude::Node, vdom, }; -use sauron_html_parser::parse_html; +use sauron_html_parser::{parse_html, raw_html}; fn main() { _ = console_log::init_with_level(log::Level::Debug); @@ -17,22 +17,335 @@ fn main() { let body_node = DomNode::from(web_sys::Node::from(dom::util::body())); let mount_node = Rc::new(RefCell::new(Some(body_node))); - let new_html = r#"
-
- Hello world! If you can see this text on the webpage then the DOM patching was executed! -
-
- This is footer1 -
-
"#; + let new_html = r#"
+ + +

+ [[!meta date="2024-07-19 14:33"]] [[!tag nix nixos libnix fixPath]] + [[!series libnix]] [[!summary libnix roadmap]] +

+

+ [[!img media/nlnet-logo.gif class="noFancy" style="float: right"]] [[!img + posts/libnix/Nix_snowflake_windows.svg class="noFancy" style="float: + right" width="200px"]] +

+

+ motivation121111s1111111111111123412112111132 +

+

+ status of native windows nix using MinGW from my series + libnix +

+

we also cover these topics:

+
    +
  • libnix: why we picked MinGW vs. other solutions
  • +
  • general roadmap
  • +
+

+ libnix: MinGW vs. other solutions +

+

+ making nix work native on windows there are a few + options, here are a few updates reaching out to these communities: +

+

Tvix

+

+ tvix is a rust reimplementation of the c++ + nix implementation, recent news: +

+
    +
  • + store implementation since + last update +
  • +
  • + nix evaluation comes close to upstream c++ nix, + however, still effort to get to 100% +
  • +
  • not all builtins are supported yet
  • +
  • no builders yet
  • +
  • + could be used to + replace the tour of nix emscripten based backend but + not much more +
  • +
+ +

cosmopolitan

+

+ cosmopolitan developers on + discord mentioned to me that they had tried porting nix with cosmopolitan: +

+
+

+ ariel nunez: Bash on windows was only possible last year, after a lot of + work by jart and contributors, and now Windows Terminal Preview can use + it. I read my logs and last attempt to compile Nix was on August 2023, + at that point in time we found out Nix used Boost and that was a blocker + at the time. +

+
+ +

MinGW

+

+ MinGW cross compiler + setup: +

+
    +
  • + using mingw cross compiler from nixos-wsl to build nix for + windows +
  • +
  • + john ericson’s MinGW contributions are ongoing and promising ~early 2024 +
  • +
+ +

libnix: general roadmap

+

+ here is a list of things which need to be done still, see + https://github.com/NixOS/nix/labels/windows + for detailed tickets. +

+

1. meson build system

+
    +
  • + in order to build nix on windows natively, we need a build system which + is not tied to bash. therefore meson is a good candidate for this and + there have been a couple of patches already. +
  • +
+

+ 2. create test suite for nix on windows +

+ +

+ 3. assemble prototype windows bootstrap system +

+
    +
  • + make nix evaluate on windows use the store on + c:\ and +
  • +
  • + get runProgram working to execute tools like + git for fetchUrl +
  • +
  • use third-party built tools from MSYS2 (not built by nix)
  • +
+

+ 4. build ‘hello world’ nixpkgs-win +

+
    +
  • +

    minimal nixpkgs like abstraction

    +
      +
    • + instead of trying to adapt nixpkgs we should start small with our + own stdenv with mingw to show how to use + it +
    • +
    +
  • +
+

+ 5. make nix + toolchain build from windows +

+
    +
  • use the prototype toolchain to built itself
  • +
  • + adapt bash and unix favoring build systems into a windows + world +
  • +
+

6. nix installer / channel

+ +

7. cargo with nix support

+ +

libnix: future nix work

+

+ these items need to be done outside of the + libnix funding but are + still worth mentioning. +

+

1. sandboxing

+ +

+ 2. user environments (pure powershell environment) +

+
    +
  • + source $HOME/.nix-profile/etc/profile.d/nix.sh for + powershell +
  • +
+

3. nix-daemon & multi user mode

+
    +
  • +

    nix-daemon

    +
      +
    • calls nix-build (with different UID/GID)
    • +
    • + windows unix domain socket support can be used +
    • +
    +
  • +
+

+ 4. nixos module system systemd like windows abstraction +

+
    +
  • + the nixos module system creates systemd targets on linux + and it would be nice if we had something similar for windows, see + systemd equivalent on windows +
  • +
+

5. store interoperability

+ +

6. usability & documentation

+
    +
  • support nix repl
  • +
  • support man pages in nix build --help
  • +
  • +
+

summary

+

+ this is a + short summary of libnix topics what we are aiming for till the end of + 2024. +

+

+ additional we think that llvm-mingw is a potent toolchain + for windows which enables us to use + fixPath. +

+ +
"#; + log::info!("Example1"); let old_node: Node<()> = parse_html::<()>("").unwrap().unwrap(); - let new_node: Node<()> = parse_html::<()>(new_html).unwrap().unwrap(); + log::info!("Example2"); + + let new_node: Node<()> = raw_html::<()>(new_html); + log::info!("Example3"); let root = dom::create_dom_node(&old_node, ev_callback); + log::info!("Example4"); + let root_node = Rc::new(RefCell::new(Some(root))); + log::info!("Example5"); - let vdom_patches = vdom::diff(&old_node, &new_node); + let vdom_patches = vdom::diff(&old_node, &new_node).unwrap(); log::debug!("Created {} VDOM patch(es)", vdom_patches.len()); log::debug!("Created {:?}", vdom_patches); diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..5d51ed6f --- /dev/null +++ b/flake.lock @@ -0,0 +1,91 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 0, + "narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=", + "path": "/nix/store/b309kyd5hrvrrf5z5xbqglmb1hhm8n6p-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1736320768, + "narHash": "sha256-nIYdTAiKIGnFNugbomgBJR+Xv5F1ZQU+HfaBqJKroC0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4bc9c909d9ac828a039f288cf872d16d38185db8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1737685583, + "narHash": "sha256-p+NVABRpGi+pT+xxf9HcLcFVxG6L+vEEy+NwzB9T0f8=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "eb64cbcc8eee0fa87ebded92805280d2ec97415a", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..43efe140 --- /dev/null +++ b/flake.nix @@ -0,0 +1,52 @@ +# please read flake introduction here: +# https://fasterthanli.me/series/building-a-rust-service-with-nix/part-10#a-flake-with-a-dev-shell +{ + description = "The fairsync importer prototype flake"; + inputs = { + rust-overlay.url = "github:oxalica/rust-overlay"; + }; + outputs = + { self, nixpkgs, flake-utils, rust-overlay }: + flake-utils.lib.eachDefaultSystem + (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + platform_packages = + if pkgs.stdenv.isLinux then + with pkgs; [ ] + else if pkgs.stdenv.isDarwin then + with pkgs.darwin.apple_sdk.frameworks; [ + CoreFoundation + Security + SystemConfiguration + ] + else + throw "unsupported platform"; + in + with pkgs; + rec { + #trunk = pkgs.callPackage ./trunk.nix { + # inherit (darwin.apple_sdk.frameworks) CoreServices Security SystemConfiguration; + #}; + #leptosfmt = pkgs.callPackage ./leptosfmt.nix {}; + + devShells.default = mkShell { + buildInputs = [ + rust + wasm-pack + firefox + #trunk # required to bundle the frontend + binaryen # required to minify WASM files with wasm-opt + git + pkg-config + just # task runner + #nodejs # required to install tailwind plugins + ]; + }; + } + ); +} From 012c24abacb5bb6bdd2c11693a37657ed71bad97 Mon Sep 17 00:00:00 2001 From: Joachim Schiele Date: Mon, 3 Mar 2025 09:53:06 +0000 Subject: [PATCH 6/7] style: supports style="" attributes in the parser --- .../src/html/attributes/attribute_macros.rs | 1 + crates/html-parser/src/lib.rs | 20 +++++++++++++++++-- tests/dom_insert_before_after_patches.rs | 1 - tests/dom_vdom_standalone.rs | 20 +++++++++++-------- tests/html_parser_test.rs | 10 ++++++++++ 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/crates/core/src/html/attributes/attribute_macros.rs b/crates/core/src/html/attributes/attribute_macros.rs index 2777fad9..23594df0 100644 --- a/crates/core/src/html/attributes/attribute_macros.rs +++ b/crates/core/src/html/attributes/attribute_macros.rs @@ -213,6 +213,7 @@ pub mod commons { srcset; start; step; + style; tabindex; target; title; diff --git a/crates/html-parser/src/lib.rs b/crates/html-parser/src/lib.rs index 431a0af3..e5be99b6 100644 --- a/crates/html-parser/src/lib.rs +++ b/crates/html-parser/src/lib.rs @@ -90,7 +90,24 @@ fn process_node(node: &rphtml::parser::Node) -> Result>, P if let Some(attr_key) = lookup::match_attribute(&key) { let value = if let Some(value) = &attr.value { let value = String::from_iter(value.content.iter()); - AttributeValue::Simple(Value::from(value)) + if key == "style" { + let raw_tokens: Vec = value.split(';').map(|s| s.trim().to_string()).collect(); + let tokens: Vec