From bc34f006995a9ea7584b009343351fe289c420bf Mon Sep 17 00:00:00 2001 From: Caelan Sayler Date: Sat, 11 Jan 2025 08:51:08 +0000 Subject: [PATCH] remove webview2_com dependency --- Cargo.lock | 441 +++++++++++++++++++++++------- Cargo.toml | 3 +- src/bins/Cargo.toml | 7 +- src/bins/src/windows/mod.rs | 1 + src/bins/src/windows/runtimes.rs | 16 +- src/bins/src/windows/shortcuts.rs | 16 +- src/bins/src/windows/strings.rs | 6 +- src/bins/src/windows/webview2.rs | 173 ++++++++++++ 8 files changed, 531 insertions(+), 132 deletions(-) create mode 100644 src/bins/src/windows/webview2.rs diff --git a/Cargo.lock b/Cargo.lock index 9cc8adfa..7c660066 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -190,7 +190,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ - "event-listener 5.3.1", + "event-listener 5.4.0", "event-listener-strategy", "pin-project-lite", ] @@ -253,9 +253,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be" [[package]] name = "block-buffer" @@ -317,16 +317,16 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 2.0.95", + "syn 2.0.96", "tempfile", "toml 0.8.19", ] [[package]] name = "cc" -version = "1.2.7" +version = "1.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" +checksum = "ad0cf6e91fde44c773c6ee7ec6bba798504641a8bc2eb7e37a04ffbf4dfaa55a" dependencies = [ "jobserver", "libc", @@ -361,9 +361,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.23" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" dependencies = [ "clap_builder", "clap_derive", @@ -371,9 +371,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.23" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" dependencies = [ "anstream", "anstyle", @@ -383,14 +383,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", ] [[package]] @@ -542,7 +542,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", ] [[package]] @@ -600,7 +600,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", ] [[package]] @@ -620,6 +620,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "erased-serde" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24e2389d65ab4fab27dc2a5de7b191e1f6617d1f1c8855c0dc569c94a4cbb18d" +dependencies = [ + "serde", + "typeid", +] + [[package]] name = "errno" version = "0.3.10" @@ -638,9 +648,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "5.3.1" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" dependencies = [ "concurrent-queue", "parking", @@ -653,7 +663,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2" dependencies = [ - "event-listener 5.3.1", + "event-listener 5.4.0", "pin-project-lite", ] @@ -972,7 +982,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", ] [[package]] @@ -1106,15 +1116,15 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "libc", ] [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litemap" @@ -1130,9 +1140,9 @@ checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" [[package]] name = "log" -version = "0.4.22" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "3d6ea2a48c204030ee31a7d7fc72c93294c92fe87ecb1789881c9543516e1a0d" dependencies = [ "value-bag", ] @@ -1205,7 +1215,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6813fde79b646e47e7ad75f480aa80ef76a5d9599e2717407961531169ee38b" dependencies = [ "quote", - "syn 2.0.95", + "syn 2.0.96", "syn-mid", ] @@ -1317,9 +1327,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -1417,9 +1427,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -1546,11 +1556,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.42" +version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" +checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.7.0", "errno", "libc", "linux-raw-sys", @@ -1559,9 +1569,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.20" +version = "0.23.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" +checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" dependencies = [ "log", "once_cell", @@ -1639,14 +1649,23 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", +] + +[[package]] +name = "serde_fmt" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d4ddca14104cd60529e8c7f7ba71a2c8acd8f7f5cfcdc2faf97eeb7c3010a4" +dependencies = [ + "serde", ] [[package]] name = "serde_json" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", @@ -1781,7 +1800,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.95", + "syn 2.0.96", ] [[package]] @@ -1790,6 +1809,84 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "sval" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6dc0f9830c49db20e73273ffae9b5240f63c42e515af1da1fceefb69fceafd8" + +[[package]] +name = "sval_buffer" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "429922f7ad43c0ef8fd7309e14d750e38899e32eb7e8da656ea169dd28ee212f" +dependencies = [ + "sval", + "sval_ref", +] + +[[package]] +name = "sval_dynamic" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f16ff5d839396c11a30019b659b0976348f3803db0626f736764c473b50ff4" +dependencies = [ + "sval", +] + +[[package]] +name = "sval_fmt" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c01c27a80b6151b0557f9ccbe89c11db571dc5f68113690c1e028d7e974bae94" +dependencies = [ + "itoa", + "ryu", + "sval", +] + +[[package]] +name = "sval_json" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0deef63c70da622b2a8069d8600cf4b05396459e665862e7bdb290fd6cf3f155" +dependencies = [ + "itoa", + "ryu", + "sval", +] + +[[package]] +name = "sval_nested" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a39ce5976ae1feb814c35d290cf7cf8cd4f045782fe1548d6bc32e21f6156e9f" +dependencies = [ + "sval", + "sval_buffer", + "sval_ref", +] + +[[package]] +name = "sval_ref" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb7c6ee3751795a728bc9316a092023529ffea1783499afbc5c66f5fabebb1fa" +dependencies = [ + "sval", +] + +[[package]] +name = "sval_serde" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a5572d0321b68109a343634e3a5d576bf131b82180c6c442dee06349dfc652a" +dependencies = [ + "serde", + "sval", + "sval_nested", +] + [[package]] name = "syn" version = "1.0.109" @@ -1803,9 +1900,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.95" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", @@ -1820,7 +1917,7 @@ checksum = "b5dc35bb08dd1ca3dfb09dce91fd2d13294d6711c88897d9a9d60acf39bce049" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", ] [[package]] @@ -1831,7 +1928,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", ] [[package]] @@ -1868,11 +1965,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.9" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ - "thiserror-impl 2.0.9", + "thiserror-impl 2.0.11", ] [[package]] @@ -1883,18 +1980,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", ] [[package]] name = "thiserror-impl" -version = "2.0.9" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", ] [[package]] @@ -2017,7 +2114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e640d9b0964e9d39df633548591090ab92f7a4567bc31d3891af23471a3365c6" dependencies = [ "lazy_static", - "thiserror 2.0.9", + "thiserror 2.0.11", "ts-rs-macros", ] @@ -2029,10 +2126,16 @@ checksum = "0e9d8656589772eeec2cf7a8264d9cda40fb28b9bc53118ceb9e8c07f8f38730" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", "termcolor", ] +[[package]] +name = "typeid" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e13db2e0ccd5e14a544e8a246ba2312cd25223f616442d7f2cb0e3db614236e" + [[package]] name = "typenum" version = "1.17.0" @@ -2101,13 +2204,43 @@ name = "value-bag" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ef4c4aa54d5d05a279399bfa921ec387b7aba77caf7a682ae8d86785b8fdad2" +dependencies = [ + "value-bag-serde1", + "value-bag-sval2", +] + +[[package]] +name = "value-bag-serde1" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bb773bd36fd59c7ca6e336c94454d9c66386416734817927ac93d81cb3c5b0b" +dependencies = [ + "erased-serde", + "serde", + "serde_fmt", +] + +[[package]] +name = "value-bag-sval2" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a916a702cac43a88694c97657d449775667bcd14b70419441d05b7fea4a83a" +dependencies = [ + "sval", + "sval_buffer", + "sval_dynamic", + "sval_fmt", + "sval_json", + "sval_ref", + "sval_serde", +] [[package]] name = "velopack" version = "0.0.0-local" dependencies = [ "async-std", - "bitflags 2.6.0", + "bitflags 2.7.0", "derivative", "glob", "lazy_static", @@ -2121,11 +2254,11 @@ dependencies = [ "serde_json", "sha1", "sha2", - "thiserror 2.0.9", + "thiserror 2.0.11", "ts-rs", "ureq", "url", - "windows", + "windows 0.59.0", "xml", "zip", "zstd", @@ -2136,7 +2269,7 @@ name = "velopack_bins" version = "0.0.0-local" dependencies = [ "anyhow", - "bitflags 2.6.0", + "bitflags 2.7.0", "chrono", "clap", "core-foundation", @@ -2174,8 +2307,8 @@ dependencies = [ "velopack", "wait-timeout", "waitpid-any", - "webview2-com", - "windows", + "webview2-com-sys", + "windows 0.59.0", "winres", "winsafe", ] @@ -2265,7 +2398,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", "wasm-bindgen-shared", ] @@ -2300,7 +2433,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2330,31 +2463,6 @@ dependencies = [ "rustls-pki-types", ] -[[package]] -name = "webview2-com" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "823e7ebcfaea51e78f72c87fc3b65a1e602c321f407a0b36dbb327d7bb7cd921" -dependencies = [ - "webview2-com-macros", - "webview2-com-sys", - "windows", - "windows-core 0.58.0", - "windows-implement", - "windows-interface", -] - -[[package]] -name = "webview2-com-macros" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d228f15bba3b9d56dde8bddbee66fa24545bd17b48d5128ccf4a8742b18e431" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.95", -] - [[package]] name = "webview2-com-sys" version = "0.34.0" @@ -2362,7 +2470,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a82bce72db6e5ee83c68b5de1e2cd6ea195b9fbff91cb37df5884cbe3222df4" dependencies = [ "thiserror 1.0.69", - "windows", + "windows 0.58.0", "windows-core 0.58.0", ] @@ -2425,6 +2533,16 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f919aee0a93304be7f62e8e5027811bbba96bcb1de84d6618be56e43f8a32a1" +dependencies = [ + "windows-core 0.59.0", + "windows-targets 0.53.0", +] + [[package]] name = "windows-core" version = "0.52.0" @@ -2440,13 +2558,26 @@ version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" dependencies = [ - "windows-implement", - "windows-interface", - "windows-result", - "windows-strings", + "windows-implement 0.58.0", + "windows-interface 0.58.0", + "windows-result 0.2.0", + "windows-strings 0.1.0", "windows-targets 0.52.6", ] +[[package]] +name = "windows-core" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "810ce18ed2112484b0d4e15d022e5f598113e220c53e373fb31e67e21670c1ce" +dependencies = [ + "windows-implement 0.59.0", + "windows-interface 0.59.0", + "windows-result 0.3.0", + "windows-strings 0.3.0", + "windows-targets 0.53.0", +] + [[package]] name = "windows-implement" version = "0.58.0" @@ -2455,7 +2586,18 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", +] + +[[package]] +name = "windows-implement" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83577b051e2f49a058c308f17f273b570a6a758386fc291b5f6a934dd84e48c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", ] [[package]] @@ -2466,7 +2608,18 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", +] + +[[package]] +name = "windows-interface" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb26fd936d991781ea39e87c3a27285081e3c0da5ca0fcbc02d368cc6f52ff01" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", ] [[package]] @@ -2478,16 +2631,34 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-result" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d08106ce80268c4067c0571ca55a9b4e9516518eaa1a1fe9b37ca403ae1d1a34" +dependencies = [ + "windows-targets 0.53.0", +] + [[package]] name = "windows-strings" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ - "windows-result", + "windows-result 0.2.0", "windows-targets 0.52.6", ] +[[package]] +name = "windows-strings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b888f919960b42ea4e11c2f408fadb55f78a9f236d5eef084103c8ce52893491" +dependencies = [ + "windows-targets 0.53.0", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -2539,13 +2710,29 @@ dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", + "windows_i686_gnullvm 0.52.6", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows-targets" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -2558,6 +2745,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -2570,6 +2763,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -2582,12 +2781,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -2600,6 +2811,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -2612,6 +2829,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -2624,6 +2847,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -2637,10 +2866,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "winnow" -version = "0.6.22" +name = "windows_x86_64_msvc" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39281189af81c07ec09db316b302a3e67bf9bd7cbf6c820b50e35fee9c2fa980" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + +[[package]] +name = "winnow" +version = "0.6.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" dependencies = [ "memchr", ] @@ -2683,9 +2918,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.24" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea8b391c9a790b496184c29f7f93b9ed5b16abb306c05415b68bcc16e4d06432" +checksum = "c5b940ebc25896e71dd073bad2dbaa2abfe97b0a391415e22ad1326d9c54e3c4" [[package]] name = "yansi" @@ -2713,7 +2948,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", "synstructure", ] @@ -2735,7 +2970,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", ] [[package]] @@ -2755,7 +2990,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", "synstructure", ] @@ -2784,7 +3019,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.95", + "syn 2.0.96", ] [[package]] @@ -2800,7 +3035,7 @@ dependencies = [ "flate2", "indexmap", "memchr", - "thiserror 2.0.9", + "thiserror 2.0.11", "zopfli", ] diff --git a/Cargo.toml b/Cargo.toml index 0982af54..3867fa92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,8 +75,9 @@ filelocksmith = "0.1" image = { version = "0.25", default-features = false, features = ["gif", "jpeg", "png"] } fs_extra = "1.3" memmap2 = "0.9" -webview2-com = "0.34" windows = "0.59" +webview2-com-sys = "0.34" +winsafe = { version = "0.0.20", features = ["gui"] } cbindgen = "0.27" log-panics = "2.1.0" core-foundation = "0.10" diff --git a/src/bins/Cargo.toml b/src/bins/Cargo.toml index 7f9d4922..780c533f 100644 --- a/src/bins/Cargo.toml +++ b/src/bins/Cargo.toml @@ -78,11 +78,12 @@ waitpid-any.workspace = true fs_extra.workspace = true memmap2.workspace = true image.workspace = true -winsafe = { version = "0.0.20", features = ["gui"] } -windows = { version = "0.58", default-features = false, features = [ +winsafe.workspace = true +windows = { workspace = true, features = [ "Win32_Foundation", "Win32_Security", "Win32_System_Com", + "Win32_Globalization", "Win32_UI", "Win32_UI_Shell", "Win32_System_Threading", @@ -105,7 +106,7 @@ windows = { version = "0.58", default-features = false, features = [ "Wdk_System", "Wdk_System_Threading", ] } -webview2-com = "0.34" +webview2-com-sys.workspace = true libloading.workspace = true strsim.workspace = true same-file.workspace = true diff --git a/src/bins/src/windows/mod.rs b/src/bins/src/windows/mod.rs index 3490a561..674cfb52 100644 --- a/src/bins/src/windows/mod.rs +++ b/src/bins/src/windows/mod.rs @@ -6,6 +6,7 @@ pub mod splash; pub mod known_path; pub mod strings; pub mod registry; +pub mod webview2; mod self_delete; mod shortcuts; diff --git a/src/bins/src/windows/runtimes.rs b/src/bins/src/windows/runtimes.rs index 9cedef68..515ffa94 100644 --- a/src/bins/src/windows/runtimes.rs +++ b/src/bins/src/windows/runtimes.rs @@ -547,18 +547,8 @@ impl RuntimeInfo for WebView2Info { } fn is_installed(&self) -> bool { - // https://github.com/myhrmans/figma-content-length-bug/blob/980b5ce03171218904782f9ab590857d6c7de700/src/webview/webview2/mod.rs#L752 - use webview2_com::{Microsoft::Web::WebView2::Win32::*, *}; - use windows::core::{PCWSTR, PWSTR}; - let mut versioninfo = PWSTR::null(); - let result = unsafe { GetAvailableCoreWebView2BrowserVersionString(PCWSTR::null(), &mut versioninfo) }; - - if result.is_err() || versioninfo == PWSTR::null() { - return false; - } - - let version = take_pwstr(versioninfo); - if version.len() > 0 { + let result = super::webview2::get_webview_version(); + if let Some(version) = result { info!("WebView2 version: {}", version); true } else { @@ -710,7 +700,7 @@ fn test_parse_dotnet_version() { assert_eq!(info.architecture, RuntimeArch::X64); assert_eq!(info.runtime_type, DotnetRuntimeType::WindowsDesktop); - let info = parse_dotnet_version("net8-sdk").unwrap(); + let info = parse_dotnet_version("net8-sdk").unwrap(); assert_eq!(info.version, "8.0.0"); assert_eq!(info.architecture, RuntimeArch::X64); assert_eq!(info.runtime_type, DotnetRuntimeType::Sdk); diff --git a/src/bins/src/windows/shortcuts.rs b/src/bins/src/windows/shortcuts.rs index 3dc9883e..bbcfcfb5 100644 --- a/src/bins/src/windows/shortcuts.rs +++ b/src/bins/src/windows/shortcuts.rs @@ -6,11 +6,11 @@ use anyhow::{anyhow, bail, Result}; use glob::glob; use same_file::is_same_file; use velopack::{locator::ShortcutLocationFlags, locator::VelopackLocator}; -use windows::core::{Interface, GUID, PCWSTR, PROPVARIANT}; +use windows::core::{Interface, GUID, PCWSTR}; use windows::Win32::Storage::EnhancedStorage::PKEY_AppUserModel_ID; use windows::Win32::System::Com::{ CoCreateInstance, CoInitializeEx, CoUninitialize, IPersistFile, StructuredStorage::InitPropVariantFromStringVector, - CLSCTX_ALL, COINIT_APARTMENTTHREADED, COINIT_DISABLE_OLE1DDE, STGM_READWRITE, + StructuredStorage::PROPVARIANT, CLSCTX_ALL, COINIT_APARTMENTTHREADED, COINIT_DISABLE_OLE1DDE, STGM_READWRITE, }; use windows::Win32::UI::Shell::{ IShellItem, IShellLinkW, IStartMenuPinnedList, PropertiesSystem::IPropertyStore, SHCreateItemFromParsingName, ShellLink, StartMenuPin, @@ -153,8 +153,7 @@ unsafe fn unsafe_update_app_manifest_lnks(next_app: &VelopackLocator, previous_a let target_path = if let Some(parent) = path.parent() { parent.join(shortcut_file_name) } else { - match get_path_for_shortcut_location(&app_id, &app_title, &app_authors, flag) - { + match get_path_for_shortcut_location(&app_id, &app_title, &app_authors, flag) { Ok(p) => p, Err(e) => { error!("Failed to get desired path for shortcut location: {:?} ({})", flag, e); @@ -526,7 +525,6 @@ impl Lnk { Ok(self.pf.Save(output, true)?) } - pub unsafe fn open_write>(link_path: P) -> Result { let link_path = link_path.as_ref().to_string_lossy().to_string(); let link: IShellLinkW = create_instance(&ShellLink)?; @@ -575,7 +573,7 @@ fn test_unpin_shortcut() { unsafe_unpin_lnk_from_start(path)?; Ok(()) }) - .unwrap(); + .unwrap(); } } #[test] @@ -597,7 +595,7 @@ fn test_shortcut_intense_intermittent() { l.save_as(&p1).unwrap(); Ok(()) }) - .unwrap(); + .unwrap(); } assert!(lnk_path.exists()); util::retry_io(|| std::fs::remove_file(&lnk_path)).unwrap(); @@ -632,7 +630,7 @@ fn test_can_resolve_existing_shortcut() { assert_eq!(target, "C:\\Users\\Caelan\\AppData\\Local\\Discord\\Update.exe"); Ok(()) }) - .unwrap(); + .unwrap(); } } @@ -708,6 +706,6 @@ fn test_shortcut_full_integration() { assert!(!start_menu_subfolder.exists()); Ok(()) }) - .unwrap(); + .unwrap(); } } diff --git a/src/bins/src/windows/strings.rs b/src/bins/src/windows/strings.rs index b5245974..83f94c94 100644 --- a/src/bins/src/windows/strings.rs +++ b/src/bins/src/windows/strings.rs @@ -8,7 +8,7 @@ pub fn string_to_u16>(input: P) -> Vec { pub fn pwstr_to_string(input: PWSTR) -> Result { unsafe { - let hstring = input.to_hstring()?; + let hstring = input.to_hstring(); let string = hstring.to_string_lossy(); Ok(string.trim_end_matches('\0').to_string()) } @@ -16,7 +16,7 @@ pub fn pwstr_to_string(input: PWSTR) -> Result { pub fn pcwstr_to_string(input: PCWSTR) -> Result { unsafe { - let hstring = input.to_hstring()?; + let hstring = input.to_hstring(); let string = hstring.to_string_lossy(); Ok(string.trim_end_matches('\0').to_string()) } @@ -24,7 +24,7 @@ pub fn pcwstr_to_string(input: PCWSTR) -> Result { pub fn u16_to_string>(input: T) -> Result { let input = input.as_ref(); - let hstring = HSTRING::from_wide(input)?; + let hstring = HSTRING::from_wide(input); let string = hstring.to_string_lossy(); Ok(string.trim_end_matches('\0').to_string()) } diff --git a/src/bins/src/windows/webview2.rs b/src/bins/src/windows/webview2.rs new file mode 100644 index 00000000..990886a8 --- /dev/null +++ b/src/bins/src/windows/webview2.rs @@ -0,0 +1,173 @@ +use std::{fmt::Display, marker::PhantomData, mem, ptr}; + +use windows::{ + core::{Param, HRESULT, PCWSTR, PWSTR}, + Win32::{Globalization::lstrlenW, System::Com}, +}; + +/// RAII holder for a [`PWSTR`] which is allocated with [`Com::CoTaskMemAlloc`] and freed +/// with [`Com::CoTaskMemFree`] when dropped. +pub struct CoTaskMemPWSTR<'a>(PWSTR, PhantomData<&'a PWSTR>); + +/// Constant guard object tied to the lifetime of the [`CoTaskMemPWSTR`] so that it +/// is safe to dereference the [`PCWSTR`] as long as both are still in scope. +pub struct CoTaskMemRef<'a>(PCWSTR, PhantomData<&'a PCWSTR>); + +impl<'a> CoTaskMemRef<'a> { + pub fn as_pcwstr(&self) -> &PCWSTR { + &self.0 + } +} + +impl<'a> From<&'a CoTaskMemPWSTR<'a>> for CoTaskMemRef<'a> { + fn from(value: &'a CoTaskMemPWSTR<'a>) -> Self { + Self(PCWSTR::from_raw(value.0.as_ptr()), PhantomData) + } +} + +/// Mutable guard object tied to the lifetime of the [`CoTaskMemPWSTR`] so that it +/// is safe to dereference the [`PWSTR`] as long as both are still in scope. +pub struct CoTaskMemMut<'a>(&'a PWSTR); + +impl<'a> CoTaskMemMut<'a> { + pub fn as_pwstr(&mut self) -> &'a PWSTR { + self.0 + } +} + +impl<'a> From<&'a mut CoTaskMemPWSTR<'a>> for CoTaskMemMut<'a> { + fn from(value: &'a mut CoTaskMemPWSTR<'a>) -> Self { + Self(&value.0) + } +} + +impl<'a> CoTaskMemPWSTR<'a> { + /// Get a mutable [`PWSTR`] guard which borrows the pointer. + pub fn as_mut(&'a mut self) -> CoTaskMemMut<'a> { + From::from(self) + } + + /// Get a constant [`PCWSTR`] guard which borrows the pointer. + pub fn as_ref(&'a self) -> CoTaskMemRef<'a> { + From::from(self) + } + + /// Take the [`PWSTR`] pointer and hand off ownership so that it is not freed when the `CoTaskMemPWSTR` is dropped. + pub fn take(&mut self) -> PWSTR { + let result = self.0; + self.0 = PWSTR::null(); + result + } +} + +impl<'a> Drop for CoTaskMemPWSTR<'a> { + fn drop(&mut self) { + if !self.0.is_null() { + unsafe { + Com::CoTaskMemFree(Some(self.0.as_ptr() as *mut _ as *const _)); + } + } + } +} + +impl<'a> Default for CoTaskMemPWSTR<'a> { + fn default() -> Self { + Self(PWSTR::null(), PhantomData) + } +} + +impl<'a> From for CoTaskMemPWSTR<'a> { + fn from(value: PWSTR) -> Self { + Self(value, PhantomData) + } +} + +impl<'a> From<&str> for CoTaskMemPWSTR<'a> { + fn from(value: &str) -> Self { + match value { + "" => Default::default(), + value => { + let encoded: Vec<_> = value.encode_utf16().chain(std::iter::once(0)).collect(); + + unsafe { + let mut buffer = Com::CoTaskMemAlloc(encoded.len() * mem::size_of::()) as *mut u16; + let result = PWSTR::from_raw(buffer); + + for char in encoded { + *buffer = char; + buffer = buffer.add(1); + } + + Self(result, PhantomData) + } + } + } + } +} + +impl<'a> Display for CoTaskMemPWSTR<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let value = string_from_pcwstr(self.as_ref().as_pcwstr()); + f.write_str(value.as_str()) + } +} + +/// Copy a [`PCWSTR`] from an input param to a [`String`]. +pub fn string_from_pcwstr(source: &PCWSTR) -> String { + if source.0.is_null() { + String::new() + } else { + let len = unsafe { lstrlenW(*source) }; + + if len > 0 { + unsafe { + let buffer = ptr::slice_from_raw_parts(source.0, len as usize); + String::from_utf16_lossy(&*buffer) + } + } else { + String::new() + } + } +} + +/// Copy a [`PWSTR`] allocated with [`Com::CoTaskMemAlloc`] from an input param to a [`String`] +/// and free the original buffer with [`Com::CoTaskMemFree`]. +pub fn take_pwstr(source: PWSTR) -> String { + CoTaskMemPWSTR::from(source).to_string() +} + +/// Allocate a [`PWSTR`] with [`Com::CoTaskMemAlloc`] and copy a [`&str`] into it. +pub fn pwstr_from_str(source: &str) -> PWSTR { + CoTaskMemPWSTR::from(source).take() +} + +// https://github.com/myhrmans/figma-content-length-bug/blob/980b5ce03171218904782f9ab590857d6c7de700/src/webview/webview2/mod.rs#L752 +pub fn get_webview_version() -> Option { + // #[cfg_attr(target_env = "msvc", link(name = "WebView2LoaderStatic", kind = "static"))] + // #[cfg_attr(not(target_env = "msvc"), link(name = "WebView2Loader.dll"))] + #[link(name = "WebView2LoaderStatic", kind = "static")] + extern "system" { + pub fn GetAvailableCoreWebView2BrowserVersionString(browserexecutablefolder: PCWSTR, versioninfo: *mut PWSTR) -> HRESULT; + } + + let browserexecutablefolder = PCWSTR::null(); + let mut versioninfo = PWSTR::null(); + + let hr = unsafe { GetAvailableCoreWebView2BrowserVersionString(browserexecutablefolder.param().abi(), &mut versioninfo).ok() }; + if hr.is_err() || versioninfo.is_null() { + return None; + } + + let str = CoTaskMemPWSTR::from(versioninfo).to_string(); + if str.is_empty() { + None + } else { + Some(str) + } +} + +#[test] +fn test_webview_version() { + let version = get_webview_version(); + assert!(version.is_some()); +}