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
This commit is contained in:
1 parent
54d465a7b5
commit
4f1d039bad
140 files changed
+374
-477
No files matched your search
@@ -2,7 +2,7 @@
|
||||
/// to the child router that maps child routes to root routes and vice versa.
|
||||
use dioxus_lib::prelude::*;
|
||||
|
||||
use crate::prelude::Routable;
|
||||
use crate::Routable;
|
||||
|
||||
/// Maps a child route into the root router and vice versa
|
||||
// NOTE: Currently child routers only support simple static prefixes, but this
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::prelude::{outlet::OutletContext, *};
|
||||
use crate::{outlet::OutletContext, *};
|
||||
use dioxus_lib::prelude::*;
|
||||
|
||||
/// An outlet for the current content.
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
use dioxus_lib::prelude::*;
|
||||
|
||||
use crate::{
|
||||
prelude::{provide_router_context, Outlet},
|
||||
routable::Routable,
|
||||
router_cfg::RouterConfig,
|
||||
};
|
||||
use crate::{provide_router_context, routable::Routable, router_cfg::RouterConfig, Outlet};
|
||||
|
||||
/// The props for [`Router`].
|
||||
#[derive(Props)]
|
||||
@@ -38,7 +34,7 @@ impl<R: Clone> PartialEq for RouterProps<R> {
|
||||
|
||||
/// A component that renders the current route.
|
||||
pub fn Router<R: Routable + Clone>(props: RouterProps<R>) -> Element {
|
||||
use crate::prelude::{outlet::OutletContext, RouterContext};
|
||||
use crate::{outlet::OutletContext, RouterContext};
|
||||
|
||||
use_hook(|| {
|
||||
provide_router_context(RouterContext::new(props.config.call(())));
|
||||
@@ -46,7 +42,7 @@ pub fn Router<R: Routable + Clone>(props: RouterProps<R>) -> Element {
|
||||
|
||||
#[cfg(feature = "streaming")]
|
||||
use_after_suspense_resolved(|| {
|
||||
dioxus_fullstack_hooks::prelude::commit_initial_chunk();
|
||||
dioxus_fullstack_hooks::commit_initial_chunk();
|
||||
});
|
||||
|
||||
use_hook(|| {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::prelude::{ExternalNavigationFailure, NavigationTarget, RouterContext};
|
||||
use crate::{ExternalNavigationFailure, NavigationTarget, RouterContext};
|
||||
|
||||
/// Acquire the navigator without subscribing to updates.
|
||||
///
|
||||
@@ -9,7 +9,7 @@ use crate::prelude::{ExternalNavigationFailure, NavigationTarget, RouterContext}
|
||||
/// Panics if there is no router present.
|
||||
pub fn navigator() -> Navigator {
|
||||
Navigator(
|
||||
dioxus_lib::prelude::try_consume_context::<RouterContext>()
|
||||
dioxus_lib::core::try_consume_context::<RouterContext>()
|
||||
.expect("A router must be present to use navigator"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use dioxus_lib::prelude::*;
|
||||
use dioxus_lib::core::{provide_context, try_consume_context, use_hook, Element, VNode};
|
||||
|
||||
use crate::{routable::Routable, utils::use_router_internal::use_router_internal};
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ use std::{
|
||||
};
|
||||
|
||||
use dioxus_history::history;
|
||||
use dioxus_lib::prelude::*;
|
||||
use dioxus_lib::{core::ReactiveContext, prelude::*};
|
||||
|
||||
use crate::{
|
||||
components::child_router::consume_child_route_mapping, navigation::NavigationTarget,
|
||||
prelude::SiteMapSegment, routable::Routable, router_cfg::RouterConfig,
|
||||
routable::Routable, router_cfg::RouterConfig, SiteMapSegment,
|
||||
};
|
||||
|
||||
/// An error that is thrown when the router fails to parse a route
|
||||
@@ -268,7 +268,7 @@ impl RouterContext {
|
||||
match route {
|
||||
Ok(route) => route,
|
||||
Err(err) => {
|
||||
throw_error(ParseRouteError { message: err });
|
||||
dioxus_core::throw_error(ParseRouteError { message: err });
|
||||
"/".parse().unwrap_or_else(|err| panic!("{err}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use dioxus_lib::prelude::{try_consume_context, use_hook};
|
||||
use dioxus_lib::core::{try_consume_context, use_hook};
|
||||
|
||||
use crate::prelude::{Navigator, RouterContext};
|
||||
use crate::{Navigator, RouterContext};
|
||||
|
||||
/// A hook that provides access to the navigator to change the router history.
|
||||
///
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
use crate::prelude::*;
|
||||
use crate::utils::use_router_internal::use_router_internal;
|
||||
use crate::Routable;
|
||||
|
||||
/// A hook that provides access to information about the current routing location.
|
||||
///
|
||||
/// > The Routable macro will define a version of this hook with an explicit type.
|
||||
///
|
||||
/// # Panic
|
||||
/// - When the calling component is not nested within a [`Router`] component.
|
||||
/// - When the calling component is not nested within a [`crate::Router`] component.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// # use dioxus::prelude::*;
|
||||
/// # use dioxus_router::{prelude::*};
|
||||
///
|
||||
/// #[derive(Clone, Routable)]
|
||||
/// enum Route {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{prelude::RouterContext, utils::use_router_internal::use_router_internal};
|
||||
use crate::{utils::use_router_internal::use_router_internal, RouterContext};
|
||||
|
||||
#[deprecated = "prefer the `router()` function or `use_route` functions"]
|
||||
#[must_use]
|
||||
@@ -10,11 +10,11 @@ pub fn use_router() -> RouterContext {
|
||||
/// Acquire the router without subscribing to updates.
|
||||
#[doc(alias = "url")]
|
||||
pub fn router() -> RouterContext {
|
||||
dioxus_lib::prelude::consume_context()
|
||||
dioxus_lib::core::consume_context()
|
||||
}
|
||||
|
||||
/// Try to acquire the router without subscribing to updates.
|
||||
#[doc(alias = "url")]
|
||||
pub fn try_router() -> Option<RouterContext> {
|
||||
dioxus_lib::prelude::try_consume_context()
|
||||
dioxus_lib::core::try_consume_context()
|
||||
}
|
||||
+18
-22
@@ -56,6 +56,7 @@ pub mod hooks {
|
||||
pub use use_router::*;
|
||||
|
||||
mod use_route;
|
||||
|
||||
pub use use_route::*;
|
||||
|
||||
mod use_navigator;
|
||||
@@ -64,30 +65,25 @@ pub mod hooks {
|
||||
|
||||
pub use hooks::router;
|
||||
|
||||
/// A collection of useful items most applications might need.
|
||||
pub mod prelude {
|
||||
#[cfg(feature = "html")]
|
||||
pub use crate::components::{
|
||||
GoBackButton, GoForwardButton, HistoryButtonProps, Link, LinkProps,
|
||||
};
|
||||
pub use crate::components::{Outlet, Router, RouterProps};
|
||||
pub use crate::contexts::*;
|
||||
pub use crate::hooks::*;
|
||||
pub use crate::navigation::*;
|
||||
pub use crate::routable::*;
|
||||
pub use crate::router_cfg::RouterConfig;
|
||||
pub use dioxus_router_macro::Routable;
|
||||
#[cfg(feature = "html")]
|
||||
pub use crate::components::{GoBackButton, GoForwardButton, HistoryButtonProps, Link, LinkProps};
|
||||
pub use crate::components::{Outlet, Router, RouterProps};
|
||||
pub use crate::contexts::*;
|
||||
pub use crate::hooks::*;
|
||||
pub use crate::navigation::*;
|
||||
pub use crate::routable::*;
|
||||
pub use crate::router_cfg::RouterConfig;
|
||||
pub use dioxus_router_macro::Routable;
|
||||
|
||||
#[doc(hidden)]
|
||||
/// A component with props used in the macro
|
||||
pub trait HasProps {
|
||||
/// The props type of the component.
|
||||
type Props;
|
||||
}
|
||||
#[doc(hidden)]
|
||||
/// A component with props used in the macro
|
||||
pub trait HasProps {
|
||||
/// The props type of the component.
|
||||
type Props;
|
||||
}
|
||||
|
||||
impl<P> HasProps for dioxus_lib::prelude::Component<P> {
|
||||
type Props = P;
|
||||
}
|
||||
impl<P> HasProps for dioxus_lib::core::Component<P> {
|
||||
type Props = P;
|
||||
}
|
||||
|
||||
mod utils {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#![allow(non_snake_case)]
|
||||
//! # Routable
|
||||
|
||||
#![allow(non_snake_case)]
|
||||
use dioxus_lib::prelude::*;
|
||||
|
||||
use dioxus_lib::core::Element;
|
||||
use std::iter::FlatMap;
|
||||
use std::slice::Iter;
|
||||
use std::{fmt::Display, str::FromStr};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::prelude::*;
|
||||
use dioxus_lib::prelude::*;
|
||||
use crate::{GenericRouterContext, NavigationTarget, Routable, RoutingCallback};
|
||||
use dioxus_lib::core::Element;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Global configuration options for the router.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use dioxus_lib::prelude::*;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::RouterContext;
|
||||
use dioxus_lib::core::{try_consume_context, use_hook};
|
||||
|
||||
/// A private hook to subscribe to the router.
|
||||
///
|
||||
@@ -8,7 +7,7 @@ use crate::prelude::*;
|
||||
/// single component, but not recommended. Multiple subscriptions will be discarded.
|
||||
///
|
||||
/// # Return values
|
||||
/// - [`None`], when the current component isn't a descendant of a [`Router`] component.
|
||||
/// - [`None`], when the current component isn't a descendant of a [`crate::Router`] component.
|
||||
/// - Otherwise [`Some`].
|
||||
pub(crate) fn use_router_internal() -> Option<RouterContext> {
|
||||
use_hook(try_consume_context)
|
||||
|
||||
Reference in new issue
Block a user