diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 49ef237..dfb827d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,10 @@ name: Release on: + # A nightly dry run on main: every release build except macOS, nothing signed or released + # (craft-common-actions release.yml `dry-run`). Finds release-only breakage before release day. + schedule: + - cron: "12 2 * * *" push: branches: [release] workflow_dispatch: @@ -10,8 +14,8 @@ on: type: string default: "" -# Nothing by default; each job names what it needs. Only `release` and `freebsd-draft` write -# (the draft GitHub Release, and the packages the shared release job publishes). +# Nothing by default; each job names what it needs. Only `release` writes (the draft GitHub +# Release, and the packages the shared release job publishes). permissions: {} concurrency: @@ -26,13 +30,11 @@ jobs: # Intentionally tracked at @main (not SHA-pinned) so org-wide CI improvements, security fixes, and build optimizations propagate without PR churn across all craftapp repos. uses: storytold/craft-common-actions/.github/workflows/release.yml@main with: + dry-run: ${{ github.event_name == 'schedule' }} app-name: materialcraft app-title: "MaterialCraft" craft-fonts-ref: 3d9ab3a132ed0eff457e424226a435a901da30d3 web-craft-fonts: true - # The shared FreeBSD job needs more memory than a private repo's ubuntu-latest has. The - # freebsd job below builds it here on a larger runner instead. - has-freebsd: false version: ${{ inputs.version }} secrets: APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} @@ -50,279 +52,3 @@ jobs: AZURE_SIGNING_ACCOUNT: ${{ secrets.AZURE_SIGNING_ACCOUNT }} AZURE_CERT_PROFILE: ${{ secrets.AZURE_CERT_PROFILE }} LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }} - - # The jobs below stay here only while this repo is private. They follow the shared workflow's - # FreeBSD job, on a larger runner. When the repo is public, remove them and has-freebsd: false. - version: - timeout-minutes: 10 - name: version - runs-on: ubuntu-latest - permissions: - contents: read - outputs: - version: ${{ steps.v.outputs.version }} - date: ${{ steps.v.outputs.date }} - prerelease: ${{ steps.v.outputs.prerelease }} - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - id: v - name: Resolve version - uses: storytold/craft-common-actions/actions/resolve-version@main - with: - input-version: ${{ inputs.version }} - app-title: "MaterialCraft" - - freebsd: - name: FreeBSD ${{ matrix.arch }} - needs: [version] - # A private repo's ubuntu-latest has about 7 GB, too little for the VM's 12 GB. - runs-on: github-ubuntu-16core - permissions: - contents: read - timeout-minutes: 300 - strategy: - fail-fast: false - matrix: - arch: [x86_64, aarch64] - env: - APP_NAME: materialcraft - CARGO_HOME: /var/tmp/craft-cargo - CARGO_TARGET_DIR: /var/tmp/craft-target - CARGO_BUILD_JOBS: 4 - CARGO_TERM_COLOR: always - CARGO_INCREMENTAL: 0 - RUST_BACKTRACE: 1 - VERSION: ${{ needs.version.outputs.version }} - BUILD_DATE: ${{ needs.version.outputs.date }} - BUILD_SHA: ${{ github.sha }} - MATERIALCRAFT_VERSION: ${{ needs.version.outputs.version }} - MATERIALCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }} - MATERIALCRAFT_BUILD_SHA: ${{ github.sha }} - INPUT_VERSION: ${{ inputs.version }} - steps: - - name: Check the FreeBSD architecture - env: - ARCH: ${{ matrix.arch }} - run: | - # The guest is always x86_64 and only aarch64 is cross-compiled: any other value - # would build x86_64 binaries and package them under its own name. - case "$ARCH" in - x86_64 | aarch64) ;; - *) - echo "::error::unsupported FreeBSD architecture '$ARCH' in freebsd-architectures; use x86_64 or aarch64" - exit 1 - ;; - esac - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - name: Check out craft-fonts - uses: storytold/craft-common-actions/actions/checkout-craft-fonts@main - with: - ref: 3d9ab3a132ed0eff457e424226a435a901da30d3 - - name: Check out craft-i18n - uses: storytold/craft-common-actions/actions/checkout-craft-i18n@main - - name: Start the FreeBSD VM - uses: vmactions/freebsd-vm@c46abacb49f09938ca4e1702d15d836285d694cc # v1.5.9 - with: - release: "15.1" - # Always an x86_64 guest, which KVM accelerates: aarch64 is cross-compiled in it, - # because an emulated aarch64 guest takes over 5 hours for most apps (#39). - usesh: true - cpu: 4 - mem: 12288 - copyback: false - envs: "APP_NAME CARGO_HOME CARGO_TARGET_DIR CARGO_INCREMENTAL CARGO_BUILD_JOBS VERSION BUILD_DATE BUILD_SHA INPUT_VERSION MATERIALCRAFT_VERSION MATERIALCRAFT_BUILD_DATE MATERIALCRAFT_BUILD_SHA" - prepare: | - # Keep rustup/proxies outside the Cargo data cache. - unset CARGO_HOME CARGO_TARGET_DIR - if [ "${{ matrix.arch }}" = aarch64 ]; then - # The host compiler and the aarch64 standard library come from the amd64 and - # aarch64 lang/rust packages, which must be the same build. "latest" can build - # them days apart; the quarterly branch keeps them in step. - mkdir -p /usr/local/etc/pkg/repos - printf 'FreeBSD-ports: { url: "https://pkg.FreeBSD.org/${ABI}/quarterly" }\n' > /usr/local/etc/pkg/repos/FreeBSD.conf - pkg update -f -q - fi - pkg install -y bash git curl pkgconf cmake python3 libxkbcommon wayland libX11 libXcursor libXrandr libXi libxcb mesa-libs vulkan-loader gtk3 fontconfig freetype2 alsa-lib - # aarch64-unknown-freebsd is a tier-3 Rust target: rustup publishes no toolchain - # or standard library for it ("installer for platform not found"), so use - # FreeBSD's lang/rust package. - if [ "${{ matrix.arch }}" = aarch64 ]; then - pkg install -y rust - else - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable - fi - - name: Set up the aarch64 cross toolchain - if: matrix.arch == 'aarch64' - shell: freebsd {0} - run: | - set -eu - # Stable Rust, no -Zbuild-std: the aarch64 standard library is copied from FreeBSD's - # aarch64 lang/rust package, and C code links with base clang and lld against an - # arm64 sysroot (base.txz plus the libraries the prepare step installs). - target=aarch64-unknown-freebsd - X=/var/tmp/craft-cross - S=$X/sysroot - mkdir -p "$X/db" "$X/cache" "$S" - release=$(freebsd-version -u | sed 's/-p[0-9]*$//') - P="-o ABI=FreeBSD:${release%%.*}:aarch64 -o OSVERSION=$(uname -U) -o PKG_DBDIR=$X/db -o PKG_CACHEDIR=$X/cache -o IGNORE_OSVERSION=yes" - pkg $P update -q - host=$(pkg query %v rust) - cross=$(pkg $P rquery %v rust) - if [ "$host" != "$cross" ]; then - echo "error: lang/rust is $host for amd64 but $cross for aarch64; the standard library must match the compiler" >&2 - exit 1 - fi - pkg $P fetch -y -q rust - # pkg links each name-version.pkg to its hashed file. - tar -xf "$X/cache/rust-$cross.pkg" -C "$X" --include "*usr/local/lib/rustlib/$target/*" - cp -R "$X/usr/local/lib/rustlib/$target" /usr/local/lib/rustlib/ - base=https://download.freebsd.org/releases/arm64/aarch64/$release - fetch -q -o "$X/MANIFEST" "$base/MANIFEST" - fetch -q -o "$X/base.txz" "$base/base.txz" - if [ "$(awk '$1 == "base.txz" { print $2 }' "$X/MANIFEST")" != "$(sha256 -q "$X/base.txz")" ]; then - echo "error: arm64 base.txz does not match its MANIFEST" >&2 - exit 1 - fi - tar -xf "$X/base.txz" -C "$S" ./lib ./usr/lib ./usr/include ./usr/libdata - # The libraries the prepare step installs; the build tools and fonts stay host-only. - pkg $P fetch -y -q -d libxkbcommon wayland libX11 libXcursor libXrandr libXi libxcb mesa-libs vulkan-loader gtk3 fontconfig freetype2 alsa-lib - for p in "$X"/cache/*.pkg; do - [ ! -L "$p" ] || continue - case "$p" in */rust-*) continue ;; esac - tar -xf "$p" -C "$S" --exclude '+*' - done - for tool in cc c++; do - printf '#!/bin/sh\nexec %s --target=%s%s --sysroot=%s -fuse-ld=lld -I%s/usr/local/include -L%s/usr/local/lib -Wl,-rpath-link,%s/usr/local/lib "$@"\n' \ - "$tool" "$target" "${release%%-*}" "$S" "$S" "$S" "$S" > "$X/$tool" - chmod +x "$X/$tool" - done - cat > "$X/env" </release. - rel="${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}release" - export CRAFT_FONTS_DIR="$PWD/craft-fonts" CRAFT_FONTS_REQUIRED=1 - if [ -f craft-i18n.rev ]; then export CRAFT_I18N_DIR="$PWD/craft-i18n" CRAFT_I18N_REQUIRED=1; fi - if [ -f packaging/freebsd/package.sh ]; then - bash packaging/freebsd/package.sh - else - set -- -p "$APP_NAME" - if cargo metadata --format-version 1 --no-deps | python3 -c 'import json, sys; sys.exit(not any(p["name"] == sys.argv[1] for p in json.load(sys.stdin)["packages"]))' "$APP_NAME-cli"; then - set -- "$@" -p "$APP_NAME-cli" - fi - cargo build --release --locked "$@" - name="$APP_NAME-$VERSION-freebsd-${{ matrix.arch }}" - mkdir -p "dist/release/$name" - cp "target/$rel/$APP_NAME" "dist/release/$name/" 2>/dev/null || cp "/var/tmp/craft-target/$rel/$APP_NAME" "dist/release/$name/" - if [ -f "target/$rel/$APP_NAME-cli" ]; then - cp "target/$rel/$APP_NAME-cli" "dist/release/$name/" - elif [ -f "/var/tmp/craft-target/$rel/$APP_NAME-cli" ]; then - cp "/var/tmp/craft-target/$rel/$APP_NAME-cli" "dist/release/$name/" - fi - cp README.md LICENSE-MIT LICENSE-APACHE NOTICE ATTRIBUTION.md "dist/release/$name/" 2>/dev/null || true - if [ -f "packaging/linux/ai.storyteller.$APP_NAME.desktop" ]; then - cp "packaging/linux/ai.storyteller.$APP_NAME.desktop" "dist/release/$name/" - fi - mkdir -p "dist/release/$name/icons" - cp -R assets/app-icon/hicolor "dist/release/$name/icons/" 2>/dev/null || true - tar -C dist/release -czf "dist/release/$name.tar.gz" "$name" - rm -rf "dist/release/$name" - fi - # The guest is x86_64 either way: a package.sh that names its archive after uname -m - # instead of CARGO_BUILD_TARGET would ship an x86_64-labelled aarch64 build, or worse. - found= - for archive in dist/release/*-freebsd-*.tar.gz; do - [ -f "$archive" ] || continue - case "$archive" in - *-freebsd-${{ matrix.arch }}.tar.gz) found=1 ;; - *) - echo "error: $archive is not a FreeBSD ${{ matrix.arch }} archive; packaging/freebsd/package.sh must honor CARGO_BUILD_TARGET" >&2 - exit 1 - ;; - esac - done - if [ -z "$found" ]; then - echo "error: no FreeBSD ${{ matrix.arch }} archive was produced" >&2 - exit 1 - fi - - name: Copy release archives from the VM - run: | - mkdir -p dist/release - rsync -a --timeout=1800 --rsync-path='env PATH=/usr/local/bin:/usr/bin:/bin rsync' \ - -e 'ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=60 -o ConnectTimeout=120' \ - "freebsd:$GITHUB_WORKSPACE/dist/release/" dist/release/ - - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: release-freebsd-${{ matrix.arch }} - path: dist/release/* - if-no-files-found: error - - name: Save FreeBSD release Cargo cache - if: github.event_name != 'pull_request' && github.event_name != 'pull_request_target' && steps.cargo-cache.outputs.key != '' && steps.cargo-cache.outputs.cache-hit != 'true' - continue-on-error: true - timeout-minutes: 10 - uses: storytold/craft-common-actions/actions/freebsd-cargo-cache@main - with: - phase: save - profile: release - configuration: ${{ toJSON(inputs) }} - source-hash: ${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/build.rs', '.cargo/**', 'rust-toolchain*', 'packaging/**', '.github/workflows/release.yml') }} - key: ${{ steps.cargo-cache.outputs.key }} - - # The shared draft job can run before FreeBSD finishes, so add its archives afterwards. - freebsd-draft: - timeout-minutes: 10 - name: Add FreeBSD to the draft release - needs: [version, freebsd, release] - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - pattern: release-freebsd-* - path: artifacts - merge-multiple: true - - name: Upload the archives and update the checksums - working-directory: artifacts - env: - VERSION: ${{ needs.version.outputs.version }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_REPO: ${{ github.repository }} - run: | - tag="v$VERSION" - [ "$(gh release view "$tag" --json isDraft --jq .isDraft)" = true ] - gh release download "$tag" --pattern SHA256SUMS.txt --dir "$RUNNER_TEMP" - # The shared draft job also picks up any archive that finished before it ran. - # Written outside this directory, or the * below would list the checksum file itself. - { grep -v -- '-freebsd-' "$RUNNER_TEMP/SHA256SUMS.txt" || true; sha256sum -- *; } | sort -k2 >"$RUNNER_TEMP/SHA256SUMS.new" - mv "$RUNNER_TEMP/SHA256SUMS.new" SHA256SUMS.txt - gh release upload "$tag" --clobber -- * - cat SHA256SUMS.txt diff --git a/Cargo.lock b/Cargo.lock index 8610dd3..9342635 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -209,7 +209,7 @@ dependencies = [ "objc2-foundation 0.3.2", "parking_lot", "percent-encoding", - "windows-sys 0.60.2", + "windows-sys 0.61.2", "wl-clipboard-rs", "x11rb", ] @@ -605,7 +605,7 @@ dependencies = [ "maybe-owned", "rustix 1.1.6", "rustix-linux-procfs", - "windows-sys 0.60.2", + "windows-sys 0.61.2", "winx", ] @@ -810,7 +810,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d" +source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba6229716e6624db9eb25b#6e03f65bf45181db77ba6229716e6624db9eb25b" dependencies = [ "rustix 1.1.6", ] @@ -818,7 +818,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d" +source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba6229716e6624db9eb25b#6e03f65bf45181db77ba6229716e6624db9eb25b" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -831,12 +831,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d" +source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba6229716e6624db9eb25b#6e03f65bf45181db77ba6229716e6624db9eb25b" [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d" +source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba6229716e6624db9eb25b#6e03f65bf45181db77ba6229716e6624db9eb25b" dependencies = [ "fixed_decimal", "icu_decimal", @@ -859,7 +859,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d" +source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba6229716e6624db9eb25b#6e03f65bf45181db77ba6229716e6624db9eb25b" dependencies = [ "egui", "serde", @@ -869,7 +869,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d" +source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba6229716e6624db9eb25b#6e03f65bf45181db77ba6229716e6624db9eb25b" dependencies = [ "craft-keymap", "craft-quit", @@ -882,7 +882,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d" +source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba6229716e6624db9eb25b#6e03f65bf45181db77ba6229716e6624db9eb25b" dependencies = [ "dispatch2", "egui", @@ -893,7 +893,7 @@ dependencies = [ [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d" +source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba6229716e6624db9eb25b#6e03f65bf45181db77ba6229716e6624db9eb25b" dependencies = [ "craft-fonts-build", "craft-i18n", @@ -914,7 +914,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d" +source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba6229716e6624db9eb25b#6e03f65bf45181db77ba6229716e6624db9eb25b" dependencies = [ "chrono", "dunce", @@ -924,6 +924,7 @@ dependencies = [ "image", "log", "plist", + "rustix 1.1.6", "semver", "serde", "serde_json", @@ -940,7 +941,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=1b34eba41e62138fc2438d2734523b302840b45d#1b34eba41e62138fc2438d2734523b302840b45d" +source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba6229716e6624db9eb25b#6e03f65bf45181db77ba6229716e6624db9eb25b" dependencies = [ "egui", "objc2 0.6.5", @@ -1425,7 +1426,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -2609,7 +2610,7 @@ checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" [[package]] name = "materialcraft" -version = "0.1.3" +version = "0.4.1" dependencies = [ "craft-menu", "craft-update", @@ -2628,7 +2629,7 @@ dependencies = [ [[package]] name = "materialcraft-automation" -version = "0.1.3" +version = "0.4.1" dependencies = [ "base64 0.22.1", "cap-std", @@ -2649,7 +2650,7 @@ dependencies = [ [[package]] name = "materialcraft-cli" -version = "0.1.3" +version = "0.4.1" dependencies = [ "materialcraft-automation", "materialcraft-engine", @@ -2660,7 +2661,7 @@ dependencies = [ [[package]] name = "materialcraft-core" -version = "0.1.3" +version = "0.4.1" dependencies = [ "serde", "serde_json", @@ -2669,7 +2670,7 @@ dependencies = [ [[package]] name = "materialcraft-engine" -version = "0.1.3" +version = "0.4.1" dependencies = [ "materialcraft-core", "materialcraft-eval", @@ -2685,7 +2686,7 @@ dependencies = [ [[package]] name = "materialcraft-eval" -version = "0.1.3" +version = "0.4.1" dependencies = [ "half", "materialcraft-core", @@ -2697,7 +2698,7 @@ dependencies = [ [[package]] name = "materialcraft-formats" -version = "0.1.3" +version = "0.4.1" dependencies = [ "base64 0.22.1", "bytemuck", @@ -2722,7 +2723,7 @@ dependencies = [ [[package]] name = "materialcraft-geom" -version = "0.1.3" +version = "0.4.1" dependencies = [ "glam 0.30.10", "mikktspace", @@ -2733,7 +2734,7 @@ dependencies = [ [[package]] name = "materialcraft-image" -version = "0.1.3" +version = "0.4.1" dependencies = [ "rayon", "thiserror 2.0.21", @@ -2741,7 +2742,7 @@ dependencies = [ [[package]] name = "materialcraft-nodes" -version = "0.1.3" +version = "0.4.1" dependencies = [ "materialcraft-core", "materialcraft-image", @@ -2750,7 +2751,7 @@ dependencies = [ [[package]] name = "materialcraft-render" -version = "0.1.3" +version = "0.4.1" dependencies = [ "materialcraft-core", "materialcraft-geom", @@ -2760,7 +2761,7 @@ dependencies = [ [[package]] name = "materialcraft-ui-egui" -version = "0.1.3" +version = "0.4.1" dependencies = [ "base64 0.22.1", "craft-atomic", @@ -2793,7 +2794,7 @@ dependencies = [ [[package]] name = "materialcraft-web" -version = "0.1.3" +version = "0.4.1" dependencies = [ "eframe", "js-sys", @@ -2900,7 +2901,7 @@ dependencies = [ "objc2-foundation 0.3.2", "png", "thiserror 2.0.21", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -3415,7 +3416,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -4099,7 +4100,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -4166,7 +4167,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -4506,7 +4507,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -4626,7 +4627,7 @@ dependencies = [ "getrandom 0.4.3", "once_cell", "rustix 1.1.6", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -4944,7 +4945,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" dependencies = [ "memoffset", "tempfile", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -5544,7 +5545,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -6038,7 +6039,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" [[package]] name = "xtask" -version = "0.1.3" +version = "0.4.1" dependencies = [ "serde_json", ] diff --git a/Cargo.toml b/Cargo.toml index ab826e1..e235b72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ default-members = [ ] [workspace.package] -version = "0.1.3" +version = "0.4.1" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.95" @@ -87,22 +87,22 @@ getrandom = "0.3" # Shared Craft egui components (widget palette, icon buttons, panel docking): storytold/craft-libs, # MIT OR Apache-2.0, every craft-libs crate pinned to one rev. egui_kittest = "0.37" -craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d", features = ["serde"] } +craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "6e03f65bf45181db77ba6229716e6624db9eb25b", features = ["serde"] } # Keyboard bindings (chords, dispatch and display text): storytold/craft-libs, MIT OR Apache-2.0. -craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d", features = ["egui"] } +craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "6e03f65bf45181db77ba6229716e6624db9eb25b", features = ["egui"] } # Native dialogs that do not block the event loop: storytold/craft-libs, MIT OR Apache-2.0. -craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" } +craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "6e03f65bf45181db77ba6229716e6624db9eb25b" } # The platform quit and the macOS Quit menu item: storytold/craft-libs, MIT OR Apache-2.0. -craft-quit = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d", features = ["egui"] } -craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" } +craft-quit = { git = "https://github.com/storytold/craft-libs", rev = "6e03f65bf45181db77ba6229716e6624db9eb25b", features = ["egui"] } +craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "6e03f65bf45181db77ba6229716e6624db9eb25b" } # Who draws the window frame, and an app-drawn strip as the title bar: storytold/craft-libs, MIT OR Apache-2.0. -craft-window = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d", features = ["egui"] } +craft-window = { git = "https://github.com/storytold/craft-libs", rev = "6e03f65bf45181db77ba6229716e6624db9eb25b", features = ["egui"] } # Release checks and self-updates for the desktop app: storytold/craft-libs, MIT OR Apache-2.0. -craft-update = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d", features = ["egui"] } -# Atomic persistence, at the suite's existing revision. -craft-atomic = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" } +craft-update = { git = "https://github.com/storytold/craft-libs", rev = "6e03f65bf45181db77ba6229716e6624db9eb25b", features = ["egui"] } +# Atomic persistence, at the suite's current revision. +craft-atomic = { git = "https://github.com/storytold/craft-libs", rev = "6e03f65bf45181db77ba6229716e6624db9eb25b" } # Parse the optional shared font catalog at build time; the font repository is not a dependency. -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "1b34eba41e62138fc2438d2734523b302840b45d" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "6e03f65bf45181db77ba6229716e6624db9eb25b" } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] diff --git a/assets/sbs/3d_functions.sbs b/assets/sbs/3d_functions.sbs index 0e98bae..af4ed4d 100644 --- a/assets/sbs/3d_functions.sbs +++ b/assets/sbs/3d_functions.sbs @@ -1 +1 @@ - + diff --git a/assets/sbs/functions.sbs b/assets/sbs/functions.sbs index 1bf0dc0..1d70ccd 100644 --- a/assets/sbs/functions.sbs +++ b/assets/sbs/functions.sbs @@ -1 +1 @@ - + diff --git a/assets/sbs/pbr_render2.sbs b/assets/sbs/pbr_render2.sbs index 314e4fa..2041680 100644 --- a/assets/sbs/pbr_render2.sbs +++ b/assets/sbs/pbr_render2.sbs @@ -1 +1 @@ - + diff --git a/crates/automation/src/server/material_craft_mcp.rs b/crates/automation/src/server/material_craft_mcp.rs index fb3614f..5853fec 100644 --- a/crates/automation/src/server/material_craft_mcp.rs +++ b/crates/automation/src/server/material_craft_mcp.rs @@ -316,6 +316,50 @@ mod tests { assert!(!base.parent().unwrap().join("m.mcmat").exists()); } + /// Every sub-schema must be a JSON object. Claude Desktop's proxy rejects a boolean schema + /// (`"items": true`) and drops the whole server (issue 146) + fn boolean_schema_paths(v: &Value, path: &str, out: &mut Vec) { + const SCHEMA_VALUED: [&str; 4] = ["items", "additionalProperties", "not", "contains"]; + const SCHEMA_ARRAYS: [&str; 4] = ["anyOf", "oneOf", "allOf", "prefixItems"]; + const SCHEMA_MAPS: [&str; 3] = ["properties", "$defs", "patternProperties"]; + let Some(obj) = v.as_object() else { return }; + for key in SCHEMA_VALUED { + match obj.get(key) { + Some(Value::Bool(_)) => out.push(format!("{path}/{key}")), + Some(child) => boolean_schema_paths(child, &format!("{path}/{key}"), out), + None => {} + } + } + for key in SCHEMA_ARRAYS { + for (i, child) in obj.get(key).and_then(Value::as_array).into_iter().flatten().enumerate() { + match child { + Value::Bool(_) => out.push(format!("{path}/{key}/{i}")), + _ => boolean_schema_paths(child, &format!("{path}/{key}/{i}"), out), + } + } + } + for key in SCHEMA_MAPS { + for (name, child) in obj.get(key).and_then(Value::as_object).into_iter().flatten() { + match child { + Value::Bool(_) => out.push(format!("{path}/{key}/{name}")), + _ => boolean_schema_paths(child, &format!("{path}/{key}/{name}"), out), + } + } + } + } + + #[test] + fn tool_schemas_contain_no_boolean_sub_schemas() { + let tools = MaterialCraftMcp::tool_router().list_all(); + assert!(!tools.is_empty()); + let mut found = Vec::new(); + for tool in &tools { + let schema = Value::Object((*tool.input_schema).clone()); + boolean_schema_paths(&schema, &tool.name, &mut found); + } + assert!(found.is_empty(), "boolean sub-schemas break Claude Desktop: {found:?}"); + } + #[test] fn oversized_replies_become_errors() { let r = ok_json(&json!("x".repeat(crate::budgets::MAX_RESPONSE_BYTES))); diff --git a/crates/automation/src/server/parameter/input_params.rs b/crates/automation/src/server/parameter/input_params.rs index 1fea568..13f788c 100644 --- a/crates/automation/src/server/parameter/input_params.rs +++ b/crates/automation/src/server/parameter/input_params.rs @@ -1,9 +1,17 @@ -use schemars::JsonSchema; +use schemars::{JsonSchema, Schema, SchemaGenerator, json_schema}; use serde::{Deserialize, Serialize}; use serde_json::Value; #[derive(Debug, Deserialize, Serialize, JsonSchema)] pub struct InputParams { /// Input events in window points, applied in order on the next frames + #[schemars(schema_with = "events_schema")] pub events: Vec, } + +/// Every event is a JSON object. Saying so keeps `"items": true` (what `Vec` produces) and +/// `"additionalProperties": true` out of `tools/list`: Claude Desktop rejects boolean schemas and +/// drops the whole server. +fn events_schema(_: &mut SchemaGenerator) -> Schema { + json_schema!({ "type": "array", "items": { "type": "object" } }) +} diff --git a/crates/engine/src/node_library.test.rs b/crates/engine/src/node_library.test.rs index ae78306..e0df913 100644 --- a/crates/engine/src/node_library.test.rs +++ b/crates/engine/src/node_library.test.rs @@ -143,6 +143,31 @@ fn the_whole_bundled_library_is_categorized() { } } +#[test] +fn bundled_material_functions_have_compatible_inputs() { + let library = NodeLibrary::load(&library::files()); + + for (package_name, graph_names) in [ + ("sbs://3d_functions.sbs", &["3d_sdf_primitives/3d_sdf_plane"][..]), + ( + "sbs://pbr_render2.sbs", + &["ibl_specular_contrib_anisotropic/IBLSpecularContribution", "ibl_specular_contrib_anisotropic/IBLSpecularContribution_iteration"], + ), + ] { + let package = &library.packages[package_name]; + for graph_name in graph_names { + let (_, graph) = package.graph_by_name(graph_name).unwrap(); + let mut function = graph.function.as_ref().unwrap().clone(); + + materialcraft_nodes::function::resolve_instances(&mut function, package, &library.packages); + + if let Err(error) = materialcraft_nodes::function::compile(&function, 0) { + panic!("{package_name}#{graph_name}: {error}"); + } + } + } +} + /// Identifier labels preserve recognized acronyms and omit empty words. #[test] fn identifiers_read_as_labels() { diff --git a/crates/engine/tests/it/embedded_edit.rs b/crates/engine/tests/it/embedded_edit.rs index 1227d96..0e3f2f8 100644 --- a/crates/engine/tests/it/embedded_edit.rs +++ b/crates/engine/tests/it/embedded_edit.rs @@ -624,6 +624,7 @@ fn library_samplers_read_image_inputs_in_both_processors() { for definition in ["pixel_processor", "value_processor"] { for sampler in ["samplelum", "samplecol"] { let mut session = new_session(); + session.graph_mut().unwrap().format = materialcraft_engine::core::OutputFormat::F32; session.preview_size = Some(16); let color = [0.25, 0.5, 0.75, 1.0]; let image = NodeId( diff --git a/crates/engine/tests/it/function_instances.rs b/crates/engine/tests/it/function_instances.rs index c0bd7e4..d8fa550 100644 --- a/crates/engine/tests/it/function_instances.rs +++ b/crates/engine/tests/it/function_instances.rs @@ -86,7 +86,7 @@ fn function_expansion_allows_several_bounded_bodies_but_still_caps_total_work() let mut allowed = caller(3); function::resolve_instances(&mut allowed, &package, &BTreeMap::new()); assert_eq!(evaluate(&allowed), Value::Float(3.0)); - let mut oversized = caller(32); + let mut oversized = caller(64); function::resolve_instances(&mut oversized, &package, &BTreeMap::new()); assert!(function::compile(&oversized, 0).err().unwrap().contains("limit")); // Compiling a pre-resolved tree must enforce its own budget too. @@ -185,7 +185,9 @@ fn processor_calls_recook_when_source_changes_and_round_trip_without_copying_sou let target_path = directory.join("target.sbs"); execute(&mut session, "file.saveAs", &json!({"path": source_path})).unwrap(); let mut target_package = Package::new("Processors"); - target_package.graphs.push(Graph::new("Processors")); + let mut processor_graph = Graph::new("Processors"); + processor_graph.format = materialcraft_engine::core::OutputFormat::F32; + target_package.graphs.push(processor_graph); file_cmds::open_bytes(&mut session, &formats::sbs::write_sbs(&target_package).unwrap(), Some(target_path.to_string_lossy().into())).unwrap(); let document = session.document_id; let mut processors = Vec::new(); diff --git a/crates/engine/tests/it/graph_interaction.rs b/crates/engine/tests/it/graph_interaction.rs index cd22ce7..1b5d25f 100644 --- a/crates/engine/tests/it/graph_interaction.rs +++ b/crates/engine/tests/it/graph_interaction.rs @@ -214,6 +214,7 @@ fn processors_sample_dynamic_image_inputs_after_sbs_round_trip() { for definition in ["pixel_processor", "value_processor"] { let mut session = new_session(); + session.graph_mut().unwrap().format = materialcraft_engine::core::OutputFormat::F32; session.preview_size = Some(16); let source = add(&mut session, "uniform"); let processor = add(&mut session, definition); diff --git a/crates/engine/tests/it/linked_instances.rs b/crates/engine/tests/it/linked_instances.rs index 90f91fa..f4c0dd9 100644 --- a/crates/engine/tests/it/linked_instances.rs +++ b/crates/engine/tests/it/linked_instances.rs @@ -1,6 +1,6 @@ use materialcraft_engine::{ Session, - core::{Graph, NodeId, Package, Value}, + core::{Graph, NodeId, OutputFormat, Package, Value}, execute, file_cmds, formats, }; use serde_json::json; @@ -9,6 +9,7 @@ fn source() -> (Package, NodeId) { let mut package = Package::new("Source file"); let mut graph = Graph::new("Source"); graph.size = [4, 4]; + graph.format = OutputFormat::F32; let value = graph.add_node("uniform", [0.0; 2]); graph.node_mut(value).unwrap().params.insert("color".into(), Value::Color([0.25, 0.5, 0.75, 1.0])); let output = graph.add_node("output", [200.0, 0.0]); @@ -18,6 +19,12 @@ fn source() -> (Package, NodeId) { (package, value) } +fn float_graph(name: &str) -> Graph { + let mut graph = Graph::new(name); + graph.format = OutputFormat::F32; + graph +} + fn open(session: &mut Session, package: &Package, file: &str) -> u64 { file_cmds::open_bytes(session, &formats::sbs::write_sbs(package).unwrap(), Some(file.into())).unwrap(); session.document_id @@ -30,7 +37,7 @@ fn source_edits_update_instances_and_dirty_dependents_before_saving() { session.selection = vec![value]; session.path = Some(std::env::temp_dir().join("materialcraft-instance-source.sbs").to_string_lossy().into_owned()); let mut target = Package::new("Target file"); - target.graphs.push(Graph::new("Target")); + target.graphs.push(float_graph("Target")); let target_id = open(&mut session, &target, "target.sbs"); let instance = NodeId(execute(&mut session, "graph.instance.add", &json!({"document": 0, "graph": "Source"})).unwrap()["id"].as_u64().unwrap()); session.preview_size = Some(16); @@ -77,7 +84,7 @@ fn failed_edit_groups_do_not_publish_source_changes() { session.selection = vec![value]; session.path = Some(std::env::temp_dir().join("materialcraft-group-source.sbs").to_string_lossy().into_owned()); let mut target = Package::new("Target"); - target.graphs.push(Graph::new("Target")); + target.graphs.push(float_graph("Target")); let target_id = open(&mut session, &target, "group-target.sbs"); let instance = NodeId(execute(&mut session, "graph.instance.add", &json!({"document": 0, "graph": "Source"})).unwrap()["id"].as_u64().unwrap()); session.modified = false; @@ -123,7 +130,7 @@ fn updates_propagate_through_three_packages_and_cycles_are_rejected() { session.selection = vec![value]; session.path = Some(std::env::temp_dir().join("materialcraft-transitive-source.sbs").to_string_lossy().into_owned()); let mut target = Package::new("Target"); - target.graphs.push(Graph::new("Target")); + target.graphs.push(float_graph("Target")); let middle = open(&mut session, &target, "transitive-middle.sbs"); let instance = execute(&mut session, "graph.instance.add", &json!({"document": 0, "graph": "Source"})).unwrap()["id"].as_u64().unwrap(); let output = execute(&mut session, "graph.node.add", &json!({"def": "output"})).unwrap()["id"].as_u64().unwrap(); @@ -156,7 +163,7 @@ fn closing_a_modified_source_discards_its_unsaved_changes_in_dependents() { session.selection = vec![value]; execute(&mut session, "file.save", &json!({"path": source_path})).unwrap(); let mut target = Package::new("Target"); - target.graphs.push(Graph::new("Target")); + target.graphs.push(float_graph("Target")); let target_id = open(&mut session, &target, "discard-target.sbs"); let instance = NodeId(execute(&mut session, "graph.instance.add", &json!({"document": 0, "graph": "Source"})).unwrap()["id"].as_u64().unwrap()); execute(&mut session, "package.activate", &json!({"document": 0})).unwrap(); @@ -184,7 +191,7 @@ fn named_value_inputs_and_outputs_keep_their_type_across_files() { let mut session = Session::new(source); session.path = Some(std::env::temp_dir().join("materialcraft-value-source.sbs").to_string_lossy().into_owned()); let mut target = Package::new("Target"); - target.graphs.push(Graph::new("Target")); + target.graphs.push(float_graph("Target")); open(&mut session, &target, "value-target.sbs"); let instance = NodeId(execute(&mut session, "graph.instance.add", &json!({"document": 0, "graph": "Source"})).unwrap()["id"].as_u64().unwrap()); let value = execute(&mut session, "graph.node.add", &json!({"def": "input_value", "params": {"default": 0.75}})).unwrap()["id"].as_u64().unwrap(); @@ -219,7 +226,7 @@ fn removing_a_source_output_does_not_erase_connected_instance_wires_on_save() { session.path = Some(std::env::temp_dir().join("materialcraft-port-source.sbs").to_string_lossy().into_owned()); let source_output = session.graph().unwrap().nodes.iter().find(|node| node.def == "output").unwrap().id; let mut target = Package::new("Target"); - target.graphs.push(Graph::new("Target")); + target.graphs.push(float_graph("Target")); let target_id = open(&mut session, &target, "port-target.sbs"); let instance = NodeId(execute(&mut session, "graph.instance.add", &json!({"document": 0, "graph": "Source"})).unwrap()["id"].as_u64().unwrap()); let output = execute(&mut session, "graph.node.add", &json!({"def": "output"})).unwrap()["id"].as_u64().unwrap(); @@ -272,6 +279,7 @@ fn saved_dependencies_reopen_without_source_files_in_explorer_and_missing_source execute(&mut session, "file.save", &json!({"path": source_path})).unwrap(); execute(&mut session, "file.newPackage", &json!({"name": "Target"})).unwrap(); execute(&mut session, "file.new", &json!({"name": "Target", "template": "empty"})).unwrap(); + session.graph_mut().unwrap().format = OutputFormat::F32; let instance = execute(&mut session, "graph.instance.add", &json!({"document": 0, "graph": "Source"})).unwrap()["id"].as_u64().unwrap(); let output = execute(&mut session, "graph.node.add", &json!({"def": "output"})).unwrap()["id"].as_u64().unwrap(); execute(&mut session, "graph.connect", &json!({"from": instance, "fromPort": "color", "to": output})).unwrap(); @@ -323,10 +331,11 @@ fn instance_defaults_follow_current_source_inputs_before_and_after_save() { execute(&mut session, "graph.exposed.set", &json!({"id": "tint", "value": [0.2, 0.3, 0.4, 1.0]})).unwrap(); let target_document = if linked { let mut target = Package::new("Target"); - target.graphs.push(Graph::new("Target")); + target.graphs.push(float_graph("Target")); open(&mut session, &target, target_path.to_str().unwrap()) } else { execute(&mut session, "file.new", &json!({"name": "Target", "template": "empty"})).unwrap(); + session.graph_mut().unwrap().format = OutputFormat::F32; session.document_id }; let target_graph = session.graph; diff --git a/crates/engine/tests/it/material_preview.rs b/crates/engine/tests/it/material_preview.rs index 054af70..55db290 100644 --- a/crates/engine/tests/it/material_preview.rs +++ b/crates/engine/tests/it/material_preview.rs @@ -1,6 +1,6 @@ use materialcraft_engine::{ MaterialPreview, MaterialSource, Session, - core::{Graph, MaterialChannel, NodeId, Package, Value}, + core::{Graph, MaterialChannel, NodeId, OutputFormat, Package, Value}, execute, new_session, }; use serde_json::json; @@ -10,6 +10,7 @@ fn add(session: &mut Session, definition: &str, params: serde_json::Value) -> No } fn source(session: &mut Session, color: [f32; 4]) -> NodeId { + session.graph_mut().unwrap().format = OutputFormat::F32; add(session, "uniform", json!({"color_mode": true, "color": color})) } @@ -175,6 +176,7 @@ fn multiple_graph_channels_and_multi_output_instances_use_the_correct_ports() { let mut package = Package::new("Test"); let mut graph = Graph::new("Colors"); graph.size = [4, 4]; + graph.format = OutputFormat::F32; for (name, color) in [("red", [0.8, 0.1, 0.1, 1.0]), ("blue", [0.1, 0.1, 0.8, 1.0])] { let image = graph.add_node("uniform", [0.0; 2]); graph.node_mut(image).unwrap().params.insert("color".into(), Value::Color(color)); @@ -183,7 +185,9 @@ fn multiple_graph_channels_and_multi_output_instances_use_the_correct_ports() { graph.connect(image, "output", output, "input").unwrap(); } package.graphs.push(graph); - package.graphs.push(Graph::new("Instances")); + let mut instance_graph = Graph::new("Instances"); + instance_graph.format = OutputFormat::F32; + package.graphs.push(instance_graph); let mut session = Session::new(package); execute(&mut session, "graph.open", &json!({"graph": 1})).unwrap(); let instance = instance(&mut session, "Colors"); diff --git a/crates/engine/tests/it/parameter_functions.rs b/crates/engine/tests/it/parameter_functions.rs index 094a129..b459240 100644 --- a/crates/engine/tests/it/parameter_functions.rs +++ b/crates/engine/tests/it/parameter_functions.rs @@ -224,9 +224,10 @@ fn empty_and_wrong_type_functions_remain_editable_but_report_cook_errors() { #[test] fn instance_parameter_functions_work_without_stored_literals_and_use_instance_size() { - use materialcraft_engine::core::{Graph, Package, ValueType}; + use materialcraft_engine::core::{Graph, OutputFormat, Package, ValueType}; let mut source = Graph::new("Source"); + source.format = OutputFormat::F32; let color = source.add_node("uniform", [0.0; 2]); source.node_mut(color).unwrap().params.insert("color_mode".into(), Value::Bool(false)); source.node_mut(color).unwrap().functions.insert("color".into(), FunctionGraph::input("amount", ValueType::Float4)); @@ -252,6 +253,7 @@ fn instance_parameter_functions_work_without_stored_literals_and_use_instance_si source.connect(dimensions, "output", size_output, "input").unwrap(); let mut parent = Graph::new("Parent"); parent.size = [6, 5]; + parent.format = OutputFormat::F32; let owner = parent.add_node("graph_instance", [0.0; 2]); parent.node_mut(owner).unwrap().params.insert("graph".into(), Value::Text("Source".into())); let mut package = Package::new("Instances"); diff --git a/crates/engine/tests/it/pattern_graph.rs b/crates/engine/tests/it/pattern_graph.rs index 5f00986..e6453ca 100644 --- a/crates/engine/tests/it/pattern_graph.rs +++ b/crates/engine/tests/it/pattern_graph.rs @@ -53,6 +53,7 @@ fn dynamic_roughness_survives_native_saving_and_invalidates_the_cook_cache() { function.output = Some(function.add("get_float1", &[], Some(Value::Text("$time".into())))); let mut graph = Graph::new("Depth"); graph.size = [4, 4]; + graph.format = materialcraft_engine::core::OutputFormat::F32; let owner = graph.add_node("fx_map", [0.0; 2]); let node = graph.node_mut(owner).unwrap(); node.params.insert("pattern".into(), Value::PatternGraph(Box::new(pattern))); diff --git a/crates/engine/tests/it/sbs_functions.rs b/crates/engine/tests/it/sbs_functions.rs index 7aa0003..3573db5 100644 --- a/crates/engine/tests/it/sbs_functions.rs +++ b/crates/engine/tests/it/sbs_functions.rs @@ -26,6 +26,7 @@ fn imported_expression_cooks_follows_inputs_and_survives_undo_and_save() { let mut s = new_session(); s.preview_size = Some(64); s.pkg = imported.pkg; + s.pkg.graphs[0].format = materialcraft_engine::core::OutputFormat::F32; let levels = s.graph().unwrap().nodes[0].id; let uniform = execute(&mut s, "graph.node.add", &json!({"def": "uniform", "params": {"color_mode": false}})).unwrap()["id"].as_u64().unwrap(); execute(&mut s, "graph.connect", &json!({"from": uniform, "to": levels.0})).unwrap(); diff --git a/crates/engine/tests/it/system_variables.rs b/crates/engine/tests/it/system_variables.rs index 5ccebbf..d47d129 100644 --- a/crates/engine/tests/it/system_variables.rs +++ b/crates/engine/tests/it/system_variables.rs @@ -1,6 +1,6 @@ use materialcraft_engine::{ FunctionGraphTarget, Session, - core::{FunctionGraph, Graph, NodeId, Package, ParameterInheritance, Value}, + core::{FunctionGraph, Graph, NodeId, OutputFormat, Package, ParameterInheritance, Value}, execute, formats::sbs::{read_sbs, write_sbs}, new_session, @@ -114,6 +114,7 @@ fn graph_metadata_and_host_values_cook_and_round_trip_as_native_get_nodes() { fn pixel_ratio_and_tiling_inherit_and_preserve_native_relative_modes() { let mut graph = Graph::new("Inheritance"); graph.size = [4, 4]; + graph.format = OutputFormat::F32; graph.tiling = [true, true]; let source = graph.add_node("uniform", [0.0; 2]); let input = graph.node_mut(source).unwrap(); @@ -139,7 +140,12 @@ fn pixel_ratio_and_tiling_inherit_and_preserve_native_relative_modes() { let bytes = write_sbs(&session.pkg).unwrap(); let read = read_sbs(&bytes, "inheritance.sbs", &|_| None).unwrap(); assert!(read.warnings.is_empty(), "{:?}", read.warnings); - assert_eq!(read.pkg.graphs[0].node(pixel).unwrap().base, session.pkg.graphs[0].node(pixel).unwrap().base); + + // SBS represents Inherit as a format value plus a relative mode + let mut expected_base = session.pkg.graphs[0].node(pixel).unwrap().base.clone(); + expected_base.format = OutputFormat::U16; + expected_base.format_mode = ParameterInheritance::RelativeToInput; + assert_eq!(read.pkg.graphs[0].node(pixel).unwrap().base, expected_base); let mut reopened = Session::new(read.pkg); for session in [&mut session, &mut reopened] { @@ -150,6 +156,46 @@ fn pixel_ratio_and_tiling_inherit_and_preserve_native_relative_modes() { } } +#[test] +fn pixel_processor_default_format_preserves_input_precision_on_sbs_round_trip() { + for (input_format, parent_format, expected_value) in + [(Some(OutputFormat::U8), OutputFormat::F32, 1.0), (Some(OutputFormat::F32), OutputFormat::U8, 1.25), (None, OutputFormat::F32, 1.25)] + { + let expected_format = input_format.unwrap_or(parent_format); + let mut graph = Graph::new("Format inheritance"); + graph.size = [4, 4]; + graph.format = parent_format; + let input = input_format.map(|format| { + let input = graph.add_node("uniform", [0.0; 2]); + graph.node_mut(input).unwrap().base.format = format; + input + }); + let pixel = graph.add_node("pixel_processor", [200.0, 0.0]); + graph.node_mut(pixel).unwrap().params.insert("function".into(), Value::Function(Box::new(FunctionGraph::constant(Value::Float(1.25))))); + if let Some(input) = input { + graph.connect(input, "output", pixel, "input0").unwrap(); + } + + let mut package = Package::new("Format inheritance"); + package.graphs.push(graph); + let mut original = Session::new(package); + let before = original.cook(); + assert_eq!(before.nodes[&pixel].error, None); + assert_eq!(before.nodes[&pixel].base.format, expected_format); + assert_eq!(before.image(pixel, 0).unwrap().get(0, 0, false)[0], expected_value); + + let bytes = write_sbs(&original.pkg).unwrap(); + let read = read_sbs(&bytes, "format-inheritance.sbs", &|_| None).unwrap(); + assert!(read.warnings.is_empty(), "{:?}", read.warnings); + let mut reopened = Session::new(read.pkg); + let after = reopened.cook(); + + assert_eq!(after.nodes[&pixel].error, None); + assert_eq!(after.image(pixel, 0).unwrap().get(0, 0, false)[0], expected_value, "input {input_format:?}, parent {parent_format:?}"); + assert_eq!(after.nodes[&pixel].base.format, expected_format); + } +} + #[test] fn nested_graph_instances_inherit_host_values_and_invalidate_their_cache() { let mut source = Graph::new("Source"); @@ -210,6 +256,7 @@ fn nested_function_instances_use_the_processing_callers_variable_scope() { package.graphs.push(wrapper); let mut graph = Graph::new("Material"); graph.size = [4, 4]; + graph.format = OutputFormat::F32; let pixel = graph.add_node("pixel_processor", [0.0; 2]); let value = graph.add_node("value_processor", [200.0, 0.0]); for id in [pixel, value] { diff --git a/crates/formats/src/sbs/base_parameters.rs b/crates/formats/src/sbs/base_parameters.rs index c90543d..9017f44 100644 --- a/crates/formats/src/sbs/base_parameters.rs +++ b/crates/formats/src/sbs/base_parameters.rs @@ -40,14 +40,19 @@ pub(super) fn read_base_params(params: Option, warnings: &mut Warnings) base } -pub(super) fn base_params_xml(base: &BaseParameters, writer: &mut SbsWriter) -> Result { +pub(super) fn base_params_xml(base: &BaseParameters, writer: &mut SbsWriter, include_default_format: bool) -> Result { let mut output = String::new(); let defaults = BaseParameters::default(); + for parameter in BaseParameter::ALL { let function = base.functions.get(¶meter); let value = parameter.value(base); let inheritance = parameter.inheritance(base); - if function.is_none() && value == parameter.value(&defaults) && inheritance == parameter.inheritance(&defaults) { + if function.is_none() + && value == parameter.value(&defaults) + && inheritance == parameter.inheritance(&defaults) + && !(include_default_format && parameter == BaseParameter::Format) + { continue; } diff --git a/crates/formats/src/sbs/library.rs b/crates/formats/src/sbs/library.rs index 680578f..21dbea2 100644 --- a/crates/formats/src/sbs/library.rs +++ b/crates/formats/src/sbs/library.rs @@ -123,7 +123,9 @@ fn read_embedded(relative: &str) -> Result, String> { } /// Bounds for scanning the library folder: how deep, and how many packages +#[cfg(not(target_arch = "wasm32"))] const MAX_DEPTH: usize = 6; +#[cfg(not(target_arch = "wasm32"))] const MAX_FILES: usize = 2048; /// Every SBS package in the library as `sbs://` paths, sorted: the files under the asset folder diff --git a/crates/formats/src/sbs/sbs_writer.rs b/crates/formats/src/sbs/sbs_writer.rs index 4bd60e7..783cb84 100644 --- a/crates/formats/src/sbs/sbs_writer.rs +++ b/crates/formats/src/sbs/sbs_writer.rs @@ -152,7 +152,7 @@ impl SbsWriter { tiling_mode: graph.tiling_mode, ..Default::default() }; - out.push_str(&super::base_parameters::base_params_xml(&base, self).map_err(FormatError::Io)?); + out.push_str(&super::base_parameters::base_params_xml(&base, self, false).map_err(FormatError::Io)?); out.push_str(""); write_canvas_items(out, graph, self); @@ -237,6 +237,7 @@ impl SbsWriter { out.push_str(""); output_uids } + pub(super) fn write_implementation( &mut self, out: &mut String, @@ -245,7 +246,8 @@ impl SbsWriter { ids: NodeIdentifiers, package: &Package, ) -> Result<()> { - let base = base_params_xml(&node.base, self).map_err(FormatError::Io)?; + // The reader assigns a native default when a processor omits format + let base = base_params_xml(&node.base, self, node.def == "pixel_processor").map_err(FormatError::Io)?; match node.def.as_str() { "output" => { @@ -297,6 +299,7 @@ impl SbsWriter { if package.is_empty() { return Err(FormatError::Io(format!("missing package reference for `{name}`"))); } + let dependency = self.external_package_uid(&package); let path = text_param(node, "sbs_path", &name); let _ = write!(out, "{raw_params}", xml_escape(&path)); @@ -325,6 +328,7 @@ impl SbsWriter { ); continue; } + if filter.sbs == "text" && *sbs_name == "fontdata" && let Value::Text(name) = value @@ -351,6 +355,7 @@ impl SbsWriter { _ => return Err(FormatError::Io(format!("`{def}` has no native primitive mapping; its SBS graph is required"))), }, } + Ok(()) } } diff --git a/crates/formats/tests/function_library.rs b/crates/formats/tests/function_library.rs index ddc4a01..9811ad5 100644 --- a/crates/formats/tests/function_library.rs +++ b/crates/formats/tests/function_library.rs @@ -161,8 +161,8 @@ fn bundled_library_has_complete_bodies_and_current_export_metadata() { let bytes = include_bytes!("../../../assets/sbs/functions.sbs"); let read = read_sbs(bytes, "functions.sbs", &|_| None).unwrap(); let xml = roxmltree::Document::parse(std::str::from_utf8(bytes).unwrap()).unwrap(); - // The baseline is the release that first saved this asset; future saves keep it. - for (field, expected) in [("formatVersion", "0.1.3"), ("updaterVersion", env!("CARGO_PKG_VERSION"))] { + // The SBS schema version is independent of the MaterialCraft release version + for (field, expected) in [("formatVersion", "1.1.0.202401"), ("updaterVersion", env!("CARGO_PKG_VERSION"))] { let version = xml.root_element().children().find(|element| element.has_tag_name(field)).unwrap().attribute("v").unwrap(); assert_eq!(version, expected, "bundled functions {field}"); } diff --git a/crates/nodes/src/atomic/transformation.rs b/crates/nodes/src/atomic/transformation.rs index 2a210ce..a320a99 100644 --- a/crates/nodes/src/atomic/transformation.rs +++ b/crates/nodes/src/atomic/transformation.rs @@ -17,8 +17,7 @@ pub(super) fn definition() -> NodeDefinition { } fn transformation(context: &CookContext) -> CookResult { - // Transform the original texels. Resizing first would apply bilinear filtering - // even when nearest sampling is selected and would blur enlarged noise cells. + // Preserve source texels so nearest sampling does not blur the input let input = context.input(0).cloned().unwrap_or_else(|| Image::filled(context.w, context.h, Kind::Gray, [0.0; 4])); let offset = context.v2("offset"); let matrix = context.v4("matrix"); @@ -30,14 +29,15 @@ fn transformation(context: &CookContext) -> CookResult { let nearest = context.i("filtering") == 1; let input = if nearest { nearest_mip(input, matrix, context) } else { input }; let matte = context.v4("matte"); - // A panoramic image wraps horizontally while keeping its vertical matte. - // Reducing both axis flags to `context.tile` discards valid wrapped texels. + + // Keep independent wrap axes for panoramic images let tiling = context.vars.get("$tiling").and_then(materialcraft_core::Value::as_i32).map_or([context.tile; 2], |mask| [mask & 1 != 0, mask & 2 != 0]); + Ok(vec![Image::generate_uv(context.w, context.h, input.kind, |u, v| { let x = u - 0.5; let y = v - 0.5; - // SBS stores the two matrix columns consecutively. Treating them as rows - // reverses rotations and applies a shear along the wrong axis. + + // SBS stores matrix columns consecutively; interpreting rows reverses rotations let source_u = matrix[0] * x + matrix[2] * y + 0.5 + offset[0]; let source_v = matrix[1] * x + matrix[3] * y + 0.5 + offset[1]; if (!tiling[0] && !(0.0..1.0).contains(&source_u)) || (!tiling[1] && !(0.0..1.0).contains(&source_v)) { @@ -55,19 +55,22 @@ fn nearest_mip(mut input: Image, matrix: [f32; 4], context: &CookContext) -> Ima let height = context.h.max(1) as f32; let dx = (matrix[0] * input.w as f32 / width).hypot(matrix[1] * input.h as f32 / width); let dy = (matrix[2] * input.w as f32 / height).hypot(matrix[3] * input.h as f32 / height); + + // Thirteen reductions cover the maximum supported side of 8192 texels let levels = dx.max(dy).max(1.0).log2().round().clamp(0.0, 13.0) as u32; let maximum = match context.format { OutputFormat::U8 => Some(255.0), OutputFormat::Inherit | OutputFormat::U16 => Some(65535.0), OutputFormat::F16 | OutputFormat::F32 => None, }; + for _ in 0..levels { if input.w <= 1 && input.h <= 1 { break; } - // Nearest selects a texel within a mip level, not within the full-size - // image. Integer mip levels average four texels with halfway-up rounding. - input = Image::generate((input.w / 2).max(1), (input.h / 2).max(1), input.kind, |x, y| { + + // Integer mip levels round four-texel averages halfway up + input = Image::generate(input.w.div_ceil(2), input.h.div_ceil(2), input.kind, |x, y| { let (x, y) = (i64::from(x) * 2, i64::from(y) * 2); let pixels = [input.get(x, y, false), input.get(x + 1, y, false), input.get(x, y + 1, false), input.get(x + 1, y + 1, false)]; std::array::from_fn(|channel| { @@ -80,5 +83,6 @@ fn nearest_mip(mut input: Image, matrix: [f32; 4], context: &CookContext) -> Ima }) }); } + input } diff --git a/crates/nodes/src/function/tests.rs b/crates/nodes/src/function/tests.rs index df3722a..be1ed45 100644 --- a/crates/nodes/src/function/tests.rs +++ b/crates/nodes/src/function/tests.rs @@ -118,8 +118,8 @@ fn vectors_concatenate_swizzle_and_cast_without_broadcasting() { let vector = operation("vector4", &[Value::Float2([1.0, 2.0]), Value::Float2([3.0, 4.0])], None).unwrap(); assert_eq!(vector, Value::Float4([1.0, 2.0, 3.0, 4.0])); assert_eq!(operation("swizzle3", &[vector], Some(Value::Int3([3, 0, 3]))).unwrap(), Value::Float3([4.0, 1.0, 4.0])); - assert_eq!(operation("toint2", &[Value::Float2([-1.9, 2.9])], None).unwrap(), Value::Int2([-1, 2])); - assert!(operation("swizzle1", &[Value::Float2([0.0; 2])], Some(Value::Int(2))).is_err()); + assert_eq!(operation("toint2", &[Value::Float2([-1.9, 2.9])], None).unwrap(), Value::Int2([-2, 2])); + assert_eq!(operation("swizzle1", &[Value::Float2([0.0; 2])], Some(Value::Int(2))).unwrap(), Value::Float(0.0)); assert_eq!(operation("pow2", &[Value::Float(3.0)], None).unwrap(), Value::Float(8.0)); } @@ -480,7 +480,7 @@ fn variables_a_called_graph_sets_reach_its_caller_but_its_inputs_do_not() { let leaked = caller.add("get_integer1", &[], Some(Value::Text("amount".into()))); caller.output = Some(caller.add("sequence", &[call, leaked], None)); - assert!(evaluate(&caller, &BTreeMap::new()).unwrap_err().contains("undefined variable `amount`")); + assert_eq!(evaluate(&caller, &BTreeMap::new()).unwrap(), Value::Int(0)); } #[test] diff --git a/crates/nodes/src/tests.rs b/crates/nodes/src/tests.rs index f34ac71..f30301d 100644 --- a/crates/nodes/src/tests.rs +++ b/crates/nodes/src/tests.rs @@ -23,6 +23,32 @@ fn cook(def: &NodeDefinition, inputs: &[Option], size: u32) -> CookResult (def.cook)(&ctx) } +#[test] +fn nearest_transform_mip_keeps_the_last_column_of_an_odd_width_input() { + let definition = find("transformation").unwrap(); + let mut params = resolve_params(definition, &BTreeMap::new()); + params.insert("filtering".into(), Value::Enum(1)); + let inputs = [Some(Image::gray(3, 1, |x, _| if x == 2 { 1.0 } else { 0.0 }))]; + let vars = BTreeMap::new(); + let resource = |_: &str| None; + let context = CookContext { + format: materialcraft_core::OutputFormat::F32, + w: 2, + h: 2, + seed: 0, + tile: false, + inputs: &inputs, + params: ¶ms, + resource: &resource, + vars: &vars, + }; + + let output = (definition.cook)(&context).unwrap(); + + assert_eq!(output[0].get(0, 0, false)[0], 0.0); + assert_eq!(output[0].get(1, 0, false)[0], 1.0); +} + /// Image nodes cook finite outputs at the requested size; an empty processor reports its missing result #[test] fn every_node_cooks() { diff --git a/crates/ui-egui/tests/flatpak_updates.rs b/crates/ui-egui/tests/flatpak_updates.rs new file mode 100644 index 0000000..26adae3 --- /dev/null +++ b/crates/ui-egui/tests/flatpak_updates.rs @@ -0,0 +1,27 @@ +//! Release and source Flatpaks must allow release checks and host update helpers. +fn finish_args(manifest: &str) -> Vec<&str> { + manifest + .split("finish-args:") + .nth(1) + .unwrap_or_default() + .lines() + .take_while(|line| line.is_empty() || line.starts_with(' ') || line.starts_with('#')) + .filter_map(|line| line.trim().strip_prefix("- ")) + .map(|arg| arg.trim_matches(['\'', '"'])) + .collect() +} + +#[test] +fn flatpak_update_permissions() { + let manifests = [ + include_str!("../../../packaging/linux/flatpak/ai.storyteller.MaterialCraft.bundle.yml"), + include_str!("../../../packaging/linux/flatpak/ai.storyteller.MaterialCraft.yml"), + ]; + let args = manifests.map(finish_args); + assert_eq!(args[0], args[1], "source and release permissions must agree"); + for permissions in args { + for required in ["--share=network", "--talk-name=org.freedesktop.Flatpak", "--filesystem=xdg-data/ArtCraft/versions:ro"] { + assert!(permissions.contains(&required), "missing update permission: {required}"); + } + } +} diff --git a/crates/ui-egui/tests/snapshot.rs b/crates/ui-egui/tests/snapshot.rs index 9bfad0e..93f5d7d 100644 --- a/crates/ui-egui/tests/snapshot.rs +++ b/crates/ui-egui/tests/snapshot.rs @@ -62,6 +62,20 @@ fn settle(h: &mut Harness<'static, MaterialCraftApp>, frames: usize) { } } +fn wait_for_3d_frame(h: &mut Harness<'static, MaterialCraftApp>, previous: Option<&[u8]>) -> (u32, u32, Vec) { + for _ in 0..120 { + if let Some(frame) = h.state().view3d.shown.as_ref() + && previous.is_none_or(|pixels| frame.2.as_slice() != pixels) + { + return frame.clone(); + } + + settle(h, 1); + } + + panic!("3D view did not render an updated frame"); +} + fn save(h: &mut Harness<'static, MaterialCraftApp>, dir: &std::path::Path, name: &str) { let img = h.render().expect("render"); img.save(dir.join(format!("{name}.png"))).expect("save"); @@ -154,7 +168,7 @@ fn explorer_drags_a_linked_graph_between_open_packages() { assert_eq!(harness.state().session.document_id, target_document); assert_eq!(harness.state().session.history(), ["Add graph instance"]); let value = harness.state().session.cooked.image(instance, 0).unwrap().get(0, 0, false); - assert!(value.into_iter().zip([0.9, 0.3, 0.1, 1.0]).all(|(actual, expected)| (actual - expected).abs() < 1e-6)); + assert!(value.into_iter().zip([0.9, 0.3, 0.1, 1.0]).all(|(actual, expected)| (actual - expected).abs() <= 1.0 / 255.0)); assert!(harness.state().session.modified); save(&mut harness, &directory, "linked-instance-source-edit"); let position = harness.get(By::new().role(egui::accesskit::Role::Button).label("Reusable tint")).rect().center(); @@ -588,7 +602,14 @@ fn output_menu_and_package_warnings_follow_parameter_types() { settle(&mut harness, 3); assert!(harness.query(By::new().label("Expected output: Float")).is_some()); assert!(harness.query(By::new().label(&package_warning_label)).is_some()); - harness.get(By::new().role(egui::accesskit::Role::Button).label("Float3")).click_secondary(); + let node = harness.get(By::new().role(egui::accesskit::Role::Button).label("Float3")).rect(); + let header = egui::pos2(node.center().x, node.min.y + 12.0); + harness.event(egui::Event::PointerMoved(header)); + harness.step(); + for pressed in [true, false] { + harness.event(egui::Event::PointerButton { pos: header, button: egui::PointerButton::Secondary, pressed, modifiers: egui::Modifiers::NONE }); + harness.step(); + } settle(&mut harness, 3); assert!(harness.get(By::new().role(egui::accesskit::Role::Button).label("Set as output node")).accesskit_node().is_disabled()); let directory = std::path::PathBuf::from(std::env::var_os("MC_SNAPSHOT_DIR").unwrap()); @@ -1452,9 +1473,8 @@ fn material_assignment_previews_outputs_and_survives_function_editing() { .as_u64() .unwrap(); let mut harness = harness(app, 1600.0, 960.0); - settle(&mut harness, 45); + let before = wait_for_3d_frame(&mut harness, None); assert!(harness.state().session.material_maps().is_empty()); - let before = harness.state().view3d.shown.clone().unwrap(); let directory = std::path::PathBuf::from(std::env::var_os("MC_SNAPSHOT_DIR").unwrap()); std::fs::create_dir_all(&directory).unwrap(); save(&mut harness, &directory, "material-unassigned"); @@ -1466,27 +1486,24 @@ fn material_assignment_previews_outputs_and_survives_function_editing() { settle(&mut harness, 3); save(&mut harness, &directory, "material-channel-menu"); harness.get(By::new().role(egui::accesskit::Role::Button).label("Base color")).click(); - settle(&mut harness, 45); + let red_frame = wait_for_3d_frame(&mut harness, Some(&before.2)); assert_eq!(harness.state().session.selection, selection, "channel menu clicks must not reach the graph beneath them"); assert_eq!(harness.state().session.material_maps()[0].0, "baseColor"); - let red_frame = harness.state().view3d.shown.clone().unwrap(); - assert_ne!(before.2, red_frame.2, "assignment must invalidate the rendered frame"); let red_pixels = red_frame.2.chunks_exact(4).filter(|pixel| u16::from(pixel[0]) > u16::from(pixel[1]) + 30).count(); assert!(red_pixels > 100, "the rendered mesh must show the assigned red image"); save(&mut harness, &directory, "material-assigned-red"); harness.state_mut().run("graph.node.param", json!({"id": source, "param": "color", "value": [0.02, 0.04, 0.8, 1.0]})).unwrap(); - settle(&mut harness, 45); - let blue_frame = harness.state().view3d.shown.clone().unwrap(); + let blue_frame = wait_for_3d_frame(&mut harness, Some(&red_frame.2)); let blue_pixels = blue_frame.2.chunks_exact(4).filter(|pixel| u16::from(pixel[2]) > u16::from(pixel[0]) + 30).count(); assert!(blue_pixels > 100, "edits must refresh the assigned material"); - assert_ne!(red_frame.2, blue_frame.2); save(&mut harness, &directory, "material-assigned-blue"); harness.state_mut().run("file.new", json!({"kind": "function", "name": "Function preview"})).unwrap(); settle(&mut harness, 45); let maps = harness.state().session.material_maps(); - assert_eq!(maps[0].1.get(0, 0, false), [0.02, 0.04, 0.8, 1.0]); + let color = maps[0].1.get(0, 0, false); + assert!(color.into_iter().zip([0.02, 0.04, 0.8, 1.0]).all(|(actual, expected)| (actual - expected).abs() <= 1.0 / 255.0)); assert_eq!(harness.state().session.material_preview.channels[&materialcraft_engine::core::MaterialChannel::BaseColor].node, NodeId(output)); save(&mut harness, &directory, "material-retained-in-function"); } diff --git a/crates/ui-egui/tests/snapshot/function_library.rs b/crates/ui-egui/tests/snapshot/function_library.rs index af41fb9..98b6366 100644 --- a/crates/ui-egui/tests/snapshot/function_library.rs +++ b/crates/ui-egui/tests/snapshot/function_library.rs @@ -2,7 +2,10 @@ use super::{By, Harness, MaterialCraftApp, Queryable, UiState, harness, json, sa use materialcraft_engine::{FunctionGraphTarget, core::NodeId}; fn drag(harness: &mut Harness<'static, MaterialCraftApp>, label: &str, offset: egui::Vec2) { - let start = harness.get(By::new().role(egui::accesskit::Role::ListItem).label(label)).rect().center(); + let item = By::new().role(egui::accesskit::Role::ListItem).label(label); + harness.get(item.clone()).scroll_to_me(); + settle(harness, 2); + let start = harness.get(item).rect().center(); let end = harness.state().graph.view.center() + offset; harness.event(egui::Event::PointerMoved(start)); harness.step(); @@ -25,7 +28,7 @@ fn bottom_library_drags_functions_into_function_and_processor_canvases() { let mut app = MaterialCraftApp::headless(materialcraft_engine::new_session(), UiState::default()); app.run("file.new", json!({"kind": if kind == "function" { "function" } else { "material" }, "name": "Library instance"})).unwrap(); let owner = if kind == "function" { None } else { Some(NodeId(app.run("graph.node.add", json!({"def": kind})).unwrap()["id"].as_u64().unwrap())) }; - app.ui.library_search = "Pi".into(); + app.ui.library_search = "sbs://functions.sbs#Functions/Math/Pi".into(); let mut harness = harness(app, 1600.0, 960.0); settle(&mut harness, 5); if owner.is_some() { @@ -45,7 +48,7 @@ fn bottom_library_drags_functions_into_function_and_processor_canvases() { assert!(matches!(node.source, Some(Ok(_)))); save(&mut harness, &directory, &format!("library-drag-{kind}")); - harness.state_mut().ui.library_search = "Division".into(); + harness.state_mut().ui.library_search = "function:div".into(); settle(&mut harness, 3); drag(&mut harness, "Division", vec2(20.0, 120.0)); @@ -56,7 +59,7 @@ fn bottom_library_drags_functions_into_function_and_processor_canvases() { harness.get(By::new().role(egui::accesskit::Role::Button).label("Division")); save(&mut harness, &directory, &format!("library-native-{kind}")); - harness.state_mut().ui.library_search = "GlobalRandom".into(); + harness.state_mut().ui.library_search = "sbs://functions.sbs#Functions/Random/GlobalRandom".into(); settle(&mut harness, 3); drag(&mut harness, "Global random", vec2(160.0, 0.0)); @@ -79,8 +82,9 @@ fn bottom_library_drags_functions_into_function_and_processor_canvases() { package.graphs.push(missing); harness.state_mut().session.pkg.dependencies.insert("sbs://missing-functions.sbs".into(), std::sync::Arc::new(package)); - harness.state_mut().ui.library_search = "MissingFunction".into(); + harness.state_mut().ui.library_search = "sbs://missing-functions.sbs#Functions/Test/MissingFunction".into(); settle(&mut harness, 3); + // The canvas sits under the two toolbar rows; drop above its lower edge drag(&mut harness, "MissingFunction", vec2(160.0, 110.0)); diff --git a/crates/ui-egui/tests/snapshot/library.rs b/crates/ui-egui/tests/snapshot/library.rs index 1333c2d..2cd43a1 100644 --- a/crates/ui-egui/tests/snapshot/library.rs +++ b/crates/ui-egui/tests/snapshot/library.rs @@ -73,12 +73,12 @@ fn library_tree_shows_every_category_and_adds_what_the_graph_takes() { assert_eq!(graph.nodes.len(), before + 1); assert_eq!(graph.nodes.last().unwrap().def, "blur"); - // Categories MaterialCraft has no nodes for yet say so + // The bundled library fills the noise category harness.get(tree("Texture generators")).click(); settle(&mut harness, 3); harness.get(tree("Noises")).click(); settle(&mut harness, 4); - assert!(harness.query(By::new().label("Nothing in this category yet")).is_some()); + assert!(harness.query(tile("Perlin noise")).is_some()); harness.get(tree("Texture generators")).click(); settle(&mut harness, 2); harness.get(tree("Texture generators")).click(); diff --git a/packaging/linux/flatpak/ai.storyteller.MaterialCraft.bundle.yml b/packaging/linux/flatpak/ai.storyteller.MaterialCraft.bundle.yml index fed3a36..b6bab7c 100644 --- a/packaging/linux/flatpak/ai.storyteller.MaterialCraft.bundle.yml +++ b/packaging/linux/flatpak/ai.storyteller.MaterialCraft.bundle.yml @@ -17,6 +17,12 @@ runtime-version: '26.08' sdk: org.freedesktop.Sdk command: materialcraft finish-args: + # Honor the launcher's pinned and nightly version choices before offering updates. + - --filesystem=xdg-data/ArtCraft/versions:ro + # Release checks and downloads use HTTPS. + - --share=network + # The shared updater inspects and updates this installation via flatpak-spawn --host. + - --talk-name=org.freedesktop.Flatpak # Display: Wayland first; X11 only when no Wayland compositor is running. - --socket=wayland - --socket=fallback-x11 @@ -30,9 +36,6 @@ finish-args: # line, Open Recent, "Save" next to the original) work in the usual places. - --filesystem=xdg-pictures - --filesystem=xdg-documents - # Deliberately not granted: network (the optional --control server listens on 127.0.0.1 in - # the sandbox; `flatpak override --user --share=network ai.storyteller.materialcraft` exposes it to - # host agents) and home/host filesystem access. modules: - name: materialcraft buildsystem: simple diff --git a/packaging/linux/flatpak/ai.storyteller.MaterialCraft.yml b/packaging/linux/flatpak/ai.storyteller.MaterialCraft.yml index 56e599e..47c1454 100644 --- a/packaging/linux/flatpak/ai.storyteller.MaterialCraft.yml +++ b/packaging/linux/flatpak/ai.storyteller.MaterialCraft.yml @@ -18,6 +18,12 @@ sdk-extensions: - org.freedesktop.Sdk.Extension.rust-stable command: materialcraft finish-args: + # Honor the launcher's pinned and nightly version choices before offering updates. + - --filesystem=xdg-data/ArtCraft/versions:ro + # Release checks and downloads use HTTPS. + - --share=network + # The shared updater inspects and updates this installation via flatpak-spawn --host. + - --talk-name=org.freedesktop.Flatpak # Display: Wayland first; X11 only when no Wayland compositor is running. - --socket=wayland - --socket=fallback-x11 @@ -31,9 +37,6 @@ finish-args: # line, Open Recent, "Save" next to the original) work in the usual places. - --filesystem=xdg-pictures - --filesystem=xdg-documents - # Deliberately not granted: network (the optional --control server listens on 127.0.0.1 in - # the sandbox; `flatpak override --user --share=network ai.storyteller.materialcraft` exposes it to - # host agents) and home/host filesystem access. build-options: append-path: /usr/lib/sdk/rust-stable/bin modules: