1
0
Эх сурвалжийг харах

make anyprops and vprops private again

Evan Almloff 1 жил өмнө
parent
commit
c3edf99b63

+ 2 - 7
packages/core/src/any_props.rs

@@ -4,7 +4,7 @@ use std::{any::Any, panic::AssertUnwindSafe};
 pub(crate) type BoxedAnyProps = Box<dyn AnyProps>;
 
 /// 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<F: ComponentFunction<P, M>, P, M> {
+pub(crate) struct VProps<F: ComponentFunction<P, M>, P, M> {
     render_fn: F,
     memo: fn(&P, &P) -> bool,
     props: P,
@@ -52,11 +52,6 @@ impl<F: ComponentFunction<P, M> + 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<F: ComponentFunction<P, M> + Clone, P: Clone + 'static, M: 'static> AnyProps

+ 6 - 6
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

+ 2 - 1
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},

+ 3 - 3
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 {

+ 0 - 2
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<Cfg: 'static = (), ContextFn: ?Sized = ValidContext> {