commit 1e8c2a24eb4dd9842107badeecb6c3b269cc78f8 Author: Ryan Walters Date: Fri Oct 31 01:10:53 2025 -0500 Update source files diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..b08f96f --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,18 @@ +[build] +rustc-wrapper = "sccache" + +[target.wasm32-unknown-unknown] +rustflags = [ + '--cfg', + 'getrandom_backend="wasm_js"', + '--cfg=web_sys_unstable_apis', +] + +# for Linux +[target.x86_64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-C", "link-arg=-fuse-ld=lld"] + +# for Windows +[target.x86_64-pc-windows-msvc] +linker = "rust-lld.exe" diff --git a/.cargo/mutants.toml b/.cargo/mutants.toml new file mode 100644 index 0000000..6c19eab --- /dev/null +++ b/.cargo/mutants.toml @@ -0,0 +1,17 @@ +# Copy VCS directories (.git, etc.) to build directories +copy_vcs = true + +# Examine only files matching these glob patterns +# examine_globs = ["src/**/*.rs", "examples/**/*.rs"] + +# Exclude files matching these glob patterns +# exclude_globs = ["src/test_*.rs", "src/**/test.rs", "tests/**/*.rs"] + +# Use built-in defaults for skip_calls (includes "with_capacity") +skip_calls_defaults = true + +# Run tests from these specific packages for all mutants +test_package = ["borders-core"] + +# Cargo profile to use for builds +profile = "mutant" diff --git a/.cargo/nextest.toml b/.cargo/nextest.toml new file mode 100644 index 0000000..18ee230 --- /dev/null +++ b/.cargo/nextest.toml @@ -0,0 +1,2 @@ +[profile.default] +fail-fast = false diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml new file mode 100644 index 0000000..1986317 --- /dev/null +++ b/.github/workflows/builds.yml @@ -0,0 +1,177 @@ +name: Builds +on: + - push +env: + CARGO_TERM_COLOR: always + RUST_VERSION: "stable" +jobs: + desktop: + name: Desktop (${{ matrix.target.os }} / ${{ matrix.target.arch }}) + runs-on: ${{ matrix.target.runner }} + strategy: + fail-fast: false + matrix: + target: + - os: linux + arch: x86_64 + runner: ubuntu-22.04 + rust_target: x86_64-unknown-linux-gnu + - os: macos + arch: x86_64 + runner: macos-15-intel + rust_target: x86_64-apple-darwin + - os: macos + arch: aarch64 + runner: macos-latest + rust_target: aarch64-apple-darwin + - os: windows + arch: x86_64 + runner: windows-latest + rust_target: x86_64-pc-windows-msvc + - os: windows + arch: aarch64 + runner: windows-latest + rust_target: aarch64-pc-windows-msvc + steps: + - uses: actions/checkout@v5 + - name: Setup Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_VERSION }} + components: rustfmt, clippy + targets: ${{ matrix.target.rust_target }} + - name: Rust cache + uses: Swatinem/rust-cache@v2 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + - name: Setup Node + uses: actions/setup-node@v5 + with: + node-version: 20 + cache: pnpm + cache-dependency-path: frontend/pnpm-lock.yaml + - name: Install frontend dependencies + run: pnpm install --frozen-lockfile --prefer-offline + working-directory: frontend + - name: Cache Tauri CLI (macOS only) + if: matrix.target.os == 'macos' + id: cache-tauri-cli + uses: actions/cache@v4 + with: + path: ~/.cargo/bin/cargo-tauri + key: ${{ runner.os }}-${{ runner.arch }}-tauri-cli-2 + - name: Install cargo-binstall + if: matrix.target.os != 'macos' + uses: taiki-e/install-action@cargo-binstall + - name: Install Tauri CLI (via binstall) + if: matrix.target.os != 'macos' + run: cargo binstall tauri-cli --version '^2' --no-confirm + - name: Install Tauri CLI (from source on macOS) + if: matrix.target.os == 'macos' && steps.cache-tauri-cli.outputs.cache-hit != 'true' + run: cargo install tauri-cli --version '^2' --locked + env: + CARGO_PROFILE_RELEASE_LTO: false + - name: Cache apt packages + if: matrix.target.os == 'linux' + uses: actions/cache@v4 + with: + path: | + /var/cache/apt/archives/*.deb + key: ${{ matrix.target.runner }}-apt-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ matrix.target.runner }}-apt- + - name: Install Linux dependencies + if: matrix.target.os == 'linux' + run: | + sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends \ + build-essential \ + libglib2.0-dev \ + libwebkit2gtk-4.1-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev \ + patchelf + - name: Build desktop app + run: cargo tauri build --target ${{ matrix.target.rust_target }} + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: iron-borders-${{ matrix.target.os }}-${{ matrix.target.arch }} + path: | + target/${{ matrix.target.rust_target }}/release/*.exe + target/${{ matrix.target.rust_target }}/release/bundle/appimage/*.AppImage + target/${{ matrix.target.rust_target }}/release/bundle/deb/*.deb + target/${{ matrix.target.rust_target }}/release/bundle/rpm/*.rpm + target/${{ matrix.target.rust_target }}/release/bundle/dmg/*.dmg + if-no-files-found: ignore + browser: + name: Browser (WASM) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_VERSION }} + targets: x86_64-unknown-linux-gnu, wasm32-unknown-unknown + - uses: Swatinem/rust-cache@v2 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + - name: Setup Node + uses: actions/setup-node@v5 + with: + node-version: 20 + cache: pnpm + cache-dependency-path: frontend/pnpm-lock.yaml + - name: Install frontend dependencies + run: pnpm install --frozen-lockfile --prefer-offline + working-directory: frontend + - name: Install wasm-bindgen-cli + uses: taiki-e/install-action@v2 + with: + tool: wasm-bindgen-cli@0.2.104 + - name: Install wasm-opt + uses: taiki-e/install-action@v2 + with: + tool: wasm-opt@0.116.1 + - name: Build WASM release + run: | + cargo build -p borders-wasm --profile wasm-release --target wasm32-unknown-unknown + wasm-bindgen --out-dir pkg --out-name borders --target web target/wasm32-unknown-unknown/wasm-release/borders_wasm.wasm + wasm-opt -Oz --enable-bulk-memory --enable-threads --all-features pkg/borders_bg.wasm -o pkg/borders_bg.wasm + mkdir -p frontend/pkg + cp -r pkg/* frontend/pkg/ + - name: Build frontend (root-based) + run: pnpm run build:browser + working-directory: frontend + - name: Upload browser artifacts + uses: actions/upload-artifact@v4 + with: + name: iron-borders-browser + path: frontend/dist/browser/client/**/* + if-no-files-found: error + deploy-cloudflare: + name: Deploy to Cloudflare Pages + needs: browser + runs-on: ubuntu-latest + if: github.event_name == 'push' + steps: + - name: Download browser artifact + uses: actions/download-artifact@v4 + with: + name: iron-borders-browser + path: dist + - name: Deploy to Cloudflare Pages + id: deploy + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy dist --project-name=borders + - name: Print deployment URL + env: + DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment-url }} + run: echo "Deployed to $DEPLOYMENT_URL" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..0526b15 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,66 @@ +name: Coverage +on: + - push +env: + CARGO_TERM_COLOR: always + RUST_VERSION: "nightly" +jobs: + coverage: + name: Code Coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_VERSION }} + targets: x86_64-unknown-linux-gnu + components: llvm-tools-preview + - uses: Swatinem/rust-cache@v2 + - name: Cache apt packages + uses: actions/cache@v4 + with: + path: | + /var/cache/apt/archives/*.deb + key: ubuntu-latest-apt-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ubuntu-latest-apt- + - name: Install Linux dependencies + run: | + sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends \ + build-essential \ + libglib2.0-dev \ + libwebkit2gtk-4.1-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev \ + patchelf + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Install nextest + uses: taiki-e/install-action@nextest + - name: Run tests with coverage + run: cargo llvm-cov nextest --workspace --no-fail-fast + - name: Generate coverage reports + run: | + mkdir -p coverage + cargo llvm-cov report --html --output-dir coverage/html + cargo llvm-cov report --json --output-path coverage/coverage.json + cargo llvm-cov report --lcov --output-path coverage/lcov.info + - name: Upload HTML coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-html + path: coverage/html + retention-days: 7 + - name: Upload JSON coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-json + path: coverage/coverage.json + retention-days: 7 + - name: Upload LCOV coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-lcov + path: coverage/lcov.info + retention-days: 7 diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 0000000..4a98da5 --- /dev/null +++ b/.github/workflows/quality.yml @@ -0,0 +1,84 @@ +name: Quality +on: + - push +env: + CARGO_TERM_COLOR: always + RUST_VERSION: "stable" +jobs: + rust-quality: + name: Rust Quality + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_VERSION }} + targets: x86_64-unknown-linux-gnu, wasm32-unknown-unknown + - uses: Swatinem/rust-cache@v2 + - name: Cache apt packages + uses: actions/cache@v4 + with: + path: | + /var/cache/apt/archives/*.deb + key: ubuntu-latest-apt-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ubuntu-latest-apt- + - name: Install Linux dependencies + run: | + sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends \ + build-essential \ + libglib2.0-dev \ + libwebkit2gtk-4.1-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev \ + patchelf + - name: Install just + uses: taiki-e/install-action@just + - name: Install cargo-machete + uses: taiki-e/install-action@cargo-machete + - name: Run Rust checks + run: just --shell bash --shell-arg -c check + - name: Install cargo-audit + uses: taiki-e/install-action@cargo-audit + - name: Run security audit + run: cargo audit + frontend-quality: + name: Frontend Quality + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + - name: Setup Node + uses: actions/setup-node@v5 + with: + node-version: 20 + cache: pnpm + cache-dependency-path: frontend/pnpm-lock.yaml + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_VERSION }} + targets: x86_64-unknown-linux-gnu, wasm32-unknown-unknown + - uses: Swatinem/rust-cache@v2 + - name: Install wasm-bindgen-cli + uses: taiki-e/install-action@v2 + with: + tool: wasm-bindgen-cli@0.2.104 + - name: Install frontend dependencies + run: pnpm install --frozen-lockfile + working-directory: frontend + - name: Install just + uses: taiki-e/install-action@just + - name: Build WASM for frontend checks + run: | + cargo build -p borders-wasm --profile wasm-dev --target wasm32-unknown-unknown + wasm-bindgen --out-dir pkg --out-name borders --target web target/wasm32-unknown-unknown/wasm-dev/borders_wasm.wasm + mkdir -p frontend/pkg + cp -r pkg/* frontend/pkg/ + - name: Run frontend TypeScript checks + run: pnpm run build:browser + working-directory: frontend diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..5f0254d --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,39 @@ +name: Tests +on: + - push +env: + CARGO_TERM_COLOR: always + RUST_VERSION: "stable" +jobs: + test: + name: Test Suite + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.RUST_VERSION }} + targets: x86_64-unknown-linux-gnu + - uses: Swatinem/rust-cache@v2 + - name: Cache apt packages + uses: actions/cache@v4 + with: + path: | + /var/cache/apt/archives/*.deb + key: ubuntu-latest-apt-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ubuntu-latest-apt- + - name: Install Linux dependencies + run: | + sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends \ + build-essential \ + libglib2.0-dev \ + libwebkit2gtk-4.1-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev \ + patchelf + - name: Install nextest + uses: taiki-e/install-action@nextest + - name: Run tests + run: cargo nextest run --workspace --no-fail-fast --hide-progress-bar --failure-output final diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fd1b77 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +target/ +pkg/ +*.pem +/*.io/ +releases/ +mutants.out*/ +coverage/ + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/.source-commit b/.source-commit new file mode 100644 index 0000000..7313b04 --- /dev/null +++ b/.source-commit @@ -0,0 +1 @@ +4f842e4ad8b999d408857d532230bf326dd1a434 diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..91bcbb3 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,8022 @@ +# 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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "aligned-vec" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b" +dependencies = [ + "equator", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anyhow" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" + +[[package]] +name = "arbitrary" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" + +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "assert2" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6c710e60d14b07d8f42d0e702b16120865eea39edb751e75cd6bf401d18f14" +dependencies = [ + "assert2-macros", + "diff", + "yansi", +] + +[[package]] +name = "assert2-macros" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9008cbbba9e1d655538870b91fd93814bd82e6968f27788fc734375120ac6f57" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.108", +] + +[[package]] +name = "assert_type_match" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f548ad2c4031f2902e3edc1f29c29e835829437de49562d8eb5dc5584d3a1043" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[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.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a89bce6054c720275ac2432fbba080a66a2106a44a1b804553930ca6909f4e0" +dependencies = [ + "compression-codecs", + "compression-core", + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "async-executor" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497c00e0fd83a72a79a39fcbd8e3e2f055d6f6c7e025f3b3d91f4f8e76527fb8" +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.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd03604047cee9b6ce9de9f70c6cd540a0520c813cbd49bae61f33ab80ed1dc" +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.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "async-signal" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43c070bbf59cd3570b6b2dd54cd772527c7c3620fce8be898406dd3ed6adc64c" +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" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[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 = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "av1-grain" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cfddb07216410377231960af4fcab838eaa12e013417781b78bd95ee22077f8" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom 8.0.0", + "num-rational", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47c8fbc0f831f4519fe8b810b6a7a91410ec83031b8233f730a0480029f6a23f" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "aws-lc-rs" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879b6c89592deb404ba4dc0ae6b58ffd1795c78991cbb5b8bc441c48a070440d" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "107a4e9d9cab9963e04e84bb8dee0e25f2a987f9a8bad5ed054abd439caa8f8c" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", +] + +[[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 = "bevy_ecs" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69d929d32190cfcde6efd2df493601c4dbc18a691fd9775a544c951c3c112e1a" +dependencies = [ + "arrayvec", + "bevy_ecs_macros", + "bevy_platform", + "bevy_ptr", + "bevy_reflect", + "bevy_tasks", + "bevy_utils", + "bitflags 2.10.0", + "bumpalo", + "concurrent-queue", + "derive_more 2.0.1", + "fixedbitset", + "indexmap 2.12.0", + "log", + "nonmax", + "serde", + "slotmap", + "smallvec", + "thiserror 2.0.17", + "tracing", + "variadics_please", +] + +[[package]] +name = "bevy_ecs_macros" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eeddfb80a2e000663e87be9229c26b4da92bddbc06c8776bc0d1f4a7f679079" +dependencies = [ + "bevy_macro_utils", + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "bevy_macro_utils" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17dbc3f8948da58b3c17767d20fd3cd35fe4721ed19a9a3204a6f1d6c9951bdd" +dependencies = [ + "parking_lot", + "proc-macro2", + "quote", + "syn 2.0.108", + "toml_edit 0.23.7", +] + +[[package]] +name = "bevy_platform" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cf8cda162688c95250e74cffaa1c3a04597f105d4ca35554106f107308ea57" +dependencies = [ + "critical-section", + "foldhash", + "futures-channel", + "hashbrown 0.16.0", + "js-sys", + "portable-atomic", + "portable-atomic-util", + "serde", + "spin 0.10.0", + "wasm-bindgen", + "wasm-bindgen-futures", +] + +[[package]] +name = "bevy_ptr" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28ab4074e7b781bab84e9b0a41ede245d673d1f75646ce0db27643aedcfb3a85" + +[[package]] +name = "bevy_reflect" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "333df3f5947b7e62728eb5c0b51d679716b16c7c5283118fed4563f13230954e" +dependencies = [ + "assert_type_match", + "bevy_platform", + "bevy_ptr", + "bevy_reflect_derive", + "bevy_utils", + "derive_more 2.0.1", + "disqualified", + "downcast-rs", + "erased-serde", + "foldhash", + "glam", + "serde", + "smallvec", + "smol_str", + "thiserror 2.0.17", + "uuid", + "variadics_please", + "wgpu-types", +] + +[[package]] +name = "bevy_reflect_derive" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0205dce9c5a4d8d041b263bcfd96e9d9d6f3d49416e12db347ab5778b3071fe1" +dependencies = [ + "bevy_macro_utils", + "indexmap 2.12.0", + "proc-macro2", + "quote", + "syn 2.0.108", + "uuid", +] + +[[package]] +name = "bevy_tasks" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18839182775f30d26f0f84d9de85d25361bb593c99517a80b64ede6cbaf41adc" +dependencies = [ + "async-channel", + "async-task", + "atomic-waker", + "bevy_platform", + "crossbeam-queue", + "derive_more 2.0.1", + "futures-lite", + "heapless", + "pin-project", +] + +[[package]] +name = "bevy_utils" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "080254083c74d5f6eb0649d7cd6181bda277e8fe3c509ec68990a5d56ec23f24" +dependencies = [ + "bevy_platform", + "disqualified", + "thread_local", +] + +[[package]] +name = "bindgen" +version = "0.72.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +dependencies = [ + "bitflags 2.10.0", + "cexpr", + "clang-sys", + "itertools 0.13.0", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.108", +] + +[[package]] +name = "bit_field" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +dependencies = [ + "serde_core", +] + +[[package]] +name = "bitstream-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2 0.5.2", +] + +[[package]] +name = "block2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" +dependencies = [ + "objc2 0.6.3", +] + +[[package]] +name = "blocking" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83f8d02be6967315521be875afa792a316e28d57b5a2d401897e2a7921b7f21" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + +[[package]] +name = "borders-core" +version = "0.6.1" +dependencies = [ + "assert2", + "bevy_ecs", + "chrono", + "criterion", + "directories", + "extension-traits", + "flume", + "futures", + "futures-lite", + "glam", + "gloo-timers", + "hex", + "hickory-resolver", + "hmac", + "image", + "js-sys", + "machineid-rs", + "once_cell", + "pem", + "quanta", + "rand 0.9.2", + "reqwest", + "ring", + "rkyv", + "rstest", + "serde", + "serde_bytes", + "serde_json", + "sha2", + "slotmap", + "sysinfo 0.37.2", + "tokio", + "tracing", + "tracing-subscriber", + "uuid", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "web-transport", + "winreg 0.55.0", +] + +[[package]] +name = "borders-desktop" +version = "0.6.1" +dependencies = [ + "bevy_ecs", + "borders-core", + "chrono", + "flume", + "serde", + "serde_json", + "tauri", + "tauri-build", + "tauri-plugin-opener", + "tauri-plugin-process", + "tokio", + "tracing", + "tracing-subscriber", + "tracing-tracy", + "tracy-client", +] + +[[package]] +name = "borders-server" +version = "0.6.1" +dependencies = [ + "anyhow", + "borders-core", + "flume", + "rkyv", + "rustls-pemfile", + "tokio", + "tracing", + "tracing-log", + "tracing-subscriber", + "web-transport", +] + +[[package]] +name = "borders-wasm" +version = "0.6.1" +dependencies = [ + "bevy_ecs", + "borders-core", + "console_error_panic_hook", + "flume", + "getrandom 0.3.4", + "gloo-timers", + "js-sys", + "lazy_static", + "serde", + "serde-wasm-bindgen", + "serde_json", + "tracing", + "tracing-subscriber", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-tracing", +] + +[[package]] +name = "brotli" +version = "8.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bd8b9603c7aa97359dbd97ecf258968c95f3adddd6db2f7e7a5bef101c84560" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "built" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b" + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "bytecheck" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0caa33a2c0edca0419d15ac723dff03f1956f7978329b1e3b5fdaaaed9d3ca8b" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "rancor", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89385e82b5d1821d2219e0b095efa2cc1f246cbf99080f3be46a1a85c0d392d9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "bytemuck" +version = "1.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[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.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +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.10.0", + "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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276a59bf2b2c967788139340c9f0c5b12d7fd6630315c15c217e559de85d2609" +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.17", +] + +[[package]] +name = "cargo_toml" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374b7c592d9c00c1f4972ea58390ac6b18cbb6ab79011f3bdc90a0b82ca06b77" +dependencies = [ + "serde", + "toml 0.9.8", +] + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cc" +version = "1.2.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "739eb0f94557554b3ca9a86d2d37bebd49c5e6d0c1d2bda35ba5bdac830befc2" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom 7.1.3", +] + +[[package]] +name = "cfb" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f" +dependencies = [ + "byteorder", + "fnv", + "uuid", +] + +[[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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chrono" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link 0.2.1", +] + +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading 0.8.9", +] + +[[package]] +name = "clap" +version = "4.5.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0" +dependencies = [ + "anstyle", + "clap_lex", +] + +[[package]] +name = "clap_lex" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" + +[[package]] +name = "cmake" +version = "0.1.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" +dependencies = [ + "cc", +] + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "compression-codecs" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8a506ec4b81c460798f572caead636d57d3d7e940f998160f52bd254bf2d23" +dependencies = [ + "brotli", + "compression-core", + "flate2", + "memchr", + "zstd", + "zstd-safe", +] + +[[package]] +name = "compression-core" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e47641d3deaf41fb1538ac1f54735925e275eaf3bf4d55c81b137fba797e5cbb" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", + "portable-atomic", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cookie" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" +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.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" +dependencies = [ + "bitflags 2.10.0", + "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.10.0", + "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 = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "criterion" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1c047a62b0cc3e145fa84415a3191f628e980b194c2755aa12300a4e6cbd928" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "itertools 0.13.0", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b1bcc0dc7dfae599d84ad0b1a55f80cde8af3725da8313b528da95ef783e338" +dependencies = [ + "cast", + "itertools 0.13.0", +] + +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "cssparser" +version = "0.29.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93d03419cb5950ccfd3daf3ff1c7a36ace64609a1a8746d493df1ca0afde0fa" +dependencies = [ + "cssparser-macros", + "dtoa-short", + "itoa", + "matches", + "phf 0.10.1", + "proc-macro2", + "quote", + "smallvec", + "syn 1.0.109", +] + +[[package]] +name = "cssparser-macros" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" +dependencies = [ + "quote", + "syn 2.0.108", +] + +[[package]] +name = "ctor" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501" +dependencies = [ + "quote", + "syn 2.0.108", +] + +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.108", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "data-encoding" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" + +[[package]] +name = "deranged" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" +dependencies = [ + "powerfmt", + "serde_core", +] + +[[package]] +name = "derive_more" +version = "0.99.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.108", +] + +[[package]] +name = "derive_more" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", + "unicode-xid", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "directories" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +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 = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dispatch2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" +dependencies = [ + "bitflags 2.10.0", + "objc2 0.6.3", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "disqualified" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9c272297e804878a2a4b707cfcfc6d2328b5bb936944613b4fdf2b9269afdfd" + +[[package]] +name = "dlopen2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b54f373ccf864bf587a89e880fb7610f8d73f3045f13580948ccbcaff26febff" +dependencies = [ + "dlopen2_derive", + "libc", + "once_cell", + "winapi", +] + +[[package]] +name = "dlopen2_derive" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "788160fb30de9cdd857af31c6a2675904b16ece8fc2737b2c7127ba368c9d0f4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "downcast-rs" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "117240f60069e65410b3ae1bb213295bd828f707b5bec6596a1afc8793ce0cbc" + +[[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.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6add3b8cff394282be81f3fc1a0605db594ed69890078ca6e2cab1c408bcf04" + +[[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 = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "embed-resource" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55a075fc573c64510038d7ee9abc7990635863992f83ebc52c8b433b8411a02e" +dependencies = [ + "cc", + "memchr", + "rustc_version", + "toml 0.9.8", + "vswhom", + "winreg 0.55.0", +] + +[[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" + +[[package]] +name = "enum-as-inner" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[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.108", +] + +[[package]] +name = "equator" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" +dependencies = [ + "equator-macro", +] + +[[package]] +name = "equator-macro" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "erased-serde" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "259d404d09818dec19332e31d94558aeb442fea04c817006456c24b5460bbd4b" +dependencies = [ + "serde", + "serde_core", + "typeid", +] + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "event-listener" +version = "5.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" +dependencies = [ + "concurrent-queue", + "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 = "exr" +version = "1.73.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0" +dependencies = [ + "bit_field", + "half", + "lebe", + "miniz_oxide", + "rayon-core", + "smallvec", + "zune-inflate", +] + +[[package]] +name = "ext-trait" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c24fe28375ffabb5479233d60a5d99930a3983ed3aa6db66dd03b830fc41b2" +dependencies = [ + "ext-trait-proc_macros", +] + +[[package]] +name = "ext-trait-proc_macros" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad551ddce9af58215158c84e1e655b2011f6355b655c13b56d88986b14d3db98" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "extension-traits" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fea67d50388b3db0e51e65815ed7293703607ff9dc50d86f93e1abcc67b572" +dependencies = [ + "ext-trait", +] + +[[package]] +name = "fastbloom" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18c1ddb9231d8554c2d6bdf4cfaabf0c59251658c68b6c95cd52dd0c513a912a" +dependencies = [ + "getrandom 0.3.4", + "libm", + "rand 0.9.2", + "siphasher 1.0.1", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fax" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05de7d48f37cd6730705cbca900770cab77a89f413d23e100ad7fad7795a0ab" +dependencies = [ + "fax_derive", +] + +[[package]] +name = "fax_derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[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 = "find-msvc-tools" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "flate2" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfe33edd8e85a12a67454e37f8c75e730830d83e313556ab9ebf9ee7fbeb3bfb" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "flume" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" +dependencies = [ + "futures-core", + "futures-sink", + "nanorand", + "spin 0.9.8", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[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 = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "futf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843" +dependencies = [ + "mac", + "new_debug_unreachable", +] + +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[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.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-timer" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[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 = "generator" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "605183a538e3e2a9c1038635cc5c2d194e2ee8fd0d1b66b8349fad7dbacce5a2" +dependencies = [ + "cc", + "cfg-if", + "libc", + "log", + "rustversion", + "windows 0.61.3", +] + +[[package]] +name = "generic-array" +version = "0.14.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasip2", + "wasm-bindgen", +] + +[[package]] +name = "gif" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae047235e33e2829703574b54fdec96bfbad892062d97fed2f76022287de61b" +dependencies = [ + "color_quant", + "weezl", +] + +[[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 = "glam" +version = "0.30.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12d847aeb25f41be4c0ec9587d624e9cd631bc007a8fd7ce3f5851e064c6460" +dependencies = [ + "rkyv", + "serde_core", +] + +[[package]] +name = "glib" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" +dependencies = [ + "bitflags 2.10.0", + "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.108", +] + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "gloo-timers" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[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.108", +] + +[[package]] +name = "h2" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.12.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h3" +version = "0.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dfb059a4f28a66f186ed16ad912d142f490676acba59353831d7cb45a96b0d3" +dependencies = [ + "bytes", + "fastrand", + "futures-util", + "http", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "h3-quinn" +version = "0.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d482318ae94198fc8e3cbb0b7ba3099c865d744e6ec7c62039ca7b6b6c66fbf" +dependencies = [ + "bytes", + "futures", + "h3", + "quinn", + "tokio", + "tokio-util", +] + +[[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 = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + +[[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" + +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +dependencies = [ + "equivalent", + "serde", +] + +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32", + "portable-atomic", + "stable_deref_trait", +] + +[[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hickory-proto" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8a6fe56c0038198998a6f217ca4e7ef3a5e51f46163bd6dd60b5c71ca6c6502" +dependencies = [ + "async-trait", + "bytes", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "h2", + "h3", + "h3-quinn", + "http", + "idna", + "ipnet", + "once_cell", + "pin-project-lite", + "quinn", + "rand 0.9.2", + "ring", + "rustls", + "thiserror 2.0.17", + "tinyvec", + "tokio", + "tokio-rustls", + "tracing", + "url", + "webpki-roots 0.26.11", +] + +[[package]] +name = "hickory-resolver" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc62a9a99b0bfb44d2ab95a7208ac952d31060efc16241c87eaf36406fecf87a" +dependencies = [ + "cfg-if", + "futures-util", + "hickory-proto", + "ipconfig", + "moka", + "once_cell", + "parking_lot", + "quinn", + "rand 0.9.2", + "resolv-conf", + "rustls", + "smallvec", + "thiserror 2.0.17", + "tokio", + "tokio-rustls", + "tracing", + "webpki-roots 0.26.11", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "html5ever" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b7410cae13cbc75623c98ac4cbfd1f0bedddf3227afc24f370cf0f50a44a11c" +dependencies = [ + "log", + "mac", + "markup5ever", + "match_token", +] + +[[package]] +name = "http" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +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 = "hyper" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots 1.0.3", +] + +[[package]] +name = "hyper-util" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2 0.6.1", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core 0.62.2", +] + +[[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.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc50b891e4acf8fe0e71ef88ec43ad82ee07b3810ad09de10f1d01f072ed4b98" +dependencies = [ + "byteorder", + "png 0.17.16", +] + +[[package]] +name = "icu_collections" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" + +[[package]] +name = "icu_properties" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "potential_utf", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" + +[[package]] +name = "icu_provider" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +dependencies = [ + "displaydoc", + "icu_locale_core", + "stable_deref_trait", + "tinystr", + "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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "image" +version = "0.25.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "529feb3e6769d234375c4cf1ee2ce713682b8e76538cb13f9fc23e1400a591e7" +dependencies = [ + "bytemuck", + "byteorder-lite", + "color_quant", + "exr", + "gif", + "image-webp", + "moxcms", + "num-traits", + "png 0.18.0", + "qoi", + "ravif", + "rayon", + "rgb", + "tiff", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "image-webp" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" +dependencies = [ + "byteorder-lite", + "quick-error", +] + +[[package]] +name = "imgref" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c5cedc30da3a610cac6b4ba17597bdf7152cf974e8aab3afb3d54455e371c8" + +[[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.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +dependencies = [ + "equivalent", + "hashbrown 0.16.0", + "serde", + "serde_core", +] + +[[package]] +name = "infer" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a588916bfdfd92e71cacef98a63d9b1f0d74d6599980d11894290e7ddefffcf7" +dependencies = [ + "cfb", +] + +[[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "ipconfig" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" +dependencies = [ + "socket2 0.5.10", + "widestring", + "windows-sys 0.48.0", + "winreg 0.50.0", +] + +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +dependencies = [ + "memchr", + "serde", +] + +[[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 = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[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 = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "json-patch" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863726d7afb6bc2590eeff7135d923545e5e964f004c2ccf8716c25e70a86f08" +dependencies = [ + "jsonptr", + "serde", + "serde_json", + "thiserror 1.0.69", +] + +[[package]] +name = "jsonptr" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dea2b27dd239b2556ed7a25ba842fe47fd602e7fc7433c2a8d6106d4d9edd70" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "keyboard-types" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" +dependencies = [ + "bitflags 2.10.0", + "serde", + "unicode-segmentation", +] + +[[package]] +name = "kuchikiki" +version = "0.8.8-speedreader" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02cb977175687f33fa4afa0c95c112b987ea1443e5a51c8f8ff27dc618270cc2" +dependencies = [ + "cssparser", + "html5ever", + "indexmap 2.12.0", + "selectors", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lebe" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" + +[[package]] +name = "libappindicator" +version = "0.9.0" +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 0.7.4", + "once_cell", +] + +[[package]] +name = "libc" +version = "0.2.177" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" + +[[package]] +name = "libfuzzer-sys" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5037190e1f70cbeef565bd267599242926f724d3b8a9f510fd7e0b540cfa4404" +dependencies = [ + "arbitrary", + "cc", +] + +[[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 = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link 0.2.1", +] + +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + +[[package]] +name = "libredox" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" +dependencies = [ + "bitflags 2.10.0", + "libc", + "redox_syscall", +] + +[[package]] +name = "linux-raw-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" + +[[package]] +name = "litemap" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" + +[[package]] +name = "loom" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + +[[package]] +name = "mac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" + +[[package]] +name = "machineid-rs" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ceb4d434d69d7199abc3036541ba6ef86767a4356e3077d5a3419f85b70b14" +dependencies = [ + "hex", + "hmac", + "md-5", + "serde", + "serde_json", + "sha-1", + "sha2", + "sysinfo 0.29.11", + "uuid", + "whoami", + "winreg 0.11.0", + "wmi", +] + +[[package]] +name = "markup5ever" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7a7213d12e1864c0f002f52c2923d4556935a43dec5e71355c2760e0f6e7a18" +dependencies = [ + "log", + "phf 0.11.3", + "phf_codegen 0.11.3", + "string_cache", + "string_cache_codegen", + "tendril", +] + +[[package]] +name = "match_token" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a9689d8d44bf9964484516275f5cd4c9b59457a6940c1d5d0ecbb94510a36b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matches" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" + +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[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.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[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 = "mio" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" +dependencies = [ + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.61.2", +] + +[[package]] +name = "moka" +version = "0.12.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8261cd88c312e0004c1d51baad2980c66528dfdb2bee62003e643a4d8f86b077" +dependencies = [ + "crossbeam-channel", + "crossbeam-epoch", + "crossbeam-utils", + "equivalent", + "parking_lot", + "portable-atomic", + "rustc_version", + "smallvec", + "tagptr", + "uuid", +] + +[[package]] +name = "moxcms" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fbdd3d7436f8b5e892b8b7ea114271ff0fa00bc5acae845d53b07d498616ef6" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] +name = "muda" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c1738382f66ed56b3b9c8119e794a2e23148ac8ea214eda86622d4cb9d415a" +dependencies = [ + "crossbeam-channel", + "dpi", + "gtk", + "keyboard-types", + "objc2 0.6.3", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "once_cell", + "png 0.17.16", + "serde", + "thiserror 2.0.17", + "windows-sys 0.60.2", +] + +[[package]] +name = "munge" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e17401f259eba956ca16491461b6e8f72913a0a114e39736ce404410f915a0c" +dependencies = [ + "munge_macro", +] + +[[package]] +name = "munge_macro" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4568f25ccbd45ab5d5603dc34318c1ec56b117531781260002151b8530a9f931" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "nanorand" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" +dependencies = [ + "getrandom 0.2.16", +] + +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags 2.10.0", + "jni-sys", + "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", +] + +[[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.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" +dependencies = [ + "bitflags 2.10.0", + "cfg-if", + "cfg_aliases", + "libc", + "memoffset", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] + +[[package]] +name = "nonmax" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" + +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1207a7e20ad57b847bbddc6776b968420d38292bbfe2089accff5e19e82454c" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff32365de1b6743cb203b710788263c44a03de03802daf96092f2da4fe6ba4d7" +dependencies = [ + "proc-macro-crate 3.4.0", + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c2599ce0ec54857b29ce62166b0ed9b4f6f1a70ccc9a71165b6154caca8c05" +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.10.0", + "block2 0.6.2", + "libc", + "objc2 0.6.3", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-core-image", + "objc2-core-text", + "objc2-core-video", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", +] + +[[package]] +name = "objc2-cloud-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c" +dependencies = [ + "bitflags 2.10.0", + "objc2 0.6.3", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-core-data" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa" +dependencies = [ + "bitflags 2.10.0", + "objc2 0.6.3", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.10.0", + "dispatch2", + "objc2 0.6.3", +] + +[[package]] +name = "objc2-core-graphics" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" +dependencies = [ + "bitflags 2.10.0", + "dispatch2", + "objc2 0.6.3", + "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 0.6.3", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-core-text" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" +dependencies = [ + "bitflags 2.10.0", + "objc2 0.6.3", + "objc2-core-foundation", + "objc2-core-graphics", +] + +[[package]] +name = "objc2-core-video" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6" +dependencies = [ + "bitflags 2.10.0", + "objc2 0.6.3", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-io-surface", +] + +[[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.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags 2.10.0", + "block2 0.5.1", + "libc", + "objc2 0.5.2", +] + +[[package]] +name = "objc2-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" +dependencies = [ + "bitflags 2.10.0", + "block2 0.6.2", + "libc", + "objc2 0.6.3", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-io-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" +dependencies = [ + "libc", + "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.10.0", + "objc2 0.6.3", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-javascript-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a1e6550c4caed348956ce3370c9ffeca70bb1dbed4fa96112e7c6170e074586" +dependencies = [ + "objc2 0.6.3", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags 2.10.0", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.10.0", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", + "objc2-metal", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" +dependencies = [ + "bitflags 2.10.0", + "objc2 0.6.3", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-security" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a" +dependencies = [ + "bitflags 2.10.0", + "objc2 0.6.3", + "objc2-core-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.10.0", + "objc2 0.6.3", + "objc2-core-foundation", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-web-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e5aaab980c433cf470df9d7af96a7b46a9d892d521a2cbbb2f8a4c16751e7f" +dependencies = [ + "bitflags 2.10.0", + "block2 0.6.2", + "objc2 0.6.3", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-javascript-core", + "objc2-security", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +dependencies = [ + "critical-section", + "portable-atomic", +] + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "open" +version = "5.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2483562e62ea94312f3576a7aca397306df7990b8d89033e18766744377ef95" +dependencies = [ + "dunce", + "is-wsl", + "libc", + "pathdiff", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[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 = "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 0.2.1", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + +[[package]] +name = "pem" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" +dependencies = [ + "base64 0.22.1", + "serde_core", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "phf" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" +dependencies = [ + "phf_shared 0.8.0", +] + +[[package]] +name = "phf" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +dependencies = [ + "phf_macros 0.10.0", + "phf_shared 0.10.0", + "proc-macro-hack", +] + +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_macros 0.11.3", + "phf_shared 0.11.3", +] + +[[package]] +name = "phf_codegen" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" +dependencies = [ + "phf_generator 0.8.0", + "phf_shared 0.8.0", +] + +[[package]] +name = "phf_codegen" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" +dependencies = [ + "phf_generator 0.11.3", + "phf_shared 0.11.3", +] + +[[package]] +name = "phf_generator" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" +dependencies = [ + "phf_shared 0.8.0", + "rand 0.7.3", +] + +[[package]] +name = "phf_generator" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +dependencies = [ + "phf_shared 0.10.0", + "rand 0.8.5", +] + +[[package]] +name = "phf_generator" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +dependencies = [ + "phf_shared 0.11.3", + "rand 0.8.5", +] + +[[package]] +name = "phf_macros" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" +dependencies = [ + "phf_generator 0.10.0", + "phf_shared 0.10.0", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "phf_macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" +dependencies = [ + "phf_generator 0.11.3", + "phf_shared 0.11.3", + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "phf_shared" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" +dependencies = [ + "siphasher 0.3.11", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher 0.3.11", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher 1.0.1", +] + +[[package]] +name = "pin-project" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "piper" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "plist" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07" +dependencies = [ + "base64 0.22.1", + "indexmap 2.12.0", + "quick-xml", + "serde", + "time", +] + +[[package]] +name = "plotters" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" + +[[package]] +name = "plotters-svg" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" +dependencies = [ + "plotters-backend", +] + +[[package]] +name = "png" +version = "0.17.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] + +[[package]] +name = "png" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97baced388464909d42d89643fe4361939af9b7ce7a31ee32a168f832a70f2a0" +dependencies = [ + "bitflags 2.10.0", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] + +[[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.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84df19adbe5b5a0782edcab45899906947ab039ccf4573713735ee7de1e6b08a" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.108", +] + +[[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.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" +dependencies = [ + "toml_edit 0.23.7", +] + +[[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-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" + +[[package]] +name = "proc-macro2" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "profiling" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" +dependencies = [ + "quote", + "syn 2.0.108", +] + +[[package]] +name = "ptr_meta" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9a0cf95a1196af61d4f1cbdab967179516d9a4a4312af1f31948f8f6224a79" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7347867d0a7e1208d93b46767be83e2b8f978c3dad35f775ac8d8847551d6fe1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "pxfm" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3cbdf373972bf78df4d3b518d07003938e2c7d1fb5891e55f9cb6df57009d84" +dependencies = [ + "num-traits", +] + +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "quanta" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3ab5a9d756f0d97bdc89019bd2e4ea098cf9cde50ee7564dde6b81ccc8f06c7" +dependencies = [ + "crossbeam-utils", + "libc", + "once_cell", + "raw-cpuid", + "wasi 0.11.1+wasi-snapshot-preview1", + "web-sys", + "winapi", +] + +[[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.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42a232e7487fc2ef313d96dde7948e7a3c05101870d8985e4fd8d26aedd27b89" +dependencies = [ + "memchr", +] + +[[package]] +name = "quinn" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +dependencies = [ + "bytes", + "cfg_aliases", + "futures-io", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2 0.6.1", + "thiserror 2.0.17", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" +dependencies = [ + "aws-lc-rs", + "bytes", + "fastbloom", + "getrandom 0.3.4", + "lru-slab", + "rand 0.9.2", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", + "slab", + "thiserror 2.0.17", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2 0.6.1", + "tracing", + "windows-sys 0.60.2", +] + +[[package]] +name = "quote" +version = "1.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" +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 = "rancor" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a063ea72381527c2a0561da9c80000ef822bdd7c3241b1cc1b12100e3df081ee" +dependencies = [ + "ptr_meta", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", + "rand_pcg", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.16", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rav1e" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +dependencies = [ + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools 0.12.1", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "once_cell", + "paste", + "profiling", + "rand 0.8.5", + "rand_chacha 0.3.1", + "simd_helpers", + "system-deps", + "thiserror 1.0.69", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.11.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5825c26fddd16ab9f515930d49028a630efec172e903483c94796cfe31893e6b" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e", + "rayon", + "rgb", +] + +[[package]] +name = "raw-cpuid" +version = "11.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" +dependencies = [ + "bitflags 2.10.0", +] + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "rayon" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.10.0", +] + +[[package]] +name = "redox_users" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" +dependencies = [ + "getrandom 0.2.16", + "libredox", + "thiserror 2.0.17", +] + +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "regex" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" + +[[package]] +name = "relative-path" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" + +[[package]] +name = "rend" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadadef317c2f20755a64d7fdc48f9e7178ee6b0e1f7fce33fa60f1d68a276e6" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "reqwest" +version = "0.12.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" +dependencies = [ + "async-compression", + "base64 0.22.1", + "bytes", + "futures-core", + "futures-util", + "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", + "web-sys", + "webpki-roots 1.0.3", +] + +[[package]] +name = "resolv-conf" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3789b30bd25ba102de4beabd95d21ac45b69b1be7d14522bab988c526d6799" + +[[package]] +name = "rgb" +version = "0.8.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6a884d2998352bb4daf0183589aec883f16a6da1f4dde84d8e2e9a5409a1ce" + +[[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.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rkyv" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35a640b26f007713818e9a9b65d34da1cf58538207b052916a83d80e43f3ffa4" +dependencies = [ + "bytecheck", + "bytes", + "hashbrown 0.15.5", + "indexmap 2.12.0", + "munge", + "ptr_meta", + "rancor", + "rend", + "rkyv_derive", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd83f5f173ff41e00337d97f6572e416d022ef8a19f371817259ae960324c482" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "rstest" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a2c585be59b6b5dd66a9d2084aa1d8bd52fbdb806eafdeffb52791147862035" +dependencies = [ + "futures", + "futures-timer", + "rstest_macros", + "rustc_version", +] + +[[package]] +name = "rstest_macros" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "825ea780781b15345a146be27eaefb05085e337e869bff01b4306a4fd4a9ad5a" +dependencies = [ + "cfg-if", + "glob", + "proc-macro-crate 3.4.0", + "proc-macro2", + "quote", + "regex", + "relative-path", + "rustc_version", + "syn 2.0.108", + "unicode-ident", +] + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +dependencies = [ + "bitflags 2.10.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9586e9ee2b4f8fab52a0048ca7334d7024eef48e2cb9407e3497bb7cab7fa7" +dependencies = [ + "aws-lc-rs", + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94182ad936a0c91c324cd46c6511b9510ed16af436d7b5bab34beab0afd55f7a" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-platform-verifier" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d99feebc72bae7ab76ba994bb5e121b8d83d910ca40b36e0921f53becc41784" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + +[[package]] +name = "rustls-webpki" +version = "0.103.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10b3f4191e8a80e6b43eebabfac91e5dcecebb27a71f04e820c47ec41d314bf" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[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 = "schannel" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +dependencies = [ + "windows-sys 0.61.2", +] + +[[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.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +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.108", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" +dependencies = [ + "bitflags 2.10.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "selectors" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c37578180969d00692904465fb7f6b3d50b9a2b952b87c23d0e2e5cb5013416" +dependencies = [ + "bitflags 1.3.2", + "cssparser", + "derive_more 0.99.20", + "fxhash", + "log", + "phf 0.8.0", + "phf_codegen 0.8.0", + "precomputed-hash", + "servo_arc", + "smallvec", +] + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +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-wasm-bindgen" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "serde_bytes" +version = "0.11.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[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.108", +] + +[[package]] +name = "serde_json" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", + "serde_core", +] + +[[package]] +name = "serde_repr" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[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.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" +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.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa66c845eee442168b2c8134fec70ac50dc20e760769c8ba0ad1319ca1959b04" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.12.0", + "schemars 0.9.0", + "schemars 1.0.4", + "serde_core", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91a903660542fced4e99881aa481bdbaec1634568ee02e0b8bd57c64cb38955" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[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.108", +] + +[[package]] +name = "servo_arc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52aa42f8fdf0fed91e5ce7f23d8138441002fa31dca008acf47e6fd4721f741" +dependencies = [ + "nodrop", + "stable_deref_trait", +] + +[[package]] +name = "sha-1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +dependencies = [ + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "slab" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" + +[[package]] +name = "slotmap" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "smol_str" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" +dependencies = [ + "serde", +] + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "softbuffer" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18051cdd562e792cad055119e0cdb2cfc137e44e3987532e0f9659a77931bb08" +dependencies = [ + "bytemuck", + "cfg_aliases", + "core-graphics", + "foreign-types", + "js-sys", + "log", + "objc2 0.5.2", + "objc2-foundation 0.2.2", + "objc2-quartz-core 0.2.2", + "raw-window-handle", + "redox_syscall", + "wasm-bindgen", + "web-sys", + "windows-sys 0.59.0", +] + +[[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 = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spin" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "string_cache" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f" +dependencies = [ + "new_debug_unreachable", + "parking_lot", + "phf_shared 0.11.3", + "precomputed-hash", + "serde", +] + +[[package]] +name = "string_cache_codegen" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c711928715f1fe0fe509c53b43e993a9a557babc2d0a3567d0a3006f1ac931a0" +dependencies = [ + "phf_generator 0.11.3", + "phf_shared 0.11.3", + "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.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4057c98e2e852d51fdcfca832aac7b571f6b351ad159f9eda5db1655f8d0c4d7" +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", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" +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.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "sysinfo" +version = "0.29.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd727fc423c2060f6c92d9534cef765c65a6ed3f428a03d7def74a8c4348e666" +dependencies = [ + "cfg-if", + "core-foundation-sys", + "libc", + "ntapi", + "once_cell", + "rayon", + "winapi", +] + +[[package]] +name = "sysinfo" +version = "0.37.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f" +dependencies = [ + "libc", + "memchr", + "ntapi", + "objc2-core-foundation", + "objc2-io-kit", + "windows 0.61.3", +] + +[[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 = "tagptr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" + +[[package]] +name = "tao" +version = "0.34.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a753bdc39c07b192151523a3f77cd0394aa75413802c883a0f6f6a0e5ee2e7" +dependencies = [ + "bitflags 2.10.0", + "block2 0.6.2", + "core-foundation", + "core-graphics", + "crossbeam-channel", + "dispatch", + "dlopen2", + "dpi", + "gdkwayland-sys", + "gdkx11-sys", + "gtk", + "jni", + "lazy_static", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "objc2 0.6.3", + "objc2-app-kit", + "objc2-foundation 0.3.2", + "once_cell", + "parking_lot", + "raw-window-handle", + "scopeguard", + "tao-macros", + "unicode-segmentation", + "url", + "windows 0.61.3", + "windows-core 0.61.2", + "windows-version", + "x11-dl", +] + +[[package]] +name = "tao-macros" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4e16beb8b2ac17db28eab8bca40e62dbfbb34c0fcdc6d9826b11b7b5d047dfd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[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.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9871670c6711f50fddd4e20350be6b9dd6e6c2b5d77d8ee8900eb0d58cd837a" +dependencies = [ + "anyhow", + "bytes", + "cookie", + "dirs", + "dunce", + "embed_plist", + "getrandom 0.3.4", + "glob", + "gtk", + "heck 0.5.0", + "http", + "jni", + "libc", + "log", + "mime", + "muda", + "objc2 0.6.3", + "objc2-app-kit", + "objc2-foundation 0.3.2", + "objc2-ui-kit", + "objc2-web-kit", + "percent-encoding", + "plist", + "raw-window-handle", + "reqwest", + "serde", + "serde_json", + "serde_repr", + "serialize-to-javascript", + "swift-rs", + "tauri-build", + "tauri-macros", + "tauri-runtime", + "tauri-runtime-wry", + "tauri-utils", + "thiserror 2.0.17", + "tokio", + "tray-icon", + "url", + "webkit2gtk", + "webview2-com", + "window-vibrancy", + "windows 0.61.3", +] + +[[package]] +name = "tauri-build" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a924b6c50fe83193f0f8b14072afa7c25b7a72752a2a73d9549b463f5fe91a38" +dependencies = [ + "anyhow", + "cargo_toml", + "dirs", + "glob", + "heck 0.5.0", + "json-patch", + "schemars 0.8.22", + "semver", + "serde", + "serde_json", + "tauri-utils", + "tauri-winres", + "toml 0.9.8", + "walkdir", +] + +[[package]] +name = "tauri-codegen" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c1fe64c74cc40f90848281a90058a6db931eb400b60205840e09801ee30f190" +dependencies = [ + "base64 0.22.1", + "brotli", + "ico", + "json-patch", + "plist", + "png 0.17.16", + "proc-macro2", + "quote", + "semver", + "serde", + "serde_json", + "sha2", + "syn 2.0.108", + "tauri-utils", + "thiserror 2.0.17", + "time", + "url", + "uuid", + "walkdir", +] + +[[package]] +name = "tauri-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "260c5d2eb036b76206b9fca20b7be3614cfd21046c5396f7959e0e64a4b07f2f" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.108", + "tauri-codegen", + "tauri-utils", +] + +[[package]] +name = "tauri-plugin" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "076c78a474a7247c90cad0b6e87e593c4c620ed4efdb79cbe0214f0021f6c39d" +dependencies = [ + "anyhow", + "glob", + "plist", + "schemars 0.8.22", + "serde", + "serde_json", + "tauri-utils", + "toml 0.9.8", + "walkdir", +] + +[[package]] +name = "tauri-plugin-opener" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c26b72571d25dee25667940027114e60f569fc3974f8cefbe50c2cbc5fd65e3b" +dependencies = [ + "dunce", + "glob", + "objc2-app-kit", + "objc2-foundation 0.3.2", + "open", + "schemars 0.8.22", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "thiserror 2.0.17", + "url", + "windows 0.61.3", + "zbus", +] + +[[package]] +name = "tauri-plugin-process" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55511a7bf6cd70c8767b02c97bf8134fa434daf3926cfc1be0a0f94132d165a" +dependencies = [ + "tauri", + "tauri-plugin", +] + +[[package]] +name = "tauri-runtime" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9368f09358496f2229313fccb37682ad116b7f46fa76981efe116994a0628926" +dependencies = [ + "cookie", + "dpi", + "gtk", + "http", + "jni", + "objc2 0.6.3", + "objc2-ui-kit", + "objc2-web-kit", + "raw-window-handle", + "serde", + "serde_json", + "tauri-utils", + "thiserror 2.0.17", + "url", + "webkit2gtk", + "webview2-com", + "windows 0.61.3", +] + +[[package]] +name = "tauri-runtime-wry" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "929f5df216f5c02a9e894554401bcdab6eec3e39ec6a4a7731c7067fc8688a93" +dependencies = [ + "gtk", + "http", + "jni", + "log", + "objc2 0.6.3", + "objc2-app-kit", + "objc2-foundation 0.3.2", + "once_cell", + "percent-encoding", + "raw-window-handle", + "softbuffer", + "tao", + "tauri-runtime", + "tauri-utils", + "url", + "webkit2gtk", + "webview2-com", + "windows 0.61.3", + "wry", +] + +[[package]] +name = "tauri-utils" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b8bbe426abdbf52d050e52ed693130dbd68375b9ad82a3fb17efb4c8d85673" +dependencies = [ + "anyhow", + "brotli", + "cargo_metadata", + "ctor", + "dunce", + "glob", + "html5ever", + "http", + "infer", + "json-patch", + "kuchikiki", + "log", + "memchr", + "phf 0.11.3", + "proc-macro2", + "quote", + "regex", + "schemars 0.8.22", + "semver", + "serde", + "serde-untagged", + "serde_json", + "serde_with", + "swift-rs", + "thiserror 2.0.17", + "toml 0.9.8", + "url", + "urlpattern", + "uuid", + "walkdir", +] + +[[package]] +name = "tauri-winres" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd21509dd1fa9bd355dc29894a6ff10635880732396aa38c0066c1e6c1ab8074" +dependencies = [ + "embed-resource", + "toml 0.9.8", +] + +[[package]] +name = "tempfile" +version = "3.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "tendril" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0" +dependencies = [ + "futf", + "mac", + "utf-8", +] + +[[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.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +dependencies = [ + "thiserror-impl 2.0.17", +] + +[[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.108", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "tiff" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af9605de7fee8d9551863fd692cce7637f548dbd9db9180fcc07ccc6d26c336f" +dependencies = [ + "fax", + "flate2", + "half", + "quick-error", + "weezl", + "zune-jpeg", +] + +[[package]] +name = "time" +version = "0.3.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b" + +[[package]] +name = "time-macros" +version = "0.2.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "tinyvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2 0.6.1", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "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 = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" +dependencies = [ + "indexmap 2.12.0", + "serde_core", + "serde_spanned 1.0.3", + "toml_datetime 0.7.3", + "toml_parser", + "toml_writer", + "winnow 0.7.13", +] + +[[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 = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" +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.12.0", + "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.12.0", + "serde", + "serde_spanned 0.6.9", + "toml_datetime 0.6.3", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.23.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" +dependencies = [ + "indexmap 2.12.0", + "toml_datetime 0.7.3", + "toml_parser", + "winnow 0.7.13", +] + +[[package]] +name = "toml_parser" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" +dependencies = [ + "winnow 0.7.13", +] + +[[package]] +name = "toml_writer" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +dependencies = [ + "bitflags 2.10.0", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[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.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "tracing-core" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "tracing-tracy" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eaa1852afa96e0fe9e44caa53dc0bd2d9d05e0f2611ce09f97f8677af56e4ba" +dependencies = [ + "tracing-core", + "tracing-subscriber", + "tracy-client", +] + +[[package]] +name = "tracy-client" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef54005d3d760186fd662dad4b7bb27ecd5531cdef54d1573ebd3f20a9205ed7" +dependencies = [ + "loom", + "once_cell", + "tracy-client-sys", +] + +[[package]] +name = "tracy-client-sys" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "319c70195101a93f56db4c74733e272d720768e13471f400c78406a326b172b0" +dependencies = [ + "cc", + "windows-targets 0.52.6", +] + +[[package]] +name = "tray-icon" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d5572781bee8e3f994d7467084e1b1fd7a93ce66bd480f8156ba89dee55a2b" +dependencies = [ + "crossbeam-channel", + "dirs", + "libappindicator", + "muda", + "objc2 0.6.3", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "once_cell", + "png 0.17.16", + "serde", + "thiserror 2.0.17", + "windows-sys 0.60.2", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "uds_windows" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" +dependencies = [ + "memoffset", + "tempfile", + "winapi", +] + +[[package]] +name = "unic-char-property" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" +dependencies = [ + "unic-char-range", +] + +[[package]] +name = "unic-char-range" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" + +[[package]] +name = "unic-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" + +[[package]] +name = "unic-ucd-ident" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e230a37c0381caa9219d67cf063aa3a375ffed5bf541a452db16e744bdab6987" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-version" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" +dependencies = [ + "unic-common", +] + +[[package]] +name = "unicode-ident" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[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.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "urlpattern" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70acd30e3aa1450bc2eece896ce2ad0d178e9c079493819301573dae3c37ba6d" +dependencies = [ + "regex", + "serde", + "unic-ucd-ident", + "url", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" +dependencies = [ + "getrandom 0.3.4", + "js-sys", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "v_frame" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2" +dependencies = [ + "aligned-vec", + "num-traits", + "wasm-bindgen", +] + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "variadics_please" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b6d82be61465f97d42bd1d15bf20f3b0a3a0905018f38f9d6f6962055b0b5c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "version-compare" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[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.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "551f88106c6d5e7ccc7cd9a16f312dd3b5d36ea8b4954304657d5dfba115d4a0" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 2.0.108", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +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-tracing" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ab253baf6d3772bbdb37a0966b67d37ab80657ccd1a084b4d7b3de3232375d" +dependencies = [ + "tracing", + "tracing-log", + "tracing-subscriber", + "wasm-bindgen", +] + +[[package]] +name = "web-streams" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c4d5dbf19463c4b65e974303d453cc11991873c7a4a4953214f791d73303a2" +dependencies = [ + "thiserror 2.0.17", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "web-sys" +version = "0.3.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a1f95c0d03a47f4ae1f7a64643a6bb97465d9b740f0fa8f90ea33915c99a9a1" +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-transport" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "949abdcee8e610e9c46927dfb37b66d391f237cab0c528c691c414a86022eacd" +dependencies = [ + "bytes", + "thiserror 2.0.17", + "url", + "web-transport-quinn", + "web-transport-wasm", +] + +[[package]] +name = "web-transport-proto" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "974fa1e325e6cc5327de8887f189a441fcff4f8eedcd31ec87f0ef0cc5283fbc" +dependencies = [ + "bytes", + "http", + "thiserror 2.0.17", + "url", +] + +[[package]] +name = "web-transport-quinn" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88e34f06fb4cd4760dc9bd348199d1759eed196ebb4ce0aa40b3817069cc58e8" +dependencies = [ + "bytes", + "futures", + "http", + "log", + "quinn", + "rustls", + "rustls-native-certs", + "thiserror 2.0.17", + "tokio", + "url", + "web-transport-proto", + "web-transport-trait", +] + +[[package]] +name = "web-transport-trait" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07665af67c56637c938425911b9b5a4f6aaea45709354e4656b9e2de45768c68" +dependencies = [ + "bytes", +] + +[[package]] +name = "web-transport-wasm" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad29c7643076549c927a579e52c32f8b59b8763c129c611e2ee181d4911e350" +dependencies = [ + "bytes", + "js-sys", + "thiserror 2.0.17", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-streams", + "web-sys", +] + +[[package]] +name = "webkit2gtk" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76b1bc1e54c581da1e9f179d0b38512ba358fb1af2d634a1affe42e37172361a" +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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62daa38afc514d1f8f12b8693d30d5993ff77ced33ce30cd04deebc267a6d57c" +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-root-certs" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d651ec480de84b762e7be71e6efa7461699c19d9e2c272c8d93455f567786e" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "webpki-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.3", +] + +[[package]] +name = "webpki-roots" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b130c0d2d49f8b6889abc456e795e82525204f27c42cf767cf0d7734e089b8" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "webview2-com" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ba622a989277ef3886dd5afb3e280e3dd6d974b766118950a08f8f678ad6a4" +dependencies = [ + "webview2-com-macros", + "webview2-com-sys", + "windows 0.61.3", + "windows-core 0.61.2", + "windows-implement 0.60.2", + "windows-interface 0.59.3", +] + +[[package]] +name = "webview2-com-macros" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d228f15bba3b9d56dde8bddbee66fa24545bd17b48d5128ccf4a8742b18e431" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "webview2-com-sys" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36695906a1b53a3bf5c4289621efedac12b73eeb0b89e7e1a89b517302d5d75c" +dependencies = [ + "thiserror 2.0.17", + "windows 0.61.3", + "windows-core 0.61.2", +] + +[[package]] +name = "weezl" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a751b3277700db47d3e574514de2eced5e54dc8a5436a3bf7a0b248b2cee16f3" + +[[package]] +name = "wgpu-types" +version = "26.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca7a8d8af57c18f57d393601a1fb159ace8b2328f1b6b5f80893f7d672c9ae2" +dependencies = [ + "bitflags 2.10.0", + "bytemuck", + "js-sys", + "log", + "serde", + "thiserror 2.0.17", + "web-sys", +] + +[[package]] +name = "whoami" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d" +dependencies = [ + "libredox", + "wasite", + "web-sys", +] + +[[package]] +name = "widestring" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471" + +[[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.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9bec5a31f3f9362f2258fd0e9c9dd61a9ca432e7306cc78c444258f0dce9a9c" +dependencies = [ + "objc2 0.6.3", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "raw-window-handle", + "windows-sys 0.59.0", + "windows-version", +] + +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-implement 0.48.0", + "windows-interface 0.48.0", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows" +version = "0.61.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" +dependencies = [ + "windows-collections", + "windows-core 0.61.2", + "windows-future", + "windows-link 0.1.3", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" +dependencies = [ + "windows-core 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement 0.60.2", + "windows-interface 0.59.3", + "windows-link 0.1.3", + "windows-result 0.3.4", + "windows-strings 0.4.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement 0.60.2", + "windows-interface 0.59.3", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", +] + +[[package]] +name = "windows-future" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" +dependencies = [ + "windows-core 0.61.2", + "windows-link 0.1.3", + "windows-threading", +] + +[[package]] +name = "windows-implement" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[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.108", +] + +[[package]] +name = "windows-interface" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[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.108", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[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.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" +dependencies = [ + "windows-core 0.61.2", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link 0.1.3", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link 0.2.1", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link 0.1.3", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link 0.2.1", +] + +[[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.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[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.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link 0.2.1", +] + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +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 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link 0.2.1", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link 0.1.3", +] + +[[package]] +name = "windows-version" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4060a1da109b9d0326b7262c8e12c84df67cc0dbc9e33cf49e01ccc2eb63631" +dependencies = [ + "windows-link 0.2.1", +] + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[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_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[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_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[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_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[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_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[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.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[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 = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a1a57ff50e9b408431e8f97d5456f2807f8eb2a2cd79b06068fc87f8ecf189" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "winreg" +version = "0.55.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb5a765337c50e9ec252c2069be9bf91c7df47afb103b642ba3a53bf8101be97" +dependencies = [ + "cfg-if", + "windows-sys 0.59.0", +] + +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "wmi" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daffb44abb7d2e87a1233aa17fdbde0d55b890b32a23a1f908895b87fa6f1a00" +dependencies = [ + "chrono", + "futures", + "log", + "serde", + "thiserror 1.0.69", + "windows 0.48.0", +] + +[[package]] +name = "writeable" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" + +[[package]] +name = "wry" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728b7d4c8ec8d81cab295e0b5b8a4c263c0d41a785fb8f8c4df284e5411140a2" +dependencies = [ + "base64 0.22.1", + "block2 0.6.2", + "cookie", + "crossbeam-channel", + "dirs", + "dpi", + "dunce", + "gdkx11", + "gtk", + "html5ever", + "http", + "javascriptcore-rs", + "jni", + "kuchikiki", + "libc", + "ndk", + "objc2 0.6.3", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-ui-kit", + "objc2-web-kit", + "once_cell", + "percent-encoding", + "raw-window-handle", + "sha2", + "soup3", + "tao-macros", + "thiserror 2.0.17", + "url", + "webkit2gtk", + "webkit2gtk-sys", + "webview2-com", + "windows 0.61.3", + "windows-core 0.61.2", + "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 = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + +[[package]] +name = "yoke" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", + "synstructure", +] + +[[package]] +name = "zbus" +version = "5.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b622b18155f7a93d1cd2dc8c01d2d6a44e08fb9ebb7b3f9e6ed101488bad6c91" +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", + "nix", + "ordered-stream", + "serde", + "serde_repr", + "tracing", + "uds_windows", + "uuid", + "windows-sys 0.61.2", + "winnow 0.7.13", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "5.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cdb94821ca8a87ca9c298b5d1cbd80e2a8b67115d99f6e4551ac49e42b6a314" +dependencies = [ + "proc-macro-crate 3.4.0", + "proc-macro2", + "quote", + "syn 2.0.108", + "zbus_names", + "zvariant", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97" +dependencies = [ + "serde", + "static_assertions", + "winnow 0.7.13", + "zvariant", +] + +[[package]] +name = "zerocopy" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zerotrie" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.16+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748" +dependencies = [ + "cc", + "pkg-config", +] + +[[package]] +name = "zune-core" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "zune-jpeg" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ce2c8a9384ad323cf564b67da86e21d3cfdff87908bc1223ed5c99bc792713" +dependencies = [ + "zune-core", +] + +[[package]] +name = "zvariant" +version = "5.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2be61892e4f2b1772727be11630a62664a1826b62efa43a6fe7449521cb8744c" +dependencies = [ + "endi", + "enumflags2", + "serde", + "winnow 0.7.13", + "zvariant_derive", + "zvariant_utils", +] + +[[package]] +name = "zvariant_derive" +version = "5.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da58575a1b2b20766513b1ec59d8e2e68db2745379f961f86650655e862d2006" +dependencies = [ + "proc-macro-crate 3.4.0", + "proc-macro2", + "quote", + "syn 2.0.108", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6949d142f89f6916deca2232cf26a8afacf2b9fdc35ce766105e104478be599" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 2.0.108", + "winnow 0.7.13", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..7457c00 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,97 @@ +[workspace] +members = [ + "crates/borders-core", + "crates/borders-desktop", + "crates/borders-wasm", + "crates/borders-server", +] +resolver = "2" + +[workspace.package] +authors = ["Xevion"] +edition = "2024" +version = "0.6.1" + + +# Enable a small amount of optimization in the dev profile. +[profile.dev] +opt-level = 1 +codegen-units = 256 + +# Enable a large amount of optimization in the dev profile for dependencies. +[profile.dev.package."*"] +opt-level = 3 + +[profile.dev.package.borders-desktop] +opt-level = 1 + +[profile.dev.package.borders-wasm] +opt-level = 1 + +[profile.dev.package.borders-server] +opt-level = 1 + +[profile.dev.package.borders-core] +opt-level = 1 + +# Optimized profile for mutant testing - prioritizes compile speed over runtime performance +[profile.mutant] +inherits = "dev" +opt-level = 1 +debug = 0 # No debug info for faster builds +codegen-units = 256 # Maximum parallelism +incremental = false # Faster for many clean builds (mutant testing) + +# Keep dependency optimizations from dev profile +[profile.mutant.package."*"] +opt-level = 3 + +[profile.mutant.package.borders-desktop] +opt-level = 1 + +[profile.mutant.package.borders-wasm] +opt-level = 1 + +[profile.mutant.package.borders-server] +opt-level = 1 + +[profile.mutant.package.borders-core] +opt-level = 1 + +# Enable more optimization in the release profile at the cost of compile time. +[profile.release] +# Compile the entire crate as one unit. +# Slows compile times, marginal improvements. +codegen-units = 1 +# Do a second optimization pass over the entire program, including dependencies. +# Slows compile times, marginal improvements. +lto = "thin" + + +# Development profile for WASM builds (faster compile times) +[profile.wasm-dev] +inherits = "dev" +opt-level = 1 +panic = "abort" + +# Size optimization profile for WASM builds +[profile.wasm-release] +inherits = "release" +incremental = false +debug = false +opt-level = "s" # Optimize for size +lto = true # Link-time optimization +codegen-units = 1 # Single codegen unit for better optimization +panic = "abort" # Smaller panic implementation +strip = true # Remove debug symbols + +# Performance profiling profile for WASM builds (fast with debug symbols) +[profile.wasm-debug] +inherits = "release" +incremental = false +debug = true # Preserve debug symbols for profiling +opt-level = 3 # Full optimization for performance +lto = "thin" # Link-time optimization without aggressive stripping +codegen-units = 1 # Single codegen unit for better optimization +panic = "abort" # Smaller panic implementation +strip = "none" # Keep all debug symbols diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..3a2ad46 --- /dev/null +++ b/Justfile @@ -0,0 +1,175 @@ +set shell := ["powershell"] + +default: + just --list + +format: + @cargo fmt --all + +# Run benchmarks with optional arguments +# Examples: +# just bench # Run all benchmarks +# just bench border_updates # Run specific benchmark +# just bench -- --save-baseline my_baseline # Save baseline +bench *args: + @cargo bench -p borders-core {{ args }} + +# Run tests with custom nextest arguments +# Examples: +# just test # Run all tests +# just test -p borders-core # Run tests in specific package +# just test --test spawn_tests # Run specific test binary +# just test -- test_name_pattern # Filter by test name +# just test -- --skip pattern # Skip tests matching pattern +test *args: + @cargo nextest run --no-fail-fast --workspace --hide-progress-bar --failure-output final {{ args }} + +# Run tests matching a pattern (filters by test name) +# Add -p to run in specific package, or --workspace for all packages +test-filter pattern *args: + @cargo nextest run --no-fail-fast --hide-progress-bar --failure-output final {{ args }} -- {{ pattern }} + +# Skip tests matching a pattern +# Add -p to run in specific package, or --workspace for all packages +test-skip pattern *args: + @cargo nextest run --no-fail-fast --hide-progress-bar --failure-output final {{ args }} -- --skip {{ pattern }} + +# Generate coverage reports (HTML, JSON, LCOV) +# Examples: +# just coverage # Generate all formats in coverage/ directory +# just coverage --open # Generate and open HTML report in browser +coverage *args: + @cargo llvm-cov nextest -p borders-core --no-fail-fast {{ args }} + @if (-not (Test-Path coverage)) { New-Item -ItemType Directory -Path coverage | Out-Null } + @cargo llvm-cov report --html --output-dir coverage/html + @cargo llvm-cov report --json --output-path coverage/coverage.json + @cargo llvm-cov report --lcov --output-path coverage/lcov.info + @echo "Coverage reports generated in coverage/ directory:" + @echo " - HTML: coverage/html/index.html" + @echo " - JSON: coverage/coverage.json" + @echo " - LCOV: coverage/lcov.info" + +# Open coverage HTML report in browser +coverage-open: + @if (Test-Path coverage/html/index.html) { \ + Invoke-Item coverage/html/index.html; \ + } else { \ + echo "Coverage report not found. Run 'just coverage' first."; \ + exit 1; \ + } + +mutants *args: + cargo mutants -p borders-core --gitignore true --caught --unviable {{ args }} + +mutants-next *args: + cargo mutants -p borders-core --gitignore true --iterate --caught --unviable {{ args }} + +check: + @echo "Running clippy (native)..." + @cargo clippy --all-targets --all-features --workspace -- -D warnings + @echo "Running cargo check (native)..." + @cargo check --all-targets --all-features --workspace + @echo "Running clippy (wasm32-unknown-unknown)..." + @cargo clippy --target wasm32-unknown-unknown --all-features -p borders-wasm -- -D warnings + @echo "Running cargo check (wasm32-unknown-unknown)..." + @cargo check --target wasm32-unknown-unknown --all-features -p borders-wasm + @echo "Running cargo machete..." + @cargo machete --with-metadata + @echo "All checks passed" + +check-ts: + @just _wasm-build wasm-dev + @echo "Running frontend checks..." + @pnpm run -C frontend check + +fix: + @echo "Running cargo fix..." + cargo fix --all-targets --all-features --workspace --allow-dirty + +wasm-dev: wasm-dev-build + pnpm -C frontend dev:browser --port 1421 + +# Build WASM with the specified profile (wasm-dev or wasm-release) +_wasm-build profile: + @$profile = "{{ profile }}"; \ + $wasmFile = "target/wasm32-unknown-unknown/$profile/borders_wasm.wasm"; \ + $pkgJs = "pkg/borders.js"; \ + $pkgWasm = "pkg/borders_bg.wasm"; \ + $frontendPkgJs = "frontend/pkg/borders.js"; \ + $frontendPkgWasm = "frontend/pkg/borders_bg.wasm"; \ + $beforeTime = if (Test-Path $wasmFile) { (Get-Item $wasmFile).LastWriteTime } else { $null }; \ + cargo build -p borders-wasm --profile $profile --target wasm32-unknown-unknown; \ + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }; \ + $afterTime = if (Test-Path $wasmFile) { (Get-Item $wasmFile).LastWriteTime } else { $null }; \ + $wasRebuilt = ($beforeTime -eq $null) -or ($afterTime -ne $beforeTime); \ + $pkgExists = (Test-Path $pkgJs) -and (Test-Path $pkgWasm); \ + $frontendPkgExists = (Test-Path $frontendPkgJs) -and (Test-Path $frontendPkgWasm); \ + $isRelease = $profile -eq "wasm-release"; \ + $isDebug = $profile -eq "wasm-debug"; \ + $needsFrontendBuild = $isRelease -or $isDebug; \ + if ($wasRebuilt -or -not $pkgExists -or ($needsFrontendBuild -and -not $frontendPkgExists)) { \ + Write-Host "Running wasm-bindgen..."; \ + wasm-bindgen --out-dir pkg --out-name borders --target web $wasmFile; \ + if ($isRelease) { \ + Write-Host "Running wasm-opt -Oz..."; \ + wasm-opt -Oz --enable-bulk-memory --enable-threads --all-features pkg/borders_bg.wasm -o pkg/borders_bg.wasm; \ + } elseif ($isDebug) { \ + Write-Host "Running wasm-opt -O3 with debug info..."; \ + wasm-opt -O3 --debuginfo --enable-bulk-memory --enable-threads --all-features pkg/borders_bg.wasm -o pkg/borders_bg.wasm; \ + }; \ + } else { \ + Write-Host "WASM not rebuilt, skipping wasm-bindgen"; \ + } \ + New-Item -ItemType Directory -Force -Path 'frontend/pkg' | Out-Null; \ + Copy-Item -Recurse -Force 'pkg/*' 'frontend/pkg/'; \ + if ($needsFrontendBuild) { \ + Write-Host "Running frontend build..."; \ + if ($isDebug) { \ + $env:VITE_DEBUG_BUILD = "true"; \ + }; \ + pnpm -C frontend build:browser; \ + if ($isDebug) { \ + Remove-Item env:VITE_DEBUG_BUILD; \ + }; \ + }; \ + +# Development WASM build, unoptimized +wasm-dev-build: + @just _wasm-build wasm-dev + +# Release WASM build, optimized +wasm-release-build: + @just _wasm-build wasm-release + +wasm-release: wasm-release-build + @echo "Visit http://localhost:8080 to play" + caddy file-server --listen :8080 --root frontend/dist/browser/client --browse + +# Debug WASM build, optimized with debug symbols +wasm-debug-build: + @just _wasm-build wasm-debug + +wasm-debug: wasm-debug-build + @echo "Visit http://localhost:8080 to play" + caddy file-server --listen :8080 --root frontend/dist/browser/client --browse + +desktop-release: + cargo tauri build + target/release/borders-desktop.exe + +desktop-dev: + cargo tauri build --debug + target/debug/borders-desktop.exe + +dev *args: + cargo tauri dev {{ args }} + +# Run release manager CLI (handles setup specially) +release *args: + @$firstArg = "{{ args }}".Split()[0]; \ + if ($firstArg -eq "setup") { \ + Write-Host "Installing release manager dependencies..."; \ + pnpm install -C scripts/release-manager; \ + } else { \ + pnpm --silent -C scripts/release-manager exec tsx cli.ts {{ args }}; \ + } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f948eca --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright Ā© 2025 Ryan Walters. All Rights Reserved. + +This software and associated documentation files (the "Software") are proprietary +and confidential. Unauthorized copying, modification, distribution, or use of this +Software, via any medium, is strictly prohibited without the express written +permission of the copyright holder. + +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/crates/borders-core/Cargo.toml b/crates/borders-core/Cargo.toml new file mode 100644 index 0000000..16e8c7e --- /dev/null +++ b/crates/borders-core/Cargo.toml @@ -0,0 +1,96 @@ +[package] +name = "borders-core" +version.workspace = true +edition.workspace = true +authors.workspace = true + +[package.metadata.cargo-machete] +ignored = ["serde_bytes", "chrono"] + +[features] +default = ["bevy_debug"] +bevy_debug = ["bevy_ecs/detailed_trace"] + +[dependencies] +bevy_ecs = { version = "0.17", default-features = false, features = ["std"] } +flume = "0.11" +futures = "0.3" +futures-lite = "2.6.1" +glam = { version = "0.30", features = ["serde", "rkyv"] } +rkyv = { version = "0.8", features = ["hashbrown-0_15"] } +hex = "0.4" +hmac = "0.12" +image = "0.25" +once_cell = "1.20" +quanta = "0.12" +rand = "0.9" +serde = { version = "1.0", features = ["derive", "rc"] } +slotmap = "1.0" +serde_bytes = "0.11" +serde_json = "1.0" +sha2 = "0.10" +tracing = "0.1" +web-transport = "0.9" +extension-traits = "2.0" + +# Target-specific dependencies to keep WASM builds compatible +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +tokio = { version = "1", features = [ + "rt-multi-thread", + "macros", + "time", + "io-util", + "sync", +] } +reqwest = { version = "0.12", default-features = false, features = [ + "json", + "rustls-tls", + "brotli", + "gzip", + "deflate", + "zstd", +] } +hickory-resolver = { version = "0.25", features = [ + "tls-ring", + "https-ring", + "quic-ring", + "h3-ring", + "webpki-roots", +] } +uuid = { version = "1.11", features = ["v4", "serde"] } +machineid-rs = "1.2" +directories = "6.0" +ring = "0.17.14" +pem = "3.0.6" +sysinfo = "0.37" + +[target.'cfg(windows)'.dependencies] +winreg = "0.55" + +[target.'cfg(target_arch = "wasm32")'.dependencies] +tokio = { version = "1", features = ["rt", "macros", "time", "io-util"] } +reqwest = { version = "0.12", default-features = false, features = ["json"] } +uuid = { version = "1.11", features = ["v4", "serde", "js"] } +js-sys = "0.3" +wasm-bindgen = "0.2" +wasm-bindgen-futures = "0.4" +gloo-timers = { version = "0.3", features = ["futures"] } +web-sys = { version = "0.3", features = [ + "BroadcastChannel", + "MessageEvent", + "Navigator", + "Window", +] } + +[dev-dependencies] +assert2 = "0.3" +criterion = { version = "0.7", features = ["html_reports"] } +rstest = "0.23" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } + +[[bench]] +name = "game_benchmarks" +harness = false + +[build-dependencies] +chrono = "0.4" diff --git a/crates/borders-core/assets/maps/World.json b/crates/borders-core/assets/maps/World.json new file mode 100644 index 0000000..d4ff1ee --- /dev/null +++ b/crates/borders-core/assets/maps/World.json @@ -0,0 +1,76 @@ +{ + "tiles": [ + { + "color": "#000000", + "name": "Water", + "colorBase": "water", + "colorVariant": 4, + "conquerable": false, + "navigable": true + }, + { + "color": "#222222", + "name": "Water", + "colorBase": "water", + "colorVariant": 6, + "conquerable": false, + "navigable": true + }, + { + "color": "#555555", + "name": "Water", + "colorBase": "water", + "colorVariant": 12, + "conquerable": false, + "navigable": true + }, + { + "color": "#777777", + "name": "Water", + "colorBase": "water", + "colorVariant": 14, + "conquerable": false, + "navigable": true + }, + { + "color": "#999999", + "name": "Land", + "colorBase": "mountain", + "colorVariant": 5, + "conquerable": true, + "navigable": false, + "expansionCost": 80, + "expansionTime": 80 + }, + { + "color": "#BBBBBB", + "name": "Land", + "colorBase": "mountain", + "colorVariant": 9, + "conquerable": true, + "navigable": false, + "expansionCost": 70, + "expansionTime": 70 + }, + { + "color": "#DDDDDD", + "name": "Land", + "colorBase": "grass", + "colorVariant": 9, + "conquerable": true, + "navigable": false, + "expansionCost": 60, + "expansionTime": 60 + }, + { + "color": "#FFFFFF", + "name": "Land", + "colorBase": "grass", + "colorVariant": 6, + "conquerable": true, + "navigable": false, + "expansionCost": 50, + "expansionTime": 50 + } + ] +} diff --git a/crates/borders-core/assets/maps/World.png b/crates/borders-core/assets/maps/World.png new file mode 100644 index 0000000..cbaa74c Binary files /dev/null and b/crates/borders-core/assets/maps/World.png differ diff --git a/crates/borders-core/benches/game_benchmarks.rs b/crates/borders-core/benches/game_benchmarks.rs new file mode 100644 index 0000000..03d4a60 --- /dev/null +++ b/crates/borders-core/benches/game_benchmarks.rs @@ -0,0 +1,244 @@ +use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; +use std::hint::black_box; + +use borders_core::prelude::*; +use std::collections::{HashMap, HashSet}; + +/// Setup a game world with specified parameters +fn setup_game_world(map_size: u16, player_count: u16, tiles_per_player: usize) -> (World, Vec) { + let mut world = World::new(); + + // Initialize Time resources (required by many systems) + world.insert_resource(Time::default()); + world.insert_resource(FixedTime::from_seconds(0.1)); + + // Generate terrain - all conquerable for simplicity + let size = (map_size as usize) * (map_size as usize); + let terrain_data = vec![0x80u8; size]; // bit 7 = land/conquerable + let tiles = vec![1u8; size]; // all land tiles + + let tile_types = vec![TileType { name: "water".to_string(), color_base: "blue".to_string(), color_variant: 0, conquerable: false, navigable: true, expansion_time: 255, expansion_cost: 255 }, TileType { name: "land".to_string(), color_base: "green".to_string(), color_variant: 0, conquerable: true, navigable: false, expansion_time: 50, expansion_cost: 50 }]; + + let map_size_vec = U16Vec2::new(map_size, map_size); + let terrain_tile_map = TileMap::from_vec(map_size_vec, terrain_data); + let terrain = TerrainData { _manifest: MapManifest { map: MapMetadata { size: map_size_vec, num_land_tiles: size }, name: "Benchmark Map".to_string(), nations: Vec::new() }, terrain_data: terrain_tile_map, tiles, tile_types }; + + // Initialize TerritoryManager + let mut territory_manager = TerritoryManager::new(map_size_vec); + let conquerable_tiles = vec![true; size]; + territory_manager.reset(map_size_vec, &conquerable_tiles); + + // Create player entities and assign territories + let mut entity_map = NationEntityMap::default(); + let mut player_ids = Vec::new(); + + for i in 0..player_count { + let nation_id = if i == 0 { NationId::ZERO } else { NationId::new(i).unwrap() }; + player_ids.push(nation_id); + + let color = HSLColor::new((i as f32 * 137.5) % 360.0, 0.6, 0.5); + + let entity = world.spawn((nation_id, NationName(format!("Player {}", i)), NationColor(color), BorderTiles::default(), Troops(100.0), TerritorySize(0), ShipCount::default())).id(); + + entity_map.0.insert(nation_id, entity); + + // Assign tiles to this player + let start_y = (i as usize * tiles_per_player) / (map_size as usize); + let end_y = ((i as usize + 1) * tiles_per_player) / (map_size as usize); + + for y in start_y..end_y.min(map_size as usize) { + for x in 0..(map_size as usize).min(tiles_per_player) { + if y * (map_size as usize) + x < size { + territory_manager.conquer(U16Vec2::new(x as u16, y as u16), nation_id); + } + } + } + } + + // Insert core resources + world.insert_resource(entity_map); + world.insert_resource(territory_manager); + world.insert_resource(ActiveAttacks::new()); + world.insert_resource(terrain); + world.insert_resource(DeterministicRng::new(0xDEADBEEF)); + world.insert_resource(BorderCache::default()); + world.insert_resource(AttackControls::default()); + world.insert_resource(LocalPlayerContext::new(NationId::ZERO)); + world.insert_resource(SpawnPhase { active: false }); + + // Compute coastal tiles + let map_size_vec = U16Vec2::new(map_size, map_size); + let coastal_tiles = CoastalTiles::compute(world.resource::(), map_size_vec); + world.insert_resource(coastal_tiles); + + (world, player_ids) +} + +/// Get 4-directional neighbors (from game utils, inlined to avoid module issues) +fn neighbors(pos: U16Vec2, map_size: U16Vec2) -> impl Iterator { + let offsets = [ + glam::I16Vec2::new(0, 1), // North + glam::I16Vec2::new(1, 0), // East + glam::I16Vec2::new(0, -1), // South + glam::I16Vec2::new(-1, 0), // West + ]; + + offsets.into_iter().filter_map(move |offset| pos.checked_add_signed(offset).filter(|&n| n.x < map_size.x && n.y < map_size.y)) +} + +/// Update player borders (simplified version of the border system) +fn update_borders(world: &mut World) { + let (changed_tiles, map_size, tiles_by_owner) = { + let territory_manager = world.resource::(); + + let changed_tiles: HashSet = territory_manager.iter_changes().collect(); + if changed_tiles.is_empty() { + return; + } + + let map_size = U16Vec2::new(territory_manager.width(), territory_manager.height()); + + let mut affected_tiles = HashSet::with_capacity(changed_tiles.len() * 5); + for &tile in &changed_tiles { + affected_tiles.insert(tile); + affected_tiles.extend(neighbors(tile, map_size)); + } + + let mut tiles_by_owner: HashMap> = HashMap::new(); + for &tile in &affected_tiles { + if let Some(nation_id) = territory_manager.get_nation_id(tile) { + tiles_by_owner.entry(nation_id).or_default().insert(tile); + } + } + + (changed_tiles, map_size, tiles_by_owner) + }; + + let ownership_snapshot: HashMap> = { + let territory_manager = world.resource::(); + let mut snapshot = HashMap::new(); + for &tile in changed_tiles.iter() { + for neighbor in neighbors(tile, map_size) { + snapshot.entry(neighbor).or_insert_with(|| territory_manager.get_nation_id(neighbor)); + } + snapshot.insert(tile, territory_manager.get_nation_id(tile)); + } + snapshot + }; + + let mut nations_query = world.query::<(&NationId, &mut BorderTiles)>(); + for (nation_id, mut component_borders) in nations_query.iter_mut(world) { + let empty_set = HashSet::new(); + let player_tiles = tiles_by_owner.get(nation_id).unwrap_or(&empty_set); + + for &tile in player_tiles { + let is_border = neighbors(tile, map_size).any(|neighbor| ownership_snapshot.get(&neighbor).and_then(|&owner| owner) != Some(*nation_id)); + + if is_border { + component_borders.0.insert(tile); + } else { + component_borders.0.remove(&tile); + } + } + + for &tile in changed_tiles.iter() { + if ownership_snapshot.get(&tile).and_then(|&owner| owner) != Some(*nation_id) { + component_borders.0.remove(&tile); + } + } + } +} + +fn bench_border_updates(c: &mut Criterion) { + let mut group = c.benchmark_group("border_updates"); + + // Parameter: territory sizes (small, medium, large) + let configs = [ + ("small_10_tiles", 20, 2, 10), // 2 players, 10 tiles each + ("medium_100_tiles", 50, 5, 100), // 5 players, 100 tiles each + ("large_500_tiles", 100, 10, 500), // 10 players, 500 tiles each + ]; + + for (name, map_size, player_count, tiles_per_player) in configs { + group.bench_with_input(BenchmarkId::from_parameter(name), &name, |b, _| { + let (mut world, player_ids) = setup_game_world(map_size, player_count, tiles_per_player); + + // Simulate some territory changes + b.iter(|| { + // Change ownership of a few tiles to trigger border updates + let tiles_to_change = 5; + for i in 0..tiles_to_change { + let tile = U16Vec2::new(i as u16, i as u16); + let new_owner = player_ids[i % player_ids.len()]; + world.resource_mut::().conquer(tile, new_owner); + } + + update_borders(black_box(&mut world)); + + // Clear changes for next iteration + world.resource_mut::().clear_changes(); + }); + }); + } + + group.finish(); +} + +fn bench_turn_execution(c: &mut Criterion) { + let mut group = c.benchmark_group("turn_execution"); + + // Parameter: player counts + let player_counts = [10, 50, 101]; + + for player_count in player_counts { + group.bench_with_input(BenchmarkId::from_parameter(player_count), &player_count, |b, &count| { + b.iter(|| { + // Setup game state for each iteration + let (mut world, _player_ids) = setup_game_world(100, count, 50); + + // Simulate a turn with territory changes + let changes = 10; + for i in 0..changes { + let tile = U16Vec2::new((i * 5) as u16, (i * 5) as u16); + let owner_idx = i % (count as usize); + let owner = if owner_idx == 0 { NationId::ZERO } else { NationId::new(owner_idx as u16).unwrap() }; + world.resource_mut::().conquer(tile, owner); + } + + update_borders(black_box(&mut world)); + + // TODO: Add actual turn execution logic here when ready + // This currently only benchmarks territory changes + border updates + }); + }); + } + + group.finish(); +} + +// TODO: Add benchmark for territory expansion +// fn bench_territory_expansion(c: &mut Criterion) { +// // Benchmark territory growth/conquest operations +// // Parameters: different expansion patterns (linear, radial, etc.) +// } + +// TODO: Add benchmark for bot AI decision-making +// fn bench_bot_decisions(c: &mut Criterion) { +// // Benchmark AI decision performance with different territory sizes +// // Parameters: number of border tiles, number of viable targets +// } + +// TODO: Add benchmark for attack processing +// fn bench_attack_processing(c: &mut Criterion) { +// // Benchmark combat calculation and resolution +// // Parameters: number of simultaneous attacks +// } + +// TODO: Add benchmark for ship pathfinding +// fn bench_ship_pathfinding(c: &mut Criterion) { +// // Benchmark naval pathfinding algorithms +// // Parameters: map complexity, path length +// } + +criterion_group!(benches, bench_border_updates, bench_turn_execution); +criterion_main!(benches); diff --git a/crates/borders-core/build.rs b/crates/borders-core/build.rs new file mode 100644 index 0000000..01cc5b9 --- /dev/null +++ b/crates/borders-core/build.rs @@ -0,0 +1,74 @@ +use std::env; +use std::fs; +use std::path::PathBuf; + +fn main() { + // Get the workspace root (two levels up from borders-core) + let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + let workspace_root = manifest_dir.parent().unwrap().parent().unwrap(); + + // Determine if we're in production mode (CI or release profile) + let is_production = env::var("CI").is_ok() || env::var("PROFILE").map(|p| p == "release").unwrap_or(false); + + // Read git commit from .source-commit file + let source_commit_path = workspace_root.join(".source-commit"); + let git_commit = if source_commit_path.exists() { + match fs::read_to_string(&source_commit_path) { + Ok(content) => content.trim().to_string(), + Err(e) if is_production => { + panic!("Failed to read .source-commit file in production: {}", e); + } + Err(_) => "unknown".to_string(), + } + } else { + // Fallback to git command if file doesn't exist (local development) + let git_result = std::process::Command::new("git").args(["rev-parse", "HEAD"]).current_dir(workspace_root).output().ok().and_then(|output| if output.status.success() { String::from_utf8(output.stdout).ok() } else { None }).map(|s| s.trim().to_string()); + + match git_result { + Some(commit) => commit, + None if is_production => { + panic!("Failed to acquire git commit in production and .source-commit file does not exist"); + } + None => "unknown".to_string(), + } + }; + + // Determine build time based on environment + let build_time = if let Ok(epoch) = env::var("SOURCE_DATE_EPOCH") { + // Use provided timestamp for reproducible builds + match epoch.parse::().ok().and_then(|ts| chrono::DateTime::from_timestamp(ts, 0)).map(|dt| dt.to_rfc3339()) { + Some(time) => time, + None if is_production => { + panic!("Failed to parse SOURCE_DATE_EPOCH in production: {}", epoch); + } + None => "unknown".to_string(), + } + } else if env::var("CI").is_ok() { + // Generate fresh timestamp in CI + chrono::Utc::now().to_rfc3339() + } else { + // Static value for local development + "dev".to_string() + }; + + // Set environment variables for compile-time access + println!("cargo:rustc-env=BUILD_GIT_COMMIT={}", git_commit); + println!("cargo:rustc-env=BUILD_TIME={}", build_time); + + // Only re-run the build script when specific files change + println!("cargo:rerun-if-changed=build.rs"); + + // In CI, watch the .source-commit file if it exists + if source_commit_path.exists() { + println!("cargo:rerun-if-changed={}", source_commit_path.display()); + } + + // In local development, watch .git/HEAD to detect branch switches + // We intentionally don't watch the branch ref file to avoid spurious rebuilds + if env::var("CI").is_err() { + let git_head = workspace_root.join(".git").join("HEAD"); + if git_head.exists() { + println!("cargo:rerun-if-changed={}", git_head.display()); + } + } +} diff --git a/crates/borders-core/src/build_info.rs b/crates/borders-core/src/build_info.rs new file mode 100644 index 0000000..87f15f2 --- /dev/null +++ b/crates/borders-core/src/build_info.rs @@ -0,0 +1,21 @@ +//! Build metadata injected at compile time + +/// The version of the application from Cargo.toml +pub const VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// The git commit hash from .source-commit file or git command +pub const GIT_COMMIT: &str = env!("BUILD_GIT_COMMIT"); + +/// The build timestamp in RFC3339 format (UTC) +pub const BUILD_TIME: &str = env!("BUILD_TIME"); + +/// Get the git commit hash (short form, first 7 characters) +pub fn git_commit_short() -> &'static str { + let full = GIT_COMMIT; + if full.len() >= 7 { &full[..7] } else { full } +} + +/// Full build information formatted as a string +pub fn info() -> String { + format!("Iron Borders v{} ({})\nBuilt: {}", VERSION, git_commit_short(), BUILD_TIME) +} diff --git a/crates/borders-core/src/dns.rs b/crates/borders-core/src/dns.rs new file mode 100644 index 0000000..1aae76f --- /dev/null +++ b/crates/borders-core/src/dns.rs @@ -0,0 +1,98 @@ +//! Custom DNS resolver using Hickory DNS with DoH/DoT support. +//! +//! This module provides DNS over HTTPS (DoH) functionality for enhanced privacy, +//! with automatic fallback to system DNS if DoH is unavailable. + +use hickory_resolver::{ + TokioResolver, + config::{NameServerConfigGroup, ResolverConfig}, + name_server::TokioConnectionProvider, +}; +use once_cell::sync::OnceCell; +use std::net::SocketAddr; +use std::sync::Arc; +use tracing::{debug, warn}; + +/// Custom DNS resolver for reqwest that uses Hickory DNS with DoH/DoT support. +/// +/// This resolver is configured to use Cloudflare's DNS over HTTPS (1.1.1.1). +/// DNS over HTTPS encrypts DNS queries, preventing eavesdropping and tampering. +/// +/// The resolver is lazily initialized within the async context to ensure +/// it's created within the Tokio runtime. +#[derive(Clone, Default)] +pub struct HickoryDnsResolver { + /// Lazily initialized resolver to ensure it's created within Tokio runtime context + state: Arc>, +} + +impl HickoryDnsResolver { + pub fn new() -> Self { + Self { state: Arc::new(OnceCell::new()) } + } + + /// Initialize the Hickory DNS resolver with Cloudflare DoH configuration + fn init_resolver() -> Result> { + let mut group: NameServerConfigGroup = NameServerConfigGroup::google(); + group.merge(NameServerConfigGroup::cloudflare()); + group.merge(NameServerConfigGroup::quad9()); + group.merge(NameServerConfigGroup::google()); + + let mut config = ResolverConfig::new(); + for server in group.iter() { + config.add_name_server(server.clone()); + } + + // Use tokio() constructor which properly integrates with current Tokio runtime + let resolver = TokioResolver::builder_with_config(config, TokioConnectionProvider::default()).build(); + + debug!("DNS resolver initialized with Cloudflare DoH"); + Ok(resolver) + } +} + +/// Fallback to system DNS when DoH is unavailable +async fn fallback_to_system_dns(name: &str) -> Result + Send>, Box> { + use tokio::net::lookup_host; + + let addrs: Vec = lookup_host(format!("{}:443", name)) + .await? + .map(|mut addr| { + addr.set_port(0); + addr + }) + .collect(); + + debug!("Resolved '{}' via system DNS ({} addresses)", name, addrs.len()); + Ok(Box::new(addrs.into_iter())) +} + +impl reqwest::dns::Resolve for HickoryDnsResolver { + fn resolve(&self, name: reqwest::dns::Name) -> reqwest::dns::Resolving { + let resolver_state = self.state.clone(); + let name_str = name.as_str().to_string(); + + Box::pin(async move { + // Get or initialize the resolver within the async context (Tokio runtime) + let resolver = match resolver_state.get_or_try_init(Self::init_resolver) { + Ok(r) => r, + Err(e) => { + warn!("Failed to initialize DoH resolver: {}, using system DNS", e); + return fallback_to_system_dns(&name_str).await; + } + }; + + // Try Hickory DNS first (DoH) + match resolver.lookup_ip(format!("{}.", name_str)).await { + Ok(lookup) => { + let addrs: reqwest::dns::Addrs = Box::new(lookup.into_iter().map(|ip| SocketAddr::new(ip, 0))); + Ok(addrs) + } + Err(e) => { + warn!("DoH lookup failed for '{}': {}, falling back to system DNS", name_str, e); + fallback_to_system_dns(&name_str).await + } + } + }) + } +} diff --git a/crates/borders-core/src/game/ai/bot.rs b/crates/borders-core/src/game/ai/bot.rs new file mode 100644 index 0000000..ad84a2d --- /dev/null +++ b/crates/borders-core/src/game/ai/bot.rs @@ -0,0 +1,454 @@ +use std::collections::{HashMap, HashSet}; + +use bevy_ecs::prelude::*; +use glam::{IVec2, U16Vec2}; +use rand::rngs::StdRng; +use rand::{Rng, SeedableRng}; + +use crate::game::SpawnPoint; +use crate::game::core::action::GameAction; +use crate::game::core::constants::bot::*; +use crate::game::core::utils::neighbors; +use crate::game::terrain::data::TerrainData; +use crate::game::world::{NationId, TerritoryManager}; + +/// Bot AI component - stores per-bot state for decision making +#[derive(Component)] +pub struct Bot { + pub last_action_tick: u64, + pub action_cooldown: u64, +} + +impl Default for Bot { + fn default() -> Self { + Self::new() + } +} + +impl Bot { + pub fn new() -> Self { + Self::with_seed(0) + } + + /// Create a bot with deterministic initial cooldown based on seed + pub fn with_seed(seed: u64) -> Self { + let mut rng = StdRng::seed_from_u64(seed); + // Ensure initial cooldown is at least ACTION_COOLDOWN_MIN to allow borders to be calculated + let cooldown = rng.random_range(ACTION_COOLDOWN_MIN..INITIAL_COOLDOWN_MAX); + Self { last_action_tick: 0, action_cooldown: cooldown } + } + + /// Sample a random subset of border tiles to reduce O(n) iteration cost + fn sample_border_tiles(border_tiles: &HashSet, border_count: usize, rng: &mut StdRng) -> Vec { + if border_count <= MAX_BORDER_SAMPLES { + border_tiles.iter().copied().collect() + } else { + // Random sampling without replacement using Fisher-Yates + let mut border_vec: Vec = border_tiles.iter().copied().collect(); + + // Partial Fisher-Yates shuffle for first MAX_BORDER_SAMPLES elements + for i in 0..MAX_BORDER_SAMPLES { + let j = rng.random_range(i..border_count); + border_vec.swap(i, j); + } + + border_vec.truncate(MAX_BORDER_SAMPLES); + border_vec + } + } + + /// Tick the bot AI - now deterministic based on turn number and RNG seed + #[allow(clippy::too_many_arguments)] + pub fn tick(&mut self, turn_number: u64, nation_id: NationId, troops: &crate::game::Troops, territory_manager: &TerritoryManager, terrain: &TerrainData, nation_borders: &HashMap>, rng_seed: u64) -> Option { + // Only act every few ticks + if turn_number < self.last_action_tick + self.action_cooldown { + return None; + } + + self.last_action_tick = turn_number; + + // Deterministic RNG based on turn number, nation ID, and global seed + let seed = rng_seed.wrapping_add(turn_number).wrapping_add(nation_id.get() as u64); + let mut rng = StdRng::seed_from_u64(seed); + self.action_cooldown = rng.random_range(ACTION_COOLDOWN_MIN..ACTION_COOLDOWN_MAX); + + // Decide action: expand into wilderness or attack a neighbor + let action_type: f32 = rng.random(); + + if action_type < EXPAND_PROBABILITY { + // Expand into wilderness (60% chance) + self.expand_wilderness(nation_id, troops, territory_manager, terrain, nation_borders, &mut rng) + } else { + // Attack a neighbor (40% chance) + self.attack_neighbor(nation_id, troops, territory_manager, nation_borders, &mut rng) + } + } + + /// Expand into unclaimed territory + fn expand_wilderness(&self, nation_id: NationId, troops: &crate::game::Troops, territory_manager: &TerritoryManager, terrain: &TerrainData, nation_borders: &HashMap>, rng: &mut StdRng) -> Option { + let border_tiles = nation_borders.get(&nation_id)?; + let border_count = border_tiles.len(); + + let size = territory_manager.size(); + let tiles_to_check = Self::sample_border_tiles(border_tiles, border_count, rng); + + // Find a valid, unclaimed neighbor tile to attack + for &tile in &tiles_to_check { + if let Some(_neighbor) = neighbors(tile, size).find(|&neighbor| !territory_manager.has_owner(neighbor) && terrain.is_conquerable(neighbor)) { + let troop_percentage: f32 = rng.random_range(EXPAND_TROOPS_MIN..EXPAND_TROOPS_MAX); + let troop_count = (troops.0 * troop_percentage).floor() as u32; + return Some(GameAction::Attack { target: None, troops: troop_count }); + } + } + + None + } + + /// Attack a neighboring nation + fn attack_neighbor(&self, nation_id: NationId, troops: &crate::game::Troops, territory_manager: &TerritoryManager, nation_borders: &HashMap>, rng: &mut StdRng) -> Option { + let border_tiles = nation_borders.get(&nation_id)?; + let border_count = border_tiles.len(); + + // Find neighboring nations + let mut neighboring_nations = HashSet::new(); + let size = territory_manager.size(); + + let tiles_to_check = Self::sample_border_tiles(border_tiles, border_count, rng); + + for &tile in &tiles_to_check { + neighboring_nations.extend(neighbors(tile, size).filter_map(|neighbor| { + let ownership = territory_manager.get_ownership(neighbor); + ownership.nation_id().filter(|&other_nation_id| other_nation_id != nation_id) + })); + } + + if neighboring_nations.is_empty() { + return None; + } + + // Pick a random neighbor to attack + let neighbor_count = neighboring_nations.len(); + let target_id = neighboring_nations.into_iter().nth(rng.random_range(0..neighbor_count)).unwrap(); + + let troop_percentage: f32 = rng.random_range(ATTACK_TROOPS_MIN..ATTACK_TROOPS_MAX); + let troop_count = (troops.0 * troop_percentage).floor() as u32; + Some(GameAction::Attack { target: Some(target_id), troops: troop_count }) + } +} + +/// Spatial grid for fast spawn collision detection +/// Divides map into cells for O(1) neighbor queries instead of O(n) +struct SpawnGrid { + grid: HashMap>, + cell_size: f32, +} + +impl SpawnGrid { + fn new(cell_size: f32) -> Self { + Self { grid: HashMap::new(), cell_size } + } + + fn insert(&mut self, pos: U16Vec2) { + let cell = self.pos_to_cell(pos); + self.grid.entry(cell).or_default().push(pos); + } + + #[inline] + fn pos_to_cell(&self, pos: U16Vec2) -> IVec2 { + let x = pos.x as f32 / self.cell_size; + let y = pos.y as f32 / self.cell_size; + IVec2::new(x as i32, y as i32) + } + + fn has_nearby(&self, pos: U16Vec2, radius: f32) -> bool { + let cell = self.pos_to_cell(pos); + let cell_radius = (radius / self.cell_size).ceil() as i32; + + for dx in -cell_radius..=cell_radius { + for dy in -cell_radius..=cell_radius { + let check_cell = cell + IVec2::new(dx, dy); + if let Some(positions) = self.grid.get(&check_cell) { + for &existing_pos in positions { + if calculate_position_distance(pos, existing_pos) < radius { + return true; + } + } + } + } + } + false + } +} + +/// Calculate Euclidean distance between two positions +#[inline] +fn calculate_position_distance(pos1: U16Vec2, pos2: U16Vec2) -> f32 { + pos1.as_vec2().distance(pos2.as_vec2()) +} + +/// Calculate initial bot spawn positions (first pass) +/// +/// Places bots at random valid locations with adaptive spacing. +/// Uses spatial grid for O(1) neighbor checks and adaptively reduces +/// minimum distance when map becomes crowded. +/// +/// Guarantees all bots spawn (no silent drops). This is deterministic based on rng_seed. +/// +/// Returns Vec for each bot +pub fn calculate_initial_spawns(bot_nation_ids: &[NationId], territory_manager: &TerritoryManager, terrain: &TerrainData, rng_seed: u64) -> Vec { + let _guard = tracing::trace_span!("calculate_initial_spawns", bot_count = bot_nation_ids.len()).entered(); + + let size = territory_manager.size(); + + let mut spawn_positions = Vec::with_capacity(bot_nation_ids.len()); + let mut grid = SpawnGrid::new(MIN_SPAWN_DISTANCE); + let mut current_min_distance = MIN_SPAWN_DISTANCE; + + for (bot_index, &nation_id) in bot_nation_ids.iter().enumerate() { + // Deterministic RNG for spawn location + let seed = rng_seed.wrapping_add(nation_id.get() as u64).wrapping_add(bot_index as u64); + let mut rng = StdRng::seed_from_u64(seed); + + let mut placed = false; + + // Try with current minimum distance + while !placed && current_min_distance >= ABSOLUTE_MIN_DISTANCE { + // Phase 1: Random sampling + for _ in 0..SPAWN_RANDOM_ATTEMPTS { + let tile_pos = U16Vec2::new(rng.random_range(0..size.x), rng.random_range(0..size.y)); + + // Check if tile is valid land + if territory_manager.has_owner(tile_pos) || !terrain.is_conquerable(tile_pos) { + continue; + } + + // Check distance using spatial grid (O(1) instead of O(n)) + if !grid.has_nearby(tile_pos, current_min_distance) { + spawn_positions.push(SpawnPoint::new(nation_id, tile_pos)); + grid.insert(tile_pos); + placed = true; + break; + } + } + + // Phase 2: Grid-guided fallback (if random sampling failed) + if !placed { + // Try a systematic grid search with stride + let stride = (current_min_distance * SPAWN_GRID_STRIDE_FACTOR) as u16; + let mut attempts = 0; + for y in (0..size.y).step_by(stride.max(1) as usize) { + for x in (0..size.x).step_by(stride.max(1) as usize) { + let tile_pos = U16Vec2::new(x, y); + + if territory_manager.has_owner(tile_pos) || !terrain.is_conquerable(tile_pos) { + continue; + } + + if !grid.has_nearby(tile_pos, current_min_distance) { + spawn_positions.push(SpawnPoint::new(nation_id, tile_pos)); + grid.insert(tile_pos); + placed = true; + break; + } + + attempts += 1; + if attempts > SPAWN_GRID_MAX_ATTEMPTS { + break; + } + } + if placed { + break; + } + } + } + + // Phase 3: Reduce minimum distance and retry + if !placed { + current_min_distance *= DISTANCE_REDUCTION_FACTOR; + if bot_index % 100 == 0 && current_min_distance < MIN_SPAWN_DISTANCE { + tracing::debug!("Adaptive spawn: reduced min_distance to {:.1} for bot {}", current_min_distance, bot_index); + } + } + } + + // Final fallback: Place at any valid land tile (guaranteed) + if !placed { + for _ in 0..SPAWN_FALLBACK_ATTEMPTS { + let tile_pos = U16Vec2::new(rng.random_range(0..size.x), rng.random_range(0..size.y)); + if !territory_manager.has_owner(tile_pos) && terrain.is_conquerable(tile_pos) { + spawn_positions.push(SpawnPoint::new(nation_id, tile_pos)); + grid.insert(tile_pos); + placed = true; + tracing::warn!("Bot {} placed with fallback (no distance constraint)", nation_id); + break; + } + } + } + + if !placed { + tracing::error!("Failed to place bot {} after all attempts", nation_id); + } + } + + spawn_positions +} + +/// Recalculate bot spawns considering human nation positions (second pass) +/// +/// For any bot that is too close to a human nation spawn, find a new position. +/// Uses adaptive algorithm with grid acceleration to guarantee all displaced +/// bots find new positions. This maintains determinism while ensuring proper spawn spacing. +/// +/// Arguments: +/// - `initial_bot_spawns`: Bot positions from first pass +/// - `human_spawns`: Human nation spawn positions +/// - `territory_manager`: For checking valid tiles +/// - `terrain`: For checking conquerable tiles +/// - `rng_seed`: For deterministic relocation +/// +/// Returns updated Vec with relocated bots +pub fn recalculate_spawns_with_players(initial_bot_spawns: Vec, player_spawns: &[SpawnPoint], territory_manager: &TerritoryManager, terrain: &TerrainData, rng_seed: u64) -> Vec { + let _guard = tracing::trace_span!("recalculate_spawns_with_players", bot_count = initial_bot_spawns.len(), human_count = player_spawns.len()).entered(); + + let size = territory_manager.size(); + + // Build spatial grid to track occupied spawn locations + // Contains all human nation spawns plus bots that don't need relocation + // Enables O(1) distance checks instead of O(n) iteration + let mut grid = SpawnGrid::new(MIN_SPAWN_DISTANCE); + for spawn in player_spawns { + grid.insert(spawn.tile); + } + + // Partition bots into two groups: + // 1. Bots that are far enough from all human nation spawns (keep as-is) + // 2. Bots that violate MIN_SPAWN_DISTANCE from any human nation (need relocation) + let mut bots_to_relocate = Vec::new(); + let mut final_spawns = Vec::new(); + + for spawn in initial_bot_spawns { + let mut needs_relocation = false; + + for human_spawn in player_spawns { + if calculate_position_distance(spawn.tile, human_spawn.tile) < MIN_SPAWN_DISTANCE { + needs_relocation = true; + break; + } + } + + if needs_relocation { + bots_to_relocate.push(spawn.nation); + } else { + // Bot is valid - add to final list and mark space as occupied + final_spawns.push(spawn); + grid.insert(spawn.tile); + } + } + + // Relocate displaced bots using a three-phase adaptive algorithm: + // Phase 1: Random sampling (fast, works well when space is available) + // Phase 2: Grid-based systematic search (fallback when random fails) + // Phase 3: Adaptive distance reduction (progressively relax spacing constraints) + // + // This adaptively reduces spacing as the map fills up, ensuring all bots + // eventually find placement even on crowded maps + let mut current_min_distance = MIN_SPAWN_DISTANCE; + + for (reloc_index, &nation_id) in bots_to_relocate.iter().enumerate() { + // Deterministic RNG with a different seed offset to avoid reusing original positions + let seed = rng_seed.wrapping_add(nation_id.get() as u64).wrapping_add(0xDEADBEEF); + let mut rng = StdRng::seed_from_u64(seed); + + let mut placed = false; + + // Keep trying with progressively relaxed distance constraints + while !placed && current_min_distance >= ABSOLUTE_MIN_DISTANCE { + // Phase 1: Random sampling - try random tiles until we find a valid spot + // Fast and evenly distributed when sufficient space exists + for _ in 0..SPAWN_RANDOM_ATTEMPTS { + let tile_pos = U16Vec2::new(rng.random_range(0..size.x), rng.random_range(0..size.y)); + + // Skip tiles that are already owned or unconquerable (water/mountains) + if territory_manager.has_owner(tile_pos) || !terrain.is_conquerable(tile_pos) { + continue; + } + + // Check if this tile is far enough from all existing spawns + // Grid lookup is O(1) - only checks cells within radius, not all spawns + if !grid.has_nearby(tile_pos, current_min_distance) { + final_spawns.push(SpawnPoint::new(nation_id, tile_pos)); + grid.insert(tile_pos); + placed = true; + break; + } + } + + // Phase 2: Grid-based systematic search + // When random sampling fails (map is crowded), use a strided grid search + // to systematically check evenly-spaced candidate positions + if !placed { + // Stride determines spacing between checked positions (larger = faster but might miss spots) + let stride = (current_min_distance * SPAWN_GRID_STRIDE_FACTOR) as u16; + let mut attempts = 0; + + for y in (0..size.y).step_by(stride.max(1) as usize) { + for x in (0..size.x).step_by(stride.max(1) as usize) { + let tile_pos = U16Vec2::new(x, y); + + if territory_manager.has_owner(tile_pos) || !terrain.is_conquerable(tile_pos) { + continue; + } + + if !grid.has_nearby(tile_pos, current_min_distance) { + final_spawns.push(SpawnPoint::new(nation_id, tile_pos)); + grid.insert(tile_pos); + placed = true; + break; + } + + // Prevent infinite loops on maps with very little valid space + attempts += 1; + if attempts > SPAWN_GRID_MAX_ATTEMPTS { + break; + } + } + if placed { + break; + } + } + } + + // Phase 3: Adaptive distance reduction + // If both random and grid search failed, the map is too crowded + // Reduce minimum spacing requirement and retry both phases + if !placed { + current_min_distance *= DISTANCE_REDUCTION_FACTOR; + if reloc_index % 50 == 0 && current_min_distance < MIN_SPAWN_DISTANCE { + tracing::debug!("Adaptive relocation: reduced min_distance to {:.1} for bot {}", current_min_distance, reloc_index); + } + } + } + + // Final fallback: ignore all distance constraints + // Guarantees placement even on extremely crowded maps + // Simply finds any valid conquerable tile + if !placed { + for _ in 0..SPAWN_FALLBACK_ATTEMPTS { + let tile_pos = U16Vec2::new(rng.random_range(0..size.x), rng.random_range(0..size.y)); + if !territory_manager.has_owner(tile_pos) && terrain.is_conquerable(tile_pos) { + final_spawns.push(SpawnPoint::new(nation_id, tile_pos)); + grid.insert(tile_pos); + placed = true; + tracing::warn!("Bot {} relocated with fallback (no distance constraint)", nation_id); + break; + } + } + } + + if !placed { + tracing::error!("Failed to relocate bot {} after all attempts", nation_id); + } + } + + final_spawns +} diff --git a/crates/borders-core/src/game/ai/mod.rs b/crates/borders-core/src/game/ai/mod.rs new file mode 100644 index 0000000..ac341d8 --- /dev/null +++ b/crates/borders-core/src/game/ai/mod.rs @@ -0,0 +1,2 @@ +pub mod bot; +pub use bot::*; diff --git a/crates/borders-core/src/game/builder.rs b/crates/borders-core/src/game/builder.rs new file mode 100644 index 0000000..6d8d3d8 --- /dev/null +++ b/crates/borders-core/src/game/builder.rs @@ -0,0 +1,361 @@ +use bevy_ecs::prelude::*; +use bevy_ecs::schedule::IntoScheduleConfigs; +use glam::U16Vec2; +use rand::rngs::StdRng; +use rand::{Rng, SeedableRng}; +use std::sync::{Arc, atomic::AtomicBool}; +use tracing::{debug, info}; + +use crate::game::{Game, NationId, ai::bot, core::constants, input}; +use crate::{game, networking, time, ui}; + +/// Builder for Game initialization with unified configuration +/// +/// Provides a fluent API for constructing fully-initialized Game instances with: +/// - Map/terrain configuration (required) +/// - Nations configuration (bots, local player) +/// - Network mode (required) +/// - Optional frontend integration +/// - Time system configuration +/// - Spawn phase settings +/// - Deterministic RNG seeding +/// - System toggle for unit tests +/// +/// # Examples +/// +/// Production desktop game: +/// ```ignore +/// let game = GameBuilder::new() +/// .with_map(terrain_data) +/// .with_bots(500) +/// .with_local_player(NationId::ZERO) +/// .with_network(NetworkMode::Local) +/// .with_frontend(TauriTransport::new()) +/// .build(); +/// ``` +/// +/// Integration test: +/// ```ignore +/// let terrain = MapBuilder::new(100, 100).all_conquerable().build(); +/// let game = GameBuilder::new() +/// .with_map(terrain) +/// .with_bots(20) +/// .with_network(NetworkMode::Local) +/// .with_spawn_phase(None) +/// .with_rng_seed(42) +/// .build(); +/// ``` +pub struct GameBuilder { + // Required + terrain_data: Option>, + network_mode: Option, + + // Optional with defaults + bot_count: u32, + local_player_id: Option, + frontend_transport: Option>, + tick_rate: u32, + clock: Option, + spawn_timeout_secs: Option, + rng_seed: Option, + enable_systems: bool, + + // Input system (Arc allows sharing across game instances on desktop) + input_queue: Arc, +} + +impl GameBuilder { + /// Create a new GameBuilder with default configuration + /// + /// Defaults: + /// - bot_count: 0 + /// - local_player_id: None (headless) + /// - tick_rate: 10 TPS + /// - clock: real-time clock + /// - spawn_timeout_secs: Some(60) + /// - rng_seed: random + /// - enable_systems: true + pub fn new() -> Self { + Self { terrain_data: None, network_mode: None, bot_count: 0, local_player_id: None, frontend_transport: None, tick_rate: 10, clock: None, spawn_timeout_secs: Some(60), rng_seed: None, enable_systems: true, input_queue: Arc::new(game::InputQueue::new()) } + } + + /// Add frontend transport for UI integration + pub fn with_frontend(mut self, transport: impl ui::FrontendTransport + 'static) -> Self { + self.frontend_transport = Some(Arc::new(transport)); + self + } + + /// Set terrain/map data (required) + pub fn with_map(mut self, terrain: Arc) -> Self { + self.terrain_data = Some(terrain); + self + } + + /// Set number of bot nations (default: 0) + pub fn with_bots(mut self, count: u32) -> Self { + self.bot_count = count; + self + } + + /// Set local player ID (default: None for headless) + pub fn with_local_player(mut self, id: NationId) -> Self { + self.local_player_id = Some(id); + self + } + + /// Set network mode (required) + pub fn with_network(mut self, mode: networking::NetworkMode) -> Self { + self.network_mode = Some(mode); + self + } + + /// Set tick rate in ticks per second (default: 10 TPS) + pub fn with_tick_rate(mut self, tps: u32) -> Self { + self.tick_rate = tps; + self + } + + /// Set custom clock for time system (default: real-time clock) + pub fn with_clock(mut self, clock: time::Clock) -> Self { + self.clock = Some(clock); + self + } + + /// Set spawn phase timeout in seconds (default: Some(60), None to skip spawn phase) + pub fn with_spawn_phase(mut self, timeout_secs: Option) -> Self { + self.spawn_timeout_secs = timeout_secs; + self + } + + /// Set RNG seed for deterministic gameplay (default: random) + pub fn with_rng_seed(mut self, seed: u64) -> Self { + self.rng_seed = Some(seed); + self + } + + /// Enable or disable systems (default: true, set to false for unit tests) + pub fn with_systems(mut self, enable: bool) -> Self { + self.enable_systems = enable; + self + } + + /// Get a sender for platforms to send input events + /// + /// Platforms should call this method to get a flume Sender that can be used + /// to send InputEvents into the game's input queue. The queue is automatically + /// processed at the start of each frame during Game::update(). + pub fn input_sender(&self) -> flume::Sender { + self.input_queue.sender() + } + + /// Use an existing input queue instead of creating a new one + /// + /// This allows platforms to create the input queue once and reuse it across + /// multiple game instances (e.g., after QuitGame/StartGame cycles on desktop). + pub fn with_input_queue(mut self, queue: Arc) -> Self { + self.input_queue = queue; + self + } + + /// Build and initialize a Game instance + pub fn build(self) -> Game { + let terrain_data = self.terrain_data.expect("Map/terrain data is required - call .with_map()"); + let network_mode = self.network_mode.expect("Network mode is required - call .with_network()"); + + info!("Creating Game with GameBuilder..."); + + let mut game = Game::new_internal(); + + let time = if let Some(clock) = self.clock { time::Time::with_clock(clock, 0) } else { time::Time::new() }; + game.insert_resource(time); + game.insert_resource(time::FixedTime::from_seconds(1.0 / self.tick_rate as f64)); + + let map_size = terrain_data.size(); + let _guard = tracing::trace_span!( + "game_initialization", + map_size = ?map_size, + ) + .entered(); + + let conquerable_tiles: Vec = (0..map_size.y) + .flat_map(|y| { + let terrain = terrain_data.clone(); + (0..map_size.x).map(move |x| terrain.is_conquerable(U16Vec2::new(x, y))) + }) + .collect(); + + let client_player_id = self.local_player_id.unwrap_or(NationId::ZERO); + let player_count = if self.local_player_id.is_some() { 1 } else { 0 }; + let bot_count_usize = self.bot_count as usize; + let nation_count = player_count + bot_count_usize; + + let rng_seed = self.rng_seed.unwrap_or_else(rand::random::); + let mut rng = StdRng::seed_from_u64(rng_seed); + + let mut nation_metadata = Vec::new(); + let hue_offset = rng.random_range(0.0..360.0); + + for i in 0..nation_count { + let is_human = i < player_count; + let nation_id = NationId::new(i as u16).expect("valid player ID"); + + let hue = (nation_id.get() as f32 * constants::colors::GOLDEN_ANGLE + hue_offset) % 360.0; + let saturation = rng.random_range(constants::colors::SATURATION_MIN..=constants::colors::SATURATION_MAX); + let lightness = rng.random_range(constants::colors::LIGHTNESS_MIN..=constants::colors::LIGHTNESS_MAX); + let color = game::HSLColor::new(hue, saturation, lightness); + + let name = if is_human { if player_count == 1 { "Player".to_string() } else { format!("Player {}", i + 1) } } else { format!("Bot {}", i - player_count + 1) }; + + nation_metadata.push((nation_id, name, color)); + } + + let mut territory_manager = game::TerritoryManager::new(map_size); + territory_manager.reset(map_size, &conquerable_tiles); + debug!("Territory manager initialized with {} tiles", conquerable_tiles.len()); + + let mut active_attacks = game::ActiveAttacks::new(); + active_attacks.init(); + + let bot_ids: Vec = nation_metadata.iter().skip(player_count).map(|(id, _, _)| *id).collect(); + let initial_bot_spawns = bot::calculate_initial_spawns(&bot_ids, &territory_manager, &terrain_data, rng_seed); + + if initial_bot_spawns.len() < bot_count_usize { + tracing::warn!("Only {} of {} bots were able to spawn - map may be too small or bot count too high", initial_bot_spawns.len(), bot_count_usize); + } + + let mut nation_entity_map = game::NationEntityMap::default(); + let initial_territory_size = 0; + + for (nation_id, name, color) in &nation_metadata { + let is_bot = bot_ids.contains(nation_id); + + let entity = if is_bot { + let bot_seed = rng_seed.wrapping_add(nation_id.get() as u64); + game.world_mut().spawn((bot::Bot::with_seed(bot_seed), *nation_id, game::NationName(name.clone()), game::NationColor(*color), game::BorderTiles::default(), game::Troops(constants::nation::INITIAL_TROOPS), game::TerritorySize(initial_territory_size), game::ships::ShipCount::default())).id() + } else { + game.world_mut().spawn((*nation_id, game::NationName(name.clone()), game::NationColor(*color), game::BorderTiles::default(), game::Troops(constants::nation::INITIAL_TROOPS), game::TerritorySize(initial_territory_size), game::ships::ShipCount::default())).id() + }; + + nation_entity_map.0.insert(*nation_id, entity); + } + + let coastal_tiles = game::CoastalTiles::compute(&terrain_data, map_size); + + let world = game.world_mut(); + world.insert_resource(nation_entity_map); + world.insert_resource(territory_manager); + world.insert_resource(active_attacks); + world.insert_resource(terrain_data.as_ref().clone()); + world.insert_resource(coastal_tiles); + world.insert_resource(game::SpawnManager::new(initial_bot_spawns.clone(), rng_seed)); + world.insert_resource(game::ShipIdCounter::new()); + world.insert_resource(game::DeterministicRng::new(rng_seed)); + world.insert_resource(game::LocalPlayerContext::new(client_player_id)); + + // Initialize CurrentTurn with turn 0 - this resource must always exist + world.insert_resource(game::CurrentTurn::new(networking::Turn { turn_number: 0, intents: Vec::new() })); + + let skip_spawn_phase = self.spawn_timeout_secs.is_none(); + let spawn_timeout_secs_f32 = self.spawn_timeout_secs.unwrap_or(60) as f32; + + world.insert_resource(game::SpawnTimeout::new(spawn_timeout_secs_f32)); + debug!("SpawnTimeout initialized ({} seconds)", spawn_timeout_secs_f32); + + world.insert_resource(game::SpawnPhase { active: !skip_spawn_phase }); + + let (turn_tx, turn_rx) = flume::unbounded(); + world.insert_resource(networking::server::LocalTurnServerHandle { paused: Arc::new(AtomicBool::new(!skip_spawn_phase)), running: Arc::new(AtomicBool::new(true)) }); + world.insert_resource(networking::server::TurnReceiver { turn_rx }); + world.insert_resource(networking::server::TurnGenerator::new(turn_tx)); + + if self.enable_systems { + let _guard = tracing::debug_span!("game_plugin_build").entered(); + + game.add_message::().add_message::().add_message::().add_message::().add_message::(); + + game.add_message::().add_message::().add_message::().add_message::().add_message::().add_message::().add_message::().add_message::(); + + game.init_resource::().init_resource::().init_resource::().init_resource::().init_resource::().init_resource::().init_resource::(); + game.init_resource::().init_resource::().init_resource::().init_resource::(); + + match &network_mode { + networking::NetworkMode::Local => { + let _guard = tracing::trace_span!("network_setup", mode = "local").entered(); + info!("Initializing game in Local mode"); + + let (tracked_intent_tx, tracked_intent_rx) = flume::unbounded(); + let (_placeholder_tx, placeholder_rx) = flume::unbounded(); + + let backend = networking::client::LocalBackend::new(tracked_intent_tx, placeholder_rx, NationId::ZERO); + let connection = networking::client::Connection::new_local(backend); + + game.insert_resource(connection).insert_resource(networking::client::IntentReceiver { rx: tracked_intent_rx }); + } + #[cfg(not(target_arch = "wasm32"))] + networking::NetworkMode::Remote { server_address: _ } => { + unimplemented!("Remote networking temporarily disabled"); + } + } + + game.add_systems(game::Update, input::input_processor_system); + + game.add_systems(game::Update, game::systems::manage_spawn_phase_system); + + game.add_systems(game::Update, (game::systems::update_current_turn_system, game::systems::process_nation_income_system).chain()); + + game.add_systems(game::Update, (game::systems::process_and_apply_actions_system, game::systems::tick_attacks_system, game::systems::handle_spawns_system, game::launch_ship_system).chain().after(game::systems::update_current_turn_system)); + + game.add_systems(game::Update, (game::update_ships_system, game::handle_ship_arrivals_system, game::check_local_player_outcome, game::update_nation_borders_system).chain().after(game::launch_ship_system)); + + game.add_systems(game::Update, (ui::emit_leaderboard_snapshot_system, ui::emit_attacks_update_system, ui::emit_ships_update_system, ui::emit_nation_highlight_system)); + + game.add_systems(game::Update, ui::protocol::handle_frontend_messages_system); + + game.add_systems(game::Update, (input::handle_tile_clicked_system, input::handle_camera_action_system, input::handle_ui_action_system).after(input::input_processor_system)); + + game.add_systems(game::Update, networking::server::generate_turns_system.before(networking::server::poll_turns_system)); + + match &network_mode { + networking::NetworkMode::Local => { + game.add_systems(game::Update, (networking::server::poll_turns_system.before(game::systems::update_current_turn_system), networking::client::send_intent_system)); + } + #[cfg(not(target_arch = "wasm32"))] + networking::NetworkMode::Remote { .. } => {} + } + + game.add_systems(game::Last, (game::clear_territory_changes_system, game::systems::turn_cleanup_system).chain()); + + if let Some(transport) = self.frontend_transport { + let _guard = tracing::trace_span!("frontend_plugin_build").entered(); + + game.insert_resource(ui::RenderBridge::new(transport)); + + game.add_systems(game::Update, (ui::send_initial_render_data, ui::stream_territory_deltas, ui::stream_spawn_preview_deltas).chain().after(game::systems::update_nation_borders_system)); + + game.add_systems(game::Update, (ui::emit_backend_messages_system, ui::ingest_frontend_messages_system)); + } + } + + game.input_queue = Some(self.input_queue); + + if self.enable_systems { + game.run_startup(); + game.finish(); + } + + info!("Game created and initialized successfully"); + game + } +} + +impl Default for GameBuilder { + fn default() -> Self { + Self::new() + } +} + +/// Resource to track previous spawn state for incremental updates +#[derive(Resource, Default)] +pub struct PreviousSpawnState { + pub spawns: Vec, +} diff --git a/crates/borders-core/src/game/combat/active.rs b/crates/borders-core/src/game/combat/active.rs new file mode 100644 index 0000000..23bd4db --- /dev/null +++ b/crates/borders-core/src/game/combat/active.rs @@ -0,0 +1,375 @@ +/// Active attacks management +/// +/// This module manages all ongoing attacks in the game. It provides efficient +/// lookup and coordination of attacks, ensuring proper merging of attacks on +/// the same target and handling counter-attacks. +use std::collections::{HashMap, HashSet}; + +use bevy_ecs::prelude::*; +use glam::U16Vec2; +use slotmap::{SlotMap, new_key_type}; + +new_key_type! { + /// Unique key for identifying attacks in the SlotMap + pub struct AttackKey; +} + +use super::executor::{AttackConfig, AttackExecutor}; +use crate::game::NationId; +use crate::game::ai::bot::Bot; +use crate::game::core::rng::DeterministicRng; +use crate::game::entities::{NationEntityMap, TerritorySize, Troops}; +use crate::game::terrain::TerrainData; +use crate::game::world::TerritoryManager; + +/// Index structure for efficient attack lookups +/// +/// Maintains multiple indices for O(1) lookups by different criteria. +/// All methods maintain index consistency automatically - you cannot +/// accidentally update one index without updating the others. +struct AttackIndex { + /// Maps each pair of nations to the on-going attacks between them + /// Multiple attacks can exist between same pair (islands, ship landings, etc.) + nation_index: HashMap<(NationId, NationId), HashSet>, + + /// Maps each nation to the unclaimed attack it has scheduled, if any + /// Each nation can only have one on-going unclaimed attack at a time + unclaimed_index: HashMap, + + /// Maps each nation to the on-going attacks it is involved in + /// A nation can have multiple on-going attacks with the same target. + nation_attack_list: HashMap>, + + /// Maps each nation to the on-going attacks it is targeted by + /// A nation can have multiple on-going attacks from the same attacker. + target_attack_list: HashMap>, +} + +impl AttackIndex { + fn new() -> Self { + Self { nation_index: HashMap::new(), unclaimed_index: HashMap::new(), nation_attack_list: HashMap::new(), target_attack_list: HashMap::new() } + } + + fn clear(&mut self) { + self.nation_index.clear(); + self.unclaimed_index.clear(); + self.nation_attack_list.clear(); + self.target_attack_list.clear(); + } + + /// Get existing unclaimed attack for a nation + fn get_unclaimed_attack(&self, nation_id: NationId) -> Option { + self.unclaimed_index.get(&nation_id).copied() + } + + /// Get first existing attack on a target (for merging troops) + fn get_existing_attack(&self, nation_id: NationId, target_id: NationId) -> Option { + self.nation_index.get(&(nation_id, target_id))?.iter().next().copied() + } + + /// Check if counter-attacks exist (opposite direction) + fn has_counter_attacks(&self, nation_id: NationId, target_id: NationId) -> bool { + self.nation_index.get(&(target_id, nation_id)).is_some_and(|set| !set.is_empty()) + } + + /// Get first counter-attack key (for resolution) + fn get_counter_attack(&self, nation_id: NationId, target_id: NationId) -> Option { + self.nation_index.get(&(target_id, nation_id))?.iter().next().copied() + } + + /// Get all attacks where nation is attacker + fn get_attacks_by_nation(&self, nation: NationId) -> Option<&HashSet> { + self.nation_attack_list.get(&nation) + } + + /// Get all attacks where nation is target + fn get_attacks_on_nation(&self, nation: NationId) -> Option<&HashSet> { + self.target_attack_list.get(&nation) + } + + /// Add a Nation-vs-Nation attack to all indices atomically + fn add_nation_attack(&mut self, source: NationId, target: NationId, key: AttackKey) { + // Invariant: Cannot attack yourself + if source == target { + tracing::error!( + nation_id = %source, + attack_key = ?key, + "Attempted to add self-attack to index (invariant violation)" + ); + return; + } + + self.nation_index.entry((source, target)).or_default().insert(key); + self.nation_attack_list.entry(source).or_default().insert(key); + self.target_attack_list.entry(target).or_default().insert(key); + } + + /// Add an unclaimed territory attack to all indices atomically + fn add_unclaimed_attack(&mut self, nation: NationId, key: AttackKey) { + self.unclaimed_index.insert(nation, key); + self.nation_attack_list.entry(nation).or_default().insert(key); + } + + /// Remove a Nation-vs-Nation attack from all indices atomically + fn remove_nation_attack(&mut self, source: NationId, target: NationId, key: AttackKey) { + if let Some(attack_set) = self.nation_attack_list.get_mut(&source) { + attack_set.remove(&key); + } + if let Some(attack_set) = self.target_attack_list.get_mut(&target) { + attack_set.remove(&key); + } + if let Some(attack_set) = self.nation_index.get_mut(&(source, target)) { + attack_set.remove(&key); + } + } + + /// Remove an unclaimed territory attack from all indices atomically + fn remove_unclaimed_attack(&mut self, nation: NationId, key: AttackKey) { + self.unclaimed_index.remove(&nation); + if let Some(attack_set) = self.nation_attack_list.get_mut(&nation) { + attack_set.remove(&key); + } + } +} + +/// Manages all active attacks in the game +/// +/// This resource tracks ongoing attacks and provides efficient lookup +/// by attacker/target relationships. Attacks progress over multiple turns +/// until they run out of troops or conquerable tiles. +/// +/// Uses SlotMap for stable keys - no index shifting needed on removal. +/// Uses AttackIndex for consistent multi-index management. +#[derive(Resource)] +pub struct ActiveAttacks { + attacks: SlotMap, + index: AttackIndex, + next_attack_id: u64, +} + +impl Default for ActiveAttacks { + fn default() -> Self { + Self::new() + } +} + +impl ActiveAttacks { + pub fn new() -> Self { + Self { attacks: SlotMap::with_key(), index: AttackIndex::new(), next_attack_id: 0 } + } + + /// Initialize the attack handler + pub fn init(&mut self) { + self.attacks.clear(); + self.index.clear(); + self.next_attack_id = 0; + } + + /// Schedule an attack on unclaimed territory + /// + /// If an attack on unclaimed territory already exists for this nation, + /// the troops are added to it and borders are expanded. + #[allow(clippy::too_many_arguments)] + pub fn schedule_unclaimed(&mut self, nation_id: NationId, troops: f32, border_tiles: Option<&HashSet>, territory_manager: &TerritoryManager, terrain: &TerrainData, nation_borders: &HashMap>, turn_number: u64, rng: &DeterministicRng) { + // Check if there's already an attack on unclaimed territory + if let Some(attack_key) = self.index.get_unclaimed_attack(nation_id) { + // Add troops to existing attack + self.attacks[attack_key].modify_troops(troops); + + // Add new borders to allow multi-region expansion + if let Some(borders) = border_tiles.or_else(|| nation_borders.get(&nation_id).copied()) { + self.attacks[attack_key].add_borders(borders, territory_manager, terrain, rng); + } + return; + } + + // Create new attack + self.add_unclaimed(nation_id, troops, border_tiles, territory_manager, terrain, nation_borders, turn_number, rng); + } + + /// Schedule an attack on another nation + /// + /// Handles attack merging (if attacking same target) and counter-attacks + /// (opposite direction attacks are resolved first). + #[allow(clippy::too_many_arguments)] + pub fn schedule_attack(&mut self, nation_id: NationId, target_id: NationId, mut troops: f32, border_tiles: Option<&HashSet>, territory_manager: &TerritoryManager, terrain: &TerrainData, nation_borders: &HashMap>, turn_number: u64, rng: &DeterministicRng) { + // Prevent self-attacks early (before any processing) + if nation_id == target_id { + tracing::warn!( + nation_id = %nation_id, + "Attempted self-attack prevented" + ); + return; + } + + // Check if there's already an attack on this target + if let Some(attack_key) = self.index.get_existing_attack(nation_id, target_id) { + // Add troops to existing attack + self.attacks[attack_key].modify_troops(troops); + + // Add new borders to allow multi-region expansion + if let Some(borders) = border_tiles.or_else(|| nation_borders.get(&nation_id).copied()) { + self.attacks[attack_key].add_borders(borders, territory_manager, terrain, rng); + } + return; + } + + // Check for counter-attacks (opposite direction) - prevent mutual attacks + while self.index.has_counter_attacks(nation_id, target_id) { + let opposite_key = self.index.get_counter_attack(nation_id, target_id).unwrap(); + + if self.attacks[opposite_key].oppose(troops) { + // Counter-attack absorbed the new attack + return; + } + + // Counter-attack was defeated, deduct its troops from the new attack + troops -= self.attacks[opposite_key].get_troops(); + + // Remove the defeated counter-attack + self.remove_attack(opposite_key); + } + + // Create new attack + self.add_attack(nation_id, target_id, troops, border_tiles, territory_manager, terrain, nation_borders, turn_number, rng); + } + + /// Tick all active attacks + /// + /// Progresses each attack by one turn. Attacks that run out of troops + /// or conquerable tiles are removed and their remaining troops are + /// returned to the attacking nation. + #[allow(clippy::too_many_arguments)] + pub fn tick(&mut self, entity_map: &NationEntityMap, nations: &mut Query<(&mut Troops, &mut TerritorySize)>, territory_manager: &mut TerritoryManager, terrain: &TerrainData, nation_borders: &HashMap>, rng: &DeterministicRng, is_bot_query: &Query>) { + let attack_count = self.attacks.len(); + let _guard = tracing::trace_span!("attacks_tick", attack_count).entered(); + + let mut attacks_to_remove = Vec::new(); + + for (attack_key, attack) in &mut self.attacks { + let should_continue = attack.tick(entity_map, nations, territory_manager, terrain, nation_borders, rng); + + if !should_continue { + // Return remaining troops to nation (ECS component) + let remaining_troops = attack.get_troops(); + + if let Some(&entity) = entity_map.0.get(&attack.source) + && let Ok((mut troops, territory_size)) = nations.get_mut(entity) + { + let is_bot = is_bot_query.get(entity).unwrap_or(false); + troops.0 = crate::game::entities::add_troops_capped(troops.0, remaining_troops, territory_size.0, is_bot); + } + + // Mark attack for removal + attacks_to_remove.push(attack_key); + } + } + + // Remove completed attacks + for attack_key in attacks_to_remove { + self.remove_attack(attack_key); + } + } + + /// Handle a tile being added to a nation's territory + /// + /// Notifies all relevant attacks that territory has changed so they can + /// update their borders and targets. + pub fn handle_territory_add(&mut self, tile: U16Vec2, nation_id: NationId, territory_manager: &TerritoryManager, terrain: &TerrainData, rng: &DeterministicRng) { + // Notify all attacks where this nation is the attacker + if let Some(attack_set) = self.index.get_attacks_by_nation(nation_id) { + for &attack_key in attack_set { + self.attacks[attack_key].handle_nation_tile_add(tile, territory_manager, terrain, rng); + } + } + + // Notify all attacks where this nation is the target + if let Some(attack_set) = self.index.get_attacks_on_nation(nation_id) { + for &attack_key in attack_set { + self.attacks[attack_key].handle_target_tile_add(tile, territory_manager, rng); + } + } + } + + /// Add an attack on unclaimed territory + #[allow(clippy::too_many_arguments)] + fn add_unclaimed(&mut self, nation: NationId, troops: f32, border_tiles: Option<&HashSet>, territory_manager: &TerritoryManager, terrain: &TerrainData, nation_borders: &HashMap>, turn_number: u64, rng: &DeterministicRng) { + let attack_id = self.next_attack_id; + self.next_attack_id += 1; + + let attack = AttackExecutor::new(AttackConfig { id: attack_id, source: nation, target: None, troops, border_tiles, territory_manager, nation_borders, turn_number, terrain }, rng); + + let attack_key = self.attacks.insert(attack); + self.index.add_unclaimed_attack(nation, attack_key); + } + + /// Add an attack on a nation + #[allow(clippy::too_many_arguments)] + fn add_attack(&mut self, nation_id: NationId, target_id: NationId, troops: f32, border_tiles: Option<&HashSet>, territory_manager: &TerritoryManager, terrain: &TerrainData, nation_borders: &HashMap>, turn_number: u64, rng: &DeterministicRng) { + let attack_id = self.next_attack_id; + self.next_attack_id += 1; + + let attack = AttackExecutor::new(AttackConfig { id: attack_id, source: nation_id, target: Some(target_id), troops, border_tiles, territory_manager, nation_borders, turn_number, terrain }, rng); + + let attack_key = self.attacks.insert(attack); + self.index.add_nation_attack(nation_id, target_id, attack_key); + } + + /// Get all attacks involving a specific nation (as attacker or target) + /// + /// Returns a list of (attacker_id, target_id, troops, start_turn, is_outgoing) + /// sorted by start_turn descending (most recent first) + pub fn get_attacks_for_nation(&self, nation_id: NationId) -> Vec<(NationId, Option, f32, u64, bool)> { + let mut attacks = Vec::new(); + + // Add outgoing attacks (nation is attacker) + if let Some(attack_set) = self.index.get_attacks_by_nation(nation_id) { + for &attack_key in attack_set { + let attack = &self.attacks[attack_key]; + attacks.push(( + attack.source, + attack.target, + attack.get_troops(), + attack.id(), + true, // outgoing + )); + } + } + + // Add incoming attacks (nation is target) + if let Some(attack_set) = self.index.get_attacks_on_nation(nation_id) { + for &attack_key in attack_set { + let attack = &self.attacks[attack_key]; + attacks.push(( + attack.source, + attack.target, + attack.get_troops(), + attack.id(), + false, // incoming + )); + } + } + + // Sort by attack ID descending (most recent first) + attacks.sort_by(|a, b| b.3.cmp(&a.3)); + attacks + } + + /// Remove an attack and update all indices + /// + /// With SlotMap, keys remain stable so no index shifting is needed. + /// HashSet provides O(1) removal without element shifting. + fn remove_attack(&mut self, attack_key: AttackKey) { + let attack = &self.attacks[attack_key]; + + // Remove from all indices atomically + if let Some(target) = attack.target { + self.index.remove_nation_attack(attack.source, target, attack_key); + } else { + self.index.remove_unclaimed_attack(attack.source, attack_key); + } + + // Remove attack from slot map - no index shifting needed! + self.attacks.remove(attack_key); + } +} diff --git a/crates/borders-core/src/game/combat/calculator.rs b/crates/borders-core/src/game/combat/calculator.rs new file mode 100644 index 0000000..64561fa --- /dev/null +++ b/crates/borders-core/src/game/combat/calculator.rs @@ -0,0 +1,118 @@ +/// Pure combat calculation functions +/// +/// This module contains all combat mathematics extracted from the attack system. +/// All functions are pure (no side effects) and deterministic, making them +/// easy to test, reason about, and modify. +use glam::U16Vec2; + +use crate::game::core::constants::combat::*; +use crate::game::world::TerritoryManager; + +/// Parameters for combat result calculation +pub struct CombatParams<'a> { + pub attacker_troops: f32, + pub attacker_territory_size: usize, + pub defender_troops: Option, + pub defender_territory_size: Option, + pub tile: U16Vec2, + pub territory_manager: &'a TerritoryManager, + pub width: u16, +} + +/// Result of combat calculations for conquering one tile +#[derive(Debug, Clone, Copy)] +pub struct CombatResult { + /// Troops lost by the attacker + pub attacker_loss: f32, + /// Troops lost by the defender + pub defender_loss: f32, + /// How much of the "tiles per tick" budget this conquest consumes + pub tiles_per_tick_used: f32, +} + +/// Sigmoid function for smooth scaling curves +/// +/// Used for empire size balancing to create smooth transitions +/// rather than hard thresholds. +#[inline] +pub fn sigmoid(x: f32, decay_rate: f32, midpoint: f32) -> f32 { + 1.0 / (1.0 + (-(x - midpoint) * decay_rate).exp()) +} + +/// Calculate combat result for conquering one tile +/// +/// This function determines troop losses and conquest cost based on: +/// - Attacker and defender troop counts and empire sizes +/// - Terrain properties (currently plains baseline) +/// - Empire size balancing (prevents snowballing) +/// - Defense structures (placeholder for future implementation) +pub fn calculate_combat_result(params: CombatParams) -> CombatResult { + if let (Some(defender_troops), Some(defender_territory_size)) = (params.defender_troops, params.defender_territory_size) { + // Attacking claimed territory + + // Base terrain values (plains baseline) + let mut mag = BASE_MAG_PLAINS; + let mut speed = BASE_SPEED_PLAINS; + + // Defense post check (placeholder - always false for now) + let has_defense_post = check_defense_post_nearby(params.tile, params.territory_manager); + if has_defense_post { + mag *= DEFENSE_POST_MAG_MULTIPLIER; + speed *= DEFENSE_POST_SPEED_MULTIPLIER; + } + + // Empire size balancing - prevents snowballing + // Large defenders get debuffed, large attackers get penalized + let defense_sig = 1.0 - sigmoid(defender_territory_size as f32, DEFENSE_DEBUFF_DECAY_RATE, DEFENSE_DEBUFF_MIDPOINT); + let large_defender_speed_debuff = LARGE_DEFENDER_BASE_DEBUFF + LARGE_DEFENDER_SCALING * defense_sig; + let large_defender_attack_debuff = LARGE_DEFENDER_BASE_DEBUFF + LARGE_DEFENDER_SCALING * defense_sig; + + let large_attacker_bonus = if params.attacker_territory_size > LARGE_EMPIRE_THRESHOLD as usize { (LARGE_EMPIRE_THRESHOLD as f32 / params.attacker_territory_size as f32).sqrt().powf(LARGE_ATTACKER_POWER_EXPONENT) } else { 1.0 }; + + let large_attacker_speed_bonus = if params.attacker_territory_size > LARGE_EMPIRE_THRESHOLD as usize { (LARGE_EMPIRE_THRESHOLD as f32 / params.attacker_territory_size as f32).powf(LARGE_ATTACKER_SPEED_EXPONENT) } else { 1.0 }; + + // Calculate troop ratio + let troop_ratio = (defender_troops / params.attacker_troops.max(1.0)).clamp(TROOP_RATIO_MIN, TROOP_RATIO_MAX); + + // Final attacker loss + let attacker_loss = troop_ratio * mag * ATTACKER_LOSS_MULTIPLIER * large_defender_attack_debuff * large_attacker_bonus; + + // Defender loss (simple: troops per tile) + let defender_loss = defender_troops / defender_territory_size.max(1) as f32; + + // Tiles per tick cost for this tile + let tiles_per_tick_used = (defender_troops / (TILES_PER_TICK_DIVISOR * params.attacker_troops.max(1.0))).clamp(TILES_PER_TICK_MIN, TILES_PER_TICK_MAX) * speed * large_defender_speed_debuff * large_attacker_speed_bonus; + + CombatResult { attacker_loss, defender_loss, tiles_per_tick_used } + } else { + // Attacking unclaimed territory + CombatResult { attacker_loss: BASE_MAG_PLAINS / UNCLAIMED_ATTACK_LOSS_DIVISOR, defender_loss: 0.0, tiles_per_tick_used: ((UNCLAIMED_BASE_MULTIPLIER * BASE_SPEED_PLAINS.max(MIN_SPEED_PLAINS)) / params.attacker_troops.max(1.0)).clamp(UNCLAIMED_TILES_MIN, UNCLAIMED_TILES_MAX) } + } +} + +/// Calculate tiles conquered per tick based on troop ratio and border size +/// +/// This determines how fast an attack progresses. It's based on: +/// - The attacker's troop advantage (or disadvantage) +/// - The size of the attack border +/// - Random variation for organic-looking expansion +pub fn calculate_tiles_per_tick(attacker_troops: f32, defender_troops: Option, border_size: f32) -> f32 { + if let Some(defender_troops) = defender_troops { + // Dynamic based on troop ratio + let ratio = ((ATTACK_RATIO_MULTIPLIER * attacker_troops) / defender_troops.max(1.0)) * ATTACK_RATIO_SCALE; + let clamped_ratio = ratio.clamp(ATTACK_RATIO_MIN, ATTACK_RATIO_MAX); + clamped_ratio * border_size * CLAIMED_TILES_PER_TICK_MULTIPLIER + } else { + // Fixed rate for unclaimed territory + border_size * UNCLAIMED_TILES_PER_TICK_MULTIPLIER + } +} + +/// Check if defender has a defense post nearby (placeholder) +/// +/// This will be implemented when defense structures are added to the game. +/// For now, always returns false. +fn check_defense_post_nearby(_tile: U16Vec2, _territory_manager: &TerritoryManager) -> bool { + // Placeholder for future defense post implementation + false +} diff --git a/crates/borders-core/src/game/combat/executor.rs b/crates/borders-core/src/game/combat/executor.rs new file mode 100644 index 0000000..57382d6 --- /dev/null +++ b/crates/borders-core/src/game/combat/executor.rs @@ -0,0 +1,396 @@ +/// Attack execution logic +/// +/// This module contains the `AttackExecutor` which manages the progression +/// of a single attack over multiple turns. It handles tile prioritization, +/// border expansion, and conquest mechanics. +use std::collections::{BinaryHeap, HashMap, HashSet}; + +use glam::U16Vec2; +use rand::Rng; + +use super::calculator::{CombatParams, calculate_combat_result, calculate_tiles_per_tick}; +use crate::game::core::constants::combat::*; +use crate::game::core::rng::DeterministicRng; +use crate::game::core::utils::neighbors; +use crate::game::entities::{NationEntityMap, TerritorySize, Troops}; +use crate::game::terrain::TerrainData; +use crate::game::world::{NationId, TerritoryManager}; +use bevy_ecs::prelude::*; + +/// Priority queue entry for tile conquest +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct TilePriority { + tile: U16Vec2, + priority: i64, // Lower value = higher priority (conquered sooner) +} + +impl PartialOrd for TilePriority { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for TilePriority { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + other.priority.cmp(&self.priority).then_with(|| self.tile.x.cmp(&other.tile.x).then_with(|| self.tile.y.cmp(&other.tile.y))) + } +} + +/// Configuration for creating an AttackExecutor +pub struct AttackConfig<'a> { + pub id: u64, + pub source: NationId, + pub target: Option, + pub troops: f32, + pub border_tiles: Option<&'a HashSet>, + pub territory_manager: &'a TerritoryManager, + pub nation_borders: &'a HashMap>, + pub turn_number: u64, + pub terrain: &'a TerrainData, +} + +/// Executes a single ongoing attack (conquering tiles over time) +/// +/// An attack progresses over multiple turns, conquering tiles based on: +/// - Available troops +/// - Troop ratio vs defender +/// - Border size and connectivity +/// - Combat formulas from the calculator module +/// +/// The executor maintains a priority queue of tiles to conquer and updates +/// borders as it progresses. +pub struct AttackExecutor { + id: u64, + pub source: NationId, + pub target: Option, + troops: f32, + /// Active conquest frontier - tiles being evaluated/conquered by this attack. + /// Distinct from nation BorderTiles: dynamically shrinks as tiles are conquered + /// and expands as new neighbors become targets. + conquest_frontier: HashSet, + priority_queue: BinaryHeap, + start_turn: u64, + current_turn: u64, + tiles_conquered: usize, // Counter for each tile conquered (for priority calculation) + pending_removal: bool, // Mark attack for removal on next tick (allows final troops=0 update) +} + +impl AttackExecutor { + /// Create a new attack executor + pub fn new(config: AttackConfig, rng: &DeterministicRng) -> Self { + let mut executor = Self { id: config.id, source: config.source, target: config.target, troops: config.troops, conquest_frontier: HashSet::new(), priority_queue: BinaryHeap::new(), start_turn: config.turn_number, current_turn: config.turn_number, tiles_conquered: 0, pending_removal: false }; + + executor.initialize_border(config.border_tiles, config.territory_manager, config.terrain, config.nation_borders, rng); + + executor + } + + /// Modify the amount of troops in the attack + pub fn modify_troops(&mut self, amount: f32) { + self.troops += amount; + } + + /// Add new border tiles to the attack, allowing expansion from multiple fronts + /// + /// This enables multi-region expansion when attacking the same target from different areas + pub fn add_borders(&mut self, new_border_tiles: &HashSet, territory_manager: &TerritoryManager, terrain: &TerrainData, rng: &DeterministicRng) { + // Add neighbors from each new border tile + for &tile in new_border_tiles { + for neighbor in neighbors(tile, territory_manager.size()) { + if self.is_valid_target(neighbor, territory_manager, terrain) && !self.conquest_frontier.contains(&neighbor) { + self.add_tile_to_border(neighbor, territory_manager, rng); + } + } + } + } + + /// Oppose an attack (counter-attack) + /// + /// Returns true if the attack continues, false if it was defeated + pub fn oppose(&mut self, troop_count: f32) -> bool { + if self.troops > troop_count { + self.troops -= troop_count; + true + } else { + false + } + } + + /// Get the unique attack identifier + pub fn id(&self) -> u64 { + self.id + } + + /// Get the amount of troops in the attack + pub fn get_troops(&self) -> f32 { + self.troops.max(0.0).floor() + } + + /// Get the turn this attack started + pub fn get_start_turn(&self) -> u64 { + self.start_turn + } + + /// Tick the attack executor + /// + /// Returns true if the attack continues, false if it's finished + pub fn tick(&mut self, entity_map: &NationEntityMap, nations: &mut Query<(&mut Troops, &mut TerritorySize)>, territory_manager: &mut TerritoryManager, terrain: &TerrainData, nation_borders: &HashMap>, rng: &DeterministicRng) -> bool { + let _guard = tracing::trace_span!("attack_tick", nation_id = %self.source).entered(); + + // If marked for removal, remove now (allows one final update with troops=0) + if self.pending_removal { + return false; + } + + self.current_turn += 1; + + // Calculate how many tiles to conquer this tick + let mut tiles_per_tick = self.calculate_tiles_per_tick(entity_map, nations, rng); + + // Track if we've already refreshed this tick to prevent infinite refresh loops + let mut has_refreshed = false; + + // Process tiles from priority queue + while tiles_per_tick > 0.0 { + if self.troops < 1.0 { + self.troops = 0.0; + self.pending_removal = true; + return true; // Keep alive for one more tick to send troops=0 + } + + if self.priority_queue.is_empty() { + // If we already refreshed this tick, stop to prevent infinite loop + if has_refreshed { + self.troops = 0.0; + self.pending_removal = true; + return true; // Keep alive for one more tick to send troops=0 + } + + // Remember border size before refresh + let border_size_before = self.conquest_frontier.len(); + + // Refresh border tiles one last time before giving up + self.refresh_border(nation_borders, territory_manager, terrain, rng); + has_refreshed = true; + + // If refresh found no new tiles, attack is finished + if self.conquest_frontier.len() == border_size_before { + self.troops = 0.0; + self.pending_removal = true; + return true; // Keep alive for one more tick to send troops=0 + } + + // If still empty after refresh (all tiles invalid), attack is finished + if self.priority_queue.is_empty() { + self.troops = 0.0; + self.pending_removal = true; + return true; // Keep alive for one more tick to send troops=0 + } + } + + let tile_priority = self.priority_queue.pop().unwrap(); + let tile = tile_priority.tile; + self.conquest_frontier.remove(&tile); + + // Check connectivity and validity + let on_border = Self::check_borders_tile(tile, self.source, territory_manager); + let tile_valid = self.is_valid_target(tile, territory_manager, terrain); + + // Prevent attacking own tiles (race condition during conquest) + let tile_owner = territory_manager.get_ownership(tile); + let attacking_self = tile_owner.nation_id() == Some(self.source); + + // Skip if any check fails + if !tile_valid || !on_border || attacking_self { + continue; + } + + // Add neighbors BEFORE conquering (critical for correct expansion) + self.add_neighbors_to_border(tile, territory_manager, terrain, rng); + + // Query attacker territory size from ECS + let attacker_troops = self.troops; + let attacker_territory_size = if let Some(&attacker_entity) = entity_map.0.get(&self.source) + && let Ok((_, territory)) = nations.get(attacker_entity) + { + territory.0 + } else { + // Attacker no longer exists - immediate removal (error state) + return false; + }; + + // Query defender stats from ECS if attacking a player + let (defender_troops, defender_territory_size) = if let Some(target_id) = self.target { if let Some(&defender_entity) = entity_map.0.get(&target_id) { if let Ok((troops, territory)) = nations.get(defender_entity) { (Some(troops.0), Some(territory.0)) } else { (None, None) } } else { (None, None) } } else { (None, None) }; + + // Calculate losses for this tile + let combat_result = { calculate_combat_result(CombatParams { attacker_troops, attacker_territory_size: attacker_territory_size as usize, defender_troops, defender_territory_size: defender_territory_size.map(|s| s as usize), tile, territory_manager, width: territory_manager.width() }) }; + + // Check if we still have enough troops to conquer this tile + if self.troops < combat_result.attacker_loss { + self.troops = 0.0; + self.pending_removal = true; + return true; // Keep alive for one more tick to send troops=0 + } + + // Apply troop losses + self.troops -= combat_result.attacker_loss; + if let Some(target_id) = self.target + && let Some(&defender_entity) = entity_map.0.get(&target_id) + && let Ok((mut troops, _)) = nations.get_mut(defender_entity) + { + troops.0 = (troops.0 - combat_result.defender_loss).max(0.0); + } + + // Conquer the tile + let previous_owner = territory_manager.conquer(tile, self.source); + + // Update nation territory sizes + if let Some(nation_id) = previous_owner + && let Some(&nation_entity) = entity_map.0.get(&nation_id) + && let Ok((_, mut territory_size)) = nations.get_mut(nation_entity) + { + territory_size.0 = territory_size.0.saturating_sub(1); + } + if let Some(&nation_entity) = entity_map.0.get(&self.source) + && let Ok((_, mut territory_size)) = nations.get_mut(nation_entity) + { + territory_size.0 += 1; + } + + // Increment tiles conquered counter (used for priority calculation) + self.tiles_conquered += 1; + + // Decrement tiles per tick counter + tiles_per_tick -= combat_result.tiles_per_tick_used; + } + + // Check if attack should continue + !self.priority_queue.is_empty() && self.troops >= 1.0 + } + + /// Calculate tiles conquered per tick based on troop ratio and border size + fn calculate_tiles_per_tick(&mut self, entity_map: &NationEntityMap, nations: &Query<(&mut Troops, &mut TerritorySize)>, rng: &DeterministicRng) -> f32 { + // Add random 0-4 to border size + // This introduces natural variation in expansion speed + let mut context_rng = rng.for_context(self.source.get() as u64); + let random_border_adjustment = context_rng.random_range(0..BORDER_RANDOM_ADJUSTMENT_MAX) as f32; + let border_size = self.priority_queue.len() as f32 + random_border_adjustment; + + // Query defender troops if attacking a player + let defender_troops = if let Some(target_id) = self.target { entity_map.0.get(&target_id).and_then(|&entity| nations.get(entity).ok()).map(|(troops, _)| troops.0) } else { None }; + + calculate_tiles_per_tick(self.troops, defender_troops, border_size) + } + + /// Check if a tile is a valid target for this attack + fn is_valid_target(&self, tile: U16Vec2, territory_manager: &TerritoryManager, terrain: &TerrainData) -> bool { + if let Some(target_id) = self.target { + territory_manager.is_owner(tile, target_id) + } else { + // For unclaimed attacks, check if tile is unowned and conquerable (not water) + !territory_manager.has_owner(tile) && terrain.is_conquerable(tile) + } + } + + /// Add a tile to the border with proper priority calculation + fn add_tile_to_border(&mut self, tile: U16Vec2, territory_manager: &TerritoryManager, rng: &DeterministicRng) { + self.conquest_frontier.insert(tile); + let priority = self.calculate_tile_priority(tile, territory_manager, rng); + self.priority_queue.push(TilePriority { tile, priority }); + } + + /// Initialize border tiles from player's existing borders + fn initialize_border(&mut self, border_tiles: Option<&HashSet>, territory_manager: &TerritoryManager, terrain: &TerrainData, nation_borders: &HashMap>, rng: &DeterministicRng) { + self.initialize_border_internal(border_tiles, territory_manager, terrain, nation_borders, rng, false); + } + + /// Refresh the attack border by re-scanning all nation border tiles + /// + /// This gives the attack one last chance to find conquerable tiles before ending + fn refresh_border(&mut self, nation_borders: &HashMap>, territory_manager: &TerritoryManager, terrain: &TerrainData, rng: &DeterministicRng) { + self.initialize_border_internal(None, territory_manager, terrain, nation_borders, rng, true); + } + + /// Internal method to initialize or refresh border tiles + fn initialize_border_internal(&mut self, border_tiles: Option<&HashSet>, territory_manager: &TerritoryManager, terrain: &TerrainData, nation_borders: &HashMap>, rng: &DeterministicRng, clear_first: bool) { + if clear_first { + self.priority_queue.clear(); + self.conquest_frontier.clear(); + } + + // Get borders or use empty set as fallback (needs lifetime handling) + let empty_borders = HashSet::new(); + let borders = border_tiles.or_else(|| nation_borders.get(&self.source).copied()).unwrap_or(&empty_borders); + + let border_count = borders.len(); + + let _refresh_guard; + let _init_guard; + if clear_first { + _refresh_guard = tracing::trace_span!("refresh_attack_border", border_count).entered(); + } else { + _init_guard = tracing::trace_span!("initialize_attack_border", border_count).entered(); + } + + // Find all target tiles adjacent to our borders + for &tile in borders { + for neighbor in neighbors(tile, territory_manager.size()) { + if self.is_valid_target(neighbor, territory_manager, terrain) && !self.conquest_frontier.contains(&neighbor) { + self.add_tile_to_border(neighbor, territory_manager, rng); + } + } + } + } + + /// Add neighbors of a newly conquered tile to the border + fn add_neighbors_to_border(&mut self, tile: U16Vec2, territory_manager: &TerritoryManager, terrain: &TerrainData, rng: &DeterministicRng) { + for neighbor in neighbors(tile, territory_manager.size()) { + if self.is_valid_target(neighbor, territory_manager, terrain) && !self.conquest_frontier.contains(&neighbor) { + self.add_tile_to_border(neighbor, territory_manager, rng); + } + } + } + + /// Calculate priority for a tile (lower = conquered sooner) + /// + /// Uses tiles_conquered counter to ensure wave-like expansion + fn calculate_tile_priority(&self, tile: U16Vec2, territory_manager: &TerritoryManager, rng: &DeterministicRng) -> i64 { + // Count how many neighbors are owned by attacker + let num_owned_by_attacker = neighbors(tile, territory_manager.size()).filter(|&neighbor| territory_manager.is_owner(neighbor, self.source)).count(); + + let terrain_mag = 1.0; + + // Random factor (0-7) + let mut tile_rng = rng.for_tile(tile); + let random_factor = tile_rng.random_range(0..TILE_PRIORITY_RANDOM_MAX); + + // Priority calculation (lower = higher priority, conquered sooner) + // Base calculation: tiles surrounded by more attacker neighbors get LOWER modifier values + // Adding tiles_conquered ensures tiles discovered earlier get lower priority values + // This creates wave-like expansion: older tiles (lower priority) conquered before newer tiles (higher priority) + let base = (random_factor + 10) as f32; + let modifier = TILE_PRIORITY_BASE - (num_owned_by_attacker as f32 * TILE_PRIORITY_NEIGHBOR_PENALTY) + (terrain_mag / 2.0); + (base * modifier) as i64 + self.tiles_conquered as i64 + } + + /// Handle the addition of a tile to the nation's territory + pub fn handle_nation_tile_add(&mut self, tile: U16Vec2, territory_manager: &TerritoryManager, terrain: &TerrainData, rng: &DeterministicRng) { + // When nation gains a tile, check its neighbors for new targets + self.add_neighbors_to_border(tile, territory_manager, terrain, rng); + } + + /// Handle the addition of a tile to the target's territory + pub fn handle_target_tile_add(&mut self, tile: U16Vec2, territory_manager: &TerritoryManager, rng: &DeterministicRng) { + // If target gains a tile that borders our territory, add it to attack + if Self::check_borders_tile(tile, self.source, territory_manager) && !self.conquest_frontier.contains(&tile) { + self.conquest_frontier.insert(tile); + let priority = self.calculate_tile_priority(tile, territory_manager, rng); + self.priority_queue.push(TilePriority { tile, priority }); + } + } + + /// Check if a tile borders the nation's territory + fn check_borders_tile(tile: U16Vec2, nation_id: NationId, territory_manager: &TerritoryManager) -> bool { + neighbors(tile, territory_manager.size()).any(|neighbor| territory_manager.is_owner(neighbor, nation_id)) + } +} diff --git a/crates/borders-core/src/game/combat/mod.rs b/crates/borders-core/src/game/combat/mod.rs new file mode 100644 index 0000000..1bf65f9 --- /dev/null +++ b/crates/borders-core/src/game/combat/mod.rs @@ -0,0 +1,7 @@ +pub mod active; +pub mod calculator; +pub mod executor; + +pub use active::*; +pub use calculator::*; +pub use executor::*; diff --git a/crates/borders-core/src/game/core/action.rs b/crates/borders-core/src/game/core/action.rs new file mode 100644 index 0000000..4189d41 --- /dev/null +++ b/crates/borders-core/src/game/core/action.rs @@ -0,0 +1,57 @@ +//! Game action system +//! +//! This module defines the core action types that can be performed in the game. +//! Actions represent discrete game events that can be initiated by both human players +//! and AI bots. They are processed deterministically during turn execution. + +use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; +use serde::{Deserialize, Serialize}; + +use crate::game::core::utils::u16vec2_serde; +use crate::game::world::NationId; + +/// Core game action type +/// +/// This enum represents all possible actions that can be performed in the game. +/// Unlike `Intent`, which is a network-layer wrapper, `GameAction` is the actual +/// game-level operation. +/// +/// Actions can originate from: +/// - Players (via input systems → intents → network → SourcedIntent wrapper) +/// - Bots (calculated deterministically during turn execution) +/// +/// Nation identity is provided separately: +/// - For players: wrapped in SourcedIntent by server (prevents spoofing) +/// - For bots: generated with id in turn execution context +/// +/// Note: Spawning is handled separately via Turn(0) and direct spawn manager updates, +/// not through the action system. +#[derive(Debug, Clone, Serialize, Deserialize, Archive, RkyvSerialize, RkyvDeserialize)] +#[rkyv(derive(Debug))] +pub enum GameAction { + /// Attack a target nation with a specified number of troops + /// + /// The attack will proceed across all borders shared with the target: + /// - `target: Some(nation_id)` - Attack specific nation across all shared borders + /// - `target: None` - Expand into unclaimed territory from all borders + Attack { target: Option, troops: u32 }, + /// Launch a transport ship to attack across water + LaunchShip { + #[serde(with = "u16vec2_serde")] + target_tile: glam::U16Vec2, + troops: u32, + }, + // Future action types: + // BuildStructure { target: U16Vec2, structure_type: StructureType }, + // LaunchNuke { target: U16Vec2 }, + // RequestAlliance { target: NationId }, + // DeclareWar { target: NationId }, +} + +/// Troop count specification for attacks +pub enum TroopCount { + /// Use a ratio of the nation's current troops (0.0-1.0) + Ratio(f32), + /// Use an absolute troop count + Absolute(u32), +} diff --git a/crates/borders-core/src/game/core/constants.rs b/crates/borders-core/src/game/core/constants.rs new file mode 100644 index 0000000..b304cd5 --- /dev/null +++ b/crates/borders-core/src/game/core/constants.rs @@ -0,0 +1,255 @@ +/// Game constants organized by domain +/// +/// This module centralizes all game balance constants that were previously +/// scattered across multiple files. Constants are grouped by gameplay domain +/// for easy discovery and tuning. +pub mod game { + /// Game tick interval in milliseconds (10 TPS = 100ms per turn) + pub const TICK_INTERVAL: u64 = 100; + + /// Number of bot nations + pub const BOT_COUNT: usize = 500; +} + +pub mod combat { + /// Empire size balancing - prevents snowballing by large empires + /// Defense effectiveness decreases as empire grows beyond this threshold + pub const DEFENSE_DEBUFF_MIDPOINT: f32 = 150_000.0; + + /// Rate of defense effectiveness decay for large empires + /// Uses natural log decay for smooth scaling + pub const DEFENSE_DEBUFF_DECAY_RATE: f32 = std::f32::consts::LN_2 / 50_000.0; + + /// Base terrain magnitude cost for plains (baseline terrain) + /// Determines troop losses when conquering a tile + pub const BASE_MAG_PLAINS: f32 = 80.0; + + /// Base terrain speed for plains (baseline terrain) + /// Affects how many tiles can be conquered per tick + pub const BASE_SPEED_PLAINS: f32 = 16.5; + + /// Maximum random adjustment to border size when calculating expansion speed + /// Introduces natural variation in attack progression (0-4 range) + pub const BORDER_RANDOM_ADJUSTMENT_MAX: u32 = 5; + + /// Multiplier for tiles conquered per tick when attacking unclaimed territory + pub const UNCLAIMED_TILES_PER_TICK_MULTIPLIER: f32 = 2.0; + + /// Multiplier for tiles conquered per tick when attacking claimed territory + pub const CLAIMED_TILES_PER_TICK_MULTIPLIER: f32 = 3.0; + + /// Large empire threshold for attack penalties (>100k tiles) + pub const LARGE_EMPIRE_THRESHOLD: u32 = 100_000; + + /// Random factor range for tile priority calculation (0-7) + pub const TILE_PRIORITY_RANDOM_MAX: u32 = 8; + + /// Defense post magnitude multiplier (when implemented) + pub const DEFENSE_POST_MAG_MULTIPLIER: f32 = 5.0; + + /// Defense post speed multiplier (when implemented) + pub const DEFENSE_POST_SPEED_MULTIPLIER: f32 = 3.0; + + /// Base defense debuff for large defenders (70%) + pub const LARGE_DEFENDER_BASE_DEBUFF: f32 = 0.7; + + /// Scaling factor for large defender sigmoid (30%) + pub const LARGE_DEFENDER_SCALING: f32 = 0.3; + + /// Power exponent for large attacker bonus calculation + pub const LARGE_ATTACKER_POWER_EXPONENT: f32 = 0.7; + + /// Speed exponent for large attacker penalty calculation + pub const LARGE_ATTACKER_SPEED_EXPONENT: f32 = 0.6; + + /// Minimum troop ratio for combat calculations + pub const TROOP_RATIO_MIN: f32 = 0.6; + + /// Maximum troop ratio for combat calculations + pub const TROOP_RATIO_MAX: f32 = 2.0; + + /// Multiplier for attacker loss calculations + pub const ATTACKER_LOSS_MULTIPLIER: f32 = 0.8; + + /// Divisor for tiles per tick calculation + pub const TILES_PER_TICK_DIVISOR: f32 = 5.0; + + /// Minimum tiles per tick cost + pub const TILES_PER_TICK_MIN: f32 = 0.2; + + /// Maximum tiles per tick cost + pub const TILES_PER_TICK_MAX: f32 = 1.5; + + /// Divisor for unclaimed territory attack losses + pub const UNCLAIMED_ATTACK_LOSS_DIVISOR: f32 = 5.0; + + /// Base multiplier for unclaimed territory conquest speed + pub const UNCLAIMED_BASE_MULTIPLIER: f32 = 2_000.0; + + /// Minimum speed value for plains terrain + pub const MIN_SPEED_PLAINS: f32 = 10.0; + + /// Minimum tiles per tick for unclaimed territory + pub const UNCLAIMED_TILES_MIN: f32 = 5.0; + + /// Maximum tiles per tick for unclaimed territory + pub const UNCLAIMED_TILES_MAX: f32 = 100.0; + + /// Multiplier for attack ratio calculation + pub const ATTACK_RATIO_MULTIPLIER: f32 = 5.0; + + /// Scale factor for attack ratio + pub const ATTACK_RATIO_SCALE: f32 = 2.0; + + /// Minimum attack ratio for dynamic calculation + pub const ATTACK_RATIO_MIN: f32 = 0.01; + + /// Maximum attack ratio for dynamic calculation + pub const ATTACK_RATIO_MAX: f32 = 0.5; + + /// Base priority value for tile conquest + pub const TILE_PRIORITY_BASE: f32 = 1.0; + + /// Priority penalty per owned neighbor tile + pub const TILE_PRIORITY_NEIGHBOR_PENALTY: f32 = 0.5; +} + +pub mod nation { + /// Multiplier for max troops calculation + pub const MAX_TROOPS_MULTIPLIER: f32 = 2.0; + + /// Power exponent for max troops based on territory size + pub const MAX_TROOPS_POWER: f32 = 0.6; + + /// Scale factor for max troops calculation + pub const MAX_TROOPS_SCALE: f32 = 1000.0; + + /// Base max troops value + pub const MAX_TROOPS_BASE: f32 = 50_000.0; + + /// Bots get 33% of human max troops + pub const BOT_MAX_TROOPS_MULTIPLIER: f32 = 0.33; + + /// Base income per tick + pub const BASE_INCOME: f32 = 10.0; + + /// Power exponent for income calculation + pub const INCOME_POWER: f32 = 0.73; + + /// Divisor for income calculation + pub const INCOME_DIVISOR: f32 = 4.0; + + /// Bots get 60% of human income + pub const BOT_INCOME_MULTIPLIER: f32 = 0.6; + + /// Initial troops for all nations at spawn + pub const INITIAL_TROOPS: f32 = 2500.0; +} + +pub mod bot { + /// Maximum initial cooldown for bot actions (0-9 ticks) + pub const INITIAL_COOLDOWN_MAX: u64 = 10; + + /// Minimum cooldown between bot actions (ticks) + pub const ACTION_COOLDOWN_MIN: u64 = 3; + + /// Maximum cooldown between bot actions (ticks) + pub const ACTION_COOLDOWN_MAX: u64 = 15; + + /// Probability that bot chooses expansion over attack (60%) + pub const EXPAND_PROBABILITY: f32 = 0.6; + + /// Minimum troop percentage for wilderness expansion (10%) + pub const EXPAND_TROOPS_MIN: f32 = 0.1; + + /// Maximum troop percentage for wilderness expansion (30%) + pub const EXPAND_TROOPS_MAX: f32 = 0.3; + + /// Minimum troop percentage for nation attacks (20%) + pub const ATTACK_TROOPS_MIN: f32 = 0.2; + + /// Maximum troop percentage for nation attacks (50%) + pub const ATTACK_TROOPS_MAX: f32 = 0.5; + + /// Minimum distance between spawn points (in tiles) + pub const MIN_SPAWN_DISTANCE: f32 = 70.0; + + /// Absolute minimum spawn distance for fallback + pub const ABSOLUTE_MIN_DISTANCE: f32 = 5.0; + + /// Distance reduction factor per adaptive wave (15% reduction) + pub const DISTANCE_REDUCTION_FACTOR: f32 = 0.85; + + /// Number of random spawn placement attempts + pub const SPAWN_RANDOM_ATTEMPTS: usize = 1000; + + /// Maximum attempts for grid-guided spawn placement + pub const SPAWN_GRID_MAX_ATTEMPTS: usize = 200; + + /// Maximum attempts for fallback spawn placement + pub const SPAWN_FALLBACK_ATTEMPTS: usize = 10_000; + + /// Stride factor for grid-guided spawn placement (80% of current distance) + pub const SPAWN_GRID_STRIDE_FACTOR: f32 = 0.8; + + /// Maximum border tiles sampled for bot decision making + pub const MAX_BORDER_SAMPLES: usize = 20; +} + +pub mod colors { + /// Golden angle for visually distinct color distribution (degrees) + pub const GOLDEN_ANGLE: f32 = 137.5; + + /// Minimum saturation for nation colors + pub const SATURATION_MIN: f32 = 0.75; + + /// Maximum saturation for nation colors + pub const SATURATION_MAX: f32 = 0.95; + + /// Minimum lightness for nation colors + pub const LIGHTNESS_MIN: f32 = 0.35; + + /// Maximum lightness for nation colors + pub const LIGHTNESS_MAX: f32 = 0.65; +} + +pub mod input { + /// Default attack ratio when game starts (50%) + pub const DEFAULT_ATTACK_RATIO: f32 = 0.5; + + /// Step size for attack ratio adjustment (10%) + pub const ATTACK_RATIO_STEP: f32 = 0.1; + + /// Minimum attack ratio (10%) + pub const ATTACK_RATIO_MIN: f32 = 0.1; + + /// Maximum attack ratio (100%) + pub const ATTACK_RATIO_MAX: f32 = 1.0; +} + +pub mod ships { + /// Maximum ships per nation + pub const MAX_SHIPS_PER_NATION: usize = 5; + + /// Ticks required to move one tile (1 = fast speed) + pub const TICKS_PER_TILE: u32 = 1; + + /// Maximum path length for ship pathfinding + pub const MAX_PATH_LENGTH: usize = 1_000_000; + + /// Percentage of troops carried by ship (20%) + pub const TROOP_PERCENT: f32 = 0.20; +} + +pub mod outcome { + /// Win threshold - percentage of map needed to win (80%) + pub const WIN_THRESHOLD: f32 = 0.80; +} + +pub mod spawning { + /// Radius of tiles claimed around spawn point (creates 5x5 square) + pub const SPAWN_RADIUS: i16 = 2; + + /// Spawn timeout duration in seconds + pub const SPAWN_TIMEOUT_SECS: f32 = 2.0; +} diff --git a/crates/borders-core/src/game/core/mod.rs b/crates/borders-core/src/game/core/mod.rs new file mode 100644 index 0000000..451563e --- /dev/null +++ b/crates/borders-core/src/game/core/mod.rs @@ -0,0 +1,18 @@ +//! Core game logic and data structures +//! +//! This module contains the fundamental game types and logic. + +pub mod action; +pub mod constants; +pub mod outcome; +pub mod rng; +pub mod turn_execution; +pub mod utils; + +// Re-export commonly used types +pub use action::*; +pub use constants::*; +pub use outcome::*; +pub use rng::*; +pub use turn_execution::*; +pub use utils::*; diff --git a/crates/borders-core/src/game/core/outcome.rs b/crates/borders-core/src/game/core/outcome.rs new file mode 100644 index 0000000..d7b0bc7 --- /dev/null +++ b/crates/borders-core/src/game/core/outcome.rs @@ -0,0 +1,78 @@ +use crate::game::core::constants::outcome::WIN_THRESHOLD; +use crate::game::entities::{Dead, NationName, TerritorySize}; +use crate::game::input::context::LocalPlayerContext; +use crate::game::{NationEntityMap, NationId, TerritoryManager}; +use crate::ui::protocol::{BackendMessage, GameOutcome}; +use bevy_ecs::prelude::*; +use tracing::info; + +/// System that checks if the local player has won or lost +pub fn check_local_player_outcome(mut local_context: If>, territory_manager: Res, active_nations: Query<(&NationId, &TerritorySize, &NationName), Without>, nation_entity_map: Res, mut backend_messages: MessageWriter) { + // Don't check if outcome already determined + if local_context.my_outcome.is_some() { + return; + } + + let my_player_id = local_context.id; + + // Get local player entity and stats + let Some(&my_entity) = nation_entity_map.0.get(&my_player_id) else { + return; + }; + + let Ok((_, my_territory_size, _)) = active_nations.get(my_entity) else { + // Query failed but entity exists in entity_map, so player must have Dead marker + info!("Local player defeated - eliminated (Dead marker)"); + local_context.mark_defeated(); + backend_messages.write(BackendMessage::GameEnded { outcome: GameOutcome::Defeat }); + return; + }; + + let my_tiles = my_territory_size.0; + + // Don't check outcome until player has spawned (has tiles) + if my_tiles == 0 { + return; + } + + // Calculate total claimable tiles for victory condition checks + let total_claimable_tiles = crate::game::queries::count_land_tiles(&territory_manager); + + if total_claimable_tiles > 0 { + let my_occupation = my_tiles as f32 / total_claimable_tiles as f32; + + // Check if I've won by occupation + if my_occupation >= WIN_THRESHOLD { + info!("Local player victorious - reached {:.1}% occupation ({}/{} claimable tiles, threshold: {:.0}%)", my_occupation * 100.0, my_tiles, total_claimable_tiles, WIN_THRESHOLD * 100.0); + local_context.mark_victorious(); + backend_messages.write(BackendMessage::GameEnded { outcome: GameOutcome::Victory }); + return; + } + + // Check if any opponent has won by occupation (which means I lost) + for (id, territory, name) in active_nations.iter() { + if *id == my_player_id { + continue; + } + + let occupation = territory.0 as f32 / total_claimable_tiles as f32; + + if occupation >= WIN_THRESHOLD { + tracing::event!(target:module_path!(),tracing::Level::INFO,"Local player defeated - {} reached {:.1}% occupation ({}/{} claimable tiles, threshold: {:.0}%)",name.0,occupation*100.0,territory.0,total_claimable_tiles,WIN_THRESHOLD*100.0); + local_context.mark_defeated(); + backend_messages.write(BackendMessage::GameEnded { outcome: GameOutcome::Defeat }); + return; + } + } + } + + // Check victory by eliminating all opponents + // If no living opponents remain (query filters Without), then I've won + let any_opponents_alive = active_nations.iter().any(|(opponent_id, _, _)| *opponent_id != my_player_id); + + if !any_opponents_alive { + info!("Local player victorious - all opponents eliminated"); + local_context.mark_victorious(); + backend_messages.write(BackendMessage::GameEnded { outcome: GameOutcome::Victory }); + } +} diff --git a/crates/borders-core/src/game/core/rng.rs b/crates/borders-core/src/game/core/rng.rs new file mode 100644 index 0000000..e25be65 --- /dev/null +++ b/crates/borders-core/src/game/core/rng.rs @@ -0,0 +1,85 @@ +use bevy_ecs::prelude::*; +use rand::SeedableRng; +use rand::rngs::StdRng; + +use crate::game::NationId; + +/// Centralized deterministic RNG resource +/// +/// This resource provides deterministic random number generation for all game systems. +/// It is updated at the start of each turn with the current turn number, ensuring that +/// the same sequence of turns always produces the same random values. +/// +/// # Determinism Guarantees +/// +/// - Same turn number + base seed + context → same RNG state +/// - No stored RNG state in individual systems (prevents desync) +/// - All randomness flows through this single source of truth +/// +/// # Usage +/// +/// Systems should never store RNG state. Instead, request context-specific RNG: +/// +/// ```rust,ignore +/// fn my_system(rng: Res) { +/// let mut player_rng = rng.for_player(player_id); +/// let random_value = player_rng.gen_range(0..10); +/// } +/// ``` +#[derive(Resource)] +pub struct DeterministicRng { + /// Base seed for the entire game (set at game start) + base_seed: u64, + /// Current turn number (updated each turn) + turn_number: u64, +} + +impl DeterministicRng { + /// Create a new DeterministicRng with a base seed + pub fn new(base_seed: u64) -> Self { + Self { base_seed, turn_number: 0 } + } + + /// Update the turn number (should be called at start of each turn) + pub fn update_turn(&mut self, turn_number: u64) { + self.turn_number = turn_number; + } + + /// Get the current turn number + #[inline] + pub fn turn_number(&self) -> u64 { + self.turn_number + } + + /// Create an RNG for a specific context within the current turn + /// + /// The context_id allows different systems/entities to have independent + /// random sequences while maintaining determinism. + #[inline] + pub fn for_context(&self, context_id: u64) -> StdRng { + let seed = self + .turn_number + .wrapping_mul(997) // Prime multiplier for turn + .wrapping_add(self.base_seed) + .wrapping_add(context_id.wrapping_mul(1009)); // Prime multiplier for context + StdRng::seed_from_u64(seed) + } + + /// Get an RNG for a specific nation's actions this turn + /// + /// This is a convenience wrapper around `for_context` for nation-specific randomness. + #[inline] + pub fn for_nation(&self, id: NationId) -> StdRng { + self.for_context(id.get() as u64) + } + + /// Get an RNG for a specific tile's calculations this turn + /// + /// Useful for tile-based randomness that should be consistent within a turn. + pub fn for_tile(&self, tile: glam::U16Vec2) -> StdRng { + // Use large offset to avoid collision with nation IDs + // Convert tile position to unique ID + let tile_id = (tile.y as u64) * u16::MAX as u64 + (tile.x as u64); + self.for_context(1_000_000 + tile_id) + } +} diff --git a/crates/borders-core/src/game/core/turn_execution.rs b/crates/borders-core/src/game/core/turn_execution.rs new file mode 100644 index 0000000..b1bcbba --- /dev/null +++ b/crates/borders-core/src/game/core/turn_execution.rs @@ -0,0 +1,190 @@ +use std::collections::{HashMap, HashSet}; + +use bevy_ecs::prelude::*; +use glam::U16Vec2; + +use crate::game::ai::bot::Bot; +use crate::game::combat::ActiveAttacks; +use crate::game::core::action::{GameAction, TroopCount}; +use crate::game::core::rng::DeterministicRng; +use crate::game::entities::{Dead, NationEntityMap, TerritorySize, Troops, remove_troops}; +use crate::game::ships::LaunchShipMessage; +use crate::game::terrain::data::TerrainData; +use crate::game::world::{NationId, TerritoryManager}; +use crate::networking::{Intent, Turn}; + +/// Execute bot AI to generate actions +/// This must be called before execute_turn to avoid query conflicts +/// Returns (nation_id, action) pairs +pub fn process_bot_actions(turn_number: u64, territory_manager: &TerritoryManager, terrain: &TerrainData, nation_borders: &HashMap>, rng_seed: u64, bots: &mut Query<(&NationId, &Troops, &mut Bot), Without>) -> Vec<(NationId, GameAction)> { + let mut bot_actions = Vec::new(); + + for (nation_id, troops, mut bot) in &mut *bots { + if let Some(action) = bot.tick(turn_number, *nation_id, troops, territory_manager, terrain, nation_borders, rng_seed) { + bot_actions.push((*nation_id, action)); + } + } + + bot_actions +} + +/// Execute a full game turn +#[allow(clippy::too_many_arguments)] +pub fn execute_turn(turn: &Turn, turn_number: u64, bot_actions: Vec<(NationId, GameAction)>, territory_manager: &mut TerritoryManager, terrain: &TerrainData, active_attacks: &mut ActiveAttacks, rng: &mut DeterministicRng, nation_borders: &HashMap>, entity_map: &NationEntityMap, nations: &mut Query<(&mut Troops, &mut TerritorySize)>, is_bot_query: &Query>, launch_ship_writer: &mut MessageWriter) { + let _guard = tracing::trace_span!("execute_turn", turn_number, intent_count = turn.intents.len(), bot_action_count = bot_actions.len()).entered(); + + // Update RNG for this turn + rng.update_turn(turn_number); + + // PHASE 1: Process bot actions (deterministic, based on turn N-1 state) + { + let _guard = tracing::trace_span!("apply_bot_actions", count = bot_actions.len()).entered(); + + for (nation_id, action) in bot_actions { + apply_action(nation_id, action, turn_number, territory_manager, terrain, active_attacks, rng, nation_borders, entity_map, nations, launch_ship_writer); + } + } + + // PHASE 2: Process player intents (from network) + for sourced_intent in &turn.intents { + match &sourced_intent.intent { + Intent::Action(action) => { + apply_action(sourced_intent.source, action.clone(), turn_number, territory_manager, terrain, active_attacks, rng, nation_borders, entity_map, nations, launch_ship_writer); + } + Intent::SetSpawn { .. } => {} + } + } + + // PHASE 3: Tick game systems (attacks, etc.) + active_attacks.tick(entity_map, nations, territory_manager, terrain, nation_borders, rng, is_bot_query); +} + +/// Apply a game action (attack or ship launch) +#[allow(clippy::too_many_arguments)] +pub fn apply_action(nation_id: NationId, action: GameAction, turn_number: u64, territory_manager: &TerritoryManager, terrain: &TerrainData, active_attacks: &mut ActiveAttacks, rng: &DeterministicRng, nation_borders: &HashMap>, entity_map: &NationEntityMap, nations: &mut Query<(&mut Troops, &mut TerritorySize)>, launch_ship_writer: &mut MessageWriter) { + match action { + GameAction::Attack { target, troops } => { + handle_attack(nation_id, target, troops, turn_number, territory_manager, terrain, active_attacks, rng, nation_borders, entity_map, nations); + } + GameAction::LaunchShip { target_tile, troops } => { + launch_ship_writer.write(LaunchShipMessage { nation_id, target_tile, troops }); + } + } +} + +/// Handle nation spawn at a given tile +#[allow(clippy::too_many_arguments)] +pub fn handle_spawn(nation_id: NationId, tile: U16Vec2, territory_manager: &mut TerritoryManager, terrain: &TerrainData, active_attacks: &mut ActiveAttacks, rng: &DeterministicRng, entity_map: &NationEntityMap, nations: &mut Query<(&mut Troops, &mut TerritorySize)>) { + if territory_manager.has_owner(tile) || !terrain.is_conquerable(tile) { + tracing::debug!( + nation_id = %nation_id, + ?tile, + "Spawn on occupied/water tile ignored" + ); + return; + } + + // Claim 5x5 territory around spawn point + let size = territory_manager.size(); + + // We need to work with territory data directly to use the helper function + // Convert TerritoryManager slice to Vec for modification + let mut territories: Vec<_> = territory_manager.as_slice().to_vec(); + let changed = crate::game::systems::spawn_territory::claim_spawn_territory(tile, nation_id, &mut territories, terrain, size); + + // Apply changes back to TerritoryManager + if !changed.is_empty() { + for &tile_pos in &changed { + territory_manager.conquer(tile_pos, nation_id); + } + + // Update nation stats + if let Some(&entity) = entity_map.0.get(&nation_id) + && let Ok((_, mut territory_size)) = nations.get_mut(entity) + { + territory_size.0 += changed.len() as u32; + } + + // Notify active attacks that territory changed + for &t in &changed { + active_attacks.handle_territory_add(t, nation_id, territory_manager, terrain, rng); + } + } +} + +/// Handle an attack action +#[allow(clippy::too_many_arguments)] +pub fn handle_attack(nation_id: NationId, target: Option, troops: u32, turn_number: u64, territory_manager: &TerritoryManager, terrain: &TerrainData, active_attacks: &mut ActiveAttacks, rng: &DeterministicRng, nation_borders: &HashMap>, entity_map: &NationEntityMap, nations: &mut Query<(&mut Troops, &mut TerritorySize)>) { + handle_attack_internal(nation_id, target, TroopCount::Absolute(troops), true, None, turn_number, territory_manager, terrain, active_attacks, rng, nation_borders, entity_map, nations); +} + +/// Handle attack with specific border tiles and troop allocation +#[allow(clippy::too_many_arguments)] +pub fn handle_attack_internal(nation_id: NationId, target: Option, troop_count: TroopCount, deduct_from_nation: bool, border_tiles: Option<&HashSet>, turn_number: u64, territory_manager: &TerritoryManager, terrain: &TerrainData, active_attacks: &mut ActiveAttacks, rng: &DeterministicRng, nation_borders: &HashMap>, entity_map: &NationEntityMap, nations: &mut Query<(&mut Troops, &mut TerritorySize)>) { + // Validate not attacking self + if target == Some(nation_id) { + tracing::debug!( + nation_id = ?nation_id, + "Attack on own nation ignored" + ); + return; + } + + let troops = match troop_count { + TroopCount::Ratio(ratio) => { + let Some(&entity) = entity_map.0.get(&nation_id) else { + return; + }; + if let Ok((troops, _)) = nations.get(entity) { + troops.0 * ratio + } else { + return; + } + } + TroopCount::Absolute(count) => count as f32, + }; + + // Clamp troops to available and deduct from nation's pool when creating the attack (if requested) + if deduct_from_nation { + let Some(&entity) = entity_map.0.get(&nation_id) else { + return; + }; + if let Ok((mut troops_comp, _)) = nations.get_mut(entity) { + let available = troops_comp.0; + let clamped_troops = troops.min(available); + + if troops > available { + tracing::warn!( + nation_id = ?nation_id, + requested = troops, + available = available, + "Attack requested more troops than available, clamping to available" + ); + } + + troops_comp.0 = remove_troops(troops_comp.0, clamped_troops); + } else { + return; + } + } + + let border_tiles_to_use = border_tiles.or_else(|| nation_borders.get(&nation_id).copied()); + + match target { + None => { + // Attack unclaimed territory + if entity_map.0.contains_key(&nation_id) { + active_attacks.schedule_unclaimed(nation_id, troops, border_tiles_to_use, territory_manager, terrain, nation_borders, turn_number, rng); + } + } + Some(target_id) => { + // Attack specific nation + let attacker_exists = entity_map.0.contains_key(&nation_id); + let target_exists = entity_map.0.contains_key(&target_id); + + if attacker_exists && target_exists { + active_attacks.schedule_attack(nation_id, target_id, troops, border_tiles_to_use, territory_manager, terrain, nation_borders, turn_number, rng); + } + } + } +} diff --git a/crates/borders-core/src/game/core/utils.rs b/crates/borders-core/src/game/core/utils.rs new file mode 100644 index 0000000..b9fe2ae --- /dev/null +++ b/crates/borders-core/src/game/core/utils.rs @@ -0,0 +1,45 @@ +use glam::{I16Vec2, U16Vec2}; + +/// Serde helper for U16Vec2 serialization +pub mod u16vec2_serde { + use serde::{Deserialize, Deserializer, Serialize, Serializer}; + + pub fn serialize(vec: &glam::U16Vec2, serializer: S) -> Result + where + S: Serializer, + { + (vec.x, vec.y).serialize(serializer) + } + + pub fn deserialize<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let (x, y) = <(u16, u16)>::deserialize(deserializer)?; + Ok(glam::U16Vec2::new(x, y)) + } +} + +/// Returns an iterator over all valid cardinal neighbors of a tile position. +/// +/// Yields positions for left, right, up, and down neighbors that are within bounds. +/// Handles boundary checks for the 4-connected grid. +/// +/// # Examples +/// ``` +/// use glam::U16Vec2; +/// use borders_core::game::utils::neighbors; +/// +/// let size = U16Vec2::new(10, 10); +/// let tile = U16Vec2::new(5, 5); +/// let neighbor_count = neighbors(tile, size).count(); +/// assert_eq!(neighbor_count, 4); +/// ``` +pub fn neighbors(tile: U16Vec2, size: U16Vec2) -> impl Iterator { + const CARDINAL_DIRECTIONS: [I16Vec2; 4] = [I16Vec2::new(-1, 0), I16Vec2::new(1, 0), I16Vec2::new(0, -1), I16Vec2::new(0, 1)]; + + CARDINAL_DIRECTIONS.into_iter().filter_map(move |offset| { + let neighbor = tile.checked_add_signed(offset)?; + if neighbor.x < size.x && neighbor.y < size.y { Some(neighbor) } else { None } + }) +} diff --git a/crates/borders-core/src/game/entities.rs b/crates/borders-core/src/game/entities.rs new file mode 100644 index 0000000..76fcb28 --- /dev/null +++ b/crates/borders-core/src/game/entities.rs @@ -0,0 +1,146 @@ +use bevy_ecs::prelude::*; +use std::collections::{HashMap, HashSet}; +use std::ops::{Deref, DerefMut}; + +use crate::game::core::constants::nation::*; +use crate::game::world::NationId; + +/// Marker component to identify eliminated nations +/// Alive nations are identified by the ABSENCE of this component +/// Use Without in queries to filter for alive nations +#[derive(Component, Debug, Clone, Copy, Default)] +pub struct Dead; + +/// Nation name component +#[derive(Component, Debug, Clone)] +pub struct NationName(pub String); + +/// Nation color component +#[derive(Component, Debug, Clone, Copy)] +pub struct NationColor(pub HSLColor); + +/// Border tiles component - tiles at the edge of a nation's territory +#[derive(Component, Debug, Clone, Default)] +pub struct BorderTiles(pub HashSet); + +impl Deref for BorderTiles { + type Target = HashSet; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for BorderTiles { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +/// Troops component - current troop count +#[derive(Component, Debug, Clone, Copy)] +pub struct Troops(pub f32); + +/// Territory size component - number of tiles owned +#[derive(Component, Debug, Clone, Copy)] +pub struct TerritorySize(pub u32); + +/// Maps nation IDs to their ECS entities for O(1) lookup +/// +/// This resource enables systems to quickly find a nation's entity +/// by their nation_id without iterating through all entities. +#[derive(Resource, Default)] +pub struct NationEntityMap(pub HashMap); + +impl NationEntityMap { + /// Get the entity for a nation, panicking if not found + /// + /// # Panics + /// Panics if the nation ID is not in the map + #[inline] + pub fn get_entity(&self, nation_id: NationId) -> Entity { + *self.0.get(&nation_id).unwrap_or_else(|| panic!("Nation entity not found for nation {}", nation_id.get())) + } + + /// Try to get the entity for a nation + /// + /// Returns None if the nation ID is not in the map + #[inline] + pub fn try_get_entity(&self, nation_id: NationId) -> Option { + self.0.get(&nation_id).copied() + } +} + +/// HSL Color representation +#[derive(Debug, Clone, Copy)] +pub struct HSLColor { + pub h: f32, // Hue: 0-360 + pub s: f32, // Saturation: 0-1 + pub l: f32, // Lightness: 0-1 +} + +impl HSLColor { + pub fn new(h: f32, s: f32, l: f32) -> Self { + Self { h, s, l } + } + + pub fn to_rgba(&self) -> [f32; 4] { + let c = (1.0 - (2.0 * self.l - 1.0).abs()) * self.s; + let h_prime = self.h / 60.0; + let x = c * (1.0 - ((h_prime % 2.0) - 1.0).abs()); + + let (r1, g1, b1) = if h_prime < 1.0 { + (c, x, 0.0) + } else if h_prime < 2.0 { + (x, c, 0.0) + } else if h_prime < 3.0 { + (0.0, c, x) + } else if h_prime < 4.0 { + (0.0, x, c) + } else if h_prime < 5.0 { + (x, 0.0, c) + } else { + (c, 0.0, x) + }; + + let m = self.l - c / 2.0; + [r1 + m, g1 + m, b1 + m, 1.0] + } +} + +/// Calculate maximum troop capacity based on territory size +#[inline] +pub fn calculate_max_troops(territory_size: u32, is_bot: bool) -> f32 { + let base_max = MAX_TROOPS_MULTIPLIER * ((territory_size as f32).powf(MAX_TROOPS_POWER) * MAX_TROOPS_SCALE + MAX_TROOPS_BASE); + + if is_bot { base_max * BOT_MAX_TROOPS_MULTIPLIER } else { base_max } +} + +/// Calculate income for this tick based on current troops and territory +#[inline] +pub fn calculate_income(troops: f32, territory_size: u32, is_bot: bool) -> f32 { + let max_troops = calculate_max_troops(territory_size, is_bot); + + // Base income calculation + let mut income = BASE_INCOME + (troops.powf(INCOME_POWER) / INCOME_DIVISOR); + + // Soft cap as approaching max troops + let ratio = 1.0 - (troops / max_troops); + income *= ratio; + + // Apply bot modifier + if is_bot { income * BOT_INCOME_MULTIPLIER } else { income } +} + +/// Add troops with max cap enforcement +#[inline] +pub fn add_troops_capped(current: f32, amount: f32, territory_size: u32, is_bot: bool) -> f32 { + let max_troops = calculate_max_troops(territory_size, is_bot); + (current + amount).min(max_troops) +} + +/// Remove troops, ensuring non-negative result +#[inline] +pub fn remove_troops(current: f32, amount: f32) -> f32 { + (current - amount).max(0.0) +} diff --git a/crates/borders-core/src/game/input/context.rs b/crates/borders-core/src/game/input/context.rs new file mode 100644 index 0000000..2649a43 --- /dev/null +++ b/crates/borders-core/src/game/input/context.rs @@ -0,0 +1,66 @@ +use bevy_ecs::prelude::*; +use serde::{Deserialize, Serialize}; + +use crate::game::NationId; + +/// Represents the outcome for a specific player (local, not shared) +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +pub enum PlayerOutcome { + /// Player has won the game + Victory, + /// Player has been eliminated/defeated + Defeat, +} + +/// Local player context - CLIENT-SPECIFIC state, NOT part of deterministic game state +/// +/// **Important: This is LOCAL context, not shared/deterministic state!** +/// +/// This resource contains information specific to THIS client's perspective: +/// - Which player ID this client controls +/// - Whether this player won/lost (irrelevant to other clients) +/// - Whether this client can send commands or is spectating +/// +/// In multiplayer: +/// - Each client has their own LocalPlayerContext with different player IDs +/// - One client may have `my_outcome = Victory` while others have `Defeat` +/// - A spectator would have `can_send_intents = false` +/// - The shared game state continues running regardless +#[derive(Resource)] +pub struct LocalPlayerContext { + /// The player ID for this client + pub id: NationId, + + /// The outcome for this specific player (if determined) + /// None = still playing, Some(Victory/Defeat) = game ended for this player + pub my_outcome: Option, + + /// Whether this client can send intents (false when defeated or spectating) + pub can_send_intents: bool, +} + +impl LocalPlayerContext { + /// Create a new local player context for the given player ID + pub fn new(id: NationId) -> Self { + Self { id, my_outcome: None, can_send_intents: true } + } + + /// Mark the local player as defeated + pub fn mark_defeated(&mut self) { + self.my_outcome = Some(PlayerOutcome::Defeat); + self.can_send_intents = false; + } + + /// Mark the local player as victorious + pub fn mark_victorious(&mut self) { + self.my_outcome = Some(PlayerOutcome::Victory); + // Player can still send intents after victory (to continue playing if desired) + // Or set to false if you want to prevent further actions + } + + /// Check if the local player is still actively playing + #[inline] + pub fn is_playing(&self) -> bool { + self.my_outcome.is_none() && self.can_send_intents + } +} diff --git a/crates/borders-core/src/game/input/events.rs b/crates/borders-core/src/game/input/events.rs new file mode 100644 index 0000000..d7974de --- /dev/null +++ b/crates/borders-core/src/game/input/events.rs @@ -0,0 +1,68 @@ +//! Input event and message types + +use bevy_ecs::message::Message; +use glam::{U16Vec2, Vec2}; +use serde::{Deserialize, Serialize}; + +use super::types::{ButtonState, KeyCode, MouseButton}; + +/// Raw input events sent by platforms via the input queue +#[derive(Debug, Clone, Serialize, Deserialize)] +pub enum InputEvent { + /// Mouse button pressed or released + MouseButton { button: MouseButton, state: ButtonState, tile: Option, world_pos: Vec2 }, + /// Mouse moved over the map + MouseMotion { tile: Option, world_pos: Vec2 }, + /// Keyboard key pressed or released + KeyEvent { key: KeyCode, state: ButtonState }, +} + +/// Mouse button message +#[derive(Message, Debug, Clone)] +pub struct MouseButtonMessage { + pub button: MouseButton, + pub state: ButtonState, + pub tile: Option, + pub world_pos: Vec2, +} + +/// Mouse motion message +#[derive(Message, Debug, Clone)] +pub struct MouseMotionMessage { + pub tile: Option, + pub world_pos: Vec2, +} + +/// Keyboard key message +#[derive(Message, Debug, Clone)] +pub struct KeyEventMessage { + pub key: KeyCode, + pub state: ButtonState, +} + +/// A tile was clicked +#[derive(Message, Debug, Clone)] +pub struct TileClickedAction { + pub tile: U16Vec2, + pub button: MouseButton, +} + +/// Camera-related actions +#[derive(Message, Debug, Clone)] +pub enum CameraAction { + /// Center camera on player territory + Center, + /// Camera drag/interaction started + InteractionStarted, + /// Camera drag/interaction ended + InteractionEnded, +} + +/// UI-related actions +#[derive(Message, Debug, Clone)] +pub enum UiAction { + /// Adjust attack ratio by amount + UpdateAttackRatio { amount: f32 }, + /// Toggle pause + TogglePause, +} diff --git a/crates/borders-core/src/game/input/handlers.rs b/crates/borders-core/src/game/input/handlers.rs new file mode 100644 index 0000000..fd13c47 --- /dev/null +++ b/crates/borders-core/src/game/input/handlers.rs @@ -0,0 +1,213 @@ +//! Action handler systems - process semantic input actions + +use bevy_ecs::prelude::*; +use tracing::{debug, info, trace}; + +use crate::game::core::constants::input::*; +use crate::game::systems::borders::BorderCache; +use crate::game::terrain::TerrainData; +use crate::game::{BorderTiles, CoastalTiles, GameAction, LocalPlayerContext, NationEntityMap, SpawnManager, SpawnTimeout, TerritoryManager, Troops}; +use crate::networking::{Intent, IntentEvent}; + +use super::events::{CameraAction, TileClickedAction, UiAction}; + +/// Resource tracking whether spawn phase is active +#[derive(Resource, Default)] +pub struct SpawnPhase { + pub active: bool, +} + +/// Resource for attack control settings +#[derive(Resource)] +pub struct AttackControls { + pub attack_ratio: f32, +} + +impl Default for AttackControls { + fn default() -> Self { + Self { attack_ratio: DEFAULT_ATTACK_RATIO } + } +} + +/// Handle tile clicks during spawn and gameplay phases +#[allow(clippy::too_many_arguments)] +pub fn handle_tile_clicked_system(mut tile_clicked: MessageReader, spawn_phase: Res, local_context: If>, mut spawn_manager: Option>, mut spawn_timeout: Option>, mut intent_writer: MessageWriter, territory_manager: Res, terrain: Res, coastal_tiles: Res, attack_controls: Res, entity_map: Res, border_query: Query<&BorderTiles>, troops_query: Query<&Troops>) { + // Can't interact if not allowed to send intents + if !local_context.can_send_intents { + return; + }; + + for action in tile_clicked.read() { + if spawn_phase.active { + // Spawn phase logic + handle_spawn_click(action.tile, local_context.as_ref(), &mut spawn_manager, &mut spawn_timeout, &mut intent_writer, &territory_manager, &terrain); + } else { + // Gameplay phase logic + handle_attack_click(action.tile, local_context.as_ref(), &territory_manager, &terrain, &coastal_tiles, &attack_controls, &mut intent_writer, &entity_map, &border_query, &troops_query); + } + } +} + +/// Handle spawn click logic +#[allow(clippy::too_many_arguments)] +fn handle_spawn_click(tile_coord: glam::U16Vec2, local_context: &LocalPlayerContext, spawn_manager: &mut Option>, spawn_timeout: &mut Option>, intent_writer: &mut MessageWriter, territory_manager: &TerritoryManager, terrain: &TerrainData) { + let _guard = tracing::trace_span!("spawn_click").entered(); + + let tile_ownership = territory_manager.get_ownership(tile_coord); + if tile_ownership.is_owned() { + debug!("Spawn click on tile {:?} ignored - occupied", tile_coord); + return; + } + + // Check if tile is water/unconquerable + if !terrain.is_conquerable(tile_coord) { + debug!("Spawn click on tile {:?} ignored - water or unconquerable", tile_coord); + return; + } + + // Player has chosen a spawn location - send to server + info!("Player {} setting spawn at tile {:?}", local_context.id.get(), tile_coord); + + // Check if this is the first spawn (timer not started yet) + let is_first_spawn = if let Some(spawn_mgr) = spawn_manager { spawn_mgr.get_player_spawns().is_empty() } else { true }; + + // Send SetSpawn intent to server (not Action - this won't be in game history) + // Server will validate, track, and eventually send Turn(0) when timeout expires + intent_writer.write(IntentEvent(Intent::SetSpawn { tile_index: tile_coord })); + + // Start spawn timeout on first spawn (spawn_phase plugin will emit countdown updates) + if is_first_spawn && let Some(timeout) = spawn_timeout { + timeout.start(); + info!("Spawn timeout started ({:.1}s)", timeout.duration_secs); + } + + // Update local spawn manager for preview/bot recalculation + // Note: This only updates the spawn manager, not the game instance + // The actual game state is updated when Turn(0) is processed + if let Some(spawn_mgr) = spawn_manager { + // Update spawn manager (triggers bot spawn recalculation) + spawn_mgr.update_player_spawn(local_context.id, tile_coord, territory_manager, terrain); + + info!("Spawn manager updated with player {} spawn at tile {:?}", local_context.id.get(), tile_coord); + info!("Total spawns in manager: {}", spawn_mgr.get_all_spawns().len()); + } +} + +/// Handle attack click logic +#[allow(clippy::too_many_arguments)] +fn handle_attack_click(tile_coord: glam::U16Vec2, local_context: &LocalPlayerContext, territory_manager: &TerritoryManager, terrain: &TerrainData, coastal_tiles: &CoastalTiles, attack_controls: &AttackControls, intent_writer: &mut MessageWriter, entity_map: &NationEntityMap, border_query: &Query<&BorderTiles>, troops_query: &Query<&Troops>) { + let _guard = tracing::trace_span!("attack_click").entered(); + + let tile_ownership = territory_manager.get_ownership(tile_coord); + let nation_id = local_context.id; + + // Can't attack own tiles + if tile_ownership.is_owned_by(nation_id) { + return; + } + + // Check if target is water - ignore water clicks + if terrain.is_navigable(tile_coord) { + return; + } + + // Check if target is connected to player's territory + let size = territory_manager.size(); + let is_connected = crate::game::connectivity::is_connected_to_player(territory_manager.as_slice(), terrain, tile_coord, nation_id, size); + + if is_connected { + // Target is connected to player's territory - use normal attack + // Calculate absolute troop count from ratio + let troops = if let Some(&entity) = entity_map.0.get(&nation_id) + && let Ok(troops_comp) = troops_query.get(entity) + { + (troops_comp.0 * attack_controls.attack_ratio).floor() as u32 + } else { + 0 + }; + + intent_writer.write(IntentEvent(Intent::Action(GameAction::Attack { target: tile_ownership.nation_id(), troops }))); + return; + } + + // Target is NOT connected - need to use ship + debug!("Target {:?} not connected to player territory, attempting ship launch", tile_coord); + + // Find target's nearest coastal tile + let target_coastal_tile = crate::game::connectivity::find_coastal_tile_in_region(territory_manager.as_slice(), terrain, tile_coord, size); + + let Some(target_coastal_tile) = target_coastal_tile else { + debug!("No coastal tile found in target's region for tile {:?}", tile_coord); + return; + }; + + // Find player's nearest coastal tile using O(1) entity lookup + let player_border_tiles = entity_map.0.get(&nation_id).and_then(|&entity| border_query.get(entity).ok()); + + let launch_tile = player_border_tiles.and_then(|tiles| crate::game::ships::pathfinding::find_nearest_player_coastal_tile(coastal_tiles.tiles(), tiles, target_coastal_tile)); + + let Some(launch_tile) = launch_tile else { + debug!("Player has no coastal tiles to launch ship from"); + return; + }; + + debug!("Found launch tile {:?} and target coastal tile {:?} for target {:?}", launch_tile, target_coastal_tile, tile_coord); + + // Try to find a water path from launch tile to target coastal tile + let path = crate::game::ships::pathfinding::find_water_path(terrain, launch_tile, target_coastal_tile, crate::game::ships::MAX_PATH_LENGTH); + + if let Some(_path) = path { + // We can reach the target by ship! + // Calculate absolute troop count from ratio + let troops = if let Some(&entity) = entity_map.0.get(&nation_id) + && let Ok(troops_comp) = troops_query.get(entity) + { + (troops_comp.0 * attack_controls.attack_ratio).floor() as u32 + } else { + 0 + }; + + debug!("Launching ship to target {:?} with {} troops", tile_coord, troops); + + intent_writer.write(IntentEvent(Intent::Action(GameAction::LaunchShip { target_tile: tile_coord, troops }))); + } else { + debug!("No water path found from {:?} to {:?}", launch_tile, target_coastal_tile); + } +} + +/// Handle camera actions +pub fn handle_camera_action_system(mut camera_actions: MessageReader, border_cache: Res, local_context: If>) { + for action in camera_actions.read() { + match action { + CameraAction::Center => { + // Find any owned tile to center on + if let Some(_tile) = border_cache.get(local_context.id).and_then(|tiles| tiles.iter().next().copied()) { + // TODO: Implement camera centering when camera commands are added + tracing::debug!("Camera center requested (not implemented)"); + } + } + CameraAction::InteractionStarted => { + trace!("Camera interaction started"); + } + CameraAction::InteractionEnded => { + trace!("Camera interaction ended"); + } + } + } +} + +/// Handle UI actions +pub fn handle_ui_action_system(mut ui_actions: MessageReader, mut attack_controls: ResMut) { + for action in ui_actions.read() { + match action { + UiAction::UpdateAttackRatio { amount } => { + attack_controls.attack_ratio = (attack_controls.attack_ratio + amount).clamp(ATTACK_RATIO_MIN, ATTACK_RATIO_MAX); + debug!("Attack ratio changed to {:.1}", attack_controls.attack_ratio); + } + UiAction::TogglePause => { + // TODO: Implement pause functionality + debug!("Pause toggle requested (not implemented)"); + } + } + } +} diff --git a/crates/borders-core/src/game/input/mod.rs b/crates/borders-core/src/game/input/mod.rs new file mode 100644 index 0000000..e3f8761 --- /dev/null +++ b/crates/borders-core/src/game/input/mod.rs @@ -0,0 +1,17 @@ +//! Player input handling +//! +//! This module handles player input events and local player context. + +pub mod context; +pub mod events; +pub mod handlers; +pub mod processor; +pub mod queue; +pub mod types; + +pub use context::*; +pub use events::*; +pub use handlers::*; +pub use processor::*; +pub use queue::*; +pub use types::*; diff --git a/crates/borders-core/src/game/input/processor.rs b/crates/borders-core/src/game/input/processor.rs new file mode 100644 index 0000000..2833d03 --- /dev/null +++ b/crates/borders-core/src/game/input/processor.rs @@ -0,0 +1,70 @@ +//! Input processor system - converts raw input into action messages + +use bevy_ecs::prelude::*; + +use crate::game::core::constants::input::*; + +use super::events::*; +use super::types::{ButtonState, KeyCode, MouseButton}; + +/// Processes raw input messages and emits action messages +/// +/// This system runs in PreUpdate and: +/// 1. Reads raw MouseButtonMessage, KeyEventMessage from the queue +/// 2. Filters out camera drags (clicks during middle mouse drag) +/// 3. Emits semantic action messages (TileClickedAction, CameraAction, UiAction) +/// +/// Action handler systems in Update consume these action messages. +pub fn input_processor_system(mut mouse_events: MessageReader, mut key_events: MessageReader, mut tile_clicked: MessageWriter, mut camera_action: MessageWriter, mut ui_action: MessageWriter, mut camera_dragging: Local) { + // Process mouse button events + for event in mouse_events.read() { + match event.button { + MouseButton::Left => match event.state { + ButtonState::Pressed => { + // Reset camera drag flag on new press + *camera_dragging = false; + } + ButtonState::Released => { + // Only emit TileClicked if no camera drag occurred + if !*camera_dragging && let Some(tile) = event.tile { + tile_clicked.write(TileClickedAction { tile, button: event.button }); + } + *camera_dragging = false; + } + }, + MouseButton::Middle => { + if event.state == ButtonState::Pressed { + *camera_dragging = true; + camera_action.write(CameraAction::InteractionStarted); + } else { + camera_action.write(CameraAction::InteractionEnded); + } + } + _ => {} + } + } + + // Process keyboard events + for event in key_events.read() { + // Only process key presses (not releases) + if event.state != ButtonState::Pressed { + continue; + } + + match event.key { + KeyCode::KeyC => { + camera_action.write(CameraAction::Center); + } + KeyCode::Digit1 => { + ui_action.write(UiAction::UpdateAttackRatio { amount: -ATTACK_RATIO_STEP }); + } + KeyCode::Digit2 => { + ui_action.write(UiAction::UpdateAttackRatio { amount: ATTACK_RATIO_STEP }); + } + KeyCode::Space => { + ui_action.write(UiAction::TogglePause); + } + _ => {} + } + } +} diff --git a/crates/borders-core/src/game/input/queue.rs b/crates/borders-core/src/game/input/queue.rs new file mode 100644 index 0000000..799c3ae --- /dev/null +++ b/crates/borders-core/src/game/input/queue.rs @@ -0,0 +1,40 @@ +//! Async input queue for platform-to-game communication + +use flume::{Receiver, Sender}; + +use super::events::InputEvent; + +/// Input queue using flume channel for lock-free, async-friendly input handling +/// +/// Platforms send InputEvent via the sender, and Game drains them each frame +/// before running systems. This decouples platform input from ECS execution. +pub struct InputQueue { + sender: Sender, + receiver: Receiver, +} + +impl InputQueue { + /// Create a new unbounded input queue + pub fn new() -> Self { + let (sender, receiver) = flume::unbounded(); + Self { sender, receiver } + } + + /// Get a sender for platforms to send input events + pub fn sender(&self) -> Sender { + self.sender.clone() + } + + /// Drain all pending input events from the queue + /// + /// Called internally by Game::update() to convert queued events into Bevy messages + pub(crate) fn drain(&self) -> impl Iterator + '_ { + self.receiver.try_iter() + } +} + +impl Default for InputQueue { + fn default() -> Self { + Self::new() + } +} diff --git a/crates/borders-core/src/game/input/types.rs b/crates/borders-core/src/game/input/types.rs new file mode 100644 index 0000000..95d41eb --- /dev/null +++ b/crates/borders-core/src/game/input/types.rs @@ -0,0 +1,34 @@ +//! Input type definitions + +use serde::{Deserialize, Serialize}; + +/// Mouse button types +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum MouseButton { + Left, + Middle, + Right, + Back, + Forward, +} + +/// Button state (pressed or released) +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum ButtonState { + Pressed, + Released, +} + +/// Keyboard key codes +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum KeyCode { + KeyW, + KeyA, + KeyS, + KeyD, + KeyC, + Digit1, + Digit2, + Space, + Escape, +} diff --git a/crates/borders-core/src/game/mod.rs b/crates/borders-core/src/game/mod.rs new file mode 100644 index 0000000..c85b60a --- /dev/null +++ b/crates/borders-core/src/game/mod.rs @@ -0,0 +1,206 @@ +//! Game logic and state management +//! +//! This module contains all game-related functionality organized by domain. + +// Core modules +pub mod ai; +pub mod builder; +pub mod combat; +pub mod core; +pub mod entities; +pub mod input; +pub mod queries; +pub mod ships; +pub mod systems; +pub mod terrain; +pub mod world; + +// Re-exports from submodules +pub use builder::*; +pub use combat::*; +pub use core::*; +pub use entities::*; +pub use input::*; +pub use queries::*; +pub use ships::*; +pub use systems::*; +pub use terrain::*; +pub use world::*; + +use bevy_ecs::message::{Message, Messages}; +use bevy_ecs::prelude::*; +use bevy_ecs::schedule::{IntoScheduleConfigs, ScheduleLabel, Schedules}; +use bevy_ecs::system::ScheduleSystem; +use std::fmt::Debug; +use std::sync::Arc; + +#[derive(Debug, Hash, PartialEq, Eq, Clone, ScheduleLabel)] +pub struct Startup; + +#[derive(Debug, Hash, PartialEq, Eq, Clone, ScheduleLabel)] +pub struct Update; + +#[derive(Debug, Hash, PartialEq, Eq, Clone, ScheduleLabel)] +pub struct Last; + +pub struct Game { + world: World, + input_queue: Option>, +} + +impl std::ops::Deref for Game { + type Target = World; + + fn deref(&self) -> &Self::Target { + &self.world + } +} + +impl std::ops::DerefMut for Game { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.world + } +} + +impl Game { + /// Internal method for creating an uninitialized Game + /// + /// This is used internally by GameBuilder and for test setup. + /// Most users should use `GameBuilder` instead. + #[doc(hidden)] + pub fn new_internal() -> Self { + let mut world = World::new(); + + // Initialize schedules with proper ordering + let mut schedules = Schedules::new(); + schedules.insert(Schedule::new(Startup)); + schedules.insert(Schedule::new(Update)); + schedules.insert(Schedule::new(Last)); + + world.insert_resource(schedules); + + Self { world, input_queue: None } + } + + pub fn world(&self) -> &World { + &self.world + } + + pub fn world_mut(&mut self) -> &mut World { + &mut self.world + } + + pub fn insert_resource(&mut self, resource: R) -> &mut Self { + self.world.insert_resource(resource); + self + } + + pub fn init_resource(&mut self) -> &mut Self { + self.world.init_resource::(); + self + } + + pub fn insert_non_send_resource(&mut self, resource: R) -> &mut Self { + self.world.insert_non_send_resource(resource); + self + } + + pub fn add_message(&mut self) -> &mut Self { + if !self.world.contains_resource::>() { + self.world.init_resource::>(); + + // Add system to update this message type each frame + self.add_systems(Last, |mut messages: ResMut>| { + messages.update(); + }); + } + self + } + + pub fn add_systems(&mut self, schedule: impl ScheduleLabel, systems: impl IntoScheduleConfigs) -> &mut Self { + let mut schedules = self.world.resource_mut::(); + if let Some(schedule_inst) = schedules.get_mut(schedule) { + schedule_inst.add_systems(systems); + } + self + } + + /// Process queued input events and send them as Bevy messages + /// + /// Called internally by update() at the start of each frame to drain the + /// input queue and convert InputEvents into Bevy messages. + fn process_input_queue(&mut self) { + let Some(queue) = &self.input_queue else { + return; + }; + + for event in queue.drain() { + match event { + input::InputEvent::MouseButton { button, state, tile, world_pos } => { + self.world.write_message(input::MouseButtonMessage { button, state, tile, world_pos }); + } + input::InputEvent::MouseMotion { tile, world_pos } => { + self.world.write_message(input::MouseMotionMessage { tile, world_pos }); + } + input::InputEvent::KeyEvent { key, state } => { + self.world.write_message(input::KeyEventMessage { key, state }); + } + } + } + } + + pub fn update(&mut self) { + let _guard = tracing::trace_span!("game_update").entered(); + + // Process queued input at the start of each frame + self.process_input_queue(); + + // Remove schedules temporarily to avoid resource_scope conflicts + let mut schedules = self.world.remove_resource::().unwrap(); + + // Run Update schedule + if let Some(schedule) = schedules.get_mut(Update) { + let _guard = tracing::trace_span!("update_schedule").entered(); + schedule.run(&mut self.world); + } + + // Run Last schedule (includes event updates) + if let Some(schedule) = schedules.get_mut(Last) { + let _guard = tracing::trace_span!("last_schedule").entered(); + schedule.run(&mut self.world); + } + + // Re-insert schedules + self.world.insert_resource(schedules); + } + + pub fn run_startup(&mut self) { + let _guard = tracing::trace_span!("run_startup_schedule").entered(); + + // Remove schedules temporarily to avoid resource_scope conflicts + let mut schedules = self.world.remove_resource::().unwrap(); + + // Run Startup schedule + if let Some(schedule) = schedules.get_mut(Startup) { + schedule.run(&mut self.world); + } + + // Re-insert schedules + self.world.insert_resource(schedules); + } + + pub fn finish(&mut self) { + // Finalize schedules + let mut schedules = self.world.remove_resource::().unwrap(); + + let system_count: usize = schedules.iter().map(|(_, schedule)| schedule.systems().map(|iter| iter.count()).unwrap_or(0)).sum(); + + let _guard = tracing::trace_span!("finish_schedules", system_count = system_count).entered(); + + for (_, schedule) in schedules.iter_mut() { + schedule.graph_mut().initialize(&mut self.world); + } + + self.world.insert_resource(schedules); + } +} diff --git a/crates/borders-core/src/game/queries.rs b/crates/borders-core/src/game/queries.rs new file mode 100644 index 0000000..40f5f1b --- /dev/null +++ b/crates/borders-core/src/game/queries.rs @@ -0,0 +1,19 @@ +//! ECS query helper utilities for common game state queries + +use glam::U16Vec2; + +use crate::game::systems::borders::BorderCache; +use crate::game::{NationId, TerritoryManager}; + +/// Find any tile owned by a specific nation (useful for camera centering) +/// Returns the tile position if found +#[inline] +pub fn find_nation_tile(border_cache: &BorderCache, nation_id: NationId) -> Option { + border_cache.get(nation_id)?.iter().next().copied() +} + +/// Count the total number of conquerable (non-water, owned) tiles on the map +#[inline] +pub fn count_land_tiles(territory_manager: &TerritoryManager) -> u32 { + territory_manager.as_slice().iter().filter(|ownership| ownership.is_owned()).count() as u32 +} diff --git a/crates/borders-core/src/game/ships/components.rs b/crates/borders-core/src/game/ships/components.rs new file mode 100644 index 0000000..d5e9438 --- /dev/null +++ b/crates/borders-core/src/game/ships/components.rs @@ -0,0 +1,100 @@ +use bevy_ecs::prelude::*; +use glam::U16Vec2; + +/// Ship component containing all ship state +#[derive(Component, Debug, Clone)] +pub struct Ship { + pub id: u32, + pub troops: u32, + pub path: Vec, + pub current_path_index: usize, + pub ticks_per_tile: u32, + pub ticks_since_move: u32, + pub launch_tick: u64, + pub target_tile: U16Vec2, +} + +impl Ship { + /// Create a new ship + pub fn new(id: u32, troops: u32, path: Vec, ticks_per_tile: u32, launch_tick: u64) -> Self { + let target_tile = *path.last().unwrap_or(&path[0]); + + Self { id, troops, path, current_path_index: 0, ticks_per_tile, ticks_since_move: 0, launch_tick, target_tile } + } + + /// Update the ship's position based on the current tick + /// Returns true if the ship has reached its destination + pub fn update(&mut self) -> bool { + if self.has_arrived() { + return true; + } + + self.ticks_since_move += 1; + + if self.ticks_since_move >= self.ticks_per_tile { + self.ticks_since_move = 0; + self.current_path_index += 1; + + if self.has_arrived() { + return true; + } + } + + false + } + + /// Get the current tile the ship is on + #[inline] + pub fn get_current_tile(&self) -> U16Vec2 { + if self.current_path_index < self.path.len() { self.path[self.current_path_index] } else { self.target_tile } + } + + /// Check if the ship has reached its destination + #[inline] + pub fn has_arrived(&self) -> bool { + self.current_path_index >= self.path.len() - 1 + } + + /// Get interpolation factor for smooth rendering (0.0 to 1.0) + #[inline] + pub fn get_visual_interpolation(&self) -> f32 { + if self.ticks_per_tile == 0 { + return 1.0; + } + self.ticks_since_move as f32 / self.ticks_per_tile as f32 + } + + /// Get the next tile in the path (for interpolation) + #[inline] + pub fn get_next_tile(&self) -> Option { + if self.current_path_index + 1 < self.path.len() { Some(self.path[self.current_path_index + 1]) } else { None } + } +} + +/// Component tracking number of ships owned by a player +#[derive(Component, Debug, Clone, Copy, Default)] +pub struct ShipCount(pub usize); + +/// Resource for generating unique ship IDs +#[derive(Resource)] +pub struct ShipIdCounter { + next_id: u32, +} + +impl ShipIdCounter { + pub fn new() -> Self { + Self { next_id: 1 } + } + + pub fn generate_id(&mut self) -> u32 { + let id = self.next_id; + self.next_id += 1; + id + } +} + +impl Default for ShipIdCounter { + fn default() -> Self { + Self::new() + } +} diff --git a/crates/borders-core/src/game/ships/mod.rs b/crates/borders-core/src/game/ships/mod.rs new file mode 100644 index 0000000..80d1729 --- /dev/null +++ b/crates/borders-core/src/game/ships/mod.rs @@ -0,0 +1,15 @@ +//! Ship system using ECS architecture. +//! +//! Ships are entities with parent-child relationships to players. +//! See systems.rs for launch/update/arrival systems. + +mod components; +pub mod pathfinding; +pub mod systems; + +pub use components::*; +pub use pathfinding::*; +pub use systems::*; + +// Re-export ship constants from central location +pub use crate::game::core::constants::ships::*; diff --git a/crates/borders-core/src/game/ships/pathfinding.rs b/crates/borders-core/src/game/ships/pathfinding.rs new file mode 100644 index 0000000..beda557 --- /dev/null +++ b/crates/borders-core/src/game/ships/pathfinding.rs @@ -0,0 +1,248 @@ +use std::cmp::Ordering; +use std::collections::{BinaryHeap, HashMap, HashSet}; + +use glam::U16Vec2; +use tracing::debug; + +use crate::game::terrain::data::TerrainData; +use crate::game::utils::neighbors; + +/// A node in the pathfinding search +#[derive(Clone, Eq, PartialEq)] +struct PathNode { + pos: U16Vec2, + g_cost: u32, // Cost from start + h_cost: u32, // Heuristic cost to goal + f_cost: u32, // Total cost (g + h) +} + +impl Ord for PathNode { + fn cmp(&self, other: &Self) -> Ordering { + // Reverse ordering for min-heap + other.f_cost.cmp(&self.f_cost) + } +} + +impl PartialOrd for PathNode { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +/// Find a water path from start_tile to target_tile using A* algorithm +/// Returns None if no path exists +pub fn find_water_path(terrain: &TerrainData, start_tile: U16Vec2, target_tile: U16Vec2, max_path_length: usize) -> Option> { + let size = terrain.size(); + + // Check if target is reachable (must be coastal or water) + if !is_valid_ship_destination(terrain, target_tile, size) { + debug!("Pathfinding failed: target {:?} is not a valid ship destination", target_tile); + return None; + } + + // Find actual water start position (adjacent to coast) + debug!("Pathfinding: looking for water launch tile adjacent to coastal tile {:?}", start_tile); + let water_start = find_water_launch_tile(terrain, start_tile, size)?; + debug!("Pathfinding: found water launch tile {:?}", water_start); + + // Find water tiles adjacent to target if target is land + let water_targets = if terrain.is_navigable(target_tile) { vec![target_tile] } else { find_adjacent_water_tiles(terrain, target_tile, size) }; + + if water_targets.is_empty() { + return None; + } + + // Run A* pathfinding + let mut open_set = BinaryHeap::new(); + let mut closed_set = HashSet::new(); + let mut came_from: HashMap = HashMap::new(); + let mut g_scores: HashMap = HashMap::new(); + + // Initialize with start node + let start_h = water_start.manhattan_distance(water_targets[0]) as u32; + open_set.push(PathNode { pos: water_start, g_cost: 0, h_cost: start_h, f_cost: start_h }); + g_scores.insert(water_start, 0); + + while let Some(current_node) = open_set.pop() { + let current_pos = current_node.pos; + + // Check if we've reached any of the target tiles + if water_targets.contains(¤t_pos) { + // Reconstruct path + let mut path = vec![current_pos]; + let mut current_tile = current_pos; + + while let Some(&parent) = came_from.get(¤t_tile) { + path.push(parent); + current_tile = parent; + + // Prevent infinite loops + if path.len() > max_path_length { + return None; + } + } + + path.reverse(); + + // If original target was land, add it to the end + if !terrain.is_navigable(target_tile) { + path.push(target_tile); + } + + return Some(path); + } + + // Skip if already processed + if closed_set.contains(¤t_pos) { + continue; + } + closed_set.insert(current_pos); + + // Check if we've exceeded max path length + if current_node.g_cost as usize > max_path_length { + continue; + } + + // Explore neighbors + for neighbor in neighbors(current_pos, size) { + if closed_set.contains(&neighbor) { + continue; + } + + if !terrain.is_navigable(neighbor) { + continue; + } + + let tentative_g = current_node.g_cost + 1; + + if tentative_g < *g_scores.get(&neighbor).unwrap_or(&u32::MAX) { + came_from.insert(neighbor, current_pos); + g_scores.insert(neighbor, tentative_g); + + // Find best heuristic to any target + let h_cost = water_targets.iter().map(|&t| neighbor.manhattan_distance(t) as u32).min().unwrap_or(0); + + let f_cost = tentative_g + h_cost; + + open_set.push(PathNode { pos: neighbor, g_cost: tentative_g, h_cost, f_cost }); + } + } + } + + debug!("Pathfinding failed: no path found from {:?} to {:?}", start_tile, target_tile); + None +} + +/// Find a water tile adjacent to a coastal land tile for ship launch +fn find_water_launch_tile(terrain: &TerrainData, coast_tile: U16Vec2, size: U16Vec2) -> Option { + debug!("find_water_launch_tile: checking coastal tile {:?}", coast_tile); + + let water_tile = neighbors(coast_tile, size) + .inspect(|&neighbor| { + if terrain.is_navigable(neighbor) { + debug!(" Checking neighbor {:?}: is_water=true", neighbor); + } + }) + .find(|&neighbor| terrain.is_navigable(neighbor)); + + if let Some(tile) = water_tile { + debug!(" Found water launch tile {:?}", tile); + } else { + debug!(" No water launch tile found for coastal tile {:?}", coast_tile); + } + + water_tile +} + +/// Find all water tiles adjacent to a land tile +fn find_adjacent_water_tiles(terrain: &TerrainData, tile: U16Vec2, size: U16Vec2) -> Vec { + neighbors(tile, size).filter(|&neighbor| terrain.is_navigable(neighbor)).collect() +} + +/// Check if a tile is a valid ship destination (water or coastal land) +fn is_valid_ship_destination(terrain: &TerrainData, tile: U16Vec2, size: U16Vec2) -> bool { + // If it's water, it's valid + if terrain.is_navigable(tile) { + return true; + } + + // If it's land, check if it's coastal + neighbors(tile, size).any(|neighbor| terrain.is_navigable(neighbor)) +} + +/// Simplify a path by removing unnecessary waypoints (path smoothing) +/// This maintains determinism as it's purely geometric +pub fn smooth_path(path: Vec, terrain: &TerrainData) -> Vec { + if path.len() <= 2 { + return path; + } + + let mut smoothed = vec![path[0]]; + let mut current_idx = 0; + + while current_idx < path.len() - 1 { + let mut farthest = current_idx + 1; + + // Find the farthest point we can see directly + for i in (current_idx + 2)..path.len() { + if has_clear_water_line(terrain, path[current_idx], path[i]) { + farthest = i; + } else { + break; + } + } + + smoothed.push(path[farthest]); + current_idx = farthest; + } + + smoothed +} + +/// Check if there's a clear water line between two tiles +/// Uses Bresenham-like algorithm for deterministic line checking +fn has_clear_water_line(terrain: &TerrainData, from: U16Vec2, to: U16Vec2) -> bool { + let x0 = from.x as i32; + let y0 = from.y as i32; + let x1 = to.x as i32; + let y1 = to.y as i32; + + let dx = (x1 - x0).abs(); + let dy = (y1 - y0).abs(); + let sx = if x0 < x1 { 1 } else { -1 }; + let sy = if y0 < y1 { 1 } else { -1 }; + let mut err = dx - dy; + + let mut x = x0; + let mut y = y0; + + loop { + if !terrain.is_navigable(U16Vec2::new(x as u16, y as u16)) { + return false; // Hit land + } + + if x == x1 && y == y1 { + return true; // Reached target + } + + let e2 = 2 * err; + if e2 > -dy { + err -= dy; + x += sx; + } + if e2 < dx { + err += dx; + y += sy; + } + } +} + +/// Find the nearest coastal tile owned by a player to a target tile +/// Returns None if no valid coastal tile found +pub fn find_nearest_player_coastal_tile(coastal_tiles: &HashSet, player_border_tiles: &HashSet, target_tile: U16Vec2) -> Option { + let best_tile = player_border_tiles.iter().filter(|&tile| coastal_tiles.contains(tile)).min_by_key(|&tile| tile.manhattan_distance(target_tile)); + + debug!("Finding coastal tile: coastal_tiles.len={}, player_border_tiles.len={}, target_tile={:?}, best_tile={:?}", coastal_tiles.len(), player_border_tiles.len(), target_tile, best_tile); + + best_tile.copied() +} diff --git a/crates/borders-core/src/game/ships/systems.rs b/crates/borders-core/src/game/ships/systems.rs new file mode 100644 index 0000000..d8f7cee --- /dev/null +++ b/crates/borders-core/src/game/ships/systems.rs @@ -0,0 +1,286 @@ +use std::collections::HashSet; + +use bevy_ecs::hierarchy::ChildOf; +use bevy_ecs::prelude::*; +use glam::U16Vec2; +use tracing::debug; + +use crate::game::terrain::TerrainData; +use crate::game::{ + ActiveAttacks, CoastalTiles, DeterministicRng, NationEntityMap, TerritoryManager, TerritorySize, Troops, + entities::remove_troops, + ships::{MAX_SHIPS_PER_NATION, Ship, ShipCount, ShipIdCounter, TICKS_PER_TILE, TROOP_PERCENT}, + world::NationId, +}; +use crate::game::{ActiveTurn, BorderCache, CurrentTurn}; + +/// Event for requesting a ship launch +#[derive(Debug, Clone, Message)] +pub struct LaunchShipMessage { + pub nation_id: NationId, + pub target_tile: U16Vec2, + pub troops: u32, +} + +/// Event for ship arrivals at their destination +#[derive(Debug, Clone, Message)] +pub struct ShipArrivalMessage { + pub owner_id: NationId, + pub target_tile: U16Vec2, + pub troops: u32, +} + +/// System to handle ship launch requests +/// Validates launch conditions and spawns ship entities as children of nations +/// Uses If> to skip when no active turn +#[allow(clippy::too_many_arguments)] +pub fn launch_ship_system(active_turn: If>, mut launch_events: MessageReader, mut commands: Commands, mut ship_id_counter: ResMut, mut players: Query<(&NationId, &mut Troops, &mut ShipCount)>, terrain: Res, coastal_tiles: Res, territory_manager: Res, border_cache: Res, entity_map: Res) { + let turn_number = active_turn.turn_number; + let size = territory_manager.size(); + let territory_slice = territory_manager.as_slice(); + + for event in launch_events.read() { + let _guard = tracing::trace_span!( + "launch_ship", + nation_id = ?event.nation_id, + ?event.target_tile + ) + .entered(); + + // Get nation entity + let Some(&player_entity) = entity_map.0.get(&event.nation_id) else { + debug!(?event.nation_id, "Nation not found"); + continue; + }; + + // Get nation components + let Ok((_, mut troops, mut ship_count)) = players.get_mut(player_entity) else { + debug!(?event.nation_id, "Dead nation cannot launch ships"); + continue; + }; + + // Check ship limit + if ship_count.0 >= MAX_SHIPS_PER_NATION { + debug!( + ?event.nation_id, + "Nation cannot launch ship: already has {}/{} ships", + ship_count.0, + MAX_SHIPS_PER_NATION + ); + continue; + } + + // Check troops + if troops.0 <= 0.0 { + debug!(?event.nation_id, "Nation has no troops to launch ship"); + continue; + } + + // Clamp troops to available, use default 20% if 0 requested + let troops_to_send = if event.troops > 0 { + let available = troops.0 as u32; + let clamped = event.troops.min(available); + + if event.troops > available { + debug!( + ?event.nation_id, + requested = event.troops, + available = available, + "Ship launch requested more troops than available, clamping" + ); + } + + clamped + } else { + // Default to 20% of troops if 0 requested + (troops.0 * TROOP_PERCENT).floor() as u32 + }; + + if troops_to_send == 0 { + debug!(?event.nation_id, "Not enough troops to launch ship"); + continue; + } + + // Find target's nearest coastal tile + let target_coastal_tile = crate::game::connectivity::find_coastal_tile_in_region(territory_slice, &terrain, event.target_tile, size); + + let target_coastal_tile = match target_coastal_tile { + Some(tile) => tile, + None => { + debug!( + ?event.nation_id, + ?event.target_tile, + "No coastal tile found in target region" + ); + continue; + } + }; + + // Find nation's nearest coastal tile + let nation_border_tiles = border_cache.get(event.nation_id); + let launch_tile = nation_border_tiles.and_then(|tiles| crate::game::ships::pathfinding::find_nearest_player_coastal_tile(coastal_tiles.tiles(), tiles, target_coastal_tile)); + + let launch_tile = match launch_tile { + Some(tile) => tile, + None => { + debug!( + ?event.nation_id, + ?event.target_tile, + "Nation has no coastal tiles to launch from" + ); + continue; + } + }; + + // Calculate water path from launch tile to target coastal tile + let path = { + let _guard = tracing::trace_span!("ship_pathfinding", ?launch_tile, ?target_coastal_tile).entered(); + + crate::game::ships::pathfinding::find_water_path(&terrain, launch_tile, target_coastal_tile, crate::game::ships::MAX_PATH_LENGTH) + }; + + let path = match path { + Some(p) => p, + None => { + debug!( + ?event.nation_id, + ?event.target_tile, + ?launch_tile, + "No water path found" + ); + continue; + } + }; + + // Generate ship ID + let ship_id = ship_id_counter.generate_id(); + + // Deduct troops from nation + troops.0 = remove_troops(troops.0, troops_to_send as f32); + + // Create ship as child of nation entity + let ship = Ship::new(ship_id, troops_to_send, path, TICKS_PER_TILE, turn_number); + + let ship_entity = commands.spawn(ship).id(); + commands.entity(player_entity).add_child(ship_entity); + + // Increment ship count + ship_count.0 += 1; + + debug!( + ?event.nation_id, + ?event.target_tile, + troops_to_send, + ?launch_tile, + ship_id, + "Ship launched successfully" + ); + } +} + +/// System to update all ships and emit arrival events +pub fn update_ships_system(mut ships: Query<(Entity, &mut Ship, &ChildOf)>, mut arrival_events: MessageWriter, mut commands: Commands, mut players: Query<(&NationId, &mut ShipCount)>) { + let _guard = tracing::trace_span!("update_ships", ship_count = ships.iter().len()).entered(); + + for (ship_entity, mut ship, parent) in ships.iter_mut() { + if ship.update() { + // Ship has arrived at destination + arrival_events.write(ShipArrivalMessage { + owner_id: { + if let Ok((nation_id, _)) = players.get(parent.0) { + *nation_id + } else { + debug!(ship_id = ship.id, "Ship parent entity missing NationId"); + commands.entity(ship_entity).despawn(); + continue; + } + }, + target_tile: ship.target_tile, + troops: ship.troops, + }); + + if let Ok((nation_id, mut ship_count)) = players.get_mut(parent.0) { + ship_count.0 = ship_count.0.saturating_sub(1); + debug!(ship_id = ship.id, nation_id = nation_id.get(), troops = ship.troops, "Ship arrived at destination"); + } + + // Despawn ship + commands.entity(ship_entity).despawn(); + } + } +} + +/// System to handle ship arrivals and create beachheads +/// Uses If> to skip when no active turn +#[allow(clippy::too_many_arguments)] +pub fn handle_ship_arrivals_system(_active_turn: If>, mut arrival_events: MessageReader, current_turn: Res, terrain: Res, mut territory_manager: ResMut, mut active_attacks: ResMut, rng: Res, entity_map: Res, border_cache: Res, mut players: Query<(&mut Troops, &mut TerritorySize)>, mut commands: Commands) { + let arrivals: Vec<_> = arrival_events.read().cloned().collect(); + + if arrivals.is_empty() { + return; + } + + let _guard = tracing::trace_span!("ship_arrivals", arrival_count = arrivals.len()).entered(); + + for arrival in arrivals { + tracing::debug!( + ?arrival.owner_id, + ?arrival.target_tile, + arrival.troops, + "Ship arrived at destination, establishing beachhead" + ); + + // Step 1: Force-claim the landing tile as beachhead + let arrival_nation_id = arrival.owner_id; + let previous_owner = territory_manager.conquer(arrival.target_tile, arrival_nation_id); + + // Step 2: Update nation stats + if let Some(nation_id) = previous_owner + && let Some(&prev_entity) = entity_map.0.get(&nation_id) + && let Ok((mut troops, mut territory_size)) = players.get_mut(prev_entity) + { + territory_size.0 = territory_size.0.saturating_sub(1); + if territory_size.0 == 0 { + troops.0 = 0.0; + commands.entity(prev_entity).insert(crate::game::Dead); + } + } + if let Some(&entity) = entity_map.0.get(&arrival_nation_id) + && let Ok((_, mut territory_size)) = players.get_mut(entity) + { + territory_size.0 += 1; + } + + let turn_number = current_turn.turn.turn_number; + let size = territory_manager.size(); + let target_tile = arrival.target_tile; + let troops = arrival.troops; + + // Step 3: Notify active attacks of territory change + active_attacks.handle_territory_add(target_tile, arrival_nation_id, &territory_manager, &terrain, &rng); + + // Step 4: Create attack from beachhead to expand + // Find valid attack targets (not water, not our own tiles) + let valid_targets: Vec = crate::game::utils::neighbors(target_tile, size).filter(|&neighbor| terrain.is_conquerable(neighbor) && territory_manager.get_nation_id(neighbor) != Some(arrival_nation_id)).collect(); + + // Pick a deterministic random target from valid targets + if !valid_targets.is_empty() { + // Deterministic random selection using turn number and beachhead position + let seed = turn_number.wrapping_mul(31).wrapping_add(target_tile.x as u64).wrapping_add(target_tile.y as u64); + + let index = (seed % valid_targets.len() as u64) as usize; + let attack_target_tile = valid_targets[index]; + + // Determine the target nation (None if unclaimed) + let attack_target = territory_manager.get_nation_id(attack_target_tile); + + // Build nation borders map for compatibility + let nation_borders = border_cache.as_map(); + let beachhead_borders = Some(&HashSet::from([target_tile])); + + crate::game::handle_attack_internal(arrival_nation_id, attack_target, crate::game::TroopCount::Absolute(troops), false, beachhead_borders, turn_number, &territory_manager, &terrain, &mut active_attacks, &rng, &nation_borders, &entity_map, &mut players); + } else { + tracing::debug!(?arrival_nation_id, ?target_tile, "Ship landed but no valid attack targets found (all adjacent tiles are water or owned)"); + } + } +} diff --git a/crates/borders-core/src/game/systems/borders.rs b/crates/borders-core/src/game/systems/borders.rs new file mode 100644 index 0000000..1930611 --- /dev/null +++ b/crates/borders-core/src/game/systems/borders.rs @@ -0,0 +1,166 @@ +/// Border tile management +/// +/// This module manages border tiles for all nations. A border tile is a tile +/// adjacent to a tile with a different owner. Borders are used for: +/// - Attack targeting (attacks expand from border tiles) +/// - UI rendering (show nation borders on the map) +/// - Ship launching (find coastal borders for naval operations) +use std::collections::{HashMap, HashSet}; + +use bevy_ecs::prelude::*; +use glam::U16Vec2; + +use crate::game::{ + CurrentTurn, + entities::BorderTiles, + utils::neighbors, + world::{NationId, TerritoryManager}, +}; + +/// Cached border data for efficient non-ECS lookups +/// +/// This resource caches border tiles per nation to avoid reconstructing +/// HashMaps every turn. It is updated by `update_player_borders_system` +/// only when borders actually change. +#[derive(Resource, Default)] +pub struct BorderCache { + borders: HashMap>, +} + +impl BorderCache { + /// Get border tiles for a specific nation + #[inline] + pub fn get(&self, nation_id: NationId) -> Option<&HashSet> { + self.borders.get(&nation_id) + } + + /// Update the border cache with current border data + fn update(&mut self, nation_id: NationId, borders: &HashSet) { + self.borders.insert(nation_id, borders.clone()); + } + + /// Get all nation borders as a HashMap (for compatibility) + pub fn as_map(&self) -> HashMap> { + self.borders.iter().map(|(id, borders)| (*id, borders)).collect() + } +} + +/// Result of a border transition +#[derive(Debug)] +pub struct BorderTransitionResult { + /// Tiles that became interior (not borders anymore) + pub territory: Vec, + /// Tiles that are now attacker borders + pub attacker: Vec, + /// Tiles that are now defender borders + pub defender: Vec, +} + +/// Group affected tiles by their owner for efficient per-nation processing +/// +/// Instead of checking every tile for every nation (O(nations * tiles)), +/// we group tiles by owner once (O(tiles)) and then process each group. +fn group_tiles_by_owner(affected_tiles: &HashSet, territory: &TerritoryManager) -> HashMap> { + let _guard = tracing::trace_span!("group_tiles_by_owner", tile_count = affected_tiles.len()).entered(); + + let mut grouped: HashMap> = HashMap::new(); + for &tile in affected_tiles { + if let Some(nation_id) = territory.get_ownership(tile).nation_id() { + grouped.entry(nation_id).or_default().insert(tile); + } + } + + grouped +} + +/// System to clear territory changes +pub fn clear_territory_changes_system(current_turn: Res, mut territory_manager: ResMut) { + if current_turn.active && territory_manager.has_changes() { + tracing::trace!(count = territory_manager.iter_changes().count(), "Clearing territory changes"); + territory_manager.clear_changes(); + } +} + +/// Update all nation borders based on territory changes (batched system) +/// +/// This system runs once per turn AFTER all territory changes (conquests, spawns, ships). +/// It drains the TerritoryManager's change buffer and updates borders for all affected nations. +/// It also updates the BorderCache for efficient non-ECS lookups. +pub fn update_nation_borders_system(mut nations: Query<(&NationId, &mut BorderTiles)>, territory_manager: Res, mut border_cache: ResMut) { + if !territory_manager.has_changes() { + return; // Early exit - no work needed + } + + let _guard = tracing::trace_span!("update_player_borders").entered(); + + let (changed_tiles, raw_change_count): (HashSet, usize) = { + let _guard = tracing::trace_span!("collect_changed_tiles").entered(); + let changes_vec: Vec = territory_manager.iter_changes().collect(); + let raw_count = changes_vec.len(); + let unique_set: HashSet = changes_vec.into_iter().collect(); + (unique_set, raw_count) + }; + + if raw_change_count != changed_tiles.len() { + tracing::warn!(raw_changes = raw_change_count, unique_changes = changed_tiles.len(), duplicates = raw_change_count - changed_tiles.len(), "Duplicate tile changes detected in ChangeBuffer - this causes performance degradation"); + } + + // Build affected tiles (changed + all neighbors) + let affected_tiles = { + let _guard = tracing::trace_span!("build_affected_tiles", changed_count = changed_tiles.len()).entered(); + + let mut affected_tiles = HashSet::with_capacity(changed_tiles.len() * 5); + let size = territory_manager.size(); + for &tile in &changed_tiles { + affected_tiles.insert(tile); + affected_tiles.extend(crate::game::core::utils::neighbors(tile, size)); + } + affected_tiles + }; + + // Group tiles by owner for efficient per-nation processing + let tiles_by_owner = group_tiles_by_owner(&affected_tiles, &territory_manager); + + tracing::trace!(nation_count = nations.iter().len(), changed_tile_count = changed_tiles.len(), affected_tile_count = affected_tiles.len(), unique_owners = tiles_by_owner.len(), "Border update statistics"); + + // Update each nation's borders (pure ECS) and BorderCache + { + let _guard = tracing::trace_span!("update_all_nation_borders", nation_count = nations.iter().len()).entered(); + + for (nation_id, mut component_borders) in &mut nations { + // Only process tiles owned by this nation (or empty set if none) + let empty_set = HashSet::new(); + let nation_tiles = tiles_by_owner.get(nation_id).unwrap_or(&empty_set); + + update_borders_for_player(&mut component_borders, *nation_id, nation_tiles, &territory_manager); + + // Update the cache with the new border data + border_cache.update(*nation_id, &component_borders); + } + } +} + +/// Update borders for a single nation based on their owned tiles +/// +/// Only processes tiles owned by this nation, significantly reducing +/// redundant work when multiple nations exist. +fn update_borders_for_player(borders: &mut HashSet, nation_id: NationId, nation_tiles: &HashSet, territory: &TerritoryManager) { + let _guard = tracing::trace_span!( + "update_borders_for_nation", + nation_id = %nation_id, + nation_tile_count = nation_tiles.len(), + current_border_count = borders.len() + ) + .entered(); + + for &tile in nation_tiles { + // Check if it's a border (has at least one neighbor with different owner) + let is_border = neighbors(tile, territory.size()).any(|neighbor| !territory.is_owner(neighbor, nation_id)); + + if is_border { + borders.insert(tile); + } else { + borders.remove(&tile); + } + } +} diff --git a/crates/borders-core/src/game/systems/income.rs b/crates/borders-core/src/game/systems/income.rs new file mode 100644 index 0000000..e6f1174 --- /dev/null +++ b/crates/borders-core/src/game/systems/income.rs @@ -0,0 +1,30 @@ +use bevy_ecs::prelude::*; +use tracing::trace; + +use crate::game::ai::bot::Bot; +use crate::game::entities; +use crate::game::{ActiveTurn, CurrentTurn, Dead, TerritorySize, Troops}; + +/// Process player income at 10 TPS (once per turn) +/// Uses If> to skip when no active turn +/// +/// Uses Has to distinguish bot vs human players: +/// - true = bot player (60% income, 33% max troops) +/// - false = human player (100% income, 100% max troops) +pub fn process_nation_income_system(_active_turn: If>, current_turn: Res, mut players: Query<(&mut Troops, &TerritorySize, Has), Without>) { + // Skip income processing on Turn 0 - players haven't spawned yet + // Spawning happens during execute_turn_gameplay_system on Turn 0 + if current_turn.turn.turn_number == 0 { + trace!("Skipping income on Turn 0 (pre-spawn)"); + return; + } + + // Process income for all alive players (Without filter) + for (mut troops, territory_size, is_bot) in &mut players { + // Calculate and apply income + let income = entities::calculate_income(troops.0, territory_size.0, is_bot); + troops.0 = entities::add_troops_capped(troops.0, income, territory_size.0, is_bot); + } + + trace!("Income processed for turn {}", current_turn.turn.turn_number); +} diff --git a/crates/borders-core/src/game/systems/mod.rs b/crates/borders-core/src/game/systems/mod.rs new file mode 100644 index 0000000..f44062e --- /dev/null +++ b/crates/borders-core/src/game/systems/mod.rs @@ -0,0 +1,39 @@ +//! Game systems that run each tick/turn +//! +//! This module contains systems that execute game logic. + +use bevy_ecs::prelude::*; +use bevy_ecs::system::SystemParam; + +use crate::game::entities::NationEntityMap; +use crate::game::terrain::data::TerrainData; + +pub mod borders; +pub mod income; +pub mod spawn; +pub mod spawn_territory; +pub mod spawn_timeout; +pub mod turn; +pub mod turn_actions; +pub mod turn_attacks; +pub mod turn_spawns; + +// Re-export system functions and types +pub use borders::*; +pub use income::*; +pub use spawn::*; +pub use spawn_territory::*; +pub use spawn_timeout::*; +pub use turn::*; +pub use turn_actions::process_and_apply_actions_system; +pub use turn_attacks::tick_attacks_system; +pub use turn_spawns::handle_spawns_system; + +/// SystemParam to group read-only game resources +/// Used across multiple turn execution systems +#[derive(SystemParam)] +pub struct GameResources<'w> { + pub border_cache: Res<'w, BorderCache>, + pub nation_entity_map: Res<'w, NationEntityMap>, + pub terrain: Res<'w, TerrainData>, +} diff --git a/crates/borders-core/src/game/systems/spawn.rs b/crates/borders-core/src/game/systems/spawn.rs new file mode 100644 index 0000000..6ef0ecf --- /dev/null +++ b/crates/borders-core/src/game/systems/spawn.rs @@ -0,0 +1,80 @@ +use bevy_ecs::prelude::*; + +use crate::game::NationId; + +/// Represents a spawn point for a nation (player or bot) +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct SpawnPoint { + pub nation: NationId, + pub tile: glam::U16Vec2, +} + +impl SpawnPoint { + pub fn new(nation: NationId, tile: glam::U16Vec2) -> Self { + Self { nation, tile } + } +} + +/// Manages spawn positions during the pre-game spawn phase +/// +/// This resource tracks bot and nation spawn positions before the game starts ticking. +/// It allows for dynamic recalculation of bot positions when nations change their spawn +/// location, implementing the two-pass spawn system described in the README. +#[derive(Resource)] +pub struct SpawnManager { + /// Initial bot spawn positions from first pass + pub initial_bot_spawns: Vec, + + /// Current bot spawn positions after recalculation + /// These are updated whenever a player chooses/changes their spawn + pub current_bot_spawns: Vec, + + /// Nation spawn positions + /// Tracks human nation spawn selections + pub player_spawns: Vec, + + /// RNG seed for deterministic spawn calculations + pub rng_seed: u64, +} + +impl SpawnManager { + /// Create a new SpawnManager with initial bot spawns + pub fn new(initial_bot_spawns: Vec, rng_seed: u64) -> Self { + Self { current_bot_spawns: initial_bot_spawns.clone(), initial_bot_spawns, player_spawns: Vec::new(), rng_seed } + } + + /// Update a nation's spawn position and recalculate bot spawns if necessary + /// + /// This triggers the second pass of the two-pass spawn system, relocating + /// any bots that are too close to the new nation position. + pub fn update_player_spawn(&mut self, nation_id: NationId, tile_index: glam::U16Vec2, territory_manager: &crate::game::TerritoryManager, terrain: &crate::game::terrain::TerrainData) { + let spawn_point = SpawnPoint::new(nation_id, tile_index); + + // Update or add nation spawn + if let Some(entry) = self.player_spawns.iter_mut().find(|spawn| spawn.nation == nation_id) { + *entry = spawn_point; + } else { + self.player_spawns.push(spawn_point); + } + + // Recalculate bot spawns with updated nation positions + self.current_bot_spawns = crate::game::ai::bot::recalculate_spawns_with_players(self.initial_bot_spawns.clone(), &self.player_spawns, territory_manager, terrain, self.rng_seed); + } + + /// Get all current spawn positions (nations + bots) + pub fn get_all_spawns(&self) -> Vec { + let mut all_spawns = self.player_spawns.clone(); + all_spawns.extend(self.current_bot_spawns.iter().copied()); + all_spawns + } + + /// Get only bot spawn positions + pub fn get_bot_spawns(&self) -> &[SpawnPoint] { + &self.current_bot_spawns + } + + /// Get only nation spawn positions + pub fn get_player_spawns(&self) -> &[SpawnPoint] { + &self.player_spawns + } +} diff --git a/crates/borders-core/src/game/systems/spawn_territory.rs b/crates/borders-core/src/game/systems/spawn_territory.rs new file mode 100644 index 0000000..fd96b96 --- /dev/null +++ b/crates/borders-core/src/game/systems/spawn_territory.rs @@ -0,0 +1,61 @@ +//! Spawn territory claiming logic +//! +//! Provides utilities for claiming 5x5 territories around spawn points. + +use glam::U16Vec2; +use std::collections::HashSet; + +use crate::game::terrain::data::TerrainData; +use crate::game::world::{NationId, TileOwnership}; + +/// Claims a 5x5 territory around a spawn point +/// +/// Claims all unclaimed, conquerable tiles within 2 tiles of the spawn center +/// and returns the set of tiles that were successfully claimed. +#[inline] +pub fn claim_spawn_territory(spawn_center: U16Vec2, nation: NationId, territories: &mut [TileOwnership], terrain: &TerrainData, map_size: U16Vec2) -> HashSet { + let width = map_size.x as usize; + + (-2..=2) + .flat_map(|dy| (-2..=2).map(move |dx| (dx, dy))) + .filter_map(|(dx, dy)| { + let x = (spawn_center.x as i32 + dx).clamp(0, map_size.x as i32 - 1) as usize; + let y = (spawn_center.y as i32 + dy).clamp(0, map_size.y as i32 - 1) as usize; + let tile_pos = U16Vec2::new(x as u16, y as u16); + let idx = y * width + x; + + if territories[idx].is_unclaimed() && terrain.is_conquerable(tile_pos) { + territories[idx] = TileOwnership::Owned(nation); + Some(tile_pos) + } else { + None + } + }) + .collect() +} + +/// Clears spawn territory for a specific nation within a 5x5 area +/// +/// Reverts all tiles owned by the given nation within the 5x5 area back to unclaimed +/// and returns the set of tiles that were cleared. +#[inline] +pub fn clear_spawn_territory(spawn_center: U16Vec2, nation: NationId, territories: &mut [TileOwnership], map_size: U16Vec2) -> HashSet { + let width = map_size.x as usize; + + (-2..=2) + .flat_map(|dy| (-2..=2).map(move |dx| (dx, dy))) + .filter_map(|(dx, dy)| { + let x = (spawn_center.x as i32 + dx).clamp(0, map_size.x as i32 - 1) as usize; + let y = (spawn_center.y as i32 + dy).clamp(0, map_size.y as i32 - 1) as usize; + let tile_pos = U16Vec2::new(x as u16, y as u16); + let idx = y * width + x; + + if territories[idx].is_owned_by(nation) { + territories[idx] = TileOwnership::Unclaimed; + Some(tile_pos) + } else { + None + } + }) + .collect() +} diff --git a/crates/borders-core/src/game/systems/spawn_timeout.rs b/crates/borders-core/src/game/systems/spawn_timeout.rs new file mode 100644 index 0000000..3be6c0a --- /dev/null +++ b/crates/borders-core/src/game/systems/spawn_timeout.rs @@ -0,0 +1,107 @@ +use bevy_ecs::prelude::*; +use tracing::trace; + +use crate::{game::SpawnPhase, time, ui}; + +/// Tracks spawn phase timeout state on the client side +/// +/// This resource is used to: +/// - Show countdown timer in UI +/// - Know when spawn phase is active +/// - Calculate remaining time for display +#[derive(Resource)] +pub struct SpawnTimeout { + /// Whether spawn phase is currently active + pub active: bool, + + /// Accumulated time since start (seconds) + pub elapsed_secs: f32, + + /// Total timeout duration in seconds + pub duration_secs: f32, + + /// Remaining time in seconds (updated each frame) + pub remaining_secs: f32, + + /// Whether the initial spawn phase message has been sent + pub initial_message_sent: bool, +} + +impl Default for SpawnTimeout { + fn default() -> Self { + Self { + active: false, + elapsed_secs: 0.0, + duration_secs: 5.0, // Local mode: 5 seconds + remaining_secs: 5.0, + initial_message_sent: false, + } + } +} + +impl SpawnTimeout { + /// Create a new spawn timeout with specified duration + pub fn new(duration_secs: f32) -> Self { + Self { active: false, elapsed_secs: 0.0, duration_secs, remaining_secs: duration_secs, initial_message_sent: false } + } + + /// Start the timeout countdown + pub fn start(&mut self) { + if self.elapsed_secs == 0.0 { + self.active = true; + self.elapsed_secs = 0.0; + self.remaining_secs = self.duration_secs; + } + } + + /// Update remaining time (call each frame with delta time) + pub fn update(&mut self, delta_secs: f32) { + if !self.active { + return; + } + + self.elapsed_secs += delta_secs; + self.remaining_secs = (self.duration_secs - self.elapsed_secs).max(0.0); + + if self.remaining_secs <= 0.0 { + self.active = false; + } + } + + /// Stop the timeout + pub fn stop(&mut self) { + self.active = false; + self.elapsed_secs = 0.0; + } + + /// Check if timeout has expired + #[inline] + pub fn has_expired(&self) -> bool { + !self.active && self.remaining_secs <= 0.0 + } +} + +/// System to manage spawn timeout and emit countdown updates +pub fn manage_spawn_phase_system(mut spawn_timeout: If>, spawn_phase: Res, time: Res, mut backend_messages: MessageWriter) { + if !spawn_phase.active { + return; + } + + // Emit initial message if not sent yet + if !spawn_timeout.initial_message_sent { + backend_messages.write(ui::BackendMessage::SpawnPhaseUpdate { countdown: None }); + spawn_timeout.initial_message_sent = true; + trace!("Emitted initial SpawnPhaseUpdate (no countdown)"); + } + + // Emit countdown updates once the timer is active + if spawn_timeout.active { + spawn_timeout.update(time.delta_secs()); + + let started_at_ms = time.epoch_millis() - (spawn_timeout.elapsed_secs * 1000.0) as u64; + + backend_messages.write(ui::BackendMessage::SpawnPhaseUpdate { countdown: Some(ui::SpawnCountdown { started_at_ms, duration_secs: spawn_timeout.duration_secs }) }); + + trace!("SpawnPhaseUpdate: remaining {:.1}s", spawn_timeout.remaining_secs); + } +} diff --git a/crates/borders-core/src/game/systems/turn.rs b/crates/borders-core/src/game/systems/turn.rs new file mode 100644 index 0000000..4f82e63 --- /dev/null +++ b/crates/borders-core/src/game/systems/turn.rs @@ -0,0 +1,68 @@ +use bevy_ecs::prelude::*; +use bevy_ecs::system::SystemState; + +use crate::networking::{ProcessTurnEvent, Turn}; + +/// Marker resource indicating a turn is actively being processed +/// Added when a new turn arrives, removed after all turn-based systems complete +#[derive(Resource)] +pub struct ActiveTurn { + pub turn_number: u64, +} + +impl ActiveTurn { + pub fn new(turn: &Turn) -> Self { + Self { turn_number: turn.turn_number } + } +} + +/// Resource containing the current turn data +/// Updated once per turn (10 TPS), provides turn context to all gameplay systems +#[derive(Resource)] +pub struct CurrentTurn { + pub active: bool, + pub turn: Turn, +} + +impl CurrentTurn { + pub fn new(turn: Turn) -> Self { + Self { active: true, turn } + } +} + +/// System to receive turn events and update CurrentTurn resource +/// Exclusive system to ensure ActiveTurn is inserted immediately (not deferred) +pub fn update_current_turn_system(world: &mut World) { + // Create a SystemState to read messages in exclusive system + let mut system_state: SystemState> = SystemState::new(world); + let mut turn_events = system_state.get_mut(world); + + // Read all turn events (should only be one per frame at 10 TPS) + let turns: Vec = turn_events.read().map(|e| e.0.clone()).collect(); + + // Apply the state back to world + system_state.apply(world); + + if turns.is_empty() { + return; + } + + // Take the latest turn (in case multiple arrived, though this shouldn't happen) + let turn = turns.into_iter().last().unwrap(); + + // Insert ActiveTurn immediately to signal turn is being processed + world.insert_resource(ActiveTurn::new(&turn)); + + // Update CurrentTurn (must always exist) + let mut current_turn = world.get_resource_mut::().expect("CurrentTurn must be initialized in GameBuilder::build()"); + current_turn.active = true; + current_turn.turn = turn; +} + +/// System to cleanup ActiveTurn and CurrentTurn resources after all turn-based systems complete +pub fn turn_cleanup_system(mut current_turn: ResMut, mut commands: Commands) { + if current_turn.active { + commands.remove_resource::(); + current_turn.active = false; + } +} diff --git a/crates/borders-core/src/game/systems/turn_actions.rs b/crates/borders-core/src/game/systems/turn_actions.rs new file mode 100644 index 0000000..e010100 --- /dev/null +++ b/crates/borders-core/src/game/systems/turn_actions.rs @@ -0,0 +1,54 @@ +use bevy_ecs::prelude::*; +use tracing::trace; + +use crate::game::TerritoryManager; +use crate::game::ai::bot::Bot; +use crate::game::combat::ActiveAttacks; +use crate::game::core::rng::DeterministicRng; +use crate::game::core::turn_execution::{apply_action, process_bot_actions}; +use crate::game::entities::{Dead, TerritorySize, Troops}; +use crate::game::ships::LaunchShipMessage; +use crate::game::systems::GameResources; +use crate::game::systems::turn::{ActiveTurn, CurrentTurn}; +use crate::game::world::NationId; +use crate::networking::Intent; + +/// Process bot AI and apply all actions (bot + player) +/// Runs first in turn execution chain +/// Uses If> to skip when no active turn +#[allow(clippy::too_many_arguments, clippy::type_complexity)] +pub fn process_and_apply_actions_system(_active_turn: If>, current_turn: Res, territory_manager: Res, mut active_attacks: ResMut, mut rng: ResMut, resources: GameResources, mut player_queries: ParamSet<(Query<(&mut Troops, &mut TerritorySize)>, Query<(&NationId, &Troops, &mut Bot), Without>)>, mut launch_ship_writer: MessageWriter) { + let turn = ¤t_turn.turn; + + let _guard = tracing::trace_span!("process_and_apply_actions", turn_number = turn.turn_number, intent_count = turn.intents.len()).entered(); + + trace!("Processing actions for turn {} with {} intents", turn.turn_number, turn.intents.len()); + + // Use BorderCache for border data + let nation_borders = resources.border_cache.as_map(); + + // Update RNG for this turn + rng.update_turn(turn.turn_number); + + // Process bot AI to generate actions + let bot_actions = process_bot_actions(turn.turn_number, &territory_manager, &resources.terrain, &nation_borders, rng.turn_number(), &mut player_queries.p1()); + + // PHASE 1: Apply bot actions + { + let _guard = tracing::trace_span!("apply_bot_actions", count = bot_actions.len()).entered(); + + for (nation_id, action) in bot_actions { + apply_action(nation_id, action, turn.turn_number, &territory_manager, &resources.terrain, &mut active_attacks, &rng, &nation_borders, &resources.nation_entity_map, &mut player_queries.p0(), &mut launch_ship_writer); + } + } + + // PHASE 2: Apply player intents + for sourced_intent in &turn.intents { + match &sourced_intent.intent { + Intent::Action(action) => { + apply_action(sourced_intent.source, action.clone(), turn.turn_number, &territory_manager, &resources.terrain, &mut active_attacks, &rng, &nation_borders, &resources.nation_entity_map, &mut player_queries.p0(), &mut launch_ship_writer); + } + Intent::SetSpawn { .. } => {} + } + } +} diff --git a/crates/borders-core/src/game/systems/turn_attacks.rs b/crates/borders-core/src/game/systems/turn_attacks.rs new file mode 100644 index 0000000..f92b224 --- /dev/null +++ b/crates/borders-core/src/game/systems/turn_attacks.rs @@ -0,0 +1,21 @@ +use bevy_ecs::prelude::*; + +use crate::game::TerritoryManager; +use crate::game::ai::bot::Bot; +use crate::game::combat::ActiveAttacks; +use crate::game::core::rng::DeterministicRng; +use crate::game::entities::{TerritorySize, Troops}; +use crate::game::systems::GameResources; + +/// Tick active attacks +/// Runs after actions are applied, processes ongoing attacks +#[allow(clippy::too_many_arguments)] +pub fn tick_attacks_system(mut active_attacks: ResMut, mut territory_manager: ResMut, rng: Res, resources: GameResources, mut nations: Query<(&mut Troops, &mut TerritorySize)>, is_bot_query: Query>) { + let _guard = tracing::trace_span!("tick_attacks").entered(); + + // Use BorderCache for border data + let nation_borders = resources.border_cache.as_map(); + + // Tick all active attacks + active_attacks.tick(&resources.nation_entity_map, &mut nations, &mut territory_manager, &resources.terrain, &nation_borders, &rng, &is_bot_query); +} diff --git a/crates/borders-core/src/game/systems/turn_spawns.rs b/crates/borders-core/src/game/systems/turn_spawns.rs new file mode 100644 index 0000000..f54c66c --- /dev/null +++ b/crates/borders-core/src/game/systems/turn_spawns.rs @@ -0,0 +1,51 @@ +use bevy_ecs::prelude::*; +use tracing::info; + +use crate::game::TerritoryManager; +use crate::game::combat::ActiveAttacks; +use crate::game::core::rng::DeterministicRng; +use crate::game::core::turn_execution::handle_spawn; +use crate::game::entities::{TerritorySize, Troops}; +use crate::game::input::handlers::SpawnPhase; +use crate::game::systems::GameResources; +use crate::game::systems::spawn::SpawnManager; +use crate::game::systems::turn::ActiveTurn; +use crate::networking::server::LocalTurnServerHandle; + +use crate::ui::protocol::BackendMessage; + +/// Handle spawns and end spawn phase +/// Only processes on Turn 0 +/// Uses If> to skip when no active turn +#[allow(clippy::too_many_arguments)] +pub fn handle_spawns_system(active_turn: If>, spawn_manager: Option>, mut spawn_phase: ResMut, mut backend_messages: MessageWriter, server_handle: Option>, mut territory_manager: ResMut, mut active_attacks: ResMut, rng: Res, resources: GameResources, mut players: Query<(&mut Troops, &mut TerritorySize)>) { + // Only process on Turn 0 + if active_turn.turn_number != 0 { + return; + } + + let _guard = tracing::trace_span!("handle_spawns").entered(); + + // Apply ALL spawns (both human player and bots) to game state on Turn(0) + if let Some(ref spawn_mgr) = spawn_manager { + let all_spawns = spawn_mgr.get_all_spawns(); + tracing::debug!("Applying {} spawns to game state on Turn(0)", all_spawns.len()); + for spawn in all_spawns { + handle_spawn(spawn.nation, spawn.tile, &mut territory_manager, &resources.terrain, &mut active_attacks, &rng, &resources.nation_entity_map, &mut players); + } + } + + // End spawn phase + if spawn_phase.active { + spawn_phase.active = false; + + backend_messages.write(BackendMessage::SpawnPhaseEnded); + + info!("Spawn phase ended after Turn(0) execution"); + + if let Some(ref handle) = server_handle { + handle.resume(); + info!("Local turn server resumed - game started"); + } + } +} diff --git a/crates/borders-core/src/game/terrain/connectivity.rs b/crates/borders-core/src/game/terrain/connectivity.rs new file mode 100644 index 0000000..bbe93e5 --- /dev/null +++ b/crates/borders-core/src/game/terrain/connectivity.rs @@ -0,0 +1,124 @@ +use crate::game::NationId; +use crate::game::TileOwnership; +use crate::game::terrain::data::TerrainData; +use crate::game::utils::neighbors; +use glam::U16Vec2; +use std::collections::VecDeque; + +/// Check if a target tile's region connects to any of the nation's tiles +/// Uses flood-fill through tiles matching the target's ownership +/// Returns true if connected (normal attack), false if disconnected (ship needed) +pub fn is_connected_to_player(territory: &[TileOwnership], terrain: &TerrainData, target_tile: U16Vec2, nation_id: NationId, size: U16Vec2) -> bool { + let target_idx = (target_tile.y as usize) * (size.x as usize) + (target_tile.x as usize); + let target_ownership = territory[target_idx]; + + // Can't connect to water + if terrain.is_navigable(target_tile) { + return false; + } + + // If target is owned by nation, it's already connected + if target_ownership.is_owned_by(nation_id) { + return true; + } + + // Flood-fill from target through tiles with same ownership + let mut queue = VecDeque::new(); + let mut visited = vec![false; (size.x as usize) * (size.y as usize)]; + + queue.push_back(target_tile); + visited[target_idx] = true; + + while let Some(current_pos) = queue.pop_front() { + for neighbor_pos in neighbors(current_pos, size) { + let neighbor_idx = (neighbor_pos.y as usize) * (size.x as usize) + (neighbor_pos.x as usize); + + if visited[neighbor_idx] { + continue; + } + + // Don't cross water - only flood-fill through land on the same landmass + if terrain.is_navigable(neighbor_pos) { + continue; + } + + let neighbor_ownership = territory[neighbor_idx]; + + // Check if we found a nation tile - SUCCESS! + if neighbor_ownership.is_owned_by(nation_id) { + return true; + } + + // Only continue through tiles matching target's ownership + if neighbor_ownership == target_ownership { + visited[neighbor_idx] = true; + queue.push_back(neighbor_pos); + } + } + } + + // Exhausted search without finding nation tile + false +} + +/// Find the nearest coastal tile in a region by flood-filling from target +/// Only expands through tiles matching the target's ownership +/// Returns coastal tile position if found +pub fn find_coastal_tile_in_region(territory: &[TileOwnership], terrain: &TerrainData, target_tile: U16Vec2, size: U16Vec2) -> Option { + let target_idx = (target_tile.y as usize) * (size.x as usize) + (target_tile.x as usize); + let target_ownership = territory[target_idx]; + + // Can't find coastal tile in water + if terrain.is_navigable(target_tile) { + return None; + } + + // Check if target itself is coastal + if is_coastal_tile(terrain, target_tile, size) { + return Some(target_tile); + } + + // BFS from target through same-ownership tiles + let mut queue = VecDeque::new(); + let mut visited = vec![false; (size.x as usize) * (size.y as usize)]; + + queue.push_back(target_tile); + visited[target_idx] = true; + + while let Some(current_pos) = queue.pop_front() { + for neighbor_pos in neighbors(current_pos, size) { + let neighbor_idx = (neighbor_pos.y as usize) * (size.x as usize) + (neighbor_pos.x as usize); + + if visited[neighbor_idx] { + continue; + } + + let neighbor_ownership = territory[neighbor_idx]; + + // Only expand through matching ownership + if neighbor_ownership == target_ownership { + visited[neighbor_idx] = true; + + // Check if this tile is coastal + if is_coastal_tile(terrain, neighbor_pos, size) { + return Some(neighbor_pos); + } + + queue.push_back(neighbor_pos); + } + } + } + + None +} + +/// Check if a tile is coastal (land tile adjacent to water) +pub fn is_coastal_tile(terrain: &TerrainData, tile: U16Vec2, size: U16Vec2) -> bool { + // Must be land tile + if terrain.is_navigable(tile) { + return false; + } + + // Check if any neighbor is water (4-directional) + neighbors(tile, size).any(|neighbor| terrain.is_navigable(neighbor)) +} diff --git a/crates/borders-core/src/game/terrain/data.rs b/crates/borders-core/src/game/terrain/data.rs new file mode 100644 index 0000000..5567eb3 --- /dev/null +++ b/crates/borders-core/src/game/terrain/data.rs @@ -0,0 +1,250 @@ +use bevy_ecs::prelude::Resource; +use glam::U16Vec2; +use image::GenericImageView; +use serde::{Deserialize, Serialize}; +use tracing::info; + +use crate::game::world::tilemap::TileMap; + +/// Calculate terrain color using pastel theme formulas +fn calculate_theme_color(color_base: &str, color_variant: u8) -> [u8; 3] { + let i = color_variant as i32; + + match color_base { + "grass" => { + // rgb(238 - 2 * i, 238 - 2 * i, 190 - i) + [(238 - 2 * i).clamp(0, 255) as u8, (238 - 2 * i).clamp(0, 255) as u8, (190 - i).clamp(0, 255) as u8] + } + "mountain" => { + // rgb(250 - 2 * i, 250 - 2 * i, 220 - i) + [(250 - 2 * i).clamp(0, 255) as u8, (250 - 2 * i).clamp(0, 255) as u8, (220 - i).clamp(0, 255) as u8] + } + "water" => { + // rgb(172 - 2 * i, 225 - 2 * i, 249 - 3 * i) + [(172 - 2 * i).clamp(0, 255) as u8, (225 - 2 * i).clamp(0, 255) as u8, (249 - 3 * i).clamp(0, 255) as u8] + } + _ => { + // Default fallback color (gray) + [128, 128, 128] + } + } +} + +/// Helper structs for loading World.json format +#[derive(Deserialize)] +struct WorldMapJson { + tiles: Vec, +} + +#[derive(Deserialize)] +struct WorldTileDef { + color: String, + name: String, + #[serde(default, rename = "colorBase")] + color_base: Option, + #[serde(default, rename = "colorVariant")] + color_variant: Option, + conquerable: bool, + navigable: bool, + #[serde(default, rename = "expansionCost")] + expansion_cost: Option, + #[serde(default, rename = "expansionTime")] + expansion_time: Option, +} + +/// Parse hex color string (#RRGGBB) to RGB bytes +fn parse_hex_rgb(s: &str) -> Option<[u8; 3]> { + let s = s.trim_start_matches('#'); + if s.len() != 6 { + return None; + } + let r = u8::from_str_radix(&s[0..2], 16).ok()?; + let g = u8::from_str_radix(&s[2..4], 16).ok()?; + let b = u8::from_str_radix(&s[4..6], 16).ok()?; + Some([r, g, b]) +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct TileType { + pub name: String, + pub color_base: String, + pub color_variant: u8, + pub conquerable: bool, + pub navigable: bool, + pub expansion_time: u8, + pub expansion_cost: u8, +} + +/// Map manifest structure +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct MapManifest { + pub map: MapMetadata, + pub name: String, + pub nations: Vec, +} + +/// Map size metadata +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct MapMetadata { + pub size: glam::U16Vec2, + pub num_land_tiles: usize, +} + +impl MapMetadata { + /// Get the width of the map + #[inline] + pub fn width(&self) -> u16 { + self.size.x + } + + /// Get the height of the map + #[inline] + pub fn height(&self) -> u16 { + self.size.y + } +} + +/// Nation spawn point +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct NationSpawn { + pub coordinates: [usize; 2], + pub flag: String, + pub name: String, + pub strength: u32, +} + +/// Loaded map data +#[derive(Debug, Clone, Resource)] +pub struct TerrainData { + pub _manifest: MapManifest, + /// Legacy terrain data (for backward compatibility) + pub terrain_data: TileMap, + /// Tile type indices (new format) + pub tiles: Vec, + /// Tile type definitions + pub tile_types: Vec, +} + +impl TerrainData { + /// Load the World map from embedded assets + pub fn load_world_map() -> Result> { + let _guard = tracing::debug_span!("load_world_map").entered(); + + const MAP_JSON: &[u8] = include_bytes!("../../../assets/maps/World.json"); + const MAP_PNG: &[u8] = include_bytes!("../../../assets/maps/World.png"); + + // Parse JSON tile definitions + let map_json: WorldMapJson = { + let _guard = tracing::trace_span!("parse_json").entered(); + serde_json::from_slice(MAP_JSON)? + }; + + // Load PNG image + let (png, width, height) = { + let _guard = tracing::trace_span!("load_png").entered(); + let png = image::load_from_memory(MAP_PNG)?; + let (width, height) = png.dimensions(); + (png, width, height) + }; + + info!("Loading World map: {}x{}", width, height); + + // Build color-to-index lookup table + let color_to_index: Vec<([u8; 3], usize)> = map_json.tiles.iter().enumerate().filter_map(|(idx, t)| parse_hex_rgb(&t.color).map(|rgb| (rgb, idx))).collect(); + + let pixel_count = (width as usize) * (height as usize); + let mut tiles = vec![0u8; pixel_count]; + let mut terrain_data_raw = vec![0u8; pixel_count]; + + // Match each pixel to nearest tile type by color + { + let _guard = tracing::trace_span!("pixel_processing", pixel_count = pixel_count).entered(); + + for y in 0..height { + for x in 0..width { + let pixel = png.get_pixel(x, y).0; + let rgb = [pixel[0], pixel[1], pixel[2]]; + + // Find nearest tile by RGB distance + let (tile_idx, _) = color_to_index + .iter() + .map(|(c, idx)| { + let dr = rgb[0] as i32 - c[0] as i32; + let dg = rgb[1] as i32 - c[1] as i32; + let db = rgb[2] as i32 - c[2] as i32; + let dist = (dr * dr + dg * dg + db * db) as u32; + (idx, dist) + }) + .min_by_key(|(_, d)| *d) + .unwrap(); + + let i = (y * width + x) as usize; + tiles[i] = *tile_idx as u8; + + // Set bit 7 if conquerable (land) + if map_json.tiles[*tile_idx].conquerable { + terrain_data_raw[i] |= 0x80; + } + // Lower 5 bits for terrain magnitude (unused for World map) + } + } + } + + // Convert to TileType format + let tile_types = { + let _guard = tracing::trace_span!("tile_type_conversion").entered(); + map_json.tiles.into_iter().map(|t| TileType { name: t.name, color_base: t.color_base.unwrap_or_default(), color_variant: t.color_variant.unwrap_or(0) as u8, conquerable: t.conquerable, navigable: t.navigable, expansion_cost: t.expansion_cost.unwrap_or(50) as u8, expansion_time: t.expansion_time.unwrap_or(50) as u8 }).collect() + }; + + let num_land_tiles = terrain_data_raw.iter().filter(|&&b| b & 0x80 != 0).count(); + + info!("World map loaded: {} land tiles", num_land_tiles); + + Ok(Self { _manifest: MapManifest { name: "World".to_string(), map: MapMetadata { size: glam::U16Vec2::new(width as u16, height as u16), num_land_tiles }, nations: vec![] }, terrain_data: TileMap::from_vec(glam::U16Vec2::new(width as u16, height as u16), terrain_data_raw), tiles, tile_types }) + } + + /// Get the size of the map + #[inline] + pub fn size(&self) -> U16Vec2 { + self.terrain_data.size() + } + + #[inline] + pub fn get_value(&self, pos: U16Vec2) -> u8 { + self.terrain_data[pos] + } + + /// Check if a tile is land (bit 7 set) + #[inline] + pub fn is_land(&self, pos: U16Vec2) -> bool { + self.get_value(pos) & 0x80 != 0 + } + + /// Get tile type at position + pub fn get_tile_type(&self, pos: U16Vec2) -> &TileType { + let idx = self.terrain_data.pos_to_index(pos) as usize; + &self.tile_types[self.tiles[idx] as usize] + } + + /// Check if a tile is conquerable + pub fn is_conquerable(&self, pos: U16Vec2) -> bool { + self.get_tile_type(pos).conquerable + } + + /// Check if a tile is navigable (water) + pub fn is_navigable(&self, pos: U16Vec2) -> bool { + self.get_tile_type(pos).navigable + } + + /// Get tile type IDs for rendering (each position maps to a tile type) + pub fn get_tile_ids(&self) -> &[u8] { + &self.tiles + } + + /// Get terrain palette colors from tile types (for rendering) + /// Returns a vec where index = tile type ID, value = RGB color + /// Colors are calculated using theme formulas based on colorBase and colorVariant + pub fn get_terrain_palette_colors(&self) -> Vec<[u8; 3]> { + self.tile_types.iter().map(|tile_type| calculate_theme_color(&tile_type.color_base, tile_type.color_variant)).collect() + } +} diff --git a/crates/borders-core/src/game/terrain/mod.rs b/crates/borders-core/src/game/terrain/mod.rs new file mode 100644 index 0000000..1301f36 --- /dev/null +++ b/crates/borders-core/src/game/terrain/mod.rs @@ -0,0 +1,9 @@ +//! Terrain and map connectivity +//! +//! This module handles terrain data and pathfinding/connectivity analysis. + +pub mod connectivity; +pub mod data; + +pub use connectivity::*; +pub use data::*; diff --git a/crates/borders-core/src/game/world/changes.rs b/crates/borders-core/src/game/world/changes.rs new file mode 100644 index 0000000..87d9b3e --- /dev/null +++ b/crates/borders-core/src/game/world/changes.rs @@ -0,0 +1,254 @@ +use std::collections::HashSet; + +use glam::U16Vec2; + +/// Lightweight change tracking buffer for tile mutations. +/// +/// Stores only the indices of changed tiles, using a HashSet to automatically +/// deduplicate when the same tile changes multiple times per turn. This enables +/// efficient delta updates for GPU rendering and network synchronization. +/// +/// # Design +/// - Records tile index changes as they occur +/// - Automatically deduplicates tile indices +/// - O(1) average insert, O(changes) iteration +/// - Optional: can be cleared/ignored when tracking not needed +#[derive(Debug, Clone)] +pub struct ChangeBuffer { + changed_indices: HashSet, +} + +impl ChangeBuffer { + /// Creates a new empty ChangeBuffer. + pub fn new() -> Self { + Self { changed_indices: HashSet::new() } + } + + /// Creates a new ChangeBuffer with pre-allocated capacity. + /// + /// Use this when you know the approximate number of changes to avoid reallocations. + pub fn with_capacity(capacity: usize) -> Self { + Self { changed_indices: HashSet::with_capacity(capacity) } + } + + /// Records a tile index as changed. + /// + /// Automatically deduplicates - pushing the same index multiple times + /// only records it once. This is O(1) average case. + #[inline] + pub fn push(&mut self, position: U16Vec2) { + self.changed_indices.insert(position); + } + + /// Returns an iterator over changed indices without consuming them. + /// + /// Use this when you need to read changes without clearing the buffer. + /// The buffer will still contain all changes after iteration. + pub fn iter(&self) -> impl Iterator + '_ { + self.changed_indices.iter().copied() + } + + /// Drains all changed indices, returning an iterator and clearing the buffer. + /// + /// The buffer retains its capacity for reuse. + pub fn drain(&mut self) -> impl Iterator + '_ { + self.changed_indices.drain() + } + + /// Clears all tracked changes without returning them. + /// + /// The buffer retains its capacity for reuse. + pub fn clear(&mut self) { + self.changed_indices.clear(); + } + + /// Returns true if any changes have been recorded. + #[inline] + pub fn has_changes(&self) -> bool { + !self.changed_indices.is_empty() + } + + /// Returns the number of changes recorded. + /// + /// Note: This may include duplicate indices if the same tile was changed multiple times. + #[inline] + pub fn len(&self) -> usize { + self.changed_indices.len() + } + + /// Returns true if no changes have been recorded. + #[inline] + pub fn is_empty(&self) -> bool { + self.changed_indices.is_empty() + } + + /// Returns the current capacity of the internal buffer. + #[inline] + pub fn capacity(&self) -> usize { + self.changed_indices.capacity() + } +} + +impl Default for ChangeBuffer { + fn default() -> Self { + Self::new() + } +} + +#[cfg(test)] +mod tests { + use assert2::assert; + use glam::U16Vec2; + + use crate::game::world::changes::ChangeBuffer; + + #[test] + fn test_len_empty() { + let buffer = ChangeBuffer::new(); + assert!(buffer.len() == 0); + } + + #[test] + fn test_len_single_item() { + let mut buffer = ChangeBuffer::new(); + buffer.push(U16Vec2::new(10, 20)); + assert!(buffer.len() == 1); + } + + #[test] + fn test_len_multiple_items() { + let mut buffer = ChangeBuffer::new(); + buffer.push(U16Vec2::new(10, 20)); + buffer.push(U16Vec2::new(30, 40)); + buffer.push(U16Vec2::new(50, 60)); + assert!(buffer.len() == 3); + } + + #[test] + fn test_len_with_duplicates() { + let mut buffer = ChangeBuffer::new(); + let pos = U16Vec2::new(10, 20); + + buffer.push(pos); + buffer.push(pos); + buffer.push(pos); + + // HashSet deduplicates, so len should be 1 + assert!(buffer.len() == 1); + } + + #[test] + fn test_len_after_drain() { + let mut buffer = ChangeBuffer::new(); + buffer.push(U16Vec2::new(10, 20)); + buffer.push(U16Vec2::new(30, 40)); + + // Drain all items + let _drained: Vec<_> = buffer.drain().collect(); + + assert!(buffer.len() == 0); + } + + #[test] + fn test_is_empty_new_buffer() { + let buffer = ChangeBuffer::new(); + assert!(buffer.is_empty()); + } + + #[test] + fn test_is_empty_after_push() { + let mut buffer = ChangeBuffer::new(); + buffer.push(U16Vec2::new(10, 20)); + assert!(!buffer.is_empty()); + } + + #[test] + fn test_is_empty_after_clear() { + let mut buffer = ChangeBuffer::new(); + buffer.push(U16Vec2::new(10, 20)); + buffer.push(U16Vec2::new(30, 40)); + + buffer.clear(); + + assert!(buffer.is_empty()); + } + + #[test] + fn test_is_empty_after_drain() { + let mut buffer = ChangeBuffer::new(); + buffer.push(U16Vec2::new(10, 20)); + + let _drained: Vec<_> = buffer.drain().collect(); + + assert!(buffer.is_empty()); + } + + #[test] + fn test_with_capacity_allocates_space() { + let buffer = ChangeBuffer::with_capacity(100); + + // Capacity should be at least what we requested + assert!(buffer.capacity() >= 100, "Expected capacity >= 100, but got {}", buffer.capacity()); + } + + #[test] + fn test_with_capacity_differs_from_new() { + let buffer_new = ChangeBuffer::new(); + let buffer_with_cap = ChangeBuffer::with_capacity(100); + + // with_capacity should allocate more space than new + assert!(buffer_with_cap.capacity() > buffer_new.capacity(), "with_capacity(100) should have larger capacity than new(), but got {} vs {}", buffer_with_cap.capacity(), buffer_new.capacity()); + } + + #[test] + fn test_with_capacity_differs_from_default() { + let buffer_default = ChangeBuffer::default(); + let buffer_with_cap = ChangeBuffer::with_capacity(100); + + // with_capacity should allocate more space than default + assert!(buffer_with_cap.capacity() > buffer_default.capacity(), "with_capacity(100) should have larger capacity than default(), but got {} vs {}", buffer_with_cap.capacity(), buffer_default.capacity()); + } + + #[test] + fn test_capacity_persists_after_clear() { + let mut buffer = ChangeBuffer::with_capacity(100); + let initial_capacity = buffer.capacity(); + + buffer.push(U16Vec2::new(10, 20)); + buffer.clear(); + + // Capacity should remain after clear + assert!(buffer.capacity() == initial_capacity, "Capacity should persist after clear, but changed from {} to {}", initial_capacity, buffer.capacity()); + } + + #[test] + fn test_capacity_persists_after_drain() { + let mut buffer = ChangeBuffer::with_capacity(100); + let initial_capacity = buffer.capacity(); + + buffer.push(U16Vec2::new(10, 20)); + let _drained: Vec<_> = buffer.drain().collect(); + + // Capacity should remain after drain + assert!(buffer.capacity() == initial_capacity, "Capacity should persist after drain, but changed from {} to {}", initial_capacity, buffer.capacity()); + } + + #[test] + fn test_len_is_empty_consistency() { + let mut buffer = ChangeBuffer::new(); + + // Empty: len == 0 and is_empty() == true + assert!(buffer.len() == 0); + assert!(buffer.is_empty()); + + // Non-empty: len > 0 and is_empty() == false + buffer.push(U16Vec2::new(10, 20)); + assert!(buffer.len() > 0); + assert!(!buffer.is_empty()); + + // Add more items + buffer.push(U16Vec2::new(30, 40)); + assert!(buffer.len() == 2); + assert!(!buffer.is_empty()); + } +} diff --git a/crates/borders-core/src/game/world/coastal.rs b/crates/borders-core/src/game/world/coastal.rs new file mode 100644 index 0000000..49adfd1 --- /dev/null +++ b/crates/borders-core/src/game/world/coastal.rs @@ -0,0 +1,73 @@ +use std::collections::HashSet; + +use bevy_ecs::prelude::*; +use glam::U16Vec2; + +use crate::game::core::utils::neighbors; +use crate::game::terrain::TerrainData; + +/// Resource containing precomputed coastal tile positions +/// +/// A coastal tile is defined as a land tile (not water) that is adjacent +/// to at least one water tile in 4-directional connectivity. +/// +/// This is computed once during game initialization and never changes, +/// providing O(1) lookups for systems that need to check if a tile is coastal. +#[derive(Resource)] +pub struct CoastalTiles { + tiles: HashSet, +} + +impl CoastalTiles { + /// Compute all coastal tile positions from terrain data + /// + /// This scans the entire map once to find all land tiles adjacent to water. + /// The result is cached in a HashSet for fast lookups. + pub fn compute(terrain: &TerrainData, size: U16Vec2) -> Self { + let mut coastal_tiles = HashSet::new(); + let width = size.x as usize; + let height = size.y as usize; + + for y in 0..height { + for x in 0..width { + let tile_pos = U16Vec2::new(x as u16, y as u16); + + // Skip water tiles + if terrain.is_navigable(tile_pos) { + continue; + } + + // Check if any neighbor is water using the neighbors utility + if neighbors(tile_pos, size).any(|neighbor| terrain.is_navigable(neighbor)) { + coastal_tiles.insert(tile_pos); + } + } + } + + Self { tiles: coastal_tiles } + } + + /// Check if a tile is coastal + #[inline] + pub fn contains(&self, tile: U16Vec2) -> bool { + self.tiles.contains(&tile) + } + + /// Get a reference to the set of all coastal tiles + #[inline] + pub fn tiles(&self) -> &HashSet { + &self.tiles + } + + /// Get the number of coastal tiles + #[inline] + pub fn len(&self) -> usize { + self.tiles.len() + } + + /// Check if there are no coastal tiles + #[inline] + pub fn is_empty(&self) -> bool { + self.tiles.is_empty() + } +} diff --git a/crates/borders-core/src/game/world/manager.rs b/crates/borders-core/src/game/world/manager.rs new file mode 100644 index 0000000..ad20247 --- /dev/null +++ b/crates/borders-core/src/game/world/manager.rs @@ -0,0 +1,200 @@ +use bevy_ecs::prelude::*; +use glam::U16Vec2; + +use super::changes::ChangeBuffer; +use super::tilemap::TileMap; +use super::{NationId, TileOwnership}; +use crate::game::utils::neighbors; + +/// Manages territory ownership for all tiles +#[derive(Resource)] +pub struct TerritoryManager { + tile_owners: TileMap, + changes: ChangeBuffer, + /// Cached u16 representation for efficient serialization to frontend + u16_cache: Vec, + cache_dirty: bool, +} + +impl TerritoryManager { + /// Creates a new territory manager + pub fn new(map_size: U16Vec2) -> Self { + let size = (map_size.x as usize) * (map_size.y as usize); + Self { tile_owners: TileMap::with_default(map_size, TileOwnership::Unclaimed), changes: ChangeBuffer::with_capacity(size / 100), u16_cache: vec![0; size], cache_dirty: true } + } + + /// Resets the territory manager + pub fn reset(&mut self, map_size: U16Vec2, _conquerable_tiles: &[bool]) { + self.tile_owners = TileMap::with_default(map_size, TileOwnership::Unclaimed); + self.changes.clear(); + + let size = (map_size.x as usize) * (map_size.y as usize); + self.u16_cache.resize(size, 0); + self.cache_dirty = true; + } + + /// Checks if a tile is a border tile of the territory of its owner + /// A tile is a border tile if it is adjacent to a tile that is not owned by the same player + pub fn is_border(&self, tile: U16Vec2) -> bool { + let owner = self.tile_owners[tile]; + + // Border if on map edge + if tile.x == 0 || tile.x == self.tile_owners.width() - 1 || tile.y == 0 || tile.y == self.tile_owners.height() - 1 { + return true; + } + + // Border if any neighbor has different owner + for neighbor_pos in self.tile_owners.neighbors(tile) { + if self.tile_owners[neighbor_pos] != owner { + return true; + } + } + + false + } + + /// Checks if a tile has an owner + pub fn has_owner(&self, tile: U16Vec2) -> bool { + self.tile_owners[tile].is_owned() + } + + /// Checks if a tile is owned by a specific nation + pub fn is_owner(&self, tile: U16Vec2, owner: NationId) -> bool { + self.tile_owners[tile].is_owned_by(owner) + } + + /// Gets the nation ID of the tile owner, if any + pub fn get_nation_id(&self, tile: U16Vec2) -> Option { + self.tile_owners[tile].nation_id() + } + + /// Gets the ownership enum for a tile + pub fn get_ownership(&self, tile: U16Vec2) -> TileOwnership { + self.tile_owners[tile] + } + + /// Conquers a tile for a nation + /// Returns the previous owner, if any + pub fn conquer(&mut self, tile: U16Vec2, owner: NationId) -> Option { + let previous_owner = self.tile_owners[tile]; + let new_ownership = TileOwnership::Owned(owner); + + if previous_owner != new_ownership { + self.tile_owners[tile] = new_ownership; + self.changes.push(tile); + self.cache_dirty = true; + } + + previous_owner.nation_id() + } + + /// Clears a tile (removes ownership) + pub fn clear(&mut self, tile: U16Vec2) -> Option { + let ownership = self.tile_owners[tile]; + if ownership.is_owned() { + self.tile_owners[tile] = TileOwnership::Unclaimed; + self.changes.push(tile); + self.cache_dirty = true; + ownership.nation_id() + } else { + None + } + } + + /// Get the size of the map as U16Vec2 + #[inline] + pub fn size(&self) -> U16Vec2 { + self.tile_owners.size() + } + + /// Get width of the map + #[inline] + pub fn width(&self) -> u16 { + self.tile_owners.width() + } + + /// Get height of the map + #[inline] + pub fn height(&self) -> u16 { + self.tile_owners.height() + } + + /// Returns a reference to the underlying tile ownership data as a slice of enums + #[inline] + pub fn as_slice(&self) -> &[TileOwnership] { + self.tile_owners.as_slice() + } + + /// Returns the tile ownership data as u16 values for frontend serialization + /// This is cached and only recomputed when ownership changes + pub fn as_u16_slice(&mut self) -> &[u16] { + if self.cache_dirty { + let tile_count = self.tile_owners.len(); + let _guard = tracing::trace_span!("rebuild_u16_cache", tile_count).entered(); + + for (i, ownership) in self.tile_owners.as_slice().iter().enumerate() { + self.u16_cache[i] = (*ownership).into(); + } + self.cache_dirty = false; + } + &self.u16_cache + } + + /// Returns the number of tiles in the map + #[inline] + pub fn len(&self) -> usize { + self.tile_owners.len() + } + + /// Returns true if the map has no tiles + #[inline] + pub fn is_empty(&self) -> bool { + self.tile_owners.len() == 0 + } + + /// Returns an iterator over changed tile positions without consuming them + /// Use this to read changes without clearing the buffer + #[inline] + pub fn iter_changes(&self) -> impl Iterator + '_ { + self.changes.iter() + } + + /// Drains all changed tile positions, returning an iterator and clearing the change buffer + #[inline] + pub fn drain_changes(&mut self) -> impl Iterator + '_ { + self.changes.drain() + } + + /// Returns true if any territory changes have been recorded since last drain + #[inline] + pub fn has_changes(&self) -> bool { + self.changes.has_changes() + } + + /// Clears all tracked changes without returning them + #[inline] + pub fn clear_changes(&mut self) { + self.changes.clear() + } + + /// Calls a closure for each neighbor using tile indices (legacy compatibility) + #[inline] + pub fn on_neighbor_indices(&self, index: u32, closure: F) + where + F: FnMut(u32), + { + self.tile_owners.on_neighbor_indices(index, closure) + } + + /// Checks if any neighbor has a different owner than the specified owner + pub fn any_neighbor_has_different_owner(&self, tile: U16Vec2, owner: NationId) -> bool { + let owner_enum = TileOwnership::Owned(owner); + neighbors(tile, self.size()).any(|neighbor| self.tile_owners[neighbor] != owner_enum) + } + + /// Converts position to flat u32 index for JavaScript/IPC boundary + #[inline] + pub fn pos_to_index>(&self, pos: P) -> u32 { + self.tile_owners.pos_to_index(pos) + } +} diff --git a/crates/borders-core/src/game/world/mod.rs b/crates/borders-core/src/game/world/mod.rs new file mode 100644 index 0000000..ea35e9c --- /dev/null +++ b/crates/borders-core/src/game/world/mod.rs @@ -0,0 +1,17 @@ +//! World and territory management module +//! +//! This module contains all spatial data structures and territory management. + +pub mod changes; +pub mod coastal; +pub mod manager; +pub mod nation_id; +pub mod ownership; +pub mod tilemap; + +pub use changes::*; +pub use coastal::*; +pub use manager::*; +pub use nation_id::*; +pub use ownership::*; +pub use tilemap::*; diff --git a/crates/borders-core/src/game/world/nation_id.rs b/crates/borders-core/src/game/world/nation_id.rs new file mode 100644 index 0000000..3ce635d --- /dev/null +++ b/crates/borders-core/src/game/world/nation_id.rs @@ -0,0 +1,100 @@ +use bevy_ecs::prelude::Component; +use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +/// Unique identifier for a nation/player in the game. +/// +/// This is a validated newtype wrapper around u16 that prevents invalid nation IDs +/// from being constructed. The maximum valid nation ID is 65534, as 65535 is reserved +/// for encoding unclaimed tiles in the ownership serialization format. +#[derive(Component, Debug, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, Archive, RkyvSerialize, RkyvDeserialize)] +#[rkyv(derive(Debug, Hash, PartialEq, Eq))] +pub struct NationId(u16); + +impl NationId { + /// Maximum valid nation ID (65534). Value 65535 is reserved for unclaimed tiles. + pub const MAX: u16 = u16::MAX - 1; + + /// Constant for nation ID 0 (commonly used for default/first player) + pub const ZERO: Self = Self(0); + + /// Creates a new NationId if the value is valid (<= MAX). + /// + /// Returns None if id > MAX (i.e., id == 65535). + #[inline] + pub fn new(id: u16) -> Option { + (id <= Self::MAX).then_some(Self(id)) + } + + /// Creates a NationId without validation. + /// + /// # Safety + /// Caller must ensure id <= MAX. This is primarily for const contexts. + #[inline] + pub const fn new_unchecked(id: u16) -> Self { + Self(id) + } + + /// Extracts the inner u16 value. + #[inline] + pub fn get(self) -> u16 { + self.0 + } + + /// Converts to little-endian bytes. + #[inline] + pub fn to_le_bytes(self) -> [u8; 2] { + self.0.to_le_bytes() + } +} + +impl TryFrom for NationId { + type Error = InvalidNationId; + + fn try_from(value: u16) -> Result { + Self::new(value).ok_or(InvalidNationId(value)) + } +} + +impl From for u16 { + fn from(id: NationId) -> Self { + id.0 + } +} + +impl std::fmt::Display for NationId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +/// Error type for invalid nation ID values +#[derive(Debug, Clone, Copy)] +pub struct InvalidNationId(pub u16); + +impl std::fmt::Display for InvalidNationId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "Invalid nation ID: {} (must be <= {})", self.0, NationId::MAX) + } +} + +impl std::error::Error for InvalidNationId {} + +impl Serialize for NationId { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + Serialize::serialize(&self.0, serializer) + } +} + +impl<'de> Deserialize<'de> for NationId { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value = u16::deserialize(deserializer)?; + NationId::new(value).ok_or_else(|| serde::de::Error::custom(format!("Invalid nation ID: {} (must be <= {})", value, NationId::MAX))) + } +} diff --git a/crates/borders-core/src/game/world/ownership.rs b/crates/borders-core/src/game/world/ownership.rs new file mode 100644 index 0000000..76b89b0 --- /dev/null +++ b/crates/borders-core/src/game/world/ownership.rs @@ -0,0 +1,64 @@ +//! Tile ownership representation + +use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; +use serde::{Deserialize, Serialize}; + +use super::NationId; + +/// Represents the ownership state of a single tile. +/// +/// Terrain type (water, land, mountain, etc.) is stored separately in TerrainData. +/// This enum only tracks whether a tile is owned by a nation or unclaimed. +#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize, Default, Archive, RkyvSerialize, RkyvDeserialize)] +#[rkyv(derive(Debug))] +pub enum TileOwnership { + /// Owned by a specific nation + Owned(NationId), + /// Unclaimed but potentially conquerable land + #[default] + Unclaimed, +} + +impl TileOwnership { + /// Check if this tile is owned by any nation + #[inline] + pub fn is_owned(self) -> bool { + matches!(self, TileOwnership::Owned(_)) + } + + /// Check if this tile is unclaimed land + #[inline] + pub fn is_unclaimed(self) -> bool { + matches!(self, TileOwnership::Unclaimed) + } + + /// Get the nation ID if this tile is owned, otherwise None + #[inline] + pub fn nation_id(self) -> Option { + match self { + TileOwnership::Owned(id) => Some(id), + TileOwnership::Unclaimed => None, + } + } + + /// Check if this tile is owned by a specific nation + #[inline] + pub fn is_owned_by(self, nation_id: NationId) -> bool { + matches!(self, TileOwnership::Owned(id) if id == nation_id) + } +} + +impl From for TileOwnership { + fn from(value: u16) -> Self { + if value == 65535 { TileOwnership::Unclaimed } else { NationId::new(value).map(TileOwnership::Owned).unwrap_or(TileOwnership::Unclaimed) } + } +} + +impl From for u16 { + fn from(ownership: TileOwnership) -> Self { + match ownership { + TileOwnership::Owned(id) => id.get(), + TileOwnership::Unclaimed => 65535, + } + } +} diff --git a/crates/borders-core/src/game/world/tilemap.rs b/crates/borders-core/src/game/world/tilemap.rs new file mode 100644 index 0000000..5166051 --- /dev/null +++ b/crates/borders-core/src/game/world/tilemap.rs @@ -0,0 +1,268 @@ +use glam::{U16Vec2, UVec2}; +use std::ops::{Index, IndexMut}; + +/// A 2D grid-based map structure optimized for tile-based games. +/// +/// Provides efficient access to tiles using 2D coordinates (U16Vec2) while maintaining +/// cache-friendly contiguous memory layout. Supports generic tile types that implement Copy. +/// +/// Uses `u16` for dimensions, supporting maps up to 65,535x65,535 tiles. +/// +/// # Type Parameters +/// * `T` - The tile value type. Must implement `Copy` for efficient access. +/// +/// # Examples +/// ``` +/// use glam::U16Vec2; +/// use borders_core::game::TileMap; +/// +/// let mut map = TileMap::::new(U16Vec2::new(10, 10)); +/// map[U16Vec2::new(5, 5)] = 42; +/// assert_eq!(map[U16Vec2::new(5, 5)], 42); +/// ``` +#[derive(Clone, Debug)] +pub struct TileMap { + tiles: Box<[T]>, + size: U16Vec2, +} + +impl TileMap { + /// Creates a new TileMap with the specified dimensions and default value. + /// + /// # Arguments + /// * `size` - The size of the map (width, height) in tiles + /// * `default` - The default value to initialize all tiles with + pub fn with_default(size: U16Vec2, default: T) -> Self { + let capacity = (size.x as usize) * (size.y as usize); + let tiles = vec![default; capacity].into_boxed_slice(); + Self { tiles, size } + } + + /// Creates a TileMap from an existing vector of tile data. + /// + /// # Arguments + /// * `size` - The size of the map (width, height) in tiles + /// * `data` - Vector containing tile data in row-major order + /// + /// # Panics + /// Panics if `data.len() != size.x * size.y` + pub fn from_vec(size: U16Vec2, data: Vec) -> Self { + assert_eq!(data.len(), (size.x as usize) * (size.y as usize), "Data length must match size.x * size.y"); + Self { tiles: data.into_boxed_slice(), size } + } + + /// Converts the position to a flat array index. + /// + /// Accepts both U16Vec2 and UVec2 for backward compatibility. + /// + /// # Safety + /// Debug builds will assert that the position is in bounds. + /// Release builds skip the check for performance. + #[inline] + pub fn pos_to_index>(&self, pos: P) -> u32 { + let pos = pos.into(); + debug_assert!(pos.x < self.size.x && pos.y < self.size.y); + (pos.y as u32) * (self.size.x as u32) + (pos.x as u32) + } + + /// Converts a flat array index to a 2D position. + #[inline] + pub fn index_to_pos(&self, index: u32) -> U16Vec2 { + debug_assert!(index < self.tiles.len() as u32); + let width = self.size.x as u32; + U16Vec2::new((index % width) as u16, (index / width) as u16) + } + + /// Checks if a position is within the map bounds. + /// + /// Accepts both U16Vec2 and UVec2 for backward compatibility. + #[inline] + pub fn in_bounds>(&self, pos: P) -> bool { + let pos = pos.into(); + pos.x < self.size.x && pos.y < self.size.y + } + + /// Gets the tile value at the specified position. + /// + /// Returns `None` if the position is out of bounds. + pub fn get>(&self, pos: P) -> Option { + let pos = pos.into(); + if self.in_bounds(pos) { Some(self.tiles[self.pos_to_index(pos) as usize]) } else { None } + } + + /// Sets the tile value at the specified position. + /// + /// Returns `true` if the position was in bounds and the value was set, + /// `false` otherwise. + pub fn set>(&mut self, pos: P, tile: T) -> bool { + let pos = pos.into(); + if self.in_bounds(pos) { + let idx = self.pos_to_index(pos) as usize; + self.tiles[idx] = tile; + true + } else { + false + } + } + + /// Returns the size of the map as U16Vec2. + #[inline] + pub fn size(&self) -> U16Vec2 { + self.size + } + + /// Returns the width of the map. + #[inline] + pub fn width(&self) -> u16 { + self.size.x + } + + /// Returns the height of the map. + #[inline] + pub fn height(&self) -> u16 { + self.size.y + } + + /// Returns the total number of tiles in the map. + #[inline] + pub fn len(&self) -> usize { + self.tiles.len() + } + + /// Returns `true` if the map contains no tiles. + #[inline] + pub fn is_empty(&self) -> bool { + self.tiles.is_empty() + } + + /// Returns an iterator over all valid cardinal neighbors of a position. + /// + /// Yields positions for up, down, left, and right neighbors that are within bounds. + pub fn neighbors>(&self, pos: P) -> impl Iterator { + crate::game::utils::neighbors(pos.into(), self.size) + } + + /// Calls a closure for each neighbor using tile indices instead of positions. + /// + /// This is useful when working with systems that still use raw indices. + pub fn on_neighbor_indices(&self, index: u32, mut closure: F) + where + F: FnMut(u32), + { + let width = self.size.x as u32; + let height = self.size.y as u32; + let x = index % width; + let y = index / width; + + if x > 0 { + closure(index - 1); + } + if x < width - 1 { + closure(index + 1); + } + if y > 0 { + closure(index - width); + } + if y < height - 1 { + closure(index + width); + } + } + + /// Returns an iterator over all positions and their tile values. + pub fn iter(&self) -> impl Iterator + '_ { + (0..self.size.y).flat_map(move |y| { + (0..self.size.x).map(move |x| { + let pos = U16Vec2::new(x, y); + (pos, self[pos]) + }) + }) + } + + /// Returns an iterator over just the tile values. + pub fn iter_values(&self) -> impl Iterator + '_ { + self.tiles.iter().copied() + } + + /// Returns an iterator over all positions in the map. + pub fn positions(&self) -> impl Iterator + '_ { + (0..self.size.y).flat_map(move |y| (0..self.size.x).map(move |x| U16Vec2::new(x, y))) + } + + /// Returns an iterator over tile indices, positions, and values. + pub fn enumerate(&self) -> impl Iterator + '_ { + self.tiles.iter().enumerate().map(move |(idx, &value)| { + let pos = self.index_to_pos(idx as u32); + (idx, pos, value) + }) + } + + /// Returns a reference to the underlying tile data as a slice. + pub fn as_slice(&self) -> &[T] { + &self.tiles + } + + /// Returns a mutable reference to the underlying tile data as a slice. + pub fn as_mut_slice(&mut self) -> &mut [T] { + &mut self.tiles + } +} + +impl TileMap { + /// Creates a new TileMap with the specified dimensions, using T::default() for initialization. + pub fn new(size: U16Vec2) -> Self { + Self::with_default(size, T::default()) + } +} + +impl Index for TileMap { + type Output = T; + + #[inline] + fn index(&self, pos: U16Vec2) -> &Self::Output { + &self.tiles[self.pos_to_index(pos) as usize] + } +} + +impl IndexMut for TileMap { + #[inline] + fn index_mut(&mut self, pos: U16Vec2) -> &mut Self::Output { + let idx = self.pos_to_index(pos) as usize; + &mut self.tiles[idx] + } +} + +// Backward compatibility: allow indexing with UVec2 +impl Index for TileMap { + type Output = T; + + #[inline] + fn index(&self, pos: UVec2) -> &Self::Output { + let pos16 = U16Vec2::new(pos.x as u16, pos.y as u16); + &self.tiles[self.pos_to_index(pos16) as usize] + } +} + +impl IndexMut for TileMap { + #[inline] + fn index_mut(&mut self, pos: UVec2) -> &mut Self::Output { + let pos16 = U16Vec2::new(pos.x as u16, pos.y as u16); + let idx = self.pos_to_index(pos16) as usize; + &mut self.tiles[idx] + } +} + +impl Index for TileMap { + type Output = T; + + #[inline] + fn index(&self, index: usize) -> &Self::Output { + &self.tiles[index] + } +} + +impl IndexMut for TileMap { + #[inline] + fn index_mut(&mut self, index: usize) -> &mut Self::Output { + &mut self.tiles[index] + } +} diff --git a/crates/borders-core/src/lib.rs b/crates/borders-core/src/lib.rs new file mode 100644 index 0000000..db15c22 --- /dev/null +++ b/crates/borders-core/src/lib.rs @@ -0,0 +1,43 @@ +pub mod build_info; +pub mod game; +pub mod networking; +pub mod telemetry; +pub mod time; +pub mod ui; + +use std::future::Future; + +/// Spawn an async task on the appropriate runtime for the platform. +/// +/// On native targets, uses tokio::spawn for multi-threaded execution. +/// On WASM targets, uses wasm_bindgen_futures::spawn_local for browser integration. +#[cfg(not(target_arch = "wasm32"))] +pub fn spawn_task(future: F) +where + F: Future + Send + 'static, +{ + tokio::spawn(future); +} + +#[cfg(target_arch = "wasm32")] +pub fn spawn_task(future: F) +where + F: Future + 'static, +{ + wasm_bindgen_futures::spawn_local(future); +} + +#[cfg(not(target_arch = "wasm32"))] +pub mod dns; + +pub mod prelude { + //! Prelude module for convenient imports in tests and examples + pub use crate::game::*; + pub use crate::networking::*; + pub use crate::spawn_task; + pub use crate::time::*; + + // Re-export common external dependencies + pub use bevy_ecs::prelude::*; + pub use glam::*; +} diff --git a/crates/borders-core/src/networking/client/connection.rs b/crates/borders-core/src/networking/client/connection.rs new file mode 100644 index 0000000..3e2f594 --- /dev/null +++ b/crates/borders-core/src/networking/client/connection.rs @@ -0,0 +1,270 @@ +//! Unified connection abstraction for local and remote networking +//! +//! This module provides a generic `Connection` interface that abstracts away +//! the transport mechanism (local channels vs network). Game systems interact +//! with a single `Connection` resource regardless of whether the game is +//! single-player or multiplayer. + +use std::collections::{HashMap, VecDeque}; + +use bevy_ecs::prelude::*; +use flume::{Receiver, Sender}; +use tracing::{debug, warn}; + +use crate::game::NationId; +use crate::networking::{Intent, Turn, protocol::NetMessage}; + +/// Intent with tracking ID for confirmation +#[derive(Debug, Clone)] +pub struct TrackedIntent { + pub id: u64, + pub intent: Intent, +} + +/// Resource for receiving tracked intents (local mode) +#[derive(Resource)] +pub struct TrackedIntentReceiver { + pub rx: Receiver, +} + +/// Backend trait for connection implementations +/// +/// This trait abstracts the transport mechanism, allowing both local +/// and remote connections to be used interchangeably. +pub trait ConnectionBackend: Send + Sync { + /// Send an intent with tracking ID + fn send_intent(&self, id: u64, intent: Intent); + + /// Get the player ID for this connection + fn player_id(&self) -> Option; + + /// Try to receive a turn (non-blocking) + /// Returns None if no turn is available + fn try_recv_turn(&self) -> Option; +} + +/// Local backend implementation (single-player) +pub struct LocalBackend { + intent_tx: Sender, + turn_rx: Receiver, + player_id: NationId, +} + +impl LocalBackend { + pub fn new(intent_tx: Sender, turn_rx: Receiver, player_id: NationId) -> Self { + Self { intent_tx, turn_rx, player_id } + } +} + +impl ConnectionBackend for LocalBackend { + fn send_intent(&self, id: u64, intent: Intent) { + let tracked = TrackedIntent { id, intent }; + if let Err(e) = self.intent_tx.try_send(tracked) { + warn!("Failed to send tracked intent: {:?}", e); + } + } + + fn player_id(&self) -> Option { + Some(self.player_id) + } + + fn try_recv_turn(&self) -> Option { + self.turn_rx.try_recv().ok() + } +} + +/// Remote backend implementation (multiplayer) +pub struct RemoteBackend { + intent_tx: Sender, + net_message_rx: Receiver, + player_id: std::sync::Arc>>, +} + +impl RemoteBackend { + pub fn new(intent_tx: Sender, net_message_rx: Receiver) -> Self { + Self { intent_tx, net_message_rx, player_id: std::sync::Arc::new(std::sync::RwLock::new(None)) } + } + + /// Try to receive a NetMessage (for processing in receive system) + pub fn try_recv_message(&self) -> Option { + self.net_message_rx.try_recv().ok() + } + + /// Set player ID when ServerConfig is received + pub fn set_player_id(&self, player_id: NationId) { + if let Ok(mut guard) = self.player_id.write() { + *guard = Some(player_id); + } + } +} + +impl ConnectionBackend for RemoteBackend { + fn send_intent(&self, id: u64, intent: Intent) { + let msg = NetMessage::Intent { id, intent }; + if let Err(e) = self.intent_tx.try_send(msg) { + warn!("Failed to send net intent: {:?}", e); + } + } + + fn player_id(&self) -> Option { + self.player_id.read().ok().and_then(|guard| *guard) + } + + fn try_recv_turn(&self) -> Option { + // For remote, turn reception is handled by receive_messages_system + // which processes NetMessage protocol + None + } +} + +/// Pending intent tracking info +pub struct PendingIntent { + pub intent: Intent, + pub sent_turn: u64, +} + +/// Intent tracker for drop detection +pub struct IntentTracker { + next_id: u64, + pending: HashMap, + pending_ordered: VecDeque, + turn_buffer_size: usize, +} + +impl IntentTracker { + pub fn new() -> Self { + Self { + next_id: 1, + pending: HashMap::new(), + pending_ordered: VecDeque::new(), + turn_buffer_size: 5, // 500ms buffer at 100ms/turn + } + } + + pub fn next_id(&mut self) -> u64 { + let id = self.next_id; + self.next_id += 1; + id + } + + pub fn track_sent(&mut self, intent_id: u64, intent: Intent, current_turn: u64) { + self.pending.insert(intent_id, PendingIntent { intent, sent_turn: current_turn }); + self.pending_ordered.push_back(intent_id); + } + + pub fn confirm_intent(&mut self, intent_id: u64) -> bool { + self.pending.remove(&intent_id).is_some() + } + + pub fn expire_old(&mut self, current_turn: u64) -> Vec { + let mut expired = Vec::new(); + + while let Some(&id) = self.pending_ordered.front() { + if let Some(pending) = self.pending.get(&id) { + // Check if still within buffer window + if current_turn.saturating_sub(pending.sent_turn) <= self.turn_buffer_size as u64 { + break; + } + // Expired - remove and warn + expired.push(self.pending.remove(&id).unwrap()); + } + // Either expired or already confirmed - remove from queue + self.pending_ordered.pop_front(); + } + + expired + } + + pub fn turn_buffer_size(&self) -> usize { + self.turn_buffer_size + } +} + +impl Default for IntentTracker { + fn default() -> Self { + Self::new() + } +} + +/// Unified connection resource +/// +/// This resource abstracts away local vs remote transport mechanisms. +/// Game systems interact with this single resource regardless of network mode. +#[derive(Resource)] +pub struct Connection { + backend: Box, + tracker: IntentTracker, +} + +impl Connection { + pub fn new(backend: Box) -> Self { + Self { backend, tracker: IntentTracker::new() } + } + + pub fn new_local(backend: LocalBackend) -> Self { + Self::new(Box::new(backend)) + } + + pub fn new_remote(backend: RemoteBackend) -> Self { + Self::new(Box::new(backend)) + } + + /// Send an intent with automatic tracking + pub fn send_intent(&mut self, intent: Intent, current_turn: u64) { + let intent_id = self.tracker.next_id(); + self.tracker.track_sent(intent_id, intent.clone(), current_turn); + self.backend.send_intent(intent_id, intent); + } + + /// Confirm receipt of an intent by ID + pub fn confirm_intent(&mut self, intent_id: u64) -> bool { + let confirmed = self.tracker.confirm_intent(intent_id); + if confirmed { + debug!("Confirmed intent {}", intent_id); + } + confirmed + } + + /// Check for expired intents that weren't received + pub fn check_expired(&mut self, current_turn: u64) -> Vec { + self.tracker.expire_old(current_turn) + } + + /// Get player ID for this connection + pub fn player_id(&self) -> Option { + self.backend.player_id() + } + + /// Try to receive a turn (works for local backend) + pub fn try_recv_turn(&self) -> Option { + self.backend.try_recv_turn() + } + + /// Get the turn buffer size for warning messages + pub fn turn_buffer_size(&self) -> usize { + self.tracker.turn_buffer_size() + } + + /// Get mutable access to backend (for downcasting) + pub fn backend_mut(&mut self) -> &mut dyn ConnectionBackend { + &mut *self.backend + } +} + +/// Helper trait for downcasting backends +pub trait AsRemoteBackend { + fn as_remote(&self) -> Option<&RemoteBackend>; + fn as_remote_mut(&mut self) -> Option<&mut RemoteBackend>; +} + +impl AsRemoteBackend for dyn ConnectionBackend { + fn as_remote(&self) -> Option<&RemoteBackend> { + // This is a simplified approach - in production you'd use Any trait + None + } + + fn as_remote_mut(&mut self) -> Option<&mut RemoteBackend> { + // This is a simplified approach - in production you'd use Any trait + None + } +} diff --git a/crates/borders-core/src/networking/client/mod.rs b/crates/borders-core/src/networking/client/mod.rs new file mode 100644 index 0000000..0e2e9b9 --- /dev/null +++ b/crates/borders-core/src/networking/client/mod.rs @@ -0,0 +1,5 @@ +mod connection; +mod systems; + +pub use connection::*; +pub use systems::*; diff --git a/crates/borders-core/src/networking/client/systems.rs b/crates/borders-core/src/networking/client/systems.rs new file mode 100644 index 0000000..ae1d9ec --- /dev/null +++ b/crates/borders-core/src/networking/client/systems.rs @@ -0,0 +1,39 @@ +use super::connection::Connection; +use crate::{ + game::{SpawnManager, SpawnPoint, TerrainData, TerritoryManager, systems::turn::CurrentTurn}, + networking::{IntentEvent, SpawnConfigEvent}, +}; +use bevy_ecs::prelude::*; +use tracing::{debug, info}; + +/// Resource for receiving tracked intents from the client +pub type IntentReceiver = super::connection::TrackedIntentReceiver; + +/// Unified intent sending system that works for both local and remote +/// +/// Uses the generic `Connection` resource to abstract transport mechanism. +pub fn send_intent_system(mut intent_events: MessageReader, mut connection: ResMut, current_turn: Option>) { + let turn_number = current_turn.as_ref().map(|ct| ct.turn.turn_number).unwrap_or(0); + + for event in intent_events.read() { + debug!("Sending intent: {:?}", event.0); + connection.send_intent(event.0.clone(), turn_number); + } +} + +/// System to handle spawn configuration updates from server +/// Updates local SpawnManager with remote player spawn positions +pub fn handle_spawn_config_system(mut events: MessageReader, mut spawns: If>, territory: Res, terrain: Res) { + for event in events.read() { + // Update player spawns from server + spawns.player_spawns.clear(); + for (&player_id, &tile_index) in &event.0 { + spawns.player_spawns.push(SpawnPoint::new(player_id, tile_index)); + } + + // Recalculate bot spawns based on updated player positions + spawns.current_bot_spawns = crate::game::ai::bot::recalculate_spawns_with_players(spawns.initial_bot_spawns.clone(), &spawns.player_spawns, &territory, &terrain, spawns.rng_seed); + + info!("Updated spawn manager with {} player spawns from server", spawns.player_spawns.len()); + } +} diff --git a/crates/borders-core/src/networking/mod.rs b/crates/borders-core/src/networking/mod.rs new file mode 100644 index 0000000..60b5be2 --- /dev/null +++ b/crates/borders-core/src/networking/mod.rs @@ -0,0 +1,16 @@ +//! Networking and multiplayer synchronization +//! +//! This module provides the core networking infrastructure for the game: +//! - Shared protocol and data structures +//! - Client-side connection and systems +//! - Server-side turn generation and coordination + +// Public modules +pub mod client; +pub mod server; + +// Flattened public modules +mod protocol; +mod types; +pub use protocol::*; +pub use types::*; diff --git a/crates/borders-core/src/networking/protocol.rs b/crates/borders-core/src/networking/protocol.rs new file mode 100644 index 0000000..b2f60c0 --- /dev/null +++ b/crates/borders-core/src/networking/protocol.rs @@ -0,0 +1,43 @@ +//! Network protocol for multiplayer client-server communication + +use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; + +use crate::{game::NationId, networking::Intent}; +use glam::U16Vec2; +use std::collections::HashMap; + +/// Intent wrapper with source nation ID assigned by server +/// +/// The server wraps all intents with the authenticated source nation ID +/// to prevent client spoofing. The intent_id is echoed back from the +/// client for round-trip tracking. +#[derive(Debug, Clone, Archive, RkyvSerialize, RkyvDeserialize)] +#[rkyv(derive(Debug))] +#[derive(serde::Serialize, serde::Deserialize)] +pub struct SourcedIntent { + /// Authenticated nation ID (assigned by server) + pub source: NationId, + /// Client-assigned ID for tracking (echoed back by server) + pub intent_id: u64, + /// The actual intent payload + pub intent: Intent, +} + +/// Network message protocol for client-server communication +#[derive(Debug, Clone, Archive, RkyvSerialize, RkyvDeserialize)] +#[rkyv(derive(Debug))] +pub enum NetMessage { + /// Server assigns nation ID to client + ServerConfig { nation_id: NationId }, + /// Client sends intent to server with tracking ID + Intent { id: u64, intent: Intent }, + /// Server broadcasts turn to all clients with sourced intents + Turn { turn: u64, intents: Vec }, + /// Server broadcasts current spawn configuration during spawn phase + /// Maps nation_id -> tile_position for all nations who have chosen spawns + SpawnConfiguration { spawns: HashMap }, +} + +/// Shared constants across all binaries for deterministic behavior +pub const NETWORK_SEED: u64 = 0xC0FFEE; +pub const TICK_MS: u64 = 100; diff --git a/crates/borders-core/src/networking/server/coordinator.rs b/crates/borders-core/src/networking/server/coordinator.rs new file mode 100644 index 0000000..ff7c03f --- /dev/null +++ b/crates/borders-core/src/networking/server/coordinator.rs @@ -0,0 +1,157 @@ +use crate::game::terrain::TerrainData; +use crate::game::{SpawnManager, TerritoryManager}; +use crate::time::Time; +use bevy_ecs::prelude::*; +use tracing::warn; + +use super::turn_generator::{SharedTurnGenerator, TurnOutput}; +use crate::game::LocalPlayerContext; +use crate::networking::{Intent, ProcessTurnEvent, SourcedIntent, Turn}; +use flume::{Receiver, Sender}; +use std::sync::{ + Arc, + atomic::{AtomicBool, Ordering}, +}; + +/// Resource for receiving tracked intents from the client +/// This has replaced the old IntentReceiver that used plain Intent +pub type IntentReceiver = crate::networking::client::TrackedIntentReceiver; + +#[derive(Resource)] +pub struct TurnReceiver { + pub turn_rx: Receiver, +} + +/// Local turn server control handle +#[derive(Resource, Clone)] +pub struct LocalTurnServerHandle { + pub paused: Arc, + pub running: Arc, +} + +impl LocalTurnServerHandle { + pub fn pause(&self) { + self.paused.store(true, Ordering::SeqCst); + } + + pub fn resume(&self) { + self.paused.store(false, Ordering::SeqCst); + } + + pub fn stop(&self) { + self.running.store(false, Ordering::SeqCst); + } + + pub fn is_paused(&self) -> bool { + self.paused.load(Ordering::SeqCst) + } + + pub fn is_running(&self) -> bool { + self.running.load(Ordering::SeqCst) + } +} + +/// Resource wrapping the shared turn generator and output channel +#[derive(Resource)] +pub struct TurnGenerator { + generator: SharedTurnGenerator, + turn_tx: Sender, +} + +impl TurnGenerator { + pub fn new(turn_tx: Sender) -> Self { + Self { generator: SharedTurnGenerator::new(), turn_tx } + } + + /// Skip spawn phase and start the game immediately + /// This is useful for tests that don't need the spawn phase + pub fn start_game_immediately(&mut self) { + self.generator.skip_spawn_phase(); + } +} + +/// System to generate turns using Bevy's Update loop +#[allow(clippy::too_many_arguments)] +pub fn generate_turns_system(mut generator: If>, server_handle: If>, intent_receiver: If>, local_context: Option>, mut spawns: Option>, time: Res