cli json output, dx bundle fix, dx serve --platform android, race condition, drop ssg platform (#3186)

* clean up logging to avoid random extra trace

* fix race condition with updates

* properly wire up verbose

* fix bundling (macos) and logging

* Add structured output

* clean up clap names

* extract out wire format

* switch structured key to json

* fix random println, fallback to `dioxus/platform`

* clean up logging for run/build

* clean up logging around project

* remove manual exits

* fix tokio runtime for mobile

* rework dog app

* rip out ssg

* Switch dioxus/axum to dioxus/server

* add android template inline

* pre restructure for bundle prep

* add the whole res directory

* Better theme for the app

* remove mobile demo now that most apps work natively

* self-referential android

* only use deep linking for assets

* fix imports for android

* clippy, fixup ios and android

* I'm not boxing compiler message you can't make me

* fix clippy on unix
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-11-12 09:01:01 -05:00
1 parent 8a998e7d49
commit ac3e33af46
116 files changed
+2367 -6091

No files matched your search

+2 -7
View File
@@ -24,13 +24,11 @@ dioxus-web = { workspace = true, default-features = false, optional = true }
dioxus-mobile = { workspace = true, optional = true }
dioxus-desktop = { workspace = true, default-features = true, optional = true }
dioxus-fullstack = { workspace = true, default-features = true, optional = true }
dioxus-static-site-generation = { workspace = true, optional = true }
dioxus-liveview = { workspace = true, optional = true }
dioxus-ssr = { workspace = true, optional = true }
manganis = { workspace = true, optional = true }
serde = { version = "1.0.136", optional = true }
axum = { workspace = true, optional = true }
[target.'cfg(not(any(target_arch = "wasm32", target_os = "ios", target_os = "android")))'.dependencies]
dioxus-devtools = { workspace = true, optional = true }
@@ -55,12 +53,10 @@ router = ["dep:dioxus-router"]
fullstack = ["dep:dioxus-fullstack", "dioxus-config-macro/fullstack", "dep:serde"]
desktop = ["dep:dioxus-desktop", "dioxus-fullstack?/desktop", "dioxus-config-macro/desktop"]
mobile = ["dep:dioxus-mobile", "dioxus-fullstack?/mobile", "dioxus-config-macro/mobile"]
web = ["dep:dioxus-web", "dioxus-fullstack?/web", "dioxus-static-site-generation?/web", "dioxus-config-macro/web"]
web = ["dep:dioxus-web", "dioxus-fullstack?/web", "dioxus-config-macro/web"]
ssr = ["dep:dioxus-ssr", "dioxus-config-macro/ssr"]
liveview = ["dep:dioxus-liveview", "dioxus-config-macro/liveview"]
static-generation = ["dep:dioxus-static-site-generation", "dioxus-config-macro/static-generation"]
axum = ["server"]
server = ["dioxus-fullstack?/axum", "dioxus-fullstack?/server", "dioxus-static-site-generation?/server", "ssr", "dioxus-liveview?/axum", "dep:axum"]
server = ["dioxus-fullstack?/axum", "dioxus-fullstack?/server", "ssr", "dioxus-liveview?/axum"]
# This feature just disables the no-renderer-enabled warning
third-party-renderer = []
@@ -90,6 +86,5 @@ features = [
"hooks",
"html",
"liveview",
"static-generation",
"server"
]
+14 -60
View File
@@ -16,6 +16,7 @@ pub struct LaunchBuilder {
}
pub type LaunchFn = fn(fn() -> Element, Vec<ContextFn>, Vec<Box<dyn Any>>);
/// A context function is a Send and Sync closure that returns a boxed trait object
pub type ContextFn = Box<dyn Fn() -> Box<dyn Any> + Send + Sync + 'static>;
@@ -32,10 +33,9 @@ impl LaunchBuilder {
feature = "mobile",
feature = "web",
feature = "fullstack",
feature = "static-generation"
))),
deprecated(
note = "No renderer is enabled. You must enable a renderer feature on the dioxus crate before calling the launch function.\nAdd `web`, `desktop`, `mobile`, `fullstack`, or `static-generation` to the `features` of dioxus field in your Cargo.toml.\n# Example\n```toml\n# ...\n[dependencies]\ndioxus = { version = \"0.5.0\", features = [\"web\"] }\n# ...\n```"
note = "No renderer is enabled. You must enable a renderer feature on the dioxus crate before calling the launch function.\nAdd `web`, `desktop`, `mobile`, or `fullstack` to the `features` of dioxus field in your Cargo.toml.\n# Example\n```toml\n# ...\n[dependencies]\ndioxus = { version = \"0.5.0\", features = [\"web\"] }\n# ...\n```"
)
)]
pub fn new() -> LaunchBuilder {
@@ -82,22 +82,6 @@ impl LaunchBuilder {
}
}
/// Launch your static site generation application.
#[cfg(all(feature = "static-generation", feature = "server"))]
#[cfg_attr(
docsrs,
doc(cfg(all(feature = "static-generation", feature = "server")))
)]
pub fn static_generation() -> LaunchBuilder {
LaunchBuilder {
launch_fn: |root, contexts, cfg| {
dioxus_static_site_generation::launch::launch(root, contexts, cfg)
},
contexts: Vec::new(),
configs: Vec::new(),
}
}
/// Launch your fullstack application.
#[cfg(feature = "mobile")]
#[cfg_attr(docsrs, doc(cfg(feature = "mobile")))]
@@ -188,19 +172,10 @@ impl LaunchBuilder {
(self.launch_fn)(app, self.contexts, cfg);
}
// Static generation is the only platform that may exit. We can't use the `!` type here
#[cfg(any(feature = "static-generation", feature = "web"))]
/// Launch your application.
pub fn launch(self, app: fn() -> Element) {
self.launch_inner(app);
}
#[cfg(not(any(feature = "static-generation", feature = "web")))]
/// Launch your application.
pub fn launch(self, app: fn() -> Element) -> ! {
self.launch_inner(app);
unreachable!("Launching an application will never exit")
}
}
/// Re-export the platform we expect the user wants
@@ -209,7 +184,6 @@ impl LaunchBuilder {
/// - `fullstack`
/// - `desktop`
/// - `mobile`
/// - `static-generation`
/// - `web`
/// - `liveview`
mod current_platform {
@@ -227,20 +201,12 @@ mod current_platform {
not(feature = "desktop"),
not(all(feature = "fullstack", feature = "server"))
))]
pub use dioxus_mobile::launch::*;
#[cfg(all(
all(feature = "static-generation", feature = "server"),
not(all(feature = "fullstack", feature = "server")),
not(feature = "desktop"),
not(feature = "mobile")
))]
pub use dioxus_static_site_generation::launch::*;
pub use dioxus_mobile::launch_bindings::*;
#[cfg(all(
feature = "web",
not(all(feature = "fullstack", feature = "server")),
not(all(feature = "static-generation", feature = "server")),
not(all(feature = "server")),
not(feature = "desktop"),
not(feature = "mobile"),
))]
@@ -255,7 +221,7 @@ mod current_platform {
#[cfg(all(
feature = "liveview",
not(all(feature = "fullstack", feature = "server")),
not(all(feature = "static-generation", feature = "server")),
not(all(feature = "server")),
not(feature = "desktop"),
not(feature = "mobile"),
not(feature = "web"),
@@ -265,7 +231,7 @@ mod current_platform {
#[cfg(not(any(
feature = "liveview",
all(feature = "fullstack", feature = "server"),
all(feature = "static-generation", feature = "server"),
all(feature = "server"),
feature = "desktop",
feature = "mobile",
feature = "web",
@@ -274,7 +240,7 @@ mod current_platform {
root: fn() -> dioxus_core::Element,
contexts: Vec<super::ContextFn>,
platform_config: Vec<Box<dyn std::any::Any>>,
) -> ! {
) {
#[cfg(feature = "third-party-renderer")]
panic!("No first party renderer feature enabled. It looks like you are trying to use a third party renderer. You will need to use the launch function from the third party renderer crate.");
@@ -282,23 +248,11 @@ mod current_platform {
}
}
// ! is unstable, so we can't name the type with an alias. Instead we need to generate different variants of items with macros
macro_rules! impl_launch {
($($return_type:tt),*) => {
/// Launch your application without any additional configuration. See [`LaunchBuilder`] for more options.
pub fn launch(app: fn() -> Element) -> $($return_type)* {
#[allow(deprecated)]
LaunchBuilder::new().launch(app)
}
};
pub fn launch(app: fn() -> Element) {
#[allow(deprecated)]
LaunchBuilder::new().launch(app)
}
// Static generation is the only platform that may exit. We can't use the `!` type here
#[cfg(any(feature = "static-generation", feature = "web"))]
impl_launch!(());
#[cfg(not(any(feature = "static-generation", feature = "web")))]
impl_launch!(!);
#[cfg(feature = "web")]
fn web_launch(
root: fn() -> dioxus_core::Element,
@@ -306,7 +260,7 @@ fn web_launch(
platform_config: Vec<Box<dyn std::any::Any>>,
) {
// If the server feature is enabled, launch the client with hydration enabled
#[cfg(any(feature = "static-generation", feature = "fullstack"))]
#[cfg(feature = "fullstack")]
{
let platform_config = platform_config
.into_iter()
@@ -319,12 +273,11 @@ fn web_launch(
for context in contexts {
vdom.insert_any_root_context(context());
}
#[cfg(feature = "document")]
{
#[cfg(feature = "fullstack")]
use dioxus_fullstack::document;
#[cfg(all(feature = "static-generation", not(feature = "fullstack")))]
use dioxus_static_site_generation::document;
let document = std::rc::Rc::new(document::web::FullstackWebDocument)
as std::rc::Rc<dyn crate::prelude::document::Document>;
vdom.provide_root_context(document);
@@ -334,6 +287,7 @@ fn web_launch(
dioxus_web::launch::launch_virtual_dom(factory(), platform_config)
}
#[cfg(not(any(feature = "static-generation", feature = "fullstack")))]
#[cfg(not(any(feature = "fullstack")))]
dioxus_web::launch::launch(root, contexts, platform_config);
}
+1 -17
View File
@@ -19,8 +19,7 @@
//! - `mobile`: enables the mobile platform
//! - `web`: enables the web platform. If the fullstack platform is enabled, this will set the fullstack platform to client mode
//! - `liveview`: enables the liveview platform
//! - `static-generation`: enables the static generation platform. This must be used in combination with the `web` feature for wasm builds and `axum` feature for server builds
//! - `axum`: enables the axum server with static generation or fullstack and sets the platform to server mode
//! - `server`: enables the server variant of dioxus
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
#![cfg_attr(docsrs, feature(doc_cfg))]
@@ -119,13 +118,6 @@ pub mod prelude {
#[cfg_attr(docsrs, doc(cfg(feature = "fullstack")))]
pub use dioxus_fullstack::prelude::*;
#[cfg(all(feature = "static-generation", not(feature = "fullstack")))]
#[cfg_attr(
docsrs,
doc(cfg(all(feature = "static-generation", not(feature = "fullstack"))))
)]
pub use dioxus_static_site_generation::prelude::*;
#[cfg(feature = "router")]
#[cfg_attr(docsrs, doc(cfg(feature = "router")))]
pub use dioxus_router;
@@ -134,10 +126,6 @@ pub mod prelude {
#[cfg_attr(docsrs, doc(cfg(feature = "router")))]
pub use dioxus_router::prelude::*;
#[cfg(feature = "axum")]
#[cfg_attr(docsrs, doc(cfg(feature = "axum")))]
pub use axum;
#[cfg(feature = "asset")]
#[cfg_attr(docsrs, doc(cfg(feature = "asset")))]
pub use manganis::{self, asset, Asset, ImageAsset, ImageType};
@@ -155,10 +143,6 @@ 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;