FIx: cargo fix to clean up things
This commit is contained in:
1 parent
29751a4bab
commit
78d093a945
23 files changed
+91
-101
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
use crate::{builder::BuildConfig, cli::DevelopOptions, config::Config, error::Result};
|
use crate::{builder::BuildConfig, cli::DevelopOptions, config::Config, error::Result};
|
||||||
use async_std::{channel, prelude::FutureExt};
|
use async_std::{prelude::FutureExt};
|
||||||
|
|
||||||
use async_std::future;
|
use async_std::future;
|
||||||
use async_std::prelude::*;
|
use async_std::prelude::*;
|
||||||
@@ -57,7 +57,7 @@ async fn watch_directory(config: Config) -> Result<()> {
|
|||||||
.watch(src_dir.join("examples"), RecursiveMode::Recursive)
|
.watch(src_dir.join("examples"), RecursiveMode::Recursive)
|
||||||
.expect("Failed to watch dir");
|
.expect("Failed to watch dir");
|
||||||
|
|
||||||
let mut build_config = BuildConfig::default();
|
let build_config = BuildConfig::default();
|
||||||
|
|
||||||
'run: loop {
|
'run: loop {
|
||||||
crate::builder::build(&config, &build_config)?;
|
crate::builder::build(&config, &build_config)?;
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
use dioxus_core_macro::fc;
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use dioxus_core_macro::rsx;
|
|
||||||
|
|
||||||
pub mod dioxus {
|
pub mod dioxus {
|
||||||
pub mod builder {
|
pub mod builder {
|
||||||
@@ -25,32 +25,32 @@ pub mod dioxus {
|
|||||||
|
|
||||||
impl Builder {
|
impl Builder {
|
||||||
// fn attr<T>(mut self, key: &str, value: impl Into<AttrVal>) -> Self {
|
// fn attr<T>(mut self, key: &str, value: impl Into<AttrVal>) -> Self {
|
||||||
pub fn attr<T>(mut self, key: &str, value: T) -> Self {
|
pub fn attr<T>(self, _key: &str, _value: T) -> Self {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on<T>(mut self, key: &str, value: T) -> Self {
|
pub fn on<T>(self, _key: &str, _value: T) -> Self {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish(mut self) {
|
pub fn finish(self) {
|
||||||
// Self
|
// Self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Bump;
|
pub struct Bump;
|
||||||
pub fn div(bump: &Bump) -> Builder {
|
pub fn div(_bump: &Bump) -> Builder {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
pub fn h1(bump: &Bump) -> Builder {
|
pub fn h1(_bump: &Bump) -> Builder {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
pub fn h2(bump: &Bump) -> Builder {
|
pub fn h2(_bump: &Bump) -> Builder {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
use dioxus::builder::Bump;
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
// render(rsx! {
|
// render(rsx! {
|
||||||
// div { // we can actually support just a list of nodes too
|
// div { // we can actually support just a list of nodes too
|
||||||
@@ -86,7 +86,7 @@ pub fn main() {
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
let g = String::from("asd");
|
let _g = String::from("asd");
|
||||||
|
|
||||||
// let lazy = rsx! {
|
// let lazy = rsx! {
|
||||||
// div {
|
// div {
|
||||||
@@ -124,4 +124,4 @@ pub fn main() {
|
|||||||
// render(lazy);
|
// render(lazy);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(f: impl Fn(&dioxus::builder::Bump)) {}
|
fn render(_f: impl Fn(&dioxus::builder::Bump)) {}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::{quote, quote_spanned, ToTokens};
|
use quote::{quote, ToTokens};
|
||||||
use syn::spanned::Spanned;
|
|
||||||
use syn::{
|
use syn::{
|
||||||
parse::{Parse, ParseStream},
|
parse::{Parse, ParseStream},
|
||||||
Signature,
|
Signature,
|
||||||
};
|
};
|
||||||
use syn::{
|
use syn::{
|
||||||
parse_macro_input, Attribute, Block, FnArg, Ident, Item, ItemFn, ReturnType, Type, Visibility,
|
Attribute, Block, FnArg, Ident, Item, ItemFn, ReturnType, Type, Visibility,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A parsed version of the user's input
|
/// A parsed version of the user's input
|
||||||
@@ -109,11 +109,11 @@ impl ToTokens for FunctionComponent {
|
|||||||
let FunctionComponent {
|
let FunctionComponent {
|
||||||
block,
|
block,
|
||||||
// props_type,
|
// props_type,
|
||||||
arg,
|
arg: _,
|
||||||
vis,
|
vis: _,
|
||||||
attrs,
|
attrs: _,
|
||||||
name: function_name,
|
name: function_name,
|
||||||
return_type,
|
return_type: _,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
// if function_name == component_name {
|
// if function_name == component_name {
|
||||||
@@ -192,19 +192,19 @@ pub fn ensure_fn_block(item: Item) -> syn::Result<ItemFn> {
|
|||||||
Item::Fn(it) => Ok(it),
|
Item::Fn(it) => Ok(it),
|
||||||
Item::Static(it) => {
|
Item::Static(it) => {
|
||||||
let syn::ItemStatic {
|
let syn::ItemStatic {
|
||||||
attrs,
|
attrs: _,
|
||||||
vis,
|
vis: _,
|
||||||
static_token,
|
static_token: _,
|
||||||
mutability,
|
mutability: _,
|
||||||
ident,
|
ident: _,
|
||||||
colon_token,
|
colon_token: _,
|
||||||
ty,
|
ty,
|
||||||
eq_token,
|
eq_token: _,
|
||||||
expr,
|
expr: _,
|
||||||
semi_token,
|
semi_token: _,
|
||||||
} = ⁢
|
} = ⁢
|
||||||
match ty.as_ref() {
|
match ty.as_ref() {
|
||||||
Type::BareFn(bare) => {}
|
Type::BareFn(_bare) => {}
|
||||||
// Type::Array(_)
|
// Type::Array(_)
|
||||||
// | Type::Group(_)
|
// | Type::Group(_)
|
||||||
// | Type::ImplTrait(_)
|
// | Type::ImplTrait(_)
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ struct Element {
|
|||||||
impl ToTokens for ToToksCtx<&Element> {
|
impl ToTokens for ToToksCtx<&Element> {
|
||||||
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
||||||
// let ctx = self.ctx;
|
// let ctx = self.ctx;
|
||||||
let name = &self.inner.name;
|
let _name = &self.inner.name;
|
||||||
tokens.append_all(quote! {
|
tokens.append_all(quote! {
|
||||||
dioxus::builder::ElementBuilder::new(ctx, "#name")
|
dioxus::builder::ElementBuilder::new(ctx, "#name")
|
||||||
});
|
});
|
||||||
@@ -184,7 +184,7 @@ impl Parse for Element {
|
|||||||
s.parse::<Token![<]>()?;
|
s.parse::<Token![<]>()?;
|
||||||
let name = Ident::parse_any(s)?;
|
let name = Ident::parse_any(s)?;
|
||||||
let mut attrs = vec![];
|
let mut attrs = vec![];
|
||||||
let mut children: Vec<Node> = vec![];
|
let _children: Vec<Node> = vec![];
|
||||||
|
|
||||||
// keep looking for attributes
|
// keep looking for attributes
|
||||||
while !s.peek(Token![>]) {
|
while !s.peek(Token![>]) {
|
||||||
@@ -293,7 +293,7 @@ impl Parse for Attr {
|
|||||||
impl ToTokens for ToToksCtx<&Attr> {
|
impl ToTokens for ToToksCtx<&Attr> {
|
||||||
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
||||||
let name = self.inner.name.to_string();
|
let name = self.inner.name.to_string();
|
||||||
let mut attr_stream = TokenStream2::new();
|
let _attr_stream = TokenStream2::new();
|
||||||
match &self.inner.ty {
|
match &self.inner.ty {
|
||||||
AttrType::Value(value) => {
|
AttrType::Value(value) => {
|
||||||
let value = self.recurse(value);
|
let value = self.recurse(value);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ pub fn rsx(s: TokenStream) -> TokenStream {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn fc(attr: TokenStream, item: TokenStream) -> TokenStream {
|
pub fn fc(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
match syn::parse::<fc::FunctionComponent>(item) {
|
match syn::parse::<fc::FunctionComponent>(item) {
|
||||||
Err(e) => e.to_compile_error().into(),
|
Err(e) => e.to_compile_error().into(),
|
||||||
Ok(s) => s.to_token_stream().into(),
|
Ok(s) => s.to_token_stream().into(),
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use proc_macro2::TokenStream;
|
|||||||
|
|
||||||
use syn::parse::Error;
|
use syn::parse::Error;
|
||||||
use syn::spanned::Spanned;
|
use syn::spanned::Spanned;
|
||||||
use syn::{parse_macro_input, DeriveInput};
|
|
||||||
|
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ impl ToTokens for ToToksCtx<&Component> {
|
|||||||
// tokens.append_all(quote! {
|
// tokens.append_all(quote! {
|
||||||
// .finish()
|
// .finish()
|
||||||
// });
|
// });
|
||||||
let toks = tokens.append_all(quote! {
|
let _toks = tokens.append_all(quote! {
|
||||||
dioxus::builder::virtual_child(ctx, #name, #builder)
|
dioxus::builder::virtual_child(ctx, #name, #builder)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -209,7 +209,7 @@ impl Parse for Component {
|
|||||||
syn::braced!(content in s);
|
syn::braced!(content in s);
|
||||||
|
|
||||||
let mut body: Vec<ComponentField> = Vec::new();
|
let mut body: Vec<ComponentField> = Vec::new();
|
||||||
let mut children: Vec<Node> = Vec::new();
|
let _children: Vec<Node> = Vec::new();
|
||||||
|
|
||||||
// parse_element_content(content, &mut attrs, &mut children);
|
// parse_element_content(content, &mut attrs, &mut children);
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ impl Parse for Component {
|
|||||||
|
|
||||||
// eventually we'll parse the attrs
|
// eventually we'll parse the attrs
|
||||||
// let mut attrs: Vec<Attr> = vec![];
|
// let mut attrs: Vec<Attr> = vec![];
|
||||||
let mut children: Vec<Node> = vec![];
|
let children: Vec<Node> = vec![];
|
||||||
// parse_element_content(content, &mut attrs, &mut children);
|
// parse_element_content(content, &mut attrs, &mut children);
|
||||||
|
|
||||||
let children = MaybeExpr::Literal(children);
|
let children = MaybeExpr::Literal(children);
|
||||||
@@ -250,8 +250,8 @@ pub struct ComponentField {
|
|||||||
|
|
||||||
impl Parse for ComponentField {
|
impl Parse for ComponentField {
|
||||||
fn parse(input: ParseStream) -> Result<Self> {
|
fn parse(input: ParseStream) -> Result<Self> {
|
||||||
let mut name = Ident::parse_any(input)?;
|
let name = Ident::parse_any(input)?;
|
||||||
let name_str = name.to_string();
|
let _name_str = name.to_string();
|
||||||
input.parse::<Token![:]>()?;
|
input.parse::<Token![:]>()?;
|
||||||
let content = input.parse()?;
|
let content = input.parse()?;
|
||||||
|
|
||||||
@@ -472,7 +472,7 @@ impl ToTokens for ToToksCtx<&Attr> {
|
|||||||
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
||||||
let name = self.inner.name.to_string();
|
let name = self.inner.name.to_string();
|
||||||
let nameident = &self.inner.name;
|
let nameident = &self.inner.name;
|
||||||
let mut attr_stream = TokenStream2::new();
|
let _attr_stream = TokenStream2::new();
|
||||||
match &self.inner.ty {
|
match &self.inner.ty {
|
||||||
AttrType::Value(value) => {
|
AttrType::Value(value) => {
|
||||||
let value = self.recurse(value);
|
let value = self.recurse(value);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
||||||
use std::fmt::Debug;
|
|
||||||
|
|
||||||
use dioxus_core::prelude::*;
|
use dioxus_core::prelude::*;
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ struct ListItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn app(ctx: Context, props: &Props) -> DomTree {
|
fn app(ctx: Context, props: &Props) -> DomTree {
|
||||||
let (f, setter) = use_state(&ctx, || 0);
|
let (_f, setter) = use_state(&ctx, || 0);
|
||||||
|
|
||||||
ctx.render(move |c| {
|
ctx.render(move |c| {
|
||||||
let mut root = builder::ElementBuilder::new(c, "div");
|
let mut root = builder::ElementBuilder::new(c, "div");
|
||||||
@@ -64,7 +64,7 @@ struct ChildProps<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for ChildProps<'_> {
|
impl PartialEq for ChildProps<'_> {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, _other: &Self) -> bool {
|
||||||
// assume the dyn fn is never stable -
|
// assume the dyn fn is never stable -
|
||||||
// wrap with use_callback if it's an issue for you
|
// wrap with use_callback if it's an issue for you
|
||||||
false
|
false
|
||||||
@@ -78,7 +78,7 @@ impl<'a> Properties for ChildProps<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ChildItem(ctx: Context, props: &ChildProps) -> DomTree {
|
fn ChildItem(_ctx: Context, _props: &ChildProps) -> DomTree {
|
||||||
todo!()
|
todo!()
|
||||||
// ctx.render(rsx! {
|
// ctx.render(rsx! {
|
||||||
// div {
|
// div {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use dioxus_core::component::fc_to_builder;
|
use dioxus_core::component::fc_to_builder;
|
||||||
use dioxus_core::prelude::*;
|
use dioxus_core::prelude::*;
|
||||||
use dioxus_core_macro::fc;
|
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
static BLAH: FC<()> = |ctx, props| {
|
|
||||||
|
|
||||||
|
static BLAH: FC<()> = |ctx, _props| {
|
||||||
let g = "asd".to_string();
|
let g = "asd".to_string();
|
||||||
ctx.render(rsx! {
|
ctx.render(rsx! {
|
||||||
div {
|
div {
|
||||||
@@ -20,7 +20,7 @@ pub struct ExampleProps {
|
|||||||
some_field: String,
|
some_field: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
static SomeComponent: FC<ExampleProps> = |ctx, props| {
|
static SomeComponent: FC<ExampleProps> = |ctx, _props| {
|
||||||
ctx.render(rsx! {
|
ctx.render(rsx! {
|
||||||
div { }
|
div { }
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
// #[macro_use]
|
// #[macro_use]
|
||||||
extern crate fstrings;
|
extern crate fstrings;
|
||||||
|
|
||||||
use bumpalo::collections::String;
|
|
||||||
|
|
||||||
// use dioxus_core::ifmt;
|
// use dioxus_core::ifmt;
|
||||||
// use fstrings::format_args_f;
|
// use fstrings::format_args_f;
|
||||||
use bumpalo::core_alloc::fmt::Write;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let bump = bumpalo::Bump::new();
|
let bump = bumpalo::Bump::new();
|
||||||
let b = ≎
|
let _b = ≎
|
||||||
let world = "123";
|
let _world = "123";
|
||||||
// dioxus_core::ifmt!(in b; "Hello {world}";);
|
// dioxus_core::ifmt!(in b; "Hello {world}";);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ struct SomeProps {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let g: SomeProps = SomeProps::builder().a(10).b(10).build();
|
let g: SomeProps = SomeProps::builder().a(10).b(10).build();
|
||||||
|
|
||||||
let r = g.b.unwrap_or_else(|| 10);
|
let _r = g.b.unwrap_or_else(|| 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn auto_into_some() {}
|
fn auto_into_some() {}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use bumpalo::Bump;
|
|
||||||
use dioxus_core::prelude::*;
|
use dioxus_core::prelude::*;
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
@@ -26,8 +26,8 @@ struct Button<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Render for Button<'_> {
|
impl Render for Button<'_> {
|
||||||
fn render(ctx: Context, props: &Self) -> DomTree {
|
fn render(ctx: Context, _props: &Self) -> DomTree {
|
||||||
let onfocus = move |evt: ()| log::debug!("Focused");
|
let _onfocus = move |_evt: ()| log::debug!("Focused");
|
||||||
|
|
||||||
// todo!()
|
// todo!()
|
||||||
ctx.render(rsx! {
|
ctx.render(rsx! {
|
||||||
@@ -35,7 +35,7 @@ impl Render for Button<'_> {
|
|||||||
// ..props.attrs,
|
// ..props.attrs,
|
||||||
class: "abc123",
|
class: "abc123",
|
||||||
// style: { a: 2, b: 3, c: 4 },
|
// style: { a: 2, b: 3, c: 4 },
|
||||||
onclick: move |evt| {
|
onclick: move |_evt| {
|
||||||
// log::info("hello world");
|
// log::info("hello world");
|
||||||
},
|
},
|
||||||
// Custom1 { a: 123 }
|
// Custom1 { a: 123 }
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use dioxus_core::{component::Properties, prelude::*};
|
|||||||
fn main() -> Result<(), ()> {
|
fn main() -> Result<(), ()> {
|
||||||
let p1 = SomeProps { name: "bob".into() };
|
let p1 = SomeProps { name: "bob".into() };
|
||||||
|
|
||||||
let mut vdom = VirtualDom::new_with_props(Example, p1);
|
let _vdom = VirtualDom::new_with_props(Example, p1);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,6 @@ impl Properties for () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fc_to_builder<T: Properties>(f: FC<T>) -> T::Builder {
|
pub fn fc_to_builder<T: Properties>(_f: FC<T>) -> T::Builder {
|
||||||
T::builder()
|
T::builder()
|
||||||
}
|
}
|
||||||
@@ -34,11 +34,10 @@
|
|||||||
//! - https://hacks.mozilla.org/2019/03/fast-bump-allocated-virtual-doms-with-rust-and-wasm/
|
//! - https://hacks.mozilla.org/2019/03/fast-bump-allocated-virtual-doms-with-rust-and-wasm/
|
||||||
use crate::{
|
use crate::{
|
||||||
innerlude::*,
|
innerlude::*,
|
||||||
scope::{create_scoped, Scoped},
|
|
||||||
};
|
};
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use fxhash::{FxHashMap, FxHashSet};
|
use fxhash::{FxHashMap, FxHashSet};
|
||||||
use generational_arena::Arena;
|
|
||||||
use std::{cell::RefCell, cmp::Ordering, collections::VecDeque, rc::Rc};
|
use std::{cell::RefCell, cmp::Ordering, collections::VecDeque, rc::Rc};
|
||||||
|
|
||||||
/// The DiffState is a cursor internal to the VirtualDOM's diffing algorithm that allows persistence of state while
|
/// The DiffState is a cursor internal to the VirtualDOM's diffing algorithm that allows persistence of state while
|
||||||
@@ -112,7 +111,7 @@ impl<'a> DiffMachine<'a> {
|
|||||||
self.diff_children(eold.children, enew.children);
|
self.diff_children(eold.children, enew.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
(VNode::Component(cold), VNode::Component(cnew)) => {
|
(VNode::Component(_cold), VNode::Component(_cnew)) => {
|
||||||
// if cold.comp != cnew.comp {
|
// if cold.comp != cnew.comp {
|
||||||
// // queue an event to mount this new component
|
// // queue an event to mount this new component
|
||||||
// return;
|
// return;
|
||||||
@@ -123,7 +122,7 @@ impl<'a> DiffMachine<'a> {
|
|||||||
todo!("Usage of component VNode not currently supported");
|
todo!("Usage of component VNode not currently supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
(_, VNode::Component(new)) => {
|
(_, VNode::Component(_new)) => {
|
||||||
// we have no stable reference to work from
|
// we have no stable reference to work from
|
||||||
// push the lifecycle event onto the queue
|
// push the lifecycle event onto the queue
|
||||||
// self.lifecycle_events
|
// self.lifecycle_events
|
||||||
@@ -142,7 +141,7 @@ impl<'a> DiffMachine<'a> {
|
|||||||
// push the current
|
// push the current
|
||||||
}
|
}
|
||||||
|
|
||||||
(VNode::Component(old), _) => {
|
(VNode::Component(_old), _) => {
|
||||||
todo!("Usage of component VNode not currently supported");
|
todo!("Usage of component VNode not currently supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +164,7 @@ impl<'a> DiffMachine<'a> {
|
|||||||
self.change_list.commit_traversal();
|
self.change_list.commit_traversal();
|
||||||
}
|
}
|
||||||
|
|
||||||
'outer1: for (l_idx, new_l) in new.iter().enumerate() {
|
'outer1: for (_l_idx, new_l) in new.iter().enumerate() {
|
||||||
// unsafe {
|
// unsafe {
|
||||||
// Safety relies on removing `new_l` from the registry manually at
|
// Safety relies on removing `new_l` from the registry manually at
|
||||||
// the end of its lifetime. This happens below in the `'outer2`
|
// the end of its lifetime. This happens below in the `'outer2`
|
||||||
@@ -818,7 +817,7 @@ impl<'a> DiffMachine<'a> {
|
|||||||
self.change_list.create_element(tag_name);
|
self.change_list.create_element(tag_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
listeners.iter().enumerate().for_each(|(id, listener)| {
|
listeners.iter().enumerate().for_each(|(_id, listener)| {
|
||||||
self.change_list
|
self.change_list
|
||||||
.new_event_listener(listener.event, listener.scope, listener.id)
|
.new_event_listener(listener.event, listener.scope, listener.id)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ mod use_reducer_def {
|
|||||||
pub fn use_reducer<'a, 'c, State: 'static, Action: 'static>(
|
pub fn use_reducer<'a, 'c, State: 'static, Action: 'static>(
|
||||||
ctx: &'c Context<'a>,
|
ctx: &'c Context<'a>,
|
||||||
initial_state_fn: impl FnOnce() -> State,
|
initial_state_fn: impl FnOnce() -> State,
|
||||||
reducer: impl Fn(&mut State, Action),
|
_reducer: impl Fn(&mut State, Action),
|
||||||
) -> (&'a State, &'a impl Fn(Action)) {
|
) -> (&'a State, &'a impl Fn(Action)) {
|
||||||
ctx.use_hook(
|
ctx.use_hook(
|
||||||
move || UseReducer {
|
move || UseReducer {
|
||||||
@@ -146,7 +146,7 @@ mod use_reducer_def {
|
|||||||
caller: Box::new(|_| println!("setter called!")),
|
caller: Box::new(|_| println!("setter called!")),
|
||||||
},
|
},
|
||||||
move |hook| {
|
move |hook| {
|
||||||
let inner = hook.new_val.clone();
|
let _inner = hook.new_val.clone();
|
||||||
let scheduled_update = ctx.schedule_update();
|
let scheduled_update = ctx.schedule_update();
|
||||||
|
|
||||||
// get ownership of the new val and replace the current with the new
|
// get ownership of the new val and replace the current with the new
|
||||||
@@ -157,7 +157,7 @@ mod use_reducer_def {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo: swap out the caller with a subscription call and an internal update
|
// todo: swap out the caller with a subscription call and an internal update
|
||||||
hook.caller = Box::new(move |new_val| {
|
hook.caller = Box::new(move |_new_val| {
|
||||||
// update the setter with the new value
|
// update the setter with the new value
|
||||||
// let mut new_inner = inner.as_ref().borrow_mut();
|
// let mut new_inner = inner.as_ref().borrow_mut();
|
||||||
// *new_inner = Some(new_val);
|
// *new_inner = Some(new_val);
|
||||||
@@ -175,9 +175,9 @@ mod use_reducer_def {
|
|||||||
|
|
||||||
// #[cfg(test)]
|
// #[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use bumpalo::Bump;
|
|
||||||
enum Actions {
|
enum Actions {
|
||||||
Incr,
|
Incr,
|
||||||
Decr,
|
Decr,
|
||||||
|
|||||||
@@ -91,11 +91,11 @@ pub(crate) mod innerlude {
|
|||||||
// pub(crate) use crate::component::Properties;
|
// pub(crate) use crate::component::Properties;
|
||||||
pub(crate) use crate::component::Properties;
|
pub(crate) use crate::component::Properties;
|
||||||
pub(crate) use crate::context::Context;
|
pub(crate) use crate::context::Context;
|
||||||
pub(crate) use crate::error::{Error, Result};
|
pub(crate) use crate::error::{Result};
|
||||||
pub use crate::events::EventTrigger;
|
pub use crate::events::EventTrigger;
|
||||||
use crate::nodes;
|
use crate::nodes;
|
||||||
pub(crate) use crate::scope::Scope;
|
|
||||||
pub(crate) use crate::virtual_dom::VirtualDom;
|
|
||||||
pub(crate) use nodes::*;
|
pub(crate) use nodes::*;
|
||||||
|
|
||||||
pub use crate::component::ScopeIdx;
|
pub use crate::component::ScopeIdx;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! Helpers for building virtual DOM VNodes.
|
//! Helpers for building virtual DOM VNodes.
|
||||||
|
|
||||||
use std::{borrow::BorrowMut, ops::Deref};
|
use std::{borrow::BorrowMut};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
context::NodeCtx,
|
context::NodeCtx,
|
||||||
@@ -10,8 +10,8 @@ use crate::{
|
|||||||
prelude::VElement,
|
prelude::VElement,
|
||||||
};
|
};
|
||||||
|
|
||||||
use bumpalo::format;
|
|
||||||
use bumpalo::Bump;
|
|
||||||
|
|
||||||
/// A virtual DOM element builder.
|
/// A virtual DOM element builder.
|
||||||
///
|
///
|
||||||
@@ -339,7 +339,7 @@ where
|
|||||||
/// })
|
/// })
|
||||||
/// .finish();
|
/// .finish();
|
||||||
/// ```
|
/// ```
|
||||||
pub fn on(mut self, event: &'static str, callback: impl Fn(VirtualEvent) + 'a) -> Self {
|
pub fn on(self, event: &'static str, callback: impl Fn(VirtualEvent) + 'a) -> Self {
|
||||||
let listener = Listener {
|
let listener = Listener {
|
||||||
event,
|
event,
|
||||||
callback: self.ctx.bump.alloc(callback),
|
callback: self.ctx.bump.alloc(callback),
|
||||||
@@ -527,9 +527,9 @@ pub fn attr<'a>(name: &'static str, value: &'a str) -> Attribute<'a> {
|
|||||||
// _f: crate::innerlude::FC<T>,
|
// _f: crate::innerlude::FC<T>,
|
||||||
// _props: T
|
// _props: T
|
||||||
pub fn virtual_child<'a, 'b, T: crate::innerlude::Properties>(
|
pub fn virtual_child<'a, 'b, T: crate::innerlude::Properties>(
|
||||||
ctx: &'b NodeCtx<'a>,
|
_ctx: &'b NodeCtx<'a>,
|
||||||
f: FC<T>,
|
_f: FC<T>,
|
||||||
p: T,
|
_p: T,
|
||||||
) -> VNode<'a> {
|
) -> VNode<'a> {
|
||||||
// crate::nodes::VComponent
|
// crate::nodes::VComponent
|
||||||
todo!()
|
todo!()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use crate::{
|
|||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::{
|
use std::{
|
||||||
any::{Any, TypeId},
|
any::{Any},
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
@@ -280,14 +280,14 @@ pub struct VComponent<'src> {
|
|||||||
}
|
}
|
||||||
pub struct Comparator(Box<dyn Fn(&dyn Any) -> bool>);
|
pub struct Comparator(Box<dyn Fn(&dyn Any) -> bool>);
|
||||||
impl std::fmt::Debug for Comparator {
|
impl std::fmt::Debug for Comparator {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Caller(Box<dyn Fn(Context) -> DomTree>);
|
pub struct Caller(Box<dyn Fn(Context) -> DomTree>);
|
||||||
impl std::fmt::Debug for Caller {
|
impl std::fmt::Debug for Caller {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::nodes::VNode;
|
|||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
any::{Any, TypeId},
|
any::{Any},
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
ops::Deref,
|
ops::Deref,
|
||||||
@@ -145,7 +145,7 @@ impl<P: Properties + 'static> Scoped for Scope<P> {
|
|||||||
.expect("Viewing did not happen");
|
.expect("Viewing did not happen");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compare_props(&self, new: &Any) -> bool {
|
fn compare_props(&self, new: &dyn Any) -> bool {
|
||||||
new.downcast_ref::<P>()
|
new.downcast_ref::<P>()
|
||||||
.map(|f| &self.props == f)
|
.map(|f| &self.props == f)
|
||||||
.expect("Props should not be of a different type")
|
.expect("Props should not be of a different type")
|
||||||
|
|||||||
@@ -7,16 +7,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use generational_arena::Arena;
|
use generational_arena::Arena;
|
||||||
use std::{
|
|
||||||
any::TypeId,
|
|
||||||
borrow::BorrowMut,
|
|
||||||
cell::{RefCell, UnsafeCell},
|
|
||||||
collections::{vec_deque, VecDeque},
|
|
||||||
future::Future,
|
|
||||||
marker::PhantomData,
|
|
||||||
rc::Rc,
|
|
||||||
sync::atomic::AtomicUsize,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// An integrated virtual node system that progresses events and diffs UI trees.
|
/// An integrated virtual node system that progresses events and diffs UI trees.
|
||||||
/// Differences are converted into patches which a renderer can use to draw the UI.
|
/// Differences are converted into patches which a renderer can use to draw the UI.
|
||||||
@@ -68,7 +59,7 @@ impl VirtualDom {
|
|||||||
///
|
///
|
||||||
/// This is useful when a component tree can be driven by external state (IE SSR) but it would be too expensive
|
/// This is useful when a component tree can be driven by external state (IE SSR) but it would be too expensive
|
||||||
/// to toss out the entire tree.
|
/// to toss out the entire tree.
|
||||||
pub fn new_with_props<P: Properties + 'static>(root: FC<P>, root_props: P) -> Self {
|
pub fn new_with_props<P: Properties + 'static>(_root: FC<P>, _root_props: P) -> Self {
|
||||||
// let mut components = Arena::new();
|
// let mut components = Arena::new();
|
||||||
// let mut components = Arena::new();
|
// let mut components = Arena::new();
|
||||||
|
|
||||||
@@ -104,7 +95,7 @@ impl VirtualDom {
|
|||||||
.expect("Root should always exist")
|
.expect("Root should always exist")
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
let b = Bump::new();
|
let _b = Bump::new();
|
||||||
|
|
||||||
let mut diff_machine = DiffMachine::new(&self.diff_bump);
|
let mut diff_machine = DiffMachine::new(&self.diff_bump);
|
||||||
// let mut diff_machine = DiffMachine::new(self, &self.diff_bump, self.base_scope);
|
// let mut diff_machine = DiffMachine::new(self, &self.diff_bump, self.base_scope);
|
||||||
@@ -142,7 +133,7 @@ impl VirtualDom {
|
|||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
pub fn progress_with_event(&mut self, event: EventTrigger) -> Result<EditList<'_>> {
|
pub fn progress_with_event(&mut self, _event: EventTrigger) -> Result<EditList<'_>> {
|
||||||
// self.components
|
// self.components
|
||||||
// .borrow_mut()
|
// .borrow_mut()
|
||||||
// .get_mut(event.component_id)
|
// .get_mut(event.component_id)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use dioxus_core::prelude::*;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// let mut s = Context { props: &() };
|
// let mut s = Context { props: &() };
|
||||||
|
|||||||
Reference in new issue
Block a user