commit 1fcd3a85f7c28b70835bea12f5cc440703564572 Author: Christian Date: Wed Nov 18 17:44:07 2026 -0500 Atmosphere: music library, player and downloader Native Rust + Tauri 2 app for Windows, macOS and Linux. - Library with songs, albums, artist profiles, liked songs and folder-based playlists - Player with EQ, presets, filters, reverb, 8D, independent pitch and tempo - Synced and word-synced lyrics (local, LRCLIB, NetEase, Musixmatch API, custom) - TV mode with second-screen output - Downloader built on yt-dlp and ffmpeg with honest format choices and tagging - Listening stats with shareable social-size cards - Portable mode, temp-file cleanup, branded installers diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c040b4d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,66 @@ +# atmosphere · build.yml · CI: runs the tests and builds installers for Windows, macOS (Apple Silicon + Intel) and Linux. +name: build + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + name: windows-x64 + - os: macos-latest + name: macos-arm64 + - os: macos-13 + name: macos-x64 + - os: ubuntu-22.04 + name: linux-x64 + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Linux system libraries + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf + + - uses: dtolnay/rust-toolchain@stable + + - uses: Swatinem/rust-cache@v2 + + - name: Tests + run: cargo test --locked + + - name: Install Tauri CLI + run: cargo install tauri-cli --version "^2" --locked + + - name: Build installers + run: cargo tauri build + + - name: Portable executable + if: runner.os == 'Windows' + uses: actions/upload-artifact@v4 + with: + name: atmosphere-portable-${{ matrix.name }} + path: target/release/atmosphere.exe + if-no-files-found: error + + - uses: actions/upload-artifact@v4 + with: + name: atmosphere-${{ matrix.name }} + path: | + target/release/bundle/**/*.msi + target/release/bundle/**/*.exe + target/release/bundle/**/*.dmg + target/release/bundle/**/*.app.tar.gz + target/release/bundle/**/*.deb + target/release/bundle/**/*.rpm + target/release/bundle/**/*.AppImage + if-no-files-found: error diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..03bc4a5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/target +/gen +*.part +*.ytdl +AtmosphereData/ +portable +portable.txt +Thumbs.db +.DS_Store diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..1c257ee --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,6255 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloc-no-stdlib" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2fb6cfd47bf496ff64095c20eaba0c201404ee38714d4142fcfa1dc334fcc7a" + +[[package]] +name = "alloc-stdlib" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5c1865780388bfa186411ab5f247819487fc4864c6e9c3106611fa347586e1" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "arboard" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb9553e62312c8756a5979254fc6d7da8bbeb5986a1e17037fab932f7037917" +dependencies = [ + "clipboard-win", + "image", + "log", + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation", + "parking_lot", + "percent-encoding", + "windows-sys 0.61.2", + "wl-clipboard-rs", + "x11rb", +] + +[[package]] +name = "async-broadcast" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-channel" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-compression" +version = "0.4.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ad47a740fb906fffdd891e8b6d5fde2511600f7bfaebd68939fa08a14999459" +dependencies = [ + "compression-codecs", + "compression-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "async-executor" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f426a31126c735126297bc5ea7a521263c9faff4f63ca415267ee625651c4f37" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" +dependencies = [ + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-lock" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0876700b0d007ad25d5508865a4259c3af9af6d296bf663a0d586d0bc3369f6f" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75" +dependencies = [ + "async-channel", + "async-io", + "async-lock", + "async-signal", + "async-task", + "blocking", + "cfg-if", + "event-listener", + "futures-lite", + "rustix", +] + +[[package]] +name = "async-recursion" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "async-signal" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix", + "signal-hook-registry", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + +[[package]] +name = "async-trait" +version = "0.1.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "atk" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b" +dependencies = [ + "atk-sys", + "glib", + "libc", +] + +[[package]] +name = "atk-sys" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "atmosphere" +version = "0.1.0" +dependencies = [ + "anyhow", + "base64 0.23.1", + "bytes", + "dirs", + "futures-util", + "image", + "lofty", + "lzma-rs", + "notify", + "regex", + "reqwest 0.12.28", + "serde", + "serde_json", + "sha2 0.11.1", + "tar", + "tauri", + "tauri-build", + "tauri-plugin-clipboard-manager", + "tauri-plugin-dialog", + "tauri-plugin-opener", + "tokio", + "trash", + "url", + "walkdir", + "zip", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec 0.8.0", +] + +[[package]] +name = "bit-set" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d87354e4229f54a44f7bf2435906a4656dba36026ab6eaca629a2c436a691c" +dependencies = [ + "bit-vec 0.10.2", +] + +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + +[[package]] +name = "bit-vec" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72503af1e72be411d74ca45cd6b309878fcb35354e252fc2a3a8bda3a97082a0" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +dependencies = [ + "serde_core", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "block2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" +dependencies = [ + "objc2", +] + +[[package]] +name = "blocking" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + +[[package]] +name = "brotli" +version = "9.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9071f285ed78f04f37d675abaaef5de7689e2f30a216c8dc6795465d81910a13" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "6.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc031cd87c6529082b0b65c604e86af0ed7744841b17ccfe60b1e31fa606179e" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "bumpalo" +version = "3.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" + +[[package]] +name = "byteorder" +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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "776dfebd015e2d8732c684a2c71003674ccb49457b539b9e82151ba38e96dd7c" +dependencies = [ + "serde", +] + +[[package]] +name = "cairo-rs" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2" +dependencies = [ + "bitflags 2.13.2", + "cairo-sys-rs", + "glib", + "libc", + "once_cell", + "thiserror 1.0.69", +] + +[[package]] +name = "cairo-sys-rs" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "camino" +version = "1.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbad30e4b4c14a39e3cc8aed085a12a327257c316619c93581e017bc52be591" +dependencies = [ + "serde_core", +] + +[[package]] +name = "cargo-platform" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +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.2.1+spec-1.1.0", +] + +[[package]] +name = "cc" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +dependencies = [ + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cfg-if" +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 = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "rand_core", +] + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "num-traits", + "serde", + "windows-link", +] + +[[package]] +name = "clipboard-win" +version = "5.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052af7878466feccda12ba7a6a67d019d712f296809559b47c12c8cc196d3a9a" +dependencies = [ + "error-code", +] + +[[package]] +name = "combine" +version = "4.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "compression-codecs" +version = "0.4.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84f840cff84d10085260e460023934d0af699e71212b09b2a41452e8bd9cda43" +dependencies = [ + "compression-core", + "flate2", + "memchr", +] + +[[package]] +name = "compression-core" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ebdda89edc534bf8d5dd2857562633b6495557e5846552ade994b99ed13c36a" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-oid" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" + +[[package]] +name = "constant_time_eq" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eb6feb175df65d0a3ccd3e73484e940d0ac664e8034f0519fd49a93db3071d9" +dependencies = [ + "rustversion", +] + +[[package]] +name = "cookie" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87" +dependencies = [ + "time", + "version_check", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core-graphics" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97" +dependencies = [ + "bitflags 2.13.2", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" +dependencies = [ + "bitflags 2.13.2", + "core-foundation", + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "217698eaf96b4a3f0bc4f3662aaa55bdf913cd54d7204591faa790070c6d0853" + +[[package]] +name = "crc32fast" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-common" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "cssparser" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9cdaae01d5ed7882b04d795e7f752f46ff52d2fa3b50a20d28c464510bba98" +dependencies = [ + "cssparser-macros", + "dtoa-short", + "itoa", + "phf 0.13.1", + "smallvec", +] + +[[package]] +name = "cssparser" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11119743ad110e8c1bdccd930d7f5c30c99e5fc76a7b63ec9807e84eef0c5f59" +dependencies = [ + "cssparser-macros", + "dtoa-short", + "itoa", + "phf 0.14.0", + "smallvec", +] + +[[package]] +name = "cssparser-macros" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d045de693cb712d0b22c6a64be5b953f67b3ce00ab5ad3dd5d8b441886ab8e1a" +dependencies = [ + "quote", + "syn 3.0.10", +] + +[[package]] +name = "ctor" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea691ed9f36489d087419b8b2ba3ef27d89621380b4178c73e2445a379e4e0f4" +dependencies = [ + "link-section", +] + +[[package]] +name = "darling" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 3.0.10", +] + +[[package]] +name = "darling_macro" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" +dependencies = [ + "darling_core", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "data-encoding" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" + +[[package]] +name = "dbus" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab69f03cc8c4340c9c8e315114e1658e6775a9b16a04357973aa21cec22b32e" +dependencies = [ + "libc", + "libdbus-sys", + "windows-sys 0.61.2", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common 0.1.7", +] + +[[package]] +name = "digest" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" +dependencies = [ + "block-buffer 0.12.1", + "const-oid", + "crypto-common 0.2.2", +] + +[[package]] +name = "dirs" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.61.2", +] + +[[package]] +name = "dispatch2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" +dependencies = [ + "bitflags 2.13.2", + "block2", + "libc", + "objc2", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "dlopen2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e2c5bd4158e66d1e215c49b837e11d62f3267b30c92f1d171c4d3105e3dc4d4" +dependencies = [ + "dlopen2_derive", + "libc", + "once_cell", + "winapi", +] + +[[package]] +name = "dlopen2_derive" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fbbb781877580993a8707ec48672673ec7b81eeba04cfd2310bd28c08e47c8f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "dom_query" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fac5fca71e65e94cc718a6e2af65d6e0f9c6027751c2aa562fbb5087fda639bc" +dependencies = [ + "bit-set 0.8.0", + "cssparser 0.37.0", + "foldhash 0.2.0", + "html5ever 0.39.0", + "precomputed-hash", + "selectors 0.38.0", + "tendril", +] + +[[package]] +name = "dom_query" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "498c698ac51127148a3984450e51fca7f01805a91d7a1f7a24af0a5f761e3385" +dependencies = [ + "bit-set 0.11.1", + "cssparser 0.38.0", + "foldhash 0.2.0", + "html5ever 0.40.1", + "precomputed-hash", + "selectors 0.41.0", + "tendril", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c3cf4824e2d5f025c7b531afcb2325364084a16806f6d47fbc1f5fbd9960590" + +[[package]] +name = "dtoa-short" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd1511a7b6a56299bd043a9c167a6d2bfb37bf84a6dfceaba651168adfb43c87" +dependencies = [ + "dtoa", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + +[[package]] +name = "embed-resource" +version = "3.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6168487b5e7eb2673e6efe1200b1848016e436a6ca0b8031bf04bd9d493a249f" +dependencies = [ + "cc", + "memchr", + "rustc_version", + "toml 1.2.1+spec-1.1.0", + "vswhom", + "winreg", +] + +[[package]] +name = "embed_plist" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7" + +[[package]] +name = "endi" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" + +[[package]] +name = "enumflags2" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" +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 = "erased-serde" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e59b668157f32d3459d4bd634861a06ffa2503a461ca5f0916b9f0252605e66" +dependencies = [ + "serde", + "serde_core", + "typeid", +] + +[[package]] +name = "errno" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "error-code" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7" + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "field-offset" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" +dependencies = [ + "memoffset", + "rustc_version", +] + +[[package]] +name = "filetime" +version = "0.2.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1255e7a9f1902190d4c10a75f2f7f495d3d3ce13e9ba26e6c48683a0f4dbed7" +dependencies = [ + "cfg-if", + "libc", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "fixedbitset" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5905ec755cc8386d7928353e4d356d2be3e89e81e5ca01fe630a1ca4d08dc175" + +[[package]] +name = "flate2" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" +dependencies = [ + "crc32fast", + "miniz_oxide 0.9.1", + "zlib-rs", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea5190182e6915eb873ddbc16e23b711b6eb1f9c00a0d0a3a91b5f6228475225" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-lite" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "gdk" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9f245958c627ac99d8e529166f9823fb3b838d1d41fd2b297af3075093c2691" +dependencies = [ + "cairo-rs", + "gdk-pixbuf", + "gdk-sys", + "gio", + "glib", + "libc", + "pango", +] + +[[package]] +name = "gdk-pixbuf" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec" +dependencies = [ + "gdk-pixbuf-sys", + "gio", + "glib", + "libc", + "once_cell", +] + +[[package]] +name = "gdk-pixbuf-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gdk-sys" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c2d13f38594ac1e66619e188c6d5a1adb98d11b2fcf7894fc416ad76aa2f3f7" +dependencies = [ + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "pkg-config", + "system-deps", +] + +[[package]] +name = "gdkwayland-sys" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "140071d506d223f7572b9f09b5e155afbd77428cd5cc7af8f2694c41d98dfe69" +dependencies = [ + "gdk-sys", + "glib-sys", + "gobject-sys", + "libc", + "pkg-config", + "system-deps", +] + +[[package]] +name = "gdkx11" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3caa00e14351bebbc8183b3c36690327eb77c49abc2268dd4bd36b856db3fbfe" +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", + "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", +] + +[[package]] +name = "gethostname" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" +dependencies = [ + "rustix", + "windows-link", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 6.0.0", + "rand_core", + "wasm-bindgen", +] + +[[package]] +name = "gio" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "gio-sys", + "glib", + "libc", + "once_cell", + "pin-project-lite", + "smallvec", + "thiserror 1.0.69", +] + +[[package]] +name = "gio-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", + "winapi", +] + +[[package]] +name = "glib" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" +dependencies = [ + "bitflags 2.13.2", + "futures-channel", + "futures-core", + "futures-executor", + "futures-task", + "futures-util", + "gio-sys", + "glib-macros", + "glib-sys", + "gobject-sys", + "libc", + "memchr", + "once_cell", + "smallvec", + "thiserror 1.0.69", +] + +[[package]] +name = "glib-macros" +version = "0.18.5" +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-error", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "glib-sys" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" +dependencies = [ + "libc", + "system-deps", +] + +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + +[[package]] +name = "gobject-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gtk" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd56fb197bfc42bd5d2751f4f017d44ff59fbb58140c6b49f9b3b2bdab08506a" +dependencies = [ + "atk", + "cairo-rs", + "field-offset", + "futures-channel", + "gdk", + "gdk-pixbuf", + "gio", + "glib", + "gtk-sys", + "gtk3-macros", + "libc", + "pango", + "pkg-config", +] + +[[package]] +name = "gtk-sys" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f29a1c21c59553eb7dd40e918be54dccd60c52b049b75119d5d96ce6b624414" +dependencies = [ + "atk-sys", + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "system-deps", +] + +[[package]] +name = "gtk3-macros" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ff3c5b21f14f0736fed6dcfc0bfb4225ebf5725f3c0209edeec181e4d73e9d" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "h2" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d29020232d6aa3fb1daca64c1127cf662cf97f254ae16c18c05b8ab635fc118" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.14.2", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "zerocopy", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +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 = "html5ever" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a1761807faccc9a19e86944bbf40610014066306f96edcdedc2fb714bcb7b8" +dependencies = [ + "log", + "markup5ever 0.39.0", +] + +[[package]] +name = "html5ever" +version = "0.40.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456a1a377e608e555d22ddab27ac0114bc7a7b4199078108e34c2aeae6c9b130" +dependencies = [ + "log", + "markup5ever 0.40.0", + "memchr", +] + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hybrid-array" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" +dependencies = [ + "typenum", +] + +[[package]] +name = "hyper" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" +dependencies = [ + "base64 0.23.1", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "image" +version = "0.25.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" +dependencies = [ + "bytemuck", + "byteorder-lite", + "moxcms", + "num-traits", + "png", + "tiff", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", + "serde", + "serde_core", +] + +[[package]] +name = "infer" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4200d433cbd5178df7797c9c2e75b348b728e39631cf14520d1e2fc424201f4" +dependencies = [ + "cfb", +] + +[[package]] +name = "inotify" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cc00ea907cab49550b7da656f80ebb97be1b997d931fbcd28d39734e17ce592" +dependencies = [ + "bitflags 2.13.2", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c033f80b2c113cdf91ab7a33faa9cbc014726dcad99880c8609af2a370edf37d" +dependencies = [ + "libc", +] + +[[package]] +name = "ipnet" +version = "2.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" + +[[package]] +name = "is-docker" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" +dependencies = [ + "once_cell", +] + +[[package]] +name = "is-wsl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" +dependencies = [ + "is-docker", + "once_cell", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "javascriptcore-rs" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca5671e9ffce8ffba57afc24070e906da7fc4b1ba66f2cabebf61bf2ea257fcc" +dependencies = [ + "bitflags 1.3.2", + "glib", + "javascriptcore-rs-sys", +] + +[[package]] +name = "javascriptcore-rs-sys" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1be78d14ffa4b75b66df31840478fef72b51f8c2465d4ca7c194da9f7a5124" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "jiff" +version = "0.2.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175dc66334db3b9ab9985bf8b61cfed50dc16d20964bb47f9e479adcae984a7f" +dependencies = [ + "jiff-core 0.1.8", + "jiff-static 0.2.46", + "jiff-tzdb-platform", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", + "windows-link", +] + +[[package]] +name = "jiff" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5d126d72eb017f10b302e73bdeca446bea405ee449af4d9e7866d6b082d83e" +dependencies = [ + "jiff-core 1.0.1", + "jiff-static 1.0.1", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", + "windows-link", +] + +[[package]] +name = "jiff-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e599b80292e597019b8b3e392de3f4bea2959ddfb8c7dff60e035e9e311a2c1b" +dependencies = [ + "log", +] + +[[package]] +name = "jiff-core" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b46a105a9874634dd96231021526bf24ca04955a5998c59a9c7666e634b7b8" +dependencies = [ + "log", +] + +[[package]] +name = "jiff-static" +version = "0.2.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7b1af7547d47354bc438d797e3854601bde8f8d185780c5ba4ab27afa54f1ba" +dependencies = [ + "jiff-core 0.1.8", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "jiff-static" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0127e9bde3c6130d6169e7d8d68676e4be69c4bf7573c308b6f960a5089c428" +dependencies = [ + "jiff-core 1.0.1", + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "jiff-tzdb" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0980fca2cc272465bd60e82397607ba9f33add9e48defd77923301bbd03808f2" + +[[package]] +name = "jiff-tzdb-platform" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" +dependencies = [ + "jiff-tzdb", +] + +[[package]] +name = "jni" +version = "0.21.1" +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", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "json-patch" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7421438de105a0827e44fadd05377727847d717c80ce29a229f85fd04c427b72" +dependencies = [ + "jsonptr", + "serde", + "serde_json", + "thiserror 2.0.21", +] + +[[package]] +name = "jsonptr" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5a3cc660ba5d72bce0b3bb295bf20847ccbb40fd423f3f05b61273672e561fe" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "keyboard-types" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fbe853b403ae61a04233030ae8a79d94975281ed9770a1f9e246732b534b28d" +dependencies = [ + "bitflags 2.13.2", + "serde", +] + +[[package]] +name = "kqueue" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d763e5b24120b4ddf50de6c92308156765aabfbbccebf401da7cff2d70a41ea" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07293a4e297ac234359b510362495713f75ea345d5307140414f20c69ffeb087" +dependencies = [ + "bitflags 2.13.2", + "libc", +] + +[[package]] +name = "libappindicator" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a" +dependencies = [ + "glib", + "gtk", + "gtk-sys", + "libappindicator-sys", + "log", +] + +[[package]] +name = "libappindicator-sys" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e9ec52138abedcc58dc17a7c6c0c00a2bdb4f3427c7f63fa97fd0d859155caf" +dependencies = [ + "gtk-sys", + "libloading", + "once_cell", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libdbus-sys" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "328c4789d42200f1eeec05bd86c9c13c7f091d2ba9a6ea35acdf51f31bc0f043" +dependencies = [ + "pkg-config", +] + +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "libredox" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +dependencies = [ + "libc", +] + +[[package]] +name = "link-section" +version = "0.19.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d9aae57673c1a235149777a74d152f3210ebd3e3b13346d2cdb6809e566bd3c" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "lofty" +version = "0.25.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35d45c446382e04663705aa8e786157f64ef1fa85755d410121ffbf08f54b0db" +dependencies = [ + "byteorder", + "data-encoding", + "flate2", + "lofty_attr", + "log", + "ogg_pager", + "paste", +] + +[[package]] +name = "lofty_attr" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdbca1b60ba7cea959ffc84ac27f3dbdbacd6dfda168c7eabbc00e48654bb9fd" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "lru-slab" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f" + +[[package]] +name = "lzma-rs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "297e814c836ae64db86b36cf2a557ba54368d03f6afcd7d947c266692f71115e" +dependencies = [ + "byteorder", + "crc", +] + +[[package]] +name = "markup5ever" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7122d987ec5f704ee56f6e5b41a7d93722e9aae27ae07cafa4036c4d3f9757de" +dependencies = [ + "log", + "tendril", + "web_atoms 0.2.6", +] + +[[package]] +name = "markup5ever" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab3dc68ac4a0f5719e560136778c1ee716e296030d75dbd4484e37e39e3a842" +dependencies = [ + "log", + "tendril", + "web_atoms 0.3.0", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5848f5a9e8117cf94f2f90faac24a87ff81600ff8628c1e3deaab572e76bfa1" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a" +dependencies = [ + "libc", + "log", + "wasi", + "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cca139e57da4383727f189e43e66e84fa372347027fc996f9f1a007ec0a37996" +dependencies = [ + "crossbeam-channel", + "dpi", + "gtk", + "keyboard-types", + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation", + "once_cell", + "png", + "serde", + "thiserror 2.0.21", + "windows-sys 0.61.2", +] + +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags 2.13.2", + "jni-sys 0.3.1", + "log", + "ndk-sys", + "num_enum", + "raw-window-handle", + "thiserror 1.0.69", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys 0.3.1", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "nix" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77730ed34f01f4990cb2ea67fec715ecebc6fab9a6396cf83c5529b13f581bdc" +dependencies = [ + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] + +[[package]] +name = "notify" +version = "8.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c41a04a5f59df9322cc657286dd2d79f90816119b22c5f847607c850110205ab" +dependencies = [ + "bitflags 2.13.2", + "inotify", + "kqueue", + "libc", + "log", + "mio", + "notify-types", + "objc2-core-foundation", + "objc2-core-services", + "walkdir", + "windows-sys 0.61.2", +] + +[[package]] +name = "notify-types" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd044e85df3d939d8e32a1c35a3b737c7d0a4eeb7acd737bd207644e00f4e5f" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_enum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +dependencies = [ + "proc-macro-crate 3.5.0", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "objc2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" +dependencies = [ + "objc2-encode", + "objc2-exception-helper", +] + +[[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", + "objc2", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation", + "objc2-quartz-core", +] + +[[package]] +name = "objc2-cloud-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c" +dependencies = [ + "bitflags 2.13.2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-data" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa" +dependencies = [ + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2", +] + +[[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", + "objc2-core-foundation", + "objc2-io-surface", +] + +[[package]] +name = "objc2-core-image" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006" +dependencies = [ + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-location" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca347214e24bc973fc025fd0d36ebb179ff30536ed1f80252706db19ee452009" +dependencies = [ + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-services" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583300ad934cba24ff5292aee751ecc070f7ca6b39a574cc21b7b5e588e06a0b" +dependencies = [ + "libc", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-core-text" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" +dependencies = [ + "bitflags 2.13.2", + "objc2", + "objc2-core-foundation", + "objc2-core-graphics", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-exception-helper" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7a1c5fbb72d7735b076bb47b578523aedc40f3c439bea6dfd595c089d79d98a" +dependencies = [ + "cc", +] + +[[package]] +name = "objc2-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" +dependencies = [ + "bitflags 2.13.2", + "block2", + "libc", + "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-io-surface" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" +dependencies = [ + "bitflags 2.13.2", + "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" +dependencies = [ + "bitflags 2.13.2", + "objc2", + "objc2-core-foundation", + "objc2-foundation", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.3.2" +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", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-core-image", + "objc2-core-location", + "objc2-core-text", + "objc2-foundation", + "objc2-quartz-core", + "objc2-user-notifications", +] + +[[package]] +name = "objc2-user-notifications" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9df9128cbbfef73cda168416ccf7f837b62737d748333bfe9ab71c245d76613e" +dependencies = [ + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-web-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e5aaab980c433cf470df9d7af96a7b46a9d892d521a2cbbb2f8a4c16751e7f" +dependencies = [ + "bitflags 2.13.2", + "block2", + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation", +] + +[[package]] +name = "ogg_pager" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "166611b491f939446e64c6be930843a31eb8e6798204ec3e9f57e084c18e7446" +dependencies = [ + "byteorder", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "open" +version = "5.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d8c8b8e725ad26404d6896eb2f064294a0a7b4f1d9120210d85544684c4ca95" +dependencies = [ + "dunce", + "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-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "os_pipe" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "pango" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4" +dependencies = [ + "gio", + "glib", + "libc", + "once_cell", + "pango-sys", +] + +[[package]] +name = "pango-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap 2.14.2", +] + +[[package]] +name = "phf" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" +dependencies = [ + "phf_macros 0.13.1", + "phf_shared 0.13.1", + "serde", +] + +[[package]] +name = "phf" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6" +dependencies = [ + "phf_macros 0.14.0", + "phf_shared 0.14.0", + "serde", +] + +[[package]] +name = "phf_codegen" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1" +dependencies = [ + "phf_generator 0.13.1", + "phf_shared 0.13.1", +] + +[[package]] +name = "phf_codegen" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b585a510fb76fdebead6897982ef2a03a21d8e6cbcca904999742a4afc6ffe" +dependencies = [ + "phf_generator 0.14.0", + "phf_shared 0.14.0", +] + +[[package]] +name = "phf_generator" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737" +dependencies = [ + "fastrand", + "phf_shared 0.13.1", +] + +[[package]] +name = "phf_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100" +dependencies = [ + "fastrand", + "phf_shared 0.14.0", +] + +[[package]] +name = "phf_macros" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef" +dependencies = [ + "phf_generator 0.13.1", + "phf_shared 0.13.1", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "phf_macros" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085" +dependencies = [ + "phf_generator 0.14.0", + "phf_shared 0.14.0", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "phf_shared" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266" +dependencies = [ + "siphasher", +] + +[[package]] +name = "phf_shared" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "piper" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "plist" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86a77b7d9cdebd9643c180c158748db7d894b24a3935ed4b5843e698ae086eb" +dependencies = [ + "base64 0.23.1", + "indexmap 2.14.2", + "quick-xml 0.42.0", + "serde", + "time", +] + +[[package]] +name = "png" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" +dependencies = [ + "bitflags 2.13.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" +dependencies = [ + "toml_datetime 0.6.3", + "toml_edit 0.20.2", +] + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit 0.25.19+spec-1.1.0", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[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.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + +[[package]] +name = "quick-xml" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b1177fdf999d2321d3fb46ff47159d9c1fb9ad66a4879f8c50a0b504615e9b" +dependencies = [ + "memchr", +] + +[[package]] +name = "quinn" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.21", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe" +dependencies = [ + "bytes", + "getrandom 0.4.3", + "lru-slab", + "rand", + "rand_pcg", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.21", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.61.2", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rand_pcg" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb95882a1e14462c69aea9984bb261293ccfe6022ef8de0eda18bd5afb0052df" +dependencies = [ + "rand_core", +] + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "redox_users" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0" +dependencies = [ + "libredox", + "thiserror 2.0.21", +] + +[[package]] +name = "ref-cast" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "regex" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6" + +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tokio-util", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams 0.4.2", + "web-sys", + "webpki-roots", +] + +[[package]] +name = "reqwest" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16a1cfa75cc186dd73d5818e510e042e40927bccc9c236b061cea97e1eb08029" +dependencies = [ + "base64 0.23.1", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "js-sys", + "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 0.5.0", + "web-sys", +] + +[[package]] +name = "rfd" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20dafead71c16a34e1ff357ddefc8afc11e7d51d6d2b9fbd07eaa48e3e540220" +dependencies = [ + "block2", + "dispatch2", + "glib-sys", + "gobject-sys", + "gtk-sys", + "js-sys", + "libc", + "log", + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation", + "percent-encoding", + "raw-window-handle", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +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 = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schemars" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" +dependencies = [ + "dyn-clone", + "indexmap 1.9.3", + "schemars_derive", + "serde", + "serde_json", + "url", + "uuid", +] + +[[package]] +name = "schemars" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab508826f74a77ca9d5aba6ff19b522583ee3eaf28a19384ff3d0e5835fadf6e" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.119", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "selectors" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8adfa1c298912827b8a28b223b3b874357397ae706e6190acd9bf28cee99114d" +dependencies = [ + "bitflags 2.13.2", + "cssparser 0.37.0", + "derive_more", + "log", + "new_debug_unreachable", + "phf 0.13.1", + "phf_codegen 0.13.1", + "precomputed-hash", + "rustc-hash", + "servo_arc 0.4.3", + "smallvec", +] + +[[package]] +name = "selectors" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8322aebea94a6cc288ff884e8a49bdbceef60206c400c6c46d22e62fc4fd91a6" +dependencies = [ + "bitflags 2.13.2", + "cssparser 0.38.0", + "derive_more", + "log", + "new_debug_unreachable", + "precomputed-hash", + "rustc-hash", + "servo_arc 0.5.0", + "smallvec", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9faf48a4a2d2693be24c6289dbe26552776eb7737074e6722891fadbe6c5058" +dependencies = [ + "erased-serde", + "serde", + "serde_core", + "typeid", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_repr" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_spanned" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[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 0.2.46", + "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.10", +] + +[[package]] +name = "serialize-to-javascript" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04f3666a07a197cdb77cdf306c32be9b7f598d7060d50cfd4d5aa04bfd92f6c5" +dependencies = [ + "serde", + "serde_json", + "serialize-to-javascript-impl", +] + +[[package]] +name = "serialize-to-javascript-impl" +version = "0.1.2" +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", +] + +[[package]] +name = "servo_arc" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eceb519ec34d8290aaf6e46f435102f2bfa63f22b05a144fb16ab266d3b198" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "digest 0.11.3", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "siphasher" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59" + +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "softbuffer" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aac18da81ebbf05109ab275b157c22a653bb3c12cf884450179942f81bcbf6c3" +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", +] + +[[package]] +name = "soup3" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "471f924a40f31251afc77450e781cb26d55c0b650842efafc9c6cbd2f7cc4f9f" +dependencies = [ + "futures-channel", + "gio", + "glib", + "libc", + "soup3-sys", +] + +[[package]] +name = "soup3-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebe8950a680a12f24f15ebe1bf70db7af98ad242d9db43596ad3108aab86c27" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_vcruntime" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff7589a1859b09232522bb9edf076ca7fcf14ded96685d3fa629db73023ffbb7" + +[[package]] +name = "string_cache" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18596f8c785a729f2819c0f6a7eae6ebeebdfffbfe4214ae6b087f690e31901" +dependencies = [ + "new_debug_unreachable", + "parking_lot", + "phf_shared 0.13.1", + "precomputed-hash", +] + +[[package]] +name = "string_cache" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffa8a5dbe8b3f0bbe29d4c3225daafaeead63afdc1b65fc4c01a1384166038e6" +dependencies = [ + "new_debug_unreachable", + "parking_lot", + "phf_shared 0.14.0", + "precomputed-hash", +] + +[[package]] +name = "string_cache_codegen" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "585635e46db231059f76c5849798146164652513eb9e8ab2685939dd90f29b69" +dependencies = [ + "phf_generator 0.13.1", + "phf_shared 0.13.1", + "proc-macro2", + "quote", +] + +[[package]] +name = "string_cache_codegen" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928dcdf75e47626b3617a976ec205d9f057584c371c1f23b782129268d0e6edc" +dependencies = [ + "phf_generator 0.14.0", + "phf_shared 0.14.0", + "proc-macro2", + "quote", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "swift-rs" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cefd87076fd385308ee4aff597256c902f1fbb4d031de1558efc12f8ffefadd9" +dependencies = [ + "base64 0.21.7", + "serde", + "serde_json", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "system-deps" +version = "6.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" +dependencies = [ + "cfg-expr", + "heck 0.5.0", + "pkg-config", + "toml 0.8.2", + "version-compare", +] + +[[package]] +name = "tao" +version = "0.37.2" +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", + "windows-core", + "windows-version", + "x11-dl", +] + +[[package]] +name = "tao-macros" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f7eeb6d99155545da6150a1795945f16ac9c178deb2a5f2e74d776107bd5849" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tar" +version = "0.4.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840" +dependencies = [ + "filetime", + "libc", + "xattr", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "tauri" +version = "2.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30fbfbb9dc9a2697b0e96d909ddc295fb18d2d82a58ed542ab8d9eba2edbe6da" +dependencies = [ + "anyhow", + "bytes", + "cookie", + "dirs", + "dunce", + "embed_plist", + "getrandom 0.3.4", + "glob", + "gtk", + "heck 0.5.0", + "http", + "image", + "jni", + "libc", + "log", + "mime", + "muda", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "objc2-ui-kit", + "objc2-web-kit", + "percent-encoding", + "plist", + "raw-window-handle", + "reqwest 0.13.5", + "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", +] + +[[package]] +name = "tauri-build" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73d80784e874fa117b9b00a6680cf2f9b8a51bbd14406bea980cf8f328b00646" +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", +] + +[[package]] +name = "tauri-codegen" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5dc6caab4da5646f57648f39b794bae118f0dd4a4305eeb8c892966171f4852" +dependencies = [ + "base64 0.23.1", + "brotli", + "ico", + "json-patch", + "plist", + "png", + "proc-macro2", + "quote", + "semver", + "serde", + "serde_json", + "sha2 0.11.1", + "syn 2.0.119", + "tauri-utils", + "thiserror 2.0.21", + "time", + "url", + "uuid", + "walkdir", +] + +[[package]] +name = "tauri-macros" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2831c5da8603a96b1efc0b650c2cb6decc69b6cda257d815fe70c7f5be53818e" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.119", + "tauri-codegen", + "tauri-utils", +] + +[[package]] +name = "tauri-plugin" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c18076d9b04211cb4899387aab97497e8edd0d02cd21710623afcdde27145d1" +dependencies = [ + "anyhow", + "glob", + "plist", + "schemars 0.8.22", + "serde", + "serde_json", + "tauri-utils", + "walkdir", +] + +[[package]] +name = "tauri-plugin-clipboard-manager" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9be5ed8d94c33afe8377e885119069f6508780659271d0a25cfc54d441f2bc81" +dependencies = [ + "arboard", + "log", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "thiserror 2.0.21", +] + +[[package]] +name = "tauri-plugin-dialog" +version = "2.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce0fb9c2b6d34a9720627ed930ebc8af26f61e648695aecaeb03d5c33c5896f5" +dependencies = [ + "log", + "raw-window-handle", + "rfd", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "tauri-plugin-fs", + "thiserror 2.0.21", + "url", +] + +[[package]] +name = "tauri-plugin-fs" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d58eb1d4984e535f47a642ffec09a2da6f5c18a12b5902d12126cb7626d628b" +dependencies = [ + "anyhow", + "dunce", + "glob", + "log", + "objc2-foundation", + "percent-encoding", + "schemars 0.8.22", + "serde", + "serde_json", + "serde_repr", + "tauri", + "tauri-plugin", + "tauri-utils", + "thiserror 2.0.21", + "toml 1.2.1+spec-1.1.0", + "url", +] + +[[package]] +name = "tauri-plugin-opener" +version = "2.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54592c6718b42ab198bf11bda6a428a3553ca2f2f8e506df56f6a063ec328331" +dependencies = [ + "dunce", + "glob", + "objc2-app-kit", + "objc2-foundation", + "open", + "schemars 0.8.22", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "thiserror 2.0.21", + "url", + "windows", + "zbus", +] + +[[package]] +name = "tauri-runtime" +version = "2.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60c2b14bd5265b63993cdc34ad526fb836e0fd0cf64a4634a895db0784844d5e" +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", +] + +[[package]] +name = "tauri-runtime-wry" +version = "2.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c14a025255cc9816d401635035075b09b6cc9973b7b8fd7b8fcb8753f30f92" +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", + "wry", +] + +[[package]] +name = "tauri-utils" +version = "2.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d1d33d4453c5df0bf1672dbc7ada69d8ed74f56a4316d964a4aa73d4ecd3ad" +dependencies = [ + "anyhow", + "brotli", + "cargo_metadata", + "ctor", + "dom_query 0.28.0", + "dunce", + "glob", + "http", + "infer", + "json-patch", + "log", + "memchr", + "phf 0.13.1", + "plist", + "proc-macro2", + "quote", + "regex", + "schemars 0.8.22", + "semver", + "serde", + "serde-untagged", + "serde_json", + "serde_with", + "swift-rs", + "thiserror 2.0.21", + "toml 1.2.1+spec-1.1.0", + "url", + "urlpattern", + "uuid", + "walkdir", +] + +[[package]] +name = "tauri-winres" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c52bb6904475a6ca662f15ef787f18ade61d5740a1ee12c45d3b748efdb6f796" +dependencies = [ + "dunce", + "embed-resource", + "toml 1.2.1+spec-1.1.0", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "tendril" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fed54709c5b3a53d09bb1c113ea4f5ceafd1e772ddcb0030a82e1d56c087b08" +dependencies = [ + "new_debug_unreachable", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db" +dependencies = [ + "rustls", + "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", + "libc", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +dependencies = [ + "serde", + "serde_spanned 0.6.9", + "toml_datetime 0.6.3", + "toml_edit 0.20.2", +] + +[[package]] +name = "toml" +version = "1.2.1+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5755c51863cdac711f1956baf8eb9588e060755f7d3c4c979e70ea1e1f32cd7" +dependencies = [ + "indexmap 2.14.2", + "serde_core", + "serde_spanned 1.1.3", + "toml_datetime 1.1.3+spec-1.1.0", + "toml_parser", + "toml_writer", + "winnow 1.0.5", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +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", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap 2.14.2", + "serde", + "serde_spanned 0.6.9", + "toml_datetime 0.6.3", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.25.19+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +dependencies = [ + "indexmap 2.14.2", + "toml_datetime 1.1.3+spec-1.1.0", + "toml_parser", + "winnow 1.0.5", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow 1.0.5", +] + +[[package]] +name = "toml_writer" +version = "1.2.0+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a" + +[[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 = [ + "async-compression", + "bitflags 2.13.2", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "pin-project-lite", + "tokio", + "tokio-util", + "tower", + "tower-layer", + "tower-service", + "url", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "trash" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7363f9516b65bd2e855f4e6c3338b1a98efc2773c25349c958908897e1170ded" +dependencies = [ + "jiff 1.0.1", + "libc", + "log", + "objc2", + "objc2-foundation", + "once_cell", + "percent-encoding", + "scopeguard", + "urlencoding", + "windows", + "windows-core", +] + +[[package]] +name = "tray-icon" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b9c52859a94554803ccd4a24b98f74148ebc73b90676d783f3490b1bff9d72" +dependencies = [ + "crossbeam-channel", + "dirs", + "libappindicator", + "muda", + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation", + "once_cell", + "png", + "serde", + "thiserror 2.0.21", + "windows-sys 0.61.2", +] + +[[package]] +name = "tree_magic_mini" +version = "3.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" +dependencies = [ + "memchr", + "nom", + "petgraph", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typed-path" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce898823d8cd0f028662d2f349694b1af0a5cc9be83f1d213a00d3147445e1e" + +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "uds_windows" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" +dependencies = [ + "memoffset", + "tempfile", + "windows-sys 0.61.2", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", + "serde_derive", +] + +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "urlpattern" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df16f50ef4cc145211879a3867ba757076b25dfee812040dcb0658bd9ae7904b" +dependencies = [ + "icu_properties", + "regex", + "serde", + "url", +] + +[[package]] +name = "utf8_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + +[[package]] +name = "uuid" +version = "1.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c14b15dffa2f4bd712103e857140aa04a4f2ff6e955c77d7eb8e53ee02a3b64" +dependencies = [ + "getrandom 0.4.3", + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "version-compare" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vswhom" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" +dependencies = [ + "libc", + "vswhom-sys", +] + +[[package]] +name = "vswhom-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb067e4cbd1ff067d1df46c9194b5de0e98efd2810bbc95c5d5e5f25a3231150" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.10", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-streams" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "wasm-streams" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb" +dependencies = [ + "futures-util", + "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", + "rustix", + "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-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-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 0.41.0", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" +dependencies = [ + "pkg-config", +] + +[[package]] +name = "web-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web_atoms" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba8b815c1b593dc0baf78dd0f4fc8fdb2de53198fb1163738093e9a311c33fb3" +dependencies = [ + "phf 0.13.1", + "phf_codegen 0.13.1", + "string_cache 0.9.0", + "string_cache_codegen 0.6.1", +] + +[[package]] +name = "web_atoms" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7572660c8890448ba236b7376f27e389c6a7e1c70195622faced601f855c0ada" +dependencies = [ + "phf 0.14.0", + "phf_codegen 0.14.0", + "string_cache 0.11.0", + "string_cache_codegen 0.11.2", +] + +[[package]] +name = "webkit2gtk" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1027150013530fb2eaf806408df88461ae4815a45c541c8975e61d6f2fc4793" +dependencies = [ + "bitflags 1.3.2", + "cairo-rs", + "gdk", + "gdk-sys", + "gio", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "gtk", + "gtk-sys", + "javascriptcore-rs", + "libc", + "once_cell", + "soup3", + "webkit2gtk-sys", +] + +[[package]] +name = "webkit2gtk-sys" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "916a5f65c2ef0dfe12fff695960a2ec3d4565359fdbb2e9943c974e06c734ea5" +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", +] + +[[package]] +name = "webpki-roots" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7265c9301c16a8711c992c2d8da90ee77ef54b1ed51482d6dfeb00dc756b1297" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "webview2-com" +version = "0.39.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f89fca7a704cee10dcb3654c1dbb8941d1783132f1917358af75bec37a7d7e6" +dependencies = [ + "webview2-com-macros", + "webview2-com-sys", + "windows", + "windows-core", +] + +[[package]] +name = "webview2-com-macros" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a921c1b6914c367b2b823cd4cde6f96beec77d30a939c8199bb377cf9b9b54" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "webview2-com-sys" +version = "0.39.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a07132775117d6065853d9d1178157b8c90e228de47129d6bce2c7edebedfb" +dependencies = [ + "thiserror 2.0.21", + "windows", + "windows-core", +] + +[[package]] +name = "weezl" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "window-vibrancy" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "111e51caca442cafd9bab396628ac4d814880eaea4e63dfd76a12e9f342b5580" +dependencies = [ + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation", + "objc2-quartz-core", + "raw-window-handle", + "windows-sys 0.61.2", + "windows-version", +] + +[[package]] +name = "windows" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" +dependencies = [ + "windows-collections", + "windows-core", + "windows-future", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" +dependencies = [ + "windows-core", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" +dependencies = [ + "windows-core", + "windows-link", + "windows-threading", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-numerics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" +dependencies = [ + "windows-core", + "windows-link", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +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", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-version" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4060a1da109b9d0326b7262c8e12c84df67cc0dbc9e33cf49e01ccc2eb63631" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d6f32a0ff4a9f6f01231eb2059cc85479330739333e0e58cadf03b6af2cca10" +dependencies = [ + "cfg-if", + "windows-sys 0.61.2", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wl-clipboard-rs" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "959c7ac3b8afde864f7a7448ac16f29b2b83350b7eccbf77fb781c3999aa6848" +dependencies = [ + "libc", + "log", + "os_pipe", + "rustix", + "thiserror 2.0.21", + "tree_magic_mini", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "wry" +version = "0.57.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceb43f824178e8110e3181bfd478359c43b041452a9560d321bd8d121e468f86" +dependencies = [ + "base64 0.23.1", + "block2", + "cookie", + "crossbeam-channel", + "dirs", + "dom_query 0.29.0", + "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 0.10.9", + "soup3", + "tao-macros", + "thiserror 2.0.21", + "url", + "webkit2gtk", + "webkit2gtk-sys", + "webview2-com", + "windows", + "windows-core", + "windows-version", + "x11-dl", +] + +[[package]] +name = "x11" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "502da5464ccd04011667b11c435cb992822c2c0dbde1770c988480d312a0db2e" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + +[[package]] +name = "x11rb" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414" +dependencies = [ + "gethostname", + "rustix", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" + +[[package]] +name = "xattr" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "963d6fab92d5504b971dc8bd90ca743c2575e590bc8071ea5bc571598667ae08" +dependencies = [ + "libc", + "rustix", +] + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zbus" +version = "5.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5db4be7c075cb421e4b7ee645541604239bd243ba7c357511f4ff3a74b555907" +dependencies = [ + "async-broadcast", + "async-executor", + "async-io", + "async-lock", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "enumflags2", + "event-listener", + "futures-core", + "futures-lite", + "hex", + "libc", + "ordered-stream", + "rustix", + "serde", + "serde_repr", + "tracing", + "uds_windows", + "uuid", + "windows-sys 0.61.2", + "winnow 1.0.5", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "5.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40" +dependencies = [ + "proc-macro-crate 3.5.0", + "proc-macro2", + "quote", + "syn 3.0.10", + "zbus_names", + "zvariant", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "4.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd" +dependencies = [ + "serde", + "winnow 1.0.5", + "zvariant", +] + +[[package]] +name = "zcheapstr" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939f186d9ecebe044315a5cb6d6f78568bbc21152adc954d5a0c2f58bdbc9920" +dependencies = [ + "serde", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ccff8a4805aba1eaa4cd4afcd49f7557dd2cf5fd79ffc37f8959466effc5aa" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "zip" +version = "9.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08687262e7c0f1284b259686f322805a8adaa8ef4d7210e76448950b3f083bf7" +dependencies = [ + "constant_time_eq", + "crc32fast", + "flate2", + "getrandom 0.4.3", + "indexmap 2.14.2", + "libc", + "memchr", + "nix", + "typed-path", + "windows-sys 0.61.2", + "zeroize", + "zopfli", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zopfli" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf7fc5d30c28483d93805c4a5e12b05bbb52407fa67c5f8bd552374cd01fb11" +dependencies = [ + "bumpalo", + "crc32fast", + "log", + "simd-adler32", +] + +[[package]] +name = "zune-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7" +dependencies = [ + "endi", + "enumflags2", + "serde", + "winnow 1.0.5", + "zcheapstr", + "zvariant_derive", + "zvariant_utils", +] + +[[package]] +name = "zvariant_derive" +version = "5.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d" +dependencies = [ + "proc-macro-crate 3.5.0", + "proc-macro2", + "quote", + "syn 3.0.10", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 3.0.10", + "winnow 1.0.5", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..da8f6a5 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,46 @@ +# atmosphere · Cargo.toml · Crate manifest and dependencies for the Atmosphere desktop app. +[package] +name = "atmosphere" +version = "0.1.0" +edition = "2021" +description = "A lightweight SoundCloud downloader for content you have the rights to." + +[features] +default = ["custom-protocol"] +custom-protocol = ["tauri/custom-protocol"] + +[profile.release] +opt-level = "s" +lto = true +codegen-units = 1 +strip = true +panic = "abort" + +[dependencies] +anyhow = "1.0.104" +base64 = "0.23.1" +bytes = "1.12.2" +dirs = "7.0.0" +futures-util = "0.3.34" +image = { version = "0.25.10", default-features = false, features = ["jpeg", "png"] } +lofty = "0.25.5" +lzma-rs = "0.3.0" +notify = "8.2.2" +regex = "1.13.2" +reqwest = { version = "0.12", default-features = false, features = ["json", "stream", "rustls-tls", "gzip", "http2"] } +serde = { version = "1.0.229", features = ["derive"] } +serde_json = "1.0.154" +sha2 = { version = "0.11.1", default-features = false } +tar = "0.4.46" +tauri = { version = "2", features = ["image-png"] } +tauri-plugin-clipboard-manager = "2" +tauri-plugin-dialog = "2" +tauri-plugin-opener = "2" +tokio = { version = "1.54.1", features = ["full"] } +trash = "5.4.0" +url = "2.5.8" +walkdir = "2.5.0" +zip = { version = "9.7.0", default-features = false, features = ["deflate"] } + +[build-dependencies] +tauri-build = "2" diff --git a/README.md b/README.md new file mode 100644 index 0000000..3cca6fd --- /dev/null +++ b/README.md @@ -0,0 +1,202 @@ +

+ + + + Atmosphere + +

+ +

+ Your music, beautifully kept.
+ A fast, native music library, player and downloader for Windows, macOS and Linux. +

+ +

+ Windows · macOS · Linux + Built with Rust and Tauri 2 + Engine: yt-dlp and ffmpeg + Size: about 8 MB +

+ +

+ Atmosphere's library view with the player bar +

+ +--- + +Atmosphere puts your library, a good-sounding player and a downloader in one app. Paste a link from SoundCloud, YouTube, Bandcamp or [1,000+ other sites](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md). Atmosphere shows you exactly what's available and saves a properly tagged file. The file lands in your library, attached to its artist and album, ready to play with synced lyrics. + +It's built for media you **own or have the rights to keep**, such as your own uploads, artist-enabled downloads and Creative Commons releases, and it never bypasses DRM. + +## A look around + + + + + + + + + + + + + + +
Artist profile
Artist profiles: popular tracks, releases, appears-on, and your own photo and bio.
Sound panel
Sound: a drag-to-shape EQ, presets, independent pitch and tempo, reverb and 8D.
TV mode with synced lyrics
TV mode: full-screen cover art and word-synced lyrics, on any connected screen.
Getting a track
Get: honest format choices, editable tags, lyrics detected from the description.
Listening stats
Stats: listening time, plays, and top songs, artists and albums by week, month or year.
Shareable stats card
Share cards: branded images sized for Stories, posts, X and Discord.
+ +Screenshots use demo data with generated cover art. + +## Features + +### Library +- **Your folders:** the download folder plus any music folders you add. Scans are incremental, and a **live file watcher** picks up added, moved or deleted files within about a second. +- **Songs, Albums, Artists, Liked.** The song list is virtualized, so big libraries scroll smoothly. Search and sort everywhere. +- **Artist profiles** with popular tracks, albums, singles & EPs, appears-on, and a photo and bio you can attach. +- **Playlists are real folders** on your drive, so phones, USB drives and other players can use them as-is. Songs are hard-linked (no extra space) or copied, and a `playlist.m3u8` keeps the order. +- **Multi-select** with Ctrl/Shift-click. Drag songs onto playlists, play next, add to queue, edit tags, **remove from library** (the file stays) or **delete from device** (sent to the Recycle Bin or Trash). + +### Player +- Queue, shuffle and repeat. Resumes where you left off, works with OS media keys, and counts plays. +- **Sound panel:** + - Presets: Bass boost, Vocal, Rock, Hip-hop, Nightcore, Slowed + reverb, Vaporwave, Lo-fi, 8D, Concert hall, and your own. + - A 10-band EQ you shape by dragging. + - Low-cut and high-cut filters, reverb and 8D panning. + - **Pitch** (±12 semitones) and **tempo** (0.5×–2×), changed independently, or linked in **Vinyl** mode. + - An Effects on/off switch for instant comparison. +- **TV mode** (`F`): full-screen with the cover-art backdrop and big synced lyrics, or a visualizer when there are none. Sends to a second screen when one is connected. + +### Lyrics +- Synced line by line, plus **word by word** when the source supports it. Click a line to jump, nudge the timing, and save `.lrc` files. +- **Free sources:** no key needed and on by default. + + | Source | Key | Notes | + | --- | --- | --- | + | Your files | No | Embedded lyrics tags and `.lrc` sidecar files | + | [LRCLIB](https://lrclib.net) | No | Free, community-synced library | + | NetEase Cloud Music | No | Free; often word-synced, with translations | + | Musixmatch | Your key | Official developer API (free tier available) | + | Kugou | No | Often blocked outside China, so it's off by default | + | Custom | Yours | Any service you have access to: URL template, headers, key and format | + +- **Attach your own lyrics** while downloading or later. Paste or import a `.lrc`/`.txt` file, then sync it yourself with **Stamp current time** while the song plays. +- **Lyrics in descriptions:** lyrics an artist put in a SoundCloud description are detected, split from the credits and links, and prefilled. + +### Downloads +- One bar for links and search (YouTube and SoundCloud). Paste anywhere, drag links in, or accept the "Use copied link" offer. +- **Release detection:** Album, EP, Single, LP, Compilation, Mixtape, Playlist, Profile and Channel. This drives track numbering, album tags and folder names. +- **Save as** describes outcomes: + - Original file + - Best quality + - MP3 + - M4A + - FLAC/WAV + - Video at the resolutions that item actually has + + **Bitrates never exceed the source.** Matching codecs are copied rather than re-encoded. +- Metadata editing per release and per track: composer, ISRC, BPM, key, cover art and trimming. +- Downloads run in **track order**, with progress, retry, history, and skipping of anything downloaded before. +- Extras: chapters, subtitles, SponsorBlock, a speed limit, a proxy, and browser sign-in for your own private uploads. + +### Stats +- Week, month, year or all time: listening time, plays, songs, artists, time in the app, a by-day chart, and top songs, artists and albums. +- Songs you delete are removed from your history. +- **Share cards** with the Atmosphere logo: + - Story 1080×1920 + - Square 1080×1080 + - Portrait 1080×1350 + - Wide 1600×900 + + Choose a cover-art or night-sky look, then save as PNG or copy to the clipboard. + +### The app itself +- **About 8 MB**, native on each OS. Custom title bar and right-click menus throughout. Light and dark themes. +- **Portable:** `atmosphere.exe` runs from any folder. Put an empty file named `portable` next to it, and all data stays beside it. +- **Tidy:** temp files are wiped on every launch and exit, and stalled downloads are cleaned up. **Settings → Storage** shows what Atmosphere keeps and lets you clean it up. + +## Get started + +### Download +Grab a build from the [Actions](../../actions) tab, under the latest run's artifacts: + +| Platform | Files | +| --- | --- | +| Windows | Setup `.exe`, `.msi`, or the portable `atmosphere.exe` | +| macOS | `.dmg` (Apple Silicon and Intel) | +| Linux | `.deb`, `.rpm`, `.AppImage` | + +On first launch: +1. Confirm the three rights statements. +2. Let Atmosphere set up its engine: [yt-dlp](https://github.com/yt-dlp/yt-dlp) and [ffmpeg](https://ffmpeg.org), downloaded from their official releases and checksum-verified. On macOS, install ffmpeg with `brew install ffmpeg`. +3. Add your music folders in **Settings → Library**, or paste a link. + +### Build from source +You'll need [Rust](https://rustup.rs). On Linux, also install the WebKitGTK dependencies: + +```bash +sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf +``` + +Run the app: + +```bash +cargo run --release +``` + +Build installers with the Tauri CLI: + +```bash +cargo install tauri-cli --version "^2" +cargo tauri build +``` + +## Keyboard shortcuts + +| Keys | Action | +| --- | --- | +| `Space` | Play / pause | +| `←` `→` | Seek 5 seconds | +| `Ctrl ←` `Ctrl →` | Previous / next track | +| `M` | Mute | +| `L` | Lyrics | +| `Q` | Queue | +| `F` | TV mode | +| `Ctrl K` | Link or search bar | +| `Ctrl F` | Search the current view | +| `Delete` | Delete the selected songs (with confirmation) | +| `Ctrl A` | Select all in the current list | + +On macOS, use `⌘` in place of `Ctrl`. + +## Responsible use + +Atmosphere is for media you own or are allowed to keep. + +- **Before first use**, you confirm three statements about rights and responsibility. **Each download** also asks for confirmation. The app's backend enforces both, not only the UI. +- It **never bypasses DRM or paywalls**, and skips preview-only media, the same way yt-dlp itself refuses encrypted formats. +- **Artists recovering their own uploads** can enable downloads on the track and choose **Original file** to get the uploaded master. + +## Project layout + +| Path | What's there | +| --- | --- | +| `src/main.rs` | Tauri setup, the rights gate, and app commands | +| `src/engine.rs` | Installs and runs yt-dlp and ffmpeg (SHA-256 verified), portable mode | +| `src/media.rs` | Link probing, playlist streaming, release detection, lyrics found in descriptions | +| `src/downloader.rs` | The ordered download queue, format plans and progress | +| `src/library.rs`, `src/libcmd.rs` | Library, artwork, folder playlists, stats, the file watcher, and the `atmo://` media protocol | +| `src/lyrics.rs` | Lyrics providers, LRC and word-timing parsing, cache | +| `src/storage.rs` | Temp-file cleanup and the Storage report | +| `src/tagging.rs` | Writes tags, cover art and lyrics into files | +| `ui/` | The interface in plain HTML, CSS and JS (no build step) | +| `branding/`, `tools/` | The logo, wordmark lockups and installer art, all generated from code | +| `site/` | The upcoming website | + +## Acknowledgements + +Atmosphere is built on: +- **Engine and app:** [yt-dlp](https://github.com/yt-dlp/yt-dlp), [FFmpeg](https://ffmpeg.org), [Tauri](https://tauri.app) and [lofty](https://github.com/Serial-ATA/lofty-rs). +- **Icons:** [Tabler Icons](https://tabler.io/icons) (MIT). +- **Lyrics:** the [LRCLIB](https://lrclib.net) community. + +

Made with care for people who still keep their music.

diff --git a/branding/logo-lockup-dark.svg b/branding/logo-lockup-dark.svg new file mode 100644 index 0000000..5ebdabb --- /dev/null +++ b/branding/logo-lockup-dark.svg @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branding/logo-lockup-light.svg b/branding/logo-lockup-light.svg new file mode 100644 index 0000000..58f53ce --- /dev/null +++ b/branding/logo-lockup-light.svg @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..3474242 --- /dev/null +++ b/build.rs @@ -0,0 +1,4 @@ +// atmosphere · build.rs · Tauri build script: embeds the app manifest, icon and capabilities. +fn main() { + tauri_build::build() +} diff --git a/capabilities/default.json b/capabilities/default.json new file mode 100644 index 0000000..8055401 --- /dev/null +++ b/capabilities/default.json @@ -0,0 +1,24 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Permissions for the main Atmosphere window", + "windows": [ + "main" + ], + "permissions": [ + "core:default", + "core:window:allow-minimize", + "core:window:allow-toggle-maximize", + "core:window:allow-close", + "core:window:allow-start-dragging", + "core:window:allow-is-maximized", + "core:window:allow-set-position", + "core:window:allow-set-size", + "core:window:allow-outer-position", + "core:window:allow-outer-size", + "core:window:allow-available-monitors", + "core:window:allow-current-monitor", + "core:window:allow-maximize", + "core:window:allow-unmaximize" + ] +} \ No newline at end of file diff --git a/docs/screenshots/artist.jpg b/docs/screenshots/artist.jpg new file mode 100644 index 0000000..903d6f2 Binary files /dev/null and b/docs/screenshots/artist.jpg differ diff --git a/docs/screenshots/get.jpg b/docs/screenshots/get.jpg new file mode 100644 index 0000000..7a80f0a Binary files /dev/null and b/docs/screenshots/get.jpg differ diff --git a/docs/screenshots/library.jpg b/docs/screenshots/library.jpg new file mode 100644 index 0000000..1123fca Binary files /dev/null and b/docs/screenshots/library.jpg differ diff --git a/docs/screenshots/share-card.jpg b/docs/screenshots/share-card.jpg new file mode 100644 index 0000000..ae2cadc Binary files /dev/null and b/docs/screenshots/share-card.jpg differ diff --git a/docs/screenshots/sound.jpg b/docs/screenshots/sound.jpg new file mode 100644 index 0000000..071a719 Binary files /dev/null and b/docs/screenshots/sound.jpg differ diff --git a/docs/screenshots/stats.jpg b/docs/screenshots/stats.jpg new file mode 100644 index 0000000..4233321 Binary files /dev/null and b/docs/screenshots/stats.jpg differ diff --git a/docs/screenshots/tv-mode.jpg b/docs/screenshots/tv-mode.jpg new file mode 100644 index 0000000..0cd4d4b Binary files /dev/null and b/docs/screenshots/tv-mode.jpg differ diff --git a/icons/128x128.png b/icons/128x128.png new file mode 100644 index 0000000..011264c Binary files /dev/null and b/icons/128x128.png differ diff --git a/icons/128x128@2x.png b/icons/128x128@2x.png new file mode 100644 index 0000000..8f85b1b Binary files /dev/null and b/icons/128x128@2x.png differ diff --git a/icons/32x32.png b/icons/32x32.png new file mode 100644 index 0000000..f75481d Binary files /dev/null and b/icons/32x32.png differ diff --git a/icons/icon.icns b/icons/icon.icns new file mode 100644 index 0000000..19a0126 Binary files /dev/null and b/icons/icon.icns differ diff --git a/icons/icon.ico b/icons/icon.ico new file mode 100644 index 0000000..8e1d82d Binary files /dev/null and b/icons/icon.ico differ diff --git a/icons/icon.png b/icons/icon.png new file mode 100644 index 0000000..b3c8a3f Binary files /dev/null and b/icons/icon.png differ diff --git a/installer/RIGHTS.txt b/installer/RIGHTS.txt new file mode 100644 index 0000000..37bc5ab --- /dev/null +++ b/installer/RIGHTS.txt @@ -0,0 +1,19 @@ +ATMOSPHERE: YOUR RESPONSIBILITY + +Atmosphere saves audio and video you're allowed to keep, and plays your own music library. + +By installing Atmosphere, you agree that: + +1. You'll only download media you own, that the rights holder has allowed you to download, or that's under a licence that permits it, such as artist-enabled downloads or Creative Commons. + +2. You understand that downloading without permission can infringe copyright and break a site's terms of use, and that you're responsible for how you use Atmosphere. + +3. You won't share downloaded media unless its licence or the rights holder allows it. + +Atmosphere never bypasses DRM or paywalls, and skips preview-only media. Artists recovering their own uploads can enable downloads on their tracks and choose "Original file" to get their uploaded master. + +Atmosphere downloads two open-source tools on first run, both from their official releases with checksum verification: +- yt-dlp (Unlicense): https://github.com/yt-dlp/yt-dlp +- ffmpeg (GPL builds): https://github.com/yt-dlp/FFmpeg-Builds + +You'll be asked to confirm these points again the first time you open the app. diff --git a/installer/nsis-header.bmp b/installer/nsis-header.bmp new file mode 100644 index 0000000..c9d8510 Binary files /dev/null and b/installer/nsis-header.bmp differ diff --git a/installer/nsis-sidebar.bmp b/installer/nsis-sidebar.bmp new file mode 100644 index 0000000..a9ef202 Binary files /dev/null and b/installer/nsis-sidebar.bmp differ diff --git a/installer/wix-banner.bmp b/installer/wix-banner.bmp new file mode 100644 index 0000000..22ef589 Binary files /dev/null and b/installer/wix-banner.bmp differ diff --git a/installer/wix-dialog.bmp b/installer/wix-dialog.bmp new file mode 100644 index 0000000..664a506 Binary files /dev/null and b/installer/wix-dialog.bmp differ diff --git a/src/downloader.rs b/src/downloader.rs new file mode 100644 index 0000000..f3c510f --- /dev/null +++ b/src/downloader.rs @@ -0,0 +1,771 @@ +// atmosphere · downloader.rs · Ordered download queue driving yt-dlp: format choice, progress, cancellation, tagging and history. +use crate::engine::{self, Tools}; +use crate::history::{History, Record}; +use crate::library::Library; +use crate::media::{self, Entry}; +use crate::settings::{snap_bitrate, SaveAs, Settings}; +use crate::tagging::{self, TagFields}; +use anyhow::{anyhow, bail, Result}; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::collections::{HashMap, VecDeque}; +use std::path::{Path, PathBuf}; +use std::process::Stdio; +use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; +use tauri::{AppHandle, Emitter}; +use tokio::io::{AsyncBufReadExt, BufReader}; +use tokio::sync::mpsc; + +pub const EVENT: &str = "atmosphere://job"; +const EMIT_INTERVAL: Duration = Duration::from_millis(150); + +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(rename_all = "camelCase", default)] +pub struct Trim { + pub start: String, + pub end: String, +} + +#[derive(Clone, Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct JobRequest { + pub entry: Entry, + #[serde(default)] + pub meta: TagFields, + pub folder: Option, + #[serde(default)] + pub trim: Option, + #[serde(default)] + pub playlist: Option, +} + +#[derive(Clone, Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct SaveOptions { + pub save_as: SaveAs, + pub mp3_bitrate: u32, + pub video_height: u32, + pub video_container: String, +} + +#[derive(Clone, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct JobEvent { + pub id: u64, + pub state: &'static str, + pub progress: f64, + pub received: u64, + pub total: Option, + pub speed: u64, + pub stage: u32, + pub format: Option, + pub message: Option, + pub path: Option, +} + +#[derive(Debug)] +pub struct Cancelled; + +impl std::fmt::Display for Cancelled { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("cancelled") + } +} + +impl std::error::Error for Cancelled {} + +struct Pending { + id: u64, + req: JobRequest, + save: SaveOptions, + flag: Arc, +} + +struct Queue { + pending: VecDeque, + running: usize, + limit: usize, +} + +pub struct Downloader { + app: AppHandle, + history: Arc, + library: Arc, + http: reqwest::Client, + settings: Arc>, + queue: Mutex, + flags: Mutex>>, + next: AtomicU64, +} + +pub const LIBRARY_EVENT: &str = "atmosphere://library"; + +async fn after_download(app: &AppHandle, library: &Library, http: &reqwest::Client, settings: &Settings, req: &JobRequest, path: &Path) { + let playlists = PathBuf::from(&settings.playlists_dir); + let attached = req.meta.lyrics.trim(); + if !attached.is_empty() { + if crate::lyrics::is_timed(attached) { + let _ = tokio::fs::write(path.with_extension("lrc"), attached).await; + } + } else if settings.lyrics_on_download && tagging_ext(path) { + let q = crate::lyrics::Query { + title: if req.meta.title.trim().is_empty() { req.entry.title.clone() } else { req.meta.title.clone() }, + artist: if req.meta.artist.trim().is_empty() { req.entry.artist.clone() } else { req.meta.artist.clone() }, + album: req.meta.album.clone(), + duration_ms: req.entry.duration_ms, + path: None, + }; + if let Ok(Some(l)) = crate::lyrics::find(http, settings, &q, false).await.map(|f| f.lyrics) { + if l.synced { + let _ = tokio::fs::write(path.with_extension("lrc"), crate::lyrics::to_lrc(&l)).await; + } + } + } + let _ = library.add_file(path, &playlists); + if let Some(name) = req.playlist.as_deref().filter(|n| !n.trim().is_empty()) { + let _ = library.playlist_add(&playlists, name, &[path.to_path_buf()], !settings.playlist_copy); + } + let _ = app.emit(LIBRARY_EVENT, serde_json::json!({ "type": "changed" })); +} + +fn tagging_ext(path: &Path) -> bool { + path.extension().and_then(|e| e.to_str()).is_some_and(|e| crate::library::AUDIO_EXT.contains(&e.to_ascii_lowercase().as_str())) +} + +impl Downloader { + pub fn new(app: AppHandle, settings: Arc>, history: Arc, library: Arc, http: reqwest::Client) -> Self { + let limit = settings.lock().unwrap().concurrency.max(1) as usize; + Self { + app, + history, + library, + http, + settings, + queue: Mutex::new(Queue { pending: VecDeque::new(), running: 0, limit }), + flags: Mutex::new(HashMap::new()), + next: AtomicU64::new(1), + } + } + + pub fn set_concurrency(self: &Arc, n: u8) { + self.queue.lock().unwrap().limit = n.max(1) as usize; + self.pump(); + } + + pub fn enqueue(self: &Arc, reqs: Vec, save: SaveOptions) -> Vec { + let mut ids = Vec::with_capacity(reqs.len()); + { + let mut q = self.queue.lock().unwrap(); + let mut flags = self.flags.lock().unwrap(); + for req in reqs { + let id = self.next.fetch_add(1, Ordering::SeqCst); + let flag = Arc::new(AtomicBool::new(false)); + flags.insert(id, flag.clone()); + q.pending.push_back(Pending { id, req, save: save.clone(), flag }); + ids.push(id); + } + } + self.pump(); + ids + } + + fn pump(self: &Arc) { + loop { + let next = { + let mut q = self.queue.lock().unwrap(); + if q.running >= q.limit { + None + } else { + let p = q.pending.pop_front(); + if p.is_some() { + q.running += 1; + } + p + } + }; + let Some(p) = next else { break }; + let this = self.clone(); + tauri::async_runtime::spawn(async move { + let settings = this.settings.lock().unwrap().clone(); + let mut job = Job::new(this.app.clone(), p.id, p.flag.clone()); + let result = match job.check() { + Ok(()) => job.run(&settings, &p.req, &p.save).await, + Err(e) => Err(e), + }; + match result { + Ok(Some(path)) => { + this.history.add(Record::new(&p.req, &path, job.format.clone())); + after_download(&this.app, &this.library, &this.http, &settings, &p.req, &path).await; + } + Ok(None) => {} + Err(e) if e.is::() => job.emit("cancelled", None, None), + Err(e) => job.emit("error", Some(format!("{e:#}")), None), + } + this.flags.lock().unwrap().remove(&p.id); + this.queue.lock().unwrap().running -= 1; + this.pump(); + }); + } + } + + fn drop_pending(&self, pred: impl Fn(&Pending) -> bool) { + let removed: Vec = { + let mut q = self.queue.lock().unwrap(); + let (gone, keep): (Vec<_>, Vec<_>) = q.pending.drain(..).partition(|p| pred(p)); + q.pending = keep.into(); + gone + }; + let mut flags = self.flags.lock().unwrap(); + for p in removed { + flags.remove(&p.id); + Job::new(self.app.clone(), p.id, p.flag).emit("cancelled", None, None); + } + } + + pub fn cancel(&self, id: u64) { + if let Some(f) = self.flags.lock().unwrap().get(&id) { + f.store(true, Ordering::SeqCst); + } + self.drop_pending(|p| p.id == id); + } + + pub fn busy(&self) -> bool { + let q = self.queue.lock().unwrap(); + q.running > 0 || !q.pending.is_empty() + } + + pub fn cancel_all(&self) { + self.flags.lock().unwrap().values().for_each(|f| f.store(true, Ordering::SeqCst)); + self.drop_pending(|_| true); + } +} + +struct Job { + app: AppHandle, + id: u64, + flag: Arc, + state: &'static str, + progress: f64, + received: u64, + total: Option, + speed: u64, + stage: u32, + last_emit: Instant, + format: Option, +} + +impl Job { + fn new(app: AppHandle, id: u64, flag: Arc) -> Self { + Self { + app, + id, + flag, + state: "queued", + progress: 0.0, + received: 0, + total: None, + speed: 0, + stage: 0, + last_emit: Instant::now(), + format: None, + } + } + + fn check(&self) -> Result<()> { + if self.flag.load(Ordering::SeqCst) { + return Err(anyhow!(Cancelled)); + } + Ok(()) + } + + fn emit(&mut self, state: &'static str, message: Option, path: Option<&Path>) { + self.state = state; + self.last_emit = Instant::now(); + let _ = self.app.emit( + EVENT, + JobEvent { + id: self.id, + state, + progress: self.progress, + received: self.received, + total: self.total, + speed: self.speed, + stage: self.stage, + format: self.format.clone(), + message, + path: path.map(|p| p.to_string_lossy().into_owned()), + }, + ); + } + + async fn run(&mut self, settings: &Settings, req: &JobRequest, save: &SaveOptions) -> Result> { + self.emit("preparing", None, None); + let entry = &req.entry; + match entry.availability.as_str() { + "drm" => bail!("This stream is DRM-encrypted, so it was skipped. If it's your own track, turn on downloads for it in the platform's track settings (or enable “Use my browser sign-in”), then choose Original file to get your uploaded master."), + "preview" => bail!("Only a preview is available for this item, so it was skipped."), + _ => {} + } + let tools = engine::locate(&settings.ytdlp_path, &settings.ffmpeg_path)?; + let dir = target_dir(settings, req); + tokio::fs::create_dir_all(&dir).await.map_err(|e| anyhow!("Couldn't create the output folder ({e})"))?; + let stem = file_stem(settings, req); + let plan = plan(entry, save, tools.ffmpeg.is_some())?; + self.format = Some(plan.label.clone()); + if let Some(ext) = &plan.known_ext { + let target = dir.join(format!("{stem}.{ext}")); + if target.exists() { + self.progress = 1.0; + self.emit("skipped", Some("Already in your library".into()), Some(&target)); + return Ok(None); + } + } + let job_temp = engine::temp_root().join(format!("job-{}", self.id)); + let _ = tokio::fs::create_dir_all(&job_temp).await; + let args = build_args(settings, &tools, req, &plan, &dir, &stem, &job_temp); + let outcome = self.execute(&tools, args, &dir, &stem).await; + let _ = tokio::fs::remove_dir_all(&job_temp).await; + let path = match outcome? { + Some(p) => p, + None => { + self.progress = 1.0; + self.emit("skipped", Some("Downloaded before, so it was skipped. Turn off “Skip anything downloaded before” to fetch it again.".into()), None); + return Ok(None); + } + }; + let mut notes = plan.notes.clone(); + if settings.embed_metadata { + self.emit("tagging", None, None); + if let Err(e) = tagging::apply(&path, &req.meta, &req.entry.url, tools.ffmpeg.as_deref()).await { + notes.push(format!("Saved, but your metadata edits couldn't be written ({e}).")); + } + } + self.progress = 1.0; + let note = (!notes.is_empty()).then(|| notes.join(" ")); + self.emit("done", note, Some(&path)); + Ok(Some(path)) + } + + async fn execute(&mut self, tools: &Tools, args: Vec, dir: &Path, stem: &str) -> Result> { + let mut child = engine::command(&tools.ytdlp) + .args(&args) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .kill_on_drop(true) + .spawn() + .map_err(|e| anyhow!("Couldn't start yt-dlp ({e})"))?; + let (tx, mut rx) = mpsc::unbounded_channel::<(bool, String)>(); + for (is_err, pipe) in [(false, child.stdout.take().map(|p| Box::new(p) as Box)), (true, child.stderr.take().map(|p| Box::new(p) as Box))] { + if let Some(pipe) = pipe { + let tx = tx.clone(); + tokio::spawn(async move { + let mut lines = BufReader::new(pipe).lines(); + while let Ok(Some(l)) = lines.next_line().await { + let _ = tx.send((is_err, l)); + } + }); + } + } + drop(tx); + let mut final_path = None; + let mut errors: Vec = Vec::new(); + let started = Instant::now(); + loop { + tokio::select! { + msg = rx.recv() => { + let Some((is_err, line)) = msg else { break }; + if is_err { + if line.contains("ERROR") || errors.len() < 40 { errors.push(line); } + continue; + } + if let Some(json) = line.strip_prefix("ATMOSP ") { + self.on_progress(json, started); + } else if let Some(p) = line.strip_prefix("ATMOSF ") { + final_path = Some(PathBuf::from(p.trim())); + } + } + _ = tokio::time::sleep(Duration::from_millis(200)) => {} + } + if self.flag.load(Ordering::SeqCst) { + let _ = child.kill().await; + cleanup(dir, stem).await; + return Err(anyhow!(Cancelled)); + } + } + let status = child.wait().await?; + if !status.success() { + cleanup(dir, stem).await; + let err = errors.iter().rev().find(|l| l.contains("ERROR")).cloned().unwrap_or_else(|| errors.join("\n")); + bail!(media::humanize(&err)); + } + Ok(final_path.filter(|p| p.exists())) + } + + fn on_progress(&mut self, json: &str, started: Instant) { + let Ok(v) = serde_json::from_str::(json) else { return }; + match v["status"].as_str() { + Some("downloading") => { + if self.state != "downloading" { + self.state = "downloading"; + self.last_emit = Instant::now() - EMIT_INTERVAL; + } + self.received = v["downloaded_bytes"].as_u64().unwrap_or(self.received); + self.total = v["total_bytes"].as_u64().or_else(|| v["total_bytes_estimate"].as_f64().map(|t| t as u64)); + self.speed = v["speed"].as_f64().map(|s| s as u64).unwrap_or_else(|| (self.received as f64 / started.elapsed().as_secs_f64().max(0.1)) as u64); + self.progress = match (self.total, v["fragment_index"].as_u64(), v["fragment_count"].as_u64()) { + (Some(t), _, _) if t > 0 => (self.received as f64 / t as f64).min(1.0), + (_, Some(i), Some(c)) if c > 0 => i as f64 / c as f64, + _ => self.progress, + }; + if self.last_emit.elapsed() >= EMIT_INTERVAL { + self.emit("downloading", None, None); + } + } + Some("finished") => { + self.stage += 1; + self.progress = 1.0; + self.emit("processing", None, None); + } + _ => {} + } + } +} + +#[derive(Debug, Clone)] +struct Plan { + format: String, + sort: Option, + extract: Option<(String, Option)>, + merge: Option, + video: bool, + known_ext: Option, + label: String, + notes: Vec, +} + +fn plan(entry: &Entry, save: &SaveOptions, has_ffmpeg: bool) -> Result { + let media = entry.media.clone().unwrap_or_default(); + let from_original = media.original && media.original_lossless; + let source_abr = if from_original || media.lossless { None } else { media.best_abr }; + let stream = media + .best_codec + .as_deref() + .map(|c| match media.best_abr { + Some(a) => format!("{} {a} kbps", c.to_uppercase()), + None => c.to_uppercase(), + }) + .unwrap_or_else(|| "best available".into()); + let original_label = format!("original {}", media.original_ext.as_deref().unwrap_or("file").to_uppercase()); + let src = if from_original { original_label.clone() } else { stream.clone() }; + let lossless_source = from_original || media.lossless; + let source_format = if from_original { "download/bestaudio/best" } else { "bestaudio/best" }; + let mut notes = Vec::new(); + let needs_ffmpeg = |what: &str| -> Result<()> { + if has_ffmpeg { + Ok(()) + } else { + bail!("{what} needs ffmpeg. Install it from Settings → Engine.") + } + }; + let audio = |format: &str| Plan { + format: format.into(), + sort: None, + extract: has_ffmpeg.then(|| ("best".into(), None)), + merge: None, + video: false, + known_ext: None, + label: format!("Best audio · {stream}"), + notes: Vec::new(), + }; + Ok(match save.save_as { + SaveAs::Original => { + if media.original { + let mut p = audio("download/bestaudio/best"); + p.extract = None; + p.label = format!("Original file{}", media.original_ext.as_deref().map(|e| format!(" · {}", e.to_uppercase())).unwrap_or_default()); + p + } else { + let mut p = audio("bestaudio/best"); + notes.push("The uploader hasn't offered an original file, so the best stream was saved instead.".into()); + p.notes = notes; + p + } + } + SaveAs::Best => audio("bestaudio/best"), + SaveAs::Mp3 => { + needs_ffmpeg("Saving as MP3")?; + let kbps = snap_bitrate(save.mp3_bitrate, source_abr); + if kbps < save.mp3_bitrate { + notes.push(format!("Encoded at {kbps} kbps to match the source ({src}); a higher bitrate wouldn't add quality.")); + } + let floor = kbps.saturating_sub(8); + Plan { + format: if from_original { source_format.into() } else { format!("bestaudio[acodec^=mp3][abr>={floor}]/bestaudio/best") }, + sort: None, + extract: Some(("mp3".into(), Some(kbps))), + merge: None, + video: false, + known_ext: Some("mp3".into()), + label: format!("MP3 {kbps} kbps · from {src}"), + notes, + } + } + SaveAs::M4a => { + needs_ffmpeg("Saving as M4A")?; + Plan { + format: "bestaudio[acodec^=mp4a]/bestaudio/best".into(), + sort: None, + extract: Some(("m4a".into(), source_abr.map(|a| a.max(128)))), + merge: None, + video: false, + known_ext: Some("m4a".into()), + label: format!("M4A (AAC) · from {src}"), + notes, + } + } + SaveAs::Flac | SaveAs::Wav => { + let ext = save.save_as.audio_format().unwrap_or("flac"); + needs_ffmpeg(&format!("Saving as {}", ext.to_uppercase()))?; + if !lossless_source { + notes.push(format!("{} is lossless, but it can't add quality beyond the {src} source.", ext.to_uppercase())); + } + Plan { + format: source_format.into(), + sort: None, + extract: Some((ext.into(), None)), + merge: None, + video: false, + known_ext: Some(ext.into()), + label: format!("{} · from {src}", ext.to_uppercase()), + notes, + } + } + SaveAs::Video => { + if !media.has_video && entry.detailed { + bail!("This item has no video. Choose an audio option instead."); + } + needs_ffmpeg("Saving video")?; + let available = media.heights.first().copied(); + let h = match (save.video_height, available) { + (0, _) => None, + (want, Some(max)) if want > max => { + notes.push(format!("{want}p isn't available; saved the highest available ({max}p).")); + Some(max) + } + (want, _) => Some(want), + }; + let container = match save.video_container.as_str() { + "mkv" | "webm" => save.video_container.clone(), + _ => "mp4".into(), + }; + let res = h.map(|h| format!("res:{h},")).unwrap_or_default(); + let sort = if container == "mp4" { format!("{res}vcodec:h264,acodec:aac") } else { res.trim_end_matches(',').to_string() }; + Plan { + format: "bv*+ba/b".into(), + sort: (!sort.is_empty()).then_some(sort), + extract: None, + merge: Some(container.clone()), + video: true, + known_ext: Some(container.clone()), + label: format!("Video {} · {}", h.map(|h| format!("{h}p")).unwrap_or_else(|| "best".into()), container.to_uppercase()), + notes, + } + } + }) +} + +fn template_escape(s: &str) -> String { + s.replace('%', "%%") +} + +fn build_args(settings: &Settings, tools: &Tools, req: &JobRequest, plan: &Plan, dir: &Path, stem: &str, temp: &Path) -> Vec { + let mut a = media::base_args(settings, tools); + let push = |a: &mut Vec, items: &[&str]| a.extend(items.iter().map(|s| s.to_string())); + push(&mut a, &["--newline", "--progress", "--no-playlist", "--no-mtime", "--no-overwrites", "--concurrent-fragments", "4"]); + push(&mut a, &["--progress-template", "download:ATMOSP %(progress)j", "--print", "after_move:ATMOSF %(filepath)s"]); + push(&mut a, &["-P", &dir.to_string_lossy(), "-P", &format!("temp:{}", temp.to_string_lossy()), "-o", &format!("{}.%(ext)s", template_escape(stem))]); + push(&mut a, &["-f", &plan.format]); + if let Some(sort) = &plan.sort { + push(&mut a, &["-S", sort]); + } + if let Some((fmt, kbps)) = &plan.extract { + push(&mut a, &["-x", "--audio-format", fmt]); + if let Some(k) = kbps { + push(&mut a, &["--audio-quality", &format!("{k}K")]); + } + } + if let Some(container) = &plan.merge { + push(&mut a, &["--merge-output-format", container, "--remux-video", container]); + } + let has_ff = tools.ffmpeg.is_some(); + if settings.embed_metadata { + push(&mut a, &["--embed-metadata"]); + let wav = plan.extract.as_ref().is_some_and(|(f, _)| f == "wav"); + if has_ff && !wav { + push(&mut a, &["--embed-thumbnail", "--convert-thumbnails", "jpg"]); + } + } + if settings.embed_chapters && has_ff { + push(&mut a, &["--embed-chapters"]); + } + if plan.video && settings.embed_subtitles && has_ff { + push(&mut a, &["--write-subs", "--sub-langs", settings.subtitle_langs.trim(), "--embed-subs"]); + } + if settings.sponsorblock && has_ff && req.entry.platform == "YouTube" { + let cats = if plan.video { "sponsor,selfpromo,interaction" } else { "sponsor,selfpromo,interaction,music_offtopic" }; + push(&mut a, &["--sponsorblock-remove", cats]); + } + if let Some(t) = req.trim.as_ref().filter(|t| !t.start.trim().is_empty() || !t.end.trim().is_empty()) { + let start = if t.start.trim().is_empty() { "0" } else { t.start.trim() }; + let end = if t.end.trim().is_empty() { "inf" } else { t.end.trim() }; + push(&mut a, &["--download-sections", &format!("*{start}-{end}")]); + if has_ff { + push(&mut a, &["--force-keyframes-at-cuts"]); + } + } + if settings.skip_downloaded { + push(&mut a, &["--download-archive", &engine::data_dir().join("archive.txt").to_string_lossy()]); + } + if !settings.rate_limit.trim().is_empty() { + push(&mut a, &["--limit-rate", settings.rate_limit.trim()]); + } + push(&mut a, &["--", &req.entry.url]); + a +} + +async fn cleanup(dir: &Path, stem: &str) { + let Ok(mut rd) = tokio::fs::read_dir(dir).await else { return }; + while let Ok(Some(e)) = rd.next_entry().await { + let name = e.file_name().to_string_lossy().into_owned(); + let leftover = [".part", ".ytdl", ".temp", ".webp", ".jpg", ".png"].iter().any(|x| name.ends_with(x)) || name.contains(".part-Frag"); + if name.starts_with(stem) && leftover { + let _ = tokio::fs::remove_file(e.path()).await; + } + } +} + +fn target_dir(settings: &Settings, req: &JobRequest) -> PathBuf { + let base = PathBuf::from(&settings.output_dir); + match (&req.folder, settings.collection_folders) { + (Some(name), true) if !name.trim().is_empty() => base.join(sanitize(name)), + _ => base, + } +} + +fn file_stem(settings: &Settings, req: &JobRequest) -> String { + let m = &req.meta; + let title = if m.title.trim().is_empty() { &req.entry.title } else { &m.title }; + let artist = if m.artist.trim().is_empty() { &req.entry.artist } else { &m.artist }; + let width = m.track_total.map_or(2, |n| n.to_string().len().max(2)); + let index = m.track_number.map(|i| format!("{i:0width$}")); + let year = m.date.get(..4).unwrap_or_default().to_string(); + let template = &settings.filename_template; + let mut name = template + .replace("{artist}", artist) + .replace("{title}", title) + .replace("{album}", &m.album) + .replace("{albumartist}", &m.album_artist) + .replace("{collection}", req.folder.as_deref().unwrap_or("")) + .replace("{genre}", &m.genre) + .replace("{year}", &year) + .replace("{platform}", &req.entry.platform) + .replace("{index}", index.as_deref().unwrap_or("")); + if settings.number_tracks && req.folder.is_some() && !template.contains("{index}") { + if let Some(i) = index { + name = format!("{i} - {name}"); + } + } + sanitize(&name) +} + +pub fn sanitize(input: &str) -> String { + let cleaned: String = input.chars().map(|c| if c.is_control() || r#"<>:"/\|?*"#.contains(c) { '_' } else { c }).collect(); + let mut out = cleaned.split_whitespace().collect::>().join(" "); + out = out.trim_matches(|c: char| c == '.' || c == ' ' || c == '-').to_string(); + if out.chars().count() > 150 { + out = out.chars().take(150).collect::().trim_end().to_string(); + } + let upper = out.split('.').next().unwrap_or_default().to_ascii_uppercase(); + let reserved = matches!(upper.as_str(), "CON" | "PRN" | "AUX" | "NUL") + || ((upper.starts_with("COM") || upper.starts_with("LPT")) && upper.len() == 4 && upper.as_bytes()[3].is_ascii_digit()); + if reserved { + out.insert(0, '_'); + } + if out.is_empty() { + "untitled".into() + } else { + out + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::media::MediaInfo; + + fn entry(abr: Option, lossless: bool, heights: Vec) -> Entry { + Entry { + title: "Night Drive".into(), + artist: "Nova".into(), + url: "https://example.com/x".into(), + detailed: true, + availability: "ok".into(), + media: Some(MediaInfo { best_abr: abr, best_codec: Some("aac".into()), lossless, has_video: !heights.is_empty(), heights, ..Default::default() }), + ..Default::default() + } + } + + fn save(save_as: SaveAs, kbps: u32, h: u32) -> SaveOptions { + SaveOptions { save_as, mp3_bitrate: kbps, video_height: h, video_container: "mp4".into() } + } + + #[test] + fn mp3_bitrate_never_exceeds_source() { + let p = plan(&entry(Some(160), false, vec![]), &save(SaveAs::Mp3, 320, 0), true).unwrap(); + assert_eq!(p.extract, Some(("mp3".into(), Some(160)))); + assert!(p.label.starts_with("MP3 160 kbps")); + assert_eq!(p.notes.len(), 1); + let p = plan(&entry(None, true, vec![]), &save(SaveAs::Mp3, 320, 0), true).unwrap(); + assert_eq!(p.extract, Some(("mp3".into(), Some(320)))); + } + + #[test] + fn lossless_original_lifts_the_mp3_cap_honestly() { + let mut e = entry(Some(160), false, vec![]); + if let Some(m) = e.media.as_mut() { + m.original = true; + m.original_lossless = true; + m.original_ext = Some("wav".into()); + } + let p = plan(&e, &save(SaveAs::Mp3, 320, 0), true).unwrap(); + assert_eq!(p.extract, Some(("mp3".into(), Some(320)))); + assert!(p.format.starts_with("download/")); + assert!(p.label.contains("original WAV")); + let plain = plan(&entry(Some(160), false, vec![]), &save(SaveAs::Flac, 320, 0), true).unwrap(); + assert_eq!(plain.notes.len(), 1); + } + + #[test] + fn video_plans_respect_available_heights() { + let p = plan(&entry(Some(128), false, vec![720, 480]), &save(SaveAs::Video, 1080, 1080), true).unwrap(); + assert!(p.label.contains("720p")); + assert_eq!(p.sort.as_deref(), Some("res:720,vcodec:h264,acodec:aac")); + assert!(plan(&entry(Some(128), false, vec![]), &save(SaveAs::Video, 0, 1080), true).is_err()); + assert!(plan(&entry(Some(128), false, vec![720]), &save(SaveAs::Mp3, 320, 0), false).is_err()); + } + + #[test] + fn builds_stems_and_escapes_templates() { + let mut settings = Settings::default(); + settings.output_dir = "out".into(); + let meta = TagFields { title: "100% Night".into(), track_number: Some(3), track_total: Some(120), ..Default::default() }; + let req = JobRequest { entry: entry(None, false, vec![]), meta, folder: Some("Nova - Glass: Vol 1".into()), trim: None, playlist: None }; + let stem = file_stem(&settings, &req); + assert_eq!(stem, "003 - Nova - 100% Night"); + assert_eq!(template_escape(&stem), "003 - Nova - 100%% Night"); + assert_eq!(target_dir(&settings, &req), PathBuf::from("out").join("Nova - Glass_ Vol 1")); + assert_eq!(sanitize("con"), "_con"); + } +} diff --git a/src/engine.rs b/src/engine.rs new file mode 100644 index 0000000..5d536b7 --- /dev/null +++ b/src/engine.rs @@ -0,0 +1,306 @@ +// atmosphere · engine.rs · Locates, installs and runs the yt-dlp and ffmpeg tools that power every download. +use anyhow::{anyhow, bail, Context, Result}; +use serde::Serialize; +use sha2::{Digest, Sha256}; +use std::io::Read; +use std::path::{Path, PathBuf}; +use std::process::Stdio; +use tokio::process::Command; + +#[cfg(windows)] +const EXE: &str = ".exe"; +#[cfg(not(windows))] +const EXE: &str = ""; + +const YTDLP_RELEASE: &str = "https://github.com/yt-dlp/yt-dlp/releases/latest/download"; +const FFMPEG_RELEASE: &str = "https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest"; + +#[derive(Clone, Debug, Default, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct ToolInfo { + pub path: Option, + pub version: Option, + pub managed: bool, +} + +#[derive(Clone, Debug, Default, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct ToolStatus { + pub ytdlp: ToolInfo, + pub ffmpeg: ToolInfo, + pub can_install_ffmpeg: bool, +} + +pub fn bin_dir() -> PathBuf { + data_dir().join("bin") +} + +pub fn portable_root() -> Option { + let exe = std::env::current_exe().ok()?; + let dir = exe.parent()?; + ["portable", "portable.txt", ".portable"].iter().any(|m| dir.join(m).is_file()).then(|| dir.join("AtmosphereData")) +} + +pub fn data_dir() -> PathBuf { + if let Some(dir) = std::env::var_os("ATMOSPHERE_DATA_DIR") { + return PathBuf::from(dir); + } + portable_root().unwrap_or_else(|| dirs::data_local_dir().unwrap_or_else(|| PathBuf::from(".")).join("atmosphere")) +} + +pub fn temp_root() -> PathBuf { + data_dir().join("temp") +} + +fn search_dirs() -> Vec { + let mut dirs: Vec = std::env::var_os("PATH").map(|p| std::env::split_paths(&p).collect()).unwrap_or_default(); + if cfg!(unix) { + let home = dirs::home_dir().unwrap_or_default(); + for extra in ["/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/snap/bin", "/opt/local/bin"] { + dirs.push(PathBuf::from(extra)); + } + dirs.push(home.join(".local/bin")); + dirs.push(home.join("bin")); + } + dirs +} + +fn on_path(name: &str) -> Option { + let file = format!("{name}{EXE}"); + search_dirs().into_iter().map(|d| d.join(&file)).find(|c| c.is_file()) +} + +fn resolve(custom: &str, name: &str) -> (Option, bool) { + if !custom.trim().is_empty() { + let p = PathBuf::from(custom.trim()); + return (p.is_file().then_some(p), false); + } + let managed = bin_dir().join(format!("{name}{EXE}")); + if managed.is_file() { + return (Some(managed), true); + } + (on_path(name), false) +} + +pub fn command(program: &Path) -> Command { + let mut cmd = Command::new(program); + cmd.stdin(Stdio::null()).env("PYTHONIOENCODING", "utf-8").env("PYTHONUTF8", "1"); + #[cfg(windows)] + cmd.creation_flags(0x0800_0000); + cmd +} + +async fn version_of(path: &Path, args: &[&str]) -> Option { + let out = command(path).args(args).stdout(Stdio::piped()).stderr(Stdio::null()).output().await.ok()?; + let text = String::from_utf8_lossy(&out.stdout); + let line = text.lines().next()?.trim(); + let v = line.strip_prefix("ffmpeg version ").map(|r| r.split_whitespace().next().unwrap_or(r)).unwrap_or(line); + (!v.is_empty()).then(|| v.to_string()) +} + +pub struct Tools { + pub ytdlp: PathBuf, + pub ffmpeg: Option, +} + +pub fn locate(ytdlp_custom: &str, ffmpeg_custom: &str) -> Result { + let (ytdlp, _) = resolve(ytdlp_custom, "yt-dlp"); + let ytdlp = ytdlp.ok_or_else(|| anyhow!("yt-dlp isn't set up yet. Open Settings → Engine to install it."))?; + let (ffmpeg, _) = resolve(ffmpeg_custom, "ffmpeg"); + Ok(Tools { ytdlp, ffmpeg }) +} + +pub async fn status(ytdlp_custom: &str, ffmpeg_custom: &str) -> ToolStatus { + let (yp, ym) = resolve(ytdlp_custom, "yt-dlp"); + let (fp, fm) = resolve(ffmpeg_custom, "ffmpeg"); + let yv = match &yp { + Some(p) => version_of(p, &["--version"]).await, + None => None, + }; + let fv = match &fp { + Some(p) => version_of(p, &["-version"]).await, + None => None, + }; + ToolStatus { + ytdlp: ToolInfo { path: yp.map(|p| p.to_string_lossy().into_owned()), version: yv, managed: ym }, + ffmpeg: ToolInfo { path: fp.map(|p| p.to_string_lossy().into_owned()), version: fv, managed: fm }, + can_install_ffmpeg: ffmpeg_asset().is_some(), + } +} + +fn ytdlp_asset() -> &'static str { + match (std::env::consts::OS, std::env::consts::ARCH) { + ("windows", _) => "yt-dlp.exe", + ("macos", _) => "yt-dlp_macos", + ("linux", "aarch64") => "yt-dlp_linux_aarch64", + _ => "yt-dlp_linux", + } +} + +fn ffmpeg_asset() -> Option<&'static str> { + match (std::env::consts::OS, std::env::consts::ARCH) { + ("windows", "aarch64") => Some("ffmpeg-master-latest-winarm64-gpl.zip"), + ("windows", _) => Some("ffmpeg-master-latest-win64-gpl.zip"), + ("linux", "aarch64") => Some("ffmpeg-master-latest-linuxarm64-gpl.tar.xz"), + ("linux", "x86_64") => Some("ffmpeg-master-latest-linux64-gpl.tar.xz"), + _ => None, + } +} + +fn wanted(path: &str) -> Option { + let path = path.replace('\\', "/"); + let file = path.rsplit('/').next().unwrap_or_default(); + (path.contains("/bin/") && (file == format!("ffmpeg{EXE}") || file == format!("ffprobe{EXE}"))).then(|| file.to_string()) +} + +fn extract_ffmpeg(asset: &str, data: Vec, dir: &Path) -> Result { + let mut found = None; + let mut keep = |file: String, buf: Vec| -> Result<()> { + let dest = dir.join(&file); + write_exec(&dest, &buf)?; + if file.starts_with("ffmpeg") { + found = Some(dest); + } + Ok(()) + }; + if asset.ends_with(".zip") { + let mut archive = zip::ZipArchive::new(std::io::Cursor::new(data))?; + for i in 0..archive.len() { + let mut entry = archive.by_index(i)?; + if let Some(file) = wanted(&entry.name()?) { + let mut buf = Vec::with_capacity(entry.size() as usize); + entry.read_to_end(&mut buf)?; + keep(file, buf)?; + } + } + } else { + let mut tar_bytes = Vec::new(); + lzma_rs::xz_decompress(&mut std::io::BufReader::new(std::io::Cursor::new(data)), &mut tar_bytes) + .map_err(|e| anyhow!("Couldn't unpack ffmpeg ({e})"))?; + let mut archive = tar::Archive::new(std::io::Cursor::new(tar_bytes)); + for entry in archive.entries()? { + let mut entry = entry?; + let name = entry.path()?.to_string_lossy().into_owned(); + if let Some(file) = wanted(&name) { + let mut buf = Vec::new(); + entry.read_to_end(&mut buf)?; + keep(file, buf)?; + } + } + } + found.ok_or_else(|| anyhow!("ffmpeg wasn't in the downloaded archive")) +} + +async fn fetch(http: &reqwest::Client, url: &str, mut progress: impl FnMut(u64, Option)) -> Result> { + use futures_util::StreamExt; + let resp = http.get(url).send().await?.error_for_status().with_context(|| format!("Download failed: {url}"))?; + let total = resp.content_length(); + let mut body = resp.bytes_stream(); + let mut data = Vec::with_capacity(total.unwrap_or(0) as usize); + while let Some(chunk) = body.next().await { + data.extend_from_slice(&chunk?); + progress(data.len() as u64, total); + } + Ok(data) +} + +fn expected_hash(sums: &str, asset: &str) -> Option { + sums.lines().find_map(|l| { + let mut parts = l.split_whitespace(); + let hash = parts.next()?; + let name = parts.next()?.trim_start_matches('*'); + (name == asset).then(|| hash.to_ascii_lowercase()) + }) +} + +fn verify(data: &[u8], sums: &str, asset: &str) -> Result<()> { + let expected = expected_hash(sums, asset).ok_or_else(|| anyhow!("No published checksum for {asset}"))?; + let actual = Sha256::digest(data).iter().map(|b| format!("{b:02x}")).collect::(); + if actual != expected { + bail!("Checksum mismatch for {asset}. The download was discarded."); + } + Ok(()) +} + +fn write_exec(path: &Path, data: &[u8]) -> Result<()> { + if let Some(dir) = path.parent() { + std::fs::create_dir_all(dir)?; + } + let tmp = path.with_extension("download"); + std::fs::write(&tmp, data)?; + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + std::fs::set_permissions(&tmp, std::fs::Permissions::from_mode(0o755))?; + } + std::fs::rename(&tmp, path)?; + Ok(()) +} + +pub async fn install_ytdlp(http: &reqwest::Client, progress: impl FnMut(u64, Option)) -> Result { + let asset = ytdlp_asset(); + let sums = http.get(format!("{YTDLP_RELEASE}/SHA2-256SUMS")).send().await?.error_for_status()?.text().await?; + let data = fetch(http, &format!("{YTDLP_RELEASE}/{asset}"), progress).await?; + verify(&data, &sums, asset)?; + let dest = bin_dir().join(format!("yt-dlp{EXE}")); + write_exec(&dest, &data)?; + Ok(dest) +} + +pub async fn install_ffmpeg(http: &reqwest::Client, progress: impl FnMut(u64, Option)) -> Result { + let Some(asset) = ffmpeg_asset() else { + bail!(if cfg!(target_os = "macos") { + "On macOS, install ffmpeg with Homebrew (`brew install ffmpeg`). Atmosphere finds it automatically." + } else { + "Install ffmpeg with your package manager, then restart Atmosphere." + }); + }; + let sums = http.get(format!("{FFMPEG_RELEASE}/checksums.sha256")).send().await?.error_for_status()?.text().await?; + let data = fetch(http, &format!("{FFMPEG_RELEASE}/{asset}"), progress).await?; + verify(&data, &sums, asset)?; + let dir = bin_dir(); + tokio::task::spawn_blocking(move || extract_ffmpeg(asset, data, &dir)).await? +} + +pub async fn update_ytdlp(path: &Path) -> Result { + let out = command(path).arg("-U").stdout(Stdio::piped()).stderr(Stdio::piped()).output().await?; + let text = format!("{}{}", String::from_utf8_lossy(&out.stdout), String::from_utf8_lossy(&out.stderr)); + let line = text + .lines() + .rev() + .find(|l| l.contains("Updated") || l.contains("up to date") || l.contains("ERROR")) + .unwrap_or("Update finished") + .trim() + .trim_start_matches("ERROR: ") + .to_string(); + if !out.status.success() { + bail!(line); + } + Ok(line) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn finds_checksums() { + let sums = "abc123 yt-dlp.exe\nDEF456 *yt-dlp_linux\n"; + assert_eq!(expected_hash(sums, "yt-dlp.exe").as_deref(), Some("abc123")); + assert_eq!(expected_hash(sums, "yt-dlp_linux").as_deref(), Some("def456")); + assert!(expected_hash(sums, "nope").is_none()); + let data = b"hello"; + let good = format!("{} file.bin", Sha256::digest(data).iter().map(|b| format!("{b:02x}")).collect::()); + assert!(verify(data, &good, "file.bin").is_ok()); + assert!(verify(b"tampered", &good, "file.bin").is_err()); + } + + #[test] + fn picks_ffmpeg_binaries_from_archives() { + let exe = |n: &str| format!("{n}{EXE}"); + assert_eq!(wanted(&format!("ffmpeg-master-latest/bin/{}", exe("ffmpeg"))), Some(exe("ffmpeg"))); + assert_eq!(wanted(&format!("ffmpeg-master-latest\\bin\\{}", exe("ffprobe"))), Some(exe("ffprobe"))); + assert_eq!(wanted("ffmpeg-master-latest/doc/ffmpeg.html"), None); + assert_eq!(wanted(&format!("ffmpeg-master-latest/bin/{}", exe("ffplay"))), None); + } +} diff --git a/src/history.rs b/src/history.rs new file mode 100644 index 0000000..4943e00 --- /dev/null +++ b/src/history.rs @@ -0,0 +1,96 @@ +// atmosphere · history.rs · Persists the list of finished downloads so the Library view survives restarts. +use crate::downloader::JobRequest; +use serde::{Deserialize, Serialize}; +use std::path::{Path, PathBuf}; +use std::sync::Mutex; +use std::time::{SystemTime, UNIX_EPOCH}; + +const LIMIT: usize = 5000; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Record { + pub id: String, + pub title: String, + pub artist: String, + pub platform: String, + pub url: String, + pub path: String, + pub format: Option, + pub collection: Option, + pub thumbnail: Option, + pub at: u64, +} + +impl Record { + pub fn new(req: &JobRequest, path: &Path, format: Option) -> Self { + let at = SystemTime::now().duration_since(UNIX_EPOCH).map(|d| d.as_millis() as u64).unwrap_or(0); + let pick = |edited: &str, original: &str| if edited.trim().is_empty() { original.to_string() } else { edited.to_string() }; + Self { + id: format!("{at}-{}", req.entry.index), + title: pick(&req.meta.title, &req.entry.title), + artist: pick(&req.meta.artist, &req.entry.artist), + platform: req.entry.platform.clone(), + url: req.entry.url.clone(), + path: path.to_string_lossy().into_owned(), + format, + collection: req.folder.clone(), + thumbnail: req.entry.thumbnail.clone(), + at, + } + } +} + +pub struct History { + file: PathBuf, + items: Mutex>, +} + +impl History { + pub fn load(file: PathBuf) -> Self { + let items = std::fs::read_to_string(&file).ok().and_then(|s| serde_json::from_str(&s).ok()).unwrap_or_default(); + Self { file, items: Mutex::new(items) } + } + + fn persist(&self, items: &[Record]) { + if let Some(dir) = self.file.parent() { + let _ = std::fs::create_dir_all(dir); + } + if let Ok(data) = serde_json::to_vec(items) { + let tmp = self.file.with_extension("json.tmp"); + if std::fs::write(&tmp, data).is_ok() { + let _ = std::fs::rename(&tmp, &self.file); + } + } + } + + pub fn add(&self, record: Record) { + let mut items = self.items.lock().unwrap(); + items.retain(|r| r.path != record.path); + items.insert(0, record); + items.truncate(LIMIT); + self.persist(&items); + } + + pub fn list(&self) -> Vec { + self.items.lock().unwrap().iter().map(|r| { + let mut r = r.clone(); + if !Path::new(&r.path).exists() { + r.path = String::new(); + } + r + }).collect() + } + + pub fn remove(&self, ids: &[String]) { + let mut items = self.items.lock().unwrap(); + items.retain(|r| !ids.contains(&r.id)); + self.persist(&items); + } + + pub fn clear(&self) { + let mut items = self.items.lock().unwrap(); + items.clear(); + self.persist(&items); + } +} diff --git a/src/libcmd.rs b/src/libcmd.rs new file mode 100644 index 0000000..f74e723 --- /dev/null +++ b/src/libcmd.rs @@ -0,0 +1,452 @@ +// atmosphere · libcmd.rs · Library, playlist, lyrics and window commands, plus the atmo:// media protocol that streams local files. +use crate::library::{Snapshot, Track}; +use crate::lyrics::{self, Found, Lyrics, Query}; +use crate::tagging::{self, TagFields}; +use crate::{err, AppState, CmdResult}; +use notify::{RecursiveMode, Watcher}; +use std::collections::HashSet; +use std::io::{Read, Seek, SeekFrom}; +use std::sync::Mutex; +use std::time::Duration; +use std::path::{Path, PathBuf}; +use tauri::http::{Request, Response}; +use tauri::{AppHandle, Emitter, Manager, State}; +use tauri_plugin_dialog::DialogExt; + +pub const LIBRARY_EVENT: &str = crate::downloader::LIBRARY_EVENT; +const MAX_CHUNK: u64 = 4 * 1024 * 1024; + +fn dirs(state: &AppState) -> (Vec, PathBuf) { + let s = state.snapshot(); + (s.library_folders.iter().map(PathBuf::from).collect(), PathBuf::from(&s.playlists_dir)) +} + +fn changed(app: &AppHandle) { + let _ = app.emit(LIBRARY_EVENT, serde_json::json!({ "type": "changed" })); +} + +#[tauri::command] +pub fn library_get(state: State<'_, AppState>) -> Snapshot { + let (_, pl) = dirs(&state); + state.library.snapshot(&pl) +} + +pub fn spawn_scan(app: AppHandle) { + tauri::async_runtime::spawn_blocking(move || { + let state = app.state::(); + let (roots, pl) = dirs(&state); + let _ = std::fs::create_dir_all(&pl); + let emitter = app.clone(); + let result = state.library.scan(&roots, &pl, |done, total| { + let _ = emitter.emit(LIBRARY_EVENT, serde_json::json!({ "type": "progress", "done": done, "total": total })); + }); + let _ = app.emit(LIBRARY_EVENT, match result { + Ok(n) => serde_json::json!({ "type": "scanned", "count": n }), + Err(e) => serde_json::json!({ "type": "error", "message": format!("{e:#}") }), + }); + }); +} + +static WATCHER: Mutex> = Mutex::new(None); + +fn apply_changes(app: &AppHandle, paths: HashSet) { + let state = app.state::(); + let (_, pl) = dirs(&state); + let temp = crate::engine::temp_root(); + let mut touched = false; + for p in paths { + if p.starts_with(&temp) || p.file_name().and_then(|n| n.to_str()).is_some_and(crate::storage::is_partial) { + continue; + } + if p.file_name().and_then(|n| n.to_str()) == Some("playlist.m3u8") { + touched = true; + continue; + } + if !p.exists() { + touched |= state.library.remove_under(&p) > 0; + } else if p.is_dir() { + for e in walkdir::WalkDir::new(&p).into_iter().flatten().filter(|e| e.file_type().is_file()) { + if crate::library::is_audio(e.path()) && !state.library.knows(e.path()) { + touched |= state.library.add_file(e.path(), &pl).is_ok(); + } + } + } else if crate::library::is_audio(&p) && !state.library.knows(&p) { + touched |= state.library.add_file(&p, &pl).is_ok(); + } + } + if touched { + changed(app); + } +} + +pub fn start_watch(app: AppHandle) { + let (tx, rx) = std::sync::mpsc::channel::>(); + let Ok(mut watcher) = notify::recommended_watcher(tx) else { return }; + let (roots, pl) = dirs(&app.state::()); + let _ = std::fs::create_dir_all(&pl); + let mut watched: Vec = Vec::new(); + for r in roots.into_iter().chain(std::iter::once(pl)) { + if r.is_dir() && !watched.iter().any(|w| r.starts_with(w)) && watcher.watch(&r, RecursiveMode::Recursive).is_ok() { + watched.push(r); + } + } + *WATCHER.lock().unwrap() = Some(watcher); + std::thread::spawn(move || { + while let Ok(first) = rx.recv() { + let mut batch: HashSet = HashSet::new(); + if let Ok(ev) = first { + batch.extend(ev.paths); + } + while let Ok(next) = rx.recv_timeout(Duration::from_millis(700)) { + if let Ok(ev) = next { + batch.extend(ev.paths); + } + } + if !batch.is_empty() { + apply_changes(&app, batch); + } + } + }); +} + +#[tauri::command] +pub fn library_scan(app: AppHandle) { + spawn_scan(app); +} + +#[tauri::command] +pub async fn library_add_folder(app: AppHandle, state: State<'_, AppState>) -> CmdResult> { + let a = app.clone(); + let picked = tauri::async_runtime::spawn_blocking(move || a.dialog().file().set_title("Add a music folder").blocking_pick_folder()) + .await + .map_err(|e| e.to_string())?; + let Some(path) = picked.and_then(|p| p.into_path().ok()) else { return Ok(None) }; + let p = path.to_string_lossy().into_owned(); + state.update(|s| { + if !s.library_folders.contains(&p) { + s.library_folders.push(p.clone()); + } + })?; + spawn_scan(app.clone()); + start_watch(app); + Ok(Some(p)) +} + +#[tauri::command] +pub fn library_remove_folder(app: AppHandle, state: State<'_, AppState>, path: String) -> CmdResult<()> { + state.update(|s| s.library_folders.retain(|f| *f != path))?; + spawn_scan(app.clone()); + start_watch(app); + Ok(()) +} + +#[tauri::command] +pub fn playlist_create(app: AppHandle, state: State<'_, AppState>, name: String) -> CmdResult { + let (_, pl) = dirs(&state); + let n = state.library.playlist_create(&pl, &name).map_err(err)?; + changed(&app); + Ok(n) +} + +#[tauri::command] +pub fn playlist_rename(app: AppHandle, state: State<'_, AppState>, from: String, to: String) -> CmdResult { + let (_, pl) = dirs(&state); + let n = state.library.playlist_rename(&pl, &from, &to).map_err(err)?; + changed(&app); + Ok(n) +} + +#[tauri::command] +pub fn playlist_delete(app: AppHandle, state: State<'_, AppState>, name: String) -> CmdResult<()> { + let (_, pl) = dirs(&state); + state.library.playlist_delete(&pl, &name).map_err(err)?; + changed(&app); + Ok(()) +} + +#[tauri::command] +pub async fn playlist_add(app: AppHandle, state: State<'_, AppState>, name: String, ids: Vec) -> CmdResult { + let (_, pl) = dirs(&state); + let sources: Vec = ids.iter().filter_map(|id| state.library.track(id)).map(|t| PathBuf::from(t.path)).collect(); + let link = !state.snapshot().playlist_copy; + let lib = state.library.clone(); + let n = tauri::async_runtime::spawn_blocking(move || lib.playlist_add(&pl, &name, &sources, link)).await.map_err(|e| e.to_string())?.map_err(err)?; + changed(&app); + Ok(n) +} + +#[tauri::command] +pub async fn playlist_add_files(app: AppHandle, state: State<'_, AppState>, name: String) -> CmdResult { + let a = app.clone(); + let picked = tauri::async_runtime::spawn_blocking(move || { + a.dialog().file().set_title("Add songs to the playlist").add_filter("Audio", &crate::library::AUDIO_EXT).blocking_pick_files() + }) + .await + .map_err(|e| e.to_string())?; + let files: Vec = picked.unwrap_or_default().into_iter().filter_map(|p| p.into_path().ok()).collect(); + if files.is_empty() { + return Ok(0); + } + let (_, pl) = dirs(&state); + let lib = state.library.clone(); + let n = tauri::async_runtime::spawn_blocking(move || lib.playlist_add(&pl, &name, &files, false)).await.map_err(|e| e.to_string())?.map_err(err)?; + changed(&app); + Ok(n) +} + +#[tauri::command] +pub fn playlist_remove(app: AppHandle, state: State<'_, AppState>, name: String, ids: Vec) -> CmdResult<()> { + let (_, pl) = dirs(&state); + state.library.playlist_remove(&pl, &name, &ids).map_err(err)?; + changed(&app); + Ok(()) +} + +#[tauri::command] +pub fn playlist_reorder(state: State<'_, AppState>, name: String, ids: Vec) -> CmdResult<()> { + let (_, pl) = dirs(&state); + state.library.playlist_reorder(&pl, &name, &ids).map_err(err) +} + +#[tauri::command] +pub async fn tracks_delete(app: AppHandle, state: State<'_, AppState>, ids: Vec, playlists: bool) -> CmdResult { + let (_, pl) = dirs(&state); + let lib = state.library.clone(); + let n = tauri::async_runtime::spawn_blocking(move || lib.delete(&ids, &pl, playlists)).await.map_err(|e| e.to_string())?; + changed(&app); + n.map_err(err) +} + +#[tauri::command] +pub fn tracks_hide(app: AppHandle, state: State<'_, AppState>, ids: Vec) -> usize { + let n = state.library.hide(&ids); + changed(&app); + n +} + +#[tauri::command] +pub fn tracks_unhide_all(app: AppHandle, state: State<'_, AppState>) -> usize { + let n = state.library.unhide_all(); + spawn_scan(app); + n +} + +#[tauri::command] +pub fn track_played(state: State<'_, AppState>, id: String) { + state.library.played(&id); +} + +#[tauri::command] +pub fn track_listened(state: State<'_, AppState>, id: String, ms: u64) { + state.library.listened(&id, ms); +} + +#[tauri::command] +pub fn app_heartbeat(state: State<'_, AppState>, day: String, secs: u64) { + state.library.app_seconds(&day, secs); +} + +#[tauri::command] +pub fn stats_get(state: State<'_, AppState>) -> crate::library::StatsData { + state.library.stats() +} + +fn png_from(data: &str) -> CmdResult> { + use base64::Engine as _; + let raw = data.split_once(',').map(|(_, b)| b).unwrap_or(data); + base64::engine::general_purpose::STANDARD.decode(raw).map_err(|e| e.to_string()) +} + +#[tauri::command] +pub async fn image_save(app: AppHandle, data: String, name: String) -> CmdResult> { + let bytes = png_from(&data)?; + let a = app.clone(); + let picked = tauri::async_runtime::spawn_blocking(move || a.dialog().file().set_title("Save your stats").set_file_name(&name).add_filter("PNG image", &["png"]).blocking_save_file()) + .await + .map_err(|e| e.to_string())?; + let Some(path) = picked.and_then(|p| p.into_path().ok()) else { return Ok(None) }; + std::fs::write(&path, bytes).map_err(|e| e.to_string())?; + Ok(Some(path.to_string_lossy().into_owned())) +} + +#[tauri::command] +pub fn image_copy(app: AppHandle, data: String) -> CmdResult<()> { + use tauri_plugin_clipboard_manager::ClipboardExt; + let bytes = png_from(&data)?; + let img = tauri::image::Image::from_bytes(&bytes).map_err(|e| e.to_string())?; + app.clipboard().write_image(&img).map_err(|e| e.to_string()) +} + +#[tauri::command] +pub fn track_like(state: State<'_, AppState>, id: String, liked: bool) { + state.library.like(&id, liked); +} + +#[tauri::command] +pub async fn track_edit(app: AppHandle, state: State<'_, AppState>, id: String, meta: TagFields) -> CmdResult { + let t = state.library.track(&id).ok_or("That track is no longer in the library")?; + let s = state.snapshot(); + let ffmpeg = crate::engine::locate(&s.ytdlp_path, &s.ffmpeg_path).ok().and_then(|t| t.ffmpeg); + tagging::apply(Path::new(&t.path), &meta, "", ffmpeg.as_deref()).await.map_err(err)?; + let (_, pl) = dirs(&state); + let updated = state.library.refresh(&id, &pl).map_err(err)?; + changed(&app); + Ok(updated) +} + +#[tauri::command] +pub async fn artist_update(app: AppHandle, state: State<'_, AppState>, name: String, pick_image: bool, bio: Option) -> CmdResult { + let image = if pick_image { + let a = app.clone(); + let picked = tauri::async_runtime::spawn_blocking(move || a.dialog().file().set_title("Choose an artist image").add_filter("Images", &["jpg", "jpeg", "png"]).blocking_pick_file()) + .await + .map_err(|e| e.to_string())?; + match picked.and_then(|p| p.into_path().ok()) { + Some(p) => Some(p), + None => return Err("cancelled".into()), + } + } else { + None + }; + let meta = state.library.set_artist(&name, image.as_deref(), bio).map_err(err)?; + changed(&app); + Ok(meta) +} + +#[tauri::command] +pub async fn lyrics_get(state: State<'_, AppState>, query: Query, refresh: bool) -> CmdResult { + let s = state.snapshot(); + lyrics::find(&state.http, &s, &query, refresh).await.map_err(err) +} + +#[tauri::command] +pub fn lyrics_save(app: AppHandle, state: State<'_, AppState>, id: String, lyrics: Lyrics) -> CmdResult<()> { + let t = state.library.track(&id).ok_or("That track is no longer in the library")?; + std::fs::write(Path::new(&t.path).with_extension("lrc"), lyrics::to_lrc(&lyrics)).map_err(|e| e.to_string())?; + let (_, pl) = dirs(&state); + let _ = state.library.refresh(&id, &pl); + changed(&app); + Ok(()) +} + +#[tauri::command] +pub async fn lyrics_save_text(app: AppHandle, state: State<'_, AppState>, id: String, text: String) -> CmdResult<()> { + let t = state.library.track(&id).ok_or("That track is no longer in the library")?; + let path = PathBuf::from(&t.path); + let lrc = path.with_extension("lrc"); + let text = text.trim().to_string(); + if lyrics::is_timed(&text) { + std::fs::write(&lrc, &text).map_err(|e| e.to_string())?; + } else if lrc.exists() { + let _ = trash::delete(&lrc); + } + let meta = TagFields { lyrics: if text.is_empty() { String::new() } else { text.clone() }, ..Default::default() }; + if !text.is_empty() { + tagging::apply(&path, &meta, "", None).await.map_err(err)?; + } + let (_, pl) = dirs(&state); + let _ = state.library.refresh(&id, &pl); + changed(&app); + Ok(()) +} + +#[tauri::command] +pub fn set_fullscreen(app: AppHandle, on: bool) -> CmdResult { + let w = app.get_webview_window("main").ok_or("No window")?; + w.set_fullscreen(on).map_err(|e| e.to_string())?; + w.is_fullscreen().map_err(|e| e.to_string()) +} + +fn mime(path: &Path) -> &'static str { + match path.extension().and_then(|e| e.to_str()).unwrap_or_default().to_ascii_lowercase().as_str() { + "mp3" => "audio/mpeg", + "m4a" | "mp4" | "aac" => "audio/mp4", + "flac" => "audio/flac", + "ogg" => "audio/ogg", + "opus" => "audio/ogg; codecs=opus", + "wav" => "audio/wav", + "aiff" | "aif" => "audio/aiff", + "jpg" | "jpeg" => "image/jpeg", + "png" => "image/png", + _ => "application/octet-stream", + } +} + +fn respond(status: u16, ctype: &str, body: Vec, extra: &[(&str, String)]) -> Response> { + let mut b = Response::builder().status(status).header("Content-Type", ctype).header("Access-Control-Allow-Origin", "*").header("Accept-Ranges", "bytes"); + for (k, v) in extra { + b = b.header(*k, v.as_str()); + } + b.body(body).unwrap_or_else(|_| Response::new(Vec::new())) +} + +fn range_of(header: Option<&str>, len: u64) -> Option<(u64, u64)> { + let spec = header?.trim().strip_prefix("bytes=")?; + let (a, b) = spec.split_once('-')?; + let (start, end) = if a.is_empty() { + let n: u64 = b.parse().ok()?; + (len.saturating_sub(n), len - 1) + } else { + let s: u64 = a.parse().ok()?; + let e = if b.is_empty() { (s + MAX_CHUNK - 1).min(len - 1) } else { b.parse::().ok()?.min(len - 1) }; + (s, e) + }; + (start <= end && start < len).then_some((start, end)) +} + +fn stream(path: &Path, range: Option<&str>) -> Response> { + let Ok(mut f) = std::fs::File::open(path) else { return respond(404, "text/plain", b"not found".to_vec(), &[]) }; + let len = f.metadata().map(|m| m.len()).unwrap_or(0); + if len == 0 { + return respond(200, mime(path), Vec::new(), &[]); + } + match range_of(range, len) { + Some((start, end)) => { + let mut buf = vec![0u8; (end - start + 1) as usize]; + if f.seek(SeekFrom::Start(start)).is_err() || f.read_exact(&mut buf).is_err() { + return respond(416, "text/plain", Vec::new(), &[]); + } + respond(206, mime(path), buf, &[("Content-Range", format!("bytes {start}-{end}/{len}"))]) + } + None => { + let mut buf = Vec::with_capacity(len as usize); + let _ = f.read_to_end(&mut buf); + respond(200, mime(path), buf, &[]) + } + } +} + +pub fn serve(app: &AppHandle, request: &Request>) -> Response> { + let state = app.state::(); + let path = request.uri().path().trim_start_matches('/').to_string(); + let range = request.headers().get("range").and_then(|v| v.to_str().ok()); + let (kind, id) = path.split_once('/').unwrap_or(("", "")); + match kind { + "t" => match state.library.track(id) { + Some(t) => stream(Path::new(&t.path), range), + None => respond(404, "text/plain", b"unknown track".to_vec(), &[]), + }, + "a" => match state.library.art_path(id) { + Some(p) => { + let data = std::fs::read(&p).unwrap_or_default(); + respond(200, "image/jpeg", data, &[("Cache-Control", "max-age=86400".into())]) + } + None => respond(404, "text/plain", Vec::new(), &[]), + }, + _ => respond(400, "text/plain", Vec::new(), &[]), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_byte_ranges() { + assert_eq!(range_of(Some("bytes=0-"), 10_000_000), Some((0, MAX_CHUNK - 1))); + assert_eq!(range_of(Some("bytes=100-199"), 1000), Some((100, 199))); + assert_eq!(range_of(Some("bytes=-100"), 1000), Some((900, 999))); + assert_eq!(range_of(Some("bytes=5000-"), 1000), None); + assert_eq!(range_of(None, 1000), None); + } +} diff --git a/src/library.rs b/src/library.rs new file mode 100644 index 0000000..dcaba29 --- /dev/null +++ b/src/library.rs @@ -0,0 +1,701 @@ +// atmosphere · library.rs · Local music library: folder scanning, tags, artwork cache, folder-based playlists, play stats and artist profiles. +use crate::downloader::sanitize; +use crate::engine::data_dir; +use anyhow::{anyhow, bail, Context, Result}; +use lofty::file::{AudioFile, TaggedFileExt}; +use lofty::tag::{Accessor, ItemKey}; +use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256}; +use std::collections::{HashMap, HashSet}; +use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::RwLock; +use std::time::{SystemTime, UNIX_EPOCH}; + +pub const AUDIO_EXT: [&str; 9] = ["mp3", "m4a", "flac", "ogg", "opus", "wav", "aac", "aiff", "aif"]; +const ORDER_FILE: &str = "playlist.m3u8"; + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", default)] +pub struct Track { + pub id: String, + pub path: String, + pub title: String, + pub artist: String, + pub album: String, + pub album_artist: String, + pub track_no: Option, + pub track_total: Option, + pub disc_no: Option, + pub year: Option, + pub genre: String, + pub duration_ms: u64, + pub bitrate: Option, + pub format: String, + pub size: u64, + pub mtime: u64, + pub art: Option, + pub playlist: Option, + pub has_lyrics: bool, + pub added: u64, +} + +#[derive(Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", default)] +struct Stats { + plays: HashMap, + last_played: HashMap, + liked: HashSet, + listens: Vec, + app_time: std::collections::BTreeMap, +} + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +pub struct Listen { + pub id: String, + pub at: u64, + pub ms: u64, +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +pub struct StatsData { + pub listens: Vec, + pub app_time: std::collections::BTreeMap, +} + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", default)] +pub struct ArtistMeta { + pub name: String, + pub image: Option, + pub bio: String, +} + +#[derive(Clone, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Playlist { + pub name: String, + pub path: String, + pub order: Vec, +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Snapshot { + pub tracks: Vec, + pub playlists: Vec, + pub plays: HashMap, + pub last_played: HashMap, + pub liked: Vec, + pub artists: HashMap, + pub scanning: bool, + pub hidden: usize, +} + +pub struct Library { + tracks: RwLock>, + stats: RwLock, + artists: RwLock>, + hidden: RwLock>, + scanning: AtomicBool, +} + +fn now() -> u64 { + SystemTime::now().duration_since(UNIX_EPOCH).map(|d| d.as_millis() as u64).unwrap_or(0) +} + +pub fn hash(s: &str) -> String { + Sha256::digest(s.as_bytes()).iter().take(10).map(|b| format!("{b:02x}")).collect() +} + +pub fn artist_key(name: &str) -> String { + hash(&name.trim().to_lowercase()) +} + +fn art_dir() -> PathBuf { + data_dir().join("art") +} + +fn load Deserialize<'de> + Default>(name: &str) -> T { + std::fs::read(data_dir().join(name)).ok().and_then(|b| serde_json::from_slice(&b).ok()).unwrap_or_default() +} + +fn store(name: &str, value: &T) { + let path = data_dir().join(name); + let _ = std::fs::create_dir_all(data_dir()); + if let Ok(data) = serde_json::to_vec(value) { + let tmp = path.with_extension("tmp"); + if std::fs::write(&tmp, data).is_ok() { + let _ = std::fs::rename(&tmp, &path); + } + } +} + +pub fn is_audio(p: &Path) -> bool { + p.extension().and_then(|e| e.to_str()).is_some_and(|e| AUDIO_EXT.contains(&e.to_ascii_lowercase().as_str())) +} + +fn file_stamp(p: &Path) -> Option<(u64, u64)> { + let m = std::fs::metadata(p).ok()?; + let mtime = m.modified().ok()?.duration_since(UNIX_EPOCH).ok()?.as_secs(); + Some((m.len(), mtime)) +} + +fn save_art(key: &str, data: &[u8]) -> Option { + let dir = art_dir(); + let out = dir.join(format!("{key}.jpg")); + if out.exists() { + return Some(key.to_string()); + } + std::fs::create_dir_all(&dir).ok()?; + let img = image::load_from_memory(data).ok()?; + let rgb = img.thumbnail(600, 600).to_rgb8(); + let mut buf = Vec::new(); + image::codecs::jpeg::JpegEncoder::new_with_quality(&mut buf, 86).encode_image(&rgb).ok()?; + std::fs::write(&out, buf).ok()?; + Some(key.to_string()) +} + +fn year_of(s: &str) -> Option { + let digits: String = s.chars().skip_while(|c| !c.is_ascii_digit()).take(4).collect(); + digits.parse().ok().filter(|y| (1000..3000).contains(y)) +} + +pub fn read_track(path: &Path, playlist: Option) -> Result { + let (size, mtime) = file_stamp(path).ok_or_else(|| anyhow!("unreadable"))?; + let file = lofty::read_from_path(path)?; + let props = file.properties(); + let tag = file.primary_tag().or_else(|| file.first_tag()); + let get = |f: &dyn Fn(&lofty::tag::Tag) -> Option| tag.and_then(f).map(|s| s.trim().to_string()).filter(|s| !s.is_empty()); + let stem = path.file_stem().and_then(|s| s.to_str()).unwrap_or("Untitled").to_string(); + let title = get(&|t| t.title().map(|c| c.into_owned())).unwrap_or(stem); + let artist = get(&|t| t.artist().map(|c| c.into_owned())).unwrap_or_default(); + let album = get(&|t| t.album().map(|c| c.into_owned())).unwrap_or_default(); + let album_artist = get(&|t| t.get_string(ItemKey::AlbumArtist).map(String::from)).unwrap_or_default(); + let year = get(&|t| t.get_string(ItemKey::Year).or_else(|| t.get_string(ItemKey::RecordingDate)).or_else(|| t.get_string(ItemKey::ReleaseDate)).map(String::from)).and_then(|y| year_of(&y)); + let lyrics_tag = tag.and_then(|t| t.get_string(ItemKey::Lyrics)).is_some_and(|l| !l.trim().is_empty()); + let group = format!("{}|{}", if album_artist.is_empty() { &artist } else { &album_artist }, album).to_lowercase(); + let art_key = if album.is_empty() { hash(&path.to_string_lossy()) } else { hash(&group) }; + let art = tag.and_then(|t| t.pictures().first()).and_then(|p| save_art(&art_key, p.data())); + let path_s = path.to_string_lossy().into_owned(); + Ok(Track { + id: hash(&path_s), + title, + artist, + album, + album_artist, + track_no: tag.and_then(|t| t.track()), + track_total: tag.and_then(|t| t.track_total()), + disc_no: tag.and_then(|t| t.disk()), + year, + genre: get(&|t| t.genre().map(|c| c.into_owned())).unwrap_or_default(), + duration_ms: props.duration().as_millis() as u64, + bitrate: props.audio_bitrate(), + format: path.extension().and_then(|e| e.to_str()).unwrap_or_default().to_ascii_lowercase(), + size, + mtime, + art, + playlist, + has_lyrics: lyrics_tag || path.with_extension("lrc").exists(), + added: now(), + path: path_s, + }) +} + +fn playlist_of(path: &Path, playlists_dir: &Path) -> Option { + let rel = path.strip_prefix(playlists_dir).ok()?; + let mut parts = rel.components(); + let first = parts.next()?.as_os_str().to_string_lossy().into_owned(); + parts.next().map(|_| first) +} + +fn read_order(dir: &Path) -> Vec { + std::fs::read_to_string(dir.join(ORDER_FILE)) + .map(|s| s.lines().map(str::trim).filter(|l| !l.is_empty() && !l.starts_with('#')).map(String::from).collect()) + .unwrap_or_default() +} + +fn write_order(dir: &Path, names: &[String]) -> Result<()> { + let mut body = String::from("#EXTM3U\n"); + for n in names { + body.push_str(n); + body.push('\n'); + } + std::fs::write(dir.join(ORDER_FILE), body)?; + Ok(()) +} + +impl Library { + pub fn load() -> Self { + let cached: Vec = load("library.json"); + Self { + tracks: RwLock::new(cached.into_iter().map(|t| (t.id.clone(), t)).collect()), + stats: RwLock::new(load("stats.json")), + artists: RwLock::new(load("artists.json")), + hidden: RwLock::new(load("hidden.json")), + scanning: AtomicBool::new(false), + } + } + + fn persist(&self) { + let list: Vec = self.tracks.read().unwrap().values().cloned().collect(); + store("library.json", &list); + } + + pub fn track(&self, id: &str) -> Option { + self.tracks.read().unwrap().get(id).cloned() + } + + pub fn art_path(&self, key: &str) -> Option { + let safe: String = key.chars().filter(|c| c.is_ascii_alphanumeric()).collect(); + let p = art_dir().join(format!("{safe}.jpg")); + p.exists().then_some(p) + } + + pub fn scan(&self, roots: &[PathBuf], playlists_dir: &Path, mut progress: impl FnMut(usize, usize)) -> Result { + if self.scanning.swap(true, Ordering::SeqCst) { + bail!("A scan is already running."); + } + let result = self.scan_files(roots, playlists_dir, &mut progress); + self.scanning.store(false, Ordering::SeqCst); + result + } + + fn scan_files(&self, roots: &[PathBuf], playlists_dir: &Path, progress: &mut impl FnMut(usize, usize)) -> Result { + { + let old: HashMap = self.tracks.read().unwrap().values().map(|t| (t.path.clone(), t.clone())).collect(); + let mut files: Vec = Vec::new(); + let mut seen = HashSet::new(); + let mut all_roots: Vec = roots.to_vec(); + all_roots.push(playlists_dir.to_path_buf()); + for root in all_roots.iter().filter(|r| r.is_dir()) { + for entry in walkdir::WalkDir::new(root).follow_links(false).into_iter().filter_entry(|e| !e.file_name().to_string_lossy().starts_with('.')).flatten() { + let p = entry.path(); + if entry.file_type().is_file() && is_audio(p) && seen.insert(p.to_path_buf()) { + files.push(p.to_path_buf()); + } + } + } + let hidden = self.hidden.read().unwrap().clone(); + files.retain(|p| !hidden.contains(&*p.to_string_lossy())); + let total = files.len(); + let mut next: HashMap = HashMap::with_capacity(total); + for (i, p) in files.iter().enumerate() { + let playlist = playlist_of(p, playlists_dir); + let key = p.to_string_lossy().into_owned(); + let reuse = old.get(&key).filter(|t| file_stamp(p) == Some((t.size, t.mtime))).cloned(); + let track = match reuse { + Some(mut t) => { + t.playlist = playlist; + Some(t) + } + None => read_track(p, playlist).ok(), + }; + if let Some(t) = track { + next.insert(t.id.clone(), t); + } + if i % 25 == 0 || i + 1 == total { + progress(i + 1, total); + } + } + let count = next.len(); + *self.tracks.write().unwrap() = next; + self.persist(); + Ok(count) + } + } + + pub fn add_file(&self, path: &Path, playlists_dir: &Path) -> Result { + if self.hidden.read().unwrap().contains(&*path.to_string_lossy()) { + bail!("hidden"); + } + let t = read_track(path, playlist_of(path, playlists_dir))?; + self.tracks.write().unwrap().insert(t.id.clone(), t.clone()); + self.persist(); + Ok(t) + } + + pub fn snapshot(&self, playlists_dir: &Path) -> Snapshot { + let tracks: Vec = self.tracks.read().unwrap().values().cloned().collect(); + let stats = self.stats.read().unwrap(); + Snapshot { + playlists: self.playlists(playlists_dir, &tracks), + tracks, + plays: stats.plays.clone(), + last_played: stats.last_played.clone(), + liked: stats.liked.iter().cloned().collect(), + artists: self.artists.read().unwrap().clone(), + scanning: self.scanning.load(Ordering::SeqCst), + hidden: self.hidden.read().unwrap().len(), + } + } + + fn playlists(&self, dir: &Path, tracks: &[Track]) -> Vec { + let Ok(rd) = std::fs::read_dir(dir) else { return Vec::new() }; + let mut out = Vec::new(); + for entry in rd.flatten().filter(|e| e.path().is_dir()) { + let name = entry.file_name().to_string_lossy().into_owned(); + if name.starts_with('.') { + continue; + } + let folder = entry.path(); + let mut members: Vec<&Track> = tracks.iter().filter(|t| t.playlist.as_deref() == Some(name.as_str())).collect(); + let order = read_order(&folder); + let file_name = |t: &Track| Path::new(&t.path).file_name().map(|f| f.to_string_lossy().into_owned()).unwrap_or_default(); + members.sort_by_key(|t| (order.iter().position(|o| *o == file_name(t)).unwrap_or(usize::MAX), file_name(t).to_lowercase())); + out.push(Playlist { name, path: folder.to_string_lossy().into_owned(), order: members.iter().map(|t| t.id.clone()).collect() }); + } + out.sort_by_key(|p| p.name.to_lowercase()); + out + } + + pub fn playlist_create(&self, dir: &Path, name: &str) -> Result { + let clean = sanitize(name.trim()); + let folder = dir.join(&clean); + if folder.exists() { + bail!("A playlist called “{clean}” already exists."); + } + std::fs::create_dir_all(&folder).context("Couldn't create the playlist folder")?; + write_order(&folder, &[])?; + Ok(clean) + } + + pub fn playlist_rename(&self, dir: &Path, from: &str, to: &str) -> Result { + let clean = sanitize(to.trim()); + let (a, b) = (dir.join(from), dir.join(&clean)); + if b.exists() { + bail!("A playlist called “{clean}” already exists."); + } + std::fs::rename(&a, &b).context("Couldn't rename the playlist folder")?; + let moved: Vec = self.tracks.read().unwrap().values().filter(|t| t.playlist.as_deref() == Some(from)).cloned().collect(); + let mut tracks = self.tracks.write().unwrap(); + for t in moved { + tracks.remove(&t.id); + let new_path = b.join(Path::new(&t.path).file_name().unwrap_or_default()); + let mut nt = t.clone(); + nt.path = new_path.to_string_lossy().into_owned(); + nt.id = hash(&nt.path); + nt.playlist = Some(clean.clone()); + tracks.insert(nt.id.clone(), nt); + } + drop(tracks); + self.persist(); + Ok(clean) + } + + pub fn playlist_delete(&self, dir: &Path, name: &str) -> Result<()> { + trash::delete(dir.join(name)).map_err(|e| anyhow!("Couldn't move the playlist to the trash ({e})"))?; + self.tracks.write().unwrap().retain(|_, t| t.playlist.as_deref() != Some(name)); + self.persist(); + Ok(()) + } + + pub fn playlist_add(&self, dir: &Path, name: &str, sources: &[PathBuf], link: bool) -> Result { + let folder = dir.join(name); + std::fs::create_dir_all(&folder)?; + let mut order = read_order(&folder); + let mut added = 0; + for src in sources { + let Some(file) = src.file_name() else { continue }; + let dest = folder.join(file); + let fname = file.to_string_lossy().into_owned(); + if !dest.exists() { + let linked = link && std::fs::hard_link(src, &dest).is_ok(); + if !linked { + std::fs::copy(src, &dest).with_context(|| format!("Couldn't add {fname}"))?; + } + if let Some(lrc) = Some(src.with_extension("lrc")).filter(|l| l.exists()) { + let _ = std::fs::copy(&lrc, dest.with_extension("lrc")); + } + added += 1; + } + if !order.contains(&fname) { + order.push(fname); + } + if let Ok(t) = read_track(&dest, Some(name.to_string())) { + self.tracks.write().unwrap().insert(t.id.clone(), t); + } + } + write_order(&folder, &order)?; + self.persist(); + Ok(added) + } + + pub fn playlist_remove(&self, dir: &Path, name: &str, ids: &[String]) -> Result<()> { + let folder = dir.join(name); + let mut order = read_order(&folder); + for id in ids { + let Some(t) = self.track(id).filter(|t| t.playlist.as_deref() == Some(name)) else { continue }; + let p = PathBuf::from(&t.path); + trash::delete(&p).map_err(|e| anyhow!("Couldn't move the file to the trash ({e})"))?; + let lrc = p.with_extension("lrc"); + if lrc.exists() { + let _ = trash::delete(&lrc); + } + let fname = p.file_name().map(|f| f.to_string_lossy().into_owned()).unwrap_or_default(); + order.retain(|o| *o != fname); + self.tracks.write().unwrap().remove(id); + } + write_order(&folder, &order)?; + self.persist(); + Ok(()) + } + + pub fn playlist_reorder(&self, dir: &Path, name: &str, ids: &[String]) -> Result<()> { + let names: Vec = ids + .iter() + .filter_map(|id| self.track(id)) + .filter_map(|t| Path::new(&t.path).file_name().map(|f| f.to_string_lossy().into_owned())) + .collect(); + write_order(&dir.join(name), &names) + } + + pub fn remove_under(&self, path: &Path) -> usize { + let mut tracks = self.tracks.write().unwrap(); + let before = tracks.len(); + tracks.retain(|_, t| { + let p = Path::new(&t.path); + p != path && !p.starts_with(path) + }); + let n = before - tracks.len(); + drop(tracks); + if n > 0 { + self.persist(); + } + n + } + + pub fn knows(&self, path: &Path) -> bool { + let stamp = file_stamp(path); + self.tracks.read().unwrap().values().any(|t| Path::new(&t.path) == path && stamp == Some((t.size, t.mtime))) + } + + pub fn hide(&self, ids: &[String]) -> usize { + let mut hidden = self.hidden.write().unwrap(); + let mut tracks = self.tracks.write().unwrap(); + let mut n = 0; + for id in ids { + if let Some(t) = tracks.remove(id) { + hidden.insert(t.path); + n += 1; + } + } + store("hidden.json", &*hidden); + drop(tracks); + self.persist(); + n + } + + pub fn unhide_all(&self) -> usize { + let mut hidden = self.hidden.write().unwrap(); + let n = hidden.len(); + hidden.clear(); + store("hidden.json", &*hidden); + n + } + + fn same_song(a: &Track, b: &Track) -> bool { + let n = |s: &str| s.trim().to_lowercase(); + n(&a.title) == n(&b.title) && n(&a.artist) == n(&b.artist) && a.duration_ms.abs_diff(b.duration_ms) < 2000 + } + + pub fn delete(&self, ids: &[String], playlists_dir: &Path, also_playlists: bool) -> Result { + let targets: Vec = ids.iter().filter_map(|id| self.track(id)).collect(); + let mut doomed: Vec = targets.clone(); + if also_playlists { + let all: Vec = self.tracks.read().unwrap().values().cloned().collect(); + for t in targets.iter().filter(|t| t.playlist.is_none()) { + doomed.extend(all.iter().filter(|p| p.playlist.is_some() && p.id != t.id && Self::same_song(t, p)).cloned()); + } + } + doomed.sort_by(|a, b| a.id.cmp(&b.id)); + doomed.dedup_by(|a, b| a.id == b.id); + let mut deleted = 0; + let mut failures = Vec::new(); + for t in &doomed { + let p = PathBuf::from(&t.path); + if p.exists() { + if let Err(e) = trash::delete(&p) { + failures.push(format!("{} ({e})", t.title)); + continue; + } + } + let lrc = p.with_extension("lrc"); + if lrc.exists() { + let _ = trash::delete(&lrc); + } + if let Some(name) = &t.playlist { + let folder = playlists_dir.join(name); + let fname = p.file_name().map(|f| f.to_string_lossy().into_owned()).unwrap_or_default(); + let mut order = read_order(&folder); + order.retain(|o| *o != fname); + let _ = write_order(&folder, &order); + } + self.tracks.write().unwrap().remove(&t.id); + if t.playlist.is_none() { + deleted += 1; + } + } + { + let mut s = self.stats.write().unwrap(); + for t in &doomed { + s.plays.remove(&t.id); + s.last_played.remove(&t.id); + s.liked.remove(&t.id); + } + let gone: HashSet<&str> = doomed.iter().map(|t| t.id.as_str()).collect(); + s.listens.retain(|l| !gone.contains(l.id.as_str())); + store("stats.json", &*s); + } + self.persist(); + if !failures.is_empty() { + bail!("Couldn't move to the trash: {}", failures.join(", ")); + } + Ok(deleted.max(targets.iter().filter(|t| t.playlist.is_some()).count())) + } + + pub fn listened(&self, id: &str, ms: u64) { + if ms < 1000 || self.track(id).is_none() { + return; + } + let mut s = self.stats.write().unwrap(); + s.listens.push(Listen { id: id.to_string(), at: now(), ms: ms.min(6 * 3600 * 1000) }); + store("stats.json", &*s); + } + + pub fn app_seconds(&self, day: &str, secs: u64) { + if day.len() != 10 || secs == 0 { + return; + } + let mut s = self.stats.write().unwrap(); + *s.app_time.entry(day.to_string()).or_default() += secs.min(600); + store("stats.json", &*s); + } + + pub fn stats(&self) -> StatsData { + let tracks = self.tracks.read().unwrap(); + let s = self.stats.read().unwrap(); + StatsData { listens: s.listens.iter().filter(|l| tracks.contains_key(&l.id)).cloned().collect(), app_time: s.app_time.clone() } + } + + pub fn played(&self, id: &str) { + let mut s = self.stats.write().unwrap(); + *s.plays.entry(id.to_string()).or_default() += 1; + s.last_played.insert(id.to_string(), now()); + store("stats.json", &*s); + } + + pub fn like(&self, id: &str, liked: bool) { + let mut s = self.stats.write().unwrap(); + if liked { + s.liked.insert(id.to_string()); + } else { + s.liked.remove(id); + } + store("stats.json", &*s); + } + + pub fn set_artist(&self, name: &str, image: Option<&Path>, bio: Option) -> Result { + let key = artist_key(name); + let mut artists = self.artists.write().unwrap(); + let meta = artists.entry(key.clone()).or_default(); + meta.name = name.trim().to_string(); + if let Some(src) = image { + let data = std::fs::read(src).context("Couldn't read that image")?; + let id = format!("artist{key}"); + let _ = std::fs::remove_file(art_dir().join(format!("{id}.jpg"))); + meta.image = Some(save_art(&id, &data).ok_or_else(|| anyhow!("That image couldn't be read"))?); + } + if let Some(b) = bio { + meta.bio = b; + } + let out = meta.clone(); + store("artists.json", &*artists); + Ok(out) + } + + pub fn refresh(&self, id: &str, playlists_dir: &Path) -> Result { + let t = self.track(id).ok_or_else(|| anyhow!("That track is no longer in the library"))?; + let _ = std::fs::remove_file(art_dir().join(format!("{}.jpg", t.art.clone().unwrap_or_default()))); + self.tracks.write().unwrap().remove(id); + self.add_file(Path::new(&t.path), playlists_dir) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn finds_playlist_membership() { + let root = Path::new("/music/Playlists"); + assert_eq!(playlist_of(Path::new("/music/Playlists/Gym/a.mp3"), root), Some("Gym".into())); + assert_eq!(playlist_of(Path::new("/music/Playlists/a.mp3"), root), None); + assert_eq!(playlist_of(Path::new("/music/Other/a.mp3"), root), None); + } + + #[test] + fn parses_years_and_extensions() { + assert_eq!(year_of("2019-04-12"), Some(2019)); + assert_eq!(year_of("Released 1998"), Some(1998)); + assert_eq!(year_of("n/a"), None); + assert!(is_audio(Path::new("x/Song.FLAC"))); + assert!(!is_audio(Path::new("x/cover.jpg"))); + } + + fn wav(path: &Path, seconds: u32) { + let rate = 8000u32; + let n = rate * seconds; + let mut d = Vec::new(); + d.extend(b"RIFF"); + d.extend((36 + n * 2).to_le_bytes()); + d.extend(b"WAVEfmt "); + d.extend(16u32.to_le_bytes()); + d.extend(1u16.to_le_bytes()); + d.extend(1u16.to_le_bytes()); + d.extend(rate.to_le_bytes()); + d.extend((rate * 2).to_le_bytes()); + d.extend(2u16.to_le_bytes()); + d.extend(16u16.to_le_bytes()); + d.extend(b"data"); + d.extend((n * 2).to_le_bytes()); + d.extend(std::iter::repeat_n(0u8, (n * 2) as usize)); + std::fs::create_dir_all(path.parent().unwrap()).unwrap(); + std::fs::write(path, d).unwrap(); + } + + #[test] + fn hide_restore_and_folder_removal() { + let root = std::env::temp_dir().join(format!("atmo-lib-{}", now())); + std::env::set_var("ATMOSPHERE_DATA_DIR", root.join("data")); + let music = root.join("music"); + let lists = music.join("Playlists"); + wav(&music.join("Album A").join("one.wav"), 2); + wav(&music.join("Album A").join("two.wav"), 3); + wav(&lists.join("Gym").join("one.wav"), 2); + let lib = Library::load(); + assert_eq!(lib.scan(std::slice::from_ref(&music), &lists, |_, _| {}).unwrap(), 3); + let snap = lib.snapshot(&lists); + assert_eq!(snap.playlists.len(), 1); + assert_eq!(snap.playlists[0].order.len(), 1); + let one = snap.tracks.iter().find(|t| t.path.ends_with("one.wav") && t.playlist.is_none()).unwrap().id.clone(); + assert_eq!(lib.hide(std::slice::from_ref(&one)), 1); + assert_eq!(lib.scan(std::slice::from_ref(&music), &lists, |_, _| {}).unwrap(), 2); + assert_eq!(lib.snapshot(&lists).hidden, 1); + assert_eq!(lib.unhide_all(), 1); + assert_eq!(lib.scan(std::slice::from_ref(&music), &lists, |_, _| {}).unwrap(), 3); + assert_eq!(lib.remove_under(&music.join("Album A")), 2); + assert_eq!(lib.snapshot(&lists).tracks.len(), 1); + let _ = std::fs::remove_dir_all(&root); + } + + #[test] + fn playlist_order_roundtrip() { + let dir = std::env::temp_dir().join(format!("atmo-test-{}", now())); + std::fs::create_dir_all(&dir).unwrap(); + write_order(&dir, &["b.mp3".into(), "a.mp3".into()]).unwrap(); + assert_eq!(read_order(&dir), vec!["b.mp3".to_string(), "a.mp3".to_string()]); + let _ = std::fs::remove_dir_all(&dir); + } +} diff --git a/src/lyrics.rs b/src/lyrics.rs new file mode 100644 index 0000000..6cccd55 --- /dev/null +++ b/src/lyrics.rs @@ -0,0 +1,590 @@ +// atmosphere · lyrics.rs · Lyrics lookup across providers (local, LRCLIB, Musixmatch, NetEase, Kugou, custom) with LRC parsing and caching. +use crate::engine::data_dir; +use crate::library::hash; +use crate::settings::Settings; +use anyhow::{anyhow, Result}; +use base64::Engine as _; +use regex::Regex; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::path::Path; +use std::sync::LazyLock; +use std::time::{Duration, SystemTime, UNIX_EPOCH}; + +const CACHE_DAYS: u64 = 14; + +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(rename_all = "camelCase", default)] +pub struct Query { + pub title: String, + pub artist: String, + pub album: String, + pub duration_ms: Option, + pub path: Option, +} + +#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct Word { + pub t: u64, + pub d: u64, + pub text: String, +} + +#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct Line { + pub t: Option, + pub text: String, + pub words: Vec, + pub translation: Option, +} + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Lyrics { + pub provider: String, + pub synced: bool, + pub word_synced: bool, + pub lines: Vec, + pub copyright: Option, + pub instrumental: bool, +} + +#[derive(Clone, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Attempt { + pub provider: String, + pub outcome: String, +} + +#[derive(Clone, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Found { + pub lyrics: Option, + pub tried: Vec, + pub cached: bool, +} + +static JUNK: LazyLock = LazyLock::new(|| { + Regex::new(r"(?i)\s*[\(\[][^)\]]*\b(official|video|audio|lyrics?|visuali[sz]er|music video|mv|m/v|hd|hq|4k|explicit|clean|full song)\b[^)\]]*[\)\]]").unwrap() +}); +static TAIL: LazyLock = LazyLock::new(|| Regex::new(r"(?i)\s*[||/]\s*.*$|\s+(official|lyrics?)\s*(video|audio)?\s*$").unwrap()); + +pub fn clean(q: &Query) -> Query { + let mut title = JUNK.replace_all(q.title.trim(), "").to_string(); + title = TAIL.replace_all(&title, "").trim().to_string(); + let mut artist = q.artist.trim().trim_end_matches(" - Topic").to_string(); + if let Some((a, t)) = title.split_once(" - ").map(|(a, t)| (a.trim().to_string(), t.trim().to_string())) { + let lower_a = a.to_lowercase(); + let related = artist.is_empty() || lower_a.contains(&artist.to_lowercase()) || artist.to_lowercase().contains(&lower_a); + if related && !a.is_empty() && !t.is_empty() { + artist = a; + title = t; + } + } + Query { title: if title.is_empty() { q.title.clone() } else { title }, artist, ..q.clone() } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", default)] +pub struct ProviderCfg { + pub id: String, + pub enabled: bool, +} + +impl Default for ProviderCfg { + fn default() -> Self { + Self { id: String::new(), enabled: true } + } +} + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", default)] +pub struct CustomProvider { + pub id: String, + pub name: String, + pub url: String, + pub headers: String, + pub format: String, + pub json_path: String, + pub key: String, +} + +pub fn default_providers() -> Vec { + [("local", true), ("lrclib", true), ("netease", true), ("musixmatch", false), ("kugou", false)] + .into_iter() + .map(|(id, enabled)| ProviderCfg { id: id.into(), enabled }) + .collect() +} + +static TIME: LazyLock = LazyLock::new(|| Regex::new(r"\[(\d{1,3}):(\d{1,2})(?:[.:](\d{1,3}))?\]").unwrap()); +static WORD: LazyLock = LazyLock::new(|| Regex::new(r"<(\d{1,3}):(\d{1,2})(?:[.:](\d{1,3}))?>([^<]*)").unwrap()); +static OFFSET: LazyLock = LazyLock::new(|| Regex::new(r"(?mi)^\[offset:\s*([+-]?\d+)\]").unwrap()); +static YRC_LINE: LazyLock = LazyLock::new(|| Regex::new(r"^\[(\d+),(\d+)\](.*)$").unwrap()); +static YRC_WORD: LazyLock = LazyLock::new(|| Regex::new(r"\((\d+),(\d+),\d+\)([^(]*)").unwrap()); + +fn ms(m: &str, s: &str, frac: Option<&str>) -> u64 { + let f = frac.map(|f| match f.len() { + 1 => f.parse::().unwrap_or(0) * 100, + 2 => f.parse::().unwrap_or(0) * 10, + _ => f[..3].parse::().unwrap_or(0), + }); + m.parse::().unwrap_or(0) * 60_000 + s.parse::().unwrap_or(0) * 1000 + f.unwrap_or(0) +} + +pub fn parse_lrc(text: &str) -> Vec { + let offset: i64 = OFFSET.captures(text).and_then(|c| c[1].parse().ok()).unwrap_or(0); + let shift = |t: u64| (t as i64 - offset).max(0) as u64; + let mut lines = Vec::new(); + let mut plain = Vec::new(); + for raw in text.lines() { + let stamps: Vec = TIME.captures_iter(raw).map(|c| shift(ms(&c[1], &c[2], c.get(3).map(|m| m.as_str())))).collect(); + let body = TIME.replace_all(raw, "").trim().to_string(); + if stamps.is_empty() { + if !raw.trim().is_empty() && !raw.trim_start().starts_with('[') { + plain.push(Line { t: None, text: raw.trim().to_string(), ..Default::default() }); + } + continue; + } + let mut words: Vec = WORD + .captures_iter(&body) + .map(|c| Word { t: shift(ms(&c[1], &c[2], c.get(3).map(|m| m.as_str()))), d: 0, text: c[4].to_string() }) + .filter(|w| !w.text.is_empty()) + .collect(); + for i in 0..words.len() { + let next = words.get(i + 1).map(|n| n.t); + if let Some(n) = next { + words[i].d = n.saturating_sub(words[i].t); + } + } + let text = if words.is_empty() { body } else { words.iter().map(|w| w.text.as_str()).collect::().trim().to_string() }; + for t in stamps { + lines.push(Line { t: Some(t), text: text.clone(), words: words.clone(), translation: None }); + } + } + if lines.is_empty() { + return plain; + } + lines.sort_by_key(|l| l.t); + lines +} + +pub fn parse_yrc(text: &str) -> Vec { + text.lines() + .filter_map(|l| { + let c = YRC_LINE.captures(l.trim())?; + let words: Vec = YRC_WORD.captures_iter(&c[3]).map(|w| Word { t: w[1].parse().unwrap_or(0), d: w[2].parse().unwrap_or(0), text: w[3].to_string() }).collect(); + let text = words.iter().map(|w| w.text.as_str()).collect::().trim().to_string(); + (!text.is_empty()).then(|| Line { t: c[1].parse().ok(), text, words, translation: None }) + }) + .collect() +} + +fn build(provider: &str, lines: Vec, copyright: Option) -> Option { + let lines: Vec = lines.into_iter().filter(|l| !l.text.trim().is_empty() || l.t.is_some()).collect(); + if lines.iter().all(|l| l.text.trim().is_empty()) { + return None; + } + let synced = lines.iter().any(|l| l.t.is_some()); + let word_synced = lines.iter().any(|l| l.words.len() > 1); + Some(Lyrics { provider: provider.into(), synced, word_synced, lines, copyright, instrumental: false }) +} + +fn norm(s: &str) -> String { + static PAREN: LazyLock = LazyLock::new(|| Regex::new(r"(?i)\s*[\(\[][^)\]]*(feat|ft\.|remaster|version|edit|live|mix)[^)\]]*[\)\]]").unwrap()); + PAREN.replace_all(s, "").to_lowercase().chars().filter(|c| c.is_alphanumeric() || c.is_whitespace()).collect::().split_whitespace().collect::>().join(" ") +} + +fn score(q: &Query, title: &str, artist: &str, duration_ms: Option) -> i64 { + let (qt, qa, t, a) = (norm(&q.title), norm(&q.artist), norm(title), norm(artist)); + let mut s = 0; + if t == qt { + s += 50; + } else if t.contains(&qt) || qt.contains(&t) { + s += 25; + } else { + return -100; + } + if !qa.is_empty() && (a.contains(&qa) || qa.contains(&a) || qa.split(' ').any(|w| w.len() > 2 && a.contains(w))) { + s += 30; + } + if let (Some(x), Some(y)) = (q.duration_ms, duration_ms) { + let diff = (x as i64 - y as i64).abs(); + if diff > 8000 { + return -100; + } + s += 20 - (diff / 500).min(20); + } + s +} + +fn local(q: &Query) -> Option { + let path = Path::new(q.path.as_deref()?); + if let Ok(text) = std::fs::read_to_string(path.with_extension("lrc")) { + if let Some(l) = build("Local .lrc", parse_lrc(&text), None) { + return Some(l); + } + } + let file = lofty::read_from_path(path).ok()?; + use lofty::file::TaggedFileExt; + let tag = file.primary_tag().or_else(|| file.first_tag())?; + let text = tag.get_string(lofty::tag::ItemKey::Lyrics)?; + build("Embedded", parse_lrc(text), None) +} + +async fn get_json(http: &reqwest::Client, url: &str, headers: &[(String, String)]) -> Result { + let mut req = http.get(url).timeout(Duration::from_secs(10)); + for (k, v) in headers { + req = req.header(k.as_str(), v.as_str()); + } + let resp = req.send().await?; + if resp.status().as_u16() == 404 { + return Ok(Value::Null); + } + Ok(resp.error_for_status()?.json().await?) +} + +fn enc(s: &str) -> String { + url::form_urlencoded::byte_serialize(s.as_bytes()).collect() +} + +async fn lrclib(http: &reqwest::Client, q: &Query) -> Result> { + let from = |v: &Value| -> Option { + if v["instrumental"].as_bool() == Some(true) { + return Some(Lyrics { provider: "LRCLIB".into(), instrumental: true, ..Default::default() }); + } + v["syncedLyrics"].as_str().and_then(|s| build("LRCLIB", parse_lrc(s), None)).or_else(|| v["plainLyrics"].as_str().and_then(|s| build("LRCLIB", parse_lrc(s), None))) + }; + let mut url = format!("https://lrclib.net/api/get?track_name={}&artist_name={}", enc(&q.title), enc(&q.artist)); + if !q.album.is_empty() { + url.push_str(&format!("&album_name={}", enc(&q.album))); + } + if let Some(d) = q.duration_ms { + url.push_str(&format!("&duration={}", d / 1000)); + } + let v = get_json(http, &url, &[]).await?; + if let Some(l) = from(&v) { + return Ok(Some(l)); + } + let mut list = get_json(http, &format!("https://lrclib.net/api/search?track_name={}&artist_name={}", enc(&q.title), enc(&q.artist)), &[]).await?; + if list.as_array().is_none_or(|a| a.is_empty()) { + list = get_json(http, &format!("https://lrclib.net/api/search?q={}", enc(&format!("{} {}", q.artist, q.title))), &[]).await?; + } + let best = list.as_array().and_then(|a| { + a.iter() + .map(|v| (score(q, v["trackName"].as_str().unwrap_or(""), v["artistName"].as_str().unwrap_or(""), v["duration"].as_f64().map(|d| (d * 1000.0) as u64)), v)) + .filter(|(s, _)| *s >= 40) + .max_by_key(|(s, v)| (*s, v["syncedLyrics"].is_string() as i64)) + .map(|(_, v)| v.clone()) + }); + Ok(best.as_ref().and_then(from)) +} + +async fn musixmatch(http: &reqwest::Client, q: &Query, key: &str) -> Result> { + if key.trim().is_empty() { + return Ok(None); + } + let base = "https://api.musixmatch.com/ws/1.1"; + let common = format!("q_track={}&q_artist={}&apikey={}", enc(&q.title), enc(&q.artist), enc(key.trim())); + let mut sub = format!("{base}/matcher.subtitle.get?{common}"); + if let Some(d) = q.duration_ms { + sub.push_str(&format!("&f_subtitle_length={}&f_subtitle_length_max_deviation=5", d / 1000)); + } + let v = get_json(http, &sub, &[]).await?; + if v["message"]["header"]["status_code"].as_u64() == Some(401) { + return Err(anyhow!("Musixmatch rejected the API key")); + } + let body = &v["message"]["body"]["subtitle"]; + if let Some(text) = body["subtitle_body"].as_str() { + if let Some(l) = build("Musixmatch", parse_lrc(text), body["lyrics_copyright"].as_str().map(String::from)) { + return Ok(Some(l)); + } + } + let v = get_json(http, &format!("{base}/matcher.lyrics.get?{common}"), &[]).await?; + let body = &v["message"]["body"]["lyrics"]; + if body["instrumental"].as_u64() == Some(1) { + return Ok(Some(Lyrics { provider: "Musixmatch".into(), instrumental: true, ..Default::default() })); + } + let text = body["lyrics_body"].as_str().unwrap_or(""); + let cleaned: String = text.lines().take_while(|l| !l.contains("*******")).collect::>().join("\n"); + Ok(build("Musixmatch", parse_lrc(&cleaned), body["lyrics_copyright"].as_str().map(String::from))) +} + +async fn netease(http: &reqwest::Client, q: &Query) -> Result> { + let search = get_json(http, &format!("https://music.163.com/api/search/get?s={}&type=1&limit=8", enc(&format!("{} {}", q.artist, q.title))), &[]).await?; + let best = search["result"]["songs"].as_array().and_then(|songs| { + songs + .iter() + .map(|s| { + let artist = s["artists"].as_array().map(|a| a.iter().filter_map(|x| x["name"].as_str()).collect::>().join(" ")).unwrap_or_default(); + (score(q, s["name"].as_str().unwrap_or(""), &artist, s["duration"].as_u64()), s["id"].as_u64()) + }) + .filter(|(sc, _)| *sc >= 45) + .max_by_key(|(sc, _)| *sc) + .and_then(|(_, id)| id) + }); + let Some(id) = best else { return Ok(None) }; + let v = get_json(http, &format!("https://music.163.com/api/song/lyric?id={id}&lv=1&tv=-1&yv=1"), &[]).await?; + let mut lines = v["yrc"]["lyric"].as_str().map(parse_yrc).filter(|l| !l.is_empty()).unwrap_or_else(|| v["lrc"]["lyric"].as_str().map(parse_lrc).unwrap_or_default()); + if let Some(tr) = v["tlyric"]["lyric"].as_str().map(parse_lrc) { + for line in lines.iter_mut() { + if let Some(t) = line.t { + line.translation = tr.iter().find(|x| x.t.is_some_and(|xt| xt.abs_diff(t) < 600)).map(|x| x.text.clone()).filter(|s| !s.is_empty()); + } + } + } + Ok(build("NetEase Cloud Music", lines, None)) +} + +async fn kugou(http: &reqwest::Client, q: &Query) -> Result> { + let mut url = format!("https://lyrics.kugou.com/search?ver=1&man=yes&client=pc&keyword={}", enc(&format!("{} - {}", q.artist, q.title))); + if let Some(d) = q.duration_ms { + url.push_str(&format!("&duration={d}")); + } + let v = get_json(http, &url, &[]).await?; + let best = v["candidates"].as_array().and_then(|c| { + c.iter() + .map(|x| (score(q, x["song"].as_str().unwrap_or(""), x["singer"].as_str().unwrap_or(""), x["duration"].as_u64()), x)) + .filter(|(s, _)| *s >= 45) + .max_by_key(|(s, _)| *s) + .map(|(_, x)| x.clone()) + }); + let Some(c) = best else { return Ok(None) }; + let dl = format!( + "https://lyrics.kugou.com/download?ver=1&client=pc&id={}&accesskey={}&fmt=lrc&charset=utf8", + enc(&c["id"].as_str().map(String::from).unwrap_or_else(|| c["id"].to_string())), + enc(c["accesskey"].as_str().unwrap_or("")) + ); + let v = get_json(http, &dl, &[]).await?; + let Some(content) = v["content"].as_str() else { return Ok(None) }; + let bytes = base64::engine::general_purpose::STANDARD.decode(content.trim())?; + Ok(build("Kugou", parse_lrc(&String::from_utf8_lossy(&bytes)), None)) +} + +fn json_path<'a>(v: &'a Value, path: &str) -> Option<&'a Value> { + path.split('.').filter(|p| !p.is_empty()).try_fold(v, |cur, part| match part.parse::() { + Ok(i) => cur.get(i), + Err(_) => cur.get(part), + }) +} + +async fn custom(http: &reqwest::Client, q: &Query, p: &CustomProvider) -> Result> { + if p.url.trim().is_empty() { + return Ok(None); + } + let fill = |s: &str, encode: bool| { + let e = |x: &str| if encode { enc(x) } else { x.to_string() }; + s.replace("{title}", &e(&q.title)) + .replace("{artist}", &e(&q.artist)) + .replace("{album}", &e(&q.album)) + .replace("{duration}", &q.duration_ms.map(|d| (d / 1000).to_string()).unwrap_or_default()) + .replace("{duration_ms}", &q.duration_ms.map(|d| d.to_string()).unwrap_or_default()) + .replace("{key}", &e(&p.key)) + }; + let url = fill(&p.url, true); + let headers: Vec<(String, String)> = p.headers.lines().filter_map(|l| l.split_once(':')).map(|(k, v)| (k.trim().to_string(), fill(v.trim(), false))).collect(); + let name = if p.name.trim().is_empty() { "Custom" } else { p.name.trim() }; + if p.format == "json" { + let v = get_json(http, &url, &headers).await?; + let text = json_path(&v, &p.json_path).and_then(|x| x.as_str()).unwrap_or(""); + return Ok(build(name, parse_lrc(text), None)); + } + let mut req = http.get(&url).timeout(Duration::from_secs(10)); + for (k, v) in &headers { + req = req.header(k.as_str(), v.as_str()); + } + let resp = req.send().await?; + if !resp.status().is_success() { + return Ok(None); + } + Ok(build(name, parse_lrc(&resp.text().await?), None)) +} + +fn cache_key(q: &Query) -> String { + hash(&format!("{}|{}|{}", norm(&q.title), norm(&q.artist), q.duration_ms.map(|d| d / 2000).unwrap_or(0))) +} + +fn cache_path(q: &Query) -> std::path::PathBuf { + data_dir().join("lyrics").join(format!("{}.json", cache_key(q))) +} + +#[derive(Serialize, Deserialize)] +struct Cached { + at: u64, + lyrics: Option, +} + +fn now_s() -> u64 { + SystemTime::now().duration_since(UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0) +} + +pub async fn find(http: &reqwest::Client, settings: &Settings, raw: &Query, refresh: bool) -> Result { + let mut tried = Vec::new(); + if settings.lyrics_providers.iter().any(|p| p.id == "local" && p.enabled) { + if let Some(l) = local(raw) { + return Ok(Found { lyrics: Some(l), tried, cached: false }); + } + tried.push(Attempt { provider: "Your files".into(), outcome: "no .lrc or embedded lyrics".into() }); + } + let q = clean(raw); + let cpath = cache_path(&q); + if !refresh { + if let Some(c) = std::fs::read(&cpath).ok().and_then(|b| serde_json::from_slice::(&b).ok()) { + if c.lyrics.is_some() || now_s().saturating_sub(c.at) < CACHE_DAYS * 86400 { + return Ok(Found { lyrics: c.lyrics, tried, cached: true }); + } + } + } + let mut fallback: Option = None; + let enabled: Vec<&ProviderCfg> = settings.lyrics_providers.iter().filter(|p| p.enabled && p.id != "local").collect(); + for p in &enabled { + let name = match p.id.as_str() { + "lrclib" => "LRCLIB".to_string(), + "musixmatch" => "Musixmatch".to_string(), + "netease" => "NetEase".to_string(), + "kugou" => "Kugou".to_string(), + other => settings.custom_lyrics.iter().find(|c| format!("custom:{}", c.id) == other).map(|c| if c.name.trim().is_empty() { "Custom source".to_string() } else { c.name.clone() }).unwrap_or_else(|| "Custom source".into()), + }; + let result = match p.id.as_str() { + "lrclib" => lrclib(http, &q).await, + "musixmatch" if settings.musixmatch_key.trim().is_empty() => { + tried.push(Attempt { provider: name, outcome: "skipped, no API key".into() }); + continue; + } + "musixmatch" => musixmatch(http, &q, &settings.musixmatch_key).await, + "netease" => netease(http, &q).await, + "kugou" => kugou(http, &q).await, + other => match settings.custom_lyrics.iter().find(|c| format!("custom:{}", c.id) == other) { + Some(c) => custom(http, &q, c).await, + None => Ok(None), + }, + }; + match result { + Ok(Some(l)) if l.synced || l.instrumental => { + tried.push(Attempt { provider: name, outcome: if l.instrumental { "instrumental".into() } else { "found synced lyrics".into() } }); + fallback = Some(l); + break; + } + Ok(Some(l)) => { + tried.push(Attempt { provider: name, outcome: "found unsynced lyrics".into() }); + fallback.get_or_insert(l); + } + Ok(None) => tried.push(Attempt { provider: name, outcome: "not found".into() }), + Err(e) => tried.push(Attempt { provider: name, outcome: format!("unreachable ({})", e.to_string().chars().take(80).collect::()) }), + } + } + let all_failed = !enabled.is_empty() && tried.iter().filter(|t| t.outcome.starts_with("unreachable")).count() == enabled.len(); + if !all_failed { + let _ = std::fs::create_dir_all(cpath.parent().unwrap_or(Path::new("."))); + let _ = std::fs::write(&cpath, serde_json::to_vec(&Cached { at: now_s(), lyrics: fallback.clone() }).unwrap_or_default()); + } + Ok(Found { lyrics: fallback, tried, cached: false }) +} + +pub fn is_timed(text: &str) -> bool { + parse_lrc(text).iter().filter(|l| l.t.is_some()).count() >= 2 +} + +pub fn plain_text(text: &str) -> String { + if !is_timed(text) { + return text.trim().to_string(); + } + parse_lrc(text).into_iter().map(|l| l.text).collect::>().join("\n") +} + +pub fn to_lrc(l: &Lyrics) -> String { + l.lines + .iter() + .map(|line| match line.t { + Some(t) => format!("[{:02}:{:02}.{:02}]{}", t / 60000, (t / 1000) % 60, (t % 1000) / 10, line.text), + None => line.text.clone(), + }) + .collect::>() + .join("\n") +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_lrc_with_offsets_and_repeats() { + let l = parse_lrc("[ar:Nova]\n[offset:+500]\n[00:12.50][01:02.00]Hello there\n[00:05.1]First\n"); + assert_eq!(l.len(), 3); + assert_eq!(l[0].t, Some(4600)); + assert_eq!(l[0].text, "First"); + assert_eq!(l[1].t, Some(12000)); + assert_eq!(l[2].t, Some(61500)); + } + + #[test] + fn parses_enhanced_and_yrc_word_timing() { + let l = parse_lrc("[00:01.00]<00:01.00>Hel<00:01.40>lo <00:02.00>world"); + assert_eq!(l[0].text, "Hello world"); + assert_eq!(l[0].words.len(), 3); + assert_eq!(l[0].words[0].d, 400); + let y = parse_yrc("{\"t\":0,\"c\":[]}\n[1000,2000](1000,500,0)Hi (1500,500,0)you"); + assert_eq!(y.len(), 1); + assert_eq!(y[0].text, "Hi you"); + assert_eq!(y[0].words[1].t, 1500); + } + + #[test] + fn plain_text_stays_unsynced() { + let l = parse_lrc("Line one\nLine two"); + assert_eq!(l.len(), 2); + assert!(l.iter().all(|x| x.t.is_none())); + assert!(build("x", l, None).is_some_and(|b| !b.synced)); + } + + #[test] + fn scores_candidates_sensibly() { + let q = Query { title: "Night Drive (feat. Kai)".into(), artist: "Nova Lumen".into(), duration_ms: Some(200_000), ..Default::default() }; + assert!(score(&q, "Night Drive", "Nova Lumen", Some(201_000)) > 80); + assert!(score(&q, "Night Drive", "Nova Lumen", Some(260_000)) < 0); + assert!(score(&q, "Daylight", "Nova Lumen", Some(200_000)) < 0); + let v: Value = serde_json::json!({"a": {"b": [ {"c": "x"} ]}}); + assert_eq!(json_path(&v, "a.b.0.c").and_then(|x| x.as_str()), Some("x")); + } + + #[test] + fn cleans_video_style_titles() { + let q = |t: &str, a: &str| clean(&Query { title: t.into(), artist: a.into(), ..Default::default() }); + let c = q("Daft Punk - Get Lucky (Official Video)", "Daft Punk"); + assert_eq!((c.artist.as_str(), c.title.as_str()), ("Daft Punk", "Get Lucky")); + let c = q("Night Drive [Lyrics]", "Nova Lumen - Topic"); + assert_eq!((c.artist.as_str(), c.title.as_str()), ("Nova Lumen", "Night Drive")); + let c = q("Ember (Night Edit)", "Kai Rivers"); + assert_eq!(c.title, "Ember (Night Edit)"); + let c = q("Halsey - Without Me | Official Music Video", ""); + assert_eq!((c.artist.as_str(), c.title.as_str()), ("Halsey", "Without Me")); + } + + #[tokio::test] + #[ignore = "hits the network; run with --ignored"] + async fn live_lookup_finds_free_lyrics() { + let http = reqwest::Client::builder().user_agent("atmosphere/0.1").build().unwrap(); + let settings = Settings::default(); + for (title, artist, dur) in [("Daft Punk - Get Lucky (Official Video)", "Daft Punk", 248_000), ("Blinding Lights", "The Weeknd", 200_000)] { + let q = Query { title: title.into(), artist: artist.into(), duration_ms: Some(dur), ..Default::default() }; + let f = find(&http, &settings, &q, true).await.unwrap(); + let l = f.lyrics.as_ref(); + println!("{title}: provider={:?} synced={:?} words={:?} lines={:?} tried={:?}", l.map(|x| &x.provider), l.map(|x| x.synced), l.map(|x| x.word_synced), l.map(|x| x.lines.len()), f.tried.iter().map(|t| format!("{}: {}", t.provider, t.outcome)).collect::>()); + assert!(l.is_some_and(|x| x.synced)); + } + let mut only_netease = Settings::default(); + only_netease.lyrics_providers = vec![ProviderCfg { id: "netease".into(), enabled: true }]; + let q = Query { title: "Get Lucky".into(), artist: "Daft Punk".into(), duration_ms: Some(248_000), ..Default::default() }; + let f = find(&http, &only_netease, &q, true).await.unwrap(); + let l = f.lyrics.as_ref(); + println!("NetEase only: provider={:?} synced={:?} words={:?} lines={:?}", l.map(|x| &x.provider), l.map(|x| x.synced), l.map(|x| x.word_synced), l.map(|x| x.lines.len())); + assert!(l.is_some_and(|x| x.synced)); + } + + #[test] + fn roundtrips_to_lrc() { + let l = build("x", parse_lrc("[01:02.34]Hey"), None).unwrap(); + assert_eq!(to_lrc(&l), "[01:02.34]Hey"); + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..b4289a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,416 @@ +// atmosphere · main.rs · App entry point: shared state, the rights gate and every command the UI can call. +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +mod downloader; +mod engine; +mod history; +mod libcmd; +mod library; +mod lyrics; +mod media; +mod settings; +mod storage; +mod tagging; + +use base64::Engine as _; +use downloader::{Downloader, JobRequest, SaveOptions}; +use history::{History, Record}; +use media::{Collection, Entry, Prober}; +use serde::Serialize; +use settings::{Settings, SettingsPatch, TERMS_VERSION}; +use std::sync::{Arc, Mutex}; +use std::time::Duration; +use tauri::{AppHandle, Emitter, Manager, State}; +use tauri_plugin_clipboard_manager::ClipboardExt; +use tauri_plugin_dialog::DialogExt; +use tauri_plugin_opener::OpenerExt; + +pub(crate) struct AppState { + settings: Arc>, + pub(crate) http: reqwest::Client, + prober: Arc, + dl: Arc, + history: Arc, + pub(crate) library: Arc, + startup_cleanup: Mutex>, +} + +pub(crate) type CmdResult = Result; + +pub(crate) fn err(e: anyhow::Error) -> String { + format!("{e:#}") +} + +impl AppState { + pub(crate) fn snapshot(&self) -> Settings { + self.settings.lock().unwrap().clone() + } + + pub(crate) fn update(&self, f: impl FnOnce(&mut Settings)) -> CmdResult { + let mut s = self.settings.lock().unwrap(); + f(&mut s); + settings::save(&s).map_err(err)?; + Ok(s.clone()) + } + + fn require_rights(&self) -> CmdResult { + let s = self.snapshot(); + if !s.rights_ok() { + return Err("Confirm the rights acknowledgment before using Atmosphere.".into()); + } + Ok(s) + } +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +struct SettingsView { + #[serde(flatten)] + settings: Settings, + rights_accepted: bool, + terms_version: u32, +} + +fn view(s: Settings) -> SettingsView { + SettingsView { rights_accepted: s.rights_ok(), terms_version: TERMS_VERSION, settings: s } +} + +#[tauri::command] +fn get_settings(state: State<'_, AppState>) -> SettingsView { + view(state.snapshot()) +} + +#[tauri::command] +fn accept_rights(state: State<'_, AppState>, version: u32) -> CmdResult { + if version != TERMS_VERSION { + return Err("The acknowledgment has changed. Please review it again.".into()); + } + Ok(view(state.update(Settings::accept_rights)?)) +} + +#[tauri::command] +fn revoke_rights(state: State<'_, AppState>) -> CmdResult { + state.dl.cancel_all(); + Ok(view(state.update(Settings::revoke_rights)?)) +} + +#[tauri::command] +fn save_settings(state: State<'_, AppState>, patch: SettingsPatch) -> CmdResult { + let before = state.snapshot().concurrency; + let after = state.update(|s| s.apply(patch))?; + if after.concurrency != before { + state.dl.set_concurrency(after.concurrency); + } + Ok(view(after)) +} + +#[tauri::command] +async fn tools_status(state: State<'_, AppState>) -> CmdResult { + let s = state.snapshot(); + Ok(engine::status(&s.ytdlp_path, &s.ffmpeg_path).await) +} + +#[derive(Clone, Serialize)] +#[serde(rename_all = "camelCase")] +struct InstallProgress { + tool: String, + received: u64, + total: Option, +} + +#[tauri::command] +async fn install_tool(app: AppHandle, state: State<'_, AppState>, tool: String) -> CmdResult { + let emit = |received: u64, total: Option| { + let _ = app.emit("atmosphere://install", InstallProgress { tool: tool.clone(), received, total }); + }; + match tool.as_str() { + "ytdlp" => engine::install_ytdlp(&state.http, emit).await.map_err(err)?, + "ffmpeg" => engine::install_ffmpeg(&state.http, emit).await.map_err(err)?, + _ => return Err("Unknown tool".into()), + }; + let s = state.snapshot(); + Ok(engine::status(&s.ytdlp_path, &s.ffmpeg_path).await) +} + +#[tauri::command] +async fn update_ytdlp(state: State<'_, AppState>) -> CmdResult { + let s = state.snapshot(); + let tools = engine::locate(&s.ytdlp_path, &s.ffmpeg_path).map_err(err)?; + engine::update_ytdlp(&tools.ytdlp).await.map_err(err) +} + +#[tauri::command] +async fn probe(app: AppHandle, state: State<'_, AppState>, url: String) -> CmdResult { + let s = state.require_rights()?; + state.prober.probe(&app, &s, url.trim()).await.map_err(err) +} + +#[tauri::command] +async fn search(state: State<'_, AppState>, platform: String, query: String) -> CmdResult { + let s = state.require_rights()?; + state.prober.search(&s, &platform, query.trim()).await.map_err(err) +} + +#[tauri::command] +async fn detail(state: State<'_, AppState>, url: String, index: u32) -> CmdResult { + let s = state.require_rights()?; + state.prober.detail(&s, &url, index).await.map_err(err) +} + +#[tauri::command] +fn forget(state: State<'_, AppState>, id: String) { + state.prober.cancel(&id); +} + +#[tauri::command] +fn enqueue(state: State<'_, AppState>, jobs: Vec, save: SaveOptions, attested: bool) -> CmdResult> { + state.require_rights()?; + if !attested { + return Err("Confirm you have the rights to download these items first.".into()); + } + Ok(state.dl.enqueue(jobs, save)) +} + +#[tauri::command] +fn cancel(state: State<'_, AppState>, id: u64) { + state.dl.cancel(id); +} + +#[tauri::command] +fn cancel_all(state: State<'_, AppState>) { + state.dl.cancel_all(); +} + +#[tauri::command] +fn history_list(state: State<'_, AppState>) -> Vec { + state.history.list() +} + +#[tauri::command] +fn history_remove(state: State<'_, AppState>, ids: Vec) { + state.history.remove(&ids); +} + +#[tauri::command] +fn history_clear(state: State<'_, AppState>) { + state.history.clear(); +} + +#[tauri::command] +async fn pick_folder(app: AppHandle, state: State<'_, AppState>) -> CmdResult> { + let start = state.snapshot().output_dir; + let picked = tauri::async_runtime::spawn_blocking(move || { + app.dialog().file().set_directory(start).set_title("Choose where downloads are saved").blocking_pick_folder() + }) + .await + .map_err(|e| e.to_string())?; + Ok(picked.and_then(|p| p.into_path().ok()).map(|p| p.to_string_lossy().into_owned())) +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +struct PickedImage { + path: String, + data_url: String, +} + +#[tauri::command] +async fn pick_image(app: AppHandle) -> CmdResult> { + let picked = tauri::async_runtime::spawn_blocking(move || { + app.dialog().file().set_title("Choose cover art").add_filter("Images", &["jpg", "jpeg", "png"]).blocking_pick_file() + }) + .await + .map_err(|e| e.to_string())?; + let Some(path) = picked.and_then(|p| p.into_path().ok()) else { return Ok(None) }; + let data = tokio::fs::read(&path).await.map_err(|e| e.to_string())?; + if data.len() > 20 * 1024 * 1024 { + return Err("That image is over 20 MB. Pick a smaller cover.".into()); + } + let mime = if data.starts_with(&[0x89, b'P', b'N', b'G']) { + "image/png" + } else if data.starts_with(&[0xFF, 0xD8]) { + "image/jpeg" + } else { + return Err("Cover art must be a JPEG or PNG image.".into()); + }; + let data_url = format!("data:{mime};base64,{}", base64::engine::general_purpose::STANDARD.encode(&data)); + Ok(Some(PickedImage { path: path.to_string_lossy().into_owned(), data_url })) +} + +#[tauri::command] +fn reveal(app: AppHandle, path: String) -> CmdResult<()> { + let p = std::path::PathBuf::from(&path); + let result = if p.is_file() { + app.opener().reveal_item_in_dir(&p) + } else { + std::fs::create_dir_all(&p).map_err(|e| e.to_string())?; + app.opener().open_path(path, None::<&str>) + }; + result.map_err(|e| e.to_string()) +} + +#[tauri::command] +fn open_link(app: AppHandle, url: String) -> CmdResult<()> { + if !url.starts_with("https://") && !url.starts_with("http://") { + return Err("Only web links can be opened.".into()); + } + app.opener().open_url(url, None::<&str>).map_err(|e| e.to_string()) +} + +#[tauri::command] +fn storage_report(state: State<'_, AppState>) -> Vec { + let s = state.snapshot(); + let lib = state.library.snapshot(std::path::Path::new(&s.playlists_dir)); + storage::report(&s, &lib, state.dl.busy()) +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +struct Cleaned { + files: usize, + bytes: u64, +} + +#[tauri::command] +fn storage_clean(state: State<'_, AppState>, ids: Vec) -> Cleaned { + let s = state.snapshot(); + let lib = state.library.snapshot(std::path::Path::new(&s.playlists_dir)); + let (files, bytes) = storage::clean(&s, &lib, &ids, state.dl.busy()); + Cleaned { files, bytes } +} + +#[tauri::command] +fn startup_cleanup(state: State<'_, AppState>) -> Option { + state.startup_cleanup.lock().unwrap().take().filter(|(n, _)| *n > 0).map(|(files, bytes)| Cleaned { files, bytes }) +} + +#[tauri::command] +async fn pick_text_file(app: AppHandle) -> CmdResult> { + let picked = tauri::async_runtime::spawn_blocking(move || { + app.dialog().file().set_title("Import lyrics").add_filter("Lyrics", &["lrc", "txt"]).blocking_pick_file() + }) + .await + .map_err(|e| e.to_string())?; + let Some(path) = picked.and_then(|p| p.into_path().ok()) else { return Ok(None) }; + let data = tokio::fs::read(&path).await.map_err(|e| e.to_string())?; + if data.len() > 1024 * 1024 { + return Err("That file is too large to be lyrics.".into()); + } + Ok(Some(String::from_utf8_lossy(&data).trim_start_matches('\u{feff}').to_string())) +} + +#[tauri::command] +fn clipboard_text(app: AppHandle) -> String { + app.clipboard().read_text().unwrap_or_default() +} + +#[tauri::command] +fn clipboard_write(app: AppHandle, text: String) -> CmdResult<()> { + app.clipboard().write_text(text).map_err(|e| e.to_string()) +} + +#[tauri::command] +fn read_clipboard(app: AppHandle, state: State<'_, AppState>) -> Option { + if !state.snapshot().watch_clipboard { + return None; + } + let text = app.clipboard().read_text().ok()?; + let t = text.trim(); + (t.len() < 2048 && (t.starts_with("https://") || t.starts_with("http://")) && !t.contains(char::is_whitespace)).then(|| t.to_string()) +} + +fn main() { + let settings = Arc::new(Mutex::new(settings::load())); + let http = reqwest::Client::builder() + .user_agent(concat!("atmosphere/", env!("CARGO_PKG_VERSION"))) + .connect_timeout(Duration::from_secs(15)) + .read_timeout(Duration::from_secs(90)) + .build() + .expect("http client"); + + tauri::Builder::default() + .plugin(tauri_plugin_dialog::init()) + .plugin(tauri_plugin_opener::init()) + .plugin(tauri_plugin_clipboard_manager::init()) + .register_asynchronous_uri_scheme_protocol("atmo", |ctx, request, responder| { + let app = ctx.app_handle().clone(); + tauri::async_runtime::spawn_blocking(move || responder.respond(libcmd::serve(&app, &request))); + }) + .setup(move |app| { + let history = Arc::new(History::load(engine::data_dir().join("history.json"))); + let cleaned = storage::startup(&settings.lock().unwrap()); + let library = Arc::new(library::Library::load()); + let dl = Arc::new(Downloader::new(app.handle().clone(), settings.clone(), history.clone(), library.clone(), http.clone())); + app.manage(AppState { settings: settings.clone(), http: http.clone(), prober: Arc::new(Prober::default()), dl, history, library, startup_cleanup: Mutex::new(Some(cleaned)) }); + libcmd::spawn_scan(app.handle().clone()); + libcmd::start_watch(app.handle().clone()); + Ok(()) + }) + .invoke_handler(tauri::generate_handler![ + get_settings, + accept_rights, + revoke_rights, + save_settings, + tools_status, + install_tool, + update_ytdlp, + probe, + search, + detail, + forget, + enqueue, + cancel, + cancel_all, + history_list, + history_remove, + history_clear, + pick_folder, + pick_image, + reveal, + open_link, + read_clipboard, + clipboard_text, + pick_text_file, + clipboard_write, + storage_report, + storage_clean, + startup_cleanup, + libcmd::library_get, + libcmd::library_scan, + libcmd::library_add_folder, + libcmd::library_remove_folder, + libcmd::playlist_create, + libcmd::playlist_rename, + libcmd::playlist_delete, + libcmd::playlist_add, + libcmd::playlist_add_files, + libcmd::playlist_remove, + libcmd::playlist_reorder, + libcmd::track_played, + libcmd::track_listened, + libcmd::app_heartbeat, + libcmd::stats_get, + libcmd::image_save, + libcmd::image_copy, + libcmd::tracks_delete, + libcmd::tracks_hide, + libcmd::tracks_unhide_all, + libcmd::track_like, + libcmd::track_edit, + libcmd::artist_update, + libcmd::lyrics_get, + libcmd::lyrics_save, + libcmd::lyrics_save_text, + libcmd::set_fullscreen + ]) + .build(tauri::generate_context!()) + .expect("error while building atmosphere") + .run(|app, event| { + if let tauri::RunEvent::Exit = event { + if let Some(state) = app.try_state::() { + state.dl.cancel_all(); + } + storage::wipe_temp(); + } + }); +} diff --git a/src/media.rs b/src/media.rs new file mode 100644 index 0000000..4bc9c55 --- /dev/null +++ b/src/media.rs @@ -0,0 +1,675 @@ +// atmosphere · media.rs · Turns links and searches into collections via yt-dlp: metadata, available formats and release-type detection. +use crate::engine::{self, Tools}; +use crate::settings::Settings; +use anyhow::{anyhow, bail, Result}; +use regex::Regex; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::collections::HashMap; +use std::process::Stdio; +use std::sync::{Arc, LazyLock, Mutex}; +use tauri::{AppHandle, Emitter}; +use tokio::io::{AsyncBufReadExt, BufReader}; +use tokio::sync::Notify; + +pub const PROBE_EVENT: &str = "atmosphere://probe"; + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct MediaInfo { + pub has_video: bool, + pub heights: Vec, + pub best_abr: Option, + pub best_codec: Option, + pub lossless: bool, + pub original: bool, + pub original_lossless: bool, + pub original_ext: Option, +} + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", default)] +pub struct Entry { + pub index: u32, + pub id: String, + pub url: String, + pub title: String, + pub artist: String, + pub uploader: String, + pub album: Option, + pub album_artist: Option, + pub track_number: Option, + pub disc_number: Option, + pub genre: Option, + pub composer: Option, + pub release_date: Option, + pub year: Option, + pub duration_ms: Option, + pub thumbnail: Option, + pub license: Option, + pub description: Option, + pub lyrics: Option, + pub platform: String, + pub availability: String, + pub media: Option, + pub detailed: bool, +} + +#[derive(Clone, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Collection { + pub id: String, + pub single: bool, + pub release_type: String, + pub release_type_source: String, + pub title: String, + pub artist: String, + pub url: String, + pub thumbnail: Option, + pub platform: String, + pub year: Option, + pub entries: Vec, + pub enriching: bool, +} + +#[derive(Clone, Debug, Serialize)] +#[serde(rename_all = "camelCase", tag = "type")] +pub enum ProbeEvent { + #[serde(rename_all = "camelCase")] + Entry { collection: String, entry: Box }, + #[serde(rename_all = "camelCase")] + Done { collection: String, release_type: String, release_type_source: String, artist: String, year: Option, failed: u32 }, +} + +#[derive(Default)] +pub struct Prober { + running: Mutex>>, +} + +static NEXT_ID: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1); + +fn s(v: &Value) -> Option { + v.as_str().map(str::trim).filter(|x| !x.is_empty()).map(String::from) +} + +fn joined(v: &Value) -> Option { + let items: Vec = v.as_array()?.iter().filter_map(s).collect(); + (!items.is_empty()).then(|| items.join(", ")) +} + +fn ymd(raw: &str) -> Option { + let d: String = raw.chars().filter(|c| c.is_ascii_digit()).collect(); + match d.len() { + 8 => Some(format!("{}-{}-{}", &d[..4], &d[4..6], &d[6..])), + 4 => Some(d), + _ => None, + } +} + +pub fn platform_name(extractor: &str) -> String { + let e = extractor.to_ascii_lowercase(); + let known = [ + ("soundcloud", "SoundCloud"), + ("youtube", "YouTube"), + ("bandcamp", "Bandcamp"), + ("vimeo", "Vimeo"), + ("twitch", "Twitch"), + ("mixcloud", "Mixcloud"), + ("audiomack", "Audiomack"), + ("tiktok", "TikTok"), + ("twitter", "X"), + ("instagram", "Instagram"), + ("dailymotion", "Dailymotion"), + ("archiveorg", "Internet Archive"), + ("generic", "Web"), + ]; + known + .iter() + .find(|(k, _)| e.starts_with(k)) + .map(|(_, n)| n.to_string()) + .unwrap_or_else(|| extractor.trim_end_matches("IE").to_string()) +} + +fn summarize_formats(v: &Value) -> (MediaInfo, String) { + let mut info = MediaInfo::default(); + let formats = v["formats"].as_array().cloned().unwrap_or_default(); + let usable: Vec<&Value> = formats + .iter() + .filter(|f| !f["has_drm"].as_bool().unwrap_or(false)) + .filter(|f| !s(&f["format_id"]).unwrap_or_default().contains("preview")) + .collect(); + if formats.is_empty() { + let has_v = s(&v["vcodec"]).is_some_and(|c| c != "none"); + info.has_video = has_v; + info.best_abr = v["abr"].as_f64().map(|a| a.round() as u32); + return (info, "ok".into()); + } + if usable.is_empty() { + let drm = formats.iter().any(|f| f["has_drm"].as_bool().unwrap_or(false)); + return (info, if drm { "drm" } else { "preview" }.into()); + } + let lossless_codec = |c: &str| ["flac", "alac", "pcm", "wav", "aiff"].iter().any(|l| c.starts_with(l)); + let mut heights: Vec = Vec::new(); + let mut best: Option<(u32, String)> = None; + for f in &usable { + let vcodec = s(&f["vcodec"]).unwrap_or_else(|| "none".into()); + let acodec = s(&f["acodec"]).unwrap_or_else(|| "none".into()); + let id = s(&f["format_id"]).unwrap_or_default(); + if id == "download" { + info.original = true; + info.original_ext = s(&f["ext"]); + if f["ext"].as_str().is_some_and(|e| ["wav", "flac", "aiff", "aif"].contains(&e)) { + info.original_lossless = true; + } + continue; + } + if vcodec != "none" { + info.has_video = true; + if let Some(h) = f["height"].as_u64() { + if !heights.contains(&(h as u32)) { + heights.push(h as u32); + } + } + } + if acodec != "none" { + if lossless_codec(&acodec) { + info.lossless = true; + } + let abr = f["abr"].as_f64().or_else(|| (vcodec == "none").then(|| f["tbr"].as_f64()).flatten()); + if let Some(a) = abr.map(|a| a.round() as u32) { + if best.as_ref().is_none_or(|(b, _)| a > *b) { + best = Some((a, acodec.split('.').next().unwrap_or(&acodec).to_string())); + } + } + } + } + heights.sort_unstable_by(|a, b| b.cmp(a)); + info.heights = heights; + if let Some((abr, codec)) = best { + info.best_abr = Some(abr); + info.best_codec = Some(codec); + } + (info, "ok".into()) +} + +fn best_thumbnail(v: &Value) -> Option { + if let Some(list) = v["thumbnails"].as_array() { + let pick = list + .iter() + .filter(|t| s(&t["url"]).is_some()) + .max_by_key(|t| (t["preference"].as_i64().unwrap_or(0), t["width"].as_u64().unwrap_or(0))); + if let Some(t) = pick { + return s(&t["url"]); + } + } + s(&v["thumbnail"]) +} + +pub fn entry_from_info(v: &Value, index: u32) -> Entry { + let extractor = s(&v["extractor_key"]).or_else(|| s(&v["ie_key"])).unwrap_or_default(); + let uploader = s(&v["uploader"]).or_else(|| s(&v["channel"])).unwrap_or_default(); + let has_formats = v["formats"].is_array() || v["vcodec"].is_string() || v["acodec"].is_string(); + let (media, mut availability) = if has_formats { + let (m, a) = summarize_formats(v); + (Some(m), a) + } else { + (None, "ok".into()) + }; + if let Some(a) = s(&v["availability"]) { + if matches!(a.as_str(), "needs_auth" | "premium_only" | "subscriber_only") && availability == "ok" { + availability = "restricted".into(); + } + } + let (desc_lyrics, desc_rest) = s(&v["description"]).map(|d| split_lyrics(&d)).unwrap_or((None, None)); + let release_date = s(&v["release_date"]).and_then(|d| ymd(&d)).or_else(|| s(&v["upload_date"]).and_then(|d| ymd(&d))); + let year = v["release_year"] + .as_u64() + .map(|y| y as u16) + .or_else(|| release_date.as_deref().and_then(|d| d.get(..4)?.parse().ok())); + Entry { + index, + id: s(&v["id"]).unwrap_or_default(), + url: s(&v["webpage_url"]).or_else(|| s(&v["original_url"])).or_else(|| s(&v["url"])).unwrap_or_default(), + title: s(&v["track"]).or_else(|| s(&v["title"])).unwrap_or_else(|| "Untitled".into()), + artist: s(&v["artist"]) + .or_else(|| joined(&v["artists"])) + .or_else(|| s(&v["creator"])) + .unwrap_or_else(|| uploader.clone()), + uploader, + album: s(&v["album"]), + album_artist: s(&v["album_artist"]).or_else(|| joined(&v["album_artists"])), + track_number: v["track_number"].as_u64().map(|n| n as u32), + disc_number: v["disc_number"].as_u64().map(|n| n as u32), + genre: s(&v["genre"]).or_else(|| joined(&v["genres"])), + composer: s(&v["composer"]).or_else(|| joined(&v["composers"])), + release_date, + year, + duration_ms: v["duration"].as_f64().map(|d| (d * 1000.0) as u64), + thumbnail: best_thumbnail(v), + license: s(&v["license"]), + description: desc_rest, + lyrics: desc_lyrics, + platform: platform_name(&extractor), + availability, + detailed: has_formats, + media, + } +} + +static LYRIC_HEAD: LazyLock = LazyLock::new(|| Regex::new(r"(?i)^\s*[\[\(]?\s*(lyrics|lyric|letra|letras|paroles|songtext|testo|歌词|歌詞|가사)\s*[\]\)]?\s*[::\-–—]?\s*(.*)$").unwrap()); +static SECTION: LazyLock = LazyLock::new(|| Regex::new(r"(?i)^\s*[\[\(]\s*(verse|chorus|hook|bridge|intro|outro|pre-chorus|refrain|interlude|breakdown|drop)[^\]\)]*[\]\)]\s*$").unwrap()); +static END: LazyLock = LazyLock::new(|| Regex::new(r"(?i)^\s*(prod\.?|produced|producer|mixed|mix(ing)?\s*(&|and)?\s*master|mastered|mastering|engineered|artwork|cover art|art by|written by|composed|credits?|follow|stream|download|free download|buy|out now|available|booking|contact|management|label|instagram|insta|ig\b|twitter|tiktok|spotify|apple music|youtube|bandcamp|soundcloud|support|thanks|©|℗|copyright|\(c\)|https?://|www\.|@\w)").unwrap()); +static LRC_LINE: LazyLock = LazyLock::new(|| Regex::new(r"^\s*\[\d{1,3}:\d{1,2}(?:[.:]\d{1,3})?\]").unwrap()); + +fn tidy(lines: &[&str]) -> Option { + let text = lines.join("\n").trim_matches(|c: char| c == '\n' || c.is_whitespace()).to_string(); + let words = text.split_whitespace().count(); + (words >= 12).then_some(text) +} + +pub fn split_lyrics(desc: &str) -> (Option, Option) { + let lines: Vec<&str> = desc.lines().collect(); + let rest_of = |skip: std::ops::Range| { + let r: Vec<&str> = lines.iter().enumerate().filter(|(i, _)| !skip.contains(i)).map(|(_, l)| *l).collect(); + let t = r.join("\n").trim().to_string(); + (!t.is_empty()).then_some(t) + }; + let timed: Vec = lines.iter().enumerate().filter(|(_, l)| LRC_LINE.is_match(l)).map(|(i, _)| i).collect(); + if timed.len() >= 4 { + let (a, b) = (timed[0], timed[timed.len() - 1] + 1); + if let Some(l) = tidy(&lines[a..b]) { + return (Some(l), rest_of(a..b)); + } + } + if let Some(start) = lines.iter().position(|l| LYRIC_HEAD.is_match(l)) { + let inline = LYRIC_HEAD.captures(lines[start]).and_then(|c| c.get(2)).map(|m| m.as_str().trim()).filter(|s| !s.is_empty()); + let mut end = start + 1; + let mut blank_run = 0; + while end < lines.len() { + let l = lines[end].trim(); + if END.is_match(l) { + break; + } + blank_run = if l.is_empty() { blank_run + 1 } else { 0 }; + if blank_run >= 3 { + break; + } + end += 1; + } + let mut body: Vec<&str> = Vec::new(); + if let Some(i) = inline { + body.push(i); + } + body.extend_from_slice(&lines[start + 1..end]); + if let Some(l) = tidy(&body) { + return (Some(l), rest_of(start..end)); + } + } + let sections = lines.iter().filter(|l| SECTION.is_match(l)).count(); + if sections >= 2 { + let first = lines.iter().position(|l| SECTION.is_match(l)).unwrap_or(0); + let mut end = first; + while end < lines.len() && !END.is_match(lines[end].trim()) { + end += 1; + } + if let Some(l) = tidy(&lines[first..end]) { + return (Some(l), rest_of(first..end)); + } + } + let t = desc.trim(); + (None, (!t.is_empty()).then(|| t.chars().take(4000).collect())) +} + +fn common(entries: &[Entry], f: impl Fn(&Entry) -> Option) -> Option { + let first = f(entries.first()?)?; + entries.iter().all(|e| f(e).as_ref() == Some(&first)).then_some(first) +} + +fn by_length(entries: &[Entry]) -> &'static str { + let minutes = entries.iter().filter_map(|e| e.duration_ms).sum::() as f64 / 60000.0; + match entries.len() { + n if n <= 3 && minutes < 30.0 => "single", + n if n <= 6 && minutes < 30.0 => "ep", + _ => "album", + } +} + +static TITLE_RULES: LazyLock> = LazyLock::new(|| { + [ + (r"(?i)\b(compilation|various artists|v\.?a\.?)\b", "compilation"), + (r"(?i)\bmix ?tape\b", "mixtape"), + (r"(?i)\be\.?p\.?\b", "ep"), + (r"(?i)\bl\.?p\.?\b", "lp"), + (r"(?i)\bsingle\b", "single"), + (r"(?i)\b(deluxe|album|remaster(ed)?|anniversary edition)\b", "album"), + ] + .into_iter() + .map(|(p, k)| (Regex::new(p).unwrap(), k)) + .collect() +}); + +pub fn classify(extractor: &str, playlist_id: &str, url: &str, title: &str, entries: &[Entry]) -> (String, String) { + let ex = extractor.to_ascii_lowercase(); + if ex.contains("soundclouduser") || ex.contains("soundcloud:user") { + return ("profile".into(), "platform".into()); + } + if ex.starts_with("youtubetab") && (playlist_id.starts_with("UC") || url.contains("/@") || url.contains("/channel/")) { + return ("channel".into(), "platform".into()); + } + for (re, kind) in TITLE_RULES.iter() { + if re.is_match(title) { + return ((*kind).into(), "title".into()); + } + } + if ex.starts_with("bandcampalbum") || ex == "bandcamp:album" || playlist_id.starts_with("OLAK5uy_") { + return (by_length(entries).into(), "platform".into()); + } + let norm = |x: &str| x.trim().to_lowercase(); + let shared_album = common(entries, |e| e.album.as_deref().map(norm)); + let one_artist = common(entries, |e| Some(e.artist.to_lowercase())).is_some(); + let numbered = entries.len() > 1 && entries.iter().enumerate().all(|(i, e)| e.track_number == Some(i as u32 + 1)); + if shared_album.as_deref().is_some_and(|a| a == norm(title)) || (shared_album.is_some() && one_artist) || (numbered && one_artist) { + return (by_length(entries).into(), "metadata".into()); + } + ("playlist".into(), "none".into()) +} + +fn release_artist(kind: &str, fallback: &str, entries: &[Entry]) -> String { + if let Some(a) = common(entries, |e| e.album_artist.clone()) { + return a; + } + if let Some(a) = common(entries, |e| Some(e.artist.clone())) { + return a; + } + if kind == "compilation" { + return "Various Artists".into(); + } + fallback.to_string() +} + +pub fn humanize(stderr: &str) -> String { + let err = stderr + .lines() + .rev() + .find(|l| l.contains("ERROR")) + .map(|l| l.trim().trim_start_matches("ERROR:").trim().to_string()) + .unwrap_or_else(|| stderr.lines().last().unwrap_or("Unknown error").trim().to_string()); + let lower = err.to_lowercase(); + if lower.contains("unsupported url") { + "Atmosphere can't read that link. The site isn't supported.".into() + } else if lower.contains("drm") { + "This stream is DRM-encrypted, so Atmosphere can't read it. If it's your own track, turn on downloads for it in the platform's track settings (or enable “Use my browser sign-in”), then choose Original file to get your uploaded master.".into() + } else if lower.contains("sign in") || lower.contains("private") || lower.contains("login") || lower.contains("members-only") { + format!("{err} — if this is your own content, enable “Use my browser sign-in” in Settings.") + } else if lower.contains("404") || lower.contains("not found") || lower.contains("does not exist") { + "Not found — the link may be private, removed or mistyped.".into() + } else if lower.contains("429") || lower.contains("too many requests") { + "The site is rate-limiting requests. Wait a bit and try again.".into() + } else { + static PREFIX: LazyLock = LazyLock::new(|| Regex::new(r"^\[[^\]]+\]\s*(\S+:\s+)?").unwrap()); + let cleaned = PREFIX.replace(&err, "").trim().chars().take(300).collect::(); + if cleaned.is_empty() { err } else { cleaned } + } +} + +pub fn base_args(settings: &Settings, tools: &Tools) -> Vec { + let mut args: Vec = ["--ignore-config", "--no-warnings", "--encoding", "utf-8", "--no-color"].map(String::from).into(); + if let Some(ff) = &tools.ffmpeg { + args.push("--ffmpeg-location".into()); + args.push(ff.to_string_lossy().into_owned()); + } + if !settings.cookies_browser.trim().is_empty() { + args.push("--cookies-from-browser".into()); + args.push(settings.cookies_browser.trim().into()); + } + if !settings.proxy.trim().is_empty() { + args.push("--proxy".into()); + args.push(settings.proxy.trim().into()); + } + args +} + +async fn run_json(tools: &Tools, args: Vec) -> Result { + let out = engine::command(&tools.ytdlp).args(&args).stdout(Stdio::piped()).stderr(Stdio::piped()).output().await?; + if !out.status.success() || out.stdout.is_empty() { + bail!(humanize(&String::from_utf8_lossy(&out.stderr))); + } + serde_json::from_slice(&out.stdout).map_err(|e| anyhow!("Unexpected response from yt-dlp ({e})")) +} + +fn collection_from(v: &Value, id: String, link: &str) -> Collection { + let extractor = s(&v["extractor_key"]).unwrap_or_default(); + let is_list = matches!(v["_type"].as_str(), Some("playlist") | Some("multi_video")); + if !is_list { + let entry = entry_from_info(v, 1); + return Collection { + id, + single: true, + release_type: "track".into(), + release_type_source: "none".into(), + title: entry.title.clone(), + artist: entry.artist.clone(), + url: entry.url.clone(), + thumbnail: entry.thumbnail.clone(), + platform: entry.platform.clone(), + year: entry.year, + entries: vec![entry], + enriching: false, + }; + } + let entries: Vec = v["entries"] + .as_array() + .map(|list| { + list.iter() + .enumerate() + .filter(|(_, e)| !e.is_null()) + .map(|(i, e)| { + let mut entry = entry_from_info(e, i as u32 + 1); + if entry.platform.is_empty() { + entry.platform = platform_name(&extractor); + } + entry + }) + .collect() + }) + .unwrap_or_default(); + let title = s(&v["title"]).unwrap_or_else(|| "Untitled".into()); + let pid = s(&v["id"]).unwrap_or_default(); + let url = s(&v["webpage_url"]).unwrap_or_else(|| link.to_string()); + let (release_type, source) = classify(&extractor, &pid, &url, &title, &entries); + let owner = s(&v["uploader"]).or_else(|| s(&v["channel"])).unwrap_or_default(); + let artist = release_artist(&release_type, &owner, &entries); + let thumbnail = best_thumbnail(v).or_else(|| entries.iter().find_map(|e| e.thumbnail.clone())); + let needs_detail = entries.iter().any(|e| !e.detailed); + Collection { + id, + single: false, + release_type, + release_type_source: source, + title, + artist, + url, + thumbnail, + platform: platform_name(&extractor), + year: v["release_year"].as_u64().map(|y| y as u16).or_else(|| entries.iter().find_map(|e| e.year)), + entries, + enriching: needs_detail, + } +} + +impl Prober { + pub async fn probe(self: &Arc, app: &AppHandle, settings: &Settings, link: &str) -> Result { + let tools = engine::locate(&settings.ytdlp_path, &settings.ffmpeg_path)?; + let mut args = base_args(settings, &tools); + args.extend(["-J", "--flat-playlist", "--", link].map(String::from)); + let v = run_json(&tools, args).await?; + let id = format!("c{}", NEXT_ID.fetch_add(1, std::sync::atomic::Ordering::SeqCst)); + let collection = collection_from(&v, id.clone(), link); + if collection.enriching { + self.enrich(app.clone(), settings.clone(), tools, collection.clone(), v); + } + Ok(collection) + } + + pub async fn search(&self, settings: &Settings, platform: &str, query: &str) -> Result { + let tools = engine::locate(&settings.ytdlp_path, &settings.ffmpeg_path)?; + let prefix = match platform { + "soundcloud" => "scsearch20", + _ => "ytsearch20", + }; + let mut args = base_args(settings, &tools); + args.extend(["-J".into(), "--flat-playlist".into(), "--".into(), format!("{prefix}:{query}")]); + let v = run_json(&tools, args).await?; + let id = format!("s{}", NEXT_ID.fetch_add(1, std::sync::atomic::Ordering::SeqCst)); + let mut c = collection_from(&v, id, query); + c.release_type = "search".into(); + c.release_type_source = "none".into(); + c.title = query.to_string(); + c.enriching = false; + Ok(c) + } + + pub async fn detail(&self, settings: &Settings, url: &str, index: u32) -> Result { + let tools = engine::locate(&settings.ytdlp_path, &settings.ffmpeg_path)?; + let mut args = base_args(settings, &tools); + args.extend(["-J", "--no-playlist", "--", url].map(String::from)); + Ok(entry_from_info(&run_json(&tools, args).await?, index)) + } + + pub fn cancel(&self, id: &str) { + if let Some(n) = self.running.lock().unwrap().remove(id) { + n.notify_one(); + } + } + + fn enrich(self: &Arc, app: AppHandle, settings: Settings, tools: Tools, collection: Collection, raw: Value) { + let stop = Arc::new(Notify::new()); + self.running.lock().unwrap().insert(collection.id.clone(), stop.clone()); + let this = self.clone(); + tauri::async_runtime::spawn(async move { + let mut args = base_args(&settings, &tools); + args.extend(["-j", "--ignore-errors", "--yes-playlist", "--", &collection.url].map(String::from)); + let mut entries = collection.entries.clone(); + let mut failed = 0u32; + let spawned = engine::command(&tools.ytdlp).args(&args).stdout(Stdio::piped()).stderr(Stdio::null()).kill_on_drop(true).spawn(); + if let Ok(mut child) = spawned { + if let Some(stdout) = child.stdout.take() { + let mut lines = BufReader::new(stdout).lines(); + loop { + tokio::select! { + _ = stop.notified() => { let _ = child.kill().await; return; } + line = lines.next_line() => { + let Ok(Some(line)) = line else { break }; + let Ok(v) = serde_json::from_str::(&line) else { continue }; + let idx = v["playlist_index"].as_u64().map(|i| i as u32); + let vid = s(&v["id"]).unwrap_or_default(); + let slot = entries.iter().position(|e| Some(e.index) == idx).or_else(|| entries.iter().position(|e| e.id == vid)); + if let Some(pos) = slot { + let entry = entry_from_info(&v, entries[pos].index); + entries[pos] = entry.clone(); + let _ = app.emit(PROBE_EVENT, ProbeEvent::Entry { collection: collection.id.clone(), entry: Box::new(entry) }); + } + } + } + } + } + let _ = child.wait().await; + } + failed += entries.iter().filter(|e| !e.detailed).count() as u32; + let extractor = s(&raw["extractor_key"]).unwrap_or_default(); + let pid = s(&raw["id"]).unwrap_or_default(); + let (release_type, source) = classify(&extractor, &pid, &collection.url, &collection.title, &entries); + let owner = s(&raw["uploader"]).or_else(|| s(&raw["channel"])).unwrap_or_default(); + let artist = release_artist(&release_type, &owner, &entries); + let year = entries.iter().find_map(|e| e.year); + let _ = app.emit( + PROBE_EVENT, + ProbeEvent::Done { collection: collection.id.clone(), release_type, release_type_source: source, artist, year, failed }, + ); + this.running.lock().unwrap().remove(&collection.id); + }); + } +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + + fn e(artist: &str, album: Option<&str>, mins: u64, n: Option) -> Entry { + Entry { + artist: artist.into(), + album: album.map(String::from), + duration_ms: Some(mins * 60000), + track_number: n, + ..Default::default() + } + } + + #[test] + fn classifies_by_title_platform_and_metadata() { + let five: Vec<_> = (0..5).map(|i| e("Nova", Some("Glass"), 4, Some(i + 1))).collect(); + assert_eq!(classify("SoundcloudSet", "1", "", "Glass", &five), ("ep".into(), "metadata".into())); + let ten: Vec<_> = (0..10).map(|i| e("Nova", Some("Glass"), 4, Some(i + 1))).collect(); + assert_eq!(classify("SoundcloudSet", "1", "", "Glass", &ten).0, "album"); + assert_eq!(classify("SoundcloudSet", "1", "", "Midnight Drive EP", &ten), ("ep".into(), "title".into())); + assert_eq!(classify("SoundcloudSet", "1", "", "Sunset LP", &ten).0, "lp"); + assert_eq!(classify("SoundcloudSet", "1", "", "Summer Mixtape 2024", &ten).0, "mixtape"); + assert_eq!(classify("BandcampAlbum", "1", "", "Glass", &ten), ("album".into(), "platform".into())); + assert_eq!(classify("SoundcloudUser", "1", "", "Nova", &ten).0, "profile"); + let mixed = vec![e("A", None, 3, None), e("B", None, 3, None)]; + assert_eq!(classify("SoundcloudSet", "1", "", "Faves", &mixed).0, "playlist"); + assert_eq!(classify("SoundcloudSet", "1", "", "Help", &mixed).0, "playlist"); + assert_eq!(release_artist("compilation", "owner", &mixed), "Various Artists"); + } + + #[test] + fn summarizes_formats_honestly() { + let v = json!({ + "id": "1", "title": "Song", "extractor_key": "Soundcloud", "webpage_url": "https://soundcloud.com/a/b", + "upload_date": "20210314", "duration": 200.5, + "formats": [ + {"format_id": "hls_mp3_1_0", "acodec": "mp3", "vcodec": "none", "abr": 128, "ext": "mp3"}, + {"format_id": "hls_aac_160k", "acodec": "aac", "vcodec": "none", "abr": 160, "ext": "m4a"}, + {"format_id": "download", "ext": "wav", "acodec": "none", "vcodec": "none"}, + {"format_id": "x", "acodec": "aac", "vcodec": "none", "abr": 256, "has_drm": true} + ] + }); + let entry = entry_from_info(&v, 1); + let m = entry.media.unwrap(); + assert_eq!(m.best_abr, Some(160)); + assert!(m.original && m.original_lossless && !m.lossless && !m.has_video); + assert_eq!(entry.release_date.as_deref(), Some("2021-03-14")); + assert_eq!(entry.platform, "SoundCloud"); + assert_eq!(entry.duration_ms, Some(200500)); + let drm = entry_from_info(&json!({"formats": [{"format_id": "a", "has_drm": true}]}), 1); + assert_eq!(drm.availability, "drm"); + } + + #[test] + fn splits_lyrics_from_descriptions() { + let d = "New single out now!\n\nLyrics:\nHeadlights on the overpass\nEvery window holds a star\n\nWe don't need to say it twice\nNight drive keep the city close\n\nProd. by Kai Rivers\nInstagram: @novalumen\nhttps://example.com"; + let (l, rest) = split_lyrics(d); + let l = l.unwrap(); + assert!(l.starts_with("Headlights") && l.ends_with("city close")); + let rest = rest.unwrap(); + assert!(rest.contains("out now") && rest.contains("Prod. by") && !rest.contains("Headlights")); + let timed = "Stream everywhere\n[00:01.00]One two three four\n[00:04.00]Five six seven eight\n[00:08.00]Nine ten eleven twelve\n[00:12.00]Thirteen fourteen fifteen"; + let (l, rest) = split_lyrics(timed); + assert!(l.unwrap().starts_with("[00:01.00]")); + assert_eq!(rest.as_deref(), Some("Stream everywhere")); + let sections = "[Verse 1]\nI walk the line between the night and day\nCount the lights along the way\n[Chorus]\nHold on hold on we're nearly home\nHold on we're not alone\nFollow me on twitter"; + let (l, _) = split_lyrics(sections); + assert!(l.unwrap().contains("[Chorus]")); + let promo = "Free download! Mixed and mastered by me. Thanks for 10k plays"; + let (l, rest) = split_lyrics(promo); + assert!(l.is_none()); + assert_eq!(rest.as_deref(), Some(promo)); + } + + #[test] + fn humanizes_errors() { + assert!(humanize("ERROR: Unsupported URL: https://x").contains("isn't supported")); + assert!(humanize("ERROR: [youtube] abc: Private video. Sign in").contains("browser sign-in")); + } +} diff --git a/src/settings.rs b/src/settings.rs new file mode 100644 index 0000000..5fc9e1e --- /dev/null +++ b/src/settings.rs @@ -0,0 +1,264 @@ +// atmosphere · settings.rs · Persistent user settings: rights acknowledgment, save-as defaults, engine paths and network options. +use crate::lyrics::{default_providers, CustomProvider, ProviderCfg}; +use anyhow::{Context, Result}; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; +use std::time::{SystemTime, UNIX_EPOCH}; + +pub const TERMS_VERSION: u32 = 1; +pub const MP3_BITRATES: [u32; 7] = [64, 96, 128, 160, 192, 256, 320]; + +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum SaveAs { + Original, + #[default] + Best, + Mp3, + M4a, + Flac, + Wav, + Video, +} + +impl SaveAs { + pub fn audio_format(self) -> Option<&'static str> { + match self { + SaveAs::Mp3 => Some("mp3"), + SaveAs::M4a => Some("m4a"), + SaveAs::Flac => Some("flac"), + SaveAs::Wav => Some("wav"), + _ => None, + } + } +} + +pub fn snap_bitrate(requested: u32, cap: Option) -> u32 { + let limit = cap.map_or(requested, |c| requested.min(c)); + MP3_BITRATES.iter().copied().filter(|b| *b <= limit).max().unwrap_or(MP3_BITRATES[0]) +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase", default)] +pub struct Settings { + pub rights_version: u32, + pub rights_accepted_at: Option, + pub output_dir: String, + pub save_as: SaveAs, + pub mp3_bitrate: u32, + pub video_height: u32, + pub video_container: String, + pub concurrency: u8, + pub filename_template: String, + pub embed_metadata: bool, + pub collection_folders: bool, + pub number_tracks: bool, + pub skip_downloaded: bool, + pub sponsorblock: bool, + pub embed_subtitles: bool, + pub subtitle_langs: String, + pub embed_chapters: bool, + pub cookies_browser: String, + pub proxy: String, + pub rate_limit: String, + pub ytdlp_path: String, + pub ffmpeg_path: String, + pub watch_clipboard: bool, + pub theme: String, + pub library_folders: Vec, + pub playlists_dir: String, + pub playlist_copy: bool, + pub lyrics_providers: Vec, + pub musixmatch_key: String, + pub custom_lyrics: Vec, + pub lyrics_on_download: bool, + pub fx_presets: Vec, +} + +impl Default for Settings { + fn default() -> Self { + let base = dirs::audio_dir().or_else(dirs::download_dir).unwrap_or_else(|| PathBuf::from(".")); + let out = base.join("Atmosphere"); + Self { + rights_version: 0, + rights_accepted_at: None, + output_dir: out.to_string_lossy().into_owned(), + save_as: SaveAs::Best, + mp3_bitrate: 320, + video_height: 1080, + video_container: "mp4".into(), + concurrency: 3, + filename_template: "{artist} - {title}".into(), + embed_metadata: true, + collection_folders: true, + number_tracks: true, + skip_downloaded: true, + sponsorblock: false, + embed_subtitles: false, + subtitle_langs: "en".into(), + embed_chapters: true, + cookies_browser: String::new(), + proxy: String::new(), + rate_limit: String::new(), + ytdlp_path: String::new(), + ffmpeg_path: String::new(), + watch_clipboard: true, + theme: "system".into(), + library_folders: vec![out.to_string_lossy().into_owned()], + playlists_dir: out.join("Playlists").to_string_lossy().into_owned(), + playlist_copy: false, + lyrics_providers: default_providers(), + musixmatch_key: String::new(), + custom_lyrics: Vec::new(), + lyrics_on_download: false, + fx_presets: Vec::new(), + } + } +} + +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(rename_all = "camelCase", default)] +pub struct SettingsPatch { + pub output_dir: Option, + pub save_as: Option, + pub mp3_bitrate: Option, + pub video_height: Option, + pub video_container: Option, + pub concurrency: Option, + pub filename_template: Option, + pub embed_metadata: Option, + pub collection_folders: Option, + pub number_tracks: Option, + pub skip_downloaded: Option, + pub sponsorblock: Option, + pub embed_subtitles: Option, + pub subtitle_langs: Option, + pub embed_chapters: Option, + pub cookies_browser: Option, + pub proxy: Option, + pub rate_limit: Option, + pub ytdlp_path: Option, + pub ffmpeg_path: Option, + pub watch_clipboard: Option, + pub theme: Option, + pub library_folders: Option>, + pub playlists_dir: Option, + pub playlist_copy: Option, + pub lyrics_providers: Option>, + pub musixmatch_key: Option, + pub custom_lyrics: Option>, + pub lyrics_on_download: Option, + pub fx_presets: Option>, +} + +impl Settings { + pub fn rights_ok(&self) -> bool { + self.rights_version == TERMS_VERSION + } + + pub fn accept_rights(&mut self) { + self.rights_version = TERMS_VERSION; + self.rights_accepted_at = SystemTime::now().duration_since(UNIX_EPOCH).ok().map(|d| d.as_secs()); + } + + pub fn revoke_rights(&mut self) { + self.rights_version = 0; + self.rights_accepted_at = None; + } + + pub fn apply(&mut self, p: SettingsPatch) { + macro_rules! set { + ($($f:ident),*) => { $( if let Some(v) = p.$f { self.$f = v; } )* }; + } + set!(save_as, embed_metadata, collection_folders, number_tracks, skip_downloaded, sponsorblock, embed_subtitles, embed_chapters, watch_clipboard); + set!(cookies_browser, proxy, rate_limit, ytdlp_path, ffmpeg_path, subtitle_langs, musixmatch_key, playlist_copy, lyrics_on_download, custom_lyrics, fx_presets); + if let Some(v) = p.library_folders { + let mut seen = std::collections::HashSet::new(); + self.library_folders = v.into_iter().map(|f| f.trim().to_string()).filter(|f| !f.is_empty() && seen.insert(f.clone())).collect(); + } + if let Some(v) = p.playlists_dir.filter(|v| !v.trim().is_empty()) { + self.playlists_dir = v; + } + if let Some(mut v) = p.lyrics_providers { + for d in default_providers() { + if !v.iter().any(|x| x.id == d.id) { + v.push(d); + } + } + self.lyrics_providers = v; + } + if let Some(v) = p.output_dir.filter(|v| !v.trim().is_empty()) { + self.output_dir = v; + } + if let Some(v) = p.mp3_bitrate { + self.mp3_bitrate = snap_bitrate(v, None); + } + if let Some(v) = p.video_height { + self.video_height = v; + } + if let Some(v) = p.video_container.filter(|v| matches!(v.as_str(), "mp4" | "mkv" | "webm")) { + self.video_container = v; + } + if let Some(v) = p.concurrency { + self.concurrency = v.clamp(1, 8); + } + if let Some(v) = p.filename_template { + self.filename_template = if v.trim().is_empty() { Settings::default().filename_template } else { v }; + } + if let Some(v) = p.theme.filter(|v| matches!(v.as_str(), "system" | "light" | "dark")) { + self.theme = v; + } + } +} + +fn path() -> PathBuf { + match crate::engine::portable_root() { + Some(root) => root.join("settings.json"), + None => dirs::config_dir().unwrap_or_else(|| PathBuf::from(".")).join("atmosphere").join("settings.json"), + } +} + +pub fn load() -> Settings { + let mut s: Settings = std::fs::read_to_string(path()).ok().and_then(|s| serde_json::from_str(&s).ok()).unwrap_or_default(); + for d in default_providers() { + if !s.lyrics_providers.iter().any(|x| x.id == d.id) { + s.lyrics_providers.push(d); + } + } + if s.library_folders.is_empty() { + s.library_folders.push(s.output_dir.clone()); + } + s +} + +pub fn save(s: &Settings) -> Result<()> { + let p = path(); + if let Some(dir) = p.parent() { + std::fs::create_dir_all(dir)?; + } + let tmp = p.with_extension("json.tmp"); + std::fs::write(&tmp, serde_json::to_vec_pretty(s)?)?; + std::fs::rename(&tmp, &p).context("Couldn't save settings") +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn snaps_bitrates_to_source() { + assert_eq!(snap_bitrate(320, Some(160)), 160); + assert_eq!(snap_bitrate(320, Some(150)), 128); + assert_eq!(snap_bitrate(192, None), 192); + assert_eq!(snap_bitrate(320, Some(40)), 64); + } + + #[test] + fn applies_patches_safely() { + let mut s = Settings::default(); + s.apply(SettingsPatch { concurrency: Some(40), theme: Some("neon".into()), mp3_bitrate: Some(200), ..Default::default() }); + assert_eq!(s.concurrency, 8); + assert_eq!(s.theme, "system"); + assert_eq!(s.mp3_bitrate, 192); + } +} diff --git a/src/storage.rs b/src/storage.rs new file mode 100644 index 0000000..aba964d --- /dev/null +++ b/src/storage.rs @@ -0,0 +1,144 @@ +// atmosphere · storage.rs · Temp-file hygiene: startup and exit cleanup, stalled partial downloads, orphaned caches and the Storage report. +use crate::engine::{bin_dir, data_dir, temp_root}; +use crate::library::Snapshot; +use crate::settings::Settings; +use serde::Serialize; +use std::collections::HashSet; +use std::path::{Path, PathBuf}; + +#[derive(Clone, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Item { + pub id: String, + pub label: String, + pub detail: String, + pub bytes: u64, + pub count: usize, + pub cleanable: bool, +} + +pub fn is_partial(name: &str) -> bool { + let n = name.to_ascii_lowercase(); + n.ends_with(".part") || n.ends_with(".ytdl") || n.contains(".part-frag") || n.contains(".atmosphere-src.") || n.contains(".tagging.") || n.ends_with(".temp") || n.ends_with(".download") +} + +fn walk(dir: &Path, depth: usize, out: &mut Vec, keep: &dyn Fn(&Path) -> bool) { + let Ok(rd) = std::fs::read_dir(dir) else { return }; + for e in rd.flatten() { + let p = e.path(); + match e.file_type() { + Ok(t) if t.is_dir() && depth > 0 => walk(&p, depth - 1, out, keep), + Ok(t) if t.is_file() && keep(&p) => out.push(p), + _ => {} + } + } +} + +fn size(paths: &[PathBuf]) -> u64 { + paths.iter().filter_map(|p| std::fs::metadata(p).ok()).map(|m| m.len()).sum() +} + +fn all_files(dir: &Path) -> Vec { + let mut out = Vec::new(); + walk(dir, 6, &mut out, &|_| true); + out +} + +fn stalled(settings: &Settings) -> Vec { + let mut out = Vec::new(); + let mut roots: Vec = vec![PathBuf::from(&settings.output_dir), PathBuf::from(&settings.playlists_dir), bin_dir()]; + roots.dedup(); + for r in roots { + walk(&r, 4, &mut out, &|p| p.file_name().and_then(|n| n.to_str()).is_some_and(is_partial)); + } + out.sort(); + out.dedup(); + out +} + +fn orphan_art(lib: &Snapshot) -> Vec { + let used: HashSet = lib.tracks.iter().filter_map(|t| t.art.clone()).chain(lib.artists.values().filter_map(|a| a.image.clone())).collect(); + let mut out = Vec::new(); + walk(&data_dir().join("art"), 0, &mut out, &|p| p.file_stem().and_then(|s| s.to_str()).is_some_and(|s| !used.contains(s))); + out +} + +fn mb(bytes: u64) -> String { + format!("{:.1} MB", bytes as f64 / 1_048_576.0) +} + +pub fn report(settings: &Settings, lib: &Snapshot, busy: bool) -> Vec { + let temp = all_files(&temp_root()); + let stall = if busy { Vec::new() } else { stalled(settings) }; + let orphans = orphan_art(lib); + let lyrics = all_files(&data_dir().join("lyrics")); + let art = all_files(&data_dir().join("art")); + let engine = all_files(&bin_dir()); + vec![ + Item { id: "temp".into(), label: "Temporary files".into(), detail: "Pieces of downloads in progress. Wiped automatically on launch and exit.".into(), bytes: size(&temp), count: temp.len(), cleanable: !busy }, + Item { id: "stalled".into(), label: "Stalled partial downloads".into(), detail: if busy { "Checked when no downloads are running.".into() } else { "Unfinished pieces left in your download or playlist folders.".into() }, bytes: size(&stall), count: stall.len(), cleanable: !busy }, + Item { id: "orphan-art".into(), label: "Unused cover art".into(), detail: "Artwork for songs no longer in your library.".into(), bytes: size(&orphans), count: orphans.len(), cleanable: true }, + Item { id: "lyrics".into(), label: "Lyrics cache".into(), detail: "Lyrics fetched online; they're fetched again when needed.".into(), bytes: size(&lyrics), count: lyrics.len(), cleanable: true }, + Item { id: "art".into(), label: "Cover art in use".into(), detail: format!("Thumbnails for your library ({}).", mb(size(&art).saturating_sub(size(&orphans)))), bytes: size(&art).saturating_sub(size(&orphans)), count: art.len().saturating_sub(orphans.len()), cleanable: false }, + Item { id: "engine".into(), label: "Download engine".into(), detail: "yt-dlp and ffmpeg managed by Atmosphere.".into(), bytes: size(&engine), count: engine.len(), cleanable: false }, + ] +} + +fn remove_all(paths: &[PathBuf]) -> (usize, u64) { + let mut n = 0; + let mut bytes = 0; + for p in paths { + let len = std::fs::metadata(p).map(|m| m.len()).unwrap_or(0); + if std::fs::remove_file(p).is_ok() { + n += 1; + bytes += len; + } + } + (n, bytes) +} + +pub fn wipe_temp() -> (usize, u64) { + let files = all_files(&temp_root()); + let r = remove_all(&files); + let _ = std::fs::remove_dir_all(temp_root()); + r +} + +pub fn clean(settings: &Settings, lib: &Snapshot, ids: &[String], busy: bool) -> (usize, u64) { + let mut total = (0, 0); + let mut add = |r: (usize, u64)| { + total.0 += r.0; + total.1 += r.1; + }; + for id in ids { + match id.as_str() { + "temp" if !busy => add(wipe_temp()), + "stalled" if !busy => add(remove_all(&stalled(settings))), + "orphan-art" => add(remove_all(&orphan_art(lib))), + "lyrics" => add(remove_all(&all_files(&data_dir().join("lyrics")))), + _ => {} + } + } + total +} + +pub fn startup(settings: &Settings) -> (usize, u64) { + let a = wipe_temp(); + let b = remove_all(&stalled(settings)); + (a.0 + b.0, a.1 + b.1) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn recognises_partial_files_only() { + for n in ["Song.mp3.part", "x.f251.webm.part-Frag12", "a.ytdl", "03 - Track.atmosphere-src.m4a", "v.tagging.mkv", "yt-dlp.download"] { + assert!(is_partial(n), "{n}"); + } + for n in ["Song.mp3", "partner.flac", "cover.jpg", "playlist.m3u8", "Night Drive.lrc"] { + assert!(!is_partial(n), "{n}"); + } + } +} diff --git a/src/tagging.rs b/src/tagging.rs new file mode 100644 index 0000000..e2eb46a --- /dev/null +++ b/src/tagging.rs @@ -0,0 +1,184 @@ +// atmosphere · tagging.rs · Applies the user's edited metadata and cover art on top of what yt-dlp embedded. +use anyhow::{anyhow, bail, Result}; +use lofty::config::WriteOptions; +use lofty::file::{AudioFile, TaggedFileExt}; +use lofty::picture::{MimeType, Picture, PictureType}; +use lofty::tag::items::Timestamp; +use lofty::tag::{Accessor, ItemKey, Tag}; +use serde::Deserialize; +use std::path::{Path, PathBuf}; +use std::process::Stdio; + +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(tag = "kind", rename_all = "lowercase")] +pub enum Artwork { + #[default] + Keep, + None, + File { + path: String, + }, +} + +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(rename_all = "camelCase", default)] +pub struct TagFields { + pub title: String, + pub artist: String, + pub album: String, + pub album_artist: String, + pub genre: String, + pub date: String, + pub track_number: Option, + pub track_total: Option, + pub disc_number: Option, + pub composer: String, + pub label: String, + pub isrc: String, + pub bpm: Option, + pub key: String, + pub comment: String, + pub lyrics: String, + pub artwork: Artwork, +} + +const LOFTY: [&str; 10] = ["mp3", "m4a", "mp4", "m4v", "flac", "ogg", "opus", "wav", "aiff", "aif"]; + +fn parse_date(raw: &str) -> Option { + let raw = raw.trim(); + if raw.is_empty() { + return None; + } + raw.parse::().ok().or_else(|| { + let year = raw.get(..4)?.parse().ok()?; + Some(Timestamp { year, ..Default::default() }) + }) +} + +fn put(tag: &mut Tag, key: ItemKey, value: &str) { + let v = value.trim(); + if !v.is_empty() { + tag.insert_text(key, v.to_string()); + } +} + +fn write_lofty(path: &Path, f: &TagFields, source_url: &str) -> Result<()> { + let mut file = lofty::read_from_path(path)?; + let kind = file.primary_tag_type(); + if file.primary_tag().is_none() { + file.insert_tag(Tag::new(kind)); + } + let tag = file.primary_tag_mut().ok_or_else(|| anyhow!("no writable tag"))?; + put(tag, ItemKey::TrackTitle, &f.title); + put(tag, ItemKey::TrackArtist, &f.artist); + put(tag, ItemKey::AlbumTitle, &f.album); + put(tag, ItemKey::AlbumArtist, &f.album_artist); + put(tag, ItemKey::Genre, &f.genre); + put(tag, ItemKey::Composer, &f.composer); + put(tag, ItemKey::Label, &f.label); + put(tag, ItemKey::Isrc, &f.isrc); + put(tag, ItemKey::InitialKey, &f.key); + put(tag, ItemKey::Comment, &f.comment); + put(tag, ItemKey::AudioSourceUrl, source_url); + if !f.lyrics.trim().is_empty() { + tag.insert_text(ItemKey::Lyrics, crate::lyrics::plain_text(&f.lyrics)); + } + if let Some(bpm) = f.bpm.filter(|b| *b > 0) { + tag.insert_text(ItemKey::IntegerBpm, bpm.to_string()); + } + if let Some(date) = parse_date(&f.date) { + tag.set_date(date); + } + if let Some(n) = f.track_number { + tag.set_track(n); + } + if let Some(total) = f.track_total { + tag.set_track_total(total); + } + if let Some(disc) = f.disc_number { + tag.set_disk(disc); + } + match &f.artwork { + Artwork::Keep => {} + Artwork::None => { + while !tag.pictures().is_empty() { + tag.remove_picture(0); + } + } + Artwork::File { path } => { + let data = std::fs::read(path).map_err(|e| anyhow!("couldn't read the cover image ({e})"))?; + let mime = if data.starts_with(&[0x89, b'P', b'N', b'G']) { MimeType::Png } else { MimeType::Jpeg }; + while !tag.pictures().is_empty() { + tag.remove_picture(0); + } + tag.push_picture(Picture::unchecked(data).pic_type(PictureType::CoverFront).mime_type(mime).build()); + } + } + file.save_to_path(path, WriteOptions::default())?; + Ok(()) +} + +async fn write_ffmpeg(ffmpeg: &Path, path: &Path, f: &TagFields) -> Result<()> { + let pairs = [ + ("title", f.title.clone()), + ("artist", f.artist.clone()), + ("album", f.album.clone()), + ("album_artist", f.album_artist.clone()), + ("genre", f.genre.clone()), + ("date", f.date.clone()), + ("composer", f.composer.clone()), + ("comment", f.comment.clone()), + ("track", f.track_number.map(|n| n.to_string()).unwrap_or_default()), + ]; + let meta: Vec<(&str, String)> = pairs.into_iter().filter(|(_, v)| !v.trim().is_empty()).collect(); + if meta.is_empty() { + return Ok(()); + } + let ext = path.extension().and_then(|e| e.to_str()).unwrap_or("mkv"); + let tmp: PathBuf = path.with_extension(format!("tagging.{ext}")); + let mut cmd = crate::engine::command(ffmpeg); + cmd.args(["-y", "-v", "error", "-i"]).arg(path).args(["-map", "0", "-c", "copy"]); + for (k, v) in &meta { + cmd.arg("-metadata").arg(format!("{k}={}", v.trim())); + } + let out = cmd.arg(&tmp).stdout(Stdio::null()).stderr(Stdio::piped()).output().await?; + if !out.status.success() { + let _ = tokio::fs::remove_file(&tmp).await; + bail!("{}", String::from_utf8_lossy(&out.stderr).lines().last().unwrap_or("ffmpeg failed")); + } + tokio::fs::rename(&tmp, path).await?; + Ok(()) +} + +pub async fn apply(path: &Path, f: &TagFields, source_url: &str, ffmpeg: Option<&Path>) -> Result<()> { + let ext = path.extension().and_then(|e| e.to_str()).unwrap_or_default().to_ascii_lowercase(); + if LOFTY.contains(&ext.as_str()) { + let (path, f, url) = (path.to_path_buf(), f.clone(), source_url.to_string()); + return tokio::task::spawn_blocking(move || write_lofty(&path, &f, &url)).await?; + } + match ffmpeg { + Some(ff) => write_ffmpeg(ff, path, f).await, + None => Ok(()), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_dates() { + assert_eq!(parse_date("2021").unwrap().year, 2021); + let full = parse_date("2019-04-12").unwrap(); + assert_eq!((full.year, full.month, full.day), (2019, Some(4), Some(12))); + assert!(parse_date(" ").is_none()); + } + + #[test] + fn artwork_defaults_to_keep() { + let f: TagFields = serde_json::from_str(r#"{"title":"x"}"#).unwrap(); + assert!(matches!(f.artwork, Artwork::Keep)); + let f: TagFields = serde_json::from_str(r#"{"artwork":{"kind":"file","path":"c.jpg"}}"#).unwrap(); + assert!(matches!(f.artwork, Artwork::File { .. })); + } +} diff --git a/tauri.conf.json b/tauri.conf.json new file mode 100644 index 0000000..ab2e75a --- /dev/null +++ b/tauri.conf.json @@ -0,0 +1,68 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "Atmosphere", + "version": "0.1.0", + "identifier": "app.atmosphere.desktop", + "build": { + "frontendDist": "ui" + }, + "app": { + "withGlobalTauri": true, + "windows": [ + { + "label": "main", + "title": "Atmosphere", + "width": 1200, + "height": 800, + "minWidth": 900, + "minHeight": 620, + "center": true, + "backgroundColor": "#0b0d14", + "dragDropEnabled": false, + "decorations": false, + "shadow": true + } + ], + "security": { + "csp": "default-src 'self'; img-src 'self' https: data: atmo: http://atmo.localhost; media-src 'self' atmo: http://atmo.localhost blob:; style-src 'self' 'unsafe-inline'; script-src 'self'; worker-src 'self' blob:; connect-src ipc: http://ipc.localhost atmo: http://atmo.localhost" + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ], + "category": "Music", + "shortDescription": "Save audio and video you have the rights to keep.", + "macOS": { + "minimumSystemVersion": "10.15" + }, + "linux": { + "deb": { + "depends": [] + } + }, + "licenseFile": "installer/RIGHTS.txt", + "windows": { + "nsis": { + "installMode": "both", + "installerIcon": "icons/icon.ico", + "headerImage": "installer/nsis-header.bmp", + "sidebarImage": "installer/nsis-sidebar.bmp", + "displayLanguageSelector": false + }, + "wix": { + "bannerPath": "installer/wix-banner.bmp", + "dialogImagePath": "installer/wix-dialog.bmp" + }, + "webviewInstallMode": { + "type": "downloadBootstrapper" + } + } + } +} \ No newline at end of file diff --git a/tauri.macos.conf.json b/tauri.macos.conf.json new file mode 100644 index 0000000..b50b7e3 --- /dev/null +++ b/tauri.macos.conf.json @@ -0,0 +1,21 @@ +{ + "app": { + "windows": [ + { + "label": "main", + "title": "Atmosphere", + "width": 1200, + "height": 800, + "minWidth": 900, + "minHeight": 620, + "center": true, + "backgroundColor": "#0b0d14", + "dragDropEnabled": false, + "decorations": true, + "shadow": true, + "titleBarStyle": "Overlay", + "hiddenTitle": true + } + ] + } +} \ No newline at end of file diff --git a/ui/app.js b/ui/app.js new file mode 100644 index 0000000..79ed348 --- /dev/null +++ b/ui/app.js @@ -0,0 +1,1397 @@ +/* atmosphere · app.js · Frontend logic: onboarding, command bar, release sheets, metadata editing, save options, downloads and settings. */ +const { invoke } = window.__TAURI__.core; +const { listen } = window.__TAURI__.event; + +const $ = (s, r = document) => r.querySelector(s); +const $$ = (s, r = document) => [...r.querySelectorAll(s)]; +const svg = (name) => (window.ICONS[name] ? `` : ""); +const reduced = matchMedia("(prefers-reduced-motion: reduce)"); + +function h(tag, attrs = {}, ...kids) { + const el = document.createElement(tag); + for (const [k, v] of Object.entries(attrs)) { + if (v == null || v === false) continue; + if (k === "class") el.className = v; + else if (k === "icon") el.innerHTML = svg(v); + else if (k.startsWith("on")) el.addEventListener(k.slice(2), v); + else el.setAttribute(k, v === true ? "" : v); + } + for (const kid of kids.flat()) if (kid != null && kid !== false) el.append(kid.nodeType ? kid : String(kid)); + return el; +} +const icon = (name) => h("span", { class: "i", icon: name }); +const isMac = /Mac|iPhone|iPad/.test(navigator.userAgentData?.platform || navigator.platform || navigator.userAgent); +const platformKeys = () => isMac && $$("kbd").forEach((k) => (k.textContent = k.textContent.replace(/^Ctrl /, "⌘ "))); +const hydrate = (root = document) => $$("[data-icon]", root).forEach((el) => (el.innerHTML = svg(el.dataset.icon))); + +const KIND = { album: "Album", ep: "EP", single: "Single", lp: "LP", compilation: "Compilation", mixtape: "Mixtape", playlist: "Playlist", profile: "Profile", channel: "Channel", search: "Search results", track: "Track" }; +const RELEASES = new Set(["album", "ep", "single", "lp", "compilation", "mixtape"]); +const SOURCE = { title: "Detected from the title", metadata: "Detected from track details", platform: "As listed on the platform", you: "Set by you" }; +const FINAL = new Set(["done", "skipped", "error", "cancelled"]); +const ACTIVE = new Set(["queued", "preparing", "downloading", "processing", "tagging"]); +const PLATFORM_ICON = [ + [/soundcloud\.com|snd\.sc/i, "brand-soundcloud", "SoundCloud"], + [/youtube\.com|youtu\.be|music\.youtube/i, "brand-youtube", "YouTube"], + [/bandcamp\.com/i, "brand-bandcamp", "Bandcamp"], + [/vimeo\.com/i, "brand-vimeo", "Vimeo"], + [/twitch\.tv/i, "brand-twitch", "Twitch"], + [/tiktok\.com/i, "brand-tiktok", "TikTok"], + [/(^|\.)x\.com|twitter\.com/i, "brand-x", "X"], + [/instagram\.com/i, "brand-instagram", "Instagram"], +]; +const platformIcon = (name) => (PLATFORM_ICON.find((p) => p[2] === name) || [0, "world"])[1]; + +const state = { + settings: null, + tools: null, + view: "get", + collections: [], + pending: [], + active: null, + scope: "youtube", + jobs: new Map(), + groups: [], + early: new Map(), + history: [], + historyDirty: true, + clipDismissed: new Set(), + installing: {}, +}; + +/* formatting */ +const nf = new Intl.NumberFormat(undefined, { maximumFractionDigits: 1 }); +function fmtDur(ms) { + if (!ms && ms !== 0) return ""; + const s = Math.round(ms / 1000), hh = Math.floor(s / 3600), mm = Math.floor((s % 3600) / 60), ss = String(s % 60).padStart(2, "0"); + return hh ? `${hh}:${String(mm).padStart(2, "0")}:${ss}` : `${mm}:${ss}`; +} +function fmtLong(ms) { + const m = Math.round(ms / 60000); + return m >= 60 ? `${Math.floor(m / 60)} hr ${m % 60} min` : `${m} min`; +} +function fmtBytes(n) { + if (!n) return "0 MB"; + const u = ["B", "KB", "MB", "GB"], i = Math.min(Math.floor(Math.log(n) / Math.log(1024)), 3); + return `${nf.format(n / 1024 ** i)} ${u[i]}`; +} +const timeFmt = new Intl.DateTimeFormat(undefined, { hour: "numeric", minute: "2-digit" }); +const dayFmt = new Intl.DateTimeFormat(undefined, { weekday: "long", month: "short", day: "numeric" }); +function dayLabel(ts) { + const d = new Date(ts), today = new Date(); + const diff = Math.round((new Date(today.toDateString()) - new Date(d.toDateString())) / 86400000); + return diff === 0 ? "Today" : diff === 1 ? "Yesterday" : dayFmt.format(d); +} +const plural = (n, one, many = one + "s") => `${n} ${n === 1 ? one : many}`; +const errText = (e) => (typeof e === "string" ? e : e?.message || "Something went wrong."); + +function toast(message, kind = "") { + const t = h("div", { class: `toast ${kind}`, role: "status" }, icon(kind === "err" ? "alert-circle" : "circle-check"), h("span", {}, message)); + $("#toasts").append(t); + setTimeout(() => { + t.classList.add("out"); + setTimeout(() => t.remove(), 220); + }, kind === "err" ? 6500 : 3000); +} + +function art(url, cls, alt = "") { + if (!url) return h("div", { class: `${cls} ph` }, icon("music")); + const img = h("img", { class: cls, src: url, alt, loading: "lazy", draggable: "false", referrerpolicy: "no-referrer" }); + img.addEventListener("error", () => img.replaceWith(h("div", { class: `${cls} ph` }, icon("music"))), { once: true }); + return img; +} + +/* theme */ +function applyTheme() { + const t = state.settings.theme; + if (t === "light" || t === "dark") document.documentElement.dataset.theme = t; + else delete document.documentElement.dataset.theme; +} + +/* window chrome */ +function bindWindow() { + const bar = $("#titlebar"); + if (isMac) bar.classList.add("mac"); + const api = window.__TAURI__.window; + if (!api?.getCurrentWindow) return; + const win = api.getCurrentWindow(); + const restoreSvg = ''; + const maxSvg = ''; + const syncMax = async () => { + const maxed = await win.isMaximized().catch(() => false); + const b = $("#winMax"); + b.innerHTML = maxed ? restoreSvg : maxSvg; + b.setAttribute("aria-label", maxed ? "Restore" : "Maximize"); + b.title = maxed ? "Restore" : "Maximize"; + }; + $("#winMin").addEventListener("click", () => win.minimize()); + $("#winMax").addEventListener("click", () => win.toggleMaximize()); + $("#winClose").addEventListener("click", () => win.close()); + win.onResized?.(() => syncMax()); + window.addEventListener("focus", () => bar.classList.remove("blur")); + window.addEventListener("blur", () => bar.classList.add("blur")); + syncMax(); +} + +/* boot */ +async function init() { + hydrate(); + platformKeys(); + bindWindow(); + state.settings = await invoke("get_settings"); + applyTheme(); + bindShell(); + bindCommand(); + bindCommit(); + bindSettings(); + bindPlayer(); + bindLibrary(); + bindLyrics(); + bindStats(); + await listen("atmosphere://job", (e) => onJob(e.payload)); + await listen("atmosphere://probe", (e) => onProbe(e.payload)); + await listen("atmosphere://install", (e) => onInstall(e.payload)); + await refreshTools(); + if (!state.settings.rightsAccepted) showOnboarding(1); + else unlock(); + const cleaned = await invoke("startup_cleanup").catch(() => null); + if (cleaned) toast(`Cleaned up ${plural(cleaned.files, "leftover file")} from an earlier session (${fmtBytes(cleaned.bytes)})`, "ok"); +} + +function unlock() { + $("#onboarding").hidden = true; + $("#shell").removeAttribute("inert"); + renderAll(); + $("#commandInput").focus(); + checkClipboard(); +} + +/* onboarding */ +function showOnboarding(step) { + $("#shell").setAttribute("inert", ""); + $("#onboarding").hidden = false; + $("#obStep1").hidden = step !== 1; + $("#obStep2").hidden = step !== 2; + $("#obStep1Dot").className = step === 1 ? "on" : "done"; + $("#obStep2Dot").className = step === 2 ? "on" : ""; + if (step === 2) renderObTools(); +} + +function bindOnboarding() { + const checks = $$(".pledge-check"); + checks.forEach((c) => c.addEventListener("change", () => ($("#obAccept").disabled = !checks.every((x) => x.checked)))); + $("#obAccept").addEventListener("click", async () => { + try { + state.settings = await invoke("accept_rights", { version: state.settings.termsVersion }); + if (!state.tools?.ytdlp.path || !state.tools?.ffmpeg.path) showOnboarding(2); + else unlock(); + } catch (e) { + toast(errText(e), "err"); + } + }); + $("#obSkip").addEventListener("click", unlock); + $("#obInstall").addEventListener("click", async () => { + const btn = $("#obInstall"); + btn.disabled = true; + const ok = await installMissing(); + btn.disabled = false; + if (ok) unlock(); + }); +} + +function toolRow(key, tool, name, blurb) { + const busy = state.installing[key]; + const ready = !!tool.path; + const row = h("div", { class: "ob-tool" }, + h("div", {}, h("strong", {}, name), h("span", {}, ready ? `Ready${tool.version ? ` · ${tool.version}` : ""}` : blurb)), + ready ? h("span", { class: "flag" }, "Installed") : busy ? h("span", { class: "flag" }, "Downloading…") : h("span", { class: "flag warn" }, "Not installed") + ); + if (busy) row.append(progressBar(busy.total ? busy.received / busy.total : null)); + return row; +} + +function renderObTools() { + const t = state.tools; + if (!t) return; + $("#obTools").replaceChildren( + toolRow("ytdlp", t.ytdlp, "yt-dlp", "Reads links and downloads media (about 18 MB)."), + toolRow("ffmpeg", t.ffmpeg, "ffmpeg", t.canInstallFfmpeg ? "Converts formats and writes tags (about 90 MB)." : isMac ? "Run brew install ffmpeg in Terminal; Atmosphere finds it." : "Install it with your package manager.") + ); + $("#obInstall").textContent = t.ytdlp.path && t.ffmpeg.path ? "Continue" : "Set up both"; +} + +async function installTool(key) { + state.installing[key] = { received: 0, total: null }; + renderEngine(); + try { + state.tools = await invoke("install_tool", { tool: key }); + return true; + } catch (e) { + toast(errText(e), "err"); + return false; + } finally { + delete state.installing[key]; + renderEngine(); + } +} + +async function installMissing() { + let ok = true; + if (!state.tools.ytdlp.path) ok = (await installTool("ytdlp")) && ok; + if (!state.tools.ffmpeg.path && state.tools.canInstallFfmpeg) ok = (await installTool("ffmpeg")) && ok; + return ok; +} + +function onInstall(p) { + if (!state.installing[p.tool]) return; + state.installing[p.tool] = p; + renderEngine(); +} + +async function refreshTools() { + try { + state.tools = await invoke("tools_status"); + } catch { + state.tools = null; + } + renderEngine(); +} + +function renderEngine() { + const t = state.tools; + const foot = $("#engineState"); + const ready = !!t?.ytdlp.path; + foot.replaceChildren(h("span", { class: `dot ${ready ? (t.ffmpeg.path ? "ok" : "warn") : "warn"}` }), h("span", {}, ready ? (t.ffmpeg.path ? "Engine ready" : "ffmpeg missing: limited formats") : "Engine not set up")); + $("#engineBanner").hidden = ready || !state.settings?.rightsAccepted; + if (!$("#onboarding").hidden) renderObTools(); + renderToolSettings(); + updateCommit(); +} + +function progressBar(fraction, cls = "") { + const bar = h("div", { class: `bar ${cls} ${fraction == null ? "indet" : ""}` }, h("i")); + if (fraction != null) bar.firstChild.style.transform = `scaleX(${Math.max(0, Math.min(1, fraction))})`; + return bar; +} + +/* shell & navigation */ +function bindShell() { + bindOnboarding(); + $$("[data-nav]").forEach((b) => + b.addEventListener("click", () => { + go(b.dataset.nav); + if (b.dataset.anchor) $(`#set-${b.dataset.anchor}`)?.scrollIntoView({ block: "start" }); + }) + ); + $("#clearFetched").addEventListener("click", () => { + state.collections.forEach((c) => invoke("forget", { id: c.data.id })); + state.collections = []; + state.active = null; + renderAll(); + }); + $("#engineBannerBtn").addEventListener("click", async () => { + const b = $("#engineBannerBtn"); + b.disabled = true; + await installMissing(); + b.disabled = false; + }); + window.addEventListener("focus", checkClipboard); + document.addEventListener("keydown", onKey); + document.addEventListener("paste", (e) => { + if (e.target.closest("input, textarea, [contenteditable]")) return; + const text = e.clipboardData.getData("text").trim(); + if (/^https?:\/\//i.test(text)) { + e.preventDefault(); + go("get"); + fetchText(text); + } + }); + document.addEventListener("dragover", (e) => e.preventDefault()); + document.addEventListener("drop", (e) => { + e.preventDefault(); + const text = (e.dataTransfer.getData("text/uri-list") || e.dataTransfer.getData("text/plain") || "").trim(); + if (/^https?:\/\//i.test(text)) { + go("get"); + fetchText(text); + } + }); + document.addEventListener("click", (e) => { + if (!e.target.isConnected) return; + if (!e.target.closest("#saveMenu, #saveAsBtn")) closeSaveMenu(); + if (!e.target.closest("#typeMenu, .kind-btn")) $("#typeMenu").hidden = true; + }); +} + +function go(view) { + if (state.view === view) return; + state.view = view; + $$(".view").forEach((v) => (v.hidden = v.dataset.view !== view)); + $$(".nav-item[data-nav]").forEach((b) => b.dataset.nav === view ? b.setAttribute("aria-current", "page") : b.removeAttribute("aria-current")); + closeSaveMenu(); + closeMenus(); + if (view !== "library") closeDrawers(); + if (view === "downloads") renderDownloads(true); + if (view === "settings") renderSettings(); + markLibNav(); +} + +function onKey(e) { + const mod = e.ctrlKey || e.metaKey; + if (mod && (e.key === "k" || e.key === "l")) { + e.preventDefault(); + go("get"); + $("#commandInput").focus(); + $("#commandInput").select(); + } else if (e.key === "Escape") { + if (!$("#saveMenu").hidden) closeSaveMenu(); + else if (!$("#typeMenu").hidden) $("#typeMenu").hidden = true; + else if (current()?.inspected != null && !current().data.single) { + current().inspected = null; + renderSheet(); + } + } else if (mod && e.key === "Enter" && state.view === "get") { + startDownload(); + } +} + +function renderAll() { + renderFetched(); + renderSheet(); + renderEngine(); + updateNav(); +} + +/* clipboard */ +async function checkClipboard() { + if (!state.settings?.rightsAccepted) return; + const url = await invoke("read_clipboard").catch(() => null); + const known = state.collections.some((c) => c.data.url === url || c.source === url); + const show = url && !state.clipDismissed.has(url) && !known && !$("#commandInput").value.trim(); + $("#clipChip").hidden = !show; + if (show) $("#clipUrl").textContent = url.replace(/^https?:\/\/(www\.)?/, ""); + $("#clipChip").dataset.url = url || ""; +} + +/* command bar */ +function classifyInput(text) { + const t = text.trim(); + if (!t) return { kind: "empty" }; + const urls = t.split(/\s+/).filter((x) => /^(https?:\/\/|www\.)\S+$/i.test(x) || /^[\w-]+(\.[\w-]+)+\/\S*$/.test(x)); + if (urls.length && urls.length === t.split(/\s+/).length) { + const hit = PLATFORM_ICON.find(([re]) => re.test(urls[0])); + return { kind: "url", urls, icon: hit ? hit[1] : "world", platform: hit ? hit[2] : null }; + } + return { kind: "query", query: t }; +} + +function bindCommand() { + const input = $("#commandInput"); + const sync = () => { + const c = classifyInput(input.value); + $("#commandGlyph").innerHTML = svg(c.kind === "url" ? c.icon : c.kind === "query" ? "search" : "link"); + $("#commandGlyph").classList.toggle("known", c.kind === "url" && !!c.platform); + $("#searchScope").hidden = c.kind !== "query"; + $("#commandGo .label").textContent = c.kind === "query" ? "Search" : "Fetch"; + if (input.value.trim()) $("#clipChip").hidden = true; + }; + input.addEventListener("input", sync); + $$("#searchScope button").forEach((b) => + b.addEventListener("click", () => { + state.scope = b.dataset.scope; + $$("#searchScope button").forEach((x) => x.setAttribute("aria-checked", String(x === b))); + input.focus(); + }) + ); + $("#commandForm").addEventListener("submit", (e) => { + e.preventDefault(); + fetchText(input.value); + }); + $("#clipUse").addEventListener("click", () => { + const url = $("#clipChip").dataset.url; + $("#clipChip").hidden = true; + fetchText(url); + }); + $("#clipDismiss").addEventListener("click", () => { + state.clipDismissed.add($("#clipChip").dataset.url); + $("#clipChip").hidden = true; + }); + sync(); +} + +async function fetchText(text) { + const c = classifyInput(text); + if (c.kind === "empty") return $("#commandInput").focus(); + if (!state.tools?.ytdlp.path) return toast("Set up the engine first. It reads links for Atmosphere.", "err"); + const btn = $("#commandGo"); + btn.classList.add("loading"); + $("#clipChip").hidden = true; + const tasks = c.kind === "url" ? c.urls.map((u) => ({ url: u, label: u.replace(/^https?:\/\/(www\.)?/, "") })) : [{ query: c.query, label: `“${c.query}”` }]; + const pend = tasks.map((t) => ({ key: Math.random().toString(36).slice(2), label: t.label })); + state.pending.push(...pend); + renderFetched(); + $("#commandInput").value = ""; + $("#commandInput").dispatchEvent(new Event("input")); + await Promise.all( + tasks.map(async (t, i) => { + try { + const data = t.url ? await invoke("probe", { url: t.url }) : await invoke("search", { platform: state.scope, query: t.query }); + addCollection(data, t.url || t.query); + } catch (e) { + toast(`${tasks.length > 1 ? t.label + ": " : ""}${errText(e)}`, "err"); + } finally { + state.pending = state.pending.filter((p) => p !== pend[i]); + renderFetched(); + } + }) + ); + btn.classList.remove("loading"); +} + +/* collections */ +function selectable(e) { + return !["drm", "preview"].includes(e.availability); +} + +function addCollection(data, source) { + const existing = state.collections.findIndex((c) => c.data.url && c.data.url === data.url); + if (existing >= 0) { + invoke("forget", { id: state.collections[existing].data.id }); + state.collections.splice(existing, 1); + } + const c = { + data, + source, + releaseType: data.releaseType, + releaseSource: data.releaseTypeSource, + selected: new Set(data.releaseType === "search" ? [] : data.entries.filter(selectable).map((e) => e.index)), + album: { title: data.title, artist: data.artist, date: data.year ? String(data.year) : "", genre: "", label: "", artwork: { kind: "keep" }, preview: null }, + albumEdited: new Set(), + overrides: new Map(), + trims: new Map(), + inspected: data.single ? data.entries[0]?.index : null, + }; + state.collections.unshift(c); + state.active = c; + $("#attest").checked = false; + go("get"); + renderAll(); +} + +const current = () => state.active; +const entryOf = (c, index) => c.data.entries.find((e) => e.index === index); +const isRelease = (c) => RELEASES.has(c.releaseType); +const numbered = (c) => !c.data.single && (isRelease(c) || c.releaseType === "playlist"); + +function position(c, entry) { + return c.data.entries.indexOf(entry) + 1; +} + +function defaults(c, e) { + const rel = isRelease(c); + const n = numbered(c); + return { + title: e.title || "", + artist: e.artist || "", + album: rel ? c.album.title : e.album || (c.releaseType === "playlist" ? c.album.title : ""), + albumArtist: rel ? c.album.artist : e.albumArtist || "", + genre: (rel && c.album.genre) || e.genre || "", + date: (rel && c.album.date) || e.releaseDate || (e.year ? String(e.year) : ""), + trackNumber: n ? position(c, e) : e.trackNumber ?? null, + trackTotal: n ? c.data.entries.length : null, + discNumber: e.discNumber ?? null, + composer: e.composer || "", + label: (rel && c.album.label) || "", + isrc: "", + bpm: null, + key: "", + comment: "", + lyrics: e.lyrics || "", + artwork: rel || c.data.single ? c.album.artwork : { kind: "keep" }, + }; +} + +function finalMeta(c, e) { + return { ...defaults(c, e), ...(c.overrides.get(e.index) || {}) }; +} + +function folderFor(c) { + if (c.data.single || c.releaseType === "search") return null; + if (isRelease(c)) return [c.album.artist, c.album.title].filter(Boolean).join(" - "); + return c.album.title; +} + +function selectedEntries(c) { + return c.data.entries.filter((e) => c.selected.has(e.index)); +} + +/* probe events */ +function onProbe(p) { + const c = state.collections.find((x) => x.data.id === p.collection); + if (!c) return; + if (p.type === "entry") { + const i = c.data.entries.findIndex((e) => e.index === p.entry.index); + if (i >= 0) { + const wasSelectable = selectable(c.data.entries[i]); + c.data.entries[i] = p.entry; + if (wasSelectable && !selectable(p.entry)) c.selected.delete(p.entry.index); + } + if (c === state.active) scheduleSheet(); + } else if (p.type === "done") { + c.data.enriching = false; + if (c.releaseSource !== "you") { + c.releaseType = p.releaseType; + c.releaseSource = p.releaseTypeSource; + } + if (!c.albumEdited.has("artist") && p.artist) c.album.artist = p.artist; + if (!c.albumEdited.has("date")) { + const dates = [...new Set(c.data.entries.map((e) => e.releaseDate).filter(Boolean))]; + if (dates.length === 1) c.album.date = dates[0]; + else if (p.year) c.album.date = String(p.year); + } + if (p.failed) c.unreadable = p.failed; + renderFetched(); + if (c === state.active) renderSheet(); + } +} + +let sheetQueued = false; +function scheduleSheet() { + if (sheetQueued) return; + sheetQueued = true; + requestAnimationFrame(() => { + sheetQueued = false; + renderSheet(true); + }); +} + +/* sidebar list */ +function renderFetched() { + const list = $("#fetchedList"); + const items = [ + ...state.pending.map((p) => + h("li", {}, h("div", { class: "fetched-item" }, h("div", { class: "thumb ph" }, h("span", { class: "spin-sm" }, icon("loader-2"))), h("div", {}, h("div", { class: "t" }, "Reading link…"), h("div", { class: "m" }, p.label)))) + ), + ...state.collections.map((c) => { + const n = c.data.entries.length; + const meta = c.data.single ? `${c.data.entries[0]?.platform || ""}${c.data.entries[0]?.durationMs ? " · " + fmtDur(c.data.entries[0].durationMs) : ""}` : `${KIND[c.releaseType] || "Playlist"} · ${plural(n, "item")}`; + return h("li", {}, h("button", { class: "fetched-item", "data-cid": c.data.id, "aria-current": String(c === state.active), onclick: () => { state.active = c; go("get"); renderFetched(); renderSheet(); } }, + art(c.data.thumbnail, "thumb"), h("div", { style: "min-width:0" }, h("div", { class: "t" }, c.album.title || c.data.title), h("div", { class: "m" }, meta)))); + }), + ]; + list.replaceChildren(...items); + $("#fetchedStrip").hidden = items.length === 0; + $("#clearFetched").hidden = state.collections.length === 0; +} + +/* release sheet */ +function editable(text, placeholder, onCommit, cls = "") { + const el = h("span", { class: `editable ${cls}`, contenteditable: "plaintext-only", spellcheck: "false", role: "textbox", "aria-label": placeholder, "data-placeholder": placeholder }, text || ""); + el.addEventListener("keydown", (e) => { + if (e.key === "Enter") { + e.preventDefault(); + el.blur(); + } + if (e.key === "Escape") { + el.textContent = text || ""; + el.blur(); + } + }); + el.addEventListener("blur", () => { + const v = el.textContent.trim(); + if (v !== (text || "")) onCommit(v); + }); + return el; +} + +function setAlbum(c, key, value) { + c.album[key] = value; + c.albumEdited.add(key); + renderFetched(); + renderSheet(); +} + +function setOverride(c, index, key, value) { + const e = entryOf(c, index); + const base = defaults(c, e)[key]; + const o = { ...(c.overrides.get(index) || {}) }; + const same = (base ?? "") === (value ?? "") || (base == null && value === ""); + if (same) delete o[key]; + else o[key] = value; + Object.keys(o).length ? c.overrides.set(index, o) : c.overrides.delete(index); +} + +function renderSheet(soft = false) { + const c = current(); + const sheet = $("#sheet"); + $("#emptyGet").hidden = !!c; + sheet.hidden = !c; + $("#commit").hidden = !c; + if (!c) return; + const scrollY = $("#getScroll").scrollTop; + sheet.replaceChildren(sheetHead(c), sheetBody(c)); + if (soft) $("#getScroll").scrollTop = scrollY; + updateCommit(); +} + +function sheetHead(c) { + const d = c.data; + const single = d.single; + const e0 = d.entries[0]; + const cover = c.album.preview || d.thumbnail; + const total = d.entries.reduce((a, e) => a + (e.durationMs || 0), 0); + const coverEl = c.album.artwork.kind === "none" ? h("div", { class: "cover ph" }, icon("photo")) : art(cover, "cover", "Cover art"); + coverEl.id = "sheetCover"; + const canEditCover = single || isRelease(c); + const coverWrap = h("div", { class: "cover-wrap" }, coverEl, canEditCover && h("button", { class: "cover-edit", onclick: () => chooseCover(c) }, icon("photo"), "Change")); + + const kindLine = h("div", { class: "kind-line" }); + if (single) { + kindLine.append(h("span", { class: "kind-btn", style: "cursor:default" }, icon(platformIcon(e0.platform)), e0.platform || "Media")); + if (e0.media?.hasVideo) kindLine.append(h("span", { class: "sep" }, "·"), "Video"); + if (e0.year) kindLine.append(h("span", { class: "sep" }, "·"), String(e0.year)); + } else if (c.releaseType === "search") { + kindLine.append(h("span", { class: "kind-btn", style: "cursor:default" }, icon("search"), `Search · ${state.scope === "soundcloud" ? "SoundCloud" : "YouTube"}`)); + } else { + const kb = h("button", { class: "kind-btn", "aria-haspopup": "menu", title: SOURCE[c.releaseSource] || "Change type", onclick: (ev) => openTypeMenu(ev.currentTarget, c) }, KIND[c.releaseType] || "Playlist", icon("chevron-down")); + kindLine.append(kb); + if (SOURCE[c.releaseSource]) kindLine.append(h("span", { class: "kind-src" }, SOURCE[c.releaseSource].replace("Detected from the", "from").replace("Detected from", "from").replace("As listed on the platform", "per platform").replace("Set by you", "set by you"))); + kindLine.append(h("span", { class: "sep" }, "·"), h("span", {}, d.platform)); + } + + let title, artist; + if (single) { + const m = finalMeta(c, e0); + title = editable(m.title, "Title", (v) => { setOverride(c, e0.index, "title", v); renderFetched(); renderSheet(); }, "head-title"); + artist = editable(m.artist, "Artist", (v) => { setOverride(c, e0.index, "artist", v); renderSheet(); }, "head-artist"); + } else if (c.releaseType === "search") { + title = h("div", { class: "head-title" }, `“${d.title}”`); + artist = h("div", { class: "head-artist", style: "color:var(--text-2)" }, `${plural(d.entries.length, "result")}. Tick what you want to keep.`); + } else { + title = editable(c.album.title, isRelease(c) ? "Album title" : "Playlist name", (v) => setAlbum(c, "title", v), "head-title"); + artist = editable(c.album.artist, isRelease(c) ? "Album artist" : "Curator", (v) => setAlbum(c, "artist", v), "head-artist"); + } + + const facts = h("div", { class: "head-facts" }); + if (!single && c.releaseType !== "search") { + facts.append(h("span", {}, `${plural(d.entries.length, isRelease(c) ? "track" : "item")}${total ? " · " + fmtLong(total) : ""}`)); + if (isRelease(c)) { + facts.append( + h("span", { class: "fact" }, h("b", {}, "Year"), editable(c.album.date, "Add", (v) => setAlbum(c, "date", v))), + h("span", { class: "fact" }, h("b", {}, "Genre"), editable(c.album.genre, "Add", (v) => setAlbum(c, "genre", v))), + h("span", { class: "fact" }, h("b", {}, "Label"), editable(c.album.label, "Add", (v) => setAlbum(c, "label", v))) + ); + } + } else if (single) { + facts.append(h("span", {}, [e0.durationMs ? fmtDur(e0.durationMs) : null, e0.uploader && e0.uploader !== finalMeta(c, e0).artist ? `uploaded by ${e0.uploader}` : null, e0.license ? licenceLabel(e0.license) : null].filter(Boolean).join(" · "))); + } + + const actions = h("div", { class: "head-actions" }, + d.url && h("button", { class: "btn small", onclick: () => invoke("open_link", { url: d.url }) }, icon("external-link"), `Open on ${d.platform || "site"}`), + h("button", { class: "btn small ghost", onclick: () => removeCollection(c) }, "Remove") + ); + + return h("header", { class: "sheet-head" }, + h("div", { class: "sheet-art-bg", style: cover && c.album.artwork.kind !== "none" ? `background-image:url("${cover.replace(/"/g, "%22")}")` : "" }), + coverWrap, + h("div", { class: "head-meta" }, kindLine, title, artist, facts, actions) + ); +} + +function licenceLabel(l) { + const map = { "all-rights-reserved": "All rights reserved", "no-rights-reserved": "Public domain", "cc-by": "CC BY", "cc-by-sa": "CC BY-SA", "cc-by-nd": "CC BY-ND", "cc-by-nc": "CC BY-NC", "cc-by-nc-sa": "CC BY-NC-SA", "cc-by-nc-nd": "CC BY-NC-ND" }; + return map[l] || l; +} + +function removeCollection(c) { + invoke("forget", { id: c.data.id }); + state.collections = state.collections.filter((x) => x !== c); + state.active = state.collections[0] || null; + renderAll(); +} + +async function chooseCover(c) { + try { + const picked = await invoke("pick_image"); + if (!picked) return; + if (c.data.single) { + setOverride(c, c.data.entries[0].index, "artwork", { kind: "file", path: picked.path }); + } + c.album.artwork = { kind: "file", path: picked.path }; + c.album.preview = picked.dataUrl; + renderSheet(); + } catch (e) { + toast(errText(e), "err"); + } +} + +function openTypeMenu(anchor, c) { + const menu = $("#typeMenu"); + menu.replaceChildren( + ...["album", "ep", "single", "lp", "compilation", "mixtape", "playlist"].map((k) => + h("button", { role: "menuitemradio", "aria-checked": String(c.releaseType === k), onclick: () => { c.releaseType = k; c.releaseSource = "you"; menu.hidden = true; renderFetched(); renderSheet(); } }, KIND[k]) + ), + h("div", { class: "menu-note" }, "Albums, EPs and singles get album tags and track numbers.") + ); + const r = anchor.getBoundingClientRect(); + menu.style.left = `${r.left}px`; + menu.style.top = `${r.bottom + 6}px`; + menu.hidden = false; + menu.querySelector("button")?.focus(); +} + +function sheetBody(c) { + const d = c.data; + if (d.single) return h("div", { class: "sheet-body" }, inspector(c, d.entries[0], true)); + const body = h("div", { class: `sheet-body ${c.inspected != null ? "inspecting" : ""}` }); + const sel = c.selected.size; + const avail = d.entries.filter(selectable).length; + const allBox = h("input", { type: "checkbox", class: "tl-check", "aria-label": "Select all" }); + allBox.checked = sel > 0 && sel === avail; + allBox.indeterminate = sel > 0 && sel < avail; + allBox.addEventListener("change", () => { + c.selected = new Set(allBox.checked ? d.entries.filter(selectable).map((e) => e.index) : []); + renderSheet(true); + }); + const detailed = d.entries.filter((e) => e.detailed).length; + const unavailable = d.entries.length - avail; + body.append( + h("div", { class: "tl-tools" }, + allBox, + h("span", {}, `${sel} of ${d.entries.length} selected`), + h("span", { class: "grow" }), + d.enriching && h("span", {}, `Reading details… ${detailed} of ${d.entries.length}`), + !d.enriching && unavailable > 0 && unavailableNote(d.entries) + ) + ); + const list = h("ul", { class: "tracklist", role: "listbox", "aria-label": "Tracks", "aria-multiselectable": "true" }); + d.entries.forEach((e, i) => list.append(trackRow(c, e, i))); + body.append(list); + if (c.inspected != null) { + const e = entryOf(c, c.inspected); + if (e) body.append(inspector(c, e, false)); + } + return body; +} + +function unavailableNote(entries) { + const preview = entries.filter((e) => e.availability === "preview").length; + const drm = entries.filter((e) => e.availability === "drm").length; + const parts = [preview && `${preview} preview-only`, drm && `${drm} encrypted`].filter(Boolean).join(", "); + return h("span", { class: "warn-note", title: drm ? "If these are your own tracks, enable downloads on them in the platform's track settings, then choose Original file." : "The platform only offers a short preview of these." }, `${parts}, can't be downloaded`); +} + +function trackRow(c, e, i) { + const ok = selectable(e); + const m = finalMeta(c, e); + const box = h("input", { type: "checkbox", class: "tl-check", disabled: !ok, "aria-label": `Include ${m.title}` }); + box.checked = c.selected.has(e.index); + box.addEventListener("click", (ev) => ev.stopPropagation()); + box.addEventListener("change", () => { + box.checked ? c.selected.add(e.index) : c.selected.delete(e.index); + renderSheet(true); + }); + const loading = !e.detailed && c.data.enriching && (!e.title || e.title === "Untitled"); + const showArtist = !isRelease(c) || (m.artist && m.artist !== c.album.artist); + const main = loading + ? h("div", { class: "tl-main" }, h("span", { class: "skeleton w60" }), h("span", { class: "skeleton w30" })) + : h("div", { class: "tl-main" }, h("span", { class: "tl-title" }, m.title), showArtist && h("span", { class: "tl-sub" }, m.artist)); + const flags = h("div", { class: "row" }); + if (c.overrides.has(e.index)) flags.append(h("span", { class: "flag edited" }, "Edited")); + if (e.availability === "preview") flags.append(h("span", { class: "flag warn" }, "Preview only")); + if (e.availability === "drm") flags.append(h("span", { class: "flag warn", title: "If it's your own track, turn on downloads for it in the platform's track settings (or enable “Use my browser sign-in”), then choose Original file to get your uploaded master." }, "Encrypted")); + if (e.availability === "restricted") flags.append(h("span", { class: "flag", title: "May need your browser sign-in (Settings)" }, "Sign-in")); + if (e.media?.original) flags.append(h("span", { class: "flag", title: "The uploader offers their original file" }, "Original")); + if ((m.lyrics || "").trim()) flags.append(h("span", { class: "flag", title: e.lyrics && !c.overrides.get(e.index)?.lyrics ? "Lyrics found in the description" : "Lyrics attached" }, "Lyrics")); + const row = h("li", { class: `tl-row ${c.selected.has(e.index) ? "" : "off"}`, role: "option", "aria-selected": String(c.inspected === e.index), "data-index": e.index, onclick: () => { c.inspected = c.inspected === e.index ? null : e.index; renderSheet(true); } }, + box, + h("span", { class: "tl-num" }, numbered(c) ? i + 1 : ""), + main, + flags, + h("span", { class: "tl-dur" }, e.durationMs ? fmtDur(e.durationMs) : ""), + h("button", { class: "icon-btn", "aria-label": `Get info for ${m.title}`, onclick: (ev) => { ev.stopPropagation(); c.inspected = e.index; renderSheet(true); } }, icon("info-circle")) + ); + return row; +} + +const FIELDS = [ + ["title", "Title", "full"], ["artist", "Artist", "full"], ["album", "Album", "half"], ["albumArtist", "Album artist", "half"], + ["trackNumber", "Track", "num"], ["trackTotal", "of", "num"], ["discNumber", "Disc", "num"], ["date", "Year or date", ""], + ["genre", "Genre", "half"], ["composer", "Composer", "half"], ["label", "Label", "half"], ["isrc", "ISRC", ""], ["bpm", "BPM", "num"], + ["key", "Key", ""], ["comment", "Comment", "full"], +]; + +function inspector(c, e, inline) { + const m = finalMeta(c, e); + const base = defaults(c, e); + const fields = h("div", { class: "fields" }); + for (const [key, label, kind] of FIELDS) { + const value = m[key] ?? ""; + const input = h("input", { value: String(value), inputmode: kind === "num" ? "numeric" : null, spellcheck: "false", "aria-label": label }); + input.classList.toggle("changed", String(base[key] ?? "") !== String(value)); + input.addEventListener("change", () => { + let v = input.value.trim(); + if (kind === "num") v = v === "" ? null : Math.max(0, parseInt(v, 10) || 0); + setOverride(c, e.index, key, v); + input.classList.toggle("changed", String(base[key] ?? "") !== String(v ?? "")); + if (key === "title" || key === "artist") renderSheet(true); + else updateCommit(); + }); + fields.append(h("label", { class: `field ${kind === "full" ? "full" : kind === "half" ? "half" : ""}` }, h("span", {}, label), input)); + } + const trim = c.trims.get(e.index) || { start: "", end: "" }; + const trimIn = (k, ph) => { + const inp = h("input", { value: trim[k], placeholder: ph, spellcheck: "false", "aria-label": k === "start" ? "Start time" : "End time" }); + inp.addEventListener("change", () => { + const t = { ...(c.trims.get(e.index) || { start: "", end: "" }), [k]: inp.value.trim() }; + t.start || t.end ? c.trims.set(e.index, t) : c.trims.delete(e.index); + }); + return inp; + }; + const artKind = (m.artwork || {}).kind || "keep"; + const coverSrc = artKind === "file" ? c.album.preview : e.thumbnail; + const coverRow = h("div", { class: "ins-cover" }, + artKind === "none" ? h("div", { class: "ph" }, icon("photo")) : art(coverSrc, "", "Cover"), + h("div", { class: "stack" }, + h("strong", {}, artKind === "file" ? "Your image" : artKind === "none" ? "No cover art" : "Cover from source"), + h("div", { class: "row" }, + h("button", { class: "btn small", onclick: async () => { const p = await invoke("pick_image").catch((x) => toast(errText(x), "err")); if (p) { setOverride(c, e.index, "artwork", { kind: "file", path: p.path }); c.album.preview = c.album.preview || p.dataUrl; renderSheet(true); } } }, "Choose…"), + artKind !== "none" ? h("button", { class: "btn small ghost", onclick: () => { setOverride(c, e.index, "artwork", { kind: "none" }); renderSheet(true); } }, "Remove") : h("button", { class: "btn small ghost", onclick: () => { setOverride(c, e.index, "artwork", { kind: "keep" }); renderSheet(true); } }, "Restore") + ) + ) + ); + const avail = h("div", { class: "avail" }, ...availabilityFlags(e)); + const lyrBox = h("textarea", { class: "text area lyr-input", rows: "7", spellcheck: "false", placeholder: "Paste lyrics here. Add [mm:ss.xx] timings at the start of lines to make them synced." }, m.lyrics || ""); + const lyrStatus = h("span", { class: "muted small" }); + const describe = () => { + const v = lyrBox.value.trim(); + const lines = v ? v.split(/\n/).filter((x) => x.trim()) : []; + const timed = lines.filter((x) => /^\s*\[\d{1,3}:\d{1,2}([.:]\d{1,3})?\]/.test(x)).length; + const fromDesc = e.lyrics && v === e.lyrics.trim() && !c.overrides.get(e.index)?.lyrics; + lyrStatus.textContent = !v ? "No lyrics attached" : `${timed >= 2 ? `Synced · ${timed} timed lines` : `Plain · ${lines.length} lines`}${fromDesc ? " · found in the description" : ""}`; + }; + describe(); + lyrBox.addEventListener("input", describe); + lyrBox.addEventListener("change", () => { setOverride(c, e.index, "lyrics", lyrBox.value); renderSheet(true); }); + const lyrSection = h("div", { class: "ins-section" }, + h("div", { class: "ins-sub" }, h("h3", {}, "Lyrics"), lyrStatus), + lyrBox, + h("div", { class: "row" }, + h("button", { class: "btn small", onclick: async () => { try { const t = await invoke("pick_text_file"); if (t != null) { setOverride(c, e.index, "lyrics", t); renderSheet(true); } } catch (x) { toast(errText(x), "err"); } } }, icon("file-music"), "Import .lrc or .txt…"), + lyrBox.value ? h("button", { class: "btn small ghost", onclick: () => { setOverride(c, e.index, "lyrics", ""); renderSheet(true); } }, "Clear") : null), + h("p", { class: "muted small" }, "Saved with the download: plain lyrics go into the file's tags, and timed lyrics also become a .lrc file next to the song.")); + const descText = e.description || ""; + const descSection = descText ? h("details", { class: "ins-section desc" }, h("summary", {}, h("h3", {}, e.lyrics ? "Rest of the description" : "Description")), h("p", { class: "desc-text" }, descText)) : null; + const ins = h("aside", { class: `inspector ${inline ? "inline" : ""}`, "aria-label": "Track details" }); + if (!inline) ins.append(h("div", { class: "ins-head" }, h("span", { class: "t" }, m.title), h("button", { class: "icon-btn", "aria-label": "Close", onclick: () => { c.inspected = null; renderSheet(true); } }, icon("x")))); + ins.append( + h("div", { class: "ins-body" }, + h("div", { class: "ins-section" }, h("h3", {}, "Tags"), fields), + h("div", { class: "ins-section" }, h("h3", {}, "Cover art"), coverRow), + lyrSection, + descSection, + h("div", { class: "ins-section" }, h("h3", {}, "Trim (optional)"), h("div", { class: "fields" }, h("label", { class: "field" }, h("span", {}, "Start"), trimIn("start", "0:00")), h("label", { class: "field" }, h("span", {}, "End"), trimIn("end", e.durationMs ? fmtDur(e.durationMs) : "end")))), + h("div", { class: "ins-section" }, h("h3", {}, "What's available"), avail) + ), + h("div", { class: "ins-foot" }, + h("button", { class: "btn small ghost", disabled: !c.overrides.has(e.index), onclick: () => { c.overrides.delete(e.index); renderSheet(true); } }, "Reset edits"), + !inline && h("button", { class: "btn small", onclick: () => { c.inspected = null; renderSheet(true); } }, "Done") + ) + ); + return ins; +} + +function availabilityFlags(e) { + if (!e.media) return [h("span", { class: "flag" }, e.detailed ? "Unknown formats" : "Checking…")]; + const m = e.media, out = []; + if (m.bestCodec) out.push(h("span", { class: "flag" }, `${m.bestCodec.toUpperCase()}${m.bestAbr ? ` ${m.bestAbr} kbps` : ""} best audio`)); + if (m.original) out.push(h("span", { class: "flag" }, `Original ${m.originalExt ? m.originalExt.toUpperCase() : "file"}`)); + if (m.lossless) out.push(h("span", { class: "flag" }, "Lossless source")); + if (m.hasVideo) out.push(h("span", { class: "flag" }, m.heights.length ? `Video up to ${m.heights[0]}p` : "Video")); + if (e.availability !== "ok") out.push(h("span", { class: "flag warn" }, { drm: "Encrypted stream: if it's yours, enable downloads and use Original file", preview: "Preview only", restricted: "Needs sign-in" }[e.availability] || e.availability)); + return out; +} + +/* save-as */ +const MP3 = [64, 96, 128, 160, 192, 256, 320]; +const snap = (req, cap) => MP3.filter((b) => b <= (cap ? Math.min(req, cap) : req)).pop() || 64; + +function selectionCaps(c) { + const ents = selectedEntries(c); + const known = ents.filter((e) => e.media); + const uncapped = (m) => m.lossless || (m.original && m.originalLossless) || !m.bestAbr; + const abrs = known.filter((e) => !uncapped(e.media)).map((e) => e.media.bestAbr); + const free = known.filter((e) => uncapped(e.media)).length; + const lossless = known.some((e) => e.media.lossless || (e.media.original && e.media.originalLossless)); + const originals = known.filter((e) => e.media.original).length; + const heights = [...new Set(known.flatMap((e) => e.media.heights || []))].sort((a, b) => b - a); + const codecs = [...new Set(known.map((e) => e.media.bestCodec && `${e.media.bestCodec.toUpperCase()}${e.media.bestAbr ? ` ${e.media.bestAbr} kbps` : ""}`).filter(Boolean))]; + return { + count: ents.length, + unknown: known.length < ents.length, + maxAbr: free || !abrs.length ? null : Math.max(...abrs), + minAbr: abrs.length ? Math.min(...abrs) : null, + cappedCount: abrs.length, + losslessCount: known.filter((e) => e.media.lossless || (e.media.original && e.media.originalLossless)).length, + mixed: abrs.length > 0 && (free > 0 || Math.min(...abrs) < Math.max(...abrs)), + lossless, + originals, + anyVideo: known.some((e) => e.media.hasVideo) || (known.length === 0 && ents.length > 0), + heights, + codec: codecs.length === 1 ? codecs[0] : null, + }; +} + +function saveLabel(caps) { + const s = state.settings; + switch (s.saveAs) { + case "original": return "Original file"; + case "mp3": return `MP3 · ${caps.mixed ? "up to " : ""}${snap(s.mp3Bitrate, caps.maxAbr)} kbps`; + case "m4a": return "M4A (AAC)"; + case "flac": return "FLAC"; + case "wav": return "WAV"; + case "video": return `Video · ${s.videoHeight ? Math.min(s.videoHeight, caps.heights[0] || s.videoHeight) + "p" : "best"} ${s.videoContainer.toUpperCase()}`; + default: return "Best quality"; + } +} + +async function patchSave(patch) { + try { + state.settings = await invoke("save_settings", { patch }); + } catch (e) { + toast(errText(e), "err"); + } + updateCommit(); + renderSaveMenu(); +} + +function opt(value, title, detail, extra, disabled = false) { + const on = state.settings.saveAs === value; + return h("div", {}, + h("button", { class: "opt", role: "menuitemradio", "aria-checked": String(on), disabled, onclick: () => patchSave({ saveAs: value }) }, h("span", { class: "radio" }), h("span", {}, h("strong", {}, title), h("small", {}, detail))), + on && extra ? h("div", { style: "padding: 0 12px 10px 42px" }, extra) : null + ); +} + +function renderSaveMenu() { + const menu = $("#saveMenu"); + const c = current(); + if (menu.hidden || !c) return; + const caps = selectionCaps(c); + const s = state.settings; + const mp3Options = MP3.filter((b) => b >= 96 && (!caps.maxAbr || b <= snap(320, caps.maxAbr))); + const eff = snap(s.mp3Bitrate, caps.maxAbr); + const mp3Chips = h("div", {}, + h("div", { class: "chips" }, ...mp3Options.map((b) => h("button", { class: "chip", "aria-pressed": String(b === eff), onclick: () => patchSave({ mp3Bitrate: b }) }, `${b} kbps`))), + (caps.maxAbr || caps.mixed) && h("small", { style: "display:block;color:var(--text-3);margin-top:6px" }, + caps.mixed + ? `${plural(caps.cappedCount, "track")} only ${caps.cappedCount === 1 ? "has" : "have"} a ${caps.minAbr}${caps.maxAbr && caps.maxAbr !== caps.minAbr ? `–${caps.maxAbr}` : ""} kbps source, so ${caps.cappedCount === 1 ? "it's" : "they're"} encoded to match. Higher bitrates wouldn't add quality there.` + : `Up to ${snap(320, caps.maxAbr)} kbps, the best ${caps.count > 1 ? "these sources offer" : "this source offers"}.`) + ); + const heights = caps.heights.length ? caps.heights.filter((x) => x >= 360) : [2160, 1440, 1080, 720, 480]; + const vid = h("div", {}, + h("div", { class: "chips" }, h("button", { class: "chip", "aria-pressed": String(s.videoHeight === 0), onclick: () => patchSave({ videoHeight: 0 }) }, "Best"), ...heights.map((x) => h("button", { class: "chip", "aria-pressed": String(s.videoHeight === x), onclick: () => patchSave({ videoHeight: x }) }, `${x}p`))), + h("div", { class: "chips" }, ...["mp4", "mkv"].map((k) => h("button", { class: "chip", "aria-pressed": String(s.videoContainer === k), onclick: () => patchSave({ videoContainer: k }) }, k.toUpperCase()))) + ); + const lossless = h("div", { class: "chips" }, ...["flac", "wav"].map((k) => h("button", { class: "chip", "aria-pressed": String(s.saveAs === k), onclick: () => patchSave({ saveAs: k }) }, k.toUpperCase()))); + const noFf = !state.tools?.ffmpeg.path; + const ffNote = noFf ? " Needs ffmpeg." : ""; + const origDetail = caps.originals === 0 ? (caps.unknown ? "Checking whether the uploader offers one…" : "Not offered by the uploader") : caps.count === 1 ? "The uploader's own file, untouched" : `Offered for ${caps.originals} of ${caps.count}; the rest use best quality`; + const lossDetail = caps.losslessCount === 0 + ? `Uncompressed files, but no better than the source.${ffNote}` + : caps.losslessCount === caps.count + ? "Bit-for-bit from the lossless source." + : `Lossless for ${caps.losslessCount} of ${caps.count}; the rest can't exceed their ${caps.minAbr || "stream"} kbps source.`; + menu.replaceChildren(...[ + opt("best", "Best quality", caps.codec ? `Kept exactly as delivered: ${caps.codec}` : "Each item kept exactly as delivered, no re-encoding"), + opt("original", "Original file", origDetail, null, caps.originals === 0 && !caps.unknown), + h("div", { class: "menu-divider" }), + opt("mp3", "MP3", `Plays everywhere.${ffNote}`, mp3Chips, noFf), + opt("m4a", "M4A (AAC)", `Apple devices and iTunes. AAC sources are copied, not re-encoded.${ffNote}`, null, noFf), + opt(s.saveAs === "wav" ? "wav" : "flac", "Lossless: FLAC or WAV", lossDetail, lossless, noFf), + caps.anyVideo ? h("div", { class: "menu-divider" }) : null, + caps.anyVideo ? opt("video", "Video", caps.heights.length ? `Up to ${caps.heights[0]}p available${ffNote}` : `Picture and sound.${ffNote}`, vid, noFf) : null, + ].filter(Boolean)); +} + +function openSaveMenu() { + const menu = $("#saveMenu"); + menu.hidden = false; + $("#saveAsBtn").setAttribute("aria-expanded", "true"); + renderSaveMenu(); + const r = $("#saveAsBtn").getBoundingClientRect(); + menu.style.left = `${r.left}px`; + menu.style.top = `${Math.max(12, r.top - menu.offsetHeight - 8)}px`; + menu.querySelector(".opt[aria-checked='true']")?.focus(); +} + +function closeSaveMenu() { + $("#saveMenu").hidden = true; + $("#saveAsBtn").setAttribute("aria-expanded", "false"); +} + +/* commit bar */ +function bindCommit() { + $("#saveAsBtn").addEventListener("click", () => ($("#saveMenu").hidden ? openSaveMenu() : closeSaveMenu())); + $("#destBtn").addEventListener("click", chooseFolder); + $("#downloadBtn").addEventListener("click", startDownload); + $("#attest").addEventListener("change", () => $(".attest").classList.remove("nudge")); +} + +async function chooseFolder() { + const path = await invoke("pick_folder").catch(() => null); + if (!path) return; + state.settings = await invoke("save_settings", { patch: { outputDir: path } }); + updateCommit(); + renderSettings(); +} + +function updateCommit() { + const c = current(); + if (!c || !state.settings) return; + const caps = selectionCaps(c); + const n = caps.count; + const sep = state.settings.outputDir.includes("/") ? "/" : "\\"; + const folder = state.settings.collectionFolders ? folderFor(c) : null; + $("#saveAsValue").textContent = saveLabel(caps); + const sel = $("#destPlaylist"); + const lists = Lib.data?.playlists || []; + const keep = sel.value; + sel.replaceChildren(h("option", { value: "" }, "No playlist"), ...lists.map((p) => h("option", { value: p.name }, `+ ${p.name}`))); + sel.value = lists.some((p) => p.name === keep) ? keep : ""; + sel.hidden = lists.length === 0; + $("#destPath").textContent = folder ? `${state.settings.outputDir}${sep}${folder}` : state.settings.outputDir; + $("#attestText").textContent = n > 1 ? `I have the rights to these ${n}` : "I have the rights to this"; + const btn = $("#downloadBtn"); + btn.disabled = n === 0 || !state.tools?.ytdlp.path; + const noun = c.data.single ? (c.data.entries[0]?.media?.hasVideo && state.settings.saveAs === "video" ? "video" : "track") : isRelease(c) ? "track" : "item"; + btn.textContent = n === 0 ? "Select something" : n === 1 ? "Download" : `Download ${n} ${noun}s`; + renderSaveMenu(); +} + +async function startDownload() { + const c = current(); + if (!c || $("#downloadBtn").disabled) return; + if (!$("#attest").checked) { + const a = $(".attest"); + a.classList.remove("nudge"); + void a.offsetWidth; + a.classList.add("nudge"); + $("#attest").focus(); + return; + } + const ents = selectedEntries(c); + const folder = state.settings.collectionFolders ? folderFor(c) : null; + const playlist = $("#destPlaylist").value || null; + const jobs = ents.map((e) => ({ entry: e, meta: finalMeta(c, e), folder, trim: c.trims.get(e.index) || null, playlist })); + const s = state.settings; + try { + const ids = await invoke("enqueue", { jobs, save: { saveAs: s.saveAs, mp3Bitrate: s.mp3Bitrate, videoHeight: s.videoHeight, videoContainer: s.videoContainer }, attested: true }); + const group = { key: `${c.data.id}-${Date.now()}`, title: c.data.single ? jobs[0].meta.title : c.album.title || c.data.title, artist: c.data.single ? jobs[0].meta.artist : c.album.artist, thumb: c.album.preview || c.data.thumbnail, single: ids.length === 1, ids, started: Date.now() }; + ids.forEach((id, i) => { + const job = { id, req: jobs[i], save: { ...s }, group: group.key, num: numbered(c) ? position(c, ents[i]) : null, title: jobs[i].meta.title, state: "queued", ev: null }; + state.jobs.set(id, job); + const early = state.early.get(id); + if (early) { + state.early.delete(id); + applyJobEvent(job, early); + } + }); + state.groups.unshift(group); + fly($("#sheetCover")); + $("#attest").checked = false; + updateNav(); + if (state.view === "downloads") renderDownloads(); + } catch (e) { + toast(errText(e), "err"); + } +} + +function fly(from) { + const nav = $("#navDownloads"); + const land = () => { + nav.classList.remove("landed"); + void nav.offsetWidth; + nav.classList.add("landed"); + }; + if (!from || reduced.matches) return land(); + const a = from.getBoundingClientRect(), b = nav.querySelector(".nav-ring").getBoundingClientRect(); + const clone = from.tagName === "IMG" ? h("img", { src: from.src, alt: "" }) : h("div", { style: "background:var(--surface-2)" }); + clone.className = "flyer"; + Object.assign(clone.style, { left: `${a.left}px`, top: `${a.top}px`, width: `${a.width}px`, height: `${a.height}px` }); + document.body.append(clone); + const dx = b.left + b.width / 2 - (a.left + a.width / 2), dy = b.top + b.height / 2 - (a.top + a.height / 2), sc = 20 / a.width; + const anim = clone.animate([{ transform: "translate(0, 0) scale(1)", opacity: 1 }, { transform: `translate(${dx * 0.55}px, ${dy * 0.35 - 40}px) scale(${(1 + sc) / 2})`, opacity: 0.95, offset: 0.55 }, { transform: `translate(${dx}px, ${dy}px) scale(${sc})`, opacity: 0.2 }], { duration: 480, easing: "cubic-bezier(0.2, 0.8, 0.2, 1)" }); + anim.onfinish = () => { + clone.remove(); + land(); + }; +} + +/* jobs */ +function onJob(ev) { + const job = state.jobs.get(ev.id); + if (!job) return state.early.set(ev.id, ev); + applyJobEvent(job, ev); +} + +function applyJobEvent(job, ev) { + const was = job.state; + job.state = ev.state; + job.ev = ev; + if (ev.state === "done" && was !== "done") state.historyDirty = true; + scheduleDownloads(); +} + +let dlQueued = false; +function scheduleDownloads() { + if (dlQueued) return; + dlQueued = true; + requestAnimationFrame(() => { + dlQueued = false; + updateNav(); + if (state.view === "downloads") renderDownloads(); + }); +} + +function groupStats(g) { + const jobs = g.ids.map((id) => state.jobs.get(id)).filter(Boolean); + const done = jobs.filter((j) => j.state === "done" || j.state === "skipped").length; + const failed = jobs.filter((j) => j.state === "error").length; + const cancelled = jobs.filter((j) => j.state === "cancelled").length; + const active = jobs.filter((j) => ACTIVE.has(j.state)).length; + const progress = jobs.length ? jobs.reduce((a, j) => a + (FINAL.has(j.state) ? 1 : j.ev?.progress || 0), 0) / jobs.length : 0; + return { jobs, done, failed, cancelled, active, progress }; +} + +function updateNav() { + const groups = state.groups.map(groupStats); + const active = groups.reduce((a, g) => a + g.active, 0); + const live = groups.filter((g) => g.active > 0); + const p = live.length ? live.reduce((a, g) => a + g.progress * g.jobs.length, 0) / live.reduce((a, g) => a + g.jobs.length, 0) : 0; + $("#navDownloads").classList.toggle("busy", active > 0); + $("#navRing").style.strokeDashoffset = String(53.4 * (1 - p)); + $("#navCount").hidden = active === 0; + $("#navCount").textContent = String(active); +} + +function jobStatus(j) { + const ev = j.ev || {}; + const fmt = ev.format ? `${ev.format} · ` : ""; + switch (j.state) { + case "queued": return ["Waiting", ""]; + case "preparing": return ["Preparing…", ""]; + case "downloading": { + const size = ev.total ? `${fmtBytes(ev.received)} of ${fmtBytes(ev.total)}` : fmtBytes(ev.received); + return [`${size}${ev.speed ? ` · ${fmtBytes(ev.speed)}/s` : ""}`, ""]; + } + case "processing": return [`${fmt}Converting and embedding…`, ""]; + case "tagging": return ["Writing your tags…", ""]; + case "done": return [`Saved · ${ev.format || ""}`, "ok"]; + case "skipped": return [ev.message || "Already downloaded", "ok"]; + case "cancelled": return ["Cancelled", ""]; + case "error": return [ev.message || "Failed", "err"]; + default: return [j.state, ""]; + } +} + +function jobRow(j) { + const [text, cls] = jobStatus(j); + const ev = j.ev || {}; + const indet = j.state === "preparing" || j.state === "processing" || j.state === "tagging" || (j.state === "downloading" && !ev.total && !ev.progress); + const right = h("div", { class: "job-right" }, h("span", { class: `job-status ${cls}`, title: text }, text)); + if (ACTIVE.has(j.state) && j.state !== "queued") right.append(progressBar(indet ? null : ev.progress || 0)); + const acts = ACTIVE.has(j.state) + ? h("button", { class: "icon-btn", "aria-label": `Cancel ${j.title}`, onclick: () => invoke("cancel", { id: j.id }) }, icon("x")) + : j.state === "error" || j.state === "cancelled" + ? h("button", { class: "icon-btn", "aria-label": `Retry ${j.title}`, onclick: () => retry([j]) }, icon("refresh")) + : ev.path ? h("button", { class: "icon-btn", "aria-label": "Show in folder", onclick: () => invoke("reveal", { path: ev.path }) }, icon("folder")) : h("span"); + const li = h("li", { class: "job" }, h("span", { class: "tl-num" }, j.num ?? ""), h("span", { class: "job-title", title: j.title }, j.title), right, acts); + if (j.state === "done" && ev.message) li.append(h("div", { class: "job-note" }, ev.message)); + return li; +} + +async function retry(jobs) { + if (!jobs.length) return; + try { + const s = jobs[0].save; + const ids = await invoke("enqueue", { jobs: jobs.map((j) => j.req), save: { saveAs: s.saveAs, mp3Bitrate: s.mp3Bitrate, videoHeight: s.videoHeight, videoContainer: s.videoContainer }, attested: true }); + jobs.forEach((j, i) => { + const g = state.groups.find((x) => x.key === j.group); + state.jobs.delete(j.id); + const nj = { ...j, id: ids[i], state: "queued", ev: null }; + state.jobs.set(ids[i], nj); + if (g) g.ids = g.ids.map((x) => (x === j.id ? ids[i] : x)); + }); + scheduleDownloads(); + } catch (e) { + toast(errText(e), "err"); + } +} + +async function renderDownloads(refresh = false) { + const groups = state.groups.map((g) => ({ g, st: groupStats(g) })); + const attention = groups.filter(({ st }) => st.active > 0 || st.failed > 0 || st.cancelled > 0); + const active = groups.reduce((a, x) => a + x.st.active, 0); + $("#downloadsSub").textContent = active ? `${plural(active, "download")} in progress` : attention.length ? "Some downloads need attention" : "Nothing in progress"; + $("#cancelAllBtn").hidden = active === 0; + $("#activeGroups").replaceChildren(...attention.map(({ g, st }) => groupCard(g, st))); + if (refresh || state.historyDirty) { + state.historyDirty = false; + state.history = await invoke("history_list").catch(() => []); + renderHistory(); + } + $("#emptyDownloads").hidden = attention.length > 0 || state.history.length > 0; + $("#historySection").hidden = state.history.length === 0; +} + +function groupCard(g, st) { + const n = st.jobs.length; + const sub = st.active ? `${st.done} of ${n} done · ${Math.round(st.progress * 100)}%` : [st.done && `${st.done} saved`, st.failed && `${st.failed} failed`, st.cancelled && `${st.cancelled} cancelled`].filter(Boolean).join(" · "); + const failed = st.jobs.filter((j) => j.state === "error" || j.state === "cancelled"); + const action = st.active + ? h("button", { class: "btn small ghost", onclick: () => st.jobs.filter((j) => ACTIVE.has(j.state)).forEach((j) => invoke("cancel", { id: j.id })) }, "Cancel") + : h("div", { class: "row" }, + failed.length > 0 && h("button", { class: "btn small", onclick: () => retry(failed) }, icon("refresh"), failed.length > 1 ? `Retry ${failed.length}` : "Retry"), + h("button", { class: "btn small ghost", onclick: () => { state.groups = state.groups.filter((x) => x !== g); renderDownloads(); } }, "Dismiss")); + const card = h("article", { class: "group-card" }, + h("div", { class: "gc-head" }, art(g.thumb, "thumb"), h("div", { style: "min-width:0" }, h("div", { class: "gc-title" }, g.title), h("div", { class: "gc-sub" }, [g.artist, sub].filter(Boolean).join(" · "))), action) + ); + if (n > 1) { + card.append(h("div", { class: "gc-bar" }, progressBar(st.progress, st.failed && !st.active ? "err" : ""))); + card.append(h("ul", { class: "jobs" }, ...st.jobs.map(jobRow))); + } else if (st.jobs[0]) { + card.append(h("ul", { class: "jobs" }, jobRow(st.jobs[0]))); + } + return card; +} + +function renderHistory() { + const list = $("#historyList"); + const out = []; + let day = null; + for (const r of state.history.slice(0, 400)) { + const d = dayLabel(r.at); + if (d !== day) { + day = d; + out.push(h("h3", { class: "day" }, d)); + } + const missing = !r.path; + out.push( + h("div", { class: `hist ${missing ? "missing" : ""}`, "data-hist": r.id }, + art(r.thumbnail, "thumb"), + h("div", { style: "min-width:0" }, h("div", { class: "t" }, r.title), h("div", { class: "m" }, [r.artist, r.format, missing ? "File moved or deleted" : null].filter(Boolean).join(" · "))), + h("span", { class: "when" }, timeFmt.format(new Date(r.at))), + h("div", { class: "acts" }, + !missing && h("button", { class: "icon-btn", "aria-label": "Show in folder", onclick: () => invoke("reveal", { path: r.path }) }, icon("folder")), + r.url && h("button", { class: "icon-btn", "aria-label": "Open source page", onclick: () => invoke("open_link", { url: r.url }) }, icon("external-link")), + h("button", { class: "icon-btn", "aria-label": "Remove from history", onclick: async () => { await invoke("history_remove", { ids: [r.id] }); state.history = state.history.filter((x) => x !== r); renderHistory(); } }, icon("trash"))) + ) + ); + } + list.replaceChildren(...out); +} + +/* settings */ +let savedTimer; +async function patch(p) { + try { + state.settings = await invoke("save_settings", { patch: p }); + applyTheme(); + const f = $("#savedFlag"); + f.textContent = "Saved"; + f.classList.add("on"); + clearTimeout(savedTimer); + savedTimer = setTimeout(() => f.classList.remove("on"), 1400); + updateCommit(); + if ("ytdlpPath" in p || "ffmpegPath" in p) refreshTools(); + } catch (e) { + toast(errText(e), "err"); + } +} + +const TOKENS = ["{artist}", "{title}", "{album}", "{albumartist}", "{index}", "{year}", "{genre}", "{collection}", "{platform}"]; +function bindSettings() { + $$("[data-key]").forEach((el) => { + const key = el.dataset.key; + el.addEventListener("change", () => patch({ [key]: el.type === "checkbox" ? el.checked : el.value.trim() })); + }); + $("#templateInput").addEventListener("input", renderTemplatePreview); + $("#tokens").replaceChildren( + ...TOKENS.map((t) => + h("button", { type: "button", onclick: () => { + const inp = $("#templateInput"); + const at = inp.selectionStart ?? inp.value.length; + inp.value = inp.value.slice(0, at) + t + inp.value.slice(inp.selectionEnd ?? at); + inp.focus(); + inp.setSelectionRange(at + t.length, at + t.length); + renderTemplatePreview(); + patch({ filenameTemplate: inp.value }); + } }, t) + ) + ); + $$(".stepper button").forEach((b) => b.addEventListener("click", () => patch({ concurrency: Math.max(1, Math.min(8, state.settings.concurrency + Number(b.dataset.step))) }).then(renderSettings))); + $$("[data-seg=theme] button").forEach((b) => b.addEventListener("click", () => patch({ theme: b.dataset.value }).then(renderSettings))); + $("#setDirBtn").addEventListener("click", chooseFolder); + $("#openFolderBtn").addEventListener("click", () => invoke("reveal", { path: state.settings.outputDir })); + $("#cancelAllBtn").addEventListener("click", () => invoke("cancel_all")); + $("#clearHistory").addEventListener("click", async () => { + await invoke("history_clear"); + state.history = []; + renderDownloads(); + }); + $("#revokeBtn").addEventListener("click", async () => { + state.settings = await invoke("revoke_rights"); + $$(".pledge-check").forEach((c) => (c.checked = false)); + $("#obAccept").disabled = true; + showOnboarding(1); + }); +} + +function renderTemplatePreview() { + const t = $("#templateInput").value || "{artist} - {title}"; + const c = current(); + const e = c?.data.entries.find((x) => c.selected.has(x.index)) || c?.data.entries[0]; + const m = c && e ? finalMeta(c, e) : { artist: "Nova Lumen", title: "Night Drive", album: "Glass", albumArtist: "Nova Lumen", trackNumber: 3, trackTotal: 12, date: "2021", genre: "Ambient" }; + const idx = m.trackNumber ? String(m.trackNumber).padStart(Math.max(2, String(m.trackTotal || "").length), "0") : ""; + let name = t.replace("{artist}", m.artist).replace("{title}", m.title).replace("{album}", m.album || "").replace("{albumartist}", m.albumArtist || "").replace("{index}", idx).replace("{year}", (m.date || "").slice(0, 4)).replace("{genre}", m.genre || "").replace("{collection}", c ? folderFor(c) || "" : "Glass").replace("{platform}", e?.platform || "SoundCloud"); + if (state.settings.numberTracks && idx && !t.includes("{index}") && (!c || folderFor(c))) name = `${idx} - ${name}`; + $("#templatePreview").textContent = `${name.replace(/[<>:"/\\|?*]/g, "_")}.mp3`; +} + +function renderSettings() { + const s = state.settings; + if (!s) return; + $$("[data-key]").forEach((el) => { + const v = s[el.dataset.key]; + if (el.type === "checkbox") el.checked = !!v; + else if (document.activeElement !== el) el.value = v ?? ""; + }); + $("#setDir").textContent = s.outputDir; + $("#concValue").textContent = String(s.concurrency); + $$("[data-seg=theme] button").forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.value === s.theme))); + const at = s.rightsAcceptedAt ? new Intl.DateTimeFormat(undefined, { dateStyle: "long" }).format(new Date(s.rightsAcceptedAt * 1000)) : ""; + $("#rightsInfo").textContent = at ? `You confirmed it on ${at}. Withdrawing it cancels downloads and asks again.` : "Not confirmed yet."; + renderTemplatePreview(); + renderToolSettings(); + renderLibrarySettings(); + renderLyricsSettings(); + renderStorage(); +} + +function renderToolSettings() { + const t = state.tools; + if (!t || !$("#toolYtdlp")) return; + const card = (key, tool, name, desc) => { + const busy = state.installing[key]; + const status = tool.path ? `${tool.version ? tool.version + " · " : ""}${tool.managed ? "Managed by Atmosphere" : "Your copy"}` : desc; + const acts = h("div", { class: "acts" }); + if (busy) acts.append(progressBar(busy.total ? busy.received / busy.total : null)); + else if (!tool.path) acts.append(h("button", { class: "btn primary", disabled: key === "ffmpeg" && !t.canInstallFfmpeg, onclick: () => installTool(key) }, "Install")); + else if (key === "ytdlp") acts.append(h("button", { class: "btn", onclick: async (ev) => { const b = ev.currentTarget; b.classList.add("loading"); b.disabled = true; try { toast(await invoke("update_ytdlp"), "ok"); await refreshTools(); } catch (e) { toast(errText(e), "err"); } finally { b.disabled = false; b.classList.remove("loading"); } } }, h("span", { class: "label" }, "Check for update"), h("span", { class: "spin" }))); + else if (tool.managed) acts.append(h("button", { class: "btn", onclick: () => installTool(key) }, "Reinstall")); + return [h("div", {}, h("strong", { class: "name" }, h("span", { class: `dot ${tool.path ? "ok" : "warn"}` }), name), h("span", {}, status)), acts]; + }; + $("#toolYtdlp").replaceChildren(...card("ytdlp", t.ytdlp, "yt-dlp", "Not installed. Needed to read any link.")); + $("#toolFfmpeg").replaceChildren(...card("ffmpeg", t.ffmpeg, "ffmpeg", t.canInstallFfmpeg ? "Not installed. Needed for MP3, M4A, FLAC, WAV, video and cover art." : isMac ? "Install it with Homebrew (brew install ffmpeg). Atmosphere finds it automatically." : "Install it with your package manager, then restart.")); +} + +window.addEventListener("DOMContentLoaded", () => init().catch((e) => toast(errText(e), "err"))); diff --git a/ui/assets/icons/adjustments-horizontal.svg b/ui/assets/icons/adjustments-horizontal.svg new file mode 100644 index 0000000..535634a --- /dev/null +++ b/ui/assets/icons/adjustments-horizontal.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/alert-circle.svg b/ui/assets/icons/alert-circle.svg new file mode 100644 index 0000000..bdc674e --- /dev/null +++ b/ui/assets/icons/alert-circle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/arrow-down-circle.svg b/ui/assets/icons/arrow-down-circle.svg new file mode 100644 index 0000000..0bd4291 --- /dev/null +++ b/ui/assets/icons/arrow-down-circle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/arrow-left.svg b/ui/assets/icons/arrow-left.svg new file mode 100644 index 0000000..5e1cd17 --- /dev/null +++ b/ui/assets/icons/arrow-left.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/arrow-right.svg b/ui/assets/icons/arrow-right.svg new file mode 100644 index 0000000..3911275 --- /dev/null +++ b/ui/assets/icons/arrow-right.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/arrows-shuffle.svg b/ui/assets/icons/arrows-shuffle.svg new file mode 100644 index 0000000..526e832 --- /dev/null +++ b/ui/assets/icons/arrows-shuffle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/arrows-sort.svg b/ui/assets/icons/arrows-sort.svg new file mode 100644 index 0000000..3a7f2fd --- /dev/null +++ b/ui/assets/icons/arrows-sort.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/brand-bandcamp.svg b/ui/assets/icons/brand-bandcamp.svg new file mode 100644 index 0000000..d3e5541 --- /dev/null +++ b/ui/assets/icons/brand-bandcamp.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/brand-instagram.svg b/ui/assets/icons/brand-instagram.svg new file mode 100644 index 0000000..91124c1 --- /dev/null +++ b/ui/assets/icons/brand-instagram.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/brand-soundcloud.svg b/ui/assets/icons/brand-soundcloud.svg new file mode 100644 index 0000000..936bbeb --- /dev/null +++ b/ui/assets/icons/brand-soundcloud.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/brand-tiktok.svg b/ui/assets/icons/brand-tiktok.svg new file mode 100644 index 0000000..11e565d --- /dev/null +++ b/ui/assets/icons/brand-tiktok.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/brand-twitch.svg b/ui/assets/icons/brand-twitch.svg new file mode 100644 index 0000000..7647bb5 --- /dev/null +++ b/ui/assets/icons/brand-twitch.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/brand-vimeo.svg b/ui/assets/icons/brand-vimeo.svg new file mode 100644 index 0000000..5856dde --- /dev/null +++ b/ui/assets/icons/brand-vimeo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/brand-x.svg b/ui/assets/icons/brand-x.svg new file mode 100644 index 0000000..c55b05f --- /dev/null +++ b/ui/assets/icons/brand-x.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/brand-youtube.svg b/ui/assets/icons/brand-youtube.svg new file mode 100644 index 0000000..75583a9 --- /dev/null +++ b/ui/assets/icons/brand-youtube.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/calendar.svg b/ui/assets/icons/calendar.svg new file mode 100644 index 0000000..e6588e8 --- /dev/null +++ b/ui/assets/icons/calendar.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/chart-bar.svg b/ui/assets/icons/chart-bar.svg new file mode 100644 index 0000000..0582b9c --- /dev/null +++ b/ui/assets/icons/chart-bar.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/check.svg b/ui/assets/icons/check.svg new file mode 100644 index 0000000..3dc7be0 --- /dev/null +++ b/ui/assets/icons/check.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/chevron-down.svg b/ui/assets/icons/chevron-down.svg new file mode 100644 index 0000000..b9c6043 --- /dev/null +++ b/ui/assets/icons/chevron-down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/chevron-left.svg b/ui/assets/icons/chevron-left.svg new file mode 100644 index 0000000..6e63608 --- /dev/null +++ b/ui/assets/icons/chevron-left.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/chevron-right.svg b/ui/assets/icons/chevron-right.svg new file mode 100644 index 0000000..bffbb92 --- /dev/null +++ b/ui/assets/icons/chevron-right.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/circle-check.svg b/ui/assets/icons/circle-check.svg new file mode 100644 index 0000000..8f55475 --- /dev/null +++ b/ui/assets/icons/circle-check.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/clipboard.svg b/ui/assets/icons/clipboard.svg new file mode 100644 index 0000000..c9577e5 --- /dev/null +++ b/ui/assets/icons/clipboard.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/clock.svg b/ui/assets/icons/clock.svg new file mode 100644 index 0000000..116c8df --- /dev/null +++ b/ui/assets/icons/clock.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/cloud-download.svg b/ui/assets/icons/cloud-download.svg new file mode 100644 index 0000000..771d2df --- /dev/null +++ b/ui/assets/icons/cloud-download.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/copy.svg b/ui/assets/icons/copy.svg new file mode 100644 index 0000000..589dc02 --- /dev/null +++ b/ui/assets/icons/copy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/device-tv.svg b/ui/assets/icons/device-tv.svg new file mode 100644 index 0000000..38f87b0 --- /dev/null +++ b/ui/assets/icons/device-tv.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/disc-filled.svg b/ui/assets/icons/disc-filled.svg new file mode 100644 index 0000000..c0408da --- /dev/null +++ b/ui/assets/icons/disc-filled.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/disc.svg b/ui/assets/icons/disc.svg new file mode 100644 index 0000000..ec91fe1 --- /dev/null +++ b/ui/assets/icons/disc.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/dots.svg b/ui/assets/icons/dots.svg new file mode 100644 index 0000000..67cc7f7 --- /dev/null +++ b/ui/assets/icons/dots.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/download.svg b/ui/assets/icons/download.svg new file mode 100644 index 0000000..6e08968 --- /dev/null +++ b/ui/assets/icons/download.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/external-link.svg b/ui/assets/icons/external-link.svg new file mode 100644 index 0000000..66ab71c --- /dev/null +++ b/ui/assets/icons/external-link.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/file-music.svg b/ui/assets/icons/file-music.svg new file mode 100644 index 0000000..610bd43 --- /dev/null +++ b/ui/assets/icons/file-music.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/flame.svg b/ui/assets/icons/flame.svg new file mode 100644 index 0000000..53a6a3b --- /dev/null +++ b/ui/assets/icons/flame.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/folder-open.svg b/ui/assets/icons/folder-open.svg new file mode 100644 index 0000000..6bfb3aa --- /dev/null +++ b/ui/assets/icons/folder-open.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/folder-plus.svg b/ui/assets/icons/folder-plus.svg new file mode 100644 index 0000000..05f6b4a --- /dev/null +++ b/ui/assets/icons/folder-plus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/folder.svg b/ui/assets/icons/folder.svg new file mode 100644 index 0000000..6c329a5 --- /dev/null +++ b/ui/assets/icons/folder.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/headphones.svg b/ui/assets/icons/headphones.svg new file mode 100644 index 0000000..757dc2d --- /dev/null +++ b/ui/assets/icons/headphones.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/heart-filled.svg b/ui/assets/icons/heart-filled.svg new file mode 100644 index 0000000..1911b47 --- /dev/null +++ b/ui/assets/icons/heart-filled.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/heart.svg b/ui/assets/icons/heart.svg new file mode 100644 index 0000000..743d756 --- /dev/null +++ b/ui/assets/icons/heart.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/info-circle.svg b/ui/assets/icons/info-circle.svg new file mode 100644 index 0000000..397462b --- /dev/null +++ b/ui/assets/icons/info-circle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/layout-grid.svg b/ui/assets/icons/layout-grid.svg new file mode 100644 index 0000000..a442d05 --- /dev/null +++ b/ui/assets/icons/layout-grid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/link.svg b/ui/assets/icons/link.svg new file mode 100644 index 0000000..ace9357 --- /dev/null +++ b/ui/assets/icons/link.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/list-details.svg b/ui/assets/icons/list-details.svg new file mode 100644 index 0000000..450f8f9 --- /dev/null +++ b/ui/assets/icons/list-details.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/list.svg b/ui/assets/icons/list.svg new file mode 100644 index 0000000..f7dd024 --- /dev/null +++ b/ui/assets/icons/list.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/loader-2.svg b/ui/assets/icons/loader-2.svg new file mode 100644 index 0000000..4f8255e --- /dev/null +++ b/ui/assets/icons/loader-2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/maximize.svg b/ui/assets/icons/maximize.svg new file mode 100644 index 0000000..f04b26e --- /dev/null +++ b/ui/assets/icons/maximize.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/microphone-2.svg b/ui/assets/icons/microphone-2.svg new file mode 100644 index 0000000..de5ab73 --- /dev/null +++ b/ui/assets/icons/microphone-2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/microphone.svg b/ui/assets/icons/microphone.svg new file mode 100644 index 0000000..329ae9f --- /dev/null +++ b/ui/assets/icons/microphone.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/minimize.svg b/ui/assets/icons/minimize.svg new file mode 100644 index 0000000..d408e63 --- /dev/null +++ b/ui/assets/icons/minimize.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/music.svg b/ui/assets/icons/music.svg new file mode 100644 index 0000000..6f23f1b --- /dev/null +++ b/ui/assets/icons/music.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/pencil.svg b/ui/assets/icons/pencil.svg new file mode 100644 index 0000000..9d10ad8 --- /dev/null +++ b/ui/assets/icons/pencil.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/photo-down.svg b/ui/assets/icons/photo-down.svg new file mode 100644 index 0000000..1a1b984 --- /dev/null +++ b/ui/assets/icons/photo-down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/photo.svg b/ui/assets/icons/photo.svg new file mode 100644 index 0000000..4fb7f89 --- /dev/null +++ b/ui/assets/icons/photo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/player-pause-filled.svg b/ui/assets/icons/player-pause-filled.svg new file mode 100644 index 0000000..42d6b78 --- /dev/null +++ b/ui/assets/icons/player-pause-filled.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/player-play-filled.svg b/ui/assets/icons/player-play-filled.svg new file mode 100644 index 0000000..f71c79c --- /dev/null +++ b/ui/assets/icons/player-play-filled.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/player-play.svg b/ui/assets/icons/player-play.svg new file mode 100644 index 0000000..6b8d795 --- /dev/null +++ b/ui/assets/icons/player-play.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/player-skip-back-filled.svg b/ui/assets/icons/player-skip-back-filled.svg new file mode 100644 index 0000000..3c74fdf --- /dev/null +++ b/ui/assets/icons/player-skip-back-filled.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/player-skip-forward-filled.svg b/ui/assets/icons/player-skip-forward-filled.svg new file mode 100644 index 0000000..d7d39f9 --- /dev/null +++ b/ui/assets/icons/player-skip-forward-filled.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/playlist-add.svg b/ui/assets/icons/playlist-add.svg new file mode 100644 index 0000000..ca83499 --- /dev/null +++ b/ui/assets/icons/playlist-add.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/playlist.svg b/ui/assets/icons/playlist.svg new file mode 100644 index 0000000..9f8137d --- /dev/null +++ b/ui/assets/icons/playlist.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/plus.svg b/ui/assets/icons/plus.svg new file mode 100644 index 0000000..7d2c7a4 --- /dev/null +++ b/ui/assets/icons/plus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/refresh.svg b/ui/assets/icons/refresh.svg new file mode 100644 index 0000000..471983d --- /dev/null +++ b/ui/assets/icons/refresh.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/repeat-once.svg b/ui/assets/icons/repeat-once.svg new file mode 100644 index 0000000..1f8dd86 --- /dev/null +++ b/ui/assets/icons/repeat-once.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/repeat.svg b/ui/assets/icons/repeat.svg new file mode 100644 index 0000000..096eaa5 --- /dev/null +++ b/ui/assets/icons/repeat.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/scissors.svg b/ui/assets/icons/scissors.svg new file mode 100644 index 0000000..fa42b20 --- /dev/null +++ b/ui/assets/icons/scissors.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/search.svg b/ui/assets/icons/search.svg new file mode 100644 index 0000000..aa15330 --- /dev/null +++ b/ui/assets/icons/search.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/settings.svg b/ui/assets/icons/settings.svg new file mode 100644 index 0000000..86c18e2 --- /dev/null +++ b/ui/assets/icons/settings.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/share.svg b/ui/assets/icons/share.svg new file mode 100644 index 0000000..6ee03cb --- /dev/null +++ b/ui/assets/icons/share.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/sparkles.svg b/ui/assets/icons/sparkles.svg new file mode 100644 index 0000000..0aa8710 --- /dev/null +++ b/ui/assets/icons/sparkles.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/trash.svg b/ui/assets/icons/trash.svg new file mode 100644 index 0000000..ec1367e --- /dev/null +++ b/ui/assets/icons/trash.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/user-circle.svg b/ui/assets/icons/user-circle.svg new file mode 100644 index 0000000..aa03d57 --- /dev/null +++ b/ui/assets/icons/user-circle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/user.svg b/ui/assets/icons/user.svg new file mode 100644 index 0000000..3e825a5 --- /dev/null +++ b/ui/assets/icons/user.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/volume-off.svg b/ui/assets/icons/volume-off.svg new file mode 100644 index 0000000..1701532 --- /dev/null +++ b/ui/assets/icons/volume-off.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/volume.svg b/ui/assets/icons/volume.svg new file mode 100644 index 0000000..b20de4a --- /dev/null +++ b/ui/assets/icons/volume.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/wave-sine.svg b/ui/assets/icons/wave-sine.svg new file mode 100644 index 0000000..e36f4d0 --- /dev/null +++ b/ui/assets/icons/wave-sine.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/world.svg b/ui/assets/icons/world.svg new file mode 100644 index 0000000..36b6ecf --- /dev/null +++ b/ui/assets/icons/world.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/icons/x.svg b/ui/assets/icons/x.svg new file mode 100644 index 0000000..32f1b74 --- /dev/null +++ b/ui/assets/icons/x.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ui/assets/lockup-dark.svg b/ui/assets/lockup-dark.svg new file mode 100644 index 0000000..5ebdabb --- /dev/null +++ b/ui/assets/lockup-dark.svg @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui/assets/lockup-light.svg b/ui/assets/lockup-light.svg new file mode 100644 index 0000000..58f53ce --- /dev/null +++ b/ui/assets/lockup-light.svg @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui/assets/mark.svg b/ui/assets/mark.svg new file mode 100644 index 0000000..abd9dfd --- /dev/null +++ b/ui/assets/mark.svg @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui/icons.js b/ui/icons.js new file mode 100644 index 0000000..18e8d40 --- /dev/null +++ b/ui/icons.js @@ -0,0 +1,2 @@ +/* atmosphere · icons.js · Tabler icon set (MIT, via Iconify) bundled as inline SVG markup for the UI. */ +window.ICONS = {"adjustments-horizontal":"","alert-circle":"","arrow-down-circle":"","arrow-left":"","arrow-right":"","arrows-shuffle":"","arrows-sort":"","brand-bandcamp":"","brand-instagram":"","brand-soundcloud":"","brand-tiktok":"","brand-twitch":"","brand-vimeo":"","brand-x":"","brand-youtube":"","calendar":"","chart-bar":"","check":"","chevron-down":"","chevron-left":"","chevron-right":"","circle-check":"","clipboard":"","clock":"","cloud-download":"","copy":"","device-tv":"","disc-filled":"","disc":"","dots":"","download":"","external-link":"","file-music":"","flame":"","folder-open":"","folder-plus":"","folder":"","headphones":"","heart-filled":"","heart":"","info-circle":"","layout-grid":"","link":"","list-details":"","list":"","loader-2":"","maximize":"","microphone-2":"","microphone":"","minimize":"","music":"","pencil":"","photo-down":"","photo":"","player-pause-filled":"","player-play-filled":"","player-play":"","player-skip-back-filled":"","player-skip-forward-filled":"","playlist-add":"","playlist":"","plus":"","refresh":"","repeat-once":"","repeat":"","scissors":"","search":"","settings":"","share":"","sparkles":"","trash":"","user-circle":"","user":"","volume-off":"","volume":"","wave-sine":"","world":"","x":""}; diff --git a/ui/index.html b/ui/index.html new file mode 100644 index 0000000..6ed4eb0 --- /dev/null +++ b/ui/index.html @@ -0,0 +1,338 @@ + + + + + + + Atmosphere + + + +
+
+ Atmosphere + Atmosphere +
+
+
+ + + +
+
+
+ + +
+
+
+
+ + + + +
+ + + +
+ +
+ + +
+ +

Paste a link to begin

+

Drop in anything you have the rights to keep. Atmosphere reads it, shows you exactly what's available, and saves it tagged and named.

+
    +
  • A track or videoSaved as one file, with its cover and details.
  • +
  • An album, EP or playlistDetected, numbered in order, kept in one folder.
  • +
  • A profile or channelEvery upload, listed so you can pick.
  • +
+

Tip: drag a link onto this window, or press Ctrl V anywhere.

+
+ + +
+ +
+ + + + + +
+
+ + + + + + +
+
+ +
+
+
+
+ +
+
+
+ + + + + +
+
0:000:00
+
+
+ + + + + + +
+
+ + + + + + + + + + + +
+ + + + + + + + + + diff --git a/ui/library.js b/ui/library.js new file mode 100644 index 0000000..3e332e5 --- /dev/null +++ b/ui/library.js @@ -0,0 +1,921 @@ +/* atmosphere · library.js · Library views (songs, albums, artists, playlists, liked), context menu, dialogs and library/storage settings. */ +const Lib = { + data: null, + byId: new Map(), + songs: [], + albums: new Map(), + artists: new Map(), + liked: new Set(), + plays: {}, + route: { name: "songs" }, + back: [], + filter: "", + sort: { key: "artist", dir: 1 }, + scan: null, + drawSongs: null, + sel: new Set(), + anchor: -1, + currentList: [], +}; + +const lnorm = (s) => (s || "").trim().toLowerCase(); +const primaryArtist = (s) => (s || "").split(/\s*(?:,|;|\bfeat\.?|\bft\.?|\bfeaturing\b)\s*/i)[0].trim() || "Unknown artist"; +const artistsOf = (t) => [...new Set([t.albumArtist, ...(t.artist || "").split(/\s*(?:,|;|\bfeat\.?|\bft\.?|\bfeaturing\b)\s*/i)].map((x) => (x || "").trim()).filter(Boolean))]; +const sig = (t) => `${lnorm(t.title)}|${lnorm(primaryArtist(t.artist))}|${Math.round((t.durationMs || 0) / 2000)}`; +const albumKind = (a) => { + const mins = a.duration / 60000; + return a.tracks.length <= 3 && mins < 30 ? "Single" : a.tracks.length <= 6 && mins < 30 ? "EP" : "Album"; +}; + +function buildIndexes(snap) { + Lib.data = snap; + Lib.byId = new Map(snap.tracks.map((t) => [t.id, t])); + Lib.liked = new Set(snap.liked); + Lib.plays = snap.plays || {}; + const main = new Set(snap.tracks.filter((t) => !t.playlist).map(sig)); + Lib.songs = snap.tracks.filter((t) => !t.playlist || !main.has(sig(t))); + const albums = new Map(); + for (const t of Lib.songs) { + if (!t.album) continue; + const artist = t.albumArtist || primaryArtist(t.artist); + const key = `${lnorm(artist)}|${lnorm(t.album)}`; + let a = albums.get(key); + if (!a) albums.set(key, (a = { key, title: t.album, artist, year: t.year, art: t.art, tracks: [], duration: 0 })); + a.tracks.push(t); + a.duration += t.durationMs || 0; + a.art ||= t.art; + a.year ||= t.year; + } + for (const a of albums.values()) a.tracks.sort((x, y) => (x.discNo || 1) - (y.discNo || 1) || (x.trackNo || 999) - (y.trackNo || 999) || x.title.localeCompare(y.title)); + Lib.albums = albums; + const metaByName = new Map(Object.values(snap.artists || {}).map((m) => [lnorm(m.name), m])); + const artists = new Map(); + const touch = (name) => { + const k = lnorm(name); + if (!artists.has(k)) artists.set(k, { key: k, name, meta: metaByName.get(k) || null, albums: [], tracks: [], appearsOn: [] }); + return artists.get(k); + }; + for (const a of albums.values()) touch(a.artist).albums.push(a); + for (const t of Lib.songs) for (const n of artistsOf(t)) touch(n).tracks.push(t); + for (const a of albums.values()) { + for (const n of new Set(a.tracks.flatMap(artistsOf))) { + const ar = artists.get(lnorm(n)); + if (ar && lnorm(a.artist) !== ar.key && !ar.appearsOn.includes(a)) ar.appearsOn.push(a); + } + } + for (const ar of artists.values()) ar.albums.sort((x, y) => (y.year || 0) - (x.year || 0)); + Lib.artists = artists; +} + +async function loadLibrary() { + const snap = await invoke("library_get").catch(() => null); + if (!snap) return; + buildIndexes(snap); + for (const id of [...Lib.sel]) if (!Lib.byId.has(id)) Lib.sel.delete(id); + if (!Lib.restored) { + Lib.restored = true; + Player.restore((id) => Lib.byId.get(id)); + if (Lib.songs.length && state.view === "get" && !state.collections.length) openLib("songs", null, false); + } else { + Player.refreshTracks((id) => Lib.byId.get(id) || null); + } + renderPlaylistNav(); + if (state.view === "library") renderLib(true); + if (typeof updateCommit === "function") updateCommit(); +} + +const artistImage = (ar) => ar?.meta?.image || ar?.albums.find((a) => a.art)?.art || ar?.tracks.find((t) => t.art)?.art || null; + +function cover(key, cls, alt = "") { + return art(artUrl(key), cls, alt); +} + +/* routing */ +function openLib(name, id = null, push = true) { + if (push && state.view === "library") Lib.back.push(Lib.route); + Lib.route = { name, id }; + Lib.filter = ""; + go("library"); + renderLib(); +} + +function libBack() { + const prev = Lib.back.pop(); + if (prev) { + Lib.route = prev; + renderLib(); + } +} + +function markLibNav() { + const r = Lib.route; + $$("[data-lib]").forEach((b) => (state.view === "library" && (b.dataset.lib === r.name || (r.name === "album" && b.dataset.lib === "albums") || (r.name === "artist" && b.dataset.lib === "artists")) ? b.setAttribute("aria-current", "page") : b.removeAttribute("aria-current"))); + $$("#playlistNav .nav-item").forEach((b) => (state.view === "library" && r.name === "playlist" && b.dataset.playlist === r.id ? b.setAttribute("aria-current", "page") : b.removeAttribute("aria-current"))); +} + +/* playback helpers */ +function playList(list, i = 0, shuffle = null) { + if (!list.length) return toast("Nothing to play here yet.", "err"); + Player.setQueue(list, i, shuffle); +} + +/* track rows */ +function likeBtn(t) { + const on = Lib.liked.has(t.id); + return h("button", { class: `icon-btn like ${on ? "on" : ""}`, "aria-label": on ? "Unlike" : "Like", "aria-pressed": String(on), onclick: (e) => { e.stopPropagation(); toggleLike(t); } }, icon(on ? "heart-filled" : "heart")); +} + +async function toggleLike(t) { + const on = !Lib.liked.has(t.id); + on ? Lib.liked.add(t.id) : Lib.liked.delete(t.id); + await invoke("track_like", { id: t.id, liked: on }).catch(() => {}); + $$(`.lt-row[data-id="${t.id}"] .like`).forEach((b) => b.replaceWith(likeBtn(t))); + updatePlayerBar(); + if (Lib.route.name === "liked") renderLib(true); +} + +function artistLinks(t) { + const names = artistsOf({ ...t, albumArtist: "" }); + const wrap = h("span", { class: "links" }); + names.forEach((n, i) => { + if (i) wrap.append(", "); + wrap.append(h("button", { class: "link", onclick: (e) => { e.stopPropagation(); openLib("artist", lnorm(n)); } }, n)); + }); + return wrap; +} + +function trackRow(t, i, ctx) { + const playing = Player.current?.id === t.id; + const label = ctx.numbers ? String(ctx.numbers(t, i)) : String(i + 1); + const row = h("div", { class: `lt-row ${playing ? "playing" : ""} ${ctx.cover ? "with-cover" : ""} ${Lib.sel.has(t.id) ? "sel" : ""}`, role: "row", "aria-selected": String(Lib.sel.has(t.id)), "data-id": t.id, "data-i": i, "data-num": label, draggable: "true", tabindex: "-1", + onclick: (e) => selectRow(e, t, i, ctx), + ondblclick: () => playList(ctx.list, i), + oncontextmenu: (e) => { e.preventDefault(); if (!Lib.sel.has(t.id)) selectRow({}, t, i, ctx); trackMenu(e, t, ctx, i); }, + onkeydown: (e) => { if (e.key === "Enter") playList(ctx.list, i); }, + }, + h("span", { class: "lt-num" }, playing ? eqBars() : label, + h("button", { class: "lt-play", "aria-label": `Play ${t.title}`, onclick: (e) => { e.stopPropagation(); playList(ctx.list, i); } }, icon("player-play-filled"))), + ctx.cover ? cover(t.art, "lt-cover") : null, + h("div", { class: "lt-main" }, h("span", { class: "lt-title" }, t.title), ctx.hideArtist && !ctx.showArtistFor?.(t) ? null : h("span", { class: "lt-sub" }, artistLinks(t))), + ctx.hideAlbum ? h("span") : h("span", { class: "lt-album" }, t.album ? h("button", { class: "link", onclick: (e) => { e.stopPropagation(); openLib("album", `${lnorm(t.albumArtist || primaryArtist(t.artist))}|${lnorm(t.album)}`); } }, t.album) : ""), + likeBtn(t), + h("span", { class: "lt-dur" }, fmtDur(t.durationMs)), + ctx.playlist ? h("button", { class: "icon-btn", "aria-label": "Remove from playlist", onclick: (e) => { e.stopPropagation(); removeFromPlaylist(ctx.playlist, [t]); } }, icon("x")) : h("button", { class: "icon-btn", "aria-label": "More", onclick: (e) => { e.stopPropagation(); trackMenu(e, t, ctx, i); } }, icon("dots")) + ); + row.addEventListener("dragstart", (e) => { + const ids = Lib.sel.has(t.id) && Lib.sel.size > 1 ? [...Lib.sel] : [t.id]; + e.dataTransfer.setData("application/x-atmo-tracks", JSON.stringify(ids)); + e.dataTransfer.setData("text/plain", t.title); + e.dataTransfer.effectAllowed = "copyMove"; + }); + return row; +} + +const eqBars = () => h("span", { class: "eqbars", "aria-label": "Now playing" }, h("i"), h("i"), h("i")); + +function selectRow(e, t, i, ctx) { + Lib.currentList = ctx.list; + if (e.shiftKey && Lib.anchor >= 0) { + const [a, b] = [Math.min(Lib.anchor, i), Math.max(Lib.anchor, i)]; + if (!(e.ctrlKey || e.metaKey)) Lib.sel.clear(); + ctx.list.slice(a, b + 1).forEach((x) => Lib.sel.add(x.id)); + } else if (e.ctrlKey || e.metaKey) { + Lib.sel.has(t.id) ? Lib.sel.delete(t.id) : Lib.sel.add(t.id); + Lib.anchor = i; + } else { + Lib.sel = new Set([t.id]); + Lib.anchor = i; + } + markSelection(); +} + +function markSelection() { + $$(".lt-row").forEach((r) => { + const on = Lib.sel.has(r.dataset.id); + r.classList.toggle("sel", on); + r.setAttribute("aria-selected", String(on)); + }); +} + +function selectedTracks(fallback) { + const picked = [...Lib.sel].map((id) => Lib.byId.get(id)).filter(Boolean); + return picked.length && (!fallback || Lib.sel.has(fallback.id)) ? picked : fallback ? [fallback] : []; +} + +function playlistsContaining(t) { + const key = sig(t); + return (Lib.data?.playlists || []).map((p) => ({ p, copies: p.order.map((id) => Lib.byId.get(id)).filter((x) => x && sig(x) === key) })).filter((x) => x.copies.length); +} + +const songs = (n) => (n === 1 ? "song" : `${n} songs`); + +async function deleteTracks(tracks) { + if (!tracks.length) return; + const inPlaylists = tracks.some((t) => !t.playlist && playlistsContaining(t).length); + const box = h("input", { type: "checkbox", class: "box" }); + box.checked = true; + const body = h("div", { class: "stack" }, + h("p", { class: "muted" }, `${tracks.length === 1 ? `“${tracks[0].title}”` : songs(tracks.length)} will be moved to your ${isMac ? "Trash" : "Recycle Bin"}, along with any lyrics files, so you can restore them from there if you change your mind.`), + inPlaylists ? h("label", { class: "check-row" }, box, h("span", {}, "Also remove them from your playlists")) : null); + const ok = await modal(tracks.length === 1 ? "Delete this song from your device?" : `Delete ${tracks.length} songs from your device?`, body, [{ label: "Cancel", value: false }, { label: "Delete", value: true, primary: true }]); + if (!ok) return; + try { + const n = await invoke("tracks_delete", { ids: tracks.map((t) => t.id), playlists: inPlaylists && box.checked }); + Lib.sel.clear(); + toast(`Deleted ${songs(n)}. ${isMac ? "Trash" : "Recycle Bin"} has them if you need them back.`, "ok"); + } catch (e) { + toast(errText(e), "err"); + } +} + +async function hideTracks(tracks) { + if (!tracks.length) return; + const n = await invoke("tracks_hide", { ids: tracks.map((t) => t.id) }).catch((e) => (toast(errText(e), "err"), 0)); + Lib.sel.clear(); + if (n) toast(`Removed ${songs(n)} from your library. The files are still on your drive; restore them in Settings → Library.`, "ok"); +} + +function trackList(list, ctx = {}) { + ctx.list = ctx.list || list; + const wrap = h("div", { class: "lt", role: "table" }); + list.forEach((t, i) => { + const at = ctx.list.indexOf(t); + wrap.append(trackRow(t, at >= 0 ? at : i, ctx)); + }); + if (ctx.playlist) enableReorder(wrap, ctx.playlist); + return wrap; +} + +function markPlaying() { + const id = Player.current?.id; + $$(".lt-row").forEach((r) => { + const on = r.dataset.id === id; + if (on === r.classList.contains("playing")) return; + r.classList.toggle("playing", on); + const num = r.querySelector(".lt-num"); + const play = num.querySelector(".lt-play"); + num.replaceChildren(on ? eqBars() : r.dataset.num, play); + }); +} + +/* context menu */ +function closeMenus() { + $$(".ctx").forEach((m) => m.remove()); +} + +function menuAt(x, y, items) { + closeMenus(); + const m = h("div", { class: "menu ctx", role: "menu" }); + for (const it of items) { + if (it === "-") m.append(h("div", { class: "menu-divider" })); + else if (it) m.append(h("button", { role: "menuitem", class: `${it.sub ? "has-sub" : ""} ${it.danger ? "danger" : ""}`, disabled: it.disabled, onclick: (e) => { if (it.sub) { e.stopPropagation(); const r = e.currentTarget.getBoundingClientRect(); menuAt(r.right + 4, r.top - 6, it.sub()); } else { closeMenus(); it.run(); } } }, h("span", {}, it.label), it.sub ? icon("chevron-down") : it.hint ? h("kbd", {}, it.hint) : null)); + } + document.body.append(m); + const w = m.offsetWidth, hgt = m.offsetHeight; + m.style.left = `${Math.min(x, innerWidth - w - 8)}px`; + m.style.top = `${Math.min(y, innerHeight - hgt - 8)}px`; + m.querySelector("button")?.focus(); + return m; +} + +document.addEventListener("click", (e) => { if (!e.target.closest(".ctx")) closeMenus(); }); +document.addEventListener("keydown", (e) => { if (e.key === "Escape") closeMenus(); }); + +function playlistItems(tracks) { + return () => [ + ...(Lib.data?.playlists || []).map((p) => ({ label: p.name, run: () => addToPlaylist(p.name, tracks) })), + (Lib.data?.playlists || []).length ? "-" : null, + { label: "New playlist…", run: () => newPlaylist(tracks) }, + ]; +} + +function trackMenu(e, t, ctx, i) { + const albumKey = t.album ? `${lnorm(t.albumArtist || primaryArtist(t.artist))}|${lnorm(t.album)}` : null; + const many = selectedTracks(t); + if (many.length > 1) { + const inList = ctx.playlist ? many.filter((x) => x.playlist === ctx.playlist) : []; + return menuAt(e.clientX, e.clientY, [ + { label: `Play ${many.length} songs`, run: () => playList(many, 0, false) }, + { label: "Play next", run: () => Player.playNext(many) }, + { label: "Add to queue", run: () => Player.addToQueue(many) }, + "-", + { label: "Add to playlist", sub: playlistItems(many) }, + inList.length ? { label: `Remove ${inList.length} from this playlist`, run: () => removeFromPlaylist(ctx.playlist, inList) } : null, + "-", + { label: `Remove ${many.length} from library`, run: () => hideTracks(many) }, + { label: `Delete ${many.length} from device…`, danger: true, run: () => deleteTracks(many) }, + ]); + } + const holders = playlistsContaining(t).filter((x) => x.p.name !== ctx.playlist); + menuAt(e.clientX, e.clientY, [ + { label: "Play", run: () => playList(ctx.list, i) }, + { label: "Play next", run: () => Player.playNext([t]) }, + { label: "Add to queue", run: () => Player.addToQueue([t]) }, + "-", + { label: "Add to playlist", sub: playlistItems([t]) }, + { label: Lib.liked.has(t.id) ? "Unlike" : "Like", run: () => toggleLike(t) }, + "-", + albumKey && { label: "Go to album", run: () => openLib("album", albumKey) }, + { label: "Go to artist", run: () => openLib("artist", lnorm(t.albumArtist || primaryArtist(t.artist))) }, + "-", + { label: "Edit info…", run: () => editInfo(t) }, + { label: "Show lyrics", run: () => { if (Player.current?.id !== t.id) playList(ctx.list, i); openLyrics(); } }, + { label: "Show in folder", run: () => invoke("reveal", { path: t.path }) }, + "-", + ctx.playlist && t.playlist === ctx.playlist ? { label: "Remove from this playlist", run: () => removeFromPlaylist(ctx.playlist, [t]) } : null, + holders.length ? { label: "Remove from playlist", sub: () => holders.map(({ p, copies }) => ({ label: p.name, run: () => removeFromPlaylist(p.name, copies) })) } : null, + t.playlist ? null : { label: "Remove from library", run: () => hideTracks([t]) }, + { label: t.playlist ? "Delete this copy from device…" : "Delete from device…", danger: true, run: () => deleteTracks([t]) }, + ]); +} + +/* playlists */ +function renderPlaylistNav() { + const nav = $("#playlistNav"); + const lists = Lib.data?.playlists || []; + nav.replaceChildren( + ...lists.map((p) => { + const b = h("button", { class: "nav-item small", "data-playlist": p.name, onclick: () => openLib("playlist", p.name) }, icon("playlist"), h("span", { class: "nav-label" }, p.name), h("span", { class: "nav-meta" }, String(p.order.length))); + b.addEventListener("dragover", (e) => { if (e.dataTransfer.types.includes("application/x-atmo-tracks")) { e.preventDefault(); b.classList.add("drop"); } }); + b.addEventListener("dragleave", () => b.classList.remove("drop")); + b.addEventListener("drop", (e) => { + e.preventDefault(); + b.classList.remove("drop"); + const ids = JSON.parse(e.dataTransfer.getData("application/x-atmo-tracks") || "[]"); + addToPlaylist(p.name, ids.map((id) => Lib.byId.get(id)).filter(Boolean)); + }); + return b; + }) + ); + $("#playlistEmpty").hidden = lists.length > 0; + markLibNav(); +} + +async function addToPlaylist(name, tracks) { + if (!tracks.length) return; + try { + const n = await invoke("playlist_add", { name, ids: tracks.map((t) => t.id) }); + toast(n ? `Added ${plural(n, "song")} to ${name}` : `Already in ${name}`, "ok"); + } catch (e) { + toast(errText(e), "err"); + } +} + +async function removeFromPlaylist(name, tracks) { + const ok = await confirmBox(`Remove ${tracks.length === 1 ? `“${tracks[0].title}”` : plural(tracks.length, "song")} from ${name}?`, `The playlist's copy goes to your ${isMac ? "Trash" : "Recycle Bin"}. The song stays in your library.`, "Remove"); + if (!ok) return; + try { + await invoke("playlist_remove", { name, ids: tracks.map((t) => t.id) }); + } catch (e) { + toast(errText(e), "err"); + } +} + +function enableReorder(wrap, name) { + let dragging = null; + wrap.addEventListener("dragstart", (e) => (dragging = e.target.closest(".lt-row"))); + wrap.addEventListener("dragover", (e) => { + const over = e.target.closest(".lt-row"); + if (!dragging || !over || over === dragging) return; + e.preventDefault(); + const r = over.getBoundingClientRect(); + over.parentNode.insertBefore(dragging, e.clientY < r.top + r.height / 2 ? over : over.nextSibling); + }); + wrap.addEventListener("dragend", async () => { + if (!dragging) return; + dragging = null; + const ids = $$(".lt-row", wrap).map((r) => r.dataset.id); + await invoke("playlist_reorder", { name, ids }).catch((e) => toast(errText(e), "err")); + loadLibrary(); + }); +} + +/* dialogs */ +function modal(title, body, actions) { + return new Promise((resolve) => { + const close = (v) => { wrap.remove(); resolve(v); }; + const wrap = h("div", { class: "modal-wrap", onclick: (e) => { if (e.target === wrap) close(null); } }, + h("div", { class: "modal", role: "dialog", "aria-modal": "true", "aria-label": title }, + h("h2", {}, title), body, + h("div", { class: "row end" }, ...actions.map((a) => h("button", { class: `btn ${a.primary ? "primary" : a.danger ? "danger-ghost" : "ghost"}`, onclick: () => close(a.value) }, a.label))))); + wrap.addEventListener("keydown", (e) => { + if (e.key === "Escape") close(null); + if (e.key === "Enter" && e.target.tagName === "INPUT") close(actions.find((a) => a.primary)?.value); + }); + document.body.append(wrap); + (wrap.querySelector("input, textarea") || wrap.querySelector(".btn.primary"))?.focus(); + }); +} + +const confirmBox = (title, text, label) => modal(title, h("p", { class: "muted" }, text), [{ label: "Cancel", value: false }, { label, value: true, primary: true }]); + +async function newPlaylist(tracks = []) { + const input = h("input", { class: "text wide", placeholder: "Playlist name", "aria-label": "Playlist name" }); + const ok = await modal("New playlist", h("div", { class: "stack" }, input, h("p", { class: "muted small" }, "It's a folder of songs on this device. Phones, USB drives and other players can use it as-is.")), [{ label: "Cancel", value: false }, { label: "Create", value: true, primary: true }]); + const name = input.value.trim(); + if (!ok || !name) return; + try { + const created = await invoke("playlist_create", { name }); + if (tracks.length) await addToPlaylist(created, tracks); + openLib("playlist", created); + } catch (e) { + toast(errText(e), "err"); + } +} + +async function editInfo(t) { + const fields = [["title", "Title", t.title], ["artist", "Artist", t.artist], ["album", "Album", t.album], ["albumArtist", "Album artist", t.albumArtist], ["trackNumber", "Track", t.trackNo ?? ""], ["discNumber", "Disc", t.discNo ?? ""], ["date", "Year", t.year ?? ""], ["genre", "Genre", t.genre]]; + const inputs = {}; + const grid = h("div", { class: "fields two" }, ...fields.map(([k, label, v]) => h("label", { class: `field ${["title", "artist"].includes(k) ? "full" : ""}` }, h("span", {}, label), (inputs[k] = h("input", { value: String(v ?? ""), spellcheck: "false" }))))); + const ok = await modal("Edit info", h("div", { class: "stack" }, grid, h("p", { class: "muted small" }, "Changes are written into the file's tags, so they're kept everywhere you use it. Moving a song to a different album or artist is as simple as changing it here.")), [{ label: "Cancel", value: false }, { label: "Save", value: true, primary: true }]); + if (!ok) return; + const num = (v) => (v.trim() === "" ? null : parseInt(v, 10) || null); + const meta = { title: inputs.title.value, artist: inputs.artist.value, album: inputs.album.value, albumArtist: inputs.albumArtist.value, trackNumber: num(inputs.trackNumber.value), discNumber: num(inputs.discNumber.value), date: inputs.date.value, genre: inputs.genre.value, artwork: { kind: "keep" } }; + try { + await invoke("track_edit", { id: t.id, meta }); + toast("Saved to the file's tags", "ok"); + } catch (e) { + toast(errText(e), "err"); + } +} + +async function editArtist(ar) { + const bio = h("textarea", { class: "text area", rows: "6", placeholder: "A few lines about this artist…" }, ar.meta?.bio || ""); + const pic = h("div", { class: "row" }, cover(artistImage(ar), "avatar sm"), h("button", { class: "btn", onclick: async () => { try { await invoke("artist_update", { name: ar.name, pickImage: true, bio: null }); toast("Artist image updated", "ok"); } catch (e) { if (errText(e) !== "cancelled") toast(errText(e), "err"); } } }, "Choose image…")); + const ok = await modal(`Edit ${ar.name}`, h("div", { class: "stack" }, pic, h("label", { class: "field" }, h("span", {}, "About"), bio)), [{ label: "Cancel", value: false }, { label: "Save", value: true, primary: true }]); + if (ok) await invoke("artist_update", { name: ar.name, pickImage: false, bio: bio.value }).catch((e) => toast(errText(e), "err")); +} + +/* views */ +function libHead(title, sub, actions = [], opts = {}) { + const search = opts.search ? h("input", { class: "text lib-search", type: "search", placeholder: `Search ${title.toLowerCase()}`, value: Lib.filter, "aria-label": `Search ${title}`, oninput: (e) => { Lib.filter = e.target.value; opts.onSearch?.(); } }) : null; + return h("header", { class: "lib-head" }, + Lib.back.length ? h("button", { class: "icon-btn back", "aria-label": "Back", onclick: libBack }, icon("arrow-left")) : null, + h("div", { class: "lib-titles" }, h("h1", {}, title), sub ? h("p", { class: "view-sub" }, sub) : null), + h("div", { class: "row" }, search, ...actions)); +} + +const playBtns = (list) => [ + h("button", { class: "btn primary", disabled: !list.length, onclick: () => playList(list, 0, false) }, icon("player-play-filled"), "Play"), + h("button", { class: "btn", disabled: !list.length, onclick: () => playList(list, Math.floor(Math.random() * list.length), true) }, icon("arrows-shuffle"), "Shuffle"), +]; + +function emptyLibrary() { + const s = Lib.scan; + return h("div", { class: "lib-empty" }, + h("img", { src: "assets/mark.svg", alt: "", width: "110", height: "96" }), + h("h2", {}, s ? "Reading your music…" : "Your library is empty"), + h("p", {}, s ? `${s.done} of ${s.total} files` : "Songs you download land here automatically. You can also point Atmosphere at folders you already have."), + s ? progressBar(s.total ? s.done / s.total : null) : h("div", { class: "row" }, h("button", { class: "btn primary", onclick: addFolder }, icon("folder-plus"), "Add a music folder"), h("button", { class: "btn", onclick: () => go("get") }, icon("cloud-download"), "Get music"))); +} + +function filtered(list) { + const q = lnorm(Lib.filter); + if (!q) return list; + return list.filter((t) => `${t.title} ${t.artist} ${t.album} ${t.genre}`.toLowerCase().includes(q)); +} + +function sortedSongs() { + const { key, dir } = Lib.sort; + const val = (t) => (key === "plays" ? -(Lib.plays[t.id] || 0) : key === "added" ? -(t.added || 0) : key === "duration" ? t.durationMs : lnorm(key === "artist" ? `${t.albumArtist || t.artist}|${t.album}|${String(t.discNo || 1).padStart(2, "0")}${String(t.trackNo || 0).padStart(3, "0")}` : t[key])); + return [...filtered(Lib.songs)].sort((a, b) => (val(a) > val(b) ? dir : val(a) < val(b) ? -dir : 0)); +} + +function songsView(root) { + const list = sortedSongs(); + Lib.currentList = list; + const sortSel = h("select", { "aria-label": "Sort by", onchange: (e) => { Lib.sort = { key: e.target.value, dir: 1 }; renderLib(); } }, + ...[["artist", "Artist"], ["title", "Title"], ["album", "Album"], ["added", "Recently added"], ["plays", "Most played"], ["duration", "Length"]].map(([v, l]) => h("option", { value: v, selected: Lib.sort.key === v }, l))); + root.append(libHead("Songs", `${plural(Lib.songs.length, "song")}${Lib.scan ? ` · reading ${Lib.scan.done} of ${Lib.scan.total}…` : ""}`, [sortSel, ...playBtns(list)], { search: true, onSearch: () => renderLib(true) })); + if (!Lib.songs.length) return root.append(emptyLibrary()); + const head = h("div", { class: "lt-head with-cover" }, h("span", {}, "#"), h("span"), h("span", {}, "Title"), h("span", {}, "Album"), h("span"), h("span", { class: "r" }, icon("clock")), h("span")); + const box = h("div", { class: "vlist" }); + root.append(head, box); + if (!list.length) return box.append(h("p", { class: "muted pad" }, "No songs match your search.")); + const ctx = { list, cover: true }; + const rowH = 52; + box.addEventListener("click", (e) => { if (e.target === box || e.target === spacer) { Lib.sel.clear(); markSelection(); } }); + const spacer = h("div", { class: "vspacer", style: `height:${list.length * rowH}px` }); + box.append(spacer); + const scroller = $("#libScroll"); + const draw = () => { + const top = scroller.scrollTop - spacer.offsetTop; + const start = Math.max(0, Math.floor(top / rowH) - 10); + const end = Math.min(list.length, Math.ceil((top + scroller.clientHeight) / rowH) + 10); + const rows = []; + for (let i = start; i < end; i++) { + const r = trackRow(list[i], i, ctx); + r.style.transform = `translateY(${i * rowH}px)`; + rows.push(r); + } + spacer.replaceChildren(...rows); + }; + Lib.drawSongs = draw; + requestAnimationFrame(draw); +} + +function albumCard(a) { + return h("div", { class: "card-tile", role: "button", tabindex: "0", "data-album": a.key, onclick: () => openLib("album", a.key), onkeydown: (e) => { if (e.key === "Enter") openLib("album", a.key); } }, + h("div", { class: "tile-art" }, cover(a.art, "tile-img", a.title), h("button", { class: "tile-play", "aria-label": `Play ${a.title}`, onclick: (e) => { e.stopPropagation(); playList(a.tracks); } }, icon("player-play-filled"))), + h("div", { class: "tile-title" }, a.title), + h("div", { class: "tile-sub" }, [a.artist, a.year].filter(Boolean).join(" · "))); +} + +function albumsView(root) { + const q = lnorm(Lib.filter); + const list = [...Lib.albums.values()].filter((a) => !q || `${a.title} ${a.artist}`.toLowerCase().includes(q)).sort((x, y) => lnorm(x.artist).localeCompare(lnorm(y.artist)) || (y.year || 0) - (x.year || 0)); + root.append(libHead("Albums", plural(Lib.albums.size, "album"), [], { search: true, onSearch: () => renderLib(true) })); + if (!Lib.songs.length) return root.append(emptyLibrary()); + root.append(h("div", { class: "grid" }, ...list.map(albumCard))); +} + +function albumView(root, key) { + const a = Lib.albums.get(key); + if (!a) return root.append(libHead("Album not found", "It may have been renamed or removed.")); + const discs = new Set(a.tracks.map((t) => t.discNo || 1)).size > 1; + const multiArtist = a.tracks.some((t) => lnorm(primaryArtist(t.artist)) !== lnorm(a.artist)); + root.append( + h("header", { class: "hero" }, + h("div", { class: "hero-bg", style: a.art ? `background-image:url("${artUrl(a.art)}")` : "" }), + cover(a.art, "hero-cover", a.title), + h("div", { class: "hero-meta" }, + h("div", { class: "kind-line" }, h("span", { class: "kind-btn", style: "cursor:default" }, albumKind(a)), a.year ? h("span", {}, String(a.year)) : null, a.tracks[0]?.genre ? h("span", { class: "sep" }, "·") : null, a.tracks[0]?.genre || null), + h("h1", { class: "hero-title" }, a.title), + h("button", { class: "link hero-artist", onclick: () => openLib("artist", lnorm(a.artist)) }, a.artist), + h("p", { class: "view-sub" }, `${plural(a.tracks.length, "song")} · ${fmtLong(a.duration)}`), + h("div", { class: "row" }, ...playBtns(a.tracks), h("button", { class: "btn ghost", onclick: (e) => menuAt(e.clientX, e.clientY, playlistItems(a.tracks)()) }, icon("playlist-add"), "Add to playlist")))) + ); + if (Lib.back.length) root.firstChild.prepend(h("button", { class: "icon-btn back on-hero", "aria-label": "Back", onclick: libBack }, icon("arrow-left"))); + const ctx = { hideAlbum: true, hideArtist: !multiArtist, showArtistFor: (t) => lnorm(primaryArtist(t.artist)) !== lnorm(a.artist), numbers: (t, i) => t.trackNo || i + 1 }; + if (!discs) return root.append(h("div", { class: "pad-x" }, trackList(a.tracks, ctx))); + const body = h("div", { class: "pad-x" }); + for (const d of [...new Set(a.tracks.map((t) => t.discNo || 1))]) { + body.append(h("h3", { class: "disc" }, icon("disc"), `Disc ${d}`)); + body.append(trackList(a.tracks.filter((t) => (t.discNo || 1) === d), { ...ctx, list: a.tracks, numbers: (t) => t.trackNo || a.tracks.indexOf(t) + 1 })); + } + root.append(body); +} + +function artistCard(ar) { + return h("div", { class: "card-tile artist", role: "button", tabindex: "0", "data-artist": ar.key, onclick: () => openLib("artist", ar.key), onkeydown: (e) => { if (e.key === "Enter") openLib("artist", ar.key); } }, + h("div", { class: "tile-art round" }, cover(artistImage(ar), "tile-img", ar.name)), + h("div", { class: "tile-title" }, ar.name), + h("div", { class: "tile-sub" }, ar.albums.length ? plural(ar.albums.length, "release") : plural(ar.tracks.length, "song"))); +} + +function artistsView(root) { + const q = lnorm(Lib.filter); + const list = [...Lib.artists.values()].filter((a) => !q || a.key.includes(q)).sort((x, y) => x.key.localeCompare(y.key)); + root.append(libHead("Artists", plural(Lib.artists.size, "artist"), [], { search: true, onSearch: () => renderLib(true) })); + if (!Lib.songs.length) return root.append(emptyLibrary()); + root.append(h("div", { class: "grid" }, ...list.map(artistCard))); +} + +function artistView(root, key) { + const ar = Lib.artists.get(key); + if (!ar) return root.append(libHead("Artist not found", "Their songs may have been retagged or removed.")); + const img = artistImage(ar); + const popular = [...ar.tracks].sort((a, b) => (Lib.plays[b.id] || 0) - (Lib.plays[a.id] || 0) || (b.added || 0) - (a.added || 0)).slice(0, 5); + const plays = ar.tracks.reduce((n, t) => n + (Lib.plays[t.id] || 0), 0); + const full = ar.albums.filter((a) => albumKind(a) === "Album"); + const small = ar.albums.filter((a) => albumKind(a) !== "Album"); + root.append( + h("header", { class: "hero artist-hero" }, + h("div", { class: "hero-bg", style: img ? `background-image:url("${artUrl(img)}")` : "" }), + cover(img, "avatar", ar.name), + h("div", { class: "hero-meta" }, + h("div", { class: "kind-line" }, h("span", { class: "kind-btn", style: "cursor:default" }, icon("user"), "Artist")), + h("h1", { class: "hero-title big" }, ar.name), + h("p", { class: "view-sub" }, [plural(ar.tracks.length, "song"), ar.albums.length && plural(ar.albums.length, "release"), plays && plural(plays, "play")].filter(Boolean).join(" · ")), + h("div", { class: "row" }, ...playBtns(ar.tracks), h("button", { class: "btn ghost", onclick: () => editArtist(ar) }, icon("pencil"), "Edit profile")))) + ); + if (Lib.back.length) root.firstChild.prepend(h("button", { class: "icon-btn back on-hero", "aria-label": "Back", onclick: libBack }, icon("arrow-left"))); + const body = h("div", { class: "pad-x sections" }); + body.append(h("section", {}, h("h2", { class: "sec" }, "Popular"), trackList(popular, { cover: true, list: popular }))); + if (full.length) body.append(h("section", {}, h("h2", { class: "sec" }, "Albums"), h("div", { class: "grid" }, ...full.map(albumCard)))); + if (small.length) body.append(h("section", {}, h("h2", { class: "sec" }, "Singles & EPs"), h("div", { class: "grid" }, ...small.map(albumCard)))); + if (ar.appearsOn.length) body.append(h("section", {}, h("h2", { class: "sec" }, "Appears on"), h("div", { class: "grid" }, ...ar.appearsOn.map(albumCard)))); + body.append(h("section", { class: "about" }, h("h2", { class: "sec" }, "About"), ar.meta?.bio ? h("p", { class: "bio" }, ar.meta.bio) : h("button", { class: "link muted", onclick: () => editArtist(ar) }, "Add a bio and photo for this artist"))); + root.append(body); +} + +function mosaic(tracks) { + const arts = [...new Set(tracks.map((t) => t.art).filter(Boolean))].slice(0, 4); + if (arts.length < 4) return arts.length ? cover(arts[0], "hero-cover") : h("div", { class: "hero-cover ph" }, icon("playlist")); + return h("div", { class: "hero-cover mosaic" }, ...arts.map((k) => cover(k, ""))); +} + +function playlistView(root, name) { + const p = (Lib.data?.playlists || []).find((x) => x.name === name); + if (!p) return root.append(libHead("Playlist not found", "Its folder may have been moved or deleted.")); + const tracks = p.order.map((id) => Lib.byId.get(id)).filter(Boolean); + const dur = tracks.reduce((n, t) => n + (t.durationMs || 0), 0); + const title = h("h1", { class: "hero-title editable", contenteditable: "plaintext-only", spellcheck: "false", "aria-label": "Playlist name", onkeydown: (e) => { if (e.key === "Enter") { e.preventDefault(); e.target.blur(); } } }, p.name); + title.addEventListener("blur", async () => { + const v = title.textContent.trim(); + if (!v || v === p.name) return (title.textContent = p.name); + try { + const n = await invoke("playlist_rename", { from: p.name, to: v }); + Lib.route = { name: "playlist", id: n }; + } catch (e) { + toast(errText(e), "err"); + title.textContent = p.name; + } + }); + root.append( + h("header", { class: "hero" }, + h("div", { class: "hero-bg", style: tracks[0]?.art ? `background-image:url("${artUrl(tracks[0].art)}")` : "" }), + mosaic(tracks), + h("div", { class: "hero-meta" }, + h("div", { class: "kind-line" }, h("span", { class: "kind-btn", style: "cursor:default" }, icon("folder"), "Playlist folder")), + title, + h("p", { class: "view-sub" }, `${plural(tracks.length, "song")}${dur ? " · " + fmtLong(dur) : ""}`), + h("button", { class: "link path", title: "Open this folder", onclick: () => invoke("reveal", { path: p.path }) }, p.path), + h("div", { class: "row" }, ...playBtns(tracks), + h("button", { class: "btn ghost", onclick: async () => { try { const n = await invoke("playlist_add_files", { name: p.name }); if (n) toast(`Added ${plural(n, "song")}`, "ok"); } catch (e) { toast(errText(e), "err"); } } }, icon("plus"), "Add files…"), + h("button", { class: "btn ghost danger", onclick: async () => { if (await confirmBox(`Delete “${p.name}”?`, "The playlist folder goes to your Recycle Bin or Trash. Songs in your library aren't touched.", "Delete")) { await invoke("playlist_delete", { name: p.name }).catch((e) => toast(errText(e), "err")); openLib("songs", null, false); } } }, icon("trash"), "Delete")))) + ); + if (Lib.back.length) root.firstChild.prepend(h("button", { class: "icon-btn back on-hero", "aria-label": "Back", onclick: libBack }, icon("arrow-left"))); + if (!tracks.length) return root.append(h("div", { class: "lib-empty slim" }, h("p", {}, "Drag songs onto this playlist in the sidebar, use “Add to playlist” from any song's menu, or add files from your computer."))); + root.append(h("div", { class: "pad-x" }, h("p", { class: "muted small hint-line" }, "Drag rows to reorder. The order is saved in the folder's playlist.m3u8, so other players see it too."), trackList(tracks, { cover: true, playlist: p.name }))); +} + +function likedView(root) { + const list = filtered(Lib.songs.filter((t) => Lib.liked.has(t.id))); + root.append(libHead("Liked songs", plural(list.length, "song"), playBtns(list), { search: true, onSearch: () => renderLib(true) })); + if (!list.length) return root.append(h("div", { class: "lib-empty slim" }, icon("heart"), h("p", {}, "Tap the heart on any song to keep it here."))); + root.append(h("div", { class: "pad-x" }, trackList(list, { cover: true }))); +} + +function renderLib(soft = false) { + const root = $("#libView"); + const scroller = $("#libScroll"); + const y = soft ? scroller.scrollTop : 0; + const focusSearch = soft && document.activeElement?.classList.contains("lib-search"); + const caret = focusSearch ? document.activeElement.selectionStart : 0; + root.replaceChildren(); + Lib.drawSongs = null; + const r = Lib.route; + ({ songs: songsView, albums: albumsView, album: (x) => albumView(x, r.id), artists: artistsView, artist: (x) => artistView(x, r.id), playlist: (x) => playlistView(x, r.id), liked: likedView, stats: statsView }[r.name] || songsView)(root); + scroller.scrollTop = y; + if (focusSearch) { + const s = $(".lib-search"); + s?.focus(); + s?.setSelectionRange(caret, caret); + } + markLibNav(); +} + +/* library + storage settings */ +async function addFolder() { + try { + const p = await invoke("library_add_folder"); + if (p) { + state.settings = await invoke("get_settings"); + renderLibrarySettings(); + toast("Reading the new folder…", "ok"); + } + } catch (e) { + toast(errText(e), "err"); + } +} + +function renderLibrarySettings() { + const s = state.settings; + if (!s || !$("#libFolders")) return; + $("#libFolders").replaceChildren( + ...s.libraryFolders.map((f) => h("div", { class: "setting" }, h("div", {}, h("strong", { class: "mono-path" }, f), h("span", {}, f === s.outputDir ? "Your download folder" : "Music folder")), + h("button", { class: "btn ghost danger", disabled: s.libraryFolders.length === 1, onclick: async () => { await invoke("library_remove_folder", { path: f }); state.settings = await invoke("get_settings"); renderLibrarySettings(); } }, "Remove"))), + h("div", { class: "setting" }, h("div", {}, h("strong", {}, "Add a folder"), h("span", {}, "Atmosphere reads tags and cover art. It never moves or changes your files unless you edit them.")), + h("div", { class: "row" }, h("button", { class: "btn", onclick: () => invoke("library_scan").then(() => toast("Rescanning your library…", "ok")) }, icon("refresh"), "Rescan"), h("button", { class: "btn primary", onclick: addFolder }, icon("folder-plus"), "Add folder…"))) + ); + $("#playlistsDir").textContent = s.playlistsDir; + const hidden = Lib.data?.hidden || 0; + $("#hiddenSongs").replaceChildren( + h("div", {}, h("strong", {}, "Hidden songs"), h("span", {}, hidden ? `${songs(hidden)} removed from the library but still on your drive.` : "Songs you remove from the library (without deleting) appear here.")), + h("button", { class: "btn", disabled: !hidden, onclick: async () => { const n = await invoke("tracks_unhide_all"); toast(`Restoring ${songs(n)}…`, "ok"); } }, "Restore all")); +} + +async function renderStorage() { + const box = $("#storageList"); + if (!box) return; + const items = await invoke("storage_report").catch(() => []); + const fmt = (b) => fmtBytes(b); + const cleanable = items.filter((i) => i.cleanable && i.bytes > 0); + box.replaceChildren( + ...items.map((i) => h("div", { class: "setting" }, h("div", {}, h("strong", {}, i.label), h("span", {}, i.detail)), + h("div", { class: "row" }, h("span", { class: "size" }, i.count ? `${fmt(i.bytes)} · ${plural(i.count, "file")}` : "Empty"), + i.cleanable ? h("button", { class: "btn", disabled: !i.bytes, onclick: () => cleanStorage([i.id]) }, "Clean") : null))), + h("div", { class: "setting" }, h("div", {}, h("strong", {}, "Clean everything that's safe to remove"), h("span", {}, "Never touches your music, playlists or settings.")), + h("button", { class: "btn primary", disabled: !cleanable.length, onclick: () => cleanStorage(cleanable.map((i) => i.id)) }, "Clean up")) + ); +} + +async function cleanStorage(ids) { + const r = await invoke("storage_clean", { ids }).catch((e) => (toast(errText(e), "err"), null)); + if (r) toast(r.files ? `Removed ${plural(r.files, "file")} (${fmtBytes(r.bytes)})` : "Nothing needed cleaning", "ok"); + renderStorage(); +} + +/* boot */ +function bindLibrary() { + $$("[data-lib]").forEach((b) => b.addEventListener("click", () => { Lib.back = []; openLib(b.dataset.lib, null, false); })); + $("#newPlaylistBtn").addEventListener("click", () => newPlaylist()); + $("#libScroll").addEventListener("scroll", () => Lib.drawSongs && requestAnimationFrame(Lib.drawSongs), { passive: true }); + window.addEventListener("resize", () => Lib.drawSongs && Lib.drawSongs()); + window.addEventListener("player", (e) => { if (e.detail.type === "track") markPlaying(); }); + window.addEventListener("played", (e) => { Lib.plays[e.detail] = (Lib.plays[e.detail] || 0) + 1; }); + listen("atmosphere://library", (e) => { + const p = e.payload; + if (p.type === "progress") { + Lib.scan = { done: p.done, total: p.total }; + if (state.view === "library" && !Lib.songs.length) renderLib(true); + } else { + Lib.scan = null; + if (p.type === "error") toast(p.message, "err"); + clearTimeout(Lib.reload); + Lib.reload = setTimeout(loadLibrary, 150); + } + }); + loadLibrary(); +} + +/* app-wide context menus (replaces the browser's own) */ +const MOD = isMac ? "⌘" : "Ctrl+"; + +function editMenu(e, el) { + const isInput = el.tagName === "INPUT" || el.tagName === "TEXTAREA"; + const start = isInput ? el.selectionStart : null; + const end = isInput ? el.selectionEnd : null; + const sel = window.getSelection(); + const range = !isInput && sel.rangeCount ? sel.getRangeAt(0).cloneRange() : null; + const hasSel = isInput ? start !== end : !sel.isCollapsed; + const readOnly = el.readOnly || el.disabled; + const restore = () => { + el.focus(); + if (isInput) el.setSelectionRange(start, end); + else if (range) { sel.removeAllRanges(); sel.addRange(range); } + }; + const selected = () => (isInput ? el.value.slice(start, end) : range?.toString() || ""); + menuAt(e.clientX, e.clientY, [ + { label: "Cut", hint: `${MOD}X`, disabled: !hasSel || readOnly, run: async () => { await invoke("clipboard_write", { text: selected() }); restore(); document.execCommand("delete"); el.dispatchEvent(new Event("input", { bubbles: true })); } }, + { label: "Copy", hint: `${MOD}C`, disabled: !hasSel, run: () => invoke("clipboard_write", { text: selected() }) }, + { label: "Paste", hint: `${MOD}V`, disabled: readOnly, run: async () => { const text = await invoke("clipboard_text").catch(() => ""); restore(); if (text) document.execCommand("insertText", false, text); } }, + "-", + { label: "Select all", hint: `${MOD}A`, run: () => { el.focus(); if (isInput) el.select(); else document.execCommand("selectAll"); } }, + ]); +} + +function albumMenu(e, a) { + menuAt(e.clientX, e.clientY, [ + { label: "Play", run: () => playList(a.tracks, 0, false) }, + { label: "Shuffle", run: () => playList(a.tracks, Math.floor(Math.random() * a.tracks.length), true) }, + { label: "Play next", run: () => Player.playNext(a.tracks) }, + { label: "Add to queue", run: () => Player.addToQueue(a.tracks) }, + "-", + { label: "Add to playlist", sub: playlistItems(a.tracks) }, + { label: "Go to artist", run: () => openLib("artist", lnorm(a.artist)) }, + "-", + { label: "Remove album from library", run: () => hideTracks(a.tracks) }, + { label: "Delete album from device…", danger: true, run: () => deleteTracks(a.tracks) }, + ]); +} + +function artistMenu(e, ar) { + menuAt(e.clientX, e.clientY, [ + { label: "Play", run: () => playList(ar.tracks, 0, false) }, + { label: "Shuffle", run: () => playList(ar.tracks, Math.floor(Math.random() * ar.tracks.length), true) }, + { label: "Add to queue", run: () => Player.addToQueue(ar.tracks) }, + "-", + { label: "Open profile", run: () => openLib("artist", ar.key) }, + { label: "Edit profile…", run: () => editArtist(ar) }, + ]); +} + +async function renamePlaylist(name) { + const input = h("input", { class: "text wide", value: name, "aria-label": "Playlist name" }); + const ok = await modal("Rename playlist", input, [{ label: "Cancel", value: false }, { label: "Rename", value: true, primary: true }]); + const to = input.value.trim(); + if (!ok || !to || to === name) return; + try { + const n = await invoke("playlist_rename", { from: name, to }); + if (Lib.route.name === "playlist" && Lib.route.id === name) Lib.route = { name: "playlist", id: n }; + } catch (err) { + toast(errText(err), "err"); + } +} + +function playlistMenu(e, name) { + const p = (Lib.data?.playlists || []).find((x) => x.name === name); + if (!p) return; + const tracks = p.order.map((id) => Lib.byId.get(id)).filter(Boolean); + menuAt(e.clientX, e.clientY, [ + { label: "Play", disabled: !tracks.length, run: () => playList(tracks, 0, false) }, + { label: "Shuffle", disabled: !tracks.length, run: () => playList(tracks, Math.floor(Math.random() * tracks.length), true) }, + "-", + { label: "Add files…", run: () => invoke("playlist_add_files", { name }).catch((err) => toast(errText(err), "err")) }, + { label: "Rename…", run: () => renamePlaylist(name) }, + { label: "Show in folder", run: () => invoke("reveal", { path: p.path }) }, + "-", + { label: "Delete playlist…", danger: true, run: async () => { if (await confirmBox(`Delete “${name}”?`, "The playlist folder goes to your Recycle Bin or Trash. Songs in your library aren't touched.", "Delete")) invoke("playlist_delete", { name }).catch((err) => toast(errText(err), "err")); } }, + ]); +} + +document.addEventListener("contextmenu", (e) => { + if (e.defaultPrevented) return; + e.preventDefault(); + const t = e.target; + const field = t.closest("input:not([type=checkbox]):not([type=range]):not([type=radio]), textarea, [contenteditable]"); + if (field) return editMenu(e, field); + const selText = window.getSelection()?.toString().trim(); + if (selText) return menuAt(e.clientX, e.clientY, [{ label: "Copy", hint: `${MOD}C`, run: () => invoke("clipboard_write", { text: selText }) }]); + const album = t.closest("[data-album]"); + if (album) return Lib.albums.has(album.dataset.album) && albumMenu(e, Lib.albums.get(album.dataset.album)); + const artist = t.closest("[data-artist]"); + if (artist) return Lib.artists.has(artist.dataset.artist) && artistMenu(e, Lib.artists.get(artist.dataset.artist)); + const pl = t.closest("[data-playlist]"); + if (pl) return playlistMenu(e, pl.dataset.playlist); + const q = t.closest("[data-qi]"); + if (q) { + const i = Number(q.dataset.qi); + const tr = Player.queue[i]; + return tr && menuAt(e.clientX, e.clientY, [ + { label: "Play", run: () => Player.load(i) }, + { label: "Remove from queue", disabled: i === Player.index, run: () => Player.removeAt(i) }, + "-", + { label: "Add to playlist", sub: playlistItems([tr]) }, + { label: "Show in folder", run: () => invoke("reveal", { path: tr.path }) }, + ]); + } + const line = t.closest(".lyr-line"); + if (line && Lyr.data) { + const l = Lyr.data.lines[Number(line.dataset.i)]; + return menuAt(e.clientX, e.clientY, [ + { label: "Copy line", run: () => invoke("clipboard_write", { text: l.text }) }, + { label: "Copy all lyrics", run: () => invoke("clipboard_write", { text: Lyr.data.lines.map((x) => x.text).join("\n") }) }, + l.t != null ? { label: "Play from here", run: () => Player.seek((l.t - Lyr.offset) / 1000) } : null, + ]); + } + const fetched = t.closest(".fetched-item"); + if (fetched) { + const c = state.collections.find((x) => x.data.id === fetched.dataset.cid); + return c && menuAt(e.clientX, e.clientY, [ + { label: "Open", run: () => { state.active = c; go("get"); renderFetched(); renderSheet(); } }, + c.data.url ? { label: "Open on site", run: () => invoke("open_link", { url: c.data.url }) } : null, + c.data.url ? { label: "Copy link", run: () => invoke("clipboard_write", { text: c.data.url }) } : null, + "-", + { label: "Remove", run: () => removeCollection(c) }, + ]); + } + const hist = t.closest("[data-hist]"); + if (hist) { + const r = state.history.find((x) => x.id === hist.dataset.hist); + return r && menuAt(e.clientX, e.clientY, [ + r.path ? { label: "Show in folder", run: () => invoke("reveal", { path: r.path }) } : null, + r.url ? { label: "Open source page", run: () => invoke("open_link", { url: r.url }) } : null, + r.url ? { label: "Copy link", run: () => invoke("clipboard_write", { text: r.url }) } : null, + "-", + { label: "Remove from history", run: async () => { await invoke("history_remove", { ids: [r.id] }); state.history = state.history.filter((x) => x !== r); renderHistory(); } }, + ]); + } + const srow = t.closest(".tl-row[data-index]"); + if (srow && current()) { + const c = current(); + const idx = Number(srow.dataset.index); + const ent = entryOf(c, idx); + return ent && menuAt(e.clientX, e.clientY, [ + { label: c.selected.has(idx) ? "Don't download" : "Include in download", disabled: !selectable(ent), run: () => { c.selected.has(idx) ? c.selected.delete(idx) : c.selected.add(idx); renderSheet(true); } }, + { label: "Get info", run: () => { c.inspected = idx; renderSheet(true); } }, + ent.url ? { label: "Copy link", run: () => invoke("clipboard_write", { text: ent.url }) } : null, + ]); + } +}); + +document.addEventListener("keydown", (e) => { + const mod = e.ctrlKey || e.metaKey; + const k = e.key.toLowerCase(); + if (e.key === "F5" || (mod && ["r", "p", "s", "u", "j", "g", "o", "n"].includes(k)) || (mod && e.shiftKey && ["r", "p"].includes(k))) { + e.preventDefault(); + return; + } + const typing = e.target.closest?.("input, textarea, select, [contenteditable]"); + if (!typing && state.view === "library" && Lib.sel.size && (e.key === "Delete" || (isMac && e.key === "Backspace" && e.metaKey))) { + e.preventDefault(); + return deleteTracks(selectedTracks()); + } + if (!typing && state.view === "library" && mod && k === "a" && Lib.currentList.length) { + e.preventDefault(); + Lib.sel = new Set(Lib.currentList.map((t) => t.id)); + return markSelection(); + } + if (!typing && e.key === "Escape" && Lib.sel.size) { + Lib.sel.clear(); + markSelection(); + } + if (mod && k === "f") { + e.preventDefault(); + const s = state.view === "library" ? $(".lib-search") : null; + if (s) { s.focus(); s.select(); } + else { go("get"); $("#commandInput").focus(); } + } +}, true); diff --git a/ui/lyrics.js b/ui/lyrics.js new file mode 100644 index 0000000..96fa6bd --- /dev/null +++ b/ui/lyrics.js @@ -0,0 +1,380 @@ +/* atmosphere · lyrics.js · Synced lyrics panel, full-screen TV mode with visualizer, and the lyrics-provider settings. */ +const Lyr = { cache: new Map(), tried: [], cachedMiss: false, data: null, trackId: null, loading: false, error: null, offset: 0, raf: 0, active: -1, tv: false, idleTimer: 0 }; + +const PROVIDER_INFO = { + local: ["Your files", "Lyrics embedded in the song, or a .lrc file next to it."], + lrclib: ["LRCLIB", "Free, community-synced lyrics library. No key needed."], + musixmatch: ["Musixmatch", "Official developer API with your own key (free tier available). Synced lyrics depend on your plan."], + netease: ["NetEase Cloud Music", "Free synced lyrics, often word-by-word with translations. No key needed."], + kugou: ["Kugou", "Free synced lyrics for Chinese and Asian releases. Often blocked outside China, so it's off by default."], +}; + +function lyricsQuery(t) { + return { title: t.title, artist: primaryArtist(t.artist), album: t.album || "", durationMs: t.durationMs || null, path: t.path }; +} + +async function loadLyrics(refresh = false) { + const t = Player.current; + if (!t) { + Lyr.data = null; + Lyr.trackId = null; + return renderLyricsAll(); + } + if (!refresh && Lyr.trackId === t.id && (Lyr.data || Lyr.loading)) return; + Lyr.trackId = t.id; + Lyr.error = null; + Lyr.active = -1; + if (!refresh && Lyr.cache.has(t.id)) { + ({ lyrics: Lyr.data, tried: Lyr.tried, cached: Lyr.cachedMiss } = Lyr.cache.get(t.id)); + return renderLyricsAll(); + } + Lyr.loading = true; + Lyr.data = null; + renderLyricsAll(); + try { + const found = await invoke("lyrics_get", { query: lyricsQuery(t), refresh }); + Lyr.cache.set(t.id, found); + if (Lyr.trackId === t.id) ({ lyrics: Lyr.data, tried: Lyr.tried, cached: Lyr.cachedMiss } = found); + } catch (e) { + if (Lyr.trackId === t.id) Lyr.error = errText(e); + } finally { + if (Lyr.trackId === t.id) Lyr.loading = false; + renderLyricsAll(); + } +} + +function lyricLines(l, big) { + const box = h("div", { class: `lyr ${big ? "big" : ""} ${l.synced ? "synced" : "plain"}` }); + l.lines.forEach((line, i) => { + const el = h("div", { class: "lyr-line", "data-i": i, role: l.synced ? "button" : null, tabindex: l.synced ? "0" : null, onclick: () => line.t != null && Player.seek((line.t - Lyr.offset) / 1000) }); + if (line.words?.length > 1) line.words.forEach((w, j) => el.append(h("span", { class: "w", "data-j": j }, w.text))); + else el.append(line.text || "· · ·"); + if (line.translation) el.append(h("span", { class: "lyr-tr" }, line.translation)); + box.append(el); + }); + return box; +} + +function lyricsBody(big) { + const t = Player.current; + if (!t) return h("div", { class: "lyr-state" }, h("p", {}, "Play something to see its lyrics.")); + if (Lyr.loading) return h("div", { class: "lyr-state" }, h("span", { class: "skeleton w60" }), h("span", { class: "skeleton w30" }), h("span", { class: "skeleton w60" })); + if (Lyr.error) return h("div", { class: "lyr-state" }, h("p", {}, Lyr.error), h("button", { class: "btn small", onclick: () => loadLyrics(true) }, "Try again")); + const l = Lyr.data; + if (!l) return h("div", { class: "lyr-state" }, h("p", {}, "No lyrics found for this song."), + Lyr.cachedMiss ? h("p", { class: "muted small" }, "Searched recently with no match. Search again to retry every source.") : Lyr.tried.length ? h("ul", { class: "tried" }, ...Lyr.tried.map((a) => h("li", {}, h("strong", {}, a.provider), ` ${a.outcome}`))) : null, + h("div", { class: "row" }, h("button", { class: "btn small", onclick: () => loadLyrics(true) }, icon("refresh"), "Search again"), h("button", { class: "btn small ghost", onclick: () => { closeTv(); go("settings"); $("#set-lyrics")?.scrollIntoView(); } }, "Lyrics sources"))); + if (l.instrumental) return h("div", { class: "lyr-state" }, icon("music"), h("p", {}, "Instrumental")); + return lyricLines(l, big); +} + +function renderLyricsPanel() { + const panel = $("#lyricsPanel"); + if (panel.hidden) return; + if (Player.current && Lyr.trackId !== Player.current.id) loadLyrics(); + const l = Lyr.data; + const t = Player.current; + const canSave = l?.synced && t && !["Local .lrc", "Embedded"].includes(l.provider); + panel.replaceChildren( + h("div", { class: "drawer-head" }, h("div", {}, h("h2", {}, "Lyrics"), l ? h("p", { class: "muted small" }, `${l.provider}${l.wordSynced ? " · word-synced" : l.synced ? " · synced" : ""}`) : null), + h("div", { class: "row" }, + l?.synced ? h("div", { class: "offset", title: "Nudge timing if lyrics run early or late" }, h("button", { class: "icon-btn", "aria-label": "Lyrics earlier", onclick: () => nudge(-250) }, "−"), h("output", {}, `${Lyr.offset > 0 ? "+" : ""}${(Lyr.offset / 1000).toFixed(2)}s`), h("button", { class: "icon-btn", "aria-label": "Lyrics later", onclick: () => nudge(250) }, "+")) : null, + canSave ? h("button", { class: "icon-btn", title: "Save as .lrc next to the song", "aria-label": "Save lyrics file", onclick: saveLrc }, icon("download")) : null, + t ? h("button", { class: "icon-btn", title: "Edit or attach lyrics", "aria-label": "Edit lyrics", onclick: editLyrics }, icon("pencil")) : null, + h("button", { class: "icon-btn", title: "Search again", "aria-label": "Search again", onclick: () => loadLyrics(true) }, icon("refresh")), + h("button", { class: "icon-btn", "aria-label": "Close", onclick: closeDrawers }, icon("x")))), + h("div", { class: "drawer-body lyr-scroll" }, lyricsBody(false), l?.copyright ? h("p", { class: "lyr-copy" }, l.copyright) : null) + ); + Lyr.active = -1; + startTick(); +} + +async function editLyrics() { + const t = Player.current; + if (!t) return; + const l = Lyr.data; + const start = l?.lines?.length ? (l.synced ? l.lines.map((x) => (x.t != null ? `[${String(Math.floor(x.t / 60000)).padStart(2, "0")}:${String(Math.floor(x.t / 1000) % 60).padStart(2, "0")}.${String(Math.floor((x.t % 1000) / 10)).padStart(2, "0")}]` : "") + x.text).join("\n") : l.lines.map((x) => x.text).join("\n")) : ""; + const box = h("textarea", { class: "text area lyr-input", rows: "14", spellcheck: "false", placeholder: "Paste lyrics. Start lines with [mm:ss.xx] to make them synced." }, start); + const stamp = h("button", { class: "btn small", title: "Insert the current playback time at the cursor", onclick: () => { + const ms = Math.max(0, Player.audio.currentTime * 1000); + const tag = `[${String(Math.floor(ms / 60000)).padStart(2, "0")}:${String(Math.floor(ms / 1000) % 60).padStart(2, "0")}.${String(Math.floor((ms % 1000) / 10)).padStart(2, "0")}]`; + const at = box.selectionStart; + const lineStart = box.value.lastIndexOf("\n", at - 1) + 1; + box.value = box.value.slice(0, lineStart) + tag + box.value.slice(lineStart).replace(/^\[\d{1,3}:\d{1,2}([.:]\d{1,3})?\]/, ""); + const next = box.value.indexOf("\n", lineStart); + box.focus(); + box.setSelectionRange(next < 0 ? box.value.length : next + 1, next < 0 ? box.value.length : next + 1); + } }, icon("clock"), "Stamp current time"); + const importBtn = h("button", { class: "btn small ghost", onclick: async () => { const text = await invoke("pick_text_file").catch((x) => (toast(errText(x), "err"), null)); if (text != null) box.value = text; } }, icon("file-music"), "Import .lrc or .txt…"); + const ok = await modal(`Lyrics · ${t.title}`, h("div", { class: "stack" }, box, h("div", { class: "row" }, stamp, importBtn), h("p", { class: "muted small" }, "Tip: play the song, put the cursor on a line, and press “Stamp current time” as it's sung. That's how you sync lyrics yourself.")), [{ label: "Cancel", value: false }, { label: "Save to song", value: true, primary: true }]); + if (!ok) return; + try { + await invoke("lyrics_save_text", { id: t.id, text: box.value }); + Lyr.cache.delete(t.id); + toast("Lyrics saved to the song", "ok"); + loadLyrics(true); + } catch (e) { + toast(errText(e), "err"); + } +} + +function nudge(ms) { + Lyr.offset += ms; + renderLyricsPanel(); +} + +async function saveLrc() { + try { + await invoke("lyrics_save", { id: Player.current.id, lyrics: Lyr.data }); + toast("Saved lyrics next to the song", "ok"); + } catch (e) { + toast(errText(e), "err"); + } +} + +function openLyrics() { + if ($("#lyricsPanel").hidden) $("#lyricsBtn").click(); +} + +function renderLyricsAll() { + renderLyricsPanel(); + if (Lyr.tv) renderTv(); +} + +function tick() { + Lyr.raf = 0; + const visible = !$("#lyricsPanel").hidden || Lyr.tv; + if (!visible) return; + const l = Lyr.data; + if (l?.synced) { + const now = Player.audio.currentTime * 1000 + Lyr.offset; + let idx = -1; + for (let i = 0; i < l.lines.length; i++) { + if (l.lines[i].t != null && l.lines[i].t <= now) idx = i; + else if (l.lines[i].t != null && l.lines[i].t > now) break; + } + const boxes = $$(".lyr.synced"); + if (idx !== Lyr.active) { + Lyr.active = idx; + for (const box of boxes) { + $$(".lyr-line", box).forEach((el, i) => { + el.classList.toggle("on", i === idx); + el.classList.toggle("past", i < idx); + }); + const cur = box.querySelector(".lyr-line.on"); + if (cur) cur.scrollIntoView({ block: "center", behavior: reduced.matches ? "auto" : "smooth" }); + } + } + const line = l.lines[idx]; + if (line?.words?.length > 1) { + for (const box of boxes) { + const el = box.querySelector(".lyr-line.on"); + el && $$(".w", el).forEach((w, j) => w.classList.toggle("sung", line.words[j].t <= now)); + } + } + } + if (Lyr.tv) drawViz(); + Lyr.raf = requestAnimationFrame(tick); +} + +function startTick() { + if (!Lyr.raf) Lyr.raf = requestAnimationFrame(tick); +} + +/* TV mode */ +function renderTv() { + const tv = $("#tv"); + const t = Player.current; + const l = Lyr.data; + const hasLyrics = !!(l && !l.instrumental && l.lines?.length); + const showCol = !!t && (Lyr.loading || hasLyrics); + tv.classList.toggle("no-lyrics", !showCol); + const note = !t ? null : Lyr.loading ? null : l?.instrumental ? "Instrumental" : !hasLyrics ? (Lyr.error ? "Lyrics sources unreachable" : "No lyrics found for this song") : `Lyrics · ${l.provider}`; + const bg = t?.art ? `background-image:url("${artUrl(t.art)}")` : ""; + tv.replaceChildren( + h("div", { class: "tv-bg", style: bg }), + h("button", { class: "icon-btn tv-close", "aria-label": "Exit TV mode", onclick: closeTv }, icon("minimize")), + h("div", { class: "tv-stage" }, + h("div", { class: "tv-now" }, + t ? cover(t.art, "tv-cover", t.album || t.title) : h("div", { class: "tv-cover ph" }, icon("music")), + h("div", { class: "tv-title" }, t?.title || "Nothing playing"), + h("div", { class: "tv-artist" }, t?.artist || ""), + note ? h("div", { class: "tv-note" }, note) : null, + h("div", { class: "tv-bar" }, h("i", { id: "tvProg" })), + h("div", { class: "tv-controls" }, + h("button", { class: "icon-btn", "aria-label": "Previous", onclick: () => Player.prev() }, icon("player-skip-back-filled")), + h("button", { class: "icon-btn tv-play", "aria-label": "Play or pause", onclick: () => Player.toggle() }, icon(Player.audio.paused ? "player-play-filled" : "player-pause-filled")), + h("button", { class: "icon-btn", "aria-label": "Next", onclick: () => Player.next() }, icon("player-skip-forward-filled")))), + showCol ? h("div", { class: "tv-lyrics" }, Lyr.loading ? h("div", { class: "tv-finding" }, h("span", { class: "skeleton w60" }), h("span", { class: "skeleton w30" }), h("p", {}, "Finding lyrics…")) : lyricsBody(true)) : null), + h("canvas", { class: "tv-viz", id: "tvViz", width: "1600", height: "220", "aria-hidden": "true" }) + ); + Lyr.active = -1; + startTick(); +} + +function drawViz() { + const bar = $("#tvProg"); + const a = Player.audio; + if (bar && isFinite(a.duration)) bar.style.transform = `scaleX(${a.currentTime / a.duration})`; + const c = $("#tvViz"); + const an = Player.nodes?.analyser; + if (!c || !an) return; + const g = c.getContext("2d"); + const data = new Uint8Array(an.frequencyBinCount); + an.getByteFrequencyData(data); + g.clearRect(0, 0, c.width, c.height); + const n = 64; + const w = c.width / n; + const accent = getComputedStyle(document.documentElement).getPropertyValue("--accent").trim() || "#9aa4ff"; + g.fillStyle = accent; + g.globalAlpha = 0.55; + for (let i = 0; i < n; i++) { + const v = data[Math.floor((i / n) * data.length * 0.75)] / 255; + const hgt = Math.max(4, v * c.height * 0.9); + const x = i * w + w * 0.3; + g.beginPath(); + g.roundRect(x, c.height - hgt, w * 0.4, hgt, w * 0.2); + g.fill(); + } +} + +function wakeTv() { + const tv = $("#tv"); + tv.classList.remove("idle"); + clearTimeout(Lyr.idleTimer); + Lyr.idleTimer = setTimeout(() => tv.classList.add("idle"), 2800); +} + +const winApi = () => window.__TAURI__?.window; + +async function monitors() { + try { + return (await winApi()?.availableMonitors?.()) || []; + } catch { + return []; + } +} + +async function moveToMonitor(m) { + const api = winApi(); + const dpi = window.__TAURI__?.dpi; + if (!api || !dpi || !m) return; + const win = api.getCurrentWindow(); + Lyr.restore = { pos: await win.outerPosition(), size: await win.outerSize(), max: await win.isMaximized() }; + if (Lyr.restore.max) await win.unmaximize(); + await win.setPosition(new dpi.PhysicalPosition(m.position.x + 40, m.position.y + 40)); +} + +async function restoreWindow() { + const r = Lyr.restore; + Lyr.restore = null; + const api = winApi(); + const dpi = window.__TAURI__?.dpi; + if (!r || !api || !dpi) return; + const win = api.getCurrentWindow(); + await win.setPosition(new dpi.PhysicalPosition(r.pos.x, r.pos.y)); + await win.setSize(new dpi.PhysicalSize(r.size.width, r.size.height)); + if (r.max) await win.maximize(); +} + +async function chooseTvScreen(anchor) { + if (Lyr.tv) return closeTv(); + const list = await monitors(); + if (list.length < 2) return openTv(); + const here = await winApi().currentMonitor().catch(() => null); + const label = (m, i) => `${m.name && !/^\\\\.\\/.test(m.name) ? m.name : `Display ${i + 1}`} · ${m.size.width}×${m.size.height}`; + const r = anchor.getBoundingClientRect(); + const m = menuAt(r.left, r.top - 10, [ + { label: "This screen", run: () => openTv() }, + "-", + ...list.map((mon, i) => ({ label: `${label(mon, i)}${here && mon.position.x === here.position.x && mon.position.y === here.position.y ? " (current)" : ""}`, run: () => openTv(mon) })), + ]); + m.style.top = `${Math.max(8, r.top - m.offsetHeight - 10)}px`; +} + +async function openTv(monitor = null) { + if (Lyr.tv) return closeTv(); + Lyr.tv = true; + closeFx(); + closeMenus(); + if (monitor) await moveToMonitor(monitor).catch(() => {}); + $("#tv").hidden = false; + if (Player.current) loadLyrics(); + renderTv(); + wakeTv(); + invoke("set_fullscreen", { on: true }).catch(() => {}); +} + +async function closeTv() { + if (!Lyr.tv) return; + Lyr.tv = false; + $("#tv").hidden = true; + await invoke("set_fullscreen", { on: false }).catch(() => {}); + await restoreWindow().catch(() => {}); +} + +/* lyrics settings */ +function providerName(id) { + if (id.startsWith("custom:")) return (state.settings.customLyrics || []).find((c) => `custom:${c.id}` === id)?.name || "Custom provider"; + return PROVIDER_INFO[id]?.[0] || id; +} + +async function saveLyricsSettings(patchObj) { + state.settings = await invoke("save_settings", { patch: patchObj }); + Lyr.cache.clear(); + renderLyricsSettings(); +} + +function renderLyricsSettings() { + const s = state.settings; + const box = $("#lyricsProviders"); + if (!s || !box) return; + const list = s.lyricsProviders.filter((p) => !p.id.startsWith("custom:") || (s.customLyrics || []).some((c) => `custom:${c.id}` === p.id)); + const move = (i, d) => { + const next = [...list]; + const [x] = next.splice(i, 1); + next.splice(i + d, 0, x); + saveLyricsSettings({ lyricsProviders: next }); + }; + box.replaceChildren(...list.map((p, i) => { + const sw = h("input", { type: "checkbox", class: "switch", "aria-label": `Use ${providerName(p.id)}` }); + sw.checked = p.enabled; + sw.addEventListener("change", () => saveLyricsSettings({ lyricsProviders: list.map((x) => (x.id === p.id ? { ...x, enabled: sw.checked } : x)) })); + const needsKey = p.id === "musixmatch" && !s.musixmatchKey; + return h("div", { class: "setting" }, + h("div", {}, h("strong", {}, `${i + 1}. ${providerName(p.id)}`), h("span", {}, needsKey ? "Add your Musixmatch API key below to use it." : PROVIDER_INFO[p.id]?.[1] || "Your custom source.")), + h("div", { class: "row" }, + h("button", { class: "icon-btn", "aria-label": "Move up", disabled: i === 0, onclick: () => move(i, -1) }, "↑"), + h("button", { class: "icon-btn", "aria-label": "Move down", disabled: i === list.length - 1, onclick: () => move(i, 1) }, "↓"), + sw)); + })); + const customs = s.customLyrics || []; + $("#customProviders").replaceChildren( + ...customs.map((c) => { + const field = (key, label, attrs = {}) => { + const el = attrs.multiline ? h("textarea", { class: "text area", rows: "2", spellcheck: "false", placeholder: attrs.placeholder || "" }, c[key] || "") : h("input", { class: "text", value: c[key] || "", type: attrs.type || "text", spellcheck: "false", placeholder: attrs.placeholder || "" }); + el.addEventListener("change", () => saveLyricsSettings({ customLyrics: customs.map((x) => (x.id === c.id ? { ...x, [key]: el.value } : x)) })); + return h("label", { class: "field" }, h("span", {}, label), el); + }; + const fmt = h("select", { "aria-label": "Response format" }, h("option", { value: "lrc", selected: c.format !== "json" }, "LRC or plain text"), h("option", { value: "json", selected: c.format === "json" }, "JSON")); + fmt.addEventListener("change", () => saveLyricsSettings({ customLyrics: customs.map((x) => (x.id === c.id ? { ...x, format: fmt.value } : x)) })); + return h("div", { class: "setting stack custom" }, + h("div", { class: "fields two" }, field("name", "Name", { placeholder: "e.g. QQ Music via my proxy" }), field("key", "Key or token", { type: "password" }), h("div", { class: "field full" }, field("url", "URL template", { placeholder: "https://example.com/lyrics?track={title}&artist={artist}&key={key}" })), h("div", { class: "field full" }, field("headers", "Headers (one per line)", { multiline: true, placeholder: "Authorization: Bearer {key}" })), h("label", { class: "field" }, h("span", {}, "Response"), fmt), c.format === "json" ? field("jsonPath", "Path to lyrics", { placeholder: "data.lyrics.lrc" }) : h("span")), + h("div", { class: "row end" }, h("button", { class: "btn ghost danger", onclick: () => saveLyricsSettings({ customLyrics: customs.filter((x) => x.id !== c.id), lyricsProviders: s.lyricsProviders.filter((p) => p.id !== `custom:${c.id}`) }) }, "Remove"))); + }), + h("div", { class: "setting" }, h("div", {}, h("strong", {}, "Add a custom source"), h("span", {}, "For QQ Music, Spicy Lyrics, BiniLyrics, a self-hosted server, or any service you have access to. Use {title}, {artist}, {album}, {duration} and {key} in the URL or headers.")), + h("button", { class: "btn", onclick: () => { const id = String(Date.now()); saveLyricsSettings({ customLyrics: [...customs, { id, name: "", url: "", headers: "", format: "lrc", jsonPath: "", key: "" }], lyricsProviders: [...s.lyricsProviders, { id: `custom:${id}`, enabled: true }] }); } }, icon("plus"), "Add source")) + ); +} + +function bindLyrics() { + window.addEventListener("player", (e) => { + if (e.detail.type === "track") { + Lyr.offset = 0; + if (!$("#lyricsPanel").hidden || Lyr.tv) loadLyrics(); + } + if (e.detail.type === "state" && Lyr.tv) $(".tv-play")?.replaceChildren(icon(Player.audio.paused ? "player-play-filled" : "player-pause-filled")); + }); + $("#tv").addEventListener("mousemove", wakeTv); + document.addEventListener("keydown", (e) => { if (Lyr.tv && e.key === "Escape") closeTv(); }); +} diff --git a/ui/nowplaying.js b/ui/nowplaying.js new file mode 100644 index 0000000..2e8fc66 --- /dev/null +++ b/ui/nowplaying.js @@ -0,0 +1,331 @@ +/* atmosphere · nowplaying.js · Player bar, effects panel (presets, EQ, filters, pitch, tempo), queue drawer and playback shortcuts. */ +const LOG = (v, min, max) => Math.round(min * Math.pow(max / min, v / 100)); +const UNLOG = (f, min, max) => Math.round((Math.log(f / min) / Math.log(max / min)) * 100); +const fmtHz = (f) => (f >= 1000 ? `${nf.format(f / 1000)}k` : String(f)); + +function rangeFill(el) { + const p = ((el.value - el.min) / (el.max - el.min)) * 100; + el.style.setProperty("--p", `${p}%`); +} + +function updatePlayerBar() { + const t = Player.current; + $("#player").classList.toggle("idle", !t); + $("#npArt").replaceChildren(t ? cover(t.art, "np-cover", t.album || t.title) : h("div", { class: "np-cover ph" }, icon("music"))); + $("#npTitle").textContent = t ? t.title : "Nothing playing"; + $("#npArtist").replaceChildren(t ? artistLinks(t) : h("span", { class: "muted" }, "Pick something from your library")); + $("#npLike").replaceChildren(t ? likeBtn(t) : ""); + const paused = Player.audio.paused; + document.body.classList.toggle("is-paused", paused || !t); + $("#playBtn").innerHTML = svg(paused ? "player-play-filled" : "player-pause-filled"); + $("#playBtn").setAttribute("aria-label", paused ? "Play" : "Pause"); + $("#shuffleBtn").setAttribute("aria-pressed", String(Player.shuffle)); + $("#repeatBtn").setAttribute("aria-pressed", String(Player.repeat !== "off")); + $("#repeatBtn").replaceChildren(icon(Player.repeat === "one" ? "repeat-once" : "repeat")); + $("#repeatBtn").title = { off: "Repeat off", all: "Repeat all", one: "Repeat one" }[Player.repeat]; + $("#fxBtn").setAttribute("aria-pressed", String(fxActive())); + document.title = t ? `${t.title} · ${t.artist || "Atmosphere"}` : "Atmosphere"; +} + +function updateTime() { + const a = Player.audio; + const dur = isFinite(a.duration) ? a.duration : (Player.current?.durationMs || 0) / 1000; + $("#tCur").textContent = fmtDur(a.currentTime * 1000); + $("#tDur").textContent = fmtDur(dur * 1000); + const seek = $("#seek"); + if (!seek.matches(":active")) { + seek.value = dur ? Math.round((a.currentTime / dur) * 1000) : 0; + rangeFill(seek); + } +} + +function updateVolume() { + const v = $("#volume"); + v.value = Math.round(Player.volume * 100); + rangeFill(v); + $("#muteBtn").replaceChildren(icon(Player.muted || Player.volume === 0 ? "volume-off" : "volume")); +} + +function fxActive() { + const f = Player.fx; + return !Player.bypass && (f.tempo !== 1 || f.pitch !== 0 || f.reverb > 0 || f.wide8d || f.lowpass < 20000 || f.highpass > 20 || f.eq.some((g) => g !== 0)); +} + +/* effects panel */ +const Fx = { tab: "presets" }; + +function userPresets() { + return (state.settings?.fxPresets || []).filter((p) => p && p.id && p.fx); +} + +function smoothPath(pts) { + let d = `M${pts[0][0]},${pts[0][1]}`; + for (let i = 0; i < pts.length - 1; i++) { + const p0 = pts[i - 1] || pts[i], p1 = pts[i], p2 = pts[i + 1], p3 = pts[i + 2] || p2; + const c1 = [p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6]; + const c2 = [p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6]; + d += ` C${c1[0].toFixed(1)},${c1[1].toFixed(1)} ${c2[0].toFixed(1)},${c2[1].toFixed(1)} ${p2[0].toFixed(1)},${p2[1].toFixed(1)}`; + } + return d; +} + +function miniCurve(eq) { + const W = 120, H = 34; + const pts = (eq || EQ_BANDS.map(() => 0)).map((g, i) => [4 + (i * (W - 8)) / 9, H / 2 - (Math.max(-7, Math.min(7, g)) / 7) * (H / 2 - 3)]); + const el = h("span", { class: "mini-curve", "aria-hidden": "true" }); + el.innerHTML = ``; + return el; +} + +function presetTile(p, removable = false) { + const on = Player.fx.preset === p.id && !Player.bypass; + const tag = p.fx.tempo && p.fx.tempo !== 1 ? `${p.fx.tempo}×` : p.fx.wide8d ? "8D" : p.fx.reverb ? "Reverb" : null; + const tile = h("button", { class: `preset ${on ? "on" : ""}`, "aria-pressed": String(on), onclick: () => { if (Player.bypass) Player.setBypass(false); Player.usePreset(p); renderFx(); } }, + miniCurve(p.fx.eq), + h("span", { class: "preset-name" }, p.name, tag ? h("span", { class: "preset-tag" }, tag) : null), + h("span", { class: "preset-desc" }, p.desc || "Your preset")); + if (!removable) return tile; + return h("div", { class: "preset-wrap" }, tile, h("button", { class: "icon-btn preset-x", "aria-label": `Delete ${p.name}`, onclick: async () => { state.settings = await invoke("save_settings", { patch: { fxPresets: userPresets().filter((x) => x.id !== p.id) } }); renderFx(); } }, icon("x"))); +} + +function eqEditor() { + const W = 600, H = 170, PX = 28, PY = 16; + const xs = EQ_BANDS.map((_, i) => PX + (i * (W - PX * 2)) / 9); + const yOf = (g) => H / 2 - (g / 12) * (H / 2 - PY); + const gOf = (y) => Math.max(-12, Math.min(12, Math.round((((H / 2 - y) / (H / 2 - PY)) * 12) * 2) / 2)); + const wrap = h("div", { class: "eq-editor" }); + const grid = [12, 6, 0, -6, -12].map((g) => `${g > 0 ? "+" : ""}${g}`).join(""); + wrap.innerHTML = `${grid}${EQ_BANDS.map((f, i) => `${fmtHz(f)}`).join("")}${EQ_BANDS.map((f, i) => ``).join("")}`; + const svgEl = wrap.firstChild; + const draw = () => { + const eq = Player.fx.eq; + const pts = eq.map((g, i) => [xs[i], yOf(g)]); + const line = smoothPath(pts); + svgEl.querySelector(".curve").setAttribute("d", line); + svgEl.querySelector(".area").setAttribute("d", `${line} L${xs[9]},${H / 2} L${xs[0]},${H / 2} Z`); + svgEl.querySelectorAll(".node").forEach((n, i) => { + n.setAttribute("transform", `translate(${xs[i]},${yOf(eq[i])})`); + n.setAttribute("aria-valuenow", eq[i]); + n.querySelector(".val").textContent = eq[i] ? `${eq[i] > 0 ? "+" : ""}${eq[i]}` : "0"; + }); + }; + const set = (i, g) => { + const eq = [...Player.fx.eq]; + eq[i] = g; + if (Player.bypass) Player.setBypass(false); + Player.applyFx({ eq }, "custom"); + draw(); + }; + svgEl.querySelectorAll(".node").forEach((n) => { + const i = Number(n.dataset.i); + n.addEventListener("pointerdown", (e) => { + n.setPointerCapture(e.pointerId); + n.classList.add("drag"); + const move = (ev) => { + const r = svgEl.getBoundingClientRect(); + set(i, gOf(((ev.clientY - r.top) / r.height) * (H + 22))); + }; + const up = () => { n.classList.remove("drag"); n.removeEventListener("pointermove", move); n.removeEventListener("pointerup", up); }; + n.addEventListener("pointermove", move); + n.addEventListener("pointerup", up); + }); + n.addEventListener("dblclick", () => set(i, 0)); + n.addEventListener("keydown", (e) => { + const step = e.shiftKey ? 2 : 0.5; + const g = Player.fx.eq[i]; + if (e.key === "ArrowUp") { e.preventDefault(); set(i, Math.min(12, g + step)); } + if (e.key === "ArrowDown") { e.preventDefault(); set(i, Math.max(-12, g - step)); } + if (e.key === "Home" || e.key === "0") { e.preventDefault(); set(i, 0); } + }); + }); + draw(); + return wrap; +} + +function fxRange(value, min, max, step, onInput) { + const input = h("input", { type: "range", class: "range strong", min, max, step, value }); + rangeFill(input); + input.addEventListener("input", () => { rangeFill(input); if (Player.bypass) Player.setBypass(false); onInput(Number(input.value)); }); + return input; +} + +function adjustTab() { + const fx = Player.fx; + const tempoOut = h("output", { class: "big-val" }, `${fx.tempo.toFixed(2)}×`); + const tempo = fxRange(fx.tempo, 0.5, 2, 0.01, (v) => { tempoOut.textContent = `${v.toFixed(2)}×`; Player.applyFx({ tempo: v }, "custom"); syncSteps(); }); + const steps = h("div", { class: "chips tight" }, ...[0.75, 1, 1.25, 1.5].map((v) => h("button", { class: "chip", "data-v": v, onclick: () => { Player.applyFx({ tempo: v }, "custom"); renderFx(); } }, v === 1 ? "Normal" : `${v}×`))); + const syncSteps = () => $$(".chip", steps).forEach((c) => c.setAttribute("aria-pressed", String(Number(c.dataset.v) === Player.fx.tempo))); + syncSteps(); + const pitchDisabled = fx.vinyl || (!!Player.ctx && !Player.pitchReady); + const pitchVal = h("output", { class: "big-val" }, fx.vinyl ? "Follows speed" : `${fx.pitch > 0 ? "+" : ""}${fx.pitch} st`); + const bump = (d) => { Player.applyFx({ pitch: Math.max(-12, Math.min(12, Player.fx.pitch + d)) }, "custom"); renderFx(); }; + const mode = h("div", { class: "seg wide", role: "radiogroup", "aria-label": "How speed affects pitch" }, + h("button", { type: "button", role: "radio", "aria-pressed": String(!fx.vinyl), onclick: () => { Player.applyFx({ vinyl: false }, "custom"); renderFx(); } }, "Keep pitch"), + h("button", { type: "button", role: "radio", "aria-pressed": String(fx.vinyl), onclick: () => { Player.applyFx({ vinyl: true }, "custom"); renderFx(); } }, "Vinyl")); + const wide = h("input", { type: "checkbox", class: "switch", "aria-label": "8D audio" }); + wide.checked = fx.wide8d; + wide.addEventListener("change", () => Player.applyFx({ wide8d: wide.checked }, "custom")); + const row = (label, control, value) => h("div", { class: "fx-row" }, h("span", { class: "fx-row-label" }, label), control, value ? h("output", { class: "fx-row-val" }, value) : null); + const lpOut = h("output", { class: "fx-row-val" }, fx.lowpass >= 20000 ? "Off" : `${fmtHz(fx.lowpass)}Hz`); + const hpOut = h("output", { class: "fx-row-val" }, fx.highpass <= 20 ? "Off" : `${fmtHz(fx.highpass)}Hz`); + const rvOut = h("output", { class: "fx-row-val" }, `${Math.round(fx.reverb * 100)}%`); + return h("div", { class: "fx-adjust" }, + h("section", { class: "fx-card" }, h("div", { class: "fx-card-head" }, h("h3", {}, "Equalizer"), h("span", { class: "muted small" }, "Drag the points. Double-click to reset one.")), eqEditor()), + h("div", { class: "fx-split" }, + h("section", { class: "fx-card" }, + h("h3", {}, "Speed"), + h("div", { class: "val-row" }, tempoOut, steps), + tempo, + h("h3", { class: "gap" }, "Pitch"), + h("div", { class: "val-row" }, pitchVal, h("div", { class: "stepper" }, h("button", { type: "button", disabled: pitchDisabled, "aria-label": "Lower pitch", onclick: () => bump(-1) }, "−"), h("button", { type: "button", disabled: pitchDisabled || fx.pitch === 0, "aria-label": "Reset pitch", onclick: () => { Player.applyFx({ pitch: 0 }, "custom"); renderFx(); } }, "0"), h("button", { type: "button", disabled: pitchDisabled, "aria-label": "Raise pitch", onclick: () => bump(1) }, "+"))), + mode, + h("p", { class: "muted small" }, fx.vinyl ? "Speed changes pitch too, like a turntable." : !Player.pitchReady && Player.ctx ? "Pitch shifting isn't supported by this system's web engine." : "Change speed and pitch separately.")), + h("section", { class: "fx-card" }, + h("h3", {}, "Space"), + row("Reverb", fxRange(Math.round(fx.reverb * 100), 0, 100, 1, (v) => { rvOut.textContent = `${v}%`; Player.applyFx({ reverb: v / 100 }, "custom"); }), null), rvOut, + h("label", { class: "fx-toggle" }, wide, h("span", {}, h("strong", {}, "8D audio"), h("small", {}, "Circles the sound around you. Best with headphones."))), + h("h3", { class: "gap" }, "Filters"), + row("High cut", fxRange(UNLOG(fx.lowpass, 400, 20000), 0, 100, 1, (v) => { const f = LOG(v, 400, 20000); lpOut.textContent = f >= 20000 ? "Off" : `${fmtHz(f)}Hz`; Player.applyFx({ lowpass: f }, "custom"); }), null), lpOut, + row("Low cut", fxRange(UNLOG(fx.highpass, 20, 1200), 0, 100, 1, (v) => { const f = LOG(v, 20, 1200); hpOut.textContent = f <= 20 ? "Off" : `${fmtHz(f)}Hz`; Player.applyFx({ highpass: f }, "custom"); }), null), hpOut)) + ); +} + +function presetsTab() { + const mine = userPresets(); + return h("div", { class: "fx-presets" }, + h("h3", {}, "Tone"), h("div", { class: "preset-grid" }, ...PRESETS.filter((p) => p.group === "Tone").map((p) => presetTile(p))), + h("h3", {}, "Mood"), h("div", { class: "preset-grid" }, ...PRESETS.filter((p) => p.group === "Mood").map((p) => presetTile(p))), + h("h3", {}, "Yours"), h("div", { class: "preset-grid" }, ...mine.map((p) => presetTile(p, true)), h("button", { class: "preset add", onclick: savePreset }, icon("plus"), h("span", { class: "preset-name" }, "Save current sound"), h("span", { class: "preset-desc" }, "Keep your tweaks as a preset")))); +} + +function renderFx() { + const panel = $("#fxPanel"); + if (panel.hidden) return; + const y = panel.querySelector(".fx-scroll")?.scrollTop || 0; + const onSw = h("input", { type: "checkbox", class: "switch", "aria-label": "Effects on" }); + onSw.checked = !Player.bypass; + onSw.addEventListener("change", () => { Player.setBypass(!onSw.checked); renderFx(); }); + const tabs = h("div", { class: "seg", role: "tablist" }, ...[["presets", "Presets"], ["adjust", "Adjust"]].map(([id, label]) => h("button", { type: "button", role: "tab", "aria-pressed": String(Fx.tab === id), "aria-selected": String(Fx.tab === id), onclick: () => { Fx.tab = id; renderFx(); } }, label))); + const current = Player.bypass ? "Effects off: original sound" : PRESETS.concat(userPresets()).find((p) => p.id === Player.fx.preset)?.name || (fxActive() ? "Custom" : "Flat"); + panel.replaceChildren( + h("div", { class: "fx-head" }, + h("div", { class: "fx-title" }, h("h2", {}, "Sound"), h("span", { class: "muted small" }, current)), + tabs, + h("div", { class: "row" }, h("label", { class: "fx-power", title: "Compare with the original sound" }, h("span", {}, "Effects"), onSw), h("button", { class: "btn small ghost", onclick: () => { Player.resetFx(); renderFx(); } }, "Reset"), h("button", { class: "icon-btn", "aria-label": "Close", onclick: closeFx }, icon("x")))), + h("div", { class: `fx-scroll ${Player.bypass ? "bypassed" : ""}` }, Fx.tab === "presets" ? presetsTab() : adjustTab()) + ); + panel.querySelector(".fx-scroll").scrollTop = y; + $("#fxBtn").setAttribute("aria-pressed", String(fxActive())); +} + +async function savePreset() { + const input = h("input", { class: "text wide", placeholder: "Preset name", "aria-label": "Preset name" }); + const ok = await modal("Save sound preset", input, [{ label: "Cancel", value: false }, { label: "Save", value: true, primary: true }]); + const name = input.value.trim(); + if (!ok || !name) return; + const { preset, ...fx } = Player.fx; + const id = `user-${Date.now()}`; + const presets = [...userPresets(), { id, name, group: "Yours", desc: "Your preset", fx }]; + state.settings = await invoke("save_settings", { patch: { fxPresets: presets } }); + Player.applyFx({}, id); + renderFx(); +} + +function openFx() { + closeDrawers(); + $("#fxPanel").hidden = false; + $("#fxBtn").setAttribute("aria-expanded", "true"); + renderFx(); +} + +function closeFx() { + $("#fxPanel").hidden = true; + $("#fxBtn").setAttribute("aria-expanded", "false"); +} + +/* queue drawer */ +function renderQueue() { + const panel = $("#queuePanel"); + if (panel.hidden) return; + const now = Player.current; + const next = Player.queue.slice(Player.index + 1); + const row = (t, i, isNow) => h("div", { class: `q-row ${isNow ? "now" : ""}`, "data-qi": i, ondblclick: () => !isNow && Player.load(i) }, + cover(t.art, "lt-cover"), h("div", { class: "lt-main" }, h("span", { class: "lt-title" }, t.title), h("span", { class: "lt-sub" }, t.artist)), + isNow ? h("span", { class: "flag" }, "Now") : h("button", { class: "icon-btn", "aria-label": `Remove ${t.title}`, onclick: () => Player.removeAt(i) }, icon("x"))); + panel.replaceChildren( + h("div", { class: "drawer-head" }, h("h2", {}, "Queue"), h("div", { class: "row" }, next.length ? h("button", { class: "btn small ghost", onclick: () => Player.clearUpNext() }, "Clear") : null, h("button", { class: "icon-btn", "aria-label": "Close", onclick: closeDrawers }, icon("x")))), + h("div", { class: "drawer-body" }, + now ? row(now, Player.index, true) : h("p", { class: "muted pad" }, "Nothing playing."), + next.length ? h("h3", { class: "q-sub" }, `Up next · ${next.length}`) : null, + ...next.slice(0, 300).map((t, k) => row(t, Player.index + 1 + k, false))) + ); +} + +function closeDrawers() { + $$(".drawer-panel").forEach((p) => (p.hidden = true)); + $$("#lyricsBtn, #queueBtn").forEach((b) => b.setAttribute("aria-pressed", "false")); +} + +function toggleDrawer(id, btn, render) { + const panel = $(id); + const open = panel.hidden; + closeDrawers(); + closeFx(); + panel.hidden = !open; + $(btn).setAttribute("aria-pressed", String(open)); + if (open) render(); +} + +/* wiring */ +function bindPlayer() { + $("#playBtn").addEventListener("click", () => Player.toggle()); + $("#prevBtn").addEventListener("click", () => Player.prev()); + $("#nextBtn").addEventListener("click", () => Player.next()); + $("#shuffleBtn").addEventListener("click", () => Player.toggleShuffle()); + $("#repeatBtn").addEventListener("click", () => Player.cycleRepeat()); + $("#muteBtn").addEventListener("click", () => Player.toggleMute()); + $("#npTitle").addEventListener("click", () => { + const t = Player.current; + if (t?.album) openLib("album", `${lnorm(t.albumArtist || primaryArtist(t.artist))}|${lnorm(t.album)}`); + }); + const seek = $("#seek"); + seek.addEventListener("input", () => { + rangeFill(seek); + const dur = Player.audio.duration; + if (isFinite(dur)) $("#tCur").textContent = fmtDur((seek.value / 1000) * dur * 1000); + }); + seek.addEventListener("change", () => Player.seek((seek.value / 1000) * Player.audio.duration)); + const vol = $("#volume"); + vol.addEventListener("input", () => { Player.muted = false; Player.setVolume(vol.value / 100); }); + $("#fxBtn").addEventListener("click", () => ($("#fxPanel").hidden ? openFx() : closeFx())); + $("#queueBtn").addEventListener("click", () => toggleDrawer("#queuePanel", "#queueBtn", renderQueue)); + $("#lyricsBtn").addEventListener("click", () => toggleDrawer("#lyricsPanel", "#lyricsBtn", renderLyricsPanel)); + $("#tvBtn").addEventListener("click", (e) => chooseTvScreen(e.currentTarget)); + document.addEventListener("click", (e) => { if (e.target.isConnected && !$("#fxPanel").hidden && !e.target.closest("#fxPanel, #fxBtn, .modal-wrap")) closeFx(); }); + window.addEventListener("player", (e) => { + const type = e.detail.type; + if (type === "time") return updateTime(); + if (type === "volume") return updateVolume(); + if (type === "fx") return $("#fxBtn").setAttribute("aria-pressed", String(fxActive())); + updatePlayerBar(); + updateTime(); + if (type === "queue" || type === "track") renderQueue(); + }); + document.addEventListener("keydown", (e) => { + if (e.target.closest("input, textarea, select, [contenteditable]") || e.altKey) return; + const mod = e.ctrlKey || e.metaKey; + const k = e.key; + if (k === " " && !mod) { e.preventDefault(); Player.toggle(); } + else if (k === "ArrowRight" && mod) { e.preventDefault(); Player.next(); } + else if (k === "ArrowLeft" && mod) { e.preventDefault(); Player.prev(); } + else if (k === "ArrowRight" && !mod) Player.seek(Player.audio.currentTime + 5); + else if (k === "ArrowLeft" && !mod) Player.seek(Player.audio.currentTime - 5); + else if (k.toLowerCase() === "m" && !mod) Player.toggleMute(); + else if (k.toLowerCase() === "l" && !mod) $("#lyricsBtn").click(); + else if (k.toLowerCase() === "q" && !mod) $("#queueBtn").click(); + else if (k.toLowerCase() === "f" && !mod) openTv(); + }); + updatePlayerBar(); + updateTime(); + updateVolume(); +} diff --git a/ui/pitch-worklet.js b/ui/pitch-worklet.js new file mode 100644 index 0000000..282274c --- /dev/null +++ b/ui/pitch-worklet.js @@ -0,0 +1,61 @@ +/* atmosphere · pitch-worklet.js · Real-time pitch shifter (dual crossfaded delay taps) that changes pitch without changing tempo. */ +class PitchShifter extends AudioWorkletProcessor { + static get parameterDescriptors() { + return [{ name: "ratio", defaultValue: 1, minValue: 0.25, maxValue: 4, automationRate: "k-rate" }]; + } + + constructor() { + super(); + this.size = 1 << 16; + this.mask = this.size - 1; + this.buffers = []; + this.write = 0; + this.phase = 0; + this.window = Math.round(sampleRate * 0.07); + } + + tap(buf, pos) { + const i = Math.floor(pos); + const f = pos - i; + const a = buf[i & this.mask]; + const b = buf[(i + 1) & this.mask]; + return a + (b - a) * f; + } + + process(inputs, outputs, params) { + const input = inputs[0]; + const output = outputs[0]; + if (!input || input.length === 0) return true; + const channels = Math.min(input.length, output.length); + while (this.buffers.length < channels) this.buffers.push(new Float32Array(this.size)); + const n = input[0].length; + const ratio = params.ratio[0]; + const bypass = Math.abs(ratio - 1) < 0.001; + const win = this.window; + const step = (1 - ratio) / win; + for (let i = 0; i < n; i++) { + for (let c = 0; c < channels; c++) this.buffers[c][this.write] = input[c][i]; + if (bypass) { + for (let c = 0; c < channels; c++) output[c][i] = input[c][i]; + } else { + const p1 = this.phase; + const p2 = (p1 + 0.5) % 1; + const s1 = Math.sin(Math.PI * p1); + const g1 = s1 * s1; + const g2 = 1 - g1; + const r1 = this.write - p1 * win; + const r2 = this.write - p2 * win; + for (let c = 0; c < channels; c++) { + const buf = this.buffers[c]; + output[c][i] = this.tap(buf, r1) * g1 + this.tap(buf, r2) * g2; + } + this.phase += step; + this.phase -= Math.floor(this.phase); + } + this.write = (this.write + 1) & this.mask; + } + return true; + } +} + +registerProcessor("pitch-shifter", PitchShifter); diff --git a/ui/player.js b/ui/player.js new file mode 100644 index 0000000..ea204e8 --- /dev/null +++ b/ui/player.js @@ -0,0 +1,428 @@ +/* atmosphere · player.js · Audio engine: queue, shuffle/repeat, EQ presets, filters, reverb, 8D, pitch and tempo, media keys and resume. */ +const MEDIA_BASE = /Windows/.test(navigator.userAgent) ? "http://atmo.localhost/" : "atmo://localhost/"; +const mediaUrl = (kind, id) => `${MEDIA_BASE}${kind}/${encodeURIComponent(id)}`; +const artUrl = (key) => (key ? mediaUrl("a", key) : null); + +const EQ_BANDS = [31, 62, 125, 250, 500, 1000, 2000, 4000, 8000, 16000]; +const FX_DEFAULT = { preset: "flat", eq: EQ_BANDS.map(() => 0), tempo: 1, pitch: 0, vinyl: false, lowpass: 20000, highpass: 20, reverb: 0, wide8d: false }; + +const PRESETS = [ + { id: "flat", name: "Flat", desc: "No changes", group: "Tone", fx: {} }, + { id: "bass", name: "Bass boost", desc: "Fuller low end", group: "Tone", fx: { eq: [7, 6, 4, 2, 0, 0, 0, 0, 0, 0] } }, + { id: "treble", name: "Treble boost", desc: "Crisper highs", group: "Tone", fx: { eq: [0, 0, 0, 0, 0, 1, 2, 4, 5, 6] } }, + { id: "vocal", name: "Vocal", desc: "Voices up front", group: "Tone", fx: { eq: [-3, -2, -1, 1, 3, 4, 3, 1, 0, -1] } }, + { id: "loud", name: "Loudness", desc: "Punchy at low volume", group: "Tone", fx: { eq: [5, 4, 2, 0, -1, 0, 1, 3, 4, 4] } }, + { id: "rock", name: "Rock", desc: "Big edges, scooped mids", group: "Tone", fx: { eq: [4, 3, 2, 0, -1, -1, 1, 2, 3, 4] } }, + { id: "hiphop", name: "Hip-hop", desc: "Deep kick, clear vocals", group: "Tone", fx: { eq: [5, 4, 1, 2, -1, -1, 1, 0, 1, 2] } }, + { id: "electronic", name: "Electronic", desc: "Sub bass and sparkle", group: "Tone", fx: { eq: [4, 3, 1, 0, -2, 1, 0, 1, 3, 4] } }, + { id: "acoustic", name: "Acoustic", desc: "Warm and natural", group: "Tone", fx: { eq: [3, 3, 2, 1, 1, 1, 2, 2, 2, 1] } }, + { id: "nightcore", name: "Nightcore", desc: "Faster and higher", group: "Mood", fx: { tempo: 1.25, vinyl: true, eq: [2, 1, 0, 0, 0, 0, 1, 2, 2, 2] } }, + { id: "slowed", name: "Slowed + reverb", desc: "Slower, deeper, roomy", group: "Mood", fx: { tempo: 0.85, vinyl: true, reverb: 0.38, eq: [3, 2, 1, 0, 0, 0, -1, -2, -2, -3] } }, + { id: "vaporwave", name: "Vaporwave", desc: "Slow, dreamy, muffled", group: "Mood", fx: { tempo: 0.8, vinyl: true, lowpass: 9000, reverb: 0.22 } }, + { id: "lofi", name: "Lo-fi", desc: "Warm, dusty, soft", group: "Mood", fx: { lowpass: 3600, highpass: 140, reverb: 0.14, eq: [2, 2, 1, 0, 0, -1, -2, -3, -4, -5] } }, + { id: "8d", name: "8D audio", desc: "Sound circles your head", group: "Mood", fx: { wide8d: true, reverb: 0.16 } }, + { id: "hall", name: "Concert hall", desc: "A big, live room", group: "Mood", fx: { reverb: 0.45, eq: [1, 1, 0, 0, 0, 0, 0, 1, 1, 0] } }, +]; + +const Player = { + audio: new Audio(), + ctx: null, + nodes: null, + pitchReady: false, + queue: [], + index: -1, + shuffle: false, + repeat: "off", + volume: 0.85, + muted: false, + fx: structuredClone(FX_DEFAULT), + bypass: false, + countedPlay: false, + lookup: () => null, + listenId: null, + listenMs: 0, + lastTick: 0, + + flushListen() { + if (this.listenId && this.listenMs >= 1000) invoke("track_listened", { id: this.listenId, ms: Math.round(this.listenMs) }).catch(() => {}); + this.listenMs = 0; + this.listenId = this.current?.id || null; + }, + + emit(type, extra = {}) { + window.dispatchEvent(new CustomEvent("player", { detail: { type, ...extra } })); + }, + + get current() { + return this.queue[this.index] || null; + }, + + async ensureGraph() { + if (this.ctx) { + if (this.ctx.state === "suspended") await this.ctx.resume(); + return; + } + const AC = window.AudioContext || window.webkitAudioContext; + const ctx = new AC(); + this.ctx = ctx; + const src = ctx.createMediaElementSource(this.audio); + let pitch = null; + try { + await ctx.audioWorklet.addModule("pitch-worklet.js"); + pitch = new AudioWorkletNode(ctx, "pitch-shifter", { outputChannelCount: [2] }); + this.pitchReady = true; + } catch { + this.pitchReady = false; + } + const hp = ctx.createBiquadFilter(); + hp.type = "highpass"; + const lp = ctx.createBiquadFilter(); + lp.type = "lowpass"; + const eq = EQ_BANDS.map((f, i) => { + const b = ctx.createBiquadFilter(); + b.type = i === 0 ? "lowshelf" : i === EQ_BANDS.length - 1 ? "highshelf" : "peaking"; + b.frequency.value = f; + b.Q.value = 1.1; + return b; + }); + const dry = ctx.createGain(); + const wet = ctx.createGain(); + const verb = ctx.createConvolver(); + verb.buffer = this.impulse(ctx, 2.6, 2.4); + const sum = ctx.createGain(); + const pan = ctx.createStereoPanner(); + const lfo = ctx.createOscillator(); + lfo.frequency.value = 0.11; + const lfoDepth = ctx.createGain(); + lfoDepth.gain.value = 0; + lfo.connect(lfoDepth).connect(pan.pan); + lfo.start(); + const vol = ctx.createGain(); + const analyser = ctx.createAnalyser(); + analyser.fftSize = 256; + let head = src; + if (pitch) head = head.connect(pitch); + head = head.connect(hp).connect(lp); + for (const b of eq) head = head.connect(b); + head.connect(dry).connect(sum); + head.connect(verb).connect(wet).connect(sum); + sum.connect(pan).connect(vol).connect(analyser).connect(ctx.destination); + this.nodes = { pitch, hp, lp, eq, dry, wet, lfoDepth, vol, analyser }; + this.applyFx({}); + this.setVolume(this.volume); + }, + + impulse(ctx, seconds, decay) { + const len = Math.floor(ctx.sampleRate * seconds); + const buf = ctx.createBuffer(2, len, ctx.sampleRate); + for (let c = 0; c < 2; c++) { + const d = buf.getChannelData(c); + for (let i = 0; i < len; i++) d[i] = (Math.random() * 2 - 1) * Math.pow(1 - i / len, decay); + } + return buf; + }, + + applyFx(partial, presetId) { + this.fx = { ...this.fx, ...partial }; + if (presetId !== undefined) this.fx.preset = presetId; + const fx = this.bypass ? FX_DEFAULT : this.fx; + this.audio.playbackRate = fx.tempo; + this.audio.preservesPitch = !fx.vinyl; + this.audio.webkitPreservesPitch = !fx.vinyl; + const n = this.nodes; + if (n) { + const t = this.ctx.currentTime; + const ratio = fx.vinyl ? 1 : Math.pow(2, fx.pitch / 12); + n.pitch?.parameters.get("ratio").setValueAtTime(ratio, t); + n.hp.frequency.setTargetAtTime(fx.highpass, t, 0.02); + n.lp.frequency.setTargetAtTime(fx.lowpass, t, 0.02); + n.eq.forEach((b, i) => b.gain.setTargetAtTime(fx.eq[i] || 0, t, 0.02)); + n.wet.gain.setTargetAtTime(fx.reverb * 0.9, t, 0.05); + n.dry.gain.setTargetAtTime(1 - fx.reverb * 0.45, t, 0.05); + n.lfoDepth.gain.setTargetAtTime(fx.wide8d ? 0.85 : 0, t, 0.1); + } + this.persist(); + this.emit("fx"); + }, + + setBypass(on) { + this.bypass = on; + this.applyFx({}); + }, + + usePreset(p) { + this.applyFx({ ...structuredClone(FX_DEFAULT), ...structuredClone(p.fx) }, p.id); + }, + + resetFx() { + this.applyFx(structuredClone(FX_DEFAULT), "flat"); + }, + + setVolume(v) { + this.volume = Math.max(0, Math.min(1, v)); + const level = this.muted ? 0 : this.volume * this.volume; + if (this.nodes) { + this.audio.volume = 1; + this.nodes.vol.gain.setTargetAtTime(level, this.ctx.currentTime, 0.015); + } else { + this.audio.volume = level; + } + this.persist(); + this.emit("volume"); + }, + + toggleMute() { + this.muted = !this.muted; + this.setVolume(this.volume); + }, + + async load(i, autoplay = true, startAt = 0) { + if (i < 0 || i >= this.queue.length) return; + this.flushListen(); + this.index = i; + const t = this.current; + this.listenId = t.id; + this.countedPlay = false; + this.audio.src = mediaUrl("t", t.id); + if (startAt) this.audio.addEventListener("loadedmetadata", () => (this.audio.currentTime = startAt), { once: true }); + this.updateSession(); + this.emit("track"); + this.persist(); + if (autoplay) await this.play(); + }, + + async play() { + if (!this.current) return; + try { + await this.ensureGraph(); + await this.audio.play(); + } catch (e) { + if (e?.name === "NotAllowedError") toast("Click play to start audio.", "err"); + } + }, + + pause() { + this.audio.pause(); + }, + + toggle() { + if (!this.current) return; + this.audio.paused ? this.play() : this.pause(); + }, + + async setQueue(tracks, start = 0, shuffle = null) { + if (!tracks.length) return; + if (shuffle !== null) this.shuffle = shuffle; + let list = [...tracks]; + let first = start; + if (this.shuffle) { + const pick = list.splice(start, 1)[0]; + for (let i = list.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [list[i], list[j]] = [list[j], list[i]]; + } + list = [pick, ...list]; + first = 0; + } + this.queue = list; + this.emit("queue"); + await this.load(first); + }, + + playNext(tracks) { + if (!this.current) return this.setQueue(tracks); + this.queue.splice(this.index + 1, 0, ...tracks); + this.emit("queue"); + this.persist(); + }, + + addToQueue(tracks) { + if (!this.current) return this.setQueue(tracks); + this.queue.push(...tracks); + this.emit("queue"); + this.persist(); + }, + + removeAt(i) { + if (i === this.index) return; + this.queue.splice(i, 1); + if (i < this.index) this.index--; + this.emit("queue"); + this.persist(); + }, + + clearUpNext() { + this.queue = this.current ? [this.current] : []; + this.index = this.current ? 0 : -1; + this.emit("queue"); + this.persist(); + }, + + async next(auto = false) { + if (!this.queue.length) return; + if (auto && this.repeat === "one") { + this.audio.currentTime = 0; + return this.play(); + } + if (this.index + 1 < this.queue.length) return this.load(this.index + 1); + if (this.repeat === "all") return this.load(0); + if (auto) { + this.audio.currentTime = 0; + this.pause(); + this.emit("state"); + } + }, + + async prev() { + if (this.audio.currentTime > 3 || this.index === 0) { + this.audio.currentTime = 0; + return; + } + await this.load(this.index - 1); + }, + + seek(seconds) { + if (!isFinite(this.audio.duration)) return; + this.audio.currentTime = Math.max(0, Math.min(this.audio.duration, seconds)); + }, + + toggleShuffle() { + this.shuffle = !this.shuffle; + if (this.current && this.shuffle) { + const cur = this.current; + const rest = this.queue.filter((_, i) => i !== this.index); + for (let i = rest.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [rest[i], rest[j]] = [rest[j], rest[i]]; + } + this.queue = [cur, ...rest]; + this.index = 0; + this.emit("queue"); + } + this.persist(); + this.emit("state"); + }, + + cycleRepeat() { + this.repeat = { off: "all", all: "one", one: "off" }[this.repeat]; + this.persist(); + this.emit("state"); + }, + + updateSession() { + const t = this.current; + if (!t || !("mediaSession" in navigator)) return; + const art = artUrl(t.art); + navigator.mediaSession.metadata = new MediaMetadata({ title: t.title, artist: t.artist, album: t.album, artwork: art ? [{ src: art, sizes: "600x600", type: "image/jpeg" }] : [] }); + }, + + persist() { + clearTimeout(this._persist); + this._persist = setTimeout(() => { + try { + localStorage.setItem("atmo.player", JSON.stringify({ queue: this.queue.map((t) => t.id), index: this.index, time: this.audio.currentTime || 0, volume: this.volume, shuffle: this.shuffle, repeat: this.repeat, fx: this.fx, bypass: this.bypass })); + } catch {} + }, 400); + }, + + restore(lookup) { + this.lookup = lookup; + let saved = null; + try { + saved = JSON.parse(localStorage.getItem("atmo.player") || "null"); + } catch {} + if (!saved) return; + this.volume = saved.volume ?? this.volume; + this.shuffle = !!saved.shuffle; + this.repeat = saved.repeat || "off"; + this.fx = { ...structuredClone(FX_DEFAULT), ...(saved.fx || {}) }; + this.bypass = !!saved.bypass; + this.queue = (saved.queue || []).map(lookup).filter(Boolean); + if (this.queue.length) this.load(Math.min(Math.max(0, saved.index), this.queue.length - 1), false, saved.time || 0); + this.applyFx({}); + this.setVolume(this.volume); + this.emit("queue"); + }, + + refreshTracks(lookup) { + this.lookup = lookup; + const cur = this.current?.id; + const gone = cur && !lookup(cur); + const before = this.index; + const kept = []; + let nextIndex = -1; + this.queue.forEach((t, i) => { + const fresh = lookup(t.id); + if (fresh) { + if (i === before) nextIndex = kept.length; + if (gone && nextIndex < 0 && i > before) nextIndex = kept.length; + kept.push(fresh); + } + }); + this.queue = kept; + if (gone) { + const wasPlaying = !this.audio.paused; + this.audio.pause(); + this.audio.removeAttribute("src"); + this.audio.load(); + if (nextIndex >= 0) this.load(nextIndex, wasPlaying); + else this.index = -1; + } else { + this.index = cur ? this.queue.findIndex((t) => t.id === cur) : this.index; + } + this.emit("queue"); + this.emit("track"); + this.persist(); + }, +}; + +(() => { + const a = Player.audio; + a.preload = "auto"; + a.crossOrigin = "anonymous"; + a.addEventListener("play", () => Player.emit("state")); + a.addEventListener("pause", () => Player.emit("state")); + a.addEventListener("ended", () => { Player.flushListen(); Player.next(true); }); + a.addEventListener("playing", () => (Player.lastTick = performance.now())); + document.addEventListener("visibilitychange", () => { if (document.visibilityState === "hidden") { Player.flushListen(); } }); + window.addEventListener("beforeunload", () => Player.flushListen()); + let streak = 0; + a.addEventListener("playing", () => (streak = 0)); + a.addEventListener("error", () => { + if (!a.src || !Player.current) return; + streak++; + if (streak === 1) toast(`Couldn't play “${Player.current.title}”. The file may have moved or be unreadable.`, "err"); + if (streak >= 3) { + toast("Several songs in a row couldn't be played, so playback stopped. Try Settings → Library → Rescan.", "err"); + return; + } + if (Player.index + 1 < Player.queue.length) Player.next(true); + }); + a.addEventListener("timeupdate", () => { + Player.emit("time"); + const nowTick = performance.now(); + if (!a.paused && Player.lastTick) { + const d = nowTick - Player.lastTick; + if (d > 0 && d < 2000) Player.listenMs += d; + } + Player.lastTick = nowTick; + const t = Player.current; + if (t && !Player.countedPlay && a.currentTime > Math.min(30, (a.duration || 60) * 0.5)) { + Player.countedPlay = true; + invoke("track_played", { id: t.id }).catch(() => {}); + window.dispatchEvent(new CustomEvent("played", { detail: t.id })); + } + if (Math.floor(a.currentTime) % 5 === 0) Player.persist(); + }); + a.addEventListener("loadedmetadata", () => Player.emit("time")); + if ("mediaSession" in navigator) { + const ms = navigator.mediaSession; + ms.setActionHandler("play", () => Player.play()); + ms.setActionHandler("pause", () => Player.pause()); + ms.setActionHandler("previoustrack", () => Player.prev()); + ms.setActionHandler("nexttrack", () => Player.next()); + try { + ms.setActionHandler("seekto", (d) => Player.seek(d.seekTime)); + } catch {} + } +})(); diff --git a/ui/stats.js b/ui/stats.js new file mode 100644 index 0000000..a176391 --- /dev/null +++ b/ui/stats.js @@ -0,0 +1,291 @@ +/* atmosphere · stats.js · Listening stats (week/month/year/all), top songs/artists/albums, and shareable social-size stat cards. */ +const Stats = { period: "month", offset: 0, data: null }; +const DAY = 86400000; + +function periodRange(period, offset) { + const now = new Date(); + if (period === "week") { + const d = new Date(now.getFullYear(), now.getMonth(), now.getDate()); + d.setDate(d.getDate() - ((d.getDay() + 6) % 7) + offset * 7); + const end = new Date(d); + end.setDate(end.getDate() + 7); + const fmt = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" }); + return { start: d.getTime(), end: end.getTime(), label: offset === 0 ? "This week" : `${fmt.format(d)} – ${fmt.format(new Date(end.getTime() - DAY))}`, title: offset === 0 ? "My week" : `My week of ${fmt.format(d)}` }; + } + if (period === "month") { + const d = new Date(now.getFullYear(), now.getMonth() + offset, 1); + const end = new Date(d.getFullYear(), d.getMonth() + 1, 1); + const label = new Intl.DateTimeFormat(undefined, { month: "long", year: "numeric" }).format(d); + return { start: d.getTime(), end: end.getTime(), label, title: `My ${label}` }; + } + if (period === "year") { + const y = now.getFullYear() + offset; + return { start: new Date(y, 0, 1).getTime(), end: new Date(y + 1, 0, 1).getTime(), label: String(y), title: `My ${y}` }; + } + return { start: 0, end: Infinity, label: "All time", title: "My all time" }; +} + +function buckets(period, range) { + if (period === "week") return [...Array(7)].map((_, i) => { const d = new Date(range.start + i * DAY); return { start: d.getTime(), end: d.getTime() + DAY, label: new Intl.DateTimeFormat(undefined, { weekday: "short" }).format(d) }; }); + if (period === "month") { + const d = new Date(range.start); + const days = new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate(); + return [...Array(days)].map((_, i) => { const s = new Date(d.getFullYear(), d.getMonth(), i + 1); return { start: s.getTime(), end: s.getTime() + DAY, label: String(i + 1) }; }); + } + if (period === "year") { + const y = new Date(range.start).getFullYear(); + return [...Array(12)].map((_, i) => ({ start: new Date(y, i, 1).getTime(), end: new Date(y, i + 1, 1).getTime(), label: new Intl.DateTimeFormat(undefined, { month: "short" }).format(new Date(y, i, 1)) })); + } + const years = [...new Set((Stats.data?.listens || []).map((l) => new Date(l.at).getFullYear()))].sort(); + return (years.length ? years : [new Date().getFullYear()]).map((y) => ({ start: new Date(y, 0, 1).getTime(), end: new Date(y + 1, 0, 1).getTime(), label: String(y) })); +} + +const isPlay = (l, t) => l.ms >= 30000 || (t?.durationMs && l.ms >= t.durationMs * 0.5); +const artistOf = (t) => t.albumArtist || primaryArtist(t.artist); +const dayKey = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`; + +function fmtHours(ms) { + const m = Math.round(ms / 60000); + if (m < 60) return `${m} min`; + const hh = Math.floor(m / 60); + return m % 60 ? `${hh}h ${m % 60}m` : `${hh}h`; +} + +function aggregate() { + const range = periodRange(Stats.period, Stats.offset); + const listens = (Stats.data?.listens || []).filter((l) => l.at >= range.start && l.at < range.end && Lib.byId.has(l.id)); + const songs = new Map(), artists = new Map(), albums = new Map(); + let ms = 0, plays = 0; + for (const l of listens) { + const t = Lib.byId.get(l.id); + const p = isPlay(l, t) ? 1 : 0; + ms += l.ms; + plays += p; + const bump = (map, key, extra) => { const e = map.get(key) || { key, plays: 0, ms: 0, ...extra }; e.plays += p; e.ms += l.ms; map.set(key, e); }; + bump(songs, t.id, { track: t }); + bump(artists, lnorm(artistOf(t)), { name: artistOf(t) }); + if (t.album) bump(albums, `${lnorm(artistOf(t))}|${lnorm(t.album)}`, { title: t.album, artist: artistOf(t), art: t.art }); + } + const rank = (m) => [...m.values()].filter((e) => e.ms > 0).sort((a, b) => b.plays - a.plays || b.ms - a.ms); + const bars = buckets(Stats.period, range).map((b) => ({ ...b, ms: listens.filter((l) => l.at >= b.start && l.at < b.end).reduce((n, l) => n + l.ms, 0) })); + let appSecs = 0; + for (const [day, secs] of Object.entries(Stats.data?.appTime || {})) { + const t = new Date(`${day}T12:00:00`).getTime(); + if (t >= range.start && t < range.end) appSecs += secs; + } + return { range, ms, plays, songs: rank(songs), artists: rank(artists), albums: rank(albums), bars, appMs: appSecs * 1000 }; +} + +async function loadStats() { + Stats.data = await invoke("stats_get").catch(() => ({ listens: [], appTime: {} })); +} + +function statsView(root) { + if (!Stats.data) { + root.append(libHead("Stats", "Loading…")); + loadStats().then(() => Lib.route.name === "stats" && renderLib(true)); + return; + } + const a = aggregate(); + const seg = h("div", { class: "seg", role: "tablist", "aria-label": "Period" }, ...[["week", "Week"], ["month", "Month"], ["year", "Year"], ["all", "All time"]].map(([id, label]) => h("button", { type: "button", role: "tab", "aria-pressed": String(Stats.period === id), onclick: () => { Stats.period = id; Stats.offset = 0; renderLib(true); } }, label))); + const nav = Stats.period === "all" ? null : h("div", { class: "period-nav" }, + h("button", { class: "icon-btn", "aria-label": "Previous period", onclick: () => { Stats.offset--; renderLib(true); } }, icon("chevron-left")), + h("span", { class: "period-label" }, a.range.label), + h("button", { class: "icon-btn", "aria-label": "Next period", disabled: Stats.offset >= 0, onclick: () => { Stats.offset++; renderLib(true); } }, icon("chevron-right"))); + root.append(libHead("Stats", "Only songs still in your library are counted.", [seg, h("button", { class: "btn", disabled: !a.ms, onclick: () => shareStats(a) }, icon("share"), "Share")])); + const body = h("div", { class: "pad-x stats" }); + if (nav) body.append(nav); + if (!a.ms) { + body.append(h("div", { class: "lib-empty slim" }, icon("chart-bar"), h("h2", {}, "Nothing played yet"), h("p", {}, Stats.offset ? "No listening in this period." : "Play some music and your stats will build up here."))); + return root.append(body); + } + const card = (label, value, sub) => h("div", { class: "stat-card" }, h("span", { class: "stat-label" }, label), h("strong", { class: "stat-value" }, value), sub ? h("span", { class: "stat-sub" }, sub) : null); + body.append(h("div", { class: "stat-cards" }, + card("Listening time", fmtHours(a.ms), `${Math.round(a.ms / 60000).toLocaleString()} minutes`), + card("Plays", a.plays.toLocaleString(), a.plays ? `${fmtDur(a.ms / Math.max(1, a.plays))} average` : null), + card("Songs", a.songs.length.toLocaleString(), `${a.artists.length.toLocaleString()} artists`), + card("Time in Atmosphere", a.appMs ? fmtHours(a.appMs) : "—", "while the app was open"))); + const max = Math.max(...a.bars.map((b) => b.ms), 1); + const chart = h("div", { class: "chart", role: "img", "aria-label": `Listening time per ${Stats.period === "year" ? "month" : Stats.period === "all" ? "year" : "day"}` }, + ...a.bars.map((b) => h("div", { class: "chart-col", title: `${b.label}: ${fmtHours(b.ms)}` }, h("div", { class: "chart-bar", style: `transform: scaleY(${(b.ms / max).toFixed(3)})` }), h("span", { class: "chart-x" }, a.bars.length > 16 && Number(b.label) % 5 !== 1 && b.label !== "1" ? "" : b.label)))); + body.append(h("section", { class: "stat-panel" }, h("h2", { class: "sec" }, "When you listened"), chart)); + const songRows = a.songs.slice(0, 10).map((e, i) => h("div", { class: "rank-row", role: "button", tabindex: "0", ondblclick: () => playList(a.songs.map((x) => x.track), i) }, + h("span", { class: "rank" }, String(i + 1)), cover(e.track.art, "lt-cover"), + h("div", { class: "lt-main" }, h("span", { class: "lt-title" }, e.track.title), h("span", { class: "lt-sub" }, e.track.artist)), + h("span", { class: "rank-meta" }, `${plural(e.plays, "play")} · ${fmtHours(e.ms)}`))); + const artistRows = a.artists.slice(0, 8).map((e, i) => { + const ar = Lib.artists.get(e.key); + return h("div", { class: "rank-row", role: "button", tabindex: "0", onclick: () => ar && openLib("artist", ar.key) }, + h("span", { class: "rank" }, String(i + 1)), cover(ar ? artistImage(ar) : null, "lt-cover round"), + h("div", { class: "lt-main" }, h("span", { class: "lt-title" }, e.name), h("span", { class: "lt-sub" }, `${plural(e.plays, "play")} · ${fmtHours(e.ms)}`))); + }); + body.append(h("div", { class: "stat-split" }, + h("section", { class: "stat-panel" }, h("h2", { class: "sec" }, "Top songs"), ...songRows), + h("section", { class: "stat-panel" }, h("h2", { class: "sec" }, "Top artists"), ...artistRows))); + if (a.albums.length) { + body.append(h("section", { class: "stat-panel" }, h("h2", { class: "sec" }, "Top albums"), + h("div", { class: "grid tight" }, ...a.albums.slice(0, 6).map((e) => { const al = Lib.albums.get(e.key); return al ? albumCard(al) : null; }).filter(Boolean)))); + } + root.append(body); +} + +/* share cards */ +const SHARE_SIZES = [ + { id: "story", label: "Story", hint: "Instagram, TikTok, Snapchat", w: 1080, h: 1920 }, + { id: "square", label: "Square", hint: "Instagram post, Discord", w: 1080, h: 1080 }, + { id: "portrait", label: "Portrait", hint: "Instagram, Threads", w: 1080, h: 1350 }, + { id: "wide", label: "Wide", hint: "X, Bluesky, Reddit", w: 1600, h: 900 }, +]; +const Share = { size: "story", theme: "cover" }; + +function loadImg(src) { + return new Promise((resolve) => { + if (!src) return resolve(null); + const img = new Image(); + img.crossOrigin = "anonymous"; + img.onload = () => resolve(img); + img.onerror = () => resolve(null); + img.src = src; + }); +} + +function roundRect(g, x, y, w, hgt, r) { + g.beginPath(); + g.roundRect(x, y, w, hgt, r); +} + +function fitText(g, text, maxW) { + if (g.measureText(text).width <= maxW) return text; + let t = text; + while (t.length > 1 && g.measureText(`${t}…`).width > maxW) t = t.slice(0, -1); + return `${t}…`; +} + +async function drawCard(canvas, a) { + const size = SHARE_SIZES.find((s) => s.id === Share.size); + canvas.width = size.w; + canvas.height = size.h; + const g = canvas.getContext("2d"); + const W = size.w, H = size.h, u = Math.min(W, H) / 1080, wide = W > H; + const font = getComputedStyle(document.documentElement).getPropertyValue("--font-display").trim() || "system-ui"; + const topArt = a.albums[0]?.art || a.songs[0]?.track.art; + const [bgImg, lockup, ...covers] = await Promise.all([Share.theme === "cover" ? loadImg(artUrl(topArt)) : null, loadImg("assets/lockup-light.svg"), ...a.songs.slice(0, 5).map((e) => loadImg(artUrl(e.track.art)))]); + const sky = g.createRadialGradient(W * 0.5, H * 1.05, 0, W * 0.5, H * 1.05, Math.max(W, H) * 1.1); + sky.addColorStop(0, "#3a1f9a"); + sky.addColorStop(0.38, "#1b1248"); + sky.addColorStop(0.75, "#0c0b22"); + sky.addColorStop(1, "#06070f"); + g.fillStyle = sky; + g.fillRect(0, 0, W, H); + if (bgImg) { + g.save(); + g.filter = "blur(70px) saturate(1.4) brightness(0.55)"; + const s = Math.max(W / bgImg.width, H / bgImg.height) * 1.25; + g.drawImage(bgImg, (W - bgImg.width * s) / 2, (H - bgImg.height * s) / 2, bgImg.width * s, bgImg.height * s); + g.restore(); + const shade = g.createLinearGradient(0, 0, 0, H); + shade.addColorStop(0, "rgba(6,7,15,0.25)"); + shade.addColorStop(1, "rgba(6,7,15,0.7)"); + g.fillStyle = shade; + g.fillRect(0, 0, W, H); + } + const pad = 80 * u; + if (lockup) { + const lh = 64 * u; + g.drawImage(lockup, pad, pad, (lockup.width / lockup.height) * lh, lh); + } + g.fillStyle = "#fff"; + g.textBaseline = "alphabetic"; + const colW = wide ? W * 0.42 : W - pad * 2; + let y = pad + 64 * u + (wide ? 120 : 150) * u; + g.font = `700 ${(wide ? 76 : 92) * u}px ${font}`; + g.fillText(fitText(g, a.range.title, colW), pad, y); + g.font = `500 ${34 * u}px ${font}`; + g.fillStyle = "rgba(255,255,255,0.65)"; + y += 56 * u; + g.fillText("on Atmosphere", pad, y); + const stat = (label, value, x, yy) => { + g.fillStyle = "rgba(255,255,255,0.6)"; + g.font = `600 ${26 * u}px ${font}`; + g.fillText(label.toUpperCase(), x, yy); + g.fillStyle = "#fff"; + g.font = `700 ${68 * u}px ${font}`; + g.fillText(value, x, yy + 74 * u); + }; + y += (wide ? 90 : 120) * u; + stat("Listened", fmtHours(a.ms), pad, y); + stat("Plays", a.plays.toLocaleString(), pad + colW * 0.55, y); + y += 160 * u; + if (a.artists[0]) { + g.fillStyle = "rgba(255,255,255,0.6)"; + g.font = `600 ${26 * u}px ${font}`; + g.fillText("TOP ARTIST", pad, y); + g.fillStyle = "#fff"; + g.font = `700 ${56 * u}px ${font}`; + g.fillText(fitText(g, a.artists[0].name, colW), pad, y + 66 * u); + y += 140 * u; + } + const listX = wide ? W * 0.52 : pad; + const listW = wide ? W - listX - pad : W - pad * 2; + const n = wide ? 5 : Share.size === "square" ? 3 : 5; + const rowH = wide ? 132 * u : Share.size === "square" ? 104 * u : Share.size === "story" ? 168 * u : 124 * u; + const block = 30 * u + n * rowH; + let ly = wide ? Math.max(pad + 40 * u, (H - block) / 2) : y + Math.max(20 * u, (H - pad - 60 * u - y - block) / 2); + const coverS = rowH - 24 * u; + g.fillStyle = "rgba(255,255,255,0.6)"; + g.font = `600 ${26 * u}px ${font}`; + g.fillText("TOP SONGS", listX, ly); + ly += 30 * u; + a.songs.slice(0, n).forEach((e, i) => { + const top = ly + i * rowH; + g.fillStyle = "rgba(255,255,255,0.5)"; + g.font = `700 ${34 * u}px ${font}`; + g.fillText(String(i + 1), listX, top + rowH / 2 + 12 * u); + const cx = listX + 56 * u; + g.save(); + roundRect(g, cx, top + 12 * u, coverS, coverS, 14 * u); + g.clip(); + if (covers[i]) g.drawImage(covers[i], cx, top + 12 * u, coverS, coverS); + else { + g.fillStyle = "rgba(255,255,255,0.12)"; + g.fill(); + } + g.restore(); + const tx = cx + coverS + 28 * u; + const tw = listW - (tx - listX); + g.fillStyle = "#fff"; + g.font = `650 ${38 * u}px ${font}`; + g.fillText(fitText(g, e.track.title, tw), tx, top + rowH / 2 - 2 * u); + g.fillStyle = "rgba(255,255,255,0.62)"; + g.font = `500 ${28 * u}px ${font}`; + g.fillText(fitText(g, `${e.track.artist} · ${plural(e.plays, "play")}`, tw), tx, top + rowH / 2 + 38 * u); + }); + g.fillStyle = "rgba(255,255,255,0.45)"; + g.font = `500 ${24 * u}px ${font}`; + g.fillText(a.range.label, pad, H - pad + 10 * u); +} + +async function shareStats(a) { + const canvas = h("canvas", { class: "share-canvas", "aria-label": "Share card preview" }); + const redraw = async () => { + await drawCard(canvas, a); + sizeRow.querySelectorAll(".chip").forEach((c) => c.setAttribute("aria-pressed", String(c.dataset.id === Share.size))); + themeRow.querySelectorAll(".chip").forEach((c) => c.setAttribute("aria-pressed", String(c.dataset.id === Share.theme))); + }; + const sizeRow = h("div", { class: "chips" }, ...SHARE_SIZES.map((s) => h("button", { class: "chip", "data-id": s.id, title: `${s.w}×${s.h} · ${s.hint}`, onclick: () => { Share.size = s.id; redraw(); } }, s.label))); + const themeRow = h("div", { class: "chips" }, h("button", { class: "chip", "data-id": "cover", onclick: () => { Share.theme = "cover"; redraw(); } }, "Cover art"), h("button", { class: "chip", "data-id": "night", onclick: () => { Share.theme = "night"; redraw(); } }, "Night sky")); + const actions = h("div", { class: "row" }, + h("button", { class: "btn primary", onclick: async () => { try { const p = await invoke("image_save", { data: canvas.toDataURL("image/png"), name: `atmosphere-${Stats.period}-${Share.size}.png` }); if (p) toast("Saved your stats image", "ok"); } catch (e) { toast(errText(e), "err"); } } }, icon("photo-down"), "Save image…"), + h("button", { class: "btn", onclick: async () => { try { await invoke("image_copy", { data: canvas.toDataURL("image/png") }); toast("Copied. Paste it anywhere", "ok"); } catch (e) { toast(errText(e), "err"); } } }, icon("copy"), "Copy")); + const body = h("div", { class: "share" }, h("div", { class: "share-preview" }, canvas), h("div", { class: "share-side" }, h("h3", {}, "Size"), sizeRow, h("p", { class: "muted small" }, "Story 1080×1920 · Square 1080×1080 · Portrait 1080×1350 · Wide 1600×900"), h("h3", {}, "Look"), themeRow, actions)); + redraw(); + await modal("Share your stats", body, [{ label: "Done", value: true }]); +} + +function bindStats() { + window.addEventListener("played", () => { Stats.data = null; }); + listen("atmosphere://library", (e) => { if (e.payload.type === "changed") Stats.data = null; }); + setInterval(() => { + if (document.visibilityState === "visible") invoke("app_heartbeat", { day: dayKey(new Date()), secs: 60 }).catch(() => {}); + }, 60000); +} diff --git a/ui/styles.css b/ui/styles.css new file mode 100644 index 0000000..0cabdce --- /dev/null +++ b/ui/styles.css @@ -0,0 +1,884 @@ +/* atmosphere · styles.css · Visual system for the Atmosphere window (tokens locked in .tastemaker/style-lock.md). */ +/* tastemaker stamp: surface=app-shell · lane=calm-native, cover-art-tinted · palette=hand-tuned, matrix-verified (style-lock) · critique show5 phil4 hier4 spec5 restraint5 variety4 */ +:root { + --bg: #0f1117; + --sidebar: #0b0d12; + --surface: #171a23; + --surface-2: #1d212c; + --hover: rgba(236, 238, 244, 0.05); + --press: rgba(236, 238, 244, 0.09); + --border: #2a2f3d; + --hairline: rgba(236, 238, 244, 0.07); + --text: #eceef4; + --text-2: #a1a7b8; + --text-3: #80869a; + --primary: #5b63e6; + --primary-hover: #6970ee; + --on-primary: #ffffff; + --accent: #9aa4ff; + --accent-soft: rgba(154, 164, 255, 0.14); + --ok: #3ecf8e; + --warn: #e7b34f; + --err: #ef6b6b; + --art-opacity: 0.42; + --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.65); + --ease: cubic-bezier(0.2, 0.8, 0.2, 1); + --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, "Cantarell", "Ubuntu", "Noto Sans", sans-serif; + --font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, "Cantarell", "Ubuntu", "Noto Sans", sans-serif; + --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, ui-monospace, "DejaVu Sans Mono", monospace; + --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px; + --r-chip: 6px; --r-ctl: 8px; --r-card: 12px; + color-scheme: dark; +} + +:root[data-theme="light"] { + --bg: #f6f7fa; + --sidebar: #eceef3; + --surface: #ffffff; + --surface-2: #f1f2f6; + --hover: rgba(20, 22, 29, 0.045); + --press: rgba(20, 22, 29, 0.08); + --border: #d9dce5; + --hairline: rgba(20, 22, 29, 0.08); + --text: #14161d; + --text-2: #565c6e; + --text-3: #676d80; + --primary: #4b52d6; + --primary-hover: #565de0; + --accent: #3c43c2; + --accent-soft: rgba(75, 82, 214, 0.1); + --ok: #127a4c; + --warn: #9a6a12; + --err: #c8423f; + --art-opacity: 0.3; + --shadow: 0 18px 44px -22px rgba(30, 34, 60, 0.35); + color-scheme: light; +} + +@media (prefers-color-scheme: light) { + :root:not([data-theme="dark"]):not([data-theme="light"]) { + --bg: #f6f7fa; --sidebar: #eceef3; --surface: #ffffff; --surface-2: #f1f2f6; + --hover: rgba(20, 22, 29, 0.045); --press: rgba(20, 22, 29, 0.08); + --border: #d9dce5; --hairline: rgba(20, 22, 29, 0.08); + --text: #14161d; --text-2: #565c6e; --text-3: #676d80; + --primary: #4b52d6; --primary-hover: #565de0; --accent: #3c43c2; --accent-soft: rgba(75, 82, 214, 0.1); + --ok: #127a4c; --warn: #9a6a12; --err: #c8423f; + --art-opacity: 0.3; --shadow: 0 18px 44px -22px rgba(30, 34, 60, 0.35); + color-scheme: light; + } +} + +* { box-sizing: border-box; } +html, body { height: 100%; margin: 0; overflow: clip; } +body { background: var(--bg); color: var(--text); font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; user-select: none; } +input, textarea, [contenteditable] { user-select: text; } +button, input, select { font: inherit; color: inherit; } +button { cursor: pointer; background: none; border: 0; padding: 0; } +h1, h2, h3 { margin: 0; font-weight: 600; } +p { margin: 0; } +code, kbd { font-family: var(--mono); font-size: 11.5px; } +kbd { padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); color: var(--text-3); background: var(--surface); } +[hidden] { display: none !important; } +:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } +.i { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; } +.i svg { width: 100%; height: 100%; display: block; } + +html, body { height: 100%; } +body { display: flex; flex-direction: column; } +.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); flex: 1; min-height: 0; } + +/* sidebar */ +.sidebar { background: var(--sidebar); border-right: 1px solid var(--hairline); display: flex; flex-direction: column; min-height: 0; padding: var(--s4) var(--s3) var(--s3); gap: var(--s4); } +.brand { padding: var(--s1) var(--s2) var(--s2); } +.lockup { height: 30px; width: auto; display: block; } +.lockup-dark { display: none; } +:root[data-theme="light"] .lockup-light { display: none; } +:root[data-theme="light"] .lockup-dark { display: block; } +@media (prefers-color-scheme: light) { + :root:not([data-theme]) .lockup-light, :root[data-theme="system"] .lockup-light { display: none; } + :root:not([data-theme]) .lockup-dark, :root[data-theme="system"] .lockup-dark { display: block; } +} +.nav { display: grid; gap: 2px; } +.nav-item { position: relative; display: flex; align-items: center; gap: var(--s3); height: 36px; padding: 0 var(--s3); border-radius: var(--r-ctl); color: var(--text-2); font-weight: 500; width: 100%; text-align: left; transition: background-color 120ms var(--ease), color 120ms var(--ease); } +.nav-item:hover { background: var(--hover); color: var(--text); } +.nav-item:active { background: var(--press); } +.nav-item[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--hairline); } +.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); } +.nav-item kbd { margin-left: auto; opacity: 0; transition: opacity 120ms var(--ease); } +.nav-item:hover kbd { opacity: 1; } +.nav-item .count { margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; } +.nav-ring { position: relative; width: 18px; height: 18px; display: grid; place-items: center; } +.nav-ring > svg { position: absolute; inset: -3px; width: 24px; height: 24px; transform: rotate(-90deg); opacity: 0; transition: opacity 160ms var(--ease); } +.nav-ring .track { fill: none; stroke: var(--border); stroke-width: 2; } +.nav-ring .fill { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 53.4; stroke-dashoffset: 53.4; transition: stroke-dashoffset 300ms var(--ease); } +.nav-item.busy .nav-ring > svg { opacity: 1; } +.nav-item.busy .nav-ring .i { transform: scale(0.72); } +.nav-item.landed { animation: landed 300ms var(--ease); } +@keyframes landed { 30% { background: var(--accent-soft); } } + +.fetched-head { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s3) var(--s2); } +.fetched-head h2 { font-size: 12px; font-weight: 600; color: var(--text-3); } +.fetched-strip { display: flex; align-items: center; gap: var(--s2); } +.fetched-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: thin; } +.fetched-list li { flex: none; max-width: 240px; } +.fetched-empty { padding: 0 var(--s3); color: var(--text-3); font-size: 12px; } +.fetched-item { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--s2); align-items: center; padding: 4px 10px 4px 4px; border-radius: var(--r-ctl); width: 100%; text-align: left; border: 1px solid var(--hairline); transition: background-color 120ms var(--ease); } +.fetched-item .thumb { width: 28px; height: 28px; } +.fetched-item:hover { background: var(--hover); } +.fetched-item[aria-current="true"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--hairline); } +.fetched-item .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.fetched-item .m { color: var(--text-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.thumb { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; background: var(--surface-2); display: block; } +.thumb.ph { display: grid; place-items: center; color: var(--text-3); } +.thumb.ph .i { width: 16px; height: 16px; } +.spin-sm .i { animation: spin 900ms linear infinite; } + +.sidebar-foot { display: grid; gap: 2px; border-top: 1px solid var(--hairline); padding-top: var(--s2); } +.engine-state { display: flex; align-items: center; gap: var(--s2); padding: 6px var(--s3); border-radius: var(--r-ctl); color: var(--text-3); font-size: 11.5px; text-align: left; } +.engine-state:hover { background: var(--hover); color: var(--text-2); } +.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; } +.dot.ok { background: var(--ok); } +.dot.warn { background: var(--warn); } + +/* main + views */ +.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; } +.view { flex: 1; min-height: 0; display: flex; flex-direction: column; animation: viewIn 160ms var(--ease); } +@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } } +.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); padding: var(--s8) var(--s8) var(--s5); } +.view-head h1 { font: 600 20px/1.2 var(--font-display); letter-spacing: -0.01em; } +.view-sub { color: var(--text-2); margin-top: 2px; } +.row { display: flex; align-items: center; gap: var(--s2); } +.row.end { justify-content: flex-end; } + +/* buttons + controls */ +.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: 32px; padding: 0 var(--s4); border-radius: var(--r-ctl); border: 1px solid var(--border); background: var(--surface); font-weight: 500; white-space: nowrap; transition: background-color 120ms var(--ease), border-color 120ms var(--ease), transform 120ms var(--ease); } +.btn:hover { background: var(--surface-2); } +.btn:active { transform: translateY(1px); } +.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; } +.btn .i { width: 16px; height: 16px; color: currentColor; } +.btn.primary .i { color: var(--on-primary); } +.btn.primary { background: var(--primary); border-color: transparent; color: var(--on-primary); } +.btn.primary:hover:not(:disabled) { background: var(--primary-hover); } +.btn.big { height: 38px; padding: 0 var(--s5); font-size: 13.5px; } +.btn.small { height: 26px; padding: 0 var(--s3); font-size: 12px; } +.btn.wide { width: 100%; } +.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); } +.btn.ghost:hover { background: var(--hover); color: var(--text); } +.btn.danger-ghost { background: transparent; color: var(--err); border-color: transparent; } +.btn.danger-ghost:hover { background: var(--hover); } +.btn .spin { display: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite; } +.btn.loading .spin { display: inline-block; } +.btn.loading .label { opacity: 0.8; } +@keyframes spin { to { transform: rotate(360deg); } } +.icon-btn { width: 28px; height: 28px; display: inline-grid; place-items: center; border-radius: var(--r-ctl); color: var(--text-3); transition: background-color 120ms var(--ease), color 120ms var(--ease); } +.icon-btn:hover { background: var(--hover); color: var(--text); } +.icon-btn .i { width: 16px; height: 16px; } +.link-btn { color: var(--text-3); font-size: 12px; padding: 2px 4px; border-radius: 4px; } +.link-btn:hover { color: var(--text); } + +input[type="checkbox"].box, .attest input, .pledge input, .tl-check { appearance: none; width: 16px; height: 16px; margin: 0; border-radius: 4px; border: 1.5px solid var(--text-3); background: transparent; display: inline-grid; place-items: center; flex: none; cursor: pointer; transition: background-color 100ms var(--ease), border-color 100ms var(--ease); } +.attest input:checked, .pledge input:checked, .tl-check:checked { background: var(--primary); border-color: var(--primary); } +.attest input:checked::after, .pledge input:checked::after, .tl-check:checked::after { content: ""; width: 8px; height: 4px; border: 2px solid var(--on-primary); border-top: 0; border-right: 0; transform: translate(0, -1px) rotate(-45deg); } +.tl-check:indeterminate { background: var(--primary); border-color: var(--primary); } +.tl-check:indeterminate::after { content: ""; width: 8px; height: 2px; background: var(--on-primary); border-radius: 1px; } +.tl-check:disabled { opacity: 0.35; cursor: not-allowed; } + +.switch { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--border); position: relative; flex: none; cursor: pointer; margin: 0; transition: background-color 140ms var(--ease); } +.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--on-primary); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 160ms var(--ease); } +.switch:checked { background: var(--primary); } +.switch:checked::after { transform: translateX(14px); } + +.text, select { height: 32px; border-radius: var(--r-ctl); border: 1px solid var(--border); background: var(--bg); padding: 0 var(--s3); min-width: 0; outline: none; transition: border-color 120ms var(--ease); } +.text:focus, select:focus { border-color: var(--accent); } +.text.short { width: 140px; } +select { padding-right: var(--s6); cursor: pointer; } + +/* command bar */ +.command { padding: var(--s5) var(--s8) var(--s3); display: grid; gap: var(--s2); border-bottom: 1px solid var(--hairline); } +.command-bar { display: flex; align-items: center; gap: var(--s3); height: 46px; padding: 0 6px 0 var(--s4); border-radius: 10px; background: var(--surface); border: 1px solid var(--border); transition: border-color 120ms var(--ease); } +.command-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); } +.command-glyph { color: var(--text-3); transition: color 120ms var(--ease); } +.command-glyph.known { color: var(--text); } +.command-bar input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 15px; height: 100%; } +.command-bar input::placeholder { color: var(--text-3); } +.scope { display: flex; padding: 2px; border-radius: 7px; background: var(--bg); border: 1px solid var(--hairline); } +.scope button { height: 26px; padding: 0 10px; border-radius: 5px; color: var(--text-2); font-size: 12px; font-weight: 500; } +.scope button[aria-checked="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--hairline); } +.clip { display: flex; align-items: center; gap: var(--s2); padding: 6px 6px 6px var(--s3); border-radius: var(--r-ctl); background: var(--accent-soft); color: var(--text-2); font-size: 12.5px; animation: viewIn 180ms var(--ease); } +.clip > .i { width: 16px; height: 16px; color: var(--accent); } +.clip code { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); } + +.get-scroll { flex: 1; min-height: 0; overflow-y: auto; } +.banner { display: flex; align-items: center; gap: var(--s3); margin: var(--s5) var(--s8) 0; padding: var(--s3) var(--s4); border-radius: var(--r-card); border: 1px solid var(--border); background: var(--surface); } +.banner > .i { color: var(--warn); } +.banner div { flex: 1; color: var(--text-2); } +.banner strong { color: var(--text); font-weight: 600; } + +/* empty state */ +.empty-get { max-width: 560px; margin: 0 auto; padding: 72px var(--s8) var(--s12); display: grid; justify-items: start; gap: var(--s4); } +.empty-art img { width: 120px; height: auto; display: block; } +.empty-get h1 { font: 600 26px/1.2 var(--font-display); letter-spacing: -0.015em; } +.empty-get > p { color: var(--text-2); font-size: 14px; max-width: 46ch; } +.examples { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; gap: 1px; width: 100%; border-radius: var(--r-card); overflow: hidden; border: 1px solid var(--hairline); background: var(--hairline); } +.examples li { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); background: var(--surface); } +.examples li > .i { color: var(--accent); margin-top: 1px; } +.examples strong { display: block; font-weight: 600; } +.examples span:not(.i) { color: var(--text-2); } +.empty-get .hint { color: var(--text-3); font-size: 12.5px; } + +/* release sheet */ +.sheet { position: relative; padding-bottom: var(--s6); } +.sheet-head { position: relative; isolation: isolate; display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: var(--s8); align-items: end; padding: var(--s8) var(--s8) var(--s6); overflow: hidden; } +.sheet-art-bg { position: absolute; inset: -60px; z-index: -2; background-size: cover; background-position: center; filter: blur(56px) saturate(1.35); opacity: var(--art-opacity); transform: scale(1.15); } +.sheet-head::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to bottom, transparent 30%, var(--bg)); } +.cover { width: 176px; height: 176px; border-radius: 10px; object-fit: cover; display: block; background: var(--surface-2); box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--hairline); } +.cover.ph { display: grid; place-items: center; color: var(--text-3); } +.cover.ph .i { width: 44px; height: 44px; } +.cover-wrap { position: relative; } +.cover-edit { position: absolute; right: 8px; bottom: 8px; height: 26px; padding: 0 10px; border-radius: 6px; background: rgba(10, 12, 18, 0.72); color: #fff; font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; opacity: 0; transition: opacity 140ms var(--ease); } +.cover-edit .i { width: 14px; height: 14px; } +.cover-wrap:hover .cover-edit, .cover-edit:focus-visible { opacity: 1; } +.head-meta { min-width: 0; display: grid; gap: 6px; padding-bottom: 4px; } +.kind-line { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12.5px; flex-wrap: wrap; } +.kind-btn { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 8px; border-radius: var(--r-chip); background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 12px; box-shadow: inset 0 0 0 1px var(--hairline); } +.kind-btn .i { width: 13px; height: 13px; color: var(--text-3); } +.kind-btn:hover { background: var(--surface); } +.kind-src { color: var(--text-3); } +.sep { color: var(--text-3); } +.editable { border-radius: 6px; padding: 0 4px; margin: 0 -4px; outline: none; transition: background-color 120ms var(--ease); } +.editable:hover { background: var(--hover); } +.editable:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); } +.editable:empty::before { content: attr(data-placeholder); color: var(--text-3); } +.head-title { font: 650 30px/1.15 var(--font-display); letter-spacing: -0.02em; overflow-wrap: anywhere; } +.head-artist { font-size: 15px; color: var(--text); font-weight: 500; } +.head-facts { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); color: var(--text-2); margin-top: 6px; } +.fact { display: inline-flex; align-items: baseline; gap: 6px; } +.fact b { font-weight: 500; color: var(--text-3); font-size: 12px; } +.fact .editable { color: var(--text); min-width: 2ch; } +.head-actions { display: flex; gap: var(--s2); margin-top: var(--s3); } + +.sheet-body { position: relative; padding: 0 var(--s8); } +.sheet-body.inspecting { padding-right: calc(var(--s8) + 352px); } +.tl-tools { display: flex; align-items: center; gap: var(--s3); height: 40px; color: var(--text-2); font-size: 12.5px; border-bottom: 1px solid var(--hairline); padding: 0 var(--s2); } +.tl-tools .grow { flex: 1; } +.tl-tools .warn-note { color: var(--warn); } +.tracklist { list-style: none; margin: 0; padding: var(--s1) 0 0; } +.tl-row { display: grid; grid-template-columns: 20px 28px minmax(0, 1fr) auto 52px 28px; gap: var(--s3); align-items: center; height: 44px; padding: 0 var(--s2); border-radius: var(--r-ctl); cursor: default; transition: background-color 100ms var(--ease); } +.tl-row:hover { background: var(--hover); } +.tl-row[aria-selected="true"] { background: var(--accent-soft); } +.tl-row.off .tl-main, .tl-row.off .tl-num, .tl-row.off .tl-dur { opacity: 0.45; } +.tl-num { color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; font-size: 12.5px; } +.tl-main { min-width: 0; display: grid; } +.tl-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.tl-sub { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.tl-dur { color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; font-size: 12.5px; } +.tl-row .icon-btn { opacity: 0; } +.tl-row:hover .icon-btn, .tl-row[aria-selected="true"] .icon-btn, .tl-row .icon-btn:focus-visible { opacity: 1; } +.flag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: var(--r-chip); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); white-space: nowrap; } +.flag.warn { color: var(--warn); } +.flag.edited { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); background: var(--accent-soft); } +.skeleton { display: block; height: 10px; border-radius: 5px; background: var(--surface-2); animation: pulse 1.4s cubic-bezier(0.45, 0, 0.55, 1) infinite; } +.skeleton.w60 { width: 60%; } .skeleton.w30 { width: 30%; margin-top: 6px; height: 8px; } +@keyframes pulse { 50% { opacity: 0.45; } } + +/* inspector */ +.inspector { position: absolute; top: 0; right: var(--s8); width: 336px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--shadow); animation: slideIn 200ms var(--ease); max-height: calc(100vh - 220px); display: flex; flex-direction: column; } +.inspector.inline { position: static; width: auto; max-width: 720px; box-shadow: none; animation: none; max-height: none; } +@keyframes slideIn { from { opacity: 0; transform: translateX(12px); } } +.ins-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4); border-bottom: 1px solid var(--hairline); } +.ins-head .t { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.ins-body { padding: var(--s4); overflow-y: auto; display: grid; gap: var(--s4); } +.ins-cover { display: flex; gap: var(--s3); align-items: center; } +.ins-cover img, .ins-cover .ph { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); } +.ins-cover .stack { display: grid; gap: 4px; } +.fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); } +.inspector.inline .fields { grid-template-columns: repeat(4, minmax(0, 1fr)); } +.field { display: grid; gap: 4px; min-width: 0; } +.field.full { grid-column: 1 / -1; } +.inspector.inline .field.half { grid-column: span 2; } +.field > span { font-size: 11.5px; color: var(--text-3); font-weight: 500; } +.field input { height: 30px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg); padding: 0 var(--s2); outline: none; min-width: 0; width: 100%; font-variant-numeric: tabular-nums; } +.field input:focus { border-color: var(--accent); } +.field input.changed { border-color: var(--accent); background: var(--accent-soft); } +.ins-section { display: grid; gap: var(--s2); } +.ins-section h3 { font-size: 12px; color: var(--text-2); font-weight: 600; } +.avail { display: flex; flex-wrap: wrap; gap: 6px; } +.avail .flag { font-weight: 500; } +.ins-foot { display: flex; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--hairline); } + +/* commit bar */ +.commit { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s8); border-top: 1px solid var(--hairline); background: var(--bg); } +.save-as { display: flex; align-items: center; gap: var(--s2); height: 38px; padding: 0 var(--s3); border-radius: var(--r-ctl); border: 1px solid var(--border); background: var(--surface); transition: background-color 120ms var(--ease); } +.save-as:hover, .save-as[aria-expanded="true"] { background: var(--surface-2); } +.save-as-label { color: var(--text-3); font-size: 12px; } +.save-as-value { font-weight: 600; } +.save-as .i { width: 14px; height: 14px; color: var(--text-3); } +.dest { display: flex; align-items: center; gap: var(--s2); min-width: 0; flex: 1; height: 38px; padding: 0 var(--s3); border-radius: var(--r-ctl); color: var(--text-2); transition: background-color 120ms var(--ease), color 120ms var(--ease); } +.dest:hover { background: var(--hover); color: var(--text); } +.dest .i { width: 16px; height: 16px; } +.dest-path { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; } +.attest { display: flex; align-items: center; gap: var(--s2); color: var(--text-2); cursor: pointer; white-space: nowrap; } +.attest.nudge { animation: nudge 300ms var(--ease); color: var(--text); } +@keyframes nudge { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } } + +/* save-as menu */ +.save-menu { position: fixed; z-index: 40; width: 380px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 6px; animation: menuIn 150ms var(--ease); } +@keyframes menuIn { from { opacity: 0; transform: translateY(6px); } } +.opt { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: var(--s3); padding: 10px var(--s3); border-radius: var(--r-ctl); width: 100%; text-align: left; } +.opt:hover:not(:disabled) { background: var(--hover); } +.opt:disabled { opacity: 0.45; cursor: not-allowed; } +.opt .radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--text-3); margin-top: 2px; display: grid; place-items: center; } +.opt[aria-checked="true"] .radio { border-color: var(--primary); } +.opt[aria-checked="true"] .radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); } +.opt strong { display: block; font-weight: 600; } +.opt small { display: block; color: var(--text-2); font-size: 12px; margin-top: 1px; } +.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s2); } +.chip { height: 26px; padding: 0 10px; border-radius: var(--r-chip); border: 1px solid var(--border); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text-2); } +.chip:hover { color: var(--text); background: var(--hover); } +.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); } +.menu-divider { height: 1px; background: var(--hairline); margin: 4px 6px; } +.menu-note { padding: var(--s2) var(--s3) 6px; color: var(--text-3); font-size: 11.5px; } + +.menu { position: fixed; z-index: 40; min-width: 200px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 6px; animation: menuIn 150ms var(--ease); } +.menu button { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); width: 100%; height: 32px; padding: 0 var(--s3); border-radius: 6px; text-align: left; } +.menu button:hover { background: var(--hover); } +.menu button[aria-checked="true"]::after { content: ""; width: 8px; height: 4px; border: 2px solid var(--accent); border-top: 0; border-right: 0; transform: translateY(-2px) rotate(-45deg); } + +/* downloads */ +.downloads-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--s8) var(--s8); display: grid; align-content: start; gap: var(--s6); } +.groups { display: grid; gap: var(--s3); } +.group-card { border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--hairline); overflow: hidden; animation: viewIn 200ms var(--ease); } +.gc-head { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); } +.gc-head .thumb { width: 44px; height: 44px; border-radius: 8px; } +.gc-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.gc-sub { color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; } +.bar { height: 3px; background: var(--surface-2); border-radius: 2px; overflow: hidden; } +.bar > i { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: 2px; transform-origin: left; transform: scaleX(0); transition: transform 260ms var(--ease); } +.bar.ok > i { background: var(--ok); } +.bar.err > i { background: var(--err); } +.bar.indet > i { width: 30%; transform: none; animation: indet 1.2s linear infinite; } +@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(340%); } } +.gc-bar { margin: 0 var(--s4) var(--s3); } +.jobs { list-style: none; margin: 0; padding: 0 0 6px; border-top: 1px solid var(--hairline); } +.job { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(120px, 220px) 28px; gap: var(--s3); align-items: center; padding: 6px var(--s4); } +.job .tl-num { font-size: 12px; } +.job-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; } +.job-status { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; } +.job-status.ok { color: var(--ok); } +.job-status.err { color: var(--err); white-space: normal; } +.job-note { grid-column: 2 / -1; font-size: 11.5px; color: var(--text-2); margin-top: -2px; } +.job-right { display: grid; gap: 4px; } + +.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s2); } +.history-head h2 { font-size: 14px; } +.day { font-size: 12px; font-weight: 600; color: var(--text-3); margin: var(--s4) 0 var(--s1); } +.hist { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto auto; gap: var(--s3); align-items: center; padding: 6px var(--s2); border-radius: var(--r-ctl); } +.hist:hover { background: var(--hover); } +.hist .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; } +.hist .m { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.hist .when { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; } +.hist.missing .t, .hist.missing .m { color: var(--text-3); } +.hist .acts { display: flex; gap: 2px; opacity: 0; } +.hist:hover .acts, .hist .acts:focus-within { opacity: 1; } +.empty-downloads { display: grid; justify-items: center; text-align: center; gap: var(--s2); padding: 80px 0; color: var(--text-2); } +.empty-downloads > .i { width: 32px; height: 32px; color: var(--text-3); } +.empty-downloads h2 { font-size: 15px; color: var(--text); } + +/* settings */ +.settings-scroll { flex: 1; min-height: 0; overflow-y: auto; } +.settings { max-width: 760px; padding: 0 var(--s8) var(--s12); } +.settings h2 { font-size: 13px; font-weight: 600; color: var(--text-2); margin: var(--s6) 0 var(--s2) var(--s1); } +.settings h2:first-child { margin-top: 0; } +.group { border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--hairline); overflow: hidden; } +.setting { display: flex; align-items: center; justify-content: space-between; gap: var(--s6); min-height: 56px; padding: var(--s3) var(--s4); border-top: 1px solid var(--hairline); } +.setting:first-child { border-top: 0; } +label.setting { cursor: pointer; } +.setting > div:first-child { display: grid; gap: 2px; min-width: 0; } +.setting strong { font-weight: 500; } +.setting span { color: var(--text-2); font-size: 12px; } +.setting.stack { display: grid; justify-content: stretch; gap: var(--s2); } +.setting.stack .text { width: 100%; font-family: var(--mono); font-size: 12.5px; } +.setting code { color: var(--text); } +.tokens { display: flex; flex-wrap: wrap; gap: 6px; } +.tokens button { height: 24px; padding: 0 8px; border-radius: var(--r-chip); background: var(--surface-2); color: var(--text-2); font: 11.5px var(--mono); box-shadow: inset 0 0 0 1px var(--hairline); } +.tokens button:hover { color: var(--text); } +.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--r-ctl); overflow: hidden; } +.stepper button { width: 30px; height: 30px; color: var(--text-2); font-size: 16px; } +.stepper button:hover { background: var(--hover); color: var(--text); } +.stepper output { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; } +.seg { display: inline-flex; padding: 2px; border-radius: var(--r-ctl); background: var(--bg); border: 1px solid var(--hairline); } +.seg button { height: 26px; padding: 0 12px; border-radius: 6px; color: var(--text-2); font-weight: 500; font-size: 12px; } +.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--hairline); } +.saved { color: var(--ok); font-size: 12px; opacity: 0; transition: opacity 200ms var(--ease); } +.saved.on { opacity: 1; } +.tool { align-items: center; } +.tool .name { display: flex; align-items: center; gap: var(--s2); } +.tool .acts { display: flex; gap: var(--s2); align-items: center; } +.tool .bar { width: 140px; } +.advanced { display: block; } +.advanced summary { list-style: none; display: grid; gap: 2px; cursor: pointer; } +.advanced summary::-webkit-details-marker { display: none; } +.adv-fields { display: grid; gap: var(--s3); margin-top: var(--s3); } +.adv-fields label { display: grid; gap: 4px; } +.adv-fields .text { font-family: var(--mono); font-size: 12px; } + +/* onboarding */ +.onboarding { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: grid; place-items: center; padding: var(--s8); overflow-y: auto; animation: viewIn 200ms var(--ease); } +.ob-card { width: 100%; max-width: 560px; display: grid; gap: var(--s5); } +.ob-mark { width: 96px; height: auto; } +.ob-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--s5); color: var(--text-3); font-size: 12px; font-weight: 600; counter-reset: step; } +.ob-steps li { display: flex; align-items: center; gap: 6px; counter-increment: step; } +.ob-steps li::before { content: counter(step); width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid currentColor; font-size: 10.5px; } +.ob-steps li.on { color: var(--text); } +.ob-steps li.done { color: var(--ok); } +.ob-step { display: grid; gap: var(--s3); } +.ob-step h1 { font: 650 26px/1.2 var(--font-display); letter-spacing: -0.015em; } +.lede { color: var(--text-2); font-size: 14px; margin-bottom: var(--s2); } +.pledge { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-card); border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text-2); line-height: 1.5; transition: border-color 120ms var(--ease); } +.pledge input { margin-top: 2px; } +.pledge b { color: var(--text); font-weight: 600; } +.pledge:has(input:checked) { border-color: var(--primary); } +.fine { color: var(--text-3); font-size: 12px; margin: var(--s1) 0 var(--s2); } +.ob-tools { display: grid; gap: var(--s2); margin-bottom: var(--s2); } +.ob-tool { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2) var(--s4); align-items: center; padding: var(--s3) var(--s4); border-radius: var(--r-card); border: 1px solid var(--border); background: var(--surface); } +.ob-tool strong { font-weight: 600; } +.ob-tool > div > span { display: block; color: var(--text-2); font-size: 12px; margin-top: 2px; } +.ob-tool .bar { grid-column: 1 / -1; } + +/* cover flight + toasts */ +.flyer { position: fixed; z-index: 80; border-radius: 8px; object-fit: cover; pointer-events: none; box-shadow: var(--shadow); } +.toasts { position: fixed; bottom: 100px; left: calc(50% + 118px); transform: translateX(-50%); z-index: 90; display: grid; gap: var(--s2); justify-items: center; pointer-events: none; } +.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--s3); max-width: 560px; padding: 10px var(--s4); border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); animation: menuIn 180ms var(--ease); } +.toast .i { width: 16px; height: 16px; } +.toast.err .i { color: var(--err); } +.toast.ok .i { color: var(--ok); } +.toast.out { opacity: 0; transition: opacity 200ms var(--ease); } + +::-webkit-scrollbar { width: 10px; height: 10px; } +::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; } +::-webkit-scrollbar-track { background: transparent; } + +@media (max-width: 980px) { + .shell { grid-template-columns: 200px minmax(0, 1fr); } + .sheet-head { grid-template-columns: 128px minmax(0, 1fr); gap: var(--s5); } + .cover { width: 128px; height: 128px; } + .sheet-body.inspecting { padding-right: var(--s8); } + .inspector { position: fixed; top: 80px; right: 16px; } + .commit { flex-wrap: wrap; } + .attest { order: 3; } +} + +@media (prefers-reduced-motion: reduce) { + *, *::before, *::after { animation-duration: 120ms !important; animation-iteration-count: 1 !important; transition-duration: 120ms !important; } + .view, .inspector, .save-menu, .menu, .toast, .group-card { animation-name: fadeOnly !important; } + .skeleton, .bar.indet > i, .btn .spin { animation: none !important; } +} +@keyframes fadeOnly { from { opacity: 0; } } + +/* sidebar groups */ +.sidebar { overflow: hidden; } +.nav-group { display: grid; gap: 2px; min-height: 0; } +.nav-group.grow { flex: 1; display: flex; flex-direction: column; } +.nav-heading { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 0 var(--s3) var(--s1); } +.nav-heading-row { display: flex; align-items: center; justify-content: space-between; padding-right: var(--s1); } +.nav-heading-row .nav-heading { padding-bottom: 0; } +.playlist-nav { overflow-y: auto; min-height: 0; align-content: start; } +.nav-item.small { height: 32px; font-size: 12.5px; } +.nav-item .nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.nav-item .nav-meta { color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; } +.nav-item.drop { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--text); } +.dest-playlist { height: 38px; max-width: 170px; } + +/* library */ +.lib-scroll { flex: 1; min-height: 0; overflow-y: auto; } +.lib-head { display: flex; align-items: flex-end; gap: var(--s4); padding: var(--s8) var(--s8) var(--s4); position: sticky; top: 0; z-index: 3; background: var(--bg); } +.lib-titles { flex: 1; min-width: 0; } +.lib-head h1 { font: 650 24px/1.2 var(--font-display); letter-spacing: -0.015em; } +.lib-search { width: 220px; } +.icon-btn.back { align-self: center; } +.pad-x { padding: 0 var(--s8) var(--s8); } +.pad { padding: var(--s4); } +.muted { color: var(--text-2); } +.small { font-size: 12px; } +.lt-head, .lt-row { display: grid; grid-template-columns: 36px minmax(0, 2.2fr) minmax(0, 1.4fr) 32px 52px 32px; gap: var(--s3); align-items: center; padding: 0 var(--s3); } +.lt-head.with-cover, .lt-row.with-cover { grid-template-columns: 36px 40px minmax(0, 2.2fr) minmax(0, 1.4fr) 32px 52px 32px; } +.lt-head { height: 32px; margin: 0 var(--s8); border-bottom: 1px solid var(--hairline); color: var(--text-3); font-size: 11.5px; font-weight: 600; position: sticky; top: 92px; z-index: 2; background: var(--bg); } +.lt-head .r, .lt-head .i { justify-self: end; width: 14px; height: 14px; } +.lt-row { height: 52px; border-radius: var(--r-ctl); transition: background-color 100ms var(--ease); } +.lt-row:hover, .lt-row:focus-within { background: var(--hover); } +.lt-row.playing .lt-title { color: var(--accent); } +.lt-num { position: relative; display: grid; place-items: center; color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; } +.lt-num .i { width: 16px; height: 16px; color: var(--accent); } +.lt-play { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text); opacity: 0; border-radius: 6px; } +.lt-play .i { width: 15px; height: 15px; color: var(--text); } +.lt-row:hover .lt-play, .lt-play:focus-visible { opacity: 1; background: var(--surface-2); } +.lt-cover { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); } +.lt-cover .i { width: 16px; height: 16px; } +.lt-main { min-width: 0; display: grid; } +.lt-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.lt-sub, .lt-album { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; } +.lt-dur { color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; font-size: 12.5px; } +.lt-row .icon-btn { opacity: 0; } +.lt-row:hover .icon-btn, .lt-row .icon-btn:focus-visible, .lt-row .like.on { opacity: 1; } +.like.on { color: var(--accent); } +.link { color: inherit; text-align: left; border-radius: 3px; } +.link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; } +.links { display: inline; } +.vlist { padding: 0 var(--s8) var(--s8); } +.vspacer { position: relative; } +.vspacer .lt-row { position: absolute; left: 0; right: 0; top: 0; } +.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: var(--s5) var(--s4); padding: 0 var(--s8) var(--s8); } +.sections .grid { padding: 0; } +.card-tile { display: grid; gap: 6px; padding: var(--s2); margin: calc(var(--s2) * -1); border-radius: var(--r-card); cursor: pointer; transition: background-color 120ms var(--ease); min-width: 0; } +.card-tile:hover, .card-tile:focus-visible { background: var(--hover); } +.tile-art { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); box-shadow: 0 0 0 1px var(--hairline); } +.tile-art.round { border-radius: 50%; } +.tile-img { width: 100%; height: 100%; object-fit: cover; display: grid; place-items: center; color: var(--text-3); } +.tile-img .i { width: 36px; height: 36px; } +.tile-play { position: absolute; right: 8px; bottom: 8px; width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; opacity: 0; transform: translateY(4px); transition: opacity 140ms var(--ease), transform 140ms var(--ease); box-shadow: var(--shadow); } +.tile-play .i { width: 18px; height: 18px; } +.card-tile:hover .tile-play, .tile-play:focus-visible { opacity: 1; transform: none; } +.tile-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.tile-sub { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: -4px; } +.card-tile.artist { text-align: center; } +.hero { position: relative; isolation: isolate; display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--s8); align-items: end; padding: var(--s10) var(--s8) var(--s6); overflow: hidden; margin-bottom: var(--s2); } +.hero-bg { position: absolute; inset: -60px; z-index: -2; background-size: cover; background-position: center; filter: blur(60px) saturate(1.35); opacity: var(--art-opacity); transform: scale(1.15); } +.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to bottom, transparent 25%, var(--bg)); } +.hero-cover { width: 200px; height: 200px; border-radius: 12px; object-fit: cover; background: var(--surface-2); box-shadow: 0 18px 44px -18px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--hairline); display: grid; place-items: center; color: var(--text-3); } +.hero-cover.ph .i { width: 52px; height: 52px; } +.hero-cover.mosaic { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; } +.hero-cover.mosaic img { width: 100%; height: 100%; object-fit: cover; } +.hero-meta { display: grid; gap: var(--s2); min-width: 0; } +.hero-title { font: 700 34px/1.12 var(--font-display); letter-spacing: -0.02em; overflow-wrap: anywhere; } +.hero-title.big { font-size: 48px; letter-spacing: -0.03em; } +.hero-artist { font-size: 15px; font-weight: 600; justify-self: start; } +.hero .row { margin-top: var(--s2); flex-wrap: wrap; } +.hero .path { color: var(--text-3); font: 11.5px var(--mono); justify-self: start; } +.on-hero { position: absolute; top: var(--s4); left: var(--s4); background: rgba(10, 12, 18, 0.4); color: #fff; } +.artist-hero { grid-template-columns: 180px minmax(0, 1fr); } +.avatar { width: 180px; height: 180px; border-radius: 50%; object-fit: cover; background: var(--surface-2); box-shadow: 0 18px 44px -18px rgba(0, 0, 0, 0.6); display: grid; place-items: center; color: var(--text-3); } +.avatar .i { width: 52px; height: 52px; } +.avatar.sm { width: 64px; height: 64px; } +.sections { display: grid; gap: var(--s8); } +.sec { font-size: 18px; font-weight: 650; margin-bottom: var(--s3); letter-spacing: -0.01em; } +.bio { color: var(--text-2); max-width: 70ch; white-space: pre-wrap; line-height: 1.6; } +.disc { display: flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--text-2); margin: var(--s5) 0 var(--s2) var(--s3); } +.disc .i { width: 16px; height: 16px; } +.hint-line { margin: 0 0 var(--s2) var(--s3); } +.lib-empty { display: grid; justify-items: center; text-align: center; gap: var(--s3); padding: 72px var(--s8); color: var(--text-2); } +.lib-empty h2 { font: 600 20px/1.3 var(--font-display); color: var(--text); } +.lib-empty p { max-width: 46ch; } +.lib-empty .bar { width: 260px; } +.lib-empty.slim { padding: var(--s10) var(--s8); } +.lib-empty > .i { width: 28px; height: 28px; color: var(--text-3); } +.lib-empty .row { margin-top: var(--s2); } + +/* context menu + modal */ +.menu.ctx { position: fixed; z-index: 70; } +.menu.ctx button.has-sub .i { width: 14px; height: 14px; transform: rotate(-90deg); color: var(--text-3); } +.menu button:disabled { opacity: 0.45; } +.modal-wrap { position: fixed; inset: 0; z-index: 75; display: grid; place-items: center; background: rgba(5, 6, 12, 0.5); padding: var(--s6); animation: fadeOnly 150ms var(--ease); } +.modal { width: 100%; max-width: 480px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: var(--s6); display: grid; gap: var(--s4); animation: menuIn 180ms var(--ease); } +.modal h2 { font-size: 17px; } +.stack { display: grid; gap: var(--s3); } +.text.wide { width: 100%; } +.text.area { height: auto; padding: var(--s2) var(--s3); resize: vertical; font: inherit; line-height: 1.5; width: 100%; } +.fields.two { grid-template-columns: 1fr 1fr; } + +/* player bar */ +.player { flex: none; display: grid; grid-template-columns: minmax(200px, 1fr) minmax(320px, 1.6fr) minmax(200px, 1fr); gap: var(--s4); align-items: center; height: 78px; padding: 0 var(--s4); background: var(--sidebar); border-top: 1px solid var(--hairline); position: relative; z-index: 30; } +.np { display: flex; align-items: center; gap: var(--s3); min-width: 0; } +.np-cover { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); box-shadow: 0 0 0 1px var(--hairline); } +.np-cover .i { width: 20px; height: 20px; } +.np-text { min-width: 0; display: grid; } +.np-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.np-artist { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.player.idle .np-title { color: var(--text-3); font-weight: 500; } +.transport { display: grid; gap: 4px; justify-items: center; } +.controls { display: flex; align-items: center; gap: var(--s2); } +.controls .icon-btn { width: 32px; height: 32px; color: var(--text-2); } +.controls .icon-btn:hover { color: var(--text); } +.icon-btn[aria-pressed="true"] { color: var(--accent); } +.play-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; transition: transform 120ms var(--ease); } +.play-btn svg { width: 18px; height: 18px; } +.play-btn:active { transform: scale(0.95); } +.seek-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: var(--s2); align-items: center; width: 100%; max-width: 620px; } +.time { color: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; text-align: center; } +.np-tools { display: flex; align-items: center; justify-content: flex-end; gap: 2px; } +.np-tools .icon-btn { width: 32px; height: 32px; } +.range { appearance: none; height: 16px; background: transparent; cursor: pointer; width: 100%; margin: 0; --p: 0%; } +.range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--text-2) var(--p), var(--border) var(--p)); } +.range:hover::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--accent) var(--p), var(--border) var(--p)); } +.range::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--text); margin-top: -4px; opacity: 0; transition: opacity 120ms var(--ease); } +.range:hover::-webkit-slider-thumb, .range:focus-visible::-webkit-slider-thumb, .range:active::-webkit-slider-thumb { opacity: 1; } +.range.vol { width: 96px; flex: none; } + +/* drawers */ +.drawer-panel { position: fixed; right: 12px; top: 12px; bottom: 90px; width: 380px; z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slideIn 200ms var(--ease); overflow: hidden; } +.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s4) var(--s3); border-bottom: 1px solid var(--hairline); } +.drawer-head h2 { font-size: 15px; } +.drawer-body { flex: 1; overflow-y: auto; padding: var(--s2) var(--s2) var(--s4); } +.q-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: 6px var(--s2); border-radius: var(--r-ctl); } +.q-row:hover { background: var(--hover); } +.q-row.now .lt-title { color: var(--accent); } +.q-row .icon-btn { opacity: 0; } +.q-row:hover .icon-btn, .q-row .icon-btn:focus-visible { opacity: 1; } +.q-sub { font-size: 12px; color: var(--text-3); margin: var(--s4) var(--s2) var(--s1); } +.offset { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--r-ctl); } +.offset .icon-btn { width: 26px; height: 26px; font-size: 15px; } +.offset output { font-size: 11px; min-width: 46px; text-align: center; color: var(--text-2); font-variant-numeric: tabular-nums; } + +/* lyrics */ +.lyr { display: grid; gap: 10px; padding: var(--s6) var(--s4) 40vh; } +.lyr.plain { padding-bottom: var(--s6); } +.lyr-line { font: 650 20px/1.35 var(--font-display); color: var(--text-3); letter-spacing: -0.01em; transition: color 180ms var(--ease), opacity 180ms var(--ease); border-radius: 6px; cursor: default; } +.lyr.synced .lyr-line { cursor: pointer; opacity: 0.55; } +.lyr.synced .lyr-line:hover { opacity: 0.85; } +.lyr.synced .lyr-line.past { opacity: 0.42; } +.lyr.synced .lyr-line.on { color: var(--text); opacity: 1; } +.lyr-line .w { transition: color 120ms var(--ease); } +.lyr-line.on .w { color: var(--text-3); } +.lyr-line.on .w.sung { color: var(--text); } +.lyr.plain .lyr-line { color: var(--text); font-size: 16px; font-weight: 500; } +.lyr-tr { display: block; font: 500 14px/1.4 var(--font); color: var(--text-2); margin-top: 2px; } +.lyr-state { display: grid; gap: var(--s3); justify-items: start; padding: var(--s6) var(--s4); color: var(--text-2); } +.lyr-state .skeleton { height: 16px; } +.lyr-copy { padding: 0 var(--s4) var(--s4); font-size: 11px; color: var(--text-3); } +.lyr.big .lyr-line { font-size: clamp(26px, 3.4vw, 52px); line-height: 1.2; color: rgba(255, 255, 255, 0.4); } +.lyr.big.synced .lyr-line.on, .lyr.big .lyr-line.on .w.sung { color: #fff; } +.lyr.big .lyr-line.on .w { color: rgba(255, 255, 255, 0.45); } +.lyr.big.plain .lyr-line { color: rgba(255, 255, 255, 0.85); font-size: clamp(20px, 2.2vw, 32px); } +.lyr.big .lyr-tr { color: rgba(255, 255, 255, 0.6); font-size: 0.45em; } + +/* effects panel */ +.fx { position: fixed; right: 16px; bottom: 90px; z-index: 45; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 120px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); animation: menuIn 180ms var(--ease); } +.fx-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s5) var(--s2); position: sticky; top: 0; background: var(--surface); z-index: 1; } +.fx-head h2 { font-size: 16px; } +.fx-body { display: grid; gap: var(--s5); padding: var(--s2) var(--s5) var(--s5); } +.fx-body h3 { font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: var(--s2); } +.fx-group { display: grid; grid-template-columns: 72px 1fr; gap: var(--s3); align-items: start; margin-bottom: var(--s2); } +.fx-group .chips { margin-top: 0; } +.fx-label { font-size: 12px; color: var(--text-3); font-weight: 600; padding-top: 5px; } +.fx-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s6); } +.fx-slider { display: grid; grid-template-columns: 104px minmax(0, 1fr) 72px; gap: var(--s3); align-items: center; height: 34px; } +.fx-slider .fx-label { padding-top: 0; color: var(--text-2); font-weight: 500; } +.fx-slider output { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text); text-align: right; } +.fx-slider input { appearance: none; height: 16px; background: transparent; cursor: pointer; width: 100%; margin: 0; } +.fx-slider input::-webkit-slider-runnable-track, .eq input::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--border) var(--p, 50%)); } +.fx-slider input::-webkit-slider-thumb, .eq input::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--text); margin-top: -5px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); } +.fx-slider.off { opacity: 0.45; } +.fx-toggle { display: flex; gap: var(--s3); align-items: flex-start; margin-top: var(--s2); cursor: pointer; } +.fx-toggle strong { display: block; font-weight: 500; } +.fx-toggle small { display: block; color: var(--text-2); font-size: 12px; } +.eq { display: grid; grid-template-columns: repeat(10, 1fr); gap: var(--s2); height: 168px; align-items: stretch; padding: var(--s2) 0; } +.band { display: grid; grid-template-rows: 1fr auto; justify-items: center; gap: 6px; } +.band span { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; } +.eq input.vert { appearance: none; writing-mode: vertical-lr; direction: rtl; width: 16px; height: 100%; background: linear-gradient(var(--border), var(--border)) center / 4px 100% no-repeat; border-radius: 2px; cursor: pointer; margin: 0; } +.eq input.vert::-webkit-slider-runnable-track { width: 16px; height: auto; background: transparent; } +.eq input.vert::-webkit-slider-thumb { margin-top: 0; margin-left: -5px; } + +/* TV mode */ +.tv { position: fixed; inset: 0; z-index: 90; background: #06070d; color: #fff; overflow: hidden; display: grid; animation: fadeOnly 240ms var(--ease); } +.tv-bg { position: absolute; inset: -80px; background-size: cover; background-position: center; filter: blur(80px) saturate(1.5) brightness(0.55); transform: scale(1.2); } +.tv::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 30% 50%, transparent, rgba(4, 5, 10, 0.65)); pointer-events: none; } +.tv-stage { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.3fr); gap: 6vw; align-items: center; padding: 6vh 6vw; height: 100%; min-height: 0; } +.tv.no-lyrics .tv-stage { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; } +.tv-now { display: grid; gap: 12px; justify-items: start; } +.tv.no-lyrics .tv-now { justify-items: center; } +.tv-cover { width: min(38vh, 34vw); height: min(38vh, 34vw); border-radius: 14px; object-fit: cover; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.8); background: rgba(255, 255, 255, 0.08); display: grid; place-items: center; } +.tv.no-lyrics .tv-cover { width: min(52vh, 60vw); height: min(52vh, 60vw); } +.tv-title { font: 700 clamp(24px, 2.6vw, 40px)/1.15 var(--font-display); letter-spacing: -0.02em; margin-top: 12px; } +.tv-artist { font-size: clamp(15px, 1.4vw, 20px); color: rgba(255, 255, 255, 0.7); } +.tv-bar { width: min(38vh, 34vw); height: 4px; background: rgba(255, 255, 255, 0.2); border-radius: 2px; overflow: hidden; margin-top: 10px; } +.tv.no-lyrics .tv-bar { width: min(52vh, 60vw); } +.tv-bar i { display: block; height: 100%; width: 100%; background: #fff; transform-origin: left; transform: scaleX(0); } +.tv-controls { display: flex; gap: 10px; align-items: center; transition: opacity 300ms var(--ease); } +.tv-controls .icon-btn { width: 44px; height: 44px; color: #fff; } +.tv-controls .icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; } +.tv-controls .i { width: 22px; height: 22px; } +.tv-play { background: rgba(255, 255, 255, 0.14) !important; border-radius: 50% !important; } +.tv-lyrics { height: 100%; min-height: 0; overflow-y: auto; mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 78%, transparent); scrollbar-width: none; } +.tv-lyrics::-webkit-scrollbar { display: none; } +.tv-lyrics .lyr { padding: 40vh 0; gap: 18px; } +.tv-close { position: absolute; top: 20px; right: 20px; z-index: 2; color: #fff; background: rgba(255, 255, 255, 0.1); transition: opacity 300ms var(--ease); } +.tv-viz { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 22vh; z-index: 0; opacity: 0; pointer-events: none; } +.tv.no-lyrics .tv-viz { opacity: 1; } +.tv.idle { cursor: none; } +.tv.idle .tv-controls, .tv.idle .tv-close { opacity: 0; } + +/* settings extras */ +.set-note { color: var(--text-2); font-size: 12.5px; margin: -4px 0 var(--s2) var(--s1); } +.settings h2.sub { font-size: 12px; color: var(--text-3); margin-top: var(--s4); } +.group.gap-top { margin-top: var(--s2); } +.mono-path { font: 500 12.5px var(--mono); overflow-wrap: anywhere; } +.setting .size { color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; } +.setting.custom .fields { width: 100%; } +.setting.custom .text { width: 100%; } + +@media (max-width: 1100px) { + .player { grid-template-columns: minmax(160px, 1fr) minmax(260px, 1.4fr) auto; } + .range.vol { width: 64px; } + .lt-head.with-cover, .lt-row.with-cover { grid-template-columns: 36px 40px minmax(0, 1fr) 32px 52px 32px; } + .lt-head.with-cover > :nth-child(4), .lt-row.with-cover > .lt-album { display: none; } + .fx-cols { grid-template-columns: 1fr; } +} + +/* custom title bar */ +:root { --titlebar: 40px; } +.titlebar { flex: none; height: var(--titlebar); display: grid; grid-template-columns: 236px minmax(0, 1fr) auto; align-items: stretch; background: var(--bg); position: relative; z-index: 80; user-select: none; } +.tb-brand { display: flex; align-items: center; padding: 0 var(--s5); background: var(--sidebar); border-right: 1px solid var(--hairline); } +.tb-brand .lockup { height: 26px; width: auto; pointer-events: none; } +.tb-drag { min-width: 0; } +.tb-controls { display: flex; } +.tb-btn { width: 46px; height: var(--titlebar); display: grid; place-items: center; color: var(--text-2); transition: background-color 100ms var(--ease), color 100ms var(--ease); } +.tb-btn svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1; shape-rendering: crispEdges; } +.tb-btn:hover { background: var(--hover); color: var(--text); } +.tb-btn:active { background: var(--press); } +.tb-btn.close:hover { background: #c42b1c; color: #fff; } +.tb-btn.close:active { background: #b3271a; color: #fff; } +.titlebar.mac { grid-template-columns: 236px minmax(0, 1fr); } +.titlebar.mac .tb-controls { display: none; } +.titlebar.mac .tb-brand { padding-left: 84px; } +.titlebar.mac .tb-brand .lockup { height: 22px; } +.titlebar.blur .tb-btn, .titlebar.blur .tb-brand .lockup { opacity: 0.6; } +.sidebar { padding-top: var(--s2); } +.onboarding { top: var(--titlebar); } +.drawer-panel { top: calc(var(--titlebar) + 12px); } +.fx { max-height: calc(100vh - 140px); } + +.menu button kbd { margin-left: auto; border: 0; background: none; padding: 0; color: var(--text-3); font: 11.5px var(--font); } +.menu button.danger { color: var(--err); } +.menu { min-width: 210px; } + +/* sound panel v2 */ +.fx { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 150px); overflow: hidden; display: flex; flex-direction: column; padding: 0; } +.fx-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s4); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--hairline); position: static; } +.fx-head .row { justify-self: end; } +.fx-title { display: grid; gap: 1px; min-width: 0; } +.fx-title h2 { font-size: 16px; } +.fx-title .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.fx-power { display: flex; align-items: center; gap: var(--s2); font-size: 12.5px; color: var(--text-2); cursor: pointer; margin-right: var(--s2); } +.fx-scroll { overflow-y: auto; padding: var(--s4) var(--s5) var(--s5); transition: opacity 160ms var(--ease); } +.fx-scroll.bypassed { opacity: 0.5; } +.fx-presets h3, .fx-card h3 { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 0 var(--s2); } +.fx-presets h3:not(:first-child) { margin-top: var(--s5); } +.preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); } +.preset { display: grid; gap: 2px; text-align: left; padding: var(--s3); border-radius: 10px; background: var(--bg); border: 1px solid var(--hairline); transition: border-color 120ms var(--ease), background-color 120ms var(--ease); width: 100%; min-width: 0; } +.preset:hover { border-color: var(--border); background: var(--surface-2); } +.preset.on { border-color: var(--accent); background: var(--accent-soft); } +.preset.add { border-style: dashed; place-content: center; justify-items: center; text-align: center; color: var(--text-2); min-height: 92px; } +.preset.add .i { width: 18px; height: 18px; } +.preset-name { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; margin-top: 6px; } +.preset.add .preset-name { margin-top: 2px; } +.preset-tag { font-size: 10.5px; font-weight: 600; padding: 0 5px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); } +.preset.on .preset-tag { background: var(--surface); } +.preset-desc { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.preset-wrap { position: relative; } +.preset-x { position: absolute; top: 4px; right: 4px; opacity: 0; } +.preset-wrap:hover .preset-x, .preset-x:focus-visible { opacity: 1; } +.mini-curve { display: block; height: 30px; } +.mini-curve svg { width: 100%; height: 100%; overflow: visible; } +.mini-curve .zero { stroke: var(--border); stroke-width: 1; fill: none; } +.mini-curve .line { stroke: var(--text-2); stroke-width: 2; fill: none; stroke-linecap: round; vector-effect: non-scaling-stroke; } +.preset.on .mini-curve .line { stroke: var(--accent); } +.fx-adjust { display: grid; gap: var(--s3); } +.fx-card { border-radius: 12px; background: var(--bg); border: 1px solid var(--hairline); padding: var(--s4); display: grid; gap: var(--s2); align-content: start; } +.fx-card h3.gap { margin-top: var(--s3); } +.fx-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); } +.fx-card-head h3 { margin: 0; } +.fx-split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); } +.eq-editor svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: none; } +.eq-editor .grid { stroke: var(--hairline); stroke-width: 1; stroke-dasharray: 3 4; } +.eq-editor .zero { stroke: var(--border); stroke-width: 1.2; } +.eq-editor text { fill: var(--text-3); font: 11px var(--font); font-variant-numeric: tabular-nums; } +.eq-editor .area { fill: var(--accent-soft); stroke: none; } +.eq-editor .curve { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; } +.eq-editor .node { cursor: ns-resize; outline: none; } +.eq-editor .hit { fill: transparent; } +.eq-editor .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; transition: r 120ms var(--ease); } +.eq-editor .node:hover .dot, .eq-editor .node.drag .dot, .eq-editor .node:focus-visible .dot { fill: var(--accent); } +.eq-editor .node:focus-visible .dot { stroke: var(--text); } +.eq-editor .val { fill: var(--text); font-size: 11px; font-weight: 600; opacity: 0; transition: opacity 120ms var(--ease); } +.eq-editor .node:hover .val, .eq-editor .node.drag .val, .eq-editor .node:focus-visible .val { opacity: 1; } +.val-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; } +.big-val { font: 650 22px/1.1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; } +.chips.tight { margin-top: 0; gap: 4px; } +.chips.tight .chip { height: 24px; padding: 0 8px; } +.range.strong { height: 20px; } +.range.strong::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p), var(--surface-2) var(--p)); } +.range.strong:hover::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--accent) var(--p), var(--surface-2) var(--p)); } +.range.strong::-webkit-slider-thumb { width: 16px; height: 16px; margin-top: -5px; opacity: 1; background: var(--text); box-shadow: 0 0 0 3px var(--bg), 0 1px 4px rgba(0, 0, 0, 0.5); } +.seg.wide { display: grid; grid-template-columns: 1fr 1fr; } +.seg.wide button { height: 30px; font-size: 12.5px; } +.fx-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--s3); align-items: center; } +.fx-row-label { font-size: 12.5px; color: var(--text-2); } +.fx-card > output.fx-row-val { justify-self: end; font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; margin-top: -6px; } +.fx-card .stepper button { width: 34px; height: 30px; } +.fx-card .stepper button:disabled { opacity: 0.4; cursor: not-allowed; } +@media (max-width: 720px) { .preset-grid { grid-template-columns: 1fr 1fr; } .fx-split { grid-template-columns: 1fr; } } + +.tv-note { font-size: 13px; color: rgba(255, 255, 255, 0.55); margin-top: 2px; } +.tv-finding { display: grid; gap: 14px; padding: 40vh 0; } +.tv-finding .skeleton { height: 34px; background: rgba(255, 255, 255, 0.14); border-radius: 8px; } +.tv-finding p { color: rgba(255, 255, 255, 0.55); font-size: 15px; } + +.tried { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 12px; color: var(--text-2); } +.tried strong { color: var(--text); font-weight: 600; } + +.eqbars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; width: 14px; } +.eqbars i { flex: 1; background: var(--accent); border-radius: 1px; height: 100%; transform-origin: bottom; animation: eqb 900ms ease-in-out infinite alternate; } +.eqbars i:nth-child(1) { animation-delay: -300ms; } +.eqbars i:nth-child(2) { animation-delay: -600ms; animation-duration: 760ms; } +.eqbars i:nth-child(3) { animation-delay: -150ms; animation-duration: 1040ms; } +@keyframes eqb { 0% { transform: scaleY(0.25); } 100% { transform: scaleY(1); } } +.is-paused .eqbars i { animation-play-state: paused; } +@media (prefers-reduced-motion: reduce) { .eqbars i { animation: none !important; } .eqbars i:nth-child(1) { transform: scaleY(0.55); } .eqbars i:nth-child(3) { transform: scaleY(0.75); } } +.lt-row:hover .lt-num .eqbars { opacity: 0; } + +.ins-sub { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); } +.lyr-input { font: 13px/1.55 var(--font); min-height: 120px; } +.ins-section.desc summary { cursor: pointer; list-style: none; } +.ins-section.desc summary::-webkit-details-marker { display: none; } +.ins-section.desc summary h3::after { content: " ▸"; color: var(--text-3); } +.ins-section.desc[open] summary h3::after { content: " ▾"; } +.desc-text { white-space: pre-wrap; color: var(--text-2); font-size: 12.5px; max-height: 220px; overflow-y: auto; } +.modal:has(.lyr-input) { max-width: 620px; } + +.lt-row.sel { background: var(--accent-soft); } +.lt-row.sel:hover { background: var(--accent-soft); } +.lt-row.sel .lt-title { color: var(--text); } +.check-row { display: flex; align-items: center; gap: var(--s3); cursor: pointer; font-size: 13px; } +input[type="checkbox"].box:checked { background: var(--primary); border-color: var(--primary); } +input[type="checkbox"].box:checked::after { content: ""; width: 8px; height: 4px; border: 2px solid var(--on-primary); border-top: 0; border-right: 0; transform: translate(0, -1px) rotate(-45deg); } + +/* stats */ +.stats { display: grid; gap: var(--s5); } +.period-nav { display: flex; align-items: center; gap: var(--s2); } +.period-label { font: 650 17px/1.2 var(--font-display); min-width: 160px; text-align: center; } +.stat-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); } +.stat-card { display: grid; gap: 4px; padding: var(--s4) var(--s5); border-radius: 14px; background: var(--surface); border: 1px solid var(--hairline); } +.stat-label { font-size: 12px; color: var(--text-2); font-weight: 600; } +.stat-value { font: 700 30px/1.1 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; } +.stat-sub { font-size: 12px; color: var(--text-3); } +.stat-panel { padding: var(--s4) var(--s5); border-radius: 14px; background: var(--surface); border: 1px solid var(--hairline); display: grid; gap: 2px; align-content: start; } +.stat-panel .sec { font-size: 15px; margin-bottom: var(--s2); } +.stat-split { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--s3); } +.rank-row { display: grid; grid-template-columns: 24px 40px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: 6px var(--s2); border-radius: var(--r-ctl); cursor: default; } +.rank-row:hover { background: var(--hover); } +.rank { color: var(--text-3); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; } +.rank-meta { color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; } +.lt-cover.round { border-radius: 50%; } +.chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: var(--s2); } +.chart-col { flex: 1; height: 100%; display: grid; grid-template-rows: 1fr auto; gap: 6px; min-width: 0; } +.chart-bar { align-self: end; height: 100%; background: var(--accent); border-radius: 4px 4px 2px 2px; transform-origin: bottom; min-height: 2px; opacity: 0.85; transition: opacity 120ms var(--ease); } +.chart-col:hover .chart-bar { opacity: 1; } +.chart-x { font-size: 11px; color: var(--text-3); text-align: center; font-variant-numeric: tabular-nums; height: 14px; overflow: hidden; } +.grid.tight { padding: 0; } +.modal:has(.share) { max-width: 820px; } +.share { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: var(--s5); align-items: start; } +.share-preview { display: grid; place-items: center; background: var(--bg); border-radius: 12px; padding: var(--s4); min-height: 420px; border: 1px solid var(--hairline); } +.share-canvas { max-width: 100%; max-height: 60vh; width: auto; height: auto; border-radius: 10px; box-shadow: var(--shadow); } +.share-side { display: grid; gap: var(--s2); } +.share-side h3 { font-size: 12px; color: var(--text-2); margin-top: var(--s2); } +.share-side .row { margin-top: var(--s3); flex-wrap: wrap; } +@media (max-width: 1100px) { .stat-cards { grid-template-columns: 1fr 1fr; } .stat-split { grid-template-columns: 1fr; } .share { grid-template-columns: 1fr; } }