diff --git a/.github/nightly-signing-policy.json b/.github/nightly-signing-policy.json index 7c71a9092..957f44382 100644 --- a/.github/nightly-signing-policy.json +++ b/.github/nightly-signing-policy.json @@ -4,10 +4,10 @@ "repository_id": 1412112308, "producer_workflow_id": 429731005, "producer_workflow_path": ".github/workflows/nightly.yml", - "producer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba", - "producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba", + "producer_tooling_revision": "main", + "producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@main", "signer_workflow_path": ".github/workflows/nightly-sign.yml", - "signer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba", + "signer_tooling_revision": "main", "release_branch": "nightly-signer", "manual_actors": [ "bflatastic", @@ -28,7 +28,7 @@ "workflow_path": ".github/workflows/ci.yml", "jobs": [ { - "name": "gate / gate (ubuntu-24.04)", + "name": "gate / gate (artcraft-k8s-main)", "app_id": 15368, "applicability": "required" } @@ -95,7 +95,15 @@ "unsigned_artifact_name": "nightly-unsigned-linux-x86_64", "trust": { "fingerprint": "2B76741B414AAD6CD33E631213A005C0B9D7C3ED" - } + }, + "package_formats": [ + "appimage", + "arch", + "deb", + "flatpak", + "oci", + "rpm" + ] }, "macos-aarch64": { "unsigned_artifact_name": "nightly-unsigned-macos-aarch64", diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock index 65da56dd2..605755bf8 100644 --- a/.github/workflows/actions.lock +++ b/.github/workflows/actions.lock @@ -8,21 +8,24 @@ workflows: '.github/workflows/house-rules.yml': [] '.github/workflows/lockfile.yml': - 'actions/checkout@v7.0.1' - - 'step-security/harden-runner@v2.22.4' + - 'step-security/harden-runner@v2.23.0' '.github/workflows/nightly-macos.yml': - 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' - 'actions/upload-artifact@v7.0.2' - 'step-security/dtolnay-rust-toolchain@v1.0.0' - - 'step-security/harden-runner@v2.22.4' - - 'storytold/craft-common-actions@f5141455aac7b2eb4708aa259d8ffcdf10fde939' + - 'step-security/harden-runner@v2.23.0' + - 'storytold/craft-common-actions@main' '.github/workflows/nightly-sign.yml': [] '.github/workflows/nightly.yml': [] '.github/workflows/nix.yml': [] '.github/workflows/notify-services.yml': [] '.github/workflows/packaging-lint.yml': + - 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' - 'actions/checkout@v7.0.1' - - 'step-security/harden-runner@v2.22.4' - '.github/workflows/release.yml': [] + - 'step-security/harden-runner@v2.23.0' + '.github/workflows/release.yml': + - 'actions/checkout@v7.0.1' + - 'step-security/harden-runner@v2.23.0' '.github/workflows/sonarcloud.yml': [] '.github/workflows/windows-arm64.yml': [] dependencies: @@ -46,14 +49,14 @@ dependencies: commit: 'sha1-8dd607977d06adf4ed49b190381e74c17a9dd25f' owner_id: 88700172 repo_id: 1249865941 - 'step-security/harden-runner@v2.22.4': - ref: 'v2.22.4' - commit: 'sha1-1d88384fd173af6ecb012dfd0264a306b711241a' + 'step-security/harden-runner@v2.23.0': + ref: 'v2.23.0' + commit: 'sha1-aebdcf6156ab6691adf63218240e476564a1ed4c' owner_id: 88700172 repo_id: 422287306 - 'storytold/craft-common-actions@f5141455aac7b2eb4708aa259d8ffcdf10fde939': + 'storytold/craft-common-actions@main': ref: 'main' - commit: 'sha1-f5141455aac7b2eb4708aa259d8ffcdf10fde939' + commit: 'sha1-bc70e5d7f90828265b20708399a2265e62b9b7d6' owner_id: 76897702 repo_id: 1414429108 uses: diff --git a/.github/workflows/lockfile.yml b/.github/workflows/lockfile.yml index e630c9a8f..5c8bfa490 100644 --- a/.github/workflows/lockfile.yml +++ b/.github/workflows/lockfile.yml @@ -22,7 +22,7 @@ jobs: timeout-minutes: 10 steps: - name: Harden runner - uses: step-security/harden-runner@v2.22.4 + uses: step-security/harden-runner@v2.23.0 with: egress-policy: audit - uses: actions/checkout@v7.0.1 diff --git a/.github/workflows/nightly-macos.yml b/.github/workflows/nightly-macos.yml index c0296320e..fc14ec98b 100644 --- a/.github/workflows/nightly-macos.yml +++ b/.github/workflows/nightly-macos.yml @@ -36,7 +36,7 @@ jobs: RUST_BACKTRACE: 1 steps: - name: Harden runner - uses: step-security/harden-runner@v2.22.4 + uses: step-security/harden-runner@v2.23.0 with: egress-policy: audit - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -45,12 +45,12 @@ jobs: # The same craft-fonts commit the Nightly producer pins (nightly.yml craft-fonts-ref), so the # bundle's notices and fonts match a shipped build. - name: Check out craft-fonts - uses: storytold/craft-common-actions/actions/checkout-craft-fonts@f5141455aac7b2eb4708aa259d8ffcdf10fde939 + uses: storytold/craft-common-actions/actions/checkout-craft-fonts@main with: ref: 37827adc41fd165f9a9234ac40f94dbad353aa69 - - uses: storytold/craft-common-actions/actions/checkout-craft-i18n@f5141455aac7b2eb4708aa259d8ffcdf10fde939 + - uses: storytold/craft-common-actions/actions/checkout-craft-i18n@main - id: rust - uses: storytold/craft-common-actions/actions/rust-channel@f5141455aac7b2eb4708aa259d8ffcdf10fde939 + uses: storytold/craft-common-actions/actions/rust-channel@main with: targets: aarch64-apple-darwin - uses: step-security/dtolnay-rust-toolchain@v1.0.0 diff --git a/.github/workflows/nightly-sign.yml b/.github/workflows/nightly-sign.yml index f22ad15f0..f3b811656 100644 --- a/.github/workflows/nightly-sign.yml +++ b/.github/workflows/nightly-sign.yml @@ -34,12 +34,26 @@ jobs: checks: read attestations: write id-token: write - uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba + uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@main with: - tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba + tooling-revision: main app-name: figcraft producer_run_id: ${{ inputs.producer_run_id }} producer_run_attempt: ${{ inputs.producer_run_attempt }} + secrets: + APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} + APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} + AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} + AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} + AZURE_SIGNING_ENDPOINT: ${{ secrets.AZURE_SIGNING_ENDPOINT }} + AZURE_SIGNING_ACCOUNT: ${{ secrets.AZURE_SIGNING_ACCOUNT }} + AZURE_CERT_PROFILE: ${{ secrets.AZURE_CERT_PROFILE }} + LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }} # No secrets: inherit or raw platform values in this caller. Only the isolated native # callee job may bind the release environment and export its keys; that environment must # admit nightly-signer alongside release before the first dispatch. diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index a5ed5e09c..87b4e9d59 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -22,9 +22,9 @@ jobs: actions: read attestations: write id-token: write - uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba + uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@main with: - tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba + tooling-revision: main app-name: figcraft manual-actors: '["bflatastic","dylanmtaylor","echelon","FredApps","skylartaylor"]' craft-fonts-ref: 37827adc41fd165f9a9234ac40f94dbad353aa69 @@ -32,3 +32,4 @@ jobs: # craft-common-actions main commit that merged the exact-analysis admission (#371, after #370, # #369 and #364). platforms: '["windows-x86_64","linux-x86_64","macos-aarch64"]' + linux-package-formats: '["deb","rpm","appimage","flatpak","oci","arch"]' diff --git a/.github/workflows/packaging-lint.yml b/.github/workflows/packaging-lint.yml index 77f6c85c0..4e9284068 100644 --- a/.github/workflows/packaging-lint.yml +++ b/.github/workflows/packaging-lint.yml @@ -48,7 +48,7 @@ jobs: runs-on: windows-latest steps: - name: Harden runner - uses: step-security/harden-runner@v2.22.4 + uses: step-security/harden-runner@v2.23.0 with: egress-policy: audit - uses: actions/checkout@v7.0.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1d51d76b1..a43c675ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,9 +14,7 @@ on: type: string default: "" -permissions: - contents: write - packages: write +permissions: {} concurrency: group: release-${{ github.ref }} @@ -29,14 +27,35 @@ jobs: contents: read pull-requests: read uses: storytold/craft-common-actions/.github/workflows/refresh-contributors.yml@main + # The DMG round trip with an ad-hoc signed fixture (#387): no signing secrets. + dmg-test: + name: macOS DMG integrity + runs-on: macos-15 + timeout-minutes: 10 + permissions: + contents: read + steps: + - name: Harden runner + uses: step-security/harden-runner@v2.23.0 + with: + egress-policy: audit + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - name: Test signed fixture and installation copy + run: bash packaging/macos/dmg-test.sh release: - needs: credits + needs: [credits, dmg-test] + permissions: + contents: write + packages: write # 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: figcraft app-title: FigCraft + macos-runner: macos-15 # Combined Latin presentation and core UI catalog. Required web builds enforce # Inter Regular/SemiBold and Noto Sans Georgian Regular after asset-policy filtering. craft-fonts-ref: 37827adc41fd165f9a9234ac40f94dbad353aa69 diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index a8872386f..b374e4e86 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -17,7 +17,7 @@ concurrency: jobs: sonarcloud: # Pin the coverage setup that provisions test data and fetches locked dependencies before offline metadata tests. - uses: storytold/craft-common-actions/.github/workflows/sonarcloud.yml@5008f8cd1b011b35eed223a7d058d7a8e9075ef6 + uses: storytold/craft-common-actions/.github/workflows/sonarcloud.yml@main with: # The shared coverage archive's shards omit the CLI executable used by integration tests. # Run this repository's suite in one instrumented job and provide its pinned test data. diff --git a/AGENTS.md b/AGENTS.md index 509457096..97a6eb634 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -67,7 +67,7 @@ FigCraft is an open-source, pure-Rust (egui) design app (Figma-class): interface ### Layout - `crates/*` by layer, enforced by `cargo xtask layers`: geom and color (L0), doc (L1), layout, text, pathops, plugin, collab (L2), render and format (L3), svg, pdf and vectordrawable (L4), engine (L5), ui-egui, mcp and collab-net (L6), then `apps/`. Nothing below L6 depends on egui, eframe, rfd or winit, so the UI crate is swappable. -- Commands live in `crates/engine/src/cmd/*` (`spec!(id, label, params doc, undoable, run)`). Menus, shortcuts, the Actions palette, CLI, control channel and MCP dispatch the same ids. The menu catalog is `crates/engine/src/catalog.rs` (`cargo xtask parity`). A programmatic call only requests UI (`Session::request_ui`); the control channel drops dialog requests. +- Commands live in `crates/engine/src/cmd/*` (`spec!(id, label, params doc, undoable, run)`). Menus, shortcuts, the Actions palette, CLI, control channel and MCP dispatch the same ids. The menu catalog is `crates/engine/src/catalog.rs` (`cargo xtask parity`). Its headless column ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)) is computed: an item is `headless: yes` only when its id is in the engine registry (`find_command`), never through a UI-layer id. A counted item with no engine command gets a `no`/`partial` mark with a `window`, `os` or `engine-gap` reach in `HEADLESS` in the same file, or shows as `unknown`. Never write `yes` there, and drop the mark when the command lands (stale marks fail the tests). A programmatic call only requests UI (`Session::request_ui`); the control channel drops dialog requests. - Panels read engine state and act through `app.run(id, params)` or `app.set_props(ids, props)`. Colours come from `theme::Tokens`. - Progress docs: `ROADMAP.md`, `docs/gaps.md` (ranked work list), `docs/target-app-parity.md`, `docs/roadmap.md`, `docs/architecture.md`, the `docs/*-parity.md` files and the generated `docs/parity-checklist.md`. A PR that lands a task updates the rows it touches. - Releases: `docs/releasing.md`. Control protocol: `docs/control-protocol.md`. MCP: `docs/mcp.md`. diff --git a/Cargo.lock b/Cargo.lock index 7e10bf096..e701b0632 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,19 +138,34 @@ dependencies = [ "memchr", ] +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + [[package]] name = "alloc-no-stdlib" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2fb6cfd47bf496ff64095c20eaba0c201404ee38714d4142fcfa1dc334fcc7a" +[[package]] +name = "alloc-stdlib" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e76a019e91224d279006ff972f1e984179a6e9feb050adba6ce8274aef23195" +dependencies = [ + "alloc-no-stdlib 2.0.4", +] + [[package]] name = "alloc-stdlib" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b5c1865780388bfa186411ab5f247819487fc4864c6e9c3106611fa347586e1" dependencies = [ - "alloc-no-stdlib", + "alloc-no-stdlib 3.0.0", ] [[package]] @@ -259,15 +274,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "arbitrary" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bc62ac97cc33321f50863d514c3bc38a453947a8f9e781137e47c7401020aed" -dependencies = [ - "derive_arbitrary", -] - [[package]] name = "arboard" version = "3.7.0" @@ -517,6 +523,12 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + [[package]] name = "bindgen" version = "0.72.1" @@ -667,14 +679,35 @@ dependencies = [ "syn 3.0.9", ] +[[package]] +name = "brotli" +version = "9.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9071f285ed78f04f37d675abaaef5de7689e2f30a216c8dc6795465d81910a13" +dependencies = [ + "alloc-no-stdlib 3.0.0", + "alloc-stdlib 0.3.0", + "brotli-decompressor 6.3.2", +] + +[[package]] +name = "brotli-decompressor" +version = "5.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a32acac15fe1967bc3986b2a6347dffc965602354ea6f450ad07e8bfd253583" +dependencies = [ + "alloc-no-stdlib 2.0.4", + "alloc-stdlib 0.2.4", +] + [[package]] name = "brotli-decompressor" version = "6.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc031cd87c6529082b0b65c604e86af0ed7744841b17ccfe60b1e31fa606179e" dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", + "alloc-no-stdlib 3.0.0", + "alloc-stdlib 0.3.0", ] [[package]] @@ -1008,12 +1041,27 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "const-oid" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" +[[package]] +name = "constant_time_eq" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "144e7f1de087984240b7816d47f698b414979faa6f40839c5b86d6bd47db57b7" +dependencies = [ + "rustversion", +] + [[package]] name = "cookie-factory" version = "0.3.3" @@ -1151,12 +1199,23 @@ dependencies = [ "libc", ] +[[package]] +name = "craft-ai-agents" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-ai-integrations?rev=d94a3593adcff504eaaad9e5aee4c84fd2f07a72#d94a3593adcff504eaaad9e5aee4c84fd2f07a72" +dependencies = [ + "dirs", + "serde", + "serde_json", +] + [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "block2 0.6.2", + "objc2 0.6.5", "objc2-app-kit 0.3.2", "objc2-foundation 0.3.2", ] @@ -1164,7 +1223,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "rustix 1.1.6", ] @@ -1172,7 +1231,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1190,28 +1249,116 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "egui", ] +[[package]] +name = "craft-cms" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" +dependencies = [ + "md-5", + "rayon", +] + [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" + +[[package]] +name = "craft-color" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" +dependencies = [ + "serde", +] + +[[package]] +name = "craft-color-transform" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" +dependencies = [ + "craft-cms", + "craft-color", + "serde", +] + +[[package]] +name = "craft-control" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" +dependencies = [ + "craft-ai-agents", + "craft-atomic", + "craft-control-protocol", + "craft-flags", + "craft-platform", + "dirs", + "log", + "serde", + "serde_json", +] + +[[package]] +name = "craft-control-protocol" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" +dependencies = [ + "getrandom 0.3.4", + "serde_json", + "subtle", +] + +[[package]] +name = "craft-crw" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" +dependencies = [ + "thiserror 2.0.21", +] [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "rayon", ] +[[package]] +name = "craft-develop" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" +dependencies = [ + "craft-color", + "craft-color-transform", + "craft-develop-model", + "craft-geom", + "craft-raw", + "rayon", + "serde", + "serde_json", +] + +[[package]] +name = "craft-develop-model" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" +dependencies = [ + "craft-geom", + "craft-metadata", + "miniz_oxide 0.9.1", + "serde", + "serde_json", +] + [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "serde", ] @@ -1219,7 +1366,7 @@ dependencies = [ [[package]] name = "craft-fig" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-figma-rest", "craft-kiwi", @@ -1234,29 +1381,39 @@ dependencies = [ [[package]] name = "craft-figcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-zip", "serde", "serde_json", "thiserror 2.0.21", - "zip 9.1.1", + "zip", ] [[package]] name = "craft-figma-rest" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "serde", "serde_json", "thiserror 2.0.21", ] +[[package]] +name = "craft-flags" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" +dependencies = [ + "craft-atomic", + "dirs", + "toml_edit", +] + [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1271,7 +1428,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1280,7 +1437,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "cap-primitives", "craft-atomic", @@ -1303,12 +1460,20 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" + +[[package]] +name = "craft-geom" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" +dependencies = [ + "serde", +] [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "gif", "image", @@ -1317,7 +1482,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1330,7 +1495,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "chrono", "fixed_decimal", @@ -1358,7 +1523,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-dds", "craft-jpeg", @@ -1385,7 +1550,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "thiserror 2.0.21", ] @@ -1393,7 +1558,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-host", "craft-i18n", @@ -1408,12 +1573,12 @@ dependencies = [ [[package]] name = "craft-kiwi" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-behavior", "craft-host", @@ -1431,9 +1596,9 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ - "brotli-decompressor", + "brotli-decompressor 6.3.2", "chrono", "craft-tiff", "quick-xml 0.41.0", @@ -1443,7 +1608,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "krilla", "serde", @@ -1453,7 +1618,7 @@ dependencies = [ [[package]] name = "craft-penpot" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-zip", "serde", @@ -1464,7 +1629,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "async-channel", "async-io", @@ -1495,7 +1660,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "dispatch2", "egui", @@ -1505,10 +1670,28 @@ dependencies = [ "web-sys", ] +[[package]] +name = "craft-raw" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" +dependencies = [ + "chrono", + "craft-crw", + "craft-metadata", + "craft-tiff", + "jxl-oxide", + "miniz_oxide 0.9.1", + "rayon", + "serde", + "thiserror 2.0.21", + "zune-core", + "zune-jpeg", +] + [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-atomic", "craft-host", @@ -1525,7 +1708,7 @@ dependencies = [ [[package]] name = "craft-sketch" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-figma-rest", "craft-zip", @@ -1537,7 +1720,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-image-codecs", "craft-xml", @@ -1556,7 +1739,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -1571,7 +1754,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "serde", "thiserror 2.0.21", @@ -1581,12 +1764,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -1600,7 +1783,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-behavior", "craft-i18n", @@ -1616,7 +1799,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "accesskit", "craft-behavior", @@ -1654,7 +1837,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1665,7 +1848,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-behavior", "craft-host", @@ -1683,7 +1866,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-behavior", "craft-host", @@ -1704,7 +1887,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-behavior", "craft-host", @@ -1724,7 +1907,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-behavior", "craft-host", @@ -1743,13 +1926,15 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ + "base64 0.22.1", "chrono", "craft-host", "craft-theme", "craft-ui", "dunce", + "ed25519-dalek", "egui", "flate2", "image", @@ -1762,17 +1947,18 @@ dependencies = [ "sha2", "tar", "tempfile", + "toml", "ureq", "verifysign", "winreg", "winsafe", - "zip 9.1.1", + "zip", ] [[package]] name = "craft-vectordrawable" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "kurbo", ] @@ -1780,7 +1966,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "js-sys", "serde_json", @@ -1791,7 +1977,7 @@ dependencies = [ [[package]] name = "craft-web-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-host", "craft-platform", @@ -1803,7 +1989,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "winsafe", ] @@ -1811,7 +1997,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "craft-appkit", "craft-atomic", @@ -1835,7 +2021,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1845,11 +2031,11 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "flate2", "thiserror 2.0.21", - "zip 9.1.1", + "zip", ] [[package]] @@ -1937,6 +2123,33 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "data-encoding" version = "2.11.1" @@ -1980,23 +2193,23 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid 0.9.6", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "deranged" version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" -[[package]] -name = "derive_arbitrary" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b034bd7d5f032402a2479444dcc6f74e36a03f31854d41680fb240ef682a1ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.9", -] - [[package]] name = "deunicode" version = "1.6.2" @@ -2020,7 +2233,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ "block-buffer 0.12.1", - "const-oid", + "const-oid 0.10.2", "crypto-common 0.2.2", ] @@ -2168,16 +2381,40 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "bytemuck", "emath", ] +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" +dependencies = [ + "curve25519-dalek", + "ed25519", + "serde", + "sha2", + "subtle", + "zeroize", +] + [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "ahash", "bytemuck", @@ -2212,7 +2449,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "accesskit", "ahash", @@ -2231,7 +2468,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "ahash", "bytemuck", @@ -2250,7 +2487,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "accesskit_winit", "arboard", @@ -2276,7 +2513,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "ahash", "egui", @@ -2289,7 +2526,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "bytemuck", "egui", @@ -2308,7 +2545,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "bytemuck", ] @@ -2398,7 +2635,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" dependencies = [ "ahash", "bytemuck", @@ -2424,7 +2661,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" [[package]] name = "equivalent" @@ -2520,11 +2757,19 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b97b65636e5b9ef369943878ac74335ba1c55c1cb6adbf1e2c293c624248d693" +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + [[package]] name = "figcraft" -version = "0.18.1" +version = "0.19.0" dependencies = [ "arboard", + "chrono", + "craft-control", "craft-menu", "craft-settings", "craft-update", @@ -2555,11 +2800,14 @@ dependencies = [ [[package]] name = "figcraft-cli" -version = "0.18.1" +version = "0.19.0" dependencies = [ "clap", "clap_complete", "clap_mangen", + "craft-control", + "craft-settings", + "figcraft-collab-net", "figcraft-doc", "figcraft-engine", "figcraft-format", @@ -2573,7 +2821,7 @@ dependencies = [ [[package]] name = "figcraft-collab" -version = "0.18.1" +version = "0.19.0" dependencies = [ "base64 0.22.1", "chrono", @@ -2591,7 +2839,7 @@ dependencies = [ [[package]] name = "figcraft-collab-net" -version = "0.18.1" +version = "0.19.0" dependencies = [ "base64 0.22.1", "figcraft-collab", @@ -2601,7 +2849,9 @@ dependencies = [ "js-sys", "log", "proptest", + "ring", "rustls", + "rustls-native-certs", "rustls-pki-types", "serde_json", "tungstenite", @@ -2614,7 +2864,7 @@ dependencies = [ [[package]] name = "figcraft-color" -version = "0.18.1" +version = "0.19.0" dependencies = [ "kurbo", "serde", @@ -2623,7 +2873,7 @@ dependencies = [ [[package]] name = "figcraft-doc" -version = "0.18.1" +version = "0.19.0" dependencies = [ "figcraft-color", "figcraft-geom", @@ -2636,12 +2886,14 @@ dependencies = [ [[package]] name = "figcraft-engine" -version = "0.18.1" +version = "0.19.0" dependencies = [ "base64 0.22.1", + "chrono", "craft-docpath", "craft-font-catalog", "craft-font-store", + "craft-raw", "deunicode", "figcraft-collab", "figcraft-color", @@ -2665,19 +2917,23 @@ dependencies = [ "thiserror 2.0.21", "wat", "web-time", - "zip 2.6.1", + "zip", ] [[package]] name = "figcraft-format" -version = "0.18.1" +version = "0.19.0" dependencies = [ + "craft-color-transform", + "craft-develop", "craft-fig", "craft-figcraft-format", "craft-figma-rest", + "craft-geom", "craft-image-codecs", "craft-jpeg", "craft-penpot", + "craft-raw", "craft-sketch", "craft-zip", "figcraft-doc", @@ -2690,12 +2946,12 @@ dependencies = [ "serde_json", "sha1", "sha2", - "zip 2.6.1", + "zip", ] [[package]] name = "figcraft-geom" -version = "0.18.1" +version = "0.19.0" dependencies = [ "kurbo", "serde", @@ -2703,7 +2959,7 @@ dependencies = [ [[package]] name = "figcraft-layout" -version = "0.18.1" +version = "0.19.0" dependencies = [ "figcraft-doc", "figcraft-geom", @@ -2711,7 +2967,7 @@ dependencies = [ [[package]] name = "figcraft-mcp" -version = "0.18.1" +version = "0.19.0" dependencies = [ "base64 0.22.1", "figcraft-collab-net", @@ -2727,7 +2983,7 @@ dependencies = [ [[package]] name = "figcraft-pathops" -version = "0.18.1" +version = "0.19.0" dependencies = [ "figcraft-doc", "figcraft-geom", @@ -2736,7 +2992,7 @@ dependencies = [ [[package]] name = "figcraft-pdf" -version = "0.18.1" +version = "0.19.0" dependencies = [ "craft-pdf", "figcraft-color", @@ -2754,7 +3010,7 @@ dependencies = [ [[package]] name = "figcraft-plugin" -version = "0.18.1" +version = "0.19.0" dependencies = [ "figcraft-color", "serde", @@ -2767,7 +3023,7 @@ dependencies = [ [[package]] name = "figcraft-render" -version = "0.18.1" +version = "0.19.0" dependencies = [ "craft-gif", "craft-image-codecs", @@ -2788,7 +3044,7 @@ dependencies = [ [[package]] name = "figcraft-server" -version = "0.18.1" +version = "0.19.0" dependencies = [ "chrono", "crc32fast", @@ -2808,12 +3064,12 @@ dependencies = [ "toml", "tungstenite", "wat", - "zip 2.6.1", + "zip", ] [[package]] name = "figcraft-svg" -version = "0.18.1" +version = "0.19.0" dependencies = [ "base64 0.22.1", "craft-svg", @@ -2831,7 +3087,7 @@ dependencies = [ [[package]] name = "figcraft-text" -version = "0.18.1" +version = "0.19.0" dependencies = [ "core-text", "craft-font-catalog", @@ -2850,9 +3106,11 @@ dependencies = [ [[package]] name = "figcraft-ui-egui" -version = "0.18.1" +version = "0.19.0" dependencies = [ "base64 0.22.1", + "brotli", + "brotli-decompressor 6.3.2", "chrono", "craft-host", "craft-i18n", @@ -2883,7 +3141,7 @@ dependencies = [ [[package]] name = "figcraft-vectordrawable" -version = "0.18.1" +version = "0.19.0" dependencies = [ "craft-vectordrawable", "figcraft-color", @@ -2898,7 +3156,7 @@ dependencies = [ [[package]] name = "figcraft-web" -version = "0.18.1" +version = "0.19.0" dependencies = [ "base64 0.22.1", "craft-web-api", @@ -4085,9 +4343,9 @@ dependencies = [ [[package]] name = "jpeg-encoder" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b454d911ac55068f53495488d8ccd0646eaa540c033a28ee15b07838afafb01f" +checksum = "a0370574b86f7eca156b9f298392b5e69a23f8c86f3f865add60bbc2e79467a6" [[package]] name = "js-sys" @@ -4100,6 +4358,182 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jxl-bitstream" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b480e752277e29eb4054f69546887a9b84656fe78c08f54ba5850ced98a378fe" +dependencies = [ + "tracing", +] + +[[package]] +name = "jxl-coding" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd972bcd125e776f1eb241ac50e39f956095a1c2770c64736c968f8946bd9a3c" +dependencies = [ + "jxl-bitstream", + "tracing", +] + +[[package]] +name = "jxl-color" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f316b1358c1711755b3ee8e8cb5c4a1dad12e796233088a7a513440782de80b2" +dependencies = [ + "jxl-bitstream", + "jxl-coding", + "jxl-grid", + "jxl-image", + "jxl-oxide-common", + "jxl-threadpool", + "tracing", +] + +[[package]] +name = "jxl-frame" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d967c6fd669c7c01060b5022d8835fa82fd46b06ffc98b549f17600a097c2b3" +dependencies = [ + "jxl-bitstream", + "jxl-coding", + "jxl-grid", + "jxl-image", + "jxl-modular", + "jxl-oxide-common", + "jxl-threadpool", + "jxl-vardct", + "tracing", +] + +[[package]] +name = "jxl-grid" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01671307879a033bfa52e6e8784b941aca770b3f3a7d33830b455b6844f793fb" +dependencies = [ + "tracing", +] + +[[package]] +name = "jxl-image" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f752d62577c702a94dbbce4045caf08cb58639e8a4d56464b40ecf33ffe565" +dependencies = [ + "jxl-bitstream", + "jxl-grid", + "jxl-oxide-common", + "tracing", +] + +[[package]] +name = "jxl-jbr" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35d032bcec660647828527ff42c6f5776d2fd44b8357f9f6d9ac6dc07218e46" +dependencies = [ + "brotli-decompressor 5.0.3", + "jxl-bitstream", + "jxl-frame", + "jxl-grid", + "jxl-image", + "jxl-modular", + "jxl-oxide-common", + "jxl-threadpool", + "jxl-vardct", + "tracing", +] + +[[package]] +name = "jxl-modular" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2f045b24c738dd91d482be385512b512721ae08a671bd4b27bf1c47f215235" +dependencies = [ + "jxl-bitstream", + "jxl-coding", + "jxl-grid", + "jxl-oxide-common", + "jxl-threadpool", + "tracing", +] + +[[package]] +name = "jxl-oxide" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d36c662923f47586880211f3bc7c0d83fb3a9b410d278c7bde93450748abeef3" +dependencies = [ + "brotli-decompressor 5.0.3", + "jxl-bitstream", + "jxl-color", + "jxl-frame", + "jxl-grid", + "jxl-image", + "jxl-jbr", + "jxl-oxide-common", + "jxl-render", + "jxl-threadpool", + "tracing", +] + +[[package]] +name = "jxl-oxide-common" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62394c5021b3a9e7e0dbb2d639d555d019090c9946c39f6d3b09d390db4157b" +dependencies = [ + "jxl-bitstream", +] + +[[package]] +name = "jxl-render" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34386bfdb6a19b5a30cc9beb4d475d537422c31ae8c39bb69640fcce3fcaf19" +dependencies = [ + "bytemuck", + "jxl-bitstream", + "jxl-coding", + "jxl-color", + "jxl-frame", + "jxl-grid", + "jxl-image", + "jxl-modular", + "jxl-oxide-common", + "jxl-threadpool", + "jxl-vardct", + "tracing", +] + +[[package]] +name = "jxl-threadpool" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25f15eb830aa77a7f21148d72e153562a26bfe570139bd4922eab1908dd499d3" +dependencies = [ + "tracing", +] + +[[package]] +name = "jxl-vardct" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce72a18c6d3a47172ab6c479be2bdb56f22066b5d7092663f03b4490820b4511" +dependencies = [ + "jxl-bitstream", + "jxl-coding", + "jxl-grid", + "jxl-modular", + "jxl-oxide-common", + "jxl-threadpool", + "tracing", +] + [[package]] name = "keyboard-types" version = "0.8.3" @@ -4130,7 +4564,7 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +source = "git+https://github.com/storytold/craft-libs?rev=9949e08d6f29b6c4462f14af1d5007acac163dbf#9949e08d6f29b6c4462f14af1d5007acac163dbf" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4334,6 +4768,16 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest 0.10.7", +] + [[package]] name = "memchr" version = "2.8.3" @@ -5163,6 +5607,15 @@ dependencies = [ "ryu", ] +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "peniko" version = "0.6.1" @@ -5304,6 +5757,16 @@ dependencies = [ "system-deps", ] +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.34" @@ -5548,6 +6011,15 @@ dependencies = [ "rand_core 0.10.1", ] +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + [[package]] name = "rand_core" version = "0.9.5" @@ -6204,6 +6676,15 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "rand_core 0.6.4", +] + [[package]] name = "simd-adler32" version = "0.3.10" @@ -6382,6 +6863,16 @@ dependencies = [ "bitflags 2.13.2", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -8084,7 +8575,7 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6a992b57b3d1ee972b2e3fd9225e44793104d49818836dd812d5459187712dd" dependencies = [ - "brotli-decompressor", + "brotli-decompressor 6.3.2", "bytes", ] @@ -8207,7 +8698,7 @@ checksum = "9440ea3e5aeabb0ac63af70daf835274065238cdd0cec83418f417eae38bacee" [[package]] name = "xtask" -version = "0.18.1" +version = "0.19.0" dependencies = [ "figcraft-engine", "serde_json", @@ -8399,6 +8890,20 @@ name = "zeroize" version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] [[package]] name = "zerotrie" @@ -8439,33 +8944,21 @@ dependencies = [ [[package]] name = "zip" -version = "2.6.1" +version = "9.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dcb24d0152526ae49b9b96c1dcf71850ca1e0b882e4e28ed898a93c41334744" -dependencies = [ - "arbitrary", - "crc32fast", - "crossbeam-utils", - "flate2", - "indexmap", - "memchr", - "zopfli", -] - -[[package]] -name = "zip" -version = "9.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518b847fd864440c379748ad684c449f293af68978a485a4ff16f7c901c1f7c4" +checksum = "2d8dbe089cf6b0448b78f5fc50139ab5aaa40d08ac07cdc1baf2c13add35fcce" dependencies = [ + "constant_time_eq", "crc32fast", "flate2", "getrandom 0.4.3", "indexmap", + "libc", "memchr", "nix", "typed-path", "windows-sys 0.61.2", + "zeroize", ] [[package]] @@ -8480,18 +8973,6 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" -[[package]] -name = "zopfli" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf7fc5d30c28483d93805c4a5e12b05bbb52407fa67c5f8bd552374cd01fb11" -dependencies = [ - "bumpalo", - "crc32fast", - "log", - "simd-adler32", -] - [[package]] name = "zune-core" version = "0.5.3" @@ -8569,19 +9050,19 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" [[patch.unused]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" +source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" diff --git a/Cargo.toml b/Cargo.toml index 74bdafcca..e470e8740 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,17 +6,17 @@ exclude = ["plugins"] # default-members = ["crates/*", "apps/figcraft", "apps/figcraft-cli", "xtask"] [workspace.package] -version = "0.18.1" +version = "0.19.0" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.95" repository = "https://github.com/storytold/figcraft" [workspace.dependencies] -craft-xml = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", default-features = false, features = ["tree"] } -craft-vectordrawable = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-pdf = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-xml = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf", default-features = false, features = ["tree"] } +craft-vectordrawable = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-pdf = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } # internal figcraft-geom = { path = "crates/geom" } figcraft-color = { path = "crates/color" } @@ -39,44 +39,54 @@ figcraft-plugin = { path = "crates/plugin" } # Keep every craft-libs crate on one rev. # Which paths stored in a document may be followed (craft-libs). -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } # Who draws the window frame on Linux — the compositor or the app — so every Craft app shows the # same native titlebar per desktop (craft-libs). FigCraft reads the probe result and maps it to its # own `TitleBar`; the UI runtime takes its window system from here too. -craft-window = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-window = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +# The control channel's token files and the AI agents link through the ArtCraft Launcher's switch: +# the connection file the app publishes and the `figcraft-cli mcp` side that finds the open window +# (craft-libs; #2740). +craft-control = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf", features = ["agents"] } # craft-update: app-specific pretend versions apply to startup and manual checks. -craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", features = ["ui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf", features = ["ui"] } # The suite's font store: exact lookup of a missing font in the pinned Google Fonts and Noto # indexes, and checksum-verified installs into the one folder every Craft app reads (craft-libs). -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } # The UI runtime FigCraft's egui UI is hosted by (`crates/ui-egui/src/framework.rs`) and the # framework dialogs on it (craft-libs): who the app is to those dialogs, the runtime's key # bindings, the theme mode and the interface direction. -craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-host = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-host = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } # The macOS app menu whose Quit (⌘Q) asks the app before quitting, like the window's close button # (craft-libs; the menu it replaces quits straight through `terminate:` and loses unsaved work). -craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } # Where the settings live: the suite's folder rules, portable mode included (craft-libs). -craft-settings = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-settings = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } # Penpot export container only; JSON values cross this boundary, not shared model types. -craft-penpot = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-penpot = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } # The design-file formats (craft-libs): the .fig container and its kiwi encoding, the mapping of # a .fig message onto the REST file JSON, and that JSON's shared helpers. -craft-sketch = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-fig = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-figcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-figma-rest = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", features = ["frames"] } +craft-sketch = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-fig = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-figcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-figma-rest = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +# Camera raw files (craft-libs): the container decoders, and the shared develop stages that turn +# sensor data into a picture (demosaic, white balance, colour matrices, tone). +craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-develop = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-color-transform = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-geom = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf", features = ["frames"] } # foundation kurbo = { version = "0.13", features = ["serde"] } @@ -115,9 +125,11 @@ icu_segmenter = { version = "2.3", default-features = false, features = ["compil # dependencies, BSD-3-Clause, no_std so the web build keeps it too). deunicode = "1.6" linesweeper = "0.5" -zip = { version = "2", default-features = false, features = ["deflate"] } +zip = { version = "=9.8.2", default-features = false, features = ["deflate-flate2"] } # `.fig` import: raw deflate chunks (already built for zip) and zstd chunks (pure Rust, MIT, wasm-safe). flate2 = { version = "1", default-features = false, features = ["rust_backend"] } +brotli = { version = "9", default-features = false, features = ["std"] } +brotli-decompressor = { version = "6", default-features = false, features = ["std"] } ruzstd = { version = "0.9.1", default-features = false, features = ["std"] } sha1 = "0.11" sha2 = "0.10" @@ -196,22 +208,22 @@ opt-level = 3 # Keep the complete egui family and native event bridge on reviewed fork commits. [patch.crates-io] -ecolor = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -emath = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -egui = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } -egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_extras = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # craft-libs' vendored krilla 0.8.2: decoded PNGs are capped at 1 GiB and reserved fallibly, and a # panic while drawing unwinds without aborting. -krilla = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf" } diff --git a/README.md b/README.md index 9fae6ff68..aaef0a360 100644 --- a/README.md +++ b/README.md @@ -208,7 +208,7 @@ exposes to agents, and exported at 2x by FigCraft's own renderer. The source fil

Prototype and hand off

- Connections, triggers, actions and Smart Animate-style transitions, variables with conditionals (if / else if / else built in the interaction editor, expressions like count + 1), flows, a presentation view with device frames, hotspot hints and an Inspect panel, and a live preview pane. Alt to measure distances and padding on the canvas, Inspect mode with measurements, annotations in colour-coded categories, a ready-for-dev list with a focus view and Compare changes (before / after with property-level diffs since a frame was marked ready), and code (CSS, HTML, React, Vue, Leptos, SwiftUI, Compose, ArkUI, Flutter) where components take their properties as parameters, comment threads pinned to frames (replies, @mentions, reactions, read state) and named version history. Export any layer at any scale to PNG, JPG, WebP, SVG or PDF. + Connections, triggers, actions and Smart Animate-style transitions, variables with conditionals (if / else if / else built in the interaction editor, expressions like count + 1), flows, a presentation view with device frames, hotspot hints and an Inspect panel, and a live preview pane. Alt to measure distances and padding on the canvas, Inspect mode with measurements, annotations in colour-coded categories, a ready-for-dev list with a focus view and Compare changes (before / after with property-level diffs since a frame was marked ready), and code (CSS, HTML, React, Vue, Leptos, SwiftUI, Compose, ArkUI, Flutter, Uno C# Markup) where components take their properties as parameters, comment threads pinned to frames (replies, @mentions, reactions, read state) and named version history. Export any layer at any scale to PNG, JPG, WebP, SVG or PDF. diff --git a/ROADMAP.md b/ROADMAP.md index 3b0a51706..788aca315 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -2,7 +2,7 @@ **Stage: alpha** · next: beta, ~26 points and ~162–292 h away (one Opus 5.5 agent; ~33–67 h wall-clock with 5 agents) -> **Last reviewed:** 2026-11-15 · **Last updated:** 2026-11-19 · **Change:** minor (M5: prototype arrow-key aliases and explicit document-scoped player controls, including batch rollback; numbers unchanged; M9: clients accept complete legacy welcomes without a reconnect secret and re-authenticate on reconnect (#2365); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); a text style binds a number variable to its weight (#2174); mind maps, first step: a first node with three children on curved branches, laid out again after every edit (`board.mindMap`, `board.mindMapAdd`, #2226); the handoff mode reads Developer Mode in the interface, its ids and saved fields unchanged; the left rail's and tab strip's icons are larger, 20 pt (#553); Suggest auto layout adds nested auto layout frames by rows and columns and keeps the placement of the design, as the help center describes (#1823); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); the desktop UI takes a system face for Ethiopic, Devanagari, Gurmukhi, Gujarati, Tamil, Telugu, Kannada and Malayalam, Sinhala, Lao, Myanmar, Khmer, Armenian and Georgian as it did for Hebrew and Arabic, so a String variable's Amharic value draws in the panels instead of boxes (#2014); a layer's effect binding takes only a field its effect has; ; the boolean operation menu leads each entry with an original icon (#2003); glass takes one sample instead of its dispersion window where the colours split under 1/256 px; glass bends towards its core, and rounded rectangles work it out in closed form; glass's light is a line on its bevel and splay turns the bend towards the centre; glass bends with a thick-lens profile and splits its colours over 8 steps; glass effects take variables and keep their frost within 0–100; web host bridge: `?host=parent` or `data-host="page"` hands a page the app's files, documented in the hosting guide; a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saved with the preferences at once (gap 15); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); `.fig` connector labels without a saved snapshot are kept, centred on their line (gap 1); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); Bosnian (`bs`) draft catalog; text style dedupe is O(spans) via a last-two cache and fingerprint buckets (#1102); pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); progress docs cleaned of what merges left twice: rows merged into one, repeated status items removed, and `cargo xtask docs` (in `ci`) fails on a repeated table row or status item; a name typed for a variable or collection finds the one with that exact id before one named like it, and stored mode ids, font family variables and the panels' labels read exact ids (#1613); plugin widgets have hover styles: a layer's `hover` fill, stroke, opacity or text colour shows while the pointer is over it (gap 6); `.fig` elbowed and curved connectors without a saved path are routed like board connectors instead of drawn straight (gap 1); every file a command reads whole by path is a regular file within a cap that fits it: documents 16 GiB, placed images 256 MiB, CLI scripts 1 GiB; `figcraft-cli connect publish` publishes a code repository's code connect mappings to a design file (gap 16); while a drag only moves a large selection, its outlines, box, slots, spacing and Design panel values are worked out once and shifted, not rebuilt on every move (#1571); Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); an imported or pasted file finds an installed family under the other names its fonts give it, and with other case and spacing, instead of reporting it missing (#1292); a development example generates figcraft-cli's shell completions and man pages from its clap definitions (part of #1396); `.fig` ZIP image reads share a total byte budget and count skipped images in the import warnings (#1076); German terminology corrections (M10): gradient stops, OpenType stylistic sets and the Home-screen preference; a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; the server key is checked by comparing SHA-256 hashes of the presented and the kept key, as the deployment guide says (#1130); opening a file contacts no team library server it names until you check it (#1097); a hostile server can no longer grow a client's memory with made-up people, and a session remembers a bounded number of deleted layer ids (#1121); `doc.list` gives AI agents and plugins the open files' names, not their paths (#1117); with a large selection, frames where nothing changed reuse the selection's outlines, box and slots and the Design panel's instance and position values instead of working them out again (#1571); team libraries and plugins larger than the 16 MiB download burst can be downloaded again, more slowly (#1089); a batch keeps one undo snapshot, not one per step (#1099); files nested 256 levels deep import on the browser's 1 MB stack (#1101); SVG and PDF exports count pattern sources and the renders they embed from the layer's depth, so one cap bounds a whole export (#1082); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); joining and leaving a file nobody is editing reads and writes nothing on the server: it stays loaded a minute after everyone leaves (#1074); opening a `.figcraft` file unpacks at most 6 GiB in all (2 GiB in the browser), every area together (#1079); hovering the canvas hit-tests once per pointer move, not on every frame, and moving an auto layout frame no longer lays out its contents again on every move (#1571); `.fig` instance expansion no longer walks variable nodes for every instance or copies every outer override row into each nested instance (#1077); `comment.people` lists names that were only @mentioned, and `comment.next` and `comment.prompt` carry the mentions too (#1415); grid auto-placement looks for free cells a 64-bit word at a time and skips what blocks it, with the same placements (#1083); with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); a recovery copy made while a version is previewed holds the file, not the version shown; a FigJam `.jam` file opens as a board (#1342); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); share links can comment: a third access level beside edit and view, whose holder sees the file live and adds, replies to, reacts to and resolves comments but can't change the design; Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); `comment.list {mentions}` lists only the threads that @mention a name (#1415); in the browser an internal error that stops the page keeps its unsaved files, which open again on reload (#1123); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); figcraft-cli parses its arguments with clap, following RFC-0012 (#1396); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); the browser build publishes files to a server, so Share ▸ Online and Publish to server work there (#917); the browser build uses the fonts installed on the computer once asked, each read when text uses it (#1051); SVG import reads `color()` and `color-mix()` colours, with a note and a grey for those it can't (#1550); the portable Windows zip keeps its settings, recovery copies and plugins in `config\` beside the executable, starting with an installed copy's preferences; the window starts on other graphics when its first ones fail before the first frame: Direct3D 12 compiles with FXC and no device compiles wgpu's indirect-validation shaders, then Vulkan, OpenGL and lower requirements on the power-saving GPU (#965, #1438); Thai, Lao, Khmer and Burmese lines break between words (#1219); an AI agent attached over MCP shows where it works (#1416); a manual overlay's position can be dragged on the canvas (#405); one name for live sessions and comments: Preferences ▸ Your name, in the Join dialog too, kept in the browser, and a rename shows at once in the sessions you are in (#1380); requests that change a server's files have a budget per address, the server key's too, and join codes are found by their hash (#1075); the Join dialog shows a join from the click until its file is ready, with Cancel, and a failed join with Try again (#1381); SVG import draws each pattern tile once per scale, within the layer budget (#1080); Vietnamese letters typed with combining marks (decomposed) take one font that has every mark, instead of missing-glyph boxes beside the letter (#1478); comment.list reports each message's @mentions (#1415); mask groups draw only over the area they can paint, and nested isolated layers share one memory budget (#1061); components can't contain their own instances, directly or through other components; `edit.duplicate` returns an id map with `map: true` (#995); the batches kept for reconnecting apps are bounded in bytes by default, and `figcraft-server` takes `max_log_mb` (#1069); MCP and control calls name their document (#998); sibling placement in live sessions searches instead of counting (#1065); an AI agent attached over MCP comments under its own name, with an Agent label (#1414); the instance-swap menus have a search field (#1338); a refused batch's fixes take time linear in the batch (#1063); the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); large images on the canvas draw from a smaller copy, so two 16k images no longer lag (#1483); a file's JPEG thumbnail can't crash the home screen (#1491's progressive JPEG check, now shared); `.fig` import: library text styles linked by asset key, and override rows restating a nested level (#1234); `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); Download a missing free font from the Missing fonts window (`font.download`, #754); the web build's wasm back under its 24 MiB gate (#1472); shadows of images with transparent pixels follow their alpha (#1289); Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); offline Penpot 2.x import/export (#1143); optional batch continue-on-error with per-step outcomes (#1386); the Design panel's sections on one grid (#858); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); images placed at their own size, 2x screenshots in points (#1360); the toolbar on one 32 pt grid, without its Resources button (#1210); M4: zero-length round-capped dashes draw dots; dash expansion uses the existing safety budget; extracted from #1143; Arabic draft catalog; scaled instances keep their scale when their main is rebuilt (#922); .fig embedded images are copied once per blob, not once per hash (#1059); page ruler guides survive save and reopen (#1476); colour picker LCH and OKLCH models; non-ASCII layer names transliterate in code export (#1235); branches in live sessions and branch history entries, gap 17; plugin widgets take text input and a property menu (plugin API 4); boards: templates and tables; boards: a shared timer and voting sessions; boards: the dot grid, connector ends dragged to re-attach, curved connectors; Installed weights of an embedded font family (#1246); `.sketch` import, best effort (Sketch 48 and newer); CJK line breaking: JIS X 4051's line-start and line-end sets completed with the halfwidth small kana, the halfwidth and spacing (semi-)voiced sound marks, the iteration marks 〱–〵 and the halfwidth parentheses, with behaviour cases for each; Adobe Fonts found on macOS (#298); egui 0.37 hidden-capture deadline contract; Dev Mode measurements kept on the canvas and a read-only layers panel; boards: a board area row and progress entry; community fixes in #507, #510, #529 and #530: auto-save, a text box by dragging, batch step references, removing someone from a live session, Russian and Turkish catalogs reviewed, Czech and Indonesian drafts, the Japanese draft completed, zoom previews, the web clipboard, Alt-drag snapping and Cmd+D repeat, recovery copies, crash and rollback fixes, colour emoji, `.fig` import fixes; earlier changes are in the revision history below; CLI scales reject repeated x suffixes; CLI help and docs name the first non-divider page as the default for export and render; invalid browser-page server endpoints are ignored before they replace the sharing default; the browser crate docs no longer repeat an obsolete same-computer-only live-session restriction; document HTTP(S) links without a host are refused before opening; mind maps from the toolbar and the keyboard: Shapes ▸ Mind map places one with a click, Cmd/Ctrl+Enter adds a child and Shift+Cmd/Ctrl+Enter a sibling, Tab goes to the next sibling (#2226); code blocks, first step: a dark panel of monospace text as tall as its lines, in one of 16 languages (`board.codeBlock`, `board.setLanguage`, #2237); library analytics count insertions and detachments of styles and variables; web builds with craft-fonts embed Noto Sans Arabic by default so Persian and Arabic text draws without extra build flags (#1902); the browser build uses team libraries and plugin directories on a server; CLI post-parse errors escape terminal controls in paths and failure text; M6 `.fig` export writes text on a path (#2323), list spacing, hanging punctuation and lists, vertical trim (#2305), vector region paints (#2302), image adjustments (#2297) and a page's prototype background (#2326); M8 Tidy up keeps a row's or column's order and sizes and evens the gaps, rounds the gap, tidies overlapping rows and grids along their longer axis, and raises a negative gap so no layer reaches the one two before it, as measured in Figma (#2319); a polygon's or star's Count handle and a double-click on a layer's icon (zoom, range anchor) follow Figma; Tab while renaming moves only the rename and wraps from the last layer; Align is unavailable for a layer in an auto layout frame's flow; the Scale tool pivots on the opposite handle and starts its origin at the centre; Paste over selection puts the copies just above the selected layer; Crop from the image fill's menu crops with a drag (#2307); M10 code export writes every colour and gradient fill in paint order for CSS, SwiftUI, Compose and Flutter (#2271), CSS as one layered background; 24 pt icon buttons draw 16 pt glyphs (#2227, #2238); M5 marquee selection follows Figma's measured rules and Select layer lists locked layers with a padlock (#1560); M7 the Design panel shows the page's variable modes with nothing selected (#2215); M12 mind maps in a section or frame without a place centre on the view, stickies take a Small–Huge text-size menu, and M9 `.jam` shapes with text import as native board shapes (#1808); M4 a boolean group's corner radius rounds its result (#2222), Flatten bakes a point's corner radius into its path (#2195) and loops close through a joining segment (#1951); library links survive moving or cloning the project folder (#2132); renaming a variable group to a path with `/` nests it (#2353); SVG import, widget images, batches and grids take bounded work, and a host's server key is never sent over plain `ws://` to another machine (#1923); CI prefetches dependencies for Sonar coverage and runs Harden-Runner on every job; releases FigCraft v0.18.0 and v0.18.1 (Flatpak update fix); readiness estimates unchanged) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-11-15 · **Last updated:** 2026-11-19 · **Change:** minor (macOS DMGs are built with `hdiutil create -fs HFS+` and the app is verified in the finished image and an installation copy (#387); variables export and import as DTCG design tokens (#1687); Uno C# Markup code generation for layers, with auto layout and vectors as paths; M5: prototype arrow-key aliases and explicit document-scoped player controls, including batch rollback; numbers unchanged; M9: clients accept complete legacy welcomes without a reconnect secret and re-authenticate on reconnect (#2365); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); a text style binds a number variable to its weight (#2174); mind maps, first step: a first node with three children on curved branches, laid out again after every edit (`board.mindMap`, `board.mindMapAdd`, #2226); the handoff mode reads Developer Mode in the interface, its ids and saved fields unchanged; the left rail's and tab strip's icons are larger, 20 pt (#553); Suggest auto layout adds nested auto layout frames by rows and columns and keeps the placement of the design, as the help center describes (#1823); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); the desktop UI takes a system face for Ethiopic, Devanagari, Gurmukhi, Gujarati, Tamil, Telugu, Kannada and Malayalam, Sinhala, Lao, Myanmar, Khmer, Armenian and Georgian as it did for Hebrew and Arabic, so a String variable's Amharic value draws in the panels instead of boxes (#2014); a layer's effect binding takes only a field its effect has; ; the boolean operation menu leads each entry with an original icon (#2003); glass takes one sample instead of its dispersion window where the colours split under 1/256 px; glass bends towards its core, and rounded rectangles work it out in closed form; glass's light is a line on its bevel and splay turns the bend towards the centre; glass bends with a thick-lens profile and splits its colours over 8 steps; glass effects take variables and keep their frost within 0–100; web host bridge: `?host=parent` or `data-host="page"` hands a page the app's files, documented in the hosting guide; a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saved with the preferences at once (gap 15); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); `.fig` connector labels without a saved snapshot are kept, centred on their line (gap 1); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); Bosnian (`bs`) draft catalog; text style dedupe is O(spans) via a last-two cache and fingerprint buckets (#1102); pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); progress docs cleaned of what merges left twice: rows merged into one, repeated status items removed, and `cargo xtask docs` (in `ci`) fails on a repeated table row or status item; a name typed for a variable or collection finds the one with that exact id before one named like it, and stored mode ids, font family variables and the panels' labels read exact ids (#1613); plugin widgets have hover styles: a layer's `hover` fill, stroke, opacity or text colour shows while the pointer is over it (gap 6); `.fig` elbowed and curved connectors without a saved path are routed like board connectors instead of drawn straight (gap 1); every file a command reads whole by path is a regular file within a cap that fits it: documents 16 GiB, placed images 256 MiB, CLI scripts 1 GiB; `figcraft-cli connect publish` publishes a code repository's code connect mappings to a design file (gap 16); while a drag only moves a large selection, its outlines, box, slots, spacing and Design panel values are worked out once and shifted, not rebuilt on every move (#1571); Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); an imported or pasted file finds an installed family under the other names its fonts give it, and with other case and spacing, instead of reporting it missing (#1292); a development example generates figcraft-cli's shell completions and man pages from its clap definitions (part of #1396); `.fig` ZIP image reads share a total byte budget and count skipped images in the import warnings (#1076); German terminology corrections (M10): gradient stops, OpenType stylistic sets and the Home-screen preference; a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; the server key is checked by comparing SHA-256 hashes of the presented and the kept key, as the deployment guide says (#1130); opening a file contacts no team library server it names until you check it (#1097); a hostile server can no longer grow a client's memory with made-up people, and a session remembers a bounded number of deleted layer ids (#1121); `doc.list` gives AI agents and plugins the open files' names, not their paths (#1117); with a large selection, frames where nothing changed reuse the selection's outlines, box and slots and the Design panel's instance and position values instead of working them out again (#1571); team libraries and plugins larger than the 16 MiB download burst can be downloaded again, more slowly (#1089); a batch keeps one undo snapshot, not one per step (#1099); files nested 256 levels deep import on the browser's 1 MB stack (#1101); SVG and PDF exports count pattern sources and the renders they embed from the layer's depth, so one cap bounds a whole export (#1082); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); joining and leaving a file nobody is editing reads and writes nothing on the server: it stays loaded a minute after everyone leaves (#1074); opening a `.figcraft` file unpacks at most 6 GiB in all (2 GiB in the browser), every area together (#1079); hovering the canvas hit-tests once per pointer move, not on every frame, and moving an auto layout frame no longer lays out its contents again on every move (#1571); `.fig` instance expansion no longer walks variable nodes for every instance or copies every outer override row into each nested instance (#1077); `comment.people` lists names that were only @mentioned, and `comment.next` and `comment.prompt` carry the mentions too (#1415); grid auto-placement looks for free cells a 64-bit word at a time and skips what blocks it, with the same placements (#1083); with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); a recovery copy made while a version is previewed holds the file, not the version shown; a FigJam `.jam` file opens as a board (#1342); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); share links can comment: a third access level beside edit and view, whose holder sees the file live and adds, replies to, reacts to and resolves comments but can't change the design; Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); `comment.list {mentions}` lists only the threads that @mention a name (#1415); in the browser an internal error that stops the page keeps its unsaved files, which open again on reload (#1123); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); figcraft-cli parses its arguments with clap, following RFC-0012 (#1396); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); the browser build publishes files to a server, so Share ▸ Online and Publish to server work there (#917); the browser build uses the fonts installed on the computer once asked, each read when text uses it (#1051); SVG import reads `color()` and `color-mix()` colours, with a note and a grey for those it can't (#1550); the portable Windows zip keeps its settings, recovery copies and plugins in `config\` beside the executable, starting with an installed copy's preferences; the window starts on other graphics when its first ones fail before the first frame: Direct3D 12 compiles with FXC and no device compiles wgpu's indirect-validation shaders, then Vulkan, OpenGL and lower requirements on the power-saving GPU (#965, #1438); Thai, Lao, Khmer and Burmese lines break between words (#1219); an AI agent attached over MCP shows where it works (#1416); a manual overlay's position can be dragged on the canvas (#405); one name for live sessions and comments: Preferences ▸ Your name, in the Join dialog too, kept in the browser, and a rename shows at once in the sessions you are in (#1380); requests that change a server's files have a budget per address, the server key's too, and join codes are found by their hash (#1075); the Join dialog shows a join from the click until its file is ready, with Cancel, and a failed join with Try again (#1381); SVG import draws each pattern tile once per scale, within the layer budget (#1080); Vietnamese letters typed with combining marks (decomposed) take one font that has every mark, instead of missing-glyph boxes beside the letter (#1478); comment.list reports each message's @mentions (#1415); mask groups draw only over the area they can paint, and nested isolated layers share one memory budget (#1061); components can't contain their own instances, directly or through other components; `edit.duplicate` returns an id map with `map: true` (#995); the batches kept for reconnecting apps are bounded in bytes by default, and `figcraft-server` takes `max_log_mb` (#1069); MCP and control calls name their document (#998); sibling placement in live sessions searches instead of counting (#1065); an AI agent attached over MCP comments under its own name, with an Agent label (#1414); the instance-swap menus have a search field (#1338); a refused batch's fixes take time linear in the batch (#1063); the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); large images on the canvas draw from a smaller copy, so two 16k images no longer lag (#1483); a file's JPEG thumbnail can't crash the home screen (#1491's progressive JPEG check, now shared); `.fig` import: library text styles linked by asset key, and override rows restating a nested level (#1234); `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); Download a missing free font from the Missing fonts window (`font.download`, #754); the web build's wasm back under its 24 MiB gate (#1472); shadows of images with transparent pixels follow their alpha (#1289); Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); offline Penpot 2.x import/export (#1143); optional batch continue-on-error with per-step outcomes (#1386); the Design panel's sections on one grid (#858); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); images placed at their own size, 2x screenshots in points (#1360); the toolbar on one 32 pt grid, without its Resources button (#1210); M4: zero-length round-capped dashes draw dots; dash expansion uses the existing safety budget; extracted from #1143; Arabic draft catalog; scaled instances keep their scale when their main is rebuilt (#922); .fig embedded images are copied once per blob, not once per hash (#1059); page ruler guides survive save and reopen (#1476); colour picker LCH and OKLCH models; non-ASCII layer names transliterate in code export (#1235); branches in live sessions and branch history entries, gap 17; plugin widgets take text input and a property menu (plugin API 4); boards: templates and tables; boards: a shared timer and voting sessions; boards: the dot grid, connector ends dragged to re-attach, curved connectors; Installed weights of an embedded font family (#1246); `.sketch` import, best effort (Sketch 48 and newer); CJK line breaking: JIS X 4051's line-start and line-end sets completed with the halfwidth small kana, the halfwidth and spacing (semi-)voiced sound marks, the iteration marks 〱–〵 and the halfwidth parentheses, with behaviour cases for each; Adobe Fonts found on macOS (#298); egui 0.37 hidden-capture deadline contract; Dev Mode measurements kept on the canvas and a read-only layers panel; boards: a board area row and progress entry; community fixes in #507, #510, #529 and #530: auto-save, a text box by dragging, batch step references, removing someone from a live session, Russian and Turkish catalogs reviewed, Czech and Indonesian drafts, the Japanese draft completed, zoom previews, the web clipboard, Alt-drag snapping and Cmd+D repeat, recovery copies, crash and rollback fixes, colour emoji, `.fig` import fixes; earlier changes are in the revision history below; CLI scales reject repeated x suffixes; CLI help and docs name the first non-divider page as the default for export and render; invalid browser-page server endpoints are ignored before they replace the sharing default; the browser crate docs no longer repeat an obsolete same-computer-only live-session restriction; document HTTP(S) links without a host are refused before opening; mind maps from the toolbar and the keyboard: Shapes ▸ Mind map places one with a click, Cmd/Ctrl+Enter adds a child and Shift+Cmd/Ctrl+Enter a sibling, Tab goes to the next sibling (#2226); code blocks, first step: a dark panel of monospace text as tall as its lines, in one of 16 languages (`board.codeBlock`, `board.setLanguage`, #2237); library analytics count insertions and detachments of styles and variables; web builds with craft-fonts embed Noto Sans Arabic by default so Persian and Arabic text draws without extra build flags (#1902); the browser build uses team libraries and plugin directories on a server; the local variables JSON carries the file's text styles (`textStyles` in `variable.export`, read back by `variable.import` with their variable bindings re-pointed; a file's own export leaves its text styles alone) (#2173); CLI post-parse errors escape terminal controls in paths and failure text; M6 `.fig` export writes text on a path (#2323), list spacing, hanging punctuation and lists, vertical trim (#2305), vector region paints (#2302), image adjustments (#2297) and a page's prototype background (#2326); M8 Tidy up keeps a row's or column's order and sizes and evens the gaps, rounds the gap, tidies overlapping rows and grids along their longer axis, and raises a negative gap so no layer reaches the one two before it, as measured in Figma (#2319); a polygon's or star's Count handle and a double-click on a layer's icon (zoom, range anchor) follow Figma; Tab while renaming moves only the rename and wraps from the last layer; Align is unavailable for a layer in an auto layout frame's flow; the Scale tool pivots on the opposite handle and starts its origin at the centre; Paste over selection puts the copies just above the selected layer; Crop from the image fill's menu crops with a drag (#2307); M10 code export writes every colour and gradient fill in paint order for CSS, SwiftUI, Compose and Flutter (#2271), CSS as one layered background; 24 pt icon buttons draw 16 pt glyphs (#2227, #2238); M5 marquee selection follows Figma's measured rules and Select layer lists locked layers with a padlock (#1560); M7 the Design panel shows the page's variable modes with nothing selected (#2215); M12 mind maps in a section or frame without a place centre on the view, stickies take a Small–Huge text-size menu, and M9 `.jam` shapes with text import as native board shapes (#1808); M4 a boolean group's corner radius rounds its result (#2222), Flatten bakes a point's corner radius into its path (#2195) and loops close through a joining segment (#1951); library links survive moving or cloning the project folder (#2132); renaming a variable group to a path with `/` nests it (#2353); SVG import, widget images, batches and grids take bounded work, and a host's server key is never sent over plain `ws://` to another machine (#1923); CI prefetches dependencies for Sonar coverage and runs Harden-Runner on every job; releases FigCraft v0.18.0 and v0.18.1 (Flatpak update fix); readiness estimates unchanged) · **Target:** Figma Design (desktop app 126.10.7) FigCraft is a clean-room, open-source, pure-Rust reimplementation of the Figma design workflow, native on macOS, Windows, Linux and FreeBSD and in the browser, fully drivable by agents through @@ -366,6 +366,10 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md). | Date | Change | Summary | |---|---|---| +| 2026-11-28 | minor | M8: the MCP prompt `implement_design` takes an agent through building the selected design in a codebase: `design_context` for what the designer set, connected components reused through `component_mappings` and `sync_mappings`, tokens before literal values, real files from `export_assets`, the annotations and `responsive` for what the design states beyond its size, and `compare_design` to check the result. With nothing selected it asks which frame to build, and it reports what it approximated, assumed or couldn't check. A test now checks that every tool and result field the server instructions and prompts name exists, as one already did for command ids. Numbers unchanged | +| 2026-11-28 | minor | M1, #2185: `node.create` (and the MCP `create_node` tool) takes `children`, a list of `node.create` params made inside the new layer, each with children of its own, in one command and one undo step. The result mirrors the tree (`{id, children: [{id, children?}, …]}`), so a batch step names any layer in it with a `field` path; a refused child names its place (`children[1].children[0]: …`) and nothing is made. A card or a dialog is one call instead of a step per layer. Tests: `node_create_tree_tests`. Numbers unchanged. | +| 2026-11-28 | minor | M7, #1687: variables export and import as DTCG design tokens (format 2025.10), the files token build pipelines read. `variable.export {format: "dtcg", mode?}` (also Variables ▸ Export… ▸ Design tokens (DTCG)…, saved as `.tokens.json`) writes a group per collection and a token per variable, nested by the `/` parts of its name: colours as `colorSpace`/`components`/`alpha` objects (with `hex` in sRGB, `display-p3` in a Display P3 file), numbers as px dimensions or plain numbers where layers use them unitless, aliases as `{group.token}` (one leaving the exported collections as the value it shows), colour calculations as the colour they show; strings and booleans, which DTCG has no type for, every mode's value and the variable's scopes go under `$extensions` (`ai.storyteller.figcraft`), and `mode` picks which mode is `$value`. `variable.import` reads a file holding a `$value` as tokens: each top-level group a collection (top-level tokens one named Tokens), types handed down from groups, `color` (object or `#hex`), `dimension` (px, rem at 16 px, or the older `16px` string), `number`, `fontWeight` (number or name), `duration` (ms), `fontFamily`, strings, booleans and aliases (an untyped alias takes its target's type); without our modes a collection fills the default mode of this file's collection of its name. Composite tokens (typography, shadows and the like) are skipped and counted in the warnings, never dropped silently. Tests: `dtcg_tests` (format, three) and `variables_io_tests::design_tokens_export_and_import_round_trip`, `plain_design_tokens_update_the_default_mode` (engine). Numbers unchanged | +| 2026-11-27 | minor | M8: visual verification for agents. `inspect.compare` and the MCP tool `compare_design` compare a capture of a built page, made by the agent's own browser tools, with a frame, on this computer: the layers that differ, deepest and largest first, each a position (with its offset), colour (expected and actual) or content difference, with text held to twice the tolerance. A retina capture is the same design. Numbers unchanged. Tests: `visual_compare_tests`, MCP `compare_design`. | | 2026-11-26 | minor | #1396, craft-contrib#95: `figcraft-cli` follows RFC-0018. The CLI is a library with `run(args, out, err)` (`main` is a thin wrapper), failures are typed errors (exit 1, usage errors exit 2), output goes through the caller's writers, a closed stdout is quiet, `-V` works after subcommands, `FIGCRAFT_NO_SYSTEM_FONTS` and `FIGCRAFT_SERVER_KEY` are declared on `--no-system-fonts` and `plugin publish --key`, the packages install the man pages and Bash, Zsh and Fish completions (Linux and FreeBSD). Changed behaviour: `convert`/`run` refuse an output that is the input unless `--in-place` is given (it needs `--in`/`--out`); `export -o` and `render -o` refuse the file they read; `plugin publish` accepts `--key`; a blank `FIGCRAFT_NO_SYSTEM_FONTS` counts as unset and an unrecognised value is a usage error. Tests in `apps/figcraft-cli/tests/it/rfc18.rs`. Numbers unchanged | | 2026-11-24 | minor | M7: New York, Apple's serif that macOS installs as the hidden `.New York`, is found and listed under its public name (it was a missing font). Numbers unchanged. | | 2026-11-15 | patch | Removed the obsolete duplicate live-session bullet from the browser crate docs; the existing server publishing and remote wss guidance remains authoritative. Runtime behavior unchanged. | @@ -378,6 +382,7 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md). | 2026-11-18 | minor | M8: asset handoff. `file.exportAssets` and the MCP tool `export_assets` write a design's images and vectors into a folder: images as the file's original bytes, never re-encoded, vectors as SVG, layers with export settings by those settings, each saying which it is. Files are named by their content, so an asset has one file and exporting again writes nothing; what a layer does to an image that isn't in its bytes is listed. Numbers unchanged | | 2026-11-17 | minor | M6: Android Vector Drawable XML serialization uses the shared writer; application projection and colour policy remain local. Byte-parity tests cover full documents and generated deep wrappers; no new format capability or incumbent certification. | | 2026-11-10 | minor | M12, #2226 (step 2 of 4): mind maps in the UI. The Shapes flyout ends in a mind map tool (`tool.mindMap`): a click places a map with the first node's text starting there and types in it. Cmd/Ctrl+Enter adds a child of the selected or edited node (`board.mindMapAdd`), Shift+Cmd/Ctrl+Enter its next sibling (`board.nextSticky` on a node), both typing on; Tab and Shift+Tab walk a node's siblings in the map's order (`select.next`, `select.previous`). The bar over the selection colours a node's text (`board.setColor`) and shows a branch the connector's controls without the line types. Tests: `board_mindmap_tests` (four more), `board_ui_tests` (five more). Breadth ~47% → ~48%, ready ~29% → ~30%. | +| 2026-11-10 | minor | M7, #2173: `variable.export {format: "json"}` writes a top-level `textStyles` array beside `meta` (each text style as `style.list {type: "text"}` returns it; `bound` holds the ids `meta.variables` is keyed by for variables of the exported collections, so an export filtered by `collections` can name variables it doesn't include), and `variable.import` reads it back (styles merged by name, bindings re-pointed; a binding to a variable the JSON lacks is kept without a warning when the existing style already holds that same variable, and otherwise dropped with a warning). A FigCraft extension: the REST `styles` metadata has no values. CSS, Tailwind and Dart stay variables-only | | 2026-11-15 | patch | CLI usage and operation failures escape terminal controls in paths and error text, using the same printable-text rule as info and script diagnostics; exit codes and ordinary quotes and paths stay unchanged. | | 2026-11-10 | minor | Experimental `.fig` export preserves set-variable, set-variable-mode and conditional prototype actions (#2210). | | 2026-11-15 | patch | Document HTTP(S) links without a host are refused before opening; regressions retain valid query, fragment, IPv6 and mail links. | @@ -385,6 +390,8 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md). | 2026-11-15 | patch | CLI export and render help and docs name the existing first non-divider page default, including the all-divider fallback and explicit page selection. Behavior unchanged. | | 2026-11-15 | patch | CLI export and render reject repeated scale suffixes such as `2xx` as usage errors (exit 2); numeric values and one optional `x` suffix retain the existing limits. | | 2026-11-16 | patch | M9, #2365: native and browser clients accept the complete legacy `Welcome` layout without its later reconnect secret, preserving explicit access and rejecting incomplete or trailing data. A host that supplies no secret is rejoined with the share link instead of an unauthenticated `Resume`. Numbers unchanged. | +| 2026-11-14 | minor | M6: Uno C# Markup code, auto layout and vectors (ours): a frame with horizontal or vertical auto layout is a Toolkit `AutoLayout` that takes the box itself (`Background`, `BorderBrush`, `BorderThickness`, `CornerRadius`) with `Orientation`, `Spacing`, `Padding` (less the stroke weight unless strokes are included; where that goes negative the border sits behind the layout in a `Grid`), `PrimaryAxisAlignment`, `CounterAxisAlignment` and `Justify`; children are sized per axis (fixed writes the length, hug none, fill stretches with the attached `AutoLayout` call, min and max lengths on the child), text hugs, fills or is fixed, a child that ignores the layout is independent at its offset (a hugging parent with one is written at its size), the exported frame itself hugs where it hugs in the design, a clip is written only on a frame fixed on both axes, and `reverse_z` paints with descending `Canvas.ZIndex`; grid mode is a `Grid` with `ColumnDefinitions` / `RowDefinitions` (pixels, `Auto`, whole-number stars), `ColumnSpacing` / `RowSpacing`, children in the cell the layout crate gives them (`.Grid(row:, column:, rowSpan:, columnSpan:)`) aligned in it; wrap is one line with a note; frames without auto layout keep the `Canvas` with one warning per view that counts them; an explicit line height moves the text down by the half-leading of the face FigCraft draws with (a top padding with a negative bottom margin in a panel, the offset in a `Canvas`; the number depends on the fonts installed where `inspect.code` runs; a line height below the font's natural height keeps `LineHeight` and adds `LineStackingStrategy.BlockLineHeight`); vectors, booleans and shapes are a `Microsoft.UI.Xaml.Shapes.Path` with path data (`F1` non-zero, `F0` even-odd; at most 5,000 elements), one solid fill and one solid stroke, falling back to a PNG `Image` for gradients, several paints, effects and over the cap; containers are locals and children go in with `Children.Add(x)` / `Child = x`, since fluent `.Children(…)` doubles the load time with every level of nesting. Numbers unchanged (the incumbent has no such target). | +| 2026-11-10 | minor | M6: Uno Platform C# Markup code (ours; the incumbent generates CSS, iOS and Android only): `inspect.code {language: uno}` (aliases `csharp-markup`, `cs-markup`) writes a `UserControl` class whose content is a fluent C# Markup tree for a layer: a frame, group or rectangle is a `Border` (fill as `Color.FromArgb`, border brush and thickness, per-side thickness, per-corner radius, opacity, rotation) holding a `Canvas` with the children at their offsets (a stroke and children put the border behind the canvas in a `Grid`, so the stroke does not push the children in), an ellipse is an `Ellipse`, text is a `TextBlock` (family, size, weight, italic, colour, line height, character spacing, alignment, wrapping, trimming and max lines from the auto resize mode, decoration, case applied when the code runs, mixed styles as `Run`s) and vectors and other shapes are an `Image` on an SVG asset (`ms-appx:///Assets/.svg`, a lowercase ASCII name unique in the snippet) with a comment to export it; image fills are an `ImageBrush` on a PNG asset. Fixed sizes everywhere; auto layout, variables, components and the project export are later steps. Shadows, blurs, blend modes, gradients beyond the first stop, masks and corner smoothing stay as `// not mapped: …` comments in the chain. Not offered for code connect or component code yet. Headline numbers unchanged. | | 2026-11-10 | minor | M4, #2222: a boolean group takes a corner radius that rounds every sharp corner of its result. Numbers unchanged | | 2026-11-10 | minor | M12, #2226 (step 1 of 4): mind maps in the document and engine. `board.mindMap` places a first node with three children on curved branches and `board.mindMapAdd` adds a child or a sibling; the normalize pass lays a touched map out again from its first node (88 between columns, 48 between siblings, stacks centred on their parents). No toolbar entry yet; numbers unchanged. | | 2026-11-07 | patch | M10, #1902: web builds with craft-fonts embed Noto Sans Arabic Regular by default, so Persian and Arabic text has a fallback without `FIGCRAFT_EMBED_SCRIPTS=Arab`; required web builds reject catalogs without that face. Web faces are compressed losslessly at build time and restored once at runtime to keep the default catalog within the WASM size budget. A decode failure logs the unavailable face once; a compiler regression checks generated catalog initialization. Additional scripts remain opt-in. Exact Iran Sans appearance still needs the installed font through supported browsers' local font access. Numbers unchanged. | @@ -620,6 +627,7 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md). | 2026-10-15 | minor | Drop files anywhere to open them (M7): dragging files over the window shows a "Drop to open" (home) or "Drop to import" (canvas) overlay. On the home screen each supported file opens as a document of its own and other files are turned away with a toast; on the canvas the files import at the drop point. Both wait behind a small card that is on screen before a large file blocks the window. A canvas import stays with the document and page that received the drop even if the tab or page changes meanwhile, and is cancelled with a message if that document or page is gone. Numbers unchanged. | | 2026-10-15 | minor | M7: system font discovery skips entries observed as non-regular files before opening them, avoiding the reproduced named-pipe stall. Regular-file symlinks remain supported; directory depth, font limits and priorities are unchanged. Numbers unchanged. | | 2026-10-15 | minor | Canvas retains a bounded margin while panning so newly exposed strips can reuse the previous render. Numbers unchanged. | +| 2026-10-15 | minor | macOS DMG: replace the HFS hybrid image builder that adds FinderInfo after signing; verify the app in the finished read-only image and a normal installation copy, with notarization checks for signed releases. A separate release-workflow job runs the native ad-hoc regression once before the shared release job, covering signature integrity and cleanup (#387). Numbers unchanged. | | 2026-10-15 | minor | Dev Mode tail (M6, gap 16): import lines for connected components inside generated layer trees (definitions, slots and swapped-in instances too); `dev.compare {version}` and the compare view's Compare with menu compare with any saved version; behaviour suite (5 tests; 4 failed before the fixes): an inspect-only Dev Mode canvas with menus, shortcuts, nudges, opacity keys and paste refusing design edits, toolbar drawing tools returning to the design, Changed in the ready list (`inspect.readyForDev {status: changed}`), statuses only on sections and top-level frames; read-only plugins' panels from the Inspect tab. Dev Mode 96%/72% → 97%/76%, 0–1 h → 2–4 h (measurements kept on the canvas and a read-only layers panel counted as missing); header totals not recomputed | | 2026-10-15 | minor | Typography spacing icons scrub with the shared number-field gesture, modifier rates and one Undo step per drag (#373). Units and selected-character targeting are preserved. Numbers unchanged. | | 2026-10-14 | minor | System theme on first run (M7): preferences without a theme default to System; the first frame reads the OS appearance directly, including when returning from a manual theme. Saved Light/Dark choices stay explicit; unavailable OS appearance falls back to Light. Numbers unchanged. | diff --git a/apps/figcraft-cli/Cargo.toml b/apps/figcraft-cli/Cargo.toml index f0c28add4..2c5142407 100644 --- a/apps/figcraft-cli/Cargo.toml +++ b/apps/figcraft-cli/Cargo.toml @@ -19,12 +19,17 @@ workspace = true [dependencies] figcraft-engine = { workspace = true } +figcraft-collab-net = { workspace = true } figcraft-doc = { workspace = true } figcraft-render = { workspace = true } figcraft-text = { workspace = true } figcraft-svg = { workspace = true } figcraft-format = { workspace = true } figcraft-mcp = { workspace = true } +# `mcp`: the open window through the ArtCraft Launcher's switch, and the control channel's token. +craft-control = { workspace = true } +# The settings folder the app publishes its connection file in. +craft-settings = { workspace = true } serde_json = { workspace = true } clap = { workspace = true } thiserror = { workspace = true } diff --git a/apps/figcraft-cli/src/args.rs b/apps/figcraft-cli/src/args.rs index 601800ae3..966b21ff8 100644 --- a/apps/figcraft-cli/src/args.rs +++ b/apps/figcraft-cli/src/args.rs @@ -14,7 +14,8 @@ use figcraft_doc::{PrintSettings, VdCompat}; /// /// Files: .figcraft (native), .penpot (Penpot 2.x), .json (FigCraft or REST API file JSON), .fig /// (best effort; `info` lists what wasn't imported), .sketch (Sketch 48 or newer, best effort), -/// .svg, .png/.jpg/.webp/.gif/.bmp (open as an image layer). +/// .svg, .png/.jpg/.webp/.gif/.bmp (open as an image layer), camera raw files such as .rw2, .cr2, +/// .cr3, .nef, .arw, .raf, .orf and .dng (developed as shot into an image layer). #[derive(Parser)] #[command( name = "figcraft-cli", @@ -124,6 +125,10 @@ pub struct ExportArgs { /// (exact) or dropped without notes (ignore) #[arg(long, value_name = "bestEffort|exact|ignore", value_parser = vd_compat, default_value = "bestEffort")] pub vd_compat: VdCompat, + /// Write nothing and fail (exit 1, listing why) when the export would leave out or change + /// content. For fig, penpot and xml, the formats that report what they can't hold + #[arg(long)] + pub strict: bool, #[command(flatten)] pub roots: RootArgs, } @@ -156,6 +161,10 @@ pub struct ConvertArgs { /// Allow OUT to be the file IN, replacing it #[arg(long)] pub in_place: bool, + /// Write nothing and fail (exit 1, listing why) when OUT would leave out or change content. + /// For .fig and .penpot, which report what they can't hold, and .figcraft, which holds everything + #[arg(long)] + pub strict: bool, #[command(flatten)] pub roots: RootArgs, } @@ -196,6 +205,10 @@ pub struct RunArgs { /// Allow --out to be the --in file, replacing it #[arg(long, requires_all = ["input", "out"])] pub in_place: bool, + /// Write nothing and fail (exit 1, listing why) when --out would leave out or change content. + /// For .fig and .penpot, which report what they can't hold, and .figcraft, which holds everything + #[arg(long, requires = "out")] + pub strict: bool, #[command(flatten)] pub roots: RootArgs, } @@ -211,20 +224,29 @@ pub struct CommandsArgs { pub filter: Option, } -/// Serve MCP on stdio: headless, or attached to a running app +/// Serve MCP on stdio: the open app, headless, or attached to a running app /// -/// The automation roots confine the headless session's file access. A server started with -/// --attach is confined by the app it attaches to: start that app with `figcraft --control PORT` -/// and the same roots. +/// While the ArtCraft Launcher's AI agents switch lets agents use FigCraft, each call goes to the +/// open FigCraft window (started when it is closed), otherwise to a session without a window, which +/// uses the automation roots or else the agent folders. Without the switch, the automation roots +/// confine the headless session's file access and are required. A server started with --attach is +/// confined by the app it attaches to: start that app with `figcraft --control PORT` and the same +/// roots. #[derive(Args)] pub struct McpArgs { /// Attach to the app started with `figcraft --control PORT`; a bare port means 127.0.0.1:PORT. /// Refuses the automation roots #[arg(long, value_name = "PORT", value_parser = attach, conflicts_with_all = ["automation_read_root", "automation_write_root"])] pub attach: Option, + /// Never use the open app: a session without a window, confined to the automation roots + #[arg(long, conflicts_with = "attach")] + pub headless: bool, /// How long the attached app may take over each request, in seconds (1–600; default 60) #[arg(long, value_name = "SECONDS", requires = "attach", value_parser = clap::value_parser!(u64).range(1..=600))] pub timeout: Option, + /// Allow a confined headless MCP session to join collaboration links from this server (repeatable) + #[arg(long = "automation-allow-server", value_name = "URL", conflicts_with = "attach")] + pub automation_allow_servers: Vec, #[command(flatten)] pub roots: RootArgs, } @@ -570,6 +592,7 @@ mod tests { (&["mcp", "--attach", "7979", "--timeout", "601"], ValueValidation), (&["mcp", "--timeout", "300"], MissingRequiredArgument), (&["mcp", "--attach", "7979", "--automation-read-root", "."], ArgumentConflict), + (&["mcp", "--attach", "7979", "--automation-allow-server", "wss://figcraft.example.com/"], ArgumentConflict), (&["mcp", "--automation-write-root"], InvalidValue), (&["mcp", "stray"], UnknownArgument), (&["convert", "a"], MissingRequiredArgument), @@ -603,6 +626,7 @@ mod tests { assert_eq!(e.as_ref().map(clap::Error::kind), Some(ErrorKind::DisplayHelp), "{args:?}"); assert_eq!(e.map(|e| e.exit_code()), Some(0), "{args:?}"); } + // The help is the subcommand's, even after a mistake. let help = try_parse(&["plugin", "publish", "--bogus", "--help"]).err().map(|e| e.to_string()).unwrap_or_default(); assert!(help.contains("Usage: figcraft-cli plugin publish"), "{help}"); @@ -611,6 +635,23 @@ mod tests { assert_eq!(a.file, "-h"); } + #[test] + fn mcp_accepts_repeated_server_allowlists() { + let Command::Mcp(a) = ok(&[ + "mcp", + "--automation-read-root", + "in", + "--automation-write-root", + "out", + "--automation-allow-server", + "wss://figcraft.example.com/", + "--automation-allow-server=wss://team.example.com/design/", + ]) else { + panic!("mcp") + }; + assert_eq!(a.automation_allow_servers, ["wss://figcraft.example.com/", "wss://team.example.com/design/"]); + } + /// Every subcommand's help renders and documents each of its options. #[test] fn every_subcommand_has_help() { diff --git a/apps/figcraft-cli/src/files.rs b/apps/figcraft-cli/src/files.rs index 04f9bc10c..749fb39cf 100644 --- a/apps/figcraft-cli/src/files.rs +++ b/apps/figcraft-cli/src/files.rs @@ -113,8 +113,39 @@ fn encode(doc: &Document, pix: &figcraft_render::Pixmap, e: &str) -> CliResult CliResult<()> { +/// Whether `export` to `out` (in `format`, else by its extension) reports what it leaves out, so +/// `--strict` has something to hold it to. +pub(crate) fn export_reports_losses(format: Option<&str>, out: &str) -> bool { + let format = format.map_or_else(|| ext(out), str::to_ascii_lowercase); + matches!(format.as_str(), "fig" | "penpot" | "xml") +} + +/// Whether `export` to `out` (in `format`, else by its extension) writes Android Vector Drawables. +pub(crate) fn export_writes_xml(format: Option<&str>, out: &str) -> bool { + format.map_or_else(|| ext(out), str::to_ascii_lowercase) == "xml" +} + +/// Whether writing a document to `out` reports what it leaves out (.fig, .penpot) or keeps +/// everything (.figcraft), so `--strict` has something to hold it to. +pub(crate) fn save_reports_losses(out: &str) -> bool { + matches!(ext(out).as_str(), "figcraft" | "fig" | "penpot") +} + +/// What writing `out` left out or changed: a note each on stderr or, when `strict`, the failure that +/// keeps `out` from being written. +fn notes(out: &str, warnings: Vec, strict: bool, io: &mut Io) -> CliResult<()> { + if strict && !warnings.is_empty() { + return Err(CliError::Failed(format!("{out} wasn't written (--strict): the export would leave out or change: {}", warnings.join("; ")))); + } + for w in warnings { + errln!(io, "note: {w}"); + } + Ok(()) +} + +/// Write `doc` to `out`, choosing the format by extension. `strict`: fail, writing nothing, when +/// the format would leave something out. +pub fn write_doc(doc: &Document, page: NodeId, out: &str, strict: bool, io: &mut Io) -> CliResult<()> { let e = ext(out); let bytes = match e.as_str() { "figcraft" => { @@ -130,27 +161,24 @@ pub fn write_doc(doc: &Document, page: NodeId, out: &str, io: &mut Io) -> CliRes .into_bytes(), "png" | "jpg" | "jpeg" | "webp" => encode(doc, &render_page(doc, page, 1.0)?, &e)?, "pdf" => page_pdf(doc, page, &PrintSettings::default())?, - "fig" => fig_bytes(doc, io)?, - "penpot" => penpot_bytes(doc, io)?, + "fig" => fig_bytes(doc, out, strict, io)?, + "penpot" => penpot_bytes(doc, out, strict, io)?, other => return Err(CliError::Usage(format!("unknown output format `.{other}` (figcraft, json, svg, png, jpg, webp, pdf, fig, penpot)"))), }; write(out, &bytes) } -/// `doc` as a `.fig` file (experimental), printing what was left out. -fn fig_bytes(doc: &Document, io: &mut Io) -> CliResult> { +/// `doc` as a `.fig` file (experimental) for `out`, with [`notes`] on what was left out. +fn fig_bytes(doc: &Document, out: &str, strict: bool, io: &mut Io) -> CliResult> { let (bytes, warnings) = figcraft_engine::cmd::file::fig_bytes(doc).map_err(|e| CliError::Failed(e.to_string()))?; - for w in warnings { - errln!(io, "note: {w}"); - } + notes(out, warnings, strict, io)?; Ok(bytes) } -fn penpot_bytes(doc: &Document, io: &mut Io) -> CliResult> { +/// `doc` as a Penpot archive for `out`, with [`notes`] on what was left out. +fn penpot_bytes(doc: &Document, out: &str, strict: bool, io: &mut Io) -> CliResult> { let (bytes, warnings) = figcraft_engine::cmd::file::penpot_bytes(doc).map_err(|e| CliError::Failed(e.to_string()))?; - for w in warnings { - errln!(io, "note: {w}"); - } + notes(out, warnings, strict, io)?; Ok(bytes) } @@ -259,18 +287,20 @@ pub struct Target { pub print: PrintSettings, /// Android Vector Drawable (XML) only. pub vd_compat: VdCompat, + /// Fail, writing nothing, when the export would leave something out (`.fig`, `.penpot` and XML). + pub strict: bool, } pub fn export(file: &str, out: &str, t: &Target, io: &mut Io) -> CliResult { let doc = load(file, io)?; // `.fig`: the whole file. if t.format.as_deref().map_or(ext(out) == "fig", |f| f.eq_ignore_ascii_case("fig")) { - write(out, &fig_bytes(&doc, io)?)?; + write(out, &fig_bytes(&doc, out, t.strict, io)?)?; outln!(io, "{out}"); return Ok(0); } if t.format.as_deref().map_or(ext(out) == "penpot", |f| f.eq_ignore_ascii_case("penpot")) { - write(out, &penpot_bytes(&doc, io)?)?; + write(out, &penpot_bytes(&doc, out, t.strict, io)?)?; outln!(io, "{out}"); return Ok(0); } @@ -283,26 +313,26 @@ pub fn export(file: &str, out: &str, t: &Target, io: &mut Io) -> CliResult }; let target = node.map(|q| find_node(&doc, page, q)).transpose()?; let single = image_format(&ext(out)).is_some(); - let mut bytes_of = |ids: &[NodeId]| { + // The bytes and what an Android Vector Drawable changed or left out, like the .fig notes. + let bytes_of = |ids: &[NodeId]| { let setting = ExportSetting { format: fmt, print: *print, vd_compat: t.vd_compat, ..Default::default() }; - let (bytes, warnings) = figcraft_engine::cmd::file::export_file(&doc, ids, &setting, scale).map_err(|e| CliError::Failed(e.to_string()))?; - // What an Android Vector Drawable changed or left out, like the .fig notes. - for w in warnings { - errln!(io, "note: {w}"); - } - Ok::<_, CliError>(bytes) + figcraft_engine::cmd::file::export_file(&doc, ids, &setting, scale).map_err(|e| CliError::Failed(e.to_string())) }; if single { - let bytes = match target { + let (bytes, warnings) = match target { Some(t) => bytes_of(&[t])?, - None if fmt == ExportFormat::Pdf => page_pdf(&doc, page, print)?, + None if fmt == ExportFormat::Pdf => (page_pdf(&doc, page, print)?, Vec::new()), None => bytes_of(&children(&doc, page))?, }; + notes(out, warnings, t.strict, io)?; write(out, &bytes)?; outln!(io, "{out}"); return Ok(0); } - figcraft_engine::file_access::create_dir_all(out).map_err(|e| CliError::Failed(e.to_string()))?; + // `--strict` writes the folder only once every file in it is known to leave nothing out. + if !t.strict { + figcraft_engine::file_access::create_dir_all(out).map_err(|e| CliError::Failed(e.to_string()))?; + } let ids = match target { Some(t) => vec![t], None => { @@ -314,6 +344,7 @@ pub fn export(file: &str, out: &str, t: &Target, io: &mut Io) -> CliResult if ids.is_empty() { return Err(CliError::Failed("the page is empty: nothing to export".into())); } + let (mut pending, mut left_out) = (Vec::new(), Vec::new()); let mut used = std::collections::BTreeSet::new(); let mut next_suffix: std::collections::HashMap = std::collections::HashMap::new(); for id in ids { @@ -329,9 +360,28 @@ pub fn export(file: &str, out: &str, t: &Target, io: &mut Io) -> CliResult } }; let path = Path::new(out).join(format!("{name}.{}", fmt.ext())).to_string_lossy().into_owned(); - write(&path, &bytes_of(&[id])?)?; + let (bytes, warnings) = bytes_of(&[id])?; + if t.strict { + for w in warnings { + if !left_out.contains(&w) { + left_out.push(w); + } + } + pending.push((path, bytes)); + continue; + } + notes(&path, warnings, false, io)?; + write(&path, &bytes)?; outln!(io, "{path}"); } + if t.strict { + notes(out, left_out, true, io)?; + figcraft_engine::file_access::create_dir_all(out).map_err(|e| CliError::Failed(e.to_string()))?; + for (path, bytes) in pending { + write(&path, &bytes)?; + outln!(io, "{path}"); + } + } Ok(0) } @@ -354,7 +404,7 @@ fn refuse_dropping_images_from_script(input: Option<(&str, usize)>, active: &fig Ok(()) } -pub fn convert(input: &str, out: &str, io: &mut Io) -> CliResult { +pub fn convert(input: &str, out: &str, strict: bool, io: &mut Io) -> CliResult { let (loaded, _) = figcraft_engine::cmd::file::load_path(input, None).map_err(|e| CliError::Failed(format!("can't open {input}: {e}")))?; refuse_dropping_images(input, out, loaded.images_past_budget)?; if ext(input) == "penpot" { @@ -368,7 +418,7 @@ pub fn convert(input: &str, out: &str, io: &mut Io) -> CliResult { .filter(|p| doc.pages.contains(p)) .or_else(|| doc.first_page()) .ok_or_else(|| CliError::Failed("the document has no pages".into()))?; - write_doc(&doc, page, out, io)?; + write_doc(&doc, page, out, strict, io)?; outln!(io, "{out}"); Ok(0) } @@ -423,7 +473,7 @@ pub fn parse_script(text: &str) -> Result, String> { /// file is refused before it is read (#1114). pub const MAX_SCRIPT: u64 = 1 << 30; -pub fn run_script(script: &str, input: Option<&str>, out: Option<&str>, io: &mut Io) -> CliResult { +pub fn run_script(script: &str, input: Option<&str>, out: Option<&str>, strict: bool, io: &mut Io) -> CliResult { let bytes = figcraft_engine::file_access::read_capped(script, MAX_SCRIPT).map_err(|e| CliError::Failed(e.to_string()))?; let text = String::from_utf8(bytes).map_err(|_| CliError::Failed(format!("{script}: not UTF-8")))?; let steps = parse_script(&text).map_err(|e| CliError::Failed(format!("{script}: {e}")))?; @@ -470,7 +520,7 @@ pub fn run_script(script: &str, input: Option<&str>, out: Option<&str>, io: &mut // Through the engine, so the version history is kept. write(out, &figcraft_engine::cmd::file::file_bytes_at(ds, out).map_err(|e| CliError::Failed(e.to_string()))?)?; } else { - write_doc(&ds.doc, ds.page, out, io)?; + write_doc(&ds.doc, ds.page, out, strict, io)?; } errln!(io, "wrote {out}"); } @@ -525,7 +575,7 @@ mod tests { std::fs::write(&svg, r#""#).unwrap(); std::fs::write(&script, r#"[{"command":"no.such\u001b"}]"#).unwrap(); assert_eq!(info(svg.to_str().unwrap(), false, io!()).unwrap(), 0); - assert_eq!(run_script(script.to_str().unwrap(), None, None, io!()).unwrap(), 1); + assert_eq!(run_script(script.to_str().unwrap(), None, None, false, io!()).unwrap(), 1); let _ = std::fs::remove_dir_all(&dir); } @@ -610,7 +660,7 @@ mod tests { for ext in ["svg", "pdf"] { let path = dir.join(format!("previous.{ext}")); std::fs::write(&path, b"previous export").unwrap(); - let CliError::Failed(error) = write_doc(&doc, page, path.to_str().unwrap(), io!()).unwrap_err() else { + let CliError::Failed(error) = write_doc(&doc, page, path.to_str().unwrap(), false, io!()).unwrap_err() else { panic!("depth overflow must be an operation failure"); }; assert!(error.contains("maximum export depth of 256"), "{ext}: {error}"); @@ -637,7 +687,7 @@ mod tests { bad.push("/dev/zero".into()); } for path in bad { - let Err(CliError::Failed(e)) = run_script(&path, None, None, io!()) else { panic!("{path} ran") }; + let Err(CliError::Failed(e)) = run_script(&path, None, None, false, io!()) else { panic!("{path} ran") }; assert!(e.contains("is a folder, not a file") || e.contains("isn't a regular file"), "{path}: {e}"); } std::fs::remove_dir_all(dir).unwrap(); @@ -695,7 +745,7 @@ mod tests { ) .unwrap(); let out = dir.join("out.figcraft"); - assert_eq!(run_script(script.to_str().unwrap(), None, Some(out.to_str().unwrap()), io!()).unwrap(), 0); + assert_eq!(run_script(script.to_str().unwrap(), None, Some(out.to_str().unwrap()), false, io!()).unwrap(), 0); let mut s = Session::empty(); s.execute("file.open", &json!({"path": out.to_str().unwrap()})).unwrap(); @@ -725,7 +775,7 @@ mod tests { ) .unwrap(); let out = dir.join("out.figcraft"); - assert_eq!(run_script(script.to_str().unwrap(), None, Some(out.to_str().unwrap()), io!()).unwrap(), 0); + assert_eq!(run_script(script.to_str().unwrap(), None, Some(out.to_str().unwrap()), false, io!()).unwrap(), 0); let mut s = Session::empty(); s.execute("file.open", &json!({"path": out.to_str().unwrap()})).unwrap(); @@ -742,7 +792,7 @@ mod tests { let dir = temp_dir("run-dup-name"); let script = dir.join("script.json"); std::fs::write(&script, r#"[{"command": "select.none", "as": "a"}, {"command": "select.none", "as": "a"}]"#).unwrap(); - let Err(CliError::Failed(e)) = run_script(script.to_str().unwrap(), None, None, io!()) else { panic!("a name twice must fail") }; + let Err(CliError::Failed(e)) = run_script(script.to_str().unwrap(), None, None, false, io!()) else { panic!("a name twice must fail") }; assert!(e.contains("step 1: `as` \"a\" is already step 0's name"), "{e}"); std::fs::remove_dir_all(dir).unwrap(); } @@ -762,7 +812,7 @@ mod tests { .unwrap(); let out = dir.join("out.figcraft"); // The failure is the script's, not the call's: the CLI reports it and exits non-zero. - assert_eq!(run_script(script.to_str().unwrap(), None, Some(out.to_str().unwrap()), io!()).unwrap(), 1); + assert_eq!(run_script(script.to_str().unwrap(), None, Some(out.to_str().unwrap()), false, io!()).unwrap(), 1); assert!(!out.exists(), "a script that failed writes nothing"); std::fs::remove_dir_all(dir).unwrap(); } diff --git a/apps/figcraft-cli/src/lib.rs b/apps/figcraft-cli/src/lib.rs index c555c6cac..04d7a7adf 100644 --- a/apps/figcraft-cli/src/lib.rs +++ b/apps/figcraft-cli/src/lib.rs @@ -26,12 +26,13 @@ macro_rules! errln { mod args; mod files; +mod live; mod perf; use std::ffi::OsString; use std::io::Write; -use args::{Cli, Command, ConnectCommand, PluginCommand, RootArgs}; +use args::{Cli, Command, ConnectCommand, McpArgs, PluginCommand, RootArgs}; use serde_json::{Value, json}; /// The automation roots a file subcommand was given, if any. Omitting both leaves the run @@ -76,6 +77,13 @@ pub type CliResult = Result; fn dispatch(cli: Cli, io: &mut Io) -> CliResult { check(&cli.command)?; + // Headless MCP is always confined (AGENTS.md: agent entry points refuse to start without both + // roots, unless the ArtCraft Launcher's switch lets agents in, which gives them the agent + // folders); checked before the fonts are scanned, so a usage error comes back at once. + let mcp_plan = match &cli.command { + Command::Mcp(a) => Some(mcp_plan(a, &live::launcher_allows)?), + _ => None, + }; if !cli.no_system_fonts { // Text lays out with the installed fonts, like the desktop app, so headless renders and // auto layout sizes match what users see. @@ -87,19 +95,26 @@ fn dispatch(cli: Cli, io: &mut Io) -> CliResult { match cli.command { Command::Info(a) => confined(&a.roots, || files::info(&a.file, a.json, io)), Command::Export(a) => { - let target = - files::Target { print: a.print(), vd_compat: a.vd_compat, scale: a.scale.scale, format: a.format, page: a.page, node: a.node }; + let target = files::Target { + print: a.print(), + vd_compat: a.vd_compat, + scale: a.scale.scale, + format: a.format, + page: a.page, + node: a.node, + strict: a.strict, + }; confined(&a.roots, || files::export(&a.file, &a.out, &target, io)) } - Command::Convert(a) => confined(&a.roots, || files::convert(&a.input, &a.output, io)), + Command::Convert(a) => confined(&a.roots, || files::convert(&a.input, &a.output, a.strict, io)), Command::Render(a) => confined(&a.roots, || files::render(&a.file, &a.out, a.scale.scale, a.page.as_deref(), io)), - Command::Run(a) => confined(&a.roots, || files::run_script(&a.script, a.input.as_deref(), a.out.as_deref(), io)), + Command::Run(a) => confined(&a.roots, || files::run_script(&a.script, a.input.as_deref(), a.out.as_deref(), a.strict, io)), Command::Commands(a) => { commands(a.json, a.filter.as_deref(), io); Ok(0) } // `--attach` conflicts with the roots: the app runs the commands, only its own roots can confine them. - Command::Mcp(a) => mcp(a.attach.as_deref(), a.timeout, roots_of(&a.roots)?, io), + Command::Mcp(_) => mcp(mcp_plan.ok_or_else(|| CliError::Failed("no MCP plan".into()))?, io), Command::Plugin { command: PluginCommand::Publish(a) } => publish_plugin(&a.folder, &a.server, a.key.as_deref(), io), Command::Connect { command: ConnectCommand::Publish(a) } => { confined(&a.roots, || files::connect_publish(&a.file, &a.mappings, a.dry_run, io)) @@ -157,17 +172,60 @@ fn publish_plugin(folder: &str, server: &str, key: Option<&str>, io: &mut Io) -> Ok(0) } -fn mcp(attach: Option<&str>, timeout: Option, roots: Option, io: &mut Io) -> CliResult { - let backend: Box = match attach { - Some(addr) => { - let no_app = |e: std::io::Error| format!("can't reach the FigCraft app at {addr}: {e} (start it with `figcraft --control PORT`)"); - let b = figcraft_mcp::Attached::connect(addr).map_err(no_app)?; - match timeout { - Some(secs) => Box::new(b.with_timeout(std::time::Duration::from_secs(secs)).map_err(no_app)?), - None => Box::new(b), - } +/// How `figcraft-cli mcp` serves. +enum McpPlan { + /// `--attach ADDR`: the app started with `--control`, its token read from the file it wrote. + Attach { addr: String, timeout: Option }, + /// No window: `--headless`, or the ArtCraft Launcher's switch doesn't let agents use FigCraft. + Headless(figcraft_engine::file_access::Roots), + /// The open window while the launcher's switch lets agents in, otherwise headless (#2740). + Live(live::Options), +} + +/// What `a` asks for. `allowed` reads the launcher's switch; it is asked only when it decides +/// (no `--attach`, no `--headless`). +fn mcp_plan(a: &McpArgs, allowed: &dyn Fn() -> bool) -> CliResult { + let timeout = a.timeout.map(std::time::Duration::from_secs); + if let Some(addr) = &a.attach { + return Ok(McpPlan::Attach { addr: addr.clone(), timeout }); + } + let config_dir = live::settings_dir(); + match config_dir { + Some(config_dir) if !a.headless && allowed() => { + let servers = allowed_servers(&a.automation_allow_servers)?; + let path = |d: &String| std::path::PathBuf::from(d); + let launch = std::env::current_exe().ok().and_then(|cli| craft_control::agents::launcher(&cli, "figcraft")); + Ok(McpPlan::Live(live::Options { + config_dir, + read_roots: a.roots.automation_read_root.iter().map(path).collect(), + write_roots: a.roots.automation_write_root.iter().map(path).collect(), + servers, + timeout, + launch, + consent: Box::new(live::launcher_allows), + })) } - None => Box::new(figcraft_mcp::Headless::new()), + _ => Ok(McpPlan::Headless(mcp_roots(&a.roots, &a.automation_allow_servers)?)), + } +} + +fn mcp(plan: McpPlan, io: &mut Io) -> CliResult { + let (backend, roots): (Box, _) = match plan { + McpPlan::Attach { addr, timeout } => { + let no_app = |e: std::io::Error| format!("can't reach the FigCraft app at {addr}: {e} (start it with `figcraft --control PORT`)"); + let mut b = figcraft_mcp::Attached::connect(&addr).map_err(no_app)?; + if let Some(token) = attach_token(&addr, &live::control_app()) { + b = b.with_token(token); + } + let b = match timeout { + Some(t) => b.with_timeout(t).map_err(no_app)?, + None => b, + }; + (Box::new(b), None) + } + McpPlan::Headless(roots) => (Box::new(figcraft_mcp::Headless::new()), Some(roots)), + // Each route confines itself: the window by the app's own roots, a headless session by its folders. + McpPlan::Live(options) => (Box::new(live::LiveBackend::new(options)), None), }; errln!(io, "figcraft MCP server ({}) on stdio", backend.describe()); if let Some(r) = &roots { @@ -180,6 +238,45 @@ fn mcp(attach: Option<&str>, timeout: Option, roots: Option Option { + let (host, port) = addr.rsplit_once(':')?; + let port = port.parse::().ok()?; + let host = host.trim_start_matches('[').trim_end_matches(']'); + let loopback = host.eq_ignore_ascii_case("localhost") || host.parse::().is_ok_and(|ip| ip.is_loopback()); + if loopback { app.client_token(port, None).map(|t| t.token) } else { app.env_token() } +} + +/// The roots a headless MCP session is confined to: both kinds are required, and the servers in +/// `allowed_servers` (ws:// or wss:// addresses without a query or key) are the only ones +/// `collab.join` may reach. +fn mcp_roots(roots: &RootArgs, allowed_servers: &[String]) -> CliResult { + if roots.automation_read_root.is_empty() || roots.automation_write_root.is_empty() { + return Err(CliError::Usage("headless mcp requires both --automation-read-root and --automation-write-root".into())); + } + let roots = figcraft_engine::file_access::Roots::new(&roots.automation_read_root, &roots.automation_write_root).map_err(CliError::Failed)?; + Ok(roots.with_allowed_servers(self::allowed_servers(allowed_servers)?)) +} + +/// `--automation-allow-server`: ws:// or wss:// server URLs without a query or key. +fn allowed_servers(allowed_servers: &[String]) -> CliResult> { + let mut servers = Vec::with_capacity(allowed_servers.len()); + for server in allowed_servers { + if server.contains('?') { + return Err(CliError::Usage("--automation-allow-server must not contain a query or key".into())); + } + let (endpoint, query) = figcraft_collab_net::Endpoint::parse(server) + .map_err(|_| CliError::Usage("--automation-allow-server must be a ws:// or wss:// server URL".into()))?; + if !query.is_empty() { + return Err(CliError::Usage("--automation-allow-server must not contain a query or key".into())); + } + servers.push(endpoint.url()); + } + Ok(servers) +} + /// What the arguments can't say alone: an output that would replace its input needs `--in-place`. fn check(command: &Command) -> CliResult<()> { let refuse = |flag: &str, path: &str, input: &str, allowed: bool| -> CliResult<()> { @@ -191,6 +288,25 @@ fn check(command: &Command) -> CliResult<()> { } Err(CliError::Usage(format!("{flag} {path} is the input, which it would replace: choose another file, or pass --in-place"))) }; + // `--strict` holds a writer to what it reports, so it is refused where nothing would be checked. + let unchecked = |what: &str, formats: &str| { + Err(CliError::Usage(format!("--strict checks {formats}, the formats that report what they leave out; {what} isn't one of them"))) + }; + match command { + Command::Export(a) if a.strict && !files::export_reports_losses(a.format.as_deref(), &a.out) => { + return unchecked(&format!("--out {}", a.out), "fig, penpot and xml exports"); + } + Command::Export(a) if a.strict && a.vd_compat == figcraft_doc::VdCompat::Ignore && files::export_writes_xml(a.format.as_deref(), &a.out) => { + return Err(CliError::Usage("--strict can't check --vd-compat ignore, which drops what it can't draw without saying so".into())); + } + Command::Convert(a) if a.strict && !files::save_reports_losses(&a.output) => { + return unchecked(&format!("OUT {}", a.output), ".fig, .penpot and .figcraft output"); + } + Command::Run(a) if a.strict && !a.out.as_deref().is_some_and(files::save_reports_losses) => { + return unchecked(&format!("--out {}", a.out.as_deref().unwrap_or("")), ".fig, .penpot and .figcraft output"); + } + _ => {} + } match command { Command::Convert(a) => refuse("OUT", &a.output, &a.input, a.in_place)?, Command::Run(a) => { @@ -255,3 +371,82 @@ where } } } + +#[cfg(test)] +mod mcp_roots_tests { + use super::{CliError, McpPlan, attach_token, mcp_plan, mcp_roots}; + use crate::args::{McpArgs, RootArgs}; + + fn args(attach: Option<&str>, headless: bool, read: &[&str], write: &[&str]) -> McpArgs { + let own = |d: &[&str]| d.iter().map(|s| s.to_string()).collect(); + McpArgs { + attach: attach.map(str::to_string), + headless, + timeout: None, + automation_allow_servers: Vec::new(), + roots: RootArgs { automation_read_root: own(read), automation_write_root: own(write) }, + } + } + + // #2740: plain `mcp` with the ArtCraft Launcher's switch on needs no roots (the agent folders + // stand in); with it off, or with --headless, both roots are still required (rule 18). + #[test] + fn plain_mcp_without_roots_runs_only_while_the_launcher_lets_agents_in() { + let on = || true; + let off = || false; + let never = || -> bool { panic!("the switch decides nothing here") }; + assert!(matches!(mcp_plan(&args(None, false, &[], &[]), &off), Err(CliError::Usage(_)))); + assert!(matches!(mcp_plan(&args(None, true, &[], &[]), &never), Err(CliError::Usage(_))), "--headless needs both roots"); + assert!(matches!(mcp_plan(&args(Some("127.0.0.1:7979"), false, &[], &[]), &never), Ok(McpPlan::Attach { .. }))); + // Needs a settings folder to find the app in; every test machine has a platform folder. + let Ok(McpPlan::Live(live)) = mcp_plan(&args(None, false, &["in"], &["out", "more"]), &on) else { panic!("live") }; + assert_eq!(live.read_roots, [std::path::PathBuf::from("in")]); + assert_eq!(live.write_roots, [std::path::PathBuf::from("out"), std::path::PathBuf::from("more")], "every write root is kept"); + assert!(matches!(mcp_plan(&args(None, false, &[], &[]), &on), Ok(McpPlan::Live(_)))); + } + + fn token_folder() -> Option { + Some(std::env::temp_dir().join(format!("figcraft-cli-attach-token-{}", std::process::id()))) + } + + // This machine's token file goes only to this machine's app, never to another host on the same + // port. + #[test] + fn attach_sends_the_local_token_only_to_loopback() { + let app = craft_control::auth::App { name: "FigCraft", data_dir: token_folder, env: |_| None, utc: |s| s.to_string(), default_port: 7979 }; + let file = app.token_path(7979).unwrap(); + std::fs::create_dir_all(file.parent().unwrap()).unwrap(); + std::fs::write(&file, "local-token\n").unwrap(); + for local in ["127.0.0.1:7979", "localhost:7979", "[::1]:7979"] { + assert_eq!(attach_token(local, &app).as_deref(), Some("local-token"), "{local}"); + } + for remote in ["192.168.0.2:7979", "example.com:7979", "[2001:db8::1]:7979"] { + assert_eq!(attach_token(remote, &app), None, "{remote}"); + } + let _ = std::fs::remove_dir_all(token_folder().unwrap()); + } + + #[test] + fn headless_mcp_requires_both_roots_and_allowlist_cannot_carry_a_key() { + let server = "wss://figcraft.example.com/".to_string(); + let no_roots = RootArgs { automation_read_root: Vec::new(), automation_write_root: Vec::new() }; + assert!(matches!(mcp_roots(&no_roots, &[]), Err(CliError::Usage(_)))); + assert!(matches!(mcp_roots(&no_roots, std::slice::from_ref(&server)), Err(CliError::Usage(_)))); + + let path = std::env::temp_dir().join(format!("figcraft-cli-roots-{}", std::process::id())); + std::fs::create_dir_all(&path).unwrap(); + let root = path.to_string_lossy().into_owned(); + let read_only = RootArgs { automation_read_root: vec![root.clone()], automation_write_root: Vec::new() }; + assert!(matches!(mcp_roots(&read_only, &[]), Err(CliError::Usage(_)))); + let roots = RootArgs { automation_read_root: Vec::new(), automation_write_root: vec![path.to_string_lossy().into_owned()] }; + assert!(matches!(mcp_roots(&roots, &[]), Err(CliError::Usage(_)))); + + let roots = RootArgs { automation_read_root: vec![root.clone()], automation_write_root: vec![root] }; + let allowed = mcp_roots(&roots, &[server]).unwrap(); + assert_eq!(allowed.allowed_servers(), ["wss://figcraft.example.com:443/"]); + + let with_key = "wss://figcraft.example.com/?key=secret".to_string(); + assert!(matches!(mcp_roots(&roots, &[with_key]), Err(CliError::Usage(message)) if !message.contains("secret"))); + let _ = std::fs::remove_dir_all(path); + } +} diff --git a/apps/figcraft-cli/src/live.rs b/apps/figcraft-cli/src/live.rs new file mode 100644 index 000000000..fed68528b --- /dev/null +++ b/apps/figcraft-cli/src/live.rs @@ -0,0 +1,188 @@ +//! `figcraft-cli mcp` with the ArtCraft Launcher's agents switch on (#2740): each tool call goes to +//! the open FigCraft window, found through the connection file it publishes, and otherwise to a +//! session without a window ([`craft_control::agents::Live`] decides, before every call). The MCP +//! client's configuration holds no port and no token, and the app may start, quit or move to +//! another port while the client stays connected. A session without a window is confined to the +//! folders given to the command, or, while the switch lets agents in, the agent folders +//! (`Documents/ArtCraft/Agents/FigCraft` unless the person picked their own). + +use std::ffi::OsString; +use std::path::{Path, PathBuf}; +use std::sync::{Arc, Mutex, PoisonError}; + +use craft_control::agents::{self, AgentSettings, Consent, HeadlessFolders, Live, LiveConfig, Route, Window}; +use craft_control::auth; +use figcraft_engine::file_access::{Roots, confined}; +use figcraft_mcp::{Attached, Backend, Headless}; +use serde_json::Value; + +/// FigCraft's id in the ArtCraft Launcher's app list. +pub const LAUNCHER_APP_ID: &str = "figcraft"; +/// The app's name in messages and its agent folder's name. +const APP_NAME: &str = "FigCraft"; +/// The settings folder's name in the platform folder, as the app has it (`services::APP_ID`). +const SETTINGS_ID: &str = "FigCraft"; + +/// The stable app's settings folder, resolved as the app does (`apps/figcraft/src/services.rs`): +/// `FIGCRAFT_CONFIG_DIR`, a `portable` marker beside the executable, else `FigCraft` in the +/// platform folder. A Nightly keeps its own profile and never accepts agents. +pub fn settings_dir() -> Option { + use craft_settings::{Location, Portable, Rule}; + let probe = craft_settings::Probe { platform_config_dir: platform_dir(), ..Default::default() }; + let resolved = craft_settings::paths::resolve(SETTINGS_ID, &Portable::DEFAULT, &Location::Auto, &probe); + if resolved.rule == Rule::Fallback { + return None; + } + resolved.dir +} + +/// The platform's config folder, read from the environment as the app reads it. +fn platform_dir() -> Option { + #[cfg(target_os = "macos")] + let base = std::env::var_os("HOME").map(|h| PathBuf::from(h).join("Library/Application Support")); + #[cfg(target_os = "windows")] + let base = std::env::var_os("APPDATA").map(PathBuf::from); + #[cfg(all(unix, not(target_os = "macos")))] + let base = std::env::var_os("XDG_CONFIG_HOME").map(PathBuf::from).or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".config"))); + base +} + +/// The app's token files, as the app describes them (`apps/figcraft/src/agents.rs`), for +/// `mcp --attach PORT`. +pub fn control_app() -> auth::App { + auth::App { name: APP_NAME, data_dir: settings_dir, env, utc, default_port: 7979 } +} + +fn env(name: &str) -> Option { + std::env::var_os(format!("FIGCRAFT_{name}")) +} + +fn utc(secs: u64) -> String { + format!("{secs} s after 1970") +} + +/// Whether the launcher's switch lets agents use FigCraft now. FigCraft has no consent of its own +/// from before the switch. +pub fn launcher_allows() -> bool { + agents::agents_allowed(agents::mcp_flag(), agents::launcher_allows(LAUNCHER_APP_ID), false) +} + +type WindowRoute = Arc>; + +/// A session without a window and the folders it is confined to. +#[derive(Clone)] +pub struct Session(Arc>, Arc); + +/// The folders a session without a window may use: `folders`, with the collaboration servers +/// `servers` allowed. The shared client knows one write folder; when it is the command's first +/// write root, the command's other write roots (`more_write`) count too. The default agent folder +/// is made when it is missing. +fn session(folders: &HeadlessFolders, more_write: &[PathBuf], servers: &[String], default_folder: Option<&Path>) -> Result { + if let Some(default) = default_folder + && (folders.write.as_deref() == Some(default) || folders.read.iter().any(|f| f == default)) + { + std::fs::create_dir_all(default).map_err(|e| format!("can't make the agent folder {}: {e}", default.display()))?; + } + let text = |p: &PathBuf| p.display().to_string(); + let read: Vec = folders.read.iter().map(text).collect(); + let commands = folders.write.is_some() && folders.write.as_ref() == more_write.first(); + let write: Vec = if commands { more_write.iter().map(text).collect() } else { folders.write.iter().map(text).collect() }; + let roots = Roots::new(&read, &write)?.with_allowed_servers(servers.to_vec()); + Ok(Session(Arc::new(Mutex::new(Headless::new())), Arc::new(roots))) +} + +/// What `figcraft-cli mcp` was given. +pub struct Options { + /// The app's settings folder, where its connection file is. + pub config_dir: PathBuf, + /// `--automation-read-root`. + pub read_roots: Vec, + /// `--automation-write-root`. + pub write_roots: Vec, + /// `--automation-allow-server`, checked. + pub servers: Vec, + /// How long the window may take over each request. + pub timeout: Option, + /// Starts the app when a call finds it closed; `None` where this install can't. + pub launch: Option, + /// What the person allows, read before every call. + pub consent: Box bool + Send + Sync>, +} + +/// The MCP backend that routes each call ([`Options`]). +pub struct LiveBackend { + live: Live, +} + +impl LiveBackend { + pub fn new(o: Options) -> Self { + let Options { config_dir, read_roots, write_roots, servers, timeout, launch, consent } = o; + let write_root = write_roots.first().cloned(); + let default_folder = agents::default_folder(APP_NAME); + let headless_default = default_folder.clone(); + let mut cfg = LiveConfig::new( + APP_NAME, + config_dir, + move |_: &Path| Consent::new(consent(), AgentSettings::default()), + move |w: &Window| { + let a = Attached::connect(&w.addr()) + .map_err(|e| format!("can't reach the FigCraft window at {}: {e}", w.addr()))? + .with_token(w.token.clone()); + let a = match timeout { + Some(t) => a.with_timeout(t).map_err(|e| format!("can't reach the FigCraft window at {}: {e}", w.addr()))?, + None => a, + }; + Ok(Arc::new(Mutex::new(a))) + }, + move |folders: &HeadlessFolders| session(folders, &write_roots, &servers, headless_default.as_deref()), + ); + cfg.read_roots = read_roots; + cfg.write_root = write_root; + cfg.default_folder = default_folder; + cfg.launch = launch; + Self { live: Live::new(cfg) } + } + + /// Run `window` or `headless` on the route the next call takes. + fn route( + &self, + window: impl FnOnce(&mut Attached) -> Result, + headless: impl FnOnce(&mut Headless) -> Result, + ) -> Result { + match self.live.resolve()? { + Route::Window(w) => window(&mut w.lock().unwrap_or_else(PoisonError::into_inner)), + Route::Headless(Session(h, roots)) => confined(Some(&roots), || headless(&mut h.lock().unwrap_or_else(PoisonError::into_inner))), + } + } +} + +impl Backend for LiveBackend { + fn call(&mut self, method: &str, params: Value) -> Result { + let p = params.clone(); + self.route(|w| w.call(method, params), |h| h.call(method, p)) + } + + fn has_ui(&self) -> bool { + matches!(self.live.current(), Some(Route::Window(_))) + } + + fn describe(&self) -> String { + "the open FigCraft window while the ArtCraft Launcher lets agents use it, otherwise headless".into() + } + + fn render_png(&mut self, ids: &[u64], scale: f64) -> Result, String> { + self.route(|w| w.render_png(ids, scale), |h| h.render_png(ids, scale)) + } + + fn screenshot_png(&mut self) -> Result, String> { + self.route(Backend::screenshot_png, Backend::screenshot_png) + } + + fn window_png(&mut self, window: u64) -> Result, String> { + self.route(|w| w.window_png(window), |h| h.window_png(window)) + } +} + +#[cfg(test)] +#[path = "live_tests.rs"] +mod tests; diff --git a/apps/figcraft-cli/src/live_tests.rs b/apps/figcraft-cli/src/live_tests.rs new file mode 100644 index 000000000..e76f7d224 --- /dev/null +++ b/apps/figcraft-cli/src/live_tests.rs @@ -0,0 +1,153 @@ +#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] + +use super::*; +use std::io::{BufRead, BufReader, Write}; +use std::net::{TcpListener, TcpStream}; + +use craft_control::agents::Connection; +use serde_json::json; + +fn folder(name: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!("figcraft-cli-live-{name}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + dir +} + +/// A FigCraft window that takes connections whose first request carries `token`, answers every +/// request with `{"from": "window", "method": …}`, and refuses others as the app does. +fn fake_window(token: &'static str) -> u16 { + let listener = TcpListener::bind(("127.0.0.1", 0)).unwrap(); + let port = listener.local_addr().unwrap().port(); + std::thread::spawn(move || { + for stream in listener.incoming().flatten() { + std::thread::spawn(move || serve(stream, token)); + } + }); + port +} + +fn serve(stream: TcpStream, token: &str) { + let mut out = stream.try_clone().unwrap(); + let mut shown = false; + for line in BufReader::new(stream).lines().map_while(Result::ok) { + let v: Value = serde_json::from_str(&line).unwrap(); + if !shown && v["token"].as_str() != Some(token) { + let _ = writeln!(out, "{}", json!({"id": v["id"], "ok": false, "error": "this FigCraft control channel needs its token"})); + return; + } + shown = true; + let _ = writeln!(out, "{}", json!({"id": v["id"], "ok": true, "result": {"from": "window", "method": v["method"]}})); + } +} + +/// Publish a window on `port` in `dir` as the app does, its token file holding `token`. +fn publish(dir: &Path, port: u16, token: &str) { + let file = dir.join(agents::TOKEN_FILE); + std::fs::write(&file, format!("{token}\n")).unwrap(); + // Owner-only like the app's own token file: the client refuses one others can read (Unix). + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + std::fs::set_permissions(&file, std::fs::Permissions::from_mode(0o600)).unwrap(); + } + agents::write_connection(dir, &Connection::new(port, file, "FigCraft")).unwrap(); +} + +fn options(dir: &Path, allowed: bool) -> Options { + Options { + config_dir: dir.to_path_buf(), + read_roots: vec![dir.to_path_buf()], + write_roots: vec![dir.to_path_buf()], + servers: Vec::new(), + timeout: None, + launch: None, + consent: Box::new(move || allowed), + } +} + +// With the launcher's switch on and the app accepting agents, a call goes to the open window, with +// the token from the app's token file. +#[test] +fn a_call_goes_to_the_open_window_with_its_token() { + let dir = folder("window"); + publish(&dir, fake_window("the-token"), "the-token"); + let mut backend = LiveBackend::new(options(&dir, true)); + assert!(!backend.has_ui(), "nothing resolved yet"); + let reply = backend.call("document.inspect", json!({})).unwrap(); + assert_eq!(reply, json!({"from": "window", "method": "document.inspect"})); + assert!(backend.has_ui()); + let _ = std::fs::remove_dir_all(&dir); +} + +// A token file that holds another token: the window refuses, and the call says why. +#[test] +fn a_window_that_refuses_the_token_fails_the_call() { + let dir = folder("wrong-token"); + publish(&dir, fake_window("the-token"), "stale-token"); + let mut backend = LiveBackend::new(options(&dir, true)); + let error = backend.call("document.inspect", json!({})).unwrap_err(); + assert!(error.contains("needs its token"), "the window's own refusal: {error}"); + let _ = std::fs::remove_dir_all(&dir); +} + +// The launcher's switch off: the app publishes no window (it removes its file then), and the call +// runs headless in the folders given to the command. +#[test] +fn with_the_switch_off_a_call_runs_without_a_window() { + let dir = folder("off"); + let mut backend = LiveBackend::new(options(&dir, false)); + let reply = backend.call("engine.commands", json!({})).unwrap(); + assert_ne!(reply.get("from"), Some(&json!("window")), "{reply}"); + assert!(!backend.has_ui()); + let _ = std::fs::remove_dir_all(&dir); +} + +// Every write root given to the command counts, not only the first the shared client knows. +#[test] +fn a_headless_session_keeps_every_write_root() { + let dir = folder("roots"); + let (one, two) = (dir.join("one"), dir.join("two")); + std::fs::create_dir_all(&one).unwrap(); + std::fs::create_dir_all(&two).unwrap(); + let mut o = options(&dir, false); + o.write_roots = vec![one.clone(), two.clone()]; + let mut backend = LiveBackend::new(o); + for folder in [&one, &two] { + let path = folder.join("x.figcraft"); + backend.call("engine.execute", json!({"command": "file.saveAs", "params": {"path": path.display().to_string()}})).unwrap(); + assert!(path.exists(), "{}", path.display()); + } + let _ = std::fs::remove_dir_all(&dir); +} + +// A headless session is confined to its folders: a file outside them is refused. +#[test] +fn a_headless_session_is_confined_to_its_folders() { + let dir = folder("confined"); + let outside = folder("confined-outside"); + let mut backend = LiveBackend::new(options(&dir, false)); + let path = outside.join("x.figcraft"); + let error = backend.call("engine.execute", json!({"command": "file.saveAs", "params": {"path": path.display().to_string()}})).unwrap_err(); + assert!(error.contains("automation path rejected"), "{error}"); + assert!(!path.exists(), "nothing written outside the folders"); + let inside = dir.join("x.figcraft"); + backend.call("engine.execute", json!({"command": "file.saveAs", "params": {"path": inside.display().to_string()}})).unwrap(); + assert!(inside.exists(), "saved inside the folders"); + let _ = std::fs::remove_dir_all(&dir); + let _ = std::fs::remove_dir_all(&outside); +} + +// #2740: a connection file a crashed app left behind (nothing listens on its port any more) is not +// used: the call doesn't go there, and runs without a window in the command's folders. +#[test] +fn a_stale_connection_file_is_not_used() { + let dir = folder("stale"); + let gone = TcpListener::bind(("127.0.0.1", 0)).unwrap().local_addr().unwrap().port(); + publish(&dir, gone, "the-token"); + let mut backend = LiveBackend::new(options(&dir, false)); + let reply = backend.call("engine.commands", json!({})).unwrap(); + assert_ne!(reply.get("from"), Some(&json!("window")), "{reply}"); + assert!(!backend.has_ui(), "no window behind a stale file"); + let _ = std::fs::remove_dir_all(&dir); +} diff --git a/apps/figcraft-cli/tests/it/cli.rs b/apps/figcraft-cli/tests/it/cli.rs index efc1f0e29..327dc1a3d 100644 --- a/apps/figcraft-cli/tests/it/cli.rs +++ b/apps/figcraft-cli/tests/it/cli.rs @@ -4,7 +4,10 @@ use std::io::Write; use std::process::{Command, Stdio}; fn bin() -> Command { - Command::new(env!("CARGO_BIN_EXE_figcraft-cli")) + let mut command = Command::new(env!("CARGO_BIN_EXE_figcraft-cli")); + // The ArtCraft Launcher's agents switch on this machine must not change what `mcp` does here. + command.env("CRAFT_FLAGS", "-AI-MCP"); + command } fn tmp(name: &str) -> std::path::PathBuf { @@ -244,7 +247,18 @@ fn run_takes_the_documented_gradient_shorthand() { #[test] fn mcp_over_stdio() { - let mut child = bin().arg("mcp").stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::null()).spawn().unwrap(); + let d = tmp("mcp-over-stdio"); + let mut child = bin() + .arg("mcp") + .arg("--automation-read-root") + .arg(&d) + .arg("--automation-write-root") + .arg(&d) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::null()) + .spawn() + .unwrap(); { let stdin = child.stdin.as_mut().unwrap(); writeln!(stdin, r#"{{"jsonrpc":"2.0","id":1,"method":"initialize","params":{{"protocolVersion":"2025-06-18"}}}}"#).unwrap(); @@ -261,6 +275,7 @@ fn mcp_over_stdio() { assert_eq!(lines[0]["result"]["protocolVersion"], "2025-06-18"); assert_eq!(lines[1]["error"]["code"], -32700); assert_eq!(lines[2]["result"]["isError"], false); + let _ = std::fs::remove_dir_all(d); } #[test] @@ -270,8 +285,18 @@ fn mcp_over_stdio_confined_to_automation_roots() { std::fs::create_dir_all(d.join(sub)).unwrap(); } let p = |rel: &str| d.join(rel).to_string_lossy().into_owned(); - // A root that isn't a folder stops the server before it serves. - let out = bin().args(["mcp", "--automation-read-root", &p("missing")]).output().unwrap(); + for args in [ + vec!["mcp".to_owned()], + vec!["mcp".to_owned(), "--automation-read-root".to_owned(), p("in")], + vec!["mcp".to_owned(), "--automation-write-root".to_owned(), p("out")], + ] { + let out = bin().args(args).output().unwrap(); + assert_eq!(out.status.code(), Some(2)); + assert!(String::from_utf8_lossy(&out.stderr).contains("requires both --automation-read-root and --automation-write-root")); + } + + // Both roots are required; a root that isn't a folder stops the server before it serves. + let out = bin().args(["mcp", "--automation-read-root", &p("missing"), "--automation-write-root", &p("out")]).output().unwrap(); assert_eq!(out.status.code(), Some(1)); assert!(String::from_utf8_lossy(&out.stderr).contains("--automation-read-root")); let mut child = bin() diff --git a/apps/figcraft-cli/tests/it/rfc18.rs b/apps/figcraft-cli/tests/it/rfc18.rs index 090bc5ebe..cfbc8f109 100644 --- a/apps/figcraft-cli/tests/it/rfc18.rs +++ b/apps/figcraft-cli/tests/it/rfc18.rs @@ -220,3 +220,82 @@ fn a_server_key_flag_and_an_unreachable_app_fail_with_exit_1_and_a_message() { assert!(got.err.contains("can't reach the FigCraft app at 127.0.0.1:1"), "{}", got.err); let _ = std::fs::remove_dir_all(dir); } + +/// `--strict` writes what leaves nothing out as without it, and refuses (exit 1, the reasons listed, +/// no file written or replaced) what would leave something out. +#[test] +fn strict_refuses_to_write_what_would_leave_content_out() { + let dir = workdir("strict"); + let path = |name: &str| dir.join(name).to_str().unwrap().to_string(); + let frame = r#"{"command": "frame.create", "params": {"x": 0, "y": 0, "width": 10, "height": 10, "name": "F"}}"#; + // The .fig format has no place for comments, so the writer reports one as left out. + let comment = r#"{"command": "comment.add", "params": {"x": 5, "y": 5, "text": "Check"}}"#; + let (clean, noted, script) = (path("clean.figcraft"), path("noted.figcraft"), path("s.json")); + for (doc, steps) in [(&clean, format!("[{frame}]")), (¬ed, format!("[{frame}, {comment}]"))] { + std::fs::write(&script, steps).unwrap(); + let made = invoke(["run", script.as_str(), "--out", doc.as_str()]); + assert_eq!(made.code, 0, "{}", made.err); + } + + let fig = path("clean.fig"); + let got = invoke(["export", clean.as_str(), "-o", fig.as_str(), "--strict"]); + assert_eq!((got.code, got.err.contains("note:")), (0, false), "{}", got.err); + assert_eq!(invoke(["info", fig.as_str()]).code, 0, "the strict export reads back"); + let got = invoke(["convert", clean.as_str(), path("clean.penpot").as_str(), "--strict"]); + assert_eq!(got.code, 0, "{}", got.err); + + let (absent, previous) = (path("absent.fig"), path("previous.fig")); + std::fs::write(&previous, b"previous export").unwrap(); + for args in [ + vec!["export", noted.as_str(), "-o", absent.as_str(), "--strict"], + vec!["export", noted.as_str(), "-o", previous.as_str(), "--strict"], + vec!["convert", noted.as_str(), absent.as_str(), "--strict"], + vec!["run", script.as_str(), "--in", clean.as_str(), "--out", previous.as_str(), "--strict"], + ] { + let got = invoke(args.iter().copied()); + assert_eq!(got.code, 1, "{args:?}: {}", got.err); + assert!( + got.err.starts_with("error: ") && got.err.contains("--strict") && got.err.contains("comments were left out"), + "{args:?}: {}", + got.err + ); + assert!(!std::path::Path::new(&absent).exists(), "{args:?} wrote {absent}"); + assert_eq!(std::fs::read(&previous).unwrap(), b"previous export", "{args:?} replaced {previous}"); + } + // Without --strict the same export writes the file and notes what it left out. + let got = invoke(["export", noted.as_str(), "-o", absent.as_str()]); + assert_eq!(got.code, 0, "{}", got.err); + assert!(got.err.contains("note: comments were left out") && std::path::Path::new(&absent).exists(), "{}", got.err); + + // A folder of drawables is written only when no file in it leaves anything out. + let drawables = path("clean-drawables"); + let got = invoke(["export", clean.as_str(), "-o", drawables.as_str(), "--format", "xml", "--strict"]); + assert_eq!(got.code, 0, "{}", got.err); + assert!(std::path::Path::new(&drawables).join("F.xml").exists(), "{}", got.out); + std::fs::write( + &script, + r##"[{"command": "shape.rectangle", "params": {"x": 0, "y": 0, "width": 24, "height": 24, "name": "Dot", "props": {"fill": "#ff0000", "effects": [{"type": "dropShadow"}]}}}]"##, + ) + .unwrap(); + let shadowed = path("shadowed.figcraft"); + assert_eq!(invoke(["run", script.as_str(), "--out", shadowed.as_str()]).code, 0); + let folder = path("drawables"); + let got = invoke(["export", shadowed.as_str(), "-o", folder.as_str(), "--format", "xml", "--strict"]); + assert_eq!(got.code, 1, "{}", got.err); + assert!(got.err.contains("drop shadows were left out") && !std::path::Path::new(&folder).exists(), "{}", got.err); + + // --vd-compat only matters for drawables. + let got = invoke(["export", clean.as_str(), "-o", path("ignored.fig").as_str(), "--vd-compat", "ignore", "--strict"]); + assert_eq!(got.code, 0, "{}", got.err); + // Where nothing would be checked, --strict is a usage error. + for args in [ + vec!["export", clean.as_str(), "-o", "x.png", "--strict"], + vec!["export", clean.as_str(), "-o", "frames", "--strict"], + vec!["export", shadowed.as_str(), "-o", "x.xml", "--vd-compat", "ignore", "--strict"], + vec!["convert", clean.as_str(), "x.svg", "--strict"], + vec!["run", script.as_str(), "--strict"], + ] { + assert!(usage_error(&args).contains("--strict"), "{args:?}"); + } + std::fs::remove_dir_all(dir).unwrap(); +} diff --git a/apps/figcraft-server/src/dst_crash_tests.rs b/apps/figcraft-server/src/dst_crash_tests.rs new file mode 100644 index 000000000..605201226 --- /dev/null +++ b/apps/figcraft-server/src/dst_crash_tests.rs @@ -0,0 +1,506 @@ +//! Crash and compaction simulation over many seeds, on the real data directory: several clients +//! edit (and undo) one file while the store logs, flushes and compacts it, connections drop, and +//! the server crashes (the [`Store`] and session dropped with nothing more written) before a +//! flush, in the middle of one (its records cut short on disk) or after one but before anyone +//! heard back. Everyone leaving compacts and parks the file. As the hub does, nobody hears of a +//! change before its flush. +//! +//! After every restart the file must come back as exactly the state the server had at some +//! sequence number, no earlier than the last durable point (a clean flush or a compaction) and +//! no earlier than anything a client heard; valid; and taking appends again. Clients resume with +//! their ids, resend what the server lost, and end with exactly its state. +//! +//! One seed: `FIGCRAFT_DST_SEED=7 cargo test -p figcraft-server dst_crash`. + +use std::collections::BTreeMap; +use std::fs; +use std::path::PathBuf; + +use figcraft_collab::message::{Access, ClientMsg, ServerMsg}; +use figcraft_collab::sim::Rng; +use figcraft_collab::{Client, NoRecompute, Notice, Outgoing, Replica, Server}; +use figcraft_collab_net::hub::Backend; +use figcraft_doc::{Document, NodeId, NodeKind, Style, StyleKind}; + +use crate::disk::{self, LOG}; +use crate::store::{FILES, Store, StoreConfig}; +use crate::test_util::{TempDir, config}; + +const CLIENTS: usize = 3; + +fn fixture() -> Document { + let mut d = Document::new("Crash DST"); + let page = d.first_page().unwrap(); + for i in 0..3 { + let f = d.create(page, NodeKind::Frame, &format!("F{i}"), i as f64 * 200.0, 0.0, 150.0, 100.0).unwrap(); + for j in 0..2 { + d.create(f, NodeKind::Rectangle, &format!("R{i}{j}"), 0.0, j as f64 * 20.0, 10.0, 10.0).unwrap(); + } + } + d.repair(); + d.take_dirty(); + d +} + +/// One random edit: layers created, moved, resized, renamed, deleted; pages and styles. +fn random_edit(doc: &mut Document, rng: &mut Rng) { + let layers: Vec = doc.nodes().filter(|n| !n.is_page()).map(|n| n.id).collect(); + let containers: Vec = doc.nodes().filter(|n| n.kind.is_container()).map(|n| n.id).collect(); + match rng.below(9) { + 0 | 1 => { + if let Some(&p) = rng.pick(&containers) { + let _ = doc.create(p, NodeKind::Rectangle, "New", rng.below(300) as f64, rng.below(300) as f64, 8.0, 8.0); + } + } + 2 | 3 => { + if let Some(n) = rng.pick(&layers).copied().and_then(|x| doc.node_mut(x)) { + n.width = 1.0 + rng.below(400) as f64; + n.opacity = rng.below(11) as f32 / 10.0; + } + } + 4 => { + if let Some(n) = rng.pick(&layers).copied().and_then(|x| doc.node_mut(x)) { + n.name = format!("Layer {}", rng.below(1000)); + } + } + 5 => { + if let Some(&x) = rng.pick(&layers).filter(|_| rng.chance(0.5)) { + let _ = doc.remove(x); + } + } + 6 => { + if let (Some(&x), Some(&p)) = (rng.pick(&layers), rng.pick(&containers)) { + let _ = doc.place(x, p, 0); + } + } + 7 => { + let pages = doc.pages.clone(); + match rng.pick(&pages).copied().and_then(|p| doc.node_mut(p)) { + Some(n) if rng.chance(0.7) => n.name = format!("Page {}", rng.below(100)), + _ => { + doc.add_page("More"); + } + } + } + _ => { + let id = doc.new_style_id(); + let name = format!("Style {}", rng.below(100)); + doc.styles.push(Style { id, name, description: String::new(), kind: StyleKind::Paint { paints: vec![] }, bound: Default::default() }); + } + } +} + +fn hello(i: usize) -> figcraft_collab::Hello { + let ClientMsg::Hello(h) = Client::hello("f", "", &format!("Person {i}"), "#3366FF") else { panic!("not a hello") }; + h +} + +#[derive(Clone, Copy, PartialEq, Debug)] +enum Crash { + /// Before the pending records were written. + BeforeFlush, + /// While they were written: the log ends inside them. + Torn, + /// After a clean flush, before anyone heard back. + BeforeAcks, +} + +/// One file in a data directory, its live session and its clients. +struct Rig { + seed: u64, + rng: Rng, + dir: TempDir, + cfg: StoreConfig, + store: Option, + server: Server, + file: String, + clients: Vec, + online: Vec, + /// What the server sent, to deliver once it is flushed: (client index, message). + outbox: Vec<(usize, ServerMsg)>, + /// The server's state after each sequence number, on the timeline that survived. + history: BTreeMap, + /// The last state on disk for sure (a clean flush or a compaction). + durable: (u64, Replica), + compactions: u64, + /// Compactions over every store opened. + compacted: u64, + crashes: Vec, + /// Torn crashes whose log ended inside a record (reported at the next open). + damaged: usize, + idles: usize, +} + +impl Rig { + fn new(seed: u64) -> Rig { + let dir = TempDir::new(&format!("dst-crash-{seed}")); + let cfg = StoreConfig { compact_after: 3 + (seed % 6) as usize, ..config(dir.path()).store() }; + let mut store = Store::open(dir.path(), cfg.clone()).unwrap(); + let (info, _, _) = store.publish("DST", &Replica::new(fixture()).snapshot().unwrap()).unwrap(); + let mut server = store.open(&info.id).unwrap(); + let start = server.replica().clone(); + let mut clients = Vec::new(); + let mut outs = Vec::new(); + for i in 0..CLIENTS { + let (id, out) = server.join_as(hello(i), Access::Edit).unwrap(); + store.changed(&info.id, &mut server); + assert!(store.flush().is_empty()); + let mut welcome = None; + for o in out { + match o { + Outgoing::To(to, m @ ServerMsg::Welcome { .. }) if to == id => welcome = Some(m), + o => outs.push(o), + } + } + clients.push(Client::join(welcome.unwrap()).unwrap()); + } + let compactions = store.compactions(); + let mut rig = Rig { + seed, + rng: Rng::new(seed ^ 0xD57), + dir, + cfg, + store: Some(store), + server, + file: info.id, + clients, + online: vec![true; CLIENTS], + outbox: Vec::new(), + history: BTreeMap::from([(0, start.clone())]), + durable: (0, start), + compactions, + compacted: 0, + crashes: Vec::new(), + damaged: 0, + idles: 0, + }; + rig.route(outs); + rig.deliver(); + rig + } + + fn store(&mut self) -> &mut Store { + self.store.as_mut().unwrap() + } + + fn log_path(&self) -> PathBuf { + self.dir.path().join(FILES).join(&self.file).join(LOG) + } + + fn log_len(&self) -> u64 { + fs::metadata(self.log_path()).map_or(0, |m| m.len()) + } + + /// Queue what the server sent for the clients connected now. + fn route(&mut self, out: Vec) { + for o in out { + let ids: Vec = self.clients.iter().map(Client::id).collect(); + let (msg, targets): (ServerMsg, Vec) = match o { + Outgoing::To(id, m) => (m, ids.iter().position(|c| *c == id).into_iter().collect()), + Outgoing::All(m) => (m, (0..CLIENTS).collect()), + Outgoing::Others(id, m) => (m, (0..CLIENTS).filter(|i| ids[*i] != id).collect()), + }; + for t in targets.into_iter().filter(|t| self.online[*t]) { + self.outbox.push((t, msg.clone())); + } + } + } + + /// The store logs what the server just did (and may compact); the timeline grows. + fn logged(&mut self, out: Vec) { + let file = self.file.clone(); + let store = self.store.as_mut().unwrap(); + store.changed(&file, &mut self.server); + let compactions = store.compactions(); + let seq = self.server.seq(); + self.history.entry(seq).or_insert_with(|| self.server.replica().clone()); + if compactions != self.compactions { + self.compacted += compactions - self.compactions; + self.compactions = compactions; + self.durable = (seq, self.server.replica().clone()); + } + self.route(out); + } + + fn send(&mut self, i: usize, msg: ClientMsg) { + let id = self.clients[i].id(); + let out = self.server.receive(id, msg); + self.logged(out); + } + + /// A clean flush: what is logged is durable. + fn flush(&mut self) { + let file = self.file.clone(); + let failed = self.store().flush(); + assert!(!failed.contains(&file), "seed {}: the log couldn't be written", self.seed); + self.durable = (self.server.seq(), self.server.replica().clone()); + } + + /// Flush, then let the clients hear everything, until nothing more is said. + fn deliver(&mut self) { + for _ in 0..10_000 { + if self.outbox.is_empty() { + return; + } + self.flush(); + for (i, msg) in std::mem::take(&mut self.outbox) { + if !self.online[i] { + continue; + } + let replies = self.clients[i].receive(msg, &NoRecompute).unwrap(); + for r in replies { + self.send(i, r); + } + } + } + panic!("seed {}: the session never went quiet", self.seed); + } + + fn edit(&mut self, i: usize) { + let mut doc = self.clients[i].document().clone(); + let mut rng = Rng::new(self.rng.next_u64()); + random_edit(&mut doc, &mut rng); + // Offline (or before the welcome) it is queued. + if let Some(m) = self.clients[i].edit(&doc).unwrap() { + self.send(i, m); + } + } + + fn undo(&mut self, i: usize) { + let msgs = if self.rng.chance(0.6) { self.clients[i].undo(&NoRecompute) } else { self.clients[i].redo(&NoRecompute) }; + for m in msgs.unwrap() { + self.send(i, m); + } + } + + /// The connection drops: what was on its way to the client is lost. + fn disconnect(&mut self, i: usize) { + if !self.online[i] { + return; + } + self.online[i] = false; + self.outbox.retain(|(t, _)| *t != i); + self.clients[i].disconnect(); + let out = self.server.leave(self.clients[i].id()); + self.logged(out); + } + + fn reconnect(&mut self, i: usize) { + if self.online[i] { + return; + } + let ClientMsg::Hello(h) = self.clients[i].reconnect(hello(i)) else { panic!("not a hello") }; + let (id, out) = self.server.join_as(h, Access::Edit).unwrap(); + assert_eq!(id, self.clients[i].id(), "seed {}: client {i} came back as someone else", self.seed); + self.online[i] = true; + self.logged(out); + } + + /// The server dies; the clients' connections with it. Then it starts again from the disk. + fn crash(&mut self, mut how: Crash) { + let seed = self.seed; + let mut torn_at = None; + match how { + Crash::BeforeFlush => {} + Crash::BeforeAcks => self.flush(), + Crash::Torn => { + let before = self.log_len(); + let file = self.file.clone(); + assert!(!self.store().flush().contains(&file)); + let after = self.log_len(); + if after > before { + // Cut inside the new records: a cut on a record boundary is moved on to the + // next byte that isn't one. + let bytes = fs::read(self.log_path()).unwrap(); + let mut at = before + self.rng.below((after - before) as usize) as u64; + while at + 1 < after && disk::read_log(&bytes[..at as usize]).unwrap().damaged.is_none() { + at += 1; + } + torn_at = Some(at); + } else { + // Nothing was pending: that was a clean flush. + self.durable = (self.server.seq(), self.server.replica().clone()); + how = Crash::BeforeAcks; + } + } + } + // Nothing more is written: no flush, no compaction, no goodbye. + drop(self.store.take()); + self.outbox.clear(); + for i in 0..CLIENTS { + self.online[i] = false; + self.clients[i].disconnect(); + } + let mut damaged = false; + if let Some(at) = torn_at { + let bytes = fs::read(self.log_path()).unwrap(); + let cut = &bytes[..at as usize]; + damaged = disk::read_log(cut).unwrap().damaged.is_some(); + fs::write(self.log_path(), cut).unwrap(); + } + self.crashes.push(how); + self.damaged += usize::from(damaged); + + let mut store = Store::open(self.dir.path(), self.cfg.clone()).unwrap(); + self.server = store.open(&self.file).unwrap(); + let seq = self.server.seq(); + let what = format!("seed {seed}: after a crash {how:?} (durable {}, reopened {seq})", self.durable.0); + if damaged { + assert!(store.problems().iter().any(|p| p.contains(&self.file)), "{what}: the cut-short log wasn't reported"); + } + if how == Crash::Torn { + assert!(seq >= self.durable.0, "{what}: lost flushed edits"); + } else { + assert_eq!(seq, self.durable.0, "{what}"); + assert!(self.server.replica() == &self.durable.1, "{what}: not the state on disk"); + } + let Some(expected) = self.history.get(&seq) else { panic!("{what}: a sequence number the server never had") }; + assert!(self.server.replica() == expected, "{what}: not the state the server had then"); + assert!(self.server.document().validate().is_empty(), "{what}: {:?}", self.server.document().validate()); + // Nobody heard of anything that didn't survive, and what they heard is what came back. + for (i, c) in self.clients.iter().enumerate() { + assert!(c.seq() <= seq, "{what}: client {i} heard of seq {}", c.seq()); + assert!(c.confirmed() == &self.history[&c.seq()], "{what}: client {i}'s confirmed state isn't the server's at {}", c.seq()); + } + // What came after the surviving sequence number is gone: new batches take those numbers. + self.history.retain(|s, _| *s <= seq); + self.durable = (seq, self.server.replica().clone()); + self.compactions = store.compactions(); + self.store = Some(store); + for i in 0..CLIENTS { + if self.rng.chance(0.8) { + self.reconnect(i); + } + } + } + + /// Everyone leaves: the file is compacted and parked, and opened again on the next join. + fn everyone_leaves(&mut self) { + for i in 0..CLIENTS { + self.disconnect(i); + } + self.deliver(); + self.flush(); + let before = self.server.replica().clone(); + let file = self.file.clone(); + let mut server = std::mem::replace(&mut self.server, Server::new(Document::new(""), "", self.cfg.core)); + let store = self.store.as_mut().unwrap(); + store.idle(&file, &mut server); + self.server = store.open(&file).unwrap(); + self.compacted += store.compactions() - self.compactions; + self.compactions = store.compactions(); + assert!(self.server.replica() == &before, "seed {}: the file came back changed after everyone left", self.seed); + self.durable = (self.server.seq(), before); + self.idles += 1; + for i in 0..CLIENTS { + self.reconnect(i); + } + } + + /// Everyone back and up to date, then edits until the server holds batches not yet flushed. + fn pending_edits(&mut self) { + for i in 0..CLIENTS { + self.reconnect(i); + } + self.deliver(); + for _ in 0..1_000 { + if self.server.seq() > self.durable.0 { + return; + } + let i = self.rng.below(CLIENTS); + self.edit(i); + } + panic!("seed {}: no edit was accepted", self.seed); + } + + fn step(&mut self) { + let i = self.rng.below(CLIENTS); + match self.rng.below(24) { + 0..=8 => self.edit(i), + 9 | 10 => { + if self.online[i] { + self.undo(i); + } + } + 11..=13 => self.deliver(), + 14 | 15 => self.disconnect(i), + 16 | 17 => self.reconnect(i), + 18 => { + let how = [Crash::BeforeFlush, Crash::Torn, Crash::BeforeAcks][self.rng.below(3)]; + self.crash(how); + } + 19 => self.everyone_leaves(), + _ => self.edit(i), + } + } + + /// Everyone back, everything said: each client holds exactly the server's state. + fn settle(&mut self, when: &str) { + for i in 0..CLIENTS { + self.reconnect(i); + } + self.deliver(); + let seed = self.seed; + let server = self.server.replica(); + for (i, c) in self.clients.iter_mut().enumerate() { + assert_eq!((c.pending(), c.seq()), (0, self.server.seq()), "seed {seed} {when}: client {i}"); + assert!(c.view() == server && c.confirmed() == server, "seed {seed} {when}: client {i} differs from the server"); + let lost: Vec = c.take_notices().into_iter().filter(|n| matches!(n, Notice::Lost { .. })).collect(); + assert!(lost.is_empty(), "seed {seed} {when}: client {i} lost its queue: {lost:?}"); + } + assert!(self.server.document().validate().is_empty(), "seed {seed} {when}"); + } +} + +fn run_seed(seed: u64) -> Rig { + let mut rig = Rig::new(seed); + for round in 0..3 { + for _ in 0..25 { + rig.step(); + } + // Every round tears a flush of batches nobody heard of yet. + rig.pending_edits(); + rig.crash(Crash::Torn); + rig.settle(&format!("round {round}")); + } + // Everyone leaves (compacted, parked), then a crash: the compacted file is read from disk. + rig.everyone_leaves(); + rig.crash(Crash::BeforeFlush); + rig.settle("after a crash once everyone left"); + // Accepted and flushed, nobody heard: the clients' resends are recognised as done. + rig.pending_edits(); + rig.crash(Crash::BeforeAcks); + rig.settle("after a crash before the acks"); + // The last word: a crash right after everyone agreed loses nothing. + rig.crash(Crash::BeforeFlush); + rig.settle("after the last crash"); + assert!(rig.damaged > 0, "seed {seed}: no torn log ended inside a record"); + assert!(rig.crashes.contains(&Crash::Torn), "seed {seed}: no flush was torn"); + rig +} + +#[test] +fn dst_crashes_compactions_and_torn_logs_lose_nothing_acknowledged() { + let seeds: Vec = match std::env::var("FIGCRAFT_DST_SEED").ok().and_then(|s| s.parse().ok()) { + Some(one) => vec![one], + None => (0..24).collect(), + }; + // Seeds are independent (a data directory each) and mostly wait on the disk: run them side + // by side. Each stays deterministic. + let rigs: Vec = std::thread::scope(|s| { + let runs: Vec<_> = seeds.into_iter().map(|seed| s.spawn(move || run_seed(seed))).collect(); + runs.into_iter().map(|r| r.join().unwrap()).collect() + }); + let (mut kinds, mut damaged, mut idles, mut compactions) = ([0usize; 3], 0, 0, 0); + for rig in &rigs { + for c in &rig.crashes { + kinds[*c as usize] += 1; + } + damaged += rig.damaged; + idles += rig.idles; + compactions += rig.compacted; + } + assert!(kinds.iter().all(|k| *k > 0), "every kind of crash happens: {kinds:?}"); + assert!(damaged > 0, "some torn log ends inside a record"); + assert!(idles > 0 && compactions > 0, "files are compacted ({compactions}) and parked ({idles})"); +} diff --git a/apps/figcraft-server/src/hardening_tests.rs b/apps/figcraft-server/src/hardening_tests.rs index 186b8d9c0..119a8dc4b 100644 --- a/apps/figcraft-server/src/hardening_tests.rs +++ b/apps/figcraft-server/src/hardening_tests.rs @@ -47,7 +47,7 @@ pub(crate) fn archive(bomb: usize, padding: usize) -> Vec { let mut out = zip::ZipWriter::new(Cursor::new(Vec::new())); for i in 0..src.len() { let f = src.by_index_raw(i).unwrap(); - if bomb > 0 && f.name() == "library/document.json" { + if bomb > 0 && f.name().expect("ZIP member name") == "library/document.json" { continue; } out.raw_copy_file(f).unwrap(); diff --git a/apps/figcraft-server/src/lib.rs b/apps/figcraft-server/src/lib.rs index 99b2d3645..e49d8504f 100644 --- a/apps/figcraft-server/src/lib.rs +++ b/apps/figcraft-server/src/lib.rs @@ -101,6 +101,8 @@ mod directory_tests; #[cfg(test)] mod download_burst_tests; #[cfg(test)] +mod dst_crash_tests; +#[cfg(test)] mod hardening_tests; #[cfg(test)] mod idle_io_tests; diff --git a/apps/figcraft-server/src/store/files.rs b/apps/figcraft-server/src/store/files.rs index fcc0fd109..8db73d063 100644 --- a/apps/figcraft-server/src/store/files.rs +++ b/apps/figcraft-server/src/store/files.rs @@ -90,7 +90,7 @@ impl Store { if let Some(why) = self.low_disk() { return Err(why); } - let replica = Replica::from_snapshot(snapshot).map_err(|e| format!("the file couldn't be read: {e}"))?; + let replica = Replica::from_snapshot(snapshot.to_vec()).map_err(|e| format!("the file couldn't be read: {e}"))?; if replica.document().node_count() > self.cfg.core.max_nodes { return Err(format!("the file has more than {} layers", self.cfg.core.max_nodes)); } diff --git a/apps/figcraft-web/Cargo.toml b/apps/figcraft-web/Cargo.toml index dd18794a2..520ec3b1a 100644 --- a/apps/figcraft-web/Cargo.toml +++ b/apps/figcraft-web/Cargo.toml @@ -21,8 +21,8 @@ figcraft-collab-net = { workspace = true } figcraft-text = { workspace = true } # The host messages (storytold/craft-libs): one contract and one bridge for the web builds. # The page command API (storytold/craft-libs#413): the request plumbing behind window.figcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" } -craft-web-host = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf", version = "0.1.0" } +craft-web-host = { git = "https://github.com/storytold/craft-libs", rev = "9949e08d6f29b6c4462f14af1d5007acac163dbf", version = "0.1.0" } base64 = { workspace = true } egui = { workspace = true } log = { workspace = true } diff --git a/apps/figcraft-web/src/api.rs b/apps/figcraft-web/src/api.rs index cb82820b7..2335b21ac 100644 --- a/apps/figcraft-web/src/api.rs +++ b/apps/figcraft-web/src/api.rs @@ -124,7 +124,8 @@ fn send(method: &str, params: Value) -> Pin>> { n.get() }); let gate = RequestGate::new(); - QUEUE.with(|q| q.borrow_mut().push(ControlRequest { id: json!(id), method: method.to_string(), params, reply, state: gate.clone() })); + QUEUE + .with(|q| q.borrow_mut().push(ControlRequest { roots: None, id: json!(id), method: method.to_string(), params, reply, state: gate.clone() })); CTX.with(|c| { if let Some(ctx) = c.borrow().as_ref() { ctx.request_repaint(); diff --git a/apps/figcraft-web/src/host.rs b/apps/figcraft-web/src/host.rs index 57b67ca85..1e5687124 100644 --- a/apps/figcraft-web/src/host.rs +++ b/apps/figcraft-web/src/host.rs @@ -24,6 +24,17 @@ //! - Everything else is a copy or export that never becomes the document: `false` — rendered //! images, SVG and PDF, `.fig` copies, and the variables exports (a `.variables.json` //! sidecar's `.json` extension doesn't make it a document). +//! - Confirmed saves, opt-in: with `?save=managed` in the URL, or `data-save="managed"` on the +//! canvas ([`crate::query::confirms_saves`]), each Save and Save As of the document carries an +//! `id` (`save-1`, `save-2`, …) and the document keeps its unsaved changes until the host answers +//! `figcraft:saved` with that `id` ([`crate::host_saves`]). Then it is saved as of the file the +//! host stored, so edits made meanwhile stay unsaved, and a Save As becomes the document's file +//! only then. Answers for any other `id` are ignored; a newer save replaces the one waiting; a +//! file the host opens forgets it (the user is told). Without an answer within 30 seconds the save counts as not +//! stored: the user is told and the host gets `figcraft:failed` with the `id`. Copies and exports +//! carry no `id` and `saveAs: false`. A host that doesn't opt in sees no change: every file +//! counts as saved once it is posted. `craft-web-host` has no message yet for a host to refuse a +//! save, so a refusal shows as the timeout. //! - `figcraft:dirty` whenever unsaved changes appear or go away, `figcraft:failed` when the app //! couldn't start. //! @@ -31,10 +42,14 @@ //! edit; `?author=` names the user for comments and board notes. use std::cell::RefCell; +use std::collections::VecDeque; use std::rc::Rc; use craft_web_host::web::{FileData, Host, Message}; -use figcraft_ui_egui::FigApp; +use figcraft_engine::cmd::file::FileSnapshot; +use figcraft_ui_egui::{Delivery, FigApp}; + +use crate::host_saves::HostSaves; /// The app id in the host messages (`figcraft:ready`). const APP: &str = "figcraft"; @@ -42,38 +57,87 @@ const APP: &str = "figcraft"; /// The longest user name taken from `?author=`. const MAX_AUTHOR_CHARS: usize = 200; -/// Files the host sent, on their way to the app's own open queue ([`figcraft_ui_egui::pending_open`]): -/// `(name, bytes)`. -pub type OpenQueue = Rc)>>>; +/// What the host sent, in the order it came, for the shell's next frame ([`Bridge::frame`]). +enum FromHost { + /// A file to open: `(name, bytes)`. + Open(String, Vec), + /// The save with this `id` is stored. + Saved(String), +} #[derive(Clone)] pub struct Bridge { host: Rc, - /// The file the host opened, and after a `saveAs` hand-over the document's file: the name a - /// Save under (`saveAs: false`) is decided against. - host_file: Rc>>, + /// The host confirms saves (`?save=managed`): document saves wait for its `saved`. + confirms_saves: bool, + /// The document's file and the save waiting for the host ([`crate::host_saves`]). + saves: Rc>>, + /// Messages heard and not yet handled. The listener only queues them: a page host can answer + /// while a post is still running, so nothing else is borrowed there. + inbox: Rc>>, } impl Bridge { /// The bridge for this page, or `None` when FigCraft isn't hosted: no `?host=parent` and no /// `data-host="page"` on the canvas, an unframed `?host=parent` page (it stays the normal app - /// with downloads), or a parent on another origin. - pub fn connect(canvas: &web_sys::HtmlCanvasElement) -> Option { - Some(Self { host: Rc::new(Host::connect(APP, canvas)?), host_file: Rc::default() }) + /// with downloads), or a parent on another origin. `confirms_saves`: the host opted in to + /// confirmed saves. + pub fn connect(canvas: &web_sys::HtmlCanvasElement, confirms_saves: bool) -> Option { + Some(Self { host: Rc::new(Host::connect(APP, canvas)?), confirms_saves, saves: Rc::default(), inbox: Rc::default() }) } - /// Hear the files the host sends, and queue each one on `opens` for the app's own open path - /// (the shell drains it into [`figcraft_ui_egui::pending_open`] every frame, so a host file - /// opens like a dropped one). - pub fn listen(&self, opens: OpenQueue, ctx: egui::Context) { - let host_file = self.host_file.clone(); + /// Hear the host's messages. They are handled in the shell's next frame ([`Bridge::frame`]), + /// in the order they came. + pub fn listen(&self, ctx: egui::Context) { + let inbox = self.inbox.clone(); self.host.listen(move |message| { - if let Message::Open { name, data } = message { - deliver_open(&opens, &ctx, &host_file, &name, &data); + let heard = match message { + Message::Open { name, data } => open_bytes(&name, &data), + Message::Saved { id } => Some(FromHost::Saved(id)), + _ => None, + }; + if let Some(heard) = heard { + inbox.borrow_mut().push_back(heard); + ctx.request_repaint(); } }); } + /// Every frame: handle what the host sent, in order (a file opens on the app's own open path, + /// as a dropped one does; a `saved` marks its document saved), and end a save that waited too + /// long. `now_ms`: the app's clock, which also wakes the app when the waiting save times out. + pub fn frame(&self, fig: &mut FigApp, ctx: &egui::Context, now_ms: u64) { + let heard = std::mem::take(&mut *self.inbox.borrow_mut()); + for message in heard { + match message { + FromHost::Open(name, bytes) => { + let forgotten = self.saves.borrow_mut().opened(&name); + if let Some(save) = forgotten { + fig.document_not_stored(&save.name, &figcraft_ui_egui::save_forgotten_on_open()); + } + queue_open(fig, name, bytes); + } + FromHost::Saved(id) => { + let confirmed = self.saves.borrow_mut().saved(&id); + match confirmed { + Some(save) => fig.document_stored(&save.name, save.file), + None => log::info!("host confirmed save {id:?}, which isn't the one waiting; ignored"), + } + } + } + } + let expired = self.saves.borrow_mut().expire(now_ms); + if let Some(save) = expired { + let secs = self.saves.borrow().timeout_ms() / 1000; + let _ = self.host.post_failed(&format!("save {} was not confirmed within {secs} seconds", save.id), Some(&save.id)); + fig.document_not_stored(&save.name, &figcraft_ui_egui::save_unconfirmed(usize::try_from(secs).unwrap_or(usize::MAX))); + } + let wait = self.saves.borrow().wait_ms(now_ms); + if let Some(wait) = wait { + ctx.request_repaint_after(std::time::Duration::from_millis(wait)); + } + } + /// `?author=`: the host's name for the user signs comments and board notes. pub fn set_author(app: &mut FigApp, author: &str) { let author: String = author.trim().chars().take(MAX_AUTHOR_CHARS).collect(); @@ -93,24 +157,53 @@ impl Bridge { /// The document file the host opened or the last Save As made, if any. pub fn host_file(&self) -> Option { - self.host_file.borrow().clone() + self.saves.borrow().host_file().map(str::to_string) } - /// Hand a file the app would otherwise download to the host; `false` when nothing was - /// delivered. The `saveAs` rule is this module's documentation's. + /// Hand a file the app would otherwise download to the host, without an `id`; `false` when + /// nothing was delivered. To a host that confirms saves only copies and exports come this way + /// (the document's own file goes through [`post_document`](Self::post_document)), so they are + /// `saveAs: false`; to one that doesn't, the `saveAs` rule is this module's documentation's. pub fn post_save(&self, path: &str, bytes: &[u8]) -> bool { let name = file_name(path); - let host_file = self.host_file.borrow().clone(); - let save_as = crate::hostmode::save_as(&name, host_file.as_deref()); + let save_as = !self.confirms_saves && self.saves.borrow().save_as(&name); let sent = self.host.post_save(&name, bytes, None, save_as).is_ok(); // After a Save As hand-over the host has the new file: the next Save of it sends its name // with `saveAs: false`. A failed send changes nothing, so a retry is still a Save As. if sent && save_as { - *self.host_file.borrow_mut() = Some(name); + self.saves.borrow_mut().adopt(&name); } sent } + /// Hand the host the document's own file (Save, Save As) as `file`. To a host that confirms + /// saves it goes with an `id` and stays unsaved until the host answers ([`Delivery::Pending`]); + /// otherwise as [`post_save`](Self::post_save). + pub fn post_document(&self, path: &str, bytes: &[u8], file: FileSnapshot, now_ms: u64, ctx: &egui::Context) -> Delivery { + if !self.confirms_saves { + return if self.post_save(path, bytes) { Delivery::Saved } else { Delivery::Refused }; + } + let name = file_name(path); + // Recorded before the post: a page host can answer while it is still dispatching. + let (started, timeout_ms) = { + let mut saves = self.saves.borrow_mut(); + (saves.start(&name, file, now_ms), saves.timeout_ms()) + }; + match self.host.post_save(&name, bytes, Some(&started.id), started.save_as) { + Ok(()) => { + // Schedule the timeout wakeup immediately so an idle tab still times out if the + // host never answers after this frame. + ctx.request_repaint_after(std::time::Duration::from_millis(timeout_ms)); + Delivery::Pending + } + Err(e) => { + log::error!("couldn't hand {name} to the host: {e}"); + self.saves.borrow_mut().failed(&started.id); + Delivery::Refused + } + } + } + /// Report unsaved changes when they appear or go away, not every frame (the crate does not /// repeat a state it already reported). pub fn set_dirty(&self, dirty: bool) { @@ -118,23 +211,33 @@ impl Bridge { } } -/// The file an open message carries, queued for the app's own open path, or nothing when the -/// payload isn't one (a `File` the app doesn't read, or over the open limit). -fn deliver_open(opens: &OpenQueue, ctx: &egui::Context, host_file: &RefCell>, name: &str, data: &FileData) { +/// The app's own open queue gets a file the host sent: the same "Opening as a new file" card as a +/// dropped file, and `file.open` with the contents once read. +fn queue_open(fig: &mut FigApp, name: String, bytes: Vec) { + let read: figcraft_ui_egui::ReadFuture = Box::pin(std::future::ready(Ok(bytes))); + fig.ui.pending_opens.push(figcraft_ui_egui::pending_open::PendingOpen { + label: name.clone(), + params: serde_json::json!({ "name": name }), + command: "file.open", + target: None, + read: Some(read), + }); +} + +/// The file an open message carries, copied out for the next frame, or nothing when the payload +/// isn't one (a `File` the app doesn't read, or over the open limit). Once handled it is the +/// document's file: a Save of it under this name is `saveAs: false`. +fn open_bytes(name: &str, data: &FileData) -> Option { let name = crate::hostmode::open_name(name); let FileData::Bytes(array) = data else { log::warn!("host file {name} came as a File; FigCraft reads bytes only; not opened"); - return; + return None; }; if figcraft_ui_egui::browser_can_read(&name, data.size()).is_err() { log::warn!("host file {name} is too large to open in the browser; not opened"); - return; + return None; } - // The document's file is now the one the host sent: a Save of it under this name is - // `saveAs: false`. - *host_file.borrow_mut() = Some(name.clone()); - opens.borrow_mut().push((name, array.to_vec())); - ctx.request_repaint(); + Some(FromHost::Open(name, array.to_vec())) } /// The last component of `path`, or the whole of it when there is none. diff --git a/apps/figcraft-web/src/host_saves.rs b/apps/figcraft-web/src/host_saves.rs new file mode 100644 index 000000000..5c2f7e58c --- /dev/null +++ b/apps/figcraft-web/src/host_saves.rs @@ -0,0 +1,262 @@ +//! Confirmed saves: what the bridge ([`crate::host`]) knows about the files it handed a host page, +//! kept apart from the browser so every step is testable without one (like [`crate::hostmode`]). +//! +//! A host that confirms saves (`?save=managed`, [`crate::query::confirms_saves`]) gets each +//! Save and Save As of the document with an `id` and answers `saved` with that `id` once it stored +//! the file. Until then the document keeps its unsaved changes. Only one document save waits at a +//! time: a newer one replaces it, and an answer for any other `id` (an older save, a repeat, one +//! the host made up) is ignored. A save the host doesn't answer within the timeout counts as not +//! stored. A file the host opens forgets the save still waiting, so a late answer can't touch +//! the file opened since. +//! +//! The file the host opened, or the one the last Save As made, is kept here too: a Save As becomes +//! the document's file only once the host confirms it, so after a failed one the next Save is +//! still a Save As. + +/// How long a document save waits for the host's answer before it counts as not stored. +pub const DEFAULT_TIMEOUT_MS: u64 = 30_000; + +/// A document save handed to the host and not answered yet. +#[derive(Debug)] +pub struct PendingSave { + /// The `id` the save carried; the host's `saved` names it. + pub id: String, + /// The file name it went out under. + pub name: String, + /// It went out as `saveAs: true`: confirmed, it becomes the document's file. + pub save_as: bool, + /// When it was handed over, in the caller's clock (milliseconds). + pub started_at_ms: u64, + /// The document as handed over. In the app this is its `FileSnapshot` (the tab's uid, its + /// revision and contents), which marks the document saved as of the snapshot once confirmed. + pub file: F, +} + +/// A document save just handed to [`HostSaves::start`]: what to post with it. +#[derive(Debug, PartialEq, Eq)] +pub struct Started { + pub id: String, + pub save_as: bool, +} + +/// The bridge's record of the document's file and the save waiting for the host. +#[derive(Debug)] +pub struct HostSaves { + host_file: Option, + /// The number in the next save's `id`. Never reset, so an `id` is never used twice on a page. + next_id: u64, + pending: Option>, + timeout_ms: u64, +} + +impl Default for HostSaves { + fn default() -> Self { + Self::new(DEFAULT_TIMEOUT_MS) + } +} + +impl HostSaves { + pub fn new(timeout_ms: u64) -> Self { + Self { host_file: None, next_id: 1, pending: None, timeout_ms } + } + + /// How long a save waits for its answer, in milliseconds. + pub fn timeout_ms(&self) -> u64 { + self.timeout_ms + } + + /// The file the host opened, or the one the last confirmed (or, without confirmation, posted) + /// Save As made. + pub fn host_file(&self) -> Option<&str> { + self.host_file.as_deref() + } + + /// Whether a file named `name` goes out as `saveAs: true` now ([`crate::hostmode::save_as`]). + pub fn save_as(&self, name: &str) -> bool { + crate::hostmode::save_as(name, self.host_file.as_deref()) + } + + /// A Save As went to a host that doesn't confirm saves: `name` is the document's file now. + pub fn adopt(&mut self, name: &str) { + self.host_file = Some(name.to_string()); + } + + /// The host sent the file `name` to open: it is the document's file now. A save still waiting + /// was for the document open before, so it is forgotten and returned; its answer, if one + /// comes, is ignored, and that document keeps its unsaved changes. + pub fn opened(&mut self, name: &str) -> Option> { + self.host_file = Some(name.to_string()); + self.pending.take() + } + + /// A Save or Save As of the document as `file`, under `name`, handed over at `now_ms`: the `id` + /// and `saveAs` to post it with. A save still waiting is replaced, so its answer is ignored. + pub fn start(&mut self, name: &str, file: F, now_ms: u64) -> Started { + let id = format!("save-{}", self.next_id); + self.next_id += 1; + let save_as = self.save_as(name); + self.pending = Some(PendingSave { id: id.clone(), name: name.to_string(), save_as, started_at_ms: now_ms, file }); + Started { id, save_as } + } + + /// The host's `saved` for `id`: the save it confirms, when that is the one waiting. A Save As + /// becomes the document's file now. Any other `id` changes nothing. + pub fn saved(&mut self, id: &str) -> Option> { + let save = self.take(id)?; + if save.save_as { + self.host_file = Some(save.name.clone()); + } + Some(save) + } + + /// The save `id` could not be stored (the post failed, or the host refused it): the save, + /// when that is the one waiting. The document's file stays as it was. Any other `id` changes + /// nothing. + pub fn failed(&mut self, id: &str) -> Option> { + self.take(id) + } + + /// The save waiting since longer than the timeout at `now_ms`, which then counts as failed. + pub fn expire(&mut self, now_ms: u64) -> Option> { + let waiting = self.pending.as_ref()?; + if now_ms.saturating_sub(waiting.started_at_ms) < self.timeout_ms { + return None; + } + self.pending.take() + } + + /// How long from `now_ms` until the waiting save times out (so the app wakes then), or + /// `None` when none waits. + pub fn wait_ms(&self, now_ms: u64) -> Option { + let waiting = self.pending.as_ref()?; + Some((waiting.started_at_ms.saturating_add(self.timeout_ms)).saturating_sub(now_ms)) + } + + fn take(&mut self, id: &str) -> Option> { + if self.pending.as_ref().is_some_and(|p| p.id == id) { self.pending.take() } else { None } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + /// The document as handed over: in these tests, a label for the revision saved. + type Saves = HostSaves<&'static str>; + + fn opened(name: &str) -> Saves { + let mut saves = Saves::default(); + assert!(saves.opened(name).is_none()); + saves + } + + #[test] + fn each_save_gets_an_id_of_its_own() { + let mut saves = opened("Poster.figcraft"); + let first = saves.start("Poster.figcraft", "r1", 0).id; + let second = saves.start("Poster.figcraft", "r2", 0).id; + assert_ne!(first, second); + saves.opened("Other.figcraft"); + let third = saves.start("Other.figcraft", "r3", 0).id; + assert!(third != first && third != second, "opening a file doesn't start the ids over"); + } + + #[test] + fn a_confirmed_save_hands_back_what_was_saved() { + let mut saves = opened("Poster.figcraft"); + let started = saves.start("Poster.figcraft", "r1", 5); + assert!(!started.save_as, "a Save of the host's own file"); + let save = saves.saved(&started.id).expect("the waiting save"); + assert_eq!((save.file, save.name.as_str(), save.started_at_ms), ("r1", "Poster.figcraft", 5)); + assert!(saves.wait_ms(5).is_none(), "nothing waits any more"); + assert!(saves.saved(&started.id).is_none(), "a repeated answer changes nothing"); + } + + #[test] + fn a_save_as_becomes_the_document_s_file_only_once_confirmed() { + let mut saves = opened("Poster.figcraft"); + let started = saves.start("Poster 2.figcraft", "r1", 0); + assert!(started.save_as); + assert_eq!(saves.host_file(), Some("Poster.figcraft"), "not before the host stored it"); + saves.saved(&started.id); + assert_eq!(saves.host_file(), Some("Poster 2.figcraft")); + assert!(!saves.start("Poster 2.figcraft", "r2", 0).save_as, "the next Save is of that file"); + } + + #[test] + fn a_failed_save_as_leaves_the_document_s_file_so_a_retry_is_still_a_save_as() { + let mut saves = opened("Poster.figcraft"); + let started = saves.start("Poster 2.figcraft", "r1", 0); + let save = saves.failed(&started.id).expect("the waiting save"); + assert_eq!(save.file, "r1"); + assert_eq!(saves.host_file(), Some("Poster.figcraft")); + assert!(saves.start("Poster 2.figcraft", "r1", 0).save_as); + } + + #[test] + fn answers_for_other_ids_change_nothing() { + let mut saves = opened("Poster.figcraft"); + let started = saves.start("Poster 2.figcraft", "r1", 0); + for id in ["", "save-0", "save-99", "Save-1 ", "nonsense"] { + assert!(saves.saved(id).is_none(), "{id:?}"); + assert!(saves.failed(id).is_none(), "{id:?}"); + } + assert_eq!(saves.host_file(), Some("Poster.figcraft")); + assert!(saves.saved(&started.id).is_some(), "the real answer still counts"); + } + + #[test] + fn a_newer_save_replaces_the_one_waiting() { + let mut saves = opened("Poster.figcraft"); + let older = saves.start("Poster 2.figcraft", "r1", 0); + let newer = saves.start("Poster.figcraft", "r2", 10); + assert!(saves.saved(&older.id).is_none(), "a late answer for the older save is ignored"); + assert!(saves.failed(&older.id).is_none()); + assert_eq!(saves.host_file(), Some("Poster.figcraft"), "the older Save As never became the file"); + assert_eq!(saves.saved(&newer.id).map(|s| s.file), Some("r2")); + } + + #[test] + fn a_save_left_unanswered_times_out() { + let mut saves = Saves::new(1_000); + saves.opened("Poster.figcraft"); + let started = saves.start("Poster 2.figcraft", "r1", 100); + assert!(saves.expire(100).is_none()); + assert!(saves.expire(1_099).is_none(), "still inside the timeout"); + let remaining = saves.wait_ms(600).expect("a save waits"); + assert!(remaining > 0 && remaining < saves.timeout_ms(), "{remaining}"); + let save = saves.expire(1_100).expect("timed out"); + assert_eq!(save.file, "r1"); + assert_eq!(saves.host_file(), Some("Poster.figcraft"), "a timed-out Save As isn't the file"); + assert!(saves.saved(&started.id).is_none(), "an answer after the timeout is ignored"); + assert!(saves.expire(5_000).is_none() && saves.wait_ms(5_000).is_none()); + } + + #[test] + fn a_clock_that_goes_back_does_not_end_the_wait_early() { + let mut saves = Saves::new(1_000); + saves.start("Untitled.figcraft", "r1", 500); + assert!(saves.expire(0).is_none()); + assert!(saves.wait_ms(0).is_some_and(|w| w >= saves.timeout_ms())); + } + + #[test] + fn opening_a_file_forgets_the_save_still_waiting() { + let mut saves = opened("Poster.figcraft"); + let started = saves.start("Poster 2.figcraft", "r1", 0); + let dropped = saves.opened("Other.figcraft").expect("the save that waited"); + assert_eq!(dropped.file, "r1"); + assert!(saves.saved(&started.id).is_none(), "its late answer is ignored"); + assert_eq!(saves.host_file(), Some("Other.figcraft"), "and can't rename the file opened since"); + assert!(saves.expire(u64::MAX).is_none()); + } + + #[test] + fn without_confirmation_a_save_as_is_the_document_s_file_once_posted() { + let mut saves = Saves::default(); + assert!(saves.save_as("Untitled.figcraft"), "the host never sent a file"); + saves.adopt("Untitled.figcraft"); + assert!(!saves.save_as("Untitled.figcraft")); + assert!(!saves.save_as("Untitled.png"), "an export is never the document's file"); + } +} diff --git a/apps/figcraft-web/src/main.rs b/apps/figcraft-web/src/main.rs index 36d37ed39..59d2e008f 100644 --- a/apps/figcraft-web/src/main.rs +++ b/apps/figcraft-web/src/main.rs @@ -21,13 +21,14 @@ //! `http://` on a trusted network to reach plain `ws://` hosts on other machines. //! - host mode: `?host=parent` (a same-origin page embedding FigCraft in an `