feat: Opt-out html in dioxus-router (#4217)
* feat: Opt-out `html` in `dioxus-router` * typo: Enable html by default * Fix cargo doc on html --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
7f44a09b38
commit
db3ce07030
4 files changed
+30
-8
No files matched your search
+1
-1
@@ -136,7 +136,7 @@ version = "0.7.0-alpha.1"
|
|||||||
# dependencies that are shared across packages
|
# dependencies that are shared across packages
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
dioxus = { path = "packages/dioxus", version = "0.7.0-alpha.1" }
|
dioxus = { path = "packages/dioxus", version = "0.7.0-alpha.1" }
|
||||||
dioxus-lib = { path = "packages/dioxus-lib", version = "0.7.0-alpha.1" }
|
dioxus-lib = { path = "packages/dioxus-lib", version = "0.7.0-alpha.1", default-features = false }
|
||||||
dioxus-core = { path = "packages/core", version = "0.7.0-alpha.1" }
|
dioxus-core = { path = "packages/core", version = "0.7.0-alpha.1" }
|
||||||
dioxus-core-types = { path = "packages/core-types", version = "0.7.0-alpha.1" }
|
dioxus-core-types = { path = "packages/core-types", version = "0.7.0-alpha.1" }
|
||||||
dioxus-core-macro = { path = "packages/core-macro", version = "0.7.0-alpha.1" }
|
dioxus-core-macro = { path = "packages/core-macro", version = "0.7.0-alpha.1" }
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ homepage = "https://dioxuslabs.com"
|
|||||||
keywords = ["dom", "ui", "gui", "react", "wasm"]
|
keywords = ["dom", "ui", "gui", "react", "wasm"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dioxus-lib = { workspace = true }
|
dioxus-lib = { workspace = true, default-features = false, features = ["signals", "macro", "hooks"] }
|
||||||
dioxus-history = { workspace = true }
|
dioxus-history = { workspace = true }
|
||||||
dioxus-router-macro = { workspace = true }
|
dioxus-router-macro = { workspace = true }
|
||||||
dioxus-fullstack-hooks = { workspace = true, optional = true }
|
dioxus-fullstack-hooks = { workspace = true, optional = true }
|
||||||
@@ -21,9 +21,10 @@ dioxus-cli-config = { workspace = true }
|
|||||||
rustversion = { workspace = true }
|
rustversion = { workspace = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = ["html"]
|
||||||
streaming = ["dep:dioxus-fullstack-hooks"]
|
streaming = ["dep:dioxus-fullstack-hooks"]
|
||||||
wasm-split = []
|
wasm-split = []
|
||||||
|
html = ["dioxus-lib/html"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
axum = { workspace = true, features = ["ws"] }
|
axum = { workspace = true, features = ["ws"] }
|
||||||
|
|||||||
@@ -10,13 +10,19 @@ pub mod routable;
|
|||||||
|
|
||||||
/// Components interacting with the router.
|
/// Components interacting with the router.
|
||||||
pub mod components {
|
pub mod components {
|
||||||
|
#[cfg(feature = "html")]
|
||||||
mod default_errors;
|
mod default_errors;
|
||||||
|
#[cfg(feature = "html")]
|
||||||
pub use default_errors::*;
|
pub use default_errors::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "html")]
|
||||||
mod history_buttons;
|
mod history_buttons;
|
||||||
|
#[cfg(feature = "html")]
|
||||||
pub use history_buttons::*;
|
pub use history_buttons::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "html")]
|
||||||
mod link;
|
mod link;
|
||||||
|
#[cfg(feature = "html")]
|
||||||
pub use link::*;
|
pub use link::*;
|
||||||
|
|
||||||
mod outlet;
|
mod outlet;
|
||||||
@@ -60,10 +66,11 @@ pub use hooks::router;
|
|||||||
|
|
||||||
/// A collection of useful items most applications might need.
|
/// A collection of useful items most applications might need.
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
|
#[cfg(feature = "html")]
|
||||||
pub use crate::components::{
|
pub use crate::components::{
|
||||||
GoBackButton, GoForwardButton, HistoryButtonProps, Link, LinkProps, Outlet, Router,
|
GoBackButton, GoForwardButton, HistoryButtonProps, Link, LinkProps,
|
||||||
RouterProps,
|
|
||||||
};
|
};
|
||||||
|
pub use crate::components::{Outlet, Router, RouterProps};
|
||||||
pub use crate::contexts::*;
|
pub use crate::contexts::*;
|
||||||
pub use crate::hooks::*;
|
pub use crate::hooks::*;
|
||||||
pub use crate::navigation::*;
|
pub use crate::navigation::*;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{components::FailureExternalNavigation, prelude::*};
|
use crate::prelude::*;
|
||||||
use dioxus_lib::prelude::*;
|
use dioxus_lib::prelude::*;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@@ -31,10 +31,21 @@ pub struct RouterConfig<R> {
|
|||||||
pub(crate) on_update: Option<RoutingCallback<R>>,
|
pub(crate) on_update: Option<RoutingCallback<R>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "html"))]
|
||||||
impl<R> Default for RouterConfig<R> {
|
impl<R> Default for RouterConfig<R> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
failure_external_navigation: FailureExternalNavigation,
|
failure_external_navigation: || VNode::empty(),
|
||||||
|
on_update: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "html")]
|
||||||
|
impl<R> Default for RouterConfig<R> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
failure_external_navigation: crate::components::FailureExternalNavigation,
|
||||||
on_update: None,
|
on_update: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,7 +80,10 @@ where
|
|||||||
|
|
||||||
/// A component to render when an external navigation fails.
|
/// A component to render when an external navigation fails.
|
||||||
///
|
///
|
||||||
/// Defaults to a router-internal component called [`FailureExternalNavigation`]
|
#[cfg_attr(
|
||||||
|
feature = "html",
|
||||||
|
doc = "Defaults to [`crate::components::FailureExternalNavigation`]."
|
||||||
|
)]
|
||||||
pub fn failure_external_navigation(self, component: fn() -> Element) -> Self {
|
pub fn failure_external_navigation(self, component: fn() -> Element) -> Self {
|
||||||
Self {
|
Self {
|
||||||
failure_external_navigation: component,
|
failure_external_navigation: component,
|
||||||
|
|||||||
Reference in new issue
Block a user