include more platforms in the launch builder

This commit is contained in:
Evan Almloff committed 2024-01-22 08:58:35 -06:00
1 parent 74ec3a4a82
commit 0932130e87
10 files changed
+65 -10

No files matched your search

Generated
+3
View File
@@ -2325,6 +2325,8 @@ dependencies = [
"dioxus-router", "dioxus-router",
"dioxus-rsx", "dioxus-rsx",
"dioxus-signals", "dioxus-signals",
"dioxus-ssr",
"dioxus-tui",
"dioxus-web", "dioxus-web",
"env_logger", "env_logger",
"futures-util", "futures-util",
@@ -2564,6 +2566,7 @@ dependencies = [
"dioxus-desktop", "dioxus-desktop",
"dioxus-hot-reload", "dioxus-hot-reload",
"dioxus-lib", "dioxus-lib",
"dioxus-mobile",
"dioxus-ssr", "dioxus-ssr",
"dioxus-web", "dioxus-web",
"dioxus_server_macro", "dioxus_server_macro",
+1
View File
@@ -20,6 +20,7 @@ quote = "1.0"
default = [] default = []
fullstack = [] fullstack = []
desktop = [] desktop = []
mobile = []
web = [] web = []
ssr = [] ssr = []
liveview = [] liveview = []
+6 -4
View File
@@ -24,7 +24,8 @@ dioxus-mobile = { workspace = true, optional = true }
dioxus-desktop = { workspace = true, optional = true } dioxus-desktop = { workspace = true, optional = true }
dioxus-fullstack = { workspace = true, optional = true } dioxus-fullstack = { workspace = true, optional = true }
dioxus-liveview = { workspace = true, optional = true } dioxus-liveview = { workspace = true, optional = true }
# dioxus-tui = { workspace = true, optional = true } dioxus-ssr ={ workspace = true, optional = true }
dioxus-tui = { workspace = true, optional = true }
serde = { version = "1.0.136", optional = true } serde = { version = "1.0.136", optional = true }
@@ -45,14 +46,15 @@ router = ["dioxus-router"]
# Platforms # Platforms
fullstack = ["dioxus-fullstack", "dioxus-config-macro/fullstack", "serde", "dioxus-router?/fullstack"] fullstack = ["dioxus-fullstack", "dioxus-config-macro/fullstack", "serde", "dioxus-router?/fullstack"]
desktop = ["dioxus-desktop", "dioxus-fullstack?/desktop", "dioxus-config-macro/desktop"] desktop = ["dioxus-desktop", "dioxus-fullstack?/desktop", "dioxus-config-macro/desktop"]
mobile = ["dioxus-mobile", "dioxus-fullstack?/desktop", "dioxus-config-macro/desktop"] # todo: use the mobile versions of these 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-config-macro/web", "dioxus-router?/web"]
ssr = ["dioxus-fullstack?/ssr", "dioxus-config-macro/ssr", "dioxus-router?/ssr"] server = ["dioxus-fullstack?/ssr", "dioxus-config-macro/ssr", "dioxus-router?/ssr"]
ssr = ["dioxus-ssr"]
liveview = ["dioxus-liveview", "dioxus-config-macro/liveview", "dioxus-router?/liveview"] liveview = ["dioxus-liveview", "dioxus-config-macro/liveview", "dioxus-router?/liveview"]
axum = ["dioxus-fullstack?/axum"] axum = ["dioxus-fullstack?/axum"]
salvo = ["dioxus-fullstack?/salvo"] salvo = ["dioxus-fullstack?/salvo"]
warp = ["dioxus-fullstack?/warp"] warp = ["dioxus-fullstack?/warp"]
# tui = ["dioxus-tui", "dioxus-config-macro/tui"] tui = ["dioxus-tui", "dioxus-config-macro/tui"]
[dev-dependencies] [dev-dependencies]
futures-util = { workspace = true } futures-util = { workspace = true }
+18 -2
View File
@@ -153,10 +153,26 @@ mod current_platform {
#[cfg(all(feature = "web", not(any(feature = "desktop", feature = "fullstack"))))] #[cfg(all(feature = "web", not(any(feature = "desktop", feature = "fullstack"))))]
pub use dioxus_web::launch::*; pub use dioxus_web::launch::*;
#[cfg(not(any(feature = "desktop", feature = "web", feature = "fullstack")))] #[cfg(all(
feature = "tui",
not(any(feature = "web", feature = "desktop", feature = "fullstack"))
))]
pub use dioxus_tui::launch::*;
#[cfg(not(any(
feature = "desktop",
feature = "web",
feature = "tui",
feature = "fullstack"
)))]
pub type Config = (); pub type Config = ();
#[cfg(not(any(feature = "desktop", feature = "web", feature = "fullstack")))] #[cfg(not(any(
feature = "desktop",
feature = "web",
feature = "tui",
feature = "fullstack"
)))]
pub fn launch( pub fn launch(
root: fn() -> dioxus_core::Element, root: fn() -> dioxus_core::Element,
contexts: Vec<Box<super::ValidContext>>, contexts: Vec<Box<super::ValidContext>>,
+9
View File
@@ -77,9 +77,18 @@ pub use dioxus_fullstack as fullstack;
#[cfg(feature = "desktop")] #[cfg(feature = "desktop")]
pub use dioxus_desktop as desktop; pub use dioxus_desktop as desktop;
#[cfg(feature = "mobile")]
pub use dioxus_desktop as mobile;
#[cfg(feature = "liveview")]
pub use dioxus_liveview as liveview;
#[cfg(feature = "tui")] #[cfg(feature = "tui")]
pub use dioxus_tui as tui; pub use dioxus_tui as tui;
#[cfg(feature = "ssr")]
pub use dioxus_ssr as ssr;
/// Try to evaluate javascript in the target window /// Try to evaluate javascript in the target window
/// ///
/// For the browser, this is the window object /// For the browser, this is the window object
+4
View File
@@ -39,6 +39,9 @@ dioxus-web = { workspace = true, features = ["hydrate"], optional = true }
# Desktop Integration # Desktop Integration
dioxus-desktop = { workspace = true, optional = true } dioxus-desktop = { workspace = true, optional = true }
# Mobile Integration
dioxus-mobile = { workspace = true, optional = true }
tracing = { workspace = true } tracing = { workspace = true }
tracing-futures = { workspace = true, optional = true } tracing-futures = { workspace = true, optional = true }
once_cell = "1.17.1" once_cell = "1.17.1"
@@ -70,6 +73,7 @@ default = ["hot-reload"]
hot-reload = ["serde_json", "futures-util"] hot-reload = ["serde_json", "futures-util"]
web = ["dioxus-web", "web-sys"] web = ["dioxus-web", "web-sys"]
desktop = ["dioxus-desktop"] desktop = ["dioxus-desktop"]
mobile = ["dioxus-mobile"]
warp = ["dep:warp", "ssr"] warp = ["dep:warp", "ssr"]
axum = ["dep:axum", "tower-http", "ssr"] axum = ["dep:axum", "tower-http", "ssr"]
salvo = ["dep:salvo", "ssr", "http-body-util"] salvo = ["dep:salvo", "ssr", "http-body-util"]
+14 -3
View File
@@ -20,6 +20,9 @@ pub struct Config {
#[cfg(feature = "desktop")] #[cfg(feature = "desktop")]
pub(crate) desktop_cfg: dioxus_desktop::Config, pub(crate) desktop_cfg: dioxus_desktop::Config,
#[cfg(feature = "mobile")]
pub(crate) mobile_cfg: dioxus_mobile::Config,
} }
#[allow(clippy::derivable_impls)] #[allow(clippy::derivable_impls)]
@@ -36,6 +39,8 @@ impl Default for Config {
web_cfg: dioxus_web::Config::default(), web_cfg: dioxus_web::Config::default(),
#[cfg(feature = "desktop")] #[cfg(feature = "desktop")]
desktop_cfg: dioxus_desktop::Config::default(), desktop_cfg: dioxus_desktop::Config::default(),
#[cfg(feature = "mobile")]
mobile_cfg: dioxus_mobile::Config::default(),
} }
} }
} }
@@ -92,6 +97,12 @@ impl Config {
} }
} }
/// Set the mobile config.
#[cfg(feature = "mobile")]
pub fn mobile_cfg(self, mobile_cfg: dioxus_mobile::Config) -> Self {
Self { mobile_cfg, ..self }
}
#[cfg(feature = "ssr")] #[cfg(feature = "ssr")]
/// Launch a server application /// Launch a server application
pub async fn launch_server( pub async fn launch_server(
@@ -110,7 +121,7 @@ impl Config {
let ssr_state = SSRState::new(&cfg); let ssr_state = SSRState::new(&cfg);
let router = axum::Router::new().register_server_fns(server_fn_route); let router = axum::Router::new().register_server_fns(server_fn_route);
#[cfg(not(feature = "desktop"))] #[cfg(not(any(feature = "desktop", feature = "mobile")))]
let router = router let router = router
.serve_static_assets(cfg.assets_path) .serve_static_assets(cfg.assets_path)
.connect_hot_reload() .connect_hot_reload()
@@ -132,7 +143,7 @@ impl Config {
use warp::Filter; use warp::Filter;
// First register the server functions // First register the server functions
let router = register_server_fns(server_fn_route); let router = register_server_fns(server_fn_route);
#[cfg(not(feature = "desktop"))] #[cfg(not(any(feature = "desktop", feature = "mobile")))]
let router = { let router = {
// Serve the dist folder and the index.html file // Serve the dist folder and the index.html file
let serve_dir = warp::fs::dir(cfg.assets_path); let serve_dir = warp::fs::dir(cfg.assets_path);
@@ -159,7 +170,7 @@ impl Config {
use crate::adapters::salvo_adapter::{DioxusRouterExt, SSRHandler}; use crate::adapters::salvo_adapter::{DioxusRouterExt, SSRHandler};
use salvo::conn::Listener; use salvo::conn::Listener;
let router = salvo::Router::new().register_server_fns(server_fn_route); let router = salvo::Router::new().register_server_fns(server_fn_route);
#[cfg(not(feature = "desktop"))] #[cfg(not(any(feature = "desktop", feature = "mobile")))]
let router = router let router = router
.serve_static_assets(cfg.assets_path) .serve_static_assets(cfg.assets_path)
.connect_hot_reload() .connect_hot_reload()
+6
View File
@@ -41,5 +41,11 @@ pub fn launch(
let cfg = platform_config.desktop_cfg; let cfg = platform_config.desktop_cfg;
dioxus_desktop::launch::launch_virtual_dom(virtual_dom_factory(), cfg) dioxus_desktop::launch::launch_virtual_dom(virtual_dom_factory(), cfg)
} }
#[cfg(feature = "mobile")]
{
let cfg = platform_config.mobile_cfg;
dioxus_mobile::launch::launch_virtual_dom(virtual_dom_factory(), cfg)
}
} }
} }
+3
View File
@@ -71,3 +71,6 @@ compile_error!("The `ssr` feature (enabled by `warp`, `axum`, or `salvo`) and `w
#[cfg(all(feature = "ssr", feature = "desktop", not(doc)))] #[cfg(all(feature = "ssr", feature = "desktop", not(doc)))]
compile_error!("The `ssr` feature (enabled by `warp`, `axum`, or `salvo`) and `desktop` feature are overlapping. Please choose one or the other."); compile_error!("The `ssr` feature (enabled by `warp`, `axum`, or `salvo`) and `desktop` feature are overlapping. Please choose one or the other.");
#[cfg(all(feature = "ssr", feature = "mobile", not(doc)))]
compile_error!("The `ssr` feature (enabled by `warp`, `axum`, or `salvo`) and `mobile` feature are overlapping. Please choose one or the other.");
+1 -1
View File
@@ -10,7 +10,7 @@ keywords = ["dom", "ui", "gui", "react"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
dioxus-desktop = { workspace = true } dioxus-desktop = { workspace = true, default-features = false, features = ["tokio_runtime"] }
[lib] [lib]
doctest = false doctest = false