Create a Static Site Generation platform; Deduplicate hot reloading code (#2226)
* create static site generation helpers in the router crate * work on integrating static site generation into fullstack * move ssg into a separate crate * integrate ssg with the launch builder * simplify ssg example * fix static_routes for child routes * move CLI hot reloading websocket code into dioxus-hot-reload * fix some unused imports * use the same hot reloading websocket code for fullstack * fix fullstack hot reloading * move cli hot reloading logic into the hot reload crate * ssg example working with dx serve * add more examples * fix clippy * fix formatting * fix hot reload doctest imports * fix axum imports * don't run server doc tests * Fix hot reload websocket doc examples
This commit is contained in:
1 parent
460b70e0f0
commit
245003a5d4
59 files changed
+1507
-791
No files matched your search
@@ -22,6 +22,7 @@ dioxus-web = { workspace = true, optional = true }
|
||||
dioxus-mobile = { workspace = true, optional = true }
|
||||
dioxus-desktop = { workspace = true, default-features = true, optional = true }
|
||||
dioxus-fullstack = { workspace = true, optional = true }
|
||||
dioxus-static-site-generation = { workspace = true, optional = true }
|
||||
dioxus-liveview = { workspace = true, optional = true }
|
||||
dioxus-ssr ={ workspace = true, optional = true }
|
||||
|
||||
@@ -45,10 +46,11 @@ router = ["dioxus-router"]
|
||||
fullstack = ["dioxus-fullstack", "dioxus-config-macro/fullstack", "serde", "dioxus-router?/fullstack"]
|
||||
desktop = ["dioxus-desktop", "dioxus-fullstack?/desktop", "dioxus-config-macro/desktop"]
|
||||
mobile = ["dioxus-mobile", "dioxus-fullstack?/mobile", "dioxus-config-macro/mobile"]
|
||||
web = ["dioxus-web", "dioxus-fullstack?/web", "dioxus-config-macro/web", "dioxus-router?/web"]
|
||||
web = ["dioxus-web", "dioxus-fullstack?/web", "dioxus-static-site-generation?/web", "dioxus-config-macro/web", "dioxus-router?/web"]
|
||||
ssr = ["dioxus-ssr", "dioxus-router?/ssr", "dioxus-config-macro/ssr"]
|
||||
liveview = ["dioxus-liveview", "dioxus-config-macro/liveview", "dioxus-router?/liveview"]
|
||||
axum = ["dioxus-fullstack?/axum", "dioxus-fullstack?/server", "ssr", "dioxus-liveview?/axum"]
|
||||
static-generation = ["dioxus-static-site-generation", "dioxus-config-macro/static-generation"]
|
||||
axum = ["dioxus-fullstack?/axum", "dioxus-fullstack?/server", "dioxus-static-site-generation?/server", "ssr", "dioxus-liveview?/axum"]
|
||||
|
||||
# This feature just disables the no-renderer-enabled warning
|
||||
third-party-renderer = []
|
||||
|
||||
@@ -17,10 +17,18 @@ pub struct LaunchBuilder<Cfg: 'static = (), ContextFn: ?Sized = ValidContext> {
|
||||
|
||||
pub type LaunchFn<Cfg, Context> = fn(fn() -> Element, Vec<Box<Context>>, Cfg);
|
||||
|
||||
#[cfg(any(feature = "fullstack", feature = "liveview"))]
|
||||
#[cfg(any(
|
||||
feature = "fullstack",
|
||||
feature = "static-generation",
|
||||
feature = "liveview"
|
||||
))]
|
||||
type ValidContext = SendContext;
|
||||
|
||||
#[cfg(not(any(feature = "fullstack", feature = "liveview")))]
|
||||
#[cfg(not(any(
|
||||
feature = "fullstack",
|
||||
feature = "static-generation",
|
||||
feature = "liveview"
|
||||
)))]
|
||||
type ValidContext = UnsendContext;
|
||||
|
||||
type SendContext = dyn Fn() -> Box<dyn Any> + Send + Sync + 'static;
|
||||
@@ -178,6 +186,7 @@ impl<Cfg: Default + 'static, ContextFn: ?Sized> LaunchBuilder<Cfg, ContextFn> {
|
||||
/// - `fullstack`
|
||||
/// - `desktop`
|
||||
/// - `mobile`
|
||||
/// - `static-generation`
|
||||
/// - `web`
|
||||
/// - `liveview`
|
||||
mod current_platform {
|
||||
@@ -195,6 +204,9 @@ mod current_platform {
|
||||
}
|
||||
use crate::prelude::TryIntoConfig;
|
||||
|
||||
#[cfg(feature = "fullstack")]
|
||||
pub use dioxus_fullstack::launch::*;
|
||||
|
||||
#[cfg(any(feature = "desktop", feature = "mobile"))]
|
||||
if_else_cfg! {
|
||||
if not(feature = "fullstack") {
|
||||
@@ -211,12 +223,22 @@ mod current_platform {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "fullstack")]
|
||||
pub use dioxus_fullstack::launch::*;
|
||||
#[cfg(feature = "static-generation")]
|
||||
if_else_cfg! {
|
||||
if all(not(feature = "fullstack"), not(feature = "desktop"), not(feature = "mobile")) {
|
||||
pub use dioxus_static_site_generation::launch::*;
|
||||
} else {
|
||||
impl TryIntoConfig<crate::launch::current_platform::Config> for ::dioxus_static_site_generation::Config {
|
||||
fn into_config(self) -> Option<crate::launch::current_platform::Config> {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "web")]
|
||||
if_else_cfg! {
|
||||
if not(any(feature = "desktop", feature = "mobile", feature = "fullstack")) {
|
||||
if not(any(feature = "desktop", feature = "mobile", feature = "fullstack", feature = "static-generation")) {
|
||||
pub use dioxus_web::launch::*;
|
||||
} else {
|
||||
impl TryIntoConfig<crate::launch::current_platform::Config> for ::dioxus_web::Config {
|
||||
@@ -234,7 +256,8 @@ mod current_platform {
|
||||
feature = "web",
|
||||
feature = "desktop",
|
||||
feature = "mobile",
|
||||
feature = "fullstack"
|
||||
feature = "fullstack",
|
||||
feature = "static-generation"
|
||||
))
|
||||
{
|
||||
pub use dioxus_liveview::launch::*;
|
||||
@@ -252,7 +275,8 @@ mod current_platform {
|
||||
feature = "desktop",
|
||||
feature = "mobile",
|
||||
feature = "web",
|
||||
feature = "fullstack"
|
||||
feature = "fullstack",
|
||||
feature = "static-generation"
|
||||
)))]
|
||||
pub type Config = ();
|
||||
|
||||
@@ -261,7 +285,8 @@ mod current_platform {
|
||||
feature = "desktop",
|
||||
feature = "mobile",
|
||||
feature = "web",
|
||||
feature = "fullstack"
|
||||
feature = "fullstack",
|
||||
feature = "static-generation"
|
||||
)))]
|
||||
pub fn launch(
|
||||
root: fn() -> dioxus_core::Element,
|
||||
|
||||
@@ -101,6 +101,10 @@ pub use dioxus_router as router;
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "fullstack")))]
|
||||
pub use dioxus_fullstack as fullstack;
|
||||
|
||||
#[cfg(feature = "static-generation")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "static-generation")))]
|
||||
pub use dioxus_static_site_generation as static_site_generation;
|
||||
|
||||
#[cfg(feature = "desktop")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "desktop")))]
|
||||
pub use dioxus_desktop as desktop;
|
||||
|
||||
Reference in new issue
Block a user