diff --git a/Cargo.lock b/Cargo.lock index c3134a0..59a753b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -433,6 +433,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + [[package]] name = "bit-set" version = "0.10.0" @@ -469,6 +475,15 @@ dependencies = [ "serde_core", ] +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "block2" version = "0.5.1" @@ -712,6 +727,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "constant_time_eq" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eb6feb175df65d0a3ccd3e73484e940d0ac664e8034f0519fd49a93db3071d9" +dependencies = [ + "rustversion", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -722,6 +746,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -735,7 +769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" dependencies = [ "bitflags 1.3.2", - "core-foundation", + "core-foundation 0.9.4", "core-graphics-types", "foreign-types", "libc", @@ -748,7 +782,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" dependencies = [ "bitflags 1.3.2", - "core-foundation", + "core-foundation 0.9.4", + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ "libc", ] @@ -801,6 +844,32 @@ dependencies = [ "web-sys", ] +[[package]] +name = "craft-update" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d" +dependencies = [ + "chrono", + "dunce", + "egui", + "flate2", + "getrandom 0.3.4", + "image", + "log", + "plist", + "semver", + "serde", + "serde_json", + "sha2", + "tar", + "tempfile", + "ureq", + "verifysign", + "winreg", + "winsafe", + "zip 9.5.0", +] + [[package]] name = "crc32fast" version = "1.5.3" @@ -841,6 +910,16 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "cursor-icon" version = "1.2.0" @@ -887,6 +966,12 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" +[[package]] +name = "deranged" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" + [[package]] name = "derive_arbitrary" version = "1.5.0" @@ -911,6 +996,16 @@ dependencies = [ "rayon", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -970,6 +1065,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "dyn-clone" version = "1.0.20" @@ -1305,6 +1406,16 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b97b65636e5b9ef369943878ac74335ba1c55c1cb6adbf1e2c293c624248d693" +[[package]] +name = "filetime" +version = "0.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759" +dependencies = [ + "cfg-if", + "libc", +] + [[package]] name = "find-msvc-tools" version = "0.1.15" @@ -1506,6 +1617,16 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "gethostname" version = "1.1.0" @@ -1525,6 +1646,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "getrandom" version = "0.3.4" @@ -1544,8 +1676,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi 6.0.0", + "wasm-bindgen", ] [[package]] @@ -1796,6 +1930,22 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + [[package]] name = "iana-time-zone" version = "0.1.65" @@ -2333,6 +2483,7 @@ checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" name = "materialcraft" version = "0.1.3" dependencies = [ + "craft-update", "eframe", "egui", "image", @@ -2429,7 +2580,7 @@ dependencies = [ "serde_json", "thiserror 2.0.21", "tobj", - "zip", + "zip 2.6.1", ] [[package]] @@ -2476,6 +2627,7 @@ version = "0.1.3" dependencies = [ "base64 0.22.1", "craft-ui", + "craft-update", "eframe", "egui", "egui-phosphor", @@ -2492,7 +2644,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "zip", + "zip 2.6.1", ] [[package]] @@ -2657,6 +2809,18 @@ dependencies = [ "jni-sys 0.3.1", ] +[[package]] +name = "nix" +version = "0.31.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" +dependencies = [ + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "libc", +] + [[package]] name = "nohash-hasher" version = "0.2.0" @@ -2682,6 +2846,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + [[package]] name = "num-traits" version = "0.2.19" @@ -3041,6 +3211,12 @@ dependencies = [ "libc", ] +[[package]] +name = "openssl-probe" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e036b411754132fd6b74e94b74e9a13c5cf606fa93d1885c35860d3060820b1" + [[package]] name = "orbclient" version = "0.3.55" @@ -3249,6 +3425,19 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +[[package]] +name = "plist" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327a4cb2ad49dc48adfdc9da89e22c64d488b508c67a044d71ba729e4521a285" +dependencies = [ + "base64 0.23.1", + "indexmap", + "quick-xml 0.42.0", + "serde", + "time", +] + [[package]] name = "png" version = "0.18.1" @@ -3333,6 +3522,12 @@ dependencies = [ "zerovec", ] +[[package]] +name = "powerfmt" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" + [[package]] name = "presser" version = "0.3.1" @@ -3407,6 +3602,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b1177fdf999d2321d3fb46ff47159d9c1fb9ad66a4879f8c50a0b504615e9b" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.47" @@ -3601,6 +3805,20 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rmcp" version = "3.8.0" @@ -3723,6 +3941,80 @@ dependencies = [ "rustix 1.1.6", ] +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a073f5dc7469f984c52ad2752b63b0807745133b6de880b7b64c1ac4c48aec4" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-platform-verifier" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98" +dependencies = [ + "core-foundation 0.10.1", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f" + +[[package]] +name = "rustls-webpki" +version = "0.103.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.23" @@ -3738,6 +4030,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cb23c424d8ee841bb4d813677ca237e2a610067d594fec130f87d6093495ab5" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "schemars" version = "1.2.3" @@ -3776,6 +4077,29 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags 2.13.2", + "core-foundation 0.10.1", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "self_cell" version = "1.3.0" @@ -3787,6 +4111,10 @@ name = "semver" version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] [[package]] name = "send_wrapper" @@ -3868,6 +4196,17 @@ dependencies = [ "serde_core", ] +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "shlex" version = "2.0.1" @@ -4035,6 +4374,12 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "svgtypes" version = "0.16.2" @@ -4090,6 +4435,16 @@ dependencies = [ "web-sys", ] +[[package]] +name = "tar" +version = "0.4.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840" +dependencies = [ + "filetime", + "libc", +] + [[package]] name = "tempfile" version = "3.27.0" @@ -4166,6 +4521,36 @@ dependencies = [ "zune-jpeg", ] +[[package]] +name = "time" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tiny-skia" version = "0.12.0" @@ -4362,12 +4747,24 @@ dependencies = [ "rustc-hash 2.1.3", ] +[[package]] +name = "typed-path" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce898823d8cd0f028662d2f349694b1af0a5cc9be83f1d213a00d3147445e1e" + [[package]] name = "typeid" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + [[package]] name = "uds_windows" version = "1.2.1" @@ -4415,6 +4812,41 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7be76686bdf7198002062423ca0d8cf9b75a27c8e1de804513b97e97b555d9d" +dependencies = [ + "base64 0.23.1", + "flate2", + "log", + "percent-encoding", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", + "ureq-proto", + "utf8-zero", +] + +[[package]] +name = "ureq-proto" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622dce33c252115466d83f63e9744a18f12b4406aae51a01c15ad8fcf1185eb3" +dependencies = [ + "base64 0.23.1", + "http", + "httparse", + "log", +] + [[package]] name = "urlencoding" version = "2.1.3" @@ -4452,6 +4884,12 @@ dependencies = [ "utf_types", ] +[[package]] +name = "utf8-zero" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c0a043c9540bae7c578c88f91dda8bd82e59ae27c21baca69c8b191aaf5a6e" + [[package]] name = "utf8_iter" version = "1.1.0" @@ -4506,6 +4944,16 @@ dependencies = [ "vello_common", ] +[[package]] +name = "verifysign" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6efd25aadc22c756a9012267fae0b130278d335d6ceb512ec02ce82029b5ca9" +dependencies = [ + "core-foundation 0.10.1", + "windows-sys 0.61.2", +] + [[package]] name = "version_check" version = "0.9.5" @@ -4685,7 +5133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0" dependencies = [ "proc-macro2", - "quick-xml", + "quick-xml 0.41.0", "quote", ] @@ -4721,6 +5169,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-root-certs" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e49d0e65abc00c142e8f9428da991da9f1a250c39be97459901eb12b9b49f62a" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "weezl" version = "0.1.12" @@ -5219,7 +5676,7 @@ dependencies = [ "calloop", "cfg_aliases", "concurrent-queue", - "core-foundation", + "core-foundation 0.9.4", "core-graphics", "cursor-icon", "dpi", @@ -5264,6 +5721,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "winreg" +version = "0.55.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb5a765337c50e9ec252c2069be9bf91c7df47afb103b642ba3a53bf8101be97" +dependencies = [ + "cfg-if", + "windows-sys 0.59.0", +] + [[package]] name = "winresource" version = "0.1.34" @@ -5274,6 +5741,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "winsafe" +version = "0.0.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef0ffc427f045c0cc9ebffd6f4f91153dcd2a1547b5c3c29ee3f541e16e95c6" + [[package]] name = "winx" version = "0.36.4" @@ -5569,6 +6042,26 @@ dependencies = [ "synstructure", ] +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "zerotrie" version = "0.2.5" @@ -5621,6 +6114,25 @@ dependencies = [ "zopfli", ] +[[package]] +name = "zip" +version = "9.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700e6c427aff64acdbf02e85fbfd946c2ee12319d1af013092f3a2178914ff8" +dependencies = [ + "constant_time_eq", + "crc32fast", + "flate2", + "getrandom 0.4.3", + "indexmap", + "libc", + "memchr", + "nix", + "typed-path", + "windows-sys 0.61.2", + "zeroize", +] + [[package]] name = "zlib-rs" version = "0.6.8" diff --git a/Cargo.toml b/Cargo.toml index 03d0173..1f5470e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,6 +86,8 @@ getrandom = "0.3" # MIT OR Apache-2.0, pinned to one rev (the one TextureCraft pins). egui_kittest = "0.37" craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "f8f8829cc7be65d466d687dae381d1ca60e31242", features = ["serde"] } +# Release checks and self-updates for the desktop app: storytold/craft-libs, MIT OR Apache-2.0. +craft-update = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d", features = ["egui"] } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] diff --git a/apps/materialcraft/Cargo.toml b/apps/materialcraft/Cargo.toml index 83f388f..7017800 100644 --- a/apps/materialcraft/Cargo.toml +++ b/apps/materialcraft/Cargo.toml @@ -22,5 +22,9 @@ log = { workspace = true } # A start that never opens a window says why in an error dialog (src/start_failure.rs). rfd = { workspace = true } +# The Windows update helper is a copy of this program started with `--finish-update`. +[target.'cfg(windows)'.dependencies] +craft-update = { workspace = true } + [build-dependencies] winresource = "0.1" diff --git a/apps/materialcraft/src/main.rs b/apps/materialcraft/src/main.rs index 8139184..10a4184 100644 --- a/apps/materialcraft/src/main.rs +++ b/apps/materialcraft/src/main.rs @@ -71,7 +71,17 @@ fn icon() -> Option { Some(egui::IconData { rgba: img.into_raw(), width: w, height: h }) } +/// A scripted run (`--control` or `MATERIALCRAFT_NO_PREFS`) gets no update prompt over the window it drives +fn checks_for_updates_at_start(control: Option, throwaway_prefs: bool) -> bool { + control.is_none() && !throwaway_prefs +} + fn main() { + // Windows: the update helper is a copy of this program started with `--finish-update`. + #[cfg(windows)] + if let Some(result) = craft_update::self_update::finish(&materialcraft_ui_egui::UPDATE_APP, &std::env::args_os().skip(1).collect::>()) { + std::process::exit(i32::from(result.is_err())); + } let args = match parse_args() { Ok(Some(a)) => a, Ok(None) => return, @@ -94,13 +104,15 @@ fn main() { // Scripted runs (agents, tests) set MATERIALCRAFT_NO_PREFS so they neither read nor overwrite the user's saved layout and settings: state goes to a throwaway file let persistence_path = std::env::var_os("MATERIALCRAFT_NO_PREFS").map(|_| std::env::temp_dir().join(format!("materialcraft-noprefs-{}.ron", std::process::id()))); - let options = eframe::NativeOptions { viewport, renderer: eframe::Renderer::Wgpu, persistence_path, ..Default::default() }; let control = args.control; + let startup_update_check = checks_for_updates_at_start(control, persistence_path.is_some()); + let options = eframe::NativeOptions { viewport, renderer: eframe::Renderer::Wgpu, persistence_path, ..Default::default() }; let r = eframe::run_native( "MaterialCraft", options, Box::new(move |cc| { let mut app = MaterialCraftApp::new(cc, session); + app.set_startup_update_check(startup_update_check); if let Some(port) = control { app.control = Some(control_server::start(port, cc.egui_ctx.clone())); } @@ -119,6 +131,13 @@ fn main() { mod tests { use super::*; + #[test] + fn only_a_run_a_person_started_checks_for_updates_at_start() { + assert!(checks_for_updates_at_start(None, false)); + assert!(!checks_for_updates_at_start(Some(9000), false)); + assert!(!checks_for_updates_at_start(None, true)); + } + #[test] fn startup_without_a_file_has_one_empty_graph() { let s = initial_session(&Args { file: None, control: None }); diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index ed7cb99..7bf2aab 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -25,6 +25,7 @@ zip = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] sys-locale = "0.3" rfd = { workspace = true } +craft-update = { workspace = true } # Floating panels open as OS windows. craft-ui = { workspace = true, features = ["native-windows"] } diff --git a/crates/ui-egui/src/graph/canvas_tests.rs b/crates/ui-egui/src/graph/canvas_tests.rs index b67b27d..de23bc9 100644 --- a/crates/ui-egui/src/graph/canvas_tests.rs +++ b/crates/ui-egui/src/graph/canvas_tests.rs @@ -146,6 +146,27 @@ fn clicked_wires_swap_with_x_and_delete_together() { assert!(app.graph.selected_wires.is_empty()); } +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn node_search_shortcuts_wait_for_the_update_prompt() { + for key in [egui::Key::Space, egui::Key::Tab] { + let ctx = egui::Context::default(); + let mut app = MaterialCraftApp::headless(materialcraft_engine::sample_session(), crate::UiState::default()); + crate::updates_ui::open_prompt_for_test(&mut app); + let mut draw = |ui: &mut Ui| show(&mut app, ui); + ctx.run_ui(egui::RawInput::default(), &mut draw).textures_delta.clear(); + let input = egui::RawInput { + events: vec![ + egui::Event::PointerMoved(pos2(200.0, 200.0)), + egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE }, + ], + ..Default::default() + }; + ctx.run_ui(input, &mut draw).textures_delta.clear(); + assert!(app.graph.search.is_none(), "{key:?}"); + } +} + #[test] fn node_search_shortcuts_respect_hover_and_keyboard_focus() { for key in [egui::Key::Space, egui::Key::Tab] { diff --git a/crates/ui-egui/src/graph/input.rs b/crates/ui-egui/src/graph/input.rs index c2a9687..bbeec0a 100644 --- a/crates/ui-egui/src/graph/input.rs +++ b/crates/ui-egui/src/graph/input.rs @@ -231,7 +231,11 @@ pub(super) fn handle( // Keys over the canvas let hovered = pointer.is_some_and(|position| rect.contains(position)); - if hovered && app.graph.search.is_none() { + #[cfg(not(target_arch = "wasm32"))] + let update_dialog_open = crate::updates_ui::blocks_input(app); + #[cfg(target_arch = "wasm32")] + let update_dialog_open = false; + if hovered && app.graph.search.is_none() && !update_dialog_open { let space = !context.egui_wants_keyboard_input() && context.input(|input| input.key_pressed(egui::Key::Space)); let tab = !app.graph.keyboard_was_focused && !context.text_edit_focused() && context.input(|input| input.key_pressed(egui::Key::Tab)); if (space || tab) diff --git a/crates/ui-egui/src/i18n/ar.rs b/crates/ui-egui/src/i18n/ar.rs index 8fec061..0e5cf64 100644 --- a/crates/ui-egui/src/i18n/ar.rs +++ b/crates/ui-egui/src/i18n/ar.rs @@ -68,6 +68,7 @@ pub const TABLE: &[(&str, &str)] = &[ ("Cancel", "إلغاء"), ("Cast", "تحويل النوع"), ("Ceil", "الحد الأعلى (Ceil)"), + ("Check for updates...", "التحقق من وجود تحديثات..."), ("Choose a folder to export to", "اختر مجلداً للتصدير إليه"), ("Clamp", "تقييد النطاق (Clamp)"), ("Clear cache", "مسح الذاكرة المؤقتة"), diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 197c030..a4370b0 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -35,9 +35,20 @@ pub mod windows; mod material_craft_app; pub mod pattern; mod toast; +#[cfg(not(target_arch = "wasm32"))] +pub mod updates_ui; mod user_directory; mod value_editor; +/// This app as the updater knows it: its release repository, and the icon and accent color the +/// update prompt shows +#[cfg(not(target_arch = "wasm32"))] +pub const UPDATE_APP: craft_update::app::App = craft_update::app::App { + icon_png: Some(include_bytes!("../../../assets/app-icon/hicolor/128x128/apps/ai.storyteller.materialcraft.png")), + accent: Some([0x17, 0x8a, 0x9c]), + ..craft_update::app::App::new("materialcraft", "MaterialCraft", "Procedural material design", "storytold/materialcraft") +}; + pub use control::ControlRequest; pub use material_craft_app::MaterialCraftApp; pub use materialcraft_engine::eval::now_ms; diff --git a/crates/ui-egui/src/material_craft_app.rs b/crates/ui-egui/src/material_craft_app.rs index b602ca9..1998304 100644 --- a/crates/ui-egui/src/material_craft_app.rs +++ b/crates/ui-egui/src/material_craft_app.rs @@ -40,6 +40,9 @@ pub struct MaterialCraftApp { #[cfg_attr(target_arch = "wasm32", allow(dead_code))] next_autosave: f64, styled: Option<(theme::Brightness, theme::Accent)>, + /// Release checks and the update prompt (desktop only) + #[cfg(not(target_arch = "wasm32"))] + pub(crate) updates_rt: crate::updates_ui::Runtime, /// Fallback fonts for Arabic pub fonts: fonts::UiFonts, /// The icon font is installed (it takes effect on the frame after `set_fonts`) @@ -88,6 +91,8 @@ impl MaterialCraftApp { last_time: 0.0, next_autosave, styled: None, + #[cfg(not(target_arch = "wasm32"))] + updates_rt: crate::updates_ui::Runtime::default(), fonts: fonts::UiFonts::default(), fonts_ready: false, ui_gesture_active: false, @@ -306,6 +311,8 @@ impl MaterialCraftApp { cook::drive(self, ctx); #[cfg(not(target_arch = "wasm32"))] self.autosave(now); + #[cfg(not(target_arch = "wasm32"))] + crate::updates_ui::tick(self, ctx); self.reconcile_editors(); menus::shortcuts(self, ctx); self.toasts.retain(|t| t.until > now); diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index cb53e52..34fcdcd 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -103,6 +103,8 @@ pub const CATALOG: &[MenuItem] = &[ it("Help", "ArtCraft website...", "ui.help.website", None), it("Help", "Report a bug...", "ui.help.bug", None), sep("Help"), + #[cfg(not(target_arch = "wasm32"))] + it("Help", "Check for updates...", "ui.help.checkForUpdates", None), it("Help", "About MaterialCraft...", "ui.about", None), ]; @@ -182,6 +184,8 @@ pub fn invoke(app: &mut MaterialCraftApp, ctx: &egui::Context, id: &str) { "ui.home" => app.ui.windows.home = true, "ui.help.shortcuts" => app.ui.windows.shortcuts = true, "ui.about" => app.ui.windows.about = true, + #[cfg(not(target_arch = "wasm32"))] + "ui.help.checkForUpdates" => crate::updates_ui::check(app), "ui.help.discord" => ctx.open_url(egui::OpenUrl::new_tab("https://discord.gg/artcraft")), "ui.help.website" => ctx.open_url(egui::OpenUrl::new_tab("https://getartcraft.com/apps/materialcraft")), "ui.help.docs" => ctx.open_url(egui::OpenUrl::new_tab("https://github.com/storytold/materialcraft#readme")), @@ -295,6 +299,10 @@ pub fn shortcuts(app: &mut MaterialCraftApp, ctx: &egui::Context) { if ctx.egui_wants_keyboard_input() || egui::Popup::is_any_open(ctx) { return; } + #[cfg(not(target_arch = "wasm32"))] + if crate::updates_ui::blocks_input(app) { + return; + } if !ctx.input(|i| i.events.iter().any(|e| matches!(e, egui::Event::Key { pressed: true, .. }))) { return; } diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs new file mode 100644 index 0000000..f26e546 --- /dev/null +++ b/crates/ui-egui/src/updates_ui.rs @@ -0,0 +1,105 @@ +//! Software updates on the desktop: the background check at startup, Help > Check for updates and +//! the prompts that report them + +use craft_update::updater::{Action, Status, Updater}; +use craft_update::{CheckResultDialog, CheckResultResponse}; + +use crate::MaterialCraftApp; + +pub(crate) struct Runtime { + updater: Updater, + /// The desktop app turns the check at start on; tests and scripted runs leave it off + startup_check: bool, + check_requested: bool, + /// The context of the last frame, to wake the UI when a check is queued between frames + repaint: Option, +} + +impl Default for Runtime { + fn default() -> Self { + let updater = Updater::new(&crate::UPDATE_APP, materialcraft_engine::VERSION).with_translator(translate); + Self { updater, startup_check: false, check_requested: false, repaint: None } + } +} + +/// The updater's words in the interface language (English where the catalog has no row) +pub fn translate(text: &str, args: &[(&str, &str)]) -> String { + craft_update::translate::fill(crate::i18n::tr(text), args) +} + +impl MaterialCraftApp { + /// Whether the app asks for a newer release when it starts (off until the desktop app turns it on) + pub fn set_startup_update_check(&mut self, on: bool) { + self.updates_rt.startup_check = on; + } +} + +/// Help > Check for updates: the next frame starts a check whose outcome the result dialog shows +pub(crate) fn check(app: &mut MaterialCraftApp) { + app.updates_rt.check_requested = true; + if let Some(ctx) = &app.updates_rt.repaint { + ctx.request_repaint(); + } +} + +/// The update prompt and the modal result dialog own the keyboard while they are open: shortcuts +/// must not edit the graph behind them +pub(crate) fn blocks_input(app: &MaterialCraftApp) -> bool { + let updater = &app.updates_rt.updater; + holds_keyboard(updater.status(), updater.prompt_open()) +} + +/// The notice that an update installed leaves the app usable behind it +fn holds_keyboard(status: &Status, prompt_open: bool) -> bool { + prompt_open || (result_window_shows(status, false) && !matches!(status, Status::Updated(_))) +} + +pub(crate) fn tick(app: &mut MaterialCraftApp, ctx: &egui::Context) { + let rt = &mut app.updates_rt; + rt.repaint = Some(ctx.clone()); + if std::mem::take(&mut rt.check_requested) { + rt.updater.check_now(ctx); + } else if rt.startup_check { + rt.updater.check_at_start(ctx); + } + rt.updater.tick(ctx); +} + +/// Whether the result dialog shows: for every status but idle (a requested check, and the first +/// start after an update, which reports that it installed or why it failed), and never over the +/// startup prompt +fn result_window_shows(status: &Status, prompt_open: bool) -> bool { + !prompt_open && !matches!(status, Status::Idle) +} + +pub(crate) fn show(app: &mut MaterialCraftApp, ctx: &egui::Context) { + // An installation, and the close for a ready update, wait until nothing is unsaved + let clean = !crate::unsaved::needs_confirmation(&app.session); + match app.updates_rt.updater.show_if(ctx, clean) { + Action::OpenUrl(url) => ctx.open_url(egui::OpenUrl::new_tab(url)), + Action::Close => ctx.send_viewport_cmd(egui::ViewportCommand::Close), + Action::None => {} + } + // A found update opens the startup prompt and leaves the status idle, which ends the result dialog + let rt = &mut app.updates_rt; + if result_window_shows(rt.updater.status(), rt.updater.prompt_open()) { + match CheckResultDialog::new(&crate::UPDATE_APP, materialcraft_engine::VERSION).with_translator(translate).show(ctx, rt.updater.status()) { + CheckResultResponse::None => {} + // Closing the dialog dismisses the outcome it showed + CheckResultResponse::Close => rt.updater.dismiss_status(), + CheckResultResponse::CheckAgain => rt.check_requested = true, + // The next `show_if` asks the window to close once nothing is unsaved + CheckResultResponse::RestartToUpdate => rt.updater.restart_to_update(), + } + } +} + +/// Opens the update prompt for a test in another module +#[cfg(test)] +pub(crate) fn open_prompt_for_test(app: &mut MaterialCraftApp) { + tests::open_prompt(app); +} + +#[cfg(test)] +#[path = "updates_ui.test.rs"] +mod tests; diff --git a/crates/ui-egui/src/updates_ui.test.rs b/crates/ui-egui/src/updates_ui.test.rs new file mode 100644 index 0000000..ab8902f --- /dev/null +++ b/crates/ui-egui/src/updates_ui.test.rs @@ -0,0 +1,210 @@ +use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::mpsc::{Receiver, channel}; + +use egui_kittest::kittest::Queryable as _; + +use super::*; +use crate::menus; +use crate::state::UiState; +use materialcraft_engine::sample_session; + +const COMMAND: &str = "ui.help.checkForUpdates"; + +/// A pins file that does not exist: the tests do not read the launcher's real choices +fn no_pins() -> std::path::PathBuf { + std::env::temp_dir().join("materialcraft-updates-test-missing").join("pins.json") +} + +fn app() -> MaterialCraftApp { + let mut app = MaterialCraftApp::headless(sample_session(), UiState::default()); + app.updates_rt.updater = Updater::new(&crate::UPDATE_APP, "0.1.0").with_pins_path(no_pins()); + app +} + +/// An app whose checks answer "nothing newer" instead of asking GitHub; the receiver hears each +/// check start, and the counter says how many did +fn app_with_source() -> (MaterialCraftApp, Receiver<()>, Arc) { + let mut app = app(); + let (tx, rx) = channel(); + let calls = Arc::new(AtomicUsize::new(0)); + let counted = calls.clone(); + let source: craft_update::updater::CheckSource = Arc::new(move || { + counted.fetch_add(1, Ordering::SeqCst); + let _ = tx.send(()); + Ok(None) + }); + app.updates_rt.updater = Updater::new(&crate::UPDATE_APP, "0.1.0").with_pins_path(no_pins()).with_source(source); + (app, rx, calls) +} + +fn release() -> craft_update::Release { + craft_update::Release { + tag: "v99.0.0".into(), + version: craft_update::parse_version("99.0.0"), + name: "MaterialCraft 99.0.0".into(), + html_url: "https://github.com/storytold/materialcraft/releases/tag/v99.0.0".into(), + ..Default::default() + } +} + +pub(super) fn open_prompt(app: &mut MaterialCraftApp) { + app.updates_rt.updater = Updater::new(&crate::UPDATE_APP, "0.1.0").with_pins_path(no_pins()); + app.updates_rt.updater.offer(release()); +} + +#[test] +fn the_update_app_names_this_repository() { + assert_eq!(crate::UPDATE_APP.id, "materialcraft"); + assert_eq!(crate::UPDATE_APP.name, "MaterialCraft"); + assert_eq!(crate::UPDATE_APP.repo, "storytold/materialcraft"); + assert_eq!(crate::UPDATE_APP.bundle_id(), "ai.storyteller.materialcraft"); + assert!(crate::UPDATE_APP.icon_png.is_some()); +} + +#[test] +fn the_command_is_in_the_help_menu() { + let item = menus::CATALOG.iter().find(|item| item.id == COMMAND).unwrap(); + assert_eq!(item.menu, "Help"); + assert_eq!(item.label, "Check for updates..."); + assert!(menus::implemented(COMMAND)); + assert!(menus::enabled(&app(), COMMAND)); +} + +#[test] +fn a_new_app_is_idle_and_does_not_check_at_start() { + let rt = Runtime::default(); + assert!(!rt.startup_check); + assert!(!rt.check_requested); + assert!(!rt.updater.prompt_open()); + assert_eq!(rt.updater.status(), &Status::Idle); +} + +/// One whole frame of the app; the first one only installs the fonts +fn frame(app: &mut MaterialCraftApp, ctx: &egui::Context) { + let mut output = ctx.run_ui(egui::RawInput::default(), |ui| { + app.step(ui.ctx()); + app.draw(ui); + }); + output.textures_delta.clear(); +} + +#[test] +fn the_menu_command_starts_a_check_on_the_next_frame() { + let (mut app, checks, _) = app_with_source(); + let ctx = egui::Context::default(); + frame(&mut app, &ctx); + menus::invoke(&mut app, &ctx, COMMAND); + assert!(app.updates_rt.check_requested); + assert_eq!(app.updates_rt.updater.status(), &Status::Idle, "the check waits for the frame"); + + frame(&mut app, &ctx); + assert!(!app.updates_rt.check_requested); + assert_ne!(app.updates_rt.updater.status(), &Status::Idle); + // Dropping the app ends the wait with an error if no check was started + drop(app); + checks.recv().unwrap(); +} + +#[test] +fn the_check_at_start_runs_only_when_turned_on() { + let (mut app, checks, calls) = app_with_source(); + let ctx = egui::Context::default(); + tick(&mut app, &ctx); + assert_eq!(calls.load(Ordering::SeqCst), 0); + + app.set_startup_update_check(true); + tick(&mut app, &ctx); + assert_eq!(app.updates_rt.updater.status(), &Status::Idle, "the check at start is quiet"); + // Dropping the app ends the wait with an error if no check was started + drop(app); + checks.recv().unwrap(); + assert_eq!(calls.load(Ordering::SeqCst), 1); +} + +#[test] +fn result_window_shows_every_status_but_idle() { + let shown = [ + Status::Checking, + Status::UpToDate, + Status::Failed("no network".into()), + Status::Installing, + Status::Ready, + Status::Managed, + Status::Updated("0.2.0".into()), + Status::InstallFailed("disk full".into()), + ]; + for status in &shown { + assert!(result_window_shows(status, false), "{status:?}"); + assert!(!result_window_shows(status, true), "{status:?} over the prompt"); + } + assert!(!result_window_shows(&Status::Idle, false)); +} + +#[test] +fn an_offered_release_opens_the_prompt_over_the_window() { + let mut app = app(); + app.updates_rt.updater.offer(release()); + assert!(blocks_input(&app)); + + let mut harness = egui_kittest::Harness::builder().build_ui_state(|ui, app: &mut MaterialCraftApp| crate::windows::show(app, ui.ctx()), app); + harness.run_steps(3); + let _ = harness.get_by_label("LATER"); + assert!(harness.state().updates_rt.updater.prompt_open()); +} + +#[test] +fn a_requested_check_shows_its_progress() { + let mut app = app(); + // The check stays running until this sender goes away at the end of the test + let (release, wait) = channel::<()>(); + let wait = std::sync::Mutex::new(wait); + let source: craft_update::updater::CheckSource = Arc::new(move || { + if let Ok(wait) = wait.lock() { + let _ = wait.recv(); + } + Ok(None) + }); + app.updates_rt.updater = Updater::new(&crate::UPDATE_APP, "0.1.0").with_pins_path(no_pins()).with_source(source); + check(&mut app); + tick(&mut app, &egui::Context::default()); + + let mut harness = egui_kittest::Harness::builder().build_ui_state(|ui, app: &mut MaterialCraftApp| crate::windows::show(app, ui.ctx()), app); + harness.run_steps(3); + let _ = harness.get_by_label("Checking for updates…"); + drop(release); +} + +/// Ctrl+Shift+E opens the export window when nothing holds the keyboard +fn press_export(app: &mut MaterialCraftApp) { + let ctx = egui::Context::default(); + let modifiers = egui::Modifiers::COMMAND | egui::Modifiers::SHIFT; + let input = egui::RawInput { + events: vec![egui::Event::Key { key: egui::Key::E, physical_key: None, pressed: true, repeat: false, modifiers }], + ..Default::default() + }; + let mut output = ctx.run_ui(input, |ui| menus::shortcuts(app, ui.ctx())); + output.textures_delta.clear(); +} + +#[test] +fn the_prompt_and_the_modal_results_hold_the_keyboard() { + assert!(holds_keyboard(&Status::Idle, true)); + assert!(holds_keyboard(&Status::Checking, false)); + assert!(holds_keyboard(&Status::UpToDate, false)); + assert!(holds_keyboard(&Status::Failed("no network".into()), false)); + assert!(!holds_keyboard(&Status::Idle, false)); + assert!(!holds_keyboard(&Status::Updated("0.2.0".into()), false)); +} + +#[test] +fn shortcuts_wait_while_the_prompt_is_open() { + let mut idle = app(); + press_export(&mut idle); + assert!(idle.ui.windows.export, "the shortcut works without the prompt"); + + let mut prompted = app(); + prompted.updates_rt.updater.offer(release()); + press_export(&mut prompted); + assert!(!prompted.ui.windows.export); +} diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index 22c3c47..353a1fc 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -97,6 +97,8 @@ pub fn show(app: &mut MaterialCraftApp, ctx: &egui::Context) { } crate::unsaved::show(app, ctx); crate::explorer::dialogs(app, ctx); + #[cfg(not(target_arch = "wasm32"))] + crate::updates_ui::show(app, ctx); } fn modal(ctx: &egui::Context, id: &str, title: &str, open: &mut bool, size: egui::Vec2, body: impl FnOnce(&mut Ui)) { diff --git a/crates/ui-egui/tests/language_switching.rs b/crates/ui-egui/tests/language_switching.rs index f3f8132..e000f8b 100644 --- a/crates/ui-egui/tests/language_switching.rs +++ b/crates/ui-egui/tests/language_switching.rs @@ -17,6 +17,15 @@ fn language_switching_and_arabic_translations_work() { assert_eq!(tr("Welcome to MaterialCraft"), "مرحباً بك في MaterialCraft"); assert!(is_rtl()); + // The update menu item and dialogs use the same catalog + assert_eq!(tr("Check for updates..."), "التحقق من وجود تحديثات..."); + #[cfg(not(target_arch = "wasm32"))] + { + use materialcraft_ui_egui::updates_ui::translate; + assert_eq!(translate("Cancel", &[]), "إلغاء"); + assert_eq!(translate("{app} update", &[("app", "MaterialCraft")]), "MaterialCraft update"); + } + // Live formatting let formatted = trf("Hello {name}", &[("name", &"World")]); assert_eq!(formatted, "Hello World");