From 672f4dfefc85e974e29860a4c49c9861d83c6c5b Mon Sep 17 00:00:00 2001 From: Miles Murgaw Date: Tue, 23 Jul 2024 13:29:37 -0400 Subject: [PATCH] Re-Export Manganis & Update Examples (#2625) * feat: export manganis * revision: use manganis in examples * fix: manganis dep * fix: workspace root finder * fix: manganis dep * fix: ci --- Cargo.lock | 122 ++++++++++++++----------------- Cargo.toml | 4 +- examples/all_events.rs | 4 +- examples/assets/dog_app.css | 0 examples/calculator.rs | 4 +- examples/clock.rs | 4 +- examples/control_focus.rs | 5 +- examples/counters.rs | 4 +- examples/crm.rs | 4 +- examples/dog_app.rs | 5 +- examples/dynamic_asset.rs | 4 +- examples/file_upload.rs | 4 +- examples/flat_router.rs | 4 +- examples/global.rs | 10 ++- examples/link.rs | 4 +- examples/reducer.rs | 4 +- examples/router.rs | 4 +- examples/todomvc.rs | 4 +- packages/desktop/Cargo.toml | 20 ----- packages/desktop/src/protocol.rs | 45 +++++++++++- packages/dioxus/Cargo.toml | 6 +- packages/dioxus/src/lib.rs | 4 + packages/router/Cargo.toml | 19 ----- 23 files changed, 154 insertions(+), 134 deletions(-) delete mode 100644 examples/assets/dog_app.css diff --git a/Cargo.lock b/Cargo.lock index 8b3858f3d..c6ad95ca1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -697,9 +697,9 @@ dependencies = [ [[package]] name = "aws-lc-rs" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a47f2fb521b70c11ce7369a6c5fa4bd6af7e5d62ec06303875bafe7c6ba245" +checksum = "4ae74d9bd0a7530e8afd1770739ad34b36838829d6ad61818f9230f683f5ad77" dependencies = [ "aws-lc-sys", "mirai-annotations", @@ -709,9 +709,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2927c7af777b460b7ccd95f8b67acd7b4c04ec8896bf0c8e80ba30523cffc057" +checksum = "2e89b6941c2d1a7045538884d6e760ccfffdf8e1ffc2613d8efa74305e1f3752" dependencies = [ "bindgen", "cc", @@ -1408,9 +1408,9 @@ dependencies = [ [[package]] name = "cargo_toml" -version = "0.20.3" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4895c018bb228aa6b3ba1a0285543fcb4b704734c3fb1f72afaa75aa769500c1" +checksum = "ad639525b1c67b6a298f378417b060fbc04618bea559482a8484381cce27d965" dependencies = [ "serde", "toml 0.8.15", @@ -1439,9 +1439,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324c74f2155653c90b04f25b2a47a8a631360cb908f92a772695f430c7e31052" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" dependencies = [ "jobserver", "libc", @@ -2444,6 +2444,7 @@ dependencies = [ "dioxus-web", "env_logger 0.10.2", "futures-util", + "manganis", "rand 0.8.5", "serde", "thiserror", @@ -2578,22 +2579,6 @@ dependencies = [ "quote", ] -[[package]] -name = "dioxus-core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088daa3f45aaa729e9eef32dc0a9393dd709ee906b092089e5839cad1cad7c85" -dependencies = [ - "futures-channel", - "futures-util", - "generational-box 0.5.1", - "longest-increasing-subsequence", - "rustc-hash", - "slab", - "tracing", - "tracing-subscriber", -] - [[package]] name = "dioxus-core" version = "0.5.2" @@ -2621,6 +2606,23 @@ dependencies = [ "web-sys", ] +[[package]] +name = "dioxus-core" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3730d2459ab66951cedf10b09eb84141a6eda7f403c28057cbe010495be156b7" +dependencies = [ + "futures-channel", + "futures-util", + "generational-box 0.5.6", + "longest-increasing-subsequence", + "rustc-hash", + "slab", + "slotmap", + "tracing", + "tracing-subscriber", +] + [[package]] name = "dioxus-core-macro" version = "0.5.2" @@ -3945,15 +3947,6 @@ dependencies = [ "x11", ] -[[package]] -name = "generational-box" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f132919c96b85c02a067ceae965fd50ace57111e2f55c7384b95ac191f4d966b" -dependencies = [ - "parking_lot", -] - [[package]] name = "generational-box" version = "0.5.2" @@ -3963,6 +3956,15 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "generational-box" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "557cf2cbacd0504c6bf8c29f52f8071e0de1d9783346713dc6121d7fa1e5d0e0" +dependencies = [ + "parking_lot", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -4110,7 +4112,7 @@ dependencies = [ "gix-utils", "itoa 1.0.11", "thiserror", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -4131,7 +4133,7 @@ dependencies = [ "smallvec", "thiserror", "unicode-bom", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -4233,7 +4235,7 @@ dependencies = [ "itoa 1.0.11", "smallvec", "thiserror", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -4268,7 +4270,7 @@ dependencies = [ "gix-validate", "memmap2", "thiserror", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -5785,7 +5787,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -6040,23 +6042,22 @@ dependencies = [ [[package]] name = "manganis" version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c211cfb4529c79b32307b606e83a1bb15d491b3b4a1ab97159b161d7af9d1b72" +source = "git+https://github.com/DioxusLabs/manganis#8a6d74dc19072e7a650854bd722c452da51955d6" dependencies = [ - "dioxus-core 0.5.1", + "dioxus-core 0.5.6", "manganis-macro", ] [[package]] name = "manganis-cli-support" version = "0.2.4" -source = "git+https://github.com/DioxusLabs/manganis/#ad09a549775957c5ce177274cfbb6dc76c976c10" +source = "git+https://github.com/DioxusLabs/manganis#8a6d74dc19072e7a650854bd722c452da51955d6" dependencies = [ "anyhow", "image 0.25.1", "imagequant", "lightningcss", - "manganis-common 0.2.4 (git+https://github.com/DioxusLabs/manganis/)", + "manganis-common", "mozjpeg", "object", "png", @@ -6074,24 +6075,7 @@ dependencies = [ [[package]] name = "manganis-common" version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "542300f1e7d9313de5b7e5b92d273ba42ab547c068d773559d616aa14987de43" -dependencies = [ - "anyhow", - "base64 0.21.7", - "home", - "infer 0.11.0", - "reqwest 0.11.27", - "serde", - "toml 0.7.8", - "tracing", - "url", -] - -[[package]] -name = "manganis-common" -version = "0.2.4" -source = "git+https://github.com/DioxusLabs/manganis/#ad09a549775957c5ce177274cfbb6dc76c976c10" +source = "git+https://github.com/DioxusLabs/manganis#8a6d74dc19072e7a650854bd722c452da51955d6" dependencies = [ "anyhow", "base64 0.21.7", @@ -6107,12 +6091,12 @@ dependencies = [ [[package]] name = "manganis-macro" version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "704a0123ac90fa630b21a04fde56c29dfd5a7665c5e8f3639567989daa2d29d1" +source = "git+https://github.com/DioxusLabs/manganis#8a6d74dc19072e7a650854bd722c452da51955d6" dependencies = [ - "manganis-common 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "manganis-common", "proc-macro2", "quote", + "serde_json", "syn 2.0.71", "tracing-subscriber", ] @@ -7313,9 +7297,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" [[package]] name = "powerfmt" @@ -9958,7 +9942,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.13", + "winnow 0.6.14", ] [[package]] @@ -11270,9 +11254,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +checksum = "374ec40a2d767a3c1b4972d9475ecd557356637be906f2cb3f7fe17a6eb5e22f" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 45064b91a..0c639316a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -105,8 +105,8 @@ wasm-bindgen-futures = "0.4.42" html_parser = "0.7.0" thiserror = "1.0.40" prettyplease = { version = "0.2.16", features = ["verbatim"] } -manganis-cli-support = { git = "https://github.com/DioxusLabs/manganis/", features = ["html"] } -manganis = { version = "0.2.1" } +manganis-cli-support = { git = "hhttps://github.com/DioxusLabs/manganis", features = ["html"] } +manganis = { git = "https://github.com/DioxusLabs/manganis" } const_format = "0.2.32" cargo_toml = { version = "0.20.3" } tauri-utils = { version = "=1.5.*" } diff --git a/examples/all_events.rs b/examples/all_events.rs index c60a6a726..54577209c 100644 --- a/examples/all_events.rs +++ b/examples/all_events.rs @@ -6,6 +6,8 @@ use dioxus::prelude::*; use std::{collections::VecDeque, fmt::Debug, rc::Rc}; +const STYLE: &str = asset!(file("./examples/assets/events.css")); + fn main() { launch(app); } @@ -24,7 +26,7 @@ fn app() -> Element { }; rsx! { - style { {include_str!("./assets/events.css")} } + link { rel: "stylesheet", href: STYLE } div { id: "container", // focusing is necessary to catch keyboard events div { id: "receiver", tabindex: 0, diff --git a/examples/assets/dog_app.css b/examples/assets/dog_app.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/calculator.rs b/examples/calculator.rs index f8064c199..65f9cd201 100644 --- a/examples/calculator.rs +++ b/examples/calculator.rs @@ -12,6 +12,8 @@ use dioxus::events::*; use dioxus::html::input_data::keyboard_types::Key; use dioxus::prelude::*; +const STYLE: &str = asset!(file("./examples/assets/calculator.css")); + fn main() { LaunchBuilder::desktop() .with_cfg(desktop!({ @@ -52,7 +54,7 @@ fn app() -> Element { }; rsx! { - style { {include_str!("./assets/calculator.css")} } + link { rel: "stylesheet", href: STYLE } div { id: "wrapper", div { class: "app", div { class: "calculator", tabindex: "0", onkeydown: handle_key_down_event, diff --git a/examples/clock.rs b/examples/clock.rs index 9ca9fc201..1da9239c1 100644 --- a/examples/clock.rs +++ b/examples/clock.rs @@ -5,6 +5,8 @@ use dioxus::prelude::*; +const STYLE: &str = asset!(file("./examples/assets/clock.css")); + fn main() { launch_desktop(app); } @@ -36,7 +38,7 @@ fn app() -> Element { ); rsx! { - style { {include_str!("./assets/clock.css")} } + link { rel: "stylesheet", href: STYLE } div { id: "app", div { id: "title", "Carpe diem 🎉" } div { id: "clock-display", "{time}" } diff --git a/examples/control_focus.rs b/examples/control_focus.rs index 95f36e7cf..4f1a4845d 100644 --- a/examples/control_focus.rs +++ b/examples/control_focus.rs @@ -3,9 +3,10 @@ //! This example shows how to manage focus in a Dioxus application. We implement a "roulette" that focuses on each input //! in the grid every few milliseconds until the user interacts with the inputs. +use dioxus::prelude::*; use std::rc::Rc; -use dioxus::prelude::*; +const STYLE: &str = asset!(file("./examples/assets/roulette.css")); fn main() { launch_desktop(app); @@ -37,7 +38,7 @@ fn app() -> Element { }); rsx! { - style { {include_str!("./assets/roulette.css")} } + link { rel: "stylesheet", href: STYLE } h1 { "Input Roulette" } button { onclick: move |_| running.toggle(), "Toggle roulette" } div { id: "roulette-grid", diff --git a/examples/counters.rs b/examples/counters.rs index ebedf2712..34a384a6b 100644 --- a/examples/counters.rs +++ b/examples/counters.rs @@ -2,6 +2,8 @@ use dioxus::prelude::*; +const STYLE: &str = asset!(file("./examples/assets/counter.css")); + fn main() { launch(app); } @@ -14,7 +16,7 @@ fn app() -> Element { let sum = use_memo(move || counters.read().iter().copied().sum::()); rsx! { - style { {include_str!("./assets/counter.css")} } + link { rel: "stylesheet", href: STYLE } div { id: "controls", button { onclick: move |_| counters.write().push(0), "Add counter" } diff --git a/examples/crm.rs b/examples/crm.rs index 5360c0480..decde2920 100644 --- a/examples/crm.rs +++ b/examples/crm.rs @@ -11,6 +11,8 @@ use dioxus::prelude::*; +const STYLE: &str = asset!(file("./examples/assets/crm.css")); + fn main() { LaunchBuilder::new() .with_cfg(desktop!({ @@ -26,7 +28,7 @@ fn main() { integrity: "sha384-Uu6IeWbM+gzNVXJcM9XV3SohHtmWE+3VGi496jvgX1jyvDTXfdK+rfZc8C1Aehk5", crossorigin: "anonymous" } - style { {include_str!("./assets/crm.css")} } + link { rel: "stylesheet", href: STYLE } h1 { "Dioxus CRM Example" } Router:: {} } diff --git a/examples/dog_app.rs b/examples/dog_app.rs index 9f3b1da5d..1c53c8731 100644 --- a/examples/dog_app.rs +++ b/examples/dog_app.rs @@ -16,8 +16,8 @@ fn main() { fn app() -> Element { // Breed is a signal that will be updated when the user clicks a breed in the list - // `deerhound` is just a default that we know will exist. We could also use a `None` instead - let mut breed = use_signal(|| "deerhound".to_string()); + // `shiba` is just a default that we know will exist. We could also use a `None` instead + let mut breed = use_signal(|| "shiba".to_string()); // Fetch the list of breeds from the Dog API // Since there are no dependencies, this will never restart @@ -55,7 +55,6 @@ fn app() -> Element { }; rsx! { - style { {include_str!("./assets/dog_app.css")} } h1 { "Select a dog breed!" } div { height: "500px", display: "flex", ul { width: "100px", {breed_list} } diff --git a/examples/dynamic_asset.rs b/examples/dynamic_asset.rs index cf43dd14c..f8a4fb7ad 100644 --- a/examples/dynamic_asset.rs +++ b/examples/dynamic_asset.rs @@ -7,6 +7,8 @@ use dioxus::desktop::{use_asset_handler, wry::http::Response}; use dioxus::prelude::*; +const STYLE: &str = asset!(file("./examples/assets/custom_assets.css")); + fn main() { launch_desktop(app); } @@ -22,7 +24,7 @@ fn app() -> Element { }); rsx! { - style { {include_str!("./assets/custom_assets.css")} } + link { rel: "stylesheet", href: STYLE } h1 { "Dynamic Assets" } img { src: "/logos/logo.png" } } diff --git a/examples/file_upload.rs b/examples/file_upload.rs index 58642e9c6..ed597d486 100644 --- a/examples/file_upload.rs +++ b/examples/file_upload.rs @@ -8,6 +8,8 @@ use std::sync::Arc; use dioxus::prelude::*; use dioxus::{html::HasFileData, prelude::dioxus_elements::FileEngine}; +const STYLE: &str = asset!(file("./examples/assets/file_upload.css")); + fn main() { launch(app); } @@ -41,7 +43,7 @@ fn app() -> Element { }; rsx! { - style { {include_str!("./assets/file_upload.css")} } + link { rel: "stylesheet", href: STYLE } h1 { "File Upload Example" } p { "Drop a .txt, .rs, or .js file here to read it" } diff --git a/examples/flat_router.rs b/examples/flat_router.rs index 4af9ff85c..d428758d5 100644 --- a/examples/flat_router.rs +++ b/examples/flat_router.rs @@ -9,10 +9,12 @@ use dioxus::prelude::*; +const STYLE: &str = asset!(file("./examples/assets/flat_router.css")); + fn main() { launch(|| { rsx! { - style { {include_str!("./assets/flat_router.css")} } + link { rel: "stylesheet", href: STYLE } Router:: {} } }) diff --git a/examples/global.rs b/examples/global.rs index 2f121fbed..bbfef347e 100644 --- a/examples/global.rs +++ b/examples/global.rs @@ -7,16 +7,18 @@ use dioxus::prelude::*; -fn main() { - launch(app); -} +const STYLE: &str = asset!(file("./examples/assets/counter.css")); static COUNT: GlobalSignal = Signal::global(|| 0); static DOUBLED_COUNT: GlobalMemo = Signal::global_memo(|| COUNT() * 2); +fn main() { + launch(app); +} + fn app() -> Element { rsx! { - style { {include_str!("./assets/counter.css")} } + link { rel: "stylesheet", href: STYLE } Increment {} Decrement {} Reset {} diff --git a/examples/link.rs b/examples/link.rs index caaca6721..06a65b796 100644 --- a/examples/link.rs +++ b/examples/link.rs @@ -8,13 +8,15 @@ use dioxus::prelude::*; +const STYLE: &str = asset!(file("./examples/assets/links.css")); + fn main() { launch(app); } fn app() -> Element { rsx! ( - style { {include_str!("./assets/links.css")} } + link { rel: "stylesheet", href: STYLE } Router:: {} ) } diff --git a/examples/reducer.rs b/examples/reducer.rs index d742bcf3e..d70340f59 100644 --- a/examples/reducer.rs +++ b/examples/reducer.rs @@ -7,6 +7,8 @@ use dioxus::prelude::*; +const STYLE: &str = asset!(file("./examples/assets/radio.css")); + fn main() { launch(app); } @@ -15,7 +17,7 @@ fn app() -> Element { let mut state = use_signal(|| PlayerState { is_playing: false }); rsx!( - style { {include_str!("./assets/radio.css")} } + link { rel: "stylesheet", href: STYLE } h1 {"Select an option"} // Add some cute animations if the radio is playing! diff --git a/examples/router.rs b/examples/router.rs index 5752de3e6..c9579208c 100644 --- a/examples/router.rs +++ b/examples/router.rs @@ -8,10 +8,12 @@ use dioxus::prelude::*; +const STYLE: &str = asset!(file("./examples/assets/router.css")); + fn main() { launch(|| { rsx! { - style { {include_str!("./assets/router.css")} } + link { rel: "stylesheet", href: STYLE } Router:: {} } }); diff --git a/examples/todomvc.rs b/examples/todomvc.rs index f48ebe241..c5471eb0d 100644 --- a/examples/todomvc.rs +++ b/examples/todomvc.rs @@ -3,6 +3,8 @@ use dioxus::prelude::*; use std::collections::HashMap; +const STYLE: &str = asset!(file("./examples/assets/todomvc.css")); + fn main() { launch(app); } @@ -63,7 +65,7 @@ fn app() -> Element { }; rsx! { - style { {include_str!("./assets/todomvc.css")} } + link { rel: "stylesheet", href: STYLE } section { class: "todoapp", TodoHeader { todos } section { class: "main", diff --git a/packages/desktop/Cargo.toml b/packages/desktop/Cargo.toml index 9e2fc7428..4d5821092 100644 --- a/packages/desktop/Cargo.toml +++ b/packages/desktop/Cargo.toml @@ -135,21 +135,6 @@ name = "calculator_mutable" path = "../../examples/calculator_mutable.rs" doc-scrape-examples = true -[[example]] -name = "calculator" -path = "../../examples/calculator.rs" -doc-scrape-examples = true - -[[example]] -name = "clock" -path = "../../examples/clock.rs" -doc-scrape-examples = true - -[[example]] -name = "crm" -path = "../../examples/crm.rs" -doc-scrape-examples = true - [[example]] name = "custom_html" path = "../../examples/custom_html.rs" @@ -160,11 +145,6 @@ name = "custom_menu" path = "../../examples/custom_menu.rs" doc-scrape-examples = true -[[example]] -name = "dynamic_asset" -path = "../../examples/dynamic_asset.rs" -doc-scrape-examples = true - [[example]] name = "errors" path = "../../examples/errors.rs" diff --git a/packages/desktop/src/protocol.rs b/packages/desktop/src/protocol.rs index dcb722d41..7f9833cfe 100644 --- a/packages/desktop/src/protocol.rs +++ b/packages/desktop/src/protocol.rs @@ -2,7 +2,12 @@ use crate::{assets::*, edits::EditQueue}; use dioxus_html::document::NATIVE_EVAL_JS; use dioxus_interpreter_js::unified_bindings::SLEDGEHAMMER_JS; use dioxus_interpreter_js::NATIVE_JS; -use std::path::{Component, Path, PathBuf}; +use serde::Deserialize; +use std::{ + path::{Component, Path, PathBuf}, + process::Command, + sync::OnceLock, +}; use wry::{ http::{status::StatusCode, Request, Response}, RequestAsyncResponder, Result, @@ -108,8 +113,18 @@ fn assets_head() -> Option { fn resolve_resource(path: &Path) -> PathBuf { let mut base_path = get_asset_root_or_default(); + if running_in_dev_mode() { base_path.push(path); + + // Special handler for Manganis filesystem fallback. + // We need this since Manganis provides assets from workspace root. + if !base_path.exists() { + let workspace_root = get_workspace_root_from_cargo(); + let asset_path = workspace_root.join(path); + println!("ASSET PATH: {:?}", asset_path); + return asset_path; + } } else { let mut resource_path = PathBuf::new(); for component in path.components() { @@ -305,3 +320,31 @@ fn get_mime_by_ext(trimmed: &Path) -> &'static str { None => "application/octet-stream", } } + +/// A global that stores the workspace root. Used in [`get_workspace_root_from_cargo`]. +static WORKSPACE_ROOT: OnceLock = OnceLock::new(); + +/// Describes the metadata we need from `cargo metadata`. +#[derive(Deserialize)] +struct CargoMetadata { + workspace_root: PathBuf, +} + +/// Get the workspace root using `cargo metadata`. Should not be used in release mode. +pub(crate) fn get_workspace_root_from_cargo() -> PathBuf { + WORKSPACE_ROOT + .get_or_init(|| { + let out = Command::new("cargo") + .args(["metadata", "--format-version", "1", "--no-deps"]) + .output() + .expect("`cargo metadata` failed to run"); + + let out = + String::from_utf8(out.stdout).expect("failed to parse output of `cargo metadata`"); + let metadata = serde_json::from_str::(&out) + .expect("failed to deserialize data from `cargo metadata`"); + + metadata.workspace_root + }) + .to_owned() +} diff --git a/packages/dioxus/Cargo.toml b/packages/dioxus/Cargo.toml index c20e3d070..a15ab1140 100644 --- a/packages/dioxus/Cargo.toml +++ b/packages/dioxus/Cargo.toml @@ -24,7 +24,8 @@ 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 } +dioxus-ssr = { workspace = true, optional = true } +manganis = { workspace = true, optional = true } serde = { version = "1.0.136", optional = true } axum = { workspace = true, optional = true } @@ -33,7 +34,7 @@ axum = { workspace = true, optional = true } dioxus-hot-reload = { workspace = true, optional = true } [features] -default = ["macro", "html", "hot-reload", "signals", "hooks", "launch", "mounted", "file_engine", "document"] +default = ["macro", "html", "hot-reload", "signals", "hooks", "launch", "mounted", "file_engine", "document", "asset"] minimal = ["macro", "html", "signals", "hooks", "launch"] signals = ["dep:dioxus-signals"] macro = ["dep:dioxus-core-macro"] @@ -42,6 +43,7 @@ hooks = ["dep:dioxus-hooks"] hot-reload = ["dep:dioxus-hot-reload", "dioxus-web?/hot_reload", "dioxus-fullstack?/hot-reload"] mounted = ["dioxus-web?/mounted", "dioxus-html?/mounted"] file_engine = ["dioxus-web?/file_engine"] +asset = ["dep:manganis"] document = ["dioxus-web?/document", "dioxus-html?/document"] launch = ["dep:dioxus-config-macro"] diff --git a/packages/dioxus/src/lib.rs b/packages/dioxus/src/lib.rs index acc9bf6e8..f1231745d 100644 --- a/packages/dioxus/src/lib.rs +++ b/packages/dioxus/src/lib.rs @@ -122,6 +122,10 @@ pub mod 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, classes, mg as asset, ImageAsset, ImageType}; } #[cfg(feature = "web")] diff --git a/packages/router/Cargo.toml b/packages/router/Cargo.toml index 313ed2b54..e34660e42 100644 --- a/packages/router/Cargo.toml +++ b/packages/router/Cargo.toml @@ -61,36 +61,17 @@ serde = { version = "1", features = ["derive"] } [package.metadata.docs.rs] cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] # Most of the examples live in the workspace. We include some here so that docs.rs can scrape our examples for better inline docs -[[example]] -name = "crm" -path = "../../examples/crm.rs" -doc-scrape-examples = true - -[[example]] -name = "flat_router" -path = "../../examples/flat_router.rs" -doc-scrape-examples = true [[example]] name = "hash_fragment_state" path = "../../examples/hash_fragment_state.rs" doc-scrape-examples = true -[[example]] -name = "link" -path = "../../examples/link.rs" -doc-scrape-examples = true - [[example]] name = "query_segment_search" path = "../../examples/query_segment_search.rs" doc-scrape-examples = true -[[example]] -name = "router" -path = "../../examples/router.rs" -doc-scrape-examples = true - [[example]] name = "simple_router" path = "../../examples/simple_router.rs"