aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock339
-rw-r--r--azalea-chat/src/base_component.rs30
-rw-r--r--azalea-chat/src/click_event.rs47
-rw-r--r--azalea-chat/src/hover_event.rs28
-rw-r--r--azalea-chat/src/style.rs237
-rw-r--r--azalea-chat/src/text_component.rs6
-rw-r--r--azalea-chat/src/translatable_component.rs21
7 files changed, 317 insertions, 391 deletions
diff --git a/Cargo.lock b/Cargo.lock
index e419a7f6..8adda9c0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -101,9 +101,9 @@ dependencies = [
[[package]]
name = "anyhow"
-version = "1.0.99"
+version = "1.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
+checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
[[package]]
name = "arrayvec"
@@ -710,7 +710,7 @@ dependencies = [
"critical-section",
"foldhash",
"getrandom 0.2.16",
- "hashbrown",
+ "hashbrown 0.15.5",
"portable-atomic",
"portable-atomic-util",
"serde",
@@ -892,9 +892,9 @@ dependencies = [
[[package]]
name = "cc"
-version = "1.2.37"
+version = "1.2.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44"
+checksum = "80f41ae168f955c12fb8960b057d70d0ca153fb83182b57d86380443527be7e9"
dependencies = [
"find-msvc-tools",
"shlex",
@@ -990,18 +990,18 @@ dependencies = [
[[package]]
name = "clap"
-version = "4.5.47"
+version = "4.5.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931"
+checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae"
dependencies = [
"clap_builder",
]
[[package]]
name = "clap_builder"
-version = "4.5.47"
+version = "4.5.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6"
+checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9"
dependencies = [
"anstyle",
"clap_lex",
@@ -1177,9 +1177,9 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-rc.6"
+version = "0.7.0-rc.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2966eb7f877e5cdac7e808e71010d0bef6321d58b8e58bf01b8bbbe44f77ea0"
+checksum = "e0bfcfbe68dec4e49b4e93da8f091ce39556549554905fcb07308f6eeefae46c"
dependencies = [
"num-traits",
"rand_core 0.9.3",
@@ -1209,9 +1209,9 @@ dependencies = [
[[package]]
name = "crypto-primes"
-version = "0.7.0-pre.2"
+version = "0.7.0-pre.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ad2e4e276b4f3cc222e2724cc94e147008ee0e4481c7a220c79e2ec3bdd2bba"
+checksum = "25f2523fbb68811c8710829417ad488086720a6349e337c38d12fa81e09e50bf"
dependencies = [
"crypto-bigint",
"libm",
@@ -1237,9 +1237,9 @@ checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
[[package]]
name = "der"
-version = "0.8.0-rc.8"
+version = "0.8.0-rc.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7050e8041c28720851f7db83183195b6acf375bb7bb28e3b86f0fe6cbd69459d"
+checksum = "e9d8dd2f26c86b27a2a8ea2767ec7f9df7a89516e4794e54ac01ee618dda3aa4"
dependencies = [
"const-oid",
"pem-rfc7468",
@@ -1299,9 +1299,9 @@ dependencies = [
[[package]]
name = "digest"
-version = "0.11.0-rc.1"
+version = "0.11.0-rc.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3a4aae35a0fcbe22ff1be50fe96df72002d5a4a6fb4aae9193cf2da0daa36da2"
+checksum = "6749b668519cd7149ee3d11286a442a8a8bdc3a9d529605f579777bfccc5a4bc"
dependencies = [
"block-buffer 0.11.0-rc.5",
"const-oid",
@@ -1386,11 +1386,12 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "erased-serde"
-version = "0.4.6"
+version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7"
+checksum = "259d404d09818dec19332e31d94558aeb442fea04c817006456c24b5460bbd4b"
dependencies = [
"serde",
+ "serde_core",
"typeid",
]
@@ -1423,9 +1424,9 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
[[package]]
name = "find-msvc-tools"
-version = "0.1.1"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d"
+checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959"
[[package]]
name = "fixedbitset"
@@ -1574,20 +1575,6 @@ dependencies = [
]
[[package]]
-name = "generator"
-version = "0.8.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "605183a538e3e2a9c1038635cc5c2d194e2ee8fd0d1b66b8349fad7dbacce5a2"
-dependencies = [
- "cc",
- "cfg-if",
- "libc",
- "log",
- "rustversion",
- "windows",
-]
-
-[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1620,7 +1607,7 @@ dependencies = [
"js-sys",
"libc",
"r-efi",
- "wasi 0.14.5+wasi-0.2.4",
+ "wasi 0.14.7+wasi-0.2.4",
"wasm-bindgen",
]
@@ -1675,6 +1662,12 @@ dependencies = [
]
[[package]]
+name = "hashbrown"
+version = "0.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
+
+[[package]]
name = "heapless"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1779,9 +1772,9 @@ checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
[[package]]
name = "hybrid-array"
-version = "0.4.1"
+version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c7116c472cf19838450b1d421b4e842569f52b519d640aee9ace1ebcf5b21051"
+checksum = "2bad028b20a90afcdb5e28a53392562f1db2bdfa238aa1a978b911461bfffb92"
dependencies = [
"typenum",
]
@@ -1826,9 +1819,9 @@ dependencies = [
[[package]]
name = "hyper-util"
-version = "0.1.16"
+version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e"
+checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8"
dependencies = [
"base64",
"bytes",
@@ -1957,12 +1950,12 @@ dependencies = [
[[package]]
name = "indexmap"
-version = "2.11.1"
+version = "2.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921"
+checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
dependencies = [
"equivalent",
- "hashbrown",
+ "hashbrown 0.16.0",
]
[[package]]
@@ -2060,9 +2053,9 @@ dependencies = [
[[package]]
name = "js-sys"
-version = "0.3.78"
+version = "0.3.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c0b063578492ceec17683ef2f8c5e89121fbd0b172cbc280635ab7567db2738"
+checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305"
dependencies = [
"once_cell",
"wasm-bindgen",
@@ -2076,18 +2069,18 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
-version = "0.2.175"
+version = "0.2.176"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
+checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174"
[[package]]
name = "libloading"
-version = "0.8.8"
+version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
+checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
dependencies = [
"cfg-if",
- "windows-targets 0.53.3",
+ "windows-link 0.2.0",
]
[[package]]
@@ -2128,19 +2121,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
[[package]]
-name = "loom"
-version = "0.7.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca"
-dependencies = [
- "cfg-if",
- "generator",
- "scoped-tls",
- "tracing",
- "tracing-subscriber",
-]
-
-[[package]]
name = "lru-slab"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2167,9 +2147,9 @@ dependencies = [
[[package]]
name = "memchr"
-version = "2.7.5"
+version = "2.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
+checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
[[package]]
name = "minecraft_folder_path"
@@ -2205,20 +2185,19 @@ dependencies = [
[[package]]
name = "moka"
-version = "0.12.10"
+version = "0.12.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a9321642ca94a4282428e6ea4af8cc2ca4eac48ac7a6a4ea8f33f76d0ce70926"
+checksum = "8261cd88c312e0004c1d51baad2980c66528dfdb2bee62003e643a4d8f86b077"
dependencies = [
"crossbeam-channel",
"crossbeam-epoch",
"crossbeam-utils",
- "loom",
+ "equivalent",
"parking_lot",
"portable-atomic",
"rustc_version",
"smallvec",
"tagptr",
- "thiserror 1.0.69",
"uuid",
]
@@ -2476,9 +2455,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkcs1"
-version = "0.8.0-rc.3"
+version = "0.8.0-rc.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2345503b65d9be13aac96ddbec3eed60def8bc83869f9a519789afbcf3c2bea"
+checksum = "986d2e952779af96ea048f160fd9194e1751b4faea78bcf3ceb456efe008088e"
dependencies = [
"der",
"spki",
@@ -2486,9 +2465,9 @@ dependencies = [
[[package]]
name = "pkcs8"
-version = "0.11.0-rc.6"
+version = "0.11.0-rc.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c53e5d0804fa4070b1b2a5b320102f2c1c094920a7533d5d87c2630609bcbd34"
+checksum = "93eac55f10aceed84769df670ea4a32d2ffad7399400d41ee1c13b1cd8e1b478"
dependencies = [
"der",
"spki",
@@ -2734,9 +2713,9 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.11.2"
+version = "1.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912"
+checksum = "8b5288124840bee7b386bc413c487869b360b2b4ec421ea56425128692f2a82c"
dependencies = [
"aho-corasick",
"memchr",
@@ -2746,9 +2725,9 @@ dependencies = [
[[package]]
name = "regex-automata"
-version = "0.4.10"
+version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6"
+checksum = "833eb9ce86d40ef33cb1306d8accf7bc8ec2bfea4355cbdebb3df68b40925cad"
dependencies = [
"aho-corasick",
"memchr",
@@ -2801,9 +2780,9 @@ dependencies = [
[[package]]
name = "resolv-conf"
-version = "0.7.4"
+version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "95325155c684b1c89f7765e30bc1c42e4a6da51ca513615660cb8a62ef9a88e3"
+checksum = "6b3789b30bd25ba102de4beabd95d21ac45b69b1be7d14522bab988c526d6799"
[[package]]
name = "ring"
@@ -2821,14 +2800,14 @@ dependencies = [
[[package]]
name = "rsa"
-version = "0.10.0-rc.6"
+version = "0.10.0-rc.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "12c09fc7922fb8b7de31cc809df908e30e0ed46eb33046c6e1e438ef8ec3466b"
+checksum = "09f19b109ee0a7ad9b8fd40452adeaa2dcc1d4c148c100a2f3797d0d017a97df"
dependencies = [
"const-oid",
"crypto-bigint",
"crypto-primes",
- "digest 0.11.0-rc.1",
+ "digest 0.11.0-rc.2",
"pkcs1",
"pkcs8",
"rand_core 0.9.3",
@@ -2879,9 +2858,9 @@ dependencies = [
[[package]]
name = "rustls"
-version = "0.23.31"
+version = "0.23.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc"
+checksum = "cd3c25631629d034ce7cd9940adc9d45762d46de2b0f57193c4443b92c6d4d40"
dependencies = [
"once_cell",
"ring",
@@ -2903,9 +2882,9 @@ dependencies = [
[[package]]
name = "rustls-webpki"
-version = "0.103.5"
+version = "0.103.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b5a37813727b78798e53c2bec3f5e8fe12a6d6f8389bf9ca7802add4c9905ad8"
+checksum = "8572f3c2cb9934231157b45499fc41e1f58c589fdfb81a844ba873265e80f8eb"
dependencies = [
"ring",
"rustls-pki-types",
@@ -2934,12 +2913,6 @@ dependencies = [
]
[[package]]
-name = "scoped-tls"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
-
-[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2947,24 +2920,34 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "semver"
-version = "1.0.26"
+version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
+checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
[[package]]
name = "serde"
-version = "1.0.219"
+version = "1.0.226"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
+checksum = "0dca6411025b24b60bfa7ec1fe1f8e710ac09782dca409ee8237ba74b51295fd"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.226"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba2ba63999edb9dac981fb34b3e5c0d111a69b0924e253ed29d83f7c99e966a4"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.219"
+version = "1.0.226"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
+checksum = "8db53ae22f34573731bafa1db20f04027b2d25e02d8205921b569171699cdb33"
dependencies = [
"proc-macro2",
"quote",
@@ -2973,14 +2956,15 @@ dependencies = [
[[package]]
name = "serde_json"
-version = "1.0.143"
+version = "1.0.145"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a"
+checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
+ "serde_core",
]
[[package]]
@@ -3013,7 +2997,7 @@ checksum = "c5e046edf639aa2e7afb285589e5405de2ef7e61d4b0ac1e30256e3eab911af9"
dependencies = [
"cfg-if",
"cpufeatures",
- "digest 0.11.0-rc.1",
+ "digest 0.11.0-rc.2",
]
[[package]]
@@ -3024,7 +3008,7 @@ checksum = "d1e3878ab0f98e35b2df35fe53201d088299b41a6bb63e3e34dada2ac4abd924"
dependencies = [
"cfg-if",
"cpufeatures",
- "digest 0.11.0-rc.1",
+ "digest 0.11.0-rc.2",
]
[[package]]
@@ -3057,7 +3041,7 @@ version = "3.0.0-rc.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39195ff4c0dc41c93e123825ca1f0d11b856df8b26d5fe140a522355632c4345"
dependencies = [
- "digest 0.11.0-rc.1",
+ "digest 0.11.0-rc.2",
"rand_core 0.9.3",
]
@@ -3369,9 +3353,9 @@ dependencies = [
[[package]]
name = "tokio-rustls"
-version = "0.26.2"
+version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b"
+checksum = "05f63835928ca123f1bef57abbcd23bb2ba0ac9ae1235f1e65bda0d06e7786bd"
dependencies = [
"rustls",
"tokio",
@@ -3662,27 +3646,27 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "wasi"
-version = "0.14.5+wasi-0.2.4"
+version = "0.14.7+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a4494f6290a82f5fe584817a676a34b9d6763e8d9d18204009fb31dceca98fd4"
+checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c"
dependencies = [
"wasip2",
]
[[package]]
name = "wasip2"
-version = "1.0.0+wasi-0.2.4"
+version = "1.0.1+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24"
+checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
dependencies = [
"wit-bindgen",
]
[[package]]
name = "wasm-bindgen"
-version = "0.2.101"
+version = "0.2.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e14915cadd45b529bb8d1f343c4ed0ac1de926144b746e2710f9cd05df6603b"
+checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d"
dependencies = [
"cfg-if",
"once_cell",
@@ -3693,9 +3677,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
-version = "0.2.101"
+version = "0.2.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e28d1ba982ca7923fd01448d5c30c6864d0a14109560296a162f80f305fb93bb"
+checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19"
dependencies = [
"bumpalo",
"log",
@@ -3707,9 +3691,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
-version = "0.4.51"
+version = "0.4.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ca85039a9b469b38336411d6d6ced91f3fc87109a2a27b0c197663f5144dffe"
+checksum = "7e038d41e478cc73bae0ff9b36c60cff1c98b8f38f8d7e8061e79ee63608ac5c"
dependencies = [
"cfg-if",
"js-sys",
@@ -3720,9 +3704,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.101"
+version = "0.2.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7c3d463ae3eff775b0c45df9da45d68837702ac35af998361e2c84e7c5ec1b0d"
+checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -3730,9 +3714,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.101"
+version = "0.2.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7bb4ce89b08211f923caf51d527662b75bdc9c9c7aab40f86dcb9fb85ac552aa"
+checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
dependencies = [
"proc-macro2",
"quote",
@@ -3743,18 +3727,18 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.101"
+version = "0.2.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f143854a3b13752c6950862c906306adb27c7e839f7414cec8fea35beab624c1"
+checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1"
dependencies = [
"unicode-ident",
]
[[package]]
name = "web-sys"
-version = "0.3.78"
+version = "0.3.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "77e4b637749ff0d92b8fad63aa1f7cff3cbe125fd49c175cd6345e7272638b12"
+checksum = "9367c417a924a74cae129e6a2ae3b47fabb1f8995595ab474029da749a8be120"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -3830,74 +3814,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
-name = "windows"
-version = "0.61.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"
-dependencies = [
- "windows-collections",
- "windows-core",
- "windows-future",
- "windows-link 0.1.3",
- "windows-numerics",
-]
-
-[[package]]
-name = "windows-collections"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"
-dependencies = [
- "windows-core",
-]
-
-[[package]]
-name = "windows-core"
-version = "0.61.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
-dependencies = [
- "windows-implement",
- "windows-interface",
- "windows-link 0.1.3",
- "windows-result",
- "windows-strings",
-]
-
-[[package]]
-name = "windows-future"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"
-dependencies = [
- "windows-core",
- "windows-link 0.1.3",
- "windows-threading",
-]
-
-[[package]]
-name = "windows-implement"
-version = "0.60.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "windows-interface"
-version = "0.59.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
name = "windows-link"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3910,34 +3826,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65"
[[package]]
-name = "windows-numerics"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"
-dependencies = [
- "windows-core",
- "windows-link 0.1.3",
-]
-
-[[package]]
-name = "windows-result"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"
-dependencies = [
- "windows-link 0.1.3",
-]
-
-[[package]]
-name = "windows-strings"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"
-dependencies = [
- "windows-link 0.1.3",
-]
-
-[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4031,15 +3919,6 @@ dependencies = [
]
[[package]]
-name = "windows-threading"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6"
-dependencies = [
- "windows-link 0.1.3",
-]
-
-[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4198,9 +4077,9 @@ dependencies = [
[[package]]
name = "wit-bindgen"
-version = "0.45.1"
+version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36"
+checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
[[package]]
name = "writeable"
diff --git a/azalea-chat/src/base_component.rs b/azalea-chat/src/base_component.rs
index 27666c17..be7e9656 100644
--- a/azalea-chat/src/base_component.rs
+++ b/azalea-chat/src/base_component.rs
@@ -1,18 +1,38 @@
-use serde::Serialize;
+use serde::{Serialize, ser::SerializeMap};
use crate::{FormattedText, style::Style};
-#[derive(Clone, Debug, PartialEq, Serialize)]
+#[derive(Clone, Debug, PartialEq)]
pub struct BaseComponent {
- // implements mutablecomponent
/// Components in the "extra" field.
- #[serde(skip_serializing_if = "Vec::is_empty")]
pub siblings: Vec<FormattedText>,
- #[serde(flatten)]
pub style: Box<Style>,
}
impl BaseComponent {
+ pub fn serialize_map<S>(&self, state: &mut S::SerializeMap) -> Result<(), S::Error>
+ where
+ S: serde::Serializer,
+ {
+ if !self.siblings.is_empty() {
+ state.serialize_entry("extra", &self.siblings)?;
+ }
+ self.style.serialize_map::<S>(state)?;
+ Ok(())
+ }
+}
+impl Serialize for BaseComponent {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: serde::Serializer,
+ {
+ let mut state = serializer.serialize_map(None)?;
+ self.serialize_map::<S>(&mut state)?;
+ state.end()
+ }
+}
+
+impl BaseComponent {
pub fn new() -> Self {
Self {
siblings: Vec::new(),
diff --git a/azalea-chat/src/click_event.rs b/azalea-chat/src/click_event.rs
index dddaff74..a61e2561 100644
--- a/azalea-chat/src/click_event.rs
+++ b/azalea-chat/src/click_event.rs
@@ -1,6 +1,6 @@
use serde::Serialize;
#[cfg(feature = "simdnbt")]
-use simdnbt::owned::Nbt;
+use simdnbt::owned::{Nbt, NbtCompound, NbtTag};
#[derive(Clone, Debug, PartialEq, Serialize)]
#[serde(rename_all = "snake_case", tag = "action")]
@@ -31,3 +31,48 @@ pub enum ClickEvent {
payload: Nbt,
},
}
+
+#[cfg(feature = "simdnbt")]
+impl simdnbt::Serialize for ClickEvent {
+ fn to_compound(self) -> NbtCompound {
+ let mut compound = NbtCompound::new();
+ let mut action = |s: &str| {
+ compound.insert("action", s);
+ };
+ match self {
+ ClickEvent::OpenUrl { url } => {
+ action("open_url");
+ compound.insert("url", url);
+ }
+ ClickEvent::OpenFile { path } => {
+ action("open_file");
+ compound.insert("path", path);
+ }
+ ClickEvent::RunCommand { command } => {
+ action("run_command");
+ compound.insert("command", command);
+ }
+ ClickEvent::SuggestCommand { command } => {
+ action("suggest_command");
+ compound.insert("command", command);
+ }
+ ClickEvent::ShowDialog => {
+ action("show_dialog");
+ }
+ ClickEvent::ChangePage { page } => {
+ action("change_page");
+ compound.insert("page", NbtTag::Int(page));
+ }
+ ClickEvent::CopyToClipboard { value } => {
+ action("copy_to_clipboard");
+ compound.insert("value", value);
+ }
+ ClickEvent::Custom { id, payload } => {
+ action("custom");
+ compound.insert("id", id);
+ compound.insert("payload", (**payload).clone());
+ }
+ }
+ compound
+ }
+}
diff --git a/azalea-chat/src/hover_event.rs b/azalea-chat/src/hover_event.rs
index a18a3047..825c253b 100644
--- a/azalea-chat/src/hover_event.rs
+++ b/azalea-chat/src/hover_event.rs
@@ -1,4 +1,6 @@
use serde::Serialize;
+#[cfg(feature = "simdnbt")]
+use simdnbt::owned::NbtCompound;
use crate::FormattedText;
@@ -18,3 +20,29 @@ pub enum HoverEvent {
name: Box<FormattedText>,
},
}
+
+#[cfg(feature = "simdnbt")]
+impl simdnbt::Serialize for HoverEvent {
+ fn to_compound(self) -> NbtCompound {
+ let mut compound = NbtCompound::new();
+ let mut action = |s: &str| {
+ compound.insert("action", s);
+ };
+ match self {
+ HoverEvent::ShowText { value } => {
+ action("show_text");
+ compound.insert("value", value.to_compound());
+ }
+ HoverEvent::ShowItem { .. } => {
+ action("show_item");
+ }
+ HoverEvent::ShowEntity { id, name } => {
+ action("show_entity");
+ compound.insert("id", id);
+ // compound.insert("uuid", uuid.to_string());
+ compound.insert("name", name.to_compound());
+ }
+ }
+ compound
+ }
+}
diff --git a/azalea-chat/src/style.rs b/azalea-chat/src/style.rs
index b67dcf89..c43b7791 100644
--- a/azalea-chat/src/style.rs
+++ b/azalea-chat/src/style.rs
@@ -2,7 +2,7 @@ use std::{collections::HashMap, fmt, sync::LazyLock};
#[cfg(feature = "azalea-buf")]
use azalea_buf::AzBuf;
-use serde::{Serialize, Serializer};
+use serde::{Serialize, Serializer, ser::SerializeMap};
use serde_json::Value;
#[cfg(feature = "simdnbt")]
use simdnbt::owned::{NbtCompound, NbtTag};
@@ -304,136 +304,119 @@ impl TryFrom<ChatFormatting> for TextColor {
}
}
-#[derive(Clone, Debug, Default, PartialEq, serde::Serialize)]
-#[non_exhaustive]
-pub struct Style {
- #[serde(skip_serializing_if = "Option::is_none")]
- pub color: Option<TextColor>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub shadow_color: Option<u32>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub bold: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub italic: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub underlined: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub strikethrough: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub obfuscated: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub click_event: Option<ClickEvent>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub hover_event: Option<HoverEvent>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub insertion: Option<String>,
+macro_rules! define_style_struct {
+ ($($(#[$doc:meta])* $field:ident : $type:ty),* $(,)?) => {
+ #[derive(Clone, Debug, Default, PartialEq, serde::Serialize)]
+ #[non_exhaustive]
+ pub struct Style {
+ $(
+ #[serde(skip_serializing_if = "Option::is_none")]
+ $(#[$doc])*
+ pub $field: Option<$type>,
+ )*
+ }
+
+ impl Style {
+ $(
+ pub fn $field(mut self, value: impl Into<Option<$type>>) -> Self {
+ self.$field = value.into();
+ self
+ }
+ )*
+
+ pub fn serialize_map<S>(&self, state: &mut S::SerializeMap) -> Result<(), S::Error>
+ where
+ S: serde::Serializer,
+ {
+ $(
+ if let Some(value) = &self.$field {
+ state.serialize_entry(stringify!($field), value)?;
+ }
+ )*
+ Ok(())
+ }
+
+ /// Apply another style to this one
+ pub fn apply(&mut self, style: &Style) {
+ $(
+ if let Some(value) = &style.$field {
+ self.$field = Some(value.clone());
+ }
+ )*
+ }
+ }
+
+ #[cfg(feature = "simdnbt")]
+ impl simdnbt::Serialize for Style {
+ fn to_compound(self) -> NbtCompound {
+ let mut compound = NbtCompound::new();
+
+ $(
+ if let Some(value) = self.$field {
+ compound.insert(stringify!($field), value);
+ }
+ )*
+
+ compound
+ }
+ }
+ };
+}
+
+define_style_struct! {
+ color: TextColor,
+ shadow_color: u32,
+ bold: bool,
+ italic: bool,
+ underlined: bool,
+ strikethrough: bool,
+ obfuscated: bool,
+ click_event: ClickEvent,
+ hover_event: HoverEvent,
+ insertion: String,
/// Represented as a `ResourceLocation`.
- #[serde(skip_serializing_if = "Option::is_none")]
- pub font: Option<String>,
+ font: String,
}
+
impl Style {
pub fn new() -> Self {
Self::default()
}
- pub fn color(mut self, color: impl Into<Option<TextColor>>) -> Self {
- self.color = color.into();
- self
- }
- pub fn shadow_color(mut self, color: impl Into<Option<u32>>) -> Self {
- self.shadow_color = color.into();
- self
- }
- pub fn bold(mut self, bold: impl Into<Option<bool>>) -> Self {
- self.bold = bold.into();
- self
- }
- pub fn italic(mut self, italic: impl Into<Option<bool>>) -> Self {
- self.italic = italic.into();
- self
- }
- pub fn underlined(mut self, underlined: impl Into<Option<bool>>) -> Self {
- self.underlined = underlined.into();
- self
- }
- pub fn strikethrough(mut self, strikethrough: impl Into<Option<bool>>) -> Self {
- self.strikethrough = strikethrough.into();
- self
- }
- pub fn obfuscated(mut self, obfuscated: impl Into<Option<bool>>) -> Self {
- self.obfuscated = obfuscated.into();
- self
- }
- pub fn click_event(mut self, click_event: impl Into<Option<ClickEvent>>) -> Self {
- self.click_event = click_event.into();
- self
- }
- pub fn hover_event(mut self, hover_event: impl Into<Option<HoverEvent>>) -> Self {
- self.hover_event = hover_event.into();
- self
- }
- pub fn insertion(mut self, insertion: impl Into<Option<String>>) -> Self {
- self.insertion = insertion.into();
- self
- }
- pub fn font(mut self, font: impl Into<Option<String>>) -> Self {
- self.font = font.into();
- self
- }
-}
-#[cfg(feature = "simdnbt")]
-fn simdnbt_serialize_field(
- compound: &mut simdnbt::owned::NbtCompound,
- name: &'static str,
- value: Option<impl simdnbt::ToNbtTag>,
-) {
- if let Some(value) = value {
- compound.insert(name, value);
- }
-}
-
-#[cfg(feature = "simdnbt")]
-impl simdnbt::Serialize for Style {
- fn to_compound(self) -> NbtCompound {
- let mut compound = NbtCompound::new();
-
- simdnbt_serialize_field(&mut compound, "color", self.color);
- simdnbt_serialize_field(&mut compound, "bold", self.bold);
- simdnbt_serialize_field(&mut compound, "italic", self.italic);
- simdnbt_serialize_field(&mut compound, "underlined", self.underlined);
- simdnbt_serialize_field(&mut compound, "strikethrough", self.strikethrough);
- simdnbt_serialize_field(&mut compound, "obfuscated", self.obfuscated);
-
- compound
- }
-}
-
-impl Style {
pub fn empty() -> Self {
Self::default()
}
pub fn deserialize(json: &Value) -> Style {
- let Some(json_object) = json.as_object() else {
+ let Some(j) = json.as_object() else {
return Style::default();
};
- let bold = json_object.get("bold").and_then(|v| v.as_bool());
- let italic = json_object.get("italic").and_then(|v| v.as_bool());
- let underlined = json_object.get("underlined").and_then(|v| v.as_bool());
- let strikethrough = json_object.get("strikethrough").and_then(|v| v.as_bool());
- let obfuscated = json_object.get("obfuscated").and_then(|v| v.as_bool());
- let color: Option<TextColor> = json_object
- .get("color")
- .and_then(|v| v.as_str())
- .and_then(TextColor::parse);
+
Style {
- color,
- bold,
- italic,
- underlined,
- strikethrough,
- obfuscated,
- ..Style::default()
+ color: j
+ .get("color")
+ .and_then(|v| v.as_str())
+ .and_then(TextColor::parse),
+ shadow_color: j
+ .get("shadow_color")
+ .and_then(|v| v.as_u64())
+ .map(|v| v as u32),
+ bold: j.get("bold").and_then(|v| v.as_bool()),
+ italic: j.get("italic").and_then(|v| v.as_bool()),
+ underlined: j.get("underlined").and_then(|v| v.as_bool()),
+ strikethrough: j.get("strikethrough").and_then(|v| v.as_bool()),
+ obfuscated: j.get("obfuscated").and_then(|v| v.as_bool()),
+ // TODO: impl deserialize functions for click_event and hover_event
+ click_event: Default::default(),
+ hover_event: Default::default(),
+ insertion: j
+ .get("insertion")
+ .and_then(|v| v.as_str())
+ .map(|s| s.to_string()),
+ font: j
+ .get("font")
+ .and_then(|v| v.as_str())
+ .map(|s| s.to_string()),
}
}
@@ -513,28 +496,6 @@ impl Style {
ansi_codes
}
- /// Apply another style to this one
- pub fn apply(&mut self, style: &Style) {
- if let Some(color) = &style.color {
- self.color = Some(color.clone());
- }
- if let Some(bold) = &style.bold {
- self.bold = Some(*bold);
- }
- if let Some(italic) = &style.italic {
- self.italic = Some(*italic);
- }
- if let Some(underlined) = &style.underlined {
- self.underlined = Some(*underlined);
- }
- if let Some(strikethrough) = &style.strikethrough {
- self.strikethrough = Some(*strikethrough);
- }
- if let Some(obfuscated) = &style.obfuscated {
- self.obfuscated = Some(*obfuscated);
- }
- }
-
/// Returns a new style that is a merge of self and other.
/// For any field that `other` does not specify (is None), self’s value is
/// used.
diff --git a/azalea-chat/src/text_component.rs b/azalea-chat/src/text_component.rs
index 962ec46e..0fa0cd6f 100644
--- a/azalea-chat/src/text_component.rs
+++ b/azalea-chat/src/text_component.rs
@@ -1,6 +1,6 @@
use std::fmt::{self, Display};
-use serde::{__private::ser::FlatMapSerializer, Serialize, Serializer, ser::SerializeMap};
+use serde::{Serialize, Serializer, ser::SerializeMap};
use crate::{
FormattedText,
@@ -25,7 +25,9 @@ impl Serialize for TextComponent {
let mut state = serializer.serialize_map(None)?;
state.serialize_entry("text", &self.text)?;
- Serialize::serialize(&self.base, FlatMapSerializer(&mut state))?;
+
+ self.base.serialize_map::<S>(&mut state)?;
+
if !self.base.siblings.is_empty() {
state.serialize_entry("extra", &self.base.siblings)?;
}
diff --git a/azalea-chat/src/translatable_component.rs b/azalea-chat/src/translatable_component.rs
index 28700366..b8e93245 100644
--- a/azalea-chat/src/translatable_component.rs
+++ b/azalea-chat/src/translatable_component.rs
@@ -1,6 +1,6 @@
use std::fmt::{self, Display};
-use serde::{__private::ser::FlatMapSerializer, Serialize, Serializer, ser::SerializeMap};
+use serde::Serialize;
#[cfg(feature = "simdnbt")]
use simdnbt::Serialize as _;
@@ -24,27 +24,18 @@ impl simdnbt::ToNbtTag for StringOrComponent {
}
/// A message whose content depends on the client's language.
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct TranslatableComponent {
+ #[serde(flatten)]
pub base: BaseComponent,
+ #[serde(rename = "translate")]
pub key: String,
+ #[serde(skip_serializing_if = "Option::is_none")]
pub fallback: Option<String>,
+ #[serde(rename = "with")]
pub args: Vec<StringOrComponent>,
}
-impl Serialize for TranslatableComponent {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- let mut state = serializer.serialize_map(None)?;
- state.serialize_entry("translate", &self.key)?;
- Serialize::serialize(&self.base, FlatMapSerializer(&mut state))?;
- state.serialize_entry("with", &self.args)?;
- state.end()
- }
-}
-
#[cfg(feature = "simdnbt")]
fn serialize_args_as_nbt(args: &[StringOrComponent]) -> simdnbt::owned::NbtList {
// if it's all strings then make it a string list