Bladeren bron

Move the manganis into attribute value implementation into dioxus core (#2765)

Evan Almloff 11 maanden geleden
bovenliggende
commit
9dbdf74a1e
4 gewijzigde bestanden met toevoegingen van 11 en 1 verwijderingen
  1. 1 0
      Cargo.lock
  2. 2 0
      packages/core/Cargo.toml
  3. 7 0
      packages/core/src/nodes.rs
  4. 1 1
      packages/dioxus/Cargo.toml

+ 1 - 0
Cargo.lock

@@ -2578,6 +2578,7 @@ dependencies = [
  "futures-util",
  "generational-box",
  "longest-increasing-subsequence",
+ "manganis",
  "pretty_assertions",
  "rand 0.8.5",
  "reqwest 0.12.5",

+ 2 - 0
packages/core/Cargo.toml

@@ -25,6 +25,7 @@ generational-box = { workspace = true }
 rustversion = "1.0.17"
 const_format = { workspace = true }
 warnings = { workspace = true }
+manganis = { workspace = true, default-features = false, optional = true }
 
 [dev-dependencies]
 tokio = { workspace = true, features = ["full"] }
@@ -47,6 +48,7 @@ features = [
 
 [features]
 serialize = ["dep:serde"]
+manganis = ["dep:manganis"]
 
 [package.metadata.docs.rs]
 cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

+ 7 - 0
packages/core/src/nodes.rs

@@ -1096,6 +1096,13 @@ impl<T: IntoAttributeValue> IntoAttributeValue for Option<T> {
     }
 }
 
+#[cfg(feature = "manganis")]
+impl IntoAttributeValue for manganis::ImageAsset {
+    fn into_value(self) -> AttributeValue {
+        AttributeValue::Text(self.path().to_string())
+    }
+}
+
 /// A trait for anything that has a dynamic list of attributes
 pub trait HasAttributes {
     /// Push an attribute onto the list of attributes

+ 1 - 1
packages/dioxus/Cargo.toml

@@ -43,7 +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"]
+asset = ["dep:manganis", "dioxus-core/manganis"]
 document = ["dioxus-web?/document", "dioxus-html?/document"]
 
 launch = ["dep:dioxus-config-macro"]