Merge branch 'breaking' of https://github.com/Demonthos/dioxus into breaking
This commit is contained in:
commit
8fe2515413
4 files changed
+17
-12
No files matched your search
@@ -47,7 +47,7 @@ fn get_props_struct(component_body: &ComponentBody) -> ItemStruct {
|
|||||||
} = sig;
|
} = sig;
|
||||||
|
|
||||||
// Skip first arg since that's the context
|
// Skip first arg since that's the context
|
||||||
let struct_fields = inputs.iter().skip(1).map(move |f| {
|
let struct_fields = inputs.iter().map(move |f| {
|
||||||
match f {
|
match f {
|
||||||
FnArg::Receiver(_) => unreachable!(), // Unreachable because of ComponentBody parsing
|
FnArg::Receiver(_) => unreachable!(), // Unreachable because of ComponentBody parsing
|
||||||
FnArg::Typed(pt) => {
|
FnArg::Typed(pt) => {
|
||||||
@@ -74,9 +74,9 @@ fn get_props_struct(component_body: &ComponentBody) -> ItemStruct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let struct_attrs = if first_lifetime.is_some() {
|
let struct_attrs = if first_lifetime.is_some() {
|
||||||
quote! { #[derive(Props)] }
|
quote! { #[derive(Props, Clone)] }
|
||||||
} else {
|
} else {
|
||||||
quote! { #[derive(Props, PartialEq)] }
|
quote! { #[derive(Props, Clone, PartialEq)] }
|
||||||
};
|
};
|
||||||
|
|
||||||
let struct_generics = if first_lifetime.is_some() {
|
let struct_generics = if first_lifetime.is_some() {
|
||||||
@@ -245,7 +245,7 @@ fn get_function(component_body: &ComponentBody) -> ItemFn {
|
|||||||
let struct_ident = Ident::new(&format!("{fn_ident}Props"), fn_ident.span());
|
let struct_ident = Ident::new(&format!("{fn_ident}Props"), fn_ident.span());
|
||||||
|
|
||||||
// Skip first arg since that's the context
|
// Skip first arg since that's the context
|
||||||
let struct_field_names = inputs.iter().skip(1).filter_map(|f| match f {
|
let struct_field_names = inputs.iter().filter_map(|f| match f {
|
||||||
FnArg::Receiver(_) => unreachable!(), // ComponentBody prohibits receiver parameters.
|
FnArg::Receiver(_) => unreachable!(), // ComponentBody prohibits receiver parameters.
|
||||||
FnArg::Typed(pt) => Some(&pt.pat),
|
FnArg::Typed(pt) => Some(&pt.pat),
|
||||||
});
|
});
|
||||||
@@ -256,7 +256,7 @@ fn get_function(component_body: &ComponentBody) -> ItemFn {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let (scope_lifetime, fn_generics) = if let Some(lt) = first_lifetime {
|
let (_scope_lifetime, fn_generics) = if let Some(lt) = first_lifetime {
|
||||||
(quote! { #lt, }, generics.clone())
|
(quote! { #lt, }, generics.clone())
|
||||||
} else {
|
} else {
|
||||||
let lifetime: LifetimeParam = parse_quote! { 'a };
|
let lifetime: LifetimeParam = parse_quote! { 'a };
|
||||||
@@ -296,7 +296,7 @@ fn get_function(component_body: &ComponentBody) -> ItemFn {
|
|||||||
#asyncness #vis fn #fn_ident #fn_generics (__props: #struct_ident #generics_no_bounds) #fn_output
|
#asyncness #vis fn #fn_ident #fn_generics (__props: #struct_ident #generics_no_bounds) #fn_output
|
||||||
#where_clause
|
#where_clause
|
||||||
{
|
{
|
||||||
let #struct_ident { #(#struct_field_names),* } = &__props;
|
let #struct_ident { #(#struct_field_names),* } = __props;
|
||||||
#fn_block
|
#fn_block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,8 @@ pub fn derive_typed_builder(input: TokenStream) -> TokenStream {
|
|||||||
|
|
||||||
/// The rsx! macro makes it easy for developers to write jsx-style markup in their components.
|
/// The rsx! macro makes it easy for developers to write jsx-style markup in their components.
|
||||||
#[proc_macro]
|
#[proc_macro]
|
||||||
pub fn rsx(s: TokenStream) -> TokenStream {
|
pub fn rsx(tokens: TokenStream) -> TokenStream {
|
||||||
match syn::parse::<rsx::CallBody>(s) {
|
render(tokens)
|
||||||
Err(err) => err.to_compile_error().into(),
|
|
||||||
Ok(body) => body.to_token_stream().into(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The render! macro makes it easy for developers to write jsx-style markup in their components.
|
/// The render! macro makes it easy for developers to write jsx-style markup in their components.
|
||||||
|
|||||||
@@ -16,13 +16,15 @@ dioxus-html = { workspace = true, optional = true }
|
|||||||
dioxus-core-macro = { workspace = true, optional = true }
|
dioxus-core-macro = { workspace = true, optional = true }
|
||||||
dioxus-hooks = { workspace = true, optional = true }
|
dioxus-hooks = { workspace = true, optional = true }
|
||||||
dioxus-rsx = { workspace = true, optional = true }
|
dioxus-rsx = { workspace = true, optional = true }
|
||||||
|
dioxus-signals = { workspace = true, optional = true }
|
||||||
manganis = { git = "https://github.com/DioxusLabs/collect-assets" }
|
manganis = { git = "https://github.com/DioxusLabs/collect-assets" }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
dioxus-hot-reload = { workspace = true, optional = true }
|
dioxus-hot-reload = { workspace = true, optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["macro", "hooks", "html", "hot-reload"]
|
default = ["macro", "html", "hot-reload", "signals"]
|
||||||
|
signals = ["dioxus-signals"]
|
||||||
macro = ["dioxus-core-macro", "dioxus-rsx"]
|
macro = ["dioxus-core-macro", "dioxus-rsx"]
|
||||||
html = ["dioxus-html"]
|
html = ["dioxus-html"]
|
||||||
hooks = ["dioxus-hooks"]
|
hooks = ["dioxus-hooks"]
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ pub use dioxus_core as core;
|
|||||||
#[cfg(feature = "hooks")]
|
#[cfg(feature = "hooks")]
|
||||||
pub use dioxus_hooks as hooks;
|
pub use dioxus_hooks as hooks;
|
||||||
|
|
||||||
|
#[cfg(feature = "signals")]
|
||||||
|
pub use dioxus_signals as signals;
|
||||||
|
|
||||||
pub mod events {
|
pub mod events {
|
||||||
#[cfg(feature = "html")]
|
#[cfg(feature = "html")]
|
||||||
pub use dioxus_html::prelude::*;
|
pub use dioxus_html::prelude::*;
|
||||||
@@ -28,6 +31,9 @@ pub mod prelude {
|
|||||||
#[cfg(feature = "hooks")]
|
#[cfg(feature = "hooks")]
|
||||||
pub use crate::hooks::*;
|
pub use crate::hooks::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "signals")]
|
||||||
|
pub use dioxus_signals::*;
|
||||||
|
|
||||||
pub use dioxus_core::prelude::*;
|
pub use dioxus_core::prelude::*;
|
||||||
|
|
||||||
#[cfg(feature = "macro")]
|
#[cfg(feature = "macro")]
|
||||||
|
|||||||
Reference in new issue
Block a user