diff --git a/.github/workflows/desktop-installer.yml b/.github/workflows/desktop-installer.yml index 0118101..0cdfa62 100644 --- a/.github/workflows/desktop-installer.yml +++ b/.github/workflows/desktop-installer.yml @@ -27,19 +27,19 @@ jobs: - name: Get WiX run: dotnet tool install --global wix --version 4.0.5 - # The released program stands in for a fresh build. - - name: Get the released program - env: - GH_TOKEN: ${{ github.token }} + # Build the current PR so installer testing does not depend on a published release asset. + - name: Build the current program + working-directory: desktop + run: cargo build --release --locked -p castbay-desktop-gpui + + - name: Prepare installer inputs run: | - gh release download desktop-v0.1.0 --repo $env:GITHUB_REPOSITORY --pattern '*windows-x64.zip' --dir "$env:RUNNER_TEMP\release" - Expand-Archive "$env:RUNNER_TEMP\release\*.zip" -DestinationPath "$env:RUNNER_TEMP\release\unzipped" - $dir = Get-ChildItem "$env:RUNNER_TEMP\release\unzipped" -Directory | Select-Object -First 1 - Copy-Item "$($dir.FullName)\CastBay Desktop.exe" "$env:RUNNER_TEMP\app.exe" - Copy-Item "$($dir.FullName)\LICENSE" "$env:RUNNER_TEMP\LICENSE" + Copy-Item "desktop\target\release\castbay-desktop.exe" "$env:RUNNER_TEMP\app.exe" + Copy-Item "LICENSE" "$env:RUNNER_TEMP\LICENSE" + ./desktop/installer/collect-vc-runtime.ps1 -OutDir "$env:RUNNER_TEMP\windows-runtime" - name: Build the installers - run: ./desktop/installer/build-msi.ps1 -Version 0.1.0 -AppExe "$env:RUNNER_TEMP\app.exe" -LicenseTxt "$env:RUNNER_TEMP\LICENSE" -OutDir "$env:RUNNER_TEMP\msi" -NameStem CastBay-Desktop-0.1.0-windows-x64 + run: ./desktop/installer/build-msi.ps1 -Version 0.1.0 -AppExe "$env:RUNNER_TEMP\app.exe" -VCRuntimeDll "$env:RUNNER_TEMP\windows-runtime\vcruntime140.dll" -LicenseTxt "$env:RUNNER_TEMP\LICENSE" -OutDir "$env:RUNNER_TEMP\msi" -NameStem CastBay-Desktop-0.1.0-windows-x64 - name: Install, install over, start, uninstall (each language) run: | diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml index 156e6ec..e95e86d 100644 --- a/.github/workflows/desktop-release.yml +++ b/.github/workflows/desktop-release.yml @@ -97,7 +97,7 @@ jobs: - name: Build CastBay Desktop working-directory: desktop - run: cargo build --release --locked -p castbay-desktop --features ffmpeg-lib + run: cargo build --release --locked -p castbay-desktop-gpui --features ffmpeg-lib - name: Keep the Rust build for the other runs if: github.ref == 'refs/heads/main' @@ -108,6 +108,12 @@ jobs: desktop/target key: ${{ steps.rust.outputs.cache-primary-key }} + # The MSVC Rust executable imports vcruntime140.dll. Ship the licensed, x64 app-local + # redistributable so the portable build also starts on clean Windows installations. + - name: Stage the app-local Visual C++ runtime + shell: pwsh + run: ./desktop/installer/collect-vc-runtime.ps1 -OutDir "$PWD\desktop\build\windows-runtime" + - name: Package run: | case "$GITHUB_REF" in @@ -118,15 +124,16 @@ jobs: dir="CastBay-Desktop-$VERSION-windows-x64" mkdir -p "dist/$dir" cp desktop/target/release/castbay-desktop.exe "dist/$dir/CastBay Desktop.exe" + cp desktop/build/windows-runtime/vcruntime140.dll "dist/$dir/" cp LICENSE* "dist/$dir/" 2>/dev/null || true { echo "CastBay Desktop $VERSION" echo echo "This is the portable version: run \"CastBay Desktop.exe\" (the .msi files next to this zip on the" - echo "release page install it instead, with a Start menu entry and uninstaller). It needs the Microsoft Edge WebView2 runtime (part of" - echo "Windows 11 and recent Windows 10). Windows may ask to let it use the network: allow it" + echo "release page install it instead, with a Start menu entry and uninstaller). Windows may ask to let it use the network: allow it" echo "on private networks so receivers can be found. It is not code-signed yet, so SmartScreen" echo "may warn: choose More info, then Run anyway." + echo "The required Microsoft Visual C++ runtime is included beside the executable." echo echo "Guide: https://github.com/${GITHUB_REPOSITORY}/blob/main/desktop/docs/user-guide.md" echo @@ -154,7 +161,7 @@ jobs: run: | $appVersion = (Select-String -Path desktop\app\Cargo.toml -Pattern '^version = "(.*)"' | Select-Object -First 1).Matches[0].Groups[1].Value "APP_VERSION=$appVersion" | Out-File -Append -Encoding utf8 $env:GITHUB_ENV - ./desktop/installer/build-msi.ps1 -Version $appVersion -AppExe "$PWD\desktop\target\release\castbay-desktop.exe" -LicenseTxt "$PWD\LICENSE" -OutDir "$PWD\dist" -NameStem "CastBay-Desktop-$env:VERSION-windows-x64" + ./desktop/installer/build-msi.ps1 -Version $appVersion -AppExe "$PWD\desktop\target\release\castbay-desktop.exe" -VCRuntimeDll "$PWD\desktop\build\windows-runtime\vcruntime140.dll" -LicenseTxt "$PWD\LICENSE" -OutDir "$PWD\dist" -NameStem "CastBay-Desktop-$env:VERSION-windows-x64" # Install, install over, start, uninstall on the runner, before anything is published. - name: Try the installers @@ -164,6 +171,7 @@ jobs: "== $($m.Name)" ./desktop/installer/test-install.ps1 -Msi $m.FullName -Version $env:APP_VERSION } + ./desktop/installer/test-portable.ps1 -Zip (Get-ChildItem dist\CastBay-Desktop-*-windows-x64.zip | Select-Object -First 1).FullName - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: @@ -195,7 +203,7 @@ jobs: - name: Install the system libraries run: | sudo apt-get update - sudo apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev \ + sudo apt-get install -y --no-install-recommends libgtk-3-dev libxdo-dev libxkbcommon-x11-dev libayatana-appindicator3-dev \ librsvg2-dev libssl-dev libdbus-1-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev clang nasm - name: Note the submodule commits @@ -236,7 +244,7 @@ jobs: - name: Build CastBay Desktop working-directory: desktop - run: cargo build --release --locked -p castbay-desktop --features ffmpeg-lib + run: cargo build --release --locked -p castbay-desktop-gpui --features ffmpeg-lib - name: Keep the Rust build for the other runs if: github.ref == 'refs/heads/main' diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.yml index e7b2a18..b893a4b 100644 --- a/.github/workflows/desktop.yml +++ b/.github/workflows/desktop.yml @@ -89,7 +89,7 @@ jobs: working-directory: . run: | sudo apt-get update - sudo apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev \ + sudo apt-get install -y --no-install-recommends libgtk-3-dev libxdo-dev libxkbcommon-x11-dev libayatana-appindicator3-dev \ librsvg2-dev libssl-dev libdbus-1-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev clang - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 diff --git a/desktop/Cargo.lock b/desktop/Cargo.lock index 64e2f26..c859ac9 100644 --- a/desktop/Cargo.lock +++ b/desktop/Cargo.lock @@ -2,12 +2,126 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "accesskit" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b7f7f85a7e5f68090000ed7622545829afd484d210358702ae4cb97dd0c320" +dependencies = [ + "enumn", + "uuid", +] + +[[package]] +name = "accesskit_atspi_common" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "023da0e5097f46df7092d5280b02efb9bbf8d93298daeced42652463e357d636" +dependencies = [ + "accesskit", + "accesskit_consumer", + "atspi-common", + "phf", + "serde", + "zvariant", +] + +[[package]] +name = "accesskit_consumer" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d10a236f96f87d70732e44520046785431ef01d5bcd6b041317bfadd2f88245" +dependencies = [ + "accesskit", + "hashbrown 0.16.1", +] + +[[package]] +name = "accesskit_macos" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce02dc63b43f0c9296af9ac946312a2dc8814427d7a64d2d600971dac55b6076" +dependencies = [ + "accesskit", + "accesskit_consumer", + "hashbrown 0.16.1", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "accesskit_unix" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03e156ed3802e35eefe894ef2671bc6c889303d8a7e110b5e1b48f504b91362f" +dependencies = [ + "accesskit", + "accesskit_atspi_common", + "async-channel", + "async-executor", + "async-task", + "atspi", + "futures-lite", + "futures-util", + "serde", + "zbus 5.19.0", +] + +[[package]] +name = "accesskit_windows" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "106c2b961215864d1c2e703ee63269c25c4e80a577ffb2c1017b9c17dcdf83a1" +dependencies = [ + "accesskit", + "accesskit_consumer", + "hashbrown 0.16.1", + "static_assertions", + "windows 0.62.2", + "windows-core 0.62.2", +] + +[[package]] +name = "addr2line" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e567177890eb1617b1f774005b66b26b2377afd138a2ca37aae7d8f0c81429d4" +dependencies = [ + "gimli", +] + [[package]] name = "adler2" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", + "zeroize", +] + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "const-random", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.5" @@ -18,20 +132,29 @@ dependencies = [ ] [[package]] -name = "alloc-no-stdlib" -version = "3.0.0" +name = "aligned" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2fb6cfd47bf496ff64095c20eaba0c201404ee38714d4142fcfa1dc334fcc7a" +checksum = "ee4508988c62edf04abd8d92897fca0c2995d907ce1dfeaf369dac3716a40685" +dependencies = [ + "as-slice", +] [[package]] -name = "alloc-stdlib" -version = "0.3.0" +name = "aligned-vec" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b5c1865780388bfa186411ab5f247819487fc4864c6e9c3106611fa347586e1" +checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b" dependencies = [ - "alloc-no-stdlib", + "equator", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "android_system_properties" version = "0.1.6" @@ -63,6 +186,59 @@ version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" +[[package]] +name = "arbitrary" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bc62ac97cc33321f50863d514c3bc38a453947a8f9e781137e47c7401020aed" + +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" + +[[package]] +name = "as-raw-xcb-connection" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" + +[[package]] +name = "as-slice" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "ash" +version = "0.38.0+1.3.281" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" +dependencies = [ + "libloading 0.8.9", +] + [[package]] name = "ashpd" version = "0.13.13" @@ -70,12 +246,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb8421aaa9644a5faf26735f258b669b15f063313ef8f8e2bdb28912a1a6f111" dependencies = [ "enumflags2", + "futures-channel", "futures-util", "getrandom 0.4.3", "serde", "serde_repr", - "tokio", - "zbus", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "zbus 5.19.0", ] [[package]] @@ -155,6 +334,17 @@ dependencies = [ "slab", ] +[[package]] +name = "async-fs" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8034a681df4aed8b8edbd7fbe472401ecf009251c8b40556b304567052e294c5" +dependencies = [ + "async-lock", + "blocking", + "futures-lite", +] + [[package]] name = "async-io" version = "2.6.0" @@ -184,6 +374,17 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-net" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7" +dependencies = [ + "async-io", + "blocking", + "futures-lite", +] + [[package]] name = "async-process" version = "2.5.0" @@ -277,6 +478,43 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "atspi" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c77886257be21c9cd89a4ae7e64860c6f0eefca799bb79127913052bd0eefb3d" +dependencies = [ + "atspi-common", + "atspi-proxies", +] + +[[package]] +name = "atspi-common" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20c5617155740c98003016429ad13fe43ce7a77b007479350a9f8bf95a29f63d" +dependencies = [ + "enumflags2", + "serde", + "static_assertions", + "zbus 5.19.0", + "zbus-lockstep", + "zbus-lockstep-macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "atspi-proxies" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2230e48787ed3eb4088996eab66a32ca20c0b67bbd4fd6cdfe79f04f1f04c9fc" +dependencies = [ + "atspi-common", + "serde", + "zbus 5.19.0", +] + [[package]] name = "autocfg" version = "1.5.1" @@ -284,22 +522,68 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] -name = "base64" -version = "0.21.7" +name = "av-scenechange" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f321d77c20e19b92c39e7471cf986812cbb46659d2af674adc4331ef3f18394" +dependencies = [ + "aligned", + "anyhow", + "arg_enum_proc_macro", + "arrayvec", + "log", + "num-rational", + "num-traits", + "pastey", + "rayon", + "thiserror 2.0.21", + "v_frame", + "y4m", +] + +[[package]] +name = "av1-grain" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "8cfddb07216410377231960af4fcab838eaa12e013417781b78bd95ee22077f8" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom 8.0.0", + "num-rational", + "v_frame", +] [[package]] -name = "base64" -version = "0.22.1" +name = "avif-serialize" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +checksum = "e7178fe5f7d460b13895ebb9dcb28a3a6216d2df2574a0806cb51b555d297f38" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "backtrace" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f4220217f3288537b83684130f42fad43320b1c3b805f1910d683d52ded24f" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide 0.9.1", + "object", + "rustc-demangle", + "windows-link 0.2.1", +] [[package]] name = "base64" -version = "0.23.1" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bindgen" @@ -311,29 +595,35 @@ dependencies = [ "bitflags 2.13.2", "cexpr", "clang-sys", - "itertools", + "itertools 0.13.0", "proc-macro2", "quote", "regex", - "rustc-hash", + "rustc-hash 2.1.3", "shlex 1.3.0", "syn 2.0.119", ] [[package]] name = "bit-set" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +checksum = "09ec2f926cc3060f09db9ebc5b52823d85268d24bb917e472c0c4bea35780a7d" dependencies = [ "bit-vec", ] [[package]] name = "bit-vec" -version = "0.8.0" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" + +[[package]] +name = "bit_field" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" +checksum = "cb2907cc03d08cdb1c6724ad0670ce67c4a71e1c45a6d7635224011714cfc4b1" [[package]] name = "bitflags" @@ -346,10 +636,22 @@ name = "bitflags" version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "bitstream-io" +version = "4.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eff00be299a18769011411c9def0d827e8f2d7bf0c3dbf53633147a8867fd1f" dependencies = [ - "serde_core", + "no_std_io2", ] +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + [[package]] name = "block-buffer" version = "0.10.4" @@ -359,13 +661,31 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-padding" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2 0.5.3", +] + [[package]] name = "block2" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" dependencies = [ - "objc2", + "objc2 0.6.5", ] [[package]] @@ -382,34 +702,10 @@ dependencies = [ ] [[package]] -name = "brotli" -version = "9.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6737ce8b81460bf9407909f73ff50bf13f7cb8577e1e76715f57ed0eba58ba44" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", - "brotli-decompressor", -] - -[[package]] -name = "brotli-decompressor" -version = "6.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34c6783f42c21c952ad7112b354f0ba2f10760e9decea5b1b60523d6e270faaf" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", -] - -[[package]] -name = "bs58" -version = "0.5.1" +name = "built" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" -dependencies = [ - "tinyvec", -] +checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9" [[package]] name = "bumpalo" @@ -422,6 +718,20 @@ name = "bytemuck" version = "1.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] [[package]] name = "byteorder" @@ -429,14 +739,17 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + [[package]] name = "bytes" version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" -dependencies = [ - "serde", -] [[package]] name = "cairo-rs" @@ -464,46 +777,27 @@ dependencies = [ ] [[package]] -name = "camino" -version = "1.2.6" +name = "calloop" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbad30e4b4c14a39e3cc8aed085a12a327257c316619c93581e017bc52be591" +checksum = "43b32313e937c8721c9d17ee9bf60699a6402b4b7c2cb6ac1bee0ffcaa4b4e5e" dependencies = [ - "serde_core", + "bitflags 2.13.2", + "polling", + "rustix", + "tracing", ] [[package]] -name = "cargo-platform" -version = "0.1.9" +name = "calloop-wayland-source" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa" dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "serde", - "serde_json", - "thiserror 2.0.21", -] - -[[package]] -name = "cargo_toml" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82f4b26e751e711a5302649417f2da046dce6391b2ea30a4820f37462314f0b9" -dependencies = [ - "semver", - "serde", - "toml 1.1.8+spec-1.1.0", + "calloop", + "rustix", + "wayland-backend", + "wayland-client", ] [[package]] @@ -512,7 +806,7 @@ version = "0.0.0" dependencies = [ "ashpd", "pipewire", - "tokio", + "smol", "windows 0.61.3", "windows-capture", "windows-core 0.61.2", @@ -531,20 +825,20 @@ dependencies = [ ] [[package]] -name = "castbay-desktop" +name = "castbay-desktop-gpui" version = "0.1.8" dependencies = [ "castbay-capture", "castbay-link", "castbay-sender", "getrandom 0.3.4", + "gpui-platform-gpui-unofficial", + "gpui-unofficial", "libloading 0.8.9", "serde", "serde_json", "sha2", - "tauri", - "tauri-build", - "tauri-plugin-single-instance", + "tray-icon", "windows 0.61.3", ] @@ -582,6 +876,33 @@ dependencies = [ "windows 0.61.3", ] +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + +[[package]] +name = "cbindgen" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadd868a2ce9ca38de7eeafdcec9c7065ef89b42b32f0839278d55f35c54d1ff" +dependencies = [ + "heck 0.4.1", + "indexmap", + "log", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 2.0.119", + "tempfile", + "toml 0.8.23", +] + [[package]] name = "cc" version = "1.10.0" @@ -589,15 +910,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0" dependencies = [ "find-msvc-tools", + "jobserver", + "libc", "shlex 2.0.1", ] -[[package]] -name = "cesu8" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" - [[package]] name = "cexpr" version = "0.6.0" @@ -607,17 +924,6 @@ dependencies = [ "nom 7.1.3", ] -[[package]] -name = "cfb" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a347dcabdae9c31b0825fd6a8bed285ec9c2acb89c47827126d52fa4f59cece3" -dependencies = [ - "fnv", - "uuid", - "web-time", -] - [[package]] name = "cfg-expr" version = "0.15.8" @@ -644,6 +950,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + [[package]] name = "chrono" version = "0.4.45" @@ -651,11 +963,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" dependencies = [ "iana-time-zone", + "js-sys", "num-traits", "serde", + "wasm-bindgen", "windows-link 0.2.1", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", + "zeroize", +] + [[package]] name = "clang-sys" version = "1.9.1" @@ -668,15 +993,63 @@ dependencies = [ ] [[package]] -name = "combine" -version = "4.6.9" +name = "cocoa" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c" dependencies = [ - "bytes", - "memchr", + "bitflags 1.3.2", + "block", + "cocoa-foundation", + "core-foundation 0.9.4", + "core-graphics 0.23.2", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "cocoa-foundation" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7" +dependencies = [ + "bitflags 1.3.2", + "block", + "core-foundation 0.9.4", + "core-graphics-types 0.1.3", + "libc", + "objc", +] + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "collections-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc720ee191b626b713dfea9d7d03ff6b482cf6d9b7f185c67a6197b4faa5064e" +dependencies = [ + "gpui-util-gpui-unofficial", + "indexmap", + "rustc-hash 2.1.3", ] +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "concurrent-queue" version = "2.5.0" @@ -687,13 +1060,42 @@ dependencies = [ ] [[package]] -name = "cookie" -version = "0.18.2" +name = "console_error_panic_hook" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" dependencies = [ - "time", - "version_check", + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.17", + "once_cell", + "tiny-keccak", +] + +[[package]] +name = "convert_case" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" +dependencies = [ + "unicode-segmentation", ] [[package]] @@ -702,6 +1104,16 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9885fa71e26b8ab7855e2ec7cae6e9b380edff76cd052e07c683a0319d51b3a2" +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation" version = "0.10.1" @@ -720,17 +1132,54 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "core-graphics" -version = "0.25.0" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "core-graphics-types 0.1.3", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" +dependencies = [ + "bitflags 2.13.2", + "core-foundation 0.10.1", + "core-graphics-types 0.2.0", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-helmer-fork" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97" +checksum = "32eb7c354ae9f6d437a6039099ce7ecd049337a8109b23d73e48e8ffba8e9cd5" dependencies = [ "bitflags 2.13.2", - "core-foundation", - "core-graphics-types", + "core-foundation 0.9.4", + "core-graphics-types 0.1.3", "foreign-types", "libc", ] +[[package]] +name = "core-graphics-types" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "libc", +] + [[package]] name = "core-graphics-types" version = "0.2.0" @@ -738,10 +1187,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ "bitflags 2.13.2", - "core-foundation", + "core-foundation 0.10.1", + "libc", +] + +[[package]] +name = "core-text" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a593227b66cbd4007b2a050dfdd9e1d1318311409c8d600dc82ba1b15ca9c130" +dependencies = [ + "core-foundation 0.10.1", + "core-graphics 0.24.0", + "foreign-types", "libc", ] +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + +[[package]] +name = "core_maths" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" +dependencies = [ + "libm", +] + +[[package]] +name = "cosmic-text" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be17b688510d934ce13f48a2beba700e11583e281e0fda99c22bb256a14eda73" +dependencies = [ + "bitflags 2.13.2", + "fontdb", + "harfrust", + "linebender_resource_handle", + "log", + "rangemap", + "rustc-hash 2.1.3", + "self_cell", + "skrifa 0.40.0", + "smol_str", + "swash", + "sys-locale", + "unicode-bidi", + "unicode-linebreak", + "unicode-script", + "unicode-segmentation", +] + [[package]] name = "cpufeatures" version = "0.2.17" @@ -794,6 +1294,12 @@ version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + [[package]] name = "crypto-common" version = "0.1.7" @@ -805,177 +1311,119 @@ dependencies = [ ] [[package]] -name = "cssparser" -version = "0.37.0" +name = "ctor" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9cdaae01d5ed7882b04d795e7f752f46ff52d2fa3b50a20d28c464510bba98" +checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d" dependencies = [ - "cssparser-macros", - "dtoa-short", - "itoa", - "phf", - "smallvec", + "link-section", + "linktime-proc-macro", ] [[package]] -name = "cssparser-macros" -version = "0.7.1" +name = "data-encoding" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d045de693cb712d0b22c6a64be5b953f67b3ce00ab5ad3dd5d8b441886ab8e1a" -dependencies = [ - "quote", - "syn 3.0.9", -] +checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" [[package]] -name = "ctor" -version = "1.0.13" +name = "data-url" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d" +checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" [[package]] -name = "darling" -version = "0.24.1" +name = "der-parser" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" +checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" dependencies = [ - "darling_core", - "darling_macro", + "asn1-rs", + "displaydoc", + "nom 7.1.3", + "num-bigint", + "num-traits", + "rusticata-macros", ] [[package]] -name = "darling_core" -version = "0.24.1" +name = "deranged" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" + +[[package]] +name = "derive-refineable-gpui-unofficial" +version = "1.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" +checksum = "cc4946baf39522602d482d5c4797b53e9c44b863177d6c54d67c316109325ead" dependencies = [ - "ident_case", "proc-macro2", "quote", - "strsim", - "syn 3.0.9", + "syn 2.0.119", ] [[package]] -name = "darling_macro" -version = "0.24.1" +name = "derive_more" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" dependencies = [ - "darling_core", - "quote", - "syn 3.0.9", + "derive_more-impl", ] [[package]] -name = "data-encoding" -version = "2.11.1" +name = "derive_more-impl" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.119", +] [[package]] -name = "dbus" -version = "0.9.12" +name = "digest" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab69f03cc8c4340c9c8e315114e1658e6775a9b16a04357973aa21cec22b32e" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "libc", - "libdbus-sys", - "windows-sys 0.61.2", + "block-buffer", + "crypto-common", + "subtle", ] [[package]] -name = "defmt" -version = "1.2.0" +name = "dirs" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a0795ac740cb54d7b3775c9c17345f6aaecf884c01733b39d6017738e0e3e1" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ - "bitflags 1.3.2", - "defmt-macros", + "dirs-sys 0.4.1", ] [[package]] -name = "defmt-macros" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "840bb056bd99c495c9188198a258ab787c79f306d864db3e6e8451442d6d8366" -dependencies = [ - "defmt-parser", - "proc-macro2", - "quote", - "syn 3.0.9", -] - -[[package]] -name = "defmt-parser" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71958f69fb2de856c5dd51ac9377e986ca1aa5919f931bf5395a807277f889a0" -dependencies = [ - "thiserror 2.0.21", -] - -[[package]] -name = "der-parser" -version = "9.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" -dependencies = [ - "asn1-rs", - "displaydoc", - "nom 7.1.3", - "num-bigint", - "num-traits", - "rusticata-macros", -] - -[[package]] -name = "deranged" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" -dependencies = [ - "serde_core", -] - -[[package]] -name = "derive_more" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" -dependencies = [ - "proc-macro2", - "quote", - "rustc_version", - "syn 2.0.119", -] - -[[package]] -name = "digest" -version = "0.10.7" +name = "dirs" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f" dependencies = [ - "block-buffer", - "crypto-common", + "dirs-sys 0.5.0", ] [[package]] -name = "dirs" -version = "7.0.0" +name = "dirs-sys" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ - "dirs-sys", + "libc", + "option-ext", + "redox_users 0.4.6", + "windows-sys 0.48.0", ] [[package]] @@ -986,10 +1434,16 @@ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" dependencies = [ "libc", "option-ext", - "redox_users", + "redox_users 0.5.3", "windows-sys 0.61.2", ] +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + [[package]] name = "dispatch2" version = "0.3.1" @@ -997,9 +1451,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ "bitflags 2.13.2", - "block2", - "libc", - "objc2", + "block2 0.6.2", + "objc2 0.6.5", ] [[package]] @@ -1014,73 +1467,53 @@ dependencies = [ ] [[package]] -name = "dlopen2" -version = "0.8.2" +name = "dlib" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2c5bd4158e66d1e215c49b837e11d62f3267b30c92f1d171c4d3105e3dc4d4" +checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a" dependencies = [ - "dlopen2_derive", - "libc", - "once_cell", - "winapi", + "libloading 0.8.9", ] [[package]] -name = "dlopen2_derive" -version = "0.4.3" +name = "document-features" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbbb781877580993a8707ec48672673ec7b81eeba04cfd2310bd28c08e47c8f" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", + "litrs", ] [[package]] -name = "dom_query" -version = "0.28.0" +name = "downcast-rs" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fac5fca71e65e94cc718a6e2af65d6e0f9c6027751c2aa562fbb5087fda639bc" -dependencies = [ - "bit-set", - "cssparser", - "foldhash", - "html5ever", - "precomputed-hash", - "selectors", - "tendril", -] +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "dpi" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" -dependencies = [ - "serde", -] [[package]] -name = "dtoa" -version = "1.0.11" +name = "dunce" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c3cf4824e2d5f025c7b531afcb2325364084a16806f6d47fbc1f5fbd9960590" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] -name = "dtoa-short" -version = "0.3.5" +name = "dwrote" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd1511a7b6a56299bd043a9c167a6d2bfb37bf84a6dfceaba651168adfb43c87" +checksum = "9e1b35532432acc8b19ceed096e35dfa088d3ea037fe4f3c085f1f97f33b4d02" dependencies = [ - "dtoa", + "lazy_static", + "libc", + "winapi", + "wio", ] -[[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" @@ -1108,10 +1541,18 @@ dependencies = [ ] [[package]] -name = "embed_plist" -version = "1.2.2" +name = "encoding_rs" +version = "0.8.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7" +checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5" +dependencies = [ + "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", +] [[package]] name = "endi" @@ -1141,22 +1582,42 @@ dependencies = [ ] [[package]] -name = "equivalent" -version = "1.0.3" +name = "enumn" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" +checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] [[package]] -name = "erased-serde" -version = "0.4.11" +name = "equator" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e59b668157f32d3459d4bd634861a06ffa2503a461ca5f0916b9f0252605e66" +checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" dependencies = [ - "serde", - "serde_core", - "typeid", + "equator-macro", +] + +[[package]] +name = "equator-macro" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", ] +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + [[package]] name = "errno" version = "0.3.14" @@ -1167,6 +1628,25 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "etagere" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc89bf99e5dc15954a60f707c1e09d7540e5cd9af85fa75caa0b510bc08c5342" +dependencies = [ + "euclid", + "svg_fmt", +] + +[[package]] +name = "euclid" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a05365e3b1c6d1650318537c7460c6923f1abdd272ad6842baa2b509957a06" +dependencies = [ + "num-traits", +] + [[package]] name = "event-listener" version = "5.4.2" @@ -1187,12 +1667,34 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "exr" +version = "1.74.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb29d0be702adf92c645d9b2f93472906ba83d400e59f98adb3770ce5c18c2f6" +dependencies = [ + "bit_field", + "half", + "lebe", + "miniz_oxide 0.8.9", + "multiversion", + "rayon-core", + "smallvec", + "zune-inflate", +] + [[package]] name = "fastrand" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" +[[package]] +name = "fax" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a" + [[package]] name = "fdeflate" version = "0.3.7" @@ -1212,6 +1714,17 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "filedescriptor" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e40758ed24c9b2eeb76c35fb0aebc66c626084edd827e07e1552279814c6682d" +dependencies = [ + "libc", + "thiserror 1.0.69", + "winapi", +] + [[package]] name = "find-msvc-tools" version = "0.1.15" @@ -1229,6 +1742,24 @@ dependencies = [ "zlib-rs", ] +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" + +[[package]] +name = "float-ord" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce81f49ae8a0482e4c55ea62ebbd7e5a686af544c00b9d090bba3ff9be97b3d" + +[[package]] +name = "float_next_after" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" + [[package]] name = "flume" version = "0.11.1" @@ -1237,14 +1768,19 @@ checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" dependencies = [ "futures-core", "futures-sink", - "spin", + "spin 0.9.9", ] [[package]] -name = "fnv" -version = "1.0.7" +name = "flume" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +checksum = "5e139bc46ca777eb5efaf62df0ab8cc5fd400866427e56c68b22e414e53bd3be" +dependencies = [ + "futures-core", + "futures-sink", + "spin 0.9.9", +] [[package]] name = "foldhash" @@ -1252,6 +1788,47 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" +[[package]] +name = "font-types" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b38ad915f6dadd993ced50848a8291a543bd41ca62bc10740d5e64e2ab4cfd7" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "font-types" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835ae9d781464a79026cde387f9cbc650c9a4909d7cf7e658b127e3c35d2f35d" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "fontconfig-parser" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbc773e24e02d4ddd8395fd30dc147524273a83e54e0f312d986ea30de5f5646" +dependencies = [ + "roxmltree 0.20.0", +] + +[[package]] +name = "fontdb" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "457e789b3d1202543297a350643cf459f836cade38934e7a4cf6a39e7cde2905" +dependencies = [ + "fontconfig-parser", + "log", + "memmap2", + "slotmap", + "tinyvec", + "ttf-parser", +] + [[package]] name = "foreign-types" version = "0.5.0" @@ -1288,6 +1865,32 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "freetype-sys" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7edc5b9669349acfda99533e9e0bcf26a51862ab43b08ee7745c55d28eb134" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.34" @@ -1295,6 +1898,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -1362,6 +1966,7 @@ version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ + "futures-channel", "futures-core", "futures-io", "futures-macro", @@ -1431,54 +2036,23 @@ dependencies = [ ] [[package]] -name = "gdkwayland-sys" -version = "0.18.2" +name = "generic-array" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "140071d506d223f7572b9f09b5e155afbd77428cd5cc7af8f2694c41d98dfe69" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ - "gdk-sys", - "glib-sys", - "gobject-sys", - "libc", - "pkg-config", - "system-deps 6.2.2", + "typenum", + "version_check", ] [[package]] -name = "gdkx11" -version = "0.18.2" +name = "gethostname" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3caa00e14351bebbc8183b3c36690327eb77c49abc2268dd4bd36b856db3fbfe" +checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ - "gdk", - "gdkx11-sys", - "gio", - "glib", - "libc", - "x11", -] - -[[package]] -name = "gdkx11-sys" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e7445fe01ac26f11601db260dd8608fe172514eb63b3b5e261ea6b0f4428d" -dependencies = [ - "gdk-sys", - "glib-sys", - "libc", - "system-deps 6.2.2", - "x11", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", + "rustix", + "windows-link 0.2.1", ] [[package]] @@ -1499,9 +2073,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi 5.3.0", "wasip2", + "wasm-bindgen", ] [[package]] @@ -1515,6 +2091,22 @@ dependencies = [ "r-efi 6.0.0", ] +[[package]] +name = "gif" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8cfcc411d9adbbaba82fb72661cc1bcca13e8bba98b364e62b2dba8f960159" +dependencies = [ + "color_quant", + "weezl", +] + +[[package]] +name = "gimli" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1033caf0b349c518623b5396bfb2cf0bddf44f0306d543a250e5743297aafd10" + [[package]] name = "gio" version = "0.18.4" @@ -1547,6 +2139,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + [[package]] name = "glib" version = "0.18.5" @@ -1577,7 +2180,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" dependencies = [ "heck 0.4.1", - "proc-macro-crate 2.0.2", + "proc-macro-crate 2.0.0", "proc-macro-error", "proc-macro2", "quote", @@ -1600,6 +2203,27 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" +[[package]] +name = "glow" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29038e1c483364cc6bb3cf78feee1816002e127c331a1eec55a4d202b9e1adb5" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e" +dependencies = [ + "gl_generator", +] + [[package]] name = "gobject-sys" version = "0.18.0" @@ -1611,6 +2235,371 @@ dependencies = [ "system-deps 6.2.2", ] +[[package]] +name = "gpu-allocator" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51255ea7cfaadb6c5f1528d43e92a82acb2b96c43365989a28b2d44ee38f8795" +dependencies = [ + "ash", + "hashbrown 0.16.1", + "log", + "presser", + "thiserror 2.0.21", + "windows 0.62.2", +] + +[[package]] +name = "gpui-apple-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "765b8ebb29eed23d9139501c88b2899b2a79a0e2017f2f27da11218a4e0ae9f4" +dependencies = [ + "anyhow", + "async-task", + "block2 0.6.2", + "cbindgen", + "collections-gpui-unofficial", + "core-foundation 0.10.1", + "core-foundation-sys", + "core-graphics 0.24.0", + "core-text", + "dispatch2", + "etagere", + "futures", + "gpui-unofficial", + "gpui-util-gpui-unofficial", + "image", + "libc", + "log", + "mach2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-core-text", + "objc2-core-video", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", + "objc2-quartz-core 0.3.2", + "objc2-security", + "parking_lot", + "pathfinder_geometry", + "smallvec", + "thiserror 2.0.21", + "zed-font-kit", +] + +[[package]] +name = "gpui-ios-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5303d890a907286c7e20615020341671771406cb8b0581e2cffbe2613feb1c7" +dependencies = [ + "anyhow", + "block2 0.6.2", + "futures", + "gpui-apple-gpui-unofficial", + "gpui-unofficial", + "log", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", + "objc2-ui-kit", + "parking_lot", + "raw-window-handle", + "uuid", +] + +[[package]] +name = "gpui-linux-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ed953915fa53697d2b5b72828cc12328cc84d35c5bba3b13187964f0aef5825" +dependencies = [ + "accesskit", + "accesskit_unix", + "anyhow", + "as-raw-xcb-connection", + "ashpd", + "bytemuck", + "calloop", + "calloop-wayland-source", + "collections-gpui-unofficial", + "filedescriptor", + "futures", + "gpui-unofficial", + "gpui-util-gpui-unofficial", + "gpui-wgpu-gpui-unofficial", + "http-client-gpui-unofficial", + "libc", + "log", + "notify-rust", + "oo7", + "open", + "parking_lot", + "raw-window-handle", + "smallvec", + "smol", + "strum", + "url", + "uuid", + "wayland-backend", + "wayland-client", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-plasma", + "wayland-protocols-wlr", + "x11rb", + "xkbcommon", + "zed-scap", + "zed-xim", +] + +[[package]] +name = "gpui-macos-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade86b45021b477518fbf6d85b3f72c8f66a5a265e784da68c319e6ee2e499bf" +dependencies = [ + "accesskit", + "accesskit_macos", + "anyhow", + "block2 0.6.2", + "collections-gpui-unofficial", + "core-foundation 0.10.1", + "core-foundation-sys", + "core-graphics 0.24.0", + "ctor", + "dispatch2", + "foreign-types", + "futures", + "gpui-apple-gpui-unofficial", + "gpui-unofficial", + "gpui-util-gpui-unofficial", + "image", + "itertools 0.14.0", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-graphics", + "objc2-core-video", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", + "objc2-uniform-type-identifiers", + "objc2-user-notifications", + "parking_lot", + "raw-window-handle", + "scheduler-gpui-unofficial", + "semver", + "smallvec", + "strum", + "uuid", +] + +[[package]] +name = "gpui-macros-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36e58e5ce84c4452491d64486641b783403bddc59ba0a4533075c0dcc2f4089c" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "gpui-platform-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47317c7158b281b5ed895316b7e287a6c2ed93e62f3599fe4a5dfd52d96ad9b3" +dependencies = [ + "anyhow", + "console_error_panic_hook", + "gpui-ios-gpui-unofficial", + "gpui-linux-gpui-unofficial", + "gpui-macos-gpui-unofficial", + "gpui-unofficial", + "gpui-web-gpui-unofficial", + "gpui-windows-gpui-unofficial", +] + +[[package]] +name = "gpui-shared-string-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6a8062fc9975485eb9079604bc4f8388868e6eebcca734eabbc76a0ce86540b" +dependencies = [ + "schemars", + "serde", + "smol_str", +] + +[[package]] +name = "gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d641e3f0b270406e20f2cdc79f809c77532b9f444bc258497bd498129f9064bc" +dependencies = [ + "accesskit", + "anyhow", + "async-channel", + "async-task", + "backtrace", + "bitflags 2.13.2", + "chrono", + "collections-gpui-unofficial", + "derive_more", + "embed-resource", + "etagere", + "futures", + "getrandom 0.3.4", + "gpui-macros-gpui-unofficial", + "gpui-shared-string-gpui-unofficial", + "gpui-util-gpui-unofficial", + "heapless", + "http-client-gpui-unofficial", + "icu_segmenter", + "image", + "inventory", + "itertools 0.14.0", + "libc", + "log", + "lyon", + "num_cpus", + "objc2-core-foundation", + "objc2-core-video", + "parking", + "parking_lot", + "pin-project", + "pollster", + "profiling", + "rand 0.9.5", + "raw-window-handle", + "refineable-gpui-unofficial", + "regex", + "resvg", + "scheduler-gpui-unofficial", + "schemars", + "seahash", + "serde", + "serde_json", + "slotmap", + "smallvec", + "spin 0.10.1", + "strum", + "sum-tree-gpui-unofficial", + "taffy", + "thiserror 2.0.21", + "ttf-parser", + "unicode-segmentation", + "url", + "usvg", + "uuid", + "waker-fn", + "windows 0.62.2", + "zed-scap", +] + +[[package]] +name = "gpui-util-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea4cae31808b29b8a89fbe21216485bb58aceb17f8949f50c89c3a159075e672" +dependencies = [ + "anyhow", + "log", + "which", +] + +[[package]] +name = "gpui-web-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea1ecc9acb9e14ace13e8396c070210720204dafd7141974df6e674d0dbf41c" +dependencies = [ + "anyhow", + "async-channel", + "console_error_panic_hook", + "futures", + "gpui-unofficial", + "gpui-wgpu-gpui-unofficial", + "http-client-gpui-unofficial", + "js-sys", + "log", + "parking_lot", + "raw-window-handle", + "scheduler-gpui-unofficial", + "smallvec", + "unicode-properties", + "unicode-script", + "unicode-segmentation", + "uuid", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm_thread", + "web-sys", + "web-time", +] + +[[package]] +name = "gpui-wgpu-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "310d9c36e63c42232294b88826fa9927bd88480c848047b4ef5f494512ac83d1" +dependencies = [ + "anyhow", + "bytemuck", + "collections-gpui-unofficial", + "cosmic-text", + "etagere", + "gpui-unofficial", + "gpui-util-gpui-unofficial", + "itertools 0.14.0", + "log", + "parking_lot", + "profiling", + "raw-window-handle", + "smallvec", + "swash", + "unicode-bidi", + "unicode-segmentation", + "web-sys", + "wgpu", + "zed-font-kit", +] + +[[package]] +name = "gpui-windows-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "316e1f5ec13bff7d53c9b8eeaeafd784ab0cd54a83d70d78760963819f277bd5" +dependencies = [ + "accesskit", + "accesskit_windows", + "anyhow", + "collections-gpui-unofficial", + "dunce", + "etagere", + "futures", + "gpui-unofficial", + "gpui-util-gpui-unofficial", + "image", + "itertools 0.14.0", + "log", + "parking_lot", + "rand 0.9.5", + "raw-window-handle", + "scheduler-gpui-unofficial", + "smallvec", + "uuid", + "windows 0.62.2", + "windows-core 0.62.2", + "windows-numerics 0.3.1", + "windows-registry", +] + [[package]] name = "gtk" version = "0.18.2" @@ -1664,131 +2653,153 @@ dependencies = [ ] [[package]] -name = "hashbrown" -version = "0.12.3" +name = "half" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", + "zerocopy", +] [[package]] -name = "hashbrown" -version = "0.17.1" +name = "harfrust" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +checksum = "9da2e5ae821f6e96664977bf974d6d6a2d6682f9ccee23e62ec1d134246845f9" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "core_maths", + "read-fonts 0.37.0", + "smallvec", +] [[package]] -name = "heck" -version = "0.4.1" +name = "hash32" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] [[package]] -name = "heck" -version = "0.5.0" +name = "hashbrown" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] -name = "hermit-abi" -version = "0.5.3" +name = "hashbrown" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] [[package]] -name = "hex" -version = "0.4.3" +name = "hashbrown" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +dependencies = [ + "foldhash", +] [[package]] -name = "html5ever" -version = "0.39.0" +name = "heapless" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a1761807faccc9a19e86944bbf40610014066306f96edcdedc2fb714bcb7b8" +checksum = "25ba4bd83f9415b58b4ed8dc5714c76e626a105be4646c02630ad730ad3b5aa4" dependencies = [ - "log", - "markup5ever", + "hash32", + "stable_deref_trait", ] [[package]] -name = "http" -version = "1.5.0" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" -dependencies = [ - "bytes", - "itoa", -] +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] -name = "http-body" -version = "1.1.0" +name = "heck" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ - "bytes", - "http", + "hmac", ] [[package]] -name = "http-body-util" -version = "0.1.5" +name = "hmac" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "bytes", - "futures-core", - "http", - "http-body", - "pin-project-lite", + "digest", ] [[package]] -name = "httparse" -version = "1.10.1" +name = "http" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] [[package]] -name = "hyper" -version = "1.12.0" +name = "http-body" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" dependencies = [ - "atomic-waker", "bytes", - "futures-core", "http", - "http-body", - "httparse", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", - "want", ] [[package]] -name = "hyper-util" -version = "0.1.21" +name = "http-client-gpui-unofficial" +version = "1.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" +checksum = "c928b5dd05a30da00550918085f50ccd2d8bab6965dbcf7fa3450699e95b69fc" dependencies = [ - "base64 0.23.1", + "anyhow", "bytes", - "futures-channel", - "futures-util", + "futures", "http", "http-body", - "httparse", - "hyper", - "ipnet", - "libc", - "percent-encoding", - "pin-project-lite", - "socket2 0.6.5", - "tokio", - "tower-service", - "tracing", + "parking_lot", + "serde", + "serde_json", + "serde_urlencoded", + "url", ] [[package]] @@ -1815,16 +2826,6 @@ dependencies = [ "cc", ] -[[package]] -name = "ico" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75e94d66081e4d8dcd098bd8dc5254800fea14a26389b298410158d834de167" -dependencies = [ - "byteorder", - "png", -] - [[package]] name = "icu_collections" version = "2.4.0" @@ -1847,11 +2848,32 @@ checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" dependencies = [ "displaydoc", "litemap", + "serde", "tinystr", "writeable", "zerovec", ] +[[package]] +name = "icu_locale_fallback" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406e9ae5b95d8aa37db6293405931b766a6172d1848daee22d70eb44aa78a43c" +dependencies = [ + "icu_locale_core", + "icu_locale_fallback_data", + "icu_provider", + "potential_utf", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locale_fallback_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3632ebbd0c5c3637ba1a40bdf8288f2cb9d2268e73441a69d5fc73d7cfbaa87c" + [[package]] name = "icu_normalizer" version = "2.4.0" @@ -1901,6 +2923,8 @@ checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" dependencies = [ "displaydoc", "icu_locale_core", + "serde", + "stable_deref_trait", "writeable", "yoke", "zerofrom", @@ -1909,10 +2933,27 @@ dependencies = [ ] [[package]] -name = "ident_case" -version = "1.0.1" +name = "icu_segmenter" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b195dc605f81aa181bec9b3bd14e26cc71b903e4644f6af578ca9772c7a710" +dependencies = [ + "icu_collections", + "icu_locale_fallback", + "icu_provider", + "icu_segmenter_data", + "potential_utf", + "smallvec", + "utf8_iter", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_segmenter_data" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +checksum = "913a7d294ad056474749152107309fdee3ec17d2482d1ab70fdc61a81c64b9a3" [[package]] name = "idna" @@ -1946,150 +2987,134 @@ dependencies = [ ] [[package]] -name = "indexmap" -version = "1.9.3" +name = "image" +version = "0.25.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", + "bytemuck", + "byteorder-lite", + "color_quant", + "exr", + "gif", + "image-webp", + "moxcms", + "num-traits", + "png 0.18.1", + "qoi", + "ravif", + "rayon", + "tiff", + "zune-core", + "zune-jpeg", ] [[package]] -name = "indexmap" -version = "2.14.2" +name = "image-webp" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" dependencies = [ - "equivalent", - "hashbrown 0.17.1", - "serde", - "serde_core", + "byteorder-lite", + "quick-error", ] [[package]] -name = "infer" -version = "0.22.0" +name = "imagesize" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4200d433cbd5178df7797c9c2e75b348b728e39631cf14520d1e2fc424201f4" -dependencies = [ - "cfb", -] +checksum = "09e54e57b4c48b40f7aec75635392b12b3421fa26fe8b4332e63138ed278459c" [[package]] -name = "ipnet" -version = "2.12.2" +name = "imgref" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" +checksum = "6e44b0a4eaa4c82f441d50a963f2d5f05a787240aeee097597033e72accfd22f" [[package]] -name = "itertools" -version = "0.13.0" +name = "indexmap" +version = "2.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ - "either", + "equivalent", + "hashbrown 0.17.1", + "serde", + "serde_core", ] [[package]] -name = "itoa" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" - -[[package]] -name = "javascriptcore-rs" -version = "1.1.2" +name = "inout" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca5671e9ffce8ffba57afc24070e906da7fc4b1ba66f2cabebf61bf2ea257fcc" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ - "bitflags 1.3.2", - "glib", - "javascriptcore-rs-sys", + "block-padding", + "generic-array", ] [[package]] -name = "javascriptcore-rs-sys" -version = "1.1.1" +name = "interpolate_name" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af1be78d14ffa4b75b66df31840478fef72b51f8c2465d4ca7c194da9f7a5124" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ - "glib-sys", - "gobject-sys", - "libc", - "system-deps 6.2.2", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "jiff" -version = "0.2.38" +name = "inventory" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b005715dcbeb0089a3c0dab99f2ff1cc3b2525323552703d648585d342a383" +checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" dependencies = [ - "defmt", - "jiff-core", - "jiff-static", - "jiff-tzdb-platform", - "log", - "portable-atomic", - "portable-atomic-util", - "serde_core", - "windows-link 0.2.1", + "rustversion", ] [[package]] -name = "jiff-core" -version = "0.1.1" +name = "is-docker" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e52fe76043ccecc9005d2305ebaadf7d7fc0cc89ca6baa10a94d6bc68c7128c" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" dependencies = [ - "defmt", - "log", + "once_cell", ] [[package]] -name = "jiff-static" -version = "0.2.38" +name = "is-wsl" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc9817253cf7c7ee4684451bd327e88d6f3658014e54a29198625590650695c" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" dependencies = [ - "jiff-core", - "proc-macro2", - "quote", - "syn 2.0.119", + "is-docker", + "once_cell", ] [[package]] -name = "jiff-tzdb" -version = "0.1.9" +name = "itertools" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8377070c6bae868759445e5a77f66d84f0b72f3a054bfb00e6d038b8282da7" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] [[package]] -name = "jiff-tzdb-platform" -version = "0.1.3" +name = "itertools" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" dependencies = [ - "jiff-tzdb", + "either", ] [[package]] -name = "jni" -version = "0.21.1" +name = "itoa" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" -dependencies = [ - "cesu8", - "cfg-if", - "combine", - "jni-sys 0.3.1", - "log", - "thiserror 1.0.69", - "walkdir", - "windows-sys 0.45.0", -] +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "jni-sys" @@ -2119,6 +3144,16 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + [[package]] name = "js-sys" version = "0.3.106" @@ -2131,35 +3166,42 @@ dependencies = [ ] [[package]] -name = "json-patch" -version = "4.2.0" +name = "keyboard-types" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7421438de105a0827e44fadd05377727847d717c80ce29a229f85fd04c427b72" +checksum = "0fbe853b403ae61a04233030ae8a79d94975281ed9770a1f9e246732b534b28d" dependencies = [ - "jsonptr", + "bitflags 2.13.2", "serde", - "serde_json", - "thiserror 2.0.21", ] [[package]] -name = "jsonptr" -version = "0.7.1" +name = "khronos-egl" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5a3cc660ba5d72bce0b3bb295bf20847ccbb40fd423f3f05b61273672e561fe" +checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" dependencies = [ - "serde", - "serde_json", + "libc", + "libloading 0.8.9", + "pkg-config", ] [[package]] -name = "keyboard-types" -version = "0.8.3" +name = "khronos_api" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbe853b403ae61a04233030ae8a79d94975281ed9770a1f9e246732b534b28d" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + +[[package]] +name = "kurbo" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b60dfc32f652b926df6192e55525b16d186c69d47876c3ead4da5cc9f8450e2" dependencies = [ - "bitflags 2.13.2", - "serde", + "arrayvec", + "euclid", + "polycool", + "smallvec", ] [[package]] @@ -2168,6 +3210,12 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" +[[package]] +name = "lebe" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" + [[package]] name = "libappindicator" version = "0.9.0" @@ -2199,12 +3247,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" [[package]] -name = "libdbus-sys" -version = "0.2.7" +name = "libfuzzer-sys" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "328c4789d42200f1eeec05bd86c9c13c7f091d2ba9a6ea35acdf51f31bc0f043" +checksum = "a9fd2f41a1cba099f79a0b6b6c35656cf7c03351a7bae8ff0f28f25270f929d2" dependencies = [ - "pkg-config", + "arbitrary", + "cc", ] [[package]] @@ -2227,6 +3276,12 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + [[package]] name = "libredox" version = "0.1.25" @@ -2264,8 +3319,45 @@ dependencies = [ ] [[package]] -name = "linux-raw-sys" -version = "0.12.1" +name = "libxdo" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00333b8756a3d28e78def82067a377de7fa61b24909000aeaa2b446a948d14db" +dependencies = [ + "libxdo-sys", +] + +[[package]] +name = "libxdo-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db23b9e7e2b7831bbd8aac0bbeeeb7b68cbebc162b227e7052e8e55829a09212" +dependencies = [ + "libc", + "x11", +] + +[[package]] +name = "linebender_resource_handle" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" + +[[package]] +name = "link-section" +version = "0.19.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d9aae57673c1a235149777a74d152f3210ebd3e3b13346d2cdb6809e566bd3c" + +[[package]] +name = "linktime-proc-macro" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e57c38c1e860fd37c604281cdfb1dd2216977fd76a50f85ba2f388ef3219616" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" @@ -2275,6 +3367,12 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" +[[package]] +name = "litrs" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70" + [[package]] name = "lock_api" version = "0.4.14" @@ -2289,16 +3387,118 @@ name = "log" version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" +dependencies = [ + "serde_core", +] + +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + +[[package]] +name = "lyon" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0578bdecb7d6d88987b8b2b1e3a4e2f81df9d0ece1078623324a567904e7b7" +dependencies = [ + "lyon_algorithms", + "lyon_tessellation", +] + +[[package]] +name = "lyon_algorithms" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a6b9d4e8b48acd531fbf1241ad9b270df6e60b6b92bdea1469f4f40899d805" +dependencies = [ + "lyon_path", + "num-traits", +] + +[[package]] +name = "lyon_geom" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82dd26aa4dc0b5b70b9115de59824842bcb43cf4a28e1b1e6d0ad148c93f93e" +dependencies = [ + "arrayvec", + "euclid", + "num-traits", +] + +[[package]] +name = "lyon_path" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c463f9c428b7fc5ec885dcd39ce4aa61e29111d0e33483f6f98c74e89d8621e" +dependencies = [ + "lyon_geom", + "num-traits", +] + +[[package]] +name = "lyon_tessellation" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd4872650e70dc907dd4f7ebc449d7d657a0d2658e423b2e724970870bbbf75b" +dependencies = [ + "float_next_after", + "lyon_path", + "num-traits", +] [[package]] -name = "markup5ever" -version = "0.39.0" +name = "mac-notification-sys" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7122d987ec5f704ee56f6e5b41a7d93722e9aae27ae07cafa4036c4d3f9757de" +checksum = "fd604973958ddcc11b561193c0fb96ba146506ef2f231ef2e7c35fd2cbc9beca" dependencies = [ + "cc", "log", - "tendril", - "web_atoms", + "objc2 0.6.5", + "objc2-foundation 0.3.2", + "time", + "uuid", +] + +[[package]] +name = "mach2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dae608c151f68243f2b000364e1f7b186d9c29845f7d2d85bd31b9ad77ad552b" + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", ] [[package]] @@ -2308,7 +3508,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "328f4e1041f7cfeb3affccb814ddbe2f004856a2ce769c8bf22080d74c5204c6" dependencies = [ "fastrand", - "flume", + "flume 0.11.1", "if-addrs", "log", "mio", @@ -2321,6 +3521,15 @@ version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" +[[package]] +name = "memmap2" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.9.1" @@ -2330,12 +3539,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -2374,6 +3577,16 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "moxcms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b" +dependencies = [ + "num-traits", + "pxfm", +] + [[package]] name = "muda" version = "0.20.0" @@ -2384,37 +3597,82 @@ dependencies = [ "dpi", "gtk", "keyboard-types", - "objc2", - "objc2-app-kit", + "libxdo", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", "objc2-core-foundation", - "objc2-foundation", + "objc2-foundation 0.3.2", "once_cell", - "png", - "serde", + "png 0.18.1", "thiserror 2.0.21", "windows-sys 0.61.2", ] [[package]] -name = "ndk" -version = "0.9.0" +name = "multiversion" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb8a68be21d0755f83bfe47e79b896cc732687cf1903f0e50585e8d6ecc53076" +dependencies = [ + "multiversion-macros", + "target-features", +] + +[[package]] +name = "multiversion-macros" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a05e0c3c3e4edaa21d87c645852ed0b0c3663752bcc6ec43353bd6189dce35e1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "target-features", +] + +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + +[[package]] +name = "naga" +version = "30.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +checksum = "fd0dd362bf26c0ffdd143df6da66a25d287e196eff482f117771010b207ad163" dependencies = [ + "arrayvec", + "bit-set", "bitflags 2.13.2", - "jni-sys 0.3.1", + "cfg-if", + "cfg_aliases", + "codespan-reporting", + "half", + "hashbrown 0.17.1", + "indexmap", + "libm", "log", - "ndk-sys", - "num_enum", - "raw-window-handle", - "thiserror 1.0.69", + "naga-types", + "num-traits", + "once_cell", + "rustc-hash 1.1.0", + "spirv", + "thiserror 2.0.21", + "unicode-ident", ] [[package]] -name = "ndk-context" -version = "0.1.1" +name = "naga-types" +version = "30.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" +checksum = "14474170feb673cfb18b3565111a9869797cc1d290fb9ec969c53f5e1e231c6d" +dependencies = [ + "hashbrown 0.17.1", + "indexmap", + "rustc-hash 1.1.0", + "thiserror 2.0.21", +] [[package]] name = "ndk-sys" @@ -2431,6 +3689,15 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +[[package]] +name = "no_std_io2" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418abd1b6d34fbf6cae440dc874771b0525a604428704c76e48b29a5e67b8003" +dependencies = [ + "memchr", +] + [[package]] name = "nom" version = "7.1.3" @@ -2451,148 +3718,275 @@ dependencies = [ ] [[package]] -name = "num-bigint" -version = "0.4.8" +name = "noop_proc_macro" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + +[[package]] +name = "notify-rust" +version = "4.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57da5b5d3b7809bf71858da5a2818c3404ca4688c02c8abecdda0fcdec235df3" dependencies = [ - "num-integer", - "num-traits", + "futures-lite", + "log", + "mac-notification-sys", + "serde", + "tauri-winrt-notification", + "zbus 6.3.0", ] [[package]] -name = "num-conv" -version = "0.2.2" +name = "ntapi" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" +checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae" +dependencies = [ + "winapi", +] [[package]] -name = "num-integer" -version = "0.1.47" +name = "num" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", "num-traits", ] [[package]] -name = "num-traits" -version = "0.2.19" +name = "num-bigint" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" dependencies = [ - "autocfg", + "num-integer", + "num-traits", ] [[package]] -name = "num_enum" -version = "0.7.6" +name = "num-bigint-dig" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +checksum = "a7f9a86e097b0d187ad0e65667c2f58b9254671e86e7dbb78036b16692eae099" dependencies = [ - "num_enum_derive", - "rustversion", + "libm", + "num-integer", + "num-iter", + "num-traits", + "once_cell", + "rand 0.9.5", + "serde", + "smallvec", + "zeroize", ] [[package]] -name = "num_enum_derive" -version = "0.7.6" +name = "num-complex" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ - "proc-macro-crate 3.5.0", - "proc-macro2", - "quote", - "syn 2.0.119", + "num-traits", ] [[package]] -name = "objc2" -version = "0.6.5" +name = "num-conv" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" -dependencies = [ - "objc2-encode", - "objc2-exception-helper", -] +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" [[package]] -name = "objc2-app-kit" -version = "0.3.2" +name = "num-derive" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ - "bitflags 2.13.2", - "block2", - "objc2", - "objc2-core-foundation", - "objc2-foundation", - "objc2-quartz-core", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "objc2-cloud-kit" -version = "0.3.2" +name = "num-integer" +version = "0.1.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" dependencies = [ - "bitflags 2.13.2", - "objc2", - "objc2-foundation", + "num-traits", ] [[package]] -name = "objc2-core-data" -version = "0.3.2" +name = "num-iter" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa" +checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" dependencies = [ - "objc2", - "objc2-foundation", + "num-integer", + "num-traits", ] [[package]] -name = "objc2-core-foundation" -version = "0.3.2" +name = "num-rational" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "bitflags 2.13.2", - "dispatch2", - "objc2", + "num-bigint", + "num-integer", + "num-traits", ] [[package]] -name = "objc2-core-graphics" -version = "0.3.2" +name = "num-traits" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ - "bitflags 2.13.2", - "dispatch2", - "objc2", - "objc2-core-foundation", - "objc2-io-surface", + "autocfg", + "libm", ] [[package]] -name = "objc2-core-image" -version = "0.3.2" +name = "num_cpus" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ - "objc2", - "objc2-foundation", + "hermit-abi", + "libc", ] [[package]] -name = "objc2-core-location" -version = "0.3.2" +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", + "objc_exception", +] + +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d5490aaf8f1d7cf7688dfa9b0ce07900e168852c45cd2c03f534dfd27cfd0b" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" +dependencies = [ + "objc2-encode", +] + +[[package]] +name = "objc2-app-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "libc", + "objc2 0.5.3", + "objc2-core-data", + "objc2-core-image", + "objc2-foundation 0.2.2", + "objc2-quartz-core 0.2.2", +] + +[[package]] +name = "objc2-app-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-uniform-type-identifiers", +] + +[[package]] +name = "objc2-core-data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca347214e24bc973fc025fd0d36ebb179ff30536ed1f80252706db19ee452009" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "dispatch2", + "libc", + "objc2 0.6.5", +] + +[[package]] +name = "objc2-core-graphics" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-io-surface", +] + +[[package]] +name = "objc2-core-image" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" dependencies = [ - "objc2", - "objc2-foundation", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal 0.2.2", ] [[package]] @@ -2602,9 +3996,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" dependencies = [ "bitflags 2.13.2", - "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-core-video" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", "objc2-core-foundation", "objc2-core-graphics", + "objc2-io-surface", + "objc2-metal 0.3.2", ] [[package]] @@ -2614,12 +4020,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" [[package]] -name = "objc2-exception-helper" -version = "0.1.1" +name = "objc2-foundation" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7a1c5fbb72d7735b076bb47b578523aedc40f3c439bea6dfd595c089d79d98a" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "cc", + "bitflags 2.13.2", + "block2 0.5.1", + "libc", + "objc2 0.5.3", ] [[package]] @@ -2629,8 +4038,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ "bitflags 2.13.2", - "block2", - "objc2", + "block2 0.6.2", + "libc", + "objc2 0.6.5", "objc2-core-foundation", ] @@ -2641,10 +4051,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" dependencies = [ "bitflags 2.13.2", - "objc2", + "objc2 0.6.5", "objc2-core-foundation", ] +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-metal" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "dispatch2", + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal 0.2.2", +] + [[package]] name = "objc2-quartz-core" version = "0.3.2" @@ -2652,9 +4100,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" dependencies = [ "bitflags 2.13.2", - "objc2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", +] + +[[package]] +name = "objc2-security" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a" +dependencies = [ "objc2-core-foundation", - "objc2-foundation", ] [[package]] @@ -2664,42 +4123,60 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22" dependencies = [ "bitflags 2.13.2", - "block2", - "objc2", - "objc2-cloud-kit", - "objc2-core-data", + "block2 0.6.2", + "objc2 0.6.5", "objc2-core-foundation", - "objc2-core-graphics", - "objc2-core-image", - "objc2-core-location", - "objc2-core-text", - "objc2-foundation", - "objc2-quartz-core", - "objc2-user-notifications", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", ] [[package]] -name = "objc2-user-notifications" +name = "objc2-uniform-type-identifiers" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9df9128cbbfef73cda168416ccf7f837b62737d748333bfe9ab71c245d76613e" +checksum = "7902ac02859fc1f7045f8b598c63f1ae0cc7efeaa06a9bc9f3d9a3c955974fa4" dependencies = [ - "objc2", - "objc2-foundation", + "objc2 0.6.5", + "objc2-foundation 0.3.2", ] [[package]] -name = "objc2-web-kit" +name = "objc2-user-notifications" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2e5aaab980c433cf470df9d7af96a7b46a9d892d521a2cbbb2f8a4c16751e7f" +checksum = "9df9128cbbfef73cda168416ccf7f837b62737d748333bfe9ab71c245d76613e" dependencies = [ "bitflags 2.13.2", - "block2", - "objc2", - "objc2-app-kit", - "objc2-core-foundation", - "objc2-foundation", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc_exception" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" +dependencies = [ + "cc", +] + +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + +[[package]] +name = "object" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd229a0361b9d0d4396176e02d65897f487eebeab7caa6d443855ee152ca0b9c" +dependencies = [ + "memchr", ] [[package]] @@ -2717,12 +4194,66 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "oo7" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78f2bfed90f1618b4b48dcad9307f25e14ae894e2949642c87c351601d62cebd" +dependencies = [ + "aes", + "ashpd", + "async-fs", + "async-io", + "async-lock", + "blocking", + "cbc", + "cipher", + "digest", + "endi", + "futures-lite", + "futures-util", + "getrandom 0.4.3", + "hkdf", + "hmac", + "md-5", + "num", + "num-bigint-dig", + "pbkdf2", + "serde", + "serde_bytes", + "sha2", + "subtle", + "zbus 5.19.0", + "zbus_macros 5.19.0", + "zeroize", + "zvariant", +] + +[[package]] +name = "open" +version = "5.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d8c8b8e725ad26404d6896eb2f064294a0a7b4f1d9120210d85544684c4ca95" +dependencies = [ + "is-wsl", + "libc", +] + [[package]] name = "option-ext" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-float" +version = "5.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f59006ce1e204c30956638535b74d317bca99477b9356dfaec54c37f6f600ab" +dependencies = [ + "num-traits", +] + [[package]] name = "ordered-stream" version = "0.2.0" @@ -2787,13 +4318,54 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pastey" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" + +[[package]] +name = "pathfinder_geometry" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b7e7b4ea703700ce73ebf128e1450eb69c3a8329199ffbfb9b2a0418e5ad3" +dependencies = [ + "log", + "pathfinder_simd", +] + +[[package]] +name = "pathfinder_simd" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4500030c302e4af1d423f36f3b958d1aecb6c04184356ed5a833bf6b60435777" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest", + "hmac", +] + [[package]] name = "pem" version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" dependencies = [ - "base64 0.22.1", + "base64", "serde_core", ] @@ -2814,16 +4386,6 @@ dependencies = [ "serde", ] -[[package]] -name = "phf_codegen" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1" -dependencies = [ - "phf_generator", - "phf_shared", -] - [[package]] name = "phf_generator" version = "0.13.1" @@ -2856,6 +4418,32 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + +[[package]] +name = "pin-project" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "pin-project-lite" version = "0.2.17" @@ -2905,16 +4493,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" [[package]] -name = "plist" -version = "1.10.3" +name = "png" +version = "0.17.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327a4cb2ad49dc48adfdc9da89e22c64d488b508c67a044d71ba729e4521a285" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" dependencies = [ - "base64 0.23.1", - "indexmap 2.14.2", - "quick-xml", - "serde", - "time", + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", ] [[package]] @@ -2945,7 +4533,22 @@ dependencies = [ ] [[package]] -name = "portable-atomic" +name = "pollster" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3" + +[[package]] +name = "polycool" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50596ddc09eb5ad5f75cacd40209568e66df71baf86e1499a0e99c4cff12a5a6" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "portable-atomic" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" @@ -2965,6 +4568,8 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" dependencies = [ + "serde_core", + "writeable", "zerovec", ] @@ -2975,10 +4580,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" [[package]] -name = "precomputed-hash" -version = "0.1.1" +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "presser" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" [[package]] name = "proc-macro-crate" @@ -2992,11 +4606,10 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "2.0.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" dependencies = [ - "toml_datetime 0.6.3", "toml_edit 0.20.2", ] @@ -3042,11 +4655,51 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "profiling" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4488a4a36b9a4ba6b9334a32a39971f77c1436ec82c38707bce707699cc3bbcb" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quick-xml" -version = "0.42.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b1177fdf999d2321d3fb46ff47159d9c1fb9ad66a4879f8c50a0b504615e9b" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" dependencies = [ "memchr", ] @@ -3072,12 +4725,145 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "range-alloc" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08" + +[[package]] +name = "rangemap" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d" + +[[package]] +name = "rav1e" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b6dd56e85d9483277cde964fd1bdb0428de4fec5ebba7540995639a21cb32b" +dependencies = [ + "aligned-vec", + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av-scenechange", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools 0.14.0", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "paste", + "profiling", + "rand 0.9.5", + "rand_chacha 0.9.0", + "simd_helpers", + "thiserror 2.0.21", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e52310197d971b0f5be7fe6b57530dcd27beb35c1b013f29d66c1ad73fbbcc45" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e", + "rayon", + "rgb", +] + [[package]] name = "raw-window-handle" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" +[[package]] +name = "raw-window-metal" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40d213455a5f1dc59214213c7330e074ddf8114c9a42411eb890c767357ce135" +dependencies = [ + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", +] + [[package]] name = "rayon" version = "1.12.0" @@ -3111,6 +4897,28 @@ dependencies = [ "yasna", ] +[[package]] +name = "read-fonts" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b634fabf032fab15307ffd272149b622260f55974d9fad689292a5d33df02e5" +dependencies = [ + "bytemuck", + "core_maths", + "font-types 0.11.3", +] + +[[package]] +name = "read-fonts" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046a7d674daf459825b32f5062056d6882db0d2f5a479fbd76ccfc870ac18709" +dependencies = [ + "bytemuck", + "font-types 0.12.7", + "once_cell", +] + [[package]] name = "redox_syscall" version = "0.5.18" @@ -3120,6 +4928,17 @@ dependencies = [ "bitflags 2.13.2", ] +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom 0.2.17", + "libredox", + "thiserror 1.0.69", +] + [[package]] name = "redox_users" version = "0.5.3" @@ -3150,6 +4969,15 @@ dependencies = [ "syn 3.0.9", ] +[[package]] +name = "refineable-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49fe3f80947ec2fde40aaa5aa7e04a7c871b9355d476764e0f3b2cf7e35e025c" +dependencies = [ + "derive-refineable-gpui-unofficial", +] + [[package]] name = "regex" version = "1.13.1" @@ -3180,37 +5008,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] -name = "reqwest" -version = "0.13.5" +name = "renderdoc-sys" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a1cfa75cc186dd73d5818e510e042e40927bccc9c236b061cea97e1eb08029" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + +[[package]] +name = "resvg" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b563218631706d614e23059436526d005b50ab5f2d506b55a17eb65c5eb83419" dependencies = [ - "base64 0.23.1", - "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-util", - "js-sys", + "gif", + "image-webp", "log", - "percent-encoding", - "pin-project-lite", - "serde", - "serde_json", - "sync_wrapper", - "tokio", - "tokio-util", - "tower", - "tower-http", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-streams", - "web-sys", + "pico-args", + "rgb", + "svgtypes", + "tiny-skia", + "usvg", + "zune-jpeg", +] + +[[package]] +name = "rgb" +version = "0.8.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4" +dependencies = [ + "bytemuck", ] [[package]] @@ -3227,6 +5053,33 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "roxmltree" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" + +[[package]] +name = "roxmltree" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9da7f59328b09405b181fee1018925fad50f157afb43c0c0f5c522c256dd5907" +dependencies = [ + "memchr", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b74b56ffa8bb2830709a538c2cbcae9aa062db0d2a42563bfb09bdaae44020eb" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hash" version = "2.1.3" @@ -3305,39 +5158,53 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" [[package]] -name = "same-file" -version = "1.0.6" +name = "rustybuzz" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +checksum = "fd3c7c96f8a08ee34eff8857b11b49b07d71d1c3f4e88f8a88d4c9e9f90b1702" dependencies = [ - "winapi-util", + "bitflags 2.13.2", + "bytemuck", + "core_maths", + "log", + "smallvec", + "ttf-parser", + "unicode-bidi-mirroring", + "unicode-ccc", + "unicode-properties", + "unicode-script", ] [[package]] -name = "schemars" -version = "0.8.22" +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "same-file" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ - "dyn-clone", - "indexmap 1.9.3", - "schemars_derive", - "serde", - "serde_json", - "url", - "uuid", + "winapi-util", ] [[package]] -name = "schemars" -version = "0.9.0" +name = "scheduler-gpui-unofficial" +version = "1.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" +checksum = "4875c22247b491e687a00fc7090428b5f3a0744a0545fff8e5b5ffe431c480ab" dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", + "async-task", + "backtrace", + "chrono", + "flume 0.12.0", + "futures", + "parking_lot", + "rand 0.9.5", + "wasm_thread", + "web-time", ] [[package]] @@ -3347,23 +5214,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab508826f74a77ca9d5aba6ff19b522583ee3eaf28a19384ff3d0e5835fadf6e" dependencies = [ "dyn-clone", + "indexmap", "ref-cast", + "schemars_derive", "serde", "serde_json", ] [[package]] name = "schemars_derive" -version = "0.8.22" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" +checksum = "e1c3a92094fa7d61aa124645844facb6b554dfc797136d0f5fd1f890e2bffc69" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.119", + "syn 3.0.9", ] +[[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" @@ -3371,54 +5246,68 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] -name = "selectors" -version = "0.38.0" +name = "screencapturekit" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adfa1c298912827b8a28b223b3b874357397ae706e6190acd9bf28cee99114d" +checksum = "1a5eeeb57ac94960cfe5ff4c402be6585ae4c8d29a2cf41b276048c2e849d64e" dependencies = [ - "bitflags 2.13.2", - "cssparser", - "derive_more", - "log", - "new_debug_unreachable", - "phf", - "phf_codegen", - "precomputed-hash", - "rustc-hash", - "servo_arc", - "smallvec", + "screencapturekit-sys", ] [[package]] -name = "semver" -version = "1.0.28" +name = "screencapturekit-sys" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +checksum = "22411b57f7d49e7fe08025198813ee6fd65e1ee5eff4ebc7880c12c82bde4c60" dependencies = [ - "serde", - "serde_core", + "block", + "dispatch", + "objc", + "objc-foundation", + "objc_id", + "once_cell", ] [[package]] -name = "serde" -version = "1.0.229" +name = "seahash" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" -dependencies = [ - "serde_core", +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "self_cell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", "serde_derive", ] [[package]] -name = "serde-untagged" -version = "0.1.9" +name = "serde_bytes" +version = "0.11.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9faf48a4a2d2693be24c6289dbe26552776eb7737074e6722891fadbe6c5058" +checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8" dependencies = [ - "erased-serde", "serde", "serde_core", - "typeid", ] [[package]] @@ -3443,13 +5332,13 @@ dependencies = [ [[package]] name = "serde_derive_internals" -version = "0.29.1" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +checksum = "f852137cce035d6a4df67ccce505ff6b3e9fd3a10e3e52b24dc71e650bb1a9bd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.9", ] [[package]] @@ -3458,6 +5347,8 @@ version = "1.0.154" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" dependencies = [ + "foldhash", + "indexmap", "itoa", "memchr", "serde", @@ -3495,68 +5386,22 @@ dependencies = [ ] [[package]] -name = "serde_with" -version = "3.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df9adc193c780ef8f159aee8b61e2d5801aaa555e6eb0947fe45530ec506296f" -dependencies = [ - "base64 0.23.1", - "bs58", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.14.2", - "jiff", - "schemars 0.9.0", - "schemars 1.2.3", - "serde_core", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17bbc68e28663bbbb90df47e058aa7eda4fb445b89fe70457bb94fbccf6e49" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 3.0.9", -] - -[[package]] -name = "serialize-to-javascript" -version = "0.1.2" +name = "serde_urlencoded" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f3666a07a197cdb77cdf306c32be9b7f598d7060d50cfd4d5aa04bfd92f6c5" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ + "form_urlencoded", + "itoa", + "ryu", "serde", - "serde_json", - "serialize-to-javascript-impl", ] [[package]] -name = "serialize-to-javascript-impl" -version = "0.1.2" +name = "sha1_smol" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772ee033c0916d670af7860b6e1ef7d658a4629a6d0b4c8c3e67f09b3765b75d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "servo_arc" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170fb83ab34de17dc69aa7c67482b22218ddb85da56546f9bd6b929e32a05930" -dependencies = [ - "stable_deref_trait", -] +checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" [[package]] name = "sha2" @@ -3598,539 +5443,389 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" [[package]] -name = "siphasher" -version = "1.0.4" +name = "simd_helpers" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] [[package]] -name = "slab" -version = "0.4.12" +name = "simdutf8" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] -name = "smallvec" -version = "1.16.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" - -[[package]] -name = "socket2" -version = "0.5.10" +name = "simplecss" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c" dependencies = [ - "libc", - "windows-sys 0.52.0", + "log", ] [[package]] -name = "socket2" -version = "0.6.5" +name = "siphasher" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" -dependencies = [ - "libc", - "windows-sys 0.61.2", -] +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" [[package]] -name = "softbuffer" -version = "0.4.8" +name = "skrifa" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aac18da81ebbf05109ab275b157c22a653bb3c12cf884450179942f81bcbf6c3" +checksum = "7fbdfe3d2475fbd7ddd1f3e5cf8288a30eb3e5f95832829570cd88115a7434ac" dependencies = [ "bytemuck", - "js-sys", - "ndk", - "objc2", - "objc2-core-foundation", - "objc2-core-graphics", - "objc2-foundation", - "objc2-quartz-core", - "raw-window-handle", - "redox_syscall", - "tracing", - "wasm-bindgen", - "web-sys", - "windows-sys 0.61.2", + "read-fonts 0.37.0", ] [[package]] -name = "soup3" -version = "0.5.0" +name = "skrifa" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "471f924a40f31251afc77450e781cb26d55c0b650842efafc9c6cbd2f7cc4f9f" +checksum = "819ab7d62b1d3e72d9d9dea5650bac30424f9111364bb94928dbf5ecad1baa68" dependencies = [ - "futures-channel", - "gio", - "glib", - "libc", - "soup3-sys", + "bytemuck", + "read-fonts 0.41.0", ] [[package]] -name = "soup3-sys" -version = "0.5.0" +name = "slab" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebe8950a680a12f24f15ebe1bf70db7af98ad242d9db43596ad3108aab86c27" -dependencies = [ - "gio-sys", - "glib-sys", - "gobject-sys", - "libc", - "system-deps 6.2.2", -] +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] -name = "spin" -version = "0.9.9" +name = "slotmap" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" dependencies = [ - "lock_api", + "version_check", ] [[package]] -name = "stable_deref_trait" -version = "1.2.1" +name = "smallvec" +version = "1.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" +checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" [[package]] -name = "static_vcruntime" -version = "3.0.0" +name = "smol" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff7589a1859b09232522bb9edf076ca7fcf14ded96685d3fa629db73023ffbb7" +checksum = "a33bd3e260892199c3ccfc487c88b2da2265080acb316cd920da72fdfd7c599f" +dependencies = [ + "async-channel", + "async-executor", + "async-fs", + "async-io", + "async-lock", + "async-net", + "async-process", + "blocking", + "futures-lite", +] [[package]] -name = "string_cache" -version = "0.9.0" +name = "smol_str" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18596f8c785a729f2819c0f6a7eae6ebeebdfffbfe4214ae6b087f690e31901" +checksum = "eeb7109d23f319619d4cc0de5464613c8b7b1a09db2774a58101459cf6be2f10" dependencies = [ - "new_debug_unreachable", - "parking_lot", - "phf_shared", - "precomputed-hash", + "serde_core", ] [[package]] -name = "string_cache_codegen" -version = "0.6.1" +name = "socket2" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585635e46db231059f76c5849798146164652513eb9e8ab2685939dd90f29b69" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" dependencies = [ - "phf_generator", - "phf_shared", - "proc-macro2", - "quote", + "libc", + "windows-sys 0.52.0", ] [[package]] -name = "strsim" -version = "0.11.1" +name = "socket2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] [[package]] -name = "subtle" -version = "2.6.1" +name = "spin" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" +dependencies = [ + "lock_api", +] [[package]] -name = "swift-rs" -version = "1.0.9" +name = "spin" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cefd87076fd385308ee4aff597256c902f1fbb4d031de1558efc12f8ffefadd9" +checksum = "023a211cb3138dbc438680b32560ad89f699977624c9f8dbb95a47d5b4c07dd3" dependencies = [ - "base64 0.21.7", - "serde", - "serde_json", + "lock_api", ] [[package]] -name = "syn" -version = "1.0.109" +name = "spirv" +version = "0.4.0+sdk-1.4.341.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "d9571ea910ebd84c86af4b3ed27f9dbdc6ad06f17c5f96146b2b671e2976744f" dependencies = [ - "proc-macro2", - "unicode-ident", + "bitflags 2.13.2", ] [[package]] -name = "syn" -version = "2.0.119" +name = "stable_deref_trait" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] -name = "syn" -version = "3.0.9" +name = "static_assertions" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] -name = "sync_wrapper" -version = "1.0.2" +name = "strict-num" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" dependencies = [ - "futures-core", + "float-cmp", ] [[package]] -name = "synstructure" -version = "0.13.2" +name = "strum" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", + "strum_macros", ] [[package]] -name = "synstructure" -version = "0.14.0" +name = "strum_macros" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664" dependencies = [ + "heck 0.5.0", "proc-macro2", "quote", - "syn 3.0.9", + "syn 2.0.119", ] [[package]] -name = "system-deps" -version = "6.2.2" +name = "subtle" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" -dependencies = [ - "cfg-expr 0.15.8", - "heck 0.5.0", - "pkg-config", - "toml 0.8.2", - "version-compare", -] +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] -name = "system-deps" -version = "7.0.8" +name = "sum-tree-gpui-unofficial" +version = "1.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396a35feb67335377e0251fcbc1092fc85c484bd4e3a7a54319399da127796e7" +checksum = "cff5cac2ebaa209396f66d85372e5f16f00d95c4d15d0a2ae3214d3d508dab8b" dependencies = [ - "cfg-expr 0.20.10", - "heck 0.5.0", - "pkg-config", - "toml 1.1.8+spec-1.1.0", - "version-compare", + "heapless", + "rayon", + "tracing", + "ztracing-gpui-unofficial", ] [[package]] -name = "tao" -version = "0.37.2" +name = "svg_fmt" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5777b06fe6435126ae8d816eba269e050e1e10d302cf5461e9c49eccabc3548" -dependencies = [ - "bitflags 2.13.2", - "block2", - "core-foundation", - "core-graphics", - "crossbeam-channel", - "dbus", - "dispatch2", - "dlopen2", - "dpi", - "gdkwayland-sys", - "gdkx11-sys", - "gtk", - "jni", - "libc", - "log", - "ndk", - "ndk-context", - "ndk-sys", - "objc2", - "objc2-app-kit", - "objc2-foundation", - "objc2-ui-kit", - "parking_lot", - "percent-encoding", - "raw-window-handle", - "tao-macros", - "unicode-segmentation", - "url", - "windows 0.62.2", - "windows-core 0.62.2", - "windows-version", - "x11-dl", -] +checksum = "0193cc4331cfd2f3d2011ef287590868599a2f33c3e69bc22c1a3d3acf9e02fb" [[package]] -name = "tao-macros" -version = "0.1.4" +name = "svgtypes" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f7eeb6d99155545da6150a1795945f16ac9c178deb2a5f2e74d776107bd5849" +checksum = "9f12b12995e3638c70618c1facb1ce65302f6a6f706b675f07c58a5d7391120e" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", + "kurbo", + "siphasher", ] [[package]] -name = "target-lexicon" -version = "0.12.16" +name = "swash" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" +checksum = "6c2499c2d826531388872b2268718aed907a39bd785ab0dcfe57fab26283f92e" +dependencies = [ + "skrifa 0.44.0", + "yazi", + "zeno", +] [[package]] -name = "target-lexicon" -version = "0.13.5" +name = "syn" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "unicode-ident", +] [[package]] -name = "tauri" -version = "2.12.5" +name = "syn" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb0244332cfb9cee7e2a568bf5da29a36ed8fdbd717f6f47a66b6b7b358c072" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" dependencies = [ - "anyhow", - "bytes", - "cookie", - "dirs", - "dunce", - "embed_plist", - "getrandom 0.3.4", - "glob", - "gtk", - "heck 0.5.0", - "http", - "jni", - "libc", - "log", - "mime", - "muda", - "objc2", - "objc2-app-kit", - "objc2-foundation", - "objc2-ui-kit", - "objc2-web-kit", - "percent-encoding", - "plist", - "raw-window-handle", - "reqwest", - "serde", - "serde_json", - "serde_repr", - "serialize-to-javascript", - "swift-rs", - "tauri-build", - "tauri-macros", - "tauri-runtime", - "tauri-runtime-wry", - "tauri-utils", - "thiserror 2.0.21", - "tokio", - "tray-icon", - "url", - "webkit2gtk", - "webview2-com", - "window-vibrancy", - "windows 0.62.2", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "tauri-build" -version = "2.7.4" +name = "syn" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adddb0e648752aaac5da9c3c3c6a68e1e87cab55e3b757b18a9441ef8c3ac614" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" dependencies = [ - "anyhow", - "cargo_toml", - "dirs", - "glob", - "heck 0.5.0", - "json-patch", - "schemars 0.8.22", - "semver", - "serde", - "serde_json", - "static_vcruntime", - "strsim", - "tauri-utils", - "tauri-winres", - "walkdir", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "tauri-codegen" -version = "2.7.4" +name = "synstructure" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37631cf71dab5e8ab55e1bdd701e18a52653d90b78e71d0e5598b1e0a61316" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ - "base64 0.23.1", - "brotli", - "ico", - "json-patch", - "plist", - "png", "proc-macro2", "quote", - "semver", - "serde", - "serde_json", - "sha2", "syn 2.0.119", - "tauri-utils", - "thiserror 2.0.21", - "time", - "url", - "uuid", - "walkdir", ] [[package]] -name = "tauri-macros" -version = "2.7.4" +name = "synstructure" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc38db58854c10fb5f91a887ed8bf82d3239bb92b5d8db86eda09e96d9963d1" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" dependencies = [ - "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.119", - "tauri-codegen", - "tauri-utils", + "syn 3.0.9", ] [[package]] -name = "tauri-plugin-single-instance" -version = "2.5.4" +name = "sys-locale" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561cd99484561bc39c954768e7b41a66cebbe1ac3d9d081c34361f740c489e2c" +checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4" dependencies = [ - "serde", - "serde_json", - "tauri", - "thiserror 2.0.21", - "tokio", - "tracing", - "windows-sys 0.61.2", - "zbus", + "libc", ] [[package]] -name = "tauri-runtime" -version = "2.12.2" +name = "sysinfo" +version = "0.31.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c55766d99cea69055904d1735b93c2049302b2e09effd462120deb5581d78e9" +checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be" dependencies = [ - "cookie", - "dpi", - "gtk", - "http", - "jni", - "objc2", - "objc2-ui-kit", - "objc2-web-kit", - "raw-window-handle", - "serde", - "serde_json", - "tauri-utils", - "thiserror 2.0.21", - "url", - "webkit2gtk", - "webview2-com", - "windows 0.62.2", + "core-foundation-sys", + "libc", + "memchr", + "ntapi", + "rayon", + "windows 0.57.0", ] [[package]] -name = "tauri-runtime-wry" -version = "2.12.3" +name = "system-deps" +version = "6.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1aa9d8b7a120f879f44fdc1053f7b7dbf416bf0bbc6a72b714dec46b782b52f" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" dependencies = [ - "gtk", - "http", - "jni", - "log", - "objc2", - "objc2-app-kit", - "percent-encoding", - "raw-window-handle", - "softbuffer", - "tao", - "tauri-runtime", - "tauri-utils", - "url", - "webkit2gtk", - "webview2-com", - "windows 0.62.2", - "wry", + "cfg-expr 0.15.8", + "heck 0.5.0", + "pkg-config", + "toml 0.8.23", + "version-compare", ] [[package]] -name = "tauri-utils" -version = "2.10.2" +name = "system-deps" +version = "7.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "362ab21cd4cc713f2a02b1a9b5688198b1541cfb6907c4281e9190e0f0ef4aa3" +checksum = "396a35feb67335377e0251fcbc1092fc85c484bd4e3a7a54319399da127796e7" dependencies = [ - "anyhow", - "brotli", - "cargo_metadata", - "ctor", - "dom_query", - "dunce", - "glob", - "http", - "infer", - "json-patch", - "log", - "memchr", - "phf", - "plist", - "proc-macro2", - "quote", - "regex", - "schemars 0.8.22", - "semver", - "serde", - "serde-untagged", - "serde_json", - "serde_with", - "swift-rs", - "thiserror 2.0.21", + "cfg-expr 0.20.10", + "heck 0.5.0", + "pkg-config", "toml 1.1.8+spec-1.1.0", - "url", - "urlpattern", - "uuid", - "walkdir", + "version-compare", ] [[package]] -name = "tauri-winres" -version = "0.3.7" +name = "taffy" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c52bb6904475a6ca662f15ef787f18ade61d5740a1ee12c45d3b748efdb6f796" +checksum = "3c8480887e8803986d96a7173729565520d4bbb721ad6b7ad6941a22897207aa" dependencies = [ - "dunce", - "embed-resource", - "toml 1.1.8+spec-1.1.0", + "serde", + "slotmap", + "smallvec", +] + +[[package]] +name = "tao-core-video-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271450eb289cb4d8d0720c6ce70c72c8c858c93dd61fc625881616752e6b98f6" +dependencies = [ + "cfg-if", + "core-foundation-sys", + "libc", + "objc", +] + +[[package]] +name = "target-features" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1bbb9f3c5c463a01705937a24fdabc5047929ac764b2d5b9cf681c1f5041ed5" + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "target-lexicon" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" + +[[package]] +name = "tauri-winrt-notification" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f37a6c354fd28fc9e322ed9bd47e3959576dad28c9d58ea1cf888cce1c7ccb36" +dependencies = [ + "thiserror 2.0.21", + "windows 0.62.2", + "windows-version", ] [[package]] @@ -4147,12 +5842,12 @@ dependencies = [ ] [[package]] -name = "tendril" -version = "0.5.1" +name = "termcolor" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fed54709c5b3a53d09bb1c113ea4f5ceafd1e772ddcb0030a82e1d56c087b08" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ - "new_debug_unreachable", + "winapi-util", ] [[package]] @@ -4195,6 +5890,20 @@ dependencies = [ "syn 3.0.9", ] +[[package]] +name = "tiff" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52" +dependencies = [ + "fax", + "flate2", + "half", + "quick-error", + "weezl", + "zune-jpeg", +] + [[package]] name = "time" version = "0.3.55" @@ -4225,6 +5934,41 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tiny-skia" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "png 0.17.16", + "tiny-skia-path", +] + +[[package]] +name = "tiny-skia-path" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + [[package]] name = "tinystr" version = "0.8.5" @@ -4232,6 +5976,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" dependencies = [ "displaydoc", + "serde_core", "zerovec", ] @@ -4251,10 +5996,8 @@ dependencies = [ "libc", "mio", "pin-project-lite", - "signal-hook-registry", "socket2 0.6.5", "tokio-macros", - "tracing", "windows-sys 0.61.2", ] @@ -4279,29 +6022,16 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-util" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e464cf451ba96ebfc6f9b6542f17ee8b8956e33f1e40d9690624e59d7a7f8a4b" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", -] - [[package]] name = "toml" -version = "0.8.2" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", "serde_spanned 0.6.9", - "toml_datetime 0.6.3", - "toml_edit 0.20.2", + "toml_datetime 0.6.11", + "toml_edit 0.22.27", ] [[package]] @@ -4310,7 +6040,7 @@ version = "1.1.8+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d" dependencies = [ - "indexmap 2.14.2", + "indexmap", "serde_core", "serde_spanned 1.1.2", "toml_datetime 1.1.2+spec-1.1.0", @@ -4321,9 +6051,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" dependencies = [ "serde", ] @@ -4343,8 +6073,8 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.14.2", - "toml_datetime 0.6.3", + "indexmap", + "toml_datetime 0.6.11", "winnow 0.5.40", ] @@ -4354,11 +6084,23 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "indexmap 2.14.2", + "indexmap", + "toml_datetime 0.6.11", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap", "serde", "serde_spanned 0.6.9", - "toml_datetime 0.6.3", - "winnow 0.5.40", + "toml_datetime 0.6.11", + "toml_write", + "winnow 0.7.15", ] [[package]] @@ -4367,7 +6109,7 @@ version = "0.25.17+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c" dependencies = [ - "indexmap 2.14.2", + "indexmap", "toml_datetime 1.1.2+spec-1.1.0", "toml_parser", "winnow 1.0.4", @@ -4383,55 +6125,16 @@ dependencies = [ ] [[package]] -name = "toml_writer" -version = "1.1.3+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" - -[[package]] -name = "tower" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" -dependencies = [ - "futures-core", - "futures-util", - "pin-project-lite", - "sync_wrapper", - "tokio", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-http" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" -dependencies = [ - "bitflags 2.13.2", - "bytes", - "futures-util", - "http", - "http-body", - "pin-project-lite", - "tower", - "tower-layer", - "tower-service", - "url", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" +name = "toml_write" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] -name = "tower-service" -version = "0.3.3" +name = "toml_writer" +version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" +checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" [[package]] name = "tracing" @@ -4439,6 +6142,7 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -4471,32 +6175,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2b9c52859a94554803ccd4a24b98f74148ebc73b90676d783f3490b1bff9d72" dependencies = [ "crossbeam-channel", - "dirs", + "dirs 7.0.0", "libappindicator", "muda", - "objc2", - "objc2-app-kit", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", "objc2-core-foundation", "objc2-core-graphics", - "objc2-foundation", + "objc2-foundation 0.3.2", "once_cell", - "png", - "serde", + "png 0.18.1", "thiserror 2.0.21", "windows-sys 0.61.2", ] [[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - -[[package]] -name = "typeid" -version = "1.0.3" +name = "ttf-parser" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" +dependencies = [ + "core_maths", +] [[package]] name = "typenum" @@ -4515,11 +6215,47 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + +[[package]] +name = "unicode-bidi-mirroring" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfa6e8c60bb66d49db113e0125ee8711b7647b5579dc7f5f19c42357ed039fe" + +[[package]] +name = "unicode-ccc" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce61d488bcdc9bc8b5d1772c404828b17fc481c0a582b5581e95fb233aef503e" + [[package]] name = "unicode-ident" version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + +[[package]] +name = "unicode-properties" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" + +[[package]] +name = "unicode-script" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa04c955db05429d464c74d495c1ee677e1866e783a4c3747f9c0cef7756cabf" [[package]] name = "unicode-segmentation" @@ -4527,6 +6263,12 @@ version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" +[[package]] +name = "unicode-vo" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" + [[package]] name = "unicode-width" version = "0.2.2" @@ -4549,19 +6291,33 @@ dependencies = [ "idna", "percent-encoding", "serde", - "serde_derive", ] [[package]] -name = "urlpattern" -version = "0.6.0" +name = "usvg" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df16f50ef4cc145211879a3867ba757076b25dfee812040dcb0658bd9ae7904b" +checksum = "e419dff010bb12512b0ae9e3d2f318dfbdf0167fde7eb05465134d4e8756076f" dependencies = [ - "icu_properties", - "regex", - "serde", - "url", + "base64", + "data-url", + "flate2", + "fontdb", + "imagesize", + "kurbo", + "log", + "pico-args", + "roxmltree 0.21.2", + "rustybuzz", + "simplecss", + "siphasher", + "strict-num", + "svgtypes", + "tiny-skia-path", + "unicode-bidi", + "unicode-script", + "unicode-vo", + "xmlwriter", ] [[package]] @@ -4579,6 +6335,18 @@ dependencies = [ "getrandom 0.4.3", "js-sys", "serde_core", + "sha1_smol", + "wasm-bindgen", +] + +[[package]] +name = "v_frame" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2" +dependencies = [ + "aligned-vec", + "num-traits", "wasm-bindgen", ] @@ -4614,6 +6382,12 @@ dependencies = [ "libc", ] +[[package]] +name = "waker-fn" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" + [[package]] name = "walkdir" version = "2.5.0" @@ -4624,15 +6398,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "want" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b" -dependencies = [ - "try-lock", -] - [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" @@ -4705,18 +6470,116 @@ dependencies = [ ] [[package]] -name = "wasm-streams" -version = "0.5.0" +name = "wasm_thread" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb" +checksum = "b7516db7f32decdadb1c3b8deb1b7d78b9df7606c5cc2f6241737c2ab3a0258e" dependencies = [ - "futures-util", + "futures", "js-sys", "wasm-bindgen", - "wasm-bindgen-futures", "web-sys", ] +[[package]] +name = "wayland-backend" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" +dependencies = [ + "cc", + "downcast-rs", + "log", + "rustix", + "scoped-tls", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" +dependencies = [ + "bitflags 2.13.2", + "rustix", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" +dependencies = [ + "rustix", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-plasma" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-wlr" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0" +dependencies = [ + "proc-macro2", + "quick-xml", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" +dependencies = [ + "dlib", + "log", + "once_cell", + "pkg-config", +] + [[package]] name = "web-sys" version = "0.3.106" @@ -4738,93 +6601,201 @@ dependencies = [ ] [[package]] -name = "web_atoms" -version = "0.2.6" +name = "weezl" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" + +[[package]] +name = "wgpu" +version = "30.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba8b815c1b593dc0baf78dd0f4fc8fdb2de53198fb1163738093e9a311c33fb3" +checksum = "146fc3d654250e6207921a66c87534c621bc886c70df83dcf466c1d66813810e" dependencies = [ - "phf", - "phf_codegen", - "string_cache", - "string_cache_codegen", + "arrayvec", + "bitflags 2.13.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "js-sys", + "log", + "naga", + "parking_lot", + "portable-atomic", + "profiling", + "raw-window-handle", + "smallvec", + "static_assertions", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "wgpu-core", + "wgpu-hal", + "wgpu-types", ] [[package]] -name = "webkit2gtk" -version = "2.0.2" +name = "wgpu-core" +version = "30.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1027150013530fb2eaf806408df88461ae4815a45c541c8975e61d6f2fc4793" +checksum = "ad661da2ee99f208c30090b585284b2ab5b8bf2358ddf2d2215592808ec62f1a" dependencies = [ - "bitflags 1.3.2", - "cairo-rs", - "gdk", - "gdk-sys", - "gio", - "gio-sys", - "glib", - "glib-sys", - "gobject-sys", - "gtk", - "gtk-sys", - "javascriptcore-rs", - "libc", + "arrayvec", + "bit-set", + "bit-vec", + "bitflags 2.13.2", + "bytemuck", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "indexmap", + "log", + "naga", + "naga-types", "once_cell", - "soup3", - "webkit2gtk-sys", + "parking_lot", + "portable-atomic", + "profiling", + "raw-window-handle", + "rustc-hash 1.1.0", + "smallvec", + "thiserror 2.0.21", + "wgpu-core-deps-apple", + "wgpu-core-deps-emscripten", + "wgpu-core-deps-wasm", + "wgpu-core-deps-windows-linux-android", + "wgpu-hal", + "wgpu-naga-bridge", + "wgpu-types", ] [[package]] -name = "webkit2gtk-sys" -version = "2.0.2" +name = "wgpu-core-deps-apple" +version = "30.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916a5f65c2ef0dfe12fff695960a2ec3d4565359fdbb2e9943c974e06c734ea5" +checksum = "7d3f2f24aee039ffe9ef527300daf6b7428c58edeefdaa1700f4fa0fd754df16" dependencies = [ - "bitflags 1.3.2", - "cairo-sys-rs", - "gdk-sys", - "gio-sys", - "glib-sys", - "gobject-sys", - "gtk-sys", - "javascriptcore-rs-sys", - "libc", - "pkg-config", - "soup3-sys", - "system-deps 6.2.2", + "wgpu-hal", ] [[package]] -name = "webview2-com" -version = "0.39.1" +name = "wgpu-core-deps-emscripten" +version = "30.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f89fca7a704cee10dcb3654c1dbb8941d1783132f1917358af75bec37a7d7e6" +checksum = "55ccf093bd215ae9dc4f96df293e675513ac1f2569f8293a2911cc34ca3505d1" dependencies = [ - "webview2-com-macros", - "webview2-com-sys", - "windows 0.62.2", - "windows-core 0.62.2", + "wgpu-hal", ] [[package]] -name = "webview2-com-macros" -version = "0.8.1" +name = "wgpu-core-deps-wasm" +version = "30.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a921c1b6914c367b2b823cd4cde6f96beec77d30a939c8199bb377cf9b9b54" +checksum = "b20f43aeb9962d05e61e3ccb717e2e27ba1b04e979d4ca7e361384f8ee03db56" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-windows-linux-android" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1331b08fa2362c5d454eccc4448e6e4f01eccfea569a00e310adbfc4415f2bdc" +dependencies = [ + "wgpu-hal", ] [[package]] -name = "webview2-com-sys" -version = "0.39.1" +name = "wgpu-hal" +version = "30.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a07132775117d6065853d9d1178157b8c90e228de47129d6bce2c7edebedfb" +checksum = "a57452fe453658e141aafdb09de1028afa498805fab518238ddf372a518813ff" dependencies = [ + "android_system_properties", + "arrayvec", + "ash", + "bit-set", + "bitflags 2.13.2", + "block2 0.6.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "glow", + "glutin_wgl_sys", + "gpu-allocator", + "hashbrown 0.17.1", + "js-sys", + "khronos-egl", + "libc", + "libloading 0.8.9", + "log", + "naga", + "naga-types", + "ndk-sys", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", + "objc2-quartz-core 0.3.2", + "once_cell", + "ordered-float", + "parking_lot", + "portable-atomic", + "portable-atomic-util", + "profiling", + "range-alloc", + "raw-window-handle", + "raw-window-metal", + "renderdoc-sys", + "smallvec", + "static_assertions", "thiserror 2.0.21", + "wasm-bindgen", + "wayland-sys", + "web-sys", + "wgpu-naga-bridge", + "wgpu-types", "windows 0.62.2", "windows-core 0.62.2", + "windows-result 0.4.1", +] + +[[package]] +name = "wgpu-naga-bridge" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44a62ead68aad7cd40ac9e2cd2b8ec64f32dfbad2765f429b9fb74b8b735869f" +dependencies = [ + "naga", + "wgpu-types", +] + +[[package]] +name = "wgpu-types" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9f6ee0bd50f5ab79fb8c25e3f33afb27126f034af4ba5909c7a0967058659e6" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "js-sys", + "log", + "naga-types", + "raw-window-handle", + "static_assertions", + "web-sys", +] + +[[package]] +name = "which" +version = "8.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae2f2b2b816647a1cab1acc91f5bd20812d53cb344382635ec2181940c8034f" +dependencies = [ + "libc", ] [[package]] @@ -4859,19 +6830,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "window-vibrancy" -version = "0.8.1" +name = "windows" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "111e51caca442cafd9bab396628ac4d814880eaea4e63dfd76a12e9f342b5580" +checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" dependencies = [ - "objc2", - "objc2-app-kit", - "objc2-core-foundation", - "objc2-foundation", - "objc2-quartz-core", - "raw-window-handle", - "windows-sys 0.61.2", - "windows-version", + "windows-core 0.57.0", + "windows-targets 0.52.6", ] [[package]] @@ -4930,14 +6895,26 @@ dependencies = [ "windows-core 0.62.2", ] +[[package]] +name = "windows-core" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" +dependencies = [ + "windows-implement 0.57.0", + "windows-interface 0.57.0", + "windows-result 0.1.2", + "windows-targets 0.52.6", +] + [[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-implement 0.60.2", + "windows-interface 0.59.3", "windows-link 0.1.3", "windows-result 0.3.4", "windows-strings 0.4.2", @@ -4949,8 +6926,8 @@ version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ - "windows-implement", - "windows-interface", + "windows-implement 0.60.2", + "windows-interface 0.59.3", "windows-link 0.2.1", "windows-result 0.4.1", "windows-strings 0.5.1", @@ -4978,6 +6955,17 @@ dependencies = [ "windows-threading 0.2.1", ] +[[package]] +name = "windows-implement" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "windows-implement" version = "0.60.2" @@ -4989,6 +6977,17 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "windows-interface" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "windows-interface" version = "0.59.3" @@ -5032,6 +7031,26 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", +] + +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-result" version = "0.3.4" @@ -5070,11 +7089,11 @@ dependencies = [ [[package]] name = "windows-sys" -version = "0.45.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.42.2", + "windows-targets 0.48.5", ] [[package]] @@ -5106,17 +7125,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -5164,9 +7183,9 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" @@ -5176,9 +7195,9 @@ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" @@ -5188,9 +7207,9 @@ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" @@ -5206,9 +7225,9 @@ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" @@ -5218,9 +7237,9 @@ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" @@ -5230,9 +7249,9 @@ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" @@ -5242,9 +7261,9 @@ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" @@ -5261,6 +7280,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" +dependencies = [ + "memchr", +] + [[package]] name = "winnow" version = "1.0.4" @@ -5280,6 +7308,15 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "wio" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" +dependencies = [ + "winapi", +] + [[package]] name = "wit-bindgen" version = "0.57.1" @@ -5292,49 +7329,6 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" -[[package]] -name = "wry" -version = "0.57.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c50ddad0ef9913bb5496cb9d509a50433a3b78cb0238d61105526589cf0e9" -dependencies = [ - "base64 0.23.1", - "block2", - "cookie", - "crossbeam-channel", - "dirs", - "dom_query", - "dpi", - "dunce", - "gdkx11", - "gtk", - "http", - "javascriptcore-rs", - "jni", - "libc", - "ndk", - "objc2", - "objc2-app-kit", - "objc2-core-foundation", - "objc2-foundation", - "objc2-ui-kit", - "objc2-web-kit", - "percent-encoding", - "raw-window-handle", - "sha2", - "soup3", - "tao-macros", - "thiserror 2.0.21", - "url", - "webkit2gtk", - "webkit2gtk-sys", - "webview2-com", - "windows 0.62.2", - "windows-core 0.62.2", - "windows-version", - "x11-dl", -] - [[package]] name = "x11" version = "2.21.0" @@ -5346,16 +7340,25 @@ dependencies = [ ] [[package]] -name = "x11-dl" -version = "2.21.0" +name = "x11rb" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414" dependencies = [ + "as-raw-xcb-connection", + "gethostname", "libc", - "once_cell", - "pkg-config", + "rustix", + "x11rb-protocol", + "xcursor", ] +[[package]] +name = "x11rb-protocol" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" + [[package]] name = "x509-parser" version = "0.16.0" @@ -5373,6 +7376,78 @@ dependencies = [ "time", ] +[[package]] +name = "xcb" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6c2ad15e0e922856ee89afe862b8992334bbe7953adad56cd1199358cb30566" +dependencies = [ + "bitflags 2.13.2", + "libc", + "quick-xml", + "x11", +] + +[[package]] +name = "xcursor" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23" + +[[package]] +name = "xim-ctext" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac61a7062c40f3c37b6e82eeeef835d5cc7824b632a72784a89b3963c33284c" +dependencies = [ + "encoding_rs", +] + +[[package]] +name = "xim-parser" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcee45f89572d5a65180af3a84e7ddb24f5ea690a6d3aa9de231281544dd7b7" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "xkbcommon" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d66ca9352cbd4eecbbc40871d8a11b4ac8107cfc528a6e14d7c19c69d0e1ac9" +dependencies = [ + "as-raw-xcb-connection", + "libc", + "memmap2", + "xkeysym", +] + +[[package]] +name = "xkeysym" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" + +[[package]] +name = "xml-rs" +version = "0.8.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" + +[[package]] +name = "xmlwriter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" + +[[package]] +name = "y4m" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5a4b21e1a62b67a2970e6831bc091d7b87e119e7f9791aef9702e3bef04448" + [[package]] name = "yasna" version = "0.5.2" @@ -5382,6 +7457,23 @@ dependencies = [ "time", ] +[[package]] +name = "yazi" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac366ea532fa8ee6a992cec9dea525b1dc284e69702f36c2ab5fbebadc81ec86" + +[[package]] +name = "yeslogic-fontconfig-sys" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d8b8abf912b9a29ff112e1671c97c33636903d13a69712037190e6805af4f76" +dependencies = [ + "dlib", + "once_cell", + "pkg-config", +] + [[package]] name = "yoke" version = "0.8.4" @@ -5430,17 +7522,67 @@ dependencies = [ "rustix", "serde", "serde_repr", - "tokio", "tracing", "uds_windows", "uuid", "windows-sys 0.61.2", "winnow 1.0.4", - "zbus_macros", + "zbus_macros 5.19.0", "zbus_names", "zvariant", ] +[[package]] +name = "zbus" +version = "6.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4aae740b23927ceabed962431abab2cdefb9f7f885e5bbab062da09bf580e4" +dependencies = [ + "async-trait", + "bitflags 2.13.2", + "endi", + "futures-core", + "hex", + "libc", + "ordered-stream", + "rustix", + "serde", + "serde_repr", + "socket2 0.6.5", + "uds_windows", + "uuid", + "windows-sys 0.61.2", + "winnow 1.0.4", + "zbus_macros 6.3.0", + "zbus_utils", + "zcheapstr", + "zruntime", +] + +[[package]] +name = "zbus-lockstep" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6998de05217a084b7578728a9443d04ea4cd80f2a0839b8d78770b76ccd45863" +dependencies = [ + "zbus_xml", + "zvariant", +] + +[[package]] +name = "zbus-lockstep-macros" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10da05367f3a7b7553c8cdf8fa91aee6b64afebe32b51c95177957efc47ca3a0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "zbus-lockstep", + "zbus_xml", + "zvariant", +] + [[package]] name = "zbus_macros" version = "5.19.0" @@ -5456,6 +7598,18 @@ dependencies = [ "zvariant_utils", ] +[[package]] +name = "zbus_macros" +version = "6.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37c9dd4beaf145c16fcb2902862f50da86e54aed13dd368ddf64a1d17e6b8529" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "zbus_utils", +] + [[package]] name = "zbus_names" version = "4.3.5" @@ -5467,6 +7621,31 @@ dependencies = [ "zvariant", ] +[[package]] +name = "zbus_utils" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af55e52da295311b368c45bcae221f020e28e97a2420360170ce389218e76ec7" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 3.0.9", + "winnow 1.0.4", +] + +[[package]] +name = "zbus_xml" +version = "5.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1586c021a01ca0a9216dcd874e546382e156a5cbab5fab6cb5f10087e22682a" +dependencies = [ + "serde", + "winnow 1.0.4", + "zbus_names", + "zvariant", +] + [[package]] name = "zcheapstr" version = "1.1.0" @@ -5476,6 +7655,93 @@ dependencies = [ "serde", ] +[[package]] +name = "zed-font-kit" +version = "0.14.1-zed" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3898e450f36f852edda72e3f985c34426042c4951790b23b107f93394f9bff5" +dependencies = [ + "bitflags 2.13.2", + "byteorder", + "core-foundation 0.10.1", + "core-graphics 0.24.0", + "core-text", + "dirs 5.0.1", + "dwrote", + "float-ord", + "freetype-sys", + "lazy_static", + "libc", + "log", + "pathfinder_geometry", + "pathfinder_simd", + "walkdir", + "winapi", + "yeslogic-fontconfig-sys", +] + +[[package]] +name = "zed-scap" +version = "0.0.8-zed" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b338d705ae33a43ca00287c11129303a7a0aa57b101b72a1c08c863f698ac8" +dependencies = [ + "anyhow", + "cocoa", + "core-graphics-helmer-fork", + "log", + "objc", + "rand 0.8.8", + "screencapturekit", + "screencapturekit-sys", + "sysinfo", + "tao-core-video-sys", + "windows 0.61.3", + "windows-capture", + "x11", + "xcb", +] + +[[package]] +name = "zed-xim" +version = "0.4.0-zed" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0b46ed118eba34d9ba53d94ddc0b665e0e06a2cf874cfa2dd5dec278148642" +dependencies = [ + "ahash", + "hashbrown 0.14.5", + "log", + "x11rb", + "xim-ctext", + "xim-parser", +] + +[[package]] +name = "zeno" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6df3dc4292935e51816d896edcd52aa30bc297907c26167fec31e2b0c6a32524" + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "zerofrom" version = "0.1.8" @@ -5502,6 +7768,20 @@ 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" @@ -5512,6 +7792,7 @@ dependencies = [ "displaydoc", "yoke", "zerofrom", + "zerovec", ] [[package]] @@ -5520,6 +7801,7 @@ version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" dependencies = [ + "serde", "yoke", "zerofrom", "zerovec-derive", @@ -5548,6 +7830,59 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" +[[package]] +name = "zruntime" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6a55d4f521760475a30f7b96779508fe8c40dc834478709454dd1d5f0ebc72" +dependencies = [ + "futures-core", + "futures-io", + "rustix", + "socket2 0.6.5", + "windows-sys 0.61.2", +] + +[[package]] +name = "ztracing-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126aa72bc85209aa9ba718ac9bed86c0030efc4663206b795aa4e487a40e5c13" +dependencies = [ + "tracing", + "ztracing-macro-gpui-unofficial", +] + +[[package]] +name = "ztracing-macro-gpui-unofficial" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5879404d2f2b78c66eed689eed9d9bd2a3fb2fb964202c81b3cfe244d686f447" + +[[package]] +name = "zune-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "zune-jpeg" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" +dependencies = [ + "zune-core", +] + [[package]] name = "zvariant" version = "5.15.1" @@ -5557,6 +7892,7 @@ dependencies = [ "endi", "enumflags2", "serde", + "serde_bytes", "winnow 1.0.4", "zcheapstr", "zvariant_derive", diff --git a/desktop/Cargo.toml b/desktop/Cargo.toml index 7e0eb06..f961d49 100644 --- a/desktop/Cargo.toml +++ b/desktop/Cargo.toml @@ -1,6 +1,7 @@ [workspace] resolver = "2" -members = ["core/capture", "core/encode", "core/link", "core/sender", "core/cli", "app"] +members = ["core/capture", "core/encode", "core/link", "core/sender", "core/cli", "app-gpui"] +exclude = ["app"] [workspace.package] edition = "2021" diff --git a/desktop/README.md b/desktop/README.md index d821ee8..af526fd 100644 --- a/desktop/README.md +++ b/desktop/README.md @@ -20,12 +20,20 @@ picker (the system asks what to share), takes the sound from PipeWire, keeps the logind and starts with the session through an autostart entry. Tested on Ubuntu 26.04 (GNOME, Wayland, an NVIDIA GPU); see docs/limitations.md. -Building on Linux: `tools/build-ffmpeg-linux.sh` (gcc, make, nasm, pkg-config), then `cargo build --release -p castbay-desktop --features ffmpeg-lib`; `installer/linux/build-deb.sh BINARY VERSION OUTDIR` makes the package. +The shared UI uses the pinned `gpui-unofficial` and `gpui-platform-gpui-unofficial` crates, the +stable crates.io distribution of GPUI. Windows and Linux compile the same application module and +render the same pages and controls; only the screen-capture picker is supplied by each OS. + +Building on Linux: `tools/build-ffmpeg-linux.sh` (gcc, make, nasm, pkg-config), then `cargo build --release -p castbay-desktop-gpui --features ffmpeg-lib`; `installer/linux/build-deb.sh BINARY VERSION OUTDIR` makes the package. Building on Windows: `tools/build-ffmpeg.cmd` builds FFmpeg from the submodules (needs MSYS2 and -Visual Studio's C++ tools); then `cargo build --release -p castbay-desktop --features ffmpeg-lib` +Visual Studio's C++ tools); the GPUI application does not require WebView2. Then `cargo build --release -p castbay-desktop-gpui --features ffmpeg-lib` with `FFMPEG_DIR` pointing at its output (default `desktop/build/ffmpeg`). Without the feature the encoders run as an `ffmpeg.exe` child process (`CASTBAY_FFMPEG`). +Windows release packages include the required x64 `vcruntime140.dll` beside the application so the +portable build and per-user MSI can start without a separately installed Visual C++ Redistributable. +The release workflow sources this redistributable DLL from the Visual Studio installation and checks +that the app loads the copy shipped with each package. - [docs/limitations.md](docs/limitations.md): what is not done, not tested or not possible - [docs/user-guide.md](docs/user-guide.md): installing and using it (English and 中文) diff --git a/desktop/app-gpui/Cargo.toml b/desktop/app-gpui/Cargo.toml new file mode 100644 index 0000000..dd98eac --- /dev/null +++ b/desktop/app-gpui/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "castbay-desktop-gpui" +version = "0.1.8" +edition.workspace = true +license.workspace = true +publish = false + +[[bin]] +name = "castbay-desktop" +path = "src/main.rs" + +[features] +ffmpeg-lib = ["castbay-sender/ffmpeg-lib"] + +[dependencies] +gpui = { package = "gpui-unofficial", version = "=1.28.1", default-features = false } +gpui_platform = { package = "gpui-platform-gpui-unofficial", version = "=1.28.1", default-features = false, features = ["wayland", "x11"] } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +getrandom = "0.3" +tray-icon = "0.25.1" +sha2 = "0.10" +castbay-capture = { path = "../core/capture" } +castbay-link = { path = "../core/link" } +castbay-sender = { path = "../core/sender" } + +[target.'cfg(target_os = "linux")'.dependencies] +libloading = "0.8" + +[target.'cfg(windows)'.dependencies.windows] +version = "0.61" +features = ["Win32_Globalization", "Win32_Foundation", "Win32_UI_WindowsAndMessaging"] diff --git a/desktop/app-gpui/src/autostart.rs b/desktop/app-gpui/src/autostart.rs new file mode 100644 index 0000000..7953ff6 --- /dev/null +++ b/desktop/app-gpui/src/autostart.rs @@ -0,0 +1,78 @@ +use std::path::PathBuf; + +#[cfg(windows)] +const RUN_KEY: &str = r"HKCU\Software\Microsoft\Windows\CurrentVersion\Run"; +#[cfg(windows)] +const RUN_VALUE: &str = "CastBayDesktop"; + +#[cfg(windows)] +fn reg(args: &[&str]) -> std::io::Result { + use std::os::windows::process::CommandExt; + std::process::Command::new("reg") + .args(args) + .creation_flags(0x0800_0000) + .output() +} +#[cfg(windows)] +pub fn get() -> bool { + reg(&["query", RUN_KEY, "/v", RUN_VALUE]) + .map(|o| o.status.success()) + .unwrap_or(false) +} +#[cfg(windows)] +pub fn set(enabled: bool) -> Result<(), String> { + if enabled { + let exe = std::env::current_exe().map_err(|e| e.to_string())?; + let value = format!(r#""{}" --minimized"#, exe.display()); + if !reg(&[ + "add", RUN_KEY, "/v", RUN_VALUE, "/t", "REG_SZ", "/d", &value, "/f", + ]) + .map_err(|e| e.to_string())? + .status + .success() + { + return Err("Could not write the Windows startup entry".into()); + } + } else { + let _ = reg(&["delete", RUN_KEY, "/v", RUN_VALUE, "/f"]); + } + Ok(()) +} + +#[cfg(not(windows))] +fn entry() -> Result { + let base = std::env::var_os("XDG_CONFIG_HOME") + .map(PathBuf::from) + .or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".config"))) + .ok_or("No home folder")?; + Ok(base.join("autostart").join("castbay-desktop.desktop")) +} +#[cfg(not(windows))] +pub fn get() -> bool { + entry().map(|p| p.exists()).unwrap_or(false) +} +#[cfg(not(windows))] +pub fn set(enabled: bool) -> Result<(), String> { + let path = entry()?; + if enabled { + let exe = std::env::current_exe().map_err(|e| e.to_string())?; + let text = format!( + r#"[Desktop Entry] +Type=Application +Name=CastBay Desktop +Exec="{}" --minimized +X-GNOME-Autostart-enabled=true +"#, + exe.display() + ); + std::fs::create_dir_all(path.parent().unwrap()).map_err(|e| e.to_string())?; + std::fs::write(&path, text).map_err(|e| e.to_string())?; + } else { + match std::fs::remove_file(&path) { + Ok(()) => {} + Err(e) if e.kind() == std::io::ErrorKind::NotFound => {} + Err(e) => return Err(e.to_string()), + } + } + Ok(()) +} diff --git a/desktop/app-gpui/src/main.rs b/desktop/app-gpui/src/main.rs new file mode 100644 index 0000000..25dbd86 --- /dev/null +++ b/desktop/app-gpui/src/main.rs @@ -0,0 +1,2029 @@ +#![cfg_attr(all(not(debug_assertions), windows), windows_subsystem = "windows")] + +use std::{ + io::{Read, Write}, + net::{TcpListener, TcpStream}, + path::PathBuf, + sync::{ + Arc, Mutex, + atomic::{AtomicBool, Ordering}, + mpsc::{Sender, channel}, + }, + time::Duration, +}; + +use castbay_sender::{Codec, Options, Status, Stopper, Switcher, Target}; +#[path = "autostart.rs"] +mod autostart; +use gpui::{ + App, Bounds, ClickEvent, Context, FocusHandle, Focusable, FontWeight, SharedString, Window, + WindowBounds, WindowOptions, div, prelude::*, px, rgb, size, +}; +use gpui_platform::application; + +#[path = "../../app/src/crash.rs"] +mod crash; +#[path = "../../app/src/diagnostics.rs"] +mod diagnostics; +#[path = "../../app/src/settings.rs"] +mod settings; +#[path = "../../app/src/update.rs"] +mod update; +#[path = "../../app/src/usage.rs"] +mod usage; + +use settings::Settings; + +static ACTIVATE_REQUESTED: AtomicBool = AtomicBool::new(false); +static TRAY_ACTION: Mutex> = Mutex::new(None); + +#[derive(Clone)] +struct Receiver { + id: String, + name: String, + ip: String, + port: u16, + pair: String, + password: bool, + model: Option, + app_version: Option, +} + +#[derive(Default)] +struct Sources { + monitors: Vec, + windows: Vec, + system_picker: bool, +} + +#[derive(Clone, Copy, PartialEq)] +enum Page { + Home, + Settings, + Paired, + Diagnostics, + About, +} + +#[derive(Clone, Copy, PartialEq)] +enum InputMode { + None, + Password, + PairCode, +} + +#[derive(Default)] +struct Runtime { + stopper: Option, + switcher: Option, + code: Option>>, +} + +struct CastBay { + dir: PathBuf, + window_handle: Option, + settings: Settings, + receivers: Vec, + sources: Sources, + selected_receiver: usize, + selected_source: usize, + page: Page, + status: Arc>, + status_text: String, + error: String, + runtime: Arc>, + input_mode: InputMode, + input: String, + focus: FocusHandle, + paired: Vec<(String, String, u64)>, + logs: Vec, + update_message: String, + autostart: bool, + pending_crash: Option, + report_confirm: bool, + reset_confirm: bool, +} + +impl CastBay { + fn new(cx: &mut Context) -> Self { + let dir = data_dir(); + let _ = std::fs::create_dir_all(&dir); + crash::install_hook(dir.clone()); + let settings = Settings::load(&dir); + let pending = crash::take(&dir); + let status = Arc::new(Mutex::new(String::from("Ready"))); + let runtime = Arc::new(Mutex::new(Runtime::default())); + let mut state = Self { + dir: dir.clone(), + window_handle: None, + settings, + receivers: vec![], + sources: Sources::default(), + selected_receiver: 0, + selected_source: 0, + page: Page::Home, + status: status.clone(), + status_text: if pending.is_some() { + "Previous run ended unexpectedly".into() + } else { + "Ready".into() + }, + error: String::new(), + runtime: runtime.clone(), + input_mode: InputMode::None, + input: String::new(), + focus: cx.focus_handle(), + paired: vec![], + logs: vec![], + update_message: String::new(), + autostart: autostart::get(), + pending_crash: pending, + report_confirm: false, + reset_confirm: false, + }; + + state.load_sources(); + log_line(&dir, "application started"); + if state.settings.usage_stats { + let _ = usage::turn_on(&dir); + } + if state.settings.check_updates { + cx.spawn(async move |this, cx| { + let result = cx + .background_executor() + .spawn(async move { latest_version() }) + .await; + let _ = this.update(cx, |app, cx| { + match result { + Ok(Some(v)) if v != env!("CARGO_PKG_VERSION") => { + app.update_message = format!("Version {v} is available") + } + Ok(_) => app.update_message = "You are using the latest version".into(), + Err(e) => app.update_message = format!("Update check failed: {e}"), + } + cx.notify(); + }); + }) + .detach(); + } + cx.spawn(async move |this, cx| { + let found = cx + .background_executor() + .spawn(async move { castbay_link::browse(Duration::from_secs(3)) }) + .await; + let _ = this.update(cx, |app, cx| { + match found { + Ok(list) => { + app.receivers = list + .into_iter() + .filter_map(|r| { + let ip = r + .addresses + .iter() + .find(|a| a.is_ipv4()) + .or(r.addresses.first())?; + Some(Receiver { + id: r.id, + name: r.name, + ip: ip.to_string(), + port: r.port, + pair: format!("{:?}", r.pair).to_lowercase(), + password: r.password, + model: r.model, + app_version: r.app_version, + }) + }) + .collect(); + app.receivers.sort_by(|a, b| a.name.cmp(&b.name)); + app.selected_receiver = app + .receivers + .iter() + .position(|r| r.id == app.settings.last_receiver) + .unwrap_or(0); + app.error.clear(); + } + Err(e) => app.error = e.to_string(), + } + cx.notify(); + }); + }) + .detach(); + + let poll_status = status; + cx.spawn(async move |this, cx| { + loop { + cx.background_executor() + .timer(Duration::from_millis(400)) + .await; + let value = poll_status.lock().map(|s| s.clone()).unwrap_or_default(); + let mut activate = ACTIVATE_REQUESTED.swap(false, Ordering::SeqCst); + let action = TRAY_ACTION.lock().ok().and_then(|mut action| action.take()); + if let Some(action) = action { + match action.as_str() { + "settings" => { + let _ = this.update(cx, |app, cx| { + app.page = Page::Settings; + cx.notify(); + }); + activate = true; + } + "about" => { + let _ = this.update(cx, |app, cx| { + app.page = Page::About; + cx.notify(); + }); + activate = true; + } + "stop" => { + if let Ok(app) = this.read_with(cx, |app, _| app.runtime.clone()) { + if let Ok(rt) = app.lock() { + if let Some(stop) = rt.stopper.as_ref() { + stop.stop(); + } + } + } + } + "quit" => { + if let Ok(app) = this.read_with(cx, |app, _| app.runtime.clone()) { + if let Ok(rt) = app.lock() { + if let Some(stop) = rt.stopper.as_ref() { + stop.stop(); + } + } + } + let _ = cx.update(|app| app.quit()); + break; + } + _ => activate = true, + } + } + if activate { + let handle = this + .read_with(cx, |app, _| app.window_handle) + .ok() + .flatten(); + let _ = cx.update(|app| app.activate(true)); + if let Some(handle) = handle { + let _ = handle.update(cx, |_, window, _| window.activate_window()); + } + } + if this + .update(cx, |app, cx| { + if app.status_text != value { + app.status_text = value; + cx.notify(); + } + }) + .is_err() + { + break; + } + } + }) + .detach(); + if state.settings.error_reports { + if let Some(pending) = state.pending_crash.clone() { + let report_dir = dir.clone(); + let report_settings = state.settings.clone(); + cx.spawn(async move |this, cx| { + let result = cx + .background_executor() + .spawn(async move { + let text = report_text( + &report_dir, + &report_settings, + "crash", + Some(pending.text), + ); + diagnostics::upload( + &text, + env!("CARGO_PKG_VERSION"), + "crash", + &report_dir.join("report-cache"), + ) + .map_err(|e| e.text()) + }) + .await; + let _ = this.update(cx, |app, cx| { + match result { + Ok(id) => { + app.pending_crash = None; + app.status_text = format!("Crash report uploaded: {id}"); + } + Err(e) => app.error = format!("Crash report failed: {e}"), + } + cx.notify(); + }); + }) + .detach(); + } + } + let settings_for_stats = state.settings.clone(); + let stats_dir = dir.clone(); + std::thread::spawn(move || { + send_usage_once(&stats_dir, &settings_for_stats); + loop { + std::thread::sleep(Duration::from_secs(6 * 3600)); + send_usage_once(&stats_dir, &settings_for_stats); + } + }); + state + } + + fn refresh(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + self.status_text = "Searching for receivers…".into(); + self.error.clear(); + cx.notify(); + cx.spawn(async move |this, cx| { + let result = cx + .background_executor() + .spawn(async move { castbay_link::browse(Duration::from_secs(3)) }) + .await; + let _ = this.update(cx, |app, cx| { + match result { + Ok(list) => { + app.receivers = list + .into_iter() + .filter_map(|r| { + let ip = r + .addresses + .iter() + .find(|a| a.is_ipv4()) + .or(r.addresses.first())?; + Some(Receiver { + id: r.id, + name: r.name, + ip: ip.to_string(), + port: r.port, + pair: format!("{:?}", r.pair).to_lowercase(), + password: r.password, + model: r.model, + app_version: r.app_version, + }) + }) + .collect(); + app.receivers.sort_by(|a, b| a.name.cmp(&b.name)); + app.status_text = format!("{} receiver(s) found", app.receivers.len()); + app.selected_receiver = app + .receivers + .iter() + .position(|r| r.id == app.settings.last_receiver) + .unwrap_or(0); + } + Err(e) => { + app.error = e.to_string(); + app.status_text = "Search failed".into(); + } + } + cx.notify(); + }); + }) + .detach(); + } + + fn start(&mut self, _: &ClickEvent, window: &mut Window, cx: &mut Context) { + let Some(receiver) = self.receivers.get(self.selected_receiver).cloned() else { + self.error = + "No receiver selected. Refresh and make sure CastBay is open on the TV.".into(); + cx.notify(); + return; + }; + if receiver.password && self.input.is_empty() { + self.input_mode = InputMode::Password; + window.focus(&self.focus, cx); + self.error = "Enter the receiver password, then press Enter.".into(); + cx.notify(); + return; + } + if self.runtime.lock().unwrap().stopper.is_some() { + return; + } + let target = if self.sources.system_picker { + Target::Monitor(0) + } else if self.settings.source_kind == "window" { + Target::Window( + self.sources + .windows + .get(self.selected_source) + .cloned() + .unwrap_or_default(), + ) + } else { + Target::Monitor(self.selected_source) + }; + let (fps, bitrate_bps) = self.settings.quality_params(); + let codec = if self.settings.encoder == "auto" { + None + } else { + Codec::parse(&self.settings.encoder) + }; + let ip: std::net::IpAddr = match receiver.ip.parse() { + Ok(ip) => ip, + Err(e) => { + self.error = e.to_string(); + cx.notify(); + return; + } + }; + let (code_tx, code_rx) = channel::>(); + let status = self.status.clone(); + let dir = self.dir.clone(); + let options = Options { + addr: std::net::SocketAddr::new(ip, receiver.port), + receiver_id: Some(receiver.id.clone()), + name: std::env::var("COMPUTERNAME") + .or_else(|_| std::env::var("HOSTNAME")) + .unwrap_or_else(|_| "Computer".into()), + password: if receiver.password { + Some(std::mem::take(&mut self.input)) + } else { + None + }, + target, + fps, + bitrate_bps, + codec, + video_format: castbay_sender::FormatChoice::parse(&self.settings.video_format) + .unwrap_or_default(), + audio: self.settings.send_audio, + max_size: (1920, 1080), + data_dir: dir.clone(), + max_duration: None, + }; + let code = Box::new(move |_expected: &str| { + code_rx + .recv_timeout(Duration::from_secs(180)) + .ok() + .flatten() + }); + let on_status = Arc::new(move |s: Status| { + let text = match &s { + Status::Connecting => "Connecting…".into(), + Status::NeedsCode => "Enter the pairing code shown on the TV".into(), + Status::Casting { + receiver, + width, + height, + format, + } => format!("Casting to {receiver} · {width}×{height} · {format}"), + Status::Reconnecting(reason) => format!("Reconnecting: {reason}"), + Status::Reconnected => "Reconnected".into(), + Status::Receiver { + decode_ms, + dropped, + fps, + } => format!("Receiver: {fps:.1} fps · {decode_ms} ms decode · {dropped} dropped"), + Status::Bitrate(bps) => format!("Bitrate: {} Mbit/s", bps / 1_000_000), + Status::Still(true) => "Screen is idle; capture rate reduced".into(), + Status::Still(false) => "Screen activity resumed".into(), + Status::SourceLost => "Shared source closed; choose another source".into(), + Status::Switched => "Source switched".into(), + Status::SwitchFailed(reason) => format!("Could not switch source: {reason}"), + Status::ScreenLocked(true) => "Computer locked".into(), + Status::ScreenLocked(false) => "Computer unlocked".into(), + Status::Ended(reason) => format!("Casting ended: {reason}"), + }; + if let Ok(mut value) = status.lock() { + *value = text; + } + }); + let started = std::time::Instant::now(); + let day = usage::day_of(now_secs()); + if self.settings.usage_stats { + let key = if self.settings.source_kind == "window" { + "cast.window" + } else { + "cast.screen" + }; + usage::count(&dir, &day, key); + usage::count( + &dir, + &day, + if self.settings.fps == 60 { + "fps.60" + } else { + "fps.30" + }, + ); + usage::count(&dir, &day, usage::bitrate_key(self.settings.bitrate_mbps)); + usage::count( + &dir, + &day, + if self.settings.send_audio { + "sound.on" + } else { + "sound.off" + }, + ); + } + log_line( + &dir, + &format!( + "casting started to receiver {} using {} at {} fps and {} Mbit/s", + receiver.id, self.settings.encoder, self.settings.fps, self.settings.bitrate_mbps + ), + ); + let handle = castbay_sender::start(options, on_status, code); + let stopper = handle.stopper(); + let switcher = handle.switcher(); + let rt = self.runtime.clone(); + *rt.lock().unwrap() = Runtime { + stopper: Some(stopper), + switcher: Some(switcher), + code: Some(code_tx), + }; + crash::mark_casting(&dir, true); + let _ = self + .settings + .apply(&serde_json::json!({"last_receiver":receiver.id})); + let _ = self.settings.save(&dir); + let status = self.status.clone(); + let dir2 = dir.clone(); + let settings_on_end = self.settings.clone(); + std::thread::spawn(move || { + let outcome = handle.join(); + crash::mark_casting(&dir2, false); + if settings_on_end.usage_stats { + usage::count( + &dir2, + &usage::day_of(now_secs()), + usage::length_key(started.elapsed().as_secs_f64()), + ); + } + let failed = outcome + .as_ref() + .err() + .map(|e| (e.code.clone(), e.detail.clone())); + if let Some((code, detail)) = failed.as_ref() { + log_line(&dir2, &format!("casting failed: {code} - {detail}")); + if settings_on_end.usage_stats { + usage::count(&dir2, &usage::day_of(now_secs()), usage::failure_key(code)); + } + if settings_on_end.error_reports + && matches!( + code.as_str(), + "encoder" | "capture" | "no_picture" | "protocol" | "other" + ) + { + let text = report_text( + &dir2, + &settings_on_end, + "failure", + Some(format!("{code}: {detail}")), + ); + let _ = diagnostics::upload( + &text, + env!("CARGO_PKG_VERSION"), + "failure", + &dir2.join("report-cache"), + ); + } + } else { + log_line(&dir2, "casting stopped"); + } + if let Ok(mut v) = status.lock() { + *v = match outcome { + Ok(_) => "Ready".into(), + Err(e) => format!("Cast failed: {} ({})", e.code, e.detail), + }; + } + if let Ok(mut runtime) = rt.lock() { + *runtime = Runtime::default(); + } + }); + self.error.clear(); + self.input_mode = InputMode::None; + if self.settings.minimize_on_cast { + window.minimize_window(); + } + cx.notify(); + } + + fn stop(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + if let Some(s) = self.runtime.lock().unwrap().stopper.as_ref() { + s.stop(); + } + cx.notify(); + } + + fn choose_receiver( + &mut self, + index: usize, + _: &ClickEvent, + _: &mut Window, + cx: &mut Context, + ) { + if index < self.receivers.len() { + self.selected_receiver = index; + } + cx.notify(); + } + + fn choose_source(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + let total = if self.settings.source_kind == "window" { + self.sources.windows.len() + } else { + self.sources.monitors.len() + }; + if total > 0 { + self.selected_source = (self.selected_source + 1) % total; + let value = if self.settings.source_kind == "window" { + self.sources + .windows + .get(self.selected_source) + .cloned() + .unwrap_or_default() + } else { + self.sources + .monitors + .get(self.selected_source) + .cloned() + .unwrap_or_default() + }; + let key = if self.settings.source_kind == "window" { + "source_window" + } else { + "source_monitor" + }; + let patch = serde_json::json!({key:value}); + if let Err(e) = self + .settings + .apply(&patch) + .and_then(|_| self.settings.save(&self.dir)) + { + self.error = e; + } + if let Some(switcher) = self.runtime.lock().unwrap().switcher.as_ref() { + let target = if self.settings.source_kind == "window" { + Target::Window(value) + } else { + Target::Monitor(self.selected_source) + }; + switcher.switch(target); + } + } + cx.notify(); + } + + fn change_page(&mut self, page: Page, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + self.page = page; + if page == Page::Settings { + self.load_sources(); + } + if page == Page::Paired { + self.load_paired(); + } + cx.notify(); + } + + fn load_sources(&mut self) { + self.sources = Sources { + monitors: castbay_capture::monitors().unwrap_or_default(), + windows: castbay_capture::window_titles().unwrap_or_default(), + system_picker: cfg!(target_os = "linux"), + }; + let saved = if self.settings.source_kind == "window" { + &self.settings.source_window + } else { + &self.settings.source_monitor + }; + let list = if self.settings.source_kind == "window" { + &self.sources.windows + } else { + &self.sources.monitors + }; + self.selected_source = list.iter().position(|source| source == saved).unwrap_or(0); + } + + fn load_paired(&mut self) { + self.paired = castbay_link::Pins::load(&self.dir) + .list() + .into_iter() + .map(|r| (r.id, r.name, r.seen)) + .collect(); + } + + fn cycle_setting( + &mut self, + key: &'static str, + _: &ClickEvent, + _: &mut Window, + cx: &mut Context, + ) { + let patch = match key { + "fps" => serde_json::json!({"fps": if self.settings.fps==30 {60} else {30}}), + "encoder" => { + let mut values = vec!["auto"]; + values.extend( + castbay_sender::available_encoders() + .iter() + .map(|c| match c { + Codec::Amf => "amf", + Codec::Nvenc => "nvenc", + Codec::Qsv => "qsv", + Codec::X264 => "x264", + }), + ); + let i = values + .iter() + .position(|v| *v == self.settings.encoder) + .unwrap_or(0); + serde_json::json!({"encoder":values[(i+1)%values.len()]}) + } + "video_format" => { + let a = ["h264", "auto", "h265"]; + let i = a + .iter() + .position(|v| *v == self.settings.video_format) + .unwrap_or(0); + serde_json::json!({"video_format":a[(i+1)%a.len()]}) + } + "bitrate" => { + serde_json::json!({"bitrate_mbps": if self.settings.bitrate_mbps>=20 {2} else {self.settings.bitrate_mbps+1}}) + } + "source_kind" => { + self.selected_source = 0; + serde_json::json!({"source_kind": if self.settings.source_kind=="monitor" {"window"} else {"monitor"}}) + } + "language" => { + serde_json::json!({"language": match self.settings.language.as_str() {"auto"=>"zh","zh"=>"en",_=>"auto"}}) + } + "send_audio" => serde_json::json!({"send_audio":!self.settings.send_audio}), + "minimize_on_cast" => { + serde_json::json!({"minimize_on_cast":!self.settings.minimize_on_cast}) + } + "usage_stats" => serde_json::json!({"usage_stats":!self.settings.usage_stats}), + "error_reports" => serde_json::json!({"error_reports":!self.settings.error_reports}), + "check_updates" => serde_json::json!({"check_updates":!self.settings.check_updates}), + "autostart" => serde_json::json!({}), + _ => serde_json::json!({}), + }; + if key == "usage_stats" { + let was = self.settings.usage_stats; + if let Err(e) = self + .settings + .apply(&patch) + .and_then(|_| self.settings.save(&self.dir)) + { + self.error = e; + cx.notify(); + return; + } + if self.settings.usage_stats && !was { + if !usage::turn_on(&self.dir) { + self.error = "Could not initialize anonymous statistics".into(); + } + } else if was && !self.settings.usage_stats { + if let Some(id) = usage::turn_off(&self.dir) { + let cache = self.dir.join("report-cache"); + std::thread::spawn(move || { + let body = serde_json::json!({"id":id}).to_string(); + let _ = diagnostics::post( + "/api/stats/delete", + "application/json", + &[], + &body, + &cache, + ); + }); + } + } + } else if let Err(e) = self + .settings + .apply(&patch) + .and_then(|_| self.settings.save(&self.dir)) + { + self.error = e; + } + if key == "source_kind" { + self.load_sources(); + } + log_line(&self.dir, &format!("setting changed: {key}")); + cx.notify(); + } + + fn key_down(&mut self, event: &gpui::KeyDownEvent, _: &mut Window, cx: &mut Context) { + if self.input_mode == InputMode::None { + return; + } + let key = &event.keystroke.key; + if key == "backspace" || key == "Backspace" { + self.input.pop(); + } else if key == "enter" || key == "Enter" { + if self.input_mode == InputMode::PairCode { + if let Some(tx) = self.runtime.lock().unwrap().code.as_ref() { + let _ = tx.send(Some(std::mem::take(&mut self.input))); + } + self.input_mode = InputMode::None; + } else { + self.input_mode = InputMode::None; + self.status_text = "Password entered; choose Start casting.".into(); + } + } else if let Some(c) = event + .keystroke + .key_char + .as_ref() + .and_then(|s| s.chars().next()) + { + if !c.is_control() && self.input.len() < 64 { + self.input.push(c); + } + } + cx.notify(); + } + + fn toggle_autostart(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + match autostart::set(!self.autostart) { + Ok(()) => { + self.autostart = !self.autostart; + log_line(&self.dir, &format!("autostart {}", self.autostart)); + } + Err(e) => self.error = e, + } + cx.notify(); + } + + fn request_report(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + self.report_confirm = !self.report_confirm; + self.logs = diagnostics::read_log(&self.dir); + cx.notify(); + } + + fn send_manual_report(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + let dir = self.dir.clone(); + let settings = self.settings.clone(); + self.report_confirm = false; + self.status_text = "Preparing diagnostic report…".into(); + cx.notify(); + cx.spawn(async move |this, cx| { + let result = cx + .background_executor() + .spawn(async move { + let text = report_text(&dir, &settings, "manual", None); + diagnostics::upload( + &text, + env!("CARGO_PKG_VERSION"), + "manual", + &dir.join("report-cache"), + ) + .map_err(|e| e.text()) + }) + .await; + let _ = this.update(cx, |app, cx| { + match result { + Ok(id) => app.status_text = format!("Report uploaded: {id}"), + Err(e) => app.error = format!("Report upload failed: {e}"), + } + log_line(&app.dir, &app.status_text); + cx.notify(); + }); + }) + .detach(); + } + + fn skip_update(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + if let Some(version) = self + .update_message + .split_whitespace() + .find(|word| update::valid_version(word)) + .map(str::to_string) + { + let _ = self + .settings + .apply(&serde_json::json!({"ignored_update":version})); + if let Err(e) = self.settings.save(&self.dir) { + self.error = e; + } + self.update_message = localized( + "已忽略此版本更新提示", + "Skipped this update", + self.settings.chinese(system_is_chinese()), + ) + .into(); + } + cx.notify(); + } + + fn dismiss_crash(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + self.pending_crash = None; + log_line(&self.dir, "previous crash report dismissed"); + cx.notify(); + } + + fn send_crash(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + let Some(pending) = self.pending_crash.clone() else { + return; + }; + let dir = self.dir.clone(); + let settings = self.settings.clone(); + cx.spawn(async move |this, cx| { + let result = cx + .background_executor() + .spawn(async move { + let text = report_text(&dir, &settings, "crash", Some(pending.text)); + diagnostics::upload( + &text, + env!("CARGO_PKG_VERSION"), + "crash", + &dir.join("report-cache"), + ) + .map_err(|e| e.text()) + }) + .await; + let _ = this.update(cx, |app, cx| { + match result { + Ok(id) => { + app.pending_crash = None; + app.status_text = format!("Crash report uploaded: {id}"); + } + Err(e) => app.error = format!("Crash report failed: {e}"), + } + log_line(&app.dir, &app.status_text); + cx.notify(); + }); + }) + .detach(); + } + + fn check_updates(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + self.update_message = "Checking for updates…".into(); + cx.notify(); + cx.spawn(async move |this, cx| { + let result = cx + .background_executor() + .spawn(async move { latest_version() }) + .await; + let _ = this.update(cx, |app, cx| { + app.update_message = match result { + Ok(Some(v)) if v != env!("CARGO_PKG_VERSION") => { + format!("Version {v} is available") + } + Ok(_) => "You are using the latest version".into(), + Err(e) => format!("Update check failed: {e}"), + }; + cx.notify(); + }); + }) + .detach(); + } + + fn install_update(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + if self + .runtime + .lock() + .map(|r| r.stopper.is_some()) + .unwrap_or(false) + { + self.error = "Stop casting before updating.".into(); + cx.notify(); + return; + } + let Some(version) = self + .update_message + .split_whitespace() + .find(|w| update::valid_version(w)) + .map(str::to_string) + else { + self.error = "Check for an available version first.".into(); + cx.notify(); + return; + }; + let settings = self.settings.clone(); + let dir = self.dir.clone(); + self.update_message = format!("Downloading and verifying {version}…"); + cx.notify(); + cx.spawn(async move |this, cx| { + let result = cx + .background_executor() + .spawn(async move { + let exe = std::env::current_exe().map_err(|e| e.to_string())?; + let installed = if cfg!(windows) { + std::env::var_os("LOCALAPPDATA").is_some_and(|root| { + exe.starts_with( + PathBuf::from(root).join("Programs").join("CastBay Desktop"), + ) + }) + } else { + exe == PathBuf::from("/usr/bin/castbay-desktop") + }; + if !installed { + return Err("This copy must be updated from the release page.".to_string()); + } + let zh = settings.chinese(system_is_chinese()); + let package = update::fetch(&version, cfg!(windows), zh, &dir.join("update"))?; + #[cfg(windows)] + { + update::install(&package, &exe)?; + std::process::exit(0); + } + #[cfg(not(windows))] + { + match update::install(&package)? { + update::Installed::Yes => { + update::start_again(&exe)?; + std::process::exit(0); + } + update::Installed::Cancelled => Err("Update cancelled.".into()), + update::Installed::NoPrompt => { + open_path(&package); + Ok(()) + } + } + } + }) + .await; + let _ = this.update(cx, |app, cx| { + match result { + Ok(()) => { + app.update_message = "Installer opened; follow the system prompt.".into() + } + Err(e) => app.error = e, + } + cx.notify(); + }); + }) + .detach(); + } + + fn dismiss_welcome(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + let _ = self + .settings + .apply(&serde_json::json!({"welcome_done":true})); + if let Err(e) = self.settings.save(&self.dir) { + self.error = e; + } + cx.notify(); + } + + fn clear_error(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + self.error.clear(); + cx.notify(); + } + + fn reset(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + if !self.reset_confirm { + self.reset_confirm = true; + cx.notify(); + return; + } + self.reset_confirm = false; + self.settings.restore_defaults(); + if let Err(e) = self.settings.save(&self.dir) { + self.error = e; + } + cx.notify(); + } + + fn forget_share(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context) { + match std::fs::remove_file(self.dir.join("screencast-token")) { + Ok(()) => self.status_text = "Screen share permission will be requested again".into(), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => { + self.status_text = "No saved screen permission".into() + } + Err(e) => self.error = e.to_string(), + } + cx.notify(); + } + + fn remove_paired( + &mut self, + id: String, + _: &ClickEvent, + _: &mut Window, + cx: &mut Context, + ) { + if let Err(e) = castbay_link::Pins::load(&self.dir).forget(&id) { + self.error = e.to_string(); + } + self.load_paired(); + cx.notify(); + } +} + +impl Focusable for CastBay { + fn focus_handle(&self, _: &App) -> FocusHandle { + self.focus.clone() + } +} + +impl Render for CastBay { + fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { + let dark = 0x101827; + let panel = 0x1c2a3a; + let muted = 0xa8b5c8; + let accent = 0x8c74e8; + let page = self.page; + let zh = self.settings.chinese(system_is_chinese()); + let mut root = div() + .id("main") + .size_full() + .bg(rgb(dark)) + .text_color(rgb(0xe6edf7)) + .flex() + .flex_col() + .p_6() + .gap_4() + .overflow_y_scroll() + .track_focus(&self.focus) + .on_key_down(cx.listener(Self::key_down)); + root = root.child( + div() + .flex() + .items_center() + .justify_between() + .pb_3() + .border_b_1() + .border_color(rgb(0x34445a)) + .child( + div() + .text_2xl() + .font_weight(FontWeight::BOLD) + .child("CastBay Desktop"), + ) + .child( + div() + .flex() + .gap_2() + .child(nav( + localized("首页", "Home", zh), + page == Page::Home, + cx.listener(|this, e, w, cx| this.change_page(Page::Home, e, w, cx)), + )) + .child(nav( + localized("设置", "Settings", zh), + page == Page::Settings, + cx.listener(|this, e, w, cx| { + this.change_page(Page::Settings, e, w, cx) + }), + )) + .child(nav( + localized("已配对", "Paired", zh), + page == Page::Paired, + cx.listener(|this, e, w, cx| this.change_page(Page::Paired, e, w, cx)), + )) + .child(nav( + localized("诊断", "Diagnostics", zh), + page == Page::Diagnostics, + cx.listener(|this, e, w, cx| { + this.change_page(Page::Diagnostics, e, w, cx) + }), + )) + .child(nav( + localized("关于", "About", zh), + page == Page::About, + cx.listener(|this, e, w, cx| this.change_page(Page::About, e, w, cx)), + )), + ), + ); + root = root.child( + div() + .text_sm() + .text_color(rgb(muted)) + .child(self.status_text.clone()), + ); + if !self.error.is_empty() { + root = root.child( + div() + .rounded_md() + .bg(rgb(0x4c2634)) + .p_3() + .child(self.error.clone()) + .child(button("Dismiss", cx.listener(Self::clear_error))), + ); + } + if let Some(pending) = self.pending_crash.as_ref() { + root = root.child( + section( + localized("上次异常退出", "Previous unexpected exit", zh), + 0x4c2634, + ) + .child(div().child(pending.text.clone())) + .child( + div() + .flex() + .gap_2() + .child(button( + localized("发送崩溃报告", "Send crash report", zh), + cx.listener(Self::send_crash), + )) + .child(button( + localized("忽略", "Dismiss", zh), + cx.listener(Self::dismiss_crash), + )), + ), + ); + } + if self.report_confirm { + let home = std::env::var("HOME") + .or_else(|_| std::env::var("USERPROFILE")) + .unwrap_or_default(); + let preview = diagnostics::scrub(&diagnostics::newest(&self.logs, 40_000), &home); + root=root.child(section(localized("上传前预览","Review before upload",zh),panel) + .child(div().text_sm().child(format!("This uploads system details, settings and recent logs. Addresses, receiver names and your home folder are removed first. +{}",preview))) + .child(div().flex().gap_2().child(button(localized("确认上传","Upload report",zh),cx.listener(Self::send_manual_report))).child(button(localized("取消","Cancel",zh),cx.listener(Self::request_report))))); + } + match self.page { + Page::Home => { + if !self.settings.welcome_done { + root=root.child(section(localized("欢迎使用 CastBay Desktop","Welcome to CastBay Desktop",zh),panel) + .child(div().child(localized("在接收端电视上开启桌面投屏,然后选择接收端和屏幕或窗口。","Enable desktop casting on your CastBay receiver, then choose a receiver and a screen or window.",zh))) + .child(button(localized("知道了","Got it",zh),cx.listener(Self::dismiss_welcome)))); + } + root = root.child(section(localized("接收端", "Receivers", zh), panel).child( + button(localized("刷新", "Refresh", zh), cx.listener(Self::refresh)), + )); + if self.receivers.is_empty() { + root = root.child(div().text_color(rgb(muted)).child(localized( + "没有发现接收端。请在电视上打开 CastBay 后刷新。", + "No receivers found. Open CastBay on a receiver and refresh.", + zh, + ))); + } + for (i, r) in self.receivers.iter().enumerate() { + let selected = i == self.selected_receiver; + let label = format!( + "{} · {}:{} · {} · {}{}", + r.name, + r.ip, + r.port, + r.app_version.as_deref().unwrap_or("CastBay"), + r.model.as_deref().unwrap_or(""), + if r.password { + if zh { + " · 需要密码" + } else { + " · Password required" + } + } else { + if r.pair == "required" { + if zh { + " · 需要配对" + } else { + " · Pairing required" + } + } else { + "" + } + } + ); + root = + root.child( + div() + .rounded_md() + .border_1() + .border_color(rgb(if selected { accent } else { 0x34445a })) + .bg(rgb(panel)) + .p_3() + .child(label) + .id(format!("receiver-{i}")) + .on_click(cx.listener(move |this, e, w, cx| { + this.choose_receiver(i, e, w, cx) + })), + ); + } + let src = if self.settings.source_kind == "window" { + self.sources + .windows + .get(self.selected_source) + .cloned() + .unwrap_or_else(|| "Choose window".into()) + } else { + self.sources + .monitors + .get(self.selected_source) + .cloned() + .unwrap_or_else(|| { + if self.sources.system_picker { + "Choose screen using system picker".into() + } else { + "Choose display".into() + } + }) + }; + let mut source_panel = section(localized("投屏来源", "Source", zh), panel); + if !self.sources.system_picker { + source_panel = source_panel.child(button( + format!( + "{}: {}", + if zh { + "来源类型(点击切换)" + } else { + "Type (click to change)" + }, + if zh { + if self.settings.source_kind == "window" { + "窗口" + } else { + "屏幕" + } + } else if self.settings.source_kind == "window" { + "Window" + } else { + "Screen" + } + ), + cx.listener(|this, e, w, cx| this.cycle_setting("source_kind", e, w, cx)), + )); + } + source_panel = source_panel.child(button( + format!( + "{}: {src}", + if zh { + "捕获来源(点击切换)" + } else { + "Capture (click to cycle)" + } + ), + cx.listener(Self::choose_source), + )); + root = root.child(source_panel); + root = root.child( + div() + .flex() + .gap_3() + .child(button( + localized("开始投屏", "Start casting", zh), + cx.listener(Self::start), + )) + .child(button( + localized("停止投屏", "Stop casting", zh), + cx.listener(Self::stop), + )), + ); + if self.input_mode != InputMode::None { + let value = if self.input_mode == InputMode::Password { + "•".repeat(self.input.len()) + } else { + self.input.clone() + }; + let form = section( + if self.input_mode == InputMode::PairCode { + localized("配对码", "Pairing code", zh) + } else { + localized("接收端密码", "Receiver password", zh) + }, + panel, + ) + .child(div().rounded_md().bg(rgb(0x101827)).p_3().child(value)) + .child(localized( + "在应用窗口输入内容并按 Enter 确认。", + "Type in the focused window; press Enter to submit.", + zh, + )); + root = root.child(form); + } + if let Ok(rt) = self.runtime.lock() { + if rt.code.is_some() && self.input_mode == InputMode::None { + root = root.child(button( + localized("输入配对码", "Enter pairing code", zh), + cx.listener(|this, _, window, cx| { + this.input_mode = InputMode::PairCode; + this.input.clear(); + window.focus(&this.focus, cx); + cx.notify(); + }), + )); + } + } + if !self.sources.monitors.is_empty() || !self.sources.windows.is_empty() { + root = root.child(div().text_sm().text_color(rgb(muted)).child(format!( + "Available: {} displays · {} windows", + self.sources.monitors.len(), + self.sources.windows.len() + ))); + } + } + Page::Settings => { + root=root.child(section(localized("偏好设置","Preferences",zh),panel) + .child(setting_line(localized("帧率","Frame rate",zh),format!("{} fps",self.settings.fps),cx.listener(|this,e,w,cx|this.cycle_setting("fps",e,w,cx)))) + .child(setting_line(localized("码率","Bitrate",zh),format!("{} Mbit/s",self.settings.bitrate_mbps),cx.listener(|this,e,w,cx|this.cycle_setting("bitrate",e,w,cx)))) + .child(setting_line(localized("编码器","Encoder",zh),if self.settings.encoder=="auto" {localized("自动","Auto",zh).into()} else {self.settings.encoder.clone()},cx.listener(|this,e,w,cx|this.cycle_setting("encoder",e,w,cx)))) + .child(setting_line(localized("视频格式","Video format",zh),localized(match self.settings.video_format.as_str() {"auto"=>"自动","h265"=>"H.265",_=>"H.264"},match self.settings.video_format.as_str() {"auto"=>"Auto","h265"=>"H.265",_=>"H.264"},zh).to_string(),cx.listener(|this,e,w,cx|this.cycle_setting("video_format",e,w,cx)))) + .child(setting_line(localized("发送声音","Send audio",zh),localized(if self.settings.send_audio {"开"} else {"关"},if self.settings.send_audio {"On"} else {"Off"},zh).to_string(),cx.listener(|this,e,w,cx|this.cycle_setting("send_audio",e,w,cx)))) + .child(setting_line(localized("投屏后最小化","Minimize when casting",zh),localized(if self.settings.minimize_on_cast {"开"} else {"关"},if self.settings.minimize_on_cast {"On"} else {"Off"},zh).to_string(),cx.listener(|this,e,w,cx|this.cycle_setting("minimize_on_cast",e,w,cx)))) + .child(setting_line(localized("语言","Language",zh),localized(match self.settings.language.as_str() {"zh"=>"中文","en"=>"English",_=>"跟随系统"},match self.settings.language.as_str() {"zh"=>"Chinese","en"=>"English",_=>"Follow system"},zh).to_string(),cx.listener(|this,e,w,cx|this.cycle_setting("language",e,w,cx)))) + .child(setting_line(localized("开机启动","Start with computer",zh),localized(if self.autostart {"开"} else {"关"},if self.autostart {"On"} else {"Off"},zh).to_string(),cx.listener(Self::toggle_autostart))) + .child(div().text_sm().text_color(rgb(muted)).child(localized("默认关闭;启用后每天发送匿名汇总。关闭时会请求删除已上传的统计数据。","Off by default; when enabled, anonymous daily summaries are sent. Turning it off requests deletion of uploaded statistics.",zh))) + .child(setting_line(localized("发送匿名使用统计","Anonymous usage statistics",zh),localized(if self.settings.usage_stats {"开"} else {"关"},if self.settings.usage_stats {"On"} else {"Off"},zh).to_string(),cx.listener(|this,e,w,cx|this.cycle_setting("usage_stats",e,w,cx)))) + .child(div().text_sm().text_color(rgb(muted)).child(localized("默认关闭;开启后,程序异常结束或投屏遇到特定错误时会自动上传已脱敏的报告。","Off by default; when enabled, a scrubbed report is sent after a crash or certain casting failures.",zh))) + .child(setting_line(localized("自动发送错误报告","Automatic error reports",zh),localized(if self.settings.error_reports {"开"} else {"关"},if self.settings.error_reports {"On"} else {"Off"},zh).to_string(),cx.listener(|this,e,w,cx|this.cycle_setting("error_reports",e,w,cx)))) + .child(setting_line(localized("启动时检查更新","Check for updates at startup",zh),localized(if self.settings.check_updates {"开"} else {"关"},if self.settings.check_updates {"On"} else {"Off"},zh).to_string(),cx.listener(|this,e,w,cx|this.cycle_setting("check_updates",e,w,cx)))) + .child(button(localized("清除屏幕共享授权","Forget saved screen-sharing permission",zh),cx.listener(Self::forget_share))) + .child(button(if self.reset_confirm {localized("再次点击确认恢复默认设置","Click again to restore defaults",zh)} else {localized("恢复默认设置","Restore defaults",zh)},cx.listener(Self::reset)))); + } + Page::Paired => { + root = root.child(section( + localized("已配对的接收端", "Paired receivers", zh), + panel, + )); + if self.paired.is_empty() { + root = root.child(div().text_color(rgb(muted)).child(localized( + "尚无已配对的接收端。", + "No paired receivers yet.", + zh, + ))); + } + for (id, name, seen) in self.paired.clone() { + root = root.child( + div() + .flex() + .justify_between() + .rounded_md() + .bg(rgb(panel)) + .p_3() + .child(format!( + "{} · {} {seen}", + name, + localized("最近使用", "last used", zh) + )) + .child(button( + localized("忘记设备", "Forget", zh), + cx.listener(move |this, e, w, cx| { + this.remove_paired(id.clone(), e, w, cx) + }), + )), + ); + } + } + Page::Diagnostics => { + root = root.child( + section(localized("诊断信息", "Diagnostics", zh), panel) + .child( + div() + .text_color(rgb(muted)) + .child(diagnostics::system_line()), + ) + .child( + div() + .text_color(rgb(muted)) + .child(format!("Log directory: {}", self.dir.display())), + ) + .child(div().text_color(rgb(muted)).child(format!( + "Paired receivers: {}", + castbay_link::Pins::load(&self.dir).list().len() + ))) + .child(button( + localized( + "预览并上传诊断报告", + "Review and upload diagnostic report", + zh, + ), + cx.listener(Self::request_report), + )) + .child(button( + localized("打开日志目录", "Open logs folder", zh), + cx.listener(|this, _, _, cx| { + open_path(&this.dir); + cx.notify(); + }), + )), + ); + } + Page::About => { + root = root.child( + section( + localized("关于 CastBay Desktop", "About CastBay Desktop", zh), + panel, + ) + .child( + div() + .text_color(rgb(muted)) + .child(format!("Version {}", env!("CARGO_PKG_VERSION"))), + ) + .child(button( + localized("检查更新", "Check for updates", zh), + cx.listener(Self::check_updates), + )) + .child(button( + localized("安装可用更新", "Install available update", zh), + cx.listener(Self::install_update), + )) + .child(button( + localized("忽略此版本", "Skip this version", zh), + cx.listener(Self::skip_update), + )) + .child(button( + localized("查看更新说明", "Release notes", zh), + cx.listener(|this, _, _, _| { + if let Some(v) = this + .update_message + .split_whitespace() + .find(|word| update::valid_version(word)) + { + open_url(&format!( + "https://castbay.weenas.com/{}changelog#desktop-v{v}", + if this.settings.chinese(system_is_chinese()) { + "zh/" + } else { + "" + } + )); + } + }), + )) + .child(button( + localized("打开桌面版发布页", "Open CastBay Desktop releases", zh), + cx.listener(|_, _, _, _| { + open_url("https://github.com/weenas/castbay/releases") + }), + )) + .child(button( + localized("反馈问题", "Report a problem", zh), + cx.listener(|this, _, _, _| { + open_url(&format!( + "https://castbay.weenas.com/{}feedback?from=desktop&v={}", + if this.settings.chinese(system_is_chinese()) { + "zh/" + } else { + "" + }, + env!("CARGO_PKG_VERSION") + )) + }), + )) + .child(button( + localized("查看 GPL-3.0 许可证", "Open GPL-3.0 license", zh), + cx.listener(|_, _, _, _| { + open_url("https://github.com/weenas/castbay/blob/main/LICENSE") + }), + )) + .child(button( + localized("打开项目网站", "Open project website", zh), + cx.listener(|_, _, _, _| open_url("https://castbay.weenas.com")), + )) + .child(button( + localized("打开源代码仓库", "Open source repository", zh), + cx.listener(|_, _, _, _| open_url("https://github.com/weenas/castbay")), + )) + .child( + div() + .text_color(rgb(muted)) + .child(self.update_message.clone()), + ), + ); + } + } + root + } +} + +fn section(title: &'static str, color: u32) -> gpui::Div { + div() + .flex() + .flex_col() + .gap_3() + .rounded_lg() + .bg(rgb(color)) + .p_4() + .child(div().text_lg().font_weight(FontWeight::BOLD).child(title)) +} +fn nav( + label: &'static str, + selected: bool, + on_click: impl Fn(&ClickEvent, &mut Window, &mut gpui::App) + 'static, +) -> gpui::Stateful { + div() + .id(label) + .cursor_pointer() + .rounded_md() + .px_3() + .py_2() + .bg(rgb(if selected { 0x6850b5 } else { 0x28384d })) + .child(label) + .on_click(on_click) +} +fn button( + label: impl Into, + on_click: impl Fn(&ClickEvent, &mut Window, &mut gpui::App) + 'static, +) -> gpui::Stateful { + let label: SharedString = label.into(); + div() + .id(label.clone()) + .cursor_pointer() + .rounded_md() + .bg(rgb(0x2a3a50)) + .px_4() + .py_2() + .child(label) + .on_click(on_click) +} +fn setting_line( + label: &'static str, + value: String, + on_click: impl Fn(&ClickEvent, &mut Window, &mut gpui::App) + 'static, +) -> gpui::Div { + div() + .flex() + .justify_between() + .items_center() + .py_2() + .child(label) + .child(button(value, on_click)) +} +fn now_secs() -> u64 { + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap_or_default() + .as_secs() +} +fn send_usage_once(dir: &std::path::Path, settings: &Settings) { + if !settings.usage_stats { + return; + } + let Some((id, days)) = usage::finished_days(dir, &usage::day_of(now_secs())) else { + return; + }; + let cache = dir.join("usage-cache"); + let encoders: Vec<&str> = castbay_sender::available_encoders() + .iter() + .map(|c| match c { + Codec::Amf => "amf", + Codec::Nvenc => "nvenc", + Codec::Qsv => "qsv", + Codec::X264 => "x264", + }) + .collect(); + let height = castbay_capture::monitors() + .ok() + .and_then(|m| m.iter().filter_map(|s| usage::monitor_height(s)).max()); + let session = std::env::var("XDG_SESSION_TYPE").unwrap_or_else(|_| { + if cfg!(windows) { + "windows".into() + } else { + "other".into() + } + }); + for (day, counts) in days { + let body=serde_json::json!({ + "platform":"desktop","id":id,"day":day,"app":env!("CARGO_PKG_VERSION"), + "os":if cfg!(windows){"windows"}else{"linux"}, + "osVersion":if cfg!(windows){diagnostics::windows_version(&diagnostics::system_line()).unwrap_or_else(||"unknown".into())}else{diagnostics::linux_distribution(&std::fs::read_to_string("/etc/os-release").unwrap_or_default())}, + "arch":std::env::consts::ARCH,"session":match session.as_str(){"windows"=>"windows","wayland"=>"wayland","x11"=>"x11",_=>"other"}, + "screen":height.map(usage::screen_class).unwrap_or("unknown"),"lang":if settings.chinese(system_is_chinese()){"zh"}else{"en"}, + "encoders":encoders.iter().copied().collect::>(), + "counts":counts,"settings":{"encoder":settings.encoder,"language":settings.language,"updates":settings.check_updates,"errorReports":settings.error_reports} + }).to_string(); + match diagnostics::post("/api/stats", "application/json", &[], &body, &cache) { + Ok((code, _)) if (200..300).contains(&code) => { + usage::forget(dir, &day); + log_line(dir, &format!("usage summary sent for {day}")); + } + other => { + log_line(dir, &format!("usage summary failed: {other:?}")); + break; + } + } + } +} +fn system_is_chinese() -> bool { + let locale = std::env::var("LANG") + .unwrap_or_default() + .to_ascii_lowercase(); + locale.starts_with("zh") || locale.contains("_cn") || locale.contains("-cn") +} +fn version_cmp(a: &str, b: &str) -> std::cmp::Ordering { + let aa: Vec = a.split('.').map(|x| x.parse().unwrap_or(0)).collect(); + let bb: Vec = b.split('.').map(|x| x.parse().unwrap_or(0)).collect(); + for i in 0..aa.len().max(bb.len()) { + match aa + .get(i) + .copied() + .unwrap_or(0) + .cmp(&bb.get(i).copied().unwrap_or(0)) + { + std::cmp::Ordering::Equal => {} + other => return other, + } + } + std::cmp::Ordering::Equal +} +fn latest_version() -> Result, String> { + let urls = [ + "https://api.github.com/repos/weenas/castbay/releases?per_page=30", + "https://castbay.weenas.com/desktop/latest.json", + "https://cast.weenas.com/desktop/latest.json", + ]; + let mut newest: Option = None; + let mut failure = String::from("No update service responded"); + for url in urls { + let output = match std::process::Command::new("curl") + .args([ + "--fail", + "--silent", + "--show-error", + "--proto", + "=https", + "--connect-timeout", + "10", + "--max-time", + "30", + url, + ]) + .output() + { + Ok(output) => output, + Err(e) => { + failure = e.to_string(); + continue; + } + }; + if !output.status.success() { + failure = String::from_utf8_lossy(&output.stderr).trim().to_string(); + continue; + } + let data: serde_json::Value = match serde_json::from_slice(&output.stdout) { + Ok(data) => data, + Err(e) => { + failure = e.to_string(); + continue; + } + }; + let mut candidates = Vec::new(); + if let Some(list) = data.as_array() { + for item in list { + if item["draft"].as_bool().unwrap_or(false) { + continue; + } + if let Some(version) = item["tag_name"] + .as_str() + .and_then(|tag| tag.strip_prefix("desktop-v")) + { + if update::valid_version(version) { + candidates.push(version.to_string()); + } + } + } + } else if let Some(version) = data["version"].as_str() { + if update::valid_version(version) { + candidates.push(version.to_string()); + } + } + for version in candidates { + if newest + .as_deref() + .is_none_or(|current| version_cmp(&version, current).is_gt()) + { + newest = Some(version); + } + } + if newest.is_some() { + break; + } + } + let Some(version) = newest else { + return Err(failure); + }; + if version_cmp(&version, env!("CARGO_PKG_VERSION")).is_gt() { + Ok(Some(version)) + } else { + Ok(None) + } +} +fn log_line(dir: &std::path::Path, line: &str) { + use std::io::Write; + let _ = std::fs::create_dir_all(dir); + let path = dir.join("castbay-desktop.log"); + if std::fs::metadata(&path) + .map(|m| m.len() > 512 * 1024) + .unwrap_or(false) + { + let _ = std::fs::rename(&path, dir.join("castbay-desktop.old.log")); + } + if let Ok(mut f) = std::fs::OpenOptions::new() + .create(true) + .append(true) + .open(path) + { + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap_or_default() + .as_secs(); + let _ = writeln!(f, "{now} {line}"); + } +} +fn report_text( + dir: &std::path::Path, + settings: &Settings, + kind: &str, + extra: Option, +) -> String { + let mut head = format!( + "CastBay Desktop problem report, {}\nVersion: {}\nSystem: {}\nArchitecture: {}\nSettings: {} fps, {} Mbit/s, encoder {}, audio {}, language {}\nPaired receivers: {}\n", + usage::day_of( + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap_or_default() + .as_secs() + ), + env!("CARGO_PKG_VERSION"), + diagnostics::system_line(), + std::env::consts::ARCH, + settings.fps, + settings.bitrate_mbps, + settings.encoder, + if settings.send_audio { "on" } else { "off" }, + settings.language, + castbay_link::Pins::load(dir).list().len() + ); + if let Some(detail) = extra { + head.push_str(&format!("\n== {kind} ==\n{detail}\n")); + } + let home = std::env::var("HOME") + .or_else(|_| std::env::var("USERPROFILE")) + .unwrap_or_default(); + diagnostics::report_text(&head, &diagnostics::read_log(dir), &home) +} + +fn localized(zh: &'static str, en: &'static str, is_zh: bool) -> &'static str { + if is_zh { zh } else { en } +} +fn data_dir() -> PathBuf { + #[cfg(windows)] + { + return std::env::var_os("APPDATA") + .map(PathBuf::from) + .unwrap_or_else(std::env::temp_dir) + .join("com.weenas.castbay.desktop"); + } + #[cfg(target_os = "linux")] + { + return std::env::var_os("XDG_DATA_HOME") + .map(PathBuf::from) + .unwrap_or_else(|| { + PathBuf::from(std::env::var_os("HOME").unwrap_or_default()).join(".local/share") + }) + .join("com.weenas.castbay.desktop"); + } + #[allow(unreachable_code)] + std::env::temp_dir().join("com.weenas.castbay.desktop") +} +fn open_url(url: &str) { + #[cfg(target_os = "linux")] + { + let _ = std::process::Command::new("xdg-open").arg(url).spawn(); + } + #[cfg(windows)] + { + let _ = std::process::Command::new("rundll32") + .args(["url.dll,FileProtocolHandler", url]) + .spawn(); + } +} +fn open_path(path: &std::path::Path) { + #[cfg(target_os = "linux")] + { + let _ = std::process::Command::new("xdg-open").arg(path).spawn(); + } + #[cfg(windows)] + { + let _ = std::process::Command::new("explorer").arg(path).spawn(); + } +} + +fn build_tray() -> Option { + use tray_icon::{ + Icon, MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent, + menu::{Menu, MenuEvent, MenuItem, PredefinedMenuItem}, + }; + let menu = Menu::new(); + let open = MenuItem::with_id("open", "Open CastBay Desktop", true, None); + let settings = MenuItem::with_id("settings", "Settings", true, None); + let switch = MenuItem::with_id("switch", "Switch casting source…", true, None); + let about = MenuItem::with_id("about", "About", true, None); + let stop = MenuItem::with_id("stop", "Stop casting", true, None); + let quit = MenuItem::with_id("quit", "Quit", true, None); + menu.append_items(&[ + &open, + &settings, + &switch, + &about, + &PredefinedMenuItem::separator(), + &stop, + &PredefinedMenuItem::separator(), + &quit, + ]) + .ok()?; + let mut rgba = vec![0u8; 32 * 32 * 4]; + for y in 0..32 { + for x in 0..32 { + let i = (y * 32 + x) * 4; + let inside = (6..26).contains(&x) && (8..24).contains(&y); + if inside { + rgba[i..i + 4].copy_from_slice(&[140, 116, 232, 255]); + } + if inside + && ((y == 12 && (11..21).contains(&x)) + || (y == 15 && (9..23).contains(&x)) + || (y == 18 && (11..21).contains(&x))) + { + rgba[i..i + 4].copy_from_slice(&[255, 255, 255, 255]); + } + } + } + let icon = Icon::from_rgba(rgba, 32, 32).ok()?; + MenuEvent::set_event_handler(Some(|event: tray_icon::menu::MenuEvent| { + if let Ok(mut action) = TRAY_ACTION.lock() { + *action = Some(event.id.0); + } + })); + TrayIconEvent::set_event_handler(Some(|event| { + if let TrayIconEvent::Click { + button: MouseButton::Left, + button_state: MouseButtonState::Up, + .. + } = event + { + if let Ok(mut action) = TRAY_ACTION.lock() { + *action = Some("open".into()); + } + } + })); + TrayIconBuilder::new() + .with_tooltip("CastBay Desktop") + .with_menu(Box::new(menu)) + .with_icon(icon) + .build() + .ok() +} + +fn ensure_single_instance() -> bool { + const ADDRESS: &str = "127.0.0.1:51833"; + match TcpListener::bind(ADDRESS) { + Ok(listener) => { + let _ = listener.set_nonblocking(true); + std::thread::spawn(move || { + loop { + match listener.accept() { + Ok((mut stream, _)) => { + let mut buffer = [0u8; 64]; + if stream + .read(&mut buffer) + .is_ok_and(|n| &buffer[..n] == b"castbay-activate\n") + { + ACTIVATE_REQUESTED.store(true, Ordering::SeqCst); + } + } + Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => { + std::thread::sleep(Duration::from_millis(250)) + } + Err(_) => break, + } + } + }); + true + } + Err(_) => { + if let Ok(mut stream) = TcpStream::connect(ADDRESS) { + let _ = stream.write_all(b"castbay-activate\n"); + } + false + } + } +} + +fn main() { + if !ensure_single_instance() { + return; + } + let _tray = build_tray(); + application().run(|cx: &mut App| { + let bounds = Bounds::centered(None, size(px(900.), px(720.)), cx); + let minimized = std::env::args().any(|arg| arg == "--minimized"); + cx.open_window( + WindowOptions { + window_bounds: Some(WindowBounds::Windowed(bounds)), + ..Default::default() + }, + move |window, cx| { + window.set_window_title("CastBay Desktop"); + let app = cx.new(CastBay::new); + let handle = window.window_handle(); + app.update(cx, |app, _| app.window_handle = Some(handle)); + let app_for_close = app.downgrade(); + window.on_window_should_close(cx, move |window, cx| { + let casting = app_for_close + .read_with(cx, |app, _| { + app.runtime + .lock() + .map(|runtime| runtime.stopper.is_some()) + .unwrap_or(false) + }) + .unwrap_or(false); + if casting { + window.minimize_window(); + false + } else { + true + } + }); + if minimized { + window.minimize_window(); + } + app + }, + ) + .expect("open CastBay"); + cx.activate(true); + }); +} diff --git a/desktop/app/src/crash.rs b/desktop/app/src/crash.rs index e030981..d12abca 100644 --- a/desktop/app/src/crash.rs +++ b/desktop/app/src/crash.rs @@ -26,9 +26,15 @@ pub fn install_hook(dir: PathBuf) { std::panic::set_hook(Box::new(move |info| { let backtrace = std::backtrace::Backtrace::force_capture(); let thread = std::thread::current(); - let text = format!("panic in thread {}: {info}\n{backtrace}", thread.name().unwrap_or("?")); + let text = format!( + "panic in thread {}: {info}\n{backtrace}", + thread.name().unwrap_or("?") + ); let _ = std::fs::create_dir_all(&dir); - let _ = std::fs::write(dir.join(CRASH), &text.as_bytes()[..text.len().min(MAX_CRASH_BYTES)]); + let _ = std::fs::write( + dir.join(CRASH), + &text.as_bytes()[..text.len().min(MAX_CRASH_BYTES)], + ); previous(info); })); } @@ -45,7 +51,9 @@ pub fn mark_casting(dir: &Path, on: bool) { /// What the previous run left, and then nothing: the files are removed, the text is the caller's. pub fn take(dir: &Path) -> Option { - let panic = std::fs::read(dir.join(CRASH)).ok().map(|b| String::from_utf8_lossy(&b).into_owned()); + let panic = std::fs::read(dir.join(CRASH)) + .ok() + .map(|b| String::from_utf8_lossy(&b).into_owned()); let unfinished = dir.join(MARKER).exists(); let _ = std::fs::remove_file(dir.join(CRASH)); let _ = std::fs::remove_file(dir.join(MARKER)); @@ -96,7 +104,10 @@ mod tests { std::fs::write(dir.join(CRASH), "panic in thread main: boom").unwrap(); mark_casting(&dir, true); let pending = take(&dir).unwrap(); - assert_eq!((pending.kind, pending.text.as_str()), ("panic", "panic in thread main: boom")); + assert_eq!( + (pending.kind, pending.text.as_str()), + ("panic", "panic in thread main: boom") + ); assert_eq!(take(&dir), None); let _ = std::fs::remove_dir_all(dir); } diff --git a/desktop/app/src/diagnostics.rs b/desktop/app/src/diagnostics.rs index e8e39ed..81805e8 100644 --- a/desktop/app/src/diagnostics.rs +++ b/desktop/app/src/diagnostics.rs @@ -40,7 +40,11 @@ pub fn scrub(text: &str, home: &str) -> String { if home.len() > 3 { out = replace_ignoring_case(&out, home, "~"); // A path may also be written with the other kind of slash. - let other = if home.contains('\\') { home.replace('\\', "/") } else { home.replace('/', "\\") }; + let other = if home.contains('\\') { + home.replace('\\', "/") + } else { + home.replace('/', "\\") + }; out = replace_ignoring_case(&out, &other, "~"); } out = hide_addresses(&out); @@ -74,7 +78,10 @@ fn hide_addresses(text: &str) -> String { // A full stop that ends a sentence is not part of the address. let body = run.trim_end_matches('.'); let parts: Vec<&str> = body.split('.').collect(); - let address = parts.len() == 4 && parts.iter().all(|p| !p.is_empty() && p.len() <= 3 && p.parse::().is_ok_and(|n| n <= 255)); + let address = parts.len() == 4 + && parts.iter().all(|p| { + !p.is_empty() && p.len() <= 3 && p.parse::().is_ok_and(|n| n <= 255) + }); if address { out.push_str(""); out.push_str(&run[body.len()..]); @@ -139,7 +146,12 @@ pub fn read_log(dir: &Path) -> Vec { ["castbay-desktop.old.log", "castbay-desktop.log"] .iter() .filter_map(|name| std::fs::read(dir.join(name)).ok()) - .flat_map(|bytes| String::from_utf8_lossy(&bytes).lines().map(str::to_string).collect::>()) + .flat_map(|bytes| { + String::from_utf8_lossy(&bytes) + .lines() + .map(str::to_string) + .collect::>() + }) .collect() } @@ -147,7 +159,10 @@ pub fn read_log(dir: &Path) -> Vec { pub fn report_text(head: &str, log: &[String], home: &str) -> String { let head = scrub(head, home); let budget = MAX_CHARS.saturating_sub(head.len() + 64); - format!("{head}\n== Log (oldest first) ==\n{}\n", scrub(&newest(log, budget), home)) + format!( + "{head}\n== Log (oldest first) ==\n{}\n", + scrub(&newest(log, budget), home) + ) } /// This computer's operating system, in a line. @@ -155,17 +170,30 @@ pub fn system_line() -> String { #[cfg(windows)] { use std::os::windows::process::CommandExt; - let out = Command::new("cmd").args(["/c", "ver"]).creation_flags(0x0800_0000).output(); - out.ok().map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()).filter(|s| !s.is_empty()).unwrap_or_else(|| "Windows".into()) + let out = Command::new("cmd") + .args(["/c", "ver"]) + .creation_flags(0x0800_0000) + .output(); + out.ok() + .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()) + .filter(|s| !s.is_empty()) + .unwrap_or_else(|| "Windows".into()) } #[cfg(not(windows))] { let release = std::fs::read_to_string("/etc/os-release").unwrap_or_default(); - let name = release.lines().find_map(|l| l.strip_prefix("PRETTY_NAME=")).map(|v| v.trim_matches('"').to_string()).unwrap_or_else(|| "Linux".into()); + let name = release + .lines() + .find_map(|l| l.strip_prefix("PRETTY_NAME=")) + .map(|v| v.trim_matches('"').to_string()) + .unwrap_or_else(|| "Linux".into()); let kernel = std::fs::read_to_string("/proc/sys/kernel/osrelease").unwrap_or_default(); let session = std::env::var("XDG_SESSION_TYPE").unwrap_or_default(); let desktop = std::env::var("XDG_CURRENT_DESKTOP").unwrap_or_default(); - format!("{name}, kernel {}, session {session}, desktop {desktop}", kernel.trim()) + format!( + "{name}, kernel {}, session {session}, desktop {desktop}", + kernel.trim() + ) } } @@ -177,7 +205,13 @@ fn address(base: &str, path: &str) -> String { /// POSTs `text` to `path` of the website, and if it cannot be reached, of its relay: the status /// and the answer. Whatever answer comes (an error status too) is final; only a failure to reach /// an address tries the next one. `headers` are whole lines (`Name: value`). -pub fn post(path: &str, content_type: &str, headers: &[String], text: &str, dir: &Path) -> Result<(u16, String), Refusal> { +pub fn post( + path: &str, + content_type: &str, + headers: &[String], + text: &str, + dir: &Path, +) -> Result<(u16, String), Refusal> { std::fs::create_dir_all(dir).map_err(|e| Refusal::Network(e.to_string()))?; let file = dir.join("post.txt"); std::fs::write(&file, text).map_err(|e| Refusal::Network(e.to_string()))?; @@ -185,12 +219,27 @@ pub fn post(path: &str, content_type: &str, headers: &[String], text: &str, dir: for base in [SITE, RELAY] { let mut command = Command::new("curl"); command - .args(["--silent", "--show-error", "--proto", "=https", "--connect-timeout", "15", "--max-time", "90", "--request", "POST"]) + .args([ + "--silent", + "--show-error", + "--proto", + "=https", + "--connect-timeout", + "15", + "--max-time", + "90", + "--request", + "POST", + ]) .args(["--header", &format!("Content-Type: {content_type}")]); for header in headers { command.args(["--header", header]); } - command.arg("--data-binary").arg(format!("@{}", file.display())).args(["--write-out", "\n%{http_code}"]).arg(address(base, path)); + command + .arg("--data-binary") + .arg(format!("@{}", file.display())) + .args(["--write-out", "\n%{http_code}"]) + .arg(address(base, path)); #[cfg(windows)] { use std::os::windows::process::CommandExt; @@ -204,8 +253,17 @@ pub fn post(path: &str, content_type: &str, headers: &[String], text: &str, dir: } }; if !output.status.success() { - let line = String::from_utf8_lossy(&output.stderr).lines().last().unwrap_or("").trim().to_string(); - last = Refusal::Network(if line.is_empty() { output.status.to_string() } else { line }); + let line = String::from_utf8_lossy(&output.stderr) + .lines() + .last() + .unwrap_or("") + .trim() + .to_string(); + last = Refusal::Network(if line.is_empty() { + output.status.to_string() + } else { + line + }); continue; } let _ = std::fs::remove_file(&file); @@ -223,8 +281,18 @@ pub fn post(path: &str, content_type: &str, headers: &[String], text: &str, dir: /// Sends a problem report and returns its ID. `kind` is `manual`, `crash` or `failure` (what the /// website files it under). pub fn upload(text: &str, version: &str, kind: &str, dir: &Path) -> Result { - let headers = [format!("X-CastBay-Version: {version}"), format!("X-CastBay-Report: {kind}"), "X-CastBay-App: desktop".to_string()]; - match post("/api/reports", "text/plain; charset=utf-8", &headers, text, dir)? { + let headers = [ + format!("X-CastBay-Version: {version}"), + format!("X-CastBay-Report: {kind}"), + "X-CastBay-App: desktop".to_string(), + ]; + match post( + "/api/reports", + "text/plain; charset=utf-8", + &headers, + text, + dir, + )? { (201, body) => parse_id(&body).ok_or_else(|| Refusal::Network("unreadable answer".into())), (code, _) => Err(Refusal::Status(code)), } @@ -234,7 +302,11 @@ pub fn upload(text: &str, version: &str, kind: &str, dir: &Path) -> Result Option { let v = line.split("Version ").nth(1)?.trim_end_matches(']').trim(); let parts: Vec<&str> = v.split('.').take(3).collect(); - (parts.len() == 3 && parts.iter().all(|p| !p.is_empty() && p.bytes().all(|b| b.is_ascii_digit()))).then(|| parts.join(".")) + (parts.len() == 3 + && parts + .iter() + .all(|p| !p.is_empty() && p.bytes().all(|b| b.is_ascii_digit()))) + .then(|| parts.join(".")) } /// A Linux distribution from /etc/os-release, as "ubuntu 26.04" (just the ID when it has no version). @@ -244,7 +316,12 @@ pub fn linux_distribution(os_release: &str) -> String { .lines() .find_map(|l| l.strip_prefix(key)) .map(|v| v.trim().trim_matches('"').to_ascii_lowercase()) - .filter(|v| !v.is_empty() && v.len() <= 20 && v.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'.' || b == b'_' || b == b'-')) + .filter(|v| { + !v.is_empty() + && v.len() <= 20 + && v.bytes() + .all(|b| b.is_ascii_alphanumeric() || b == b'.' || b == b'_' || b == b'-') + }) }; match (value("ID="), value("VERSION_ID=")) { (Some(id), Some(version)) => format!("{id} {version}"), @@ -255,8 +332,14 @@ pub fn linux_distribution(os_release: &str) -> String { /// The ID in the website's answer (`{"id":"CB-7K3F9Q"}`), if it has the shape of one. fn parse_id(body: &str) -> Option { - let id = serde_json::from_str::(body).ok()?["id"].as_str()?.to_string(); - let valid = id.len() == 9 && id.starts_with("CB-") && id[3..].bytes().all(|b| b.is_ascii_digit() || b.is_ascii_uppercase()); + let id = serde_json::from_str::(body).ok()?["id"] + .as_str()? + .to_string(); + let valid = id.len() == 9 + && id.starts_with("CB-") + && id[3..] + .bytes() + .all(|b| b.is_ascii_digit() || b.is_ascii_uppercase()); valid.then_some(id) } @@ -266,16 +349,28 @@ mod tests { #[test] fn addresses_go_but_versions_stay() { - assert_eq!(scrub("start: 10.1.1.168:33339 monitor", ""), "start: :33339 monitor"); + assert_eq!( + scrub("start: 10.1.1.168:33339 monitor", ""), + "start: :33339 monitor" + ); assert_eq!(scrub("a 192.168.0.1, b 8.8.8.8.", ""), "a , b ."); - assert_eq!(scrub("Version 10.0.19045.5555 and 0.1.3", ""), "Version 10.0.19045.5555 and 0.1.3"); - assert_eq!(scrub("300.1.1.1 is not an address", ""), "300.1.1.1 is not an address"); + assert_eq!( + scrub("Version 10.0.19045.5555 and 0.1.3", ""), + "Version 10.0.19045.5555 and 0.1.3" + ); + assert_eq!( + scrub("300.1.1.1 is not an address", ""), + "300.1.1.1 is not an address" + ); } #[test] fn receiver_names_go() { let line = r#"Casting { receiver: "Anna's TV", width: 1728 } and receiver: "X" again"#; - assert_eq!(scrub(line, ""), r#"Casting { receiver: "", width: 1728 } and receiver: "" again"#); + assert_eq!( + scrub(line, ""), + r#"Casting { receiver: "", width: 1728 } and receiver: "" again"# + ); // Unfinished: what follows the key goes on as it is, no panic. assert_eq!(scrub("receiver: \"half", ""), "receiver: \"half"); } @@ -283,7 +378,10 @@ mod tests { #[test] fn the_home_folder_goes_in_either_spelling_and_case() { let home = r"C:\Users\Anna"; - assert_eq!(scrub(r"C:\Users\Anna\AppData\x and c:\users\anna\y", home), r"~\AppData\x and ~\y"); + assert_eq!( + scrub(r"C:\Users\Anna\AppData\x and c:\users\anna\y", home), + r"~\AppData\x and ~\y" + ); assert_eq!(scrub("C:/Users/Anna/AppData", home), "~/AppData"); assert_eq!(scrub("/home/anna/.cache/x", "/home/anna"), "~/.cache/x"); // A home folder too short to be one is not looked for (it would match everywhere). @@ -293,14 +391,24 @@ mod tests { #[test] fn the_newest_lines_that_fit() { let lines: Vec = (1..=5).map(|n| format!("line {n}")).collect(); - assert_eq!(newest(&lines, 100), "line 1\nline 2\nline 3\nline 4\nline 5"); + assert_eq!( + newest(&lines, 100), + "line 1\nline 2\nline 3\nline 4\nline 5" + ); assert_eq!(newest(&lines, 21), "line 3\nline 4\nline 5"); assert_eq!(newest(&lines, 3), ""); } #[test] fn a_report_stays_within_the_limit_and_is_scrubbed() { - let log: Vec = (0..20_000).map(|n| format!("2026-10-29 start: 10.1.1.{}:3 receiver: \"TV {n}\"", n % 250)).collect(); + let log: Vec = (0..20_000) + .map(|n| { + format!( + "2026-10-29 start: 10.1.1.{}:3 receiver: \"TV {n}\"", + n % 250 + ) + }) + .collect(); let text = report_text("CastBay Desktop 0.1.4\nSystem: Test", &log, ""); assert!(text.len() <= MAX_CHARS, "{}", text.len()); assert!(text.contains("") && text.contains("") && !text.contains("10.1.1.")); @@ -309,16 +417,31 @@ mod tests { #[test] fn requests_go_to_the_right_addresses() { - assert_eq!(address(SITE, "/api/reports"), "https://castbay.weenas.com/api/reports"); - assert_eq!(address(RELAY, "/api/stats"), "https://cast.weenas.com/api/stats"); - assert_eq!(address(SITE, "/api/stats/delete"), "https://castbay.weenas.com/api/stats/delete"); + assert_eq!( + address(SITE, "/api/reports"), + "https://castbay.weenas.com/api/reports" + ); + assert_eq!( + address(RELAY, "/api/stats"), + "https://cast.weenas.com/api/stats" + ); + assert_eq!( + address(SITE, "/api/stats/delete"), + "https://castbay.weenas.com/api/stats/delete" + ); } #[test] fn the_system_is_named_coarsely() { - assert_eq!(windows_version("Microsoft Windows [Version 10.0.19045.5555]").as_deref(), Some("10.0.19045")); + assert_eq!( + windows_version("Microsoft Windows [Version 10.0.19045.5555]").as_deref(), + Some("10.0.19045") + ); assert_eq!(windows_version("Windows"), None); - assert_eq!(linux_distribution("NAME=\"Ubuntu\"\nID=ubuntu\nVERSION_ID=\"26.04\"\n"), "ubuntu 26.04"); + assert_eq!( + linux_distribution("NAME=\"Ubuntu\"\nID=ubuntu\nVERSION_ID=\"26.04\"\n"), + "ubuntu 26.04" + ); assert_eq!(linux_distribution("ID=arch\n"), "arch"); assert_eq!(linux_distribution("PRETTY_NAME=x"), "linux"); // Anything odd is not passed on. @@ -327,8 +450,17 @@ mod tests { #[test] fn the_answer_must_have_the_shape_of_an_id() { - assert_eq!(parse_id(r#"{"id":"CB-7K3F9Q"}"#).as_deref(), Some("CB-7K3F9Q")); - for bad in [r#"{"id":"CB-7k3f9q"}"#, r#"{"id":"XX-7K3F9Q"}"#, r#"{"id":"CB-7K3F9Q1"}"#, r#"{"error":"busy"}"#, "not json"] { + assert_eq!( + parse_id(r#"{"id":"CB-7K3F9Q"}"#).as_deref(), + Some("CB-7K3F9Q") + ); + for bad in [ + r#"{"id":"CB-7k3f9q"}"#, + r#"{"id":"XX-7K3F9Q"}"#, + r#"{"id":"CB-7K3F9Q1"}"#, + r#"{"error":"busy"}"#, + "not json", + ] { assert_eq!(parse_id(bad), None, "{bad}"); } } diff --git a/desktop/app/src/settings.rs b/desktop/app/src/settings.rs index 304b9fb..37a4a57 100644 --- a/desktop/app/src/settings.rs +++ b/desktop/app/src/settings.rs @@ -79,7 +79,10 @@ const KINDS: [&str; 2] = ["monitor", "window"]; impl Settings { /// What is saved; defaults for a missing, unreadable or damaged file (and for fields it lacks). pub fn load(dir: &Path) -> Settings { - let Some(value) = std::fs::read(dir.join("settings.json")).ok().and_then(|b| serde_json::from_slice::(&b).ok()) else { + let Some(value) = std::fs::read(dir.join("settings.json")) + .ok() + .and_then(|b| serde_json::from_slice::(&b).ok()) + else { return Settings::default(); }; let mut settings: Settings = serde_json::from_value(value.clone()).unwrap_or_default(); @@ -103,7 +106,11 @@ impl Settings { pub fn save(&self, dir: &Path) -> Result<(), String> { std::fs::create_dir_all(dir).map_err(|e| e.to_string())?; let temporary = dir.join("settings.json.tmp"); - std::fs::write(&temporary, serde_json::to_vec_pretty(self).expect("settings serialise")).map_err(|e| e.to_string())?; + std::fs::write( + &temporary, + serde_json::to_vec_pretty(self).expect("settings serialise"), + ) + .map_err(|e| e.to_string())?; std::fs::rename(&temporary, dir.join("settings.json")).map_err(|e| e.to_string()) } @@ -117,7 +124,15 @@ impl Settings { for (key, value) in object { match key.as_str() { "bitrate_mbps" => next.bitrate_mbps = number(value, BITRATE_MBPS, key)?, - "fps" => next.fps = number(value, 30..=60, key).and_then(|n| if FPS.contains(&n) { Ok(n) } else { Err(format!("{key}: 30 or 60")) })?, + "fps" => { + next.fps = number(value, 30..=60, key).and_then(|n| { + if FPS.contains(&n) { + Ok(n) + } else { + Err(format!("{key}: 30 or 60")) + } + })? + } // What the page kept in its own storage before settings.json (three fixed qualities). "quality" => match value.as_str() { Some(q @ ("saver" | "balanced" | "smooth")) => next.use_quality(q), @@ -202,12 +217,18 @@ fn choice(value: &Value, allowed: &[&str], key: &str) -> Result fn number(value: &Value, allowed: std::ops::RangeInclusive, key: &str) -> Result { match value.as_u64() { Some(n) if allowed.contains(&(n as u32)) && n <= u32::MAX as u64 => Ok(n as u32), - _ => Err(format!("{key}: a whole number from {} to {}", allowed.start(), allowed.end())), + _ => Err(format!( + "{key}: a whole number from {} to {}", + allowed.start(), + allowed.end() + )), } } fn boolean(value: &Value, key: &str) -> Result { - value.as_bool().ok_or_else(|| format!("{key}: must be true or false")) + value + .as_bool() + .ok_or_else(|| format!("{key}: must be true or false")) } fn text(value: &Value, key: &str) -> Result { @@ -223,7 +244,8 @@ mod tests { use serde_json::json; fn temp(name: &str) -> std::path::PathBuf { - let dir = std::env::temp_dir().join(format!("castbay-settings-{name}-{}", std::process::id())); + let dir = + std::env::temp_dir().join(format!("castbay-settings-{name}-{}", std::process::id())); let _ = std::fs::remove_dir_all(&dir); dir } @@ -232,7 +254,10 @@ mod tests { fn a_new_install_gets_the_defaults() { let s = Settings::load(&temp("none")); assert_eq!(s, Settings::default()); - assert_eq!((s.send_audio, s.encoder.as_str(), s.error_reports), (true, "auto", false)); + assert_eq!( + (s.send_audio, s.encoder.as_str(), s.error_reports), + (true, "auto", false) + ); assert_eq!(s.quality_params(), (30, 8_000_000)); } @@ -252,7 +277,15 @@ mod tests { fn a_bad_value_changes_nothing() { let mut s = Settings::default(); assert!(s.apply(&json!({"fps": 60, "encoder": "magic"})).is_err()); - for bad in [json!({"fps": 45}), json!({"fps": "60"}), json!({"bitrate_mbps": 1}), json!({"bitrate_mbps": 21}), json!({"bitrate_mbps": 7.5}), json!({"bitrate_mbps": -3}), json!({"quality": "best"})] { + for bad in [ + json!({"fps": 45}), + json!({"fps": "60"}), + json!({"bitrate_mbps": 1}), + json!({"bitrate_mbps": 21}), + json!({"bitrate_mbps": 7.5}), + json!({"bitrate_mbps": -3}), + json!({"quality": "best"}), + ] { assert!(s.apply(&bad).is_err(), "{bad}"); } assert_eq!(s, Settings::default()); @@ -265,7 +298,8 @@ mod tests { #[test] fn unknown_fields_are_ignored_and_a_patch_changes_only_what_it_names() { let mut s = Settings::default(); - s.apply(&json!({"language": "zh", "from_the_future": 1})).unwrap(); + s.apply(&json!({"language": "zh", "from_the_future": 1})) + .unwrap(); assert_eq!(s.language, "zh"); assert_eq!((s.fps, s.bitrate_mbps), (30, 8)); } @@ -279,7 +313,10 @@ mod tests { // A file from a version with fewer fields keeps what it has. std::fs::write(dir.join("settings.json"), br#"{"language": "en"}"#).unwrap(); let s = Settings::load(&dir); - assert_eq!((s.language.as_str(), s.send_audio, s.quality_params()), ("en", true, (30, 8_000_000))); + assert_eq!( + (s.language.as_str(), s.send_audio, s.quality_params()), + ("en", true, (30, 8_000_000)) + ); let _ = std::fs::remove_dir_all(dir); } @@ -287,15 +324,32 @@ mod tests { fn the_three_qualities_of_earlier_versions_become_a_rate_and_a_bitrate() { let dir = temp("qualities"); std::fs::create_dir_all(&dir).unwrap(); - for (quality, expected) in [("saver", (30, 4_000_000)), ("balanced", (30, 8_000_000)), ("smooth", (60, 10_000_000)), ("unheard-of", (30, 8_000_000))] { - std::fs::write(dir.join("settings.json"), format!(r#"{{"quality": "{quality}"}}"#)).unwrap(); + for (quality, expected) in [ + ("saver", (30, 4_000_000)), + ("balanced", (30, 8_000_000)), + ("smooth", (60, 10_000_000)), + ("unheard-of", (30, 8_000_000)), + ] { + std::fs::write( + dir.join("settings.json"), + format!(r#"{{"quality": "{quality}"}}"#), + ) + .unwrap(); assert_eq!(Settings::load(&dir).quality_params(), expected, "{quality}"); } // Once the two settings exist the old one is not looked at again. - std::fs::write(dir.join("settings.json"), br#"{"quality": "smooth", "bitrate_mbps": 6, "fps": 30}"#).unwrap(); + std::fs::write( + dir.join("settings.json"), + br#"{"quality": "smooth", "bitrate_mbps": 6, "fps": 30}"#, + ) + .unwrap(); assert_eq!(Settings::load(&dir).quality_params(), (30, 6_000_000)); // A hand-edited value out of range falls back to the default. - std::fs::write(dir.join("settings.json"), br#"{"bitrate_mbps": 500, "fps": 144}"#).unwrap(); + std::fs::write( + dir.join("settings.json"), + br#"{"bitrate_mbps": 500, "fps": 144}"#, + ) + .unwrap(); assert_eq!(Settings::load(&dir).quality_params(), (30, 8_000_000)); // The page's old storage can still hand over a quality. let mut s = Settings::default(); @@ -311,9 +365,34 @@ mod tests { "check_updates": false, "usage_stats": true, "last_receiver": "tv-1", "source_kind": "window", "source_window": "Notes", "welcome_done": true})).unwrap(); s.restore_defaults(); let fresh = Settings::default(); - assert_eq!((s.fps, s.bitrate_mbps, s.encoder.as_str(), s.language.as_str()), (fresh.fps, fresh.bitrate_mbps, "auto", "auto")); - assert_eq!((s.send_audio, s.error_reports, s.check_updates, s.usage_stats, s.minimize_on_cast), (true, false, true, false, true)); - assert_eq!((s.last_receiver.as_str(), s.source_kind.as_str(), s.source_window.as_str(), s.welcome_done), ("tv-1", "window", "Notes", true)); + assert_eq!( + ( + s.fps, + s.bitrate_mbps, + s.encoder.as_str(), + s.language.as_str() + ), + (fresh.fps, fresh.bitrate_mbps, "auto", "auto") + ); + assert_eq!( + ( + s.send_audio, + s.error_reports, + s.check_updates, + s.usage_stats, + s.minimize_on_cast + ), + (true, false, true, false, true) + ); + assert_eq!( + ( + s.last_receiver.as_str(), + s.source_kind.as_str(), + s.source_window.as_str(), + s.welcome_done + ), + ("tv-1", "window", "Notes", true) + ); } #[test] @@ -326,7 +405,10 @@ mod tests { assert!(s.apply(&json!({"video_format": 265})).is_err()); assert_eq!(s.video_format, "h265", "a refused value changes nothing"); s.restore_defaults(); - assert_eq!(s.video_format, "h264", "it is how the program behaves, so it goes back"); + assert_eq!( + s.video_format, "h264", + "it is how the program behaves, so it goes back" + ); } #[test] @@ -335,11 +417,17 @@ mod tests { assert_eq!(s.ignored_update, ""); s.apply(&json!({"ignored_update": "0.1.4"})).unwrap(); assert_eq!(s.ignored_update, "0.1.4"); - assert!(s.apply(&json!({"ignored_update": "https://evil.example/"})).is_err()); + assert!( + s.apply(&json!({"ignored_update": "https://evil.example/"})) + .is_err() + ); assert!(s.apply(&json!({"ignored_update": 4})).is_err()); assert_eq!(s.ignored_update, "0.1.4", "a refused value changes nothing"); s.restore_defaults(); - assert_eq!(s.ignored_update, "0.1.4", "it is what the person decided, not how the program behaves"); + assert_eq!( + s.ignored_update, "0.1.4", + "it is what the person decided, not how the program behaves" + ); s.apply(&json!({"ignored_update": ""})).unwrap(); assert_eq!(s.ignored_update, ""); } diff --git a/desktop/app/src/update.rs b/desktop/app/src/update.rs index c333ed8..98ea2a5 100644 --- a/desktop/app/src/update.rs +++ b/desktop/app/src/update.rs @@ -26,15 +26,22 @@ const MAX_BYTES: u64 = 300_000_000; pub fn valid_version(v: &str) -> bool { let (core, suffix) = v.split_once('-').map_or((v, ""), |(a, b)| (a, b)); !core.is_empty() - && core.split('.').all(|p| !p.is_empty() && p.bytes().all(|b| b.is_ascii_digit())) - && suffix.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'.') + && core + .split('.') + .all(|p| !p.is_empty() && p.bytes().all(|b| b.is_ascii_digit())) + && suffix + .bytes() + .all(|b| b.is_ascii_alphanumeric() || b == b'.') } /// The release file this system installs: the .msi in the person's language on Windows, the .deb /// of this architecture on Linux. pub fn asset_name(version: &str, windows: bool, zh: bool, arch: &str) -> String { if windows { - format!("CastBay-Desktop-{version}-windows-x64-{}.msi", if zh { "zh-CN" } else { "en-US" }) + format!( + "CastBay-Desktop-{version}-windows-x64-{}.msi", + if zh { "zh-CN" } else { "en-US" } + ) } else { format!("castbay-desktop_{version}_{arch}.deb") } @@ -51,7 +58,11 @@ pub fn find_asset(release: &Value, name: &str, version: &str) -> Result<(String, if url != format!("{DOWNLOADS}{version}/{name}") { return Err("the download address is not this project's".into()); } - let digest = asset["digest"].as_str().and_then(|d| d.strip_prefix("sha256:")).unwrap_or_default().to_ascii_lowercase(); + let digest = asset["digest"] + .as_str() + .and_then(|d| d.strip_prefix("sha256:")) + .unwrap_or_default() + .to_ascii_lowercase(); if digest.len() != 64 || !digest.bytes().all(|b| b.is_ascii_hexdigit()) { return Err("the release lists no SHA-256 for the file".into()); } @@ -70,12 +81,19 @@ fn sha256_file(path: &Path) -> Result { } hasher.update(&buf[..n]); } - Ok(hasher.finalize().iter().map(|b| format!("{b:02x}")).collect()) + Ok(hasher + .finalize() + .iter() + .map(|b| format!("{b:02x}")) + .collect()) } /// Where a release file can be had: the website, then GitHub. fn file_urls(version: &str, name: &str) -> [String; 2] { - [format!("{SITE}{version}/{name}"), format!("{DOWNLOADS}{version}/{name}")] + [ + format!("{SITE}{version}/{name}"), + format!("{DOWNLOADS}{version}/{name}"), + ] } /// The SHA-256 (lower case hex) of the file `name` in the website's description of the release @@ -84,7 +102,10 @@ pub fn site_digest(description: &Value, name: &str, version: &str) -> Result Result Command { let mut c = Command::new("curl"); - c.args(["--fail", "--silent", "--show-error", "--location", "--proto", "=https", "--proto-redir", "=https", "--connect-timeout", "10", "--max-time", "900"]); + c.args([ + "--fail", + "--silent", + "--show-error", + "--location", + "--proto", + "=https", + "--proto-redir", + "=https", + "--connect-timeout", + "10", + "--max-time", + "900", + ]); #[cfg(windows)] { use std::os::windows::process::CommandExt; @@ -105,7 +139,14 @@ fn curl() -> Command { fn describe(output: &std::process::Output) -> String { let text = String::from_utf8_lossy(&output.stderr); let line = text.lines().last().unwrap_or("").trim(); - format!("curl: {}", if line.is_empty() { output.status.to_string() } else { line.to_string() }) + format!( + "curl: {}", + if line.is_empty() { + output.status.to_string() + } else { + line.to_string() + } + ) } /// The file's SHA-256 from GitHub's description of the release, else the website's, else its relay's. @@ -117,7 +158,10 @@ fn digest_of(name: &str, version: &str) -> Result { ]; let mut failure = String::new(); for (url, site) in sources { - let out = curl().args(["--header", "Accept: application/vnd.github+json", &url]).output().map_err(|e| format!("curl: {e}"))?; + let out = curl() + .args(["--header", "Accept: application/vnd.github+json", &url]) + .output() + .map_err(|e| format!("curl: {e}"))?; if !out.status.success() { failure = describe(&out); continue; @@ -126,7 +170,11 @@ fn digest_of(name: &str, version: &str) -> Result { failure = "the release description is not JSON".into(); continue; }; - match if site { site_digest(&json, name, version) } else { find_asset(&json, name, version).map(|(_, d)| d) } { + match if site { + site_digest(&json, name, version) + } else { + find_asset(&json, name, version).map(|(_, d)| d) + } { Ok(digest) => return Ok(digest), Err(e) => failure = e, } @@ -139,7 +187,11 @@ pub fn fetch(version: &str, windows: bool, zh: bool, dir: &Path) -> Result Result Result<(), String> { use std::os::windows::process::CommandExt; let (msi, exe) = (msi.to_string_lossy(), exe.to_string_lossy()); // The two paths go into one command line of cmd.exe, where these would mean something else. - if msi.chars().chain(exe.chars()).any(|c| matches!(c, '"' | '%' | '&' | '^' | '!' | '\r' | '\n')) { + if msi + .chars() + .chain(exe.chars()) + .any(|c| matches!(c, '"' | '%' | '&' | '^' | '!' | '\r' | '\n')) + { return Err("a path holds a character the installer line cannot carry".into()); } // 0x08 DETACHED_PROCESS | 0x200 CREATE_NEW_PROCESS_GROUP | 0x0800_0000 CREATE_NO_WINDOW: it outlives this program. Command::new("cmd") - .raw_arg(format!("/c msiexec /i \"{msi}\" /passive /norestart & start \"\" \"{exe}\"")) + .raw_arg(format!( + "/c msiexec /i \"{msi}\" /passive /norestart & start \"\" \"{exe}\"" + )) .creation_flags(0x08 | 0x200 | 0x0800_0000) .spawn() .map_err(|e| e.to_string())?; @@ -203,7 +266,14 @@ pub enum Installed { #[cfg(not(windows))] fn install_command(deb: &Path) -> Command { let mut c = Command::new("pkexec"); - c.args(["/usr/bin/env", "DEBIAN_FRONTEND=noninteractive", "/usr/bin/apt-get", "install", "-y"]).arg(deb); + c.args([ + "/usr/bin/env", + "DEBIAN_FRONTEND=noninteractive", + "/usr/bin/apt-get", + "install", + "-y", + ]) + .arg(deb); c } @@ -223,8 +293,20 @@ pub fn install(deb: &Path) -> Result { Some(127) => Ok(Installed::NoPrompt), _ => { let text = String::from_utf8_lossy(&out.stderr); - let line = text.lines().rev().find(|l| !l.trim().is_empty()).unwrap_or("").trim(); - Err(format!("apt-get: {}", if line.is_empty() { out.status.to_string() } else { line.to_string() })) + let line = text + .lines() + .rev() + .find(|l| !l.trim().is_empty()) + .unwrap_or("") + .trim(); + Err(format!( + "apt-get: {}", + if line.is_empty() { + out.status.to_string() + } else { + line.to_string() + } + )) } } } @@ -256,16 +338,35 @@ mod tests { fn versions_are_plain() { assert!(valid_version("0.1.3")); assert!(valid_version("1.0.0-beta.1")); - for bad in ["", ".", "1..2", "1.2/../3", "1.2.3 ", "1.2.3?x=1", "a.b", "1.2.3-é", "-1"] { + for bad in [ + "", + ".", + "1..2", + "1.2/../3", + "1.2.3 ", + "1.2.3?x=1", + "a.b", + "1.2.3-é", + "-1", + ] { assert!(!valid_version(bad), "{bad}"); } } #[test] fn asset_names_follow_the_release_workflow() { - assert_eq!(asset_name("0.1.3", true, true, "amd64"), "CastBay-Desktop-0.1.3-windows-x64-zh-CN.msi"); - assert_eq!(asset_name("0.1.3", true, false, "amd64"), "CastBay-Desktop-0.1.3-windows-x64-en-US.msi"); - assert_eq!(asset_name("0.1.3", false, true, "amd64"), "castbay-desktop_0.1.3_amd64.deb"); + assert_eq!( + asset_name("0.1.3", true, true, "amd64"), + "CastBay-Desktop-0.1.3-windows-x64-zh-CN.msi" + ); + assert_eq!( + asset_name("0.1.3", true, false, "amd64"), + "CastBay-Desktop-0.1.3-windows-x64-en-US.msi" + ); + assert_eq!( + asset_name("0.1.3", false, true, "amd64"), + "castbay-desktop_0.1.3_amd64.deb" + ); } fn release(url: &str, digest: Value) -> Value { @@ -279,7 +380,12 @@ mod tests { #[test] fn finds_the_asset_and_its_digest() { let hex = "AB".repeat(32); - let (url, digest) = find_asset(&release(DEB, json!(format!("sha256:{hex}"))), "castbay-desktop_0.1.3_amd64.deb", "0.1.3").unwrap(); + let (url, digest) = find_asset( + &release(DEB, json!(format!("sha256:{hex}"))), + "castbay-desktop_0.1.3_amd64.deb", + "0.1.3", + ) + .unwrap(); assert_eq!(url, DEB); assert_eq!(digest, "ab".repeat(32)); } @@ -289,16 +395,49 @@ mod tests { let name = "castbay-desktop_0.1.3_amd64.deb"; assert!(find_asset(&release(DEB, Value::Null), name, "0.1.3").is_err()); assert!(find_asset(&release(DEB, json!("sha256:abc")), name, "0.1.3").is_err()); - assert!(find_asset(&release(DEB, json!(format!("md5:{}", "a".repeat(64)))), name, "0.1.3").is_err()); - assert!(find_asset(&release(DEB, json!(format!("sha256:{}", "g".repeat(64)))), name, "0.1.3").is_err()); - assert!(find_asset(&release(DEB, json!(format!("sha256:{}", "a".repeat(64)))), "missing.deb", "0.1.3").is_err()); + assert!( + find_asset( + &release(DEB, json!(format!("md5:{}", "a".repeat(64)))), + name, + "0.1.3" + ) + .is_err() + ); + assert!( + find_asset( + &release(DEB, json!(format!("sha256:{}", "g".repeat(64)))), + name, + "0.1.3" + ) + .is_err() + ); + assert!( + find_asset( + &release(DEB, json!(format!("sha256:{}", "a".repeat(64)))), + "missing.deb", + "0.1.3" + ) + .is_err() + ); } #[test] fn refuses_a_foreign_address() { let digest = json!(format!("sha256:{}", "a".repeat(64))); - for url in ["https://evil.example/castbay-desktop_0.1.3_amd64.deb", "http://github.com/weenas/castbay/releases/download/desktop-v0.1.3/castbay-desktop_0.1.3_amd64.deb", "https://github.com/weenas/castbay/releases/download/desktop-v0.1.4/castbay-desktop_0.1.3_amd64.deb"] { - assert!(find_asset(&release(url, digest.clone()), "castbay-desktop_0.1.3_amd64.deb", "0.1.3").is_err(), "{url}"); + for url in [ + "https://evil.example/castbay-desktop_0.1.3_amd64.deb", + "http://github.com/weenas/castbay/releases/download/desktop-v0.1.3/castbay-desktop_0.1.3_amd64.deb", + "https://github.com/weenas/castbay/releases/download/desktop-v0.1.4/castbay-desktop_0.1.3_amd64.deb", + ] { + assert!( + find_asset( + &release(url, digest.clone()), + "castbay-desktop_0.1.3_amd64.deb", + "0.1.3" + ) + .is_err(), + "{url}" + ); } } @@ -306,17 +445,36 @@ mod tests { fn files_come_from_the_website_then_github() { let [site, github] = file_urls("0.1.3", "a.deb"); assert_eq!(site, "https://castbay.weenas.com/desktop/0.1.3/a.deb"); - assert_eq!(github, "https://github.com/weenas/castbay/releases/download/desktop-v0.1.3/a.deb"); + assert_eq!( + github, + "https://github.com/weenas/castbay/releases/download/desktop-v0.1.3/a.deb" + ); } #[test] fn the_websites_description_is_checked() { let hex = "Cd".repeat(32); let site = json!({"version": "0.1.3", "files": {"a.deb": hex}}); - assert_eq!(site_digest(&site, "a.deb", "0.1.3").unwrap(), "cd".repeat(32)); - assert!(site_digest(&site, "a.deb", "0.1.4").is_err(), "another version"); - assert!(site_digest(&site, "b.deb", "0.1.3").is_err(), "no such file"); - assert!(site_digest(&json!({"version": "0.1.3", "files": {"a.deb": "abc"}}), "a.deb", "0.1.3").is_err()); + assert_eq!( + site_digest(&site, "a.deb", "0.1.3").unwrap(), + "cd".repeat(32) + ); + assert!( + site_digest(&site, "a.deb", "0.1.4").is_err(), + "another version" + ); + assert!( + site_digest(&site, "b.deb", "0.1.3").is_err(), + "no such file" + ); + assert!( + site_digest( + &json!({"version": "0.1.3", "files": {"a.deb": "abc"}}), + "a.deb", + "0.1.3" + ) + .is_err() + ); } #[cfg(not(windows))] @@ -324,8 +482,20 @@ mod tests { fn the_install_runs_apt_get_as_an_administrator_on_that_file() { let c = install_command(Path::new("/home/a b/castbay-desktop_0.1.3_amd64.deb")); assert_eq!(c.get_program(), "pkexec"); - let args: Vec<_> = c.get_args().map(|a| a.to_string_lossy().into_owned()).collect(); - assert_eq!(args[..5], ["/usr/bin/env", "DEBIAN_FRONTEND=noninteractive", "/usr/bin/apt-get", "install", "-y"]); + let args: Vec<_> = c + .get_args() + .map(|a| a.to_string_lossy().into_owned()) + .collect(); + assert_eq!( + args[..5], + [ + "/usr/bin/env", + "DEBIAN_FRONTEND=noninteractive", + "/usr/bin/apt-get", + "install", + "-y" + ] + ); // One argument, a path: a space in it does not split it. assert_eq!(args[5], "/home/a b/castbay-desktop_0.1.3_amd64.deb"); assert_eq!(args.len(), 6); @@ -335,7 +505,10 @@ mod tests { fn hashes_a_file() { let path = std::env::temp_dir().join("castbay-update-test.bin"); std::fs::write(&path, b"abc").unwrap(); - assert_eq!(sha256_file(&path).unwrap(), "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"); + assert_eq!( + sha256_file(&path).unwrap(), + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" + ); let _ = std::fs::remove_file(path); } diff --git a/desktop/app/src/usage.rs b/desktop/app/src/usage.rs index dd493de..932b270 100644 --- a/desktop/app/src/usage.rs +++ b/desktop/app/src/usage.rs @@ -12,7 +12,7 @@ use std::path::{Path, PathBuf}; use std::sync::Mutex; -use serde_json::{json, Map, Value}; +use serde_json::{Map, Value, json}; /// One thread at a time reads and writes the file. static FILE: Mutex<()> = Mutex::new(()); @@ -24,7 +24,11 @@ fn path(dir: &Path) -> PathBuf { } fn read(dir: &Path) -> Value { - std::fs::read(path(dir)).ok().and_then(|b| serde_json::from_slice(&b).ok()).filter(Value::is_object).unwrap_or_else(|| json!({})) + std::fs::read(path(dir)) + .ok() + .and_then(|b| serde_json::from_slice(&b).ok()) + .filter(Value::is_object) + .unwrap_or_else(|| json!({})) } fn write(dir: &Path, value: &Value) { @@ -45,7 +49,14 @@ pub fn new_id() -> String { b[6] = (b[6] & 0x0f) | 0x40; b[8] = (b[8] & 0x3f) | 0x80; let hex: String = b.iter().map(|x| format!("{x:02x}")).collect(); - format!("{}-{}-{}-{}-{}", &hex[0..8], &hex[8..12], &hex[12..16], &hex[16..20], &hex[20..32]) + format!( + "{}-{}-{}-{}-{}", + &hex[0..8], + &hex[8..12], + &hex[12..16], + &hex[16..20], + &hex[20..32] + ) } /// Statistics were turned on: an ID is made if there is none. Returns whether there is one. @@ -69,7 +80,10 @@ pub fn turn_on(dir: &Path) -> bool { /// website to be asked to delete what it holds. pub fn turn_off(dir: &Path) -> Option { let _guard = FILE.lock().unwrap(); - let id = read(dir)["id"].as_str().filter(|s| !s.is_empty()).map(str::to_string); + let id = read(dir)["id"] + .as_str() + .filter(|s| !s.is_empty()) + .map(str::to_string); let _ = std::fs::remove_file(path(dir)); id } @@ -92,7 +106,10 @@ pub fn count(dir: &Path, day: &str, key: &str) { /// The ID and each finished day's counts (days before `today`, not older than a week), oldest /// first; older days are dropped here. -pub fn finished_days(dir: &Path, today: &str) -> Option<(String, Vec<(String, Map)>)> { +pub fn finished_days( + dir: &Path, + today: &str, +) -> Option<(String, Vec<(String, Map)>)> { let _guard = FILE.lock().unwrap(); let mut value = read(dir); let id = value["id"].as_str().filter(|s| !s.is_empty())?.to_string(); @@ -107,7 +124,13 @@ pub fn finished_days(dir: &Path, today: &str) -> Option<(String, Vec<(String, Ma let mut finished: Vec<(String, Map)> = days .into_iter() .filter(|(day, _)| day.as_str() < today) - .filter_map(|(day, counts)| counts.as_object().cloned().filter(|c| !c.is_empty()).map(|c| (day, c))) + .filter_map(|(day, counts)| { + counts + .as_object() + .cloned() + .filter(|c| !c.is_empty()) + .map(|c| (day, c)) + }) .collect(); finished.sort_by(|a, b| a.0.cmp(&b.0)); Some((id, finished)) @@ -131,7 +154,11 @@ pub fn day_of(secs: u64) -> String { fn days_before(day: &str, n: u64) -> String { let mut parts = day.split('-').filter_map(|p| p.parse::().ok()); - let (y, m, d) = (parts.next().unwrap_or(1970), parts.next().unwrap_or(1), parts.next().unwrap_or(1)); + let (y, m, d) = ( + parts.next().unwrap_or(1970), + parts.next().unwrap_or(1), + parts.next().unwrap_or(1), + ); let days = days_from_civil(y, m, d) - n as i64; day_of((days.max(0) as u64) * 86400) } @@ -178,7 +205,12 @@ pub fn bitrate_key(mbps: u32) -> &'static str { /// The height in pixels in a monitor's name ("0: 1920x1080 @ 60 Hz"). pub fn monitor_height(name: &str) -> Option { - let size = name.split_whitespace().find(|word| word.contains('x') && word.split('x').all(|p| !p.is_empty() && p.bytes().all(|b| b.is_ascii_digit())))?; + let size = name.split_whitespace().find(|word| { + word.contains('x') + && word + .split('x') + .all(|p| !p.is_empty() && p.bytes().all(|b| b.is_ascii_digit())) + })?; size.split('x').nth(1)?.parse().ok() } @@ -235,7 +267,10 @@ mod tests { count(&dir, "2026-10-29", "cast.window"); let (id, days) = finished_days(&dir, "2026-10-29").unwrap(); assert_eq!(id.len(), 36); - assert_eq!(days.iter().map(|(d, _)| d.as_str()).collect::>(), ["2026-10-27", "2026-10-28"]); + assert_eq!( + days.iter().map(|(d, _)| d.as_str()).collect::>(), + ["2026-10-27", "2026-10-28"] + ); assert_eq!(days[0].1["cast.screen"], 2); forget(&dir, "2026-10-27"); assert_eq!(finished_days(&dir, "2026-10-29").unwrap().1.len(), 1); @@ -252,7 +287,11 @@ mod tests { assert_eq!(days.len(), 1); assert_eq!(days[0].0, "2026-10-25"); // And it is gone from the file, not only from the answer. - assert!(!std::fs::read_to_string(path(&dir)).unwrap().contains("2026-10-01")); + assert!( + !std::fs::read_to_string(path(&dir)) + .unwrap() + .contains("2026-10-01") + ); let _ = std::fs::remove_dir_all(dir); } @@ -276,9 +315,15 @@ mod tests { fn an_id_looks_like_a_version_4_uuid() { let id = new_id(); let parts: Vec<&str> = id.split('-').collect(); - assert_eq!(parts.iter().map(|p| p.len()).collect::>(), [8, 4, 4, 4, 12]); + assert_eq!( + parts.iter().map(|p| p.len()).collect::>(), + [8, 4, 4, 4, 12] + ); assert!(parts[2].starts_with('4') && "89ab".contains(&parts[3][..1])); - assert!(id.bytes().all(|b| b == b'-' || b.is_ascii_digit() || (b'a'..=b'f').contains(&b))); + assert!( + id.bytes() + .all(|b| b == b'-' || b.is_ascii_digit() || (b'a'..=b'f').contains(&b)) + ); assert_ne!(new_id(), id); } @@ -296,10 +341,55 @@ mod tests { assert_eq!(day_of(1_793_000_000), "2026-10-26"); assert_eq!(days_before("2026-10-29", 7), "2026-10-22"); assert_eq!(days_before("2026-03-03", 7), "2026-02-24"); - assert_eq!([length_key(30.0), length_key(60.0), length_key(599.0), length_key(600.0)], ["length.under1m", "length.1to10m", "length.1to10m", "length.over10m"]); - assert_eq!([bitrate_key(2), bitrate_key(5), bitrate_key(6), bitrate_key(11), bitrate_key(12), bitrate_key(20)], - ["bitrate.under6", "bitrate.under6", "bitrate.6to11", "bitrate.6to11", "bitrate.12plus", "bitrate.12plus"]); - assert_eq!([screen_class(2160), screen_class(1440), screen_class(1080), screen_class(900), screen_class(480)], ["2160p", "1440p", "1080p", "720p", "smaller"]); - assert_eq!([failure_key("encoder"), failure_key("busy"), failure_key("network")], ["fail.encoder", "fail.other", "fail.network"]); + assert_eq!( + [ + length_key(30.0), + length_key(60.0), + length_key(599.0), + length_key(600.0) + ], + [ + "length.under1m", + "length.1to10m", + "length.1to10m", + "length.over10m" + ] + ); + assert_eq!( + [ + bitrate_key(2), + bitrate_key(5), + bitrate_key(6), + bitrate_key(11), + bitrate_key(12), + bitrate_key(20) + ], + [ + "bitrate.under6", + "bitrate.under6", + "bitrate.6to11", + "bitrate.6to11", + "bitrate.12plus", + "bitrate.12plus" + ] + ); + assert_eq!( + [ + screen_class(2160), + screen_class(1440), + screen_class(1080), + screen_class(900), + screen_class(480) + ], + ["2160p", "1440p", "1080p", "720p", "smaller"] + ); + assert_eq!( + [ + failure_key("encoder"), + failure_key("busy"), + failure_key("network") + ], + ["fail.encoder", "fail.other", "fail.network"] + ); } } diff --git a/desktop/core/capture/Cargo.toml b/desktop/core/capture/Cargo.toml index b84ac2f..5808452 100644 --- a/desktop/core/capture/Cargo.toml +++ b/desktop/core/capture/Cargo.toml @@ -24,6 +24,6 @@ features = [ ] [target.'cfg(target_os = "linux")'.dependencies] -ashpd = { version = "0.13", default-features = false, features = ["tokio", "screencast", "inhibit"] } +ashpd = { version = "0.13", default-features = false, features = ["async-io", "screencast", "inhibit"] } pipewire = "0.10" -tokio = { version = "1", features = ["rt-multi-thread", "time"] } +smol = "2" diff --git a/desktop/core/capture/src/audio.rs b/desktop/core/capture/src/audio.rs index 3a20e01..8a88c0d 100644 --- a/desktop/core/capture/src/audio.rs +++ b/desktop/core/capture/src/audio.rs @@ -5,15 +5,23 @@ use std::time::Duration; use windows::core::{implement, Interface}; use windows::Win32::Media::Audio::{ - eConsole, eRender, ActivateAudioInterfaceAsync, IActivateAudioInterfaceAsyncOperation, IActivateAudioInterfaceCompletionHandler, - IActivateAudioInterfaceCompletionHandler_Impl, AUDIOCLIENT_ACTIVATION_PARAMS, AUDIOCLIENT_ACTIVATION_PARAMS_0, - AUDIOCLIENT_ACTIVATION_TYPE_PROCESS_LOOPBACK, AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS, PROCESS_LOOPBACK_MODE_INCLUDE_TARGET_PROCESS_TREE, PROCESS_LOOPBACK_MODE_EXCLUDE_TARGET_PROCESS_TREE, - VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK, IAudioCaptureClient, IAudioClient, IMMDeviceEnumerator, MMDeviceEnumerator, AUDCLNT_BUFFERFLAGS_SILENT, - AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM, AUDCLNT_STREAMFLAGS_LOOPBACK, AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY, + eConsole, eRender, ActivateAudioInterfaceAsync, IActivateAudioInterfaceAsyncOperation, + IActivateAudioInterfaceCompletionHandler, IActivateAudioInterfaceCompletionHandler_Impl, + IAudioCaptureClient, IAudioClient, IMMDeviceEnumerator, MMDeviceEnumerator, + AUDCLNT_BUFFERFLAGS_SILENT, AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM, + AUDCLNT_STREAMFLAGS_LOOPBACK, AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY, + AUDIOCLIENT_ACTIVATION_PARAMS, AUDIOCLIENT_ACTIVATION_PARAMS_0, + AUDIOCLIENT_ACTIVATION_TYPE_PROCESS_LOOPBACK, AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS, + PROCESS_LOOPBACK_MODE_EXCLUDE_TARGET_PROCESS_TREE, + PROCESS_LOOPBACK_MODE_INCLUDE_TARGET_PROCESS_TREE, VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK, WAVEFORMATEX, }; -use windows::Win32::System::Com::StructuredStorage::{PROPVARIANT, PROPVARIANT_0, PROPVARIANT_0_0, PROPVARIANT_0_0_0}; -use windows::Win32::System::Com::{BLOB, CoCreateInstance, CoInitializeEx, CoUninitialize, CLSCTX_ALL, COINIT_MULTITHREADED}; +use windows::Win32::System::Com::StructuredStorage::{ + PROPVARIANT, PROPVARIANT_0, PROPVARIANT_0_0, PROPVARIANT_0_0_0, +}; +use windows::Win32::System::Com::{ + CoCreateInstance, CoInitializeEx, CoUninitialize, BLOB, CLSCTX_ALL, COINIT_MULTITHREADED, +}; use windows::Win32::System::Variant::VT_BLOB; use crate::Error; @@ -33,7 +41,11 @@ fn platform(e: windows::core::Error) -> Error { /// With `process` (a process id) only what that process and the ones it started play is /// delivered (a window's own sound, a browser's included); where Windows cannot do that (before /// Windows 10 version 2004) the whole output is delivered, as without it. -pub fn run_loopback(process: Option, stop: &dyn Fn() -> bool, mut on_samples: impl FnMut(&[f32])) -> Result<(), Error> { +pub fn run_loopback( + process: Option, + stop: &dyn Fn() -> bool, + mut on_samples: impl FnMut(&[f32]), +) -> Result<(), Error> { unsafe { let initialised = CoInitializeEx(None, COINIT_MULTITHREADED).is_ok(); let result = capture(process, stop, &mut on_samples); @@ -49,12 +61,19 @@ pub fn device_format() -> String { unsafe { let initialised = CoInitializeEx(None, COINIT_MULTITHREADED).is_ok(); let text = (|| -> windows::core::Result { - let enumerator: IMMDeviceEnumerator = CoCreateInstance(&MMDeviceEnumerator, None, CLSCTX_ALL)?; + let enumerator: IMMDeviceEnumerator = + CoCreateInstance(&MMDeviceEnumerator, None, CLSCTX_ALL)?; let device = enumerator.GetDefaultAudioEndpoint(eRender, eConsole)?; let client: IAudioClient = device.Activate(CLSCTX_ALL, None)?; let format = client.GetMixFormat()?; let f = std::ptr::read_unaligned(format); - let text = format!("{} Hz, {} channels, {} bits, tag {}", { f.nSamplesPerSec }, { f.nChannels }, { f.wBitsPerSample }, { f.wFormatTag }); + let text = format!( + "{} Hz, {} channels, {} bits, tag {}", + { f.nSamplesPerSec }, + { f.nChannels }, + { f.wBitsPerSample }, + { f.wFormatTag } + ); windows::Win32::System::Com::CoTaskMemFree(Some(format as *const _)); Ok(text) })(); @@ -70,7 +89,10 @@ pub fn device_format() -> String { struct Done(std::sync::mpsc::Sender<()>); impl IActivateAudioInterfaceCompletionHandler_Impl for Done_Impl { - fn ActivateCompleted(&self, _operation: windows::core::Ref<'_, IActivateAudioInterfaceAsyncOperation>) -> windows::core::Result<()> { + fn ActivateCompleted( + &self, + _operation: windows::core::Ref<'_, IActivateAudioInterfaceAsyncOperation>, + ) -> windows::core::Result<()> { let _ = self.0.send(()); Ok(()) } @@ -83,7 +105,11 @@ unsafe fn process_client(process: u32, only_it: bool) -> Result Result() as u32, pBlobData: &mut params as *mut _ as *mut u8 }, + blob: BLOB { + cbSize: std::mem::size_of::() as u32, + pBlobData: &mut params as *mut _ as *mut u8, + }, }, }), }, }); let (tx, rx) = std::sync::mpsc::channel(); let handler: IActivateAudioInterfaceCompletionHandler = Done(tx).into(); - let operation = ActivateAudioInterfaceAsync(VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK, &IAudioClient::IID, Some(&*variant), &handler).map_err(platform)?; - rx.recv_timeout(Duration::from_secs(5)).map_err(|_| Error::Platform("the audio of the window did not answer".into()))?; + let operation = ActivateAudioInterfaceAsync( + VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK, + &IAudioClient::IID, + Some(&*variant), + &handler, + ) + .map_err(platform)?; + rx.recv_timeout(Duration::from_secs(5)) + .map_err(|_| Error::Platform("the audio of the window did not answer".into()))?; let (mut result, mut client) = (windows::core::HRESULT(0), None); - operation.GetActivateResult(&mut result, &mut client).map_err(platform)?; + operation + .GetActivateResult(&mut result, &mut client) + .map_err(platform)?; result.ok().map_err(platform)?; - client.ok_or_else(|| Error::Platform("no audio client".into()))?.cast::().map_err(platform) + client + .ok_or_else(|| Error::Platform("no audio client".into()))? + .cast::() + .map_err(platform) } -unsafe fn capture(process: Option, stop: &dyn Fn() -> bool, on_samples: &mut dyn FnMut(&[f32])) -> Result<(), Error> { +unsafe fn capture( + process: Option, + stop: &dyn Fn() -> bool, + on_samples: &mut dyn FnMut(&[f32]), +) -> Result<(), Error> { // The whole output is taken the same way, as everything but this program's own sound: the level // and the character of the sound then do not change when what is cast goes from a window to a screen // (the device's own loopback is quieter by a good deal than a process's). @@ -123,8 +168,11 @@ unsafe fn capture(process: Option, stop: &dyn Fn() -> bool, on_samples: &mu Ok(client) => client, // Not possible here: the sound of the whole output, as before. Err(_) => { - let enumerator: IMMDeviceEnumerator = CoCreateInstance(&MMDeviceEnumerator, None, CLSCTX_ALL).map_err(platform)?; - let device = enumerator.GetDefaultAudioEndpoint(eRender, eConsole).map_err(platform)?; + let enumerator: IMMDeviceEnumerator = + CoCreateInstance(&MMDeviceEnumerator, None, CLSCTX_ALL).map_err(platform)?; + let device = enumerator + .GetDefaultAudioEndpoint(eRender, eConsole) + .map_err(platform)?; device.Activate(CLSCTX_ALL, None).map_err(platform)? } }; @@ -140,7 +188,9 @@ unsafe fn capture(process: Option, stop: &dyn Fn() -> bool, on_samples: &mu client .Initialize( AUDCLNT_SHAREMODE_SHARED, - AUDCLNT_STREAMFLAGS_LOOPBACK | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY, + AUDCLNT_STREAMFLAGS_LOOPBACK + | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM + | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY, 2_000_000, // 200 ms 0, &format, @@ -156,7 +206,9 @@ unsafe fn capture(process: Option, stop: &dyn Fn() -> bool, on_samples: &mu std::thread::sleep(Duration::from_millis(5)); while capture.GetNextPacketSize().map_err(platform)? > 0 { let (mut data, mut frames, mut flags) = (std::ptr::null_mut::(), 0u32, 0u32); - capture.GetBuffer(&mut data, &mut frames, &mut flags, None, None).map_err(platform)?; + capture + .GetBuffer(&mut data, &mut frames, &mut flags, None, None) + .map_err(platform)?; let samples = frames as usize * CHANNELS as usize; if flags & (AUDCLNT_BUFFERFLAGS_SILENT.0 as u32) != 0 || data.is_null() { silence.clear(); diff --git a/desktop/core/capture/src/audio_linux.rs b/desktop/core/capture/src/audio_linux.rs index 4bd6db5..a2c0acf 100644 --- a/desktop/core/capture/src/audio_linux.rs +++ b/desktop/core/capture/src/audio_linux.rs @@ -23,7 +23,11 @@ struct State<'a> { /// `stop` says so. PipeWire converts whatever the device uses to the format asked for. /// /// `process` is only for Windows (the sound of one window): here it is the whole output. -pub fn run_loopback(_process: Option, stop: &dyn Fn() -> bool, mut on_samples: impl FnMut(&[f32])) -> Result<(), Error> { +pub fn run_loopback( + _process: Option, + stop: &dyn Fn() -> bool, + mut on_samples: impl FnMut(&[f32]), +) -> Result<(), Error> { pw::init(); let mainloop = pw::main_loop::MainLoopRc::new(None).map_err(platform)?; let context = pw::context::ContextRc::new(&mainloop, None).map_err(platform)?; @@ -43,17 +47,28 @@ pub fn run_loopback(_process: Option, stop: &dyn Fn() -> bool, mut on_sampl .map_err(platform)?; let _listener = stream - .add_local_listener_with_user_data(State { on_samples: &mut on_samples }) + .add_local_listener_with_user_data(State { + on_samples: &mut on_samples, + }) .process(|stream, state| { - let Some(mut buffer) = stream.dequeue_buffer() else { return }; - let Some(data) = buffer.datas_mut().first_mut() else { return }; + let Some(mut buffer) = stream.dequeue_buffer() else { + return; + }; + let Some(data) = buffer.datas_mut().first_mut() else { + return; + }; let (offset, size) = { let chunk = data.chunk(); (chunk.offset() as usize, chunk.size() as usize) }; let Some(bytes) = data.data() else { return }; - let Some(bytes) = bytes.get(offset..offset + size) else { return }; - let samples: Vec = bytes.chunks_exact(4).map(|b| f32::from_le_bytes([b[0], b[1], b[2], b[3]])).collect(); + let Some(bytes) = bytes.get(offset..offset + size) else { + return; + }; + let samples: Vec = bytes + .chunks_exact(4) + .map(|b| f32::from_le_bytes([b[0], b[1], b[2], b[3]])) + .collect(); if !samples.is_empty() { (state.on_samples)(&samples); } @@ -70,16 +85,22 @@ pub fn run_loopback(_process: Option, stop: &dyn Fn() -> bool, mut on_sampl id: spa::param::ParamType::EnumFormat.as_raw(), properties: info.into(), }; - let bytes: Vec = spa::pod::serialize::PodSerializer::serialize(std::io::Cursor::new(Vec::new()), &spa::pod::Value::Object(object)) - .map_err(|e| platform(format!("{e:?}")))? - .0 - .into_inner(); - let mut params = [spa::pod::Pod::from_bytes(&bytes).ok_or_else(|| platform("the format request is not valid"))?]; + let bytes: Vec = spa::pod::serialize::PodSerializer::serialize( + std::io::Cursor::new(Vec::new()), + &spa::pod::Value::Object(object), + ) + .map_err(|e| platform(format!("{e:?}")))? + .0 + .into_inner(); + let mut params = [spa::pod::Pod::from_bytes(&bytes) + .ok_or_else(|| platform("the format request is not valid"))?]; stream .connect( spa::utils::Direction::Input, None, - pw::stream::StreamFlags::AUTOCONNECT | pw::stream::StreamFlags::MAP_BUFFERS | pw::stream::StreamFlags::RT_PROCESS, + pw::stream::StreamFlags::AUTOCONNECT + | pw::stream::StreamFlags::MAP_BUFFERS + | pw::stream::StreamFlags::RT_PROCESS, &mut params, ) .map_err(platform)?; @@ -93,7 +114,10 @@ pub fn run_loopback(_process: Option, stop: &dyn Fn() -> bool, mut on_sampl } }); timer - .update_timer(Some(Duration::from_millis(100)), Some(Duration::from_millis(100))) + .update_timer( + Some(Duration::from_millis(100)), + Some(Duration::from_millis(100)), + ) .into_result() .map_err(|e| platform(format!("{e:?}")))?; diff --git a/desktop/core/capture/src/lib.rs b/desktop/core/capture/src/lib.rs index 6b74fbd..4337817 100644 --- a/desktop/core/capture/src/lib.rs +++ b/desktop/core/capture/src/lib.rs @@ -84,7 +84,9 @@ pub fn run( #[cfg(not(any(windows, target_os = "linux")))] { let _ = (target, stop, &mut on_frame); - Err(Error::Platform("screen capture is not implemented on this system".into())) + Err(Error::Platform( + "screen capture is not implemented on this system".into(), + )) } } diff --git a/desktop/core/capture/src/linux.rs b/desktop/core/capture/src/linux.rs index 49a131e..617683a 100644 --- a/desktop/core/capture/src/linux.rs +++ b/desktop/core/capture/src/linux.rs @@ -75,7 +75,10 @@ async fn open_portal(target: &Target) -> Result { async fn open_portal_with(target: &Target, use_token: bool) -> Result { let proxy = Screencast::new().await.map_err(platform)?; - let session = proxy.create_session(Default::default()).await.map_err(platform)?; + let session = proxy + .create_session(Default::default()) + .await + .map_err(platform)?; let token = token_file() .filter(|_| use_token) .and_then(|f| std::fs::read_to_string(f).ok()) @@ -99,9 +102,14 @@ async fn open_portal_with(target: &Target, use_token: bool) -> Result result, - Err(_) => { + Err(()) => { let _ = session.close().await; return Err(Error::Platform(STALE.into())); } @@ -119,8 +127,15 @@ async fn open_portal_with(target: &Target, use_token: bool) -> Result bool + Send + 'static, on_frame: impl FnMut(Frame<'_>) -> bool + Send + 'static, ) -> Result { - // One runtime for the whole process: the portal's D-Bus connection is shared and lives on the - // runtime that first used it, so a second capture (the engine opens one to learn the picture - // size) would hang if that runtime were gone. - let runtime = runtime()?; - let share = runtime.block_on(open_portal(target))?; + // Keep the portal futures on the async-io executor used by GPUI as well, so the desktop host and + // the capture backend never enable conflicting D-Bus runtimes. + let share = smol::block_on(open_portal(target))?; let close = share.close; let result = stream(share.node, share.fd, stop, Box::new(on_frame)); - runtime.block_on(close()); + smol::block_on(close()); result } -fn runtime() -> Result<&'static tokio::runtime::Runtime, Error> { - static RUNTIME: OnceLock = OnceLock::new(); - if let Some(runtime) = RUNTIME.get() { - return Ok(runtime); - } - let built = tokio::runtime::Builder::new_multi_thread().worker_threads(1).enable_all().build().map_err(platform)?; - Ok(RUNTIME.get_or_init(|| built)) -} - -fn stream(node: u32, fd: OwnedFd, stop: impl Fn() -> bool + 'static, on_frame: Box) -> bool + Send>) -> Result { +fn stream( + node: u32, + fd: OwnedFd, + stop: impl Fn() -> bool + 'static, + on_frame: Box) -> bool + Send>, +) -> Result { pw::init(); let mainloop = pw::main_loop::MainLoopRc::new(None).map_err(platform)?; let context = pw::context::ContextRc::new(&mainloop, None).map_err(platform)?; @@ -230,21 +239,34 @@ fn stream(node: u32, fd: OwnedFd, stop: impl Fn() -> bool + 'static, on_frame: B if id != spa::param::ParamType::Format.as_raw() { return; } - let Ok((media_type, media_subtype)) = spa::param::format_utils::parse_format(param) else { return }; - if media_type != spa::param::format::MediaType::Video || media_subtype != spa::param::format::MediaSubtype::Raw { + let Ok((media_type, media_subtype)) = spa::param::format_utils::parse_format(param) + else { + return; + }; + if media_type != spa::param::format::MediaType::Video + || media_subtype != spa::param::format::MediaSubtype::Raw + { return; } let _ = state.format.parse(param); }) .process(|stream, state| { - let Some(mut buffer) = stream.dequeue_buffer() else { return }; - let Some(data) = buffer.datas_mut().first_mut() else { return }; + let Some(mut buffer) = stream.dequeue_buffer() else { + return; + }; + let Some(data) = buffer.datas_mut().first_mut() else { + return; + }; let (stride, chunk_size) = (data.chunk().stride(), data.chunk().size() as usize); let size = state.format.size(); if size.width == 0 || size.height == 0 { return; } - let stride = if stride > 0 { stride as usize } else { size.width as usize * 4 }; + let stride = if stride > 0 { + stride as usize + } else { + size.width as usize * 4 + }; let Some(bytes) = data.data() else { return }; // A picture may arrive without new content (a bare buffer): there is nothing to send. if chunk_size == 0 { @@ -264,7 +286,13 @@ fn stream(node: u32, fd: OwnedFd, stop: impl Fn() -> bool + 'static, on_frame: B saved.data.extend_from_slice(&bytes[..wanted]); saved.at = Some(Instant::now()); } - let frame = Frame { width: size.width, height: size.height, stride, data: &bytes[..wanted], timestamp: state.started.elapsed() }; + let frame = Frame { + width: size.width, + height: size.height, + stride, + data: &bytes[..wanted], + timestamp: state.started.elapsed(), + }; if !(state.on_frame.borrow_mut())(frame) { state.ended.set(Some(Ended::Stopped)); state.mainloop.quit(); @@ -279,8 +307,16 @@ fn stream(node: u32, fd: OwnedFd, stop: impl Fn() -> bool + 'static, on_frame: B let object = spa::pod::object!( spa::utils::SpaTypes::ObjectParamFormat, spa::param::ParamType::EnumFormat, - spa::pod::property!(spa::param::format::FormatProperties::MediaType, Id, spa::param::format::MediaType::Video), - spa::pod::property!(spa::param::format::FormatProperties::MediaSubtype, Id, spa::param::format::MediaSubtype::Raw), + spa::pod::property!( + spa::param::format::FormatProperties::MediaType, + Id, + spa::param::format::MediaType::Video + ), + spa::pod::property!( + spa::param::format::FormatProperties::MediaSubtype, + Id, + spa::param::format::MediaSubtype::Raw + ), spa::pod::property!( spa::param::format::FormatProperties::VideoFormat, Choice, @@ -295,9 +331,18 @@ fn stream(node: u32, fd: OwnedFd, stop: impl Fn() -> bool + 'static, on_frame: B Choice, Range, Rectangle, - spa::utils::Rectangle { width: 1920, height: 1080 }, - spa::utils::Rectangle { width: 16, height: 16 }, - spa::utils::Rectangle { width: 8192, height: 8192 } + spa::utils::Rectangle { + width: 1920, + height: 1080 + }, + spa::utils::Rectangle { + width: 16, + height: 16 + }, + spa::utils::Rectangle { + width: 8192, + height: 8192 + } ), spa::pod::property!( spa::param::format::FormatProperties::VideoFramerate, @@ -306,16 +351,28 @@ fn stream(node: u32, fd: OwnedFd, stop: impl Fn() -> bool + 'static, on_frame: B Fraction, spa::utils::Fraction { num: 60, denom: 1 }, spa::utils::Fraction { num: 0, denom: 1 }, - spa::utils::Fraction { num: 1000, denom: 1 } + spa::utils::Fraction { + num: 1000, + denom: 1 + } ), ); - let bytes: Vec = spa::pod::serialize::PodSerializer::serialize(std::io::Cursor::new(Vec::new()), &spa::pod::Value::Object(object)) - .map_err(|e| platform(format!("{e:?}")))? - .0 - .into_inner(); - let mut params = [spa::pod::Pod::from_bytes(&bytes).ok_or_else(|| platform("the format request is not valid"))?]; + let bytes: Vec = spa::pod::serialize::PodSerializer::serialize( + std::io::Cursor::new(Vec::new()), + &spa::pod::Value::Object(object), + ) + .map_err(|e| platform(format!("{e:?}")))? + .0 + .into_inner(); + let mut params = [spa::pod::Pod::from_bytes(&bytes) + .ok_or_else(|| platform("the format request is not valid"))?]; stream - .connect(spa::utils::Direction::Input, Some(node), pw::stream::StreamFlags::AUTOCONNECT | pw::stream::StreamFlags::MAP_BUFFERS, &mut params) + .connect( + spa::utils::Direction::Input, + Some(node), + pw::stream::StreamFlags::AUTOCONNECT | pw::stream::StreamFlags::MAP_BUFFERS, + &mut params, + ) .map_err(platform)?; // A static desktop sends no pictures, but the person may still stop: look every 100 ms. @@ -327,9 +384,18 @@ fn stream(node: u32, fd: OwnedFd, stop: impl Fn() -> bool + 'static, on_frame: B } // Nothing changed for a while: hand the last picture on again. let mut saved = saved.borrow_mut(); - if saved.at.is_some_and(|at| at.elapsed() >= Duration::from_millis(500)) { + if saved + .at + .is_some_and(|at| at.elapsed() >= Duration::from_millis(500)) + { saved.at = Some(Instant::now()); - let frame = Frame { width: saved.width, height: saved.height, stride: saved.stride, data: &saved.data, timestamp: started.elapsed() }; + let frame = Frame { + width: saved.width, + height: saved.height, + stride: saved.stride, + data: &saved.data, + timestamp: started.elapsed(), + }; if !(on_frame.borrow_mut())(frame) { idle_ended.set(Some(Ended::Stopped)); looper.quit(); @@ -337,7 +403,10 @@ fn stream(node: u32, fd: OwnedFd, stop: impl Fn() -> bool + 'static, on_frame: B } }); timer - .update_timer(Some(Duration::from_millis(100)), Some(Duration::from_millis(100))) + .update_timer( + Some(Duration::from_millis(100)), + Some(Duration::from_millis(100)), + ) .into_result() .map_err(|e| platform(format!("{e:?}")))?; diff --git a/desktop/core/capture/src/windows.rs b/desktop/core/capture/src/windows.rs index d71c890..c232351 100644 --- a/desktop/core/capture/src/windows.rs +++ b/desktop/core/capture/src/windows.rs @@ -35,7 +35,12 @@ impl GraphicsCaptureApiHandler for Handler { type Error = Box; fn new(ctx: Context) -> Result { - let flags = ctx.flags.lock().unwrap().take().ok_or("capture flags missing")?; + let flags = ctx + .flags + .lock() + .unwrap() + .take() + .ok_or("capture flags missing")?; Ok(Handler { flags }) } @@ -125,7 +130,11 @@ pub fn run( } let _ = control.stop(); - Ok(if closed.load(Ordering::SeqCst) { Ended::SourceClosed } else { Ended::Stopped }) + Ok(if closed.load(Ordering::SeqCst) { + Ended::SourceClosed + } else { + Ended::Stopped + }) } /// Names of the monitors, for the picker and the CLI. @@ -156,7 +165,12 @@ pub fn windows() -> Result, Error> { .filter_map(|w| w.title().ok()) .map(|t| t.trim().to_string()) // Console windows are titled with their program's path, and the input method has a window of its own. - .filter(|t| !t.is_empty() && !t.to_lowercase().ends_with(".exe") && t != "Windows 输入体验" && t != "Program Manager") + .filter(|t| { + !t.is_empty() + && !t.to_lowercase().ends_with(".exe") + && t != "Windows 输入体验" + && t != "Program Manager" + }) .collect(); titles.sort(); titles.dedup(); diff --git a/desktop/core/cli/src/main.rs b/desktop/core/cli/src/main.rs index d8a7518..ae2ab1b 100644 --- a/desktop/core/cli/src/main.rs +++ b/desktop/core/cli/src/main.rs @@ -24,27 +24,58 @@ fn main() { /// Listens for a few seconds to the PC's sound, or to that of the window whose title contains /// `--window` (Windows), and prints the loudest sample of each second. fn audio_test(args: &[String]) { - let process = option(args, "--window").map(|title| castbay_capture::window_process(title).unwrap_or_else(|| panic!("no window named {title}"))); - let seconds: u64 = option(args, "--seconds").and_then(|v| v.parse().ok()).unwrap_or(5); - #[cfg(windows)] - println!("the output mixes {}", castbay_capture::audio::device_format()); - println!("listening for {seconds} s to {}", process.map(|p| format!("process {p} and what it started")).unwrap_or("everything played".into())); - let (started, mut peak, mut second, mut count, mut sq) = (Instant::now(), 0f32, 0u64, 0usize, 0f64); - let result = castbay_capture::audio::run_loopback(process, &|| started.elapsed() >= Duration::from_secs(seconds), |samples| { - peak = samples.iter().fold(peak, |m, s| m.max(s.abs())); - count += samples.len() / 2; - sq += samples.iter().map(|s| (*s as f64) * (*s as f64)).sum::(); - let now = started.elapsed().as_secs(); - if now > second { - println!("second {second}: peak {peak:.3}, rms {:.3}, {count} sample pairs", (sq / (count.max(1) * 2) as f64).sqrt()); - (second, peak, count, sq) = (now, 0.0, 0, 0.0); - } + let process = option(args, "--window").map(|title| { + castbay_capture::window_process(title).unwrap_or_else(|| panic!("no window named {title}")) }); - println!("{}", result.map(|_| "done".to_string()).unwrap_or_else(|e| format!("failed: {e}"))); + let seconds: u64 = option(args, "--seconds") + .and_then(|v| v.parse().ok()) + .unwrap_or(5); + #[cfg(windows)] + println!( + "the output mixes {}", + castbay_capture::audio::device_format() + ); + println!( + "listening for {seconds} s to {}", + process + .map(|p| format!("process {p} and what it started")) + .unwrap_or("everything played".into()) + ); + let (started, mut peak, mut second, mut count, mut sq) = + (Instant::now(), 0f32, 0u64, 0usize, 0f64); + let result = castbay_capture::audio::run_loopback( + process, + &|| started.elapsed() >= Duration::from_secs(seconds), + |samples| { + peak = samples.iter().fold(peak, |m, s| m.max(s.abs())); + count += samples.len() / 2; + sq += samples + .iter() + .map(|s| (*s as f64) * (*s as f64)) + .sum::(); + let now = started.elapsed().as_secs(); + if now > second { + println!( + "second {second}: peak {peak:.3}, rms {:.3}, {count} sample pairs", + (sq / (count.max(1) * 2) as f64).sqrt() + ); + (second, peak, count, sq) = (now, 0.0, 0, 0.0); + } + }, + ); + println!( + "{}", + result + .map(|_| "done".to_string()) + .unwrap_or_else(|e| format!("failed: {e}")) + ); } fn list() { - match (castbay_capture::monitors(), castbay_capture::window_titles()) { + match ( + castbay_capture::monitors(), + castbay_capture::window_titles(), + ) { (Ok(monitors), Ok(windows)) => { monitors.iter().for_each(|m| println!("monitor {m}")); windows.iter().for_each(|w| println!("window {w}")); @@ -60,8 +91,14 @@ fn list() { /// capture alone, without encoding or the network. fn capture_test(args: &[String]) { use std::sync::{Arc, Mutex}; - let target = if args.iter().any(|a| a == "--window") { Target::Window(String::new()) } else { Target::Monitor(0) }; - let seconds: u64 = option(args, "--seconds").and_then(|v| v.parse().ok()).unwrap_or(5); + let target = if args.iter().any(|a| a == "--window") { + Target::Window(String::new()) + } else { + Target::Monitor(0) + }; + let seconds: u64 = option(args, "--seconds") + .and_then(|v| v.parse().ok()) + .unwrap_or(5); castbay_capture::set_data_dir(&data_dir(args)); let seen = Arc::new(Mutex::new((0u64, 0u32, 0u32, None::>))); let collect = seen.clone(); @@ -73,7 +110,13 @@ fn capture_test(args: &[String]) { let mut s = collect.lock().unwrap(); s.0 += 1; if s.0 == 1 { - println!("first picture after {:.1} s: {}x{} (stride {})", started.elapsed().as_secs_f64(), frame.width, frame.height, frame.stride); + println!( + "first picture after {:.1} s: {}x{} (stride {})", + started.elapsed().as_secs_f64(), + frame.width, + frame.height, + frame.stride + ); } // Keep a tightly packed copy of the latest picture for the PNG. let mut packed = Vec::with_capacity(frame.width as usize * frame.height as usize * 4); @@ -87,7 +130,12 @@ fn capture_test(args: &[String]) { }, ); let s = seen.lock().unwrap(); - println!("ended: {result:?}; {} pictures in {:.1} s ({:.1} per second)", s.0, started.elapsed().as_secs_f64(), s.0 as f64 / seconds as f64); + println!( + "ended: {result:?}; {} pictures in {:.1} s ({:.1} per second)", + s.0, + started.elapsed().as_secs_f64(), + s.0 as f64 / seconds as f64 + ); if let (Some(path), Some(bgra)) = (option(args, "--png"), &s.3) { write_png(path, s.1, s.2, bgra).expect("could not write the PNG"); println!("saved {path}"); @@ -101,7 +149,11 @@ fn write_png(path: &str, width: u32, height: u32, bgra: &[u8]) -> std::io::Resul for &b in data { crc ^= b as u32; for _ in 0..8 { - crc = if crc & 1 != 0 { (crc >> 1) ^ 0xEDB8_8320 } else { crc >> 1 }; + crc = if crc & 1 != 0 { + (crc >> 1) ^ 0xEDB8_8320 + } else { + crc >> 1 + }; } } !crc @@ -146,16 +198,25 @@ fn write_png(path: &str, width: u32, height: u32, bgra: &[u8]) -> std::io::Resul } fn option<'a>(args: &'a [String], name: &str) -> Option<&'a str> { - args.iter().position(|a| a == name).and_then(|i| args.get(i + 1)).map(String::as_str) + args.iter() + .position(|a| a == name) + .and_then(|i| args.get(i + 1)) + .map(String::as_str) } #[cfg(windows)] fn bench_capture(args: &[String]) { let target = match option(args, "--window") { Some(title) => Target::Window(title.to_string()), - None => Target::Monitor(option(args, "--monitor").and_then(|v| v.parse().ok()).unwrap_or(0)), + None => Target::Monitor( + option(args, "--monitor") + .and_then(|v| v.parse().ok()) + .unwrap_or(0), + ), }; - let seconds: u64 = option(args, "--seconds").and_then(|v| v.parse().ok()).unwrap_or(10); + let seconds: u64 = option(args, "--seconds") + .and_then(|v| v.parse().ok()) + .unwrap_or(10); println!("capturing {target:?} for {seconds} s"); #[derive(Default)] @@ -171,33 +232,55 @@ fn bench_capture(args: &[String]) { let stats = std::sync::Arc::new(std::sync::Mutex::new(Stats::default())); let shared = stats.clone(); let limit = Duration::from_secs(seconds); - let result = castbay_capture::windows::run(&target, || false, move |frame| { - let now = Instant::now(); - let mut state = shared.lock().unwrap(); - // The cost of getting at the picture on the CPU: touch every row once. - let t = Instant::now(); - let mut sum = 0u8; - for row in frame.data.chunks(frame.stride).take(frame.height as usize) { - sum = sum.wrapping_add(row[0]); - } - std::hint::black_box(sum); - state.touch += t.elapsed(); - state.frames += 1; - state.bytes += frame.data.len() as u64; - state.size = (frame.width, frame.height); - if let Some(last) = state.last { - state.max_gap = state.max_gap.max(now.saturating_duration_since(last)); - } - state.last = Some(now); - frame.timestamp < limit - }); - let Stats { frames, bytes, size, max_gap, touch, .. } = std::mem::take(&mut *stats.lock().unwrap()); + let result = castbay_capture::windows::run( + &target, + || false, + move |frame| { + let now = Instant::now(); + let mut state = shared.lock().unwrap(); + // The cost of getting at the picture on the CPU: touch every row once. + let t = Instant::now(); + let mut sum = 0u8; + for row in frame.data.chunks(frame.stride).take(frame.height as usize) { + sum = sum.wrapping_add(row[0]); + } + std::hint::black_box(sum); + state.touch += t.elapsed(); + state.frames += 1; + state.bytes += frame.data.len() as u64; + state.size = (frame.width, frame.height); + if let Some(last) = state.last { + state.max_gap = state.max_gap.max(now.saturating_duration_since(last)); + } + state.last = Some(now); + frame.timestamp < limit + }, + ); + let Stats { + frames, + bytes, + size, + max_gap, + touch, + .. + } = std::mem::take(&mut *stats.lock().unwrap()); let elapsed = started.elapsed().as_secs_f64(); println!("ended: {result:?}"); - println!("frames: {frames} in {elapsed:.1} s = {:.1} fps", frames as f64 / elapsed); - println!("size: {}x{}, {:.0} MB/s of pixels", size.0, size.1, bytes as f64 / elapsed / 1e6); + println!( + "frames: {frames} in {elapsed:.1} s = {:.1} fps", + frames as f64 / elapsed + ); + println!( + "size: {}x{}, {:.0} MB/s of pixels", + size.0, + size.1, + bytes as f64 / elapsed / 1e6 + ); println!("longest gap between frames: {} ms", max_gap.as_millis()); - println!("row touch per frame: {:.2} ms", touch.as_secs_f64() * 1000.0 / frames.max(1) as f64); + println!( + "row touch per frame: {:.2} ms", + touch.as_secs_f64() * 1000.0 / frames.max(1) as f64 + ); } #[cfg(not(windows))] @@ -210,9 +293,20 @@ fn bench_capture(_: &[String]) { fn cpu_time() -> Duration { use windows::Win32::Foundation::FILETIME; use windows::Win32::System::Threading::{GetCurrentProcess, GetProcessTimes}; - let (mut create, mut exit, mut kernel, mut user) = (FILETIME::default(), FILETIME::default(), FILETIME::default(), FILETIME::default()); + let (mut create, mut exit, mut kernel, mut user) = ( + FILETIME::default(), + FILETIME::default(), + FILETIME::default(), + FILETIME::default(), + ); unsafe { - let _ = GetProcessTimes(GetCurrentProcess(), &mut create, &mut exit, &mut kernel, &mut user); + let _ = GetProcessTimes( + GetCurrentProcess(), + &mut create, + &mut exit, + &mut kernel, + &mut user, + ); } let ticks = |t: FILETIME| ((t.dwHighDateTime as u64) << 32) | t.dwLowDateTime as u64; Duration::from_nanos((ticks(kernel) + ticks(user)) * 100) @@ -225,14 +319,36 @@ fn bench_encode(args: &[String]) { let target = match option(args, "--window") { Some(title) => Target::Window(title.to_string()), - None => Target::Monitor(option(args, "--monitor").and_then(|v| v.parse().ok()).unwrap_or(0)), + None => Target::Monitor( + option(args, "--monitor") + .and_then(|v| v.parse().ok()) + .unwrap_or(0), + ), }; - let seconds: u64 = option(args, "--seconds").and_then(|v| v.parse().ok()).unwrap_or(10); - let fps: u32 = option(args, "--fps").and_then(|v| v.parse().ok()).unwrap_or(30); - let bitrate: u32 = option(args, "--bitrate").and_then(|v| v.parse().ok()).unwrap_or(8_000_000); - let kind = if args.iter().any(|a| a == "--sw") { Kind::Software } else { Kind::Hardware }; - let codec = option(args, "--encoder").map(|n| castbay_encode::ffmpeg::Codec::parse(n).expect("encoder: amf, nvenc, qsv or x264")); - println!("encoding {target:?} for {seconds} s at {fps} fps, {} kbit/s, {}", bitrate / 1000, codec.map(|c| format!("ffmpeg {c:?}")).unwrap_or(format!("Media Foundation {kind:?}"))); + let seconds: u64 = option(args, "--seconds") + .and_then(|v| v.parse().ok()) + .unwrap_or(10); + let fps: u32 = option(args, "--fps") + .and_then(|v| v.parse().ok()) + .unwrap_or(30); + let bitrate: u32 = option(args, "--bitrate") + .and_then(|v| v.parse().ok()) + .unwrap_or(8_000_000); + let kind = if args.iter().any(|a| a == "--sw") { + Kind::Software + } else { + Kind::Hardware + }; + let codec = option(args, "--encoder").map(|n| { + castbay_encode::ffmpeg::Codec::parse(n).expect("encoder: amf, nvenc, qsv or x264") + }); + println!( + "encoding {target:?} for {seconds} s at {fps} fps, {} kbit/s, {}", + bitrate / 1000, + codec + .map(|c| format!("ffmpeg {c:?}")) + .unwrap_or(format!("Media Foundation {kind:?}")) + ); #[derive(Default)] struct Stats { @@ -262,69 +378,80 @@ fn bench_encode(args: &[String]) { let mut next = Duration::ZERO; let cpu_before = cpu_time(); let started = Instant::now(); - let result = castbay_capture::windows::run(&target, || false, move |frame| { - let mut st = shared.lock().unwrap(); - st.offered += 1; - if frame.timestamp < next { - return frame.timestamp < limit; - } - next = next.max(frame.timestamp.saturating_sub(interval)) + interval; - let (w, h) = ((frame.width & !1) as usize, (frame.height & !1) as usize); - if encoder.is_none() { - let config = Config { width: w as u32, height: h as u32, fps, bitrate_bps: bitrate, gop: fps * 2, format: Default::default() }; - let made = match codec { - Some(c) => castbay_encode::ffmpeg::FfmpegEncoder::new(&config, c).map(Any::Ff), - None => MfEncoder::new(config, kind).map(Any::Mf), + let result = castbay_capture::windows::run( + &target, + || false, + move |frame| { + let mut st = shared.lock().unwrap(); + st.offered += 1; + if frame.timestamp < next { + return frame.timestamp < limit; + } + next = next.max(frame.timestamp.saturating_sub(interval)) + interval; + let (w, h) = ((frame.width & !1) as usize, (frame.height & !1) as usize); + if encoder.is_none() { + let config = Config { + width: w as u32, + height: h as u32, + fps, + bitrate_bps: bitrate, + gop: fps * 2, + format: Default::default(), + }; + let made = match codec { + Some(c) => castbay_encode::ffmpeg::FfmpegEncoder::new(&config, c).map(Any::Ff), + None => MfEncoder::new(config, kind).map(Any::Mf), + }; + match made { + Ok(e) => { + st.name = match &e { + Any::Mf(m) => m.name.clone(), + Any::Ff(f) => f.name.clone(), + }; + st.size = (w as u32, h as u32); + nv12 = vec![0; w * h * 3 / 2]; + encoder = Some(e); + } + Err(e) => { + st.error = Some(e.to_string()); + return false; + } + } + } + let t = Instant::now(); + bgra_to_nv12(frame.data, frame.stride, w, h, &mut nv12); + st.convert += t.elapsed(); + let t = Instant::now(); + let pts = frame.timestamp.as_micros() as i64; + let result = match encoder.as_mut().unwrap() { + Any::Mf(e) => e.encode(&nv12, pts), + Any::Ff(e) => e.encode(&nv12, pts), }; - match made { - Ok(e) => { - st.name = match &e { - Any::Mf(m) => m.name.clone(), - Any::Ff(f) => f.name.clone(), - }; - st.size = (w as u32, h as u32); - nv12 = vec![0; w * h * 3 / 2]; - encoder = Some(e); + let took = t.elapsed(); + st.encode += took; + st.worst_encode = st.worst_encode.max(took); + st.encoded += 1; + match result { + Ok(units) => { + for unit in units { + st.units += 1; + st.bytes += unit.data.len() as u64; + st.keys += unit.key as u64; + } } Err(e) => { st.error = Some(e.to_string()); return false; } } - } - let t = Instant::now(); - bgra_to_nv12(frame.data, frame.stride, w, h, &mut nv12); - st.convert += t.elapsed(); - let t = Instant::now(); - let pts = frame.timestamp.as_micros() as i64; - let result = match encoder.as_mut().unwrap() { - Any::Mf(e) => e.encode(&nv12, pts), - Any::Ff(e) => e.encode(&nv12, pts), - }; - let took = t.elapsed(); - st.encode += took; - st.worst_encode = st.worst_encode.max(took); - st.encoded += 1; - match result { - Ok(units) => { - for unit in units { - st.units += 1; - st.bytes += unit.data.len() as u64; - st.keys += unit.key as u64; + if frame.timestamp >= limit { + if let Some(Any::Ff(e)) = &encoder { + st.child_cpu = e.child_cpu(); } } - Err(e) => { - st.error = Some(e.to_string()); - return false; - } - } - if frame.timestamp >= limit { - if let Some(Any::Ff(e)) = &encoder { - st.child_cpu = e.child_cpu(); - } - } - frame.timestamp < limit - }); + frame.timestamp < limit + }, + ); let elapsed = started.elapsed().as_secs_f64(); let st_cpu = stats.lock().unwrap().child_cpu; let cpu = cpu_time() - cpu_before + st_cpu; @@ -334,11 +461,34 @@ fn bench_encode(args: &[String]) { println!("error: {e}"); } println!("encoder: {} ({}x{})", st.name, st.size.0, st.size.1); - println!("pictures offered by capture: {}, encoded: {}, units out: {}, key frames: {}", st.offered, st.encoded, st.units, st.keys); - println!("rate: {:.1} fps in, {:.1} fps out, {:.2} Mbit/s", st.encoded as f64 / elapsed, st.units as f64 / elapsed, st.bytes as f64 * 8.0 / elapsed / 1e6); + println!( + "pictures offered by capture: {}, encoded: {}, units out: {}, key frames: {}", + st.offered, st.encoded, st.units, st.keys + ); + println!( + "rate: {:.1} fps in, {:.1} fps out, {:.2} Mbit/s", + st.encoded as f64 / elapsed, + st.units as f64 / elapsed, + st.bytes as f64 * 8.0 / elapsed / 1e6 + ); let n = st.encoded.max(1) as f64; - println!("per picture: convert {:.2} ms, encode {:.2} ms (worst {:.1} ms)", st.convert.as_secs_f64() * 1000.0 / n, st.encode.as_secs_f64() * 1000.0 / n, st.worst_encode.as_secs_f64() * 1000.0); - println!("CPU (this process + ffmpeg): {:.0} % of one core, {:.0} % of this machine ({} threads)", cpu.as_secs_f64() / elapsed * 100.0, cpu.as_secs_f64() / elapsed * 100.0 / std::thread::available_parallelism().map(|n| n.get()).unwrap_or(1) as f64, std::thread::available_parallelism().map(|n| n.get()).unwrap_or(1)); + println!( + "per picture: convert {:.2} ms, encode {:.2} ms (worst {:.1} ms)", + st.convert.as_secs_f64() * 1000.0 / n, + st.encode.as_secs_f64() * 1000.0 / n, + st.worst_encode.as_secs_f64() * 1000.0 + ); + println!( + "CPU (this process + ffmpeg): {:.0} % of one core, {:.0} % of this machine ({} threads)", + cpu.as_secs_f64() / elapsed * 100.0, + cpu.as_secs_f64() / elapsed * 100.0 + / std::thread::available_parallelism() + .map(|n| n.get()) + .unwrap_or(1) as f64, + std::thread::available_parallelism() + .map(|n| n.get()) + .unwrap_or(1) + ); } #[cfg(not(windows))] @@ -348,12 +498,22 @@ fn bench_encode(_: &[String]) { /// Looks for receivers on the network. fn discover(args: &[String]) { - let seconds: u64 = option(args, "--seconds").and_then(|v| v.parse().ok()).unwrap_or(3); + let seconds: u64 = option(args, "--seconds") + .and_then(|v| v.parse().ok()) + .unwrap_or(3); match castbay_link::browse(Duration::from_secs(seconds)) { Ok(found) if found.is_empty() => println!("no receivers found"), Ok(found) => { for r in found { - println!("{} (id {}): {:?} port {}, verification {:?}{}", r.name, r.id, r.addresses, r.port, r.pair, if r.password { ", password" } else { "" }); + println!( + "{} (id {}): {:?} port {}, verification {:?}{}", + r.name, + r.id, + r.addresses, + r.port, + r.pair, + if r.password { ", password" } else { "" } + ); } } Err(e) => eprintln!("{e}"), @@ -371,7 +531,9 @@ fn data_dir(args: &[String]) -> std::path::PathBuf { // Elsewhere: the XDG data folder. let share = std::env::var_os("XDG_DATA_HOME") .map(std::path::PathBuf::from) - .or_else(|| std::env::var_os("HOME").map(|h| std::path::PathBuf::from(h).join(".local/share"))) + .or_else(|| { + std::env::var_os("HOME").map(|h| std::path::PathBuf::from(h).join(".local/share")) + }) .unwrap_or_else(|| ".".into()); share.join("castbay-desktop") } @@ -385,26 +547,51 @@ fn cast(args: &[String]) { let target = match option(args, "--window") { Some(title) => Target::Window(title.to_string()), - None => Target::Monitor(option(args, "--monitor").and_then(|v| v.parse().ok()).unwrap_or(0)), + None => Target::Monitor( + option(args, "--monitor") + .and_then(|v| v.parse().ok()) + .unwrap_or(0), + ), }; - let seconds: u64 = option(args, "--seconds").and_then(|v| v.parse().ok()).unwrap_or(30); - let fps: u32 = option(args, "--fps").and_then(|v| v.parse().ok()).unwrap_or(30); - let bitrate: u32 = option(args, "--bitrate").and_then(|v| v.parse().ok()).unwrap_or(8_000_000); - let codec = Codec::parse(option(args, "--encoder").unwrap_or("amf")).expect("encoder: amf, nvenc, qsv or x264"); + let seconds: u64 = option(args, "--seconds") + .and_then(|v| v.parse().ok()) + .unwrap_or(30); + let fps: u32 = option(args, "--fps") + .and_then(|v| v.parse().ok()) + .unwrap_or(30); + let bitrate: u32 = option(args, "--bitrate") + .and_then(|v| v.parse().ok()) + .unwrap_or(8_000_000); + let codec = Codec::parse(option(args, "--encoder").unwrap_or("amf")) + .expect("encoder: amf, nvenc, qsv or x264"); // Which receiver: by address, or found by name. let (addr, receiver_id) = match (option(args, "--host"), option(args, "--receiver")) { (Some(host), _) => { - let port: u16 = option(args, "--port").and_then(|v| v.parse().ok()).expect("--host needs --port"); - (std::net::SocketAddr::new(host.parse().expect("an IP address"), port), option(args, "--id").map(str::to_string)) + let port: u16 = option(args, "--port") + .and_then(|v| v.parse().ok()) + .expect("--host needs --port"); + ( + std::net::SocketAddr::new(host.parse().expect("an IP address"), port), + option(args, "--id").map(str::to_string), + ) } (None, Some(name)) => { let found = castbay_link::browse(Duration::from_secs(4)).expect("discovery"); - let r = found.into_iter().find(|r| r.name.contains(name)).unwrap_or_else(|| { - eprintln!("no receiver named like \"{name}\" found"); - std::process::exit(1); - }); - let ip = r.addresses.iter().find(|a| a.is_ipv4()).or(r.addresses.first()).copied().expect("an address"); + let r = found + .into_iter() + .find(|r| r.name.contains(name)) + .unwrap_or_else(|| { + eprintln!("no receiver named like \"{name}\" found"); + std::process::exit(1); + }); + let ip = r + .addresses + .iter() + .find(|a| a.is_ipv4()) + .or(r.addresses.first()) + .copied() + .expect("an address"); println!("found {} at {ip}:{}", r.name, r.port); (std::net::SocketAddr::new(ip, r.port), Some(r.id)) } @@ -430,20 +617,37 @@ fn cast(args: &[String]) { let options = Options { addr, receiver_id, - name: option(args, "--name").map(str::to_string).unwrap_or_else(|| std::env::var("COMPUTERNAME").unwrap_or_else(|_| "Computer".into())), + name: option(args, "--name") + .map(str::to_string) + .unwrap_or_else(|| std::env::var("COMPUTERNAME").unwrap_or_else(|_| "Computer".into())), password: option(args, "--password").map(str::to_string), target: target.clone(), fps, bitrate_bps: bitrate, codec: Some(codec), - video_format: castbay_sender::FormatChoice::parse(option(args, "--format").unwrap_or("h264")).expect("--format: h264, auto or h265"), + video_format: castbay_sender::FormatChoice::parse( + option(args, "--format").unwrap_or("h264"), + ) + .expect("--format: h264, auto or h265"), audio: args.iter().any(|a| a == "--audio"), - max_size: (option(args, "--max-width").and_then(|v| v.parse().ok()).unwrap_or(1920), option(args, "--max-height").and_then(|v| v.parse().ok()).unwrap_or(1080)), + max_size: ( + option(args, "--max-width") + .and_then(|v| v.parse().ok()) + .unwrap_or(1920), + option(args, "--max-height") + .and_then(|v| v.parse().ok()) + .unwrap_or(1080), + ), data_dir: data_dir(args), max_duration: Some(Duration::from_secs(seconds)), }; let on_status = Arc::new(move |status: Status| match status { - Status::Casting { receiver, width, height, format } => { + Status::Casting { + receiver, + width, + height, + format, + } => { println!("casting {target:?} ({width}x{height}) to {receiver} for {seconds} s at {fps} fps, {} kbit/s, {codec:?}, {format}", bitrate / 1000) } Status::Reconnecting(reason) => println!("connection lost ({reason}); reconnecting"), @@ -461,14 +665,25 @@ fn cast(args: &[String]) { println!("ended: {}", report.ended); println!( "units sent: {} ({} dropped, {} repeated pictures), {:.2} Mbit/s, {:.1} fps", - report.units_sent, report.units_dropped, report.repeated_pictures, report.bytes as f64 * 8.0 / report.seconds / 1e6, report.units_sent as f64 / report.seconds + report.units_sent, + report.units_dropped, + report.repeated_pictures, + report.bytes as f64 * 8.0 / report.seconds / 1e6, + report.units_sent as f64 / report.seconds ); if report.audio_frames > 0 { println!("audio: {} AAC frames sent", report.audio_frames); } - println!("capture delivered {} pictures, {} went to the encoder", report.pictures_seen, report.pictures_taken); + println!( + "capture delivered {} pictures, {} went to the encoder", + report.pictures_seen, report.pictures_taken + ); if report.bitrate_changes > 0 { - println!("bitrate changed {} time(s), now {:.1} Mbit/s", report.bitrate_changes, report.final_bitrate_bps as f64 / 1e6); + println!( + "bitrate changed {} time(s), now {:.1} Mbit/s", + report.bitrate_changes, + report.final_bitrate_bps as f64 / 1e6 + ); } if report.reconnects > 0 { println!("reconnected {} time(s)", report.reconnects); @@ -478,7 +693,12 @@ fn cast(args: &[String]) { } if !report.lags_ms.is_empty() { let at = |q: f64| report.lags_ms[((report.lags_ms.len() - 1) as f64 * q) as usize]; - println!("captured to ready to send: median {:.0} ms, 95th {:.0} ms, worst {:.0} ms", at(0.5), at(0.95), at(1.0)); + println!( + "captured to ready to send: median {:.0} ms, 95th {:.0} ms, worst {:.0} ms", + at(0.5), + at(0.95), + at(1.0) + ); } } diff --git a/desktop/core/encode/build.rs b/desktop/core/encode/build.rs index 90f5a32..5864078 100644 --- a/desktop/core/encode/build.rs +++ b/desktop/core/encode/build.rs @@ -6,16 +6,27 @@ fn main() { if std::env::var_os("CARGO_FEATURE_FFMPEG_LIB").is_none() { return; } - let dir = std::env::var_os("FFMPEG_DIR").map(std::path::PathBuf::from).unwrap_or_else(|| { - std::path::Path::new(&std::env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("../../build/ffmpeg") - }); - cc::Build::new().file("csrc/shim.c").include(dir.join("include")).compile("castbay_shim"); - println!("cargo:rustc-link-search=native={}", dir.join("lib").display()); + let dir = std::env::var_os("FFMPEG_DIR") + .map(std::path::PathBuf::from) + .unwrap_or_else(|| { + std::path::Path::new(&std::env::var_os("CARGO_MANIFEST_DIR").unwrap()) + .join("../../build/ffmpeg") + }); + cc::Build::new() + .file("csrc/shim.c") + .include(dir.join("include")) + .compile("castbay_shim"); + println!( + "cargo:rustc-link-search=native={}", + dir.join("lib").display() + ); for lib in ["avcodec", "avutil", "x264"] { println!("cargo:rustc-link-lib=static={lib}"); } if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") { - for lib in ["bcrypt", "ole32", "user32", "ws2_32", "secur32", "advapi32", "oleaut32", "uuid"] { + for lib in [ + "bcrypt", "ole32", "user32", "ws2_32", "secur32", "advapi32", "oleaut32", "uuid", + ] { println!("cargo:rustc-link-lib={lib}"); } } diff --git a/desktop/core/encode/src/ffmpeg.rs b/desktop/core/encode/src/ffmpeg.rs index 23d54b8..818c5c4 100644 --- a/desktop/core/encode/src/ffmpeg.rs +++ b/desktop/core/encode/src/ffmpeg.rs @@ -36,17 +36,75 @@ impl Codec { let gop = config.gop.to_string(); let mut a: Vec<&str> = Vec::new(); match self { - Codec::Amf => a.extend(["-c:v", "h264_amf", "-usage", "ultralowlatency", "-quality", "speed", "-rc", "cbr", "-bf", "0", "-async_depth", "1", "-forced_idr", "1", "-header_spacing", "1"]), - Codec::Nvenc => a.extend(["-c:v", "h264_nvenc", "-preset", "p1", "-tune", "ll", "-zerolatency", "1", "-rc", "cbr", "-bf", "0"]), - Codec::Qsv => a.extend(["-c:v", "h264_qsv", "-preset", "veryfast", "-look_ahead", "0", "-bf", "0"]), - Codec::X264 => a.extend(["-c:v", "libx264", "-preset", "ultrafast", "-tune", "zerolatency", "-bf", "0"]), + Codec::Amf => a.extend([ + "-c:v", + "h264_amf", + "-usage", + "ultralowlatency", + "-quality", + "speed", + "-rc", + "cbr", + "-bf", + "0", + "-async_depth", + "1", + "-forced_idr", + "1", + "-header_spacing", + "1", + ]), + Codec::Nvenc => a.extend([ + "-c:v", + "h264_nvenc", + "-preset", + "p1", + "-tune", + "ll", + "-zerolatency", + "1", + "-rc", + "cbr", + "-bf", + "0", + ]), + Codec::Qsv => a.extend([ + "-c:v", + "h264_qsv", + "-preset", + "veryfast", + "-look_ahead", + "0", + "-bf", + "0", + ]), + Codec::X264 => a.extend([ + "-c:v", + "libx264", + "-preset", + "ultrafast", + "-tune", + "zerolatency", + "-bf", + "0", + ]), } let mut out: Vec = a.into_iter().map(String::from).collect(); - out.extend(["-b:v".into(), rate.clone(), "-maxrate".into(), rate, "-g".into(), gop]); + out.extend([ + "-b:v".into(), + rate.clone(), + "-maxrate".into(), + rate, + "-g".into(), + gop, + ]); if self == Codec::Amf { // h264_amf ignores -g (one key frame per stream); timed key frames work. let seconds = (config.gop as f64 / config.fps as f64).max(1.0); - out.extend(["-force_key_frames".into(), format!("expr:gte(t,n_forced*{seconds})")]); + out.extend([ + "-force_key_frames".into(), + format!("expr:gte(t,n_forced*{seconds})"), + ]); } out } @@ -62,7 +120,9 @@ pub struct FfmpegEncoder { } fn ffmpeg_path() -> PathBuf { - std::env::var_os("CASTBAY_FFMPEG").map(PathBuf::from).unwrap_or_else(|| PathBuf::from("ffmpeg")) + std::env::var_os("CASTBAY_FFMPEG") + .map(PathBuf::from) + .unwrap_or_else(|| PathBuf::from("ffmpeg")) } impl FfmpegEncoder { @@ -70,10 +130,37 @@ impl FfmpegEncoder { let size = format!("{}x{}", config.width, config.height); let mut command = Command::new(ffmpeg_path()); command - .args(["-hide_banner", "-loglevel", "error", "-fflags", "nobuffer", "-flags", "low_delay"]) - .args(["-f", "rawvideo", "-pix_fmt", "nv12", "-s", &size, "-r", &config.fps.to_string(), "-i", "-"]) + .args([ + "-hide_banner", + "-loglevel", + "error", + "-fflags", + "nobuffer", + "-flags", + "low_delay", + ]) + .args([ + "-f", + "rawvideo", + "-pix_fmt", + "nv12", + "-s", + &size, + "-r", + &config.fps.to_string(), + "-i", + "-", + ]) .args(codec.args(config)) - .args(["-bsf:v", "h264_metadata=aud=insert", "-flush_packets", "1", "-f", "h264", "-"]) + .args([ + "-bsf:v", + "h264_metadata=aud=insert", + "-flush_packets", + "1", + "-f", + "h264", + "-", + ]) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::inherit()); @@ -82,9 +169,14 @@ impl FfmpegEncoder { use std::os::windows::process::CommandExt; command.creation_flags(0x0800_0000); // CREATE_NO_WINDOW } - let mut child = command.spawn().map_err(|e| Error(format!("cannot start ffmpeg: {e}")))?; + let mut child = command + .spawn() + .map_err(|e| Error(format!("cannot start ffmpeg: {e}")))?; let stdin = child.stdin.take(); - let mut stdout = child.stdout.take().ok_or_else(|| Error("no ffmpeg output".into()))?; + let mut stdout = child + .stdout + .take() + .ok_or_else(|| Error("no ffmpeg output".into()))?; let (send, units) = channel(); let reader = std::thread::spawn(move || { // Cut the stream at access unit delimiters (NAL type 9): a unit is complete when @@ -100,7 +192,11 @@ impl FfmpegEncoder { let mut start = 0; let mut i = 1; while i + 3 < pending.len() { - if pending[i] == 0 && pending[i + 1] == 0 && pending[i + 2] == 1 && pending[i + 3] & 0x1F == 9 { + if pending[i] == 0 + && pending[i + 1] == 0 + && pending[i + 2] == 1 + && pending[i + 3] & 0x1F == 9 + { let cut = if pending[i - 1] == 0 { i - 1 } else { i }; // A unit that is only a delimiter (the encoder wrote its own) belongs to the next one. if cut > start + 6 && send.send(pending[start..cut].to_vec()).is_err() { @@ -131,12 +227,17 @@ impl FfmpegEncoder { /// a picture is complete only when the next picture's delimiter arrives, so output lags /// the input by one picture. pub fn encode(&mut self, nv12: &[u8], pts_us: i64) -> Result, Error> { - let stdin = self.stdin.as_mut().ok_or_else(|| Error("ffmpeg closed".into()))?; + let stdin = self + .stdin + .as_mut() + .ok_or_else(|| Error("ffmpeg closed".into()))?; let trace = std::env::var_os("CASTBAY_TRACE").is_some(); if trace { eprintln!("[ffmpeg] writing {} bytes", nv12.len()); } - stdin.write_all(nv12).map_err(|e| Error(format!("ffmpeg input: {e}")))?; + stdin + .write_all(nv12) + .map_err(|e| Error(format!("ffmpeg input: {e}")))?; if trace { eprintln!("[ffmpeg] written"); } @@ -144,7 +245,11 @@ impl FfmpegEncoder { let mut out = Vec::new(); while let Ok(data) = self.units.try_recv() { let key = nal_types(&data).contains(&5); - out.push(Encoded { data, key, pts_us: self.pending_pts.pop_front().unwrap_or(0) }); + out.push(Encoded { + data, + key, + pts_us: self.pending_pts.pop_front().unwrap_or(0), + }); } Ok(out) } @@ -157,10 +262,20 @@ impl FfmpegEncoder { use std::os::windows::io::AsRawHandle; use windows::Win32::Foundation::{FILETIME, HANDLE}; use windows::Win32::System::Threading::GetProcessTimes; - let (mut create, mut exit, mut kernel, mut user) = - (FILETIME::default(), FILETIME::default(), FILETIME::default(), FILETIME::default()); + let (mut create, mut exit, mut kernel, mut user) = ( + FILETIME::default(), + FILETIME::default(), + FILETIME::default(), + FILETIME::default(), + ); unsafe { - let _ = GetProcessTimes(HANDLE(self.child.as_raw_handle()), &mut create, &mut exit, &mut kernel, &mut user); + let _ = GetProcessTimes( + HANDLE(self.child.as_raw_handle()), + &mut create, + &mut exit, + &mut kernel, + &mut user, + ); } let ticks = |t: FILETIME| ((t.dwHighDateTime as u64) << 32) | t.dwLowDateTime as u64; std::time::Duration::from_nanos((ticks(kernel) + ticks(user)) * 100) diff --git a/desktop/core/encode/src/inproc.rs b/desktop/core/encode/src/inproc.rs index 3059039..c431d6f 100644 --- a/desktop/core/encode/src/inproc.rs +++ b/desktop/core/encode/src/inproc.rs @@ -50,8 +50,14 @@ impl InProcessEncoder { (Codec::Nvenc, VideoFormat::H264) => "h264_nvenc", (Codec::Nvenc, VideoFormat::H265) => "hevc_nvenc", (Codec::X264, VideoFormat::H264) => "libx264", - (Codec::X264, VideoFormat::H265) => return Err(Error("the CPU encoder makes H.264 only".into())), - (Codec::Qsv, _) => return Err(Error("Intel Quick Sync is not built into the in-process encoder yet".into())), + (Codec::X264, VideoFormat::H265) => { + return Err(Error("the CPU encoder makes H.264 only".into())) + } + (Codec::Qsv, _) => { + return Err(Error( + "Intel Quick Sync is not built into the in-process encoder yet".into(), + )) + } }; let cname = CString::new(name).unwrap(); let mut err = [0 as c_char; 256]; @@ -68,21 +74,40 @@ impl InProcessEncoder { ) }; if enc.is_null() { - let text = unsafe { std::ffi::CStr::from_ptr(err.as_ptr()) }.to_string_lossy().into_owned(); + let text = unsafe { std::ffi::CStr::from_ptr(err.as_ptr()) } + .to_string_lossy() + .into_owned(); return Err(Error(format!("{name}: {text}"))); } - Ok(Self { enc, frame_len: (config.width * config.height * 3 / 2) as usize }) + Ok(Self { + enc, + frame_len: (config.width * config.height * 3 / 2) as usize, + }) } /// Encodes one NV12 picture. `force_key` makes it an IDR picture. Returns the access unit /// that is ready, if any (none while the encoder is still filling). - pub fn encode(&mut self, nv12: &[u8], pts_us: i64, force_key: bool) -> Result, Error> { + pub fn encode( + &mut self, + nv12: &[u8], + pts_us: i64, + force_key: bool, + ) -> Result, Error> { if nv12.len() < self.frame_len { return Err(Error("picture is smaller than the configured size".into())); } let (mut out, mut len, mut key, mut out_pts) = (std::ptr::null(), 0, 0, 0i64); let r = unsafe { - cb_enc_encode(self.enc, nv12.as_ptr(), pts_us, force_key as c_int, &mut out, &mut len, &mut key, &mut out_pts) + cb_enc_encode( + self.enc, + nv12.as_ptr(), + pts_us, + force_key as c_int, + &mut out, + &mut len, + &mut key, + &mut out_pts, + ) }; match r { 1 => Ok(Some(Encoded { @@ -108,10 +133,21 @@ struct CbAac { } extern "C" { - fn cb_aac_open(sample_rate: c_int, channels: c_int, bitrate: c_int, err: *mut c_char, errlen: c_int) -> *mut CbAac; + fn cb_aac_open( + sample_rate: c_int, + channels: c_int, + bitrate: c_int, + err: *mut c_char, + errlen: c_int, + ) -> *mut CbAac; fn cb_aac_frame_size(e: *mut CbAac) -> c_int; fn cb_aac_config(e: *mut CbAac, out: *mut u8, cap: c_int) -> c_int; - fn cb_aac_encode(e: *mut CbAac, interleaved: *const f32, out: *mut *const u8, out_len: *mut c_int) -> c_int; + fn cb_aac_encode( + e: *mut CbAac, + interleaved: *const f32, + out: *mut *const u8, + out_len: *mut c_int, + ) -> c_int; fn cb_aac_close(e: *mut CbAac); } @@ -127,13 +163,27 @@ unsafe impl Send for AacEncoder {} impl AacEncoder { pub fn new(sample_rate: u32, channels: u32, bitrate_bps: u32) -> Result { let mut err = [0 as c_char; 256]; - let enc = unsafe { cb_aac_open(sample_rate as c_int, channels as c_int, bitrate_bps as c_int, err.as_mut_ptr(), err.len() as c_int) }; + let enc = unsafe { + cb_aac_open( + sample_rate as c_int, + channels as c_int, + bitrate_bps as c_int, + err.as_mut_ptr(), + err.len() as c_int, + ) + }; if enc.is_null() { - let text = unsafe { std::ffi::CStr::from_ptr(err.as_ptr()) }.to_string_lossy().into_owned(); + let text = unsafe { std::ffi::CStr::from_ptr(err.as_ptr()) } + .to_string_lossy() + .into_owned(); return Err(Error(format!("aac: {text}"))); } let frame_samples = unsafe { cb_aac_frame_size(enc) } as usize; - Ok(Self { enc, channels: channels as usize, frame_samples }) + Ok(Self { + enc, + channels: channels as usize, + frame_samples, + }) } /// Samples per channel that go into each [`AacEncoder::encode`] call (1024). @@ -155,7 +205,9 @@ impl AacEncoder { } let (mut out, mut len) = (std::ptr::null(), 0); match unsafe { cb_aac_encode(self.enc, interleaved.as_ptr(), &mut out, &mut len) } { - 1 => Ok(Some(unsafe { std::slice::from_raw_parts(out, len as usize) }.to_vec())), + 1 => Ok(Some( + unsafe { std::slice::from_raw_parts(out, len as usize) }.to_vec(), + )), 0 => Ok(None), code => Err(Error(format!("aac encode failed ({code})"))), } diff --git a/desktop/core/encode/src/lib.rs b/desktop/core/encode/src/lib.rs index c1d3936..48390fd 100644 --- a/desktop/core/encode/src/lib.rs +++ b/desktop/core/encode/src/lib.rs @@ -75,7 +75,10 @@ impl std::error::Error for Error {} pub fn bgra_to_nv12(src: &[u8], stride: usize, width: usize, height: usize, out: &mut [u8]) { assert!(width % 2 == 0 && height % 2 == 0 && out.len() >= width * height * 3 / 2); let (luma, chroma) = out.split_at_mut(width * height); - let threads = std::thread::available_parallelism().map(|n| n.get()).unwrap_or(2).min(8); + let threads = std::thread::available_parallelism() + .map(|n| n.get()) + .unwrap_or(2) + .min(8); let pairs = height / 2; let per = pairs.div_ceil(threads); std::thread::scope(|scope| { @@ -103,15 +106,18 @@ pub fn bgra_to_nv12(src: &[u8], stride: usize, width: usize, height: usize, out: for dx in 0..2 { let p = &row[(x + dx) * 4..][..4]; let (pb, pg, pr) = (p[0] as i32, p[1] as i32, p[2] as i32); - ly[x + dx] = (((47 * pr + 157 * pg + 16 * pb + 128) >> 8) + 16) as u8; + ly[x + dx] = + (((47 * pr + 157 * pg + 16 * pb + 128) >> 8) + 16) as u8; r += pr; g += pg; b += pb; } } let (r, g, b) = ((r + 2) >> 2, (g + 2) >> 2, (b + 2) >> 2); - cuv[x] = ((((-26 * r - 87 * g + 112 * b + 128) >> 8) + 128).clamp(0, 255)) as u8; - cuv[x + 1] = ((((112 * r - 102 * g - 10 * b + 128) >> 8) + 128).clamp(0, 255)) as u8; + cuv[x] = + ((((-26 * r - 87 * g + 112 * b + 128) >> 8) + 128).clamp(0, 255)) as u8; + cuv[x + 1] = + ((((112 * r - 102 * g - 10 * b + 128) >> 8) + 128).clamp(0, 255)) as u8; } } }); diff --git a/desktop/core/encode/src/scale.rs b/desktop/core/encode/src/scale.rs index 259aeac..fc5f2e3 100644 --- a/desktop/core/encode/src/scale.rs +++ b/desktop/core/encode/src/scale.rs @@ -21,7 +21,15 @@ pub fn fit_size(w: u32, h: u32, max_w: u32, max_h: u32) -> (u32, u32) { /// Converts a BGRA picture of `sw`x`sh` to NV12 (BT.709 limited range) of exactly `dw`x`dh` /// into `out` (`dw * dh * 3 / 2` bytes). The picture is scaled down to fit, never up, keeping its /// shape and centred; what is left is black. Same size in and out is the plain fast conversion. -pub fn bgra_to_nv12_fit(src: &[u8], stride: usize, sw: usize, sh: usize, dw: usize, dh: usize, out: &mut [u8]) { +pub fn bgra_to_nv12_fit( + src: &[u8], + stride: usize, + sw: usize, + sh: usize, + dw: usize, + dh: usize, + out: &mut [u8], +) { assert!(dw % 2 == 0 && dh % 2 == 0 && out.len() >= dw * dh * 3 / 2 && sw >= 2 && sh >= 2); if sw == dw && sh == dh { return bgra_to_nv12(src, stride, sw & !1, sh & !1, out); @@ -44,7 +52,10 @@ pub fn bgra_to_nv12_fit(src: &[u8], stride: usize, sw: usize, sh: usize, dw: usi .filter(|(pair, _)| pair * 2 >= oy && pair * 2 < oy + fh) .map(|(pair, (l, c))| (pair, l, c)) .collect(); - let threads = std::thread::available_parallelism().map(|n| n.get()).unwrap_or(2).min(8); + let threads = std::thread::available_parallelism() + .map(|n| n.get()) + .unwrap_or(2) + .min(8); let per = jobs.len().div_ceil(threads).max(1); std::thread::scope(|scope| { while !jobs.is_empty() { @@ -56,16 +67,28 @@ pub fn bgra_to_nv12_fit(src: &[u8], stride: usize, sw: usize, sh: usize, dw: usi let (mut r, mut g, mut b) = (0i32, 0i32, 0i32); for dy in 0..2 { for dx in 0..2 { - let (pr, pg, pb) = average(src, stride, sw, sh, fw, fh, x + dx - ox, pair * 2 + dy - oy); - l[dy * dw + x + dx] = (((47 * pr + 157 * pg + 16 * pb + 128) >> 8) + 16) as u8; + let (pr, pg, pb) = average( + src, + stride, + sw, + sh, + fw, + fh, + x + dx - ox, + pair * 2 + dy - oy, + ); + l[dy * dw + x + dx] = + (((47 * pr + 157 * pg + 16 * pb + 128) >> 8) + 16) as u8; r += pr; g += pg; b += pb; } } let (r, g, b) = ((r + 2) >> 2, (g + 2) >> 2, (b + 2) >> 2); - c[x] = ((((-26 * r - 87 * g + 112 * b + 128) >> 8) + 128).clamp(0, 255)) as u8; - c[x + 1] = ((((112 * r - 102 * g - 10 * b + 128) >> 8) + 128).clamp(0, 255)) as u8; + c[x] = + ((((-26 * r - 87 * g + 112 * b + 128) >> 8) + 128).clamp(0, 255)) as u8; + c[x + 1] = + ((((112 * r - 102 * g - 10 * b + 128) >> 8) + 128).clamp(0, 255)) as u8; } } }); @@ -75,7 +98,16 @@ pub fn bgra_to_nv12_fit(src: &[u8], stride: usize, sw: usize, sh: usize, dw: usi /// The average colour of the source area that output pixel (`u`, `v`) of a `fw`x`fh` picture covers. #[allow(clippy::too_many_arguments)] -fn average(src: &[u8], stride: usize, sw: usize, sh: usize, fw: usize, fh: usize, u: usize, v: usize) -> (i32, i32, i32) { +fn average( + src: &[u8], + stride: usize, + sw: usize, + sh: usize, + fw: usize, + fh: usize, + u: usize, + v: usize, +) -> (i32, i32, i32) { let x0 = u * sw / fw; let x1 = ((u + 1) * sw / fw).clamp(x0 + 1, sw); let y0 = v * sh / fh; @@ -90,7 +122,11 @@ fn average(src: &[u8], stride: usize, sw: usize, sh: usize, fw: usize, fh: usize } } let n = ((x1 - x0) * (y1 - y0)) as u32; - (((r + n / 2) / n) as i32, ((g + n / 2) / n) as i32, ((b + n / 2) / n) as i32) + ( + ((r + n / 2) / n) as i32, + ((g + n / 2) / n) as i32, + ((b + n / 2) / n) as i32, + ) } #[cfg(test)] @@ -139,7 +175,12 @@ mod tests { let mut out = vec![0u8; 4 * 6 * 3 / 2]; bgra_to_nv12_fit(&src, 8 * 4, 8, 4, 4, 6, &mut out); let row = |y: usize| &out[y * 4..y * 4 + 4]; - assert!(row(0).iter().chain(row(1)).chain(row(4)).chain(row(5)).all(|&y| y == 16)); + assert!(row(0) + .iter() + .chain(row(1)) + .chain(row(4)) + .chain(row(5)) + .all(|&y| y == 16)); assert!(row(2).iter().chain(row(3)).all(|&y| y >= 234)); // The chroma of the bars is neutral. assert_eq!(&out[24..28], &[128, 128, 128, 128]); diff --git a/desktop/core/encode/src/windows.rs b/desktop/core/encode/src/windows.rs index e9ff35d..5116cc2 100644 --- a/desktop/core/encode/src/windows.rs +++ b/desktop/core/encode/src/windows.rs @@ -6,14 +6,14 @@ use std::time::{Duration, Instant}; use windows::core::{Interface, GUID}; use windows::Win32::Foundation::HMODULE; -use windows::Win32::System::Variant::{VARIANT, VARIANT_0, VARIANT_0_0, VARIANT_0_0_0, VT_UI4}; -use windows::Win32::Media::MediaFoundation::*; -use windows::Win32::Graphics::Direct3D::{D3D_DRIVER_TYPE_HARDWARE}; +use windows::Win32::Graphics::Direct3D::D3D_DRIVER_TYPE_HARDWARE; use windows::Win32::Graphics::Direct3D11::{ - D3D11CreateDevice, ID3D11Device, ID3D11Multithread, D3D11_CREATE_DEVICE_BGRA_SUPPORT, D3D11_CREATE_DEVICE_VIDEO_SUPPORT, - D3D11_SDK_VERSION, + D3D11CreateDevice, ID3D11Device, ID3D11Multithread, D3D11_CREATE_DEVICE_BGRA_SUPPORT, + D3D11_CREATE_DEVICE_VIDEO_SUPPORT, D3D11_SDK_VERSION, }; +use windows::Win32::Media::MediaFoundation::*; use windows::Win32::System::Com::{CoInitializeEx, CoTaskMemFree, COINIT_MULTITHREADED}; +use windows::Win32::System::Variant::{VARIANT, VARIANT_0, VARIANT_0_0, VARIANT_0_0_0, VT_UI4}; use crate::{nal_types, Config, Encoded, Error}; @@ -70,7 +70,12 @@ fn set_u32(codec: &ICodecAPI, api: &GUID, value: u32) { } /// Two 32-bit values packed in one 64-bit attribute (frame size, frame rate, aspect ratio). -fn set_pair(attributes: &IMFMediaType, key: &GUID, high: u32, low: u32) -> windows::core::Result<()> { +fn set_pair( + attributes: &IMFMediaType, + key: &GUID, + high: u32, + low: u32, +) -> windows::core::Result<()> { unsafe { attributes.SetUINT64(key, ((high as u64) << 32) | low as u64) } } @@ -82,15 +87,25 @@ impl MfEncoder { MFStartup(MF_VERSION, MFSTARTUP_FULL).map_err(|e| err("MFStartup", e))?; trace("enumerate"); - let output = MFT_REGISTER_TYPE_INFO { guidMajorType: MFMediaType_Video, guidSubtype: MFVideoFormat_H264 }; + let output = MFT_REGISTER_TYPE_INFO { + guidMajorType: MFMediaType_Video, + guidSubtype: MFVideoFormat_H264, + }; let flags = match kind { Kind::Hardware => MFT_ENUM_FLAG_HARDWARE | MFT_ENUM_FLAG_SORTANDFILTER, Kind::Software => MFT_ENUM_FLAG_SYNCMFT | MFT_ENUM_FLAG_SORTANDFILTER, }; let mut list: *mut Option = std::ptr::null_mut(); let mut count = 0u32; - MFTEnumEx(MFT_CATEGORY_VIDEO_ENCODER, flags, None, Some(&output), &mut list, &mut count) - .map_err(|e| err("MFTEnumEx", e))?; + MFTEnumEx( + MFT_CATEGORY_VIDEO_ENCODER, + flags, + None, + Some(&output), + &mut list, + &mut count, + ) + .map_err(|e| err("MFTEnumEx", e))?; if count == 0 || list.is_null() { return Err(Error(format!("no {kind:?} H.264 encoder found"))); } @@ -100,7 +115,10 @@ impl MfEncoder { let mut name = String::new(); let mut buffer = [0u16; 256]; let mut length = 0u32; - if activate.GetString(&MFT_FRIENDLY_NAME_Attribute, &mut buffer, Some(&mut length)).is_ok() { + if activate + .GetString(&MFT_FRIENDLY_NAME_Attribute, &mut buffer, Some(&mut length)) + .is_ok() + { name = String::from_utf16_lossy(&buffer[..length as usize]); } match activate.ActivateObject::() { @@ -116,7 +134,8 @@ impl MfEncoder { } CoTaskMemFree(Some(list as *const _)); trace("activated"); - let (transform, name) = chosen.ok_or_else(|| Error("no encoder could be created".into()))?; + let (transform, name) = + chosen.ok_or_else(|| Error("no encoder could be created".into()))?; let attributes = transform.GetAttributes().ok(); let is_async = attributes @@ -125,59 +144,103 @@ impl MfEncoder { .unwrap_or(false); if is_async { if let Some(a) = &attributes { - a.SetUINT32(&MF_TRANSFORM_ASYNC_UNLOCK, 1).map_err(|e| err("async unlock", e))?; + a.SetUINT32(&MF_TRANSFORM_ASYNC_UNLOCK, 1) + .map_err(|e| err("async unlock", e))?; } } if let Some(a) = &attributes { let _ = a.SetUINT32(&MF_LOW_LATENCY, 1); } - let events = if is_async { transform.cast::().ok() } else { None }; + let events = if is_async { + transform.cast::().ok() + } else { + None + }; trace(&format!("async={is_async}")); // Hardware encoders want a Direct3D device to work on; AMD's one crashes without it. let knobs = std::env::var("CASTBAY_KNOBS").unwrap_or_default(); - let device = if kind == Kind::Hardware && !knobs.contains('d') { Some(Self::attach_device(&transform)?) } else { None }; + let device = if kind == Kind::Hardware && !knobs.contains('d') { + Some(Self::attach_device(&transform)?) + } else { + None + }; trace("device attached"); // The output type first: encoders choose their input types from it. let out_type = MFCreateMediaType().map_err(|e| err("output type", e))?; - out_type.SetGUID(&MF_MT_MAJOR_TYPE, &MFMediaType_Video).map_err(|e| err("major", e))?; - out_type.SetGUID(&MF_MT_SUBTYPE, &MFVideoFormat_H264).map_err(|e| err("subtype", e))?; - out_type.SetUINT32(&MF_MT_AVG_BITRATE, config.bitrate_bps).map_err(|e| err("bitrate", e))?; - set_pair(&out_type, &MF_MT_FRAME_SIZE, config.width, config.height).map_err(|e| err("size", e))?; + out_type + .SetGUID(&MF_MT_MAJOR_TYPE, &MFMediaType_Video) + .map_err(|e| err("major", e))?; + out_type + .SetGUID(&MF_MT_SUBTYPE, &MFVideoFormat_H264) + .map_err(|e| err("subtype", e))?; + out_type + .SetUINT32(&MF_MT_AVG_BITRATE, config.bitrate_bps) + .map_err(|e| err("bitrate", e))?; + set_pair(&out_type, &MF_MT_FRAME_SIZE, config.width, config.height) + .map_err(|e| err("size", e))?; set_pair(&out_type, &MF_MT_FRAME_RATE, config.fps, 1).map_err(|e| err("rate", e))?; set_pair(&out_type, &MF_MT_PIXEL_ASPECT_RATIO, 1, 1).map_err(|e| err("aspect", e))?; - out_type.SetUINT32(&MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive.0 as u32).map_err(|e| err("interlace", e))?; - out_type.SetUINT32(&MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_High.0 as u32).map_err(|e| err("profile", e))?; - transform.SetOutputType(0, &out_type, 0).map_err(|e| err("SetOutputType", e))?; + out_type + .SetUINT32(&MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive.0 as u32) + .map_err(|e| err("interlace", e))?; + out_type + .SetUINT32(&MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_High.0 as u32) + .map_err(|e| err("profile", e))?; + transform + .SetOutputType(0, &out_type, 0) + .map_err(|e| err("SetOutputType", e))?; let in_type = MFCreateMediaType().map_err(|e| err("input type", e))?; - in_type.SetGUID(&MF_MT_MAJOR_TYPE, &MFMediaType_Video).map_err(|e| err("major", e))?; - in_type.SetGUID(&MF_MT_SUBTYPE, &MFVideoFormat_NV12).map_err(|e| err("subtype", e))?; - set_pair(&in_type, &MF_MT_FRAME_SIZE, config.width, config.height).map_err(|e| err("size", e))?; + in_type + .SetGUID(&MF_MT_MAJOR_TYPE, &MFMediaType_Video) + .map_err(|e| err("major", e))?; + in_type + .SetGUID(&MF_MT_SUBTYPE, &MFVideoFormat_NV12) + .map_err(|e| err("subtype", e))?; + set_pair(&in_type, &MF_MT_FRAME_SIZE, config.width, config.height) + .map_err(|e| err("size", e))?; set_pair(&in_type, &MF_MT_FRAME_RATE, config.fps, 1).map_err(|e| err("rate", e))?; set_pair(&in_type, &MF_MT_PIXEL_ASPECT_RATIO, 1, 1).map_err(|e| err("aspect", e))?; - in_type.SetUINT32(&MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive.0 as u32).map_err(|e| err("interlace", e))?; - in_type.SetUINT32(&MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT709.0 as u32).ok(); - in_type.SetUINT32(&MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235.0 as u32).ok(); + in_type + .SetUINT32(&MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive.0 as u32) + .map_err(|e| err("interlace", e))?; + in_type + .SetUINT32(&MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT709.0 as u32) + .ok(); + in_type + .SetUINT32(&MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235.0 as u32) + .ok(); trace("output type set"); - transform.SetInputType(0, &in_type, 0).map_err(|e| err("SetInputType", e))?; + transform + .SetInputType(0, &in_type, 0) + .map_err(|e| err("SetInputType", e))?; trace("input type set"); let codec = transform.cast::().ok(); if let Some(codec) = &codec { set_u32(codec, &CODECAPI_AVLowLatencyMode, 1); - set_u32(codec, &CODECAPI_AVEncCommonRateControlMode, eAVEncCommonRateControlMode_CBR.0 as u32); + set_u32( + codec, + &CODECAPI_AVEncCommonRateControlMode, + eAVEncCommonRateControlMode_CBR.0 as u32, + ); set_u32(codec, &CODECAPI_AVEncCommonMeanBitRate, config.bitrate_bps); set_u32(codec, &CODECAPI_AVEncMPVGOPSize, config.gop); set_u32(codec, &CODECAPI_AVEncMPVDefaultBPictureCount, 0); set_u32(codec, &CODECAPI_AVEncCommonRealTime, 1); } - - let info = transform.GetOutputStreamInfo(0).map_err(|e| err("output info", e))?; - trace(&format!("stream info flags={:#x} size={}", info.dwFlags, info.cbSize)); + let info = transform + .GetOutputStreamInfo(0) + .map_err(|e| err("output info", e))?; + trace(&format!( + "stream info flags={:#x} size={}", + info.dwFlags, info.cbSize + )); let provides_samples = info.dwFlags - & (MFT_OUTPUT_STREAM_PROVIDES_SAMPLES.0 as u32 | MFT_OUTPUT_STREAM_CAN_PROVIDE_SAMPLES.0 as u32) + & (MFT_OUTPUT_STREAM_PROVIDES_SAMPLES.0 as u32 + | MFT_OUTPUT_STREAM_CAN_PROVIDE_SAMPLES.0 as u32) != 0; trace("flush"); @@ -185,10 +248,14 @@ impl MfEncoder { transform.ProcessMessage(MFT_MESSAGE_COMMAND_FLUSH, 0).ok(); } trace("begin"); - transform.ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, 0).map_err(|e| err("begin streaming", e))?; + transform + .ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, 0) + .map_err(|e| err("begin streaming", e))?; trace("start of stream"); if !knobs.contains('s') { - transform.ProcessMessage(MFT_MESSAGE_NOTIFY_START_OF_STREAM, 0).map_err(|e| err("start of stream", e))?; + transform + .ProcessMessage(MFT_MESSAGE_NOTIFY_START_OF_STREAM, 0) + .map_err(|e| err("start of stream", e))?; } trace("streaming"); @@ -210,7 +277,9 @@ impl MfEncoder { } } - unsafe fn attach_device(transform: &IMFTransform) -> Result<(ID3D11Device, IMFDXGIDeviceManager), Error> { + unsafe fn attach_device( + transform: &IMFTransform, + ) -> Result<(ID3D11Device, IMFDXGIDeviceManager), Error> { let mut device: Option = None; D3D11CreateDevice( None, @@ -230,9 +299,12 @@ impl MfEncoder { } let mut token = 0u32; let mut manager: Option = None; - MFCreateDXGIDeviceManager(&mut token, &mut manager).map_err(|e| err("MFCreateDXGIDeviceManager", e))?; + MFCreateDXGIDeviceManager(&mut token, &mut manager) + .map_err(|e| err("MFCreateDXGIDeviceManager", e))?; let manager = manager.ok_or_else(|| Error("no device manager".into()))?; - manager.ResetDevice(&device, token).map_err(|e| err("ResetDevice", e))?; + manager + .ResetDevice(&device, token) + .map_err(|e| err("ResetDevice", e))?; transform .ProcessMessage(MFT_MESSAGE_SET_D3D_MANAGER, manager.as_raw() as usize) .map_err(|e| err("SET_D3D_MANAGER", e))?; @@ -253,14 +325,24 @@ impl MfEncoder { let length = nv12.len() as u32; let buffer = MFCreateMemoryBuffer(length).map_err(|e| err("buffer", e))?; let mut data = std::ptr::null_mut(); - buffer.Lock(&mut data, None, None).map_err(|e| err("lock", e))?; + buffer + .Lock(&mut data, None, None) + .map_err(|e| err("lock", e))?; std::ptr::copy_nonoverlapping(nv12.as_ptr(), data, nv12.len()); buffer.Unlock().map_err(|e| err("unlock", e))?; - buffer.SetCurrentLength(length).map_err(|e| err("length", e))?; + buffer + .SetCurrentLength(length) + .map_err(|e| err("length", e))?; let sample = MFCreateSample().map_err(|e| err("sample", e))?; - sample.AddBuffer(&buffer).map_err(|e| err("add buffer", e))?; - sample.SetSampleTime(pts_us * 10).map_err(|e| err("time", e))?; - sample.SetSampleDuration(10_000_000 / self.config.fps as i64).map_err(|e| err("duration", e))?; + sample + .AddBuffer(&buffer) + .map_err(|e| err("add buffer", e))?; + sample + .SetSampleTime(pts_us * 10) + .map_err(|e| err("time", e))?; + sample + .SetSampleDuration(10_000_000 / self.config.fps as i64) + .map_err(|e| err("duration", e))?; if self.events.is_some() { // Asynchronous (hardware) transform: feed it when it asks, collect what it hands out. @@ -269,13 +351,17 @@ impl MfEncoder { return Err(Error("encoder did not ask for input".into())); } self.need_input -= 1; - self.transform.ProcessInput(0, &sample, 0).map_err(|e| err("ProcessInput", e))?; + self.transform + .ProcessInput(0, &sample, 0) + .map_err(|e| err("ProcessInput", e))?; self.pending_pts.push_back(pts_us); self.frame_index += 1; // Low-latency encoders answer each picture with one unit: wait briefly for it. self.pump(&mut out, Duration::from_millis(60), false)?; } else { - self.transform.ProcessInput(0, &sample, 0).map_err(|e| err("ProcessInput", e))?; + self.transform + .ProcessInput(0, &sample, 0) + .map_err(|e| err("ProcessInput", e))?; self.pending_pts.push_back(pts_us); self.frame_index += 1; self.drain_sync(&mut out)?; @@ -286,7 +372,12 @@ impl MfEncoder { /// Handles transform events until `deadline`; with `until_input` it stops once the /// transform wants input, otherwise once an output came out. - unsafe fn pump(&mut self, out: &mut Vec, limit: Duration, until_input: bool) -> Result<(), Error> { + unsafe fn pump( + &mut self, + out: &mut Vec, + limit: Duration, + until_input: bool, + ) -> Result<(), Error> { let started = Instant::now(); let events = self.events.clone().unwrap(); loop { @@ -348,11 +439,17 @@ impl MfEncoder { } let sample = ManuallyDrop::take(&mut buffers[0].pSample); let _events = ManuallyDrop::take(&mut buffers[0].pEvents); - let Some(sample) = sample else { return Ok(None) }; - let buffer = sample.ConvertToContiguousBuffer().map_err(|e| err("contiguous", e))?; + let Some(sample) = sample else { + return Ok(None); + }; + let buffer = sample + .ConvertToContiguousBuffer() + .map_err(|e| err("contiguous", e))?; let mut data = std::ptr::null_mut(); let mut length = 0u32; - buffer.Lock(&mut data, None, Some(&mut length)).map_err(|e| err("lock out", e))?; + buffer + .Lock(&mut data, None, Some(&mut length)) + .map_err(|e| err("lock out", e))?; let mut bytes = std::slice::from_raw_parts(data, length as usize).to_vec(); buffer.Unlock().ok(); @@ -369,7 +466,11 @@ impl MfEncoder { bytes = with; } let pts_us = self.pending_pts.pop_front().unwrap_or(0); - Ok(Some(Encoded { data: bytes, key, pts_us })) + Ok(Some(Encoded { + data: bytes, + key, + pts_us, + })) } } @@ -388,8 +489,12 @@ fn find_nal(data: &[u8], nal_type: u8) -> Option { impl Drop for MfEncoder { fn drop(&mut self) { unsafe { - let _ = self.transform.ProcessMessage(MFT_MESSAGE_NOTIFY_END_OF_STREAM, 0); - let _ = self.transform.ProcessMessage(MFT_MESSAGE_NOTIFY_END_STREAMING, 0); + let _ = self + .transform + .ProcessMessage(MFT_MESSAGE_NOTIFY_END_OF_STREAM, 0); + let _ = self + .transform + .ProcessMessage(MFT_MESSAGE_NOTIFY_END_STREAMING, 0); let _ = MFShutdown(); } } diff --git a/desktop/core/encode/tests/inproc.rs b/desktop/core/encode/tests/inproc.rs index 333b426..f52065a 100644 --- a/desktop/core/encode/tests/inproc.rs +++ b/desktop/core/encode/tests/inproc.rs @@ -20,13 +20,21 @@ fn picture(i: usize) -> Vec { } fn config() -> Config { - Config { width: W as u32, height: H as u32, fps: 30, bitrate_bps: 2_000_000, gop: 60, format: VideoFormat::H264 } + Config { + width: W as u32, + height: H as u32, + fps: 30, + bitrate_bps: 2_000_000, + gop: 60, + format: VideoFormat::H264, + } } /// 60 pictures, a key frame forced at 20 and 40: every picture comes out at once, the first /// carries the parameter sets, the forced ones are key frames. fn check(codec: Codec) { - let mut encoder = InProcessEncoder::new(&config(), codec).unwrap_or_else(|e| panic!("{codec:?}: {e}")); + let mut encoder = + InProcessEncoder::new(&config(), codec).unwrap_or_else(|e| panic!("{codec:?}: {e}")); let mut keys = Vec::new(); for i in 0..60 { let unit = encoder @@ -35,23 +43,33 @@ fn check(codec: Codec) { .unwrap_or_else(|| panic!("{codec:?} held picture {i} back")); if i == 0 { let types = nal_types(&unit.data); - assert!(types.contains(&7) && types.contains(&8) && types.contains(&5), "{codec:?}: the first unit lacks SPS, PPS or IDR: {types:?}"); + assert!( + types.contains(&7) && types.contains(&8) && types.contains(&5), + "{codec:?}: the first unit lacks SPS, PPS or IDR: {types:?}" + ); } if unit.key { keys.push(i); } } - assert!(keys.contains(&0) && keys.contains(&20) && keys.contains(&40), "{codec:?}: key frames at {keys:?}"); + assert!( + keys.contains(&0) && keys.contains(&20) && keys.contains(&40), + "{codec:?}: key frames at {keys:?}" + ); } fn config_h265() -> Config { - Config { format: VideoFormat::H265, ..config() } + Config { + format: VideoFormat::H265, + ..config() + } } /// The same for H.265: the first unit carries the parameter sets (VPS, SPS, PPS) and an IDR picture, /// and the pictures forced to be key frames are IDR pictures with the parameter sets in front. fn check_h265(codec: Codec) { - let mut encoder = InProcessEncoder::new(&config_h265(), codec).unwrap_or_else(|e| panic!("{codec:?}: {e}")); + let mut encoder = + InProcessEncoder::new(&config_h265(), codec).unwrap_or_else(|e| panic!("{codec:?}: {e}")); let mut keys = Vec::new(); for i in 0..60 { let unit = encoder @@ -60,14 +78,23 @@ fn check_h265(codec: Codec) { .unwrap_or_else(|| panic!("{codec:?} held picture {i} back")); let types = nal_types_h265(&unit.data); if i == 0 || unit.key { - assert!(types.contains(&32) && types.contains(&33) && types.contains(&34), "{codec:?}: picture {i} lacks VPS, SPS or PPS: {types:?}"); - assert!(types.contains(&19) || types.contains(&20), "{codec:?}: picture {i} is no IDR picture: {types:?}"); + assert!( + types.contains(&32) && types.contains(&33) && types.contains(&34), + "{codec:?}: picture {i} lacks VPS, SPS or PPS: {types:?}" + ); + assert!( + types.contains(&19) || types.contains(&20), + "{codec:?}: picture {i} is no IDR picture: {types:?}" + ); } if unit.key { keys.push(i); } } - assert!(keys.contains(&0) && keys.contains(&20) && keys.contains(&40), "{codec:?}: key frames at {keys:?}"); + assert!( + keys.contains(&0) && keys.contains(&20) && keys.contains(&40), + "{codec:?}: key frames at {keys:?}" + ); } #[test] @@ -102,9 +129,14 @@ fn aac_gives_frames_and_the_config_a_decoder_needs() { // AAC-LC, 48 kHz, stereo: the two bytes 0x11 0x90. FFmpeg's encoder appends a three byte // "no SBR" marker after them, which decoders (and the receiver, up to five bytes) accept. let config = aac.config(); - assert!(config.starts_with(&[0x11, 0x90]) && config.len() <= 5, "config {config:02x?}"); + assert!( + config.starts_with(&[0x11, 0x90]) && config.len() <= 5, + "config {config:02x?}" + ); assert_eq!(aac.frame_samples(), 1024); - let samples: Vec = (0..1024 * 2).map(|i| ((i / 2) as f32 * 0.05).sin() * 0.5).collect(); + let samples: Vec = (0..1024 * 2) + .map(|i| ((i / 2) as f32 * 0.05).sin() * 0.5) + .collect(); let mut frames = 0; for _ in 0..20 { if let Some(frame) = aac.encode(&samples).expect("encode") { @@ -113,5 +145,8 @@ fn aac_gives_frames_and_the_config_a_decoder_needs() { } } assert!(frames >= 18, "{frames} frames out of 20 inputs"); - assert!(aac.encode(&samples[..100]).is_err(), "a wrong sample count is refused"); + assert!( + aac.encode(&samples[..100]).is_err(), + "a wrong sample count is refused" + ); } diff --git a/desktop/core/link/src/discovery.rs b/desktop/core/link/src/discovery.rs index 4bccc27..764d0eb 100644 --- a/desktop/core/link/src/discovery.rs +++ b/desktop/core/link/src/discovery.rs @@ -32,9 +32,24 @@ pub struct Receiver { } /// A receiver from the text records of its service (`text` looks a key up) and where it was seen. -fn receiver_from(text: impl Fn(&str) -> Option, fullname: &str, addresses: Vec, port: u16) -> Receiver { +fn receiver_from( + text: impl Fn(&str) -> Option, + fullname: &str, + addresses: Vec, + port: u16, +) -> Receiver { // Hints from the network: shown to the person, so only plain, short text is taken. - let plain = |key: &str| text(key).map(|v| v.trim().chars().filter(|c| !c.is_control()).take(40).collect::()).filter(|v| !v.is_empty()); + let plain = |key: &str| { + text(key) + .map(|v| { + v.trim() + .chars() + .filter(|c| !c.is_control()) + .take(40) + .collect::() + }) + .filter(|v| !v.is_empty()) + }; Receiver { id: text("id").unwrap_or_else(|| fullname.to_string()), name: text("name").unwrap_or_else(|| fullname.split('.').next().unwrap_or("").to_string()), @@ -54,14 +69,21 @@ fn receiver_from(text: impl Fn(&str) -> Option, fullname: &str, addresse /// Browses for `listen` and returns the receivers seen by then. pub fn browse(listen: Duration) -> Result, Error> { let daemon = ServiceDaemon::new().map_err(|e| Error::Io(e.to_string()))?; - let events = daemon.browse("_castbay._tcp.local.").map_err(|e| Error::Io(e.to_string()))?; + let events = daemon + .browse("_castbay._tcp.local.") + .map_err(|e| Error::Io(e.to_string()))?; let until = Instant::now() + listen; let mut found: Vec = Vec::new(); while let Some(left) = until.checked_duration_since(Instant::now()) { match events.recv_timeout(left) { Ok(ServiceEvent::ServiceResolved(info)) => { let text = |key: &str| info.get_property_val_str(key).map(str::to_string); - let receiver = receiver_from(text, info.get_fullname(), info.get_addresses().iter().copied().collect(), info.get_port()); + let receiver = receiver_from( + text, + info.get_fullname(), + info.get_addresses().iter().copied().collect(), + info.get_port(), + ); found.retain(|r| r.id != receiver.id); found.push(receiver); } @@ -79,14 +101,37 @@ mod tests { use std::collections::HashMap; fn from(pairs: &[(&str, &str)]) -> Receiver { - let map: HashMap = pairs.iter().map(|(k, v)| (k.to_string(), v.to_string())).collect(); - receiver_from(|key| map.get(key).cloned(), "CastBay._castbay._tcp.local.", vec![], 7000) + let map: HashMap = pairs + .iter() + .map(|(k, v)| (k.to_string(), v.to_string())) + .collect(); + receiver_from( + |key| map.get(key).cloned(), + "CastBay._castbay._tcp.local.", + vec![], + 7000, + ) } #[test] fn the_model_and_version_are_read_when_there_are_any() { - let r = from(&[("id", "x"), ("name", "TV"), ("model", "BRAVIA 4K"), ("app", "1.8.9"), ("pair", "pin"), ("pw", "1")]); - assert_eq!((r.model.as_deref(), r.app_version.as_deref(), r.pair, r.password), (Some("BRAVIA 4K"), Some("1.8.9"), PairMode::Pin, true)); + let r = from(&[ + ("id", "x"), + ("name", "TV"), + ("model", "BRAVIA 4K"), + ("app", "1.8.9"), + ("pair", "pin"), + ("pw", "1"), + ]); + assert_eq!( + ( + r.model.as_deref(), + r.app_version.as_deref(), + r.pair, + r.password + ), + (Some("BRAVIA 4K"), Some("1.8.9"), PairMode::Pin, true) + ); } #[test] @@ -106,6 +151,9 @@ mod tests { #[test] fn without_an_id_or_name_the_service_name_stands_in() { let r = from(&[]); - assert_eq!((r.id.as_str(), r.name.as_str()), ("CastBay._castbay._tcp.local.", "CastBay")); + assert_eq!( + (r.id.as_str(), r.name.as_str()), + ("CastBay._castbay._tcp.local.", "CastBay") + ); } } diff --git a/desktop/core/link/src/identity.rs b/desktop/core/link/src/identity.rs index 0c1b275..98d2c09 100644 --- a/desktop/core/link/src/identity.rs +++ b/desktop/core/link/src/identity.rs @@ -13,7 +13,8 @@ use crate::protocol::Error; /// SHA-256 of a certificate's SubjectPublicKeyInfo: how both sides name a key. pub fn fingerprint(cert_der: &[u8]) -> Result<[u8; 32], Error> { - let (_, cert) = x509_parser::parse_x509_certificate(cert_der).map_err(|e| Error::Protocol(format!("certificate: {e}")))?; + let (_, cert) = x509_parser::parse_x509_certificate(cert_der) + .map_err(|e| Error::Protocol(format!("certificate: {e}")))?; Ok(Sha256::digest(cert.tbs_certificate.subject_pki.raw).into()) } @@ -36,21 +37,35 @@ impl Identity { let key_path = dir.join("key.der"); if let (Ok(cert), Ok(key)) = (fs::read(&cert_path), fs::read(&key_path)) { let fingerprint = fingerprint(&cert)?; - return Ok(Identity { cert, key, fingerprint }); + return Ok(Identity { + cert, + key, + fingerprint, + }); } - let key_pair = KeyPair::generate_for(&PKCS_ECDSA_P256_SHA256).map_err(|e| Error::Protocol(e.to_string()))?; - let mut params = CertificateParams::new(Vec::::new()).map_err(|e| Error::Protocol(e.to_string()))?; + let key_pair = KeyPair::generate_for(&PKCS_ECDSA_P256_SHA256) + .map_err(|e| Error::Protocol(e.to_string()))?; + let mut params = CertificateParams::new(Vec::::new()) + .map_err(|e| Error::Protocol(e.to_string()))?; params.distinguished_name = DistinguishedName::new(); - params.distinguished_name.push(DnType::CommonName, "CastBay Desktop"); + params + .distinguished_name + .push(DnType::CommonName, "CastBay Desktop"); // Valid for a long time: nothing checks the date, the key is the identity. params.not_before = rcgen::date_time_ymd(2024, 1, 1); params.not_after = rcgen::date_time_ymd(2054, 1, 1); - let cert = params.self_signed(&key_pair).map_err(|e| Error::Protocol(e.to_string()))?; + let cert = params + .self_signed(&key_pair) + .map_err(|e| Error::Protocol(e.to_string()))?; let (cert, key) = (cert.der().to_vec(), key_pair.serialize_der()); write_private(&key_path, &key)?; fs::write(&cert_path, &cert)?; let fingerprint = fingerprint(&cert)?; - Ok(Identity { cert, key, fingerprint }) + Ok(Identity { + cert, + key, + fingerprint, + }) } pub(crate) fn rustls(&self) -> (Vec>, PrivateKeyDer<'static>) { @@ -100,7 +115,10 @@ impl Entry { fn known(&self) -> Known { match self { - Entry::Key(fp) => Known { fp: fp.clone(), ..Known::default() }, + Entry::Key(fp) => Known { + fp: fp.clone(), + ..Known::default() + }, Entry::Known(k) => k.clone(), } } @@ -126,7 +144,10 @@ pub struct Pins { impl Pins { pub fn load(dir: &Path) -> Pins { let path = dir.join("receivers.json"); - let map = fs::read(&path).ok().and_then(|b| serde_json::from_slice(&b).ok()).unwrap_or_default(); + let map = fs::read(&path) + .ok() + .and_then(|b| serde_json::from_slice(&b).ok()) + .unwrap_or_default(); Pins { path, map } } @@ -143,14 +164,27 @@ impl Pins { } /// Remembers a receiver's key, its name (kept when `name` is empty) and that it was just seen. - pub fn pin(&mut self, receiver_id: &str, fingerprint: &[u8; 32], name: &str) -> Result<(), Error> { - let mut known = self.map.get(receiver_id).map(Entry::known).unwrap_or_default(); + pub fn pin( + &mut self, + receiver_id: &str, + fingerprint: &[u8; 32], + name: &str, + ) -> Result<(), Error> { + let mut known = self + .map + .get(receiver_id) + .map(Entry::known) + .unwrap_or_default(); known.fp = hex(fingerprint); if !name.is_empty() { known.name = name.to_string(); } - known.seen = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0); - self.map.insert(receiver_id.to_string(), Entry::Known(known)); + known.seen = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map(|d| d.as_secs()) + .unwrap_or(0); + self.map + .insert(receiver_id.to_string(), Entry::Known(known)); self.save() } @@ -166,10 +200,19 @@ impl Pins { .iter() .map(|(id, e)| { let k = e.known(); - PinnedReceiver { id: id.clone(), name: k.name, seen: k.seen } + PinnedReceiver { + id: id.clone(), + name: k.name, + seen: k.seen, + } }) .collect(); - all.sort_by(|a, b| b.seen.cmp(&a.seen).then_with(|| a.name.cmp(&b.name)).then_with(|| a.id.cmp(&b.id))); + all.sort_by(|a, b| { + b.seen + .cmp(&a.seen) + .then_with(|| a.name.cmp(&b.name)) + .then_with(|| a.id.cmp(&b.id)) + }); all } @@ -177,7 +220,10 @@ impl Pins { if let Some(dir) = self.path.parent() { fs::create_dir_all(dir)?; } - fs::write(&self.path, serde_json::to_vec_pretty(&self.map).expect("a map serialises"))?; + fs::write( + &self.path, + serde_json::to_vec_pretty(&self.map).expect("a map serialises"), + )?; Ok(()) } } @@ -187,7 +233,8 @@ mod tests { use super::*; fn temp(name: &str) -> PathBuf { - let dir = std::env::temp_dir().join(format!("castbay-link-test-{name}-{}", std::process::id())); + let dir = + std::env::temp_dir().join(format!("castbay-link-test-{name}-{}", std::process::id())); let _ = fs::remove_dir_all(&dir); dir } @@ -228,7 +275,10 @@ mod tests { std::thread::sleep(std::time::Duration::from_millis(1100)); pins.pin("a", &[1u8; 32], "").unwrap(); let list = Pins::load(&dir).list(); - assert_eq!(list.iter().map(|r| r.id.as_str()).collect::>(), ["a", "b"]); + assert_eq!( + list.iter().map(|r| r.id.as_str()).collect::>(), + ["a", "b"] + ); assert_eq!(list[0].name, "Bedroom"); assert!(list[0].seen > list[1].seen); let _ = fs::remove_dir_all(dir); @@ -242,7 +292,14 @@ mod tests { fs::write(dir.join("receivers.json"), format!(r#"{{"abc": "{key}"}}"#)).unwrap(); let mut pins = Pins::load(&dir); assert_eq!(pins.get("abc"), Some([7u8; 32])); - assert_eq!(pins.list(), vec![PinnedReceiver { id: "abc".into(), name: String::new(), seen: 0 }]); + assert_eq!( + pins.list(), + vec![PinnedReceiver { + id: "abc".into(), + name: String::new(), + seen: 0 + }] + ); // Meeting it again fills in the name; the file is then in the new format. pins.pin("abc", &[7u8; 32], "Old TV").unwrap(); let reread = Pins::load(&dir); diff --git a/desktop/core/link/src/protocol.rs b/desktop/core/link/src/protocol.rs index 2d26b14..2de0372 100644 --- a/desktop/core/link/src/protocol.rs +++ b/desktop/core/link/src/protocol.rs @@ -31,7 +31,10 @@ impl fmt::Display for Error { Error::Rejected(reason) => write!(f, "the receiver refused: {reason}"), Error::PairingFailed(reason) => write!(f, "pairing failed: {reason}"), Error::CodeRequired => write!(f, "the receiver needs a pairing code"), - Error::ReceiverChanged => write!(f, "this is not the receiver paired before (its key changed)"), + Error::ReceiverChanged => write!( + f, + "this is not the receiver paired before (its key changed)" + ), Error::Protocol(what) => write!(f, "protocol error: {what}"), Error::Io(what) => write!(f, "network error: {what}"), } diff --git a/desktop/core/link/src/session.rs b/desktop/core/link/src/session.rs index 66c9251..b43ddc9 100644 --- a/desktop/core/link/src/session.rs +++ b/desktop/core/link/src/session.rs @@ -19,7 +19,10 @@ use tokio_rustls::client::TlsStream; use tokio_rustls::TlsConnector; use crate::identity::{fingerprint, hex, Identity, Pins}; -use crate::protocol::{audio_frame, control_frame, verification_code, video_frame, Error, MAX_CONTROL, TYPE_CONTROL, VERSION}; +use crate::protocol::{ + audio_frame, control_frame, verification_code, video_frame, Error, MAX_CONTROL, TYPE_CONTROL, + VERSION, +}; /// Audio the sender will send: AAC-LC frames (see docs/protocol.md). #[derive(Debug, Clone)] @@ -54,7 +57,11 @@ const DEFAULT_FORMATS: [&str; 1] = ["h264"]; /// The format to offer: the sender's best that the receiver (its `hello`'s `video`) decodes, else H.264. pub fn choose_format(wanted: &[String], receiver_video: &[String]) -> String { - wanted.iter().find(|f| receiver_video.contains(f)).cloned().unwrap_or_else(|| "h264".to_string()) + wanted + .iter() + .find(|f| receiver_video.contains(f)) + .cloned() + .unwrap_or_else(|| "h264".to_string()) } /// Where the pairing code comes from: the person at the keyboard, who reads it off the TV. @@ -76,7 +83,11 @@ impl Option + Send> PairingCode for F { pub enum Event { /// The decoder lost its place (or frames were dropped here): send a key frame soon. KeyFrameRequested, - Stats { decode_ms: i64, dropped: u64, fps: f64 }, + Stats { + decode_ms: i64, + dropped: u64, + fps: f64, + }, /// The session is over: the receiver said goodbye (`stopped_by_receiver`, `replaced`, ...) or the connection broke. Closed(String), } @@ -106,12 +117,32 @@ impl ServerCertVerifier for AcceptAny { Ok(ServerCertVerified::assertion()) } - fn verify_tls12_signature(&self, message: &[u8], cert: &CertificateDer<'_>, dss: &DigitallySignedStruct) -> Result { - verify_tls12_signature(message, cert, dss, &self.0.signature_verification_algorithms) + fn verify_tls12_signature( + &self, + message: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + ) -> Result { + verify_tls12_signature( + message, + cert, + dss, + &self.0.signature_verification_algorithms, + ) } - fn verify_tls13_signature(&self, message: &[u8], cert: &CertificateDer<'_>, dss: &DigitallySignedStruct) -> Result { - verify_tls13_signature(message, cert, dss, &self.0.signature_verification_algorithms) + fn verify_tls13_signature( + &self, + message: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + ) -> Result { + verify_tls13_signature( + message, + cert, + dss, + &self.0.signature_verification_algorithms, + ) } fn supported_verify_schemes(&self) -> Vec { @@ -144,14 +175,20 @@ async fn read_control(reader: &mut Reader) -> Result, Error> { Err(e) => return Err(e.into()), } let length = u32::from_be_bytes([head[1], head[2], head[3], head[4]]) as usize; - let limit = if head[0] == TYPE_CONTROL { MAX_CONTROL } else { crate::protocol::MAX_MESSAGE }; + let limit = if head[0] == TYPE_CONTROL { + MAX_CONTROL + } else { + crate::protocol::MAX_MESSAGE + }; if length > limit { return Err(Error::Protocol(format!("a message of {length} bytes"))); } let mut payload = vec![0u8; length]; reader.read_exact(&mut payload).await?; if head[0] == TYPE_CONTROL { - return serde_json::from_slice(&payload).map(Some).map_err(|_| Error::Protocol("a control message that is not JSON".into())); + return serde_json::from_slice(&payload) + .map(Some) + .map_err(|_| Error::Protocol("a control message that is not JSON".into())); } } } @@ -170,7 +207,11 @@ fn kind(message: &Value) -> &str { } fn reason(message: &Value) -> String { - message.get("reason").and_then(Value::as_str).unwrap_or("").to_string() + message + .get("reason") + .and_then(Value::as_str) + .unwrap_or("") + .to_string() } /// A running cast. Frames go in with [`Session::send_video`]; the receiver's messages come @@ -210,10 +251,18 @@ pub async fn connect( .map_err(|_| Error::Io("connecting timed out".into()))??; tcp.set_nodelay(true)?; let connector = TlsConnector::from(Arc::new(tls_config(identity)?)); - let tls = timeout(Duration::from_secs(10), connector.connect(ServerName::try_from("castbay").expect("a valid name"), tcp)) - .await - .map_err(|_| Error::Io("the TLS handshake timed out".into()))??; - let peer = tls.get_ref().1.peer_certificates().and_then(|c| c.first()).ok_or_else(|| Error::Protocol("the receiver sent no certificate".into()))?; + let tls = timeout( + Duration::from_secs(10), + connector.connect(ServerName::try_from("castbay").expect("a valid name"), tcp), + ) + .await + .map_err(|_| Error::Io("the TLS handshake timed out".into()))??; + let peer = tls + .get_ref() + .1 + .peer_certificates() + .and_then(|c| c.first()) + .ok_or_else(|| Error::Protocol("the receiver sent no certificate".into()))?; let receiver_fp = fingerprint(peer.as_ref())?; if let Some(id) = receiver_id { if let Some(pinned) = pins.get(id) { @@ -235,15 +284,29 @@ pub async fn connect( return Err(Error::Rejected(reason(&first))); } if kind(&first) != "hello" { - return Err(Error::Protocol(format!("expected hello, got {}", kind(&first)))); + return Err(Error::Protocol(format!( + "expected hello, got {}", + kind(&first) + ))); } - let receiver_name = first.get("name").and_then(Value::as_str).unwrap_or("").to_string(); + let receiver_name = first + .get("name") + .and_then(Value::as_str) + .unwrap_or("") + .to_string(); let receiver_video: Vec = match first.get("video").and_then(Value::as_array) { - Some(list) => list.iter().filter_map(Value::as_str).map(str::to_string).collect(), + Some(list) => list + .iter() + .filter_map(Value::as_str) + .map(str::to_string) + .collect(), None => DEFAULT_FORMATS.iter().map(|f| f.to_string()).collect(), }; let format = choose_format(&config.formats, &receiver_video); - let id = receiver_id.map(str::to_string).or_else(|| first.get("id").and_then(Value::as_str).map(str::to_string)).unwrap_or_default(); + let id = receiver_id + .map(str::to_string) + .or_else(|| first.get("id").and_then(Value::as_str).map(str::to_string)) + .unwrap_or_default(); // Admission: a reject, a pairing code to type, or ready. loop { @@ -253,7 +316,9 @@ pub async fn connect( "pair_required" => { let expected = verification_code(&receiver_fp, &identity.fingerprint); let typed = code.code(&expected).ok_or(Error::CodeRequired)?; - writer.write_all(&control_frame(&json!({"t": "pair", "sas": typed}))).await?; + writer + .write_all(&control_frame(&json!({"t": "pair", "sas": typed}))) + .await?; } "pair_result" => { if message.get("ok").and_then(Value::as_bool) != Some(true) { @@ -279,7 +344,8 @@ pub async fn connect( let message = expect(&mut reader, "accept").await?; match kind(&message) { "accept" => { - audio_accepted = config.audio.is_some() && message.get("audio").and_then(Value::as_bool) == Some(true); + audio_accepted = config.audio.is_some() + && message.get("audio").and_then(Value::as_bool) == Some(true); break; } "reject" => return Err(Error::Rejected(reason(&message))), @@ -294,7 +360,19 @@ pub async fn connect( let closed = Arc::new(AtomicBool::new(false)); let writer_task = tokio::spawn(write_loop(writer, queue, audio_queue, closed.clone())); let reader_task = tokio::spawn(read_loop(reader, events_tx, closed.clone())); - Ok(Session { frames, audio, events, dropping, closed, writer: writer_task, reader: reader_task, receiver_id: id, receiver_name, audio_accepted, format }) + Ok(Session { + frames, + audio, + events, + dropping, + closed, + writer: writer_task, + reader: reader_task, + receiver_id: id, + receiver_name, + audio_accepted, + format, + }) } /// Pictures waiting to be written; more than this and the connection is not keeping up. @@ -303,7 +381,12 @@ const QUEUE_FRAMES: usize = 6; /// AAC frames waiting to be written (about 21 ms each): well under a second, then the oldest news is dropped. const AUDIO_QUEUE_FRAMES: usize = 32; -async fn write_loop(mut writer: Writer, mut queue: mpsc::Receiver>, mut audio: mpsc::Receiver>, closed: Arc) { +async fn write_loop( + mut writer: Writer, + mut queue: mpsc::Receiver>, + mut audio: mpsc::Receiver>, + closed: Arc, +) { let mut ping = tokio::time::interval(Duration::from_secs(2)); let mut audio_open = true; loop { @@ -336,7 +419,11 @@ async fn write_loop(mut writer: Writer, mut queue: mpsc::Receiver>, mut let _ = writer.shutdown().await; } -async fn read_loop(mut reader: Reader, events: mpsc::UnboundedSender, closed: Arc) { +async fn read_loop( + mut reader: Reader, + events: mpsc::UnboundedSender, + closed: Arc, +) { let end = loop { match timeout(Duration::from_secs(10), read_control(&mut reader)).await { Err(_) => break "the receiver went silent".to_string(), @@ -348,7 +435,10 @@ async fn read_loop(mut reader: Reader, events: mpsc::UnboundedSender, clo } "stats" => { let _ = events.send(Event::Stats { - decode_ms: message.get("decode_ms").and_then(Value::as_i64).unwrap_or(-1), + decode_ms: message + .get("decode_ms") + .and_then(Value::as_i64) + .unwrap_or(-1), dropped: message.get("dropped").and_then(Value::as_u64).unwrap_or(0), fps: message.get("fps").and_then(Value::as_f64).unwrap_or(0.0), }); @@ -411,7 +501,10 @@ impl Session { /// Says goodbye and waits for what is queued to be written. pub async fn close(self) { - let _ = self.frames.send(control_frame(&json!({"t": "bye", "reason": "done"}))).await; + let _ = self + .frames + .send(control_frame(&json!({"t": "bye", "reason": "done"}))) + .await; drop(self.frames); let _ = timeout(Duration::from_secs(3), self.writer).await; self.reader.abort(); @@ -428,10 +521,25 @@ mod tests { #[test] fn the_best_format_both_sides_have_is_offered() { - assert_eq!(choose_format(&v(&["h265", "h264"]), &v(&["h264", "h265"])), "h265"); - assert_eq!(choose_format(&v(&["h265", "h264"]), &v(&["h264"])), "h264", "the receiver does not decode H.265"); - assert_eq!(choose_format(&v(&["h264"]), &v(&["h264", "h265"])), "h264", "the sender cannot encode H.265, or was told not to"); - assert_eq!(choose_format(&v(&["h265"]), &v(&["h264"])), "h264", "nothing in common: H.264, which every receiver decodes"); + assert_eq!( + choose_format(&v(&["h265", "h264"]), &v(&["h264", "h265"])), + "h265" + ); + assert_eq!( + choose_format(&v(&["h265", "h264"]), &v(&["h264"])), + "h264", + "the receiver does not decode H.265" + ); + assert_eq!( + choose_format(&v(&["h264"]), &v(&["h264", "h265"])), + "h264", + "the sender cannot encode H.265, or was told not to" + ); + assert_eq!( + choose_format(&v(&["h265"]), &v(&["h264"])), + "h264", + "nothing in common: H.264, which every receiver decodes" + ); assert_eq!(choose_format(&v(&["h265", "h264"]), &v(&[])), "h264"); } } diff --git a/desktop/core/sender/src/engine.rs b/desktop/core/sender/src/engine.rs index b697234..b712345 100644 --- a/desktop/core/sender/src/engine.rs +++ b/desktop/core/sender/src/engine.rs @@ -48,7 +48,12 @@ impl Enc { FfmpegEncoder::new(config, codec).map(Enc::Process) } - fn encode(&mut self, nv12: &[u8], pts: i64, key: bool) -> Result, castbay_encode::Error> { + fn encode( + &mut self, + nv12: &[u8], + pts: i64, + key: bool, + ) -> Result, castbay_encode::Error> { match self { // A child process cannot be told to make a key frame; it makes them on its own timer. Enc::Process(e) => { @@ -70,7 +75,9 @@ fn wanted_formats(choice: FormatChoice, codec: Option, h265: &Config) -> return vec![h264]; } match Enc::open(h265, codec) { - Ok((_, used)) if used != Codec::X264 => vec![VideoFormat::H265.protocol_name().to_string(), h264], + Ok((_, used)) if used != Codec::X264 => { + vec![VideoFormat::H265.protocol_name().to_string(), h264] + } _ => vec![h264], } } @@ -78,8 +85,18 @@ fn wanted_formats(choice: FormatChoice, codec: Option, h265: &Config) -> /// The encoders that open on this computer, in the order "automatic" tries them. A hardware /// encoder is tried with a small picture and closed again at once, so this takes a moment. pub fn available_encoders() -> Vec { - let config = Config { width: 640, height: 360, fps: 30, bitrate_bps: 2_000_000, gop: 60, format: Default::default() }; - [Codec::Amf, Codec::Nvenc, Codec::X264].into_iter().filter(|codec| Enc::new(&config, *codec).is_ok()).collect() + let config = Config { + width: 640, + height: 360, + fps: 30, + bitrate_bps: 2_000_000, + gop: 60, + format: Default::default(), + }; + [Codec::Amf, Codec::Nvenc, Codec::X264] + .into_iter() + .filter(|codec| Enc::new(&config, *codec).is_ok()) + .collect() } /// AAC-LC encoding for the cast's audio; only the in-process encoder build has one. @@ -98,16 +115,22 @@ impl Aac for castbay_encode::inproc::AacEncoder { castbay_encode::inproc::AacEncoder::frame_samples(self) } fn encode(&mut self, interleaved: &[f32]) -> Option> { - castbay_encode::inproc::AacEncoder::encode(self, interleaved).ok().flatten() + castbay_encode::inproc::AacEncoder::encode(self, interleaved) + .ok() + .flatten() } } fn open_aac() -> Option> { #[cfg(feature = "ffmpeg-lib")] { - castbay_encode::inproc::AacEncoder::new(castbay_capture::audio::SAMPLE_RATE, castbay_capture::audio::CHANNELS, 128_000) - .ok() - .map(|e| Box::new(e) as Box) + castbay_encode::inproc::AacEncoder::new( + castbay_capture::audio::SAMPLE_RATE, + castbay_capture::audio::CHANNELS, + 128_000, + ) + .ok() + .map(|e| Box::new(e) as Box) } #[cfg(not(feature = "ffmpeg-lib"))] { @@ -117,10 +140,18 @@ fn open_aac() -> Option> { /// Captures what the PC plays, encodes it and sends it on the current connection until the end. /// A device that goes away (the default output changed) is picked up again a second later. -fn run_audio(mut enc: Box, session_ref: Arc>>, over: impl Fn() -> bool, started: Instant, counter: Arc, process: Arc>>) { +fn run_audio( + mut enc: Box, + session_ref: Arc>>, + over: impl Fn() -> bool, + started: Instant, + counter: Arc, + process: Arc>>, +) { let samples_per_frame = enc.frame_samples(); let frame_len = samples_per_frame * castbay_capture::audio::CHANNELS as usize; - let frame_us = samples_per_frame as u64 * 1_000_000 / castbay_capture::audio::SAMPLE_RATE as u64; + let frame_us = + samples_per_frame as u64 * 1_000_000 / castbay_capture::audio::SAMPLE_RATE as u64; let base_us = started.elapsed().as_micros() as u64; let mut pending: Vec = Vec::with_capacity(frame_len * 4); let mut sent: u64 = 0; @@ -258,7 +289,14 @@ fn capture_callback bool + Send + 'static>( state: Arc>, session_ref: Arc>>, capture_status: OnStatus, - (width, height, interval, started, encoder_config, codec): (u32, u32, Duration, Instant, Config, Option), + (width, height, interval, started, encoder_config, codec): ( + u32, + u32, + Duration, + Instant, + Config, + Option, + ), ) -> impl FnMut(castbay_capture::Frame<'_>) -> bool + Send + 'static { move |frame| { if over() { @@ -275,7 +313,12 @@ fn capture_callback bool + Send + 'static>( // after a repeat: a repeat only stands in where nothing new came, and must not make the new // picture that follows it wait (that was the case: most new pictures were dropped, and // old ones repeated in their place). - if takes_new_picture(st.have_picture, st.last_was_repeat, arrived.duration_since(st.last_taken), interval) { + if takes_new_picture( + st.have_picture, + st.last_was_repeat, + arrived.duration_since(st.last_taken), + interval, + ) { if frame.width >= 2 && frame.height >= 2 { // The usual gap follows the screen: a gap longer than 100 ms is a pause, not the pace. let gap = arrived.duration_since(st.last_taken).min(STILL_REPEAT); @@ -287,12 +330,28 @@ fn capture_callback bool + Send + 'static>( capture_status(Status::Still(false)); } let mut nv12 = std::mem::take(&mut st.nv12); - bgra_to_nv12_fit(frame.data, frame.stride, frame.width as usize, frame.height as usize, width as usize, height as usize, &mut nv12); + bgra_to_nv12_fit( + frame.data, + frame.stride, + frame.width as usize, + frame.height as usize, + width as usize, + height as usize, + &mut nv12, + ); st.nv12 = nv12; st.have_picture = true; st.frames_taken += 1; if let Some(link) = session_ref.lock().unwrap().as_ref() { - push(&mut st, link, Instant::now(), started, &encoder_config, codec, false); + push( + &mut st, + link, + Instant::now(), + started, + &encoder_config, + codec, + false, + ); if let Some(bps) = st.announce_bitrate.take() { capture_status(Status::Bitrate(bps)); } @@ -335,7 +394,12 @@ fn repeat_wait(interval: Duration, in_a_row: u32, gap: Duration) -> Duration { /// Whether a picture that has just come from the capture is sent. A screen that changes faster than /// the cast does not set the pace (not before three quarters of an interval since the last one was /// taken), and a picture is always taken after a repeat, which only stood in where nothing new came. -fn takes_new_picture(have_picture: bool, last_was_repeat: bool, since_last_taken: Duration, interval: Duration) -> bool { +fn takes_new_picture( + have_picture: bool, + last_was_repeat: bool, + since_last_taken: Duration, + interval: Duration, +) -> bool { !have_picture || last_was_repeat || since_last_taken + interval / 4 >= interval } @@ -349,12 +413,24 @@ fn key_due(encoder: &str, since_key: Option) -> bool { } /// Pushes the current picture into the encoder and sends what came out. -fn push(st: &mut State, link: &Session, captured: Instant, started: Instant, config: &Config, codec: Option, repeat: bool) { +fn push( + st: &mut State, + link: &Session, + captured: Instant, + started: Instant, + config: &Config, + codec: Option, + repeat: bool, +) { if st.lost.is_some() { return; } if st.encoder.is_none() { - let config = Config { bitrate_bps: st.rate.current(), format: st.format, ..config.clone() }; + let config = Config { + bitrate_bps: st.rate.current(), + format: st.format, + ..config.clone() + }; match Enc::open(&config, codec) { Ok((e, used)) => { st.encoder = Some(e); @@ -375,7 +451,9 @@ fn push(st: &mut State, link: &Session, captured: Instant, started: Instant, con } let pts = captured.duration_since(started).as_micros() as i64; let nv12 = std::mem::take(&mut st.nv12); - let key = link.wants_key_frame() || st.want_key || key_due(st.encoder_name, st.last_key.map(|t| t.elapsed())); + let key = link.wants_key_frame() + || st.want_key + || key_due(st.encoder_name, st.last_key.map(|t| t.elapsed())); if key { st.last_key = Some(Instant::now()); } @@ -410,7 +488,10 @@ fn push(st: &mut State, link: &Session, captured: Instant, started: Instant, con Err(e) => st.failed = Some(Failure::new("encoder", e.to_string())), } // For trying the response without a bad network: a burst of drops five seconds in. - if !st.simulated && std::env::var_os("CASTBAY_SIMULATE_CONGESTION").is_some() && started.elapsed() > Duration::from_secs(5) { + if !st.simulated + && std::env::var_os("CASTBAY_SIMULATE_CONGESTION").is_some() + && started.elapsed() > Duration::from_secs(5) + { st.simulated = true; for _ in 0..8 { st.rate.dropped(Instant::now()); @@ -427,27 +508,60 @@ fn push(st: &mut State, link: &Session, captured: Instant, started: Instant, con /// Runs the cast and delivers its result through `done`. The thread that calls this ends up /// running the capture itself (the capture library wants to own its thread's message loop), so /// a supervisor thread watches for the end and reports it. -pub fn run(options: Options, on_status: OnStatus, code: Box Option + Send>, stop: Arc, switch: Arc>>, done: std::sync::mpsc::Sender>) { +pub fn run( + options: Options, + on_status: OnStatus, + code: Box Option + Send>, + stop: Arc, + switch: Arc>>, + done: std::sync::mpsc::Sender>, +) { if let Err(e) = setup_and_run(options, on_status, code, stop, switch, done.clone()) { let _ = done.send(Err(e)); } } -fn setup_and_run(options: Options, on_status: OnStatus, code: Box Option + Send>, stop: Arc, switch: Arc>>, done: std::sync::mpsc::Sender>) -> Result<(), Failure> { - let Options { addr, receiver_id, name, password, target, fps, bitrate_bps, codec, video_format, audio, max_size, data_dir, max_duration } = options; +fn setup_and_run( + options: Options, + on_status: OnStatus, + code: Box Option + Send>, + stop: Arc, + switch: Arc>>, + done: std::sync::mpsc::Sender>, +) -> Result<(), Failure> { + let Options { + addr, + receiver_id, + name, + password, + target, + fps, + bitrate_bps, + codec, + video_format, + audio, + max_size, + data_dir, + max_duration, + } = options; castbay_capture::set_data_dir(&data_dir); on_status(Status::Connecting); - let runtime = tokio::runtime::Runtime::new().map_err(|e| Failure::new("other", e.to_string()))?; + let runtime = + tokio::runtime::Runtime::new().map_err(|e| Failure::new("other", e.to_string()))?; // The first picture fixes the size, so the offer waits for it. let first = Arc::new(Mutex::new(None::<(u32, u32)>)); { let (first, target) = (first.clone(), target.clone()); std::thread::spawn(move || { - let _ = castbay_capture::run(&target, || false, move |frame| { - *first.lock().unwrap() = Some((frame.width & !1, frame.height & !1)); - false - }); + let _ = castbay_capture::run( + &target, + || false, + move |frame| { + *first.lock().unwrap() = Some((frame.width & !1, frame.height & !1)); + false + }, + ); }); } let waited = Instant::now(); @@ -459,7 +573,10 @@ fn setup_and_run(options: Options, on_status: OnStatus, code: Box Duration::from_secs(10) { - return Err(Failure::new("no_picture", "no picture from the screen (is it locked, or the window gone?)")); + return Err(Failure::new( + "no_picture", + "no picture from the screen (is it locked, or the window gone?)", + )); } std::thread::sleep(Duration::from_millis(50)); }; @@ -474,7 +591,18 @@ fn setup_and_run(options: Options, on_status: OnStatus, code: Box d) + move || { + stop.load(Ordering::SeqCst) + || finish.load(Ordering::SeqCst) + || max_duration.is_some_and(|d| started.elapsed() > d) + } }; let session_ref = Arc::new(Mutex::new(Some(session))); let state = Arc::new(Mutex::new(State { @@ -550,8 +706,15 @@ fn setup_and_run(options: Options, on_status: OnStatus, code: Box>> = Arc::new(Mutex::new(None)); let audio_thread = match aac { Some(enc) if audio_accepted => { - let (session_ref, over, counter, process) = (session_ref.clone(), over.clone(), audio_frames.clone(), audio_process.clone()); - Some(std::thread::spawn(move || run_audio(enc, session_ref, over, started, counter, process))) + let (session_ref, over, counter, process) = ( + session_ref.clone(), + over.clone(), + audio_frames.clone(), + audio_process.clone(), + ); + Some(std::thread::spawn(move || { + run_audio(enc, session_ref, over, started, counter, process) + })) } _ => None, }; @@ -575,16 +738,30 @@ fn setup_and_run(options: Options, on_status: OnStatus, code: Box st.ended = Some(reason), + Event::Closed(reason) + if matches!( + reason.as_str(), + "stopped_by_receiver" | "replaced" | "receiver_stopped" + ) => + { + st.ended = Some(reason) + } Event::Closed(reason) => { st.lost.get_or_insert(reason); } - Event::Stats { decode_ms, dropped, fps } => { + Event::Stats { + decode_ms, + dropped, + fps, + } => { st.last_report = Some((decode_ms, dropped, fps)); - on_status(Status::Receiver { decode_ms, dropped, fps }); + on_status(Status::Receiver { + decode_ms, + dropped, + fps, + }); } Event::KeyFrameRequested => st.want_key = true, } } // A repeat stands in where nothing new came for as long as `repeat_wait` says. - if st.have_picture && st.last.elapsed() >= repeat_wait(interval, st.repeats_in_a_row, st.gap) { + if st.have_picture + && st.last.elapsed() >= repeat_wait(interval, st.repeats_in_a_row, st.gap) + { push(&mut st, link, Instant::now(), started, &config, codec, true); st.repeats_in_a_row = st.repeats_in_a_row.saturating_add(1); if st.repeats_in_a_row >= STILL_NOTE_AFTER && !st.still && interval < STILL_REPEAT { @@ -622,7 +816,13 @@ fn setup_and_run(options: Options, on_status: OnStatus, code: Box { renewed = Some(session); break; @@ -662,7 +869,8 @@ fn setup_and_run(options: Options, on_status: OnStatus, code: Box { // The same receiver, so the same format; but it is what was agreed, not what was assumed. - st.format = VideoFormat::from_protocol_name(&session.format).unwrap_or_default(); + st.format = + VideoFormat::from_protocol_name(&session.format).unwrap_or_default(); *session_ref.lock().unwrap() = Some(session); st.encoder = None; st.captured.clear(); @@ -671,7 +879,12 @@ fn setup_and_run(options: Options, on_status: OnStatus, code: Box st.failed = Some(Failure::new("network", "the receiver could not be reached again")), + None => { + st.failed = Some(Failure::new( + "network", + "the receiver could not be reached again", + )) + } } } }) @@ -680,12 +893,24 @@ fn setup_and_run(options: Options, on_status: OnStatus, code: Box seen; @@ -790,10 +1034,18 @@ fn setup_and_run(options: Options, on_status: OnStatus, code: Box { - state.lock().unwrap().ended.get_or_insert_with(|| "the captured window or screen went away".into()); + state + .lock() + .unwrap() + .ended + .get_or_insert_with(|| "the captured window or screen went away".into()); } Err(e) => { - state.lock().unwrap().failed.get_or_insert_with(|| Failure::new("capture", e.to_string())); + state + .lock() + .unwrap() + .failed + .get_or_insert_with(|| Failure::new("capture", e.to_string())); } Ok(_) => {} } @@ -803,7 +1055,13 @@ fn setup_and_run(options: Options, on_status: OnStatus, code: Box>, started: Instant, stop: &Arc, on_status: &OnStatus, audio_frames: u64) -> Result { +fn report( + state: &Arc>, + started: Instant, + stop: &Arc, + on_status: &OnStatus, + audio_frames: u64, +) -> Result { let mut st = state.lock().unwrap(); let ended = if let Some(failure) = st.failed.clone() { failure.detail @@ -866,11 +1124,23 @@ mod tests { fn a_new_picture_is_taken_at_its_turn_not_early_and_always_after_a_repeat() { let interval = Duration::from_micros(33_333); let ms = Duration::from_millis; - assert!(takes_new_picture(false, false, ms(1), interval), "the first picture"); - assert!(takes_new_picture(true, false, ms(33), interval), "a picture a frame after the last: 30 pictures a second stay 30"); + assert!( + takes_new_picture(false, false, ms(1), interval), + "the first picture" + ); + assert!( + takes_new_picture(true, false, ms(33), interval), + "a picture a frame after the last: 30 pictures a second stay 30" + ); assert!(takes_new_picture(true, false, ms(26), interval)); - assert!(!takes_new_picture(true, false, ms(16), interval), "a screen at 60 Hz sends every other one"); - assert!(takes_new_picture(true, true, ms(2), interval), "after a repeat"); + assert!( + !takes_new_picture(true, false, ms(16), interval), + "a screen at 60 Hz sends every other one" + ); + assert!( + takes_new_picture(true, true, ms(2), interval), + "after a repeat" + ); } #[test] diff --git a/desktop/core/sender/src/lib.rs b/desktop/core/sender/src/lib.rs index a36658d..6d60b14 100644 --- a/desktop/core/sender/src/lib.rs +++ b/desktop/core/sender/src/lib.rs @@ -76,12 +76,21 @@ pub enum Status { /// The receiver asked for a pairing code (it shows one on its screen). NeedsCode, /// `format` is what is sent: `h264` or `h265`. - Casting { receiver: String, width: u32, height: u32, format: &'static str }, + Casting { + receiver: String, + width: u32, + height: u32, + format: &'static str, + }, /// The connection broke; a new one is being made. Reconnecting(String), Reconnected, /// The receiver's once-a-second report. - Receiver { decode_ms: i64, dropped: u64, fps: f64 }, + Receiver { + decode_ms: i64, + dropped: u64, + fps: f64, + }, /// The bitrate in use changed (the connection could not keep up, or has recovered), in bit/s. Bitrate(u32), /// The screen stopped changing and the frame rate was lowered (true), or it changed again and the @@ -139,7 +148,10 @@ pub struct Failure { impl Failure { pub fn new(code: &str, detail: impl Into) -> Failure { - Failure { code: code.into(), detail: detail.into() } + Failure { + code: code.into(), + detail: detail.into(), + } } } @@ -159,7 +171,10 @@ impl From for Failure { E::Protocol(_) => "protocol".into(), E::Io(_) => "network".into(), }; - Failure { code, detail: e.to_string() } + Failure { + code, + detail: e.to_string(), + } } } @@ -215,7 +230,9 @@ impl Handle { if let Some(done) = self.finished.take() { return done; } - self.result.recv().unwrap_or_else(|_| Err(Failure::new("other", "the cast thread crashed"))) + self.result + .recv() + .unwrap_or_else(|_| Err(Failure::new("other", "the cast thread crashed"))) } /// Whether the cast has ended (without waiting). @@ -234,7 +251,11 @@ impl Handle { /// Starts casting on its own threads. `code` is asked for the pairing code when the receiver /// needs one (the person reads it off the TV). #[cfg(any(windows, target_os = "linux"))] -pub fn start(options: Options, on_status: OnStatus, code: Box Option + Send>) -> Handle { +pub fn start( + options: Options, + on_status: OnStatus, + code: Box Option + Send>, +) -> Handle { let stop = Arc::new(std::sync::atomic::AtomicBool::new(false)); let flag = stop.clone(); let (tx, result) = std::sync::mpsc::channel(); @@ -244,14 +265,27 @@ pub fn start(options: Options, on_status: OnStatus, code: Box .name("castbay-cast".into()) .spawn(move || engine::run(options, on_status, code, flag, switch_for_engine, tx)) .expect("a thread"); - Handle { stop, switch, result, finished: std::cell::Cell::new(None) } + Handle { + stop, + switch, + result, + finished: std::cell::Cell::new(None), + } } #[cfg(not(any(windows, target_os = "linux")))] pub fn start(_: Options, _: OnStatus, _: Box Option + Send>) -> Handle { let (tx, result) = std::sync::mpsc::channel(); - let _ = tx.send(Err(Failure::new("other", "casting is not implemented on this system"))); - Handle { stop: Arc::new(std::sync::atomic::AtomicBool::new(true)), switch: Arc::new(std::sync::Mutex::new(None)), result, finished: std::cell::Cell::new(None) } + let _ = tx.send(Err(Failure::new( + "other", + "casting is not implemented on this system", + ))); + Handle { + stop: Arc::new(std::sync::atomic::AtomicBool::new(true)), + switch: Arc::new(std::sync::Mutex::new(None)), + result, + finished: std::cell::Cell::new(None), + } } #[cfg(test)] @@ -262,7 +296,10 @@ mod tests { fn link_errors_become_codes_the_app_can_word() { use castbay_link::Error as E; assert_eq!(Failure::from(E::Rejected("busy".into())).code, "busy"); - assert_eq!(Failure::from(E::PairingFailed("wrong_code".into())).code, "wrong_code"); + assert_eq!( + Failure::from(E::PairingFailed("wrong_code".into())).code, + "wrong_code" + ); assert_eq!(Failure::from(E::CodeRequired).code, "code_required"); assert_eq!(Failure::from(E::ReceiverChanged).code, "receiver_changed"); assert_eq!(Failure::from(E::Io("x".into())).code, "network"); diff --git a/desktop/core/sender/src/power.rs b/desktop/core/sender/src/power.rs index a8028dd..dd7d552 100644 --- a/desktop/core/sender/src/power.rs +++ b/desktop/core/sender/src/power.rs @@ -2,8 +2,12 @@ //! screen (which Windows does not let anything capture) should be told to the person. use windows::Win32::Media::{timeBeginPeriod, timeEndPeriod}; -use windows::Win32::System::Power::{SetThreadExecutionState, ES_CONTINUOUS, ES_DISPLAY_REQUIRED, ES_SYSTEM_REQUIRED}; -use windows::Win32::System::StationsAndDesktops::{CloseDesktop, OpenInputDesktop, DESKTOP_CONTROL_FLAGS, DESKTOP_SWITCHDESKTOP}; +use windows::Win32::System::Power::{ + SetThreadExecutionState, ES_CONTINUOUS, ES_DISPLAY_REQUIRED, ES_SYSTEM_REQUIRED, +}; +use windows::Win32::System::StationsAndDesktops::{ + CloseDesktop, OpenInputDesktop, DESKTOP_CONTROL_FLAGS, DESKTOP_SWITCHDESKTOP, +}; /// Keeps the PC awake for as long as it lives, on the thread that made it (that is how Windows /// scopes the request); what Windows lists under `powercfg /requests`. diff --git a/desktop/core/sender/src/power_linux.rs b/desktop/core/sender/src/power_linux.rs index cef9f5e..413357f 100644 --- a/desktop/core/sender/src/power_linux.rs +++ b/desktop/core/sender/src/power_linux.rs @@ -8,7 +8,14 @@ pub struct Awake(Option); impl Awake { pub fn new() -> Awake { let child = Command::new("systemd-inhibit") - .args(["--what=idle:sleep", "--who=CastBay Desktop", "--why=Casting the screen", "--mode=block", "sleep", "infinity"]) + .args([ + "--what=idle:sleep", + "--who=CastBay Desktop", + "--why=Casting the screen", + "--mode=block", + "sleep", + "infinity", + ]) .stdin(Stdio::null()) .stdout(Stdio::null()) .stderr(Stdio::null()) @@ -29,7 +36,9 @@ impl Drop for Awake { /// Whether the session is locked, as the desktop told logind. pub fn screen_locked() -> bool { - let Ok(id) = std::env::var("XDG_SESSION_ID") else { return false }; + let Ok(id) = std::env::var("XDG_SESSION_ID") else { + return false; + }; Command::new("loginctl") .args(["show-session", &id, "-p", "LockedHint", "--value"]) .stdin(Stdio::null()) diff --git a/desktop/core/sender/src/rate.rs b/desktop/core/sender/src/rate.rs index 97a71c5..343b1f3 100644 --- a/desktop/core/sender/src/rate.rs +++ b/desktop/core/sender/src/rate.rs @@ -25,7 +25,14 @@ impl RateControl { /// `target` is what the person asked for; it is also the most that is ever used. pub fn new(target: u32, now: Instant) -> RateControl { let floor = (target / 6).max(1_500_000).min(target); - RateControl { target, current: target, floor, drops: VecDeque::new(), last_drop: None, last_change: now } + RateControl { + target, + current: target, + floor, + drops: VecDeque::new(), + last_drop: None, + last_change: now, + } } pub fn current(&self) -> u32 { @@ -40,7 +47,11 @@ impl RateControl { /// Call every now and then; the new bitrate when it should change. pub fn adjust(&mut self, now: Instant) -> Option { - while self.drops.front().is_some_and(|&t| now.duration_since(t) > WINDOW) { + while self + .drops + .front() + .is_some_and(|&t| now.duration_since(t) > WINDOW) + { self.drops.pop_front(); } if now.duration_since(self.last_change) < COOLDOWN { @@ -52,7 +63,9 @@ impl RateControl { self.last_change = now; return Some(self.current); } - let calm = self.last_drop.map_or(true, |t| now.duration_since(t) >= CALM); + let calm = self + .last_drop + .map_or(true, |t| now.duration_since(t) >= CALM); if self.current < self.target && calm && now.duration_since(self.last_change) >= CALM { self.current = (self.current as u64 * 115 / 100).min(self.target as u64) as u32; self.last_change = now; diff --git a/desktop/docs/design.md b/desktop/docs/design.md index 199bdb8..76db597 100644 --- a/desktop/docs/design.md +++ b/desktop/docs/design.md @@ -1,6 +1,6 @@ # CastBay Desktop: design -Status: draft for review. Decisions marked **open** need an experiment before they are final. +Status: implementation update. The original Tauri shell decision below is superseded by the shared GPUI shell in `app-gpui/`; historical planning details remain for context. ## 1. Goals and non-goals @@ -38,7 +38,8 @@ desktop/ encode/ trait Encoder; Media Foundation H.264 (now) session/ glues capture, encode and link; owns the lifecycle and stats cli/ `castbay-cast`: a command-line sender used for tests and benchmarks - app/ Tauri 2 + React + TypeScript shell (UI only) + app/ legacy shell modules retained for shared support code and reference + app-gpui/ shared GPUI desktop application (Windows and Linux) .github/workflows/desktop.yml path-filtered to desktop/** ``` @@ -57,19 +58,19 @@ appears. ## 4. Desktop stack -**Tauri 2 shell over an independent Rust core.** Capture, encoding and networking are native -in either framework, and the UI is a device list, a source picker and a status page, so the -framework matters least. Keeping everything below the UI in `core` means the shell can be -swapped (Electron through napi-rs) without touching it, which is what keeps this decision -reversible. +**GPUI shell over an independent Rust core.** Windows and Linux use one Rust UI implementation +for receiver discovery, settings, paired devices, diagnostics, reports, updates and casting +status. The screen/window selection remains platform-specific because Linux uses the XDG desktop +portal while Windows enumerates capture sources directly. Core capture, encoding and transport +remain independent from the UI. Why not rely on the web view's `getDisplayMedia` and WebCodecs: it exists on Windows (WebView2) but not on the other systems' web views, and it gives little control over frame rate, bitrate, window selection and latency. -Costs accepted: the project has no Rust yet; Linux web views are the weakest part of Tauri -(only the UI is affected). **open**: if the Tauri build or WebView2 deployment turns out -painful in Phase 1, revisit. +The GPUI crates are pinned to a stable crates.io distribution and the same application is built +on Windows and Linux in CI. Keep the legacy shell excluded from the default workspace build while +shared support modules are migrated out of it. ## 5. Pipeline (sender) diff --git a/desktop/installer/build-msi.ps1 b/desktop/installer/build-msi.ps1 index f7a664d..2ec56f7 100644 --- a/desktop/installer/build-msi.ps1 +++ b/desktop/installer/build-msi.ps1 @@ -1,7 +1,8 @@ # Builds the English and Chinese MSIs. Needs the WiX 4 tool (dotnet tool install --global wix --version 4.0.5). -# Usage: build-msi.ps1 -Version 0.1.0 -AppExe -LicenseTxt -OutDir -NameStem CastBay-Desktop-0.1.0-windows-x64 +# Usage: build-msi.ps1 -Version 0.1.0 -AppExe -VCRuntimeDll -LicenseTxt -OutDir -NameStem CastBay-Desktop-0.1.0-windows-x64 param( [Parameter(Mandatory)] [string] $Version, [Parameter(Mandatory)] [string] $AppExe, + [Parameter(Mandatory)] [string] $VCRuntimeDll, [Parameter(Mandatory)] [string] $LicenseTxt, [Parameter(Mandatory)] [string] $OutDir, [Parameter(Mandatory)] [string] $NameStem ) @@ -17,7 +18,8 @@ foreach ($culture in @(@('en-US', 1033), @('zh-CN', 2052))) { $out = Join-Path $OutDir "$NameStem-$name.msi" wix build -arch x64 -ext WixToolset.UI.wixext -culture $name -loc "$here\$name.wxl" ` -d "Version=$Version" -d "Lcid=$lcid" -d "AppExe=$AppExe" -d "AppIcon=$here\..\app\icons\icon.ico" ` - -d "LicenseTxt=$LicenseTxt" -d "LicenseRtf=$rtf" -o $out "$here\castbay-desktop.wxs" + -d "VCRuntimeDll=$VCRuntimeDll" -d "LicenseTxt=$LicenseTxt" -d "LicenseRtf=$rtf" ` + -o $out "$here\castbay-desktop.wxs" if ($LASTEXITCODE -ne 0) { throw "wix build failed for $name" } Get-Item $out | Select-Object Name, Length } diff --git a/desktop/installer/castbay-desktop.wxs b/desktop/installer/castbay-desktop.wxs index dbebe5a..c31b577 100644 --- a/desktop/installer/castbay-desktop.wxs +++ b/desktop/installer/castbay-desktop.wxs @@ -10,6 +10,7 @@ wix build -arch x64 -ext WixToolset.UI.wixext -culture -loc .wxl -d Version=0.1.0 -d AppExe=... -d AppIcon=... -d LicenseTxt=... -d LicenseRtf=... + -d VCRuntimeDll=... -o out.msi castbay-desktop.wxs --> @@ -36,6 +37,7 @@ + diff --git a/desktop/installer/collect-vc-runtime.ps1 b/desktop/installer/collect-vc-runtime.ps1 new file mode 100644 index 0000000..d8dc908 --- /dev/null +++ b/desktop/installer/collect-vc-runtime.ps1 @@ -0,0 +1,27 @@ +# Stage the licensed x64 MSVC runtime DLLs required by CastBay Desktop for app-local deployment. +# Usage: collect-vc-runtime.ps1 -OutDir +param([Parameter(Mandatory)] [string] $OutDir) +$ErrorActionPreference = 'Stop' + +$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe' +if (-not (Test-Path $vswhere)) { throw "vswhere.exe was not found: $vswhere" } +$vsPath = & $vswhere -latest -products '*' -property installationPath +if (-not $vsPath -or $LASTEXITCODE -ne 0) { throw 'Visual Studio installation was not found.' } + +$redistRoot = Join-Path $vsPath 'VC\Redist\MSVC' +if (-not (Test-Path $redistRoot)) { throw "MSVC redistributable directory was not found: $redistRoot" } +$runtimeDirs = Get-ChildItem $redistRoot -Directory | + Sort-Object { try { [version]$_.Name } catch { [version]'0.0' } } -Descending | + ForEach-Object { Join-Path $_.FullName 'x64\Microsoft.VC143.CRT' } +$runtimeDir = $runtimeDirs | Where-Object { Test-Path (Join-Path $_ 'vcruntime140.dll') } | Select-Object -First 1 +if (-not $runtimeDir) { throw 'The x64 Microsoft.VC143.CRT app-local runtime was not found.' } + +New-Item -ItemType Directory -Force $OutDir | Out-Null +Copy-Item (Join-Path $runtimeDir 'vcruntime140.dll') (Join-Path $OutDir 'vcruntime140.dll') -Force +$file = Get-Item (Join-Path $OutDir 'vcruntime140.dll') +$signature = Get-AuthenticodeSignature $file.FullName +if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notlike '*Microsoft Corporation*') { + throw "The staged runtime DLL does not have a valid Microsoft signature: $($signature.Status)" +} +"Staged $($file.Name), $($file.Length) bytes, signer: $($signature.SignerCertificate.Subject)" +Get-FileHash $file.FullName -Algorithm SHA256 | Select-Object Algorithm, Hash diff --git a/desktop/installer/linux/build-deb.sh b/desktop/installer/linux/build-deb.sh index 6061c37..44bf4cd 100755 --- a/desktop/installer/linux/build-deb.sh +++ b/desktop/installer/linux/build-deb.sh @@ -21,7 +21,7 @@ Version: $version Section: video Priority: optional Architecture: $arch -Depends: libwebkit2gtk-4.1-0, libgtk-3-0, libayatana-appindicator3-1 | libappindicator3-1, libpipewire-0.3-0, xdg-desktop-portal, xdg-utils, curl +Depends: libgtk-3-0, libxdo3, libxkbcommon-x11-0, libayatana-appindicator3-1 | libappindicator3-1, libpipewire-0.3-0, xdg-desktop-portal, xdg-utils, curl Recommends: gnome-shell-extension-appindicator | xfce4-statusnotifier-plugin Maintainer: CastBay Homepage: https://castbay.weenas.com diff --git a/desktop/installer/test-install.ps1 b/desktop/installer/test-install.ps1 index 40561e9..d52b7ed 100644 --- a/desktop/installer/test-install.ps1 +++ b/desktop/installer/test-install.ps1 @@ -30,6 +30,7 @@ function Msiexec($arguments) { foreach ($round in 1, 2) { Msiexec "/i `"$Msi`" /qn /l*v `"$log`"" Check (Test-Path $exe) "program installed (round $round)" + Check (Test-Path (Join-Path $dir 'vcruntime140.dll')) 'app-local Visual C++ runtime installed' Check (Test-Path $lnk) 'Start menu shortcut' $entry = Arp Check ($null -ne $entry) 'Settings > Apps entry' @@ -49,6 +50,8 @@ Check ($null -ne (Get-ItemProperty $run -Name CastBayDesktop -ErrorAction Silent $app = Start-Process $exe -PassThru Start-Sleep 8 Check (-not $app.HasExited) 'program keeps running after start' +$runtime = (Get-Process -Id $app.Id).Modules | Where-Object ModuleName -IEQ 'vcruntime140.dll' | Select-Object -First 1 +Check ($runtime -and $runtime.FileName.StartsWith($dir, [StringComparison]::OrdinalIgnoreCase)) 'program loads the app-local Visual C++ runtime' # Uninstalling closes the running program, then removes everything. Msiexec "/x `"$Msi`" /qn /l*v `"$log`"" diff --git a/desktop/installer/test-portable.ps1 b/desktop/installer/test-portable.ps1 new file mode 100644 index 0000000..402f04b --- /dev/null +++ b/desktop/installer/test-portable.ps1 @@ -0,0 +1,30 @@ +# Extracts the portable package, starts the application and verifies that it loaded the app-local CRT. +# Usage: test-portable.ps1 -Zip +param([Parameter(Mandatory)] [string] $Zip) +$ErrorActionPreference = 'Stop' +$temp = Join-Path $env:TEMP ([guid]::NewGuid().ToString('N')) +$process = $null +try { + Expand-Archive -LiteralPath $Zip -DestinationPath $temp + $appDir = Get-ChildItem $temp -Directory | Select-Object -First 1 + if (-not $appDir) { throw 'Portable archive did not contain an application directory.' } + $exe = Join-Path $appDir.FullName 'CastBay Desktop.exe' + $runtimeDll = Join-Path $appDir.FullName 'vcruntime140.dll' + if (-not (Test-Path $exe)) { throw 'Portable archive did not contain CastBay Desktop.exe.' } + if (-not (Test-Path $runtimeDll)) { throw 'Portable archive did not contain vcruntime140.dll.' } + + $process = Start-Process -FilePath $exe -WorkingDirectory $appDir.FullName -PassThru + Start-Sleep -Seconds 8 + $process.Refresh() + if ($process.HasExited) { throw "Portable application exited with code $($process.ExitCode)." } + $loadedRuntime = (Get-Process -Id $process.Id).Modules | + Where-Object ModuleName -IEQ 'vcruntime140.dll' | Select-Object -First 1 + if (-not $loadedRuntime -or -not $loadedRuntime.FileName.StartsWith($appDir.FullName, [StringComparison]::OrdinalIgnoreCase)) { + throw 'The portable application did not load vcruntime140.dll from its own folder.' + } + "Portable smoke test passed; runtime loaded from $($loadedRuntime.FileName)" +} +finally { + if ($process -and -not $process.HasExited) { Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue } + Remove-Item $temp -Recurse -Force -ErrorAction SilentlyContinue +} diff --git a/desktop/rust-toolchain.toml b/desktop/rust-toolchain.toml new file mode 100644 index 0000000..f71b0da --- /dev/null +++ b/desktop/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.98.1" +profile = "minimal"