diff --git a/apps/vectorcraft-cli/tests/it/thumbnail.rs b/apps/vectorcraft-cli/tests/it/thumbnail.rs index 4aa636dd06..b75d99b158 100644 --- a/apps/vectorcraft-cli/tests/it/thumbnail.rs +++ b/apps/vectorcraft-cli/tests/it/thumbnail.rs @@ -7,31 +7,23 @@ const THUMBNAILER: &str = include_str!("../../../../packaging/linux/ai.storytell const MIME: &str = include_str!("../../../../packaging/linux/ai.storyteller.vectorcraft.mime.xml"); const PACKAGE: &str = include_str!("../../../../packaging/linux/package.sh"); -/// Returns the path of `name` in `vectorcraft-cli-thumbnail-` in the temp folder. The first -/// call removes that folder and creates it again empty. -fn tmp(name: &str) -> PathBuf { - static DIR: std::sync::OnceLock = std::sync::OnceLock::new(); - DIR.get_or_init(|| { - let dir = std::env::temp_dir().join(format!("vectorcraft-cli-thumbnail-{}", std::process::id())); - let _ = std::fs::remove_dir_all(&dir); - std::fs::create_dir_all(&dir).unwrap(); - dir - }) - .join(name) +/// Returns a new empty folder in the temp folder, removed with everything in it when the guard drops. +fn tmp() -> tempfile::TempDir { + tempfile::tempdir().unwrap() } fn cli(args: &[&str]) -> Output { Command::new(crate::bin()).args(args).output().unwrap() } -/// Saves a `width`×`height` document with a rectangle on its artboard as `name` and returns its path. -fn document(name: &str, width: u32, height: u32) -> PathBuf { - save(name, width, height, &["--cmd", "shape.rectangle", "--params", r#"{"x":10,"y":10,"width":40,"height":20}"#]) +/// Saves a `width`×`height` document with a rectangle on its artboard as `name` in `dir` and returns its path. +fn document(dir: &Path, name: &str, width: u32, height: u32) -> PathBuf { + save(dir, name, width, height, &["--cmd", "shape.rectangle", "--params", r#"{"x":10,"y":10,"width":40,"height":20}"#]) } -/// Saves a new `width`×`height` document as `name` after the `run` arguments `steps`. -fn save(name: &str, width: u32, height: u32, steps: &[&str]) -> PathBuf { - let path = tmp(name); +/// Saves a new `width`×`height` document as `name` in `dir` after the `run` arguments `steps`. +fn save(dir: &Path, name: &str, width: u32, height: u32, steps: &[&str]) -> PathBuf { + let path = dir.join(name); let size = format!(r#"{{"width":{width},"height":{height}}}"#); let mut args = vec!["run", "--cmd", "file.new", "--params", &size]; args.extend_from_slice(steps); @@ -78,8 +70,9 @@ fn exec(size: u32, input: &Path, output: &Path) -> Vec { /// renderer that embeds a native file's preview. #[test] fn the_thumbnailer_entry_writes_the_first_artboard() { - let doc = document("wide.vectorcraft", 200, 100); - let out = tmp("wide.png"); + let dir = tmp(); + let doc = document(dir.path(), "wide.vectorcraft", 200, 100); + let out = dir.path().join("wide.png"); let command = exec(128, &doc, &out); assert_eq!(command[0], entry("TryExec")); assert_eq!(command[0], "vectorcraft-cli"); @@ -109,8 +102,9 @@ fn the_thumbnailer_entry_covers_the_native_types() { /// The size defaults to 256 pixels on the longer side, and a tall artboard is fitted by its height. #[test] fn thumbnail_fits_the_longer_side() { - let doc = document("tall.vectorcraft", 100, 400); - let out = tmp("tall.png"); + let dir = tmp(); + let doc = document(dir.path(), "tall.vectorcraft", 100, 400); + let out = dir.path().join("tall.png"); let run = cli(&["thumbnail", doc.to_str().unwrap(), out.to_str().unwrap()]); assert!(run.status.success(), "{}", String::from_utf8_lossy(&run.stderr)); assert_eq!(png_size(&std::fs::read(&out).unwrap()), (64, 256)); @@ -120,8 +114,9 @@ fn thumbnail_fits_the_longer_side() { /// PNG is written. #[test] fn thumbnail_refuses_bad_arguments() { - let doc = document("args.vectorcraft", 100, 100); - let out = tmp("args.png"); + let dir = tmp(); + let doc = document(dir.path(), "args.vectorcraft", 100, 100); + let out = dir.path().join("args.png"); let (d, o) = (doc.to_str().unwrap(), out.to_str().unwrap()); for (args, says) in [ (vec!["thumbnail", "--size", "0", d, o], "--size"), @@ -142,20 +137,21 @@ fn thumbnail_refuses_bad_arguments() { /// an empty document get an error and no PNG, so the file manager shows the file's icon. #[test] fn thumbnail_writes_nothing_for_files_it_cannot_read() { - let text = tmp("notes.vectorcraft"); + let dir = tmp(); + let text = dir.path().join("notes.vectorcraft"); std::fs::write(&text, b"not a document").unwrap(); - let saved = std::fs::read(document("whole.vectorcraft", 100, 100)).unwrap(); - let damaged = tmp("damaged.vectorcraft"); + let saved = std::fs::read(document(dir.path(), "whole.vectorcraft", 100, 100)).unwrap(); + let damaged = dir.path().join("damaged.vectorcraft"); std::fs::write(&damaged, &saved[..saved.len() / 2]).unwrap(); // Sparse where the file system allows it: its size is checked before anything is read. - let large = tmp("large.vectorcraft"); + let large = dir.path().join("large.vectorcraft"); std::fs::File::create(&large).unwrap().set_len((256 << 20) + 1).unwrap(); - let missing = tmp("missing.vectorcraft"); - let empty = save("empty.vectorcraft", 100, 100, &[]); + let missing = dir.path().join("missing.vectorcraft"); + let empty = save(dir.path(), "empty.vectorcraft", 100, 100, &[]); for (input, says) in [(&text, None), (&damaged, None), (&large, Some("larger than 256 MiB")), (&missing, None), (&empty, Some("the document shows nothing"))] { - let out = tmp("unreadable.png"); + let out = dir.path().join("unreadable.png"); let run = cli(&["thumbnail", input.to_str().unwrap(), out.to_str().unwrap()]); assert!(!run.status.success(), "{input:?}"); let err = String::from_utf8_lossy(&run.stderr); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 03be483277..31463dee2e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1006,7 +1006,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Locked artboards:** a click in the Artboards panel's lock column locks or unlocks an artboard in one undo step (`artboard.setProps {index, locked}`), and the native format saves the lock. The Artboard tool doesn't move, copy, resize or delete a locked artboard, Rearrange and Fit to Artwork Bounds leave it as it is, and its name isn't edited on the canvas. The art on it (each object whose bounds overlap it, a group as one object) acts as locked art until it is unlocked: clicks, marquees, `select.set`, `select.all` and the tools pass over it, and commands that act on the selection leave it; art drawn or pasted onto it stays selected and editable until the selection leaves it out. Tests in `crates/doc/src/lib.rs`, `tests/panelcmds.rs`, `xform/artboard.rs`, `panels/artboards.rs` and `canvas.rs` cover them. Public references: [Lock artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/organize-manage-artboards/lock-artboards.html) and [Managing Artboards in Illustrator](https://creativepro.com/managing-artboards-in-illustrator/). - **Linux RPM packaging:** 64-bit runtime capabilities replace Fedora-specific required package names (#1275); glibc 2.35, libm and libgcc_s are declared alongside dynamically loaded xkbcommon and Vulkan/EGL. Generated x86_64/aarch64 metadata and isolated synthetic-provider resolution checked; real-distro install/start-up QA remains pending. - **Linux file associations:** the desktop entry lists the MIME type of every format File › Open reads but PSD, PSB, `.ps` PostScript, Targa, PCX, Pixar, JPEG 2000, HEIC/HEIF, JPEG XL, HP-GL, `.cdr` and `.cmx`, `.ai`, `.ait` and EPS included, and the MIME package declares the types shared-mime-info lacks (VectorCraft documents and templates, `.ait`, Affinity), so file managers list VectorCraft under Open With for them, as Finder does on macOS. `the_linux_desktop_entry_opens_every_readable_format` in `apps/vectorcraft/src/tests.rs` checks both files against `OPEN_EXTS`. On Debian 13, Ubuntu 24.04 and Fedora 42, `desktop-file-validate` accepts the desktop entry, `update-mime-database` accepts the MIME package, and `gio` registers the app for every one of these types. -- **Linux file manager thumbnails:** the deb, rpm and tar.gz packages install `share/thumbnailers/ai.storyteller.vectorcraft.thumbnailer`, a [thumbnailer entry](https://gitlab.gnome.org/GNOME/gnome-desktop/-/raw/master/libgnome-desktop/gnome-desktop-thumbnail.c) for VectorCraft documents and templates, so file managers that read these entries show a thumbnail of the first artboard. The entry runs `vectorcraft-cli thumbnail --size N IN OUT`, which opens the document as the app does and writes an 8-bit RGBA PNG of the first artboard, N pixels (at most 1024) on its longer side, as the [thumbnail standard](https://specifications.freedesktop.org/thumbnail-spec/latest/creation.html) asks. A file larger than 256 MiB, one that can't be opened, a document that shows nothing, or a run longer than 20 seconds gets no PNG and a non-zero exit status, and the file manager keeps the file's icon. The Nightly deb and rpm leave the entry out, as they leave out the MIME package; a Flatpak install doesn't provide it. Tests in `apps/vectorcraft-cli/tests/it/thumbnail.rs` cover it. +- **Linux file manager thumbnails:** the deb, rpm and tar.gz packages install `share/thumbnailers/ai.storyteller.vectorcraft.thumbnailer`, a [thumbnailer entry](https://gitlab.gnome.org/GNOME/gnome-desktop/-/raw/master/libgnome-desktop/gnome-desktop-thumbnail.c) for VectorCraft documents and templates, so file managers that read these entries show a thumbnail of the first artboard. The entry runs `vectorcraft-cli thumbnail --size N IN OUT`, which opens the document as the app does and writes an 8-bit RGBA PNG of the first artboard, N pixels (at most 1024) on its longer side, as the [thumbnail standard](https://specifications.freedesktop.org/thumbnail-spec/latest/creation.html) asks. A file larger than 256 MiB, one that can't be opened, a document that shows nothing, or a run longer than 20 seconds gets no PNG and a non-zero exit status, and the file manager keeps the file's icon. The Nightly deb and rpm leave the entry out, as they leave out the MIME package; a Flatpak install doesn't provide it. Tests in `apps/vectorcraft-cli/tests/it/thumbnail.rs` cover all of it except the 20-second limit. - **Architecture:** 19+ crates with enforced layering (`cargo xtask layers`). Every action is a command (~400 engine + ~50 UI). Undo is unlimited via structural sharing. `command.batch` runs several commands as one transaction. - **Parameter schemas:** a command can carry a machine-readable parameter schema (the new `vectorcraft-apischema` crate): each parameter's type, range, unit, whether it is required, its default, whether null counts as left out, and the API levels it was added and deprecated at. `engine.commands` lists the schema in the shape of a JSON Schema 2020-12 object schema, a test keeps the command's `params` text equal to the text the schema writes, and a new call has the params checked against it before the command runs (batch steps before the first step), with an error naming the parameter and no change to the document (a value nested past the schema's 16 levels is such a parameter error, and only a schema that is wrong in itself is an internal error); saved steps keep a key the schema does not name, and their values are checked. The View commands `view.capsLock`, `view.saved.new`, `view.saved.edit`, `view.saved.list`, `view.transparencyGrid` and `view.snapToGlyph.options` have schemas. The schemas belong to API level 1 (`vectorcraft_engine::schemas::API_VERSION`), and a test fails when a schema changes without a new level. Tests: `crates/apischema/src/tests.rs` (with `conformance.rs`, a separate check of the JSON form against the JSON Schema 2020-12 rules), `schemas::tests` and `cmd::views::tests::each_view_command_refuses_a_bad_value_naming_the_parameter` in `vectorcraft-engine`.