From c3edf99b6367f6b21989ed9c453790be74a1ff76 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 25 Jan 2024 09:32:36 -0600 Subject: [PATCH] make anyprops and vprops private again --- packages/core/src/any_props.rs | 9 ++------- packages/core/src/lib.rs | 12 ++++++------ packages/core/src/nodes.rs | 3 ++- packages/core/src/virtual_dom.rs | 6 +++--- packages/dioxus/src/launch.rs | 2 -- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/packages/core/src/any_props.rs b/packages/core/src/any_props.rs index 9f8f9b45e..e5cf42694 100644 --- a/packages/core/src/any_props.rs +++ b/packages/core/src/any_props.rs @@ -4,7 +4,7 @@ use std::{any::Any, panic::AssertUnwindSafe}; pub(crate) type BoxedAnyProps = Box; /// A trait for a component that can be rendered. -pub trait AnyProps: 'static { +pub(crate) trait AnyProps: 'static { /// Render the component with the internal props. fn render(&self) -> RenderReturn; /// Check if the props are the same as the type erased props of another component. @@ -16,7 +16,7 @@ pub trait AnyProps: 'static { } /// A component along with the props the component uses to render. -pub struct VProps, P, M> { +pub(crate) struct VProps, P, M> { render_fn: F, memo: fn(&P, &P) -> bool, props: P, @@ -52,11 +52,6 @@ impl + Clone, P: Clone + 'static, M: 'static> VProps< phantom: std::marker::PhantomData, } } - - /// Get the current props of the VProps object - pub fn props(&self) -> &P { - &self.props - } } impl + Clone, P: Clone + 'static, M: 'static> AnyProps diff --git a/packages/core/src/lib.rs b/packages/core/src/lib.rs index 5a2075f1a..3b3689f3e 100644 --- a/packages/core/src/lib.rs +++ b/packages/core/src/lib.rs @@ -22,7 +22,7 @@ mod tasks; mod virtual_dom; pub(crate) mod innerlude { - pub use crate::any_props::*; + pub(crate) use crate::any_props::*; pub use crate::arena::*; pub use crate::dirty_scope::*; pub use crate::error_boundary::*; @@ -74,11 +74,11 @@ pub(crate) mod innerlude { pub use crate::innerlude::{ fc_to_builder, generation, schedule_update, schedule_update_any, use_hook, vdom_is_rendering, - AnyProps, AnyValue, Attribute, AttributeValue, CapturedError, Component, ComponentFunction, - DynamicNode, Element, ElementId, Event, Fragment, HasAttributes, IntoDynNode, Mutation, - Mutations, NoOpMutations, Properties, RenderReturn, Runtime, ScopeId, ScopeState, Task, - Template, TemplateAttribute, TemplateNode, VComponent, VNode, VNodeInner, VPlaceholder, VProps, - VText, VirtualDom, WriteMutations, + AnyValue, Attribute, AttributeValue, CapturedError, Component, ComponentFunction, DynamicNode, + Element, ElementId, Event, Fragment, HasAttributes, IntoDynNode, Mutation, Mutations, + NoOpMutations, Properties, RenderReturn, Runtime, ScopeId, ScopeState, Task, Template, + TemplateAttribute, TemplateNode, VComponent, VNode, VNodeInner, VPlaceholder, VText, + VirtualDom, WriteMutations, }; /// The purpose of this module is to alleviate imports of many common types diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index 2cb1a0a4b..c5f80a326 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -1,4 +1,5 @@ -use crate::{any_props::BoxedAnyProps, innerlude::ScopeState, VProps}; +use crate::innerlude::VProps; +use crate::{any_props::BoxedAnyProps, innerlude::ScopeState}; use crate::{arena::ElementId, Element, Event}; use crate::{ innerlude::{ElementRef, EventHandler, MountId}, diff --git a/packages/core/src/virtual_dom.rs b/packages/core/src/virtual_dom.rs index abfaf3e7f..daa844097 100644 --- a/packages/core/src/virtual_dom.rs +++ b/packages/core/src/virtual_dom.rs @@ -7,13 +7,13 @@ use crate::{ arena::ElementId, innerlude::{ DirtyScope, ElementRef, ErrorBoundary, NoOpMutations, SchedulerMsg, ScopeState, VNodeMount, - WriteMutations, + VProps, WriteMutations, }, nodes::RenderReturn, nodes::{Template, TemplateId}, runtime::{Runtime, RuntimeGuard}, scopes::ScopeId, - AttributeValue, ComponentFunction, Element, Event, Mutations, Task, VProps, + AttributeValue, ComponentFunction, Element, Event, Mutations, Task, }; use futures_util::{pin_mut, StreamExt}; use rustc_hash::{FxHashMap, FxHashSet}; @@ -303,7 +303,7 @@ impl VirtualDom { /// let mut dom = VirtualDom::new_from_root(VComponent::new(Example, SomeProps { name: "jane" }, "Example")); /// let mutations = dom.rebuild(); /// ``` - pub fn new_with_component(root: impl AnyProps + 'static) -> Self { + pub(crate) fn new_with_component(root: impl AnyProps + 'static) -> Self { let (tx, rx) = futures_channel::mpsc::unbounded(); let mut dom = Self { diff --git a/packages/dioxus/src/launch.rs b/packages/dioxus/src/launch.rs index 097bca778..b3f276658 100644 --- a/packages/dioxus/src/launch.rs +++ b/packages/dioxus/src/launch.rs @@ -4,8 +4,6 @@ use std::any::Any; use crate::prelude::*; -use dioxus_core::AnyProps; -use dioxus_core::VProps; /// A builder for a fullstack app. pub struct LaunchBuilder {