diff --git a/.github/workflows/flakehub.yml b/.github/workflows/flakehub.yml deleted file mode 100644 index 86f8459b..00000000 --- a/.github/workflows/flakehub.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Publish to FlakeHub - -on: - push: - branches: [main] - paths: ["**.nix", "**.rs", "Cargo.lock"] - pull_request: - paths: ["**.nix", "**.rs", "Cargo.lock"] - workflow_dispatch: - -jobs: - build: - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - - permissions: - id-token: write - contents: read - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - - name: Setup cachix - uses: cachix/cachix-action@v15 - with: - name: catppuccin - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - - name: Build packages - run: nix build -L .#catwalk - - - uses: DeterminateSystems/flakehub-push@main - # only push to FlakeHub once when running on main - if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && matrix.os == 'ubuntu-latest' - with: - name: catppuccin/toolbox - rolling: true - visibility: public diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index c5466edf..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Lint - -on: - pull_request: - paths: ["**.rs", "**.toml", "**.lock"] - push: - branches: [main] - paths: ["**.rs", "**.toml", "**.lock"] - -jobs: - rust: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@stable - with: - targets: "wasm32-unknown-unknown" - components: "rustfmt,clippy" - - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}-lint - - - name: clippy - run: | - cargo clippy - cargo clippy --target wasm32-unknown-unknown --lib - cargo clippy --target wasm32-unknown-unknown --lib --all-features - - - name: rustfmt check - run: | - cargo fmt --all --check diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index ff9b8977..62de910f 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -16,16 +16,3 @@ jobs: - uses: googleapis/release-please-action@v4 id: release if: ${{ !env.ACT }} - outputs: - catwalk_release: ${{ steps.release.outputs['catwalk--release_created'] || env.ACT }} - catwalk_tag: ${{ steps.release.outputs['catwalk--tag_name'] }} - - upload-catwalk: - needs: release-please - if: ${{ needs.release-please.outputs.catwalk_release }} - uses: ./.github/workflows/upload-rust.yml - with: - tag: ${{ needs.release-please.outputs.catwalk_tag }} - executable: catwalk - member: catppuccin-catwalk - secrets: inherit diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index d6f8d37d..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Test - -on: - pull_request: - paths: ["**.rs", "**.toml", "**.lock"] - push: - branches: [main] - paths: ["**.rs", "**.toml", "**.lock"] - -jobs: - rust: - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - - uses: dtolnay/rust-toolchain@stable - - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}-test - - - name: cargo test - run: cargo test --all-features diff --git a/.github/workflows/upload-rust.yml b/.github/workflows/upload-rust.yml deleted file mode 100644 index 258c77ee..00000000 --- a/.github/workflows/upload-rust.yml +++ /dev/null @@ -1,73 +0,0 @@ -on: - workflow_call: - inputs: - executable: - required: true - type: string - member: - required: true - type: string - tag: - required: true - type: string - secrets: - CARGO_REGISTRY_TOKEN: - required: true - -jobs: - upload: - name: Upload ${{ inputs.executable }} for ${{ matrix.os }} - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: ["ubuntu-latest", "macos-latest", "windows-latest"] - - defaults: - run: - shell: bash - - env: - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse - EXE_SUFFIX: ${{ matrix.os == 'windows-latest' && '.exe' || '' }} - - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('./Cargo.lock') }}-${{ inputs.member }} - - - name: Build - id: build - run: | - cargo build --release --locked -p ${{ inputs.member }} - cargo test --release --locked -p ${{ inputs.member }} - - export BINARY_NAME="${{ inputs.executable }}-$(rustc --version --verbose | grep host | cut -d ' ' -f 2)${EXE_SUFFIX}" - mv "target/release/${{ inputs.executable }}${EXE_SUFFIX}" "./${BINARY_NAME}" - echo "binary=${BINARY_NAME}" >> $GITHUB_OUTPUT - - - name: Publish to crates.io - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - run: cargo publish -p ${{ inputs.member }} ${{ env.ACT && '--dry-run' }} - if: ${{ matrix.os == 'ubuntu-latest' && !env.ACT }} - - - name: Upload to release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release upload "${{ inputs.tag }}" ${{ steps.build.outputs.binary }} - if: ${{ !env.ACT }} - - - name: Upload to artifact - uses: actions/upload-artifact@v4 - with: - name: ${{steps.build.outputs.binary}} - path: ${{steps.build.outputs.binary}} - if: ${{ env.ACT }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ef725870..ce299365 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,4 +1,3 @@ { - "catwalk": "1.3.1", "deno-lib": "1.0.0" } diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index b4e14881..00000000 --- a/Cargo.lock +++ /dev/null @@ -1,619 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "anstream" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" - -[[package]] -name = "anstyle-parse" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" -dependencies = [ - "anstyle", - "windows-sys", -] - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "backtrace" -version = "0.3.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - -[[package]] -name = "catppuccin-catwalk" -version = "1.3.1" -dependencies = [ - "clap", - "clap_complete", - "color-eyre", - "getrandom", - "js-sys", - "ril", - "thiserror", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "cc" -version = "1.0.98" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "clap" -version = "4.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4170d524c0b624f1824a08c100d0b80ec7035e411978a31cf1973d753666c9e7" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d997d985ae5ef61b0a485bcff38f199045f1d1d07122f27cd5ffee5b3bbf913" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_complete" -version = "4.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a2d6eec27fce550d708b2be5d798797e5a55b246b323ef36924a0001996352" -dependencies = [ - "clap", -] - -[[package]] -name = "clap_derive" -version = "4.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "clap_lex" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" - -[[package]] -name = "color-eyre" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" -dependencies = [ - "backtrace", - "eyre", - "indenter", - "once_cell", - "owo-colors", -] - -[[package]] -name = "colorchoice" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" - -[[package]] -name = "crc32fast" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "eyre" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" -dependencies = [ - "indenter", - "once_cell", -] - -[[package]] -name = "fast_image_resize" -version = "2.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc789a40040e11bbe4ba31ca319406805a12fe3f8d71314bbc4bd076602ad55a" -dependencies = [ - "num-traits", - "thiserror", -] - -[[package]] -name = "fdeflate" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" -dependencies = [ - "simd-adler32", -] - -[[package]] -name = "flate2" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "getrandom" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "wasi", - "wasm-bindgen", -] - -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "indenter" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" - -[[package]] -name = "js-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.155" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "libwebp-sys2" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e2ae528b6c8f543825990b24c00cfd8fe64dde126c8288f4972b18e3d558072" -dependencies = [ - "cc", - "cfg-if", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "log" -version = "0.4.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" - -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "miniz_oxide" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" -dependencies = [ - "adler", - "simd-adler32", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "object" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "owo-colors" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" - -[[package]] -name = "pkg-config" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" - -[[package]] -name = "png" -version = "0.17.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" -dependencies = [ - "bitflags", - "crc32fast", - "fdeflate", - "flate2", - "miniz_oxide", -] - -[[package]] -name = "proc-macro2" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "ril" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb9d89f558ed427b172d6014c4cf3145b506d379df0676b471964dbbbe923ea1" -dependencies = [ - "fast_image_resize", - "libwebp-sys2", - "num-traits", - "png", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - -[[package]] -name = "simd-adler32" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" - -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "syn" -version = "2.0.65" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "1.0.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" - -[[package]] -name = "web-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 8c92a14a..00000000 --- a/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[workspace] -resolver = "2" -members = ["catwalk"] - -[profile.release] -lto = true -opt-level = "z" -strip = true - -[profile.release.package.catppuccin-catwalk] -opt-level = "s" diff --git a/README.md b/README.md index 52c0af4a..1defc45b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A set of software tools by Catppuccin developers, for Catppuccin developers. -- [Catwalk](https://github.com/catppuccin/toolbox/tree/main/catwalk#readme) +- [Catwalk (separate repository)](https://github.com/catppuccin/catwalk) - [Whiskers (separate repository)](https://github.com/catppuccin/whiskers)   @@ -33,13 +33,15 @@ Add the following to your `flake.nix`: ```nix { inputs = { - catppuccin-toolbox.url = "github:catppuccin/whiskers"; + catppuccin-catwalk.url = "github:catppuccin/catwalk"; + catppuccin-whiskers.url = "github:catppuccin/whiskers"; }; - outputs = {nixpkgs, catppuccin-whiskers, ...}: { + outputs = {nixpkgs, catppuccin-whiskers, catppuccin-catwalk, ...}: { nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem { modules = [ { environment.systemPackages = [ + catppuccin-catwalk.packages.${pkgs.system}.default catppuccin-whiskers.packages.${pkgs.system}.default ]; } @@ -62,16 +64,18 @@ Add the following to your `flake.nix`: inputs.nixpkgs.follows = "nixpkgs"; }; + catppuccin-catwalk.url = "github:catppuccin/catwalk"; catppuccin-whiskers.url = "github:catppuccin/whiskers"; }; - outputs = {nixpkgs, home-manager, catppuccin-whiskers, ...}: { + outputs = {nixpkgs, home-manager, catppuccin-whiskers, catppuccin-catwalk ...}: { homeConfigurations."user@hostname" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; modules = [ { home.packages = [ + catppuccin-catwalk.packages.${pkgs.system}.default catppuccin-whiskers.packages.${pkgs.system}.default ]; } @@ -88,17 +92,22 @@ Add the following to your configuration: ```nix {config, pkgs, ...}: let flake-compat = builtins.fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz"; + catppuccin-catwalk = (import flake-compat { + src = builtins.fetchTarball "https://github.com/catppuccin/catwalk/archive/main.tar.gz"; + }).defaultNix; catppuccin-whiskers = (import flake-compat { src = builtins.fetchTarball "https://github.com/catppuccin/whiskers/archive/main.tar.gz"; }).defaultNix; in { # Home Manager home.packages = [ + catppuccin-catwalk.packages.${pkgs.system}.default catppuccin-whiskers.packages.${pkgs.system}.default ]; # Nix environment.systemPackages = [ + catppuccin-catwalk.packages.${pkgs.system}.default catppuccin-whiskers.packages.${pkgs.system}.default ]; } diff --git a/catwalk/.gitignore b/catwalk/.gitignore deleted file mode 100644 index 48ea3777..00000000 --- a/catwalk/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# ignore the NPM package -pkg/* -# keep deno for esm -!pkg/deno diff --git a/catwalk/.justfile b/catwalk/.justfile deleted file mode 100644 index a3dd3bca..00000000 --- a/catwalk/.justfile +++ /dev/null @@ -1,28 +0,0 @@ -[private] -default: - @just --choose - -[private] -wasm-pack-build *args: - wasm-pack build --scope catppuccin --release {{args}} - -build-wasm: - @echo "Building npm package..." - rm -rf ./pkg || true - mkdir -p ./pkg - @just wasm-pack-build \ - --target nodejs \ - --out-dir ./pkg \ - --out-name catwalk - sed -i 's/@catppuccin\/catppuccin-catwalk/@catppuccin\/catwalk/g' ./pkg/package.json - @just wasm-pack-build \ - --target deno \ - --out-dir ./pkg/deno \ - --out-name catwalk - rm ./pkg/.gitignore || true - rm ./pkg/deno/.gitignore || true - -check: - cargo clippy || true - cargo clippy --target wasm32-unknown-unknown --lib || true - cargo clippy --target wasm32-unknown-unknown --lib --all-features || true diff --git a/catwalk/CHANGELOG.md b/catwalk/CHANGELOG.md deleted file mode 100644 index 10e86545..00000000 --- a/catwalk/CHANGELOG.md +++ /dev/null @@ -1,74 +0,0 @@ -# Changelog - -## [1.3.1](https://github.com/catppuccin/toolbox/compare/catwalk-v1.3.0...catwalk-v1.3.1) (2024-05-20) - - -### Bug Fixes - -* **deps:** update rust crate clap to 4.5.4 ([#189](https://github.com/catppuccin/toolbox/issues/189)) ([52d5aa4](https://github.com/catppuccin/toolbox/commit/52d5aa42b0e9a6085b22da37580912a55c442477)) -* **deps:** update rust crate clap_complete to 4.5.2 ([#190](https://github.com/catppuccin/toolbox/issues/190)) ([cda4f29](https://github.com/catppuccin/toolbox/commit/cda4f2999ed187cacf14e3304ff73637119d1f27)) -* **deps:** update rust crate color-eyre to 0.6.3 ([#191](https://github.com/catppuccin/toolbox/issues/191)) ([8a7c14a](https://github.com/catppuccin/toolbox/commit/8a7c14a3ee9f48ceccda36c42815279c08862916)) -* **deps:** update rust crate getrandom to 0.2.14 ([#196](https://github.com/catppuccin/toolbox/issues/196)) ([fb426be](https://github.com/catppuccin/toolbox/commit/fb426be432fd48785426b9da7431978c7aa342fd)) - -## [1.3.0](https://github.com/catppuccin/toolbox/compare/catwalk-v1.2.0...catwalk-v1.3.0) (2024-04-27) - - -### Features - -* binstall support ([#173](https://github.com/catppuccin/toolbox/issues/173)) ([2ae0c33](https://github.com/catppuccin/toolbox/commit/2ae0c33b9b6c577cacbeed02e6a68873194597ab)) - -## [1.2.0](https://github.com/catppuccin/toolbox/compare/catwalk-v1.1.1...catwalk-v1.2.0) (2023-11-04) - - -### Features - -* add `--layout row` ([#60](https://github.com/catppuccin/toolbox/issues/60)) ([00f26b5](https://github.com/catppuccin/toolbox/commit/00f26b56b77ba1aeb12f3070371efc19a6fb67ac)), closes [#20](https://github.com/catppuccin/toolbox/issues/20) -* **wasm:** add `Catwalk.version` ([6833066](https://github.com/catppuccin/toolbox/commit/6833066b0f371aa6c8ccd3a0300aec7cc728f3a1)) - - -### Bug Fixes - -* **wasm:** result image size ([6833066](https://github.com/catppuccin/toolbox/commit/6833066b0f371aa6c8ccd3a0300aec7cc728f3a1)) - -## [1.1.1](https://github.com/catppuccin/toolbox/compare/catwalk-v1.1.0...catwalk-v1.1.1) (2023-11-03) - - -### Bug Fixes - -* custom antialiasing artifacts ([#57](https://github.com/catppuccin/toolbox/issues/57)) ([0f25654](https://github.com/catppuccin/toolbox/commit/0f256543b404533c3bf05cc9f9862d6ea7aa13ee)) -* explicit filename extension override ([#59](https://github.com/catppuccin/toolbox/issues/59)) ([e211ba8](https://github.com/catppuccin/toolbox/commit/e211ba8e9daeb3c0199394ed149bf81799391da8)) - -## [1.1.0](https://github.com/catppuccin/toolbox/compare/catwalk-v1.0.3...catwalk-v1.1.0) (2023-10-30) - - -### Features - -* make input names optional, `-C` flag for directory, `--ext` for input file type ([#55](https://github.com/catppuccin/toolbox/issues/55)) ([b2ce59e](https://github.com/catppuccin/toolbox/commit/b2ce59e5d607f77ca3135b847c851465933d05e5)) - -## [1.0.3](https://github.com/catppuccin/toolbox/compare/catwalk-v1.0.2...catwalk-v1.0.3) (2023-10-28) - - -### Miscellaneous Chores - -* **catwalk:** release as 1.0.3 ([842134a](https://github.com/catppuccin/toolbox/commit/842134a483fa8a0fb1a2ca6cdad66a4f760ecafe)) - -## [1.0.2](https://github.com/catppuccin/toolbox/compare/catwalk-v1.0.1...catwalk-v1.0.2) (2023-10-27) - - -### Miscellaneous Chores - -* **catwalk:** release as 1.0.2 ([78834c6](https://github.com/catppuccin/toolbox/commit/78834c684ae565fc139fc307ad61f106b626e0f5)) - -## [1.0.1](https://github.com/catppuccin/toolbox/compare/catwalk-v1.0.0...catwalk-v1.0.1) (2023-10-27) - - -### Miscellaneous Chores - -* **catwalk:** release as 1.0.1 ([58ff3e0](https://github.com/catppuccin/toolbox/commit/58ff3e07cc69b51d8a6de6dd710ce1f5634f161a)) - -## [1.0.0](https://github.com/catppuccin/toolbox/compare/catwalk-v0.1.4...catwalk-v1.0.0) (2023-10-27) - - -### Miscellaneous Chores - -* **catwalk:** release as 1.0.0 ([d66ec8d](https://github.com/catppuccin/toolbox/commit/d66ec8d984887c4d417166d2180bcf249e11a318)) diff --git a/catwalk/Cargo.toml b/catwalk/Cargo.toml deleted file mode 100644 index 20966f01..00000000 --- a/catwalk/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -[package] -name = "catppuccin-catwalk" -description = "A sweet program that takes in four showcase images and displays them all at once." -authors = ["Catppuccin Org "] -repository = "https://github.com/catppuccin/toolbox" -license = "MIT" -version = "1.3.1" -edition = "2021" - -[[bin]] -name = "catwalk" -path = "src/main.rs" - -[package.metadata.binstall] -pkg-url = "{ repo }/releases/download/catwalk-v{ version }/catwalk-{ target }{ archive-suffix }" -pkg-fmt = "bin" - -[lib] -crate-type = ["cdylib", "rlib"] - -[dependencies] -thiserror = "1" - -[target.'cfg(not(target_family = "wasm"))'.dependencies] -clap = { version = "4.5.4", features = ["derive"] } -clap_complete = { version = "4.5.2" } -color-eyre = { version = "0.6.3", default-features = false } -ril = { version = "0.10.1", default-features = false, features = [ - "png", - "resize", - "webp", -] } - -[target.'cfg(target_family = "wasm")'.dependencies] -js-sys = "0.3.69" -ril = { version = "0.10.1", default-features = false } -wasm-bindgen = "0.2.92" -web-sys = { version = "0.3.69", features = ["ImageData"] } -getrandom = { version = "0.2.15", features = ["js"] } - -[package.metadata.wasm-pack.profile.release] -wasm-opt = ['-O3'] diff --git a/catwalk/LICENSE b/catwalk/LICENSE deleted file mode 120000 index ea5b6064..00000000 --- a/catwalk/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../LICENSE \ No newline at end of file diff --git a/catwalk/README.md b/catwalk/README.md index 9df2a998..d882d3b6 100644 --- a/catwalk/README.md +++ b/catwalk/README.md @@ -1,73 +1,15 @@ -

