Fix compile checks on numerous packages using --all --all-features

This commit is contained in:
Jonathan Kelley committed 2024-01-18 16:27:43 -08:00
1 parent 3506b3ea72
commit d8af9b7ed1
38 files changed
+147 -186

No files matched your search

+9 -43
View File
@@ -7,15 +7,19 @@ use std::sync::Arc;
/// Settings for a fullstack app.
pub struct Config {
#[cfg(feature = "ssr")]
server_fn_route: &'static str,
pub(crate) server_fn_route: &'static str,
#[cfg(feature = "ssr")]
server_cfg: ServeConfigBuilder,
pub(crate) server_cfg: ServeConfigBuilder,
#[cfg(feature = "ssr")]
addr: std::net::SocketAddr,
pub(crate) addr: std::net::SocketAddr,
#[cfg(feature = "web")]
web_cfg: dioxus_web::Config,
pub(crate) web_cfg: dioxus_web::Config,
#[cfg(feature = "desktop")]
desktop_cfg: dioxus_desktop::Config,
pub(crate) desktop_cfg: dioxus_desktop::Config,
}
#[allow(clippy::derivable_impls)]
@@ -88,44 +92,6 @@ impl Config {
}
}
/// Launch the app.
pub fn launch(self, build_virtual_dom: impl Fn() -> VirtualDom + Send + Sync + 'static) {
#[cfg(feature = "ssr")]
tokio::runtime::Runtime::new()
.unwrap()
.block_on(async move {
self.launch_server(build_virtual_dom).await;
});
#[cfg(not(feature = "ssr"))]
{
#[cfg(feature = "web")]
self.launch_web(build_virtual_dom);
#[cfg(feature = "desktop")]
self.launch_desktop(build_virtual_dom);
}
}
#[cfg(feature = "web")]
/// Launch the web application
pub fn launch_web(self, build_virtual_dom: impl Fn() -> VirtualDom + Send + Sync + 'static) {
#[cfg(not(feature = "ssr"))]
{
let cfg = self.web_cfg.hydrate(true);
dioxus_web::launch::launch_virtual_dom(
// TODO: this should pull the props from the document
build_virtual_dom(),
cfg,
);
}
}
#[cfg(feature = "desktop")]
/// Launch the web application
pub fn launch_desktop<P: AnyProps>(self, build_virtual_dom: impl Fn() -> VirtualDom + 'static) {
let cfg = self.desktop_cfg;
dioxus_desktop::launch::launch_with_props_blocking(self.component, self.props, cfg);
}
#[cfg(feature = "ssr")]
/// Launch a server application
pub async fn launch_server(
+12 -2
View File
@@ -20,17 +20,27 @@ pub fn launch(
}
vdom
};
#[cfg(feature = "ssr")]
tokio::runtime::Runtime::new()
.unwrap()
.block_on(async move {
platform_config.launch_server(virtual_dom_factory).await;
});
#[cfg(not(feature = "ssr"))]
{
#[cfg(feature = "web")]
platform_config.launch_web(virtual_dom_factory);
{
// TODO: this should pull the props from the document
let cfg = platform_config.web_cfg.hydrate(true);
dioxus_web::launch::launch_virtual_dom(virtual_dom_factory(), cfg);
}
#[cfg(feature = "desktop")]
platform_config.launch_desktop(virtual_dom_factory);
{
let cfg = platform_config.desktop_cfg;
dioxus_desktop::launch::launch_virtual_dom(virtual_dom_factory(), cfg)
}
}
}