|
@@ -3,7 +3,6 @@ use dioxus_core::*;
|
|
use dioxus_native_core::prelude::*;
|
|
use dioxus_native_core::prelude::*;
|
|
use dioxus_native_core_macro::partial_derive_state;
|
|
use dioxus_native_core_macro::partial_derive_state;
|
|
use shipyard::Component;
|
|
use shipyard::Component;
|
|
-use std::cell::Cell;
|
|
|
|
|
|
|
|
fn random_ns() -> Option<&'static str> {
|
|
fn random_ns() -> Option<&'static str> {
|
|
let namespace = rand::random::<u8>() % 2;
|
|
let namespace = rand::random::<u8>() % 2;
|
|
@@ -178,22 +177,23 @@ fn create_random_dynamic_node(cx: &ScopeState, depth: usize) -> DynamicNode {
|
|
let range = if depth > 3 { 1 } else { 3 };
|
|
let range = if depth > 3 { 1 } else { 3 };
|
|
match rand::random::<u8>() % range {
|
|
match rand::random::<u8>() % range {
|
|
0 => DynamicNode::Placeholder(Default::default()),
|
|
0 => DynamicNode::Placeholder(Default::default()),
|
|
- 1 => cx.make_node((0..(rand::random::<u8>() % 5)).map(|_| VNode {
|
|
|
|
- key: None,
|
|
|
|
- parent: Default::default(),
|
|
|
|
- template: Cell::new(Template {
|
|
|
|
- name: concat!(file!(), ":", line!(), ":", column!(), ":0"),
|
|
|
|
- roots: &[TemplateNode::Dynamic { id: 0 }],
|
|
|
|
- node_paths: &[&[0]],
|
|
|
|
- attr_paths: &[],
|
|
|
|
- }),
|
|
|
|
- root_ids: dioxus::core::exports::bumpalo::collections::Vec::new_in(cx.bump()).into(),
|
|
|
|
- dynamic_nodes: cx.bump().alloc([cx.component(
|
|
|
|
- create_random_element,
|
|
|
|
- DepthProps { depth, root: false },
|
|
|
|
- "create_random_element",
|
|
|
|
- )]),
|
|
|
|
- dynamic_attrs: &[],
|
|
|
|
|
|
+ 1 => cx.make_node((0..(rand::random::<u8>() % 5)).map(|_| {
|
|
|
|
+ VNode::new(
|
|
|
|
+ None,
|
|
|
|
+ Template {
|
|
|
|
+ name: concat!(file!(), ":", line!(), ":", column!(), ":0"),
|
|
|
|
+ roots: &[TemplateNode::Dynamic { id: 0 }],
|
|
|
|
+ node_paths: &[&[0]],
|
|
|
|
+ attr_paths: &[],
|
|
|
|
+ },
|
|
|
|
+ dioxus::core::exports::bumpalo::collections::Vec::new_in(cx.bump()),
|
|
|
|
+ cx.bump().alloc([cx.component(
|
|
|
|
+ create_random_element,
|
|
|
|
+ DepthProps { depth, root: false },
|
|
|
|
+ "create_random_element",
|
|
|
|
+ )]),
|
|
|
|
+ &[],
|
|
|
|
+ )
|
|
})),
|
|
})),
|
|
2 => cx.component(
|
|
2 => cx.component(
|
|
create_random_element,
|
|
create_random_element,
|
|
@@ -253,13 +253,11 @@ fn create_random_element(cx: Scope<DepthProps>) -> Element {
|
|
.into_boxed_str(),
|
|
.into_boxed_str(),
|
|
));
|
|
));
|
|
println!("{template:#?}");
|
|
println!("{template:#?}");
|
|
- let node = VNode {
|
|
|
|
- key: None,
|
|
|
|
- parent: Default::default(),
|
|
|
|
- template: Cell::new(template),
|
|
|
|
- root_ids: dioxus::core::exports::bumpalo::collections::Vec::new_in(cx.bump())
|
|
|
|
- .into(),
|
|
|
|
- dynamic_nodes: {
|
|
|
|
|
|
+ let node = VNode::new(
|
|
|
|
+ None,
|
|
|
|
+ template,
|
|
|
|
+ dioxus::core::exports::bumpalo::collections::Vec::new_in(cx.bump()),
|
|
|
|
+ {
|
|
let dynamic_nodes: Vec<_> = dynamic_node_types
|
|
let dynamic_nodes: Vec<_> = dynamic_node_types
|
|
.iter()
|
|
.iter()
|
|
.map(|ty| match ty {
|
|
.map(|ty| match ty {
|
|
@@ -273,12 +271,12 @@ fn create_random_element(cx: Scope<DepthProps>) -> Element {
|
|
.collect();
|
|
.collect();
|
|
cx.bump().alloc(dynamic_nodes)
|
|
cx.bump().alloc(dynamic_nodes)
|
|
},
|
|
},
|
|
- dynamic_attrs: cx.bump().alloc(
|
|
|
|
|
|
+ cx.bump().alloc(
|
|
(0..template.attr_paths.len())
|
|
(0..template.attr_paths.len())
|
|
.map(|_| create_random_dynamic_attr(cx))
|
|
.map(|_| create_random_dynamic_attr(cx))
|
|
.collect::<Vec<_>>(),
|
|
.collect::<Vec<_>>(),
|
|
),
|
|
),
|
|
- };
|
|
|
|
|
|
+ );
|
|
Some(node)
|
|
Some(node)
|
|
}
|
|
}
|
|
_ => None,
|
|
_ => None,
|