- Logo
- - Catppuccin Catwalk - -

+

🚧 This tool has moved 🚧

+ +This tool has moved to a separate repository to reduce the increasing +complexity of managing a monorepo. To find code, documentation, and releases +starting with and after +[v1.3.1](https://github.com/catppuccin/catwalk/releases/tag/v1.3.1), visit +[catppuccin/catwalk](https://github.com/catppuccin/catwalk).

- - - +

-  - -A sweet program that takes in four showcase images and displays them all at once. - -## Installation - -You can install Catwalk using one of the methods below: - -| Installation Method | Instructions | -| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -| crates.io | `cargo install catppuccin-catwalk` | -| Source | `cargo install --git https://github.com/catppuccin/toolbox catppuccin-catwalk` | -| Homebrew | `brew install catppuccin/tap/catwalk` | -| Nix | `nix profile install github:catppuccin/toolbox#catwalk`
`nix run github:catppuccin/toolbox#catwalk -- [OPTIONS] ` | -| Binaries
(Windows, MacOS & Linux) | Available from the [latest GitHub release](https://github.com/catppuccin/toolbox/releases?q=catwalk). | - -## Usage - -```console -$ catwalk --help -A sweet program that takes in four showcase images and displays them all at once. - -Usage: catwalk [OPTIONS] [LATTE] [FRAPPE] [MACCHIATO] [MOCHA] [COMMAND] - -Commands: - completion Generates a completion file for the given shell - help Print this message or the help of the given subcommand(s) - -Arguments: - [LATTE] Path to Latte image [default: ./latte.webp] - [FRAPPE] Path to Frappé image [default: ./frappe.webp] - [MACCHIATO] Path to Macchiato image [default: ./macchiato.webp] - [MOCHA] Path to Mocha image [default: ./mocha.webp] - -Options: - -o, --output Path to output file [default: ./preview.webp] - -l, --layout Layout to use [default: composite] [possible values: composite, stacked, grid, row] - -r, --radius Radius of rounded corners (percentage) - -g, --gap Size of gaps between pictures for the `grid` layout - -C, --directory Change to before processing files [default: .] - --ext File extension to use for input files, if they're not explicitly named [default: webp] [possible values: webp, png] - -h, --help Print help - -V, --version Print version -``` - -### Examples - -```console -$ catwalk latte.webp frappe.webp macchiato.webp mocha.webp --output catwalk.webp -``` - -```console -$ catwalk latte.png frappe.png macchiato.png mocha.png --directory ./assets/ -``` - -  - -

-

Copyright © 2021-present Catppuccin Org -

+

+ Copyright © 2021-present Catppuccin Org +

diff --git a/catwalk/cli.ts b/catwalk/cli.ts deleted file mode 100755 index 3febaa13..00000000 --- a/catwalk/cli.ts +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env -S deno run -A -import { Catwalk, Layout } from "./pkg/deno/catwalk.js"; -import { - Command, - EnumType, -} from "https://deno.land/x/cliffy@v1.0.0-rc.4/command/mod.ts"; -import { - ImageMagick, - initialize, - MagickColor, - MagickFormat, - MagickImage, -} from "https://deno.land/x/imagemagick_deno@0.0.26/mod.ts"; - -const { args, options } = await new Command() - .name("catwalk") - .version(Catwalk.version) - .description( - "A sweet program that takes in four showcase images and displays them all at once. (JS port)", - ) - .arguments(" ") - .type( - "layout", - new EnumType( - Object.keys(Layout) - .filter((k) => isNaN(Number(k))) - .map((k) => k.toLowerCase()), - ), - ) - .option("-g, --gap ", "Gap size for `grid` Layout") - .option("-l, --layout ", "Layout to use") - .option("-o, --output ", "Output file", { - default: "./result.webp", - }) - .option("-r, --radius ", "Radius of corners") - .parse(Deno.args); - -const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1); - -let fmt: MagickFormat; -switch (options.output.split(".").pop()) { - case "png": - fmt = MagickFormat.Png; - break; - case "webp": - fmt = MagickFormat.Webp; - break; - default: - console.error("Invalid output format"); - Deno.exit(1); -} - -await initialize(); - -let [width, height] = [0, 0]; -const [latte, frappe, macchiato, mocha] = args.map((path) => { - const buffer = Deno.readFileSync(path); - return ImageMagick.read(buffer, (data) => { - height = data.height; - width = data.width; - const pixels = data.getPixels((pixel) => - pixel.getArea(0, 0, width, height) - ); - return Uint8Array.from(pixels); - }); -}); - -const cw = Catwalk.new_from_u8_array(latte, frappe, macchiato, mocha, width) - .gap(options.gap) - //@ts-expect-error: i'm not dealing with this - .layout(Layout[(capitalize(options.layout ?? "")) as keyof typeof Layout]) - .radius(options.radius) - .build_buffer(); - -const img = MagickImage.create( - new MagickColor(0, 0, 0, 0), - cw.width, - cw.height, -); -// needed for WASM, as it defaults to lossy -img.quality = 100; -img.getPixels((pixels) => pixels.setArea(0, 0, cw.width, cw.height, cw.data)); -img.write(fmt, (data) => Deno.writeFile(options.output, data)); diff --git a/catwalk/pkg/deno/LICENSE b/catwalk/pkg/deno/LICENSE deleted file mode 100644 index 006383b8..00000000 --- a/catwalk/pkg/deno/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Catppuccin - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/catwalk/pkg/deno/catwalk.d.ts b/catwalk/pkg/deno/catwalk.d.ts deleted file mode 100644 index e08f1db3..00000000 --- a/catwalk/pkg/deno/catwalk.d.ts +++ /dev/null @@ -1,97 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** -*/ -export enum Layout { - Composite = 0, - Stacked = 1, - Grid = 2, - Row = 3, -} -/** -*/ -export class Catwalk { - free(): void; -/** -* Create a new Catwalk from 4 `web_sys::ImageData` objects -* # Errors -* Returns an error if the images... -* - cannot be read. -* - are not the same size. -* @param {ImageData} latte -* @param {ImageData} frappe -* @param {ImageData} macchiato -* @param {ImageData} mocha -* @returns {Catwalk} -*/ - static new_from_imagedata(latte: ImageData, frappe: ImageData, macchiato: ImageData, mocha: ImageData): Catwalk; -/** -* Create a new Catwalk from 4 `Vec`, which are in practice `Vec<[u8; 4]>` (RGBA). -* # Errors -* Returns an error if the images... -* - cannot be read. -* - are not the same size. -* @param {Uint8Array} latte -* @param {Uint8Array} frappe -* @param {Uint8Array} macchiato -* @param {Uint8Array} mocha -* @param {number} width -* @returns {Catwalk} -*/ - static new_from_u8_array(latte: Uint8Array, frappe: Uint8Array, macchiato: Uint8Array, mocha: Uint8Array, width: number): Catwalk; -/** -* Calculate the Catwalk image & return an `ImageData` object. -* # Errors -* Returns an error if any of `self.images`, `self.height`, or `self.width` are not set. -* @returns {ImageData} -*/ - build_imagedata(): ImageData; -/** -* Calculate the Catwalk image & return a `CatwalkBuffer` object. -* # Errors -* Returns an error if any of `self.images`, `self.height`, or `self.width` are not set. -* @returns {CatwalkBuffer} -*/ - build_buffer(): CatwalkBuffer; -/** -* @param {number | undefined} aa_level -* @returns {Catwalk} -*/ - aa_level(aa_level?: number): Catwalk; -/** -* @param {number | undefined} gap -* @returns {Catwalk} -*/ - gap(gap?: number): Catwalk; -/** -* @param {number | undefined} layout -* @returns {Catwalk} -*/ - layout(layout?: number): Catwalk; -/** -* Sets the radius of the rounding mask. -* # Errors -* Returns an error if the height or width are not set (automatically inferred from the `new` method arguments) -* @param {number | undefined} radius -* @returns {Catwalk} -*/ - radius(radius?: number): Catwalk; -/** -* Returns the version of the Catwalk library. -*/ - static readonly version: string; -} -/** -*/ -export class CatwalkBuffer { - free(): void; -/** -*/ - readonly data: Uint8Array; -/** -*/ - height: number; -/** -*/ - width: number; -} diff --git a/catwalk/pkg/deno/catwalk.js b/catwalk/pkg/deno/catwalk.js deleted file mode 100644 index f98fe611..00000000 --- a/catwalk/pkg/deno/catwalk.js +++ /dev/null @@ -1,420 +0,0 @@ - - -const heap = new Array(128).fill(undefined); - -heap.push(undefined, null, true, false); - -function getObject(idx) { return heap[idx]; } - -let heap_next = heap.length; - -function dropObject(idx) { - if (idx < 132) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - -const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); - -if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; - -let cachedUint8Memory0 = null; - -function getUint8Memory0() { - if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { - cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8Memory0; -} - -function getStringFromWasm0(ptr, len) { - ptr = ptr >>> 0; - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); -} - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - heap[idx] = obj; - return idx; -} - -let cachedInt32Memory0 = null; - -function getInt32Memory0() { - if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { - cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); - } - return cachedInt32Memory0; -} - -function getArrayU8FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); -} - -let WASM_VECTOR_LEN = 0; - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1, 1) >>> 0; - getUint8Memory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -let cachedUint8ClampedMemory0 = null; - -function getUint8ClampedMemory0() { - if (cachedUint8ClampedMemory0 === null || cachedUint8ClampedMemory0.byteLength === 0) { - cachedUint8ClampedMemory0 = new Uint8ClampedArray(wasm.memory.buffer); - } - return cachedUint8ClampedMemory0; -} - -function getClampedArrayU8FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint8ClampedMemory0().subarray(ptr / 1, ptr / 1 + len); -} - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); - } -} -/** -*/ -export const Layout = Object.freeze({ Composite:0,"0":"Composite",Stacked:1,"1":"Stacked",Grid:2,"2":"Grid",Row:3,"3":"Row", }); -/** -*/ -export class Catwalk { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Catwalk.prototype); - obj.__wbg_ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_catwalk_free(ptr); - } - /** - * Create a new Catwalk from 4 `web_sys::ImageData` objects - * # Errors - * Returns an error if the images... - * - cannot be read. - * - are not the same size. - * @param {ImageData} latte - * @param {ImageData} frappe - * @param {ImageData} macchiato - * @param {ImageData} mocha - * @returns {Catwalk} - */ - static new_from_imagedata(latte, frappe, macchiato, mocha) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.catwalk_new_from_imagedata(retptr, addHeapObject(latte), addHeapObject(frappe), addHeapObject(macchiato), addHeapObject(mocha)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Catwalk.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Create a new Catwalk from 4 `Vec`, which are in practice `Vec<[u8; 4]>` (RGBA). - * # Errors - * Returns an error if the images... - * - cannot be read. - * - are not the same size. - * @param {Uint8Array} latte - * @param {Uint8Array} frappe - * @param {Uint8Array} macchiato - * @param {Uint8Array} mocha - * @param {number} width - * @returns {Catwalk} - */ - static new_from_u8_array(latte, frappe, macchiato, mocha, width) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArray8ToWasm0(latte, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(frappe, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passArray8ToWasm0(macchiato, wasm.__wbindgen_malloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(mocha, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - wasm.catwalk_new_from_u8_array(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, width); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Catwalk.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Calculate the Catwalk image & return an `ImageData` object. - * # Errors - * Returns an error if any of `self.images`, `self.height`, or `self.width` are not set. - * @returns {ImageData} - */ - build_imagedata() { - try { - const ptr = this.__destroy_into_raw(); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.catwalk_build_imagedata(retptr, ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Calculate the Catwalk image & return a `CatwalkBuffer` object. - * # Errors - * Returns an error if any of `self.images`, `self.height`, or `self.width` are not set. - * @returns {CatwalkBuffer} - */ - build_buffer() { - try { - const ptr = this.__destroy_into_raw(); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.catwalk_build_buffer(retptr, ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return CatwalkBuffer.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the version of the Catwalk library. - * @returns {string} - */ - static get version() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.catwalk_version(retptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * @param {number | undefined} aa_level - * @returns {Catwalk} - */ - aa_level(aa_level) { - const ptr = this.__destroy_into_raw(); - const ret = wasm.catwalk_aa_level(ptr, !isLikeNone(aa_level), isLikeNone(aa_level) ? 0 : aa_level); - return Catwalk.__wrap(ret); - } - /** - * @param {number | undefined} gap - * @returns {Catwalk} - */ - gap(gap) { - const ptr = this.__destroy_into_raw(); - const ret = wasm.catwalk_gap(ptr, !isLikeNone(gap), isLikeNone(gap) ? 0 : gap); - return Catwalk.__wrap(ret); - } - /** - * @param {number | undefined} layout - * @returns {Catwalk} - */ - layout(layout) { - const ptr = this.__destroy_into_raw(); - const ret = wasm.catwalk_layout(ptr, isLikeNone(layout) ? 4 : layout); - return Catwalk.__wrap(ret); - } - /** - * Sets the radius of the rounding mask. - * # Errors - * Returns an error if the height or width are not set (automatically inferred from the `new` method arguments) - * @param {number | undefined} radius - * @returns {Catwalk} - */ - radius(radius) { - try { - const ptr = this.__destroy_into_raw(); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.catwalk_radius(retptr, ptr, !isLikeNone(radius), isLikeNone(radius) ? 0 : radius); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Catwalk.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -/** -*/ -export class CatwalkBuffer { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(CatwalkBuffer.prototype); - obj.__wbg_ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_catwalkbuffer_free(ptr); - } - /** - * @returns {number} - */ - get width() { - const ret = wasm.__wbg_get_catwalkbuffer_width(this.__wbg_ptr); - return ret >>> 0; - } - /** - * @param {number} arg0 - */ - set width(arg0) { - wasm.__wbg_set_catwalkbuffer_width(this.__wbg_ptr, arg0); - } - /** - * @returns {number} - */ - get height() { - const ret = wasm.__wbg_get_catwalkbuffer_height(this.__wbg_ptr); - return ret >>> 0; - } - /** - * @param {number} arg0 - */ - set height(arg0) { - wasm.__wbg_set_catwalkbuffer_height(this.__wbg_ptr, arg0); - } - /** - * @returns {Uint8Array} - */ - get data() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.catwalkbuffer_data(retptr, this.__wbg_ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} - -const imports = { - __wbindgen_placeholder__: { - __wbindgen_object_drop_ref: function(arg0) { - takeObject(arg0); - }, - __wbindgen_string_new: function(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); - }, - __wbg_width_c97f89a38a3c1da7: function(arg0) { - const ret = getObject(arg0).width; - return ret; - }, - __wbg_height_c8424a3757db7869: function(arg0) { - const ret = getObject(arg0).height; - return ret; - }, - __wbg_data_eaf4962120932fdc: function(arg0, arg1) { - const ret = getObject(arg1).data; - const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len1; - getInt32Memory0()[arg0 / 4 + 0] = ptr1; - }, - __wbg_newwithu8clampedarray_fb90064f569c16ec: function() { return handleError(function (arg0, arg1, arg2) { - const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0); - return addHeapObject(ret); - }, arguments) }, - __wbindgen_throw: function(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); - }, - }, - -}; - -const wasm_url = new URL('catwalk_bg.wasm', import.meta.url); -let wasmCode = ''; -switch (wasm_url.protocol) { - case 'file:': - wasmCode = await Deno.readFile(wasm_url); - break - case 'https:': - case 'http:': - wasmCode = await (await fetch(wasm_url)).arrayBuffer(); - break - default: - throw new Error(`Unsupported protocol: ${wasm_url.protocol}`); -} - -const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance; -const wasm = wasmInstance.exports; - diff --git a/catwalk/pkg/deno/catwalk_bg.wasm b/catwalk/pkg/deno/catwalk_bg.wasm deleted file mode 100644 index 1a7dc8a9..00000000 Binary files a/catwalk/pkg/deno/catwalk_bg.wasm and /dev/null differ diff --git a/catwalk/pkg/deno/catwalk_bg.wasm.d.ts b/catwalk/pkg/deno/catwalk_bg.wasm.d.ts deleted file mode 100644 index 76645c8a..00000000 --- a/catwalk/pkg/deno/catwalk_bg.wasm.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export const memory: WebAssembly.Memory; -export function __wbg_catwalkbuffer_free(a: number): void; -export function __wbg_get_catwalkbuffer_width(a: number): number; -export function __wbg_set_catwalkbuffer_width(a: number, b: number): void; -export function __wbg_get_catwalkbuffer_height(a: number): number; -export function __wbg_set_catwalkbuffer_height(a: number, b: number): void; -export function catwalkbuffer_data(a: number, b: number): void; -export function catwalk_new_from_imagedata(a: number, b: number, c: number, d: number, e: number): void; -export function catwalk_new_from_u8_array(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void; -export function catwalk_build_imagedata(a: number, b: number): void; -export function catwalk_build_buffer(a: number, b: number): void; -export function catwalk_version(a: number): void; -export function __wbg_catwalk_free(a: number): void; -export function catwalk_aa_level(a: number, b: number, c: number): number; -export function catwalk_gap(a: number, b: number, c: number): number; -export function catwalk_layout(a: number, b: number): number; -export function catwalk_radius(a: number, b: number, c: number, d: number): void; -export function __wbindgen_add_to_stack_pointer(a: number): number; -export function __wbindgen_free(a: number, b: number, c: number): void; -export function __wbindgen_malloc(a: number, b: number): number; -export function __wbindgen_exn_store(a: number): void; diff --git a/catwalk/src/cli.rs b/catwalk/src/cli.rs deleted file mode 100644 index 32cf1b2c..00000000 --- a/catwalk/src/cli.rs +++ /dev/null @@ -1,67 +0,0 @@ -#![deny(clippy::perf, clippy::nursery, clippy::pedantic)] -use catppuccin_catwalk::Layout; -use clap::{Command, Parser, Subcommand, ValueEnum}; -use clap_complete::{generate, Generator, Shell}; -use std::path::PathBuf; - -#[derive(Subcommand, Clone, Debug)] -pub enum Commands { - #[command(about = "Generates a completion file for the given shell")] - Completion { - #[arg(value_enum)] - shell: Shell, - }, -} - -#[derive(Copy, Clone, Debug, ValueEnum)] -pub enum Extension { - Webp, - Png, -} - -#[derive(Parser)] -#[command(author, version, about)] -pub struct Cli { - /// Path to Latte image. - #[arg(default_value = "./latte.webp")] - pub latte: Option, - /// Path to Frappé image. - #[arg(default_value = "./frappe.webp")] - pub frappe: Option, - /// Path to Macchiato image. - #[arg(default_value = "./macchiato.webp")] - pub macchiato: Option, - /// Path to Mocha image. - #[arg(default_value = "./mocha.webp")] - pub mocha: Option, - /// Path to output file. - #[arg(short, long, default_value = "./preview.webp")] - pub output: PathBuf, - /// Layout to use. - #[arg(short, long, value_enum, default_value_t=Layout::Composite)] - pub layout: Layout, - /// Radius of rounded corners (percentage). - #[arg(short, long)] - pub radius: Option, - /// Size of gaps between pictures for the `grid` layout. - #[arg(short, long)] - pub gap: Option, - /// Change to before processing files. - #[arg(short = 'C', long, default_value = ".")] - pub directory: Option, - /// File extension to use for input files, if they're not explicitly named. - #[arg(long = "ext", value_enum, default_value_t = Extension::Webp)] - pub extension: Extension, - - // Shell completion - #[command(subcommand)] - pub command: Option, -} - -pub fn print_completions(gen: G, cmd: &mut Command) { - generate(gen, cmd, cmd.get_name().to_string(), &mut std::io::stdout()); -} - -pub fn get_cli_arguments() -> Cli { - Cli::parse() -} diff --git a/catwalk/src/lib.rs b/catwalk/src/lib.rs deleted file mode 100644 index 112c431f..00000000 --- a/catwalk/src/lib.rs +++ /dev/null @@ -1,299 +0,0 @@ -#![deny(clippy::perf, clippy::nursery, clippy::pedantic)] -// ignore u32 -> f32 & vice versa for now -#![allow( - clippy::cast_possible_truncation, - clippy::cast_precision_loss, - clippy::cast_sign_loss -)] - -mod mask; -use mask::{RoundMask, TrapMask}; -use ril::prelude::*; - -#[cfg(target_family = "wasm")] -use wasm_bindgen::prelude::*; -#[cfg(target_family = "wasm")] -mod wasm; - -#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(not(target_family = "wasm"), derive(clap::ValueEnum))] -#[cfg_attr(target_family = "wasm", wasm_bindgen)] -pub enum Layout { - Composite, - Stacked, - Grid, - Row, -} - -enum GridLayouts { - Grid, - Row, -} - -#[derive(thiserror::Error, Debug)] -pub enum CatwalkError { - #[error("Images must be the same size")] - SameSize, - #[error("Builder missing argument.")] - MissingArgument, - #[error("Failed to read image from bytes")] - ReadFromBytesError, - #[error("Failed to encode image data")] - EncodeError, - - #[error("unexpected error `{0}`")] - JsError(String), - #[error("unknown error from JS")] - UnknownJsError, -} - -#[cfg_attr(target_family = "wasm", wasm_bindgen)] -pub struct Catwalk { - images: Option<[Image; 4]>, - height: Option, - width: Option, - aa_level: u32, - radius: u32, - gap: u32, - layout: Layout, -} - -impl Default for Catwalk { - fn default() -> Self { - Self { - images: None, - height: None, - width: None, - aa_level: 15, - radius: 3, - gap: 50, - layout: Layout::Composite, - } - } -} - -#[cfg_attr(target_family = "wasm", wasm_bindgen)] -impl Catwalk { - /// Creates a new instance of Catwalk. - /// # Errors - /// Returns an error if the images are not the same size. - #[cfg(not(target_family = "wasm"))] - pub fn new(images: [Image; 4]) -> Result { - let height = images[0].height(); - let width = images[0].width(); - - // verify that they're all the same size - if images - .iter() - .any(|x| x.height() != height || x.width() != width) - { - return Err(CatwalkError::SameSize); - }; - - Ok(Self { - images: Some(images), - height: Some(height), - width: Some(width), - ..Default::default() - }) - } - - #[must_use] - #[allow(clippy::missing_const_for_fn)] - pub fn aa_level(mut self, aa_level: Option) -> Self { - let Some(aa_level) = aa_level else { - return self; - }; - self.aa_level = aa_level; - self - } - - #[allow(clippy::missing_const_for_fn)] - #[must_use] - pub fn gap(mut self, gap: Option) -> Self { - let Some(gap) = gap else { - return self; - }; - self.gap = gap; - self - } - - #[must_use] - pub fn layout(mut self, layout: Option) -> Self { - let layout = layout.unwrap_or(self.layout); - self.layout = layout; - self - } - - /// Sets the radius of the rounding mask. - /// # Errors - /// Returns an error if the height or width are not set (automatically inferred from the `new` method arguments) - #[allow(clippy::use_self)] - pub fn radius(mut self, radius: Option) -> Result { - let radius = radius.unwrap_or(self.radius); - - let height = self.height.ok_or(CatwalkError::MissingArgument)?; - let width = self.width.ok_or(CatwalkError::MissingArgument)?; - - // radius as a percentage of the image width if height > width, vice versa - let radius = if height > width { - (width as f32 * (radius as f32 / 100.0)) as u32 - } else { - (height as f32 * (radius as f32 / 100.0)) as u32 - }; - - self.radius = radius; - Ok(self) - } - - fn prepare(self) -> Result { - let images = self.images.ok_or(CatwalkError::MissingArgument)?; - let height = self.height.ok_or(CatwalkError::MissingArgument)?; - let width = self.width.ok_or(CatwalkError::MissingArgument)?; - - let rounding_mask = RoundMask { - radius: self.radius, - aa_level: self.aa_level, - }; - - Ok(Magic { - images, - height, - width, - rounding_mask, - gap: self.gap, - layout: self.layout, - }) - } - - /// Calculates the catwalk image. - /// # Errors - /// Returns an error if any of `self.images`, `self.height`, or `self.width` are not set. - #[cfg(not(target_family = "wasm"))] - pub fn build(self) -> Result, CatwalkError> { - let catwalk = self.prepare()?; - Ok(catwalk.result()) - } -} - -pub struct Magic { - images: [Image; 4], - height: u32, - width: u32, - rounding_mask: RoundMask, - gap: u32, - layout: Layout, -} - -impl Magic { - /// Creates the slants image. - fn gen_composite(&self) -> Image { - let w = self.width as f32; - let h = self.height as f32; - // Use x/y to "ground" the point later on - let inverse_slope = -w / (4.0 * h); - let masked: Vec> = self - .images - .iter() - .enumerate() - .rev() - .map(|(i, x)| Self::gen_mask(w, i, 2, inverse_slope).mask(x)) - .collect(); - let mut result = Image::new(self.width, self.height, Rgba::default()) - .with_overlay_mode(OverlayMode::Merge); - for mask in masked.iter().as_ref() { - result.paste(0, 0, mask); - } - self.rounding_mask.mask(&result) - } - - /// Creates a stacked image. - fn gen_stacked(&self) -> Image { - let gap = self.height / 3; - let padding_x = f32::floor(3.0f32.mul_add(1.0 - gap as f32, self.width as f32)) as u32; - let mut result = Image::new( - (self.height * 2) + (padding_x * 3) + gap, - self.height * 2, - Rgba::default(), - ) - .with_overlay_mode(OverlayMode::Merge); - self.images - .iter() - .map(|x| self.rounding_mask.mask(x)) - .enumerate() - .for_each(|(i, x)| result.paste(padding_x + (gap * (i as u32)), gap * (i as u32), &x)); - result - } - - /// Creates a grid image. - fn gen_grid(&self, layout: &GridLayouts) -> Image { - // Round images - let gap = self.gap; - let rounded: Vec> = self - .images - .iter() - .map(|x| self.rounding_mask.mask(x)) - .collect(); - - // Create final - let mut result = match layout { - GridLayouts::Grid => Image::new( - (self.width * 2) + (gap * 3), - (self.height * 2) + (gap * 3), - Rgba::transparent(), - ), - GridLayouts::Row => Image::new( - (self.width * 4) + (gap * 5), - self.height + (gap * 2), - Rgba::transparent(), - ), - } - .with_overlay_mode(OverlayMode::Merge); - // calculate the top left coordinates for each image, and paste - rounded.iter().enumerate().for_each(|(i, img)| { - let x = match layout { - GridLayouts::Row => i % 4, - GridLayouts::Grid => i % 2, - }; - let y = match layout { - GridLayouts::Row => 0, - GridLayouts::Grid => i / 2, - }; - result.paste( - gap + (self.width + gap) * x as u32, - gap + (self.height + gap) * y as u32, - img, - ); - }); - result - } - /// Generates a mask for the given image. - fn gen_mask(w: f32, index: usize, aa_level: u32, inverse_slope: f32) -> TrapMask { - if index == 3 { - // Full mask - return TrapMask::new(None, 0.0, aa_level); - } - let i = index as f32; - let trap_top: f32 = w * i.mul_add(2.0, 3.0) / 8.0; - // Return trapezoid mask - // We only need to return bottom x here; we'll use the inverse slope to make a line - TrapMask::new(Some(trap_top), inverse_slope, aa_level) - } - - // this looks a bit odd because the WASM bindings use this as well, so - // `result()` isn't just an oversight. - fn process(self) -> Image { - match self.layout { - Layout::Composite => self.gen_composite(), - Layout::Stacked => self.gen_stacked(), - Layout::Grid => self.gen_grid(&GridLayouts::Grid), - Layout::Row => self.gen_grid(&GridLayouts::Row), - } - } - - #[cfg(not(target_family = "wasm"))] - #[must_use] - pub fn result(self) -> Image { - self.process() - } -} diff --git a/catwalk/src/main.rs b/catwalk/src/main.rs deleted file mode 100644 index 97a70c13..00000000 --- a/catwalk/src/main.rs +++ /dev/null @@ -1,99 +0,0 @@ -#![deny(clippy::perf, clippy::nursery, clippy::pedantic)] -mod cli; - -use catppuccin_catwalk::Catwalk; -use clap::CommandFactory; -use cli::{get_cli_arguments, print_completions, Cli, Commands, Extension}; -use color_eyre::{eyre::eyre, Result}; -use ril::prelude::*; -use std::io::Cursor; - -macro_rules! open_image { - ($path:expr, $args:expr) => {{ - let mut rel_path = $args.directory.clone().unwrap_or_default(); - let path = $path.unwrap_or_default(); - rel_path.push(path.clone()); - // set the `--ext` file extension unless the filenames are explicitly given - if path == std::path::PathBuf::default() { - match $args.extension { - Extension::Webp => { - rel_path.set_extension("webp"); - } - Extension::Png => { - rel_path.set_extension("png"); - } - } - } - Image::::open(&rel_path) - .map_or(Err(eyre!("Failed to open `{}`", &rel_path.display())), Ok)? - }}; -} - -fn main() -> Result<()> { - color_eyre::config::HookBuilder::default() - .panic_section(format!( - "Consider reporting this issue to {}", - env!("CARGO_PKG_REPOSITORY") - )) - .display_env_section(false) - .install()?; - - let args = get_cli_arguments(); - - if let Some(generator) = args.command { - return match generator { - Commands::Completion { shell } => { - let mut cmd = Cli::command(); - eprintln!("Generating completion file for {generator:?}..."); - print_completions(shell, &mut cmd); - Ok(()) - } - }; - } - - let catwalk = Catwalk::new([ - open_image!(args.latte, args), - open_image!(args.frappe, args), - open_image!(args.macchiato, args), - open_image!(args.mocha, args), - ])? - .gap(args.gap) - .layout(Some(args.layout)) - .radius(args.radius)? - .build()?; - - let mut writebuf = Cursor::new(Vec::new()); - match args.output.extension() { - None => return Err(eyre!("Output file type could not be determined")), - Some(os_str) => match os_str.to_str() { - Some("png") => { - use ril::encodings::png::PngEncoder; - - PngEncoder::encode_static(&catwalk, &mut writebuf)?; - } - Some("webp") => { - use ril::encodings::webp::{WebPEncoderOptions, WebPStaticEncoder}; - - let opt = WebPEncoderOptions::new().with_lossless(true); - let meta = EncoderMetadata::::from(&catwalk).with_config(opt); - let mut encoder = WebPStaticEncoder::new(&mut writebuf, meta)?; - encoder.add_frame(&catwalk)?; - } - _ => return Err(eyre!("Output file type not supported")), - }, - } - - let output = if args.directory.is_some() { - let mut path = args.directory.clone().unwrap_or_default(); - if args.output.is_absolute() { - args.output - } else { - path.push(args.output); - path - } - } else { - args.output - }; - - std::fs::write(output, writebuf.get_ref()).map_err(|e| eyre!("Failed to write image: {}", e)) -} diff --git a/catwalk/src/mask.rs b/catwalk/src/mask.rs deleted file mode 100644 index e6053e91..00000000 --- a/catwalk/src/mask.rs +++ /dev/null @@ -1,102 +0,0 @@ -// all of the stuff is named ...Mask here -#![allow(clippy::module_name_repetitions)] - -use ril::prelude::*; - -enum MaskType { - Full, - Partial(f32, f32), -} - -pub struct TrapMask { - vertices: MaskType, - aa_level: u32, -} - -#[derive(Debug)] -pub struct RoundMask { - pub radius: u32, - pub aa_level: u32, -} - -impl RoundMask { - /// Applies a round mask on an object - pub fn mask(&self, image: &Image) -> Image { - // Save us some work - if self.radius == 0 { - return image.clone(); - } - let h = image.height(); - let w = image.width(); - let r = self.radius; - // Inner corners - let corners = [(r, r), (w - r, r), (w - r, h - r), (r, h - r)]; - Image::from_fn(w, h, |x, y| { - if ((x <= r) || (x >= corners[2].0)) && ((y <= r) || (y >= corners[2].1)) { - // y is in corner squares - let distances = corners.iter().map(|c| Self::get_dis((x, y), c.to_owned())); - if distances - .clone() - .map(|c| c <= r.pow(2)) - .collect::>() - == vec![false, false, false, false] - { - // y is not in mask - let diffs: Vec = distances.map(|dis| dis - r.pow(2)).collect(); - for diff in diffs { - if diff <= self.aa_level.pow(2) { - // Fraction of opacity - let alpha = f32::from(image.pixel(x, y).alpha()) / 255.0; - let frac: f32 = alpha - (diff as f32 / self.aa_level.pow(2) as f32); - return image.pixel(x, y).with_alpha((255.0 * frac) as u8); - } - } - return Rgba::transparent(); - } - } - *image.pixel(x, y) - }) - } - - /// Gets distance between two points - const fn get_dis(p1: (u32, u32), p2: (u32, u32)) -> u32 { - u32::abs_diff(p1.0, p2.0).pow(2) + u32::abs_diff(p1.1, p2.1).pow(2) //<= r.pow(2) - } -} - -impl TrapMask { - /// Construct a new shape. - pub fn new(vertex: Option, inverse_slope: f32, aa_level: u32) -> Self { - Self { - vertices: vertex.map_or(MaskType::Full, |v| MaskType::Partial(v, inverse_slope)), - aa_level, - } - } - - /// Apply mask onto given image - pub fn mask(&self, image: &Image) -> Image { - match &self.vertices { - MaskType::Full => image.clone(), - MaskType::Partial(v, inverse_slope) => { - let w = image.width(); - let h = image.height(); - Image::from_fn(w, h, |x, y| { - let gpos = (x as f32) - ((y as f32) * inverse_slope); - if gpos <= *v { - *image.pixel(x, y) - } else { - // Not in mask - let diff: f32 = gpos - v; - if diff <= self.aa_level as f32 { - // Fraction of opacity - let alpha = f32::from(image.pixel(x, y).alpha()) / 255.0; - let frac = alpha - (diff / (self.aa_level as f32)); - return image.pixel(x, y).with_alpha((255.0 * frac) as u8); - } - Rgba::transparent() - } - }) - } - } - } -} diff --git a/catwalk/src/wasm.rs b/catwalk/src/wasm.rs deleted file mode 100644 index 69d641fe..00000000 --- a/catwalk/src/wasm.rs +++ /dev/null @@ -1,175 +0,0 @@ -// needed for WASM -#![allow(clippy::use_self, clippy::missing_const_for_fn)] - -use crate::{Catwalk, CatwalkError, Magic}; -use ril::{Image, Rgba}; -use wasm_bindgen::{prelude::*, Clamped, JsValue}; -use web_sys::ImageData; - -impl From for JsValue { - fn from(err: CatwalkError) -> Self { - JsValue::from_str(&err.to_string()) - } -} - -#[wasm_bindgen] -#[allow(dead_code)] -pub struct CatwalkBuffer { - pub width: u32, - pub height: u32, - data: Vec, -} - -#[wasm_bindgen] -impl CatwalkBuffer { - #[wasm_bindgen(getter)] - pub fn data(&self) -> Vec { - self.data.clone() - } -} - -#[wasm_bindgen] -impl Catwalk { - /// Create a new Catwalk from 4 `web_sys::ImageData` objects - /// # Errors - /// Returns an error if the images... - /// - cannot be read. - /// - are not the same size. - pub fn new_from_imagedata( - latte: ImageData, - frappe: ImageData, - macchiato: ImageData, - mocha: ImageData, - ) -> Result { - let images: [Image; 4] = [latte, frappe, macchiato, mocha] - .into_iter() - .map(|img| { - let data = img.data().0; - Image::::from_fn(img.width(), img.height(), |x, y| { - let i: usize = (y * img.width() + x) as usize * 4; - Rgba::new(data[i], data[i + 1], data[i + 2], data[i + 3]) - }) - }) - .collect::>>() - .try_into() - .map_err(|_| CatwalkError::ReadFromBytesError)?; - - let height = images[0].height(); - let width = images[0].width(); - - // verify that they're all the same size - if images - .iter() - .any(|x| x.height() != height || x.width() != width) - { - return Err(CatwalkError::SameSize); - }; - - Ok(Self { - images: Some(images), - height: Some(height), - width: Some(width), - ..Default::default() - }) - } - - /// Create a new Catwalk from 4 `Vec`, which are in practice `Vec<[u8; 4]>` (RGBA). - /// # Errors - /// Returns an error if the images... - /// - cannot be read. - /// - are not the same size. - pub fn new_from_u8_array( - latte: Vec, - frappe: Vec, - macchiato: Vec, - mocha: Vec, - width: u32, - ) -> Result { - let images: [Image; 4] = [latte, frappe, macchiato, mocha] - .into_iter() - .map(|data| { - let len = data.len() as u32; - let height = len / (width * 4); - Image::::from_fn(width, height, |x, y| { - let i: usize = (y * width + x) as usize * 4; - Rgba::new(data[i], data[i + 1], data[i + 2], data[i + 3]) - }) - }) - .collect::>>() - .try_into() - .map_err(|_| CatwalkError::ReadFromBytesError)?; - - let height = images[0].height(); - let width = images[0].width(); - - // verify that they're all the same size - if images - .iter() - .any(|x| x.height() != height || x.width() != width) - { - return Err(CatwalkError::SameSize); - }; - - Ok(Self { - images: Some(images), - height: Some(height), - width: Some(width), - ..Default::default() - }) - } - - /// Calculate the Catwalk image & return an `ImageData` object. - /// # Errors - /// Returns an error if any of `self.images`, `self.height`, or `self.width` are not set. - pub fn build_imagedata(self) -> Result { - self.prepare()?.result() - } - - /// Calculate the Catwalk image & return a `CatwalkBuffer` object. - /// # Errors - /// Returns an error if any of `self.images`, `self.height`, or `self.width` are not set. - pub fn build_buffer(self) -> Result { - Ok(self.prepare()?.result_buffer()) - } - - /// Returns the version of the Catwalk library. - #[must_use] - #[wasm_bindgen(getter)] - pub fn version() -> String { - env!("CARGO_PKG_VERSION").to_string() - } -} - -impl Magic { - /// Calculate the Catwalk image & return an `ImageData` object. - /// # Errors - /// Returns an error if the `ImageData` cannot be created. - pub fn result(self) -> Result { - let img = self.process(); - let width = img.width(); - let data = img - .data - .iter() - .flat_map(|rgba| vec![rgba.r, rgba.g, rgba.b, rgba.a]) - .collect::>(); - ImageData::new_with_u8_clamped_array(Clamped(&data), width) - } - - #[must_use] - pub fn result_buffer(self) -> CatwalkBuffer { - let img = self.process(); - let width = img.width(); - let height = img.height(); - // collect a Vec from the rgba pixels - let data: Vec = img - .data - .into_iter() - .flat_map(|rgba| vec![rgba.r, rgba.g, rgba.b, rgba.a]) - .collect(); - CatwalkBuffer { - width, - height, - data, - } - } -} diff --git a/flake.nix b/flake.nix index b74ea66c..8cb2b689 100644 --- a/flake.nix +++ b/flake.nix @@ -3,26 +3,24 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - outputs = { - self, - nixpkgs, - ... - }: let - systems = ["aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux"]; - forEachSystem = fn: lib.genAttrs systems (system: fn (import nixpkgs {inherit system;})); - inherit (nixpkgs) lib; - in { - checks = forEachSystem (pkgs: self.packages.${pkgs.system}); - packages = forEachSystem (pkgs: lib.filterAttrs (_: v: lib.isDerivation v) (pkgs.callPackage ./nix { }) // { whiskers = throw "This package has been moved to x `github:catppuccin/whiskers`"; } ); - overlays.default = final: prev: { - catppuccin-catwalk = (prev.callPackage ./nix {}).catwalk; - catppuccin-whiskers = throw "This package has been moved to x `github:catppuccin/whiskers`"; + outputs = + { nixpkgs, ... }: + let + forAllSystems = + function: + nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed ( + system: function nixpkgs.legacyPackages.${system} + ); + in + { + packages = forAllSystems (_: { + whiskers = throw "This package has been moved to `github:catppuccin/whiskers`"; + catwalk = throw "This package has been moved to `github:catppuccin/catwalk`"; + }); + + overlays.default = _: _: { + catppuccin-catwalk = throw "This package has been moved to `github:catppuccin/catwalk`"; + catppuccin-whiskers = throw "This package has been moved to `github:catppuccin/whiskers`"; +}; }; - formatter = forEachSystem (pkgs: pkgs.alejandra); - }; - - nixConfig = { - extra-substituters = ["https://catppuccin.cachix.org"]; - extra-trusted-public-keys = ["catppuccin.cachix.org-1:noG/4HkbhJb+lUAdKrph6LaozJvAeEEZj4N732IysmU="]; - }; } diff --git a/nix/default.nix b/nix/default.nix deleted file mode 100644 index dbdc4aea..00000000 --- a/nix/default.nix +++ /dev/null @@ -1,40 +0,0 @@ -{pkgs}: let - inherit (pkgs) lib; - inherit (builtins) readFile fromTOML; - workspaceCargoToml = fromTOML (readFile ../Cargo.toml); - - mkRustPkg = {pname, ...} @ args: let - memberCargoToml = fromTOML (readFile ../${pname}/Cargo.toml); - in - pkgs.rustPlatform.buildRustPackage (lib.recursiveUpdate { - inherit pname; - inherit (memberCargoToml.package) version; - src = pkgs.nix-gitignore.gitignoreSource [] ../.; - - cargoLock.lockFile = ../Cargo.lock; - buildAndTestSubdir = pname; - - meta = { - description = memberCargoToml.package.description or null; - homepage = "https://github.com/catppuccin/toolbox/tree/main/${pname}"; - license = lib.licenses.mit; - mainProgram = pname; - }; - } - args); - rustPkgOverrides = { - catwalk = { - nativeBuildInputs = with pkgs; [installShellFiles pkg-config]; - buildInputs = with pkgs; [libwebp]; - - postInstall = '' - installShellCompletion --cmd catwalk \ - --bash <($out/bin/catwalk completion bash) \ - --fish <($out/bin/catwalk completion fish) \ - --zsh <($out/bin/catwalk completion zsh) - ''; - }; - }; - rustPkgs = lib.genAttrs workspaceCargoToml.workspace.members (pname: mkRustPkg ({inherit pname;} // rustPkgOverrides.${pname} or {})); -in - rustPkgs diff --git a/nix/dev/flake.lock b/nix/dev/flake.lock deleted file mode 100644 index 0b1a5426..00000000 --- a/nix/dev/flake.lock +++ /dev/null @@ -1,101 +0,0 @@ -{ - "nodes": { - "call-flake": { - "locked": { - "lastModified": 1707614389, - "narHash": "sha256-bmhE1TmrJG4ba93l9WQTLuYM53kwGQAjYHRvHOeuxWU=", - "owner": "divnix", - "repo": "call-flake", - "rev": "4407cb74eb861db5edf20c41bbfab950275622ba", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "call-flake", - "type": "github" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1707956935, - "narHash": "sha256-ZL2TrjVsiFNKOYwYQozpbvQSwvtV/3Me7Zwhmdsfyu4=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "a4d4fe8c5002202493e87ec8dbc91335ff55552c", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "call-flake": "call-flake", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1708135817, - "narHash": "sha256-EUMO/K3+Wgh0THOLoRXhxrh6G/pQ7BlJ8No+ciy1nKA=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "c77e68d33a84ce3f9e86905c0f2ef78d5defad28", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/nix/dev/flake.nix b/nix/dev/flake.nix deleted file mode 100644 index 5cdc067b..00000000 --- a/nix/dev/flake.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ - description = "Catppuccin's development tools, dev flake"; - - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.flake-utils.follows = "flake-utils"; - }; - call-flake.url = "github:divnix/call-flake"; - }; - - outputs = { - self, - nixpkgs, - call-flake, - ... - } @ inputs: let - systems = ["aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux"]; - overlays = [inputs.rust-overlay.overlays.default]; - inherit (nixpkgs) lib; - forEachSystem = fn: lib.genAttrs systems (system: fn (import nixpkgs {inherit overlays system;})); - mainFlake = call-flake ../..; - in { - inherit (mainFlake) checks formatter packages; - - devShells = forEachSystem (pkgs: let - inherit (pkgs.stdenv) isDarwin; - rust-toolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: - toolchain.default.override { - extensions = ["rust-src"]; - targets = ["wasm32-unknown-unknown"]; - }); - in { - default = pkgs.mkShell { - buildInputs = with pkgs; - [ - self.formatter.${pkgs.system} - rust-toolchain - rust-analyzer - deno - # wasm + publishing to npm - binaryen - nodejs - wasm-bindgen-cli - wasm-pack - # wasm-bindgen can require lcurl to build - curl - ] - ++ lib.optionals isDarwin [libiconv]; - env.RUST_SRC_PATH = "${rust-toolchain}/lib/rustlib/src/rust/library"; - }; - }); - }; - - nixConfig = { - extra-substituters = ["https://catppuccin.cachix.org" "https://nix-community.cachix.org"]; - extra-trusted-public-keys = ["catppuccin.cachix.org-1:noG/4HkbhJb+lUAdKrph6LaozJvAeEEZj4N732IysmU=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="]; - }; -} diff --git a/release-please-config.json b/release-please-config.json index 4f28648a..51cc783c 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1,18 +1,9 @@ { "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", - "release-type": "rust", "packages": { - "catwalk": { - "package-name": "catwalk" - }, "deno-lib": { "package-name": "deno-lib", "release-type": "simple" } - }, - "plugins": [ - { - "type": "cargo-workspace" - } - ] + } }