mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-02 20:18:38 -05:00
Linux: file managers show thumbnails of VectorCraft documents
The deb, rpm and tar.gz packages install share/thumbnailers/ai.storyteller.vectorcraft.thumbnailer for application/x-vectorcraft and application/x-vectorcraft-template. It runs the new `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 (1 to 1024, default 256) on its longer side. A file larger than 256 MiB, one that can't be opened, a document that shows nothing, or a run longer than 20 seconds writes no PNG and exits non-zero, so the file manager keeps the file's icon. The Nightly deb and rpm leave the entry out, as they leave out the MIME package. The render moves into vectorcraft_render::encode::first_artboard, which the embedded native preview also uses.
This commit is contained in:
1 parent
4167e0abca
commit
b12c27e518
8 files changed
+256
-6
No files matched your search
@@ -7,6 +7,7 @@
|
||||
//! vectorcraft-cli commands
|
||||
//! vectorcraft-cli convert IN OUT [--scale 2] [--ppi 300] [--artboard 0 | --range 1-3,5] [--outline-text] [--decimals N] [--replace-lossy] [--editing-data] [--legacy-name-encoding ENC] [--preserve-editing] [--ai-version 7|pdf] [--hidden-objects layer|omit|visible] [--transparent-images flatten|omit]
|
||||
//! vectorcraft-cli info FILE
|
||||
//! vectorcraft-cli thumbnail [--size 256] IN OUT
|
||||
//! vectorcraft-cli bench FILE [--size 2880x1800] [--iters 5]
|
||||
//! vectorcraft-cli perf [--paths 50000] [--deep]
|
||||
//! ```
|
||||
@@ -145,6 +146,14 @@ USAGE:
|
||||
read from its preview and why), title, colour mode, units, artboards, object counts by
|
||||
kind, fonts.
|
||||
|
||||
vectorcraft-cli thumbnail [--size N] IN OUT
|
||||
Open IN (any readable format) and write OUT as a PNG of its first artboard (else the art),
|
||||
N pixels on its longer side (1 to 1024, default 256), with a transparent background. Linux
|
||||
file managers run it for .vectorcraft, .drawcraft and .vctemplate files through
|
||||
share/thumbnailers/ai.storyteller.vectorcraft.thumbnailer. It exits with an error and writes
|
||||
nothing when IN is larger than 256 MiB, can't be opened, shows nothing, or takes longer than
|
||||
20 seconds.
|
||||
|
||||
vectorcraft-cli bench FILE [--size WxH] [--iters N]
|
||||
Render FILE (any readable format) fitted to WxH (default 2880x1800) and print ms per frame
|
||||
(warm), multithreaded and single-threaded.
|
||||
@@ -217,6 +226,7 @@ fn main() -> ExitCode {
|
||||
Some("commands") => commands(),
|
||||
Some("convert") => convert(&args[1..]),
|
||||
Some("info") => info(&args[1..]),
|
||||
Some("thumbnail") => thumbnail(&args[1..]),
|
||||
Some("bench") => bench(&args[1..]),
|
||||
Some("perf") => perf::run(&args[1..]),
|
||||
Some("-h" | "--help" | "help") | None => help(),
|
||||
@@ -521,6 +531,61 @@ fn info(args: &[String]) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Largest file `thumbnail` opens, in bytes on disk.
|
||||
const THUMBNAIL_MAX_FILE: u64 = 256 << 20;
|
||||
/// Largest `--size` of `thumbnail`: the thumbnail standard's largest size, xx-large.
|
||||
const THUMBNAIL_MAX_SIZE: u32 = 1024;
|
||||
/// `--size` when it isn't given: the thumbnail standard's large size.
|
||||
const THUMBNAIL_DEFAULT_SIZE: u32 = 256;
|
||||
/// Longest `thumbnail` runs before it exits without writing OUT.
|
||||
const THUMBNAIL_TIME: std::time::Duration = std::time::Duration::from_secs(20);
|
||||
|
||||
/// `thumbnail`: the PNG a Linux file manager shows for a document, run through the
|
||||
/// `.thumbnailer` entry in `packaging/linux`
|
||||
/// (<https://specifications.freedesktop.org/thumbnail-spec/latest/creation.html>).
|
||||
fn thumbnail(args: &[String]) -> Result<(), String> {
|
||||
if help_requested(args, &["--size", "-s"]) {
|
||||
return help();
|
||||
}
|
||||
let mut files = vec![];
|
||||
let mut size = THUMBNAIL_DEFAULT_SIZE;
|
||||
let mut it = args.iter();
|
||||
while let Some(a) = it.next() {
|
||||
match a.as_str() {
|
||||
"--size" | "-s" => {
|
||||
size = it
|
||||
.next()
|
||||
.and_then(|v| v.parse().ok())
|
||||
.filter(|n| (1..=THUMBNAIL_MAX_SIZE).contains(n))
|
||||
.ok_or_else(|| format!("--size needs a number of pixels from 1 to {THUMBNAIL_MAX_SIZE}"))?;
|
||||
}
|
||||
other if other.starts_with('-') => return Err(format!("unknown thumbnail option `{other}`")),
|
||||
f => files.push(f),
|
||||
}
|
||||
}
|
||||
let [input, output] = <[&str; 2]>::try_from(files).map_err(|_| "thumbnail needs IN and OUT")?;
|
||||
// The process ends when the time is up, wherever the work is: OUT is written whole or not at all.
|
||||
std::thread::spawn(|| {
|
||||
std::thread::sleep(THUMBNAIL_TIME);
|
||||
eprintln!("vectorcraft-cli: thumbnail: took longer than {} seconds", THUMBNAIL_TIME.as_secs());
|
||||
std::process::exit(1);
|
||||
});
|
||||
let len = std::fs::metadata(input).map_err(|e| format!("{input}: {e}"))?.len();
|
||||
if len > THUMBNAIL_MAX_FILE {
|
||||
return Err(format!("{input}: larger than {} MiB", THUMBNAIL_MAX_FILE >> 20));
|
||||
}
|
||||
// Opened as the app opens it: the fonts it carries, its type measured, its linked files read.
|
||||
let mut h = Headless::new();
|
||||
h.call("app.open", json!({"path": input})).map_err(|e| format!("{input}: {e}"))?;
|
||||
let doc = &h.session.doc().map_err(|e| e.to_string())?.doc;
|
||||
// A picture without a visible pixel is an error, and the file manager keeps the file's icon.
|
||||
let img = vectorcraft_render::encode::first_artboard(doc, size)
|
||||
.filter(|img| img.pixels.as_chunks::<4>().0.iter().any(|px| px[3] != 0))
|
||||
.ok_or_else(|| format!("{input}: the document shows nothing"))?;
|
||||
let png = img.to_png().map_err(|e| format!("{input}: {e}"))?;
|
||||
vectorcraft_format::write_atomic(Path::new(output), &png).map_err(|e| format!("{output}: {e}"))
|
||||
}
|
||||
|
||||
enum Step {
|
||||
Cmd(String, Value),
|
||||
Export(String),
|
||||
|
||||
@@ -6,6 +6,7 @@ mod cli;
|
||||
mod fileio;
|
||||
mod mcp_e2e;
|
||||
mod script;
|
||||
mod thumbnail;
|
||||
|
||||
/// Nextest relocates archived binaries; Cargo's compile-time path still names the build runner.
|
||||
fn bin() -> std::path::PathBuf {
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
//! `thumbnail` and the Linux `.thumbnailer` entry that runs it for file managers.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Output};
|
||||
|
||||
const THUMBNAILER: &str = include_str!("../../../../packaging/linux/ai.storyteller.vectorcraft.thumbnailer");
|
||||
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-<pid>` 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<PathBuf> = 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)
|
||||
}
|
||||
|
||||
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 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);
|
||||
let size = format!(r#"{{"width":{width},"height":{height}}}"#);
|
||||
let mut args = vec!["run", "--cmd", "file.new", "--params", &size];
|
||||
args.extend_from_slice(steps);
|
||||
args.extend(["--export", path.to_str().unwrap()]);
|
||||
let out = cli(&args);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
path
|
||||
}
|
||||
|
||||
/// The width and height in a PNG's IHDR chunk, after checking that it is the 8-bit, non-interlaced
|
||||
/// RGBA a thumbnail must be (<https://specifications.freedesktop.org/thumbnail-spec/latest/creation.html>).
|
||||
fn png_size(png: &[u8]) -> (u32, u32) {
|
||||
assert!(png.starts_with(b"\x89PNG\r\n\x1a\n") && &png[12..16] == b"IHDR", "not a PNG");
|
||||
assert_eq!((png[24], png[25], png[28]), (8, 6, 0), "bit depth, color type (RGBA) and interlacing");
|
||||
let be = |b: &[u8]| u32::from_be_bytes([b[0], b[1], b[2], b[3]]);
|
||||
(be(&png[16..20]), be(&png[20..24]))
|
||||
}
|
||||
|
||||
/// The value of `key` in the entry's `[Thumbnailer Entry]` group.
|
||||
fn entry(key: &str) -> &'static str {
|
||||
assert_eq!(THUMBNAILER.lines().next(), Some("[Thumbnailer Entry]"));
|
||||
THUMBNAILER.lines().find_map(|l| l.strip_prefix(key)?.strip_prefix('=')).unwrap_or_else(|| panic!("no {key} key"))
|
||||
}
|
||||
|
||||
/// The file manager's command for the entry: `Exec` split at spaces, `%s` the size, `%i` the
|
||||
/// input path and `%o` the output path (the codes the thumbnail factories expand).
|
||||
fn exec(size: u32, input: &Path, output: &Path) -> Vec<String> {
|
||||
entry("Exec")
|
||||
.split(' ')
|
||||
.map(|arg| match arg {
|
||||
"%s" => size.to_string(),
|
||||
"%i" => input.to_string_lossy().into_owned(),
|
||||
"%o" => output.to_string_lossy().into_owned(),
|
||||
other => {
|
||||
assert!(!other.contains('%'), "a field code the CLI doesn't take: {other}");
|
||||
other.to_string()
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The entry runs the CLI with the size, the document and the PNG to write, as a file manager
|
||||
/// does: with no environment, and the PNG is the first artboard at that size, drawn by the
|
||||
/// 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 command = exec(128, &doc, &out);
|
||||
assert_eq!(command[0], entry("TryExec"));
|
||||
assert_eq!(command[0], "vectorcraft-cli");
|
||||
let run = Command::new(crate::bin()).args(&command[1..]).env_clear().output().unwrap();
|
||||
assert!(run.status.success(), "{}", String::from_utf8_lossy(&run.stderr));
|
||||
let png = std::fs::read(&out).unwrap();
|
||||
assert_eq!(png_size(&png), (128, 64));
|
||||
let saved = vectorcraft_format::load(&std::fs::read(&doc).unwrap()).unwrap();
|
||||
assert_eq!(Some(png), vectorcraft_render::encode::first_artboard_png(&saved, 128).unwrap(), "the renderer's picture");
|
||||
}
|
||||
|
||||
/// Each type the entry lists is a native document type the app's MIME package declares, and the
|
||||
/// packages install the entry where the thumbnail factories look.
|
||||
#[test]
|
||||
fn the_thumbnailer_entry_covers_the_native_types() {
|
||||
let types: Vec<&str> = entry("MimeType").split(';').filter(|t| !t.is_empty()).collect();
|
||||
assert_eq!(types, ["application/x-vectorcraft", "application/x-vectorcraft-template"]);
|
||||
for t in types {
|
||||
assert!(MIME.contains(&format!("<mime-type type=\"{t}\">")), "the MIME package doesn't declare {t}");
|
||||
}
|
||||
assert!(
|
||||
PACKAGE.contains(r#"install -Dm644 "$HERE/$APP_ID.thumbnailer" "$STAGE/usr/share/thumbnailers/$APP_ID.thumbnailer""#),
|
||||
"package.sh doesn't install the entry"
|
||||
);
|
||||
}
|
||||
|
||||
/// 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 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));
|
||||
}
|
||||
|
||||
/// A size outside 1 to 1024 pixels, a missing file name and an unknown option are errors, and no
|
||||
/// PNG is written.
|
||||
#[test]
|
||||
fn thumbnail_refuses_bad_arguments() {
|
||||
let doc = document("args.vectorcraft", 100, 100);
|
||||
let out = tmp("args.png");
|
||||
let (d, o) = (doc.to_str().unwrap(), out.to_str().unwrap());
|
||||
for (args, says) in [
|
||||
(vec!["thumbnail", "--size", "0", d, o], "--size"),
|
||||
(vec!["thumbnail", "--size", "1025", d, o], "--size"),
|
||||
(vec!["thumbnail", "--size", "big", d, o], "--size"),
|
||||
(vec!["thumbnail", "--size"], "--size"),
|
||||
(vec!["thumbnail", d], "IN and OUT"),
|
||||
(vec!["thumbnail", "--quality", "9", d, o], "--quality"),
|
||||
] {
|
||||
let run = cli(&args);
|
||||
assert!(!run.status.success(), "{args:?}");
|
||||
assert!(String::from_utf8_lossy(&run.stderr).contains(says), "{args:?}: {}", String::from_utf8_lossy(&run.stderr));
|
||||
assert!(!out.exists(), "{args:?} wrote a PNG");
|
||||
}
|
||||
}
|
||||
|
||||
/// A file that isn't a document, a damaged one, one larger than the CLI opens, a missing one and
|
||||
/// 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");
|
||||
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");
|
||||
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");
|
||||
std::fs::File::create(&large).unwrap().set_len((256 << 20) + 1).unwrap();
|
||||
let missing = tmp("missing.vectorcraft");
|
||||
let empty = save("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 run = cli(&["thumbnail", input.to_str().unwrap(), out.to_str().unwrap()]);
|
||||
assert!(!run.status.success(), "{input:?}");
|
||||
let err = String::from_utf8_lossy(&run.stderr);
|
||||
assert!(err.contains(input.to_str().unwrap()), "{input:?}: {err}");
|
||||
assert!(says.is_none_or(|s| err.contains(s)), "{input:?}: {err}");
|
||||
assert!(!out.exists(), "{input:?} wrote a PNG");
|
||||
}
|
||||
}
|
||||
@@ -318,12 +318,7 @@ pub(super) fn ai_native(cmd: &str, doc: &Document, so: &SaveOptions) -> Result<V
|
||||
/// The first artboard (else the art) as a PNG fitted into [`PREVIEW_MAX`] pixels (`None`: nothing
|
||||
/// to show).
|
||||
pub(crate) fn preview_png(doc: &Document) -> Result<Option<Vec<u8>>> {
|
||||
let Some(r) = doc.artboards.first().map(|a| a.rect).or_else(|| vectorcraft_render::encode::art_bounds(doc)) else { return Ok(None) };
|
||||
let scale = f64::from(PREVIEW_MAX) / r.width().max(r.height());
|
||||
if vectorcraft_render::raster_size(r, scale).is_err() {
|
||||
return Ok(None);
|
||||
}
|
||||
vectorcraft_render::Renderer::new().render_region(doc, r, scale, false).to_png().map(Some).map_err(EngineError::Other)
|
||||
vectorcraft_render::encode::first_artboard_png(doc, PREVIEW_MAX).map_err(EngineError::Other)
|
||||
}
|
||||
|
||||
/// `p` with `compress` from the Use Compression preference when it doesn't say (saves only;
|
||||
|
||||
@@ -243,6 +243,22 @@ pub fn art_bounds(doc: &Document) -> Option<Rect> {
|
||||
doc.layers.iter().fold(None, |acc, l| vectorcraft_geom::union_opt(acc, drawn_bounds(&symbols, l)))
|
||||
}
|
||||
|
||||
/// The first artboard (else the art, [`art_bounds`]) rendered with a transparent background, its
|
||||
/// longer side `max_side` pixels: the picture of a native file's embedded preview, and of the
|
||||
/// thumbnail `vectorcraft-cli thumbnail` writes for file managers. `None` when the document has
|
||||
/// no artboard and no art, or the region can't be rendered at that size ([`crate::raster_size`]).
|
||||
pub fn first_artboard(doc: &Document, max_side: u32) -> Option<Rendered> {
|
||||
let r = doc.artboards.first().map(|a| a.rect).or_else(|| art_bounds(doc))?;
|
||||
let scale = f64::from(max_side) / r.width().max(r.height());
|
||||
crate::raster_size(r, scale).ok()?;
|
||||
Some(Renderer::new().render_region(doc, r, scale, false))
|
||||
}
|
||||
|
||||
/// [`first_artboard`] as a PNG.
|
||||
pub fn first_artboard_png(doc: &Document, max_side: u32) -> Result<Option<Vec<u8>>, String> {
|
||||
first_artboard(doc, max_side).map(|img| img.to_png()).transpose()
|
||||
}
|
||||
|
||||
/// Bounds of the art an export draws ([`art_bounds`]) that is on artboard rectangle `rect`: each
|
||||
/// object of a layer or sublayer whose drawn bounds overlap `rect`, with all of its bounds; a group
|
||||
/// or a clipping layer counts as one object. `None` when no object overlaps `rect`.
|
||||
|
||||
@@ -1006,6 +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.
|
||||
|
||||
- **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`.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
[Thumbnailer Entry]
|
||||
TryExec=vectorcraft-cli
|
||||
Exec=vectorcraft-cli thumbnail --size %s %i %o
|
||||
MimeType=application/x-vectorcraft;application/x-vectorcraft-template;
|
||||
@@ -96,6 +96,7 @@ if [[ "$IS_NIGHTLY" = 1 ]]; then
|
||||
mv "$STAGE/usr/share/applications/$APP_ID.desktop.tmp" "$STAGE/usr/share/applications/$APP_ID.desktop"
|
||||
fi
|
||||
install -Dm644 "$HERE/$APP_ID.mime.xml" "$STAGE/usr/share/mime/packages/$APP_ID.xml"
|
||||
install -Dm644 "$HERE/$APP_ID.thumbnailer" "$STAGE/usr/share/thumbnailers/$APP_ID.thumbnailer"
|
||||
mkdir -p "$STAGE/usr/share/metainfo"
|
||||
sed -e "s/@VERSION@/$VERSION/g" -e "s/@DATE@/$VECTORCRAFT_BUILD_DATE/g" \
|
||||
"$HERE/$APP_ID.metainfo.xml.in" >"$STAGE/usr/share/metainfo/$APP_ID.metainfo.xml"
|
||||
@@ -183,6 +184,7 @@ CLI_WRAPPER
|
||||
"$NFPM_STAGE/usr/share/metainfo/$APP_ID.metainfo.xml" >"$NFPM_STAGE/usr/share/metainfo/$NIGHTLY_DESK_ID.metainfo.xml"
|
||||
rm -f "$NFPM_STAGE/usr/share/metainfo/$APP_ID.metainfo.xml"
|
||||
rm -rf "$NFPM_STAGE/usr/share/mime"
|
||||
rm -rf "$NFPM_STAGE/usr/share/thumbnailers"
|
||||
rm -rf "$NFPM_STAGE/usr/share/icons/hicolor"
|
||||
NIGHTLY_ICON="$ROOT/assets/app-icon/vectorcraft-nightly.png"
|
||||
[[ -f "$NIGHTLY_ICON" ]] || NIGHTLY_ICON="$ROOT/assets/app-icon/hicolor/256x256/apps/$APP_ID.png"
|
||||
|
||||
Reference in new issue
Block a user