mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
include more platforms in the launch builder
This commit is contained in:
parent
74ec3a4a82
commit
0932130e87
10 changed files with 65 additions and 10 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -2325,6 +2325,8 @@ dependencies = [
|
|||
"dioxus-router",
|
||||
"dioxus-rsx",
|
||||
"dioxus-signals",
|
||||
"dioxus-ssr",
|
||||
"dioxus-tui",
|
||||
"dioxus-web",
|
||||
"env_logger",
|
||||
"futures-util",
|
||||
|
@ -2564,6 +2566,7 @@ dependencies = [
|
|||
"dioxus-desktop",
|
||||
"dioxus-hot-reload",
|
||||
"dioxus-lib",
|
||||
"dioxus-mobile",
|
||||
"dioxus-ssr",
|
||||
"dioxus-web",
|
||||
"dioxus_server_macro",
|
||||
|
|
|
@ -20,6 +20,7 @@ quote = "1.0"
|
|||
default = []
|
||||
fullstack = []
|
||||
desktop = []
|
||||
mobile = []
|
||||
web = []
|
||||
ssr = []
|
||||
liveview = []
|
||||
|
|
|
@ -24,7 +24,8 @@ dioxus-mobile = { workspace = true, optional = true }
|
|||
dioxus-desktop = { workspace = true, optional = true }
|
||||
dioxus-fullstack = { 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 }
|
||||
|
||||
|
@ -45,14 +46,15 @@ router = ["dioxus-router"]
|
|||
# Platforms
|
||||
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?/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"]
|
||||
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"]
|
||||
axum = ["dioxus-fullstack?/axum"]
|
||||
salvo = ["dioxus-fullstack?/salvo"]
|
||||
warp = ["dioxus-fullstack?/warp"]
|
||||
# tui = ["dioxus-tui", "dioxus-config-macro/tui"]
|
||||
tui = ["dioxus-tui", "dioxus-config-macro/tui"]
|
||||
|
||||
[dev-dependencies]
|
||||
futures-util = { workspace = true }
|
||||
|
|
|
@ -153,10 +153,26 @@ mod current_platform {
|
|||
#[cfg(all(feature = "web", not(any(feature = "desktop", feature = "fullstack"))))]
|
||||
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 = ();
|
||||
|
||||
#[cfg(not(any(feature = "desktop", feature = "web", feature = "fullstack")))]
|
||||
#[cfg(not(any(
|
||||
feature = "desktop",
|
||||
feature = "web",
|
||||
feature = "tui",
|
||||
feature = "fullstack"
|
||||
)))]
|
||||
pub fn launch(
|
||||
root: fn() -> dioxus_core::Element,
|
||||
contexts: Vec<Box<super::ValidContext>>,
|
||||
|
|
|
@ -77,9 +77,18 @@ pub use dioxus_fullstack as fullstack;
|
|||
#[cfg(feature = "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")]
|
||||
pub use dioxus_tui as tui;
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
pub use dioxus_ssr as ssr;
|
||||
|
||||
/// Try to evaluate javascript in the target window
|
||||
///
|
||||
/// For the browser, this is the window object
|
||||
|
|
|
@ -39,6 +39,9 @@ dioxus-web = { workspace = true, features = ["hydrate"], optional = true }
|
|||
# Desktop Integration
|
||||
dioxus-desktop = { workspace = true, optional = true }
|
||||
|
||||
# Mobile Integration
|
||||
dioxus-mobile = { workspace = true, optional = true }
|
||||
|
||||
tracing = { workspace = true }
|
||||
tracing-futures = { workspace = true, optional = true }
|
||||
once_cell = "1.17.1"
|
||||
|
@ -70,6 +73,7 @@ default = ["hot-reload"]
|
|||
hot-reload = ["serde_json", "futures-util"]
|
||||
web = ["dioxus-web", "web-sys"]
|
||||
desktop = ["dioxus-desktop"]
|
||||
mobile = ["dioxus-mobile"]
|
||||
warp = ["dep:warp", "ssr"]
|
||||
axum = ["dep:axum", "tower-http", "ssr"]
|
||||
salvo = ["dep:salvo", "ssr", "http-body-util"]
|
||||
|
|
|
@ -20,6 +20,9 @@ pub struct Config {
|
|||
|
||||
#[cfg(feature = "desktop")]
|
||||
pub(crate) desktop_cfg: dioxus_desktop::Config,
|
||||
|
||||
#[cfg(feature = "mobile")]
|
||||
pub(crate) mobile_cfg: dioxus_mobile::Config,
|
||||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)]
|
||||
|
@ -36,6 +39,8 @@ impl Default for Config {
|
|||
web_cfg: dioxus_web::Config::default(),
|
||||
#[cfg(feature = "desktop")]
|
||||
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")]
|
||||
/// Launch a server application
|
||||
pub async fn launch_server(
|
||||
|
@ -110,7 +121,7 @@ impl Config {
|
|||
|
||||
let ssr_state = SSRState::new(&cfg);
|
||||
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
|
||||
.serve_static_assets(cfg.assets_path)
|
||||
.connect_hot_reload()
|
||||
|
@ -132,7 +143,7 @@ impl Config {
|
|||
use warp::Filter;
|
||||
// First register the server functions
|
||||
let router = register_server_fns(server_fn_route);
|
||||
#[cfg(not(feature = "desktop"))]
|
||||
#[cfg(not(any(feature = "desktop", feature = "mobile")))]
|
||||
let router = {
|
||||
// Serve the dist folder and the index.html file
|
||||
let serve_dir = warp::fs::dir(cfg.assets_path);
|
||||
|
@ -159,7 +170,7 @@ impl Config {
|
|||
use crate::adapters::salvo_adapter::{DioxusRouterExt, SSRHandler};
|
||||
use salvo::conn::Listener;
|
||||
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
|
||||
.serve_static_assets(cfg.assets_path)
|
||||
.connect_hot_reload()
|
||||
|
|
|
@ -41,5 +41,11 @@ pub fn launch(
|
|||
let cfg = platform_config.desktop_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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)))]
|
||||
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.");
|
||||
|
|
|
@ -10,7 +10,7 @@ keywords = ["dom", "ui", "gui", "react"]
|
|||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
dioxus-desktop = { workspace = true }
|
||||
dioxus-desktop = { workspace = true, default-features = false, features = ["tokio_runtime"] }
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
|
Loading…
Reference in a new issue