mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 12:43:08 +00:00
chore: clean things up
This commit is contained in:
parent
584504feb7
commit
5d91f51e17
9 changed files with 30 additions and 48 deletions
|
@ -1,11 +1,9 @@
|
|||
use std::cell::Cell;
|
||||
|
||||
use futures_util::Future;
|
||||
|
||||
use crate::{
|
||||
component::{Component, ComponentFn, Dummy, IntoComponent},
|
||||
element::Element,
|
||||
scopes::{Scope, ScopeState},
|
||||
Element,
|
||||
};
|
||||
|
||||
pub trait AnyProps {
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
use std::num::NonZeroUsize;
|
||||
|
||||
use crate::{
|
||||
nodes::{Template, VNode},
|
||||
virtualdom::VirtualDom,
|
||||
};
|
||||
use crate::{nodes::VNode, virtualdom::VirtualDom};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
pub struct ElementId(pub usize);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use futures_util::Future;
|
||||
|
||||
use crate::{element::Element, scopes::Scope};
|
||||
use crate::{scopes::Scope, Element};
|
||||
|
||||
pub type Component<T = ()> = fn(Scope<T>) -> Element;
|
||||
|
||||
|
@ -38,7 +38,7 @@ impl Future for Dummy {
|
|||
|
||||
fn poll(
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
_cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<Self::Output> {
|
||||
unreachable!()
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
use crate::nodes::{Template, VNode};
|
||||
|
||||
pub type Element<'a> = Option<VNode<'a>>;
|
|
@ -1,6 +1,5 @@
|
|||
use std::{any::Any, cell::Cell};
|
||||
|
||||
use crate::{arena::ElementId, scopes::ScopeId, virtualdom::VirtualDom, Attribute, AttributeValue};
|
||||
use crate::{arena::ElementId, virtualdom::VirtualDom, Attribute, AttributeValue};
|
||||
use std::cell::Cell;
|
||||
|
||||
/// User Events are events that are shuttled from the renderer into the [`VirtualDom`] through the scheduler channel.
|
||||
///
|
||||
|
@ -122,9 +121,12 @@ impl VirtualDom {
|
|||
.dynamic_attrs
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(idx, attr)| is_path_ascendant(parent.template.node_paths[*idx], path))
|
||||
.filter(|(idx, attr)| attr.name == event.name)
|
||||
.map(|(_, attr)| attr),
|
||||
.filter_map(|(idx, attr)| {
|
||||
match is_path_ascendant(parent.template.node_paths[idx], path) {
|
||||
true if attr.name == event.name => Some(attr),
|
||||
_ => None,
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
index = parent.parent;
|
||||
|
|
|
@ -4,7 +4,6 @@ mod bump_frame;
|
|||
mod component;
|
||||
mod create;
|
||||
mod diff;
|
||||
mod element;
|
||||
mod events;
|
||||
mod factory;
|
||||
mod future_container;
|
||||
|
@ -18,7 +17,7 @@ mod scopes;
|
|||
mod virtualdom;
|
||||
|
||||
pub(crate) mod innerlude {
|
||||
pub use crate::element::Element;
|
||||
pub use crate::arena::*;
|
||||
pub use crate::events::*;
|
||||
pub use crate::future_container::*;
|
||||
pub use crate::lazynodes::*;
|
||||
|
@ -28,10 +27,10 @@ pub(crate) mod innerlude {
|
|||
pub use crate::scopes::*;
|
||||
pub use crate::virtualdom::*;
|
||||
|
||||
// /// An [`Element`] is a possibly-none [`VNode`] created by calling `render` on [`Scope`] or [`ScopeState`].
|
||||
// ///
|
||||
// /// Any [`None`] [`Element`] will automatically be coerced into a placeholder [`VNode`] with the [`VNode::Placeholder`] variant.
|
||||
// pub type Element<'a> = Option<VNodea<'a>>;
|
||||
/// An [`Element`] is a possibly-none [`VNode`] created by calling `render` on [`Scope`] or [`ScopeState`].
|
||||
///
|
||||
/// Any [`None`] [`Element`] will automatically be coerced into a placeholder [`VNode`] with the [`VNode::Placeholder`] variant.
|
||||
pub type Element<'a> = Option<VNode<'a>>;
|
||||
|
||||
/// A [`Component`] is a function that takes a [`Scope`] and returns an [`Element`].
|
||||
///
|
||||
|
@ -67,12 +66,16 @@ pub(crate) mod innerlude {
|
|||
}
|
||||
|
||||
pub use crate::innerlude::{
|
||||
// AnyAttributeValue, AnyEvent,
|
||||
fc_to_builder,
|
||||
// AnyAttributeValue, AnyEvent, Attribute, AttributeValue, Component, Element, ElementId,
|
||||
Attribute,
|
||||
AttributeValue,
|
||||
Attributes,
|
||||
Component,
|
||||
DynamicNode,
|
||||
Element,
|
||||
ElementId,
|
||||
ElementPath,
|
||||
EventPriority,
|
||||
LazyNodes,
|
||||
NodeFactory,
|
||||
|
@ -88,9 +91,6 @@ pub use crate::innerlude::{
|
|||
VNode,
|
||||
VirtualDom,
|
||||
};
|
||||
// EventHandler, EventPriority, IntoVNode, LazyNodes, Listener, NodeFactory, Properties, Renderer,
|
||||
// SchedulerMsg, Scope, ScopeId, ScopeState, TaskId, Template, TemplateAttribute, TemplateNode,
|
||||
// UiEvent, UserEvent, VComponent, VElement, VNode, VTemplate, VText, VirtualDom,
|
||||
|
||||
/// The purpose of this module is to alleviate imports of many common types
|
||||
///
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::any_props::VComponentProps;
|
||||
use crate::arena::ElementPath;
|
||||
use crate::component::{Component, IntoComponent};
|
||||
use crate::component::Component;
|
||||
use crate::diff::DirtyScope;
|
||||
use crate::future_container::FutureQueue;
|
||||
use crate::innerlude::SchedulerMsg;
|
||||
|
|
|
@ -13,16 +13,12 @@
|
|||
|
||||
#[macro_use]
|
||||
mod errors;
|
||||
// #[cfg(any(feature = "hot-reload", debug_assertions))]
|
||||
// mod attributes;
|
||||
mod component;
|
||||
mod element;
|
||||
mod ifmt;
|
||||
mod node;
|
||||
mod template;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
// Re-export the namespaces into each other
|
||||
pub use component::*;
|
||||
pub use element::*;
|
||||
|
@ -108,6 +104,7 @@ impl<'a> ToTokens for TemplateRenderer<'a> {
|
|||
Some(BodyNode::Component(comp)) if self.roots.len() == 1 => comp.key().cloned(),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let key_tokens = match key {
|
||||
Some(tok) => quote! { Some( __cx.raw_text_inline(#tok) ) },
|
||||
None => quote! { None },
|
||||
|
@ -124,15 +121,8 @@ impl<'a> ToTokens for TemplateRenderer<'a> {
|
|||
let roots = quote! { #( #root_printer ),* };
|
||||
let node_printer = &context.dynamic_nodes;
|
||||
let dyn_attr_printer = &context.dynamic_attributes;
|
||||
let node_paths = context
|
||||
.node_paths
|
||||
.iter()
|
||||
.map(|items| quote!(&[#(#items),*]));
|
||||
|
||||
let attr_paths = context
|
||||
.attr_paths
|
||||
.iter()
|
||||
.map(|items| quote!(&[#(#items),*]));
|
||||
let node_paths = context.node_paths.iter().map(|it| quote!(&[#(#it),*]));
|
||||
let attr_paths = context.attr_paths.iter().map(|it| quote!(&[#(#it),*]));
|
||||
|
||||
out_tokens.append_all(quote! {
|
||||
static TEMPLATE: ::dioxus::core::Template = ::dioxus::core::Template {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use proc_macro2::TokenStream;
|
||||
use quote::TokenStreamExt;
|
||||
use quote::{quote, ToTokens};
|
||||
use syn::{Expr, Ident, LitStr};
|
||||
// use proc_macro2::TokenStream;
|
||||
// use quote::TokenStreamExt;
|
||||
// use quote::{quote, ToTokens};
|
||||
// use syn::{Expr, Ident, LitStr};
|
||||
|
||||
// #[cfg(any(feature = "hot-reload", debug_assertions))]
|
||||
// pub fn try_parse_template(
|
||||
|
|
Loading…
Reference in a new issue