Skip to content

Commit 4f1d039

Browse files
authored
clean up prelude (#4416)
* clear away prelude on dioxus * clippy * wip - drop prelude from dioxus-html * docs clippy * wip * more fixe * delete all preludes * doc... * better export * merge some imports * fewer global imports * global incremental renderer * fix cargo doc
1 parent 54d465a commit 4f1d039

File tree

140 files changed

+374
-477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+374
-477
lines changed

examples/fullstack-auth/src/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use axum_session::{SessionConfig, SessionLayer, SessionStore};
99
use axum_session_auth::*;
1010
use axum_session_sqlx::SessionSqlitePool;
1111
use core::pin::Pin;
12-
use dioxus_fullstack::prelude::*;
12+
use dioxus::prelude::*;
1313
use serde::{Deserialize, Serialize};
1414
use sqlx::sqlite::{SqliteConnectOptions, SqlitePool, SqlitePoolOptions};
1515
use std::error::Error;

examples/fullstack-auth/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
mod auth;
55

66
use dioxus::prelude::*;
7-
use dioxus_fullstack::prelude::*;
87
use serde::{Deserialize, Serialize};
98

109
fn main() {

examples/fullstack-desktop/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use dioxus::prelude::*;
44
fn main() {
55
// Set the url of the server where server functions are hosted.
66
#[cfg(not(feature = "server"))]
7-
dioxus::fullstack::prelude::server_fn::client::set_server_url("http://127.0.0.1:8080");
7+
dioxus::fullstack::set_server_url("http://127.0.0.1:8080");
88
dioxus::launch(app);
99
}
1010

examples/fullstack-router/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use dioxus::prelude::*;
99
fn main() {
1010
dioxus::LaunchBuilder::new()
1111
.with_cfg(server_only!(ServeConfig::builder().incremental(
12-
IncrementalRendererConfig::default()
12+
dioxus::fullstack::IncrementalRendererConfig::default()
1313
.invalidate_after(std::time::Duration::from_secs(120)),
1414
)))
1515
.launch(app);

examples/query_segment_search.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! The enum router makes it easy to use your route as state in your app. This example shows how to use the router to encode search text into the url and decode it back into a string.
44
//!
5-
//! Run this example on desktop with
5+
//! Run this example on desktop with
66
//! ```sh
77
//! dx serve --example query_segment_search
88
//! ```
@@ -29,7 +29,7 @@ enum Route {
2929

3030
// The each query segment must implement <https://docs.rs/dioxus-router/latest/dioxus_router/routable/trait.FromQueryArgument.html> and Display.
3131
// You can use multiple query segments separated by `&`s.
32-
#[route("/search?:query&:word_count")]
32+
#[route("/search?:query&:word_count")]
3333
Search {
3434
query: String,
3535
word_count: usize,

packages/core-macro/src/props/mod.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ fn extract_inner_type_from_segment(segment: &PathSegment) -> Option<&Type> {
544544
mod struct_info {
545545
use convert_case::{Case, Casing};
546546
use proc_macro2::TokenStream;
547-
use quote::quote;
547+
use quote::{quote, ToTokens};
548548
use syn::parse::Error;
549549
use syn::punctuated::Punctuated;
550550
use syn::spanned::Spanned;
@@ -884,7 +884,7 @@ Finally, call `.build()` to create the instance of `{name}`.
884884
_phantom: (#( #phantom_generics ),*),
885885
}
886886

887-
impl #impl_generics dioxus_core::prelude::Properties for #name #ty_generics
887+
impl #impl_generics dioxus_core::Properties for #name #ty_generics
888888
#b_generics_where
889889
{
890890
type Builder = #builder_name #generics_with_empty;
@@ -1024,22 +1024,19 @@ Finally, call `.build()` to create the instance of `{name}`.
10241024

10251025
Ok(quote! {
10261026
#[allow(dead_code, non_camel_case_types, missing_docs)]
1027-
impl #impl_generics dioxus_core::prelude::HasAttributes for #builder_name < #( #ty_generics ),* > #where_clause {
1027+
impl #impl_generics dioxus_core::HasAttributes for #builder_name < #( #ty_generics ),* > #where_clause {
10281028
fn push_attribute<L>(
10291029
mut self,
10301030
____name: &'static str,
10311031
____ns: Option<&'static str>,
1032-
____attr: impl dioxus_core::prelude::IntoAttributeValue<L>,
1032+
____attr: impl dioxus_core::IntoAttributeValue<L>,
10331033
____volatile: bool
10341034
) -> Self {
10351035
let ( #(#descructuring,)* ) = self.fields;
10361036
self.#field_name.push(
10371037
dioxus_core::Attribute::new(
10381038
____name,
1039-
{
1040-
use dioxus_core::prelude::IntoAttributeValue;
1041-
____attr.into_value()
1042-
},
1039+
dioxus_core::IntoAttributeValue::<L>::into_value(____attr),
10431040
____ns,
10441041
____volatile,
10451042
)
@@ -1150,16 +1147,16 @@ Finally, call `.build()` to create the instance of `{name}`.
11501147
let marker_ident = syn::Ident::new("__Marker", proc_macro2::Span::call_site());
11511148
marker = Some(marker_ident.clone());
11521149
(
1153-
quote!(impl dioxus_core::prelude::SuperInto<#arg_type, #marker_ident>),
1150+
quote!(impl dioxus_core::SuperInto<#arg_type, #marker_ident>),
11541151
// If this looks like a signal type, we automatically convert it with SuperInto and use the props struct as the owner
1155-
quote!(with_owner(self.owner.clone(), move || dioxus_core::prelude::SuperInto::super_into(#field_name))),
1152+
quote!(dioxus_core::with_owner(self.owner.clone(), move || dioxus_core::SuperInto::super_into(#field_name))),
11561153
)
11571154
} else if field.builder_attr.auto_into || field.builder_attr.strip_option {
11581155
let marker_ident = syn::Ident::new("__Marker", proc_macro2::Span::call_site());
11591156
marker = Some(marker_ident.clone());
11601157
(
1161-
quote!(impl dioxus_core::prelude::SuperInto<#arg_type, #marker_ident>),
1162-
quote!(dioxus_core::prelude::SuperInto::super_into(#field_name)),
1158+
quote!(impl dioxus_core::SuperInto<#arg_type, #marker_ident>),
1159+
quote!(dioxus_core::SuperInto::super_into(#field_name)),
11631160
)
11641161
} else if field.builder_attr.from_displayable {
11651162
(
@@ -1419,24 +1416,27 @@ Finally, call `.build()` to create the instance of `{name}`.
14191416
// If this is a signal type, we use super_into and the props struct as the owner
14201417
let is_child_owned_type = child_owned_type(field.ty);
14211418

1422-
let mut into = quote!{};
14231419

1424-
if !is_default {
1420+
let body = if !is_default {
14251421
if is_child_owned_type {
1426-
into = quote!{ .super_into() }
1422+
quote!{ dioxus_core::SuperInto::super_into(#default) }
14271423
} else if field.builder_attr.auto_into {
1428-
into = quote!{ .into() }
1424+
quote!{ (#default).into() }
14291425
} else if field.builder_attr.auto_to_string {
1430-
into = quote!{ .to_string() }
1426+
quote!{ (#default).to_string() }
1427+
} else {
1428+
default.to_token_stream()
14311429
}
1432-
}
1430+
} else {
1431+
default.to_token_stream()
1432+
};
14331433

14341434
if field.builder_attr.skip {
1435-
quote!(let #name = #default #into;)
1435+
quote!(let #name = #body;)
14361436
} else if is_child_owned_type {
1437-
quote!(let #name = #helper_trait_name::into_value(#name, || with_owner(self.owner.clone(), move || (#default) #into));)
1437+
quote!(let #name = #helper_trait_name::into_value(#name, || dioxus_core::with_owner(self.owner.clone(), move || #body));)
14381438
} else {
1439-
quote!(let #name = #helper_trait_name::into_value(#name, || #default #into);)
1439+
quote!(let #name = #helper_trait_name::into_value(#name, || #body);)
14401440
}
14411441
} else {
14421442
quote!(let #name = #name.0;)
@@ -1484,15 +1484,15 @@ Finally, call `.build()` to create the instance of `{name}`.
14841484
/// Create a component from the props.
14851485
pub fn into_vcomponent<M: 'static>(
14861486
self,
1487-
render_fn: impl dioxus_core::prelude::ComponentFunction<#original_name #ty_generics, M>,
1487+
render_fn: impl dioxus_core::ComponentFunction<#original_name #ty_generics, M>,
14881488
) -> dioxus_core::VComponent {
1489-
use dioxus_core::prelude::ComponentFunction;
1489+
use dioxus_core::ComponentFunction;
14901490
let component_name = ::std::any::type_name_of_val(&render_fn);
14911491
dioxus_core::VComponent::new(move |wrapper: Self| render_fn.rebuild(wrapper.inner), self, component_name)
14921492
}
14931493
}
14941494

1495-
impl #original_impl_generics dioxus_core::prelude::Properties for #name #ty_generics #where_clause {
1495+
impl #original_impl_generics dioxus_core::Properties for #name #ty_generics #where_clause {
14961496
type Builder = ();
14971497
fn builder() -> Self::Builder {
14981498
unreachable!()
@@ -1742,7 +1742,7 @@ fn child_owned_type(ty: &Type) -> bool {
17421742
fn looks_like_signal_type(ty: &Type) -> bool {
17431743
match extract_base_type_without_generics(ty) {
17441744
Some(path_without_generics) => {
1745-
path_without_generics == parse_quote!(dioxus_core::prelude::ReadOnlySignal)
1745+
path_without_generics == parse_quote!(dioxus_core::ReadOnlySignal)
17461746
|| path_without_generics == parse_quote!(prelude::ReadOnlySignal)
17471747
|| path_without_generics == parse_quote!(ReadOnlySignal)
17481748
}
@@ -1754,10 +1754,10 @@ fn looks_like_callback_type(ty: &Type) -> bool {
17541754
let type_without_option = remove_option_wrapper(ty.clone());
17551755
match extract_base_type_without_generics(&type_without_option) {
17561756
Some(path_without_generics) => {
1757-
path_without_generics == parse_quote!(dioxus_core::prelude::EventHandler)
1757+
path_without_generics == parse_quote!(dioxus_core::EventHandler)
17581758
|| path_without_generics == parse_quote!(prelude::EventHandler)
17591759
|| path_without_generics == parse_quote!(EventHandler)
1760-
|| path_without_generics == parse_quote!(dioxus_core::prelude::Callback)
1760+
|| path_without_generics == parse_quote!(dioxus_core::Callback)
17611761
|| path_without_generics == parse_quote!(prelude::Callback)
17621762
|| path_without_generics == parse_quote!(Callback)
17631763
}

packages/core-macro/tests/values_memoize_in_place.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use dioxus::prelude::*;
1+
use dioxus::{
2+
core::{generation, needs_update},
3+
prelude::*,
4+
};
25
use dioxus_core::ElementId;
36
use std::{any::Any, rc::Rc};
47

@@ -136,6 +139,8 @@ fn TakesSignal(sig: ReadOnlySignal<usize>, number: usize) -> Element {
136139
// Regression test for https://github.com/DioxusLabs/dioxus/issues/2582
137140
#[test]
138141
fn spreads_memorize_in_place() {
142+
use dioxus_core::Properties;
143+
139144
#[derive(Props, Clone, PartialEq)]
140145
struct CompProps {
141146
#[props(extends = GlobalAttributes)]

packages/core/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
```rust, no_run
66
# tokio::runtime::Runtime::new().unwrap().block_on(async {
7-
use dioxus_core::prelude::*;
8-
use dioxus_core::*;
7+
use dioxus_core::{VirtualDom, Event, Element, Mutations};
98
109
let mut vdom = VirtualDom::new(app);
1110
let real_dom = SomeRenderer::new();

packages/core/src/diff/component.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ use crate::{
1010
VComponent, WriteMutations,
1111
},
1212
nodes::{AsVNode, VNode},
13-
prelude::SuspenseContext,
1413
scopes::ScopeId,
1514
virtual_dom::VirtualDom,
16-
Element,
15+
Element, SuspenseContext,
1716
};
1817

1918
impl VirtualDom {

packages/core/src/events.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use crate::{
2-
prelude::current_scope_id, properties::SuperFrom, runtime::RuntimeGuard, Runtime, ScopeId,
3-
};
1+
use crate::{current_scope_id, properties::SuperFrom, runtime::RuntimeGuard, Runtime, ScopeId};
42
use generational_box::GenerationalBox;
53
use std::{any::Any, cell::RefCell, marker::PhantomData, panic::Location, rc::Rc};
64

@@ -337,7 +335,7 @@ impl<Ret> SpawnIfAsync<(), Ret> for Ret {
337335
pub struct AsyncMarker;
338336
impl<F: std::future::Future<Output = ()> + 'static> SpawnIfAsync<AsyncMarker> for F {
339337
fn spawn(self) {
340-
crate::prelude::spawn(async move {
338+
crate::spawn(async move {
341339
self.await;
342340
});
343341
}
@@ -353,9 +351,9 @@ where
353351
{
354352
#[inline]
355353
fn spawn(self) {
356-
crate::prelude::spawn(async move {
354+
crate::spawn(async move {
357355
if let Err(err) = self.await {
358-
crate::prelude::throw_error(err)
356+
crate::throw_error(err)
359357
}
360358
});
361359
}
@@ -366,7 +364,7 @@ impl SpawnIfAsync<()> for crate::Result<()> {
366364
#[inline]
367365
fn spawn(self) {
368366
if let Err(err) = self {
369-
crate::prelude::throw_error(err)
367+
crate::throw_error(err)
370368
}
371369
}
372370
}

0 commit comments

Comments
 (0)