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:
Marc EspinandJonathan Kelley authored and GitHub committed 2025-06-18 16:40:07 -07:00
1 parent 7f44a09b38
commit db3ce07030
4 files changed
+30 -8

No files matched your search

+1 -1
View File
@@ -136,7 +136,7 @@ version = "0.7.0-alpha.1"
# dependencies that are shared across packages
[workspace.dependencies]
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-types = { path = "packages/core-types", version = "0.7.0-alpha.1" }
dioxus-core-macro = { path = "packages/core-macro", version = "0.7.0-alpha.1" }
+3 -2
View File
@@ -10,7 +10,7 @@ homepage = "https://dioxuslabs.com"
keywords = ["dom", "ui", "gui", "react", "wasm"]
[dependencies]
dioxus-lib = { workspace = true }
dioxus-lib = { workspace = true, default-features = false, features = ["signals", "macro", "hooks"] }
dioxus-history = { workspace = true }
dioxus-router-macro = { workspace = true }
dioxus-fullstack-hooks = { workspace = true, optional = true }
@@ -21,9 +21,10 @@ dioxus-cli-config = { workspace = true }
rustversion = { workspace = true }
[features]
default = []
default = ["html"]
streaming = ["dep:dioxus-fullstack-hooks"]
wasm-split = []
html = ["dioxus-lib/html"]
[dev-dependencies]
axum = { workspace = true, features = ["ws"] }
+9 -2
View File
@@ -10,13 +10,19 @@ pub mod routable;
/// Components interacting with the router.
pub mod components {
#[cfg(feature = "html")]
mod default_errors;
#[cfg(feature = "html")]
pub use default_errors::*;
#[cfg(feature = "html")]
mod history_buttons;
#[cfg(feature = "html")]
pub use history_buttons::*;
#[cfg(feature = "html")]
mod link;
#[cfg(feature = "html")]
pub use link::*;
mod outlet;
@@ -60,10 +66,11 @@ 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, Outlet, Router,
RouterProps,
GoBackButton, GoForwardButton, HistoryButtonProps, Link, LinkProps,
};
pub use crate::components::{Outlet, Router, RouterProps};
pub use crate::contexts::*;
pub use crate::hooks::*;
pub use crate::navigation::*;
+17 -3
View File
@@ -1,4 +1,4 @@
use crate::{components::FailureExternalNavigation, prelude::*};
use crate::prelude::*;
use dioxus_lib::prelude::*;
use std::sync::Arc;
@@ -31,10 +31,21 @@ pub struct RouterConfig<R> {
pub(crate) on_update: Option<RoutingCallback<R>>,
}
#[cfg(not(feature = "html"))]
impl<R> Default for RouterConfig<R> {
fn default() -> 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,
}
}
@@ -69,7 +80,10 @@ where
/// 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 {
Self {
failure_external_navigation: component,