mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-20 15:48:27 +00:00
wip: move more stuff out
This commit is contained in:
parent
e4cda7c2cb
commit
464b457b80
4 changed files with 3 additions and 22 deletions
|
@ -16,7 +16,6 @@ pub(crate) mod component;
|
||||||
pub(crate) mod diff;
|
pub(crate) mod diff;
|
||||||
pub(crate) mod diff_stack;
|
pub(crate) mod diff_stack;
|
||||||
pub(crate) mod hooklist;
|
pub(crate) mod hooklist;
|
||||||
pub(crate) mod hooks;
|
|
||||||
pub(crate) mod lazynodes;
|
pub(crate) mod lazynodes;
|
||||||
pub(crate) mod mutations;
|
pub(crate) mod mutations;
|
||||||
pub(crate) mod nodes;
|
pub(crate) mod nodes;
|
||||||
|
@ -26,15 +25,11 @@ pub(crate) mod test_dom;
|
||||||
pub(crate) mod util;
|
pub(crate) mod util;
|
||||||
pub(crate) mod virtual_dom;
|
pub(crate) mod virtual_dom;
|
||||||
|
|
||||||
#[cfg(feature = "debug_vdom")]
|
|
||||||
pub mod debug_dom;
|
|
||||||
|
|
||||||
pub(crate) mod innerlude {
|
pub(crate) mod innerlude {
|
||||||
pub use crate::component::*;
|
pub use crate::component::*;
|
||||||
pub(crate) use crate::diff::*;
|
pub(crate) use crate::diff::*;
|
||||||
pub use crate::diff_stack::*;
|
pub use crate::diff_stack::*;
|
||||||
pub(crate) use crate::hooklist::*;
|
pub(crate) use crate::hooklist::*;
|
||||||
pub use crate::hooks::*;
|
|
||||||
pub use crate::lazynodes::*;
|
pub use crate::lazynodes::*;
|
||||||
pub use crate::mutations::*;
|
pub use crate::mutations::*;
|
||||||
pub use crate::nodes::*;
|
pub use crate::nodes::*;
|
||||||
|
@ -56,7 +51,6 @@ pub use crate::innerlude::{
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::component::{fc_to_builder, Fragment, Properties, Scope};
|
pub use crate::component::{fc_to_builder, Fragment, Properties, Scope};
|
||||||
pub use crate::hooks::*;
|
|
||||||
pub use crate::innerlude::Context;
|
pub use crate::innerlude::Context;
|
||||||
pub use crate::innerlude::{DioxusElement, Element, LazyNodes, NodeFactory, ScopeChildren, FC};
|
pub use crate::innerlude::{DioxusElement, Element, LazyNodes, NodeFactory, ScopeChildren, FC};
|
||||||
pub use crate::nodes::VNode;
|
pub use crate::nodes::VNode;
|
||||||
|
|
|
@ -69,8 +69,6 @@ use std::{
|
||||||
pub struct VirtualDom {
|
pub struct VirtualDom {
|
||||||
base_scope: ScopeId,
|
base_scope: ScopeId,
|
||||||
|
|
||||||
root_fc: Box<dyn Any>,
|
|
||||||
|
|
||||||
root_props: Rc<dyn Any>,
|
root_props: Rc<dyn Any>,
|
||||||
|
|
||||||
// we need to keep the allocation around, but we don't necessarily use it
|
// we need to keep the allocation around, but we don't necessarily use it
|
||||||
|
@ -85,8 +83,6 @@ pub struct VirtualDom {
|
||||||
pending_futures: FxHashSet<ScopeId>,
|
pending_futures: FxHashSet<ScopeId>,
|
||||||
pending_messages: VecDeque<SchedulerMsg>,
|
pending_messages: VecDeque<SchedulerMsg>,
|
||||||
dirty_scopes: IndexSet<ScopeId>,
|
dirty_scopes: IndexSet<ScopeId>,
|
||||||
|
|
||||||
in_progress: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods to create the VirtualDom
|
// Methods to create the VirtualDom
|
||||||
|
@ -179,21 +175,15 @@ impl VirtualDom {
|
||||||
receiver,
|
receiver,
|
||||||
sender,
|
sender,
|
||||||
|
|
||||||
root_fc: todo!(),
|
|
||||||
root_props: todo!(),
|
root_props: todo!(),
|
||||||
_root_caller: todo!(),
|
_root_caller: todo!(),
|
||||||
|
|
||||||
pending_messages: VecDeque::new(),
|
pending_messages: VecDeque::new(),
|
||||||
pending_futures: Default::default(),
|
pending_futures: Default::default(),
|
||||||
dirty_scopes: Default::default(),
|
dirty_scopes: Default::default(),
|
||||||
|
|
||||||
in_progress: false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public utility methods
|
|
||||||
impl VirtualDom {
|
|
||||||
/// Get the [`ScopeState`] for the root component.
|
/// Get the [`ScopeState`] for the root component.
|
||||||
///
|
///
|
||||||
/// This is useful for traversing the tree from the root for heuristics or alternsative renderers that use Dioxus
|
/// This is useful for traversing the tree from the root for heuristics or alternsative renderers that use Dioxus
|
||||||
|
@ -233,10 +223,7 @@ impl VirtualDom {
|
||||||
pub fn has_any_work(&self) -> bool {
|
pub fn has_any_work(&self) -> bool {
|
||||||
!(self.dirty_scopes.is_empty() && self.pending_messages.is_empty())
|
!(self.dirty_scopes.is_empty() && self.pending_messages.is_empty())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Methods to actually run the VirtualDOM
|
|
||||||
impl VirtualDom {
|
|
||||||
/// Waits for the scheduler to have work
|
/// Waits for the scheduler to have work
|
||||||
/// This lets us poll async tasks during idle periods without blocking the main thread.
|
/// This lets us poll async tasks during idle periods without blocking the main thread.
|
||||||
pub async fn wait_for_work(&mut self) {
|
pub async fn wait_for_work(&mut self) {
|
||||||
|
@ -532,7 +519,7 @@ impl VirtualDom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_scope(&self, id: &ScopeId) -> bool {
|
fn run_scope(&self, id: &ScopeId) -> bool {
|
||||||
let scope = self
|
let scope = self
|
||||||
.scopes
|
.scopes
|
||||||
.get_scope(id)
|
.get_scope(id)
|
||||||
|
@ -571,11 +558,11 @@ impl VirtualDom {
|
||||||
|
|
||||||
// Todo: see if we can add stronger guarantees around internal bookkeeping and failed component renders.
|
// Todo: see if we can add stronger guarantees around internal bookkeeping and failed component renders.
|
||||||
if let Some(key) = render(scope) {
|
if let Some(key) = render(scope) {
|
||||||
todo!("attach the niode");
|
// todo!("attach the niode");
|
||||||
// let new_head = builder.into_vnode(NodeFactory {
|
// let new_head = builder.into_vnode(NodeFactory {
|
||||||
// bump: &scope.frames.wip_frame().bump,
|
// bump: &scope.frames.wip_frame().bump,
|
||||||
// });
|
// });
|
||||||
log::debug!("Render is successful");
|
// log::debug!("Render is successful");
|
||||||
|
|
||||||
// the user's component succeeded. We can safely cycle to the next frame
|
// the user's component succeeded. We can safely cycle to the next frame
|
||||||
// scope.frames.wip_frame_mut().head_node = unsafe { std::mem::transmute(new_head) };
|
// scope.frames.wip_frame_mut().head_node = unsafe { std::mem::transmute(new_head) };
|
||||||
|
|
Loading…
Add table
Reference in a new issue