make anyprops and vprops private again

This commit is contained in:
Evan Almloff 2024-01-25 09:32:36 -06:00
parent 53380c9956
commit c3edf99b63
5 changed files with 13 additions and 19 deletions

View file

@ -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

View file

@ -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

View file

@ -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},

View file

@ -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 {

View file

@ -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> {